xref: /illumos-gate/usr/src/head/xti.h (revision 6e270ca8)
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
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
22ba3594baSGarrett D'Amore /*
23ba3594baSGarrett D'Amore  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24ba3594baSGarrett D'Amore  */
257c478bd9Sstevel@tonic-gate /*	Copyright (c) 1996 Sun Microsystems, Inc.	*/
26b4203d75SMarcel Telka /*	  All Rights Reserved	*/
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifndef _XTI_H
307c478bd9Sstevel@tonic-gate #define	_XTI_H
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #include <sys/types.h>
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate /*
357c478bd9Sstevel@tonic-gate  * The following include file has declarations needed by both the kernel
367c478bd9Sstevel@tonic-gate  * level transport providers and the user level library. This file includes
377c478bd9Sstevel@tonic-gate  * it to expose its namespaces to XTI user level interface.
387c478bd9Sstevel@tonic-gate  */
397c478bd9Sstevel@tonic-gate #include <sys/tpicommon.h>
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate /*
427c478bd9Sstevel@tonic-gate  * Include XTI interface level options management declarations
437c478bd9Sstevel@tonic-gate  */
447c478bd9Sstevel@tonic-gate #include <sys/xti_xtiopt.h>
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate #if !defined(_XPG5)
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate /*
497c478bd9Sstevel@tonic-gate  * Include declarations related to OSI transport and management data
507c478bd9Sstevel@tonic-gate  * structures, and the Internet Protocol Suite.
517c478bd9Sstevel@tonic-gate  * Note: The older Unix95/XNS4 XTI spec required these to be
527c478bd9Sstevel@tonic-gate  * exposed through the generic interface header.
537c478bd9Sstevel@tonic-gate  */
547c478bd9Sstevel@tonic-gate #include <sys/xti_osi.h>
557c478bd9Sstevel@tonic-gate #include <sys/xti_inet.h>
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG5) */
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
607c478bd9Sstevel@tonic-gate extern "C" {
617c478bd9Sstevel@tonic-gate #endif
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate /*
647c478bd9Sstevel@tonic-gate  * The following t_errno error codes are included in the namespace by
657c478bd9Sstevel@tonic-gate  * inclusion of <sys/tpicommon.h> above. The english language error strings
667c478bd9Sstevel@tonic-gate  * associated with the error values are reproduced here for easy reference.
677c478bd9Sstevel@tonic-gate  *
687c478bd9Sstevel@tonic-gate  * Error		Value	Error message string
697c478bd9Sstevel@tonic-gate  * ----			-----	--------------------
707c478bd9Sstevel@tonic-gate  * TBADADDR		1	Incorrect address format
717c478bd9Sstevel@tonic-gate  * TBADOPT		2	Incorrect options format
727c478bd9Sstevel@tonic-gate  * TACCES		3	Illegal permissions
737c478bd9Sstevel@tonic-gate  * TBADF		4	Illegal file descriptor
747c478bd9Sstevel@tonic-gate  * TNOADDR		5	Couldn't allocate address
757c478bd9Sstevel@tonic-gate  * TOUTSTATE		6	Routine will place interface out of state
767c478bd9Sstevel@tonic-gate  * TBADSEQ		7	Illegal called/calling sequence number
777c478bd9Sstevel@tonic-gate  * TSYSERR		8	System error
787c478bd9Sstevel@tonic-gate  * TLOOK		9	An event requires attention
797c478bd9Sstevel@tonic-gate  * TBADDATA		10	Illegal amount of data
807c478bd9Sstevel@tonic-gate  * TBUFOVFLW		11	Buffer not large enough
817c478bd9Sstevel@tonic-gate  * TFLOW		12	Can't send message - (blocked)
827c478bd9Sstevel@tonic-gate  * TNODATA		13	No message currently available
837c478bd9Sstevel@tonic-gate  * TNODIS		14	Disconnect message not found
847c478bd9Sstevel@tonic-gate  * TNOUDERR		15	Unitdata error message not found
857c478bd9Sstevel@tonic-gate  * TBADFLAG		16	Incorrect flags specified
867c478bd9Sstevel@tonic-gate  * TNOREL		17	Orderly release message not found
877c478bd9Sstevel@tonic-gate  * TNOTSUPPORT		18	Primitive not supported by provider
887c478bd9Sstevel@tonic-gate  * TSTATECHNG		19	State is in process of changing
897c478bd9Sstevel@tonic-gate  * TNOSTRUCTYPE		20	Unsupported structure type requested
907c478bd9Sstevel@tonic-gate  * TBADNAME		21	Invalid transport provider name
917c478bd9Sstevel@tonic-gate  * TBADQLEN		22	Listener queue length limit is zero
927c478bd9Sstevel@tonic-gate  * TADDRBUSY		23	Transport address is in use
937c478bd9Sstevel@tonic-gate  * TINDOUT		24	Outstanding connection indications
947c478bd9Sstevel@tonic-gate  * TPROVMISMATCH	25	Listener-acceptor transport provider mismatch
957c478bd9Sstevel@tonic-gate  * TRESQLEN		26	Connection acceptor has listen queue length
967c478bd9Sstevel@tonic-gate  *				limit greater than zero
977c478bd9Sstevel@tonic-gate  * TRESADDR		27	Connection acceptor-listener addresses not
987c478bd9Sstevel@tonic-gate  *				same but required by transport
997c478bd9Sstevel@tonic-gate  * TQFULL		28	Incoming connection queue is full
1007c478bd9Sstevel@tonic-gate  * TPROTO		29	Protocol error on transport primitive
1017c478bd9Sstevel@tonic-gate  *
1027c478bd9Sstevel@tonic-gate  */
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate /*
1057c478bd9Sstevel@tonic-gate  * The following are the events returned by t_look
1067c478bd9Sstevel@tonic-gate  */
1077c478bd9Sstevel@tonic-gate #define	T_LISTEN	0x0001	/* connection indication received	*/
1087c478bd9Sstevel@tonic-gate #define	T_CONNECT	0x0002	/* connect confirmation received	*/
1097c478bd9Sstevel@tonic-gate #define	T_DATA		0x0004	/* normal data received			*/
1107c478bd9Sstevel@tonic-gate #define	T_EXDATA	0x0008	/* expedited data received		*/
1117c478bd9Sstevel@tonic-gate #define	T_DISCONNECT	0x0010	/* disconnect received			*/
1127c478bd9Sstevel@tonic-gate #define	T_UDERR		0x0040	/* data gram error indication		*/
1137c478bd9Sstevel@tonic-gate #define	T_ORDREL	0x0080	/* orderly release indication		*/
1147c478bd9Sstevel@tonic-gate #define	T_GODATA	0x0100	/* sending normal data is again possible */
1157c478bd9Sstevel@tonic-gate #define	T_GOEXDATA	0x0200	/* sending expedited data is again possible */
1167c478bd9Sstevel@tonic-gate 
1177c478bd9Sstevel@tonic-gate /*
1187c478bd9Sstevel@tonic-gate  * Flags for data primitives
1197c478bd9Sstevel@tonic-gate  */
1207c478bd9Sstevel@tonic-gate #define	T_MORE		0x001	/* more data		*/
1217c478bd9Sstevel@tonic-gate #define	T_EXPEDITED	0x002	/* expedited data	*/
1227c478bd9Sstevel@tonic-gate #define	T_PUSH		0x004	/* send data immediately */
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate /*
1257c478bd9Sstevel@tonic-gate  * XTI error return
1267c478bd9Sstevel@tonic-gate  */
1277c478bd9Sstevel@tonic-gate #if defined(_REENTRANT) || defined(_TS_ERRNO)
1287c478bd9Sstevel@tonic-gate extern int	*__t_errno();
1297c478bd9Sstevel@tonic-gate #define	t_errno (*(__t_errno()))
1307c478bd9Sstevel@tonic-gate #else
1317c478bd9Sstevel@tonic-gate extern int t_errno;
1327c478bd9Sstevel@tonic-gate #endif	/* defined(_REENTRANT) || defined(_TS_ERRNO) */
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate /*
1367c478bd9Sstevel@tonic-gate  * The following are for t_sysconf()
1377c478bd9Sstevel@tonic-gate  */
1387c478bd9Sstevel@tonic-gate #ifndef T_IOV_MAX
1397c478bd9Sstevel@tonic-gate #define	T_IOV_MAX	16	/* Maximum number of scatter/gather buffers */
1407c478bd9Sstevel@tonic-gate #endif				/* Should be <= IOV_MAX */
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate #ifndef _SC_T_IOV_MAX
143*6e270ca8SMarcel Telka #define	_SC_T_IOV_MAX	79	/* Should be same in <unistd.h> for use by */
1447c478bd9Sstevel@tonic-gate #endif				/* sysconf() */
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate struct t_iovec {
1477c478bd9Sstevel@tonic-gate 	void	*iov_base;
1487c478bd9Sstevel@tonic-gate 	size_t	iov_len;
1497c478bd9Sstevel@tonic-gate };
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate /*
1527c478bd9Sstevel@tonic-gate  * Translate source level interface to binary entry point names.
1537c478bd9Sstevel@tonic-gate  *
1547c478bd9Sstevel@tonic-gate  * Note: This is done to maintain co-existence of TLI and XTI
1557c478bd9Sstevel@tonic-gate  * interfaces which have identical names for most functions but
1567c478bd9Sstevel@tonic-gate  * different semantics. The XTI names are moved to the different
1577c478bd9Sstevel@tonic-gate  * prefix space in the ABI. The #ifdef is required to make use of
1587c478bd9Sstevel@tonic-gate  * of the compiler feature to allow redefinition of external names
1597c478bd9Sstevel@tonic-gate  * where available. Otherwise a simple #define is used when this
1607c478bd9Sstevel@tonic-gate  * header is used with other compilers.
1617c478bd9Sstevel@tonic-gate  * The use of #define also has the effect of renaming all names (not
1627c478bd9Sstevel@tonic-gate  * just function names) to the new name. The TLI function names
1637c478bd9Sstevel@tonic-gate  * (e.g. t_bind) can have identical names for structure names
1647c478bd9Sstevel@tonic-gate  * (e.g struct t_bind). Therefore, this redefinition of names needs
1657c478bd9Sstevel@tonic-gate  * to be before all structure and function name declarations in the header.
1667c478bd9Sstevel@tonic-gate  */
1677c478bd9Sstevel@tonic-gate 
1687c478bd9Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME
1697c478bd9Sstevel@tonic-gate 
1707c478bd9Sstevel@tonic-gate #if defined(_XOPEN_SOURCE) && !defined(_XPG5)
1717c478bd9Sstevel@tonic-gate #pragma redefine_extname t_accept	_xti_accept
1727c478bd9Sstevel@tonic-gate #else
1737c478bd9Sstevel@tonic-gate #pragma redefine_extname t_accept	_xti_xns5_accept
1747c478bd9Sstevel@tonic-gate #endif
1757c478bd9Sstevel@tonic-gate #pragma redefine_extname t_alloc	_xti_alloc
1767c478bd9Sstevel@tonic-gate #pragma redefine_extname t_bind		_xti_bind
1777c478bd9Sstevel@tonic-gate #pragma redefine_extname t_close	_xti_close
1787c478bd9Sstevel@tonic-gate #pragma redefine_extname t_connect	_xti_connect
1797c478bd9Sstevel@tonic-gate #pragma redefine_extname t_error	_xti_error
1807c478bd9Sstevel@tonic-gate #pragma redefine_extname t_free		_xti_free
1817c478bd9Sstevel@tonic-gate #pragma redefine_extname t_getinfo	_xti_getinfo
1827c478bd9Sstevel@tonic-gate #pragma redefine_extname t_getstate	_xti_getstate
1837c478bd9Sstevel@tonic-gate #pragma redefine_extname t_getprotaddr	_xti_getprotaddr
1847c478bd9Sstevel@tonic-gate #pragma redefine_extname t_listen	_xti_listen
1857c478bd9Sstevel@tonic-gate #pragma redefine_extname t_look		_xti_look
1867c478bd9Sstevel@tonic-gate #pragma redefine_extname t_open		_xti_open
1877c478bd9Sstevel@tonic-gate #pragma redefine_extname t_optmgmt	_xti_optmgmt
1887c478bd9Sstevel@tonic-gate #pragma redefine_extname t_rcv		_xti_rcv
1897c478bd9Sstevel@tonic-gate #pragma redefine_extname t_rcvconnect	_xti_rcvconnect
1907c478bd9Sstevel@tonic-gate #pragma redefine_extname t_rcvdis	_xti_rcvdis
1917c478bd9Sstevel@tonic-gate #pragma redefine_extname t_rcvrel	_xti_rcvrel
1927c478bd9Sstevel@tonic-gate #pragma redefine_extname t_rcvreldata	_xti_rcvreldata
1937c478bd9Sstevel@tonic-gate #pragma redefine_extname t_rcvudata	_xti_rcvudata
1947c478bd9Sstevel@tonic-gate #pragma redefine_extname t_rcvuderr	_xti_rcvuderr
1957c478bd9Sstevel@tonic-gate #pragma redefine_extname t_rcvv		_xti_rcvv
1967c478bd9Sstevel@tonic-gate #pragma redefine_extname t_rcvvudata	_xti_rcvvudata
1977c478bd9Sstevel@tonic-gate #if defined(_XOPEN_SOURCE) && !defined(_XPG5)
1987c478bd9Sstevel@tonic-gate #pragma redefine_extname t_snd		_xti_snd
1997c478bd9Sstevel@tonic-gate #else
2007c478bd9Sstevel@tonic-gate #pragma redefine_extname t_snd		_xti_xns5_snd
2017c478bd9Sstevel@tonic-gate #endif
2027c478bd9Sstevel@tonic-gate #pragma redefine_extname t_snddis	_xti_snddis
2037c478bd9Sstevel@tonic-gate #pragma redefine_extname t_sndrel	_xti_sndrel
2047c478bd9Sstevel@tonic-gate #pragma redefine_extname t_sndreldata	_xti_sndreldata
2057c478bd9Sstevel@tonic-gate #pragma redefine_extname t_sndudata	_xti_sndudata
2067c478bd9Sstevel@tonic-gate #pragma redefine_extname t_sndv		_xti_sndv
2077c478bd9Sstevel@tonic-gate #pragma redefine_extname t_sndvudata	_xti_sndvudata
2087c478bd9Sstevel@tonic-gate #pragma redefine_extname t_strerror	_xti_strerror
2097c478bd9Sstevel@tonic-gate #pragma redefine_extname t_sync		_xti_sync
2107c478bd9Sstevel@tonic-gate #pragma redefine_extname t_sysconf	_xti_sysconf
2117c478bd9Sstevel@tonic-gate #pragma redefine_extname t_unbind	_xti_unbind
2127c478bd9Sstevel@tonic-gate 
2137c478bd9Sstevel@tonic-gate #else /* __PRAGMA_REDEFINE_EXTNAME */
2147c478bd9Sstevel@tonic-gate 
2157c478bd9Sstevel@tonic-gate #if defined(_XOPEN_SOURCE) && !defined(_XPG5)
2167c478bd9Sstevel@tonic-gate #define	t_accept	_xti_accept
2177c478bd9Sstevel@tonic-gate #else
2187c478bd9Sstevel@tonic-gate #define	t_accept	_xti_xns5_accept
2197c478bd9Sstevel@tonic-gate #endif
2207c478bd9Sstevel@tonic-gate #define	t_alloc		_xti_alloc
2217c478bd9Sstevel@tonic-gate #define	t_bind		_xti_bind
2227c478bd9Sstevel@tonic-gate #define	t_close		_xti_close
2237c478bd9Sstevel@tonic-gate #define	t_connect	_xti_connect
2247c478bd9Sstevel@tonic-gate #define	t_error		_xti_error
2257c478bd9Sstevel@tonic-gate #define	t_free		_xti_free
2267c478bd9Sstevel@tonic-gate #define	t_getinfo	_xti_getinfo
2277c478bd9Sstevel@tonic-gate #define	t_getstate	_xti_getstate
2287c478bd9Sstevel@tonic-gate #define	t_getprotaddr	_xti_getprotaddr
2297c478bd9Sstevel@tonic-gate #define	t_listen	_xti_listen
2307c478bd9Sstevel@tonic-gate #define	t_look		_xti_look
2317c478bd9Sstevel@tonic-gate #define	t_open		_xti_open
2327c478bd9Sstevel@tonic-gate #define	t_optmgmt	_xti_optmgmt
2337c478bd9Sstevel@tonic-gate #define	t_rcv		_xti_rcv
2347c478bd9Sstevel@tonic-gate #define	t_rcvconnect	_xti_rcvconnect
2357c478bd9Sstevel@tonic-gate #define	t_rcvdis	_xti_rcvdis
2367c478bd9Sstevel@tonic-gate #define	t_rcvrel	_xti_rcvrel
2377c478bd9Sstevel@tonic-gate #define	t_rcvreldata	_xti_rcvreldata
2387c478bd9Sstevel@tonic-gate #define	t_rcvudata	_xti_rcvudata
2397c478bd9Sstevel@tonic-gate #define	t_rcvuderr	_xti_rcvuderr
2407c478bd9Sstevel@tonic-gate #define	t_rcvv		_xti_rcvv
2417c478bd9Sstevel@tonic-gate #define	t_rcvvudata	_xti_rcvvudata
2427c478bd9Sstevel@tonic-gate #if defined(_XOPEN_SOURCE) && !defined(_XPG5)
2437c478bd9Sstevel@tonic-gate #define	t_snd		_xti_snd
2447c478bd9Sstevel@tonic-gate #else
2457c478bd9Sstevel@tonic-gate #define	t_snd		_xti_xns5_snd
2467c478bd9Sstevel@tonic-gate #endif
2477c478bd9Sstevel@tonic-gate #define	t_snddis	_xti_snddis
2487c478bd9Sstevel@tonic-gate #define	t_sndrel	_xti_sndrel
2497c478bd9Sstevel@tonic-gate #define	t_sndreldata	_xti_sndreldata
2507c478bd9Sstevel@tonic-gate #define	t_sndudata	_xti_sndudata
2517c478bd9Sstevel@tonic-gate #define	t_sndv		_xti_sndv
2527c478bd9Sstevel@tonic-gate #define	t_sndvudata	_xti_sndvudata
2537c478bd9Sstevel@tonic-gate #define	t_strerror	_xti_strerror
2547c478bd9Sstevel@tonic-gate #define	t_sync		_xti_sync
2557c478bd9Sstevel@tonic-gate #define	t_sysconf	_xti_sysconf
2567c478bd9Sstevel@tonic-gate #define	t_unbind	_xti_unbind
2577c478bd9Sstevel@tonic-gate 
2587c478bd9Sstevel@tonic-gate #endif /* __PRAGMA_REDEFINE_EXTNAME */
2597c478bd9Sstevel@tonic-gate 
2607c478bd9Sstevel@tonic-gate /*
2617c478bd9Sstevel@tonic-gate  * protocol specific service limits
2627c478bd9Sstevel@tonic-gate  */
2637c478bd9Sstevel@tonic-gate struct t_info {
2647c478bd9Sstevel@tonic-gate 	t_scalar_t addr;	/* max size of protocol address		*/
2657c478bd9Sstevel@tonic-gate 	t_scalar_t options;	/* max size of protocol options		*/
2667c478bd9Sstevel@tonic-gate 	t_scalar_t tsdu;	/* max size of max transport service	*/
2677c478bd9Sstevel@tonic-gate 				/* data unit	*/
2687c478bd9Sstevel@tonic-gate 	t_scalar_t etsdu;	/* max size of max expedited tsdu	*/
2697c478bd9Sstevel@tonic-gate 	t_scalar_t connect;	/* max data for connection primitives	*/
2707c478bd9Sstevel@tonic-gate 	t_scalar_t discon;	/* max data for disconnect primitives	*/
2717c478bd9Sstevel@tonic-gate 	t_scalar_t servtype;	/* provider service type		*/
2727c478bd9Sstevel@tonic-gate 	t_scalar_t flags;	/* other info about transport providers	*/
2737c478bd9Sstevel@tonic-gate };
2747c478bd9Sstevel@tonic-gate 
2757c478bd9Sstevel@tonic-gate /*
2767c478bd9Sstevel@tonic-gate  * Flags definitions for the t_info structure
2777c478bd9Sstevel@tonic-gate  */
2787c478bd9Sstevel@tonic-gate #define	T_SENDZERO	0x001	/* supports 0-length TSDUs */
2797c478bd9Sstevel@tonic-gate #define	T_ORDRELDATA	0x002	/* supports orderly release data */
2807c478bd9Sstevel@tonic-gate 
2817c478bd9Sstevel@tonic-gate /*
2827c478bd9Sstevel@tonic-gate  * netbuf structure
2837c478bd9Sstevel@tonic-gate  */
2847c478bd9Sstevel@tonic-gate struct netbuf {
2857c478bd9Sstevel@tonic-gate 	unsigned int maxlen;
2867c478bd9Sstevel@tonic-gate 	unsigned int len;
2877c478bd9Sstevel@tonic-gate #if defined(_XPG5)
2887c478bd9Sstevel@tonic-gate 	void *buf;
2897c478bd9Sstevel@tonic-gate #else
2907c478bd9Sstevel@tonic-gate 	char *buf;
2917c478bd9Sstevel@tonic-gate #endif
2927c478bd9Sstevel@tonic-gate };
2937c478bd9Sstevel@tonic-gate 
2947c478bd9Sstevel@tonic-gate /*
2957c478bd9Sstevel@tonic-gate  * t_opthdr structure
2967c478bd9Sstevel@tonic-gate  */
2977c478bd9Sstevel@tonic-gate struct t_opthdr {
2987c478bd9Sstevel@tonic-gate 	t_uscalar_t	len;	/* total length of option */
2997c478bd9Sstevel@tonic-gate 	t_uscalar_t	level;	/* protocol level */
3007c478bd9Sstevel@tonic-gate 	t_uscalar_t	name;	/* option name */
3017c478bd9Sstevel@tonic-gate 	t_uscalar_t	status;	/* status value */
3027c478bd9Sstevel@tonic-gate 	/* followed by option value */
3037c478bd9Sstevel@tonic-gate };
3047c478bd9Sstevel@tonic-gate 
3057c478bd9Sstevel@tonic-gate /*
3067c478bd9Sstevel@tonic-gate  * t_bind - format of the addres and options arguments of bind
3077c478bd9Sstevel@tonic-gate  */
3087c478bd9Sstevel@tonic-gate 
3097c478bd9Sstevel@tonic-gate struct t_bind {
3107c478bd9Sstevel@tonic-gate 	struct netbuf	addr;
3117c478bd9Sstevel@tonic-gate 	unsigned int	qlen;
3127c478bd9Sstevel@tonic-gate };
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate /*
3157c478bd9Sstevel@tonic-gate  * options management
3167c478bd9Sstevel@tonic-gate  */
3177c478bd9Sstevel@tonic-gate struct t_optmgmt {
3187c478bd9Sstevel@tonic-gate 	struct netbuf	opt;
3197c478bd9Sstevel@tonic-gate 	t_scalar_t	flags;
3207c478bd9Sstevel@tonic-gate };
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate /*
3237c478bd9Sstevel@tonic-gate  * disconnect structure
3247c478bd9Sstevel@tonic-gate  */
3257c478bd9Sstevel@tonic-gate struct t_discon {
3267c478bd9Sstevel@tonic-gate 	struct netbuf	udata;		/* user data		*/
3277c478bd9Sstevel@tonic-gate 	int		reason;		/* reason code		*/
3287c478bd9Sstevel@tonic-gate 	int		sequence;	/* sequence number	*/
3297c478bd9Sstevel@tonic-gate };
3307c478bd9Sstevel@tonic-gate 
3317c478bd9Sstevel@tonic-gate /*
3327c478bd9Sstevel@tonic-gate  * call structure
3337c478bd9Sstevel@tonic-gate  */
3347c478bd9Sstevel@tonic-gate struct t_call {
3357c478bd9Sstevel@tonic-gate 	struct netbuf	addr;		/*  address		*/
3367c478bd9Sstevel@tonic-gate 	struct netbuf	opt;		/* options		*/
3377c478bd9Sstevel@tonic-gate 	struct netbuf	udata;		/* user data		*/
3387c478bd9Sstevel@tonic-gate 	int		sequence;	/* sequence number	*/
3397c478bd9Sstevel@tonic-gate };
3407c478bd9Sstevel@tonic-gate 
3417c478bd9Sstevel@tonic-gate /*
3427c478bd9Sstevel@tonic-gate  * data gram structure
3437c478bd9Sstevel@tonic-gate  */
3447c478bd9Sstevel@tonic-gate struct t_unitdata {
3457c478bd9Sstevel@tonic-gate 	struct netbuf	addr;		/*  address		*/
3467c478bd9Sstevel@tonic-gate 	struct netbuf	opt;		/* options		*/
3477c478bd9Sstevel@tonic-gate 	struct netbuf	udata;		/* user data		*/
3487c478bd9Sstevel@tonic-gate };
3497c478bd9Sstevel@tonic-gate 
3507c478bd9Sstevel@tonic-gate /*
3517c478bd9Sstevel@tonic-gate  * unitdata error
3527c478bd9Sstevel@tonic-gate  */
3537c478bd9Sstevel@tonic-gate struct t_uderr {
3547c478bd9Sstevel@tonic-gate 	struct netbuf	addr;		/* address		*/
355*6e270ca8SMarcel Telka 	struct netbuf	opt;		/* options		*/
3567c478bd9Sstevel@tonic-gate 	t_scalar_t	error;		/* error code		*/
3577c478bd9Sstevel@tonic-gate };
3587c478bd9Sstevel@tonic-gate 
3597c478bd9Sstevel@tonic-gate /*
3607c478bd9Sstevel@tonic-gate  * The following are structure types used when dynamically
3617c478bd9Sstevel@tonic-gate  * allocating the above structures via t_structalloc().
3627c478bd9Sstevel@tonic-gate  */
3637c478bd9Sstevel@tonic-gate #define	T_BIND		1		/* struct t_bind	*/
3647c478bd9Sstevel@tonic-gate #define	T_OPTMGMT	2		/* struct t_optmgmt	*/
3657c478bd9Sstevel@tonic-gate #define	T_CALL		3		/* struct t_call	*/
3667c478bd9Sstevel@tonic-gate #define	T_DIS		4		/* struct t_discon	*/
3677c478bd9Sstevel@tonic-gate #define	T_UNITDATA	5		/* struct t_unitdata	*/
3687c478bd9Sstevel@tonic-gate #define	T_UDERROR	6		/* struct t_uderr	*/
3697c478bd9Sstevel@tonic-gate #define	T_INFO		7		/* struct t_info	*/
3707c478bd9Sstevel@tonic-gate 
3717c478bd9Sstevel@tonic-gate /*
3727c478bd9Sstevel@tonic-gate  * The following bits specify which fields of the above
3737c478bd9Sstevel@tonic-gate  * structures should be allocated by t_alloc().
3747c478bd9Sstevel@tonic-gate  */
3757c478bd9Sstevel@tonic-gate #define	T_ADDR	0x01			/* address		*/
3767c478bd9Sstevel@tonic-gate #define	T_OPT	0x02			/* options		*/
3777c478bd9Sstevel@tonic-gate #define	T_UDATA	0x04			/* user data		*/
3787c478bd9Sstevel@tonic-gate #define	T_ALL	0xffff			/* all the above fields */
3797c478bd9Sstevel@tonic-gate 
3807c478bd9Sstevel@tonic-gate 
3817c478bd9Sstevel@tonic-gate /*
3827c478bd9Sstevel@tonic-gate  * the following are the states for the user
3837c478bd9Sstevel@tonic-gate  */
3847c478bd9Sstevel@tonic-gate 
3857c478bd9Sstevel@tonic-gate #define	T_UNINIT	0		/* uninitialized		*/
3867c478bd9Sstevel@tonic-gate #define	T_UNBND		1		/* unbound			*/
3877c478bd9Sstevel@tonic-gate #define	T_IDLE		2		/* idle				*/
388*6e270ca8SMarcel Telka #define	T_OUTCON	3		/* outgoing connection pending	*/
3897c478bd9Sstevel@tonic-gate #define	T_INCON		4		/* incoming connection pending	*/
3907c478bd9Sstevel@tonic-gate #define	T_DATAXFER	5		/* data transfer		*/
3917c478bd9Sstevel@tonic-gate #define	T_OUTREL	6		/* outgoing release pending	*/
3927c478bd9Sstevel@tonic-gate #define	T_INREL		7		/* incoming release pending	*/
3937c478bd9Sstevel@tonic-gate 
3947c478bd9Sstevel@tonic-gate 
3957c478bd9Sstevel@tonic-gate #define	T_UNUSED		-1
3967c478bd9Sstevel@tonic-gate #define	T_NULL			0
3977c478bd9Sstevel@tonic-gate 
3987c478bd9Sstevel@tonic-gate 
3997c478bd9Sstevel@tonic-gate /*
4007c478bd9Sstevel@tonic-gate  * Allegedly general purpose constant. Used with (and needs to be bitwise
4017c478bd9Sstevel@tonic-gate  * distinct from) T_NOPROTECT, T_PASSIVEPROTECT and T_ACTIVEPROTECT
4027c478bd9Sstevel@tonic-gate  * which are OSI specific constants but part of this header (defined
4037c478bd9Sstevel@tonic-gate  * in <xti_osi.h> which is included in this header for historical
4047c478bd9Sstevel@tonic-gate  * XTI specification reasons)
4057c478bd9Sstevel@tonic-gate  */
4067c478bd9Sstevel@tonic-gate #define	T_ABSREQ		0x8000
4077c478bd9Sstevel@tonic-gate 
4087c478bd9Sstevel@tonic-gate /*
4097c478bd9Sstevel@tonic-gate  * General definitions for option management
4107c478bd9Sstevel@tonic-gate  *
4117c478bd9Sstevel@tonic-gate  * Multiple variable length options may be packed into a single option buffer.
4127c478bd9Sstevel@tonic-gate  * Each option consists of a fixed length header followed by variable length
4137c478bd9Sstevel@tonic-gate  * data. The header and data will have to be aligned at appropriate
4147c478bd9Sstevel@tonic-gate  * boundaries. The following macros are used to manipulate the options.
4157c478bd9Sstevel@tonic-gate  *
4167c478bd9Sstevel@tonic-gate  * Helper Macros: Macros beginning with a "_T" prefix are helper macros.
4177c478bd9Sstevel@tonic-gate  *		  They are private, not meant for public use and may
4187c478bd9Sstevel@tonic-gate  *		  change without notice. Users  should use the standard
4197c478bd9Sstevel@tonic-gate  *		  XTI macros beginning with "T_" prefix
4207c478bd9Sstevel@tonic-gate  */
4217c478bd9Sstevel@tonic-gate 
4227c478bd9Sstevel@tonic-gate #define	_T_OPT_HALIGN_SZ	(sizeof (t_scalar_t)) /* Hdr Alignment size  */
4237c478bd9Sstevel@tonic-gate #define	_T_OPT_DALIGN_SZ	(sizeof (int32_t))    /* Data Alignment size */
4247c478bd9Sstevel@tonic-gate #define	_T_OPTHDR_SZ	(sizeof (struct t_opthdr))
4257c478bd9Sstevel@tonic-gate 
4267c478bd9Sstevel@tonic-gate /* Align 'x' to the next 'asize' alignment  boundary */
4277c478bd9Sstevel@tonic-gate #define	_T_OPT_ALIGN(x, asize) \
4287c478bd9Sstevel@tonic-gate 	(((uintptr_t)(x) + ((asize) - 1L)) & ~((asize) - 1L))
4297c478bd9Sstevel@tonic-gate 
4307c478bd9Sstevel@tonic-gate /* Align 'x' to the next header alignment  boundary */
4317c478bd9Sstevel@tonic-gate #define	_T_OPTHDR_ALIGN(x) \
4327c478bd9Sstevel@tonic-gate 	(_T_OPT_ALIGN((x), _T_OPT_HALIGN_SZ))
4337c478bd9Sstevel@tonic-gate 
4347c478bd9Sstevel@tonic-gate /* Align 'x' to the next data alignment  boundary */
4357c478bd9Sstevel@tonic-gate #define	_T_OPTDATA_ALIGN(x) \
4367c478bd9Sstevel@tonic-gate 	(_T_OPT_ALIGN((x), _T_OPT_DALIGN_SZ))
4377c478bd9Sstevel@tonic-gate 
4387c478bd9Sstevel@tonic-gate /*
4397c478bd9Sstevel@tonic-gate  * struct t_opthdr *T_OPT_FIRSTHDR(struct netbuf *nbp):
4407c478bd9Sstevel@tonic-gate  *     Get aligned start of first option header
4417c478bd9Sstevel@tonic-gate  *
4427c478bd9Sstevel@tonic-gate  * unsigned char *T_OPT_DATA(struct t_opthdr *tohp):
4437c478bd9Sstevel@tonic-gate  *     Get aligned start of data part after option header
4447c478bd9Sstevel@tonic-gate  *
4457c478bd9Sstevel@tonic-gate  * struct t_opthdr *T_OPT_NEXTHDR(struct netbuf *nbp, struct t_opthdr *tohp):
446*6e270ca8SMarcel Telka  *	Skip to next option header
4477c478bd9Sstevel@tonic-gate  */
4487c478bd9Sstevel@tonic-gate 
4497c478bd9Sstevel@tonic-gate #define	T_OPT_FIRSTHDR(nbp)    \
4507c478bd9Sstevel@tonic-gate 	((nbp)->len >= _T_OPTHDR_SZ ? (struct t_opthdr *)(nbp)->buf : \
4517c478bd9Sstevel@tonic-gate 	    (struct t_opthdr *)0)
4527c478bd9Sstevel@tonic-gate 
4537c478bd9Sstevel@tonic-gate #define	T_OPT_DATA(tohp)	\
4547c478bd9Sstevel@tonic-gate 	((unsigned char *)_T_OPTDATA_ALIGN((char *)(tohp) + _T_OPTHDR_SZ))
4557c478bd9Sstevel@tonic-gate 
4567c478bd9Sstevel@tonic-gate #define	_T_NEXTHDR(pbuf, buflen, popt) \
4577c478bd9Sstevel@tonic-gate 	(((char *)_T_OPTHDR_ALIGN((char *)(popt) + (popt)->len) + \
4587c478bd9Sstevel@tonic-gate 	    _T_OPTHDR_SZ <= ((char *)(pbuf) + (buflen))) ? \
4597c478bd9Sstevel@tonic-gate 	(struct t_opthdr *)((char *)_T_OPTHDR_ALIGN((char *)(popt) + \
4607c478bd9Sstevel@tonic-gate 	    (popt)->len)) : (struct t_opthdr *)0)
4617c478bd9Sstevel@tonic-gate 
4627c478bd9Sstevel@tonic-gate #define	T_OPT_NEXTHDR(nbp, tohp)   (_T_NEXTHDR((nbp)->buf, (nbp)->len, (tohp)))
4637c478bd9Sstevel@tonic-gate 
4647c478bd9Sstevel@tonic-gate #if !defined(_XPG5)
4657c478bd9Sstevel@tonic-gate /*
4667c478bd9Sstevel@tonic-gate  * The macros below are meant for older applications for compatibility.
4677c478bd9Sstevel@tonic-gate  * New applications should use the T_OPT_* macros, obviating the need
4687c478bd9Sstevel@tonic-gate  * to explicitly use the T_ALIGN macro
4697c478bd9Sstevel@tonic-gate  *
4707c478bd9Sstevel@tonic-gate  * struct t_opthdr *OPT_NEXTHDR(char *pbuf, unsigned int buflen,
4717c478bd9Sstevel@tonic-gate  *                               struct t_opthdr *popt):
4727c478bd9Sstevel@tonic-gate  *         Skip to next option header
4737c478bd9Sstevel@tonic-gate  */
4747c478bd9Sstevel@tonic-gate #define	T_ALIGN(p)	(((uintptr_t)(p) + (sizeof (t_scalar_t) - 1))\
4757c478bd9Sstevel@tonic-gate 					& ~(sizeof (t_scalar_t) - 1))
4767c478bd9Sstevel@tonic-gate #define	OPT_NEXTHDR(pbuf, buflen, popt)	(_T_NEXTHDR((pbuf), (buflen), (popt)))
4777c478bd9Sstevel@tonic-gate #endif
4787c478bd9Sstevel@tonic-gate 
4797c478bd9Sstevel@tonic-gate /*
4807c478bd9Sstevel@tonic-gate  * XTI LIBRARY FUNCTIONS
4817c478bd9Sstevel@tonic-gate  */
4827c478bd9Sstevel@tonic-gate 
4837c478bd9Sstevel@tonic-gate #if defined(_XOPEN_SOURCE) && !defined(_XPG5)
4847c478bd9Sstevel@tonic-gate extern int t_accept(int, int, struct t_call *);
4857c478bd9Sstevel@tonic-gate extern char *t_alloc(int, int, int);
4867c478bd9Sstevel@tonic-gate extern int t_bind(int, struct t_bind *, struct t_bind *);
4877c478bd9Sstevel@tonic-gate extern int t_connect(int, struct t_call *, struct t_call *);
4887c478bd9Sstevel@tonic-gate extern int t_error(char *);
4897c478bd9Sstevel@tonic-gate extern int t_free(char *, int);
4907c478bd9Sstevel@tonic-gate extern int t_open(char *, int, struct t_info *);
4917c478bd9Sstevel@tonic-gate extern int t_optmgmt(int, struct t_optmgmt *, struct t_optmgmt *);
4927c478bd9Sstevel@tonic-gate extern int t_rcv(int, char *, unsigned int, int *);
4937c478bd9Sstevel@tonic-gate extern int t_snd(int, char *, unsigned int, int);
4947c478bd9Sstevel@tonic-gate extern int t_snddis(int, struct t_call *);
4957c478bd9Sstevel@tonic-gate extern int t_sndudata(int, struct t_unitdata *);
4967c478bd9Sstevel@tonic-gate extern char *t_strerror(int);
4977c478bd9Sstevel@tonic-gate #else
4987c478bd9Sstevel@tonic-gate extern int t_accept(int, int, const struct t_call *);
4997c478bd9Sstevel@tonic-gate extern void *t_alloc(int, int, int);
5007c478bd9Sstevel@tonic-gate extern int t_bind(int, const struct t_bind *, struct t_bind *);
5017c478bd9Sstevel@tonic-gate extern int t_connect(int, const struct t_call *, struct t_call *);
5027c478bd9Sstevel@tonic-gate extern int t_error(const char *);
5037c478bd9Sstevel@tonic-gate extern int t_free(void *, int);
5047c478bd9Sstevel@tonic-gate extern int t_open(const char *, int, struct t_info *);
5057c478bd9Sstevel@tonic-gate extern int t_optmgmt(int, const struct t_optmgmt *, struct t_optmgmt *);
5067c478bd9Sstevel@tonic-gate extern int t_rcv(int, void *, unsigned int, int *);
5077c478bd9Sstevel@tonic-gate extern int t_snd(int, void *, unsigned int, int);
5087c478bd9Sstevel@tonic-gate extern int t_snddis(int, const struct t_call *);
5097c478bd9Sstevel@tonic-gate extern int t_sndudata(int, const struct t_unitdata *);
5107c478bd9Sstevel@tonic-gate extern const char *t_strerror(int);
5117c478bd9Sstevel@tonic-gate #endif
5127c478bd9Sstevel@tonic-gate extern int t_close(int);
5137c478bd9Sstevel@tonic-gate extern int t_getinfo(int, struct t_info *);
5147c478bd9Sstevel@tonic-gate extern int t_getstate(int);
5157c478bd9Sstevel@tonic-gate extern int t_getprotaddr(int, struct t_bind *, struct t_bind *);
5167c478bd9Sstevel@tonic-gate extern int t_listen(int, struct t_call *);
5177c478bd9Sstevel@tonic-gate extern int t_look(int);
5187c478bd9Sstevel@tonic-gate extern int t_rcvconnect(int, struct t_call *);
5197c478bd9Sstevel@tonic-gate extern int t_rcvdis(int, struct t_discon *);
5207c478bd9Sstevel@tonic-gate extern int t_rcvrel(int);
5217c478bd9Sstevel@tonic-gate extern int t_rcvreldata(int, struct t_discon *);
5227c478bd9Sstevel@tonic-gate extern int t_rcvudata(int, struct t_unitdata *, int *);
5237c478bd9Sstevel@tonic-gate extern int t_rcvuderr(int, struct t_uderr *);
5247c478bd9Sstevel@tonic-gate extern int t_rcvv(int, struct t_iovec *, unsigned int, int *);
5257c478bd9Sstevel@tonic-gate extern int t_rcvvudata(int, struct t_unitdata *, struct t_iovec *,
5267c478bd9Sstevel@tonic-gate 	unsigned int, int *);
5277c478bd9Sstevel@tonic-gate extern int t_sndrel(int);
5287c478bd9Sstevel@tonic-gate extern int t_sndreldata(int, struct t_discon *);
5297c478bd9Sstevel@tonic-gate extern int t_sndv(int, const struct t_iovec *,  unsigned int, int);
5307c478bd9Sstevel@tonic-gate extern int t_sndvudata(int, struct t_unitdata *, struct t_iovec *,
5317c478bd9Sstevel@tonic-gate 	unsigned int);
5327c478bd9Sstevel@tonic-gate extern int t_sync(int);
5337c478bd9Sstevel@tonic-gate extern int t_sysconf(int);
5347c478bd9Sstevel@tonic-gate extern int t_unbind(int);
5357c478bd9Sstevel@tonic-gate 
5367c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
5377c478bd9Sstevel@tonic-gate }
5387c478bd9Sstevel@tonic-gate #endif
5397c478bd9Sstevel@tonic-gate 
5407c478bd9Sstevel@tonic-gate #endif	/* _XTI_H */
541