home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1 / HamRadio.cdr / misc / tcpipsrc / mbuf.h < prev    next >
Text File  |  1990-11-09  |  2KB  |  64 lines

  1. #ifndef    _MBUF_H
  2. #define    _MBUF_H
  3.  
  4. #include <stdio.h>
  5.  
  6. #ifndef _GLOBAL_H
  7. #include "global.h"
  8. #endif
  9.  
  10. extern unsigned Ibufsize;    /* Size of interrupt buffers to allocate */
  11. extern int Nibufs;        /* Number of interrupt buffers to allocate */
  12.  
  13. /* Basic message buffer structure */
  14. struct mbuf {
  15.     struct mbuf *next;    /* Links mbufs belonging to single packets */
  16.     struct mbuf *anext;    /* Links packets on queues */
  17.     int16 size;        /* Size of associated data buffer */
  18.     int refcnt;        /* Reference count */
  19.     struct mbuf *dup;    /* Pointer to duplicated mbuf */
  20.     char *data;        /* Active working pointers */
  21.     int16 cnt;
  22. };
  23. #define    NULLBUF    (struct mbuf *)0
  24. #define    NULLBUFP (struct mbuf **)0
  25.  
  26. #define    PULLCHAR(bpp)\
  27.  ((bpp) != NULL && (*bpp) != NULLBUF && (*bpp)->cnt > 1 ? \
  28.  ((*bpp)->cnt--,(unsigned char)*(*bpp)->data++) : pullchar(bpp))
  29.  
  30. /* In mbuf.c: */
  31. void enqueue __ARGS((struct mbuf **q,struct mbuf *bp));
  32. void append __ARGS((struct mbuf **bph,struct mbuf *bp));
  33. void free_q __ARGS((struct mbuf **q));
  34. void trim_mbuf __ARGS((struct mbuf **bpp,int16 length));
  35. struct mbuf *alloc_mbuf __ARGS((int16 size));
  36. struct mbuf *ambufw __ARGS((int16 size));
  37. struct mbuf *free_mbuf __ARGS((struct mbuf *bp));
  38. struct mbuf *dequeue __ARGS((struct mbuf **q));
  39. struct mbuf *copy_p __ARGS((struct mbuf *bp,int16 cnt));
  40. struct mbuf *free_p __ARGS((struct mbuf *bp));
  41. struct mbuf *qdata __ARGS((char *data,int16 cnt));
  42. struct mbuf *pushdown __ARGS((struct mbuf *bp,int16 size));
  43. int16 pullup __ARGS((struct mbuf **bph,char *buf,int16 cnt));
  44. int16 dup_p __ARGS((struct mbuf **hp,struct mbuf *bp,int16 offset,int16 cnt));
  45. int16 len_p __ARGS((struct mbuf *bp));
  46. int16 dqdata __ARGS((struct mbuf *bp,char *buf,unsigned cnt));
  47. int16 len_q __ARGS((struct mbuf *bp));
  48. int32 pull32 __ARGS((struct mbuf **bpp));
  49. int32 get32 __ARGS((char *cp));
  50. long pull16 __ARGS((struct mbuf **bpp));
  51. void refiq __ARGS((void));
  52. void mbuf_crunch __ARGS((struct mbuf **bpp));
  53. int16 get16 __ARGS((char *cp));
  54. int pullchar __ARGS((struct mbuf **bpp));
  55. char *put16 __ARGS((char *cp,int16 x));
  56. char *put32 __ARGS((char *cp,int32 x));
  57. int write_p __ARGS((FILE *fp,struct mbuf *bp));
  58. void iqstat __ARGS((void));
  59.  
  60. #define    AUDIT(bp)    audit(bp,__FILE__,__LINE__)
  61.  
  62.  
  63. #endif    /* _MBUF_H */
  64.