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

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

?? interface.c

?? VxWorks下DHCP的源代碼!
?? C
字號:
/* interface.c - DHCP server and relay agent network interface library *//* Copyright 1984 - 2001 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01f,10oct01,rae  fixed modhist line01e,06oct97,spm  split interface name into device name and unit number01d,26aug97,spm  moved routines from common_subr.c not used by DHCP client01c,06may97,spm  changed memory access to align IP header on four byte                 boundary; removed unused timeout variable01b,18apr97,spm  added conditional include DHCPS_DEBUG for displayed output01a,07apr97,spm  created by modifying WIDE project DHCP implementation*//*DESCRIPTIONThis library contains the code used by the DHCP server and relay agents tomonitor one or more network interfaces for incoming DHCP messages. The monitorroutine is triggered on a semaphore given by an Ethernet input hook. Thecorresponding message, read from a pre-allocated ring buffer, identifies theoriginating network interface and the amount of received data. The data itselfis then copied from another ring buffer into a temporary interface-specificbuffer.INCLUDE_FILES: None*//* * WIDE Project DHCP Implementation * Copyright (c) 1995 Akihiro Tominaga * Copyright (c) 1995 WIDE Project * All rights reserved. * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided only with the following * conditions are satisfied: * * 1. Both the copyright notice and this permission notice appear in *    all copies of the software, derivative works or modified versions, *    and any portions thereof, and that both notices appear in *    supporting documentation. * 2. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *      This product includes software developed by WIDE Project and *      its contributors. * 3. Neither the name of WIDE Project nor the names of its contributors *    may be used to endorse or promote products derived from this software *    without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND WIDE * PROJECT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ALSO, THERE * IS NO WARRANTY IMPLIED OR OTHERWISE, NOR IS SUPPORT PROVIDED. * * Feedback of the results generated from any improvements or * extensions made to this software would be much appreciated. * Any such feedback should be sent to: *  *  Akihiro Tominaga *  WIDE Project *  Keio University, Endo 5322, Kanagawa, Japan *  (E-mail: dhcp-dist@wide.ad.jp) * * WIDE project has the rights to redistribute these changes. */#include "vxWorks.h"#include "ioLib.h"              /* ioctl() declaration */#include "vxLib.h"              /* checksum() declaration */#include "sockLib.h"#include "logLib.h"#include "rngLib.h"#include <stdio.h>#include <stdlib.h>#include <fcntl.h>#include <string.h>#include <unistd.h>#include <sys/ioctl.h>#include <sys/socket.h>#include <net/if.h>#include <netinet/in_systm.h>#include <netinet/in.h>#include "dhcp/dhcp.h"#include "dhcp/common.h"#include "dhcp/common_subr.h"/********************************************************************************* open_if - initialize per-interface data structure** This routine sets the IP address and subnet mask entries for each* interface monitored by the DHCP server or relay agent.** RETURNS: 0 if successful, or -1 on error.** ERRNO: N/A** NOMANUAL*/int open_if (struct if_info *ifinfo /* pointer to interface descriptor */    ){    int n;    struct ifreq ifreq;    bzero ((char *) &ifreq, sizeof (ifreq));    sprintf (ifreq.ifr_name, "%s%d", ifinfo->name, ifinfo->unit);    /*     * Initialize the interface information (subnet and IP address).     */    n = socket (AF_INET, SOCK_DGRAM, 0);    if (n < 0)        return (-1);    if (ioctl (n, SIOCGIFNETMASK, (int) &ifreq) < 0) {#ifdef DHCPS_DEBUG        logMsg ("Error: Can't retrieve netmask in open_if().\n", 0, 0, 0, 0, 0, 0);#endif        close (n);        return (-1);    }    ifinfo->subnetmask.s_addr = ((struct sockaddr_in *) &ifreq.ifr_addr)->sin_addr.s_addr;    if (ioctl (n, SIOCGIFADDR, (int) &ifreq) < 0) {#ifdef DHCPS_DEBUG        logMsg ("Error: can't retrieve address in open_if().\n", 0, 0, 0, 0, 0, 0);#endif        close (n);        return (-1);    }    ifinfo->ipaddr.s_addr = ((struct sockaddr_in *) &ifreq.ifr_addr)->sin_addr.s_addr;    close (n);    /*     * Store size of preallocated buffer. Offset used to align IP header on      * 4-byte boundary for Sun BSP's.      */    ifinfo->buf_size = DHCP_MSG_SIZE + DHCPS_OFF;    return (0);}/********************************************************************************* read_interfaces - extract arriving messages from shared buffers** This function waits for the arrival of a DHCP message (extracted by* a BPF device) and copies the message into the private buffer* associated with the receiving interface.** RETURNS: Pointer to data structure of receiving interface, or NULL on error.** ERRNO: N/A** NOMANUAL*/struct if_info *read_interfaces (struct if_info *iflist,    /* pointer to interface descriptors */                                 int *n,    /* buffer for actual length of message */                                 int maxSize    /* length of (internal) buffer for message */    ){    struct if_info *ifp = NULL; /* descriptor of receiver's interface */    int status;                 /* message extraction results */    fd_set readFds;    int fileNum = 0;    int maxFileNum = 0;    /* Wait for an arriving DHCP message. */    FD_ZERO (&readFds);    ifp = iflist;    while (ifp != NULL) {        fileNum = ifp->bpfDev;        FD_SET (fileNum, &readFds);        if (fileNum > maxFileNum)            maxFileNum = fileNum;        ifp = ifp->next;    }    maxFileNum++;               /* Adjust maximum for select() routine. */#ifdef DHCPS_DEBUG    logMsg ("DHCP server: waiting for data.\n", 0, 0, 0, 0, 0, 0);#endif    status = select (maxFileNum, &readFds, NULL, NULL, NULL);    if (status <= 0)        return (NULL);#ifdef DHCPS_DEBUG    logMsg ("DHCP server: read_interfaces() received new message.\n", 0, 0, 0, 0, 0, 0);#endif    /* Find the interface descriptor for the first available DHCP message. */    ifp = iflist;    while (ifp != NULL) {        fileNum = ifp->bpfDev;        if (FD_ISSET (fileNum, &readFds))            break;        ifp = ifp->next;    }    if (ifp == NULL) {#ifdef DHCPS_DEBUG        logMsg ("Warning: invalid network device in read_interfaces()\n", 0, 0, 0, 0, 0, 0);#endif        return (NULL);    }    status = read (fileNum, ifp->buf, maxSize);    if (status <= 0) {#ifdef DHCPS_DEBUG        logMsg ("Warning: error reading DHCP message.\n", 0, 0, 0, 0, 0, 0);#endif        return (NULL);    }    *n = status;    return (ifp);}/********************************************************************************* get_ipsum - retrieve the IP header checksum** This routine fetches the checksum for the given IP header.** RETURNS: Value of checksum in network byte order.** ERRNO:   N/A** NOMANUAL*/u_short get_ipsum (struct ip * pIph /* IP header */    ){    pIph->ip_sum = 0;#if BSD<44    return (checksum ((u_short *) pIph, (pIph->ip_v_hl & 0xf) << 2));#else    return (checksum ((u_short *) pIph, pIph->ip_hl << 2));#endif}/********************************************************************************* check_ipsum - verify the IP header checksum** This routine retrieves the checksum for the given IP header and compares* it to the received checksum.** RETURNS: TRUE if checksums match, or FALSE otherwise.** ERRNO:   N/A** NOMANUAL*/BOOL check_ipsum (struct ip * pIph  /* Received IP header */    ){    u_short ripcksum;           /* received IP checksum */    ripcksum = pIph->ip_sum;    return (ripcksum == get_ipsum (pIph));}/********************************************************************************* get_udpsum - retrieve the UDP header checksum** This routine fetches the checksum for a UDP header.** RETURNS: Value of checksum in network byte order.** ERRNO:   N/A** NOMANUAL*/u_short get_udpsum (struct ip * pIph,   /* IP header */                    struct udphdr * pUdph   /* UDP header */    ){    struct ps_udph UdpPh;       /* UDP pseudo-header */    bzero ((char *) &UdpPh, sizeof (UdpPh));    UdpPh.srcip.s_addr = pIph->ip_src.s_addr;    UdpPh.dstip.s_addr = pIph->ip_dst.s_addr;    UdpPh.zero = 0;    UdpPh.prto = IPPROTO_UDP;    UdpPh.ulen = pUdph->uh_ulen;    pUdph->uh_sum = 0;    return (udp_cksum (&UdpPh, (char *) pUdph, ntohs (UdpPh.ulen)));}/********************************************************************************* check_udpsum - verify the IP header checksum** This routine retrieves the checksum for a UDP header and compares it* to the received checksum.** RETURNS: TRUE if checksums match, or FALSE otherwise.** ERRNO:   N/A** NOMANUAL*/int check_udpsum (struct ip *pIph,  /* Received IP header */                  struct udphdr *pUdph  /* Received UDP header */    ){    u_short rudpcksum;          /* received UDP checksum */    if (pUdph->uh_sum == 0)        return (TRUE);    rudpcksum = pUdph->uh_sum;    return (rudpcksum == get_udpsum (pIph, pUdph));}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品一区四区| 国产精品视频看| 日本一区二区动态图| 一区二区三区国产精华| 久久精品免费观看| 91免费观看国产| 欧美精品一区二| 一区二区三区精品视频| 韩国毛片一区二区三区| 欧洲一区二区三区免费视频| 久久久久国产精品麻豆ai换脸 | 日韩视频免费观看高清完整版在线观看| 久久久精品综合| 亚洲午夜一区二区| 波多野结衣在线一区| 日韩精品一区二区三区四区视频 | 成人性生交大片| 欧美精品v日韩精品v韩国精品v| 中文字幕第一区| 日韩电影网1区2区| 欧美性猛交xxxx乱大交退制版 | 日韩一区二区三区视频在线观看| 亚洲欧美色一区| 国产精品乡下勾搭老头1| 日韩欧美在线观看一区二区三区| 亚洲综合色网站| 99久久免费精品高清特色大片| 久久久国际精品| 久久99精品久久久| 91精品欧美一区二区三区综合在| 亚洲一卡二卡三卡四卡五卡| 91亚洲精品乱码久久久久久蜜桃 | 粉嫩在线一区二区三区视频| 337p粉嫩大胆色噜噜噜噜亚洲| 日韩国产精品久久久久久亚洲| 欧美日韩亚洲综合在线| 亚洲精品视频在线观看网站| 99r精品视频| 日本一区二区成人| 波多野结衣中文字幕一区二区三区| 国产欧美日韩三区| 国产91精品在线观看| 国产亚洲欧美日韩在线一区| 国产乱码精品1区2区3区| 国产亚洲欧洲997久久综合| 风间由美一区二区av101| 国产精品视频看| 色婷婷av一区二区三区软件| 樱花影视一区二区| 欧美亚洲动漫另类| 日韩综合一区二区| 欧美xxxxx牲另类人与| 国产综合色在线| 国产精品沙发午睡系列990531| jiyouzz国产精品久久| 亚洲色图20p| 欧美日韩激情一区| 秋霞国产午夜精品免费视频| 精品国产凹凸成av人网站| 国产伦精品一区二区三区免费| 国产欧美一区二区三区在线老狼| 成人精品在线视频观看| 一区二区三区在线观看欧美| 欧美一区二区三区在线视频| 国产一区二区按摩在线观看| 综合在线观看色| 欧美日产国产精品| 国产精品影视在线观看| 亚洲免费av观看| 日韩女优视频免费观看| 成人深夜福利app| 午夜精品视频在线观看| 精品国产三级电影在线观看| 色婷婷综合中文久久一本| 亚洲123区在线观看| 久久综合久久综合久久综合| 91免费看`日韩一区二区| 日韩在线a电影| 中文字幕不卡在线| 欧美伦理影视网| www.欧美日韩国产在线| 日本女优在线视频一区二区| 国产精品久久久久毛片软件| 91麻豆精品91久久久久久清纯| 成人一区二区视频| 丝瓜av网站精品一区二区 | 日韩三级在线免费观看| av一本久道久久综合久久鬼色| 日韩vs国产vs欧美| 综合久久久久综合| 久久九九久精品国产免费直播| 欧美亚洲另类激情小说| 成人动漫一区二区| 国产一区福利在线| 日韩中文字幕麻豆| 亚洲黄色性网站| 中文字幕在线一区| 久久精品夜色噜噜亚洲aⅴ| 欧美精品一二三四| 在线免费观看日本一区| 成人一区二区三区视频在线观看 | 在线播放中文一区| 99久久精品国产网站| 国产精品亚洲一区二区三区妖精| 亚洲高清久久久| 最近中文字幕一区二区三区| 中文字幕免费观看一区| 精品国产一区二区精华| 日韩欧美国产麻豆| 91精品国产色综合久久不卡电影 | 久久精品一区二区三区不卡牛牛| 69精品人人人人| 欧美三级电影网站| 日本国产一区二区| 色综合久久综合网欧美综合网| 国产成人av电影在线播放| 精品亚洲porn| 国产制服丝袜一区| 国产精品888| 国产成a人亚洲精| 成人性生交大片| 99久久99久久免费精品蜜臀| 成人午夜av影视| 成人av在线看| 99这里只有久久精品视频| 成人18视频日本| 97久久精品人人澡人人爽| 99久久精品国产一区| 色哟哟在线观看一区二区三区| 91麻豆自制传媒国产之光| 91一区在线观看| 欧美日韩视频一区二区| 欧美精品在线观看播放| 日韩欧美在线影院| 国产日韩精品一区二区浪潮av| 久久精品人人做人人爽97| 国产精品视频一二三| 亚洲人精品午夜| 亚洲图片有声小说| 久久9热精品视频| 国产jizzjizz一区二区| 99精品久久99久久久久| 欧美午夜精品理论片a级按摩| 欧美三级视频在线播放| 日韩一区国产二区欧美三区| 久久久久久久久久久电影| 国产精品久久久久久久裸模| 夜夜嗨av一区二区三区四季av| 日本成人在线电影网| 国产精品资源站在线| 91在线观看美女| 91精品久久久久久久99蜜桃 | 欧美一区二区国产| 精品日韩在线一区| 国产精品国产三级国产普通话三级 | 国产精品青草久久| 一区二区三区丝袜| 久久99精品久久久久久动态图| 成人av中文字幕| 67194成人在线观看| 欧美激情一区二区三区全黄| 五月天婷婷综合| 高清在线成人网| 91精品午夜视频| 亚洲欧洲精品一区二区三区不卡| 日本不卡视频在线观看| 成人av在线资源网站| 日韩三级中文字幕| 一区二区三区中文字幕在线观看| 九色综合国产一区二区三区| 在线免费观看视频一区| 国产色产综合产在线视频| 午夜久久久影院| 99精品视频免费在线观看| 日韩精品在线看片z| 亚洲aⅴ怡春院| 色婷婷综合久久久久中文| 国产网红主播福利一区二区| 日韩在线卡一卡二| 在线观看av不卡| 综合色中文字幕| 成人av在线观| 国产欧美精品一区aⅴ影院| 麻豆精品视频在线| 欧美日韩在线播放三区| 自拍偷拍亚洲欧美日韩| 成人综合婷婷国产精品久久蜜臀| 精品sm捆绑视频| 日本欧美肥老太交大片| 欧美日韩高清一区二区| 亚洲精品国产无天堂网2021| 成年人网站91| 欧美激情在线免费观看| 国产成人在线观看免费网站| 欧美大片在线观看一区二区| 天堂蜜桃一区二区三区| 欧美日韩国产123区| 日韩制服丝袜av| 欧美日韩精品电影| 日本麻豆一区二区三区视频|