ConOpSys V2970  P004.07
ANVILEX control operating system
Macros | Functions
pbuf.c File Reference
#include "lwip/opt.h"
#include "lwip/pbuf.h"
#include "lwip/stats.h"
#include "lwip/def.h"
#include "lwip/mem.h"
#include "lwip/memp.h"
#include "lwip/sys.h"
#include "lwip/netif.h"
#include <string.h>
Include dependency graph for pbuf.c:

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

static const struct pbufpbuf_skip_const (const struct pbuf *in, u16_t in_offset, u16_t *out_offset)
 
static void pbuf_init_alloced_pbuf (struct pbuf *p, void *payload, u16_t tot_len, u16_t len, pbuf_type type, u8_t flags)
 
struct pbufpbuf_alloc (pbuf_layer layer, u16_t length, pbuf_type type)
 
struct pbufpbuf_alloc_reference (void *payload, u16_t length, pbuf_type type)
 
void pbuf_realloc (struct pbuf *p, u16_t new_len)
 
static u8_t pbuf_add_header_impl (struct pbuf *p, size_t header_size_increment, u8_t force)
 
u8_t pbuf_add_header (struct pbuf *p, size_t header_size_increment)
 
u8_t pbuf_add_header_force (struct pbuf *p, size_t header_size_increment)
 
u8_t pbuf_remove_header (struct pbuf *p, size_t header_size_decrement)
 
static u8_t pbuf_header_impl (struct pbuf *p, s16_t header_size_increment, u8_t force)
 
u8_t pbuf_header (struct pbuf *p, s16_t header_size_increment)
 
u8_t pbuf_header_force (struct pbuf *p, s16_t header_size_increment)
 
struct pbufpbuf_free_header (struct pbuf *q, u16_t size)
 
u8_t pbuf_free (struct pbuf *p)
 
u16_t pbuf_clen (const struct pbuf *p)
 
void pbuf_ref (struct pbuf *p)
 
void pbuf_cat (struct pbuf *h, struct pbuf *t)
 
void pbuf_chain (struct pbuf *h, struct pbuf *t)
 
struct pbufpbuf_dechain (struct pbuf *p)
 
err_t pbuf_copy (struct pbuf *p_to, const struct pbuf *p_from)
 
u16_t pbuf_copy_partial (const struct pbuf *buf, void *dataptr, u16_t len, u16_t offset)
 
void * pbuf_get_contiguous (const struct pbuf *p, void *buffer, size_t bufsize, u16_t len, u16_t offset)
 
struct pbufpbuf_skip (struct pbuf *in, u16_t in_offset, u16_t *out_offset)
 
err_t pbuf_take (struct pbuf *buf, const void *dataptr, u16_t len)
 
err_t pbuf_take_at (struct pbuf *buf, const void *dataptr, u16_t len, u16_t offset)
 
struct pbufpbuf_coalesce (struct pbuf *p, pbuf_layer layer)
 
struct pbufpbuf_clone (pbuf_layer layer, pbuf_type type, struct pbuf *p)
 
u8_t pbuf_get_at (const struct pbuf *p, u16_t offset)
 
int pbuf_try_get_at (const struct pbuf *p, u16_t offset)
 
void pbuf_put_at (struct pbuf *p, u16_t offset, u8_t data)
 
u16_t pbuf_memcmp (const struct pbuf *p, u16_t offset, const void *s2, u16_t n)
 
u16_t pbuf_memfind (const struct pbuf *p, const void *mem, u16_t mem_len, u16_t start_offset)
 
u16_t pbuf_strstr (const struct pbuf *p, const char *substr)
 

Detailed Description

Packet buffer management

Macro Definition Documentation

◆ PBUF_POOL_BUFSIZE_ALIGNED

#define PBUF_POOL_BUFSIZE_ALIGNED   LWIP_MEM_ALIGN_SIZE(PBUF_POOL_BUFSIZE)

◆ PBUF_POOL_IS_EMPTY

#define PBUF_POOL_IS_EMPTY ( )

◆ SIZEOF_STRUCT_PBUF

#define SIZEOF_STRUCT_PBUF   LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf))

Function Documentation

◆ pbuf_add_header()

u8_t pbuf_add_header ( struct pbuf p,
size_t  header_size_increment 
)

Adjusts the payload pointer to reveal headers in the payload.

Adjusts the ->payload pointer so that space for a header appears in the pbuf payload.

The ->payload, ->tot_len and ->len fields are adjusted.

Parameters
ppbuf to change the header size.
header_size_incrementNumber of bytes to increment header size which increases the size of the pbuf. New space is on the front. If header_size_increment is 0, this function does nothing and returns successful.

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.

Returns
non-zero on failure, zero on success.

References pbuf_add_header_impl().

Here is the call graph for this function:

◆ pbuf_add_header_force()

u8_t pbuf_add_header_force ( struct pbuf p,
size_t  header_size_increment 
)

Same as pbuf_add_header but does not check if 'header_size > 0' is allowed. This is used internally only, to allow PBUF_REF for RX.

References pbuf_add_header_impl().

Here is the call graph for this function:

◆ pbuf_add_header_impl()

static u8_t pbuf_add_header_impl ( struct pbuf p,
size_t  header_size_increment,
u8_t  force 
)
static

Adjusts the payload pointer to reveal headers in the payload.

See also
pbuf_add_header.
Parameters
ppbuf to change the header size.
header_size_incrementNumber of bytes to increment header size.
forceAllow 'header_size_increment > 0' for PBUF_REF/PBUF_ROM types
Returns
non-zero on failure, zero on success.

