t_sndudata.c (7c478bd9) t_sndudata.c (61961e0f)
1/*
2 * CDDL HEADER START
3 *
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
7 * with the License.
8 *

--- 5 unchanged lines hidden (view full) ---

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]
19 *
20 * CDDL HEADER END
21 */
1/*
2 * CDDL HEADER START
3 *
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
7 * with the License.
8 *

--- 5 unchanged lines hidden (view full) ---

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]
19 *
20 * CDDL HEADER END
21 */
22
22/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23/* All Rights Reserved */
24
23/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
24/* All Rights Reserved */
25
25
26/*
26/*
27 * Copyright 1993-2003 Sun Microsystems, Inc. All rights reserved.
27 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
29 */
30
28 * Use is subject to license terms.
29 */
30
31
32#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */
33
34/*
35 * t_sndudata.c and t_sndvudata.c are very similar and contain common code.
36 * Any changes to either of them should be reviewed to see whether they
37 * are applicable to the other file.
38 */
39#include "mt.h"
31#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */
32
33/*
34 * t_sndudata.c and t_sndvudata.c are very similar and contain common code.
35 * Any changes to either of them should be reviewed to see whether they
36 * are applicable to the other file.
37 */
38#include "mt.h"
40#include <rpc/trace.h>
41#include <stdlib.h>
42#include <errno.h>
43#include <stropts.h>
44#include <sys/stream.h>
45#define _SUN_TPI_VERSION 2
46#include <sys/tihdr.h>
47#include <sys/timod.h>
48#include <xti.h>

--- 5 unchanged lines hidden (view full) ---

