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

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

?? tunnel.c

?? 包含一下內(nèi)容: * An extensible agent * An SNMP library * tools to request or set information from SNMP a
?? 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一区二区三区免费野_久草精品视频
欧美一二三四在线| 国产在线播放一区| 亚洲免费视频成人| 亚洲少妇中出一区| 亚洲图片你懂的| 亚洲免费观看高清在线观看| 亚洲日韩欧美一区二区在线| 成人免费小视频| 亚洲色图.com| 亚洲黄色尤物视频| 亚洲电影中文字幕在线观看| 亚洲电影在线免费观看| 日韩精品成人一区二区三区| 日韩电影一区二区三区| 免费国产亚洲视频| 国产一区二区三区久久久| 国产成人无遮挡在线视频| 成人手机电影网| 91在线视频免费91| 欧美最新大片在线看| 91精品国产乱| 2022国产精品视频| 国产精品久久久久精k8| 亚洲精品国产视频| 日韩中文字幕区一区有砖一区 | 欧美日韩国产一级| 欧美男男青年gay1069videost| 欧美丰满少妇xxxxx高潮对白| 日韩丝袜美女视频| 国产精品视频一二| 亚洲最新视频在线播放| 日韩电影一区二区三区| 国产精品69毛片高清亚洲| 91一区在线观看| 777亚洲妇女| 久久一区二区视频| 亚洲老司机在线| 免费观看日韩电影| 成人动漫视频在线| 欧美日韩一区不卡| 久久久精品黄色| 亚洲国产精品久久人人爱| 极品美女销魂一区二区三区| 99综合电影在线视频| 欧美男生操女生| 国产精品沙发午睡系列990531| 亚洲福利视频导航| 国产成人免费xxxxxxxx| 欧美色爱综合网| 国产亚洲成aⅴ人片在线观看| 一级女性全黄久久生活片免费| 国产一区二区在线观看视频| 91国产精品成人| 久久久久久99精品| 天堂在线亚洲视频| 99久久精品免费看| 欧美成人福利视频| 亚洲福利一二三区| 粉嫩嫩av羞羞动漫久久久 | 久久久综合激的五月天| 亚洲一区二区三区激情| 国产精品小仙女| 欧美精品第一页| 亚洲欧洲日韩av| 极品少妇一区二区| 91超碰这里只有精品国产| 中文字幕中文字幕中文字幕亚洲无线| 热久久久久久久| 欧美日韩中文字幕一区| 国产精品久线观看视频| 国产一区二区在线视频| 日韩一区二区三区在线| 亚洲精品国产品国语在线app| 国产成a人无v码亚洲福利| 欧美一区二区三区免费在线看| 又紧又大又爽精品一区二区| 国产1区2区3区精品美女| 日韩欧美色综合网站| 亚洲国产精品麻豆| 色八戒一区二区三区| 国产精品乱人伦| 国产一区视频在线看| 日韩精品专区在线影院重磅| 视频在线观看一区二区三区| 欧美性生活久久| 亚洲免费高清视频在线| 99精品久久久久久| 国产精品网曝门| 国产电影一区在线| 国产亚洲欧洲一区高清在线观看| 美女脱光内衣内裤视频久久网站| 欧美日韩三级视频| 亚洲高清在线精品| 欧美日韩久久一区| 亚洲午夜免费视频| 欧美日韩中文字幕一区二区| 亚洲综合在线第一页| 色av成人天堂桃色av| 樱桃视频在线观看一区| 91久久精品一区二区三| 亚洲美女视频在线| 色综合亚洲欧洲| 亚洲自拍偷拍九九九| 在线日韩一区二区| 亚洲国产精品麻豆| 欧美人狂配大交3d怪物一区| 视频一区视频二区中文字幕| 欧美一级欧美一级在线播放| 免费高清在线一区| 精品免费国产二区三区 | 91精品一区二区三区久久久久久| 三级欧美韩日大片在线看| 欧美一区二区精品| 精品亚洲成av人在线观看| 久久精品免视看| 成人精品在线视频观看| 亚洲天堂福利av| 欧美在线免费观看亚洲| 日韩电影免费在线看| 久久人人爽人人爽| 不卡一区在线观看| 亚洲一区二区三区四区五区中文 | 欧洲一区在线观看| 午夜伦欧美伦电影理论片| 日韩免费电影一区| 成人亚洲一区二区一| 亚洲精品国产无套在线观| 67194成人在线观看| 久久99深爱久久99精品| 日本一区免费视频| 色综合久久综合中文综合网| 午夜电影久久久| 久久毛片高清国产| 成人97人人超碰人人99| 亚洲成人免费影院| 日韩一区二区在线免费观看| 粉嫩aⅴ一区二区三区四区五区 | 男女男精品视频| 国产偷国产偷精品高清尤物| 色综合久久久网| 毛片av一区二区| 中文子幕无线码一区tr| 欧美三区在线观看| 狠狠色丁香婷婷综合| 亚洲精品视频在线看| 欧美丰满一区二区免费视频 | 欧美日韩在线直播| 久久成人久久爱| 日韩毛片视频在线看| 欧美精品第1页| a级精品国产片在线观看| 亚洲成人av中文| 欧美国产精品v| 91精品黄色片免费大全| av不卡免费在线观看| 视频一区二区三区在线| 国产精品久久久久久久久免费丝袜 | 国产欧美一区二区精品性色| 91精品1区2区| 国产综合久久久久影院| 亚洲一二三四区| 国产日产精品一区| 91精品国产乱| 欧美在线综合视频| 成人免费高清在线观看| 美腿丝袜一区二区三区| 一区二区三区四区av| 国产亚洲1区2区3区| 欧美精品v日韩精品v韩国精品v| 99久久免费视频.com| 国产一区二区不卡在线| 日本在线不卡视频| 亚洲一卡二卡三卡四卡五卡| 国产精品国产三级国产aⅴ原创 | 免费观看久久久4p| 一区二区三区在线免费视频| 国产欧美日韩亚州综合| 日韩一级欧美一级| 欧美日韩美少妇| 色综合久久综合| 不卡电影免费在线播放一区| 国产在线一区二区综合免费视频| 亚洲成人精品一区| 亚洲女同ⅹxx女同tv| 国产日产亚洲精品系列| 欧美精品一区二区三区蜜臀| 91精选在线观看| 欧美三级三级三级爽爽爽| 色94色欧美sute亚洲线路一ni| 国产成a人亚洲精品| 国产激情视频一区二区在线观看| 毛片av一区二区三区| 日本欧美一区二区三区乱码| 性做久久久久久久久| 亚洲一区二区三区四区中文字幕| 亚洲精品中文字幕乱码三区| 国产精品成人网| 亚洲图片你懂的| 亚洲欧洲中文日韩久久av乱码| 中文字幕一区在线观看视频|