home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (c) 1982, 1986, 1988, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)mbuf.h 8.5 (Berkeley) 2/19/95
- */
-
- #ifndef _SYS_MBUF_H
- #define _SYS_MBUF_H
-
- #ifndef EXEC_TYPES_H
- #include <exec/types.h>
- #endif /* EXEC_TYPES_H */
-
- #ifndef _NET_IF_H
- #include <net/if.h>
- #endif /* _NET_IF_H */
-
- /*
- * Constants related to network buffer management.
- * MCLBYTES must be no larger than CLBYTES (the software page size), and,
- * on machines that exchange pages of input or output buffers with mbuf
- * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
- * of the hardware page size.
- */
- #define MSIZE 128 /* size of an mbuf */
- #define MCLBYTES 2048 /* large enough for ether MTU */
- #define MCLSHIFT 11
- #define MCLOFSET (MCLBYTES - 1)
-
- /*
- * Mbufs are of a single size, MSIZE (machine/machparam.h), which
- * includes overhead. An mbuf may add a single "mbuf cluster" of size
- * MCLBYTES (also in machine/machparam.h), which has no additional overhead
- * and is used instead of the internal data area; this is done when
- * at least MINCLSIZE of data must be stored.
- */
-
- #define MLEN (MSIZE - sizeof(struct m_hdr)) /* normal data len */
- #define MHLEN (MLEN - sizeof(struct pkthdr)) /* data len w/pkthdr */
-
- #define MINCLSIZE (MHLEN + MLEN) /* smallest amount to put in cluster */
- #define M_MAXCOMPRESS (MHLEN / 2) /* max amount to copy for compression */
-
- /*
- * Macros for type conversion
- * mtod(m,t) - convert mbuf pointer to data pointer of correct type
- * dtom(x) - convert data pointer within mbuf to mbuf pointer (XXX)
- */
- #define mtod(m,t) ((t)((m)->m_data))
- #define dtom(x) ((struct mbuf *)((long)(x) & ~(MSIZE-1)))
-
- /* header at beginning of each mbuf: */
- struct m_hdr {
- struct mbuf *mh_next; /* next buffer in chain */
- struct mbuf *mh_nextpkt; /* next chain in queue/record */
- APTR mh_data; /* location of data */
- LONG mh_len; /* amount of data in this mbuf */
- WORD mh_type; /* type of data in this mbuf */
- WORD mh_flags; /* flags; see below */
- };
-
- /* record/packet header in first mbuf of chain; valid if M_PKTHDR set */
- struct pkthdr {
- struct ifnet *rcvif; /* rcv interface */
- LONG len; /* total packet length */
- };
-
- /* description of external storage mapped into mbuf, valid if M_EXT set */
- struct m_ext {
- APTR ext_buf; /* start of buffer */
- APTR ext_free; /* free routine if not the usual */
- ULONG ext_size; /* size of buffer, for ext_free */
- };
-
- struct mbuf {
- struct m_hdr m_hdr;
- union {
- struct {
- struct pkthdr MH_pkthdr; /* M_PKTHDR set */
- union {
- struct m_ext MH_ext; /* M_EXT set */
- UBYTE MH_databuf[MHLEN];
- } MH_dat;
- } MH;
- UBYTE M_databuf[MLEN]; /* !M_PKTHDR, !M_EXT */
- } M_dat;
- };
- #define m_next m_hdr.mh_next
- #define m_len m_hdr.mh_len
- #define m_data m_hdr.mh_data
- #define m_type m_hdr.mh_type
- #define m_flags m_hdr.mh_flags
- #define m_nextpkt m_hdr.mh_nextpkt
- #define m_act m_nextpkt
- #define m_pkthdr M_dat.MH.MH_pkthdr
- #define m_ext M_dat.MH.MH_dat.MH_ext
- #define m_pktdat M_dat.MH.MH_dat.MH_databuf
- #define m_dat M_dat.M_databuf
-
- /* mbuf flags */
- #define M_EXT 0x0001 /* has associated external storage */
- #define M_PKTHDR 0x0002 /* start of record */
- #define M_EOR 0x0004 /* end of record */
-
- /* mbuf pkthdr flags, also in m_flags */
- #define M_BCAST 0x0100 /* send/received as link-level broadcast */
- #define M_MCAST 0x0200 /* send/received as link-level multicast */
-
- /* flags copied when copying m_pkthdr */
- #define M_COPYFLAGS (M_PKTHDR|M_EOR|M_BCAST|M_MCAST)
-
- /* length to m_copy to copy all */
- #define M_COPYALL 1000000000
-
- /*
- * Mbuf statistics.
- */
- struct mbstat {
- ULONG m_mbufs; /* mbufs obtained from page pool */
- ULONG m_clusters; /* clusters obtained from page pool */
- ULONG m_spare; /* spare field */
- ULONG m_clfree; /* free clusters */
- ULONG m_drops; /* times failed to find space */
- ULONG m_wait; /* times waited for space */
- ULONG m_drain; /* times drained protocols for space */
- };
-
- #endif /* _SYS_MBUF_H */
-