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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? pbuf.c

?? “華為模塊(GTM900)+ ARM(LPC2104) + LWIP1.1”以PPP 方式實現(xiàn)GPRS 無線數(shù)據(jù)傳輸
?? 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 "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"#include "uart.h"static u8_t pbuf_pool_memory[(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 *)&pbuf_pool_memory[0];  LWIP_ASSERT("pbuf_init: pool aligned", (mem_ptr_t)pbuf_pool % MEM_ALIGNMENT == 0);#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);  //DEBUG_FUNCTION("pbuf_pool_alloc()");#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=%u)\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 */      DEBUG_ERR("pbuf_pool_alloc, but return NULL");      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 */	 DEBUG_ERR("pbuf_alloc: Out of pbufs in pool.");        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) {	DEBUG_ERR("mem_malloc: but return 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;

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产欧美精品一区| 亚洲欧洲综合另类在线| 亚洲综合在线免费观看| 不卡一区二区在线| 国产午夜精品久久| 高清在线观看日韩| 欧美激情艳妇裸体舞| 99久久综合精品| 亚洲婷婷国产精品电影人久久| 国产福利一区二区三区| 久久美女高清视频| 成人黄色小视频在线观看| 欧美高清一级片在线观看| 国产成人免费在线观看不卡| 日韩欧美精品在线| 成人在线视频首页| 亚洲欧洲精品一区二区三区| 国产专区欧美精品| 亚洲婷婷国产精品电影人久久| 91国产精品成人| 亚洲一区二区三区影院| 精品国免费一区二区三区| 精品亚洲porn| 欧美国产视频在线| 欧美人与性动xxxx| 久久99热这里只有精品| 久久久久久久久久久久久久久99| 播五月开心婷婷综合| 一区二区欧美国产| 欧美日韩激情一区二区| 激情六月婷婷综合| 国产精品成人免费在线| 欧美午夜精品一区| 美女在线一区二区| 国产精品国产自产拍在线| 日本道免费精品一区二区三区| 丝袜亚洲另类欧美| 国产精品福利av| 欧美三级中文字幕在线观看| 久久se精品一区二区| 亚洲精品菠萝久久久久久久| 欧美揉bbbbb揉bbbbb| 国产另类ts人妖一区二区| 亚洲综合丁香婷婷六月香| 欧美一级日韩免费不卡| 粉嫩一区二区三区在线看| 亚洲第一福利一区| 国产丝袜在线精品| 欧美三级日韩三级| 97久久精品人人澡人人爽| 婷婷综合在线观看| 久久九九全国免费| 欧美一级二级三级乱码| 91在线你懂得| 经典一区二区三区| 亚洲成人久久影院| 1024亚洲合集| 久久亚洲精华国产精华液| 欧美日韩亚州综合| 9人人澡人人爽人人精品| 麻豆91精品91久久久的内涵| 亚洲免费视频成人| 亚洲国产精品ⅴa在线观看| 欧美男生操女生| 91免费国产视频网站| 精品在线播放免费| 亚洲午夜视频在线观看| 久久久久久毛片| 91精品国产综合久久久久久| 国产精品羞羞答答xxdd| 午夜精品久久久久久久| 一区二区三区四区五区视频在线观看| 精品成a人在线观看| 日本精品一级二级| 在线观看精品一区| 不卡的av中国片| 国产成人免费视| 欧美精品一区二区不卡| 亚洲精品午夜久久久| 911精品国产一区二区在线| 亚洲国产精品一区二区久久 | 这里是久久伊人| 久久激情五月婷婷| 欧美美女喷水视频| 国产黄色精品网站| 亚洲成人一二三| ww亚洲ww在线观看国产| 久久综合色综合88| 97久久人人超碰| 成人av网在线| 成人网页在线观看| 成人亚洲一区二区一| 国产91精品免费| 国产高清视频一区| 国产美女精品在线| 韩国三级中文字幕hd久久精品| 国产在线观看一区二区| 狠狠色丁香久久婷婷综| 激情久久五月天| 日本午夜精品一区二区三区电影| 亚洲伊人色欲综合网| 亚洲视频每日更新| 国产精品国产三级国产普通话蜜臀| 综合久久综合久久| 亚洲久草在线视频| 亚洲人成亚洲人成在线观看图片| 亚洲综合免费观看高清完整版在线| 一区二区三区 在线观看视频| 亚洲一二三四久久| 日本亚洲天堂网| 九色porny丨国产精品| 国产盗摄一区二区| 色综合久久88色综合天天| 欧美婷婷六月丁香综合色| 国产日产欧美一区| 国产精品午夜在线观看| 综合久久国产九一剧情麻豆| 三级影片在线观看欧美日韩一区二区| 香蕉成人伊视频在线观看| 卡一卡二国产精品 | 欧美一级二级三级乱码| 欧美大片一区二区三区| 国产欧美日韩久久| 国产欧美视频在线观看| 亚洲电影第三页| 激情国产一区二区| 秋霞成人午夜伦在线观看| 成人深夜在线观看| 欧美视频一二三区| 精品国产凹凸成av人导航| 中文字幕在线不卡视频| 日韩精品每日更新| 波多野结衣一区二区三区| 欧美乱妇一区二区三区不卡视频| 精品国产91洋老外米糕| 亚洲一级在线观看| 国产曰批免费观看久久久| 成人精品一区二区三区中文字幕| 色94色欧美sute亚洲线路一久| 日韩欧美专区在线| 亚洲欧美日韩国产手机在线| 蜜桃久久久久久| 91免费观看在线| 精品日产卡一卡二卡麻豆| 亚洲色图.com| 懂色av噜噜一区二区三区av| 欧美性猛交xxxxxx富婆| 久久久91精品国产一区二区精品| 日韩成人午夜电影| 91麻豆.com| 日韩一区二区电影网| 亚洲国产你懂的| 丁香激情综合五月| 欧美最猛性xxxxx直播| 国产农村妇女毛片精品久久麻豆 | 国产精品乱人伦中文| 亚洲在线观看免费视频| 高清国产午夜精品久久久久久| 4438x成人网最大色成网站| 亚洲靠逼com| 成人激情动漫在线观看| 欧美成人高清电影在线| 老司机精品视频导航| 欧美日韩中文另类| 亚洲欧美另类小说视频| 9i看片成人免费高清| 久久久久久影视| 日韩成人一区二区| 欧美一区二区美女| 午夜免费欧美电影| 成人av电影在线| 国产精品视频一二三区| 国产精品一二三在| 337p亚洲精品色噜噜噜| 亚洲无人区一区| 日本伦理一区二区| 91丨九色丨黑人外教| 欧美伊人久久久久久久久影院| 一区二区三区精品视频在线| 91国产成人在线| 婷婷综合另类小说色区| 在线综合视频播放| 久色婷婷小香蕉久久| 久久日一线二线三线suv| 国产成人av资源| 日韩毛片视频在线看| 欧美在线免费播放| 日日夜夜精品免费视频| 欧美一区二区免费视频| 国产在线精品一区二区夜色| 欧美高清在线精品一区| 91久久免费观看| 天堂av在线一区| 国产亚洲精品bt天堂精选| 成人h精品动漫一区二区三区| 亚洲美女少妇撒尿| 日韩一区二区不卡| 成人综合婷婷国产精品久久| 亚洲靠逼com| 精品国产露脸精彩对白|