38 #ifndef LWIP_HDR_PBUF_H    39 #define LWIP_HDR_PBUF_H    54 #ifndef LWIP_SUPPORT_CUSTOM_PBUF    55 #define LWIP_SUPPORT_CUSTOM_PBUF ((IP_FRAG && !LWIP_NETIF_TX_SINGLE_PBUF) || (LWIP_IPV6 && LWIP_IPV6_FRAG))    71 #ifndef PBUF_NEEDS_COPY    72 #define PBUF_NEEDS_COPY(p)  ((p)->type_internal & PBUF_TYPE_FLAG_DATA_VOLATILE)    78 #define PBUF_TRANSPORT_HLEN 20    80 #define PBUF_IP_HLEN        40    82 #define PBUF_IP_HLEN        20   119 #define PBUF_TYPE_FLAG_STRUCT_DATA_CONTIGUOUS       0x80   122 #define PBUF_TYPE_FLAG_DATA_VOLATILE                0x40   125 #define PBUF_TYPE_ALLOC_SRC_MASK                    0x0F   129 #define PBUF_ALLOC_FLAG_RX                          0x0100   131 #define PBUF_ALLOC_FLAG_DATA_CONTIGUOUS             0x0200   133 #define PBUF_TYPE_ALLOC_SRC_MASK_STD_HEAP           0x00   134 #define PBUF_TYPE_ALLOC_SRC_MASK_STD_MEMP_PBUF      0x01   135 #define PBUF_TYPE_ALLOC_SRC_MASK_STD_MEMP_PBUF_POOL 0x02   137 #define PBUF_TYPE_ALLOC_SRC_MASK_APP_MIN            0x03   139 #define PBUF_TYPE_ALLOC_SRC_MASK_APP_MAX            PBUF_TYPE_ALLOC_SRC_MASK   172 #define PBUF_FLAG_PUSH      0x01U   175 #define PBUF_FLAG_IS_CUSTOM 0x02U   177 #define PBUF_FLAG_MCASTLOOP 0x04U   179 #define PBUF_FLAG_LLBCAST   0x08U   181 #define PBUF_FLAG_LLMCAST   0x10U   183 #define PBUF_FLAG_TCP_FIN   0x20U   237 #if LWIP_SUPPORT_CUSTOM_PBUF   239 typedef void (*pbuf_free_custom_fn)(
struct pbuf *p);
   246   pbuf_free_custom_fn custom_free_function;
   251 #ifndef PBUF_POOL_FREE_OOSEQ   252 #define PBUF_POOL_FREE_OOSEQ 1   254 #if LWIP_TCP && TCP_QUEUE_OOSEQ && NO_SYS && PBUF_POOL_FREE_OOSEQ   255 extern volatile u8_t pbuf_free_ooseq_pending;
   256 void pbuf_free_ooseq(
void);
   260 #define PBUF_CHECK_FREE_OOSEQ() do { if(pbuf_free_ooseq_pending) { \   263   pbuf_free_ooseq(); }}while(0)   266   #define PBUF_CHECK_FREE_OOSEQ()   274 #if LWIP_SUPPORT_CUSTOM_PBUF   276                                  struct pbuf_custom *p, 
void *payload_mem,
   277                                  u16_t payload_mem_len);
   279 void pbuf_realloc(
struct pbuf *p, u16_t size);
   280 #define pbuf_get_allocsrc(p)          ((p)->type_internal & PBUF_TYPE_ALLOC_SRC_MASK)   281 #define pbuf_match_allocsrc(p, type)  (pbuf_get_allocsrc(p) == ((type) & PBUF_TYPE_ALLOC_SRC_MASK))   282 #define pbuf_match_type(p, type)      pbuf_match_allocsrc(p, type)   283 u8_t pbuf_header(
