xref: /freebsd/usr.sbin/ppp/mbuf.h (revision e627b39baccd1ec9129690167cf5e6d860509655)
1 /*
2  *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
3  *
4  *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
5  *
6  * Redistribution and use in source and binary forms are permitted
7  * provided that the above copyright notice and this paragraph are
8  * duplicated in all such forms and that any documentation,
9  * advertising materials, and other materials related to such
10  * distribution and use acknowledge that the software was developed
11  * by the Internet Initiative Japan.  The name of the
12  * IIJ may not be used to endorse or promote products derived
13  * from this software without specific prior written permission.
14  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
16  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17  *
18  * $Id:$
19  *
20  *	TODO:
21  */
22 
23 #ifndef _MBUF_H_
24 #define _MBUF_H_
25 
26 struct mbuf {
27   u_char *base;		/* pointer to top of buffer space */
28   short size;		/* size allocated from base */
29   short offset;		/* offset to start position */
30   short cnt;		/* available byte count in buffer */
31   short type;
32   struct mbuf *next;	/* link to next mbuf */
33   struct mbuf *pnext;	/* link to next packet */
34 };
35 
36 struct mqueue {
37   struct mbuf *top;
38   struct mbuf *last;
39   int qlen;
40 };
41 
42 #define	NULLBUFF	((struct mbuf *)0)
43 
44 #define MBUF_CTOP(bp)   (bp->base + bp->offset)
45 
46 #define MB_ASYNC	1
47 #define MB_FSM		2
48 #define MB_HDLCOUT	3
49 #define MB_IPIN		4
50 #define MB_ECHO		5
51 #define MB_LQR		6
52 #define MB_MODEM	7
53 #define MB_VJCOMP	8
54 #define	MB_LOG		9
55 #define	MB_IPQ		10
56 #define	MB_MAX		MB_IPQ
57 
58 extern int plength __P((struct mbuf *bp));
59 extern struct mbuf *mballoc __P((int cnt, int type));
60 extern struct mbuf *mbfree __P((struct mbuf *bp));
61 extern void pfree __P((struct mbuf *bp));
62 extern void mbwrite __P((struct mbuf *bp, u_char *ptr, int cnt));
63 extern struct mbuf *mbread __P((struct mbuf *bp, u_char *ptr, int cnt));
64 extern void DumpBp __P((struct mbuf *bp));
65 extern void Enqueue __P((struct mqueue *queue, struct mbuf *bp));
66 extern struct mbuf *Dequeue __P((struct mqueue *queue));
67 #endif
68