Documentation

Documentation

Includes

lwip/opt.h

#include "lwip/opt.h"
#include "lwip/opt.h"

lwip/err.h

#include "lwip/err.h"
#include "lwip/err.h"

Macros

Marco LWIP_HDR_PBUF_H

#define LWIP_HDR_PBUF_H


      

Marco LWIP_SUPPORT_CUSTOM_PBUF

#define LWIP_SUPPORT_CUSTOM_PBUF ((IP_FRAG && !LWIP_NETIF_TX_SINGLE_PBUF) || (LWIP_IPV6 && LWIP_IPV6_FRAG))


      

Marco PBUF_NEEDS_COPY(p)

#define PBUF_NEEDS_COPY(p) ((p)->type_internal & PBUF_TYPE_FLAG_DATA_VOLATILE)


      

Marco PBUF_TRANSPORT_HLEN

#define PBUF_TRANSPORT_HLEN 20


      

Marco PBUF_IP_HLEN

#define PBUF_IP_HLEN       40


      

Marco PBUF_IP_HLEN

#define PBUF_IP_HLEN       20


      

Marco PBUF_TYPE_FLAG_STRUCT_DATA_CONTIGUOUS

#define PBUF_TYPE_FLAG_STRUCT_DATA_CONTIGUOUS      128
/** Indicates that the payload directly follows the struct pbuf.
 *  This makes @ref pbuf_header work in both directions. */

Marco PBUF_TYPE_FLAG_DATA_VOLATILE

#define PBUF_TYPE_FLAG_DATA_VOLATILE               64
/** Indicates the data stored in this pbuf can change. If this pbuf needs
 * to be queued, it must be copied/duplicated. */

Marco PBUF_TYPE_ALLOC_SRC_MASK

#define PBUF_TYPE_ALLOC_SRC_MASK                   15
/** 4 bits are reserved for 16 allocation sources (e.g. heap, pool1, pool2, etc)
 * Internally, we use: 0=heap, 1=MEMP_PBUF, 2=MEMP_PBUF_POOL -> 13 types free*/

Marco PBUF_ALLOC_FLAG_RX

#define PBUF_ALLOC_FLAG_RX                         256
/** Indicates this pbuf is used for RX (if not set, indicates use for TX).
 * This information can be used to keep some spare RX buffers e.g. for
 * receiving TCP ACKs to unblock a connection) */

Marco PBUF_ALLOC_FLAG_DATA_CONTIGUOUS

#define PBUF_ALLOC_FLAG_DATA_CONTIGUOUS            512
/** Indicates the application needs the pbuf payload to be in one piece */

Marco PBUF_TYPE_ALLOC_SRC_MASK_STD_HEAP

#define PBUF_TYPE_ALLOC_SRC_MASK_STD_HEAP          0


      

Marco PBUF_TYPE_ALLOC_SRC_MASK_STD_MEMP_PBUF

#define PBUF_TYPE_ALLOC_SRC_MASK_STD_MEMP_PBUF     1


      

Marco PBUF_TYPE_ALLOC_SRC_MASK_STD_MEMP_PBUF_POOL

#define PBUF_TYPE_ALLOC_SRC_MASK_STD_MEMP_PBUF_POOL 2


      

Marco PBUF_TYPE_ALLOC_SRC_MASK_APP_MIN

#define PBUF_TYPE_ALLOC_SRC_MASK_APP_MIN           3
/** First pbuf allocation type for applications */

Marco PBUF_TYPE_ALLOC_SRC_MASK_APP_MAX

#define PBUF_TYPE_ALLOC_SRC_MASK_APP_MAX           PBUF_TYPE_ALLOC_SRC_MASK
/** Last pbuf allocation type for applications */

Marco PBUF_FLAG_PUSH

#define PBUF_FLAG_PUSH     0x01U
/** indicates this packet's data should be immediately passed to the application */

Marco PBUF_FLAG_IS_CUSTOM

#define PBUF_FLAG_IS_CUSTOM 0x02U
/** indicates this is a custom pbuf: pbuf_free calls pbuf_custom->custom_free_function()
    when the last reference is released (plus custom PBUF_RAM cannot be trimmed) */

Marco PBUF_FLAG_MCASTLOOP

#define PBUF_FLAG_MCASTLOOP 0x04U
/** indicates this pbuf is UDP multicast to be looped back */

Marco PBUF_FLAG_LLBCAST

#define PBUF_FLAG_LLBCAST  0x08U
/** indicates this pbuf was received as link-level broadcast */

