mbuf.h revision 6059
16059Samurai/*
26059Samurai *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
36059Samurai *
46059Samurai *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
56059Samurai *
66059Samurai * Redistribution and use in source and binary forms are permitted
76059Samurai * provided that the above copyright notice and this paragraph are
86059Samurai * duplicated in all such forms and that any documentation,
96059Samurai * advertising materials, and other materials related to such
106059Samurai * distribution and use acknowledge that the software was developed
116059Samurai * by the Internet Initiative Japan.  The name of the
126059Samurai * IIJ may not be used to endorse or promote products derived
136059Samurai * from this software without specific prior written permission.
146059Samurai * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
156059Samurai * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
166059Samurai * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
176059Samurai *
186059Samurai * $Id:$
196059Samurai *
206059Samurai *	TODO:
216059Samurai */
226059Samurai
236059Samurai#ifndef _MBUF_H_
246059Samurai#define _MBUF_H_
256059Samurai
266059Samuraistruct mbuf {
276059Samurai  u_char *base;		/* pointer to top of buffer space */
286059Samurai  short size;		/* size allocated from base */
296059Samurai  short offset;		/* offset to start position */
306059Samurai  short cnt;		/* available byte count in buffer */
316059Samurai  short type;
326059Samurai  struct mbuf *next;	/* link to next mbuf */
336059Samurai  struct mbuf *pnext;	/* link to next packet */
346059Samurai};
356059Samurai
366059Samuraistruct mqueue {
376059Samurai  struct mbuf *top;
386059Samurai  struct mbuf *last;
396059Samurai  int qlen;
406059Samurai};
416059Samurai
426059Samurai#define	NULLBUFF	((struct mbuf *)0)
436059Samurai
446059Samurai#define MBUF_CTOP(bp)   (bp->base + bp->offset)
456059Samurai
466059Samurai#define MB_ASYNC	1
476059Samurai#define MB_FSM		2
486059Samurai#define MB_HDLCOUT	3
496059Samurai#define MB_IPIN		4
506059Samurai#define MB_ECHO		5
516059Samurai#define MB_LQR		6
526059Samurai#define MB_MODEM	7
536059Samurai#define MB_VJCOMP	8
546059Samurai#define	MB_LOG		9
556059Samurai#define	MB_IPQ		10
566059Samurai#define	MB_MAX		MB_IPQ
576059Samurai
586059Samuraiextern int plength(struct mbuf *bp);
596059Samuraiextern struct mbuf *mballoc(int cnt, int type);
606059Samuraiextern struct mbuf *mbfree(struct mbuf *bp);
616059Samuraiextern void pfree(struct mbuf *bp);
626059Samuraiextern void mbwrite(struct mbuf *bp, u_char *ptr, int cnt);
636059Samuraiextern struct mbuf *mbread(struct mbuf *bp, u_char *ptr, int cnt);
646059Samuraiextern void DumpBp(struct mbuf *bp);
656059Samuraiextern void Enqueue(struct mqueue *queue, struct mbuf *bp);
666059Samuraiextern struct mbuf *Dequeue(struct mqueue *queue);
676059Samurai#endif
68