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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? rdisclib.c

?? vxworks的完整的源代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* rdiscLib.c - ICMP router discovery server library *//* Copyright 1984 - 2001 Wind River Systems, Inc. */#include "copyright_wrs.h" /*modification history--------------------01a,29mar01,spm  file creation: copied from version 01g of tor2_0.open_stack                 branch (wpwr VOB) for unified code base*//*DESCRIPTIONrdiscLib contains code to implement ICMP Router Discovery. This featureallows routers to advertise an address to the hosts on each of the routersinterfaces.  This address is placed by the host into its route table asa default router.  A host may also solicit the address by multicastingthe request to the ALL_ROUTERS address (224.0.0.2), to which a routerwould respond with a unicast version of the advertisement.There are three routines in this implementation of router discovery:rdiscInit(), rdisc() and rdCtl().  rdiscInit() is the initializationroutine, rdisc() handles the periodic transmission of advertisementsand processing of solicitations, and rdCtl() sets/gets user parameters.*/ /* includes */#include "vxWorks.h"#include "rdiscLib.h"#include "stdioLib.h"#include "netLib.h"#include "inetLib.h"#include "sockLib.h"#include "taskLib.h"#include "routeLib.h"#include "wdLib.h"#include "vxLib.h"   #include "inetLib.h"#include "string.h"#include "logLib.h"#include "sysLib.h"#include "ioLib.h"#include "math.h"#include "netinet/ip.h"#include "netinet/in.h"#include "netinet/in_systm.h"#include "netinet/ip_icmp.h"#include "netinet/in_var.h"#ifdef VIRTUAL_STACK#include "netinet/vsLib.h"#include "netinet/vsRdisc.h"#endif /* VIRTUAL_STACK *//* defines */#define INITIAL_DELAY		600#define RDISC_PACKET_SIZE	16/* Defaults for task information */#define RDISC_TASK_PRIORITY 127#define RDISC_TASK_OPTIONS 0#define RDISC_STACK_SIZE 20000/* RFC 1256 values for each interface */struct ifrd    {    char ifName[8];    struct in_addr NetAddress;    struct in_addr AdvertAddress;    int subnet;    int mask;    int AdvertLifetime;    int Advertise;    int PrefLevel;    };    struct rdiscPacket    {    char type;    char code;    short checkSum;    char numAddrs;    char entrySize;    short lifeTime;    unsigned int rAddr;    unsigned int pref;    };/* globals */#ifndef VIRTUAL_STACKIMPORT struct ifnet     *ifnet;         /* list of all network interfaces */IMPORT struct in_ifaddr    *in_ifaddr;SEM_ID rdiscIfSem;#endif  /* VIRTUAL_STACK *//* locals */#ifndef VIRTUAL_STACKLOCAL WDOG_ID wdId;LOCAL int rdiscSock;LOCAL int terminateFlag = 0;LOCAL BOOL debugFlag = 0;LOCAL int rdiscNumInterfaces=0;LOCAL struct ifrd *pIfDisc=0;LOCAL int MaxAdvertInterval;LOCAL int MinAdvertInterval;#endif /* VIRTUAL_STACK *//* forward declarations */#ifdef VIRTUAL_STACKvoid rdiscTimerEvent (int);#endif /* VIRTUAL_STACK */LOCAL void startWdTimer();/******************************************************************************** rdiscLibInit - Initialize router discovery** This routine links the ICMP Router Discovery facility into the VxWorks system.* The arguments are the task's priority, options and stackSize.** Returns: N/A**/void rdiscLibInit    (    int priority, /* Priority of router discovery task. */    int options, /* Options to taskSpawn(1) for router discovery task. */    int stackSize /* Stack size for router discovery task. */    )    {    taskSpawn ("tRdisc", priority, options, stackSize,               (FUNCPTR) rdisc, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);    }/********************************************************************************* rdiscInit - initialize the ICMP router discovery function** This routine allocates resources for the router discovery function. Since it* called in the rdisc() routine, it should not be called subsequently ** Returns: OK on successful initialization, ERROR otherwise**/STATUS rdiscInit()    {#ifdef VIRTUAL_STACK    terminateFlag = 0;    debugFlag = 0;    rdiscNumInterfaces=0;    pIfDisc=0;#endif    /* Create Locking semaphore so we can lock our own interface list. */    if ((rdiscIfSem = semBCreate (SEM_Q_PRIORITY, SEM_FULL)) == NULL)        {        logMsg ("rdisc could not create if locking semaphore\n",                0, 0, 0, 0, 0, 0);        return (ERROR);        }              /* create RAW socket */    rdiscSock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);    if (rdiscSock < 0)        {        logMsg("could not get raw socket\n",0,0,0,0,0,0);        semDelete (rdiscIfSem);        return ERROR;        }    pIfDisc = NULL;    if (rdiscIfReset() != OK)        {        close (rdiscSock);        semDelete (rdiscIfSem);        return (ERROR);        }    terminateFlag = 0;    return OK;    }/********************************************************************************* sendAdvert - send an advertisement to one location** This routine sends a router advertisement using the data stored for its'* corresponding interface.  Only the primary network address of the interface* is used as the advertised router address.** Returns: NA**/void sendAdvert    (    int index,    struct in_addr dstAddr    )    {    struct rdiscPacket *pRdis = NULL;    struct sockaddr_in to;    int status;    char sndbuf[RDISC_PACKET_SIZE];    if (debugFlag == TRUE)        logMsg("advertising %s to %s\n",               (int)inet_ntoa((pIfDisc[index].AdvertAddress)), 		(int)inet_ntoa(dstAddr),0,0,0,0);    /* check Advertise enabled flag */    if (pIfDisc[index].Advertise == 0)	return;    bzero (sndbuf, sizeof (sndbuf));    /* form an advertisement packet */    pRdis = (struct rdiscPacket*)sndbuf;    pRdis->type = ICMP_ROUTERADVERT;    pRdis->code = 0;    pRdis->numAddrs = 1;    pRdis->entrySize = 2;    pRdis->lifeTime = htons(pIfDisc[index].AdvertLifetime);    pRdis->rAddr = (pIfDisc[index].NetAddress.s_addr);     pRdis->pref = htonl(pIfDisc[index].PrefLevel);     pRdis->checkSum = 0;    pRdis->checkSum = checksum((u_short *) pRdis, RDISC_PACKET_SIZE);    bzero ((char *)&to, sizeof (to));    to.sin_family = AF_INET;    to.sin_len = sizeof(struct sockaddr_in);    to.sin_addr.s_addr = (dstAddr.s_addr);  /* advertisement destination */     status = sendto(rdiscSock, sndbuf, sizeof(struct rdiscPacket),                    0, (struct sockaddr *)&to, sizeof(to));    if (status != sizeof(struct rdiscPacket))        {        logMsg("rdisc: corrupt packet, errno = %d\n", 		errno,0,0,0,0,0);        }    } /********************************************************************************* sendAdvertAll - send an advertisement to all active locations** This routine sends a router advertisement using the data stored for each* corresponding interface.  Only the primary network address of the interface* is used as the advertised router address.** Returns: NA**/void sendAdvertAll()    {    int i=0;    struct in_addr ia;    /* Make sure the interface list is not being updated. */    semTake (rdiscIfSem, WAIT_FOREVER);    for(i=0; i<rdiscNumInterfaces; i++)	{        if (pIfDisc[i].Advertise == 0)	    continue;         ia.s_addr = pIfDisc[i].NetAddress.s_addr;   	setsockopt(rdiscSock, IPPROTO_IP, IP_MULTICAST_IF, 		   (char *)&ia, sizeof(struct in_addr));	/* multicast to the selected network */         sendAdvert(i, pIfDisc[i].AdvertAddress);        }    semGive (rdiscIfSem);    }/********************************************************************************* rdiscTimerEvent - called after watchdog timeout** This routine is called when a new advertisement is to be sent. ** Returns: NA**/#ifdef VIRTUAL_STACKvoid rdiscTimerEventRestart    (    int stackNum    )    {    netJobAdd ((FUNCPTR)rdiscTimerEvent, stackNum, 0, 0, 0, 0);    }void rdiscTimerEvent    (    int stackNum    )    {    virtualStackNumTaskIdSet(stackNum);#elsevoid rdiscTimerEvent()    {#endif /* VIRTUAL_STACK */    sendAdvertAll();       if (terminateFlag != 0)	return;    startWdTimer();    }/********************************************************************************* rdisc - implement the ICMP router discovery function** This routine is the entry point for the router discovery function.  It* allocates and initializes resources, listens for solicitation messages * on the ALL_ROUTERS (224.0.0.1) multicast address and processes the* messages.** This routine usually runs until explicitly killed by a system operator, but* can also be terminated cleanly (see rdCtl() routine).** Returns: NA**/void rdisc ()    {    int  i;    int status;    char recvBuff[128];    struct sockaddr from;    int FromLen;    struct ip *pIp;    struct rdiscPacket *rdp;    short checkSum;    status = rdiscInit();    if (status == ERROR)        {        logMsg("rdisc: could not initialize router discovery\n", 0,0,0,0,0,0);	return;        }    /* receive buffer IP packet */    pIp = (struct ip * )recvBuff;    /* receive buffer ICMP route discovery packet */    rdp = (struct rdiscPacket *)&recvBuff[20];    /* create WatchDog timer */    wdId = wdCreate();    sendAdvertAll();#ifdef VIRTUAL_STACK    status = wdStart(wdId, INITIAL_DELAY, (FUNCPTR) rdiscTimerEventRestart,                     (int) myStackNum);#else    status = wdStart(wdId, INITIAL_DELAY, netJobAdd, (int)rdiscTimerEvent );#endif /* VIRTUAL_STACK */    if (status == ERROR) 	{	logMsg("rdisc: error starting watchdog timer: %d\n", errno,0,0,0,0,0);        }    while (terminateFlag == 0)	{        if (debugFlag == TRUE)	    logMsg("rdisc: Waiting for solicitation...\n",0,0,0,0,0,0);        status = recvfrom(rdiscSock, recvBuff, 100, 0,			 (struct sockaddr *)&from, &FromLen);        if (status < 0)	    {            logMsg("error in recvfrom returns %d, errno is %d exiting\n", 			status, errno, 0,0,0,0);            rdCtl (NULL, SET_MODE, (void*)MODE_STOP);            return;            }	if (pIp->ip_len < 8)   /* verify IP packet length */	    {            logMsg("rdisc: packet too short, %d bytes\n",                    pIp->ip_len * 4, 0,0,0,0,0);	    continue;	    }	if (rdp->code != 0) /* ICMP code */	    {            logMsg("rdisc: wrong code: %d\n", rdp->code, 0,0,0,0,0);	    continue;	    }        if (rdp->type == 10) /* solicitation message */	    {	    /* NEED to check source address here per RFC */            if (debugFlag == TRUE)		logMsg("rdisc: received solicitation from src addr is %s\n", 		        (int)inet_ntoa(pIp->ip_src), 0,0,0,0,0);    	    /* verify checksum */            checkSum = rdp->checkSum;            rdp->checkSum = 0;    	    if ((u_short)checkSum != (u_short)checksum((u_short *) rdp, 8))		{	        logMsg ("checksum error: %d != %d\n" , (u_short)checkSum , 				(u_short)checksum((u_short *) rdp,8), 0,0,0,0);	        continue;	        }            /* Check the interface list lock. */            semTake (rdiscIfSem, WAIT_FOREVER);	    /* find the matching interface */	    for(i = 0; i < rdiscNumInterfaces; i++)                {		if (pIfDisc[i].subnet == (htonl(pIp->ip_src.s_addr) & 			pIfDisc[i].mask))		   break;		}            /* Check for a match. */            if (i < rdiscNumInterfaces)                sendAdvert(i, pIp->ip_src);            semGive (rdiscIfSem);            }        else            {            if (rdp->type == 9)                {                if (debugFlag == TRUE)                    logMsg("received router advertisement from %s\n",                            (int)inet_ntoa(pIp->ip_src),0,0,0,0,0);                 }            }        }        if (pIfDisc != NULL)        free((char *)pIfDisc);    wdCancel(wdId);    close(rdiscSock);    }/********************************************************************************* restartWdTimer - called at various place when the rdisc timer has to be*    (re-) started** This routine calculates the new interval and starts the rdisc timer.** Returns: NA**/LOCAL void startWdTimer()    {    int interval = MinAdvertInterval+                (rand()%(MaxAdvertInterval-MinAdvertInterval));    interval *= sysClkRateGet();#ifdef VIRTUAL_STACK    wdStart(wdId, interval, (FUNCPTR)rdiscTimerEventRestart, (int) myStackNum);#else    wdStart(wdId, interval, netJobAdd, (int)rdiscTimerEvent);#endif /* VIRTUAL_STACK */    }/********************************************************************************* searchInterface - search interface in local database*

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色猫猫国产区一区二在线视频| 国产一二三精品| 国产酒店精品激情| 欧美日韩一区二区三区在线 | 国产69精品一区二区亚洲孕妇| 欧美久久久久久久久久| 国产精品美女久久久久久2018| 蜜臀av性久久久久蜜臀av麻豆 | 久久国产日韩欧美精品| 色一区在线观看| 久久精品在这里| 婷婷一区二区三区| 91美女蜜桃在线| 欧美国产成人在线| 老司机精品视频在线| 欧美三级视频在线观看| 亚洲少妇中出一区| 波多野结衣中文字幕一区| 久久久久国产精品麻豆ai换脸 | 亚洲18女电影在线观看| 97精品视频在线观看自产线路二| www国产精品av| 免费不卡在线观看| 欧美日韩精品三区| 亚洲免费观看视频| 91在线播放网址| 中文字幕一区在线| 国产91精品在线观看| 精品成人免费观看| 麻豆视频一区二区| 日韩一二三四区| 日韩va欧美va亚洲va久久| 91久久国产最好的精华液| 国产精品久久久久久妇女6080| 国产久卡久卡久卡久卡视频精品| 久久综合成人精品亚洲另类欧美| 久久精品国产免费| 欧美不卡一区二区| 国产呦萝稀缺另类资源| 精品国产乱码久久久久久久久| 久久不见久久见中文字幕免费| 欧美成人综合网站| 国产一区欧美二区| 欧美国产成人在线| 99久久婷婷国产综合精品电影 | 欧美一区二区三区免费观看视频| 亚洲成人免费视频| 欧美精品 国产精品| 日韩福利电影在线| 欧美一区二区啪啪| 久久福利视频一区二区| 精品99一区二区三区| 国内精品嫩模私拍在线| 久久色在线观看| 成人小视频在线| 亚洲免费在线视频| 欧美色国产精品| 男人的天堂亚洲一区| 精品捆绑美女sm三区| 国产电影一区二区三区| 中文字幕亚洲精品在线观看 | 国产资源精品在线观看| 国产三区在线成人av| 99久久久精品免费观看国产蜜| 亚洲人成影院在线观看| 欧美综合天天夜夜久久| 婷婷丁香久久五月婷婷| 精品国产乱码久久久久久免费| 国产成人精品亚洲午夜麻豆| 亚洲欧洲日韩综合一区二区| 色偷偷久久一区二区三区| 午夜影视日本亚洲欧洲精品| 精品国产髙清在线看国产毛片| 国产成人aaa| 亚洲三级在线免费| 欧美人妖巨大在线| 国产曰批免费观看久久久| 国产精品久久久久久久第一福利| 欧美亚洲丝袜传媒另类| 蜜臀久久99精品久久久久宅男| 国产亚洲精品久| 在线观看91精品国产入口| 麻豆91在线看| 国产精品国产三级国产| 欧美日韩美女一区二区| 精品在线你懂的| 日韩伦理av电影| 666欧美在线视频| 国产mv日韩mv欧美| 亚洲一区在线观看免费观看电影高清| 日韩天堂在线观看| 成人一区二区三区视频在线观看| 亚洲综合色丁香婷婷六月图片| 日韩欧美在线不卡| av资源网一区| 免费欧美日韩国产三级电影| 国产欧美日韩三级| 欧美日韩精品二区第二页| 国产精品1区2区| 香蕉成人啪国产精品视频综合网| 久久久99久久| 欧美精品在欧美一区二区少妇| 国产盗摄一区二区| 日日夜夜精品视频免费| 中文字幕不卡三区| 3d动漫精品啪啪1区2区免费| 成人高清av在线| 精品在线亚洲视频| 亚洲国产精品嫩草影院| 国产精品丝袜在线| 日韩女同互慰一区二区| 一本色道综合亚洲| 国产精品一区免费视频| 午夜激情综合网| 亚洲欧美另类小说| 国产亚洲一本大道中文在线| 欧美一区二区免费观在线| 欧美在线影院一区二区| 国产成人在线视频播放| 日本成人在线电影网| 亚洲区小说区图片区qvod| 26uuu国产在线精品一区二区| 欧美揉bbbbb揉bbbbb| caoporn国产一区二区| 国产精品伊人色| 麻豆精品一二三| 婷婷夜色潮精品综合在线| 亚洲欧美激情小说另类| 国产日韩v精品一区二区| 日韩欧美一二三区| 欧美日韩激情一区二区| 91丝袜美女网| 成人免费视频视频| 国产大陆亚洲精品国产| 久久精品av麻豆的观看方式| 亚欧色一区w666天堂| 亚洲男帅同性gay1069| 国产欧美精品在线观看| 欧美精品一区二区三| 欧美一区在线视频| 欧美日本在线一区| 欧美三级一区二区| 欧美自拍丝袜亚洲| 91色.com| 91在线视频免费91| 成人福利视频在线看| 成人午夜在线视频| 成人手机在线视频| 国产精品99久| 高清久久久久久| 懂色av一区二区在线播放| 国产精品亚洲第一区在线暖暖韩国| 麻豆精品一区二区综合av| 免费人成黄页网站在线一区二区| 日本在线播放一区二区三区| 首页综合国产亚洲丝袜| 亚洲成a人v欧美综合天堂下载| 夜夜亚洲天天久久| 亚洲综合视频在线| 亚洲国产婷婷综合在线精品| 亚洲国产精品一区二区www | 中文字幕电影一区| 中文字幕不卡三区| 国产精品久久久久四虎| 国产精品久久久久久户外露出| 国产精品久久久久天堂| 亚洲视频每日更新| 一区二区三区在线免费观看| 一区二区三区在线观看国产| 亚洲综合在线电影| 三级不卡在线观看| 国模一区二区三区白浆| 国产电影精品久久禁18| av一区二区三区| 色狠狠一区二区| 欧美日韩免费一区二区三区视频| 欧美日韩一级二级| 日韩欧美一二三区| 久久精品亚洲精品国产欧美kt∨| 欧美韩日一区二区三区| 亚洲三级理论片| 五月天激情综合| 久久精品国产999大香线蕉| 国产高清在线精品| 91老师国产黑色丝袜在线| 欧美在线三级电影| 日韩欧美高清在线| 久久久久久**毛片大全| 中文字幕在线一区| 亚洲一区二区在线观看视频| 日本不卡123| 国产精品一线二线三线| 91色视频在线| 日韩欧美精品三级| 国产欧美精品一区aⅴ影院 | 欧美高清在线一区| 亚洲影院理伦片| 久久99久久久久| 成人网在线播放| 欧美精品日韩精品|