STREAMS-UX Programmer's Guide (February 2007)
Messages
Message Processing and Flow Control
Chapter 3
55
mblk_t *copymsg(mblk_t *mp);
copymsg () Uses copyb () to copy the message blocks contained in the message pointed by bp to a newly
allocated message block, and links the new message blocks to form the new message.
mblk_t *dupb(mblk_t *bp);
dupb () Takes a pointer to a message block descriptor (mblk_t) as an input parameter, allocates a
new message and initialized it by copying the contents of the input message block. The new
message block descriptor points to the same data block as the input message block
descriptor. The db_ref in the data block (dblk_t) is incremented by 1.
When db_ref is greater than 1, modules and drivers must be aware that any changes made
to the data buffer affects all the message blocks sharing this data block. If the contents of a
message block with a reference count greater than 1 is to be modified, copymsg () should be
used to create a new message and only the new message block should be modified.
Upon success, dupb () returns a pointer to the new message block. Otherwise it returns a
NULL pointer.
mblk_t *dupmsg(mblk_t *bp);
dupmsg () Copies all the individual message block descriptors pointed by bp, and then using b_cont
pointer links the new message blocks to form the new message. Internally this utility uses
dupb (). The dupmsg () does not copy data buffers.
Upon success, dupmsg () returns a pointer to the new message. In case of failure, it returns
a NULL pointer.
int pullupmsg(mblk_t *mp, int len);
pullupmsg () Concatenates and aligns the number of bytes as represented by len bytes stored in a
complex message mp. The pullupmsg only concatenates messages of the same type. See the
Figure 3-4, “Pulling Up a Complex Message,” to see the results of the pullupmsg () operation.
If len is -1 then pullupmsg () will concatenate and align the entire contents of all the
messages into a single data block.
The pullupmsg () returns 1 on success and 0 in case of failure.