/* * 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 */ /* 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 */ caddr_t mh_data;/* location of data */ int mh_len;/* amount of data in this mbuf */ short mh_type;/* type of data in this mbuf */ short 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 */ int len;/* total packet length */ }; /* description of external storage mapped into mbuf, valid if M_EXT set */ struct m_ext { caddr_t ext_buf;/* start of buffer */ void(*ext_free)();/* free routine if not the usual */ u_int 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 */ char MH_databuf[MHLEN]; } MH_dat; } MH; char M_databuf[MLEN];/* !M_PKTHDR, !M_EXT */ } M_dat; };
/* mbuf flags */ #define M_EXT 0x0001 /* has associated external storage */ #define M_PKTHDR 0x0002 /* start of record */ #define M_EOR 0x0004 /* end of record */