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

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

?? ip6.c

?? ucos+lwip在44b0+8019開發板上跑得比較穩定的程序。是ADS的工程
?? 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一区二区三区免费野_久草精品视频
一道本成人在线| 欧美自拍偷拍午夜视频| 蜜桃视频免费观看一区| 国产精品夜夜爽| 欧美伊人久久久久久久久影院| 欧美中文字幕一区| 精品国产一区二区三区忘忧草| 国产片一区二区| 亚洲成av人影院在线观看网| 国产在线精品一区在线观看麻豆| caoporen国产精品视频| 91.com在线观看| 国产精品久久久99| 日本三级韩国三级欧美三级| 成人免费毛片app| 日韩欧美黄色影院| 一区二区三区高清| 国产精品亚洲а∨天堂免在线| gogo大胆日本视频一区| 日韩欧美国产三级电影视频| 亚洲欧美激情插| 国产精品99久久久| 91精品婷婷国产综合久久性色| 中文字幕欧美激情一区| 蜜桃久久精品一区二区| 国产99精品国产| 欧美一区二区人人喊爽| 一卡二卡欧美日韩| 懂色中文一区二区在线播放| 日韩欧美国产成人一区二区| 日韩美女视频一区| 亚洲一区在线观看视频| 在线免费亚洲电影| 一区二区三国产精华液| 欧美性感一区二区三区| 五月婷婷激情综合| 欧美精品久久一区| 青青草原综合久久大伊人精品优势| 欧美日韩精品一区二区天天拍小说 | 精品少妇一区二区三区在线视频| 视频一区二区国产| 日韩欧美一二区| 国产综合色精品一区二区三区| 久久色在线视频| 国产成人免费在线观看不卡| 成人欧美一区二区三区在线播放| 99这里只有精品| 亚洲成人av免费| 久久精品无码一区二区三区| 成人综合婷婷国产精品久久| 国产精品福利影院| 欧美体内she精视频| 日本不卡123| 国产精品视频一二| 日本韩国一区二区| 免费不卡在线观看| 国产女同性恋一区二区| 99精品久久只有精品| 亚洲一区二区三区四区不卡| 日韩欧美中文字幕公布| 波多野结衣中文字幕一区二区三区| 中文字幕综合网| 日韩欧美一区中文| 粉嫩嫩av羞羞动漫久久久| 亚洲免费视频成人| 精品久久久久久最新网址| 成人精品免费视频| 日韩中文字幕一区二区三区| 国产日韩欧美a| 欧美日韩三级一区| 国产99久久久国产精品潘金| 午夜精品福利久久久| 国产日韩欧美不卡在线| 91精品在线一区二区| 99久久精品免费看国产 | 欧美一级高清大全免费观看| 成人sese在线| 久久福利资源站| 一区二区激情小说| 日本一区二区成人在线| 欧美一区二区啪啪| 在线精品视频一区二区三四| 国产成人aaa| 免费观看30秒视频久久| 亚洲高清不卡在线观看| 国产精品电影一区二区三区| 337p粉嫩大胆色噜噜噜噜亚洲| 91官网在线免费观看| 国产成人av资源| 国产一区二区精品久久| 日本特黄久久久高潮| 亚洲精品大片www| 国产精品护士白丝一区av| 精品免费国产一区二区三区四区| 欧美日韩视频在线第一区| 91污片在线观看| 波多野结衣在线aⅴ中文字幕不卡| 成人国产免费视频| 国产乱码精品一区二区三区忘忧草 | 国产精品久久久久久久久快鸭| 日韩一区二区视频在线观看| 欧美三级午夜理伦三级中视频| 91麻豆swag| 91麻豆swag| 色欧美日韩亚洲| 欧洲视频一区二区| 在线一区二区三区| 91高清在线观看| 91福利视频久久久久| 色偷偷久久一区二区三区| 99久久国产免费看| 91香蕉视频mp4| 在线欧美日韩精品| 欧美日本在线一区| 欧美一区国产二区| 久久久亚洲午夜电影| 久久久91精品国产一区二区精品 | 精品婷婷伊人一区三区三| 欧洲视频一区二区| 欧美美女网站色| 538在线一区二区精品国产| 91精品欧美一区二区三区综合在| 欧美精品在线视频| 欧美v国产在线一区二区三区| 日韩欧美亚洲一区二区| ww久久中文字幕| 中文字幕一区免费在线观看| 亚洲欧洲另类国产综合| 亚洲三级理论片| 亚洲国产裸拍裸体视频在线观看乱了| 亚洲午夜国产一区99re久久| 视频一区免费在线观看| 久久se精品一区二区| 国产激情精品久久久第一区二区| 国产成人亚洲综合a∨婷婷| av网站一区二区三区| 欧美午夜精品久久久久久超碰| 欧美一区二区三区四区在线观看| 精品区一区二区| 亚洲国产精品激情在线观看| 尤物av一区二区| 韩国视频一区二区| 91视频免费观看| 日韩欧美国产电影| 综合久久综合久久| 久久精品久久综合| 成人av午夜影院| 欧美日韩成人综合在线一区二区| 久久这里只有精品6| 亚洲图片激情小说| 精品亚洲成a人| 91久久一区二区| 久久精品人人做人人综合 | 欧美天天综合网| 精品sm捆绑视频| 伊人色综合久久天天人手人婷| 免费人成精品欧美精品| 99国产精品国产精品毛片| 日韩欧美123| 夜夜嗨av一区二区三区网页 | 在线国产亚洲欧美| 亚洲精品一区二区三区蜜桃下载| 亚洲欧美另类图片小说| 国产在线乱码一区二区三区| 欧美日韩高清一区二区三区| 国产精品乱子久久久久| 久久狠狠亚洲综合| 欧美三级韩国三级日本一级| 国产精品久久久久婷婷二区次| 久久精品国产99| 欧美精品123区| 一区二区三区四区乱视频| 国产91精品精华液一区二区三区| 欧美一区二区三区四区高清| 亚洲自拍偷拍图区| 色综合网色综合| 国产精品久久久久天堂| 国产精品456露脸| 日韩美女在线视频| 日韩高清在线电影| 欧美日韩国产另类不卡| 亚洲欧美电影一区二区| av电影在线观看不卡| 国产午夜精品久久久久久久 | 天堂在线亚洲视频| 欧美性受xxxx黑人xyx性爽| 中文字幕一区二区不卡 | 欧美亚洲国产一区在线观看网站| 国产精品欧美一区喷水| 国产精品123区| 久久久99免费| 国产毛片精品视频| 国产亚洲1区2区3区| 国产美女一区二区| 久久精品视频一区二区| 夫妻av一区二区| 欧美激情自拍偷拍| 97精品久久久午夜一区二区三区| **性色生活片久久毛片| 在线视频一区二区三区|