17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*dd49f125SAnders Persson * Common Development and Distribution License (the "License"). 6*dd49f125SAnders Persson * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 227c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 237c478bd9Sstevel@tonic-gate 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate /* 26*dd49f125SAnders Persson * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. 277c478bd9Sstevel@tonic-gate */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifndef _SYS_TIHDR_H 307c478bd9Sstevel@tonic-gate #define _SYS_TIHDR_H 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #include <sys/types.h> 337c478bd9Sstevel@tonic-gate /* 347c478bd9Sstevel@tonic-gate * Include declarations implicit to TPI and shared with user level code 357c478bd9Sstevel@tonic-gate */ 367c478bd9Sstevel@tonic-gate #include <sys/tpicommon.h> 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #ifdef __cplusplus 397c478bd9Sstevel@tonic-gate extern "C" { 407c478bd9Sstevel@tonic-gate #endif 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* 437c478bd9Sstevel@tonic-gate * The feature test macro, _SUN_TPI_VERSION makes some of additional 447c478bd9Sstevel@tonic-gate * declarations available and changes some existing ones. There was 457c478bd9Sstevel@tonic-gate * some changes done to this interface and this feature test macro 467c478bd9Sstevel@tonic-gate * enables transitioning to those changes while maintaining retaining 477c478bd9Sstevel@tonic-gate * backward compatibility. 487c478bd9Sstevel@tonic-gate * 497c478bd9Sstevel@tonic-gate * The following is all the information 507c478bd9Sstevel@tonic-gate * needed by the Transport Service Interface. 517c478bd9Sstevel@tonic-gate */ 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate /* 547c478bd9Sstevel@tonic-gate * The following are the definitions of the Transport 557c478bd9Sstevel@tonic-gate * Service Interface primitives. 567c478bd9Sstevel@tonic-gate */ 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate /* 597c478bd9Sstevel@tonic-gate * Primitives that are initiated by the transport user. 607c478bd9Sstevel@tonic-gate */ 617c478bd9Sstevel@tonic-gate #define T_CONN_REQ 0 /* connection request */ 627c478bd9Sstevel@tonic-gate #if _SUN_TPI_VERSION > 1 637c478bd9Sstevel@tonic-gate #define O_T_CONN_RES 1 /* old connection response */ 647c478bd9Sstevel@tonic-gate #else 657c478bd9Sstevel@tonic-gate #define T_CONN_RES 1 /* connection response */ 667c478bd9Sstevel@tonic-gate #endif /* _SUN_TPI_VERSION > 1 */ 677c478bd9Sstevel@tonic-gate #define T_DISCON_REQ 2 /* disconnect request */ 687c478bd9Sstevel@tonic-gate #define T_DATA_REQ 3 /* data request */ 697c478bd9Sstevel@tonic-gate #define T_EXDATA_REQ 4 /* expedited data request */ 707c478bd9Sstevel@tonic-gate #define T_INFO_REQ 5 /* information request */ 717c478bd9Sstevel@tonic-gate /* 727c478bd9Sstevel@tonic-gate * Bind Request primitive (TLI inspired 737c478bd9Sstevel@tonic-gate * address binding semantics). If requested address is 747c478bd9Sstevel@tonic-gate * found to be busy, an alternative free address is 757c478bd9Sstevel@tonic-gate * returned. (Requires comparison of requested address to 767c478bd9Sstevel@tonic-gate * returned address to verify if the requested address was 777c478bd9Sstevel@tonic-gate * bound) 787c478bd9Sstevel@tonic-gate * 797c478bd9Sstevel@tonic-gate */ 807c478bd9Sstevel@tonic-gate #if _SUN_TPI_VERSION > 0 817c478bd9Sstevel@tonic-gate #define O_T_BIND_REQ 6 827c478bd9Sstevel@tonic-gate #else 837c478bd9Sstevel@tonic-gate #define T_BIND_REQ 6 847c478bd9Sstevel@tonic-gate #endif /* _SUN_TPI_VERSION > 0 */ 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate #define T_UNBIND_REQ 7 /* unbind request */ 877c478bd9Sstevel@tonic-gate #define T_UNITDATA_REQ 8 /* unitdata request */ 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate /* 907c478bd9Sstevel@tonic-gate * Option management request (with TLI inspired semantics ) 917c478bd9Sstevel@tonic-gate * The preferred name for this primitive in new code is T_SVR4_OPTMGMT_REQ. 927c478bd9Sstevel@tonic-gate * This primitive had the name T_OPTMGMT_REQ in old SVR4 derived TPI. 937c478bd9Sstevel@tonic-gate * This primitive is used for TLI and Socket API support. 947c478bd9Sstevel@tonic-gate * The packing of options in option buffer is private contract 957c478bd9Sstevel@tonic-gate * between transport provider and its users and can differ 967c478bd9Sstevel@tonic-gate * between different transports. 977c478bd9Sstevel@tonic-gate * (The name O_T_OPTMGMT_REQ continues to exist for Solaris 2.6 987c478bd9Sstevel@tonic-gate * compilation environment compatibility only) 997c478bd9Sstevel@tonic-gate * 1007c478bd9Sstevel@tonic-gate */ 1017c478bd9Sstevel@tonic-gate #define T_SVR4_OPTMGMT_REQ 9 1027c478bd9Sstevel@tonic-gate #if _SUN_TPI_VERSION > 0 1037c478bd9Sstevel@tonic-gate #define O_T_OPTMGMT_REQ T_SVR4_OPTMGMT_REQ 1047c478bd9Sstevel@tonic-gate #else 1057c478bd9Sstevel@tonic-gate #define T_OPTMGMT_REQ T_SVR4_OPTMGMT_REQ 1067c478bd9Sstevel@tonic-gate #endif /* _SUN_TPI_VERSION > 0 */ 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate #define T_ORDREL_REQ 10 /* orderly release req */ 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate /* 1117c478bd9Sstevel@tonic-gate * Primitives that are initiated by the transport provider. 1127c478bd9Sstevel@tonic-gate */ 1137c478bd9Sstevel@tonic-gate #define T_CONN_IND 11 /* connection indication */ 1147c478bd9Sstevel@tonic-gate #define T_CONN_CON 12 /* connection confirmation */ 1157c478bd9Sstevel@tonic-gate #define T_DISCON_IND 13 /* disconnect indication */ 1167c478bd9Sstevel@tonic-gate #define T_DATA_IND 14 /* data indication */ 1177c478bd9Sstevel@tonic-gate #define T_EXDATA_IND 15 /* expeditied data indication */ 1187c478bd9Sstevel@tonic-gate #define T_INFO_ACK 16 /* information acknowledgment */ 1197c478bd9Sstevel@tonic-gate #define T_BIND_ACK 17 /* bind acknowledment */ 1207c478bd9Sstevel@tonic-gate #define T_ERROR_ACK 18 /* error acknowledgment */ 1217c478bd9Sstevel@tonic-gate #define T_OK_ACK 19 /* ok acknowledgment */ 1227c478bd9Sstevel@tonic-gate #define T_UNITDATA_IND 20 /* unitdata indication */ 1237c478bd9Sstevel@tonic-gate #define T_UDERROR_IND 21 /* unitdata error indication */ 1247c478bd9Sstevel@tonic-gate #define T_OPTMGMT_ACK 22 /* manage options ack */ 1257c478bd9Sstevel@tonic-gate #define T_ORDREL_IND 23 /* orderly release ind */ 1267c478bd9Sstevel@tonic-gate /* 1277c478bd9Sstevel@tonic-gate * Primitives added to namespace and contain a mix of ones 1287c478bd9Sstevel@tonic-gate * initiated by transport user or provider. 1297c478bd9Sstevel@tonic-gate */ 1307c478bd9Sstevel@tonic-gate #define T_ADDR_REQ 24 /* address request */ 1317c478bd9Sstevel@tonic-gate #define T_ADDR_ACK 25 /* address acknowledgement */ 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate #if _SUN_TPI_VERSION > 0 1347c478bd9Sstevel@tonic-gate /* 1357c478bd9Sstevel@tonic-gate * Bind request primitive with better address 1367c478bd9Sstevel@tonic-gate * binding semantics. (XTI inspired) 1377c478bd9Sstevel@tonic-gate * If the requested address is found to be busy, 1387c478bd9Sstevel@tonic-gate * an error is returned. (No need to compare addresses on successful 1397c478bd9Sstevel@tonic-gate * bind acknowledgement). 1407c478bd9Sstevel@tonic-gate */ 1417c478bd9Sstevel@tonic-gate #define T_BIND_REQ 26 /* bind request */ 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate /* 1447c478bd9Sstevel@tonic-gate * Option management request (with XTI inspired semantics) 1457c478bd9Sstevel@tonic-gate * The packing of options in option buffer is required to 1467c478bd9Sstevel@tonic-gate * be with 'struct T_opthdr' data structure defined later in 1477c478bd9Sstevel@tonic-gate * this header. 1487c478bd9Sstevel@tonic-gate */ 1497c478bd9Sstevel@tonic-gate #define T_OPTMGMT_REQ 27 /* manage options req - T_opthdr option header */ 1507c478bd9Sstevel@tonic-gate #endif /* _SUN_TPI_VERSION > 0 */ 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate #if _SUN_TPI_VERSION > 1 1537c478bd9Sstevel@tonic-gate /* 1547c478bd9Sstevel@tonic-gate * The connection response that expects its ACCEPTOR_id to have been 1557c478bd9Sstevel@tonic-gate * filled in from the value supplied via a T_CAPABILITY_ACK. 1567c478bd9Sstevel@tonic-gate */ 1577c478bd9Sstevel@tonic-gate #define T_CONN_RES 28 /* connection response */ 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate /* 1607c478bd9Sstevel@tonic-gate * Capability request and ack. These primitives are optional and 1617c478bd9Sstevel@tonic-gate * subsume the functionality of T_INFO_{REQ,ACK}. 1627c478bd9Sstevel@tonic-gate */ 1637c478bd9Sstevel@tonic-gate #define T_CAPABILITY_REQ 30 1647c478bd9Sstevel@tonic-gate #define T_CAPABILITY_ACK 31 1657c478bd9Sstevel@tonic-gate #endif /* _SUN_TPI_VERSION > 1 */ 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate #ifdef _KERNEL 1687c478bd9Sstevel@tonic-gate /* 1697c478bd9Sstevel@tonic-gate * Sun private TPI extensions. They are currently used for transparently 170*dd49f125SAnders Persson * passing options through the connection-oriented loopback transport. 1717c478bd9Sstevel@tonic-gate * Values assigned to them may change. 1727c478bd9Sstevel@tonic-gate * 1737c478bd9Sstevel@tonic-gate * T_EXTCONN_IND (extended T_CONN_IND) is used to return dst as well as 1747c478bd9Sstevel@tonic-gate * src addr/port. 1757c478bd9Sstevel@tonic-gate */ 1767c478bd9Sstevel@tonic-gate #define T_OPTDATA_REQ 0x1001 /* data (with options) request */ 1777c478bd9Sstevel@tonic-gate #define T_OPTDATA_IND 0x1002 /* data (with options) indication */ 1787c478bd9Sstevel@tonic-gate #define T_EXTCONN_IND 0x1003 /* extended T_CONN_IND to return dst as well */ 179c28749e9Skais 1807c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate /* 1837c478bd9Sstevel@tonic-gate * The following are the events that drive the state machine 1847c478bd9Sstevel@tonic-gate */ 1857c478bd9Sstevel@tonic-gate /* Initialization events */ 1867c478bd9Sstevel@tonic-gate #define TE_BIND_REQ 0 /* bind request */ 1877c478bd9Sstevel@tonic-gate #define TE_UNBIND_REQ 1 /* unbind request */ 1887c478bd9Sstevel@tonic-gate #define TE_OPTMGMT_REQ 2 /* manage options req */ 1897c478bd9Sstevel@tonic-gate #define TE_BIND_ACK 3 /* bind acknowledment */ 1907c478bd9Sstevel@tonic-gate #define TE_OPTMGMT_ACK 4 /* manage options ack */ 1917c478bd9Sstevel@tonic-gate #define TE_ERROR_ACK 5 /* error acknowledgment */ 1927c478bd9Sstevel@tonic-gate #define TE_OK_ACK1 6 /* ok ack seqcnt == 0 */ 1937c478bd9Sstevel@tonic-gate #define TE_OK_ACK2 7 /* ok ack seqcnt == 1, q == resq */ 1947c478bd9Sstevel@tonic-gate #define TE_OK_ACK3 8 /* ok ack seqcnt == 1, q != resq */ 1957c478bd9Sstevel@tonic-gate #define TE_OK_ACK4 9 /* ok ack seqcnt > 1 */ 1967c478bd9Sstevel@tonic-gate 1977c478bd9Sstevel@tonic-gate /* Connection oriented events */ 1987c478bd9Sstevel@tonic-gate #define TE_CONN_REQ 10 /* connection request */ 1997c478bd9Sstevel@tonic-gate #define TE_CONN_RES 11 /* connection response */ 2007c478bd9Sstevel@tonic-gate #define TE_DISCON_REQ 12 /* disconnect request */ 2017c478bd9Sstevel@tonic-gate #define TE_DATA_REQ 13 /* data request */ 2027c478bd9Sstevel@tonic-gate #define TE_EXDATA_REQ 14 /* expedited data request */ 2037c478bd9Sstevel@tonic-gate #define TE_ORDREL_REQ 15 /* orderly release req */ 2047c478bd9Sstevel@tonic-gate #define TE_CONN_IND 16 /* connection indication */ 2057c478bd9Sstevel@tonic-gate #define TE_CONN_CON 17 /* connection confirmation */ 2067c478bd9Sstevel@tonic-gate #define TE_DATA_IND 18 /* data indication */ 2077c478bd9Sstevel@tonic-gate #define TE_EXDATA_IND 19 /* expedited data indication */ 2087c478bd9Sstevel@tonic-gate #define TE_ORDREL_IND 20 /* orderly release ind */ 2097c478bd9Sstevel@tonic-gate #define TE_DISCON_IND1 21 /* disconnect indication seq == 0 */ 2107c478bd9Sstevel@tonic-gate #define TE_DISCON_IND2 22 /* disconnect indication seq == 1 */ 2117c478bd9Sstevel@tonic-gate #define TE_DISCON_IND3 23 /* disconnect indication seq > 1 */ 2127c478bd9Sstevel@tonic-gate #define TE_PASS_CONN 24 /* pass connection */ 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gate /* Unit data events */ 2157c478bd9Sstevel@tonic-gate #define TE_UNITDATA_REQ 25 /* unitdata request */ 2167c478bd9Sstevel@tonic-gate #define TE_UNITDATA_IND 26 /* unitdata indication */ 2177c478bd9Sstevel@tonic-gate #define TE_UDERROR_IND 27 /* unitdata error indication */ 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate #define TE_NOEVENTS 28 2207c478bd9Sstevel@tonic-gate /* 2217c478bd9Sstevel@tonic-gate * The following are the possible states of the Transport 2227c478bd9Sstevel@tonic-gate * Service Interface 2237c478bd9Sstevel@tonic-gate */ 2247c478bd9Sstevel@tonic-gate 2257c478bd9Sstevel@tonic-gate #define TS_UNBND 0 /* unbound */ 2267c478bd9Sstevel@tonic-gate #define TS_WACK_BREQ 1 /* waiting ack of BIND_REQ */ 2277c478bd9Sstevel@tonic-gate #define TS_WACK_UREQ 2 /* waiting ack of UNBIND_REQ */ 2287c478bd9Sstevel@tonic-gate #define TS_IDLE 3 /* idle */ 2297c478bd9Sstevel@tonic-gate #define TS_WACK_OPTREQ 4 /* wait ack options request */ 2307c478bd9Sstevel@tonic-gate #define TS_WACK_CREQ 5 /* waiting ack of CONN_REQ */ 2317c478bd9Sstevel@tonic-gate #define TS_WCON_CREQ 6 /* waiting confirm of CONN_REQ */ 2327c478bd9Sstevel@tonic-gate #define TS_WRES_CIND 7 /* waiting response of CONN_IND */ 2337c478bd9Sstevel@tonic-gate #define TS_WACK_CRES 8 /* waiting ack of CONN_RES */ 2347c478bd9Sstevel@tonic-gate #define TS_DATA_XFER 9 /* data transfer */ 2357c478bd9Sstevel@tonic-gate #define TS_WIND_ORDREL 10 /* releasing rd but not wr */ 2367c478bd9Sstevel@tonic-gate #define TS_WREQ_ORDREL 11 /* wait to release wr but not rd */ 2377c478bd9Sstevel@tonic-gate #define TS_WACK_DREQ6 12 /* waiting ack of DISCON_REQ */ 2387c478bd9Sstevel@tonic-gate #define TS_WACK_DREQ7 13 /* waiting ack of DISCON_REQ */ 2397c478bd9Sstevel@tonic-gate #define TS_WACK_DREQ9 14 /* waiting ack of DISCON_REQ */ 2407c478bd9Sstevel@tonic-gate #define TS_WACK_DREQ10 15 /* waiting ack of DISCON_REQ */ 2417c478bd9Sstevel@tonic-gate #define TS_WACK_DREQ11 16 /* waiting ack of DISCON_REQ */ 2427c478bd9Sstevel@tonic-gate 2437c478bd9Sstevel@tonic-gate #define TS_NOSTATES 17 2447c478bd9Sstevel@tonic-gate 2457c478bd9Sstevel@tonic-gate 2467c478bd9Sstevel@tonic-gate /* 2477c478bd9Sstevel@tonic-gate * The following structure definitions define the format of the 2487c478bd9Sstevel@tonic-gate * stream message block of the above primitives. 2497c478bd9Sstevel@tonic-gate * (everything is declared t_scalar_t to ensure proper alignment 2507c478bd9Sstevel@tonic-gate * across different machines) 2517c478bd9Sstevel@tonic-gate */ 2527c478bd9Sstevel@tonic-gate 2537c478bd9Sstevel@tonic-gate /* connection request */ 2547c478bd9Sstevel@tonic-gate 2557c478bd9Sstevel@tonic-gate struct T_conn_req { 2567c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_CONN_REQ */ 2577c478bd9Sstevel@tonic-gate t_scalar_t DEST_length; /* dest addr length */ 2587c478bd9Sstevel@tonic-gate t_scalar_t DEST_offset; /* dest addr offset */ 2597c478bd9Sstevel@tonic-gate t_scalar_t OPT_length; /* options length */ 2607c478bd9Sstevel@tonic-gate t_scalar_t OPT_offset; /* options offset */ 2617c478bd9Sstevel@tonic-gate }; 2627c478bd9Sstevel@tonic-gate 2637c478bd9Sstevel@tonic-gate /* connect response */ 2647c478bd9Sstevel@tonic-gate 2657c478bd9Sstevel@tonic-gate /* 2667c478bd9Sstevel@tonic-gate * Historical compatibility note for "struct T_conn_res" usage. 2677c478bd9Sstevel@tonic-gate * "QUEUE_ptr" field of type "queue_t" is obsolete to support 2687c478bd9Sstevel@tonic-gate * code portability and application binary compatibility 2697c478bd9Sstevel@tonic-gate * between ILP32(32-bit) and LP64 (64-bit) environments. 2707c478bd9Sstevel@tonic-gate * Use field "ACCEPTOR_id" instead. 2717c478bd9Sstevel@tonic-gate * For compatibility, drivers using (_SUN_TPI_VERSION >= 2) interface 2727c478bd9Sstevel@tonic-gate * can support treating ACCEPTOR_id content as queue pointer 2737c478bd9Sstevel@tonic-gate * only when PRIM_type is O_T_CONN_RES. 2747c478bd9Sstevel@tonic-gate */ 2757c478bd9Sstevel@tonic-gate struct T_conn_res { 2767c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* T_CONN_RES (or O_T_CONN_RES) */ 2777c478bd9Sstevel@tonic-gate t_uscalar_t ACCEPTOR_id; /* id of accepting endpoint */ 2787c478bd9Sstevel@tonic-gate t_scalar_t OPT_length; /* options length */ 2797c478bd9Sstevel@tonic-gate t_scalar_t OPT_offset; /* options offset */ 2807c478bd9Sstevel@tonic-gate t_scalar_t SEQ_number; /* sequence number */ 2817c478bd9Sstevel@tonic-gate }; 2827c478bd9Sstevel@tonic-gate 2837c478bd9Sstevel@tonic-gate /* disconnect request */ 2847c478bd9Sstevel@tonic-gate 2857c478bd9Sstevel@tonic-gate struct T_discon_req { 2867c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_DISCON_REQ */ 2877c478bd9Sstevel@tonic-gate t_scalar_t SEQ_number; /* sequnce number */ 2887c478bd9Sstevel@tonic-gate }; 2897c478bd9Sstevel@tonic-gate 2907c478bd9Sstevel@tonic-gate /* data request */ 2917c478bd9Sstevel@tonic-gate 2927c478bd9Sstevel@tonic-gate struct T_data_req { 2937c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_DATA_REQ */ 2947c478bd9Sstevel@tonic-gate t_scalar_t MORE_flag; /* more data */ 2957c478bd9Sstevel@tonic-gate }; 2967c478bd9Sstevel@tonic-gate 2977c478bd9Sstevel@tonic-gate /* expedited data request */ 2987c478bd9Sstevel@tonic-gate 2997c478bd9Sstevel@tonic-gate struct T_exdata_req { 3007c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_EXDATA_REQ */ 3017c478bd9Sstevel@tonic-gate t_scalar_t MORE_flag; /* more data */ 3027c478bd9Sstevel@tonic-gate }; 3037c478bd9Sstevel@tonic-gate 3047c478bd9Sstevel@tonic-gate /* information request */ 3057c478bd9Sstevel@tonic-gate 3067c478bd9Sstevel@tonic-gate struct T_info_req { 3077c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_INFO_REQ */ 3087c478bd9Sstevel@tonic-gate }; 3097c478bd9Sstevel@tonic-gate 3107c478bd9Sstevel@tonic-gate /* bind request */ 3117c478bd9Sstevel@tonic-gate 3127c478bd9Sstevel@tonic-gate struct T_bind_req { 3137c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* T_BIND_REQ (or O_T_BIND_REQ) */ 3147c478bd9Sstevel@tonic-gate t_scalar_t ADDR_length; /* addr length */ 3157c478bd9Sstevel@tonic-gate t_scalar_t ADDR_offset; /* addr offset */ 3167c478bd9Sstevel@tonic-gate t_uscalar_t CONIND_number; /* connect indications requested */ 3177c478bd9Sstevel@tonic-gate }; 3187c478bd9Sstevel@tonic-gate 3197c478bd9Sstevel@tonic-gate /* unbind request */ 3207c478bd9Sstevel@tonic-gate 3217c478bd9Sstevel@tonic-gate struct T_unbind_req { 3227c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_UNBIND_REQ */ 3237c478bd9Sstevel@tonic-gate }; 3247c478bd9Sstevel@tonic-gate 3257c478bd9Sstevel@tonic-gate /* unitdata request */ 3267c478bd9Sstevel@tonic-gate 3277c478bd9Sstevel@tonic-gate struct T_unitdata_req { 3287c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_UNITDATA_REQ */ 3297c478bd9Sstevel@tonic-gate t_scalar_t DEST_length; /* dest addr length */ 3307c478bd9Sstevel@tonic-gate t_scalar_t DEST_offset; /* dest addr offset */ 3317c478bd9Sstevel@tonic-gate t_scalar_t OPT_length; /* options length */ 3327c478bd9Sstevel@tonic-gate t_scalar_t OPT_offset; /* options offset */ 3337c478bd9Sstevel@tonic-gate }; 3347c478bd9Sstevel@tonic-gate 3357c478bd9Sstevel@tonic-gate /* manage options request */ 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate struct T_optmgmt_req { 3387c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* T_OPTMGMT_REQ or */ 3397c478bd9Sstevel@tonic-gate /* T_SVR4_OPTMGMT_REQ */ 3407c478bd9Sstevel@tonic-gate t_scalar_t OPT_length; /* options length */ 3417c478bd9Sstevel@tonic-gate t_scalar_t OPT_offset; /* options offset */ 3427c478bd9Sstevel@tonic-gate t_scalar_t MGMT_flags; /* options flags */ 3437c478bd9Sstevel@tonic-gate }; 3447c478bd9Sstevel@tonic-gate 3457c478bd9Sstevel@tonic-gate /* orderly release request */ 3467c478bd9Sstevel@tonic-gate 3477c478bd9Sstevel@tonic-gate struct T_ordrel_req { 3487c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_ORDREL_REQ */ 3497c478bd9Sstevel@tonic-gate }; 3507c478bd9Sstevel@tonic-gate 3517c478bd9Sstevel@tonic-gate /* protocol address request */ 3527c478bd9Sstevel@tonic-gate 3537c478bd9Sstevel@tonic-gate struct T_addr_req { 3547c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_ADDR_REQ */ 3557c478bd9Sstevel@tonic-gate }; 3567c478bd9Sstevel@tonic-gate 3577c478bd9Sstevel@tonic-gate /* connect indication */ 3587c478bd9Sstevel@tonic-gate 3597c478bd9Sstevel@tonic-gate struct T_conn_ind { 3607c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_CONN_IND */ 3617c478bd9Sstevel@tonic-gate t_scalar_t SRC_length; /* src addr length */ 3627c478bd9Sstevel@tonic-gate t_scalar_t SRC_offset; /* src addr offset */ 3637c478bd9Sstevel@tonic-gate t_scalar_t OPT_length; /* option length */ 3647c478bd9Sstevel@tonic-gate t_scalar_t OPT_offset; /* option offset */ 3657c478bd9Sstevel@tonic-gate t_scalar_t SEQ_number; /* sequnce number */ 3667c478bd9Sstevel@tonic-gate }; 3677c478bd9Sstevel@tonic-gate 3687c478bd9Sstevel@tonic-gate /* connect confirmation */ 3697c478bd9Sstevel@tonic-gate 3707c478bd9Sstevel@tonic-gate struct T_conn_con { 3717c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_CONN_CON */ 3727c478bd9Sstevel@tonic-gate t_scalar_t RES_length; /* responding addr length */ 3737c478bd9Sstevel@tonic-gate t_scalar_t RES_offset; /* responding addr offset */ 3747c478bd9Sstevel@tonic-gate t_scalar_t OPT_length; /* option length */ 3757c478bd9Sstevel@tonic-gate t_scalar_t OPT_offset; /* option offset */ 3767c478bd9Sstevel@tonic-gate }; 3777c478bd9Sstevel@tonic-gate 3787c478bd9Sstevel@tonic-gate /* disconnect indication */ 3797c478bd9Sstevel@tonic-gate 3807c478bd9Sstevel@tonic-gate struct T_discon_ind { 3817c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_DISCON_IND */ 3827c478bd9Sstevel@tonic-gate t_scalar_t DISCON_reason; /* disconnect reason */ 3837c478bd9Sstevel@tonic-gate t_scalar_t SEQ_number; /* sequnce number */ 3847c478bd9Sstevel@tonic-gate }; 3857c478bd9Sstevel@tonic-gate 3867c478bd9Sstevel@tonic-gate /* data indication */ 3877c478bd9Sstevel@tonic-gate 3887c478bd9Sstevel@tonic-gate struct T_data_ind { 3897c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_DATA_IND */ 3907c478bd9Sstevel@tonic-gate t_scalar_t MORE_flag; /* more data */ 3917c478bd9Sstevel@tonic-gate }; 3927c478bd9Sstevel@tonic-gate 3937c478bd9Sstevel@tonic-gate /* expedited data indication */ 3947c478bd9Sstevel@tonic-gate 3957c478bd9Sstevel@tonic-gate struct T_exdata_ind { 3967c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_EXDATA_IND */ 3977c478bd9Sstevel@tonic-gate t_scalar_t MORE_flag; /* more data */ 3987c478bd9Sstevel@tonic-gate }; 3997c478bd9Sstevel@tonic-gate 4007c478bd9Sstevel@tonic-gate /* information acknowledgment */ 4017c478bd9Sstevel@tonic-gate 4027c478bd9Sstevel@tonic-gate struct T_info_ack { 4037c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_INFO_ACK */ 4047c478bd9Sstevel@tonic-gate t_scalar_t TSDU_size; /* max TSDU size */ 4057c478bd9Sstevel@tonic-gate t_scalar_t ETSDU_size; /* max ETSDU size */ 4067c478bd9Sstevel@tonic-gate t_scalar_t CDATA_size; /* max connect data size */ 4077c478bd9Sstevel@tonic-gate t_scalar_t DDATA_size; /* max discon data size */ 4087c478bd9Sstevel@tonic-gate t_scalar_t ADDR_size; /* address size */ 4097c478bd9Sstevel@tonic-gate t_scalar_t OPT_size; /* options size */ 4107c478bd9Sstevel@tonic-gate t_scalar_t TIDU_size; /* max TIDU size */ 4117c478bd9Sstevel@tonic-gate t_scalar_t SERV_type; /* provider service type */ 4127c478bd9Sstevel@tonic-gate t_scalar_t CURRENT_state; /* current state */ 4137c478bd9Sstevel@tonic-gate t_scalar_t PROVIDER_flag; /* provider flags */ 4147c478bd9Sstevel@tonic-gate }; 4157c478bd9Sstevel@tonic-gate 4167c478bd9Sstevel@tonic-gate /* 4177c478bd9Sstevel@tonic-gate * The following are definitions of flags available to the transport 4187c478bd9Sstevel@tonic-gate * provider to set in the PROVIDER_flag field of the T_info_ack 4197c478bd9Sstevel@tonic-gate * structure. 4207c478bd9Sstevel@tonic-gate */ 4217c478bd9Sstevel@tonic-gate 4227c478bd9Sstevel@tonic-gate #if _SUN_TPI_VERSION > 0 4237c478bd9Sstevel@tonic-gate #define SENDZERO 0x0001 /* provider can handle --length TSDUs */ 4247c478bd9Sstevel@tonic-gate 4257c478bd9Sstevel@tonic-gate #define OLD_SENDZERO 0x1000 /* reserved for compatibility with */ 4267c478bd9Sstevel@tonic-gate /* old providers- old value of */ 4277c478bd9Sstevel@tonic-gate /* SENDZERO defined in <sys/timod.h> */ 4287c478bd9Sstevel@tonic-gate #else 4297c478bd9Sstevel@tonic-gate #define SENDZERO 0x1000 /* old SENDZERO value */ 4307c478bd9Sstevel@tonic-gate #endif /* _SUN_TPI_VERSION > 0 */ 4317c478bd9Sstevel@tonic-gate 4327c478bd9Sstevel@tonic-gate #define EXPINLINE 0x0002 /* provider wants ETSDUs in band 0 */ 4337c478bd9Sstevel@tonic-gate /* 4347c478bd9Sstevel@tonic-gate * Flag XPG4_1: 4357c478bd9Sstevel@tonic-gate * transport provider supports TPI modifications motivated by and 4367c478bd9Sstevel@tonic-gate * in conjunction with XTI inspired TPI support and all the 4377c478bd9Sstevel@tonic-gate * compatibility baggage that implies. 4387c478bd9Sstevel@tonic-gate * It implies, - primitives T_ADDR_REQ & T_ADDR_ACK supported 4397c478bd9Sstevel@tonic-gate * - primitives O_T_BIND_REQ & T_BIND_REQ separately supported 4407c478bd9Sstevel@tonic-gate * - primitives T_SVR4_OPTMGMT_REQ & T_OPTMGMT_REQ separately 4417c478bd9Sstevel@tonic-gate * supported. 4427c478bd9Sstevel@tonic-gate */ 4437c478bd9Sstevel@tonic-gate #define XPG4_1 0x0004 4447c478bd9Sstevel@tonic-gate 4457c478bd9Sstevel@tonic-gate /* bind acknowledgment */ 4467c478bd9Sstevel@tonic-gate 4477c478bd9Sstevel@tonic-gate struct T_bind_ack { 4487c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_BIND_ACK */ 4497c478bd9Sstevel@tonic-gate t_scalar_t ADDR_length; /* addr length */ 4507c478bd9Sstevel@tonic-gate t_scalar_t ADDR_offset; /* addr offset */ 4517c478bd9Sstevel@tonic-gate t_uscalar_t CONIND_number; /* connect ind to be queued */ 4527c478bd9Sstevel@tonic-gate }; 4537c478bd9Sstevel@tonic-gate 4547c478bd9Sstevel@tonic-gate /* error acknowledgment */ 4557c478bd9Sstevel@tonic-gate 4567c478bd9Sstevel@tonic-gate struct T_error_ack { 4577c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_ERROR_ACK */ 4587c478bd9Sstevel@tonic-gate t_scalar_t ERROR_prim; /* primitive in error */ 4597c478bd9Sstevel@tonic-gate t_scalar_t TLI_error; /* TLI error code */ 4607c478bd9Sstevel@tonic-gate t_scalar_t UNIX_error; /* UNIX error code */ 4617c478bd9Sstevel@tonic-gate }; 4627c478bd9Sstevel@tonic-gate 4637c478bd9Sstevel@tonic-gate /* ok acknowledgment */ 4647c478bd9Sstevel@tonic-gate 4657c478bd9Sstevel@tonic-gate struct T_ok_ack { 4667c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_OK_ACK */ 4677c478bd9Sstevel@tonic-gate t_scalar_t CORRECT_prim; /* correct primitive */ 4687c478bd9Sstevel@tonic-gate }; 4697c478bd9Sstevel@tonic-gate 4707c478bd9Sstevel@tonic-gate /* unitdata indication */ 4717c478bd9Sstevel@tonic-gate 4727c478bd9Sstevel@tonic-gate struct T_unitdata_ind { 4737c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_UNITDATA_IND */ 4747c478bd9Sstevel@tonic-gate t_scalar_t SRC_length; /* source addr length */ 4757c478bd9Sstevel@tonic-gate t_scalar_t SRC_offset; /* source addr offset */ 4767c478bd9Sstevel@tonic-gate t_scalar_t OPT_length; /* options length */ 4777c478bd9Sstevel@tonic-gate t_scalar_t OPT_offset; /* options offset */ 4787c478bd9Sstevel@tonic-gate }; 4797c478bd9Sstevel@tonic-gate 4807c478bd9Sstevel@tonic-gate /* unitdata error indication */ 4817c478bd9Sstevel@tonic-gate 4827c478bd9Sstevel@tonic-gate struct T_uderror_ind { 4837c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_UDERROR_IND */ 4847c478bd9Sstevel@tonic-gate t_scalar_t DEST_length; /* dest addr length */ 4857c478bd9Sstevel@tonic-gate t_scalar_t DEST_offset; /* dest addr offset */ 4867c478bd9Sstevel@tonic-gate t_scalar_t OPT_length; /* options length */ 4877c478bd9Sstevel@tonic-gate t_scalar_t OPT_offset; /* options offset */ 4887c478bd9Sstevel@tonic-gate t_scalar_t ERROR_type; /* error type */ 4897c478bd9Sstevel@tonic-gate }; 4907c478bd9Sstevel@tonic-gate 4917c478bd9Sstevel@tonic-gate /* manage options ack */ 4927c478bd9Sstevel@tonic-gate 4937c478bd9Sstevel@tonic-gate struct T_optmgmt_ack { 4947c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_OPTMGMT_ACK */ 4957c478bd9Sstevel@tonic-gate t_scalar_t OPT_length; /* options length */ 4967c478bd9Sstevel@tonic-gate t_scalar_t OPT_offset; /* options offset */ 4977c478bd9Sstevel@tonic-gate t_scalar_t MGMT_flags; /* managment flags */ 4987c478bd9Sstevel@tonic-gate }; 4997c478bd9Sstevel@tonic-gate 5007c478bd9Sstevel@tonic-gate /* orderly release indication */ 5017c478bd9Sstevel@tonic-gate 5027c478bd9Sstevel@tonic-gate struct T_ordrel_ind { 5037c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_ORDREL_IND */ 5047c478bd9Sstevel@tonic-gate }; 5057c478bd9Sstevel@tonic-gate 5067c478bd9Sstevel@tonic-gate 5077c478bd9Sstevel@tonic-gate /* protocol address acknowledgment */ 5087c478bd9Sstevel@tonic-gate 5097c478bd9Sstevel@tonic-gate struct T_addr_ack { 5107c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_ADDR_ACK */ 5117c478bd9Sstevel@tonic-gate t_scalar_t LOCADDR_length; /* length of local address */ 5127c478bd9Sstevel@tonic-gate t_scalar_t LOCADDR_offset; /* offset of local address */ 5137c478bd9Sstevel@tonic-gate t_scalar_t REMADDR_length; /* length of remote address */ 5147c478bd9Sstevel@tonic-gate t_scalar_t REMADDR_offset; /* offset of remote address */ 5157c478bd9Sstevel@tonic-gate }; 5167c478bd9Sstevel@tonic-gate 5177c478bd9Sstevel@tonic-gate #if _SUN_TPI_VERSION > 1 5187c478bd9Sstevel@tonic-gate /* 5197c478bd9Sstevel@tonic-gate * Capability request and ack. These primitives are optional and 5207c478bd9Sstevel@tonic-gate * subsume the functionality of T_INFO_{REQ,ACK}. 5217c478bd9Sstevel@tonic-gate */ 5227c478bd9Sstevel@tonic-gate struct T_capability_req { 5237c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_CAPABILITY_REQ */ 5247c478bd9Sstevel@tonic-gate t_uscalar_t CAP_bits1; /* capability bits #1 */ 5257c478bd9Sstevel@tonic-gate }; 5267c478bd9Sstevel@tonic-gate 5277c478bd9Sstevel@tonic-gate struct T_capability_ack { 5287c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_CAPABILITY_ACK */ 5297c478bd9Sstevel@tonic-gate t_uscalar_t CAP_bits1; /* capability bits #1 */ 5307c478bd9Sstevel@tonic-gate struct T_info_ack 5317c478bd9Sstevel@tonic-gate INFO_ack; /* info acknowledgement */ 5327c478bd9Sstevel@tonic-gate t_uscalar_t ACCEPTOR_id; /* accepting endpoint id */ 5337c478bd9Sstevel@tonic-gate }; 5347c478bd9Sstevel@tonic-gate 5357c478bd9Sstevel@tonic-gate #define TC1_INFO (1u << 0) /* Info request/ack */ 5367c478bd9Sstevel@tonic-gate #define TC1_ACCEPTOR_ID (1u << 1) /* Acceptor_id request/ack */ 5377c478bd9Sstevel@tonic-gate #define TC1_CAP_BITS2 (1u << 31) /* Reserved for future use */ 5387c478bd9Sstevel@tonic-gate 5397c478bd9Sstevel@tonic-gate #endif /* _SUN_TPI_VERSION > 1 */ 5407c478bd9Sstevel@tonic-gate 5417c478bd9Sstevel@tonic-gate #ifdef _KERNEL 5427c478bd9Sstevel@tonic-gate /* 5437c478bd9Sstevel@tonic-gate * Private Sun TPI extensions. 5447c478bd9Sstevel@tonic-gate */ 5457c478bd9Sstevel@tonic-gate 5467c478bd9Sstevel@tonic-gate /* data (with options) request */ 5477c478bd9Sstevel@tonic-gate struct T_optdata_req { 5487c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_OPTDATA_REQ */ 5497c478bd9Sstevel@tonic-gate t_scalar_t DATA_flag; /* flags like "more data" */ 5507c478bd9Sstevel@tonic-gate t_scalar_t OPT_length; /* options length */ 5517c478bd9Sstevel@tonic-gate t_scalar_t OPT_offset; /* options offset */ 5527c478bd9Sstevel@tonic-gate }; 5537c478bd9Sstevel@tonic-gate 5547c478bd9Sstevel@tonic-gate /* data (with options) indication */ 5557c478bd9Sstevel@tonic-gate struct T_optdata_ind { 5567c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_OPTDATA_IND */ 5577c478bd9Sstevel@tonic-gate t_scalar_t DATA_flag; /* flags like "more data" */ 5587c478bd9Sstevel@tonic-gate t_scalar_t OPT_length; /* options length */ 5597c478bd9Sstevel@tonic-gate t_scalar_t OPT_offset; /* options offset */ 5607c478bd9Sstevel@tonic-gate }; 5617c478bd9Sstevel@tonic-gate 5627c478bd9Sstevel@tonic-gate /* extended connect indication to return dst addr/port as well as src */ 5637c478bd9Sstevel@tonic-gate struct T_extconn_ind { 5647c478bd9Sstevel@tonic-gate t_scalar_t PRIM_type; /* always T_EXTCONN_IND */ 5657c478bd9Sstevel@tonic-gate t_scalar_t SRC_length; /* src addr length */ 5667c478bd9Sstevel@tonic-gate t_scalar_t SRC_offset; /* src addr offset */ 5677c478bd9Sstevel@tonic-gate t_scalar_t OPT_length; /* option length */ 5687c478bd9Sstevel@tonic-gate t_scalar_t OPT_offset; /* option offset */ 5697c478bd9Sstevel@tonic-gate t_scalar_t SEQ_number; /* sequnce number */ 5707c478bd9Sstevel@tonic-gate t_scalar_t DEST_length; /* dest addr length */ 5717c478bd9Sstevel@tonic-gate t_scalar_t DEST_offset; /* dest addr offset */ 5727c478bd9Sstevel@tonic-gate }; 5737c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 5747c478bd9Sstevel@tonic-gate 5757c478bd9Sstevel@tonic-gate /* 5767c478bd9Sstevel@tonic-gate * The following is a union of the primitives 5777c478bd9Sstevel@tonic-gate */ 5787c478bd9Sstevel@tonic-gate union T_primitives { 5797c478bd9Sstevel@tonic-gate t_scalar_t type; /* primitive type */ 5807c478bd9Sstevel@tonic-gate struct T_conn_req conn_req; /* connect request */ 5817c478bd9Sstevel@tonic-gate struct T_conn_res conn_res; /* connect response */ 5827c478bd9Sstevel@tonic-gate struct T_discon_req discon_req; /* disconnect request */ 5837c478bd9Sstevel@tonic-gate struct T_data_req data_req; /* data request */ 5847c478bd9Sstevel@tonic-gate struct T_exdata_req exdata_req; /* expedited data req */ 5857c478bd9Sstevel@tonic-gate struct T_info_req info_req; /* information req */ 5867c478bd9Sstevel@tonic-gate struct T_bind_req bind_req; /* bind request */ 5877c478bd9Sstevel@tonic-gate struct T_unbind_req unbind_req; /* unbind request */ 5887c478bd9Sstevel@tonic-gate struct T_unitdata_req unitdata_req; /* unitdata requset */ 5897c478bd9Sstevel@tonic-gate struct T_optmgmt_req optmgmt_req; /* manage opt req */ 5907c478bd9Sstevel@tonic-gate struct T_ordrel_req ordrel_req; /* orderly rel req */ 5917c478bd9Sstevel@tonic-gate struct T_addr_req addr_req; /* address request */ 5927c478bd9Sstevel@tonic-gate struct T_conn_ind conn_ind; /* connect indication */ 5937c478bd9Sstevel@tonic-gate struct T_conn_con conn_con; /* connect corfirm */ 5947c478bd9Sstevel@tonic-gate struct T_discon_ind discon_ind; /* discon indication */ 5957c478bd9Sstevel@tonic-gate struct T_data_ind data_ind; /* data indication */ 5967c478bd9Sstevel@tonic-gate struct T_exdata_ind exdata_ind; /* expedited data ind */ 5977c478bd9Sstevel@tonic-gate struct T_info_ack info_ack; /* info ack */ 5987c478bd9Sstevel@tonic-gate struct T_bind_ack bind_ack; /* bind ack */ 5997c478bd9Sstevel@tonic-gate struct T_error_ack error_ack; /* error ack */ 6007c478bd9Sstevel@tonic-gate struct T_ok_ack ok_ack; /* ok ack */ 6017c478bd9Sstevel@tonic-gate struct T_unitdata_ind unitdata_ind; /* unitdata ind */ 6027c478bd9Sstevel@tonic-gate struct T_uderror_ind uderror_ind; /* unitdata error ind */ 6037c478bd9Sstevel@tonic-gate struct T_optmgmt_ack optmgmt_ack; /* manage opt ack */ 6047c478bd9Sstevel@tonic-gate struct T_ordrel_ind ordrel_ind; /* orderly rel ind */ 6057c478bd9Sstevel@tonic-gate struct T_addr_ack addr_ack; /* address ack */ 6067c478bd9Sstevel@tonic-gate #if _SUN_TPI_VERSION > 1 6077c478bd9Sstevel@tonic-gate struct T_capability_req capability_req; /* capability req */ 6087c478bd9Sstevel@tonic-gate struct T_capability_ack capability_ack; /* capability ack */ 6097c478bd9Sstevel@tonic-gate #endif /* _SUN_TPI_VERSION > 1 */ 6107c478bd9Sstevel@tonic-gate #ifdef _KERNEL 6117c478bd9Sstevel@tonic-gate struct T_optdata_req optdata_req; /* option data request */ 6127c478bd9Sstevel@tonic-gate struct T_optdata_ind optdata_ind; /* option data ind */ 6137c478bd9Sstevel@tonic-gate struct T_extconn_ind extconn_ind; /* above plus dst addr */ 6147c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 6157c478bd9Sstevel@tonic-gate }; 6167c478bd9Sstevel@tonic-gate 6177c478bd9Sstevel@tonic-gate /* 6187c478bd9Sstevel@tonic-gate * TPI specification is not clear on how to pack options in option 6197c478bd9Sstevel@tonic-gate * buffers. What follows is the Solaris TPI interpretation of it. 6207c478bd9Sstevel@tonic-gate * 6217c478bd9Sstevel@tonic-gate * struct T_opthdr data structure is used to pack options in T_OPTMGMT_{REQ,ACK} 6227c478bd9Sstevel@tonic-gate * message primitives in buffer delimited by [OPT_offset, OPT_length] fields in 6237c478bd9Sstevel@tonic-gate * struct T_optmgmt_req/T_optmgmt_ack data structures. 6247c478bd9Sstevel@tonic-gate * 6257c478bd9Sstevel@tonic-gate * It is also used to pack options in similar buffers for data structures in 6267c478bd9Sstevel@tonic-gate * T_CONN_{REQ,IND,RES,CONN} primitives and T_UNITDATA_{REQ,IND} primitives 6277c478bd9Sstevel@tonic-gate * Needs to be on t_uscalar_t (32-bit word) aligned boundary. 6287c478bd9Sstevel@tonic-gate * 6297c478bd9Sstevel@tonic-gate * Note: T_SVR4_OPTMGMT_REQ primitive can, but need not, use this data 6307c478bd9Sstevel@tonic-gate * structure for packing options. The format of option buffer for 6317c478bd9Sstevel@tonic-gate * T_SVR4_OPTMGMT_REQ primitive is undefined and is a private contract 6327c478bd9Sstevel@tonic-gate * between transport provider and its users. 6337c478bd9Sstevel@tonic-gate * 6347c478bd9Sstevel@tonic-gate * |<--------------first option---------------->| |<--second option--... 6357c478bd9Sstevel@tonic-gate * ______________________________________ _ _ _ ____________________________ 6367c478bd9Sstevel@tonic-gate * | len | level | name | status | value.......| / / | len ... 6377c478bd9Sstevel@tonic-gate * -------------------------------------- - - - ---------------------------- 6387c478bd9Sstevel@tonic-gate * |32bit| 32bit |32bit | 32bit | ^ | 32bit... 6397c478bd9Sstevel@tonic-gate * | 6407c478bd9Sstevel@tonic-gate * | 6417c478bd9Sstevel@tonic-gate * alignment characters 6427c478bd9Sstevel@tonic-gate */ 6437c478bd9Sstevel@tonic-gate struct T_opthdr { 6447c478bd9Sstevel@tonic-gate t_uscalar_t len; /* total length of option (header+value) */ 6457c478bd9Sstevel@tonic-gate t_uscalar_t level; /* protocol level */ 6467c478bd9Sstevel@tonic-gate t_uscalar_t name; /* option name */ 6477c478bd9Sstevel@tonic-gate t_uscalar_t status; /* status value */ 6487c478bd9Sstevel@tonic-gate /* option value aligned on t_uscalar_t (32-bit) alignment boundary */ 6497c478bd9Sstevel@tonic-gate }; 6507c478bd9Sstevel@tonic-gate 6517c478bd9Sstevel@tonic-gate /* 6527c478bd9Sstevel@tonic-gate * ------------------------------------------------------------------------ 6537c478bd9Sstevel@tonic-gate * Common experimental private TPI alignment related macros. Not for 6547c478bd9Sstevel@tonic-gate * use outside Solaris bundled code and can change in any release. 6557c478bd9Sstevel@tonic-gate * The alignment boundary _TPI_ALIGN_SIZE represents an implementation 6567c478bd9Sstevel@tonic-gate * choice for aligning many data objects which are directly or indirectly 6577c478bd9Sstevel@tonic-gate * associated with Solaris TPI implementation. 6587c478bd9Sstevel@tonic-gate * ------------------------------------------------------------------------ 6597c478bd9Sstevel@tonic-gate */ 6607c478bd9Sstevel@tonic-gate 6617c478bd9Sstevel@tonic-gate #define __TPI_ALIGN_SIZE (sizeof (t_scalar_t)) 6627c478bd9Sstevel@tonic-gate #define __TPI_ALIGN(x) \ 6637c478bd9Sstevel@tonic-gate (((uintptr_t)(x) + __TPI_ALIGN_SIZE - 1) & ~(__TPI_ALIGN_SIZE - 1)) 6647c478bd9Sstevel@tonic-gate #define __TPI_SIZE_ISALIGNED(x) \ 6657c478bd9Sstevel@tonic-gate (((uintptr_t)(x) & (__TPI_ALIGN_SIZE - 1)) == 0) 6667c478bd9Sstevel@tonic-gate 6677c478bd9Sstevel@tonic-gate /* 6687c478bd9Sstevel@tonic-gate * TPI primitive in message must be aligned at _TPI_ALIGN_SIZE boundary 6697c478bd9Sstevel@tonic-gate */ 6707c478bd9Sstevel@tonic-gate #define __TPI_PRIM_ISALIGNED(x) __TPI_SIZE_ISALIGNED(x) 6717c478bd9Sstevel@tonic-gate 6727c478bd9Sstevel@tonic-gate /* 6737c478bd9Sstevel@tonic-gate * TPI option header "struct opthdr" objects must be aligned 6747c478bd9Sstevel@tonic-gate * at __TPI_ALIGN_SIZE boundary. 6757c478bd9Sstevel@tonic-gate */ 6767c478bd9Sstevel@tonic-gate #define __TPI_OPT_ISALIGNED(x) __TPI_SIZE_ISALIGNED(x) 6777c478bd9Sstevel@tonic-gate #define _TPI_ALIGN_OPT(x) __TPI_ALIGN(x) 6787c478bd9Sstevel@tonic-gate 6797c478bd9Sstevel@tonic-gate /* 6807c478bd9Sstevel@tonic-gate * TPI option header "struct T_opthdr" objects must be aligned 6817c478bd9Sstevel@tonic-gate * at __TPI_ALIGN_SIZE boundary. 6827c478bd9Sstevel@tonic-gate */ 6837c478bd9Sstevel@tonic-gate #define __TPI_TOPT_ISALIGNED(x) __TPI_SIZE_ISALIGNED(x) 6847c478bd9Sstevel@tonic-gate #define _TPI_ALIGN_TOPT(x) __TPI_ALIGN(x) 6857c478bd9Sstevel@tonic-gate 6867c478bd9Sstevel@tonic-gate /* 6877c478bd9Sstevel@tonic-gate * -------------------------------------------------------------------- 6887c478bd9Sstevel@tonic-gate * Private experimental macros. Not for use outside Solaris bundled 6897c478bd9Sstevel@tonic-gate * source code and can change in any release. 6907c478bd9Sstevel@tonic-gate * Macros that operate on struct T_opthdr. These are roughly modelled 6917c478bd9Sstevel@tonic-gate * after the corresponding Socket CMSG_*() and XTI T_OPT_*() macros, but 6927c478bd9Sstevel@tonic-gate * are applied to TPI option buffers. 6937c478bd9Sstevel@tonic-gate * -------------------------------------------------------------------- 6947c478bd9Sstevel@tonic-gate * 6957c478bd9Sstevel@tonic-gate * unsigned char * 6967c478bd9Sstevel@tonic-gate * _TPI_TOPT_DATA(struct T_opthdr *tohp): 6977c478bd9Sstevel@tonic-gate * Get start of data part after option header 6987c478bd9Sstevel@tonic-gate */ 6997c478bd9Sstevel@tonic-gate #define _TPI_TOPT_DATA(tohp) \ 7007c478bd9Sstevel@tonic-gate ((unsigned char *)((char *)(tohp) + sizeof (struct T_opthdr))) 7017c478bd9Sstevel@tonic-gate 7027c478bd9Sstevel@tonic-gate /* 7037c478bd9Sstevel@tonic-gate * t_uscalar_t 7047c478bd9Sstevel@tonic-gate * _TPI_TOPT_DATALEN(tohp) 7057c478bd9Sstevel@tonic-gate * Get length of contents of option data excluding header (and 7067c478bd9Sstevel@tonic-gate * padding etc if any). 7077c478bd9Sstevel@tonic-gate */ 7087c478bd9Sstevel@tonic-gate #define _TPI_TOPT_DATALEN(tohp) ((tohp)->len - sizeof (struct T_opthdr)) 7097c478bd9Sstevel@tonic-gate 7107c478bd9Sstevel@tonic-gate /* 7117c478bd9Sstevel@tonic-gate * struct T_opthdr * 7127c478bd9Sstevel@tonic-gate * _TPI_TOPT_FIRSTHDR(char *pbuf, t_scalar_t buflen): 7137c478bd9Sstevel@tonic-gate * Get pointer to the first option header in buffer 'pbuf' 7147c478bd9Sstevel@tonic-gate * Return NULL if there is not enough room for the header 7157c478bd9Sstevel@tonic-gate * 7167c478bd9Sstevel@tonic-gate * struct T_opthdr * 7177c478bd9Sstevel@tonic-gate * _TPI_TOPT_NEXTHDR(char *pbuf, t_scalar_t buflen, 7187c478bd9Sstevel@tonic-gate * struct T_opthdr *popt): 7197c478bd9Sstevel@tonic-gate * Skip to next option header 7207c478bd9Sstevel@tonic-gate * 7217c478bd9Sstevel@tonic-gate * Notes: _TPI_TOPT_NEXTHDR performs the roundup of the length. 7227c478bd9Sstevel@tonic-gate * 7237c478bd9Sstevel@tonic-gate * If _TPI_TOPT_{FIRST,NEXT}HDR returns a non-null value, the user of 7247c478bd9Sstevel@tonic-gate * _TPI_TOPT_{FIRST,NEXT}HDR must still verify that the resulting pointer 7257c478bd9Sstevel@tonic-gate * is valid, by making a call to _TPI_TOPT_VALID. The _TPI_TOPT_VALID 7267c478bd9Sstevel@tonic-gate * macro does not assume that the last option buffer is padded. 7277c478bd9Sstevel@tonic-gate */ 7287c478bd9Sstevel@tonic-gate #define _TPI_TOPT_FIRSTHDR(pbuf, buflen) \ 7297c478bd9Sstevel@tonic-gate ((((buflen) >= (unsigned int) sizeof (struct T_opthdr)) && \ 7307c478bd9Sstevel@tonic-gate __TPI_TOPT_ISALIGNED(pbuf)) ? \ 7317c478bd9Sstevel@tonic-gate (struct T_opthdr *)(pbuf) : (struct T_opthdr *)0) 7327c478bd9Sstevel@tonic-gate 7337c478bd9Sstevel@tonic-gate #define _TPI_TOPT_NEXTHDR(pbuf, buflen, popt) \ 7347c478bd9Sstevel@tonic-gate (((char *)(popt) + _TPI_ALIGN_TOPT((popt)->len)) < \ 7357c478bd9Sstevel@tonic-gate ((char *)(pbuf) + (buflen)) ? \ 7367c478bd9Sstevel@tonic-gate (struct T_opthdr *)((char *)(popt) + _TPI_ALIGN_TOPT((popt)->len)) : \ 7377c478bd9Sstevel@tonic-gate (struct T_opthdr *)0) 7387c478bd9Sstevel@tonic-gate 7397c478bd9Sstevel@tonic-gate /* 7407c478bd9Sstevel@tonic-gate * bool_t 7417c478bd9Sstevel@tonic-gate * _TPI_TOPT_VALID(struct T_opthdr *tohp, char *start, char *end) 7427c478bd9Sstevel@tonic-gate * Validate the option header at tohp, for its alignment and length. 7437c478bd9Sstevel@tonic-gate * 1. check that tohp is aligned at t_scalar_t boundary 7447c478bd9Sstevel@tonic-gate * 2. check that start <= tohp < end 7457c478bd9Sstevel@tonic-gate * 3. validate the length, should be >= sizeof(T_opthdr) and 7467c478bd9Sstevel@tonic-gate * check that there is no pointer arithmetic overflow. 7477c478bd9Sstevel@tonic-gate * (could be caused by a very large value for tohp->len) 7487c478bd9Sstevel@tonic-gate */ 7497c478bd9Sstevel@tonic-gate 7507c478bd9Sstevel@tonic-gate #define _TPI_TOPT_VALID(tohp, start, end) \ 7517c478bd9Sstevel@tonic-gate (__TPI_TOPT_ISALIGNED(tohp) && \ 7527c478bd9Sstevel@tonic-gate ((uintptr_t)(tohp) >= (uintptr_t)(start)) && \ 7537c478bd9Sstevel@tonic-gate ((uintptr_t)(tohp) < (uintptr_t)(end)) && \ 7547c478bd9Sstevel@tonic-gate ((ssize_t)(tohp)->len >= sizeof (struct T_opthdr)) && \ 7557c478bd9Sstevel@tonic-gate ((uintptr_t)(tohp) + (tohp)->len <= (uintptr_t)(end)) && \ 7567c478bd9Sstevel@tonic-gate ((uintptr_t)(tohp) + (tohp)->len >= (uintptr_t)(tohp) + \ 7577c478bd9Sstevel@tonic-gate sizeof (struct T_opthdr))) 7587c478bd9Sstevel@tonic-gate 7597c478bd9Sstevel@tonic-gate #ifdef __cplusplus 7607c478bd9Sstevel@tonic-gate } 7617c478bd9Sstevel@tonic-gate #endif 7627c478bd9Sstevel@tonic-gate 7637c478bd9Sstevel@tonic-gate #endif /* _SYS_TIHDR_H */ 764