April 2012
Intermediate to advanced
352 pages
8h
English
An mbuf structure is a memory buffer for network data. Commonly, this data spans multiple mbuf structures, which are arranged into a linked list known as an mbuf chain.
struct mbuf is defined in the <sys/mbuf.h> header as follows:
struct mbuf {
struct m_hdr m_hdr;
union {
struct {
struct pkthdr MH_pkthdr;
union {
struct m_ext MH_ext;
char MH_databuf[MHLEN];
} MH_dat;
} MH;
char M_databuf[MLEN];
} M_dat;
};Every mbuf structure contains a buffer for data and a header, which looks like this:
struct m_hdr { struct mbuf *mh_next; /* Next ...