00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef __LWIP_NETBUF_H__
00033 #define __LWIP_NETBUF_H__
00034
00035 #include "lwip/opt.h"
00036 #include "lwip/pbuf.h"
00037 #include "lwip/ip_addr.h"
00038
00039 #ifdef __cplusplus
00040 extern "C" {
00041 #endif
00042
00043 struct netbuf {
00044 struct pbuf *p, *ptr;
00045 struct ip_addr *addr;
00046 u16_t port;
00047 #if LWIP_NETBUF_RECVINFO
00048 struct ip_addr *toaddr;
00049 u16_t toport;
00050 #endif
00051 };
00052
00053
00054 struct netbuf * netbuf_new (void);
00055 void netbuf_delete (struct netbuf *buf);
00056 void * netbuf_alloc (struct netbuf *buf, u16_t size);
00057 void netbuf_free (struct netbuf *buf);
00058 err_t netbuf_ref (struct netbuf *buf,
00059 const void *dataptr, u16_t size);
00060 void netbuf_chain (struct netbuf *head,
00061 struct netbuf *tail);
00062
00063 u16_t netbuf_len (struct netbuf *buf);
00064 err_t netbuf_data (struct netbuf *buf,
00065 void **dataptr, u16_t *len);
00066 s8_t netbuf_next (struct netbuf *buf);
00067 void netbuf_first (struct netbuf *buf);
00068
00069
00070 #define netbuf_copy_partial(buf, dataptr, len, offset) \
00071 pbuf_copy_partial((buf)->p, (dataptr), (len), (offset))
00072 #define netbuf_copy(buf,dataptr,len) netbuf_copy_partial(buf, dataptr, len, 0)
00073 #define netbuf_take(buf, dataptr, len) pbuf_take((buf)->p, dataptr, len)
00074 #define netbuf_len(buf) ((buf)->p->tot_len)
00075 #define netbuf_fromaddr(buf) ((buf)->addr)
00076 #define netbuf_fromport(buf) ((buf)->port)
00077 #if LWIP_NETBUF_RECVINFO
00078 #define netbuf_destaddr(buf) ((buf)->toaddr)
00079 #define netbuf_destport(buf) ((buf)->toport)
00080 #endif
00081
00082 #ifdef __cplusplus
00083 }
00084 #endif
00085
00086 #endif