pktbuf.h 849 B

12345678910111213141516171819202122232425262728
  1. // Copyright 2015 by Thorsten von Eicken, see LICENSE.txt
  2. #ifndef PKTBUF_H
  3. #define PKTBUF_H
  4. typedef struct PktBuf {
  5. struct PktBuf *next; // next buffer in chain
  6. uint16_t filled; // number of bytes filled in buffer
  7. uint8_t data[0]; // data in buffer
  8. } PktBuf;
  9. // Allocate a new packet buffer of given length
  10. PktBuf *PktBuf_New(uint16_t length);
  11. // Append a buffer to the end of a packet buffer queue, returns new head
  12. PktBuf *PktBuf_Push(PktBuf *headBuf, PktBuf *buf);
  13. // Prepend a buffer to the beginning of a packet buffer queue, return new head
  14. PktBuf * PktBuf_Unshift(PktBuf *headBuf, PktBuf *buf);
  15. // Shift first buffer off queue, returns new head (not shifted buffer!)
  16. PktBuf *PktBuf_Shift(PktBuf *headBuf);
  17. // Shift first buffer off queue, free it, return new head
  18. PktBuf *PktBuf_ShiftFree(PktBuf *headBuf);
  19. #endif