Marco PBUF_FLAG_LLMCAST

#define PBUF_FLAG_LLMCAST  0x10U
/** indicates this pbuf was received as link-level multicast */

Marco PBUF_FLAG_TCP_FIN

#define PBUF_FLAG_TCP_FIN  0x20U
/** indicates this pbuf includes a TCP FIN flag */

Marco PBUF_POOL_FREE_OOSEQ

#define PBUF_POOL_FREE_OOSEQ 1


      

Marco PBUF_CHECK_FREE_OOSEQ()

#define PBUF_CHECK_FREE_OOSEQ() do { if(pbuf_free_ooseq_pending) { \
 /* pbuf_alloc() reported PBUF_POOL to be empty -> try to free some \
     ooseq queued pbufs now */ \
 pbuf_free_ooseq(); }}while(0)
/** When not using sys_check_timeouts(), call PBUF_CHECK_FREE_OOSEQ()
    at regular intervals from main level to check if ooseq pbufs need to be
    freed! */

Marco PBUF_CHECK_FREE_OOSEQ

#define PBUF_CHECK_FREE_OOSEQ()
/* Otherwise declare an empty PBUF_CHECK_FREE_OOSEQ */

Marco pbuf_init

#define pbuf_init()
/* Initializes the pbuf module. This call is empty for now, but may not be in future. */

Marco pbuf_get_allocsrc(p)

#define pbuf_get_allocsrc(p)         ((p)->type_internal & PBUF_TYPE_ALLOC_SRC_MASK)


      

Marco pbuf_match_allocsrc(p, type)

#define pbuf_match_allocsrc(p, type) (pbuf_get_allocsrc(p) == ((type) & PBUF_TYPE_ALLOC_SRC_MASK))


      

Marco pbuf_match_type(p, type)

#define pbuf_match_type(p, type)     pbuf_match_allocsrc(p, type)

      

Functions

Func pbuf_free_ooseq

void pbuf_free_ooseq(void);


      

Func pbuf_realloc

void pbuf_realloc(struct pbuf *p, u16_t size);


      

Func pbuf_header

u8_t pbuf_header(struct pbuf *p, s16_t header_size);


      

Func pbuf_header_force

u8_t pbuf_header_force(struct pbuf *p, s16_t header_size);


      

Func pbuf_add_header

u8_t pbuf_add_header(struct pbuf *p, size_t header_size_increment);


      

Func pbuf_add_header_force

u8_t pbuf_add_header_force(struct pbuf *p, size_t header_size_increment);


      

Func pbuf_remove_header

u8_t pbuf_remove_header(struct pbuf *p, size_t header_size);


      

Func pbuf_ref

void pbuf_ref(struct pbuf *p);


      

Func pbuf_free

u8_t pbuf_free(struct pbuf *p);


      

Func pbuf_clen

u16_t pbuf_clen(const struct pbuf *p);


      

Func pbuf_cat

void pbuf_cat(struct pbuf *head, struct pbuf *tail);


      

Func pbuf_chain

void pbuf_chain(struct pbuf *head, struct pbuf *tail);


      

Func pbuf_copy

err_t pbuf_copy(struct pbuf *p_to, const struct pbuf *p_from);


      

Func pbuf_copy_partial

u16_t pbuf_copy_partial(const struct pbuf *p, void *dataptr, u16_t len, u16_t offset);


      

Func pbuf_get_contiguous

void *pbuf_get_contiguous(const struct pbuf *p, void *buffer, size_t bufsize, u16_t len, u16_t offset);


      

Func pbuf_take

err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len);


      

Func pbuf_take_at

err_t pbuf_take_at(struct pbuf *buf, const void *dataptr, u16_t len, u16_t offset);


      

Func pbuf_fill_chksum

err_t pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr,
                      u16_t len, u16_t *chksum);


      

Func pbuf_split_64k

void pbuf_split_64k(struct pbuf *p, struct pbuf **rest);


      

Func pbuf_get_at

u8_t pbuf_get_at(const struct pbuf* p, u16_t offset);


      

Func pbuf_try_get_at

int pbuf_try_get_at(const struct pbuf* p, u16_t offset);


      

Func pbuf_put_at

void pbuf_put_at(struct pbuf* p, u16_t offset, u8_t data);


      

Func pbuf_memcmp

u16_t pbuf_memcmp(const struct pbuf* p, u16_t offset, const void* s2, u16_t n);


      

Func pbuf_memfind

