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

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

?? etharp.c

?? 基于AT91SAM7x256的硬件平臺的WEB服務器源碼(A&shy DS版本, ucOS_II+LWIP+自己編寫的DNS查詢工具)
?? C
?? 第 1 頁 / 共 2 頁
字號:
/** * @file * Address Resolution Protocol module for IP over Ethernet * * Functionally, ARP is divided into two parts. The first maps an IP address * to a physical address when sending a packet, and the second part answers * requests from other machines for our physical address. * * This implementation complies with RFC 826 (Ethernet ARP). It supports * Gratuitious ARP from RFC3220 (IP Mobility Support for IPv4) section 4.6 * if an interface calls etharp_query(our_netif, its_ip_addr, NULL) upon * address change. *//* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * Copyright (c) 2003-2004 Leon Woestenberg <leon.woestenberg@axon.tv> * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, *    this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, *    this list of conditions and the following disclaimer in the documentation *    and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products *    derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * */#include "lwip/opt.h"#include "lwip/inet.h"#include "netif/etharp.h"#include "lwip/ip.h"#include "lwip/stats.h"/* ARP needs to inform DHCP of any ARP replies? */#if (LWIP_DHCP && DHCP_DOES_ARP_CHECK)#  include "lwip/dhcp.h"#endif/** the time an ARP entry stays valid after its last update, * (240 * 5) seconds = 20 minutes. */#define ARP_MAXAGE 240/** the time an ARP entry stays pending after first request, * (2 * 5) seconds = 10 seconds. *  * @internal Keep this number at least 2, otherwise it might * run out instantly if the timeout occurs directly after a request. */#define ARP_MAXPENDING 2#define HWTYPE_ETHERNET 1/** ARP message types */#define ARP_REQUEST 1#define ARP_REPLY 2#define ARPH_HWLEN(hdr) (ntohs((hdr)->_hwlen_protolen) >> 8)#define ARPH_PROTOLEN(hdr) (ntohs((hdr)->_hwlen_protolen) & 0xff)#define ARPH_HWLEN_SET(hdr, len) (hdr)->_hwlen_protolen = htons(ARPH_PROTOLEN(hdr) | ((len) << 8))#define ARPH_PROTOLEN_SET(hdr, len) (hdr)->_hwlen_protolen = htons((len) | (ARPH_HWLEN(hdr) << 8))enum etharp_state {  ETHARP_STATE_EMPTY,  ETHARP_STATE_PENDING,  ETHARP_STATE_STABLE,  /** @internal transitional state used in etharp_tmr() for convenience*/  ETHARP_STATE_EXPIRED};struct etharp_entry {#if ARP_QUEUEING  /**    * Pointer to queue of pending outgoing packets on this ARP entry.   */   struct pbuf *p;#endif  struct ip_addr ipaddr;  struct eth_addr ethaddr;  enum etharp_state state;  u8_t ctime;};static const struct eth_addr ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}};static struct etharp_entry arp_table[ARP_TABLE_SIZE];/** * Try hard to create a new entry - we want the IP address to appear in * the cache (even if this means removing an active entry or so). */#define ETHARP_TRY_HARD 1static s8_t find_entry(struct ip_addr *ipaddr, u8_t flags);static err_t update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *ethaddr, u8_t flags);/** * Initializes ARP module. */voidetharp_init(void){  u8_t i;  /* clear ARP entries */  for(i = 0; i < ARP_TABLE_SIZE; ++i) {    arp_table[i].state = ETHARP_STATE_EMPTY;#if ARP_QUEUEING    arp_table[i].p = NULL;#endif    arp_table[i].ctime = 0;  }}/** * Clears expired entries in the ARP table. * * This function should be called every ETHARP_TMR_INTERVAL microseconds (5 seconds), * in order to expire entries in the ARP table. */voidetharp_tmr(void){  u8_t i;  LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer\n"));  /* remove expired entries from the ARP table */  for (i = 0; i < ARP_TABLE_SIZE; ++i) {    arp_table[i].ctime++;    /* stable entry? */    if ((arp_table[i].state == ETHARP_STATE_STABLE) &&         /* entry has become old? */        (arp_table[i].ctime >= ARP_MAXAGE)) {      LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: expired stable entry %"U16_F".\n", (u16_t)i));      arp_table[i].state = ETHARP_STATE_EXPIRED;    /* pending entry? */    } else if (arp_table[i].state == ETHARP_STATE_PENDING) {      /* entry unresolved/pending for too long? */      if (arp_table[i].ctime >= ARP_MAXPENDING) {        LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: expired pending entry %"U16_F".\n", (u16_t)i));        arp_table[i].state = ETHARP_STATE_EXPIRED;#if ARP_QUEUEING      } else if (arp_table[i].p != NULL) {        /* resend an ARP query here */#endif      }    }    /* clean up entries that have just been expired */    if (arp_table[i].state == ETHARP_STATE_EXPIRED) {#if ARP_QUEUEING      /* and empty packet queue */      if (arp_table[i].p != NULL) {        /* remove all queued packets */        LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: freeing entry %"U16_F", packet queue %p.\n", (u16_t)i, (void *)(arp_table[i].p)));        pbuf_free(arp_table[i].p);        arp_table[i].p = NULL;      }#endif      /* recycle entry for re-use */            arp_table[i].state = ETHARP_STATE_EMPTY;    }  }}/** * Search the ARP table for a matching or new entry. *  * If an IP address is given, return a pending or stable ARP entry that matches * the address. If no match is found, create a new entry with this address set, * but in state ETHARP_EMPTY. The caller must check and possibly change the * state of the returned entry. *  * If ipaddr is NULL, return a initialized new entry in state ETHARP_EMPTY. *  * In all cases, attempt to create new entries from an empty entry. If no * empty entries are available and ETHARP_TRY_HARD flag is set, recycle * old entries. Heuristic choose the least important entry for recycling. * * @param ipaddr IP address to find in ARP cache, or to add if not found. * @param flags * - ETHARP_TRY_HARD: Try hard to create a entry by allowing recycling of * active (stable or pending) entries. *   * @return The ARP entry index that matched or is created, ERR_MEM if no * entry is found or could be recycled. */static s8_t find_entry(struct ip_addr *ipaddr, u8_t flags){  s8_t old_pending = ARP_TABLE_SIZE, old_stable = ARP_TABLE_SIZE;  s8_t empty = ARP_TABLE_SIZE;  u8_t i = 0, age_pending = 0, age_stable = 0;#if ARP_QUEUEING  /* oldest entry with packets on queue */  s8_t old_queue = ARP_TABLE_SIZE;  /* its age */  u8_t age_queue = 0;#endif  /**   * a) do a search through the cache, remember candidates   * b) select candidate entry   * c) create new entry   */  /* a) in a single search sweep, do all of this   * 1) remember the first empty entry (if any)   * 2) remember the oldest stable entry (if any)   * 3) remember the oldest pending entry without queued packets (if any)   * 4) remember the oldest pending entry with queued packets (if any)   * 5) search for a matching IP entry, either pending or stable   *    until 5 matches, or all entries are searched for.   */  for (i = 0; i < ARP_TABLE_SIZE; ++i) {    /* no empty entry found yet and now we do find one? */    if ((empty == ARP_TABLE_SIZE) && (arp_table[i].state == ETHARP_STATE_EMPTY)) {      LWIP_DEBUGF(ETHARP_DEBUG, ("find_entry: found empty entry %"U16_F"\n", (u16_t)i));      /* remember first empty entry */      empty = i;    }    /* pending entry? */    else if (arp_table[i].state == ETHARP_STATE_PENDING) {      /* if given, does IP address match IP address in ARP entry? */      if (ipaddr && ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) {        LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: found matching pending entry %"U16_F"\n", (u16_t)i));        /* found exact IP address match, simply bail out */        return i;#if ARP_QUEUEING      /* pending with queued packets? */      } else if (arp_table[i].p != NULL) {        if (arp_table[i].ctime >= age_queue) {          old_queue = i;          age_queue = arp_table[i].ctime;        }#endif      /* pending without queued packets? */      } else {        if (arp_table[i].ctime >= age_pending) {          old_pending = i;          age_pending = arp_table[i].ctime;        }      }            }    /* stable entry? */    else if (arp_table[i].state == ETHARP_STATE_STABLE) {      /* if given, does IP address match IP address in ARP entry? */      if (ipaddr && ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) {        LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: found matching stable entry %"U16_F"\n", (u16_t)i));        /* found exact IP address match, simply bail out */        return i;      /* remember entry with oldest stable entry in oldest, its age in maxtime */      } else if (arp_table[i].ctime >= age_stable) {        old_stable = i;        age_stable = arp_table[i].ctime;      }    }  }  /* { we have no match } => try to create a new entry */     /* no empty entry found and not allowed to recycle? */  if ((empty == ARP_TABLE_SIZE) && ((flags & ETHARP_TRY_HARD) == 0))  {  	return (s8_t)ERR_MEM;  }    /* b) choose the least destructive entry to recycle:   * 1) empty entry   * 2) oldest stable entry   * 3) oldest pending entry without queued packets   * 4) oldest pending entry without queued packets   *    * { ETHARP_TRY_HARD is set at this point }   */   /* 1) empty entry available? */  if (empty < ARP_TABLE_SIZE) {    i = empty;    LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting empty entry %"U16_F"\n", (u16_t)i));  }  /* 2) found recyclable stable entry? */  else if (old_stable < ARP_TABLE_SIZE) {    /* recycle oldest stable*/    i = old_stable;    LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting oldest stable entry %"U16_F"\n", (u16_t)i));#if ARP_QUEUEING    /* no queued packets should exist on stable entries */    LWIP_ASSERT("arp_table[i].p == NULL", arp_table[i].p == NULL);#endif  /* 3) found recyclable pending entry without queued packets? */  } else if (old_pending < ARP_TABLE_SIZE) {    /* recycle oldest pending */    i = old_pending;    LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting oldest pending entry %"U16_F" (without queue)\n", (u16_t)i));#if ARP_QUEUEING  /* 4) found recyclable pending entry with queued packets? */  } else if (old_queue < ARP_TABLE_SIZE) {    /* recycle oldest pending */    i = old_queue;    LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting oldest pending entry %"U16_F", freeing packet queue %p\n", (u16_t)i, (void *)(arp_table[i].p)));    pbuf_free(arp_table[i].p);    arp_table[i].p = NULL;#endif    /* no empty or recyclable entries found */  } else {    return (s8_t)ERR_MEM;  }  /* { empty or recyclable entry found } */  LWIP_ASSERT("i < ARP_TABLE_SIZE", i < ARP_TABLE_SIZE);  /* recycle entry (no-op for an already empty entry) */  arp_table[i].state = ETHARP_STATE_EMPTY;  /* IP address given? */  if (ipaddr != NULL) {    /* set IP address */    ip_addr_set(&arp_table[i].ipaddr, ipaddr);  }  arp_table[i].ctime = 0;  return (err_t)i;}/** * Update (or insert) a IP/MAC address pair in the ARP cache. * * If a pending entry is resolved, any queued packets will be sent * at this point. *  * @param ipaddr IP address of the inserted ARP entry. * @param ethaddr Ethernet address of the inserted ARP entry. * @param flags Defines behaviour: * - ETHARP_TRY_HARD Allows ARP to insert this as a new item. If not specified, * only existing ARP entries will be updated. * * @return * - ERR_OK Succesfully updated ARP cache. * - ERR_MEM If we could not add a new ARP entry when ETHARP_TRY_HARD was set. * - ERR_ARG Non-unicast address given, those will not appear in ARP cache. * * @see pbuf_free() */static err_tupdate_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *ethaddr, u8_t flags){  s8_t i, k;  LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 3, ("update_arp_entry()\n"));  LWIP_ASSERT("netif->hwaddr_len != 0", netif->hwaddr_len != 0);  LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: %"U16_F".%"U16_F".%"U16_F".%"U16_F" - %02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F"\n",                                        ip4_addr1(ipaddr), ip4_addr2(ipaddr), ip4_addr3(ipaddr), ip4_addr4(ipaddr),                                         ethaddr->addr[0], ethaddr->addr[1], ethaddr->addr[2],                                        ethaddr->addr[3], ethaddr->addr[4], ethaddr->addr[5]));  /* non-unicast address? */  if (ip_addr_isany(ipaddr) ||      ip_addr_isbroadcast(ipaddr, netif) ||      ip_addr_ismulticast(ipaddr)) {    LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: will not add non-unicast IP address to ARP cache\n"));    return ERR_ARG;  }  /* find or create ARP entry */  i = find_entry(ipaddr, flags);  /* bail out if no entry could be found */  if (i < 0) return (err_t)i;    /* mark it stable */  arp_table[i].state = ETHARP_STATE_STABLE;  LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: updating stable entry %"S16_F"\n", (s16_t)i));  /* update address */  for (k = 0; k < netif->hwaddr_len; ++k) {    arp_table[i].ethaddr.addr[k] = ethaddr->addr[k];  }  /* reset time stamp */  arp_table[i].ctime = 0;/* this is where we will send out queued packets! */#if ARP_QUEUEING  while (arp_table[i].p != NULL) {    /* get the first packet on the queue */    struct pbuf *p = arp_table[i].p;    /* Ethernet header */    struct eth_hdr *ethhdr = p->payload;    /* remember (and reference) remainder of queue */    /* note: this will also terminate the p pbuf chain */    arp_table[i].p = pbuf_dequeue(p);    /* fill-in Ethernet header */    for (k = 0; k < netif->hwaddr_len; ++k) {      ethhdr->dest.addr[k] = ethaddr->addr[k];      ethhdr->src.addr[k] = netif->hwaddr[k];    }    ethhdr->type = htons(ETHTYPE_IP);    LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: sending queued IP packet %p.\n", (void *)p));    /* send the queued IP packet */    netif->linkoutput(netif, p);    /* free the queued IP packet */    pbuf_free(p);  }#endif  return ERR_OK;}/** * Updates the ARP table using the given IP packet.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲自拍偷拍欧美| 欧美大白屁股肥臀xxxxxx| 日韩精品一区二区三区四区视频 | 午夜av一区二区三区| 亚洲国产岛国毛片在线| 精品少妇一区二区三区视频免付费| 中文字幕久久午夜不卡| 免费日韩伦理电影| 亚洲国产中文字幕在线视频综合| 亚洲成人在线观看视频| 亚州成人在线电影| 91色综合久久久久婷婷| 成人97人人超碰人人99| 成人在线视频首页| 91在线精品秘密一区二区| 91久久线看在观草草青青| 色婷婷久久久久swag精品| 欧美日韩一级片在线观看| 在线播放91灌醉迷j高跟美女| 成人免费高清在线| 欧美大尺度电影在线| 日韩中文字幕不卡| 韩国视频一区二区| 成人动漫av在线| 日本一区二区三区dvd视频在线| 亚洲国产成人在线| 黄网站免费久久| 日韩欧美123| 蜜桃91丨九色丨蝌蚪91桃色| 国产成人午夜片在线观看高清观看| 成人理论电影网| 国产精品久久久一区麻豆最新章节| 亚洲欧美日韩小说| 日韩精品欧美成人高清一区二区| 色婷婷国产精品| 最近日韩中文字幕| 精品一区二区在线视频| 97久久人人超碰| 亚洲视频一区二区免费在线观看 | 欧美人牲a欧美精品| 国产亚洲欧洲997久久综合| 日韩美女啊v在线免费观看| 不卡的av中国片| 亚洲男帅同性gay1069| 色哟哟欧美精品| 午夜电影久久久| 日韩欧美高清dvd碟片| 国产精品99久久久久久有的能看| 在线影院国内精品| 午夜免费久久看| 欧美精品一区视频| 午夜精品久久久久影视| 欧美一级片免费看| 一区二区三区四区蜜桃| 国产成人精品一区二区三区四区 | 一个色在线综合| 欧美性猛交xxxxxx富婆| 国产日韩欧美精品在线| 成人h动漫精品| 亚洲综合精品自拍| 日韩一区二区影院| 视频一区二区中文字幕| 欧美不卡一区二区| 91猫先生在线| 免费成人在线视频观看| 中文字幕日本不卡| 国产高清亚洲一区| 一级精品视频在线观看宜春院| 日韩午夜激情av| 成人99免费视频| 麻豆精品在线视频| 国产精品灌醉下药二区| 日韩欧美成人一区| 99精品国产91久久久久久| 日本不卡的三区四区五区| 国产精品欧美精品| caoporn国产一区二区| 国产精品欧美经典| 日韩美女一区二区三区| 99r国产精品| 国产一区日韩二区欧美三区| 26uuu久久天堂性欧美| 激情六月婷婷综合| 亚洲成在人线在线播放| 日本一区二区综合亚洲| 日韩一区二区三区高清免费看看| 成人毛片老司机大片| 久久国产三级精品| 久久这里只有精品首页| 欧美片在线播放| 91在线观看视频| 国产馆精品极品| 久久国产乱子精品免费女| 亚洲一区二区在线观看视频 | 欧美精品一区二区蜜臀亚洲| 日本道精品一区二区三区| 成人在线综合网站| 精品在线观看视频| 伦理电影国产精品| 日韩电影在线免费观看| 欧美videos中文字幕| 51精品视频一区二区三区| 欧美在线短视频| 日本一道高清亚洲日美韩| 一区二区三区日本| 亚洲欧美日韩综合aⅴ视频| 国产三级精品视频| 国产亚洲综合色| 久久久www免费人成精品| 99精品久久99久久久久| 成人免费观看男女羞羞视频| 国产成人免费xxxxxxxx| 国产老肥熟一区二区三区| 国产一区二区在线视频| 久久精品国产99国产| 免费不卡在线观看| 免费成人结看片| 极品尤物av久久免费看| 国产乱色国产精品免费视频| 国产精品一区二区三区网站| 国产美女在线精品| 国产91富婆露脸刺激对白| 日韩在线a电影| 麻豆精品精品国产自在97香蕉| 日本aⅴ精品一区二区三区| 美国十次了思思久久精品导航| 美女任你摸久久| 狠狠狠色丁香婷婷综合久久五月| 激情综合色播激情啊| 国产激情精品久久久第一区二区 | 亚洲综合一区二区三区| 亚洲国产欧美在线人成| 日韩成人免费电影| 激情深爱一区二区| 99久久精品99国产精品| 欧美午夜精品一区二区三区| 欧美肥胖老妇做爰| 国产亚洲一区二区三区在线观看| 国产精品福利在线播放| 亚洲尤物在线视频观看| 免费欧美在线视频| 粉嫩av一区二区三区粉嫩| 欧美综合在线视频| 精品久久久久久久久久久久久久久久久 | 日本一二三不卡| 一区二区三区久久| 久久电影网电视剧免费观看| 成人午夜私人影院| 欧美日韩精品欧美日韩精品| 精品免费视频.| 亚洲色图一区二区| 久久99蜜桃精品| 91首页免费视频| 日韩免费一区二区| 亚洲精品va在线观看| 18成人在线观看| 日韩黄色片在线观看| 国产不卡高清在线观看视频| 欧美日韩在线综合| 国产日韩欧美电影| 午夜精品免费在线观看| 不卡av免费在线观看| 91精品国产一区二区| 久久久综合网站| 日韩成人一级大片| 色综合中文字幕| 成人动漫精品一区二区| 91麻豆精品国产91久久久资源速度| 欧美激情在线看| 蜜桃视频免费观看一区| 欧美性感一类影片在线播放| 国产偷国产偷精品高清尤物| 日韩福利电影在线观看| 高清成人免费视频| 欧美精品一区二区三区蜜桃视频 | 成人国产精品免费观看动漫| 欧美一区二区三区视频免费| 亚洲人妖av一区二区| 国产精品亚洲成人| 精品少妇一区二区三区日产乱码| 亚洲国产日韩在线一区模特| 99国产精品国产精品久久| 国产欧美视频在线观看| 激情综合五月婷婷| 日韩欧美国产麻豆| 蜜桃久久av一区| 欧美一区二区三级| 日本美女一区二区三区视频| 欧美视频一区二区三区四区| 亚洲男人的天堂在线观看| 99视频超级精品| 亚洲欧美中日韩| 99视频热这里只有精品免费| 国产精品久久99| 波多野结衣精品在线| 中文字幕欧美三区| 成人理论电影网| 国产精品国模大尺度视频| 大陆成人av片| 国产精品久久久久9999吃药|