References pbuf::len, LWIP_ASSERT, LWIP_DBG_TRACE, LWIP_DEBUGF, NULL, pbuf::payload, PBUF_DEBUG, PBUF_TYPE_FLAG_STRUCT_DATA_CONTIGUOUS, SIZEOF_STRUCT_PBUF, pbuf::tot_len, pbuf::type_internal, and U16_F.

Referenced by pbuf_add_header(), pbuf_add_header_force(), and pbuf_header_impl().

Here is the caller graph for this function:

◆ pbuf_clen()

u16_t pbuf_clen ( const struct pbuf p)

Count number of pbufs in a chain

Parameters
pfirst pbuf of chain
Returns
the number of pbufs in a chain

References pbuf::next, and NULL.

◆ pbuf_dechain()

struct pbuf* pbuf_dechain ( struct pbuf p)

Dechains the first pbuf from its succeeding pbufs in the chain.

Makes p->tot_len field equal to p->len.

Parameters
ppbuf to dechain
Returns
remainder of the pbuf chain, or NULL if it was de-allocated.
Note
May not be called on a packet queue.

References pbuf::len, LWIP_ASSERT, LWIP_DBG_TRACE, LWIP_DEBUGF, pbuf::next, NULL, PBUF_DEBUG, pbuf_free(), and pbuf::tot_len.

Here is the call graph for this function:

◆ pbuf_free_header()

struct pbuf* pbuf_free_header ( struct pbuf q,
u16_t  size 
)

Similar to pbuf_header(-size) but de-refs header pbufs for (size >= p->len)

Parameters
qpbufs to operate on
sizeThe number of bytes to remove from the beginning of the pbuf list. While size >= p->len, pbufs are freed. ATTENTION: this is the opposite direction as pbuf_header, but takes an u16_t not s16_t!
Returns
the new head pbuf

References pbuf::len, pbuf::next, pbuf_free(), and pbuf_remove_header().

Here is the call graph for this function:

◆ pbuf_header()

u8_t pbuf_header ( struct pbuf p,
s16_t  header_size_increment 
)

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.

Parameters
ppbuf to change the header size.
header_size_incrementNumber 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 header_size_increment is 0, this function does nothing and returns successful.

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.

Returns
non-zero on failure, zero on success.

References pbuf_header_impl().

Here is the call graph for this function:

◆ pbuf_header_force()

u8_t pbuf_header_force ( struct pbuf p,
s16_t  header_size_increment 
)

Same as pbuf_header but does not check if 'header_size > 0' is allowed. This is used internally only, to allow PBUF_REF for RX.

References pbuf_header_impl().

Here is the call graph for this function:

◆ pbuf_header_impl()

static u8_t pbuf_header_impl ( struct pbuf p,
s16_t  header_size_increment,
u8_t  force 
)
static

References pbuf_add_header_impl(), and pbuf_remove_header().

Referenced by pbuf_header(), and pbuf_header_force().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pbuf_init_alloced_pbuf()

static void pbuf_init_alloced_pbuf ( struct pbuf p,
void *  payload,
u16_t  tot_len,
u16_t  len,
pbuf_type  type,
u8_t  flags 
)
static

References pbuf::flags, pbuf::if_idx, pbuf::len, NETIF_NO_INDEX, pbuf::next, NULL, pbuf::payload, pbuf::ref, pbuf::tot_len, and pbuf::type_internal.

Referenced by pbuf_alloc(), and pbuf_alloc_reference().

Here is the caller graph for this function:

◆ pbuf_remove_header()

u8_t pbuf_remove_header ( struct pbuf p,
size_t  header_size_decrement 
)

Adjusts the payload pointer to hide headers in the payload.

Adjusts the ->payload pointer so that space for a header disappears in the pbuf payload.

The ->payload, ->tot_len and ->len fields are adjusted.

Parameters
ppbuf to change the header size.
header_size_decrementNumber of bytes to decrement header size which decreases the size of the pbuf. If header_size_decrement is 0, this function does nothing and returns successful.
Returns
non-zero on failure, zero on success.

References pbuf::len, LWIP_ASSERT, LWIP_DBG_TRACE, LWIP_DEBUGF, LWIP_ERROR, LWIP_UNUSED_ARG, NULL, pbuf::payload, PBUF_DEBUG, pbuf::tot_len, and U16_F.

Referenced by pbuf_free_header(), and pbuf_header_impl().

Here is the caller graph for this function:

◆ pbuf_skip_const()

static const struct pbuf * pbuf_skip_const ( const struct pbuf in,
u16_t  in_offset,
u16_t out_offset 
)
static

References pbuf::len, pbuf::next, and NULL.

Referenced by pbuf_get_contiguous(), pbuf_skip(), and pbuf_try_get_at().

Here is the caller graph for this function:

◆ pbuf_strstr()

u16_t pbuf_strstr ( const struct pbuf p,
const char *  substr 
)

Find occurrence of substr with length substr_len in pbuf p, start at offset start_offset WARNING: in contrast to strstr(), this one does not stop at the first \0 in the pbuf/source string!

Parameters
ppbuf to search, maximum length is 0xFFFE since 0xFFFF is used as return value 'not found'
substrstring to search for in p, maximum length is 0xFFFE
Returns
0xFFFF if substr was not found in p or the index where it was found

References NULL, pbuf_memfind(), and pbuf::tot_len.

Here is the call graph for this function: