Print this page
3910 t_look(3NSL) should never return T_ERROR
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libnsl/nsl/tx.h
+++ new/usr/src/lib/libnsl/nsl/tx.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22
23 23 /*
24 + * Copyright 2014 Gary Mills
24 25 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
25 26 * Use is subject to license terms.
26 27 */
27 28
28 29 #ifndef _TX_H
29 30 #define _TX_H
30 31
31 -#pragma ident "%Z%%M% %I% %E% SMI"
32 -
33 32 #include <sys/uio.h>
34 33
35 34 #ifdef __cplusplus
36 35 extern "C" {
37 36 #endif
38 37
39 38 /*
40 39 * This file contains declarations local to the TLI/XTI implmentation
41 40 */
42 41
43 42 /*
44 43 * Look buffer list
45 44 * Could be multiple buffers for MT case
46 45 */
47 46 struct _ti_lookbufs {
48 47 struct _ti_lookbufs *tl_next; /* next in list */
49 48 int tl_lookclen; /* "look" ctl part length */
50 49 char *tl_lookcbuf; /* pointer to "look" ctl */
51 50 int tl_lookdlen; /* "look" data length */
52 51 char *tl_lookdbuf; /* pointer to "look" data */
53 52 };
54 53
55 54 /* TI interface user level structure - one per open file */
56 55
57 56 struct _ti_user {
58 57 struct _ti_user *ti_next; /* next one */
59 58 struct _ti_user *ti_prev; /* previous one */
60 59 int ti_fd; /* file descriptor */
61 60 struct _ti_lookbufs ti_lookbufs; /* head of list of look buffers */
62 61 int ti_lookcnt; /* buffered look flag */
63 62 ushort_t ti_flags; /* flags */
64 63 int ti_rcvsize; /* connect or disconnect data buf size */
65 64 char *ti_rcvbuf; /* connect or disconnect data buffer */
66 65 int ti_ctlsize; /* ctl buffer size */
67 66 char *ti_ctlbuf; /* ctl buffer */
68 67 int ti_state; /* user level state */
69 68 int ti_ocnt; /* # outstanding connect indications */
70 69 t_scalar_t ti_maxpsz; /* TIDU size */
71 70 t_scalar_t ti_tsdusize; /* TSDU size */
72 71 t_scalar_t ti_etsdusize; /* ETSDU size */
73 72 t_scalar_t ti_cdatasize; /* CDATA_size */
74 73 t_scalar_t ti_ddatasize; /* DDATA_size */
75 74 t_scalar_t ti_servtype; /* service type */
76 75 t_scalar_t ti_prov_flag; /* TPI PROVIDER_flag */
77 76 uint_t ti_qlen; /* listener backlog limit */
78 77 t_uscalar_t acceptor_id; /* Saved acceptor_id value */
79 78 dev_t ti_rdev; /* for fd validation */
80 79 ino_t ti_ino; /* for fd validation */
81 80 mutex_t ti_lock; /* lock to protect this data structure */
82 81 };
83 82
84 83 /*
85 84 * Local flags used with ti_flags field in instance structure of
86 85 * type 'struct _ti_user' declared above. Historical note:
87 86 * This namespace constants were previously declared in a
88 87 * a very messed up namespace in timod.h
89 88 */
90 89 #define USED 0x0001 /* data structure in use */
91 90 #define MORE 0x0008 /* more data */
92 91 #define EXPEDITED 0x0010 /* processing expedited TSDU */
93 92 #define V_ACCEPTOR_ID 0x0020 /* acceptor_id field is has valid value */
94 93 #define TX_TQFULL_NOTIFIED 0x0040 /* TQFULL error has been returned once */
95 94
96 95
97 96 /*
98 97 * Valid flags that can be passed by user in t_sndv() or t_snd()
99 98 */
100 99
101 100 #define TX_ALL_VALID_FLAGS (T_MORE|T_EXPEDITED|T_PUSH)
102 101
103 102 #define _T_MAX(x, y) ((x) > (y) ? (x) : (y))
104 103
105 104 /*
106 105 * Following are used to indicate which API entry point is calling common
107 106 * routines
108 107 */
109 108 #define TX_TLI_API 1 /* The API semantics is TLI */
110 109 #define TX_XTI_XNS4_API 2 /* The API semantics is XTI Unix95 */
111 110 #define TX_XTI_XNS5_API 3 /* The API semantics is XTI Unix98 */
112 111 #define TX_XTI_API TX_XTI_XNS4_API
113 112 /* The base XTI semantics is Unix95 */
114 113
115 114 /* _T_IS_XTI(x) - Is 'x' an XTI inspired api_semantics */
116 115 #define _T_IS_XTI(x) ((x) != TX_TLI_API)
117 116 #define _T_IS_TLI(x) ((x) == TX_TLI_API)
118 117
119 118 /* _T_API_VER_LT(x, y) - Is API version 'x' older than API version 'y' */
120 119 #define _T_API_VER_LT(x, y) ((x) < (y))
121 120
122 121 /*
123 122 * Note: T_BADSTATE also defined in <sys/tiuser.h>
124 123 */
125 124 #define T_BADSTATE 8
126 125
127 126 #ifdef DEBUG
128 127 #include <syslog.h>
129 128 #define _T_TX_SYSLOG2(tiptr, X, Y) if ((tiptr)->ti_state == T_BADSTATE)\
130 129 syslog(X, Y)
131 130 #else
132 131 #define _T_TX_SYSLOG2(tiptr, X, Y)
133 132 #endif /* DEBUG */
134 133
135 134 /*
136 135 * Macro to change state and log invalid state error
137 136 */
138 137
139 138 #define _T_TX_NEXTSTATE(event, tiptr, errstr) \
140 139 { tiptr->ti_state = tiusr_statetbl[event][(tiptr)->ti_state]; \
141 140 _T_TX_SYSLOG2((tiptr), LOG_ERR, errstr); \
142 141 }
143 142
144 143 /*
145 144 * External declarations
146 145 */
147 146 extern mutex_t _ti_userlock;
148 147
149 148 /*
150 149 * Useful shared local constants
151 150 */
152 151
153 152 /*
154 153 * TX_XTI_LEVEL_MAX_OPTBUF:
155 154 * Max option buffer requirement reserved for any XTI level options
156 155 * passed in an option buffer. This is intended as an upper bound.
157 156 * Regardless of what the providers states in OPT_size of T_info_ack,
158 157 * XTI level options can also be added to the option buffer and XTI
159 158 * test suite in particular stuffs XTI level options whether we support
160 159 * them or not.
161 160 *
162 161 * Here is the heuristic used to arrive at a value:
163 162 * 2* [ // factor of 2 for "repeat options" type testing
164 163 * (sizeof(struct t_opthdr)+10*sizeof(t_scalar_t)) // XTI_DEBUG
165 164 * +(sizeof(struct t_opthdr)+ 2*sizeof(t_scalar_t)) // XTI_LINGER
166 165 * +(sizeof(struct t_opthdr)+ sizeof(t_scalar_t)) // XTI_RCVBUF
167 166 * +(sizeof(struct t_opthdr)+ sizeof(t_scalar_t)) // XTI_RCVLOWAT
168 167 * +(sizeof(struct t_opthdr)+ sizeof(t_scalar_t)) // XTI_SNDBUF
169 168 * +(sizeof(struct t_opthdr)+ sizeof(t_scalar_t)) // XTI_SNDLOWAT
170 169 * ]
171 170 * => 2* [ 56+24+20+20+20+20 ]
172 171 * =>
173 172 */
174 173 #define TX_XTI_LEVEL_MAX_OPTBUF 320
175 174
176 175
177 176 /*
178 177 * Historic information note:
179 178 * The libnsl/nsl code implements TLI and XTI interfaces using common
180 179 * code. Most data structures are similar in the exposed interfaces for
181 180 * the two interfaces (<tiuser.h> and <xti.h>).
182 181 * The common implementation C files include only <xti.h> which is the
183 182 * superset in terms of the exposed interfaces. However the file <tiuser.h>
184 183 * exposes (via <sys/tiuser.h>), in the past contained certain declarations
185 184 * that are strictly internal to the implementation but were exposed through
186 185 * their presence in the public header (<tiuser.h>).
187 186 * Since the implmentation still needs these declarations, they follow
188 187 * in this file and are removed from exposure through the TLI public header
189 188 * (<tiuser.h>) which exposed them in the past.
190 189 */
191 190
192 191 /*
193 192 * The following are TLI/XTI user level events which cause
194 193 * state changes.
195 194 * NOTE: Historical namespace pollution warning.
196 195 * Some of the event names share the namespace with structure tags
197 196 * so there are defined inside comments here and exposed through
198 197 * TLI and XTI headers (<tiuser.h> and <xti.h>
199 198 */
200 199
201 200 #define T_OPEN 0
202 201 /* #define T_BIND 1 */
203 202 /* #define T_OPTMGMT 2 */
204 203 #define T_UNBIND 3
205 204 #define T_CLOSE 4
206 205 #define T_SNDUDATA 5
207 206 #define T_RCVUDATA 6
208 207 #define T_RCVUDERR 7
209 208 #define T_CONNECT1 8
210 209 #define T_CONNECT2 9
211 210 #define T_RCVCONNECT 10
212 211 #define T_LISTN 11
213 212 #define T_ACCEPT1 12
214 213 #define T_ACCEPT2 13
215 214 #define T_ACCEPT3 14
216 215 #define T_SND 15
217 216 #define T_RCV 16
218 217 #define T_SNDDIS1 17
219 218 #define T_SNDDIS2 18
220 219 #define T_RCVDIS1 19
221 220 #define T_RCVDIS2 20
222 221 #define T_RCVDIS3 21
223 222 #define T_SNDREL 22
224 223 #define T_RCVREL 23
225 224 #define T_PASSCON 24
226 225
227 226 #define T_NOEVENTS 25
228 227
229 228 #define T_NOSTATES 9 /* number of legal states */
230 229
231 230 extern char tiusr_statetbl[T_NOEVENTS][T_NOSTATES];
232 231
233 232 /*
234 233 * Band definitions for data flow.
235 234 */
236 235 #define TI_NORMAL 0
237 236 #define TI_EXPEDITED 1
238 237
239 238 /*
240 239 * Bogus states from tiuser.h
241 240 */
242 241 #define T_FAKE 8 /* fake state used when state */
243 242 /* cannot be determined */
↓ open down ↓ |
201 lines elided |
↑ open up ↑ |
244 243
245 244 /*
246 245 * Flags for t_getname() from tiuser.h
247 246 * Note: This routine's counterpart in XTI is substatnially modified
248 247 * (i.e. t_getprotaddr() and does not use these flags)
249 248 */
250 249 #define LOCALNAME 0
251 250 #define REMOTENAME 1
252 251
253 252 /*
254 - * Obsolete error event for t_look() in TLI, still needed for compatibility
255 - * to broken apps that are affected (e.g nfsd,lockd) if real error returned.
256 - */
257 -#define T_ERROR 0x0020
258 -
259 -/*
260 253 * GENERAL UTILITY MACROS
261 254 */
262 255 #define A_CNT(arr) (sizeof (arr)/sizeof (arr[0]))
263 256 #define A_END(arr) (&arr[A_CNT(arr)])
264 257 #define A_LAST(arr) (&arr[A_CNT(arr)-1])
265 258
266 259 /*
267 260 * Following macro compares a signed size obtained from TPI primitive
268 261 * to unsigned size of buffer where it needs to go into passed using
269 262 * the "struct netbuf" type.
270 263 * Since many programs are buggy and forget to initialize "netbuf" or
271 264 * (while unlikely!) allocated buffer can legally even be larger than
272 265 * max signed integer, we use the following macro to do unsigned comparison
273 266 * after verifying that signed quantity is positive.
274 267 */
275 268 #define TLEN_GT_NLEN(tpilen, netbuflen) \
276 269 (((tpilen) > 0) && ((unsigned int)(tpilen) > (netbuflen)))
277 270
278 271
279 272 /*
280 273 * N.B.: this interface is deprecated. Use t_strerror() instead.
281 274 */
282 275 extern char *t_errlist[];
283 276 extern int t_nerr;
284 277
285 278 /*
286 279 * UTILITY ROUTINES FUNCTION PROTOTYPES
287 280 */
288 281
289 282 extern void _t_adjust_iov(int, struct iovec *, int *);
290 283 extern struct _ti_user *_t_checkfd(int, int, int);
291 284 extern int _t_delete_tilink(int);
292 285 extern int _t_rcv_conn_con(struct _ti_user *, struct t_call *, struct strbuf *,
293 286 int);
294 287 extern int _t_snd_conn_req(struct _ti_user *, const struct t_call *,
295 288 struct strbuf *);
296 289 extern int _t_aligned_copy(struct strbuf *, int, int, char *, t_scalar_t *);
297 290 extern struct _ti_user *_t_create(int, struct t_info *, int, int *);
298 291 extern int _t_do_ioctl(int, char *, int, int, int *);
299 292 extern int _t_is_event(int, struct _ti_user *);
300 293 extern int _t_is_ok(int, struct _ti_user *, t_scalar_t);
301 294 extern int _t_look_locked(int, struct _ti_user *, int, int);
302 295 extern int _t_register_lookevent(struct _ti_user *, caddr_t, int, caddr_t, int);
303 296 extern void _t_free_looklist_head(struct _ti_user *);
304 297 extern void _t_flush_lookevents(struct _ti_user *);
305 298 extern int _t_acquire_ctlbuf(struct _ti_user *, struct strbuf *, int *);
306 299 extern int _t_acquire_databuf(struct _ti_user *, struct strbuf *, int *);
307 300
308 301 /*
309 302 * Core function TLI/XTI routines function prototypes
310 303 */
311 304 extern int _tx_accept(int, int, const struct t_call *, int);
312 305 extern char *_tx_alloc(int, int, int, int);
313 306 extern int _tx_bind(int, const struct t_bind *, struct t_bind *, int);
314 307 extern int _tx_close(int, int);
315 308 extern int _tx_connect(int, const struct t_call *, struct t_call *, int);
316 309 extern int _tx_error(const char *, int);
317 310 extern int _tx_free(char *, int, int);
318 311 extern int _tx_getinfo(int, struct t_info *, int);
319 312 extern int _tx_getname(int, struct netbuf *, int, int);
320 313 extern int _tx_getstate(int, int);
321 314 extern int _tx_getprotaddr(int, struct t_bind *, struct t_bind *, int);
322 315 extern int _tx_listen(int, struct t_call *, int);
323 316 extern int _tx_look(int, int);
324 317 extern int _tx_open(const char *, int, struct t_info *, int);
325 318 extern int _tx_optmgmt(int, const struct t_optmgmt *, struct t_optmgmt *, int);
326 319 extern int _tx_rcv(int, char *, unsigned, int *, int);
327 320 extern int _tx_rcvconnect(int, struct t_call *, int);
328 321 extern int _tx_rcvdis(int, struct t_discon *, int);
329 322 extern int _tx_rcvrel(int, int);
330 323 extern int _tx_rcvudata(int, struct t_unitdata *, int *, int);
331 324 extern int _tx_rcvuderr(int, struct t_uderr *, int);
332 325 extern int _tx_snd(int, char *, unsigned, int, int);
333 326 extern int _tx_snddis(int, const struct t_call *, int);
334 327 extern int _tx_sndrel(int, int);
335 328 extern int _tx_sndudata(int, const struct t_unitdata *, int);
336 329 extern char *_tx_strerror(int, int);
337 330 extern int _tx_sync(int, int);
338 331 extern int _tx_unbind(int, int);
339 332 extern int _tx_unbind_locked(int, struct _ti_user *, struct strbuf *);
340 333 extern int _t_expinline_queued(int, int *);
341 334 extern int _t_do_postconn_sync(int, struct _ti_user *);
342 335
343 336 /*
344 337 * The following helper functions are used by scatter/gather functions,
345 338 * which are defined only for XTI and not available in TLI. Moreover
346 339 * the definition of struct t_iovec which is used below is not visible to
347 340 * TLI. Hence tli_wrappers.c should not see the prototypes below.
348 341 */
349 342 #ifndef TLI_WRAPPERS
350 343 unsigned int _t_bytecount_upto_intmax(const struct t_iovec *, unsigned int);
351 344 void _t_scatter(struct strbuf *, struct t_iovec *, int);
352 345 void _t_gather(char *, const struct t_iovec *, unsigned int);
353 346 void _t_copy_tiov_to_iov(const struct t_iovec *, int, struct iovec *, int *);
354 347
355 348 /*
356 349 * The following scatter/gather and other misc. functions are defined only
357 350 * for XTI and not available in TLI. Moreover the definition of struct t_iovec
358 351 * which is used below is not visible to TLI. Hence tli_wrappers.c should not
359 352 * see the prototypes below.
360 353 */
361 354 extern int _tx_rcvv(int, struct t_iovec *, unsigned int, int *, int);
362 355 extern int _tx_rcvreldata(int, struct t_discon *, int);
363 356 extern int _tx_rcvvudata(int, struct t_unitdata *, struct t_iovec *,
364 357 unsigned int, int *, int);
365 358 extern int _tx_sndv(int, const struct t_iovec *, unsigned int, int, int);
366 359 extern int _tx_sndreldata(int, struct t_discon *, int);
367 360 extern int _tx_sndvudata(int, const struct t_unitdata *, struct t_iovec *,
368 361 unsigned int, int);
369 362 extern int _tx_sysconf(int, int);
370 363 #endif /* TLI_WRAPPERS */
371 364
372 365 #ifdef __cplusplus
373 366 }
374 367 #endif
375 368
376 369 #endif /* _TX_H */
↓ open down ↓ |
107 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX