32 #ifndef __LWIP_NETBUF_H__
33 #define __LWIP_NETBUF_H__
36 #include "lwip/pbuf.h"
37 #include "lwip/ip_addr.h"
44 #define NETBUF_FLAG_DESTADDR 0x01
46 #define NETBUF_FLAG_CHKSUM 0x02
52 #if LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY
53 #if LWIP_CHECKSUM_ON_COPY
57 #if LWIP_NETBUF_RECVINFO
64 struct netbuf * netbuf_new (
void)ICACHE_FLASH_ATTR;
65 void netbuf_delete (struct
netbuf *buf)ICACHE_FLASH_ATTR;
66 void * netbuf_alloc (struct
netbuf *buf, u16_t size)ICACHE_FLASH_ATTR;
67 void netbuf_free (struct
netbuf *buf)ICACHE_FLASH_ATTR;
68 err_t netbuf_ref (struct
netbuf *buf,
69 const
void *dataptr, u16_t size)ICACHE_FLASH_ATTR;
70 void netbuf_chain (struct
netbuf *head,
71 struct
netbuf *tail)ICACHE_FLASH_ATTR;
73 err_t netbuf_data (struct
netbuf *buf,
74 void **dataptr, u16_t *len)ICACHE_FLASH_ATTR;
75 s8_t netbuf_next (struct
netbuf *buf)ICACHE_FLASH_ATTR;
76 void netbuf_first (struct
netbuf *buf)ICACHE_FLASH_ATTR;
79 #define netbuf_copy_partial(buf, dataptr, len, offset) \
80 pbuf_copy_partial((buf)->p, (dataptr), (len), (offset))
81 #define netbuf_copy(buf,dataptr,len) netbuf_copy_partial(buf, dataptr, len, 0)
82 #define netbuf_take(buf, dataptr, len) pbuf_take((buf)->p, dataptr, len)
83 #define netbuf_len(buf) ((buf)->p->tot_len)
84 #define netbuf_fromaddr(buf) (&((buf)->addr))
85 #define netbuf_set_fromaddr(buf, fromaddr) ip_addr_set((&(buf)->addr), fromaddr)
86 #define netbuf_fromport(buf) ((buf)->port)
87 #if LWIP_NETBUF_RECVINFO
88 #define netbuf_destaddr(buf) (&((buf)->toaddr))
89 #define netbuf_set_destaddr(buf, destaddr) ip_addr_set((&(buf)->addr), destaddr)
90 #define netbuf_destport(buf) (((buf)->flags & NETBUF_FLAG_DESTADDR) ? (buf)->toport_chksum : 0)
92 #if LWIP_CHECKSUM_ON_COPY
93 #define netbuf_set_chksum(buf, chksum) do { (buf)->flags = NETBUF_FLAG_CHKSUM; \
94 (buf)->toport_chksum = chksum; } while(0)
u16_t port
Definition: netbuf.h:51
ip_addr_t addr
Definition: netbuf.h:50
u8_t flags
Definition: pbuf.h:99
struct pbuf * ptr
Definition: netbuf.h:49
struct pbuf * p
Definition: netbuf.h:49