mbuf.h revision 38472
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 * 1838472Sbrian * $Id: mbuf.h,v 1.13 1998/08/07 18:42:50 brian Exp $ 196059Samurai * 206059Samurai * TODO: 216059Samurai */ 226059Samurai 236059Samuraistruct mbuf { 2438472Sbrian short size; /* size allocated (excluding header) */ 2538472Sbrian short offset; /* offset from header end to start position */ 2628679Sbrian short cnt; /* available byte count in buffer */ 2738472Sbrian short type; /* MB_* below */ 2828679Sbrian struct mbuf *next; /* link to next mbuf */ 2928679Sbrian struct mbuf *pnext; /* link to next packet */ 3038472Sbrian /* buffer space is malloc()d directly after the header */ 316059Samurai}; 326059Samurai 336059Samuraistruct mqueue { 346059Samurai struct mbuf *top; 356059Samurai struct mbuf *last; 366059Samurai int qlen; 376059Samurai}; 386059Samurai 3938472Sbrian#define MBUF_CTOP(bp) ((u_char *)((bp)+1) + (bp)->offset) 4038472Sbrian#define CONST_MBUF_CTOP(bp) ((const u_char *)((bp)+1) + (bp)->offset) 416059Samurai 426059Samurai#define MB_ASYNC 1 436059Samurai#define MB_FSM 2 4438174Sbrian#define MB_CBCP 3 4538174Sbrian#define MB_HDLCOUT 4 4638174Sbrian#define MB_IPIN 5 4738174Sbrian#define MB_ECHO 6 4838174Sbrian#define MB_LQR 7 4938174Sbrian#define MB_LINK 8 5038174Sbrian#define MB_VJCOMP 9 5138174Sbrian#define MB_IPQ 10 5238174Sbrian#define MB_MP 11 5336285Sbrian#define MB_MAX MB_MP 546059Samurai 5536285Sbrianstruct cmdargs; 5636285Sbrian 5736285Sbrianextern int mbuf_Length(struct mbuf *); 5836285Sbrianextern struct mbuf *mbuf_Alloc(int, int); 5936285Sbrianextern struct mbuf *mbuf_FreeSeg(struct mbuf *); 6036285Sbrianextern void mbuf_Free(struct mbuf *); 6136285Sbrianextern void mbuf_Write(struct mbuf *, u_char *, int); 6236285Sbrianextern struct mbuf *mbuf_Read(struct mbuf *, u_char *, int); 6336285Sbrianextern void mbuf_Log(void); 6436285Sbrianextern int mbuf_Show(struct cmdargs const *); 6536285Sbrianextern void mbuf_Enqueue(struct mqueue *, struct mbuf *); 6636285Sbrianextern struct mbuf *mbuf_Dequeue(struct mqueue *); 67