home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / network / src_1218.zip / MBUF.H < prev    next >
C/C++ Source or Header  |  1991-08-19  |  2KB  |  70 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. struct mbuf *alloc_mbuf __ARGS((int16 size));
  32. struct mbuf *free_mbuf __ARGS((struct mbuf *bp));
  33.  
  34. struct mbuf *ambufw __ARGS((int16 size));
  35. struct mbuf *copy_p __ARGS((struct mbuf *bp,int16 cnt));
  36. int16 dup_p __ARGS((struct mbuf **hp,struct mbuf *bp,int16 offset,int16 cnt));
  37. struct mbuf *free_p __ARGS((struct mbuf *bp));
  38. int16 len_p __ARGS((struct mbuf *bp));
  39. void trim_mbuf __ARGS((struct mbuf **bpp,int16 length));
  40. int write_p __ARGS((FILE *fp,struct mbuf *bp));
  41.  
  42. struct mbuf *dequeue __ARGS((struct mbuf **q));
  43. void enqueue __ARGS((struct mbuf **q,struct mbuf *bp));
  44. void free_q __ARGS((struct mbuf **q));
  45. int16 len_q __ARGS((struct mbuf *bp));
  46.  
  47. struct mbuf *qdata __ARGS((char *data,int16 cnt));
  48. int16 dqdata __ARGS((struct mbuf *bp,char *buf,unsigned cnt));
  49.  
  50. void append __ARGS((struct mbuf **bph,struct mbuf *bp));
  51. struct mbuf *pushdown __ARGS((struct mbuf *bp,int16 size));
  52. int16 pullup __ARGS((struct mbuf **bph,char *buf,int16 cnt));
  53.  
  54. int pullchar __ARGS((struct mbuf **bpp));       /* returns -1 if nothing */
  55. long pull16 __ARGS((struct mbuf **bpp));    /* returns -1 if nothing */
  56. int32 pull32 __ARGS((struct mbuf **bpp));    /* returns  0 if nothing */
  57.  
  58. int16 get16 __ARGS((char *cp));
  59. int32 get32 __ARGS((char *cp));
  60. char *put16 __ARGS((char *cp,int16 x));
  61. char *put32 __ARGS((char *cp,int32 x));
  62.  
  63. void iqstat __ARGS((void));
  64. void refiq __ARGS((void));
  65. void mbuf_crunch __ARGS((struct mbuf **bpp));
  66.  
  67. #define AUDIT(bp)       audit(bp,__FILE__,__LINE__)
  68.  
  69. #endif    /* _MBUF_H */
  70.