STREAMS-UX Programmer's Guide (February 2007)

Multiplexing
STREAMS Multiplexor
Chapter 5
133
Lower Read Put Procedure
The lower read put procedure receives upstream bound data from the lower stream. If the upper streams are
flow controlled then messages can be queued on the lower read queue.
The lower read put procedure acting like a stream head should do the following:
Handle the M_FLUSH messages.
Handle the M_ERROR and M_HANGUP messages appropriately.
Route other data messages to the upper streams based on the criteria set by the multiplexor.
An example of a lower read put procedure is shown below:
int
mux_lrput(q, mp)
queue_t *q;
mblk_t *mp;
{
...
switch (mp->b_datap->db_type) {
case M_FLUSH:
if (*mp->b_rptr & FLUSHR) {
/* Flush the read queue */
...
}
if (*mp->b_rptr & FLUSHW) {
*mp->b_rptr &= ~FLUSHR;
/* flush the write queue if messages can be enqued */
qreply(q, mp);
} else
freemsg(mp);
break;
case M_ERROR:
case M_HANGUP:
muxerr = 1;
freemsg(mp);
break;
case M_DATA:
case M_PROTO:
/* let the service procedure do the processing and routing */
putq(q,mp);
break;
default:
/* Free all unrecognized messages */