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

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

?? ip_frag.c

?? 包含lwip這個精簡IP協議棧的ucos源代碼.
?? C
字號:
/* @file *  * This is the IP packet segmentation and reassembly implementation. * *//* * 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> *  */#include <string.h>#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"/* * 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"));    memcpy(iphdr, 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);      IPH_CHKSUM_SET(iphdr, inet_chksum(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",      (void *)&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;  memcpy(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);    IPH_CHKSUM_SET(iphdr, inet_chksum(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一区二区三区免费野_久草精品视频
中文字幕在线不卡国产视频| 精品国产免费一区二区三区四区| 激情五月播播久久久精品| 亚洲国产wwwccc36天堂| 亚洲国产综合在线| 午夜精品久久久久久久99水蜜桃| 一区二区三区在线视频播放| 亚洲国产精品视频| 肉肉av福利一精品导航| 日韩av中文字幕一区二区三区 | 国产麻豆成人精品| 国产精品影视网| 国产精品综合视频| 成人精品一区二区三区四区| 成人成人成人在线视频| 91麻豆精东视频| 欧美午夜不卡视频| 欧美一级片在线看| 中文字幕的久久| 亚洲在线成人精品| 麻豆高清免费国产一区| 国产成人8x视频一区二区| 色综合天天综合网国产成人综合天| 色噜噜夜夜夜综合网| 91麻豆精品久久久久蜜臀| 欧美大胆人体bbbb| 中文字幕巨乱亚洲| 五月激情丁香一区二区三区| 精品一区二区在线免费观看| 成人爽a毛片一区二区免费| 欧美性极品少妇| 精品999在线播放| 亚洲蜜臀av乱码久久精品| 免费在线看成人av| 91色视频在线| 精品久久久久香蕉网| 一区二区中文视频| 蜜桃av一区二区在线观看| 91视视频在线观看入口直接观看www| 欧美视频在线一区| 国产农村妇女毛片精品久久麻豆| 亚洲综合在线视频| 国产一区在线观看视频| 欧美三级中文字| 亚洲国产成人午夜在线一区| 日本不卡高清视频| 91免费视频网| 中文幕一区二区三区久久蜜桃| 午夜久久久影院| 99国产精品久久久久久久久久| 56国语精品自产拍在线观看| 亚洲免费在线电影| 国产成都精品91一区二区三| 欧美一区二区三区在线电影| 亚洲欧美国产三级| 盗摄精品av一区二区三区| 日韩一区二区三区电影在线观看| 亚洲综合在线免费观看| 成人免费视频网站在线观看| 26uuu国产电影一区二区| 性久久久久久久久| 日本乱人伦aⅴ精品| 中文一区二区在线观看| 国产在线观看免费一区| 日韩视频在线一区二区| 丝袜美腿亚洲色图| 欧美日韩高清一区二区三区| 亚洲欧洲成人自拍| 成人三级在线视频| 中文字幕+乱码+中文字幕一区| 韩国成人在线视频| 欧美成va人片在线观看| 久久精品理论片| 欧美草草影院在线视频| 国产在线日韩欧美| 26uuu色噜噜精品一区二区| 久久精品国产精品亚洲综合| 日韩欧美在线网站| 国产一区二区h| 欧美国产一区在线| av一区二区三区黑人| 欧美激情一区二区三区在线| 国产成人综合在线| 国产精品国产三级国产有无不卡| 久久电影网站中文字幕| 欧美成人综合网站| 国产不卡在线播放| 国产精品久久久一本精品 | 欧美一级xxx| 精品亚洲欧美一区| 国产免费成人在线视频| 菠萝蜜视频在线观看一区| 国产精品狼人久久影院观看方式| 99精品欧美一区二区蜜桃免费| 亚洲欧美日韩国产中文在线| 欧美三级欧美一级| 精品午夜久久福利影院| 亚洲欧洲精品一区二区三区| 欧美色图免费看| 精品在线观看视频| 国产精品狼人久久影院观看方式| 色噜噜偷拍精品综合在线| 日本不卡中文字幕| 久久久精品国产99久久精品芒果 | 亚洲国产aⅴ天堂久久| 欧美一级日韩免费不卡| 成人免费av在线| 亚洲国产一区二区三区青草影视| 日韩精品一区二区三区视频在线观看| 国产精品88av| 亚洲一区二区成人在线观看| 日韩午夜在线观看视频| 99久久精品国产精品久久| 日韩经典中文字幕一区| 国产精品国产精品国产专区不片| 欧美日韩欧美一区二区| 成人美女在线视频| 蜜臀av性久久久久蜜臀av麻豆| 国产精品成人一区二区三区夜夜夜| 欧美视频日韩视频| 99久久伊人久久99| 久久99久久久欧美国产| 一区二区三区日韩精品视频| 国产午夜精品久久| 欧美一区二区免费视频| 在线看国产一区| 成人听书哪个软件好| 久久66热偷产精品| 亚洲高清免费在线| 亚洲欧美另类小说| 欧美激情在线一区二区| 精品国产乱码久久久久久浪潮| 一本色道久久加勒比精品| 韩国视频一区二区| 美女爽到高潮91| 日韩精品一级二级| 亚洲一区二区三区美女| 中文字幕日韩一区二区| 国产精品―色哟哟| 久久精品亚洲麻豆av一区二区 | 成人avav影音| 国产乱国产乱300精品| 免费亚洲电影在线| 日韩av二区在线播放| 亚洲成人动漫精品| 亚洲二区在线观看| 天堂成人国产精品一区| 亚洲国产精品一区二区www| 亚洲另类在线视频| 日韩欧美精品在线视频| 欧美一区二区三区公司| 亚洲精品国产无套在线观| 国产日产精品一区| 国产喂奶挤奶一区二区三区| 国产精品―色哟哟| 2024国产精品| 亚洲成av人片在线| 免费xxxx性欧美18vr| 91亚洲男人天堂| 精品国产网站在线观看| 一区二区三区四区国产精品| 精彩视频一区二区| 欧美日韩精品一二三区| 国产精品青草久久| 久久精品99国产精品| 欧美性猛交xxxx乱大交退制版 | 亚洲欧洲成人av每日更新| 美女网站在线免费欧美精品| 91福利社在线观看| 国产精品欧美一区喷水| 国产乱妇无码大片在线观看| 欧美福利视频一区| 夜夜爽夜夜爽精品视频| voyeur盗摄精品| 国产欧美日韩久久| 国内成+人亚洲+欧美+综合在线| 欧美日韩小视频| 亚洲最色的网站| 91原创在线视频| 欧美国产日韩a欧美在线观看| 日av在线不卡| 欧美片网站yy| 亚洲一区二区三区小说| 91丨国产丨九色丨pron| 国产日韩精品一区二区三区| 国模套图日韩精品一区二区| 日韩女优电影在线观看| 日本在线观看不卡视频| 欧美日韩国产天堂| 夜夜嗨av一区二区三区中文字幕| 92国产精品观看| 综合激情成人伊人| 95精品视频在线| 亚洲免费观看高清完整版在线| 成人福利视频在线看| 中文字幕欧美激情| 99riav久久精品riav| 亚洲特黄一级片| 色乱码一区二区三区88 | 中文字幕中文乱码欧美一区二区|