Annotation of sys/sys/mbuf.h, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: mbuf.h,v 1.92 2007/07/20 09:59:19 claudio Exp $ */
! 2: /* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */
! 3:
! 4: /*
! 5: * Copyright (c) 1982, 1986, 1988, 1993
! 6: * The Regents of the University of California. All rights reserved.
! 7: *
! 8: * Redistribution and use in source and binary forms, with or without
! 9: * modification, are permitted provided that the following conditions
! 10: * are met:
! 11: * 1. Redistributions of source code must retain the above copyright
! 12: * notice, this list of conditions and the following disclaimer.
! 13: * 2. Redistributions in binary form must reproduce the above copyright
! 14: * notice, this list of conditions and the following disclaimer in the
! 15: * documentation and/or other materials provided with the distribution.
! 16: * 3. Neither the name of the University nor the names of its contributors
! 17: * may be used to endorse or promote products derived from this software
! 18: * without specific prior written permission.
! 19: *
! 20: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
! 21: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! 22: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 23: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
! 24: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 25: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 26: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 27: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 28: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 29: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 30: * SUCH DAMAGE.
! 31: *
! 32: * @(#)mbuf.h 8.5 (Berkeley) 2/19/95
! 33: */
! 34:
! 35: #ifndef _SYS_MALLOC_H_
! 36: #include <sys/malloc.h>
! 37: #endif
! 38: #include <sys/pool.h>
! 39: #include <sys/queue.h>
! 40:
! 41: /*
! 42: * Mbufs are of a single size, MSIZE (machine/param.h), which
! 43: * includes overhead. An mbuf may add a single "mbuf cluster" of size
! 44: * MCLBYTES (also in machine/param.h), which has no additional overhead
! 45: * and is used instead of the internal data area; this is done when
! 46: * at least MINCLSIZE of data must be stored.
! 47: */
! 48:
! 49: #define MLEN (MSIZE - sizeof(struct m_hdr)) /* normal data len */
! 50: #define MHLEN (MLEN - sizeof(struct pkthdr)) /* data len w/pkthdr */
! 51:
! 52: #define MINCLSIZE (MHLEN + 1) /* smallest amount to put in cluster */
! 53: #define M_MAXCOMPRESS (MHLEN / 2) /* max amount to copy for compression */
! 54:
! 55: /* Packet tags structure */
! 56: struct m_tag {
! 57: SLIST_ENTRY(m_tag) m_tag_link; /* List of packet tags */
! 58: u_int16_t m_tag_id; /* Tag ID */
! 59: u_int16_t m_tag_len; /* Length of data */
! 60: };
! 61:
! 62: /*
! 63: * Macros for type conversion
! 64: * mtod(m,t) - convert mbuf pointer to data pointer of correct type
! 65: */
! 66: #define mtod(m,t) ((t)((m)->m_data))
! 67:
! 68: /* header at beginning of each mbuf: */
! 69: struct m_hdr {
! 70: struct mbuf *mh_next; /* next buffer in chain */
! 71: struct mbuf *mh_nextpkt; /* next chain in queue/record */
! 72: caddr_t mh_data; /* location of data */
! 73: u_int mh_len; /* amount of data in this mbuf */
! 74: short mh_type; /* type of data in this mbuf */
! 75: u_short mh_flags; /* flags; see below */
! 76: };
! 77:
! 78: /* pf stuff */
! 79: struct pkthdr_pf {
! 80: void *hdr; /* saved hdr pos in mbuf, for ECN */
! 81: u_int rtableid; /* alternate routing table id */
! 82: u_int32_t qid; /* queue id */
! 83: u_int16_t tag; /* tag id */
! 84: u_int8_t flags;
! 85: u_int8_t routed;
! 86: };
! 87:
! 88: /* pkthdr_pf.flags */
! 89: #define PF_TAG_GENERATED 0x01
! 90: #define PF_TAG_FRAGCACHE 0x02
! 91: #define PF_TAG_TRANSLATE_LOCALHOST 0x04
! 92:
! 93: /* record/packet header in first mbuf of chain; valid if M_PKTHDR set */
! 94: struct pkthdr {
! 95: struct ifnet *rcvif; /* rcv interface */
! 96: SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */
! 97: int len; /* total packet length */
! 98: int csum_flags; /* checksum flags */
! 99: struct pkthdr_pf pf;
! 100: };
! 101:
! 102: /* description of external storage mapped into mbuf, valid if M_EXT set */
! 103: struct m_ext {
! 104: caddr_t ext_buf; /* start of buffer */
! 105: /* free routine if not the usual */
! 106: void (*ext_free)(caddr_t, u_int, void *);
! 107: void *ext_arg; /* argument for ext_free */
! 108: u_int ext_size; /* size of buffer, for ext_free */
! 109: int ext_type;
! 110: struct mbuf *ext_nextref;
! 111: struct mbuf *ext_prevref;
! 112: #ifdef DEBUG
! 113: const char *ext_ofile;
! 114: const char *ext_nfile;
! 115: int ext_oline;
! 116: int ext_nline;
! 117: #endif
! 118: };
! 119:
! 120: struct mbuf {
! 121: struct m_hdr m_hdr;
! 122: union {
! 123: struct {
! 124: struct pkthdr MH_pkthdr; /* M_PKTHDR set */
! 125: union {
! 126: struct m_ext MH_ext; /* M_EXT set */
! 127: char MH_databuf[MHLEN];
! 128: } MH_dat;
! 129: } MH;
! 130: char M_databuf[MLEN]; /* !M_PKTHDR, !M_EXT */
! 131: } M_dat;
! 132: };
! 133: #define m_next m_hdr.mh_next
! 134: #define m_len m_hdr.mh_len
! 135: #define m_data m_hdr.mh_data
! 136: #define m_type m_hdr.mh_type
! 137: #define m_flags m_hdr.mh_flags
! 138: #define m_nextpkt m_hdr.mh_nextpkt
! 139: #define m_act m_nextpkt
! 140: #define m_pkthdr M_dat.MH.MH_pkthdr
! 141: #define m_ext M_dat.MH.MH_dat.MH_ext
! 142: #define m_pktdat M_dat.MH.MH_dat.MH_databuf
! 143: #define m_dat M_dat.M_databuf
! 144:
! 145: /* mbuf flags */
! 146: #define M_EXT 0x0001 /* has associated external storage */
! 147: #define M_PKTHDR 0x0002 /* start of record */
! 148: #define M_EOR 0x0004 /* end of record */
! 149: #define M_CLUSTER 0x0008 /* external storage is a cluster */
! 150: #define M_PROTO1 0x0010 /* protocol-specific */
! 151:
! 152: /* mbuf pkthdr flags, also in m_flags */
! 153: #define M_BCAST 0x0100 /* send/received as link-level broadcast */
! 154: #define M_MCAST 0x0200 /* send/received as link-level multicast */
! 155: #define M_CONF 0x0400 /* payload was encrypted (ESP-transport) */
! 156: #define M_AUTH 0x0800 /* payload was authenticated (AH or ESP auth) */
! 157: #define M_AUTH_AH 0x2000 /* header was authenticated (AH) */
! 158: #define M_TUNNEL 0x1000 /* IP-in-IP added by tunnel mode IPsec */
! 159: #define M_ANYCAST6 0x4000 /* received as IPv6 anycast */
! 160: #define M_LINK0 0x8000 /* link layer specific flag */
! 161: #define M_LOOP 0x0040 /* for Mbuf statistics */
! 162: #define M_FILDROP 0x0080 /* dropped by bpf filter */
! 163:
! 164: /* flags copied when copying m_pkthdr */
! 165: #define M_COPYFLAGS (M_PKTHDR|M_EOR|M_PROTO1|M_BCAST|M_MCAST|M_CONF|\
! 166: M_AUTH|M_ANYCAST6|M_LOOP|M_TUNNEL|M_LINK0|M_FILDROP)
! 167:
! 168: /* Checksumming flags */
! 169: #define M_IPV4_CSUM_OUT 0x0001 /* IPv4 checksum needed */
! 170: #define M_TCPV4_CSUM_OUT 0x0002 /* TCP checksum needed */
! 171: #define M_UDPV4_CSUM_OUT 0x0004 /* UDP checksum needed */
! 172: #define M_IPV4_CSUM_IN_OK 0x0008 /* IPv4 checksum verified */
! 173: #define M_IPV4_CSUM_IN_BAD 0x0010 /* IPv4 checksum bad */
! 174: #define M_TCP_CSUM_IN_OK 0x0020 /* TCP/IPv4 checksum verified */
! 175: #define M_TCP_CSUM_IN_BAD 0x0040 /* TCP/IPv4 checksum bad */
! 176: #define M_UDP_CSUM_IN_OK 0x0080 /* UDP/IPv4 checksum verified */
! 177: #define M_UDP_CSUM_IN_BAD 0x0100 /* UDP/IPv4 checksum bad */
! 178:
! 179: /* mbuf types */
! 180: #define MT_FREE 0 /* should be on free list */
! 181: #define MT_DATA 1 /* dynamic (data) allocation */
! 182: #define MT_HEADER 2 /* packet header */
! 183: #define MT_SONAME 3 /* socket name */
! 184: #define MT_SOOPTS 4 /* socket options */
! 185: #define MT_FTABLE 5 /* fragment reassembly header */
! 186: #define MT_CONTROL 6 /* extra-data protocol message */
! 187: #define MT_OOBDATA 7 /* expedited data */
! 188:
! 189: /* flags to m_get/MGET */
! 190: #define M_DONTWAIT M_NOWAIT
! 191: #define M_WAIT M_WAITOK
! 192:
! 193: /*
! 194: * mbuf utility macros:
! 195: *
! 196: * MBUFLOCK(code)
! 197: * prevents a section of code from from being interrupted by network
! 198: * drivers.
! 199: */
! 200: #define MBUFLOCK(code) do {\
! 201: int ms = splvm(); \
! 202: { code } \
! 203: splx(ms); \
! 204: } while(/* CONSTCOND */ 0)
! 205:
! 206: /*
! 207: * mbuf allocation/deallocation macros:
! 208: *
! 209: * MGET(struct mbuf *m, int how, int type)
! 210: * allocates an mbuf and initializes it to contain internal data.
! 211: *
! 212: * MGETHDR(struct mbuf *m, int how, int type)
! 213: * allocates an mbuf and initializes it to contain a packet header
! 214: * and internal data.
! 215: */
! 216: #define MGET(m, how, type) m = m_get((how), (type))
! 217:
! 218: #define MGETHDR(m, how, type) m = m_gethdr((how), (type))
! 219:
! 220: /*
! 221: * Macros for tracking external storage associated with an mbuf.
! 222: *
! 223: * Note: add and delete reference must be called at splvm().
! 224: */
! 225: #ifdef DEBUG
! 226: #define MCLREFDEBUGN(m, file, line) do { \
! 227: (m)->m_ext.ext_nfile = (file); \
! 228: (m)->m_ext.ext_nline = (line); \
! 229: } while (/* CONSTCOND */ 0)
! 230: #define MCLREFDEBUGO(m, file, line) do { \
! 231: (m)->m_ext.ext_ofile = (file); \
! 232: (m)->m_ext.ext_oline = (line); \
! 233: } while (/* CONSTCOND */ 0)
! 234: #else
! 235: #define MCLREFDEBUGN(m, file, line)
! 236: #define MCLREFDEBUGO(m, file, line)
! 237: #endif
! 238:
! 239: #define MCLBUFREF(p)
! 240: #define MCLISREFERENCED(m) ((m)->m_ext.ext_nextref != (m))
! 241: #define _MCLDEREFERENCE(m) do { \
! 242: (m)->m_ext.ext_nextref->m_ext.ext_prevref = \
! 243: (m)->m_ext.ext_prevref; \
! 244: (m)->m_ext.ext_prevref->m_ext.ext_nextref = \
! 245: (m)->m_ext.ext_nextref; \
! 246: } while (/* CONSTCOND */ 0)
! 247: #define _MCLADDREFERENCE(o, n) do { \
! 248: (n)->m_flags |= ((o)->m_flags & (M_EXT|M_CLUSTER)); \
! 249: (n)->m_ext.ext_nextref = (o)->m_ext.ext_nextref; \
! 250: (n)->m_ext.ext_prevref = (o); \
! 251: (o)->m_ext.ext_nextref = (n); \
! 252: (n)->m_ext.ext_nextref->m_ext.ext_prevref = (n); \
! 253: MCLREFDEBUGN((n), __FILE__, __LINE__); \
! 254: } while (/* CONSTCOND */ 0)
! 255: #define MCLINITREFERENCE(m) do { \
! 256: (m)->m_ext.ext_prevref = (m); \
! 257: (m)->m_ext.ext_nextref = (m); \
! 258: MCLREFDEBUGO((m), __FILE__, __LINE__); \
! 259: MCLREFDEBUGN((m), NULL, 0); \
! 260: } while (/* CONSTCOND */ 0)
! 261:
! 262: #define MCLADDREFERENCE(o, n) MBUFLOCK(_MCLADDREFERENCE((o), (n));)
! 263:
! 264: /*
! 265: * Macros for mbuf external storage.
! 266: *
! 267: * MCLGET allocates and adds an mbuf cluster to a normal mbuf;
! 268: * the flag M_EXT is set upon success.
! 269: *
! 270: * MEXTMALLOC allocates external storage and adds it to
! 271: * a normal mbuf; the flag M_EXT is set upon success.
! 272: *
! 273: * MEXTADD adds pre-allocated external storage to
! 274: * a normal mbuf; the flag M_EXT is set upon success.
! 275: */
! 276: #define MEXTMALLOC(m, size, how) do { \
! 277: (m)->m_ext.ext_buf = \
! 278: (caddr_t)malloc((size), mbtypes[(m)->m_type], (how)); \
! 279: if ((m)->m_ext.ext_buf != NULL) { \
! 280: (m)->m_data = (m)->m_ext.ext_buf; \
! 281: (m)->m_flags |= M_EXT; \
! 282: (m)->m_flags &= ~M_CLUSTER; \
! 283: (m)->m_ext.ext_size = (size); \
! 284: (m)->m_ext.ext_free = NULL; \
! 285: (m)->m_ext.ext_arg = NULL; \
! 286: (m)->m_ext.ext_type = mbtypes[(m)->m_type]; \
! 287: MCLINITREFERENCE(m); \
! 288: } \
! 289: } while (/* CONSTCOND */ 0)
! 290:
! 291: #define MEXTADD(m, buf, size, type, free, arg) do { \
! 292: (m)->m_data = (m)->m_ext.ext_buf = (caddr_t)(buf); \
! 293: (m)->m_flags |= M_EXT; \
! 294: (m)->m_flags &= ~M_CLUSTER; \
! 295: (m)->m_ext.ext_size = (size); \
! 296: (m)->m_ext.ext_free = (free); \
! 297: (m)->m_ext.ext_arg = (arg); \
! 298: (m)->m_ext.ext_type = (type); \
! 299: MCLINITREFERENCE(m); \
! 300: } while (/* CONSTCOND */ 0)
! 301:
! 302: /*
! 303: * Reset the data pointer on an mbuf.
! 304: */
! 305: #define MRESETDATA(m) \
! 306: do { \
! 307: if ((m)->m_flags & M_EXT) \
! 308: (m)->m_data = (m)->m_ext.ext_buf; \
! 309: else if ((m)->m_flags & M_PKTHDR) \
! 310: (m)->m_data = (m)->m_pktdat; \
! 311: else \
! 312: (m)->m_data = (m)->m_dat; \
! 313: } while (/* CONSTCOND */ 0)
! 314:
! 315: #define MCLGET(m, how) m_clget(m, how)
! 316:
! 317: /*
! 318: * MFREE(struct mbuf *m, struct mbuf *n)
! 319: * Free a single mbuf and associated external storage.
! 320: * Place the successor, if any, in n.
! 321: */
! 322: #define MFREE(m, n) n = m_free((m))
! 323:
! 324: /*
! 325: * Move just m_pkthdr from from to to,
! 326: * remove M_PKTHDR and clean the tag for from.
! 327: */
! 328: #define M_MOVE_HDR(to, from) { \
! 329: (to)->m_pkthdr = (from)->m_pkthdr; \
! 330: (from)->m_flags &= ~M_PKTHDR; \
! 331: SLIST_INIT(&(from)->m_pkthdr.tags); \
! 332: }
! 333:
! 334: /*
! 335: * Duplicate just m_pkthdr from from to to.
! 336: */
! 337: #define M_DUP_HDR(to, from) { \
! 338: (to)->m_pkthdr = (from)->m_pkthdr; \
! 339: SLIST_INIT(&(to)->m_pkthdr.tags); \
! 340: m_tag_copy_chain((to), (from)); \
! 341: }
! 342:
! 343: /*
! 344: * Duplicate mbuf pkthdr from from to to.
! 345: * from must have M_PKTHDR set, and to must be empty.
! 346: */
! 347: #define M_DUP_PKTHDR(to, from) { \
! 348: (to)->m_flags = (from)->m_flags & M_COPYFLAGS; \
! 349: M_DUP_HDR((to), (from)); \
! 350: (to)->m_data = (to)->m_pktdat; \
! 351: }
! 352:
! 353: /*
! 354: * MOVE mbuf pkthdr from from to to.
! 355: * from must have M_PKTHDR set, and to must be empty.
! 356: */
! 357: #define M_MOVE_PKTHDR(to, from) { \
! 358: (to)->m_flags = (from)->m_flags & M_COPYFLAGS; \
! 359: M_MOVE_HDR((to), (from)); \
! 360: (to)->m_data = (to)->m_pktdat; \
! 361: }
! 362:
! 363: /*
! 364: * Set the m_data pointer of a newly-allocated mbuf (m_get/MGET) to place
! 365: * an object of the specified size at the end of the mbuf, longword aligned.
! 366: */
! 367: #define M_ALIGN(m, len) \
! 368: { (m)->m_data += (MLEN - (len)) &~ (sizeof(long) - 1); }
! 369: /*
! 370: * As above, for mbufs allocated with m_gethdr/MGETHDR
! 371: * or initialized by M_MOVE_PKTHDR.
! 372: */
! 373: #define MH_ALIGN(m, len) \
! 374: { (m)->m_data += (MHLEN - (len)) &~ (sizeof(long) - 1); }
! 375:
! 376: /*
! 377: * Determine if an mbuf's data area is read-only. This is true for
! 378: * non-cluster external storage and for clusters that are being
! 379: * referenced by more than one mbuf.
! 380: */
! 381: #define M_READONLY(m) \
! 382: (((m)->m_flags & M_EXT) != 0 && \
! 383: (((m)->m_flags & M_CLUSTER) == 0 || MCLISREFERENCED(m)))
! 384:
! 385: /*
! 386: * Compute the amount of space available
! 387: * before the current start of data in an mbuf.
! 388: */
! 389: #define _M_LEADINGSPACE(m) \
! 390: ((m)->m_flags & M_EXT ? (m)->m_data - (m)->m_ext.ext_buf : \
! 391: (m)->m_flags & M_PKTHDR ? (m)->m_data - (m)->m_pktdat : \
! 392: (m)->m_data - (m)->m_dat)
! 393:
! 394: #define M_LEADINGSPACE(m) \
! 395: (M_READONLY((m)) ? 0 : _M_LEADINGSPACE((m)))
! 396:
! 397: /*
! 398: * Compute the amount of space available
! 399: * after the end of data in an mbuf.
! 400: */
! 401: #define _M_TRAILINGSPACE(m) \
! 402: ((m)->m_flags & M_EXT ? (m)->m_ext.ext_buf + (m)->m_ext.ext_size - \
! 403: ((m)->m_data + (m)->m_len) : \
! 404: &(m)->m_dat[MLEN] - ((m)->m_data + (m)->m_len))
! 405:
! 406: #define M_TRAILINGSPACE(m) \
! 407: (M_READONLY((m)) ? 0 : _M_TRAILINGSPACE((m)))
! 408:
! 409: /*
! 410: * Arrange to prepend space of size plen to mbuf m.
! 411: * If a new mbuf must be allocated, how specifies whether to wait.
! 412: * If how is M_DONTWAIT and allocation fails, the original mbuf chain
! 413: * is freed and m is set to NULL.
! 414: */
! 415: #define M_PREPEND(m, plen, how) { \
! 416: if (M_LEADINGSPACE(m) >= (plen)) { \
! 417: (m)->m_data -= (plen); \
! 418: (m)->m_len += (plen); \
! 419: } else \
! 420: (m) = m_prepend((m), (plen), (how)); \
! 421: if ((m) && (m)->m_flags & M_PKTHDR) \
! 422: (m)->m_pkthdr.len += (plen); \
! 423: }
! 424:
! 425: /* change mbuf to new type */
! 426: #define MCHTYPE(m, t) { \
! 427: MBUFLOCK(mbstat.m_mtypes[(m)->m_type]--; mbstat.m_mtypes[t]++;); \
! 428: (m)->m_type = t;\
! 429: }
! 430:
! 431: /* length to m_copy to copy all */
! 432: #define M_COPYALL 1000000000
! 433:
! 434: /* compatibility with 4.3 */
! 435: #define m_copy(m, o, l) m_copym((m), (o), (l), M_DONTWAIT)
! 436:
! 437: /*
! 438: * Mbuf statistics.
! 439: * For statistics related to mbuf and cluster allocations, see also the
! 440: * pool headers (mbpool and mclpool).
! 441: */
! 442: struct mbstat {
! 443: u_long _m_spare; /* formerly m_mbufs */
! 444: u_long _m_spare1; /* formerly m_clusters */
! 445: u_long _m_spare2; /* spare field */
! 446: u_long _m_spare3; /* formely m_clfree - free clusters */
! 447: u_long m_drops; /* times failed to find space */
! 448: u_long m_wait; /* times waited for space */
! 449: u_long m_drain; /* times drained protocols for space */
! 450: u_short m_mtypes[256]; /* type specific mbuf allocations */
! 451: };
! 452:
! 453: #ifdef _KERNEL
! 454: extern struct mbstat mbstat;
! 455: extern int nmbclust; /* limit on the # of clusters */
! 456: extern int mblowat; /* mbuf low water mark */
! 457: extern int mcllowat; /* mbuf cluster low water mark */
! 458: extern int max_linkhdr; /* largest link-level header */
! 459: extern int max_protohdr; /* largest protocol header */
! 460: extern int max_hdr; /* largest link+protocol header */
! 461: extern int max_datalen; /* MHLEN - max_hdr */
! 462: extern int mbtypes[]; /* XXX */
! 463: extern struct pool mbpool;
! 464: extern struct pool mclpool;
! 465:
! 466: void mbinit(void);
! 467: struct mbuf *m_copym2(struct mbuf *, int, int, int);
! 468: struct mbuf *m_copym(struct mbuf *, int, int, int);
! 469: struct mbuf *m_free(struct mbuf *);
! 470: struct mbuf *m_get(int, int);
! 471: struct mbuf *m_getclr(int, int);
! 472: struct mbuf *m_gethdr(int, int);
! 473: struct mbuf *m_prepend(struct mbuf *, int, int);
! 474: struct mbuf *m_pulldown(struct mbuf *, int, int, int *);
! 475: struct mbuf *m_pullup(struct mbuf *, int);
! 476: struct mbuf *m_pullup2(struct mbuf *, int);
! 477: struct mbuf *m_split(struct mbuf *, int, int);
! 478: struct mbuf *m_inject(struct mbuf *, int, int, int);
! 479: struct mbuf *m_getptr(struct mbuf *, int, int *);
! 480: void m_clget(struct mbuf *, int);
! 481: void m_adj(struct mbuf *, int);
! 482: int m_clalloc(int, int);
! 483: void m_copyback(struct mbuf *, int, int, const void *);
! 484: void m_freem(struct mbuf *);
! 485: void m_reclaim(void *, int);
! 486: void m_copydata(struct mbuf *, int, int, caddr_t);
! 487: void m_cat(struct mbuf *, struct mbuf *);
! 488: struct mbuf *m_devget(char *, int, int, struct ifnet *,
! 489: void (*)(const void *, void *, size_t));
! 490: void m_zero(struct mbuf *);
! 491: int m_apply(struct mbuf *, int, int,
! 492: int (*)(caddr_t, caddr_t, unsigned int), caddr_t);
! 493:
! 494: /* Packet tag routines */
! 495: struct m_tag *m_tag_get(int, int, int);
! 496: void m_tag_prepend(struct mbuf *, struct m_tag *);
! 497: void m_tag_delete(struct mbuf *, struct m_tag *);
! 498: void m_tag_delete_chain(struct mbuf *);
! 499: struct m_tag *m_tag_find(struct mbuf *, int, struct m_tag *);
! 500: struct m_tag *m_tag_copy(struct m_tag *);
! 501: int m_tag_copy_chain(struct mbuf *, struct mbuf *);
! 502: void m_tag_init(struct mbuf *);
! 503: struct m_tag *m_tag_first(struct mbuf *);
! 504: struct m_tag *m_tag_next(struct mbuf *, struct m_tag *);
! 505:
! 506: /* Packet tag types */
! 507: #define PACKET_TAG_NONE 0 /* Nadda */
! 508: #define PACKET_TAG_IPSEC_IN_DONE 1 /* IPsec applied, in */
! 509: #define PACKET_TAG_IPSEC_OUT_DONE 2 /* IPsec applied, out */
! 510: #define PACKET_TAG_IPSEC_IN_CRYPTO_DONE 3 /* NIC IPsec crypto done */
! 511: #define PACKET_TAG_IPSEC_OUT_CRYPTO_NEEDED 4 /* NIC IPsec crypto req'ed */
! 512: #define PACKET_TAG_IPSEC_IN_COULD_DO_CRYPTO 5 /* NIC notifies IPsec */
! 513: #define PACKET_TAG_IPSEC_PENDING_TDB 6 /* Reminder to do IPsec */
! 514: #define PACKET_TAG_BRIDGE 7 /* Bridge processing done */
! 515: #define PACKET_TAG_GIF 8 /* GIF processing done */
! 516: #define PACKET_TAG_GRE 9 /* GRE processing done */
! 517: #define PACKET_TAG_IN_PACKET_CHECKSUM 10 /* NIC checksumming done */
! 518: #define PACKET_TAG_DLT 17 /* data link layer type */
! 519:
! 520: #ifdef MBTYPES
! 521: int mbtypes[] = { /* XXX */
! 522: M_FREE, /* MT_FREE 0 should be on free list */
! 523: M_MBUF, /* MT_DATA 1 dynamic (data) allocation */
! 524: M_MBUF, /* MT_HEADER 2 packet header */
! 525: M_MBUF, /* MT_SONAME 8 socket name */
! 526: M_SOOPTS, /* MT_SOOPTS 10 socket options */
! 527: M_FTABLE, /* MT_FTABLE 11 fragment reassembly header */
! 528: M_MBUF, /* MT_CONTROL 14 extra-data protocol message */
! 529: M_MBUF, /* MT_OOBDATA 15 expedited data */
! 530: };
! 531: #endif /* MBTYPES */
! 532: #endif
CVSweb