mbuf.h revision 38472
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: mbuf.h,v 1.13 1998/08/07 18:42:50 brian Exp $
19 *
20 *	TODO:
21 */
22
23struct mbuf {
24  short size;			/* size allocated (excluding header) */
25  short offset;			/* offset from header end to start position */
26  short cnt;			/* available byte count in buffer */
27  short type;			/* MB_* below */
28  struct mbuf *next;		/* link to next mbuf */
29  struct mbuf *pnext;		/* link to next packet */
30  /* buffer space is malloc()d directly after the header */
31};
32
33struct mqueue {
34  struct mbuf *top;
35  struct mbuf *last;
36  int qlen;
37};
38
39#define MBUF_CTOP(bp)		((u_char *)((bp)+1) + (bp)->offset)
40#define CONST_MBUF_CTOP(bp)	((const u_char *)((bp)+1) + (bp)->offset)
41
42#define MB_ASYNC	1
43#define MB_FSM		2
44#define MB_CBCP		3
45#define MB_HDLCOUT	4
46#define MB_IPIN		5
47#define MB_ECHO		6
48#define MB_LQR		7
49#define MB_LINK		8
50#define MB_VJCOMP	9
51#define	MB_IPQ		10
52#define	MB_MP		11
53#define	MB_MAX		MB_MP
54
55struct cmdargs;
56
57extern int mbuf_Length(struct mbuf *);
58extern struct mbuf *mbuf_Alloc(int, int);
59extern struct mbuf *mbuf_FreeSeg(struct mbuf *);
60extern void mbuf_Free(struct mbuf *);
61extern void mbuf_Write(struct mbuf *, u_char *, int);
62extern struct mbuf *mbuf_Read(struct mbuf *, u_char *, int);
63extern void mbuf_Log(void);
64extern int mbuf_Show(struct cmdargs const *);
65extern void mbuf_Enqueue(struct mqueue *, struct mbuf *);
66extern struct mbuf *mbuf_Dequeue(struct mqueue *);
67