.TH msgb "" "" "STREAMS Data Structure"
.PC "Structure of a STREAMS message block"
.B "#include <sys/types.h>"
.B "#include <sys/stream.h>"
.PP
A \*(ST message consists of one or message blocks.
A message block, in turn, is referenced by a pointer to the structure
.BR msgb .
The functions
.B allocb()
and
.B esballoc()
automatically create a
.B msgb
when they allocate a message; note that this structure must be created
.I only
by those functions.
.PP
The following fields within
.B msgb
can be read by drivers and modules:
.IP "\fBstruct msgb *b_next\fR" 1.5i
.IS "\fBstruct msgb *b_prev\fR"
The addresses of, respectively, the next and previous blocks of the
message queue.
These fields bind a queue's messages into a link list, and they
bind a message onto its queue.
.IP "\fBstruct msgb *b_cont\fR"
The address of the next message block within the message.
This field is initialized when a message consists of more than
one message block.
.IP "\fBuchar_t *b_rptr\fR"
.IS "\fBuchar_t *b_wptr\fR"
The addresses of, respectively, the first unread byte
within the data buffer associated with this message,
and the next byte to be written into the data buffer.
These fields together define the message's region within the
associated data buffer.
.IP "\fBstruct datab *b_datap\fR"
The address of this message's data block.
.I Never
change this field!
.IP "\fBuchar_t b_band\fR"
The message's priority band.
In normal- and high-priority messages,
.B b_band
is set to zero.
Use the value of this field to position the message within its queue:
the higher its priority band (that is, the lower the value of this field),
the closer to the head of the queue it should be.
.IP "\fBushort_t b_flag\fR"
A bitmask of flags that control how the stream head processes the message.
At present, the only valid flag is
.BR MSGMARK ,
which indicates that the last byte in the message is ``marked''.
.PP
When a message is on a queue, all fields within its
.B msgb
are read-only.
.SH "See Also"
.B
allocb(),
datab,
DDI/DKI data structures,
esballoc(),
free_rtn,
freeb(),
getq(),
messages,
rmvq()
.R
.SH Notes
The structure
.B msgb
is defined as type
.BR mblk_t .
