This library is deprecated.
Dependents: HTTPClientStreamingExample HTTPClientExample HTTPServerExample HTTPServerHelloWorld ... more
Diff: LPC1768/lwip/include/lwip/pbuf.h
- Revision:
- 5:bc7df6da7589
- Parent:
- 0:422060928e37
--- a/LPC1768/lwip/include/lwip/pbuf.h Fri Jul 09 14:34:26 2010 +0000 +++ b/LPC1768/lwip/include/lwip/pbuf.h Thu Aug 05 15:09:22 2010 +0000 @@ -40,6 +40,10 @@ extern "C" { #endif +/* Currently, the pbuf_custom code is only needed for one specific configuration + * of IP_FRAG */ +#define LWIP_SUPPORT_CUSTOM_PBUF (IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF) + #define PBUF_TRANSPORT_HLEN 20 #define PBUF_IP_HLEN 20 @@ -58,16 +62,21 @@ } pbuf_type; -/** indicates this packet's data should be immediately passed to the application */ -#define PBUF_FLAG_PUSH 0x01U +/* indicates this packet's data should be immediately passed to the application */ +#define PBUF_FLAG_PUSH 0x01U +/* indicates this is a custom pbuf: pbuf_free and pbuf_header handle such a + a pbuf differently */ +#define PBUF_FLAG_IS_CUSTOM 0x02U +/* indicates this pbuf is UDP multicast to be looped back */ +#define PBUF_FLAG_MCASTLOOP 0x04U struct pbuf { - /** next pbuf in singly linked pbuf chain */ + /* next pbuf in singly linked pbuf chain */ struct pbuf *next; - /** pointer to the actual data in the buffer */ + /* pointer to the actual data in the buffer */ void *payload; - + /** * total length of this buffer and all next buffers in chain * belonging to the same packet. @@ -76,14 +85,14 @@ * p->tot_len == p->len + (p->next? p->next->tot_len: 0) */ u16_t tot_len; - - /** length of this buffer */ - u16_t len; - /** pbuf_type as u8_t instead of enum to save space */ + /* length of this buffer */ + u16_t len; + + /* pbuf_type as u8_t instead of enum to save space */ u8_t /*pbuf_type*/ type; - /** misc flags */ + /* misc flags */ u8_t flags; /** @@ -92,17 +101,33 @@ * the stack itself, or pbuf->next pointers from a chain. */ u16_t ref; - }; +#if LWIP_SUPPORT_CUSTOM_PBUF +/* Prototype for a function to free a custom pbuf */ +typedef void (*pbuf_free_custom_fn)(struct pbuf *p); + +/* A custom pbuf: like a pbuf, but following a function pointer to free it. */ +struct pbuf_custom { + /* The actual pbuf */ + struct pbuf pbuf; + /* This function is called when pbuf_free deallocates this pbuf(_custom) */ + pbuf_free_custom_fn custom_free_function; +}; +#endif /* LWIP_SUPPORT_CUSTOM_PBUF */ + /* Initializes the pbuf module. This call is empty for now, but may not be in future. */ #define pbuf_init() -struct pbuf *pbuf_alloc(pbuf_layer l, u16_t size, pbuf_type type); +struct pbuf *pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type); +#if LWIP_SUPPORT_CUSTOM_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); +#endif /* LWIP_SUPPORT_CUSTOM_PBUF */ void pbuf_realloc(struct pbuf *p, u16_t size); u8_t pbuf_header(struct pbuf *p, s16_t header_size); void pbuf_ref(struct pbuf *p); -void pbuf_ref_chain(struct pbuf *p); u8_t pbuf_free(struct pbuf *p); u8_t pbuf_clen(struct pbuf *p); void pbuf_cat(struct pbuf *head, struct pbuf *tail); @@ -112,6 +137,15 @@ u16_t pbuf_copy_partial(struct pbuf *p, void *dataptr, u16_t len, u16_t offset); err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len); struct pbuf *pbuf_coalesce(struct pbuf *p, pbuf_layer layer); +#if LWIP_CHECKSUM_ON_COPY +err_t pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr, + u16_t len, u16_t *chksum); +#endif /* LWIP_CHECKSUM_ON_COPY */ + +u8_t pbuf_get_at(struct pbuf* p, u16_t offset); +u16_t pbuf_memcmp(struct pbuf* p, u16_t offset, const void* s2, u16_t n); +u16_t pbuf_memfind(struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_offset); +u16_t pbuf_strstr(struct pbuf* p, const char* substr); #ifdef __cplusplus }