Print this page
12694 race between write() and shutdown() for unix sockets
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/tihdr.h
+++ new/usr/src/uts/common/sys/tihdr.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 (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
22 22 /* All Rights Reserved */
23 23
24 24
25 25 /*
26 26 * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
27 + * Copyright 2020 Joyent, Inc.
27 28 */
28 29
29 30 #ifndef _SYS_TIHDR_H
30 31 #define _SYS_TIHDR_H
31 32
32 33 #include <sys/types.h>
33 34 /*
34 35 * Include declarations implicit to TPI and shared with user level code
35 36 */
36 37 #include <sys/tpicommon.h>
37 38
38 39 #ifdef __cplusplus
39 40 extern "C" {
40 41 #endif
41 42
42 43 /*
43 44 * The feature test macro, _SUN_TPI_VERSION makes some of additional
44 45 * declarations available and changes some existing ones. There was
45 46 * some changes done to this interface and this feature test macro
46 47 * enables transitioning to those changes while maintaining retaining
47 48 * backward compatibility.
48 49 *
49 50 * The following is all the information
50 51 * needed by the Transport Service Interface.
51 52 */
52 53
53 54 /*
54 55 * The following are the definitions of the Transport
55 56 * Service Interface primitives.
56 57 */
57 58
58 59 /*
59 60 * Primitives that are initiated by the transport user.
60 61 */
61 62 #define T_CONN_REQ 0 /* connection request */
62 63 #if _SUN_TPI_VERSION > 1
63 64 #define O_T_CONN_RES 1 /* old connection response */
64 65 #else
65 66 #define T_CONN_RES 1 /* connection response */
66 67 #endif /* _SUN_TPI_VERSION > 1 */
67 68 #define T_DISCON_REQ 2 /* disconnect request */
68 69 #define T_DATA_REQ 3 /* data request */
69 70 #define T_EXDATA_REQ 4 /* expedited data request */
70 71 #define T_INFO_REQ 5 /* information request */
71 72 /*
72 73 * Bind Request primitive (TLI inspired
73 74 * address binding semantics). If requested address is
74 75 * found to be busy, an alternative free address is
75 76 * returned. (Requires comparison of requested address to
76 77 * returned address to verify if the requested address was
77 78 * bound)
78 79 *
79 80 */
80 81 #if _SUN_TPI_VERSION > 0
81 82 #define O_T_BIND_REQ 6
82 83 #else
83 84 #define T_BIND_REQ 6
84 85 #endif /* _SUN_TPI_VERSION > 0 */
85 86
86 87 #define T_UNBIND_REQ 7 /* unbind request */
87 88 #define T_UNITDATA_REQ 8 /* unitdata request */
88 89
89 90 /*
90 91 * Option management request (with TLI inspired semantics )
91 92 * The preferred name for this primitive in new code is T_SVR4_OPTMGMT_REQ.
92 93 * This primitive had the name T_OPTMGMT_REQ in old SVR4 derived TPI.
93 94 * This primitive is used for TLI and Socket API support.
94 95 * The packing of options in option buffer is private contract
95 96 * between transport provider and its users and can differ
96 97 * between different transports.
97 98 * (The name O_T_OPTMGMT_REQ continues to exist for Solaris 2.6
98 99 * compilation environment compatibility only)
99 100 *
100 101 */
101 102 #define T_SVR4_OPTMGMT_REQ 9
102 103 #if _SUN_TPI_VERSION > 0
103 104 #define O_T_OPTMGMT_REQ T_SVR4_OPTMGMT_REQ
104 105 #else
105 106 #define T_OPTMGMT_REQ T_SVR4_OPTMGMT_REQ
106 107 #endif /* _SUN_TPI_VERSION > 0 */
107 108
108 109 #define T_ORDREL_REQ 10 /* orderly release req */
109 110
110 111 /*
111 112 * Primitives that are initiated by the transport provider.
112 113 */
113 114 #define T_CONN_IND 11 /* connection indication */
114 115 #define T_CONN_CON 12 /* connection confirmation */
115 116 #define T_DISCON_IND 13 /* disconnect indication */
116 117 #define T_DATA_IND 14 /* data indication */
117 118 #define T_EXDATA_IND 15 /* expeditied data indication */
118 119 #define T_INFO_ACK 16 /* information acknowledgment */
119 120 #define T_BIND_ACK 17 /* bind acknowledment */
120 121 #define T_ERROR_ACK 18 /* error acknowledgment */
121 122 #define T_OK_ACK 19 /* ok acknowledgment */
122 123 #define T_UNITDATA_IND 20 /* unitdata indication */
123 124 #define T_UDERROR_IND 21 /* unitdata error indication */
124 125 #define T_OPTMGMT_ACK 22 /* manage options ack */
125 126 #define T_ORDREL_IND 23 /* orderly release ind */
126 127 /*
127 128 * Primitives added to namespace and contain a mix of ones
128 129 * initiated by transport user or provider.
129 130 */
130 131 #define T_ADDR_REQ 24 /* address request */
131 132 #define T_ADDR_ACK 25 /* address acknowledgement */
132 133
133 134 #if _SUN_TPI_VERSION > 0
134 135 /*
135 136 * Bind request primitive with better address
136 137 * binding semantics. (XTI inspired)
137 138 * If the requested address is found to be busy,
138 139 * an error is returned. (No need to compare addresses on successful
139 140 * bind acknowledgement).
140 141 */
141 142 #define T_BIND_REQ 26 /* bind request */
142 143
143 144 /*
144 145 * Option management request (with XTI inspired semantics)
145 146 * The packing of options in option buffer is required to
146 147 * be with 'struct T_opthdr' data structure defined later in
147 148 * this header.
148 149 */
149 150 #define T_OPTMGMT_REQ 27 /* manage options req - T_opthdr option header */
150 151 #endif /* _SUN_TPI_VERSION > 0 */
151 152
152 153 #if _SUN_TPI_VERSION > 1
153 154 /*
154 155 * The connection response that expects its ACCEPTOR_id to have been
155 156 * filled in from the value supplied via a T_CAPABILITY_ACK.
156 157 */
157 158 #define T_CONN_RES 28 /* connection response */
158 159
159 160 /*
160 161 * Capability request and ack. These primitives are optional and
161 162 * subsume the functionality of T_INFO_{REQ,ACK}.
162 163 */
163 164 #define T_CAPABILITY_REQ 30
164 165 #define T_CAPABILITY_ACK 31
165 166 #endif /* _SUN_TPI_VERSION > 1 */
166 167
167 168 #ifdef _KERNEL
168 169 /*
169 170 * Sun private TPI extensions. They are currently used for transparently
170 171 * passing options through the connection-oriented loopback transport.
171 172 * Values assigned to them may change.
172 173 *
↓ open down ↓ |
136 lines elided |
↑ open up ↑ |
173 174 * T_EXTCONN_IND (extended T_CONN_IND) is used to return dst as well as
174 175 * src addr/port.
175 176 */
176 177 #define T_OPTDATA_REQ 0x1001 /* data (with options) request */
177 178 #define T_OPTDATA_IND 0x1002 /* data (with options) indication */
178 179 #define T_EXTCONN_IND 0x1003 /* extended T_CONN_IND to return dst as well */
179 180
180 181 #endif /* _KERNEL */
181 182
182 183 /*
183 - * The following are the events that drive the state machine
184 - */
185 -/* Initialization events */
186 -#define TE_BIND_REQ 0 /* bind request */
187 -#define TE_UNBIND_REQ 1 /* unbind request */
188 -#define TE_OPTMGMT_REQ 2 /* manage options req */
189 -#define TE_BIND_ACK 3 /* bind acknowledment */
190 -#define TE_OPTMGMT_ACK 4 /* manage options ack */
191 -#define TE_ERROR_ACK 5 /* error acknowledgment */
192 -#define TE_OK_ACK1 6 /* ok ack seqcnt == 0 */
193 -#define TE_OK_ACK2 7 /* ok ack seqcnt == 1, q == resq */
194 -#define TE_OK_ACK3 8 /* ok ack seqcnt == 1, q != resq */
195 -#define TE_OK_ACK4 9 /* ok ack seqcnt > 1 */
196 -
197 -/* Connection oriented events */
198 -#define TE_CONN_REQ 10 /* connection request */
199 -#define TE_CONN_RES 11 /* connection response */
200 -#define TE_DISCON_REQ 12 /* disconnect request */
201 -#define TE_DATA_REQ 13 /* data request */
202 -#define TE_EXDATA_REQ 14 /* expedited data request */
203 -#define TE_ORDREL_REQ 15 /* orderly release req */
204 -#define TE_CONN_IND 16 /* connection indication */
205 -#define TE_CONN_CON 17 /* connection confirmation */
206 -#define TE_DATA_IND 18 /* data indication */
207 -#define TE_EXDATA_IND 19 /* expedited data indication */
208 -#define TE_ORDREL_IND 20 /* orderly release ind */
209 -#define TE_DISCON_IND1 21 /* disconnect indication seq == 0 */
210 -#define TE_DISCON_IND2 22 /* disconnect indication seq == 1 */
211 -#define TE_DISCON_IND3 23 /* disconnect indication seq > 1 */
212 -#define TE_PASS_CONN 24 /* pass connection */
213 -
214 -/* Unit data events */
215 -#define TE_UNITDATA_REQ 25 /* unitdata request */
216 -#define TE_UNITDATA_IND 26 /* unitdata indication */
217 -#define TE_UDERROR_IND 27 /* unitdata error indication */
218 -
219 -#define TE_NOEVENTS 28
220 -/*
221 184 * The following are the possible states of the Transport
222 185 * Service Interface
223 186 */
224 187
225 188 #define TS_UNBND 0 /* unbound */
226 189 #define TS_WACK_BREQ 1 /* waiting ack of BIND_REQ */
227 190 #define TS_WACK_UREQ 2 /* waiting ack of UNBIND_REQ */
228 191 #define TS_IDLE 3 /* idle */
229 192 #define TS_WACK_OPTREQ 4 /* wait ack options request */
230 193 #define TS_WACK_CREQ 5 /* waiting ack of CONN_REQ */
231 194 #define TS_WCON_CREQ 6 /* waiting confirm of CONN_REQ */
232 195 #define TS_WRES_CIND 7 /* waiting response of CONN_IND */
233 196 #define TS_WACK_CRES 8 /* waiting ack of CONN_RES */
234 197 #define TS_DATA_XFER 9 /* data transfer */
235 198 #define TS_WIND_ORDREL 10 /* releasing rd but not wr */
236 199 #define TS_WREQ_ORDREL 11 /* wait to release wr but not rd */
237 200 #define TS_WACK_DREQ6 12 /* waiting ack of DISCON_REQ */
238 201 #define TS_WACK_DREQ7 13 /* waiting ack of DISCON_REQ */
239 202 #define TS_WACK_DREQ9 14 /* waiting ack of DISCON_REQ */
240 203 #define TS_WACK_DREQ10 15 /* waiting ack of DISCON_REQ */
241 204 #define TS_WACK_DREQ11 16 /* waiting ack of DISCON_REQ */
242 205
243 206 #define TS_NOSTATES 17
244 207
245 208
246 209 /*
247 210 * The following structure definitions define the format of the
248 211 * stream message block of the above primitives.
249 212 * (everything is declared t_scalar_t to ensure proper alignment
250 213 * across different machines)
251 214 */
252 215
253 216 /* connection request */
254 217
255 218 struct T_conn_req {
256 219 t_scalar_t PRIM_type; /* always T_CONN_REQ */
257 220 t_scalar_t DEST_length; /* dest addr length */
258 221 t_scalar_t DEST_offset; /* dest addr offset */
259 222 t_scalar_t OPT_length; /* options length */
260 223 t_scalar_t OPT_offset; /* options offset */
261 224 };
262 225
263 226 /* connect response */
264 227
265 228 /*
266 229 * Historical compatibility note for "struct T_conn_res" usage.
267 230 * "QUEUE_ptr" field of type "queue_t" is obsolete to support
268 231 * code portability and application binary compatibility
269 232 * between ILP32(32-bit) and LP64 (64-bit) environments.
270 233 * Use field "ACCEPTOR_id" instead.
271 234 * For compatibility, drivers using (_SUN_TPI_VERSION >= 2) interface
272 235 * can support treating ACCEPTOR_id content as queue pointer
273 236 * only when PRIM_type is O_T_CONN_RES.
274 237 */
275 238 struct T_conn_res {
276 239 t_scalar_t PRIM_type; /* T_CONN_RES (or O_T_CONN_RES) */
277 240 t_uscalar_t ACCEPTOR_id; /* id of accepting endpoint */
278 241 t_scalar_t OPT_length; /* options length */
279 242 t_scalar_t OPT_offset; /* options offset */
280 243 t_scalar_t SEQ_number; /* sequence number */
281 244 };
282 245
283 246 /* disconnect request */
284 247
285 248 struct T_discon_req {
286 249 t_scalar_t PRIM_type; /* always T_DISCON_REQ */
287 250 t_scalar_t SEQ_number; /* sequnce number */
288 251 };
289 252
290 253 /* data request */
291 254
292 255 struct T_data_req {
293 256 t_scalar_t PRIM_type; /* always T_DATA_REQ */
294 257 t_scalar_t MORE_flag; /* more data */
295 258 };
296 259
297 260 /* expedited data request */
298 261
299 262 struct T_exdata_req {
300 263 t_scalar_t PRIM_type; /* always T_EXDATA_REQ */
301 264 t_scalar_t MORE_flag; /* more data */
302 265 };
303 266
304 267 /* information request */
305 268
306 269 struct T_info_req {
307 270 t_scalar_t PRIM_type; /* always T_INFO_REQ */
308 271 };
309 272
310 273 /* bind request */
311 274
312 275 struct T_bind_req {
313 276 t_scalar_t PRIM_type; /* T_BIND_REQ (or O_T_BIND_REQ) */
314 277 t_scalar_t ADDR_length; /* addr length */
315 278 t_scalar_t ADDR_offset; /* addr offset */
316 279 t_uscalar_t CONIND_number; /* connect indications requested */
317 280 };
318 281
319 282 /* unbind request */
320 283
321 284 struct T_unbind_req {
322 285 t_scalar_t PRIM_type; /* always T_UNBIND_REQ */
323 286 };
324 287
325 288 /* unitdata request */
326 289
327 290 struct T_unitdata_req {
328 291 t_scalar_t PRIM_type; /* always T_UNITDATA_REQ */
329 292 t_scalar_t DEST_length; /* dest addr length */
330 293 t_scalar_t DEST_offset; /* dest addr offset */
331 294 t_scalar_t OPT_length; /* options length */
332 295 t_scalar_t OPT_offset; /* options offset */
333 296 };
334 297
335 298 /* manage options request */
336 299
337 300 struct T_optmgmt_req {
338 301 t_scalar_t PRIM_type; /* T_OPTMGMT_REQ or */
339 302 /* T_SVR4_OPTMGMT_REQ */
340 303 t_scalar_t OPT_length; /* options length */
341 304 t_scalar_t OPT_offset; /* options offset */
342 305 t_scalar_t MGMT_flags; /* options flags */
343 306 };
344 307
345 308 /* orderly release request */
346 309
347 310 struct T_ordrel_req {
348 311 t_scalar_t PRIM_type; /* always T_ORDREL_REQ */
349 312 };
350 313
351 314 /* protocol address request */
352 315
353 316 struct T_addr_req {
354 317 t_scalar_t PRIM_type; /* always T_ADDR_REQ */
355 318 };
356 319
357 320 /* connect indication */
358 321
359 322 struct T_conn_ind {
360 323 t_scalar_t PRIM_type; /* always T_CONN_IND */
361 324 t_scalar_t SRC_length; /* src addr length */
362 325 t_scalar_t SRC_offset; /* src addr offset */
363 326 t_scalar_t OPT_length; /* option length */
364 327 t_scalar_t OPT_offset; /* option offset */
365 328 t_scalar_t SEQ_number; /* sequnce number */
366 329 };
367 330
368 331 /* connect confirmation */
369 332
370 333 struct T_conn_con {
371 334 t_scalar_t PRIM_type; /* always T_CONN_CON */
372 335 t_scalar_t RES_length; /* responding addr length */
373 336 t_scalar_t RES_offset; /* responding addr offset */
374 337 t_scalar_t OPT_length; /* option length */
375 338 t_scalar_t OPT_offset; /* option offset */
376 339 };
377 340
378 341 /* disconnect indication */
379 342
380 343 struct T_discon_ind {
381 344 t_scalar_t PRIM_type; /* always T_DISCON_IND */
382 345 t_scalar_t DISCON_reason; /* disconnect reason */
383 346 t_scalar_t SEQ_number; /* sequnce number */
384 347 };
385 348
386 349 /* data indication */
387 350
388 351 struct T_data_ind {
389 352 t_scalar_t PRIM_type; /* always T_DATA_IND */
390 353 t_scalar_t MORE_flag; /* more data */
391 354 };
392 355
393 356 /* expedited data indication */
394 357
395 358 struct T_exdata_ind {
396 359 t_scalar_t PRIM_type; /* always T_EXDATA_IND */
397 360 t_scalar_t MORE_flag; /* more data */
398 361 };
399 362
400 363 /* information acknowledgment */
401 364
402 365 struct T_info_ack {
403 366 t_scalar_t PRIM_type; /* always T_INFO_ACK */
404 367 t_scalar_t TSDU_size; /* max TSDU size */
405 368 t_scalar_t ETSDU_size; /* max ETSDU size */
406 369 t_scalar_t CDATA_size; /* max connect data size */
407 370 t_scalar_t DDATA_size; /* max discon data size */
408 371 t_scalar_t ADDR_size; /* address size */
409 372 t_scalar_t OPT_size; /* options size */
410 373 t_scalar_t TIDU_size; /* max TIDU size */
411 374 t_scalar_t SERV_type; /* provider service type */
412 375 t_scalar_t CURRENT_state; /* current state */
413 376 t_scalar_t PROVIDER_flag; /* provider flags */
414 377 };
415 378
416 379 /*
417 380 * The following are definitions of flags available to the transport
418 381 * provider to set in the PROVIDER_flag field of the T_info_ack
419 382 * structure.
420 383 */
421 384
422 385 #if _SUN_TPI_VERSION > 0
423 386 #define SENDZERO 0x0001 /* provider can handle --length TSDUs */
424 387
425 388 #define OLD_SENDZERO 0x1000 /* reserved for compatibility with */
426 389 /* old providers- old value of */
↓ open down ↓ |
196 lines elided |
↑ open up ↑ |
427 390 /* SENDZERO defined in <sys/timod.h> */
428 391 #else
429 392 #define SENDZERO 0x1000 /* old SENDZERO value */
430 393 #endif /* _SUN_TPI_VERSION > 0 */
431 394
432 395 #define EXPINLINE 0x0002 /* provider wants ETSDUs in band 0 */
433 396 /*
434 397 * Flag XPG4_1:
435 398 * transport provider supports TPI modifications motivated by and
436 399 * in conjunction with XTI inspired TPI support and all the
437 - * compatibility baggage that implies.
400 + * compatibility baggage that implies.
438 401 * It implies, - primitives T_ADDR_REQ & T_ADDR_ACK supported
439 402 * - primitives O_T_BIND_REQ & T_BIND_REQ separately supported
440 403 * - primitives T_SVR4_OPTMGMT_REQ & T_OPTMGMT_REQ separately
441 404 * supported.
442 405 */
443 406 #define XPG4_1 0x0004
444 407
445 408 /* bind acknowledgment */
446 409
447 410 struct T_bind_ack {
448 411 t_scalar_t PRIM_type; /* always T_BIND_ACK */
449 412 t_scalar_t ADDR_length; /* addr length */
450 413 t_scalar_t ADDR_offset; /* addr offset */
451 414 t_uscalar_t CONIND_number; /* connect ind to be queued */
452 415 };
453 416
454 417 /* error acknowledgment */
455 418
456 419 struct T_error_ack {
457 420 t_scalar_t PRIM_type; /* always T_ERROR_ACK */
458 421 t_scalar_t ERROR_prim; /* primitive in error */
459 422 t_scalar_t TLI_error; /* TLI error code */
460 423 t_scalar_t UNIX_error; /* UNIX error code */
461 424 };
462 425
463 426 /* ok acknowledgment */
464 427
465 428 struct T_ok_ack {
466 429 t_scalar_t PRIM_type; /* always T_OK_ACK */
467 430 t_scalar_t CORRECT_prim; /* correct primitive */
468 431 };
469 432
470 433 /* unitdata indication */
471 434
472 435 struct T_unitdata_ind {
473 436 t_scalar_t PRIM_type; /* always T_UNITDATA_IND */
474 437 t_scalar_t SRC_length; /* source addr length */
475 438 t_scalar_t SRC_offset; /* source addr offset */
476 439 t_scalar_t OPT_length; /* options length */
477 440 t_scalar_t OPT_offset; /* options offset */
478 441 };
479 442
480 443 /* unitdata error indication */
481 444
482 445 struct T_uderror_ind {
483 446 t_scalar_t PRIM_type; /* always T_UDERROR_IND */
484 447 t_scalar_t DEST_length; /* dest addr length */
485 448 t_scalar_t DEST_offset; /* dest addr offset */
486 449 t_scalar_t OPT_length; /* options length */
487 450 t_scalar_t OPT_offset; /* options offset */
488 451 t_scalar_t ERROR_type; /* error type */
489 452 };
490 453
491 454 /* manage options ack */
492 455
493 456 struct T_optmgmt_ack {
494 457 t_scalar_t PRIM_type; /* always T_OPTMGMT_ACK */
495 458 t_scalar_t OPT_length; /* options length */
496 459 t_scalar_t OPT_offset; /* options offset */
497 460 t_scalar_t MGMT_flags; /* managment flags */
498 461 };
499 462
500 463 /* orderly release indication */
501 464
502 465 struct T_ordrel_ind {
503 466 t_scalar_t PRIM_type; /* always T_ORDREL_IND */
504 467 };
505 468
506 469
507 470 /* protocol address acknowledgment */
508 471
509 472 struct T_addr_ack {
510 473 t_scalar_t PRIM_type; /* always T_ADDR_ACK */
511 474 t_scalar_t LOCADDR_length; /* length of local address */
512 475 t_scalar_t LOCADDR_offset; /* offset of local address */
↓ open down ↓ |
65 lines elided |
↑ open up ↑ |
513 476 t_scalar_t REMADDR_length; /* length of remote address */
514 477 t_scalar_t REMADDR_offset; /* offset of remote address */
515 478 };
516 479
517 480 #if _SUN_TPI_VERSION > 1
518 481 /*
519 482 * Capability request and ack. These primitives are optional and
520 483 * subsume the functionality of T_INFO_{REQ,ACK}.
521 484 */
522 485 struct T_capability_req {
523 - t_scalar_t PRIM_type; /* always T_CAPABILITY_REQ */
486 + t_scalar_t PRIM_type; /* always T_CAPABILITY_REQ */
524 487 t_uscalar_t CAP_bits1; /* capability bits #1 */
525 488 };
526 489
527 490 struct T_capability_ack {
528 - t_scalar_t PRIM_type; /* always T_CAPABILITY_ACK */
491 + t_scalar_t PRIM_type; /* always T_CAPABILITY_ACK */
529 492 t_uscalar_t CAP_bits1; /* capability bits #1 */
530 493 struct T_info_ack
531 494 INFO_ack; /* info acknowledgement */
532 495 t_uscalar_t ACCEPTOR_id; /* accepting endpoint id */
533 496 };
534 497
535 498 #define TC1_INFO (1u << 0) /* Info request/ack */
536 499 #define TC1_ACCEPTOR_ID (1u << 1) /* Acceptor_id request/ack */
537 500 #define TC1_CAP_BITS2 (1u << 31) /* Reserved for future use */
538 501
539 502 #endif /* _SUN_TPI_VERSION > 1 */
540 503
541 504 #ifdef _KERNEL
542 505 /*
543 506 * Private Sun TPI extensions.
544 507 */
545 508
546 509 /* data (with options) request */
547 510 struct T_optdata_req {
548 511 t_scalar_t PRIM_type; /* always T_OPTDATA_REQ */
549 512 t_scalar_t DATA_flag; /* flags like "more data" */
550 513 t_scalar_t OPT_length; /* options length */
551 514 t_scalar_t OPT_offset; /* options offset */
552 515 };
553 516
554 517 /* data (with options) indication */
555 518 struct T_optdata_ind {
556 519 t_scalar_t PRIM_type; /* always T_OPTDATA_IND */
557 520 t_scalar_t DATA_flag; /* flags like "more data" */
558 521 t_scalar_t OPT_length; /* options length */
559 522 t_scalar_t OPT_offset; /* options offset */
560 523 };
561 524
562 525 /* extended connect indication to return dst addr/port as well as src */
563 526 struct T_extconn_ind {
564 527 t_scalar_t PRIM_type; /* always T_EXTCONN_IND */
565 528 t_scalar_t SRC_length; /* src addr length */
566 529 t_scalar_t SRC_offset; /* src addr offset */
567 530 t_scalar_t OPT_length; /* option length */
568 531 t_scalar_t OPT_offset; /* option offset */
569 532 t_scalar_t SEQ_number; /* sequnce number */
570 533 t_scalar_t DEST_length; /* dest addr length */
571 534 t_scalar_t DEST_offset; /* dest addr offset */
572 535 };
573 536 #endif /* _KERNEL */
574 537
575 538 /*
576 539 * The following is a union of the primitives
577 540 */
578 541 union T_primitives {
579 542 t_scalar_t type; /* primitive type */
580 543 struct T_conn_req conn_req; /* connect request */
581 544 struct T_conn_res conn_res; /* connect response */
582 545 struct T_discon_req discon_req; /* disconnect request */
583 546 struct T_data_req data_req; /* data request */
584 547 struct T_exdata_req exdata_req; /* expedited data req */
585 548 struct T_info_req info_req; /* information req */
586 549 struct T_bind_req bind_req; /* bind request */
587 550 struct T_unbind_req unbind_req; /* unbind request */
588 551 struct T_unitdata_req unitdata_req; /* unitdata requset */
589 552 struct T_optmgmt_req optmgmt_req; /* manage opt req */
590 553 struct T_ordrel_req ordrel_req; /* orderly rel req */
591 554 struct T_addr_req addr_req; /* address request */
592 555 struct T_conn_ind conn_ind; /* connect indication */
593 556 struct T_conn_con conn_con; /* connect corfirm */
594 557 struct T_discon_ind discon_ind; /* discon indication */
595 558 struct T_data_ind data_ind; /* data indication */
596 559 struct T_exdata_ind exdata_ind; /* expedited data ind */
597 560 struct T_info_ack info_ack; /* info ack */
598 561 struct T_bind_ack bind_ack; /* bind ack */
599 562 struct T_error_ack error_ack; /* error ack */
600 563 struct T_ok_ack ok_ack; /* ok ack */
601 564 struct T_unitdata_ind unitdata_ind; /* unitdata ind */
602 565 struct T_uderror_ind uderror_ind; /* unitdata error ind */
603 566 struct T_optmgmt_ack optmgmt_ack; /* manage opt ack */
604 567 struct T_ordrel_ind ordrel_ind; /* orderly rel ind */
605 568 struct T_addr_ack addr_ack; /* address ack */
606 569 #if _SUN_TPI_VERSION > 1
607 570 struct T_capability_req capability_req; /* capability req */
608 571 struct T_capability_ack capability_ack; /* capability ack */
609 572 #endif /* _SUN_TPI_VERSION > 1 */
610 573 #ifdef _KERNEL
611 574 struct T_optdata_req optdata_req; /* option data request */
612 575 struct T_optdata_ind optdata_ind; /* option data ind */
613 576 struct T_extconn_ind extconn_ind; /* above plus dst addr */
614 577 #endif /* _KERNEL */
615 578 };
616 579
617 580 /*
618 581 * TPI specification is not clear on how to pack options in option
619 582 * buffers. What follows is the Solaris TPI interpretation of it.
620 583 *
621 584 * struct T_opthdr data structure is used to pack options in T_OPTMGMT_{REQ,ACK}
622 585 * message primitives in buffer delimited by [OPT_offset, OPT_length] fields in
623 586 * struct T_optmgmt_req/T_optmgmt_ack data structures.
624 587 *
625 588 * It is also used to pack options in similar buffers for data structures in
626 589 * T_CONN_{REQ,IND,RES,CONN} primitives and T_UNITDATA_{REQ,IND} primitives
627 590 * Needs to be on t_uscalar_t (32-bit word) aligned boundary.
628 591 *
629 592 * Note: T_SVR4_OPTMGMT_REQ primitive can, but need not, use this data
630 593 * structure for packing options. The format of option buffer for
631 594 * T_SVR4_OPTMGMT_REQ primitive is undefined and is a private contract
632 595 * between transport provider and its users.
633 596 *
634 597 * |<--------------first option---------------->| |<--second option--...
635 598 * ______________________________________ _ _ _ ____________________________
636 599 * | len | level | name | status | value.......| / / | len ...
637 600 * -------------------------------------- - - - ----------------------------
638 601 * |32bit| 32bit |32bit | 32bit | ^ | 32bit...
639 602 * |
640 603 * |
641 604 * alignment characters
642 605 */
643 606 struct T_opthdr {
644 607 t_uscalar_t len; /* total length of option (header+value) */
645 608 t_uscalar_t level; /* protocol level */
646 609 t_uscalar_t name; /* option name */
647 610 t_uscalar_t status; /* status value */
648 611 /* option value aligned on t_uscalar_t (32-bit) alignment boundary */
649 612 };
650 613
651 614 /*
652 615 * ------------------------------------------------------------------------
653 616 * Common experimental private TPI alignment related macros. Not for
654 617 * use outside Solaris bundled code and can change in any release.
655 618 * The alignment boundary _TPI_ALIGN_SIZE represents an implementation
656 619 * choice for aligning many data objects which are directly or indirectly
657 620 * associated with Solaris TPI implementation.
658 621 * ------------------------------------------------------------------------
659 622 */
660 623
661 624 #define __TPI_ALIGN_SIZE (sizeof (t_scalar_t))
662 625 #define __TPI_ALIGN(x) \
663 626 (((uintptr_t)(x) + __TPI_ALIGN_SIZE - 1) & ~(__TPI_ALIGN_SIZE - 1))
664 627 #define __TPI_SIZE_ISALIGNED(x) \
665 628 (((uintptr_t)(x) & (__TPI_ALIGN_SIZE - 1)) == 0)
666 629
667 630 /*
668 631 * TPI primitive in message must be aligned at _TPI_ALIGN_SIZE boundary
669 632 */
670 633 #define __TPI_PRIM_ISALIGNED(x) __TPI_SIZE_ISALIGNED(x)
671 634
672 635 /*
673 636 * TPI option header "struct opthdr" objects must be aligned
674 637 * at __TPI_ALIGN_SIZE boundary.
675 638 */
676 639 #define __TPI_OPT_ISALIGNED(x) __TPI_SIZE_ISALIGNED(x)
677 640 #define _TPI_ALIGN_OPT(x) __TPI_ALIGN(x)
678 641
679 642 /*
680 643 * TPI option header "struct T_opthdr" objects must be aligned
681 644 * at __TPI_ALIGN_SIZE boundary.
682 645 */
683 646 #define __TPI_TOPT_ISALIGNED(x) __TPI_SIZE_ISALIGNED(x)
684 647 #define _TPI_ALIGN_TOPT(x) __TPI_ALIGN(x)
685 648
686 649 /*
687 650 * --------------------------------------------------------------------
688 651 * Private experimental macros. Not for use outside Solaris bundled
689 652 * source code and can change in any release.
690 653 * Macros that operate on struct T_opthdr. These are roughly modelled
691 654 * after the corresponding Socket CMSG_*() and XTI T_OPT_*() macros, but
692 655 * are applied to TPI option buffers.
693 656 * --------------------------------------------------------------------
694 657 *
695 658 * unsigned char *
696 659 * _TPI_TOPT_DATA(struct T_opthdr *tohp):
697 660 * Get start of data part after option header
698 661 */
699 662 #define _TPI_TOPT_DATA(tohp) \
700 663 ((unsigned char *)((char *)(tohp) + sizeof (struct T_opthdr)))
701 664
702 665 /*
703 666 * t_uscalar_t
704 667 * _TPI_TOPT_DATALEN(tohp)
705 668 * Get length of contents of option data excluding header (and
706 669 * padding etc if any).
707 670 */
708 671 #define _TPI_TOPT_DATALEN(tohp) ((tohp)->len - sizeof (struct T_opthdr))
709 672
710 673 /*
711 674 * struct T_opthdr *
712 675 * _TPI_TOPT_FIRSTHDR(char *pbuf, t_scalar_t buflen):
713 676 * Get pointer to the first option header in buffer 'pbuf'
714 677 * Return NULL if there is not enough room for the header
715 678 *
716 679 * struct T_opthdr *
717 680 * _TPI_TOPT_NEXTHDR(char *pbuf, t_scalar_t buflen,
718 681 * struct T_opthdr *popt):
719 682 * Skip to next option header
720 683 *
721 684 * Notes: _TPI_TOPT_NEXTHDR performs the roundup of the length.
722 685 *
723 686 * If _TPI_TOPT_{FIRST,NEXT}HDR returns a non-null value, the user of
724 687 * _TPI_TOPT_{FIRST,NEXT}HDR must still verify that the resulting pointer
725 688 * is valid, by making a call to _TPI_TOPT_VALID. The _TPI_TOPT_VALID
726 689 * macro does not assume that the last option buffer is padded.
727 690 */
728 691 #define _TPI_TOPT_FIRSTHDR(pbuf, buflen) \
729 692 ((((buflen) >= (unsigned int) sizeof (struct T_opthdr)) && \
730 693 __TPI_TOPT_ISALIGNED(pbuf)) ? \
731 694 (struct T_opthdr *)(pbuf) : (struct T_opthdr *)0)
732 695
733 696 #define _TPI_TOPT_NEXTHDR(pbuf, buflen, popt) \
734 697 (((char *)(popt) + _TPI_ALIGN_TOPT((popt)->len)) < \
735 698 ((char *)(pbuf) + (buflen)) ? \
736 699 (struct T_opthdr *)((char *)(popt) + _TPI_ALIGN_TOPT((popt)->len)) : \
737 700 (struct T_opthdr *)0)
738 701
739 702 /*
740 703 * bool_t
741 704 * _TPI_TOPT_VALID(struct T_opthdr *tohp, char *start, char *end)
742 705 * Validate the option header at tohp, for its alignment and length.
743 706 * 1. check that tohp is aligned at t_scalar_t boundary
744 707 * 2. check that start <= tohp < end
745 708 * 3. validate the length, should be >= sizeof(T_opthdr) and
746 709 * check that there is no pointer arithmetic overflow.
747 710 * (could be caused by a very large value for tohp->len)
748 711 */
749 712
750 713 #define _TPI_TOPT_VALID(tohp, start, end) \
751 714 (__TPI_TOPT_ISALIGNED(tohp) && \
752 715 ((uintptr_t)(tohp) >= (uintptr_t)(start)) && \
753 716 ((uintptr_t)(tohp) < (uintptr_t)(end)) && \
754 717 ((ssize_t)(tohp)->len >= sizeof (struct T_opthdr)) && \
755 718 ((uintptr_t)(tohp) + (tohp)->len <= (uintptr_t)(end)) && \
756 719 ((uintptr_t)(tohp) + (tohp)->len >= (uintptr_t)(tohp) + \
757 720 sizeof (struct T_opthdr)))
758 721
759 722 #ifdef __cplusplus
760 723 }
761 724 #endif
762 725
763 726 #endif /* _SYS_TIHDR_H */
↓ open down ↓ |
225 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX