亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
亚洲少妇最新在线视频| 国产精品福利一区| 欧美亚洲国产一区二区三区va| 麻豆极品一区二区三区| 99久久久久免费精品国产| 26uuu亚洲| 精品福利一区二区三区| 久久伊99综合婷婷久久伊| 久久午夜羞羞影院免费观看| 久久新电视剧免费观看| 久久久久久久久久久久久夜| 国产精品嫩草影院com| 国产精品乱码一区二区三区软件 | 亚洲欧美日韩电影| 国产精品国产自产拍高清av王其| 日本一区二区三区国色天香 | 亚洲一区免费观看| 日韩精品五月天| 国产九色精品成人porny| 成人av电影在线| 欧美日韩亚洲高清一区二区| 欧美一区二区高清| 欧美国产综合一区二区| 亚洲最大成人网4388xx| 久久国产精品一区二区| 波多野结衣视频一区| 欧美日韩大陆一区二区| 欧美精品一区在线观看| 一区二区三区中文免费| 男男gaygay亚洲| 99精品久久免费看蜜臀剧情介绍| 欧洲亚洲精品在线| 久久新电视剧免费观看| 亚洲精品日韩专区silk| 精品一区二区免费看| 欧美一区二区三区视频免费 | 久久精品一区二区三区av| 亚洲天天做日日做天天谢日日欢| 日本在线播放一区二区三区| 成人一级黄色片| 欧美日韩黄视频| 国产精品国产三级国产| 蜜臀av一级做a爰片久久| 99免费精品视频| 精品福利一二区| 亚洲成人免费影院| 99re热这里只有精品免费视频| 欧美成人三级在线| 亚洲成人tv网| 色综合久久九月婷婷色综合| 久久这里只有精品6| 日韩国产在线一| 色婷婷久久综合| 国产精品入口麻豆原神| 国产在线精品免费| 91精品国产乱码久久蜜臀| 亚洲欧洲av另类| 国产福利一区二区| 精品国产免费人成在线观看| 久久久亚洲精品一区二区三区| 亚洲gay无套男同| 欧美最猛性xxxxx直播| 亚洲视频中文字幕| 成人短视频下载| 国产精品久久久爽爽爽麻豆色哟哟| 国产在线不卡一卡二卡三卡四卡| 欧美浪妇xxxx高跟鞋交| 亚洲国产一区二区视频| 91电影在线观看| 亚洲韩国精品一区| 在线视频你懂得一区二区三区| 国产精品久久久久影视| www.日本不卡| 亚洲欧美福利一区二区| 91美女片黄在线| 亚洲精品亚洲人成人网在线播放| 99riav久久精品riav| 亚洲精品综合在线| 欧美色欧美亚洲另类二区| 亚洲成人第一页| 日韩午夜激情电影| 国产原创一区二区| 国产欧美一区二区精品婷婷| 国产精品一区二区视频| 亚洲国产精华液网站w| 波多野洁衣一区| 亚洲免费观看高清完整版在线观看熊 | 亚洲精品在线免费播放| 国产精品亚洲午夜一区二区三区| 国产欧美一区二区精品性色| 波波电影院一区二区三区| 亚洲精品高清在线| 欧美日韩在线直播| 久久se精品一区二区| 欧美国产精品专区| 欧美午夜精品理论片a级按摩| 国产裸体歌舞团一区二区| 国产精品免费视频观看| 欧美性猛交xxxxxxxx| 精品在线亚洲视频| 国产精品萝li| 欧美乱熟臀69xxxxxx| 九九精品视频在线看| 椎名由奈av一区二区三区| 91精品国产免费久久综合| 国产成人精品网址| 午夜精品福利视频网站| 亚洲精品一区二区三区福利| 色悠悠久久综合| 国产一区二区精品在线观看| 一区二区三区不卡视频| 久久久精品免费免费| 欧美中文字幕一区二区三区亚洲| 韩国精品一区二区| 亚洲一区在线视频| 国产偷国产偷亚洲高清人白洁| 在线观看精品一区| 久久精品国内一区二区三区| 亚洲免费大片在线观看| 久久亚洲精精品中文字幕早川悠里| 91黄色小视频| 粉嫩av一区二区三区粉嫩 | www日韩大片| 91久久精品网| 成人a免费在线看| 国内精品国产成人| 日本怡春院一区二区| 一区二区三区四区av| 国产精品网站在线播放| 精品国产乱码久久久久久图片 | 久久精品视频一区二区三区| 欧美四级电影网| 91在线精品一区二区| 国产伦精品一区二区三区视频青涩 | 国产精品1区2区| 美女视频一区二区| 日韩在线播放一区二区| 一区二区久久久| 亚洲精品乱码久久久久久黑人| 久久精品一区蜜桃臀影院| 欧美变态凌虐bdsm| 欧美一区二区三区白人| 欧美区在线观看| 欧美三级电影网| 欧美日韩国产首页| 欧美日韩二区三区| 欧美在线影院一区二区| 色综合一区二区| 欧日韩精品视频| 欧美日韩在线三区| 欧美日高清视频| 日韩亚洲欧美一区二区三区| 在线播放一区二区三区| 在线播放/欧美激情| 欧美日韩视频在线观看一区二区三区| 色女孩综合影院| 欧美日韩国产精品成人| 欧美日韩电影在线播放| 欧美一区二区成人6969| 日韩欧美中文字幕一区| 337p粉嫩大胆色噜噜噜噜亚洲| 精品国产第一区二区三区观看体验| 91精品国产91热久久久做人人| 51精品久久久久久久蜜臀| 日韩三级在线观看| 国产日韩精品视频一区| 国产精品美女久久久久久久久| 国产精品免费观看视频| 亚洲一区二区三区视频在线播放| 亚洲成人午夜电影| 久草中文综合在线| 国产成人精品免费| 色狠狠色狠狠综合| 91麻豆精品国产91久久久久| 欧美xxxxx牲另类人与| 久久精品亚洲国产奇米99| 国产精品久久久久久久久图文区| 亚洲免费观看高清完整版在线观看| 亚洲一区二区三区视频在线播放| 琪琪一区二区三区| 成人免费高清在线| 亚洲午夜精品网| 视频一区中文字幕| 99久久er热在这里只有精品15| 91老司机福利 在线| 欧美一区永久视频免费观看| 国产欧美视频一区二区| 亚洲四区在线观看| 全国精品久久少妇| kk眼镜猥琐国模调教系列一区二区| 欧美三级电影精品| 国产精品色眯眯| 爽好久久久欧美精品| 成人av在线观| 精品欧美一区二区久久 | 一本色道综合亚洲| 精品国产乱码91久久久久久网站| 亚洲三级在线看| 国产乱人伦偷精品视频免下载| 在线观看中文字幕不卡|