uip_pbuf.h 1.9 KB

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