'\" 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 .nf #include #include \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 illumos DDI specific (illumos DDI). .SH PARAMETERS .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 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 A pointer to the requested message is returned on success. NULL is returned on failure. .SH CONTEXT This function can be called from user, kernel or interrupt context. .SH SEE ALSO .BR dupmsg (9F), .BR merror (9F) .sp .LP \fISTREAMS Programming Guide\fR