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

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

?? pbuf.c

?? 君正早期ucos系統(只有早期的才不沒有打包成庫),MPLAYER,文件系統,圖片解碼,瀏覽,電子書,錄音,想學ucos,識貨的人就下吧 russblock fmradio explore set
?? C
?? 第 1 頁 / 共 3 頁
字號:
/** * @file * Packet buffer management * * Packets are built from the pbuf data structure. It supports dynamic * memory allocation for packet contents or can reference externally * managed packet contents both in RAM and ROM. Quick allocation for * incoming packets is provided through pools with fixed sized pbufs. * * A packet may span over multiple pbufs, chained as a singly linked * list. This is called a "pbuf chain". * * Multiple packets may be queued, also using this singly linked list. * This is called a "packet queue". *  * So, a packet queue consists of one or more pbuf chains, each of * which consist of one or more pbufs. Currently, queues are only * supported in a limited section of lwIP, this is the etharp queueing * code. Outside of this section no packet queues are supported yet. *  * The differences between a pbuf chain and a packet queue are very * precise but subtle.  * * The last pbuf of a packet has a ->tot_len field that equals the * ->len field. It can be found by traversing the list. If the last * pbuf of a packet has a ->next field other than NULL, more packets * are on the queue. * * Therefore, looping through a pbuf of a single packet, has an * loop end condition (tot_len == p->len), NOT (next == NULL). *//* * 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> * */#include <string.h>#include "lwip/opt.h"#include "lwip/stats.h"#include "lwip/def.h"#include "lwip/mem.h"#include "lwip/memp.h"#include "lwip/pbuf.h"#include "lwip/sys.h"#include "arch/perf.h"static u8_t pbuf_pool_memory[MEM_ALIGNMENT - 1 + PBUF_POOL_SIZE * MEM_ALIGN_SIZE(PBUF_POOL_BUFSIZE + sizeof(struct pbuf))];#if !SYS_LIGHTWEIGHT_PROTstatic volatile u8_t pbuf_pool_free_lock, pbuf_pool_alloc_lock;static sys_sem_t pbuf_pool_free_sem;#endifstatic struct pbuf *pbuf_pool = NULL;/** * Initializes the pbuf module. * * A large part of memory is allocated for holding the pool of pbufs. * The size of the individual pbufs in the pool is given by the size * parameter, and the number of pbufs in the pool by the num parameter. * * After the memory has been allocated, the pbufs are set up. The * ->next pointer in each pbuf is set up to point to the next pbuf in * the pool. * */voidpbuf_init(void){  struct pbuf *p, *q = NULL;  u16_t i;  pbuf_pool = (struct pbuf *)MEM_ALIGN(pbuf_pool_memory);#if PBUF_STATS  lwip_stats.pbuf.avail = PBUF_POOL_SIZE;#endif /* PBUF_STATS */  /* Set up ->next pointers to link the pbufs of the pool together */  p = pbuf_pool;  for(i = 0; i < PBUF_POOL_SIZE; ++i) {    p->next = (struct pbuf *)((u8_t *)p + PBUF_POOL_BUFSIZE + sizeof(struct pbuf));    p->len = p->tot_len = PBUF_POOL_BUFSIZE;    p->payload = MEM_ALIGN((void *)((u8_t *)p + sizeof(struct pbuf)));    p->flags = PBUF_FLAG_POOL;    q = p;    p = p->next;  }  /* The ->next pointer of last pbuf is NULL to indicate that there     are no more pbufs in the pool */  q->next = NULL;#if !SYS_LIGHTWEIGHT_PROT  pbuf_pool_alloc_lock = 0;  pbuf_pool_free_lock = 0;  pbuf_pool_free_sem = sys_sem_new(1);#endif}/** * @internal only called from pbuf_alloc() */static struct pbuf *pbuf_pool_alloc(void){  struct pbuf *p = NULL;  SYS_ARCH_DECL_PROTECT(old_level);  SYS_ARCH_PROTECT(old_level);#if !SYS_LIGHTWEIGHT_PROT  /* Next, check the actual pbuf pool, but if the pool is locked, we     pretend to be out of buffers and return NULL. */  if (pbuf_pool_free_lock) {#if PBUF_STATS    ++lwip_stats.pbuf.alloc_locked;#endif /* PBUF_STATS */    return NULL;  }  pbuf_pool_alloc_lock = 1;  if (!pbuf_pool_free_lock) {#endif /* SYS_LIGHTWEIGHT_PROT */    p = pbuf_pool;    if (p) {      pbuf_pool = p->next;    }#if !SYS_LIGHTWEIGHT_PROT#if PBUF_STATS  } else {    ++lwip_stats.pbuf.alloc_locked;#endif /* PBUF_STATS */  }  pbuf_pool_alloc_lock = 0;#endif /* SYS_LIGHTWEIGHT_PROT */#if PBUF_STATS  if (p != NULL) {    ++lwip_stats.pbuf.used;    if (lwip_stats.pbuf.used > lwip_stats.pbuf.max) {      lwip_stats.pbuf.max = lwip_stats.pbuf.used;    }  }#endif /* PBUF_STATS */  SYS_ARCH_UNPROTECT(old_level);  return p;}/** * Allocates a pbuf of the given type (possibly a chain for PBUF_POOL type). * * The actual memory allocated for the pbuf is determined by the * layer at which the pbuf is allocated and the requested size * (from the size parameter). * * @param flag this parameter decides how and where the pbuf * should be allocated as follows: * * - PBUF_RAM: buffer memory for pbuf is allocated as one large *             chunk. This includes protocol headers as well. * - PBUF_ROM: no buffer memory is allocated for the pbuf, even for *             protocol headers. Additional headers must be prepended *             by allocating another pbuf and chain in to the front of *             the ROM pbuf. It is assumed that the memory used is really *             similar to ROM in that it is immutable and will not be *             changed. Memory which is dynamic should generally not *             be attached to PBUF_ROM pbufs. Use PBUF_REF instead. * - PBUF_REF: no buffer memory is allocated for the pbuf, even for *             protocol headers. It is assumed that the pbuf is only *             being used in a single thread. If the pbuf gets queued, *             then pbuf_take should be called to copy the buffer. * - PBUF_POOL: the pbuf is allocated as a pbuf chain, with pbufs from *              the pbuf pool that is allocated during pbuf_init(). * * @return the allocated pbuf. If multiple pbufs where allocated, this * is the first pbuf of a pbuf chain. */struct pbuf *pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag){  struct pbuf *p, *q, *r;  u16_t offset;  s32_t rem_len; /* remaining length */  LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_alloc(length=%"U16_F")\n", length));  /* determine header offset */  offset = 0;  switch (l) {  case PBUF_TRANSPORT:    /* add room for transport (often TCP) layer header */    offset += PBUF_TRANSPORT_HLEN;    /* FALLTHROUGH */  case PBUF_IP:    /* add room for IP layer header */    offset += PBUF_IP_HLEN;    /* FALLTHROUGH */  case PBUF_LINK:    /* add room for link layer header */    offset += PBUF_LINK_HLEN;    break;  case PBUF_RAW:    break;  default:    LWIP_ASSERT("pbuf_alloc: bad pbuf layer", 0);    return NULL;  }  switch (flag) {  case PBUF_POOL:    /* allocate head of pbuf chain into p */    p = pbuf_pool_alloc();    LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_alloc: allocated pbuf %p\n", (void *)p));    if (p == NULL) {#if PBUF_STATS      ++lwip_stats.pbuf.err;#endif /* PBUF_STATS */      return NULL;    }    p->next = NULL;    /* make the payload pointer point 'offset' bytes into pbuf data memory */    p->payload = MEM_ALIGN((void *)((u8_t *)p + (sizeof(struct pbuf) + offset)));    LWIP_ASSERT("pbuf_alloc: pbuf p->payload properly aligned",            ((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0);    /* the total length of the pbuf chain is the requested size */    p->tot_len = length;    /* set the length of the first pbuf in the chain */    p->len = length > PBUF_POOL_BUFSIZE - offset? PBUF_POOL_BUFSIZE - offset: length;    /* set reference count (needed here in case we fail) */    p->ref = 1;    /* now allocate the tail of the pbuf chain */    /* remember first pbuf for linkage in next iteration */    r = p;    /* remaining length to be allocated */    rem_len = length - p->len;    /* any remaining pbufs to be allocated? */    while (rem_len > 0) {      q = pbuf_pool_alloc();      if (q == NULL) {       LWIP_DEBUGF(PBUF_DEBUG | 2, ("pbuf_alloc: Out of pbufs in pool.\n"));#if PBUF_STATS        ++lwip_stats.pbuf.err;#endif /* PBUF_STATS */        /* free chain so far allocated */        pbuf_free(p);        /* bail out unsuccesfully */        return NULL;      }      q->next = NULL;      /* make previous pbuf point to this pbuf */      r->next = q;      /* set total length of this pbuf and next in chain */      q->tot_len = rem_len;      /* this pbuf length is pool size, unless smaller sized tail */      q->len = rem_len > PBUF_POOL_BUFSIZE? PBUF_POOL_BUFSIZE: rem_len;      q->payload = (void *)((u8_t *)q + sizeof(struct pbuf));      LWIP_ASSERT("pbuf_alloc: pbuf q->payload properly aligned",              ((mem_ptr_t)q->payload % MEM_ALIGNMENT) == 0);      q->ref = 1;      /* calculate remaining length to be allocated */      rem_len -= q->len;      /* remember this pbuf for linkage in next iteration */      r = q;    }    /* end of chain */    /*r->next = NULL;*/    break;  case PBUF_RAM:    /* If pbuf is to be allocated in RAM, allocate memory for it. */    p = mem_malloc(MEM_ALIGN_SIZE(sizeof(struct pbuf) + offset) + MEM_ALIGN_SIZE(length));    if (p == NULL) {      return NULL;    }    /* Set up internal structure of the pbuf. */    p->payload = MEM_ALIGN((void *)((u8_t *)p + sizeof(struct pbuf) + offset));    p->len = p->tot_len = length;    p->next = NULL;    p->flags = PBUF_FLAG_RAM;    LWIP_ASSERT("pbuf_alloc: pbuf->payload properly aligned",           ((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0);    break;  /* pbuf references existing (non-volatile static constant) ROM payload? */  case PBUF_ROM:

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精品乱码久久久久久久久| 欧美性做爰猛烈叫床潮| 亚洲午夜av在线| 亚洲免费在线观看| 日本一区免费视频| 亚洲私人影院在线观看| 一色桃子久久精品亚洲| 亚洲免费在线视频一区 二区| 亚洲三级小视频| 依依成人综合视频| 午夜精品爽啪视频| 日本三级韩国三级欧美三级| 午夜精品久久久久久不卡8050 | 国产一区二区三区精品欧美日韩一区二区三区 | 成人性生交大片免费看中文网站| 九九九精品视频| 国产很黄免费观看久久| 成人a级免费电影| 色素色在线综合| 欧美精品自拍偷拍动漫精品| 日韩区在线观看| 欧美国产综合色视频| 亚洲欧美日韩国产成人精品影院| 亚洲图片有声小说| 青椒成人免费视频| 国产91丝袜在线观看| 色综合天天综合给合国产| 欧美日韩高清一区二区不卡| 欧美电视剧在线观看完整版| 国产欧美精品一区| 亚洲综合自拍偷拍| 国产自产高清不卡| 91成人国产精品| 亚洲精品在线免费观看视频| 日韩美女久久久| 久久99蜜桃精品| 日本黄色一区二区| 久久精品这里都是精品| 亚洲影院久久精品| 国产在线播放一区| 欧美日韩视频在线第一区| 久久欧美一区二区| 日本伊人色综合网| 色视频一区二区| 国产婷婷色一区二区三区在线| 亚洲自拍偷拍网站| 高清日韩电视剧大全免费| 这里只有精品电影| 亚洲精品日韩专区silk| 国模冰冰炮一区二区| 欧美日韩亚洲综合在线| 自拍偷拍亚洲激情| 国产精品69毛片高清亚洲| 日韩一区二区三区在线观看| 亚洲另类春色校园小说| 国产乱码精品一区二区三 | 国产成人精品影视| 欧美伦理影视网| 亚洲黄色在线视频| 成人av网站在线| 久久久久久免费毛片精品| 日韩二区在线观看| 欧美日韩国产一二三| 一区二区三区精品视频在线| 成人永久免费视频| 337p日本欧洲亚洲大胆精品| 日韩**一区毛片| 制服丝袜成人动漫| 免费成人美女在线观看.| 69堂国产成人免费视频| 亚洲国产精品麻豆| 欧美精品tushy高清| 洋洋av久久久久久久一区| 91视频观看免费| 亚洲三级久久久| 91视频.com| 亚洲成人三级小说| 欧美美女直播网站| 日韩中文欧美在线| 日韩欧美一区中文| 激情另类小说区图片区视频区| 精品国产一区二区亚洲人成毛片 | 欧美性大战久久| 亚洲精品国产无天堂网2021| 97se亚洲国产综合在线| 一区二区三区不卡视频| 欧美色图片你懂的| 日韩经典一区二区| 精品少妇一区二区三区免费观看| 精品一区二区三区在线播放 | 综合久久综合久久| 欧美日韩亚洲综合在线| 日本伊人午夜精品| 亚洲国产高清不卡| 欧美午夜免费电影| 麻豆中文一区二区| 中文字幕第一区二区| 日本韩国一区二区三区| 蜜臀av性久久久久蜜臀av麻豆| 欧美精品一区二区三区在线| 国产白丝精品91爽爽久久| 夜夜嗨av一区二区三区网页 | 久久91精品国产91久久小草| 国产色产综合产在线视频| 91蝌蚪porny成人天涯| 免费日韩伦理电影| 中文字幕一区二区视频| 4438x成人网最大色成网站| 国产精品一卡二卡在线观看| 亚洲欧美激情视频在线观看一区二区三区| 欧美三片在线视频观看| 国产成人精品综合在线观看| 亚洲成人免费av| 亚洲国产精品国自产拍av| 在线成人av网站| 91尤物视频在线观看| 日本欧美一区二区三区| 中文字幕在线播放不卡一区| 日韩亚洲欧美一区二区三区| 99国产精品久| 国产成人综合网站| 日韩中文字幕91| 亚洲综合丝袜美腿| 国产农村妇女精品| 精品人伦一区二区色婷婷| 91福利国产精品| 国产成人精品网址| 麻豆精品视频在线观看免费| 亚洲黄色在线视频| 国产精品久久久一本精品| 日韩网站在线看片你懂的| 色av成人天堂桃色av| 国产91精品露脸国语对白| 天堂资源在线中文精品| 亚洲欧美偷拍卡通变态| 国产区在线观看成人精品 | 国产乱国产乱300精品| 亚洲第一搞黄网站| 一区二区三区精品在线| 欧美国产一区二区在线观看| 日韩欧美一区二区不卡| 欧美日韩久久久一区| 成人免费看的视频| 激情深爱一区二区| 麻豆国产精品视频| 六月丁香综合在线视频| 天天av天天翘天天综合网 | 亚洲精品一区二区三区精华液| 欧美日韩综合在线| 色哟哟在线观看一区二区三区| 国产成人一级电影| 国产福利精品一区| 国产成人精品免费在线| 国产成人av福利| 国产成人免费视频网站| 成人国产电影网| 99re热视频这里只精品 | 亚洲成人自拍偷拍| 午夜精品国产更新| 午夜久久福利影院| 日韩二区三区在线观看| 九色porny丨国产精品| 国产一区日韩二区欧美三区| 国产麻豆9l精品三级站| 高清shemale亚洲人妖| 欧美性大战久久久久久久| 日本乱人伦aⅴ精品| 欧美视频完全免费看| 欧美日韩精品一区二区三区四区| 欧美日韩国产在线观看| 日韩精品一区二区在线| 中文字幕欧美区| 亚洲一区二区在线播放相泽| 天堂资源在线中文精品| 国内精品在线播放| 99精品久久久久久| 8x8x8国产精品| 国产日韩精品一区二区浪潮av| 亚洲三级在线播放| 蜜臀av亚洲一区中文字幕| 成人av网站免费| 欧美日韩高清影院| 欧美国产欧美亚州国产日韩mv天天看完整| 亚洲欧洲99久久| 日本不卡视频一二三区| 国产成人精品一区二区三区四区| 91浏览器在线视频| 日韩免费高清视频| 中文字幕乱码日本亚洲一区二区| 一区二区三区加勒比av| 国产美女精品一区二区三区| 不卡视频免费播放| 日韩欧美一区二区免费| 亚洲男女毛片无遮挡| 久久99精品久久久久| 91美女精品福利| 久久综合色播五月| 日韩专区欧美专区| 99久久精品费精品国产一区二区| 日韩一区二区高清|