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

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

?? ip6.c

?? 一個輕量tcpip協議在移植在ucOS2系統上運行
?? C
字號:
/*
 * Copyright (c) 2001-2003 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_maskcmp(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) {

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

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

#ifdef IP_STATS
  ++lwip_stats.ip.fw;
  ++lwip_stats.ip.xmit;
#endif /* IP_STATS */

  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 */

  
#ifdef IP_STATS
  ++lwip_stats.ip.recv;
#endif /* IP_STATS */
  
  /* identify the IP header */
  iphdr = p->payload;

  
  if(iphdr->v != 6) {
    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);
#ifdef IP_STATS
    ++lwip_stats.ip.err;
    ++lwip_stats.ip.drop;
#endif /* IP_STATS */
    return;
  }
  
  /* is this packet for us? */
  for(netif = netif_list; netif != NULL; netif = netif->next) {
#if IP_DEBUG
    DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest "));
    ip_addr_debug_print(&(iphdr->dest));
    DEBUGF(IP_DEBUG, ("netif->ip_addr "));
    ip_addr_debug_print(&(netif->ip_addr));
    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 */
#ifdef 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
  /*  DEBUGF("ip_input: \n");
  ip_debug_print(p);
  DEBUGF("ip_input: p->len %u p->tot_len %u\n", p->len, p->tot_len);*/
#endif /* IP_DEBUG */
   

  pbuf_header(p, -IP_HLEN);

  switch(iphdr->nexthdr) {
  case IP_PROTO_UDP:
    udp_input(p);
    break;
  case IP_PROTO_TCP:
    tcp_input(p);
    break;
  case IP_PROTO_ICMP:
    icmp_input(p, inp);
    break;
  default:
    /* send ICMP destination protocol unreachable */
    icmp_dest_unreach(p, ICMP_DUR_PROTO);
    pbuf_free(p);
    DEBUGF(IP_DEBUG, ("Unsupported transportation protocol %u\n",
		      iphdr->nexthdr));

#ifdef IP_STATS
    ++lwip_stats.ip.proterr;
    ++lwip_stats.ip.drop;
#endif /* IP_STATS */

  }
  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;

  printf("len %u tot_len %u\n", p->len, p->tot_len);
  if(pbuf_header(p, IP_HLEN)) {
    DEBUGF(IP_DEBUG, ("ip_output: not enough room for IP header in pbuf\n"));
#ifdef IP_STATS
    ++lwip_stats.ip.err;
#endif /* IP_STATS */

    return ERR_BUF;
  }
  printf("len %u tot_len %u\n", p->len, p->tot_len);
  
  iphdr = p->payload;
  

  if(dest != IP_HDRINCL) {
    printf("!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);
  }

#ifdef IP_STATS
  ++lwip_stats.ip.xmit;
#endif /* IP_STATS */

  DEBUGF(IP_DEBUG, ("ip_output_if: %c%c (len %u)\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) {
    DEBUGF(IP_DEBUG, ("ip_output: No route to 0x%lx\n", dest->addr));
#ifdef IP_STATS
    ++lwip_stats.ip.rterr;
#endif /* IP_STATS */
    return ERR_RTE;
  }

  return ip_output_if(p, src, dest, ttl, proto, netif);
}
/*-----------------------------------------------------------------------------------*/
#if IP_DEBUG
void
ip_debug_print(struct pbuf *p)
{
  struct ip_hdr *iphdr = p->payload;
  char *payload;

  payload = (char *)iphdr + IP_HLEN;
  
  DEBUGF(IP_DEBUG, ("IP header:\n"));
  DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
  DEBUGF(IP_DEBUG, ("|%2d |  %x%x  |      %x%x           | (v, traffic class, flow label)\n",
		    iphdr->v,
		    iphdr->tclass1, iphdr->tclass2,
		    iphdr->flow1, iphdr->flow2));
  DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
  DEBUGF(IP_DEBUG, ("|    %5u      | %2u  |  %2u   | (len, nexthdr, hoplim)\n",
		    ntohs(iphdr->len),
		    iphdr->nexthdr,
		    iphdr->hoplim));
  DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
  DEBUGF(IP_DEBUG, ("|       %4lx      |       %4lx     | (src)\n",
		    ntohl(iphdr->src.addr[0]) >> 16 & 0xffff,
		    ntohl(iphdr->src.addr[0]) & 0xffff));
  DEBUGF(IP_DEBUG, ("|       %4lx      |       %4lx     | (src)\n",
		    ntohl(iphdr->src.addr[1]) >> 16 & 0xffff,
		    ntohl(iphdr->src.addr[1]) & 0xffff));
  DEBUGF(IP_DEBUG, ("|       %4lx      |       %4lx     | (src)\n",
		    ntohl(iphdr->src.addr[2]) >> 16 & 0xffff,
		    ntohl(iphdr->src.addr[2]) & 0xffff));
  DEBUGF(IP_DEBUG, ("|       %4lx      |       %4lx     | (src)\n",
		    ntohl(iphdr->src.addr[3]) >> 16 & 0xffff,
		    ntohl(iphdr->src.addr[3]) & 0xffff));
  DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
  DEBUGF(IP_DEBUG, ("|       %4lx      |       %4lx     | (dest)\n",
		    ntohl(iphdr->dest.addr[0]) >> 16 & 0xffff,
		    ntohl(iphdr->dest.addr[0]) & 0xffff));
  DEBUGF(IP_DEBUG, ("|       %4lx      |       %4lx     | (dest)\n",
		    ntohl(iphdr->dest.addr[1]) >> 16 & 0xffff,
		    ntohl(iphdr->dest.addr[1]) & 0xffff));
  DEBUGF(IP_DEBUG, ("|       %4lx      |       %4lx     | (dest)\n",
		    ntohl(iphdr->dest.addr[2]) >> 16 & 0xffff,
		    ntohl(iphdr->dest.addr[2]) & 0xffff));
  DEBUGF(IP_DEBUG, ("|       %4lx      |       %4lx     | (dest)\n",
		    ntohl(iphdr->dest.addr[3]) >> 16 & 0xffff,
		    ntohl(iphdr->dest.addr[3]) & 0xffff));
  DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
}
#endif /* IP_DEBUG */
/*-----------------------------------------------------------------------------------*/

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一级在线观看| 中文字幕亚洲精品在线观看| 成人小视频在线| 麻豆91免费看| 日本不卡视频一二三区| 午夜在线电影亚洲一区| 天堂在线亚洲视频| 日本欧美久久久久免费播放网| 五月天欧美精品| 丝袜诱惑亚洲看片| 秋霞国产午夜精品免费视频| 理论电影国产精品| 国产一区二区不卡在线| 成人av资源站| 日本丰满少妇一区二区三区| 在线观看视频91| 欧美精品在线视频| 欧美大片免费久久精品三p | 91偷拍与自偷拍精品| gogo大胆日本视频一区| 91精品福利视频| 91麻豆精品国产91久久久资源速度 | 久久精品国产成人一区二区三区 | 国产日产欧美一区| 亚洲麻豆国产自偷在线| 午夜精品免费在线| 国产一区二区网址| 色综合久久中文综合久久97 | 99精品国产99久久久久久白柏| 99视频国产精品| 7777女厕盗摄久久久| 中文字幕av一区二区三区| 亚洲欧美国产毛片在线| 奇米888四色在线精品| 99天天综合性| 日韩一区二区麻豆国产| 国产精品网站一区| 石原莉奈一区二区三区在线观看| 国产毛片精品国产一区二区三区| 在线观看一区二区视频| 久久久99免费| 三级亚洲高清视频| 99精品视频一区| 2020国产成人综合网| 亚洲成人av在线电影| 国产高清在线精品| 欧美一区二区精品| 亚洲午夜在线视频| 高清国产一区二区三区| 欧美一区二区视频网站| 亚洲一区二区三区小说| 国产91精品一区二区麻豆亚洲| 在线播放/欧美激情| 国产精品第13页| 国产乱人伦精品一区二区在线观看 | 欧美中文字幕一区二区三区亚洲| ww亚洲ww在线观看国产| 性做久久久久久免费观看欧美| av电影在线不卡| 精品国产制服丝袜高跟| 美国三级日本三级久久99| 欧美性感一区二区三区| 亚洲免费在线观看视频| 国产成人av在线影院| 精品日韩成人av| 美腿丝袜亚洲一区| 51精品久久久久久久蜜臀| 香蕉久久夜色精品国产使用方法| 色综合天天综合色综合av| 国产精品入口麻豆九色| 国产白丝精品91爽爽久久| 欧美国产日韩精品免费观看| 国产成人av影院| 日本一区二区三区四区| 国产精品99久久久久久久vr| 国产日韩精品一区二区浪潮av| 激情小说亚洲一区| 久久精品一区八戒影视| 成人av网在线| 亚洲美腿欧美偷拍| 欧美三级蜜桃2在线观看| 午夜精品福利一区二区蜜股av| 制服丝袜成人动漫| 青椒成人免费视频| xnxx国产精品| av中文字幕不卡| 一区二区激情视频| 欧美精品电影在线播放| 久久97超碰国产精品超碰| 欧美韩国日本不卡| 色婷婷精品大视频在线蜜桃视频| 亚洲国产成人91porn| 日韩精品一区二区三区视频在线观看| 激情亚洲综合在线| 最新不卡av在线| 欧美日韩亚洲综合在线| 美女国产一区二区| 欧美国产精品专区| 欧美影片第一页| 国产在线麻豆精品观看| 中文字幕一区二区三区在线不卡 | xf在线a精品一区二区视频网站| 国产iv一区二区三区| 一区二区三区免费在线观看| 欧美视频精品在线观看| 久久成人免费电影| 亚洲少妇中出一区| 日韩一区国产二区欧美三区| 国产**成人网毛片九色| 亚洲成a人片在线观看中文| 欧美精品一区二| 色综合久久久久| 麻豆国产91在线播放| 亚洲免费看黄网站| 日韩一卡二卡三卡四卡| 一本到不卡免费一区二区| 麻豆91在线看| 怡红院av一区二区三区| 精品久久99ma| 欧美自拍偷拍一区| 大胆欧美人体老妇| 青青草97国产精品免费观看无弹窗版 | 麻豆国产精品一区二区三区| 国产精品久久久久久久裸模| 欧美一二三四区在线| 色狠狠综合天天综合综合| 激情成人综合网| 天天综合天天综合色| 综合久久久久久久| 久久久.com| 日韩精品一区二区三区在线观看 | 欧美精品vⅰdeose4hd| 99久久国产综合精品色伊| 国产一二三精品| 麻豆高清免费国产一区| 天堂久久久久va久久久久| 亚洲制服丝袜一区| 亚洲女女做受ⅹxx高潮| 国产精品久久久久久久浪潮网站| 欧美成人福利视频| 日韩女优av电影| 欧美一区二区三区成人| 欧美人牲a欧美精品| 色综合久久中文字幕综合网| 国产成人av影院| 国产成人综合亚洲网站| 国产一区美女在线| 国产麻豆日韩欧美久久| 国产精品一区一区| 激情成人综合网| 国产精品一二三区在线| 国产乱码精品一区二区三| 国产精品自拍网站| 国产不卡在线一区| 成人做爰69片免费看网站| 国产盗摄视频一区二区三区| 国产传媒久久文化传媒| 成av人片一区二区| 91色在线porny| 欧亚一区二区三区| 欧美精品久久99久久在免费线| 91精品黄色片免费大全| 日韩免费观看2025年上映的电影| 欧美mv日韩mv| 久久久久国产精品麻豆| 国产精品美女久久久久久2018| 中文字幕一区二区三区蜜月| 亚洲精品videosex极品| 香蕉成人伊视频在线观看| 久久成人免费网站| 国产成人在线观看| 色系网站成人免费| 欧美日韩精品电影| 2024国产精品视频| 国产精品麻豆欧美日韩ww| 亚洲免费av高清| 免费精品视频在线| 国产精品一二三四| 日本高清不卡在线观看| 日韩欧美视频一区| 中文在线一区二区| 香蕉影视欧美成人| 国产盗摄一区二区| 欧美特级限制片免费在线观看| 欧美成人精品高清在线播放 | 欧美日韩美女一区二区| 精品国产青草久久久久福利| 中文子幕无线码一区tr| 亚洲电影视频在线| 高清国产一区二区| 欧美一级片免费看| 自拍偷拍亚洲欧美日韩| 久久精品99国产国产精| 色94色欧美sute亚洲线路一ni| 日韩欧美成人午夜| 亚洲一级片在线观看| 国产99久久久国产精品潘金 | 成人精品视频一区| 91精品国产乱| 亚洲欧美日韩精品久久久久|