| MSGPULLUP(9F) | Kernel Functions for Drivers | MSGPULLUP(9F) |
msgpullup,
msgpullup_pad — concatenate
bytes in a message
#include
<sys/stream.h>
mblk_t *
msgpullup(mblk_t *mp,
ssize_t len);
mblk_t *
msgpullup_pad(mblk_t *mp,
ssize_t len, size_t pad);
Architecture independent level 1 (DDI/DKI).
The
msgpullup()
and
msgpullup_pad()
functions concatenate and align the first len data
bytes of the message pointed to by mp, copying the
data into a new message. msgpullup_pad() allows for
the insertion of exactly pad bytes before this copied
segment to set up desired alignment of any internal structures.
msgpullup() inserts no such padding. Any remaining
bytes in the remaining message blocks will be cheaply referenced via
dupmsg(9F) and linked onto the new
message. The original message is unaltered and a new lead
mblk_t will always be allocated for a successful call,
regardless of whether mp already has sufficient
contiguous data bytes or headroom. If len equals
-1, all data are
concatenated.
Allocation of padding bytes can be useful for modules working with network packets. If a driver expects that it (or a subsequent module) will insert additional headers or encapsulation, this can provide sufficient headroom to keep all packet headers within a single mblk_t. This padding can be used by adjusting b_rptr downwards, where db_base (datab(9S)) is the lower bound.
If len bytes of the same
message type cannot be found, or the requested padding would cause an
overflow,
msgpullup()
and
msgpullup_pad()
fail and return NULL.
The msgpullup() and
msgpullup_pad() functions can be called from user,
interrupt, or kernel context.
Upon successful completion, the
msgpullup() and
msgpullup_pad() functions return a non-NULL pointer
to the new message. NULL is returned to indicate an
illegal set of parameters or an allocation failure.
srv(9E), allocb(9F), dupmsg(9F), pullupmsg(9F), datab(9S), msgb(9S)
Writing Device Drivers.
STREAMS Programming Guide.
The msgpullup() function is a
DKI-compliant replacement for the older
pullupmsg(9F) routine. Users are
strongly encouraged to use msgpullup() instead of
pullupmsg(9F).
| March 23, 2026 | OmniOS |