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