DTOM Macro for mbuf Kernel Services

Purpose

Converts an address anywhere within an mbuf structure to the head of that mbuf structure.

Syntax

#include <sys/mbuf.h>

DTOM ( bp);

Parameter

Item Description
bp Points to an address within an mbuf structure.

Description

The DTOM macro converts an address anywhere within an mbuf structure to the head of that mbuf structure. This macro is valid only for mbuf structures without an external buffer (that is, with the M_EXT flag not set).

This macro can be viewed as the opposite of the MTOD macro, which converts the address of an mbuf structure into the address of the actual data contained in the buffer. However, the DTOM macro is more general than this view implies. That is, the input parameter can point to any address within the mbuf structure, not merely the address of the actual data.

Example

The DTOM macro can be used as follows:

char               *bp;
struct mbuf        *m;
m = DTOM(bp);