STREAMS-UX Programmer's Guide (February 2007)
Messages
Message Structures
Chapter 3
44
Message Structures
All STREAMS messages consists of one or more message blocks as shown in Figure 3-1, “A Message and Its
Linkage.” STREAMS message is comprised of two data structures — a message block and a data block.
The message block represented by msgb describes the message, the data block represented by datab describes
the data and contains the pointer to the variable-length data buffer.
Figure 3-1 A Message and Its Linkage
The message block and data block are represented and defined as struct msgb (mblk_t) and struct datab
(dblk_t) respectively in <sys/stream.h>.
The mblk_t structure has the following fields:
struct msgb * b_next; /* next message on queue */
struct msgb * b_prev; /* previous message on queue */
struct msgb * b_cont; /* next message block of message */
unsigned char * b_rptr; /* first unread data byte in buffer */
unsigned char * b_wptr; /* first unwritten data byte */
struct datab * b_datap; /* data block */
unsigned char b_band; /* message priority */
unsigned short b_flag; /* message flags restricted for STREAMS framework use only */
data
block
data
block
(type)
buffer
header
queue
b_next
b_next
b_prev
b_prev
b_cont
b_cont
b_datap
b_datap
b_datap
buffer
mblk_t
mblk_t
mblk_t
data
block
(type)
buffer
mblk_t
mblk_t
mblk_t
Message
1
Message
2
b_datap
b_cont
b_cont