STREAMS-UX Programmer's Guide (February 2007)
Messages
Message Structures
Chapter 3
45
The fields perform the following functions:
b_next and b_prev Link the messages on a module or driver Queue’s message queue.
b_cont Builds a complex message from two or more message blocks.
b_rptr and b_wptr Locate the data present in the data buffer.
b_band Contains the priority band for a message.
b_datap Points to the data block header.
b_flag Contains a bitmask of flags interpreted by stream head.
Using Message Block Fields
•The b_next, b_prev, b_cont, b_rptr, b_wptr and b_band can be modified by drivers or modules.
•The b_datap must not be modified by drivers and modules.
• The following bitmask in b_flag field can be set or cleared by modules or drivers.
MSGMARK Provides a mechanism for driver or modules to mark the message.
MSGLASTCLOSE This flag is set in the M_CLOSE_REPL message by the driver upon receiving M_CLOSE
message to cause STREAMS to dismantle the stream. This is applicable only if the
device associated with the stream being closed has the flag C_ALLCLOSES set in d_flags
field of the cdevsw table corresponding to the driver being closed.
The datab structure has the following fields:
unsigned char * db_base; /* first byte of buffer */
unsigned char * db_lim; /* last byte+1 of buffer */
unsigned char db_ref; /* number of messages pointing to us */
unsigned char db_type; /* message type */
The db_base and db_lim fields point to the beginning and end (+1) of the buffer.
The db_ref represents the number of message blocks sharing the data block. Figure 3-1, “A Message and Its
Linkage,” shows Message 1 and Message 2 sharing the data block. Multiple messages can point to the same
data block to conserve the memory and avoid copying overhead. The drivers or modules can use the dupb ()
command utility to share the data block between the multiple messages. If the value of db_ref is greater than
1, the modules and driver must not modify the data buffer.
The db_type contains the message type associated with the message. The message type indicates the type of
operation and represents the implicit priority associated with the message.
Drivers and modules must not modify the contents of dblk_t.
Message Types
Every message in STREAMS that is generated by a user application or STREAMS component has a message
type attribute associated with it. The message type specifies the implicit message priority. The different types
of messages are supported by STREAMS/UX and are defined in <sys/stream.h>, refer to Appendix C,
“Message Types,” on page 239.
STREAMS/UX supports the following message types:
Ordinary Messages