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