4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
24 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
28 #pragma ident "%Z%%M% %I% %E% SMI"
31 * t_sndrel.c and t_sndreldata.c are very similar and contain common code.
32 * Any changes to either of them should be reviewed to see whether they
33 * are applicable to the other file.
38 #include <sys/stream.h>
39 #define _SUN_TPI_VERSION 2
40 #include <sys/tihdr.h>
41 #include <sys/timod.h>
47 _tx_sndreldata(int fd
, struct t_discon
*discon
, int api_semantics
)
49 struct T_ordrel_req orreq
;
51 struct _ti_user
*tiptr
;
53 assert(api_semantics
== TX_XTI_XNS5_API
);
54 if ((tiptr
= _t_checkfd(fd
, 0, api_semantics
)) == NULL
)
56 sig_mutex_lock(&tiptr
->ti_lock
);
58 if (tiptr
->ti_servtype
!= T_COTS_ORD
) {
59 t_errno
= TNOTSUPPORT
;
60 sig_mutex_unlock(&tiptr
->ti_lock
);
64 if (!(tiptr
->ti_state
== T_DATAXFER
||
65 tiptr
->ti_state
== T_INREL
)) {
67 sig_mutex_unlock(&tiptr
->ti_lock
);
71 if (_t_look_locked(fd
, tiptr
, 0,
72 api_semantics
) == T_DISCONNECT
) {
74 sig_mutex_unlock(&tiptr
->ti_lock
);
79 * Someday there could be transport providers that support T_ORDRELDATA
80 * Until that happens, this function returns TBADDATA if user data
81 * was specified. If no user data is specified, this function
82 * behaves as t_sndrel()
83 * Note: Currently only mOSI ("minimal OSI") provider is specified
84 * to use T_ORDRELDATA so probability of needing it is minimal.
87 if (discon
&& discon
->udata
.len
) {
89 sig_mutex_unlock(&tiptr
->ti_lock
);
93 orreq
.PRIM_type
= T_ORDREL_REQ
;
94 ctlbuf
.maxlen
= (int)sizeof (struct T_ordrel_req
);
95 ctlbuf
.len
= (int)sizeof (struct T_ordrel_req
);
96 ctlbuf
.buf
= (caddr_t
)&orreq
;
99 * Calls to send data (write or putmsg) can potentially
100 * block, for MT case, we drop the lock and enable signals here
101 * and acquire it back
103 sig_mutex_unlock(&tiptr
->ti_lock
);
104 if (putmsg(fd
, &ctlbuf
, NULL
, 0) < 0) {
111 sig_mutex_lock(&tiptr
->ti_lock
);
112 _T_TX_NEXTSTATE(T_SNDREL
, tiptr
,
113 "t_sndreldata: invalid state on event T_SNDREL");
114 sig_mutex_unlock(&tiptr
->ti_lock
);