Merge commit '9276b3991ba20d5a5660887ba81b0bc7bed25a0c'
[unleashed.git] / share / man / man9f / mexchange.9f
blob09876ca405ef401a5651a632fe53f60040d3c04b
1 '\" te
2 .\" Copyright (c) 2004, Sun Microsystems, Inc.  All Rights Reserved
3 .\" 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.
4 .\" 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.
5 .\" 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]
6 .TH MEXCHANGE 9F "Jun 9, 2004"
7 .SH NAME
8 mexchange \- Exchange one message for another
9 .SH SYNOPSIS
10 .LP
11 .nf
12 #include <sys/stream.h>
13 #include <sys/strsun.h>
17 \fBmblk_t *\fR\fBmexchange\fR(\fBqueue_t *\fR\fIwq\fR, \fBmblk_t *\fR\fImp\fR, \fBsize_t\fR \fIsize\fR,
18      \fBuchar_t\fR \fItype\fR, \fBint32_t\fR \fIprimtype\fR);
19 .fi
21 .SH INTERFACE LEVEL
22 .sp
23 .LP
24 Solaris DDI specific (Solaris DDI).
25 .SH PARAMETERS
26 .sp
27 .ne 2
28 .na
29 \fB\fIwq\fR\fR
30 .ad
31 .RS 12n
32 Optionally, write queue associated with the read queue to be used on failure
33 (see below).
34 .RE
36 .sp
37 .ne 2
38 .na
39 \fB\fImp\fR\fR
40 .ad
41 .RS 12n
42 Optionally, the message to exchange.
43 .RE
45 .sp
46 .ne 2
47 .na
48 \fB\fIsize\fR\fR
49 .ad
50 .RS 12n
51 Size of the returned message.
52 .RE
54 .sp
55 .ne 2
56 .na
57 \fB\fItype\fR\fR
58 .ad
59 .RS 12n
60 Type of the returned message.
61 .RE
63 .sp
64 .ne 2
65 .na
66 \fB\fIprimtype\fR\fR
67 .ad
68 .RS 12n
69 Optionally, a 4 byte value to store at the beginning of the returned message.
70 .RE
72 .SH DESCRIPTION
73 .sp
74 .LP
75 The \fBmexchange()\fR function exchanges the passed in message for another
76 message of the specified \fIsize\fR and \fItype\fR.
77 .sp
78 .LP
79 If \fImp\fR is not NULL, is of at least \fIsize\fR bytes, and has only one
80 reference (see \fBdupmsg\fR(9F)), \fImp\fR is converted to be of the specified
81 \fIsize\fR and \fItype\fR. Otherwise, a new message of the specified \fIsize\fR
82 and \fItype\fR is allocated. If allocation fails, and \fIwq\fR is not NULL,
83 \fBmerror\fR(9F) attempts to send an error to the stream head.
84 .sp
85 .LP
86 Finally, if \fIprimtype\fR is not -1 and \fIsize\fR is at least 4 bytes, the
87 first 4 bytes are assigned to be \fIprimtype\fR. This is chiefly useful for
88 STREAMS-based protocols such as \fBDLPI\fR and \fBTPI\fR which store the
89 protocol message type in the first 4 bytes of each message.
90 .SH RETURN VALUES
91 .sp
92 .LP
93 A pointer to the requested message is returned on success. NULL is returned on
94 failure.
95 .SH CONTEXT
96 .sp
97 .LP
98 This function can be called from user, kernel or interrupt context.
99 .SH SEE ALSO
102 \fBdupmsg\fR(9F), \fBmerror\fR(9F)
105 \fISTREAMS Programming Guide\fR