2 .\" Copyright 1989 AT&T
3 .\" Copyright (c) 2006, Sun Microsystems, Inc., All Rights Reserved
4 .\" 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.
5 .\" 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.
6 .\" 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]
7 .TH PUTCTL 9F "Jan 16, 2006"
9 putctl \- send a control message to a queue
13 #include <sys/stream.h>
17 \fBint\fR \fBputctl\fR(\fBqueue_t *\fR\fIq\fR, \fBint\fR \fItype\fR);
23 Architecture independent level 1 (DDI/DKI).
31 Queue to which the message is to be sent.
40 Message type (must be control, not data type).
46 The \fBputctl()\fR function tests the \fItype\fR argument to make sure a data
47 type has not been specified, and then attempts to allocate a message block.
48 \fBputctl()\fR fails if \fItype\fR is \fBM_DATA\fR, \fBM_PROTO\fR, or
49 \fBM_PCPROTO\fR, or if a message block cannot be allocated. If successful,
50 \fBputctl()\fR calls the \fBput\fR(9E) routine of the queue pointed to by
51 \fIq\fR with the newly allocated and initialized messages.
55 On success, \fB1\fR is returned. If \fItype\fR is a data type, or if a message
56 block cannot be allocated, \fB0\fR is returned.
60 The \fBputctl()\fR function can be called from user, interrupt, or kernel
64 \fBExample 1 \fRUsing \fBputctl()\fR
67 The \fBsend_ctl()\fR routine is used to pass control messages downstream.
68 \fBM_BREAK\fR messages are handled with \fBputctl()\fR (line 11).
69 \fBputctl1\fR(9F) (line 16) is used for \fBM_DELAY\fR messages, so that
70 \fIparm\fR can be used to specify the length of the delay. In either case, if a
71 message block cannot be allocated a variable recording the number of allocation
72 failures is incremented (lines 12, 17). If an invalid message type is detected,
73 \fBcmn_err\fR(9F) panics the system (line 21).
79 2 send_ctl(wrq, type, parm)
84 7 extern int num_alloc_fail;
88 11 if (!putctl(wrq->q_next, M_BREAK))
93 16 if (!putctl1(wrq->q_next, M_DELAY, parm))
98 21 cmn_err(CE_PANIC, "send_ctl: bad message type passed");
108 \fBput\fR(9E), \fBcmn_err\fR(9F), \fBdatamsg\fR(9F), \fBputctl1\fR(9F),
112 \fIWriting Device Drivers\fR
115 \fISTREAMS Programming Guide\fR