1qreply(9F)               Kernel Functions for Drivers               qreply(9F)
2
3
4

NAME

6       qreply - send a message on a stream in the reverse direction
7

SYNOPSIS

9       #include <sys/stream.h>
10
11
12
13       void qreply(queue_t *q, mblk_t *mp);
14
15

INTERFACE LEVEL

17       Architecture independent level 1 (DDI/DKI).
18

PARAMETERS

20       q     Pointer to the queue.
21
22
23       mp    Pointer to the message to be sent in the opposite direction.
24
25

DESCRIPTION

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

CONTEXT

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

EXAMPLES

35       Example 1 Canonical Flushing Code for STREAMS Drivers.
36
37
38       This  example  depicts the canonical flushing code for STREAMS drivers.
39       Assume that the driver has service procedures so that there may be mes‐
40       sages  on its queues. See srv(9E). Its write-side put procedure handles
41       M_FLUSH messages by first checking the FLUSHW bit  in the first byte of
42       the  message,  then  the write queue is flushed (line 8) and the FLUSHW
43       bit is turned off (line 9). See put(9E). If the FLUSHR bit is on,  then
44       the read queue is flushed (line 12) and the message is sent back up the
45       read side of the stream with the qreply() function (line  13).  If  the
46       FLUSHR bit is off, then the message is freed (line 15). See the example
47       for flushq(9F) for the canonical flushing code for modules.
48
49
50         1  xxxwput(q, mp)
51          2    queue_t *q;
52          3    mblk_t *mp;
53          4  {
54          5       switch(mp->b_datap->db_type) {
55          6       case M_FLUSH:
56          7           if (*mp->b_rptr & FLUSHW) {
57          8                  flushq(q, FLUSHALL);
58          9                  *mp->b_rptr &= ~FLUSHW;
59         10             }
60         11           if (*mp->b_rptr & FLUSHR) {
61         12                  flushq(RD(q), FLUSHALL);
62         13                    qreply(q, mp);
63         14           } else {
64         15                    freemsg(mp);
65         16             }
66         17           break;
67                    . . .
68         18     }
69         19  }
70
71

SEE ALSO

73       put(9E), srv(9E), flushq(9F), OTHERQ(9F), putnext(9F)
74
75
76       Writing Device Drivers
77
78
79       STREAMS Programming Guide
80
81
82
83SunOS 5.11                        16 Jan 2006                       qreply(9F)
Impressum