u16_t pbuf_memfind(const struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_offset);


      

Func pbuf_strstr

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

      

Vars

Variable pbuf

struct pbuf *pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type);


      

Variable pbuf

struct pbuf *pbuf_alloc_reference(void *payload, u16_t length, pbuf_type type);


      

Variable pbuf

struct pbuf *pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type,
                                struct pbuf_custom *p, void *payload_mem,
                                u16_t payload_mem_len);


      

Variable pbuf

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


      

Variable pbuf

struct pbuf *pbuf_dechain(struct pbuf *p);


      

Variable pbuf

struct pbuf *pbuf_skip(struct pbuf* in, u16_t in_offset, u16_t* out_offset);


      

Variable pbuf

struct pbuf *pbuf_coalesce(struct pbuf *p, pbuf_layer layer);


      

Variable pbuf

struct pbuf *pbuf_clone(pbuf_layer l, pbuf_type type, struct pbuf *p);

      

Consts

Types

Typedefs

Typedef pbuf_layer;

typedef enum {
 /** Includes spare room for transport layer header, e.g. UDP header.
   * Use this if you intend to pass the pbuf to functions like udp_send().
   */
 PBUF_TRANSPORT = PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN,
 /** Includes spare room for IP header.
   * Use this if you intend to pass the pbuf to functions like raw_send().
   */
 PBUF_IP = PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN,
 /** Includes spare room for link layer header (ethernet header).
   * Use this if you intend to pass the pbuf to functions like ethernet_output().
   * @see PBUF_LINK_HLEN
   */
 PBUF_LINK = PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN,
 /** Includes spare room for additional encapsulation header before ethernet
   * headers (e.g. 802.11).
   * Use this if you intend to pass the pbuf to functions like netif->linkoutput().
   * @see PBUF_LINK_ENCAPSULATION_HLEN
   */
 PBUF_RAW_TX = PBUF_LINK_ENCAPSULATION_HLEN,
 /** Use this for input packets in a netif driver when calling netif->input()
   * in the most common case - ethernet-layer netif driver. */
 PBUF_RAW = 0
} pbuf_layer;
/**
 * @ingroup pbuf
 * Enumeration of pbuf layers
 */

Typedef pbuf_type;

typedef enum {
 /** pbuf data is stored in RAM, used for TX mostly, struct pbuf and its payload
      are allocated in one piece of contiguous memory (so the first payload byte
      can be calculated from struct pbuf).
      pbuf_alloc() allocates PBUF_RAM pbufs as unchained pbufs (although that might
      change in future versions).
      This should be used for all OUTGOING packets (TX).*/
 PBUF_RAM = (PBUF_ALLOC_FLAG_DATA_CONTIGUOUS | PBUF_TYPE_FLAG_STRUCT_DATA_CONTIGUOUS | PBUF_TYPE_ALLOC_SRC_MASK_STD_HEAP),
 /** pbuf data is stored in ROM, i.e. struct pbuf and its payload are located in
      totally different memory areas. Since it points to ROM, payload does not
      have to be copied when queued for transmission. */
 PBUF_ROM = PBUF_TYPE_ALLOC_SRC_MASK_STD_MEMP_PBUF,
 /** pbuf comes from the pbuf pool. Much like PBUF_ROM but payload might change
      so it has to be duplicated when queued before transmitting, depending on
      who has a 'ref' to it. */
 PBUF_REF = (PBUF_TYPE_FLAG_DATA_VOLATILE | PBUF_TYPE_ALLOC_SRC_MASK_STD_MEMP_PBUF),
 /** pbuf payload refers to RAM. This one comes from a pool and should be used
      for RX. Payload can be chained (scatter-gather RX) but like PBUF_RAM, struct
      pbuf and its payload are allocated in one piece of contiguous memory (so
      the first payload byte can be calculated from struct pbuf).
      Don't use this for TX, if the pool becomes empty e.g. because of TCP queuing,
      you are unable to receive TCP acks! */
 PBUF_POOL = (PBUF_ALLOC_FLAG_RX | PBUF_TYPE_FLAG_STRUCT_DATA_CONTIGUOUS | PBUF_TYPE_ALLOC_SRC_MASK_STD_MEMP_PBUF_POOL)
} pbuf_type;
/**
 * @ingroup pbuf
 * Enumeration of pbuf types
 */

Typedef pbuf_free_custom_fn

typedef void (*pbuf_free_custom_fn)(struct pbuf *p);
/** Prototype for a function to free a custom pbuf */