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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? etharp.c

?? ARM7的一些試驗程序
?? C
?? 第 1 頁 / 共 3 頁
字號:
  {
  	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 %d\n", 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 %d\n", 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 %d (without queue)\n", 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 %d, freeing packet queue %p\n", 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_t
update_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: %u.%u.%u.%u - %02x:%02x:%02x:%02x:%02x:%02x\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 %u\n", 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.
 *
 * 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()
 */
void
etharp_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()
 */
void
etharp_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;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
不卡欧美aaaaa| 欧美日韩电影一区| 欧美日韩成人高清| 2017欧美狠狠色| 一区二区三区中文字幕电影| 韩国成人精品a∨在线观看| 91免费版在线看| 久久一日本道色综合| 日韩精品欧美成人高清一区二区| 福利电影一区二区三区| 91精品久久久久久久久99蜜臂| 中文在线资源观看网站视频免费不卡| 午夜影院在线观看欧美| www.视频一区| 久久精品日产第一区二区三区高清版| 亚洲国产精品久久艾草纯爱| 国产精品中文欧美| 日韩精品一区二区三区四区视频 | 日韩美女在线视频| 亚洲一区在线视频| 91在线精品一区二区三区| 久久一区二区视频| 久久不见久久见中文字幕免费| 欧美系列亚洲系列| 一区二区三区日韩欧美| av一区二区三区在线| 国产亚洲精久久久久久| 精品在线播放午夜| 日韩美女一区二区三区| 久久国产精品72免费观看| 宅男在线国产精品| 日本不卡高清视频| 欧美tk丨vk视频| 蜜臀91精品一区二区三区| 欧美一区二区三区婷婷月色| 亚洲中国最大av网站| 欧美伊人久久久久久久久影院| 一区二区三区中文在线| 欧美无人高清视频在线观看| 亚洲一区中文日韩| 3751色影院一区二区三区| 视频一区在线视频| 日韩一区二区三区高清免费看看| 日本色综合中文字幕| 日韩一区二区三区免费看 | 亚洲图片激情小说| 91婷婷韩国欧美一区二区| 亚洲少妇最新在线视频| 欧美性做爰猛烈叫床潮| 日韩不卡免费视频| 欧美精品一区二区久久婷婷| 国产不卡视频在线观看| 亚洲欧洲一区二区在线播放| 一本大道久久a久久精品综合| 夜色激情一区二区| 91精品国产91热久久久做人人| 蜜臀99久久精品久久久久久软件 | 这里只有精品免费| 国产一区二区久久| 中文字幕在线观看一区| 欧美视频中文一区二区三区在线观看 | 免费观看一级欧美片| 日韩一级完整毛片| 国产一区二区美女| 亚洲欧美激情一区二区| 欧美亚一区二区| 韩日精品视频一区| 专区另类欧美日韩| 欧美一区二区三区爱爱| 风间由美一区二区三区在线观看| 一区二区三区国产| 欧美精品一区二区三区在线播放| 99综合电影在线视频| 五月激情综合色| 精品福利av导航| 在线观看日韩精品| 国产精品一色哟哟哟| 亚洲综合激情另类小说区| 久久―日本道色综合久久| 91久久精品日日躁夜夜躁欧美| 日本强好片久久久久久aaa| 欧美国产一区二区在线观看| 欧美日韩国产免费| 丁香婷婷综合激情五月色| 国内精品自线一区二区三区视频| 亚洲美女一区二区三区| 精品播放一区二区| 欧美日韩亚洲丝袜制服| 成人黄色电影在线| 麻豆久久久久久久| 亚洲国产欧美日韩另类综合| 中文字幕精品一区| 欧美一区二区三区四区五区 | 在线播放欧美女士性生活| 成人一区二区视频| 久久电影国产免费久久电影| 性做久久久久久| 亚洲欧美激情视频在线观看一区二区三区| 欧美一区二区三区性视频| 欧美色综合天天久久综合精品| 不卡的av电影在线观看| 国产高清久久久| 开心九九激情九九欧美日韩精美视频电影 | 国产成人综合精品三级| 日本欧美一区二区| 午夜视频一区在线观看| 亚洲精品免费在线| 国产欧美一区二区精品久导航| 欧美亚洲综合一区| 一区二区在线观看av| 国产精品免费av| 国产精品天干天干在观线| 精品国产乱码久久久久久浪潮| 日韩欧美在线1卡| 欧美一级日韩不卡播放免费| 欧美日韩黄视频| 欧美日韩国产综合草草| 欧美日本韩国一区二区三区视频 | 国产视频一区二区三区在线观看| 欧美α欧美αv大片| 日韩欧美中文字幕精品| 日韩一区二区三区视频| 日韩精品一区二区三区在线观看| 日韩视频不卡中文| 精品裸体舞一区二区三区| 精品欧美一区二区在线观看| 精品三级在线观看| 精品久久久久久亚洲综合网| 精品精品欲导航| 国产亚洲精品中文字幕| 国产精品欧美极品| 洋洋av久久久久久久一区| 丝袜亚洲另类欧美综合| 青青草原综合久久大伊人精品| 日本aⅴ免费视频一区二区三区| 奇米精品一区二区三区四区| 久久丁香综合五月国产三级网站| 国产精品综合一区二区| 成人黄色一级视频| 91高清在线观看| 91精品婷婷国产综合久久竹菊| 日韩一区二区免费电影| 欧美高清在线精品一区| 亚洲欧美视频在线观看| 亚洲成国产人片在线观看| 蜜桃免费网站一区二区三区| 国产成人精品免费看| 色女孩综合影院| 制服丝袜av成人在线看| 久久久精品人体av艺术| 亚洲日本在线视频观看| 秋霞国产午夜精品免费视频 | 亚洲高清视频在线| 久久精品国产999大香线蕉| 不卡视频一二三| 6080国产精品一区二区| 中文字幕乱码久久午夜不卡| 亚洲成人中文在线| 国内偷窥港台综合视频在线播放| 成人高清视频在线| 欧美精品1区2区3区| 国产精品动漫网站| 三级久久三级久久久| va亚洲va日韩不卡在线观看| 91精品午夜视频| 亚洲黄色av一区| 国内精品嫩模私拍在线| 欧洲精品视频在线观看| 国产人久久人人人人爽| 日精品一区二区| 色系网站成人免费| 国产婷婷精品av在线| 青青草国产精品亚洲专区无| 91热门视频在线观看| 精品sm捆绑视频| 日韩avvvv在线播放| 欧美在线观看一区二区| 国产精品嫩草久久久久| 美美哒免费高清在线观看视频一区二区 | 亚洲综合一二区| 粉嫩av亚洲一区二区图片| 91精品欧美综合在线观看最新| 亚洲激情校园春色| 国产成人精品免费| 久久免费的精品国产v∧| 久久爱www久久做| 日韩欧美一区电影| 偷拍亚洲欧洲综合| 欧美在线高清视频| 亚洲欧美国产高清| 91污片在线观看| 18涩涩午夜精品.www| 国产盗摄视频一区二区三区| 日韩精品一区二区三区视频播放| 午夜影院久久久| 在线播放中文一区| 日韩av成人高清| 欧美大胆人体bbbb| 国产自产高清不卡| 久久久亚洲国产美女国产盗摄|