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

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

?? ip6.c

?? 包含lwip這個精簡IP協議棧的ucos源代碼.
?? 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, &(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) {
    /* 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);
    }*/


  LWIP_DEBUGF(IP_DEBUG, ("ip_forward: forwarding packet to "));
#if IP_DEBUG
  ip_addr_debug_print(IP_DEBUG, &(iphdr->dest));
#endif /* IP_DEBUG */
  LWIP_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) {
    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);
#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
    LWIP_DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest "));
    ip_addr_debug_print(IP_DEBUG, &(iphdr->dest));
    LWIP_DEBUGF(IP_DEBUG, ("netif->ip_addr "));
    ip_addr_debug_print(IP_DEBUG, &(netif->ip_addr));
    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 */
#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
  /*  LWIP_DEBUGF("ip_input: \n");
  ip_debug_print(p);
  LWIP_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);
    LWIP_DEBUGF(IP_DEBUG, ("Unsupported transport 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)) {
    LWIP_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 */

  LWIP_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) {
    LWIP_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;

  LWIP_DEBUGF(IP_DEBUG, ("IP header:\n"));
  LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
  LWIP_DEBUGF(IP_DEBUG, ("|%2d |  %x%x  |      %x%x           | (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, ("|    %5u      | %2u  |  %2u   | (len, nexthdr, hoplim)\n",
        ntohs(iphdr->len),
        iphdr->nexthdr,
        iphdr->hoplim));
  LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
  LWIP_DEBUGF(IP_DEBUG, ("|       %4lx      |       %4lx     | (src)\n",
        ntohl(iphdr->src.addr[0]) >> 16 & 0xffff,
        ntohl(iphdr->src.addr[0]) & 0xffff));
  LWIP_DEBUGF(IP_DEBUG, ("|       %4lx      |       %4lx     | (src)\n",
        ntohl(iphdr->src.addr[1]) >> 16 & 0xffff,
        ntohl(iphdr->src.addr[1]) & 0xffff));
  LWIP_DEBUGF(IP_DEBUG, ("|       %4lx      |       %4lx     | (src)\n",
        ntohl(iphdr->src.addr[2]) >> 16 & 0xffff,
        ntohl(iphdr->src.addr[2]) & 0xffff));
  LWIP_DEBUGF(IP_DEBUG, ("|       %4lx      |       %4lx     | (src)\n",
        ntohl(iphdr->src.addr[3]) >> 16 & 0xffff,
        ntohl(iphdr->src.addr[3]) & 0xffff));
  LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
  LWIP_DEBUGF(IP_DEBUG, ("|       %4lx      |       %4lx     | (dest)\n",
        ntohl(iphdr->dest.addr[0]) >> 16 & 0xffff,
        ntohl(iphdr->dest.addr[0]) & 0xffff));
  LWIP_DEBUGF(IP_DEBUG, ("|       %4lx      |       %4lx     | (dest)\n",
        ntohl(iphdr->dest.addr[1]) >> 16 & 0xffff,
        ntohl(iphdr->dest.addr[1]) & 0xffff));
  LWIP_DEBUGF(IP_DEBUG, ("|       %4lx      |       %4lx     | (dest)\n",
        ntohl(iphdr->dest.addr[2]) >> 16 & 0xffff,
        ntohl(iphdr->dest.addr[2]) & 0xffff));
  LWIP_DEBUGF(IP_DEBUG, ("|       %4lx      |       %4lx     | (dest)\n",
        ntohl(iphdr->dest.addr[3]) >> 16 & 0xffff,
        ntohl(iphdr->dest.addr[3]) & 0xffff));
  LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
}
#endif /* IP_DEBUG */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩女优av电影在线观看| 97精品国产露脸对白| 日韩女优视频免费观看| 美女视频一区二区| 精品国产乱子伦一区| 丁香激情综合国产| 中文字幕在线不卡一区| 欧美亚洲国产一区二区三区| 午夜伊人狠狠久久| 精品av久久707| 成人免费视频播放| 亚洲精品国产无套在线观| 欧美男同性恋视频网站| 久久精品国产亚洲a| 国产精品无圣光一区二区| 91美女视频网站| 五月婷婷激情综合网| 欧美精品一区在线观看| 91浏览器在线视频| 人人精品人人爱| 国产精品私房写真福利视频| 欧美亚洲一区二区在线| 国产精品一区久久久久| 亚洲一区二区av在线| 精品国产免费一区二区三区四区 | 综合久久久久久| 欧美美女激情18p| 国产成人免费av在线| 夜夜夜精品看看| 久久久久亚洲蜜桃| 欧美日本在线视频| 国产白丝网站精品污在线入口| 亚洲大片在线观看| 国产精品女主播av| 91麻豆精品国产综合久久久久久| 从欧美一区二区三区| 午夜精品国产更新| 日韩一区中文字幕| 欧美精品一区二区三区四区 | 日韩亚洲欧美在线| 91天堂素人约啪| 国产一区二区视频在线播放| 亚洲午夜电影网| 国产日韩欧美高清在线| 日韩一级大片在线| 欧美日韩成人在线| 色综合久久久久| 成人免费高清在线观看| 麻豆精品在线看| 午夜欧美在线一二页| 国产精品福利一区二区三区| 久久这里都是精品| 欧美一区二区三区日韩| 91久久一区二区| 99re这里只有精品6| 欧美精品久久天天躁| 成人黄色777网| 国产精品久久久久久久第一福利| 欧美人与性动xxxx| 色婷婷av一区二区三区软件| 高清在线观看日韩| 韩国欧美国产1区| 天天综合色天天综合| 亚洲一区国产视频| 91精品福利在线一区二区三区| 欧美在线一区二区三区| 91精品国产综合久久久久久漫画 | 丁香一区二区三区| 色婷婷av一区二区三区大白胸 | 国产一区美女在线| 成人网在线免费视频| 在线视频国产一区| 欧美一区二区三区四区久久| 中文字幕乱码亚洲精品一区| 亚洲一区在线观看免费观看电影高清 | 欧美日韩免费不卡视频一区二区三区| 6080亚洲精品一区二区| 国产视频一区在线播放| 亚洲激情图片一区| 激情偷乱视频一区二区三区| 日本韩国一区二区三区| 精品久久久久久久久久久久久久久 | 激情久久五月天| 色综合久久综合网| 欧美成人综合网站| 亚洲欧美日韩中文字幕一区二区三区| 天堂影院一区二区| 不卡的av电影在线观看| 777奇米四色成人影色区| 国产精品久久久久一区| 蜜桃久久精品一区二区| 日本高清视频一区二区| 久久亚洲综合色一区二区三区| 亚洲精品国久久99热| 国产精品综合一区二区| 欧美麻豆精品久久久久久| 久久欧美中文字幕| 亚洲va国产va欧美va观看| 白白色亚洲国产精品| 日韩无一区二区| 亚洲一级二级三级在线免费观看| 国产jizzjizz一区二区| 91精品国产高清一区二区三区蜜臀 | 亚洲精品国产一区二区精华液| 久久草av在线| 欧美视频第二页| 综合网在线视频| 成人妖精视频yjsp地址| 日韩欧美专区在线| 亚洲综合色视频| 91丨porny丨国产| 国产欧美日韩三区| 精品在线一区二区三区| 欧美夫妻性生活| 亚洲成人在线免费| 日本韩国一区二区三区| 亚洲欧美综合在线精品| 国产高清在线精品| 久久综合色综合88| 精品一区二区三区香蕉蜜桃| 91精品啪在线观看国产60岁| 亚洲综合免费观看高清完整版| 91免费在线播放| 自拍偷自拍亚洲精品播放| 国产aⅴ综合色| 欧美精品一区二区三区视频| 久久精品国产亚洲一区二区三区| 91精品国产一区二区人妖| 午夜精品影院在线观看| 欧美色偷偷大香| 亚洲第一成人在线| 欧美日韩久久一区| 午夜精品久久久久久| 欧美精品三级日韩久久| 青娱乐精品在线视频| 欧美一区二区三区日韩| 美女视频免费一区| 久久免费午夜影院| 国产999精品久久| 国产精品国模大尺度视频| 成人app网站| 亚洲精品综合在线| 色综合天天综合在线视频| 亚洲精品高清在线| 欧美唯美清纯偷拍| 日韩电影一二三区| 精品88久久久久88久久久| 国产麻豆精品一区二区| 中文av一区二区| 色综合久久综合| 亚洲一级二级在线| 欧美一级在线观看| 国产高清不卡一区二区| 成人欧美一区二区三区| 欧美日韩在线三区| 久久99最新地址| 国产精品传媒视频| 欧美人成免费网站| 国产在线播放一区| 国产精品第五页| 欧美色大人视频| 黄色日韩网站视频| 亚洲欧美国产77777| 在线成人免费视频| 国产精品一区在线观看你懂的| 亚洲人成伊人成综合网小说| 欧美日韩夫妻久久| 国产99久久久国产精品潘金网站| 亚洲免费观看高清完整 | 国产精品女上位| 91福利视频网站| 久久精品国产第一区二区三区| 国产欧美1区2区3区| 在线观看网站黄不卡| 韩国一区二区视频| 一区二区三区国产精品| 精品国产一区二区三区av性色| av中文字幕亚洲| 美女尤物国产一区| 亚洲日穴在线视频| 精品粉嫩超白一线天av| 色综合久久88色综合天天免费| 蜜臀久久99精品久久久久宅男| 国产精品美女久久久久久| 日韩一区二区免费在线观看| 91无套直看片红桃| 国产一区二区精品在线观看| 亚洲精品久久嫩草网站秘色| 久久久www成人免费无遮挡大片 | 久久精品一区四区| 欧美色视频在线观看| 成人免费视频一区| 精品一区二区三区在线观看国产| 亚洲男人都懂的| 精品成a人在线观看| 欧美日韩国产成人在线免费| 成人av电影在线播放| 麻豆久久久久久久| 亚洲午夜免费电影| 亚洲视频免费观看|