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

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

?? ip6.c

?? stm32+ucos-ii
?? C
字號:
/*
 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
 * 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.
 *
 * Author: Adam Dunkels <adam@sics.se>
 *
 */



/* ip.c
 *
 * This is the code for the IP layer for IPv6.
 *
 */


#include "lwip/opt.h"

#include "lwip/def.h"
#include "lwip/mem.h"
#include "lwip/ip.h"
#include "lwip/inet.h"
#include "lwip/netif.h"
#include "lwip/icmp.h"
#include "lwip/udp.h"
#include "lwip/tcp.h"

#include "lwip/stats.h"

#include "arch/perf.h"

/* ip_init:
 *
 * Initializes the IP layer.
 */

void
ip_init(void)
{
}

/* ip_route:
 *
 * Finds the appropriate network interface for a given IP address. It searches the
 * list of network interfaces linearly. A match is found if the masked IP address of
 * the network interface equals the masked IP address given to the function.
 */

struct netif *
ip_route(struct ip_addr *dest)
{
  struct netif *netif;

  for(netif = netif_list; netif != NULL; netif = netif->next) {
    if (ip_addr_netcmp(dest, &(netif->ip_addr), &(netif->netmask))) {
      return netif;
    }
  }

  return netif_default;
}

/* ip_forward:
 *
 * Forwards an IP packet. It finds an appropriate route for the packet, decrements
 * the TTL value of the packet, adjusts the checksum and outputs the packet on the
 * appropriate interface.
 */

static void
ip_forward(struct pbuf *p, struct ip_hdr *iphdr)
{
  struct netif *netif;

  PERF_START;

  if ((netif = ip_route((struct ip_addr *)&(iphdr->dest))) == NULL) {

    LWIP_DEBUGF(IP_DEBUG, ("ip_input: no forwarding route found for "));
#if IP_DEBUG
    ip_addr_debug_print(IP_DEBUG, ((struct ip_addr *)&(iphdr->dest)));
#endif /* IP_DEBUG */
    LWIP_DEBUGF(IP_DEBUG, ("\n"));
    pbuf_free(p);
    return;
  }
  /* Decrement TTL and send ICMP if ttl == 0. */
  if (--iphdr->hoplim == 0) {
#if LWIP_ICMP
    /* Don't send ICMP messages in response to ICMP messages */
    if (iphdr->nexthdr != IP_PROTO_ICMP) {
      icmp_time_exceeded(p, ICMP_TE_TTL);
    }
#endif /* LWIP_ICMP */
    pbuf_free(p);
    return;
  }

  /* Incremental update of the IP checksum. */
  /*  if (iphdr->chksum >= htons(0xffff - 0x100)) {
    iphdr->chksum += htons(0x100) + 1;
  } else {
    iphdr->chksum += htons(0x100);
    }*/


  LWIP_DEBUGF(IP_DEBUG, ("ip_forward: forwarding packet to "));
#if IP_DEBUG
  ip_addr_debug_print(IP_DEBUG, ((struct ip_addr *)&(iphdr->dest)));
#endif /* IP_DEBUG */
  LWIP_DEBUGF(IP_DEBUG, ("\n"));

  IP_STATS_INC(ip.fw);
  IP_STATS_INC(ip.xmit);

  PERF_STOP("ip_forward");

  netif->output(netif, p, (struct ip_addr *)&(iphdr->dest));
}

/* ip_input:
 *
 * This function is called by the network interface device driver when an IP packet is
 * received. The function does the basic checks of the IP header such as packet size
 * being at least larger than the header size etc. If the packet was not destined for
 * us, the packet is forwarded (using ip_forward). The IP checksum is always checked.
 *
 * Finally, the packet is sent to the upper layer protocol input function.
 */

