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

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

?? ip_frag.c

?? lwip在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: Jani Monoses <jani@iv.ro>  * original reassembly code by Adam Dunkels <adam@sics.se> *  *//* ip_frag.c * * This is the code for IP segmentation and reassembly * */#include "lwip/opt.h"#include "lwip/sys.h"#include "lwip/ip.h"#include "lwip/ip_frag.h"#include "lwip/netif.h"#include "lwip/stats.h"#include "string.h"/* * Copy len bytes from offset in pbuf to buffer  * * helper used by both ip_reass and ip_frag */static struct pbuf *copy_from_pbuf(struct pbuf *p, u16_t * offset,           u8_t * buffer, u16_t len){  u16_t l;  p->payload = (u8_t *)p->payload + *offset;  p->len -= *offset;  while (len) {    l = len < p->len ? len : p->len;    memcpy(buffer, p->payload, l);    buffer += l;    len -= l;    if (len)      p = p->next;    else      *offset = l;  }  return p;}#define IP_REASS_BUFSIZE 5760#define IP_REASS_MAXAGE 30#define IP_REASS_TMO 1000static u8_t ip_reassbuf[IP_HLEN + IP_REASS_BUFSIZE];static u8_t ip_reassbitmap[IP_REASS_BUFSIZE / (8 * 8)];static const u8_t bitmap_bits[8] = { 0xff, 0x7f, 0x3f, 0x1f,  0x0f, 0x07, 0x03, 0x01};static u16_t ip_reasslen;static u8_t ip_reassflags;#define IP_REASS_FLAG_LASTFRAG 0x01static u8_t ip_reasstmr;/* Reassembly timer */ static void ip_reass_timer(void *arg){  (void)arg;  if (ip_reasstmr > 1) {    ip_reasstmr--;    sys_timeout(IP_REASS_TMO, ip_reass_timer, NULL);  } else if (ip_reasstmr == 1)  ip_reasstmr = 0;}struct pbuf *ip_reass(struct pbuf *p){  struct pbuf *q;  struct ip_hdr *fraghdr, *iphdr;  u16_t offset, len;  u16_t i;  IPFRAG_STATS_INC(ip_frag.recv);  iphdr = (struct ip_hdr *) ip_reassbuf;  fraghdr = (struct ip_hdr *) p->payload;  /* If ip_reasstmr is zero, no packet is present in the buffer, so we     write the IP header of the fragment into the reassembly     buffer. The timer is updated with the maximum age. */  if (ip_reasstmr == 0) {    LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass: new packet\n"));    /* modified by hgxxx, add (void *) before iphdr */    memcpy((void *)iphdr, (void *)fraghdr, IP_HLEN);    ip_reasstmr = IP_REASS_MAXAGE;    sys_timeout(IP_REASS_TMO, ip_reass_timer, NULL);    ip_reassflags = 0;    /* Clear the bitmap. */    memset(ip_reassbitmap, 0, sizeof(ip_reassbitmap));  }  /* Check if the incoming fragment matches the one currently present     in the reasembly buffer. If so, we proceed with copying the     fragment into the buffer. */  if (ip_addr_cmp(&iphdr->src, &fraghdr->src) &&      ip_addr_cmp(&iphdr->dest, &fraghdr->dest) &&      IPH_ID(iphdr) == IPH_ID(fraghdr)) {    LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass: matching old packet\n"));    IPFRAG_STATS_INC(ip_frag.cachehit);    /* Find out the offset in the reassembly buffer where we should       copy the fragment. */    len = ntohs(IPH_LEN(fraghdr)) - IPH_HL(fraghdr) * 4;    offset = (ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) * 8;    /* If the offset or the offset + fragment length overflows the       reassembly buffer, we discard the entire packet. */    if (offset > IP_REASS_BUFSIZE || offset + len > IP_REASS_BUFSIZE) {      LWIP_DEBUGF(IP_REASS_DEBUG,       ("ip_reass: fragment outside of buffer (%d:%d/%d).\n", offset,        offset + len, IP_REASS_BUFSIZE));      sys_untimeout(ip_reass_timer, NULL);      ip_reasstmr = 0;      goto nullreturn;    }    /* Copy the fragment into the reassembly buffer, at the right       offset. */    LWIP_DEBUGF(IP_REASS_DEBUG,     ("ip_reass: copying with offset %d into %d:%d\n", offset,      IP_HLEN + offset, IP_HLEN + offset + len));    i = IPH_HL(fraghdr) * 4;    copy_from_pbuf(p, &i, &ip_reassbuf[IP_HLEN + offset], len);    /* Update the bitmap. */    if (offset / (8 * 8) == (offset + len) / (8 * 8)) {      LWIP_DEBUGF(IP_REASS_DEBUG,       ("ip_reass: updating single byte in bitmap.\n"));      /* If the two endpoints are in the same byte, we only update         that byte. */      ip_reassbitmap[offset / (8 * 8)] |=    bitmap_bits[(offset / 8) & 7] &    ~bitmap_bits[((offset + len) / 8) & 7];    } else {      /* If the two endpoints are in different bytes, we update the         bytes in the endpoints and fill the stuff inbetween with         0xff. */      ip_reassbitmap[offset / (8 * 8)] |= bitmap_bits[(offset / 8) & 7];      LWIP_DEBUGF(IP_REASS_DEBUG,       ("ip_reass: updating many bytes in bitmap (%d:%d).\n",        1 + offset / (8 * 8), (offset + len) / (8 * 8)));      for (i = 1 + offset / (8 * 8); i < (offset + len) / (8 * 8); ++i) {  ip_reassbitmap[i] = 0xff;      }      ip_reassbitmap[(offset + len) / (8 * 8)] |=    ~bitmap_bits[((offset + len) / 8) & 7];    }    /* If this fragment has the More Fragments flag set to zero, we       know that this is the last fragment, so we can calculate the       size of the entire packet. We also set the       IP_REASS_FLAG_LASTFRAG flag to indicate that we have received       the final fragment. */    if ((ntohs(IPH_OFFSET(fraghdr)) & IP_MF) == 0) {      ip_reassflags |= IP_REASS_FLAG_LASTFRAG;      ip_reasslen = offset + len;      LWIP_DEBUGF(IP_REASS_DEBUG,       ("ip_reass: last fragment seen, total len %d\n",        ip_reasslen));    }    /* Finally, we check if we have a full packet in the buffer. We do       this by checking if we have the last fragment and if all bits       in the bitmap are set. */    if (ip_reassflags & IP_REASS_FLAG_LASTFRAG) {      /* Check all bytes up to and including all but the last byte in         the bitmap. */      for (i = 0; i < ip_reasslen / (8 * 8) - 1; ++i) {  if (ip_reassbitmap[i] != 0xff) {    LWIP_DEBUGF(IP_REASS_DEBUG,     ("ip_reass: last fragment seen, bitmap %d/%d failed (%x)\n",      i, ip_reasslen / (8 * 8) - 1, ip_reassbitmap[i]));    goto nullreturn;  }      }      /* Check the last byte in the bitmap. It should contain just the         right amount of bits. */      if (ip_reassbitmap[ip_reasslen / (8 * 8)] !=    (u8_t) ~ bitmap_bits[ip_reasslen / 8 & 7]) {  LWIP_DEBUGF(IP_REASS_DEBUG,         ("ip_reass: last fragment seen, bitmap %d didn't contain %x (%x)\n",    ip_reasslen / (8 * 8), ~bitmap_bits[ip_reasslen / 8 & 7],    ip_reassbitmap[ip_reasslen / (8 * 8)]));  goto nullreturn;      }      /* Pretend to be a "normal" (i.e., not fragmented) IP packet         from now on. */      ip_reasslen += IP_HLEN;      IPH_LEN_SET(iphdr, htons(ip_reasslen));      IPH_OFFSET_SET(iphdr, 0);      IPH_CHKSUM_SET(iphdr, 0);      /* modified by hgxxx, add (void *) before iphdr */      IPH_CHKSUM_SET(iphdr, inet_chksum((void *)iphdr, IP_HLEN));      /* If we have come this far, we have a full packet in the         buffer, so we allocate a pbuf and copy the packet into it. We         also reset the timer. */      sys_untimeout(ip_reass_timer, NULL);      ip_reasstmr = 0;      pbuf_free(p);      p = pbuf_alloc(PBUF_LINK, ip_reasslen, PBUF_POOL);      if (p != NULL) {  i = 0;  for (q = p; q != NULL; q = q->next) {    /* Copy enough bytes to fill this pbuf in the chain. The       available data in the pbuf is given by the q->len       variable. */    LWIP_DEBUGF(IP_REASS_DEBUG,     ("ip_reass: memcpy from %p (%d) to %p, %d bytes\n",      &ip_reassbuf[i], i, q->payload,      q->len > ip_reasslen - i ? ip_reasslen - i : q->len));    memcpy(q->payload, &ip_reassbuf[i],    q->len > ip_reasslen - i ? ip_reasslen - i : q->len);    i += q->len;  }  IPFRAG_STATS_INC(ip_frag.fw);      } else {  IPFRAG_STATS_INC(ip_frag.memerr);      }      LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass: p %p\n", (void*)p));      return p;    }  }nullreturn:  IPFRAG_STATS_INC(ip_frag.drop);  pbuf_free(p);  return NULL;}#define MAX_MTU 1500static u8_t buf[MEM_ALIGN_SIZE(MAX_MTU)];/** * Fragment an IP packet if too large * * Chop the packet in mtu sized chunks and send them in order * by using a fixed size static memory buffer (PBUF_ROM) */err_t ip_frag(struct pbuf *p, struct netif *netif, struct ip_addr *dest){  struct pbuf *rambuf;  struct pbuf *header;  struct ip_hdr *iphdr;  u16_t nfb = 0;  u16_t left, cop;  u16_t mtu = netif->mtu;  u16_t ofo, omf;  u16_t last;  u16_t poff = IP_HLEN;  u16_t tmp;  /* Get a RAM based MTU sized pbuf */  rambuf = pbuf_alloc(PBUF_LINK, 0, PBUF_REF);  rambuf->tot_len = rambuf->len = mtu;  rambuf->payload = MEM_ALIGN((void *)buf);  /* Copy the IP header in it */  iphdr = rambuf->payload;  /* modified by hgxxx, add (void *) before iphdr */  memcpy((void *)iphdr, p->payload, IP_HLEN);  /* Save original offset */  tmp = ntohs(IPH_OFFSET(iphdr));  ofo = tmp & IP_OFFMASK;  omf = tmp & IP_MF;  left = p->tot_len - IP_HLEN;  while (left) {    last = (left <= mtu - IP_HLEN);    /* Set new offset and MF flag */    ofo += nfb;    tmp = omf | (IP_OFFMASK & (ofo));    if (!last)      tmp = tmp | IP_MF;    IPH_OFFSET_SET(iphdr, htons(tmp));    /* Fill this fragment */    nfb = (mtu - IP_HLEN) / 8;    cop = last ? left : nfb * 8;    p = copy_from_pbuf(p, &poff, (u8_t *) iphdr + IP_HLEN, cop);    /* Correct header */    IPH_LEN_SET(iphdr, htons(cop + IP_HLEN));    IPH_CHKSUM_SET(iphdr, 0);    /* modified by hgxxx, add (void *) before iphdr */    IPH_CHKSUM_SET(iphdr, inet_chksum((void *)iphdr, IP_HLEN));    if (last)      pbuf_realloc(rambuf, left + IP_HLEN);    /* This part is ugly: we alloc a RAM based pbuf for      * the link level header for each chunk and then      * free it.A PBUF_ROM style pbuf for which pbuf_header     * worked would make things simpler.     */    header = pbuf_alloc(PBUF_LINK, 0, PBUF_RAM);    pbuf_chain(header, rambuf);    netif->output(netif, header, dest);    IPFRAG_STATS_INC(ip_frag.xmit);    pbuf_free(header);    left -= cop;  }  pbuf_free(rambuf);  return ERR_OK;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美高清视频在线高清观看mv色露露十八 | 亚洲在线视频网站| 免费日本视频一区| 国产激情一区二区三区桃花岛亚洲| 91毛片在线观看| 久久婷婷国产综合国色天香| 亚洲精品视频在线观看免费| 国产一区二区在线观看免费| 欧美网站大全在线观看| 国产精品国产成人国产三级 | 欧美精品日日鲁夜夜添| 国产精品久久综合| 国内精品久久久久影院色| 欧美日韩黄色一区二区| 国产精品久久久久久久久图文区| 久久99精品国产麻豆婷婷| 欧美亚洲动漫精品| 亚洲精品国产一区二区精华液 | 狠狠色综合播放一区二区| 欧美日韩一卡二卡| 亚洲激情综合网| 成人美女视频在线观看| 国产欧美一区二区精品性色超碰 | 国产欧美日韩一区二区三区在线观看| 蜜芽一区二区三区| 在线电影一区二区三区| 亚洲一区二区三区中文字幕在线 | 成人精品小蝌蚪| 久久精品亚洲麻豆av一区二区 | 日韩和欧美一区二区三区| 色老综合老女人久久久| 亚洲另类春色国产| 91在线免费视频观看| 1000部国产精品成人观看| 成人国产精品免费网站| 国产精品久久777777| 成人免费黄色大片| 亚洲人成精品久久久久久| 99国产精品国产精品毛片| 亚洲人亚洲人成电影网站色| 91在线观看污| 亚洲一二三区不卡| 欧美日韩一级二级三级| 男女男精品视频| 久久女同精品一区二区| 成人性色生活片| 亚洲裸体xxx| 欧美日韩在线电影| 五月婷婷激情综合网| 91精品国产综合久久精品性色| 免费观看91视频大全| 精品国产a毛片| av中文字幕亚洲| 亚洲自拍偷拍欧美| 欧美一区二区三区四区视频| 九九久久精品视频| 国产精品久久久久9999吃药| 欧美日韩一区二区三区四区五区 | 精品国产麻豆免费人成网站| 国产精品综合视频| 亚洲乱码中文字幕综合| 欧美一区二区精品在线| 国产v综合v亚洲欧| 一区二区三区免费| 欧美电视剧在线看免费| 99精品热视频| 麻豆精品一区二区综合av| 中文在线资源观看网站视频免费不卡 | 欧美午夜不卡视频| 国产精品亚洲成人| 亚洲1区2区3区视频| 欧美精品一区二区三区四区 | 7777精品伊人久久久大香线蕉完整版 | 国产午夜精品久久久久久免费视| av在线一区二区三区| 免播放器亚洲一区| 亚洲精品国产成人久久av盗摄| 欧美一三区三区四区免费在线看| 国产suv精品一区二区6| 亚洲国产日韩在线一区模特| 久久精品亚洲精品国产欧美| 欧美日韩国产电影| 不卡一区二区中文字幕| 日韩极品在线观看| 一区二区三区日韩欧美| 国产精品天天看| 日韩午夜激情视频| 欧美日韩中文精品| av网站一区二区三区| 久久99久久99小草精品免视看| 亚洲美女视频在线| 国产精品久久久久久久裸模| 久久伊人蜜桃av一区二区| 777久久久精品| 欧洲精品一区二区三区在线观看| 国产经典欧美精品| 黄色精品一二区| 青青青爽久久午夜综合久久午夜| 一区二区三区四区亚洲| 国产欧美日韩不卡免费| 欧美精品一区二区久久久| 3d成人动漫网站| 欧美日韩在线播| 日本韩国精品一区二区在线观看| 懂色av一区二区在线播放| 国产一区二区导航在线播放| 久久精品免费观看| 免费成人性网站| 免费欧美在线视频| 美女尤物国产一区| 蜜桃av一区二区在线观看| 免费高清在线视频一区·| 日韩va亚洲va欧美va久久| 石原莉奈在线亚洲三区| 午夜不卡在线视频| 调教+趴+乳夹+国产+精品| 丝袜亚洲精品中文字幕一区| 图片区小说区区亚洲影院| 三级在线观看一区二区| 麻豆高清免费国产一区| 美女一区二区在线观看| 看国产成人h片视频| 国模大尺度一区二区三区| 激情六月婷婷综合| 国产成人免费9x9x人网站视频| 国产69精品久久777的优势| 成人国产精品视频| 色就色 综合激情| 欧美精品自拍偷拍| 欧美一级在线免费| 精品福利在线导航| 国产精品青草久久| 亚洲综合在线免费观看| 婷婷国产在线综合| 激情成人午夜视频| 91在线视频在线| 欧美精品精品一区| 久久天堂av综合合色蜜桃网| 亚洲国产精品成人综合| 亚洲欧美一区二区三区国产精品| 亚洲尤物视频在线| 激情综合网av| 色综合久久久久久久久| 欧美裸体bbwbbwbbw| 欧美xxxxxxxxx| 亚洲同性gay激情无套| 性感美女极品91精品| 狠狠v欧美v日韩v亚洲ⅴ| www.亚洲色图.com| 欧美日韩激情一区二区| 欧美国产1区2区| 亚洲成人av资源| 国产精品一区二区无线| 色婷婷久久一区二区三区麻豆| 91精品婷婷国产综合久久| 国产精品久久久久三级| 日本美女一区二区三区视频| 成人h版在线观看| 欧美精品aⅴ在线视频| 国产精品传媒视频| 麻豆国产精品一区二区三区| a4yy欧美一区二区三区| 日韩西西人体444www| 一区二区三区免费在线观看| 国产在线乱码一区二区三区| 欧美日韩精品福利| 亚洲人成精品久久久久久| 激情成人午夜视频| 制服丝袜av成人在线看| 亚洲日本免费电影| 国产精品18久久久久久vr| 欧美日韩国产首页| 亚洲天堂久久久久久久| 国产一区二区成人久久免费影院| 精品1区2区3区| 亚洲免费在线观看| 成人福利在线看| 国产日韩亚洲欧美综合| 免费观看30秒视频久久| 欧美色精品天天在线观看视频| 国产精品国产成人国产三级 | 久久综合中文字幕| 秋霞av亚洲一区二区三| 欧美日韩精品电影| 亚洲国产精品视频| 91国产视频在线观看| 亚洲欧美综合色| 高清不卡在线观看| 久久久精品综合| 六月婷婷色综合| 日韩欧美视频在线| 免费在线成人网| 91精品国产一区二区| 亚洲国产成人av网| 欧美专区日韩专区| 亚洲一区二区中文在线| 在线一区二区视频| 亚洲sss视频在线视频| 欧美午夜理伦三级在线观看| 夜夜爽夜夜爽精品视频|