54{
55 struct T_unitdata_req *udreq;
56 struct strbuf ctlbuf;
57 int size;
58 struct _ti_user *tiptr;
59 int sv_errno;
60 int didalloc;
61
39#include <stdlib.h>
40#include <errno.h>
41#include <stropts.h>
42#include <sys/stream.h>
43#define _SUN_TPI_VERSION 2
44#include <sys/tihdr.h>
45#include <sys/timod.h>
46#include <xti.h>

--- 5 unchanged lines hidden (view full) ---

52{
53 struct T_unitdata_req *udreq;
54 struct strbuf ctlbuf;
55 int size;
56 struct _ti_user *tiptr;
57 int sv_errno;
58 int didalloc;
59
62 trace2(TR_t_sndudata, 0, fd);
63 if ((tiptr = _t_checkfd(fd, 0, api_semantics)) == NULL) {
64 sv_errno = errno;
65 trace2(TR_t_sndudata, 1, fd);
66 errno = sv_errno;
60 if ((tiptr = _t_checkfd(fd, 0, api_semantics)) == NULL)
67 return (-1);
61 return (-1);
68 }
69 sig_mutex_lock(&tiptr->ti_lock);
70
71 if (tiptr->ti_servtype != T_CLTS) {
72 t_errno = TNOTSUPPORT;
73 sig_mutex_unlock(&tiptr->ti_lock);
62 sig_mutex_lock(&tiptr->ti_lock);
63
64 if (tiptr->ti_servtype != T_CLTS) {
65 t_errno = TNOTSUPPORT;
66 sig_mutex_unlock(&tiptr->ti_lock);
74 trace2(TR_t_sndudata, 1, fd);
75 return (-1);
76 }
77
78 if (_T_IS_XTI(api_semantics)) {
79 /*
80 * User level state verification only done for XTI
81 * because doing for TLI may break existing applications
82 */
83 if (tiptr->ti_state != T_IDLE) {
84 t_errno = TOUTSTATE;
85 sig_mutex_unlock(&tiptr->ti_lock);
67 return (-1);
68 }
69
70 if (_T_IS_XTI(api_semantics)) {
71 /*
72 * User level state verification only done for XTI
73 * because doing for TLI may break existing applications
74 */
75 if (tiptr->ti_state != T_IDLE) {
76 t_errno = TOUTSTATE;
77 sig_mutex_unlock(&tiptr->ti_lock);
86 trace2(TR_t_sndudata, 1, fd);
87 return (-1);
88 }
89 }
90
91 if (((int)unitdata->udata.len == 0) &&
92 !(tiptr->ti_prov_flag & (SENDZERO|OLD_SENDZERO))) {
93 t_errno = TBADDATA;
94 sig_mutex_unlock(&tiptr->ti_lock);
78 return (-1);
79 }
80 }
81
82 if (((int)unitdata->udata.len == 0) &&
83 !(tiptr->ti_prov_flag & (SENDZERO|OLD_SENDZERO))) {
84 t_errno = TBADDATA;
85 sig_mutex_unlock(&tiptr->ti_lock);
95 trace2(TR_t_sndudata, 1, fd);
96 return (-1);
97 }
98
99 if ((tiptr->ti_maxpsz > 0) &&
100 (unitdata->udata.len > (uint32_t)tiptr->ti_maxpsz)) {
101 if (_T_IS_TLI(api_semantics)) {
102 t_errno = TSYSERR;
103 errno = EPROTO;
104 } else
105 t_errno = TBADDATA;
106 sv_errno = errno;
107 sig_mutex_unlock(&tiptr->ti_lock);
86 return (-1);
87 }
88
89 if ((tiptr->ti_maxpsz > 0) &&
90 (unitdata->udata.len > (uint32_t)tiptr->ti_maxpsz)) {
91 if (_T_IS_TLI(api_semantics)) {
92 t_errno = TSYSERR;
93 errno = EPROTO;
94 } else
95 t_errno = TBADDATA;
96 sv_errno = errno;
97 sig_mutex_unlock(&tiptr->ti_lock);
108 trace2(TR_t_sndudata, 1, fd);
109 errno = sv_errno;
110 return (-1);
111 }
112
113 /*
114 * Acquire ctlbuf for use in sending/receiving control part
115 * of the message.
116 */
117 if (_t_acquire_ctlbuf(tiptr, &ctlbuf, &didalloc) < 0) {
118 sv_errno = errno;
119 sig_mutex_unlock(&tiptr->ti_lock);
98 errno = sv_errno;
99 return (-1);
100 }
101
102 /*
103 * Acquire ctlbuf for use in sending/receiving control part
104 * of the message.
105 */
106 if (_t_acquire_ctlbuf(tiptr, &ctlbuf, &didalloc) < 0) {
107 sv_errno = errno;
108 sig_mutex_unlock(&tiptr->ti_lock);
120 trace2(TR_t_sndudata, 1, fd);
121 errno = sv_errno;
122 return (-1);
123 }
124
109 errno = sv_errno;
110 return (-1);
111 }
112
113 /* LINTED pointer cast */
125 udreq = (struct T_unitdata_req *)ctlbuf.buf;
126
127 udreq->PRIM_type = T_UNITDATA_REQ;
128 udreq->DEST_length = unitdata->addr.len;
129 udreq->DEST_offset = 0;
130 udreq->OPT_length = unitdata->opt.len;
131 udreq->OPT_offset = 0;
132 size = (int)sizeof (struct T_unitdata_req);

--- 58 unchanged lines hidden (view full) ---

191
192 _T_TX_NEXTSTATE(T_SNDUDATA, tiptr,
193 "t_sndudata: invalid state event T_SNDUDATA");
194 if (didalloc)
195 free(ctlbuf.buf);
196 else
197 tiptr->ti_ctlbuf = ctlbuf.buf;
198 sig_mutex_unlock(&tiptr->ti_lock);
114 udreq = (struct T_unitdata_req *)ctlbuf.buf;
115
116 udreq->PRIM_type = T_UNITDATA_REQ;
117 udreq->DEST_length = unitdata->addr.len;
118 udreq->DEST_offset = 0;
119 udreq->OPT_length = unitdata->opt.len;
120 udreq->OPT_offset = 0;
121 size = (int)sizeof (struct T_unitdata_req);

--- 58 unchanged lines hidden (view full) ---

180
181 _T_TX_NEXTSTATE(T_SNDUDATA, tiptr,
182 "t_sndudata: invalid state event T_SNDUDATA");
183 if (didalloc)
184 free(ctlbuf.buf);
185 else
186 tiptr->ti_ctlbuf = ctlbuf.buf;
187 sig_mutex_unlock(&tiptr->ti_lock);
199 trace2(TR_t_sndudata, 1, fd);
200 return (0);
201err_out:
202 sv_errno = errno;
203 if (didalloc)
204 free(ctlbuf.buf);
205 else
206 tiptr->ti_ctlbuf = ctlbuf.buf;
207 sig_mutex_unlock(&tiptr->ti_lock);
188 return (0);
189err_out:
190 sv_errno = errno;
191 if (didalloc)
192 free(ctlbuf.buf);
193 else
194 tiptr->ti_ctlbuf = ctlbuf.buf;
195 sig_mutex_unlock(&tiptr->ti_lock);
208 trace2(TR_t_sndudata, 1, fd);
209 errno = sv_errno;
210 return (-1);
211}
196 errno = sv_errno;
197 return (-1);
198}