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 * $FreeBSD$ 19 * 20 * TODO: 21 */ 22 23 struct mbuf { 24 size_t m_size; /* size allocated (excluding header) */ 25 short m_offset; /* offset from header end to start position */ 26 size_t m_len; /* available byte count in buffer */ 27 short m_type; /* MB_* below */ 28 struct mbuf *m_next; /* link to next mbuf */ 29 struct mbuf *m_nextpkt; /* link to next packet */ 30 /* buffer space is malloc()d directly after the header */ 31 }; 32 33 struct mqueue { 34 struct mbuf *top; 35 struct mbuf *last; 36 size_t len; 37 }; 38 39 #define MBUF_CTOP(bp) \ 40 ((bp) ? (u_char *)((bp)+1) + (bp)->m_offset : NULL) 41 42 #define CONST_MBUF_CTOP(bp) \ 43 ((bp) ? (const u_char *)((bp)+1) + (bp)->m_offset : NULL) 44 45 #define MB_IPIN 0 46 #define MB_IPOUT 1 47 #define MB_NATIN 2 48 #define MB_NATOUT 3 49 #define MB_MPIN 4 50 #define MB_MPOUT 5 51 #define MB_VJIN 6 52 #define MB_VJOUT 7 53 #define MB_ICOMPDIN 8 54 #define MB_ICOMPDOUT 9 55 #define MB_COMPDIN 10 56 #define MB_COMPDOUT 11 57 #define MB_LQRIN 12 58 #define MB_LQROUT 13 59 #define MB_ECHOIN 14 60 #define MB_ECHOOUT 15 61 #define MB_PROTOIN 16 62 #define MB_PROTOOUT 17 63 #define MB_ACFIN 18 64 #define MB_ACFOUT 19 65 #define MB_SYNCIN 20 66 #define MB_SYNCOUT 21 67 #define MB_HDLCIN 22 68 #define MB_HDLCOUT 23 69 #define MB_ASYNCIN 24 70 #define MB_ASYNCOUT 25 71 #define MB_CBCPIN 26 72 #define MB_CBCPOUT 27 73 #define MB_CHAPIN 28 74 #define MB_CHAPOUT 29 75 #define MB_PAPIN 30 76 #define MB_PAPOUT 31 77 #define MB_CCPIN 32 78 #define MB_CCPOUT 33 79 #define MB_IPCPIN 34 80 #define MB_IPCPOUT 35 81 #define MB_LCPIN 36 82 #define MB_LCPOUT 37 83 #define MB_UNKNOWN 38 84 #define MB_MAX MB_UNKNOWN 85 86 #define M_MAXLEN (4352 - sizeof(struct mbuf)) /* > HDLCSIZE */ 87 88 struct cmdargs; 89 90 extern int m_length(struct mbuf *); 91 extern struct mbuf *m_get(size_t, int); 92 extern struct mbuf *m_free(struct mbuf *); 93 extern void m_freem(struct mbuf *); 94 extern void mbuf_Write(struct mbuf *, const void *, size_t); 95 extern struct mbuf *mbuf_Read(struct mbuf *, void *, size_t); 96 extern size_t mbuf_View(struct mbuf *, void *, size_t); 97 extern struct mbuf *m_prepend(struct mbuf *, const void *, size_t, size_t); 98 extern struct mbuf *m_adj(struct mbuf *, ssize_t); 99 extern struct mbuf *m_pullup(struct mbuf *); 100 extern void m_settype(struct mbuf *, int); 101 extern struct mbuf *m_append(struct mbuf *, const void *, size_t); 102 103 extern int mbuf_Show(struct cmdargs const *); 104 105 extern void m_enqueue(struct mqueue *, struct mbuf *); 106 extern struct mbuf *m_dequeue(struct mqueue *); 107