#include "lwip/opt.h"
#include "lwip/err.h"
Data Structures | |
struct | pbuf |
Macros | |
#define | PBUF_FLAG_PUSH 0x01U |
indicates this packet's data should be immediately passed to the application More... | |
#define | pbuf_init() |
#define | PBUF_IP_HLEN 20 |
#define | PBUF_TRANSPORT_HLEN 20 |
Enumerations | |
enum | pbuf_layer { PBUF_TRANSPORT, PBUF_IP, PBUF_LINK, PBUF_RAW, PBUF_TRANSPORT, PBUF_IP, PBUF_LINK, PBUF_RAW, PBUF_TRANSPORT, PBUF_IP, PBUF_LINK, PBUF_RAW } |
enum | pbuf_type { PBUF_RAM, PBUF_ROM, PBUF_REF, PBUF_POOL, PBUF_RAM, PBUF_ROM, PBUF_REF, PBUF_POOL, PBUF_RAM, PBUF_ROM, PBUF_REF, PBUF_POOL } |
Functions | |
struct pbuf * | pbuf_alloc (pbuf_layer l, u16_t size, pbuf_type type) |
Allocates a pbuf of the given type (possibly a chain for PBUF_POOL type). More... | |
void | pbuf_cat (struct pbuf *head, struct pbuf *tail) |
Concatenate two pbufs (each may be a pbuf chain) and take over the caller's reference of the tail pbuf. More... | |
void | pbuf_chain (struct pbuf *head, struct pbuf *tail) |
Chain two pbufs (or pbuf chains) together. More... | |
u8_t | pbuf_clen (struct pbuf *p) |
Count number of pbufs in a chain. More... | |
struct pbuf * | pbuf_coalesce (struct pbuf *p, pbuf_layer layer) |
Creates a single pbuf out of a queue of pbufs. More... | |
err_t | pbuf_copy (struct pbuf *p_to, struct pbuf *p_from) |
Create PBUF_RAM copies of pbufs. More... | |
u16_t | pbuf_copy_partial (struct pbuf *p, void *dataptr, u16_t len, u16_t offset) |
Copy (part of) the contents of a packet buffer to an application supplied buffer. More... | |
struct pbuf * | pbuf_dechain (struct pbuf *p) |
Dechains the first pbuf from its succeeding pbufs in the chain. More... | |
u8_t | 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 | pbuf_header (struct pbuf *p, s16_t header_size) |
Adjusts the payload pointer to hide or reveal headers in the payload. More... | |
void | pbuf_realloc (struct pbuf *p, u16_t size) |
Shrink a pbuf chain to a desired length. More... | |
void | pbuf_ref (struct pbuf *p) |
Increment the reference count of the pbuf. More... | |
void | pbuf_ref_chain (struct pbuf *p) |
err_t | pbuf_take (struct pbuf *buf, const void *dataptr, u16_t len) |
Copy application supplied data into a pbuf. More... | |
#define PBUF_FLAG_PUSH 0x01U |
indicates this packet's data should be immediately passed to the application
#define pbuf_init | ( | ) |
#define PBUF_IP_HLEN 20 |
#define PBUF_TRANSPORT_HLEN 20 |
enum pbuf_layer |
enum pbuf_type |
struct pbuf* 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).
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).
layer | flag to define header size |
length | size of the pbuf's payload |
type | this parameter decides how and where the pbuf should be allocated as follows: |
Concatenate two pbufs (each may be a pbuf chain) and take over the caller's reference of the tail pbuf.
Chain two pbufs (or pbuf chains) together.
The caller MUST call pbuf_free(t) once it has stopped using it. Use pbuf_cat() instead if you no longer use t.
h | head pbuf (chain) |
t | tail pbuf (chain) |
The ->tot_len fields of all pbufs of the head chain are adjusted. The ->next field of the last pbuf of the head chain is adjusted. The ->ref field of the first pbuf of the tail chain is adjusted.
Count number of pbufs in a chain.
p | first pbuf of chain |
struct pbuf* pbuf_coalesce | ( | struct pbuf * | p, |
pbuf_layer | layer | ||
) |
Creates a single pbuf out of a queue of pbufs.
p | the source pbuf |
layer | pbuf_layer of the new pbuf |
p | the source pbuf |
layer | pbuf_layer of the new pbuf |
Create PBUF_RAM copies of pbufs.
Used to queue packets on behalf of the lwIP stack, such as ARP based queueing.
p_to | pbuf destination of the copy |
p_from | pbuf source of the copy |
Copy (part of) the contents of a packet buffer to an application supplied buffer.
buf | the pbuf from which to copy data |
dataptr | the application supplied buffer |
len | length of data to copy (dataptr must be big enough). No more than buf->tot_len will be copied, irrespective of len |
offset | offset into the packet buffer from where to begin copying len bytes |
Dechains the first pbuf from its succeeding pbufs in the chain.
Makes p->tot_len field equal to p->len.
p | pbuf to dechain |
Dereference a pbuf chain or queue and deallocate any no-longer-used pbufs at the head of this chain or queue.
Decrements the pbuf reference count. If it reaches zero, the pbuf is deallocated.
For a pbuf chain, this is repeated for each pbuf in the chain, up to the first pbuf which has a non-zero reference count after decrementing. So, when all reference counts are one, the whole chain is free'd.
p | The pbuf (chain) to be dereferenced. |
examples:
Assuming existing chains a->b->c with the following reference counts, calling pbuf_free(a) results in:
1->2->3 becomes ...1->3 3->3->3 becomes 2->3->3 1->1->2 becomes ......1 2->1->1 becomes 1->1->1 1->1->1 becomes .......
Adjusts the payload pointer to hide or reveal headers in the payload.
Adjusts the ->payload pointer so that space for a header (dis)appears in the pbuf payload.
The ->payload, ->tot_len and ->len fields are adjusted.
p | pbuf to change the header size. |
header_size_increment | Number of bytes to increment header size which increases the size of the pbuf. New space is on the front. (Using a negative value decreases the header size.) If hdr_size_inc is 0, this function does nothing and returns succesful. |
PBUF_ROM and PBUF_REF type buffers cannot have their sizes increased, so the call will fail. A check is made that the increase in header size does not move the payload pointer in front of the start of the buffer.
Shrink a pbuf chain to a desired length.
p | pbuf to shrink. |
new_len | desired new length of pbuf chain |
Depending on the desired length, the first few pbufs in a chain might be skipped and left unchanged. The new last pbuf in the chain will be resized, and any remaining pbufs will be freed.
void pbuf_ref | ( | struct pbuf * | p | ) |
Increment the reference count of the pbuf.
p | pbuf to increase reference counter of |
void pbuf_ref_chain | ( | struct pbuf * | p | ) |
Copy application supplied data into a pbuf.
This function can only be used to copy the equivalent of buf->tot_len data.
buf | pbuf to fill with data |
dataptr | application supplied data buffer |
len | length of the application supplied data buffer |