struct pbuf *p, s16_t header_size);
   284 u8_t pbuf_header_force(
struct pbuf *p, s16_t header_size);
   285 u8_t pbuf_add_header(
struct pbuf *p, 
size_t header_size_increment);
   286 u8_t pbuf_add_header_force(
struct pbuf *p, 
size_t header_size_increment);
   287 u8_t pbuf_remove_header(
struct pbuf *p, 
size_t header_size);
   288 struct pbuf *pbuf_free_header(
struct pbuf *q, u16_t size);
   289 void pbuf_ref(
struct pbuf *p);
   290 u8_t pbuf_free(
struct pbuf *p);
   291 u16_t pbuf_clen(
const struct pbuf *p);
   292 void pbuf_cat(
struct pbuf *head, 
struct pbuf *tail);
   293 void pbuf_chain(
struct pbuf *head, 
struct pbuf *tail);
   294 struct pbuf *pbuf_dechain(
struct pbuf *p);
   295 err_t pbuf_copy(
struct pbuf *p_to, 
const struct pbuf *p_from);
   296 u16_t pbuf_copy_partial(
const struct pbuf *p, 
void *dataptr, u16_t len, u16_t offset);
   297 void *pbuf_get_contiguous(
const struct pbuf *p, 
void *buffer, 
size_t bufsize, u16_t len, u16_t offset);
   298 err_t pbuf_take(
struct pbuf *buf, 
const void *dataptr, u16_t len);
   299 err_t pbuf_take_at(
struct pbuf *buf, 
const void *dataptr, u16_t len, u16_t offset);
   300 struct pbuf *pbuf_skip(
struct pbuf* in, u16_t in_offset, u16_t* out_offset);
   303 #if LWIP_CHECKSUM_ON_COPY   304 err_t pbuf_fill_chksum(
struct pbuf *p, u16_t start_offset, 
const void *dataptr,
   305                        u16_t len, u16_t *chksum);
   307 #if LWIP_TCP && TCP_QUEUE_OOSEQ && LWIP_WND_SCALE   308 void pbuf_split_64k(
struct pbuf *p, 
struct pbuf **rest);
   311 u8_t pbuf_get_at(
const struct pbuf* p, u16_t offset);
   312 int pbuf_try_get_at(
const struct pbuf* p, u16_t offset);
   313 void pbuf_put_at(
struct pbuf* p, u16_t offset, u8_t data);
   314 u16_t pbuf_memcmp(
const struct pbuf* p, u16_t offset, 
const void* s2, u16_t n);
   315 u16_t pbuf_memfind(
const struct pbuf* p, 
const void* mem, u16_t mem_len, u16_t start_offset);
   316 u16_t pbuf_strstr(
const struct pbuf* p, 
const char* substr);
 u8_t type_internal
a bit field indicating pbuf type and allocation sources (see PBUF_TYPE_FLAG_*, PBUF_ALLOC_FLAG_* and ...
void * payload
pointer to the actual data in the buffer 
Includes spare room for additional encapsulation header before ethernet headers (e.g. 
const void * payload
pointer to the actual data in the buffer 
#define LWIP_PBUF_REF_T
LWIP_PBUF_REF_T: Refcount type in pbuf. 
#define PBUF_TYPE_FLAG_DATA_VOLATILE
Indicates the data stored in this pbuf can change. 
struct pbuf * next
next pbuf in singly linked pbuf chain 
lwIP Options Configuration 
LWIP_PBUF_REF_T ref
the reference count always equals the number of pointers that refer to this pbuf. ...
u16_t len
length of this buffer 
pbuf data is stored in RAM, used for TX mostly, struct pbuf and its payload are allocated in one piec...
#define PBUF_LINK_HLEN
PBUF_LINK_HLEN: the number of bytes that should be allocated for a link level header. 
Includes spare room for link layer header (ethernet header). 
struct pbuf * next
next pbuf in singly linked pbuf chain 
Includes spare room for transport layer header, e.g. 
Helper struct for const-correctness only. 
Use this for input packets in a netif driver when calling netif->input() in the most common case - et...
u8_t if_idx
For incoming packets, this contains the input netif's index. 
u16_t tot_len
total length of this buffer and all next buffers in chain belonging to the same packet. 
#define PBUF_ALLOC_FLAG_RX
Indicates this pbuf is used for RX (if not set, indicates use for TX). 
Main packet buffer struct. 
pbuf payload refers to RAM. 
pbuf data is stored in ROM, i.e. 
#define PBUF_ALLOC_FLAG_DATA_CONTIGUOUS
Indicates the application needs the pbuf payload to be in one piece. 
#define PBUF_TYPE_FLAG_STRUCT_DATA_CONTIGUOUS
Indicates that the payload directly follows the struct pbuf. 
pbuf_type
Enumeration of pbuf types. 
pbuf comes from the pbuf pool. 
Includes spare room for IP header. 
#define PBUF_LINK_ENCAPSULATION_HLEN
PBUF_LINK_ENCAPSULATION_HLEN: the number of bytes that should be allocated for an additional encapsul...
pbuf_layer
Enumeration of pbuf layers.