void
ip_input(struct pbuf *p, struct netif *inp) {
  struct ip_hdr *iphdr;
  struct netif *netif;


  PERF_START;

#if IP_DEBUG
  ip_debug_print(p);
#endif /* IP_DEBUG */


  IP_STATS_INC(ip.recv);

  /* identify the IP header */
  iphdr = p->payload;


  if (iphdr->v != 6) {
    LWIP_DEBUGF(IP_DEBUG, ("IP packet dropped due to bad version number\n"));
#if IP_DEBUG
    ip_debug_print(p);
#endif /* IP_DEBUG */
    pbuf_free(p);
    IP_STATS_INC(ip.err);
    IP_STATS_INC(ip.drop);
    return;
  }

  /* is this packet for us? */
  for(netif = netif_list; netif != NULL; netif = netif->next) {
#if IP_DEBUG
    LWIP_DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest "));
    ip_addr_debug_print(IP_DEBUG, ((struct ip_addr *)&(iphdr->dest)));
    LWIP_DEBUGF(IP_DEBUG, ("netif->ip_addr "));
    ip_addr_debug_print(IP_DEBUG, ((struct ip_addr *)&(iphdr->dest)));
    LWIP_DEBUGF(IP_DEBUG, ("\n"));
#endif /* IP_DEBUG */
    if (ip_addr_cmp(&(iphdr->dest), &(netif->ip_addr))) {
      break;
    }
  }


  if (netif == NULL) {
    /* packet not for us, route or discard */
#if IP_FORWARD
    ip_forward(p, iphdr);
#endif
    pbuf_free(p);
    return;
  }

  pbuf_realloc(p, IP_HLEN + ntohs(iphdr->len));

  /* send to upper layers */
#if IP_DEBUG
  /*  LWIP_DEBUGF("ip_input: \n");
  ip_debug_print(p);
  LWIP_DEBUGF("ip_input: p->len %"U16_F" p->tot_len %"U16_F"\n", p->len, p->tot_len);*/
#endif /* IP_DEBUG */

  if(pbuf_header(p, -IP_HLEN)) {
    LWIP_ASSERT("Can't move over header in packet", 0);
    return;
  }

  switch (iphdr->nexthdr) {
  case IP_PROTO_UDP:
    udp_input(p, inp);
    break;
  case IP_PROTO_TCP:
    tcp_input(p, inp);
    break;
#if LWIP_ICMP
  case IP_PROTO_ICMP:
    icmp_input(p, inp);
    break;
#endif /* LWIP_ICMP */
  default:
#if LWIP_ICMP
    /* send ICMP destination protocol unreachable */
    icmp_dest_unreach(p, ICMP_DUR_PROTO);
#endif /* LWIP_ICMP */
    pbuf_free(p);
    LWIP_DEBUGF(IP_DEBUG, ("Unsupported transport protocol %"U16_F"\n",
          iphdr->nexthdr));

    IP_STATS_INC(ip.proterr);
    IP_STATS_INC(ip.drop);
  }
  PERF_STOP("ip_input");
}


/* ip_output_if:
 *
 * Sends an IP packet on a network interface. This function constructs the IP header
 * and calculates the IP header checksum. If the source IP address is NULL,
 * the IP address of the outgoing network interface is filled in as source address.
 */

err_t
ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
       u8_t ttl,
       u8_t proto, struct netif *netif)
{
  struct ip_hdr *iphdr;

  PERF_START;

  LWIP_DEBUGF(IP_DEBUG, ("len %"U16_F" tot_len %"U16_F"\n", p->len, p->tot_len));
  if (pbuf_header(p, IP_HLEN)) {
    LWIP_DEBUGF(IP_DEBUG, ("ip_output: not enough room for IP header in pbuf\n"));
    IP_STATS_INC(ip.err);

    return ERR_BUF;
  }
  LWIP_DEBUGF(IP_DEBUG, ("len %"U16_F" tot_len %"U16_F"\n", p->len, p->tot_len));

  iphdr = p->payload;


  if (dest != IP_HDRINCL) {
    LWIP_DEBUGF(IP_DEBUG, ("!IP_HDRLINCL\n"));
    iphdr->hoplim = ttl;
    iphdr->nexthdr = proto;
    iphdr->len = htons(p->tot_len - IP_HLEN);
    ip_addr_set(&(iphdr->dest), dest);

    iphdr->v = 6;

    if (ip_addr_isany(src)) {
      ip_addr_set(&(iphdr->src), &(netif->ip_addr));
    } else {
      ip_addr_set(&(iphdr->src), src);
    }

  } else {
    dest = &(iphdr->dest);
  }

  IP_STATS_INC(ip.xmit);

  LWIP_DEBUGF(IP_DEBUG, ("ip_output_if: %c%c (len %"U16_F")\n", netif->name[0], netif->name[1], p->tot_len));
#if IP_DEBUG
  ip_debug_print(p);
#endif /* IP_DEBUG */

  PERF_STOP("ip_output_if");
  return netif->output(netif, p, dest);
}

