packet.h 641 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. typedef struct Packet Packet;
  2. typedef struct Mem Mem;
  3. typedef struct Frag Frag;
  4. enum {
  5. BigMemSize = MaxFragSize,
  6. SmallMemSize = BigMemSize/8,
  7. NLocalFrag = 2,
  8. };
  9. /* position to carve out of a Mem */
  10. enum {
  11. PFront,
  12. PMiddle,
  13. PEnd,
  14. };
  15. struct Mem
  16. {
  17. Lock lk;
  18. int ref;
  19. uchar *bp;
  20. uchar *ep;
  21. uchar *rp;
  22. uchar *wp;
  23. Mem *next;
  24. };
  25. enum {
  26. FragLocalFree,
  27. FragLocalAlloc,
  28. FragGlobal,
  29. };
  30. struct Frag
  31. {
  32. int state;
  33. Mem *mem;
  34. uchar *rp;
  35. uchar *wp;
  36. Frag *next;
  37. };
  38. struct Packet
  39. {
  40. int size;
  41. int asize; /* allocated memmory - always greater than size */
  42. Packet *next;
  43. Frag *first;
  44. Frag *last;
  45. Frag local[NLocalFrag];
  46. };