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

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

?? etharp.c

?? LWIP源碼.rar
?? C
?? 第 1 頁 / 共 2 頁
字號:
/** * Updates the ARP table using the given IP packet. * * Uses the incoming IP packet's source address to update the * ARP cache for the local network. The function does not alter * or free the packet. This function must be called before the * packet p is passed to the IP layer. * * @param netif The lwIP network interface on which the IP packet pbuf arrived. * @param pbuf The IP packet that arrived on netif. * * @return NULL * * @see pbuf_free() */voidetharp_ip_input(struct netif *netif, struct pbuf *p){  struct ethip_hdr *hdr;  /* Only insert an entry if the source IP address of the     incoming IP packet comes from a host on the local network. */  hdr = p->payload;  /* source is not on the local network? */  if (!ip_addr_netcmp(&(hdr->ip.src), &(netif->ip_addr), &(netif->netmask))) {    /* do nothing */    return;  }  LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_ip_input: updating ETHARP table.\n"));  /* update ARP table */  /* @todo We could use ETHARP_TRY_HARD if we think we are going to talk   * back soon (for example, if the destination IP address is ours. */  update_arp_entry(netif, &(hdr->ip.src), &(hdr->eth.src), 0);}/** * Responds to ARP requests to us. Upon ARP replies to us, add entry to cache   * send out queued IP packets. Updates cache with snooped address pairs. * * Should be called for incoming ARP packets. The pbuf in the argument * is freed by this function. * * @param netif The lwIP network interface on which the ARP packet pbuf arrived. * @param pbuf The ARP packet that arrived on netif. Is freed by this function. * @param ethaddr Ethernet address of netif. * * @return NULL * * @see pbuf_free() */voidetharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p){  struct etharp_hdr *hdr;  /* these are aligned properly, whereas the ARP header fields might not be */  struct ip_addr sipaddr, dipaddr;  u8_t i;  u8_t for_us;  /* drop short ARP packets */  if (p->tot_len < sizeof(struct etharp_hdr)) {    LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 1, ("etharp_arp_input: packet dropped, too short (%d/%d)\n", p->tot_len, sizeof(struct etharp_hdr)));    pbuf_free(p);    return;  }  hdr = p->payload;   /* get aligned copies of addresses */  *(struct ip_addr2 *)&sipaddr = hdr->sipaddr;  *(struct ip_addr2 *)&dipaddr = hdr->dipaddr;  /* this interface is not configured? */  if (netif->ip_addr.addr == 0) {    for_us = 0;  } else {    /* ARP packet directed to us? */    for_us = ip_addr_cmp(&dipaddr, &(netif->ip_addr));  }  /* ARP message directed to us? */  if (for_us) {    /* add IP address in ARP cache; assume requester wants to talk to us.     * can result in directly sending the queued packets for this host. */    update_arp_entry(netif, &sipaddr, &(hdr->shwaddr), ETHARP_TRY_HARD);  /* ARP message not directed to us? */  } else {    /* update the source IP address in the cache, if present */    update_arp_entry(netif, &sipaddr, &(hdr->shwaddr), 0);  }  /* now act on the message itself */  switch (htons(hdr->opcode)) {  /* ARP request? */  case ARP_REQUEST:    /* ARP request. If it asked for our address, we send out a     * reply. In any case, we time-stamp any existing ARP entry,     * and possiby send out an IP packet that was queued on it. */    LWIP_DEBUGF (ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP request\n"));    /* ARP request for our address? */    if (for_us) {      LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: replying to ARP request for our IP address\n"));      /* re-use pbuf to send ARP reply */      hdr->opcode = htons(ARP_REPLY);      hdr->dipaddr = hdr->sipaddr;      hdr->sipaddr = *(struct ip_addr2 *)&netif->ip_addr;      for(i = 0; i < netif->hwaddr_len; ++i) {        hdr->dhwaddr.addr[i] = hdr->shwaddr.addr[i];        hdr->shwaddr.addr[i] = ethaddr->addr[i];        hdr->ethhdr.dest.addr[i] = hdr->dhwaddr.addr[i];        hdr->ethhdr.src.addr[i] = ethaddr->addr[i];      }      hdr->hwtype = htons(HWTYPE_ETHERNET);      ARPH_HWLEN_SET(hdr, netif->hwaddr_len);      hdr->proto = htons(ETHTYPE_IP);      ARPH_PROTOLEN_SET(hdr, sizeof(struct ip_addr));      hdr->ethhdr.type = htons(ETHTYPE_ARP);      /* return ARP reply */      netif->linkoutput(netif, p);    /* we are not configured? */    } else if (netif->ip_addr.addr == 0) {      /* { for_us == 0 and netif->ip_addr.addr == 0 } */      LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: we are unconfigured, ARP request ignored.\n"));    /* request was not directed to us */    } else {      /* { for_us == 0 and netif->ip_addr.addr != 0 } */      LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: ARP request was not for us.\n"));    }    break;  case ARP_REPLY:    /* ARP reply. We already updated the ARP cache earlier. */    LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP reply\n"));#if (LWIP_DHCP && DHCP_DOES_ARP_CHECK)    /* When unconfigured, DHCP wants to know about ARP replies from the     * address offered to us, as that means someone else uses it already! */    if (netif->ip_addr.addr == 0) dhcp_arp_reply(netif, &sipaddr);#endif    break;  default:    LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: ARP unknown opcode type %d\n", htons(hdr->opcode)));    break;  }  /* free ARP packet */  pbuf_free(p);}/** * Resolve and fill-in Ethernet address header for outgoing packet. * * For IP multicast and broadcast, corresponding Ethernet addresses * are selected and the packet is transmitted on the link. * * For unicast addresses, the packet is submitted to etharp_query(). In * case the IP address is outside the local network, the IP address of * the gateway is used. * * @param netif The lwIP network interface which the IP packet will be sent on. * @param ipaddr The IP address of the packet destination. * @param pbuf The pbuf(s) containing the IP packet to be sent. * * @return * - ERR_RTE No route to destination (no gateway to external networks), * or the return type of either etharp_query() or netif->linkoutput(). */err_tetharp_output(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q){  struct eth_addr *dest, *srcaddr, mcastaddr;  struct eth_hdr *ethhdr;  u8_t i;  /* make room for Ethernet header - should not fail */  if (pbuf_header(q, sizeof(struct eth_hdr)) != 0) {    /* bail out */    LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 2, ("etharp_output: could not allocate room for header.\n"));    LINK_STATS_INC(link.lenerr);    return ERR_BUF;  }  /* assume unresolved Ethernet address */  dest = NULL;  /* Determine on destination hardware address. Broadcasts and multicasts   * are special, other IP addresses are looked up in the ARP table. */  /* broadcast destination IP address? */  if (ip_addr_isbroadcast(ipaddr, netif)) {    /* broadcast on Ethernet also */    dest = (struct eth_addr *)&ethbroadcast;  /* multicast destination IP address? */  } else if (ip_addr_ismulticast(ipaddr)) {    /* Hash IP multicast address to MAC address.*/    mcastaddr.addr[0] = 0x01;    mcastaddr.addr[1] = 0x00;    mcastaddr.addr[2] = 0x5e;    mcastaddr.addr[3] = ip4_addr2(ipaddr) & 0x7f;    mcastaddr.addr[4] = ip4_addr3(ipaddr);    mcastaddr.addr[5] = ip4_addr4(ipaddr);    /* destination Ethernet address is multicast */    dest = &mcastaddr;  /* unicast destination IP address? */  } else {    /* outside local network? */    if (!ip_addr_netcmp(ipaddr, &(netif->ip_addr), &(netif->netmask))) {      /* interface has default gateway? */      if (netif->gw.addr != 0) {        /* send to hardware address of default gateway IP address */        ipaddr = &(netif->gw);      /* no default gateway available */      } else {        /* no route to destination error (default gateway missing) */        return ERR_RTE;      }    }    /* queue on destination Ethernet address belonging to ipaddr */    return etharp_query(netif, ipaddr, q);  }  /* continuation for multicast/broadcast destinations */  /* obtain source Ethernet address of the given interface */  srcaddr = (struct eth_addr *)netif->hwaddr;  ethhdr = q->payload;  for (i = 0; i < netif->hwaddr_len; i++) {    ethhdr->dest.addr[i] = dest->addr[i];    ethhdr->src.addr[i] = srcaddr->addr[i];  }  ethhdr->type = htons(ETHTYPE_IP);  /* send packet directly on the link */  return netif->linkoutput(netif, q);}/** * Send an ARP request for the given IP address and/or queue a packet. * * If the IP address was not yet in the cache, a pending ARP cache entry * is added and an ARP request is sent for the given address. The packet * is queued on this entry. * * If the IP address was already pending in the cache, a new ARP request * is sent for the given address. The packet is queued on this entry. * * If the IP address was already stable in the cache, and a packet is * given, it is directly sent and no ARP request is sent out.  *  * If the IP address was already stable in the cache, and no packet is * given, an ARP request is sent out. *  * @param netif The lwIP network interface on which ipaddr * must be queried for. * @param ipaddr The IP address to be resolved. * @param q If non-NULL, a pbuf that must be delivered to the IP address. * q is not freed by this function. * * @return * - ERR_BUF Could not make room for Ethernet header. * - ERR_MEM Hardware address unknown, and no more ARP entries available *   to query for address or queue the packet. * - ERR_MEM Could not queue packet due to memory shortage. * - ERR_RTE No route to destination (no gateway to external networks). * - ERR_ARG Non-unicast address given, those will not appear in ARP cache. * */err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q){  struct pbuf *p;  struct eth_addr * srcaddr = (struct eth_addr *)netif->hwaddr;  err_t result = ERR_MEM;  s8_t i; /* ARP entry index */  u8_t k; /* Ethernet address octet index */  /* non-unicast address? */  if (ip_addr_isbroadcast(ipaddr, netif) ||      ip_addr_ismulticast(ipaddr) ||      ip_addr_isany(ipaddr)) {    LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: will not add non-unicast IP address to ARP cache\n"));    return ERR_ARG;  }  /* find entry in ARP cache, ask to create entry if queueing packet */  i = find_entry(ipaddr, ETHARP_TRY_HARD);  /* could not find or create entry? */  if (i < 0)  {    LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: could not create ARP entry\n"));    if (q) LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: packet dropped\n"));    return (err_t)i;  }  /* mark a fresh entry as pending (we just sent a request) */  if (arp_table[i].state == ETHARP_STATE_EMPTY) {    arp_table[i].state = ETHARP_STATE_PENDING;  }  /* { i is either a STABLE or (new or existing) PENDING entry } */  LWIP_ASSERT("arp_table[i].state == PENDING or STABLE",  ((arp_table[i].state == ETHARP_STATE_PENDING) ||   (arp_table[i].state == ETHARP_STATE_STABLE)));  /* do we have a pending entry? or an implicit query request? */  if ((arp_table[i].state == ETHARP_STATE_PENDING) || (q == NULL)) {    /* try to resolve it; send out ARP request */    result = etharp_request(netif, ipaddr);  }    /* packet given? */  if (q != NULL) {    /* stable entry? */    if (arp_table[i].state == ETHARP_STATE_STABLE) {      /* we have a valid IP->Ethernet address mapping,       * fill in the Ethernet header for the outgoing packet */      struct eth_hdr *ethhdr = q->payload;      for(k = 0; k < netif->hwaddr_len; k++) {        ethhdr->dest.addr[k] = arp_table[i].ethaddr.addr[k];        ethhdr->src.addr[k]  = srcaddr->addr[k];      }      ethhdr->type = htons(ETHTYPE_IP);      LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: sending packet %p\n", (void *)q));      /* send the packet */      result = netif->linkoutput(netif, q);    /* pending entry? (either just created or already pending */    } else if (arp_table[i].state == ETHARP_STATE_PENDING) {#if ARP_QUEUEING /* queue the given q packet */      /* copy any PBUF_REF referenced payloads into PBUF_RAM */      /* (the caller of lwIP assumes the referenced payload can be       * freed after it returns from the lwIP call that brought us here) */      p = pbuf_take(q);      /* packet could be taken over? */      if (p != NULL) {        /* queue packet ... */        if (arp_table[i].p == NULL) {        	/* ... in the empty queue */        	pbuf_ref(p);        	arp_table[i].p = p;#if 0 /* multi-packet-queueing disabled, see bug #11400 */        } else {        	/* ... at tail of non-empty queue */          pbuf_queue(arp_table[i].p, p);#endif        }        LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: queued packet %p on ARP entry %d\n", (void *)q, i));        result = ERR_OK;      } else {        LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: could not queue a copy of PBUF_REF packet %p (out of memory)\n", (void *)q));        /* { result == ERR_MEM } through initialization */      }#else /* ARP_QUEUEING == 0 */      /* q && state == PENDING && ARP_QUEUEING == 0 => result = ERR_MEM */      /* { result == ERR_MEM } through initialization */      LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: Ethernet destination address unknown, queueing disabled, packet %p dropped\n", (void *)q));#endif    }  }  return result;}err_t etharp_request(struct netif *netif, struct ip_addr *ipaddr){  struct pbuf *p;  struct eth_addr * srcaddr = (struct eth_addr *)netif->hwaddr;  err_t result = ERR_OK;  u8_t k; /* ARP entry index */  /* allocate a pbuf for the outgoing ARP request packet */  p = pbuf_alloc(PBUF_LINK, sizeof(struct etharp_hdr), PBUF_RAM);  /* could allocate a pbuf for an ARP request? */  if (p != NULL) {    struct etharp_hdr *hdr = p->payload;    LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_request: sending ARP request.\n"));    hdr->opcode = htons(ARP_REQUEST);    for (k = 0; k < netif->hwaddr_len; k++)    {      hdr->shwaddr.addr[k] = srcaddr->addr[k];      /* the hardware address is what we ask for, in       * a request it is a don't-care value, we use zeroes */      hdr->dhwaddr.addr[k] = 0x00;    }    hdr->dipaddr = *(struct ip_addr2 *)ipaddr;    hdr->sipaddr = *(struct ip_addr2 *)&netif->ip_addr;    hdr->hwtype = htons(HWTYPE_ETHERNET);    ARPH_HWLEN_SET(hdr, netif->hwaddr_len);    hdr->proto = htons(ETHTYPE_IP);    ARPH_PROTOLEN_SET(hdr, sizeof(struct ip_addr));    for (k = 0; k < netif->hwaddr_len; ++k)    {      /* broadcast to all network interfaces on the local network */      hdr->ethhdr.dest.addr[k] = 0xff;      hdr->ethhdr.src.addr[k] = srcaddr->addr[k];    }    hdr->ethhdr.type = htons(ETHTYPE_ARP);    /* send ARP query */    result = netif->linkoutput(netif, p);    /* free ARP query packet */    pbuf_free(p);    p = NULL;  /* could not allocate pbuf for ARP request */  } else {    result = ERR_MEM;    LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 2, ("etharp_request: could not allocate pbuf for ARP request.\n"));  }  return result;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品情趣视频| 国产日韩一级二级三级| 91精品国产黑色紧身裤美女| 国产精品污www在线观看| 亚洲国产视频一区二区| 成人午夜av电影| 日韩免费电影网站| 亚洲图片有声小说| 色综合一区二区三区| 国产亚洲精品久| 久久99精品久久久久| 欧美精品一卡二卡| 亚洲福利一二三区| 91福利在线观看| 亚洲欧洲无码一区二区三区| 久久色成人在线| 成人涩涩免费视频| 欧美日韩免费在线视频| 国产清纯在线一区二区www| 奇米四色…亚洲| 欧美日韩一二区| 亚洲一区二区三区三| 成人网在线播放| 国产片一区二区| 成人免费的视频| 欧美国产日韩在线观看| 粉嫩av一区二区三区| 亚洲卡通欧美制服中文| 欧美日韩国产另类不卡| 久久久久久黄色| 激情欧美一区二区| 久久天堂av综合合色蜜桃网| 久久99久久99| 久久久综合精品| 国产精品888| 国产精品久久久久久久第一福利 | 欧美日韩午夜精品| 亚洲精品一二三四区| 91国偷自产一区二区使用方法| 伊人色综合久久天天人手人婷| 欧美三级一区二区| 三级久久三级久久久| 久久综合久久综合九色| 成人在线视频一区二区| 亚洲免费色视频| 欧美男生操女生| 久久超碰97人人做人人爱| 久久先锋影音av鲁色资源| 国产99精品视频| 玉米视频成人免费看| 91精品在线免费| 国产成人综合在线观看| 亚洲色图制服诱惑| 欧美一区中文字幕| 国产sm精品调教视频网站| 亚洲人成网站色在线观看| 欧美日本在线看| 风间由美中文字幕在线看视频国产欧美| 国产精品萝li| 日韩一区二区三区三四区视频在线观看 | 中文字幕一区二区三区在线不卡| www久久精品| 91在线观看高清| 男男视频亚洲欧美| 国产精品欧美精品| 欧美一区二区视频在线观看2022 | 8x8x8国产精品| 国产91精品一区二区麻豆亚洲| 亚洲精品国产无套在线观| 日韩欧美一卡二卡| 91影院在线观看| 久久99国产精品久久| 亚洲免费视频中文字幕| 337p粉嫩大胆噜噜噜噜噜91av| 日本二三区不卡| 国产精品一区二区免费不卡 | 欧美日本视频在线| 懂色av中文一区二区三区| 亚洲成人av免费| 国产精品网站在线| 日韩午夜电影在线观看| 一本到三区不卡视频| 国产盗摄女厕一区二区三区| 日日摸夜夜添夜夜添精品视频 | 欧美体内she精视频| 国产精品一二二区| 蜜臀av一区二区| 亚洲成人福利片| 1区2区3区精品视频| 久久精品亚洲一区二区三区浴池| 69堂成人精品免费视频| 91丨porny丨国产入口| 国产成人精品免费在线| 精品影视av免费| 美女高潮久久久| 奇米色777欧美一区二区| 亚洲成人av一区二区三区| 亚洲天堂av老司机| 中文字幕一区二区三区av| 久久久久久久久久久久久久久99| 日韩一区二区免费在线观看| 欧美区在线观看| 欧美性大战久久久久久久蜜臀| av欧美精品.com| 狠狠色狠狠色合久久伊人| 日韩精品福利网| 日韩精品三区四区| 日韩高清欧美激情| 青青草国产精品97视觉盛宴| 亚洲第一av色| 日韩av中文字幕一区二区三区| 亚洲国产综合在线| 调教+趴+乳夹+国产+精品| 午夜成人免费电影| 日韩综合一区二区| 久久99国产精品免费网站| 韩国在线一区二区| 国产精品1区2区3区在线观看| 国产91在线观看| 成人黄页毛片网站| 在线一区二区三区四区五区| 精品视频在线免费| 欧美一区二区私人影院日本| 精品国产免费一区二区三区四区| 精品不卡在线视频| 中文字幕中文乱码欧美一区二区| 亚洲色图欧美偷拍| 午夜亚洲国产au精品一区二区| 日韩黄色片在线观看| 国产一区二区三区精品视频| 高清不卡一二三区| 91年精品国产| 56国语精品自产拍在线观看| 日韩丝袜美女视频| 国产精品色一区二区三区| 樱花影视一区二区| 久久精品国产**网站演员| 国产成人在线免费观看| 91黄色免费观看| 精品国产精品一区二区夜夜嗨| 中文字幕欧美三区| 性感美女极品91精品| 国产九色精品成人porny| 97超碰欧美中文字幕| 欧美一级免费大片| 中文字幕国产一区| 天天综合色天天| 国产成人在线视频免费播放| 欧美午夜精品一区二区蜜桃| 欧美精品一区二区久久久| 亚洲精品一二三区| 国产精品一区二区男女羞羞无遮挡| 色狠狠桃花综合| 久久久综合网站| 香蕉av福利精品导航| 粗大黑人巨茎大战欧美成人| 9191国产精品| 亚洲色图在线看| 国产精选一区二区三区| 欧美日韩免费不卡视频一区二区三区 | 综合网在线视频| 久久99久久精品| 欧美日韩一区高清| 国产精品久久久久久久第一福利| 美女网站视频久久| 欧美亚洲综合另类| 国产精品第一页第二页第三页| 美女国产一区二区三区| 欧美午夜精品久久久| 国产精品视频第一区| 久久精品国产免费| 欧美日韩精品三区| 亚洲欧美激情插| 成人永久aaa| www国产精品av| 蜜臀av在线播放一区二区三区| 91麻豆福利精品推荐| 国产精品色婷婷久久58| 国产麻豆日韩欧美久久| 欧美一级午夜免费电影| 亚洲国产成人高清精品| 色婷婷亚洲婷婷| 椎名由奈av一区二区三区| 成人做爰69片免费看网站| 久久女同精品一区二区| 久久99精品久久久久| 日韩一级免费观看| 日韩成人精品在线观看| 在线播放/欧美激情| 亚洲二区在线视频| 欧美日韩国产精选| 午夜视频在线观看一区二区| 欧美色欧美亚洲另类二区| 亚洲在线免费播放| 欧美三级电影精品| 亚洲国产成人tv| 欧美放荡的少妇| 免费成人在线视频观看| 日韩美女天天操| 久久99久久久欧美国产|