INET Framework for OMNeT++/OMNEST
|
Packet buffer management. More...
#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 <string.h>
Namespaces | |
inet | |
Copyright (c) 2005 Jan Ringo�, www.ringos.cz. | |
inet::tcp | |
Macros | |
#define | SIZEOF_STRUCT_PBUF LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf)) |
#define | PBUF_POOL_BUFSIZE_ALIGNED LWIP_MEM_ALIGN_SIZE(PBUF_POOL_BUFSIZE) |
#define | PBUF_POOL_IS_EMPTY() |
Functions | |
struct pbuf * | inet::tcp::pbuf_alloc (pbuf_layer layer, u16_t length, pbuf_type type) |
Allocates a pbuf of the given type (possibly a chain for PBUF_POOL type). More... | |
void | inet::tcp::pbuf_realloc (struct pbuf *p, u16_t new_len) |
Shrink a pbuf chain to a desired length. More... | |
u8_t | inet::tcp::pbuf_header (struct pbuf *p, s16_t header_size_increment) |
Adjusts the payload pointer to hide or reveal headers in the payload. More... | |
u8_t | inet::tcp::pbuf_free (struct pbuf *p) |
Dereference a pbuf chain or queue and deallocate any no-longer-used pbufs at the head of this chain or queue. More... | |
u8_t | inet::tcp::pbuf_clen (struct pbuf *p) |
Count number of pbufs in a chain. More... | |
void | inet::tcp::pbuf_ref (struct pbuf *p) |
Increment the reference count of the pbuf. More... | |
void | inet::tcp::pbuf_cat (struct pbuf *h, struct pbuf *t) |
Concatenate two pbufs (each may be a pbuf chain) and take over the caller's reference of the tail pbuf. More... | |
void | inet::tcp::pbuf_chain (struct pbuf *h, struct pbuf *t) |
Chain two pbufs (or pbuf chains) together. More... | |
struct pbuf * | inet::tcp::pbuf_dechain (struct pbuf *p) |
Dechains the first pbuf from its succeeding pbufs in the chain. More... | |
err_t | inet::tcp::pbuf_copy (struct pbuf *p_to, struct pbuf *p_from) |
Create PBUF_RAM copies of pbufs. More... | |
u16_t | inet::tcp::pbuf_copy_partial (struct pbuf *buf, void *dataptr, u16_t len, u16_t offset) |
Copy (part of) the contents of a packet buffer to an application supplied buffer. More... | |
err_t | inet::tcp::pbuf_take (struct pbuf *buf, const void *dataptr, u16_t len) |
Copy application supplied data into a pbuf. More... | |
struct pbuf * | inet::tcp::pbuf_coalesce (struct pbuf *p, pbuf_layer layer) |
Creates a single pbuf out of a queue of pbufs. More... | |
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, PACKET QUEUES ARE NOT SUPPORTED!!! Use helper structs to queue multiple packets.
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 nullptr, 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 == nullptr).
#define PBUF_POOL_BUFSIZE_ALIGNED LWIP_MEM_ALIGN_SIZE(PBUF_POOL_BUFSIZE) |
Referenced by inet::tcp::pbuf_alloc().
#define PBUF_POOL_IS_EMPTY | ( | ) |
Referenced by inet::tcp::pbuf_alloc().
#define SIZEOF_STRUCT_PBUF LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf)) |
Referenced by inet::tcp::pbuf_alloc(), and inet::tcp::pbuf_header().