/* ip_output:
 *
 * Simple interface to ip_output_if. It finds the outgoing network interface and
 * calls upon ip_output_if to do the actual work.
 */

err_t
ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
    u8_t ttl, u8_t proto)
{
  struct netif *netif;
  if ((netif = ip_route(dest)) == NULL) {
    LWIP_DEBUGF(IP_DEBUG, ("ip_output: No route to 0x%"X32_F"\n", dest->addr));
    IP_STATS_INC(ip.rterr);
    return ERR_RTE;
  }

  return ip_output_if (p, src, dest, ttl, proto, netif);
}

#if LWIP_NETIF_HWADDRHINT
err_t
ip_output_hinted(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
          u8_t ttl, u8_t tos, u8_t proto, u8_t *addr_hint)
{
  struct netif *netif;
  err_t err;

  if ((netif = ip_route(dest)) == NULL) {
    LWIP_DEBUGF(IP_DEBUG, ("ip_output: No route to 0x%"X32_F"\n", dest->addr));
    IP_STATS_INC(ip.rterr);
    return ERR_RTE;
  }

  netif->addr_hint = addr_hint;
  err = ip_output_if(p, src, dest, ttl, tos, proto, netif);
  netif->addr_hint = NULL;

  return err;
}
#endif /* LWIP_NETIF_HWADDRHINT*/

