summaryrefslogtreecommitdiff
path: root/usr/src/man/man9f/mexchange.9f
blob: 09876ca405ef401a5651a632fe53f60040d3c04b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
'\" te
.\" Copyright (c) 2004, 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]
.TH MEXCHANGE 9F "Jun 9, 2004"
.SH NAME
mexchange \- Exchange one message for another
.SH SYNOPSIS
.LP
.nf
#include <sys/stream.h>
#include <sys/strsun.h>



\fBmblk_t *\fR\fBmexchange\fR(\fBqueue_t *\fR\fIwq\fR, \fBmblk_t *\fR\fImp\fR, \fBsize_t\fR \fIsize\fR,
     \fBuchar_t\fR \fItype\fR, \fBint32_t\fR \fIprimtype\fR);
.fi

.SH INTERFACE LEVEL
.sp
.LP
Solaris DDI specific (Solaris DDI).
.SH PARAMETERS
.sp
.ne 2
.na
\fB\fIwq\fR\fR
.ad
.RS 12n
Optionally, write queue associated with the read queue to be used on failure
(see below).
.RE

.sp
.ne 2
.na
\fB\fImp\fR\fR
.ad
.RS 12n
Optionally, the message to exchange.
.RE

.sp
.ne 2
.na
\fB\fIsize\fR\fR
.ad
.RS 12n
Size of the returned message.
.RE

.sp
.ne 2
.na
\fB\fItype\fR\fR
.ad
.RS 12n
Type of the returned message.
.RE

.sp
.ne 2
.na
\fB\fIprimtype\fR\fR
.ad
.RS 12n
Optionally, a 4 byte value to store at the beginning of the returned message.
.RE

.SH DESCRIPTION
.sp
.LP
The \fBmexchange()\fR function exchanges the passed in message for another
message of the specified \fIsize\fR and \fItype\fR.
.sp
.LP
If \fImp\fR is not NULL, is of at least \fIsize\fR bytes, and has only one
reference (see \fBdupmsg\fR(9F)), \fImp\fR is converted to be of the specified
\fIsize\fR and \fItype\fR. Otherwise, a new message of the specified \fIsize\fR
and \fItype\fR is allocated. If allocation fails, and \fIwq\fR is not NULL,
\fBmerror\fR(9F) attempts to send an error to the stream head.
.sp
.LP
Finally, if \fIprimtype\fR is not -1 and \fIsize\fR is at least 4 bytes, the
first 4 bytes are assigned to be \fIprimtype\fR. This is chiefly useful for
STREAMS-based protocols such as \fBDLPI\fR and \fBTPI\fR which store the
protocol message type in the first 4 bytes of each message.
.SH RETURN VALUES
.sp
.LP
A pointer to the requested message is returned on success. NULL is returned on
failure.
.SH CONTEXT
.sp
.LP
This function can be called from user, kernel or interrupt context.
.SH SEE ALSO
.sp
.LP
\fBdupmsg\fR(9F), \fBmerror\fR(9F)
.sp
.LP
\fISTREAMS Programming Guide\fR