mbuf.h revision 46686
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.15 1999/03/29 08:21:28 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_VJCOMP 8 50#define MB_IPQ 9 51#define MB_MP 10 52#define MB_MAX MB_MP 53 54struct cmdargs; 55 56extern int mbuf_Length(struct mbuf *); 57extern struct mbuf *mbuf_Alloc(int, int); 58extern struct mbuf *mbuf_FreeSeg(struct mbuf *); 59extern void mbuf_Free(struct mbuf *); 60extern void mbuf_Write(struct mbuf *, const void *, size_t); 61extern struct mbuf *mbuf_Read(struct mbuf *, void *, size_t); 62extern size_t mbuf_View(struct mbuf *, void *, size_t); 63extern struct mbuf *mbuf_Prepend(struct mbuf *, const void *, size_t, size_t); 64extern struct mbuf *mbuf_Truncate(struct mbuf *, size_t); 65extern void mbuf_Log(void); 66extern int mbuf_Show(struct cmdargs const *); 67extern void mbuf_Enqueue(struct mqueue *, struct mbuf *); 68extern struct mbuf *mbuf_Dequeue(struct mqueue *); 69extern struct mbuf *mbuf_Contiguous(struct mbuf *); 70