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

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

?? etharp.c

?? STR71X源代碼包括例程與各功能的源代碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
  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_t
etharp_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一区二区三区免费野_久草精品视频
欧美亚洲高清一区| 26uuu亚洲| 日本精品裸体写真集在线观看| 精品美女被调教视频大全网站| 婷婷综合久久一区二区三区| 欧美午夜一区二区| 午夜精品在线看| 日韩一区二区视频| 国产一区二区免费在线| 国产精品麻豆久久久| 成人av在线电影| 亚洲人被黑人高潮完整版| 欧美日韩一区三区四区| 免费日韩伦理电影| 中文字幕第一区第二区| 色综合天天综合色综合av| 亚洲一区二区在线视频| 日韩午夜电影av| 成人黄色小视频| 亚洲国产精品综合小说图片区| 欧美刺激脚交jootjob| 国产v日产∨综合v精品视频| 亚洲欧美日韩系列| 日韩精品一区二区三区视频播放 | 日产国产高清一区二区三区| 日韩一区二区麻豆国产| 成人蜜臀av电影| 午夜在线成人av| 欧美国产日本视频| 在线观看91精品国产麻豆| 成人av网址在线| 日本v片在线高清不卡在线观看| 国产精品天天摸av网| 欧美视频你懂的| 成人精品国产一区二区4080 | 亚洲成人免费视| 国产日韩亚洲欧美综合| 欧美色综合网站| 国产综合久久久久久鬼色| 亚洲在线视频免费观看| ww亚洲ww在线观看国产| 欧美丝袜自拍制服另类| 成人小视频在线观看| 三级精品在线观看| 亚洲精品免费一二三区| 国产亚洲成年网址在线观看| 91精品国产综合久久久久久| 色综合天天综合色综合av | 国产精品久久久久久久岛一牛影视 | 亚洲精品日韩综合观看成人91| 欧美亚一区二区| 亚洲成人在线网站| 成人av在线一区二区三区| 午夜精品成人在线视频| 中文字幕一区二区三区不卡| 精品日韩成人av| 日韩一区二区电影| 欧美撒尿777hd撒尿| 91丨porny丨首页| 国产成人在线视频网站| 麻豆精品一二三| 日本三级亚洲精品| 亚洲动漫第一页| 亚洲黄色录像片| 国产精品久久久久久久久免费相片 | 亚洲丝袜美腿综合| 中文字幕欧美三区| 中文字幕不卡一区| 久久精品亚洲精品国产欧美kt∨| 91精品国产综合久久久蜜臀粉嫩 | 制服丝袜亚洲播放| 欧美日韩国产一级二级| 在线精品国精品国产尤物884a| 91免费观看视频| 91蜜桃网址入口| 一本大道久久a久久精二百| 9久草视频在线视频精品| 成人小视频在线观看| 成人午夜激情片| 99视频一区二区| 色综合天天性综合| 色婷婷狠狠综合| 欧美体内she精高潮| 欧美亚洲一区三区| 欧美日韩视频在线一区二区| 欧美另类高清zo欧美| 欧美一二三区在线观看| 欧美成人欧美edvon| 久久久久国产精品麻豆ai换脸 | 亚洲自拍偷拍网站| 亚洲与欧洲av电影| 日韩中文字幕av电影| 美脚の诱脚舐め脚责91| 国产一区二区美女| 国产a级毛片一区| 日本精品一区二区三区高清| 欧美日韩国产经典色站一区二区三区 | 婷婷中文字幕综合| 麻豆成人久久精品二区三区红| 激情五月激情综合网| 大白屁股一区二区视频| 色中色一区二区| 欧美一区二区网站| 国产视频一区不卡| 亚洲综合成人网| 狠狠色综合播放一区二区| 成人网页在线观看| 欧美美女直播网站| 国产日韩欧美制服另类| 亚洲精品国产高清久久伦理二区| 日韩精品亚洲一区二区三区免费| 国产一区二区日韩精品| 欧美亚洲自拍偷拍| 久久久亚洲精华液精华液精华液| 亚洲素人一区二区| 奇米精品一区二区三区在线观看一| 国产成人综合精品三级| 欧美日韩免费不卡视频一区二区三区| 日韩一区二区在线观看视频| 国产精品私人自拍| 免费成人小视频| 色综合网色综合| 国产午夜精品一区二区三区视频| 亚洲一区二区高清| 国产成人综合视频| 欧美一区二区三区在线视频 | 欧美午夜在线观看| 久久精品网站免费观看| 亚洲成a人片在线观看中文| 国产精品 日产精品 欧美精品| 欧美优质美女网站| 国产欧美日韩精品一区| 日本亚洲视频在线| 日本韩国欧美三级| 国产欧美日韩精品在线| 日韩高清欧美激情| 色综合久久久久| 国产精品国产馆在线真实露脸 | 日韩中文字幕一区二区三区| 色综合天天狠狠| 国产午夜精品理论片a级大结局| 日韩电影在线观看一区| 一本色道综合亚洲| 国产亚洲视频系列| 免费人成网站在线观看欧美高清| 色综合中文综合网| 亚洲黄网站在线观看| 成人一区二区在线观看| 2023国产一二三区日本精品2022| 亚洲小说欧美激情另类| bt欧美亚洲午夜电影天堂| 亚洲三级久久久| 粉嫩av一区二区三区| 精品国产乱码久久久久久免费| 午夜精品一区二区三区免费视频 | 7777精品伊人久久久大香线蕉超级流畅 | 国产一区二区三区黄视频 | 欧美艳星brazzers| ●精品国产综合乱码久久久久| 国产成都精品91一区二区三| 久久精品亚洲精品国产欧美kt∨ | 欧美精品日日鲁夜夜添| 亚洲第一狼人社区| 欧美色偷偷大香| 亚洲国产视频一区| 欧美人xxxx| 另类小说视频一区二区| 精品区一区二区| 国产精品一区一区| 久久久99精品久久| 成人午夜激情视频| 亚洲精品视频在线观看免费| 91麻豆国产自产在线观看| 日韩毛片精品高清免费| 色婷婷精品久久二区二区蜜臀av| 亚洲久本草在线中文字幕| 在线看国产一区| 亚洲va天堂va国产va久| 欧美电影在哪看比较好| 久久国产人妖系列| 久久久精品tv| 91麻豆国产福利在线观看| 亚洲一区二区三区国产| 91精品综合久久久久久| 久久国产福利国产秒拍| 国产视频一区在线观看| 91免费版在线| 日日夜夜精品视频免费| 精品国产麻豆免费人成网站| 粉嫩高潮美女一区二区三区| 亚洲国产高清在线| 欧美色视频在线| 激情综合网av| 亚洲色图制服丝袜| 91精品黄色片免费大全| 国产高清视频一区| 亚洲资源在线观看| 欧美大片日本大片免费观看| eeuss鲁片一区二区三区在线看| 亚洲综合图片区|