1 2 #ifndef __UIP_PBUF_H__ 3 #define __UIP_PBUF_H__ 4 5 //#include "lwip/opt.h" 6 //#include "lwip/err.h" 7 #include "uip-conf.h" 8 #include "uip_etharp.h" 9 10 typedef rt_int16_t s16_t; 11 typedef rt_int8_t err_t; 12 #ifdef __cplusplus 13 extern "C" { 14 #endif 15 16 #define PBUF_TRANSPORT_HLEN 20 17 #define PBUF_IP_HLEN 20 18 19 typedef enum { 20 PBUF_TRANSPORT, 21 PBUF_IP, 22 PBUF_LINK, 23 PBUF_RAW 24 } pbuf_layer; 25 26 typedef enum { 27 PBUF_RAM, /* pbuf data is stored in RAM */ 28 PBUF_ROM, /* pbuf data is stored in ROM */ 29 PBUF_REF, /* pbuf comes from the pbuf pool */ 30 PBUF_POOL /* pbuf payload refers to RAM */ 31 } pbuf_type; 32 33 34 /** indicates this packet's data should be immediately passed to the application */ 35 #define PBUF_FLAG_PUSH 0x01U 36 #ifdef RT_USING_LWIP 37 struct pbuf { 38 /** next pbuf in singly linked pbuf chain */ 39 struct pbuf *next; 40 41 /** pointer to the actual data in the buffer */ 42 void *payload; 43 44 /** 45 * total length of this buffer and all next buffers in chain 46 * belonging to the same packet. 47 * 48 * For non-queue packet chains this is the invariant: 49 * p->tot_len == p->len + (p->next? p->next->tot_len: 0) 50 */ 51 u16_t tot_len; 52 53 /** length of this buffer */ 54 u16_t len; 55 56 /** pbuf_type as u8_t instead of enum to save space */ 57 u8_t /*pbuf_type*/ type; 58 59 /** misc flags */ 60 u8_t flags; 61 62 /** 63 * the reference count always equals the number of pointers 64 * that refer to this pbuf. This can be pointers from an application, 65 * the stack itself, or pbuf->next pointers from a chain. 66 */ 67 u16_t ref; 68 69 }; 70 #else /* RT_USING_UIP */ 71 struct pbuf 72 { 73 /** pointer to the actual data in the buffer */ 74 void *payload; 75 rt_uint16_t len; 76 }; 77 #endif 78 /* Initializes the pbuf module. This call is empty for now, but may not be in future. */ 79 80 81 struct pbuf *pbuf_alloc(pbuf_layer l, u16_t size, pbuf_type type); 82 83 u8_t pbuf_header(struct pbuf *p, s16_t header_size); 84 85 u8_t pbuf_free(struct pbuf *p); 86 87 #endif /* __UIP_PBUF_H__ */ 88