#if IP_DEBUG
void
ip_debug_print(struct pbuf *p)
{
  struct ip_hdr *iphdr = p->payload;

  LWIP_DEBUGF(IP_DEBUG, ("IP header:\n"));
  LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
  LWIP_DEBUGF(IP_DEBUG, ("|%2"S16_F" |  %"X16_F"%"X16_F"  |      %"X16_F"%"X16_F"           | (v, traffic class, flow label)\n",
        iphdr->v,
        iphdr->tclass1, iphdr->tclass2,
        iphdr->flow1, iphdr->flow2));
  LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
  LWIP_DEBUGF(IP_DEBUG, ("|    %5"U16_F"      | %2"U16_F"  |  %2"U16_F"   | (len, nexthdr, hoplim)\n",
        ntohs(iphdr->len),
        iphdr->nexthdr,
        iphdr->hoplim));
  LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
  LWIP_DEBUGF(IP_DEBUG, ("|       %4"X32_F"      |       %4"X32_F"     | (src)\n",
        (ntohl(iphdr->src.addr[0]) >> 16) & 0xffff,
        ntohl(iphdr->src.addr[0]) & 0xffff));
  LWIP_DEBUGF(IP_DEBUG, ("|       %4"X32_F"      |       %4"X32_F"     | (src)\n",
        (ntohl(iphdr->src.addr[1]) >> 16) & 0xffff,
        ntohl(iphdr->src.addr[1]) & 0xffff));
  LWIP_DEBUGF(IP_DEBUG, ("|       %4"X32_F"      |       %4"X32_F"     | (src)\n",
        (ntohl(iphdr->src.addr[2]) >> 16) & 0xffff,
        ntohl(iphdr->src.addr[2]) & 0xffff));
  LWIP_DEBUGF(IP_DEBUG, ("|       %4"X32_F"      |       %4"X32_F"     | (src)\n",
        (ntohl(iphdr->src.addr[3]) >> 16) & 0xffff,
        ntohl(iphdr->src.addr[3]) & 0xffff));
  LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
  LWIP_DEBUGF(IP_DEBUG, ("|       %4"X32_F"      |       %4"X32_F"     | (dest)\n",
        (ntohl(iphdr->dest.addr[0]) >> 16) & 0xffff,
        ntohl(iphdr->dest.addr[0]) & 0xffff));
  LWIP_DEBUGF(IP_DEBUG, ("|       %4"X32_F"      |       %4"X32_F"     | (dest)\n",
        (ntohl(iphdr->dest.addr[1]) >> 16) & 0xffff,
        ntohl(iphdr->dest.addr[1]) & 0xffff));
  LWIP_DEBUGF(IP_DEBUG, ("|       %4"X32_F"      |       %4"X32_F"     | (dest)\n",
        (ntohl(iphdr->dest.addr[2]) >> 16) & 0xffff,
        ntohl(iphdr->dest.addr[2]) & 0xffff));
  LWIP_DEBUGF(IP_DEBUG, ("|       %4"X32_F"      |       %4"X32_F"     | (dest)\n",
        (ntohl(iphdr->dest.addr[3]) >> 16) & 0xffff,
        ntohl(iphdr->dest.addr[3]) & 0xffff));
  LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
}
#endif /* IP_DEBUG */

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产剧情一区在线| 成人永久aaa| 麻豆国产欧美一区二区三区| 精品亚洲porn| 一本色道久久综合精品竹菊| 欧美日高清视频| 久久久久久日产精品| 久久精工是国产品牌吗| 成人v精品蜜桃久久一区| 欧洲一区二区av| 精品久久国产老人久久综合| 国产精品久久久久影院| 美女视频黄免费的久久 | 日韩精品中文字幕在线一区| 欧美国产日产图区| 免费在线观看一区二区三区| 99久久国产综合精品色伊| 日韩欧美亚洲国产精品字幕久久久 | 欧美一级久久久| 精品一区二区三区免费播放| 91看片淫黄大片一级| 欧美本精品男人aⅴ天堂| 日韩精品乱码免费| 91国产免费观看| 亚洲天天做日日做天天谢日日欢| 国产精品一区一区三区| 日韩欧美不卡在线观看视频| 亚洲妇女屁股眼交7| 91在线国内视频| 1区2区3区欧美| 91国在线观看| 亚洲成人中文在线| 欧美日韩1234| 久久国产人妖系列| 欧美精品一区二| 久久av老司机精品网站导航| 欧美xxxx老人做受| 国产原创一区二区| 国产亚洲欧美日韩在线一区| 国产精品一区二区在线播放| 精品国产成人在线影院| 国产精品影音先锋| 国产精品久久久久久久蜜臀| 91麻豆福利精品推荐| 日韩va亚洲va欧美va久久| 日韩精品最新网址| 成人高清在线视频| 五月开心婷婷久久| 国产精品美女久久久久久久久久久 | 精品久久久久久最新网址| 成人视屏免费看| 日韩主播视频在线| 国产精品久久久久影视| 91麻豆精品国产自产在线 | 欧美韩国日本综合| 在线电影国产精品| 99精品国产视频| 久久99精品国产.久久久久| 成人欧美一区二区三区黑人麻豆| 欧美午夜电影网| 99久久伊人久久99| 精品一区二区三区影院在线午夜| 亚洲精品久久7777| 欧美国产日本视频| 精品国产乱码久久久久久1区2区| 波多野结衣精品在线| 国产精品主播直播| 欧美aaa在线| 日韩av高清在线观看| 亚洲免费在线电影| 国产精品美女久久福利网站| 精品福利av导航| 久久综合丝袜日本网| 欧美成人猛片aaaaaaa| 欧美高清视频www夜色资源网| 欧美性三三影院| 欧美日韩一二三区| 日韩三级在线观看| 成人动漫一区二区在线| 不卡av在线免费观看| 免费不卡在线观看| 久久国内精品视频| 精品中文字幕一区二区| 免费成人在线观看视频| 黄页网站大全一区二区| 国产一区视频网站| 粉嫩嫩av羞羞动漫久久久| 不卡免费追剧大全电视剧网站| www.久久久久久久久| 欧美日韩一区二区三区高清| 欧美无砖砖区免费| 日韩一级黄色大片| 欧美国产视频在线| 亚洲高清在线精品| 国产九九视频一区二区三区| 99热这里都是精品| 日韩一区二区在线看| 国产精品美女久久久久久久久| 一区二区视频在线看| 久久国产尿小便嘘嘘尿| 91丨国产丨九色丨pron| 日韩欧美一级在线播放| 日韩精品成人一区二区在线| 国产精品色一区二区三区| 久久久久国产一区二区三区四区| 天天色综合天天| 日韩欧美一区二区免费| 久久国产精品72免费观看| 日韩欧美国产麻豆| 亚洲一区二区三区中文字幕在线| 国产传媒欧美日韩成人| 在线播放国产精品二区一二区四区| 欧美精品一区二区三区高清aⅴ| 国产精品不卡一区二区三区| 亚洲国产aⅴ成人精品无吗| 成人丝袜高跟foot| 制服丝袜中文字幕一区| 一区二区三区日韩精品视频| 久久成人羞羞网站| 欧美人与禽zozo性伦| 玉足女爽爽91| 色妹子一区二区| 一级日本不卡的影视| 欧洲亚洲国产日韩| 国产福利一区二区三区| 日韩欧美一区二区视频| 成人网在线免费视频| 国产精品毛片a∨一区二区三区| 成人福利视频网站| 中文字幕在线一区| 99r精品视频| 天堂va蜜桃一区二区三区漫画版| 欧美日韩卡一卡二| 精品一区二区三区影院在线午夜| 2024国产精品| 99精品国产一区二区三区不卡| 天天综合网 天天综合色| 欧美精品一区二区三区在线播放| 国产伦精品一区二区三区视频青涩 | 丁香婷婷综合色啪| 中文字幕第一区二区| 欧美少妇性性性| 国产精品123| 亚洲成人激情av| 日本一区二区三区视频视频| 欧美美女视频在线观看| 99国产精品国产精品久久| 国产精品一级二级三级| 日韩一区欧美二区| 亚洲综合一二区| 欧美大尺度电影在线| 亚洲国产va精品久久久不卡综合| 欧美精品粉嫩高潮一区二区| 在线不卡一区二区| 精品久久免费看| 亚洲乱码国产乱码精品精98午夜 | 色8久久精品久久久久久蜜| www.欧美.com| 91亚洲精品久久久蜜桃网站| 成人综合在线观看| 国产精品一区二区久久不卡| 蜜乳av一区二区三区| 亚洲第一会所有码转帖| 亚洲精品国产品国语在线app| 国产精品午夜免费| 欧美国产精品久久| 国产三级欧美三级| 久久人人97超碰com| 久久人人超碰精品| 欧美成人三级在线| 91精品国产综合久久精品图片 | 国产精品久久久久影院亚瑟| 国产日产欧美一区二区三区| 国产精品福利影院| 午夜精品一区二区三区三上悠亚 | 亚洲激情av在线| 日本成人中文字幕| av不卡免费电影| 日韩免费性生活视频播放| 亚洲国产电影在线观看| 亚洲成人av资源| 精品亚洲国内自在自线福利| 国产成人自拍网| 91在线小视频| 欧美精品国产精品| 国产亚洲精品bt天堂精选| 一区二区三区丝袜| 久久电影国产免费久久电影| 成人av免费在线观看| 欧美午夜精品久久久久久超碰 | 国产成人精品亚洲午夜麻豆| 91免费国产视频网站| 日韩女优电影在线观看| 国产清纯美女被跳蛋高潮一区二区久久w | 欧美大片顶级少妇| 亚洲激情成人在线| 国产综合久久久久久鬼色| av日韩在线网站| 国产精品嫩草影院av蜜臀| 韩国中文字幕2020精品|