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

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

?? etharp.c

?? ARM7的一些試驗程序
?? 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一区二区三区免费野_久草精品视频
www欧美成人18+| 91免费看视频| 日韩欧美国产不卡| 久久99国产精品成人| 久久精品一区二区三区av| 国产a区久久久| 欧美激情在线看| 色天天综合久久久久综合片| 一级日本不卡的影视| 欧美日韩一区二区三区四区 | 国产亚洲综合在线| 91在线你懂得| 亚洲国产欧美在线人成| 日韩免费视频一区| av中文字幕一区| 高潮精品一区videoshd| |精品福利一区二区三区| 欧美手机在线视频| 国产乱人伦精品一区二区在线观看 | 婷婷丁香久久五月婷婷| 久久久久久电影| 色综合久久88色综合天天| 奇米精品一区二区三区四区| 国产视频一区不卡| 欧美体内she精视频| 麻豆精品蜜桃视频网站| 国产精品久久久久久久岛一牛影视| 在线这里只有精品| 国产一区二区三区久久久| 自拍偷拍亚洲综合| 欧美一级国产精品| 99久久亚洲一区二区三区青草| 婷婷综合五月天| 亚洲欧洲另类国产综合| 欧美一区二区不卡视频| www.日本不卡| 国产一区二区三区免费看| 亚洲永久免费视频| 日本一区二区三区视频视频| 欧美视频完全免费看| 国产精品一区三区| 天堂资源在线中文精品| 国产精品久久久久久久久免费樱桃| 欧美精品色一区二区三区| 成人手机电影网| 九九精品一区二区| 午夜精品久久久久久久蜜桃app| 国产精品私房写真福利视频| 制服丝袜日韩国产| 在线免费观看成人短视频| 国产毛片精品国产一区二区三区| 亚洲综合色成人| 一区精品在线播放| 久久久不卡网国产精品一区| 欧美一区日韩一区| 欧美日本一区二区三区四区| 91激情五月电影| 99国产精品久久久久久久久久久| 国产中文字幕一区| 免费成人在线网站| 男人的天堂久久精品| 天天综合日日夜夜精品| 亚洲一区二区四区蜜桃| 亚洲免费av高清| 国产精品嫩草影院av蜜臀| 久久久久久久免费视频了| 欧美成人综合网站| 日韩视频永久免费| 日韩一区二区免费视频| 日韩视频在线永久播放| 精品少妇一区二区三区免费观看| 337p亚洲精品色噜噜| 欧美日本一区二区在线观看| 欧美日韩激情一区| 在线播放亚洲一区| 91精品国产免费久久综合| 欧美日韩国产区一| 欧美一级理论性理论a| 欧美日韩三级在线| 欧美一区二区三区影视| 日韩欧美一二三| 欧美电影免费观看完整版| 精品日韩一区二区三区| 亚洲精品在线观看网站| 26uuu欧美| 国产欧美视频一区二区三区| 国产欧美视频一区二区| 亚洲色图清纯唯美| 亚洲一区二区三区四区五区黄 | 欧美高清视频不卡网| 欧美二区乱c少妇| 日韩你懂的电影在线观看| 久久影院午夜片一区| 欧美国产日韩亚洲一区| 亚洲欧美日韩久久| 丝袜美腿亚洲综合| 黑人巨大精品欧美黑白配亚洲| 国产成人精品网址| 色94色欧美sute亚洲线路一久| 精品污污网站免费看| 日韩一区二区三区三四区视频在线观看| 精品久久五月天| 亚洲视频图片小说| 日韩精品一级二级| 国产电影一区在线| 欧美专区日韩专区| 欧美大片免费久久精品三p| 国产免费观看久久| 亚洲香肠在线观看| 国产专区综合网| 欧洲亚洲精品在线| 欧美va亚洲va在线观看蝴蝶网| 国产精品免费视频网站| 日韩精品三区四区| 国产成人精品三级麻豆| 欧美专区日韩专区| 久久久不卡网国产精品一区| 亚洲乱码中文字幕| 精品夜夜嗨av一区二区三区| 91首页免费视频| 91精品国产福利在线观看| 国产片一区二区| 日韩中文字幕一区二区三区| 成人在线一区二区三区| 欧美丰满美乳xxx高潮www| 国产精品全国免费观看高清| 性欧美疯狂xxxxbbbb| 成人黄色在线网站| 欧美mv日韩mv亚洲| 一区二区三区四区亚洲| 国产乱色国产精品免费视频| 欧美日韩成人在线| 亚洲精选视频在线| 国产一区二区三区在线看麻豆| 欧美日韩在线播放| 亚洲欧洲av在线| 国产综合成人久久大片91| 欧美日韩www| 亚洲午夜久久久| gogo大胆日本视频一区| 久久综合久久综合久久综合| 日本成人在线网站| 色欧美乱欧美15图片| 国产精品美女久久久久久久久| 激情五月激情综合网| 欧美精品vⅰdeose4hd| 亚洲人成在线观看一区二区| 韩国欧美国产一区| 日韩视频免费观看高清完整版 | 国产**成人网毛片九色 | 成人性视频网站| 久久精品人人做| 韩国成人精品a∨在线观看| 欧美日韩午夜精品| 亚洲一区二区三区免费视频| 99在线精品观看| 国产精品久久精品日日| 成人动漫视频在线| 国产精品乱人伦中文| 岛国一区二区三区| 中文字幕成人av| 99久久精品免费| 中文字幕制服丝袜一区二区三区 | 精品少妇一区二区三区免费观看| 天堂久久久久va久久久久| 在线电影国产精品| 日韩高清一区在线| 制服丝袜亚洲网站| 久久激五月天综合精品| 精品久久久久一区二区国产| 麻豆国产精品777777在线| 91麻豆精品国产91久久久久久久久 | 91麻豆精东视频| 1024国产精品| 色综合天天狠狠| 亚洲综合激情另类小说区| 欧美亚洲精品一区| 日韩中文字幕一区二区三区| 欧美一级免费大片| 韩国一区二区三区| 国产精品天美传媒| 色又黄又爽网站www久久| 亚洲自拍欧美精品| 91精品国模一区二区三区| 精品一区二区三区在线观看国产| 精品捆绑美女sm三区| 风间由美一区二区av101| 亚洲天堂中文字幕| 在线91免费看| 国产又黄又大久久| 亚洲免费观看视频| 91.com在线观看| 国产精品一品二品| 亚洲精品videosex极品| 日韩一区二区视频在线观看| 成人午夜精品一区二区三区| 亚洲免费色视频| 欧美成人精品3d动漫h| 国产成人啪午夜精品网站男同| 亚洲视频中文字幕|