STREAMS-UX Programmer's Guide (February 2007)

Messages
Message Structures
Chapter 3
48
The streamtab Structure
Every STREAMS module and driver installed on a system is associated with a struct streamtab structure
defined in <sys/stream.h> in addition to other structures. The information provided by the module or driver
writer in this structure is used by STREAMS to initialize the queue-pair associated with the module or driver.
The struct streamtab contains pointers to message handling procedures and other message processing
parameters defining the behavior of the module.
struct qinit * st_rdinit; /* defines read QUEUE */
struct qinit * st_wrinit; /* defines write QUEUE */
struct qinit * st_muxrinit; /* for multiplexing drivers only */
struct qinit * st_muxwinit; /* for multiplexing drivers only */
The st_muxrinit and st_muxwinit structures point to the qinit structure of the lower read-side and
write-side of a multiplexing driver.
NOTE For all modules and non-multiplexing drivers these fields should be set to NULL.
The queue Structure
The queue structure defined in <sys/stream.h> as queue_t is the central building block of the queues in
STREAMS. The struct queue has the following fields:
struct qinit * q_qinfo; /* procedures and limits for queue */
struct msgb * q_first; /* head of message queue */
struct msgb * q_last; /* tail of message queue */
struct queue * q_next; /* next QUEUE in Stream */
struct queue * q_link; /* link to scheduling queue */
void * q_ptr; /* to private data structure */
ulong q_count; /* weighted count of characters on q */
ulong q_flag; /* QUEUE state */
long q_minpsz; /* min packet size accepted */
long q_maxpsz; /* max packet size accepted */
ulong q_hiwat; /* high water mark, for flow control */
ulong q_lowat; /* low water mark */
struct qband * q_bandp; /* band information */
unsigned char q_nband; /* number of bands */
struct queue * q_other; /* pointer to other Q in queue pair */
On a queue-pair allocation, the contents of this structure are initialized to zero. STREAMS however
initializes the following fields if specified by the modules:
q_qinfo — set to the value specified in the streamtab
q_minpsz, q_maxpsz, q_hiwat and q_lowat — set to the value specified in the struct module_info.
The module or driver open routine can optionally set the q_ptr to point to a private structure owned and
managed by the modules/drivers.
The q_first and q_last fields refer to the first and last messages on the message queue.
The q_next field points to the queue associated with the next component, downstream for a write queue and
upstream for a read queue.