copyb

Synopsis

#include <sys/stream.h>
mblk_t *copyb(mblk_t *bp);

Interface Level

Architecture independent level 1 (DDI/DKI).

Parameters

bp

Pointer to the message block from which data is copied.

Description

The copyb() function allocates a new message block, and copies into it
the data from the block that bp denotes. The new block will
be at least as large as the block being copied. copyb() uses
the b_rptr and b_wptr members of bp to determine how many bytes
to copy.

Return Values

If successful, copyb() returns a pointer to the newly allocated message block
containing the copied data. Otherwise, it returns a NULL pointer.

Context

The copyb() function can be called from user, interrupt, or kernel context.

Examples

Example 1 Using copyb

For each message in the list, test to see if the downstream
queue is full with the canputnext(9F) function (line 21). If it is
not full, use copyb to copy a header message block, and dupmsg(9F) to
duplicate the data to be retransmitted. If either operation fails, reschedule a
timeout at the next valid interval.

Update the new header block with the correct destination address (line 34),
link the message to it (line 35), and send it downstream (line
36). At the end of the list, reschedule this routine.