xref: /titanic_44/usr/src/man/man9f/qreply.9f (revision ed22c7109fc5dd9e1b7a5d0333bdc7ad2718e2ab)
te
Copyright 1989 AT&T
Copyright (c) 2006, Sun Microsystems, Inc., All Rights Reserved
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
QREPLY 9F "Jan 16, 2006"
NAME
qreply - send a message on a stream in the reverse direction
SYNOPSIS

#include <sys/stream.h>



void qreply(queue_t *q, mblk_t *mp);
INTERFACE LEVEL

Architecture independent level 1 (DDI/DKI).

PARAMETERS
q

Pointer to the queue.

mp

Pointer to the message to be sent in the opposite direction.

DESCRIPTION

The qreply() function sends messages in the reverse direction of normal flow. That is, qreply(q, mp) is equivalent to putnext(OTHERQ(q), mp).

CONTEXT

The qreply() function can be called from user, interrupt, or kernel context.

EXAMPLES

Example 1 Canonical Flushing Code for STREAMS Drivers.

This example depicts the canonical flushing code for STREAMS drivers. Assume that the driver has service procedures so that there may be messages on its queues. See srv(9E). Its write-side put procedure handles M_FLUSH messages by first checking the FLUSHW bit in the first byte of the message, then the write queue is flushed (line 8) and the FLUSHW bit is turned off (line 9). See put(9E). If the FLUSHR bit is on, then the read queue is flushed (line 12) and the message is sent back up the read side of the stream with the qreply() function (line 13). If the FLUSHR bit is off, then the message is freed (line 15). See the example for flushq(9F) for the canonical flushing code for modules.

1 xxxwput(q, mp)
 2 queue_t *q;
 3 mblk_t *mp;
 4 {
 5 switch(mp->b_datap->db_type) {
 6 case M_FLUSH:
 7 if (*mp->b_rptr & FLUSHW) {
 8 flushq(q, FLUSHALL);
 9 *mp->b_rptr &= ~FLUSHW;
10 }
11 if (*mp->b_rptr & FLUSHR) {
12 flushq(RD(q), FLUSHALL);
13 qreply(q, mp);
14 } else {
15 freemsg(mp);
16 }
17 break;
 . . .
18 }
19 }
SEE ALSO

put(9E), srv(9E), flushq(9F), OTHERQ(9F), putnext(9F)

Writing Device Drivers

STREAMS Programming Guide