亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? tunnel.c

?? Snmp(簡單網(wǎng)管協(xié)議)軟件包。
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* * tunnel.c -- *  * 	An implementation of the TUNNEL-MIB for the UCD-SNMP 4.2 *	agent running on Linux 2.2.x. * 	 * Copyright (c) 2000 Frank Strauss <strauss@ibr.cs.tu-bs.de> * *                          All Rights Reserved *  * Permission to use, copy, modify and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appears in all copies and * that both that copyright notice and this permission notice appear in * supporting documentation, and that the name of the author and CMU and * The Regents of the University of California not be used in advertising * or publicity pertaining to distribution of the software without * specific written permission. *  * THE AUTHOR AND CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA * DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL * THE AUTHOR OR CMU OR THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY * DAMAGES WHATSOEVER RESULTING FROM THE LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * *//* * NOTE: This TUNNEL-MIB implementation * *       (a) DOES NOT implement write access on the tunnelConfigTable, *	     i.e. no new tunnels can be created and no existing tunnels *	     can be removed through SET operations. * *	 (b) DOES implement write access on some tunnelIfTable objects *	     to allow reconfiguring established tunnels. This violates *           RFC 2667! However, the author thinks it makes sense. ;-) */#include <string.h>#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <sys/types.h>#include <sys/socket.h>#include <sys/time.h>#include <sys/ioctl.h>#include <signal.h>#include <netinet/in.h>#include <arpa/inet.h>#include <linux/if.h>#include <linux/ip.h>#include <linux/sockios.h>#include <linux/if_tunnel.h>#include <linux/if_arp.h>#include "config.h"#include "snmp_alarm.h"#include "callback.h"#include "default_store.h"#include "asn1.h"#include "snmp.h"#include "snmp_debug.h"#include "snmp_api.h"#include "snmp_impl.h"#include "snmp_vars.h"#include "var_struct.h"#include "agent_read_config.h"#include "tools.h"#include "util_funcs.h"#include "tunnel.h"#ifndef MIN#define MIN(a, b) (((a) < (b)) ? (a) : (b))#endif#ifndef MAX#define MAX(a, b) (((a) > (b)) ? (a) : (b))#endif/* This is used, because the TUNNEL-MIB augments ifTable. */extern unsigned char *var_ifEntry(struct variable *,				  oid *, size_t *,				  int, size_t *,				  WriteMethod **);/*  * tunnel_variables_oid: *   this is the top level oid that we want to register under.  This *   is essentially a prefix, with the suffix appearing in the *   variable below. */oid tunnel_variables_oid[] = {1, 3, 6, 1, 2, 1, 10, 131, 1, 1};const int tunnel_len = 10;oid tunnel_ifEntry_oid[] = {1, 3, 6, 1, 2, 1, 10, 131, 1, 1, 1, 1};const int tunnel_ifEntry_len = 12;oid tunnel_configEntry_oid[] = {1, 3, 6, 1, 2, 1, 10, 131, 1, 1, 2, 1};const int tunnel_configEntry_len = 12;struct tunnel {    oid	           ifindex;    int		   id;    char	   *ifname;    int		   active;    unsigned long  local;    unsigned long  remote;    int		   encaps;    int		   hoplimit;    int		   security;    int		   tos;    oid		   config_name[MAX_OID_LEN];    size_t	   config_length;    struct tunnel  *next;};/*  * variable4 tunnel_variables: *   this variable defines function callbacks and type return information  *   for the tunnel mib section  */struct variable4 tunnel_variables[] = {/*  magic number        , variable type , ro/rw , callback fn  , L, oidsuffix */#define   LOCALADDRESS          1  { LOCALADDRESS        , ASN_IPADDRESS , RWRITE, var_tunnelIfEntry, 3, { 1, 1, 1 } },#define   REMOTEADDRESS         2  { REMOTEADDRESS       , ASN_IPADDRESS , RWRITE, var_tunnelIfEntry, 3, { 1, 1, 2 } },#define   ENCAPSMETHOD          3  { ENCAPSMETHOD        , ASN_INTEGER   , RONLY , var_tunnelIfEntry, 3, { 1, 1, 3 } },#define   HOPLIMIT              4  { HOPLIMIT            , ASN_INTEGER   , RWRITE, var_tunnelIfEntry, 3, { 1, 1, 4 } },#define   SECURITY              5  { SECURITY            , ASN_INTEGER   , RONLY , var_tunnelIfEntry, 3, { 1, 1, 5 } },#define   TOS                   6  { TOS                 , ASN_INTEGER   , RWRITE, var_tunnelIfEntry, 3, { 1, 1, 6 } },#define   IFINDEX               7  { IFINDEX             , ASN_INTEGER   , RONLY , var_tunnelConfigEntry, 3, { 2, 1, 5 } },#define   ROWSTATUS             8  { ROWSTATUS           , ASN_INTEGER   , RWRITE, var_tunnelConfigEntry, 3, { 2, 1, 6 } },};extern int register_sysORTable(oid *, size_t, const char *);extern int unregister_sysORTable(oid *, size_t);static oid sysORTable_reg[] = {1, 3, 6, 1, 2, 1, 10, 131};static size_t sysORTable_reglen = 8;static struct tunnel *tunnels;void deinit_tunnel(void){    unregister_sysORTable(sysORTable_reg, sysORTable_reglen);}int term_tunnel(int majorID, int minorID, void *serverarg, void *clientarg){    deinit_tunnel();    return 0;}void init_tunnel(void){    register_sysORTable(sysORTable_reg, sysORTable_reglen,			"RFC 2667 TUNNEL-MIB implementation for "			"Linux 2.2.x kernels.");    ds_set_string(DS_LIBRARY_ID, DS_LIB_APPTYPE, "snmpd");    /* register ourselves with the agent to handle our mib tree */    REGISTER_MIB("tunnel", tunnel_variables, variable4,		 tunnel_variables_oid);    snmp_register_callback(SNMP_CALLBACK_LIBRARY,			   SNMP_CALLBACK_SHUTDOWN,			   term_tunnel, NULL);    tunnels = NULL;}static int getType(int index){    oid name[MAX_OID_LEN] = {1, 3, 6, 1, 2, 1, 2, 2, 1, 3};    size_t length = 10;    struct variable ifType_variable =	{ 3, ASN_INTEGER, RONLY, var_ifEntry, 10,	  { 1, 3, 6, 1, 2, 1, 2, 2, 1, 3 } };    unsigned char *p;    size_t var_len;    WriteMethod *write_method;        name[length] = index;    length++;    p = var_ifEntry(&ifType_variable,		    name, &length,		    1 /* exact */, &var_len, &write_method);    if (!p)	return 0;    return *(int *)p;}static char *getName(int index){    oid name[MAX_OID_LEN] = {1, 3, 6, 1, 2, 1, 2, 2, 1, 2};    size_t length = 10;    struct variable ifName_variable =	{ 2, ASN_INTEGER, RONLY, var_ifEntry, 10,	  { 1, 3, 6, 1, 2, 1, 2, 2, 1, 2 } };    unsigned char *p;    size_t var_len;    WriteMethod *write_method;        name[length] = index;    length++;    p = var_ifEntry(&ifName_variable,		    name, &length,		    1 /* exact */, &var_len, &write_method);    if (!p)	return NULL;    return p;}static struct ip_tunnel_parm *getTunnelParm(char *ifname){    struct ifreq ifrq;    int fd;    static struct ip_tunnel_parm parm;        if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {	return NULL;    }    memset(&parm, 0, sizeof(struct ip_tunnel_parm));    strcpy (ifrq.ifr_name, ifname);    ifrq.ifr_ifru.ifru_data = (void*)&parm;    if (ioctl(fd, SIOCGETTUNNEL, &ifrq) < 0) {	/*	 * try again with the last char of the device name cut off.	 * it might have been a zero digit appended by the agent.	 */	ifrq.ifr_name[strlen(ifrq.ifr_name)-1] = 0;	if (ioctl(fd, SIOCGETTUNNEL, &ifrq) < 0) {	    close(fd);	    return NULL;	}	ifname[strlen(ifname)-1] = 0;    }        close(fd);    return &parm;}int setTunnelParm(char *ifname, struct ip_tunnel_parm *parm){    struct ifreq ifrq;    int fd;    int err;        if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {	return -1;    }    strcpy (ifrq.ifr_name, ifname);    ifrq.ifr_ifru.ifru_data = (void*)parm;    err = ioctl(fd, SIOCCHGTUNNEL, &ifrq);    close(fd);    return err;}/* * update a struct tunnel. its index and ifname elements have to be set. */static struct tunnel *updateTunnel(struct tunnel *tunnel){    struct ip_tunnel_parm *parm;    int fd;    struct ifreq ifrq;    /* NOTE: getTunnelParm() may adjust the passed ifname. */    parm = getTunnelParm(tunnel->ifname);    if (!parm) {	tunnel->active = 0;	return NULL;    }    tunnel->active = 1;        tunnel->local = parm->iph.saddr;    tunnel->remote = parm->iph.daddr;    if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {	DEBUGMSGTL(("snmpd",		    "socket open failure in updateTunnels()\n"));	return NULL;    } else {	strcpy (ifrq.ifr_name, tunnel->ifname);	if (ioctl(fd, SIOCGIFHWADDR, &ifrq) == 0)	    switch (ifrq.ifr_hwaddr.sa_family) {	    case ARPHRD_TUNNEL:		tunnel->encaps = 2; break;; /* direct */	    case ARPHRD_TUNNEL6:		tunnel->encaps = 2; break;; /* direct */	    case ARPHRD_IPGRE:		tunnel->encaps = 3; break;; /* gre */	    case ARPHRD_SIT:		tunnel->encaps = 2; break;; /* direct */	    default:		tunnel->encaps = 1; /* other */	    }	close(fd);    }    tunnel->hoplimit = parm->iph.ttl;    tunnel->security = 1;    tunnel->tos = (parm->iph.tos & 1) ? -1 : parm->iph.tos;    /* XXX: adjust tos mapping (kernel <-> TUNNEL-MIB::tunnelIfTOS) */    return tunnel;}static void updateTunnels(void){    static int max_index = 1;    static struct tunnel *last_tunnel = NULL;    struct tunnel *tunnel;    char *ifname;    int type;        /* uptime the tunnels we have so far */    for (tunnel = tunnels; tunnel; tunnel = tunnel->next) {	DEBUGMSG(("tunnel",		  "updateTunnels(): updating %s (index=%d)\n",		  tunnel->ifname, tunnel->ifindex));	updateTunnel(tunnel);    }    /* look for new tunnels */    for (; max_index < 256; max_index++) {	DEBUGMSG(("tunnel",		  "updateTunnels(): looking for new index=%d\n", max_index));	type = getType(max_index);	if (type == 131) {	    tunnel = (struct tunnel *)malloc(sizeof(struct tunnel));	    if (!tunnel) break;	    tunnel->ifindex = max_index;	    tunnel->id = 1;	    	    ifname = getName(max_index);	    if (!ifname) break;	    tunnel->ifname = strdup(ifname);	    if (!tunnel->ifname) break;	    if (!updateTunnel(tunnel)) break;	    if (last_tunnel) last_tunnel->next = tunnel;	    if (!tunnels) tunnels = last_tunnel = tunnel;	    tunnel->next = NULL;	    last_tunnel = tunnel;	    DEBUGMSG(("tunnel",		      "updateTunnels(): added %s (index=%d state=%d)\n",		      tunnel->ifname, tunnel->ifindex, tunnel->active));	    	}	if (type == 0) break;    }}static struct tunnel *getTunnelByIfIndex(int index){    struct tunnel *tunnel;        DEBUGMSG(("tunnel", "getTunnelByIfIndex(%d): ", index));        for (tunnel = tunnels; tunnel; tunnel = tunnel->next) {	if (tunnel->ifindex == index) {	    if (!tunnel->active) break;	    DEBUGMSG(("tunnel",		      "%s (index=%d)\n", tunnel->ifname, tunnel->ifindex));	    return tunnel;	}    }    DEBUGMSG(("tunnel", "NONE\n"));    return NULL;}static struct tunnel *getNextTunnelByIfIndex(int index){    struct tunnel *tunnel;        DEBUGMSG(("tunnel", "getNextTunnelByIfIndex(%d): ", index));    for (tunnel = tunnels; tunnel; tunnel = tunnel->next) {	if (tunnel->ifindex > index) {	    if (!tunnel->active) continue;	    DEBUGMSG(("tunnel",		      "%s (index=%d)\n", tunnel->ifname, tunnel->ifindex));	    return tunnel;	}    }    DEBUGMSG(("tunnel", "NONE\n"));

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
六月丁香婷婷色狠狠久久| 色8久久人人97超碰香蕉987| 麻豆国产一区二区| 婷婷夜色潮精品综合在线| 亚洲一区二区综合| 亚洲成人av免费| 亚洲成人一区二区| 丝袜亚洲另类欧美综合| 肉色丝袜一区二区| 男女视频一区二区| 蜜桃久久av一区| 精品一区二区三区蜜桃| 国产乱子轮精品视频| 国产老妇另类xxxxx| 国产精品88888| 99re这里都是精品| 欧美三区在线视频| 日韩一区二区三免费高清| 精品免费视频一区二区| 国产日韩欧美在线一区| 国产精品卡一卡二卡三| 亚洲精品国产一区二区三区四区在线| 亚洲精品国产品国语在线app| 亚洲不卡在线观看| 麻豆91在线看| 538在线一区二区精品国产| 这里只有精品99re| 久久综合九色欧美综合狠狠 | 综合婷婷亚洲小说| 亚洲一区二区三区视频在线| 免费三级欧美电影| 国产91富婆露脸刺激对白| 91蝌蚪porny成人天涯| 777亚洲妇女| 国产亚洲一二三区| 亚洲老妇xxxxxx| 美女国产一区二区三区| 懂色av噜噜一区二区三区av | 亚洲欧洲av另类| 五月婷婷另类国产| 国产福利一区二区| 欧美午夜电影网| 久久久综合精品| 亚洲一二三区视频在线观看| 久久精品av麻豆的观看方式| 成人一区在线观看| 在线成人av影院| 国产精品麻豆视频| 美女视频一区在线观看| 丁香桃色午夜亚洲一区二区三区 | 亚洲精品中文字幕在线观看| 日韩经典中文字幕一区| 不卡的av网站| 精品成人在线观看| 亚洲欧美日韩国产手机在线| 精品在线播放午夜| 欧美三级中文字幕在线观看| 国产日韩精品一区| 男人操女人的视频在线观看欧美| 91美女福利视频| 久久伊人中文字幕| 日韩精品一区第一页| 成人不卡免费av| 欧美大胆一级视频| 亚洲愉拍自拍另类高清精品| 国产激情一区二区三区桃花岛亚洲| 欧美浪妇xxxx高跟鞋交| 亚洲色图欧美激情| 国产精品综合av一区二区国产馆| 欧美日韩1234| 亚洲欧洲综合另类| 丁香一区二区三区| 久久综合九色欧美综合狠狠| 国产成人精品网址| 欧美mv和日韩mv的网站| 亚洲成人手机在线| 91麻豆视频网站| 国产精品福利电影一区二区三区四区| 日产欧产美韩系列久久99| 在线一区二区视频| 中文字幕一区日韩精品欧美| 国产精品综合av一区二区国产馆| 日韩欧美123| 日韩国产成人精品| 欧美日韩久久久一区| 亚洲一区二区三区美女| 色综合一区二区| 中文字幕亚洲区| 成人av免费在线观看| 国产网站一区二区三区| 久久99九九99精品| 日韩欧美在线观看一区二区三区| 亚洲成人精品一区二区| 91猫先生在线| 一级做a爱片久久| 在线观看日韩国产| 亚洲一区二区在线免费看| 在线看日韩精品电影| 亚洲精品国产a久久久久久| 99精品久久久久久| 中文字幕一区在线观看| zzijzzij亚洲日本少妇熟睡| 国产精品国产成人国产三级| av不卡免费在线观看| 最新国产の精品合集bt伙计| 成人精品国产一区二区4080| 国产精品久久久久影院老司| 97久久人人超碰| 一区二区高清免费观看影视大全| 欧美性猛交xxxx乱大交退制版| 亚洲综合激情小说| 欧美日韩视频在线一区二区| 天堂一区二区在线免费观看| 欧美电影一区二区三区| 美女被吸乳得到大胸91| 26uuu国产日韩综合| 懂色av中文一区二区三区| 国产精品久久久久久亚洲伦 | 欧美日本一区二区| 日本不卡一区二区三区高清视频| 日韩小视频在线观看专区| 国内精品不卡在线| 国产精品久久午夜夜伦鲁鲁| 在线一区二区三区四区五区| 亚洲午夜在线电影| 国产精品热久久久久夜色精品三区| 国产成人精品免费在线| 中文字幕亚洲在| 欧美日韩成人综合在线一区二区| 日本vs亚洲vs韩国一区三区二区| 亚洲精品一区二区精华| 成人av免费在线| 亚洲国产另类精品专区| 日韩免费性生活视频播放| 国产精品1区2区3区在线观看| 亚洲特级片在线| 8x福利精品第一导航| 国产成人午夜精品5599| 亚洲女厕所小便bbb| 91精品国产黑色紧身裤美女| 国产乱子伦视频一区二区三区| 亚洲日本免费电影| 日韩一区二区三区高清免费看看| 国产成人精品影院| 婷婷国产v国产偷v亚洲高清| 久久久久久久久久电影| 欧美午夜精品久久久| 韩国成人精品a∨在线观看| 亚洲人123区| 精品福利在线导航| 日本韩国欧美国产| 青草av.久久免费一区| 国产精品久久久久久户外露出| 欧美久久久一区| 99久久精品免费看国产免费软件| 免费成人av在线播放| 国产精品白丝在线| 日韩精品中文字幕一区二区三区| hitomi一区二区三区精品| 美腿丝袜亚洲综合| 亚洲精品国产一区二区三区四区在线 | 丁香激情综合五月| 午夜日韩在线观看| 自拍偷拍欧美精品| 久久只精品国产| 欧美卡1卡2卡| 色先锋资源久久综合| 国产麻豆91精品| 日本不卡高清视频| 亚洲制服欧美中文字幕中文字幕| 欧美国产日韩在线观看| 日韩视频免费直播| 91福利精品视频| 91亚洲永久精品| 国产精品18久久久久| 美女一区二区在线观看| 亚洲国产日韩a在线播放性色| 亚洲国产精品激情在线观看| 精品女同一区二区| 欧美一区二区三区免费大片| 色狠狠色狠狠综合| av在线播放一区二区三区| 国产综合久久久久久久久久久久| 图片区小说区国产精品视频| 亚洲欧洲综合另类| 中文字幕亚洲在| 国产精品免费人成网站| 国产天堂亚洲国产碰碰| 亚洲精品一区二区三区影院 | 国产精品一区二区三区99| 日韩和欧美一区二区| 亚洲国产cao| 亚洲曰韩产成在线| 一级日本不卡的影视| 日韩美女视频一区二区| 最新国产成人在线观看| 国产精品成人一区二区艾草| 中文无字幕一区二区三区| 久久蜜桃av一区二区天堂| 久久免费国产精品|