18329232Gordon Ross/*
28329232Gordon Ross * CDDL HEADER START
38329232Gordon Ross *
48329232Gordon Ross * The contents of this file are subject to the terms of the
58329232Gordon Ross * Common Development and Distribution License, Version 1.0 only
68329232Gordon Ross * (the "License").  You may not use this file except in compliance
78329232Gordon Ross * with the License.
88329232Gordon Ross *
98329232Gordon Ross * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
108329232Gordon Ross * or http://www.opensolaris.org/os/licensing.
118329232Gordon Ross * See the License for the specific language governing permissions
128329232Gordon Ross * and limitations under the License.
138329232Gordon Ross *
148329232Gordon Ross * When distributing Covered Code, include this CDDL HEADER in each
158329232Gordon Ross * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
168329232Gordon Ross * If applicable, add the following below this CDDL HEADER, with the
178329232Gordon Ross * fields enclosed by brackets "[]" replaced with your own identifying
188329232Gordon Ross * information: Portions Copyright [yyyy] [name of copyright owner]
198329232Gordon Ross *
208329232Gordon Ross * CDDL HEADER END
218329232Gordon Ross */
228329232Gordon Ross/*
238329232Gordon Ross * Copyright 2014 Garrett D'Amore <garrett@damore.org>
248329232Gordon Ross */
258329232Gordon Ross/*	Copyright (c) 1996 Sun Microsystems, Inc.	*/
268329232Gordon Ross/*	  All Rights Reserved	*/
278329232Gordon Ross/*
288329232Gordon Ross * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
298329232Gordon Ross */
308329232Gordon Ross
318329232Gordon Ross#ifndef _XTI_H
328329232Gordon Ross#define	_XTI_H
338329232Gordon Ross
348329232Gordon Ross#include <sys/types.h>
358329232Gordon Ross
368329232Gordon Ross/*
378329232Gordon Ross * The following include file has declarations needed by both the kernel
388329232Gordon Ross * level transport providers and the user level library. This file includes
398329232Gordon Ross * it to expose its namespaces to XTI user level interface.
408329232Gordon Ross */
418329232Gordon Ross#include <sys/tpicommon.h>
428329232Gordon Ross
438329232Gordon Ross/*
448329232Gordon Ross * Include XTI interface level options management declarations
458329232Gordon Ross */
468329232Gordon Ross#include <sys/xti_xtiopt.h>
478329232Gordon Ross
488329232Gordon Ross#if !defined(_XPG5)
498329232Gordon Ross
508329232Gordon Ross/*
518329232Gordon Ross * Include declarations related to OSI transport and management data
528329232Gordon Ross * structures, and the Internet Protocol Suite.
538329232Gordon Ross * Note: The older Unix95/XNS4 XTI spec required these to be
548329232Gordon Ross * exposed through the generic interface header.
558329232Gordon Ross */
568329232Gordon Ross#include <sys/xti_osi.h>
578329232Gordon Ross#include <sys/xti_inet.h>
588329232Gordon Ross
598329232Gordon Ross#endif /* !defined(_XPG5) */
608329232Gordon Ross
618329232Gordon Ross#ifdef	__cplusplus
628329232Gordon Rossextern "C" {
638329232Gordon Ross#endif
648329232Gordon Ross
658329232Gordon Ross/*
668329232Gordon Ross * The following t_errno error codes are included in the namespace by
678329232Gordon Ross * inclusion of <sys/tpicommon.h> above. The english language error strings
688329232Gordon Ross * associated with the error values are reproduced here for easy reference.
698329232Gordon Ross *
708329232Gordon Ross * Error		Value	Error message string
718329232Gordon Ross * ----			-----	--------------------
728329232Gordon Ross * TBADADDR		1	Incorrect address format
738329232Gordon Ross * TBADOPT		2	Incorrect options format
748329232Gordon Ross * TACCES		3	Illegal permissions
758329232Gordon Ross * TBADF		4	Illegal file descriptor
768329232Gordon Ross * TNOADDR		5	Couldn't allocate address
778329232Gordon Ross * TOUTSTATE		6	Routine will place interface out of state
788329232Gordon Ross * TBADSEQ		7	Illegal called/calling sequence number
798329232Gordon Ross * TSYSERR		8	System error
808329232Gordon Ross * TLOOK		9	An event requires attention
818329232Gordon Ross * TBADDATA		10	Illegal amount of data
828329232Gordon Ross * TBUFOVFLW		11	Buffer not large enough
838329232Gordon Ross * TFLOW		12	Can't send message - (blocked)
848329232Gordon Ross * TNODATA		13	No message currently available
858329232Gordon Ross * TNODIS		14	Disconnect message not found
868329232Gordon Ross * TNOUDERR		15	Unitdata error message not found
878329232Gordon Ross * TBADFLAG		16	Incorrect flags specified
888329232Gordon Ross * TNOREL		17	Orderly release message not found
898329232Gordon Ross * TNOTSUPPORT		18	Primitive not supported by provider
908329232Gordon Ross * TSTATECHNG		19	State is in process of changing
918329232Gordon Ross * TNOSTRUCTYPE		20	Unsupported structure type requested
928329232Gordon Ross * TBADNAME		21	Invalid transport provider name
938329232Gordon Ross * TBADQLEN		22	Listener queue length limit is zero
948329232Gordon Ross * TADDRBUSY		23	Transport address is in use
958329232Gordon Ross * TINDOUT		24	Outstanding connection indications
968329232Gordon Ross * TPROVMISMATCH	25	Listener-acceptor transport provider mismatch
978329232Gordon Ross * TRESQLEN		26	Connection acceptor has listen queue length
988329232Gordon Ross *				limit greater than zero
998329232Gordon Ross * TRESADDR		27	Connection acceptor-listener addresses not
1008329232Gordon Ross *				same but required by transport
1018329232Gordon Ross * TQFULL		28	Incoming connection queue is full
1028329232Gordon Ross * TPROTO		29	Protocol error on transport primitive
1038329232Gordon Ross *
1048329232Gordon Ross */
1058329232Gordon Ross
1068329232Gordon Ross/*
1078329232Gordon Ross * The following are the events returned by t_look
1088329232Gordon Ross */
1098329232Gordon Ross#define	T_LISTEN	0x0001	/* connection indication received	*/
1108329232Gordon Ross#define	T_CONNECT	0x0002	/* connect confirmation received	*/
1118329232Gordon Ross#define	T_DATA		0x0004	/* normal data received			*/
1128329232Gordon Ross#define	T_EXDATA	0x0008	/* expedited data received		*/
1138329232Gordon Ross#define	T_DISCONNECT	0x0010	/* disconnect received			*/
1148329232Gordon Ross#define	T_UDERR		0x0040	/* data gram error indication		*/
1158329232Gordon Ross#define	T_ORDREL	0x0080	/* orderly release indication		*/
1168329232Gordon Ross#define	T_GODATA	0x0100	/* sending normal data is again possible */
1178329232Gordon Ross#define	T_GOEXDATA	0x0200	/* sending expedited data is again possible */
1188329232Gordon Ross
1198329232Gordon Ross/*
1208329232Gordon Ross * Flags for data primitives
1218329232Gordon Ross */
1228329232Gordon Ross#define	T_MORE		0x001	/* more data		*/
1238329232Gordon Ross#define	T_EXPEDITED	0x002	/* expedited data	*/
1248329232Gordon Ross#define	T_PUSH		0x004	/* send data immediately */
1258329232Gordon Ross
1268329232Gordon Ross/*
1278329232Gordon Ross * XTI error return
1288329232Gordon Ross */
1298329232Gordon Ross#if defined(_REENTRANT) || defined(_TS_ERRNO)
1308329232Gordon Rossextern int	*__t_errno();
1318329232Gordon Ross#define	t_errno (*(__t_errno()))
1328329232Gordon Ross#else
1338329232Gordon Ross#error "extern int t_errno?"
1348329232Gordon Ross#endif	/* defined(_REENTRANT) || defined(_TS_ERRNO) */
1358329232Gordon Ross
1368329232Gordon Ross
1378329232Gordon Ross/*
1388329232Gordon Ross * The following are for t_sysconf()
1398329232Gordon Ross */
1408329232Gordon Ross#ifndef T_IOV_MAX
1418329232Gordon Ross#define	T_IOV_MAX	16	/* Maximum number of scatter/gather buffers */
1428329232Gordon Ross#endif				/* Should be <= IOV_MAX */
1438329232Gordon Ross
1448329232Gordon Ross#ifndef _SC_T_IOV_MAX
1458329232Gordon Ross#define	_SC_T_IOV_MAX	79	/* Should be same in <unistd.h> for use by */
1468329232Gordon Ross#endif				/* sysconf() */
1478329232Gordon Ross
1488329232Gordon Rossstruct t_iovec {
1498329232Gordon Ross	void	*iov_base;
1508329232Gordon Ross	size_t	iov_len;
1518329232Gordon Ross};
1528329232Gordon Ross
1538329232Gordon Ross/*
1548329232Gordon Ross * Translate source level interface to binary entry point names.
1558329232Gordon Ross *
1568329232Gordon Ross * Note: This is done to maintain co-existence of TLI and XTI
1578329232Gordon Ross * interfaces which have identical names for most functions but
1588329232Gordon Ross * different semantics. The XTI names are moved to the different
1598329232Gordon Ross * prefix space in the ABI. The #ifdef is required to make use of
1608329232Gordon Ross * of the compiler feature to allow redefinition of external names
1618329232Gordon Ross * where available. Otherwise a simple #define is used when this
1628329232Gordon Ross * header is used with other compilers.
1638329232Gordon Ross * The use of #define also has the effect of renaming all names (not
1648329232Gordon Ross * just function names) to the new name. The TLI function names
1658329232Gordon Ross * (e.g. t_bind) can have identical names for structure names
1668329232Gordon Ross * (e.g struct t_bind). Therefore, this redefinition of names needs
1678329232Gordon Ross * to be before all structure and function name declarations in the header.
1688329232Gordon Ross */
1698329232Gordon Ross
1708329232Gordon Ross#ifdef __PRAGMA_REDEFINE_EXTNAME
1718329232Gordon Ross
1728329232Gordon Ross#if defined(_XOPEN_SOURCE) && !defined(_XPG5)
1738329232Gordon Ross#pragma redefine_extname t_accept	_xti_accept
1748329232Gordon Ross#else
1758329232Gordon Ross#pragma redefine_extname t_accept	_xti_xns5_accept
1768329232Gordon Ross#endif
1778329232Gordon Ross#pragma redefine_extname t_alloc	_xti_alloc
1788329232Gordon Ross#pragma redefine_extname t_bind		_xti_bind
1798329232Gordon Ross#pragma redefine_extname t_close	_xti_close
1808329232Gordon Ross#pragma redefine_extname t_connect	_xti_connect
1818329232Gordon Ross#pragma redefine_extname t_error	_xti_error
1828329232Gordon Ross#pragma redefine_extname t_free		_xti_free
1838329232Gordon Ross#pragma redefine_extname t_getinfo	_xti_getinfo
1848329232Gordon Ross#pragma redefine_extname t_getstate	_xti_getstate
1858329232Gordon Ross#pragma redefine_extname t_getprotaddr	_xti_getprotaddr
1868329232Gordon Ross#pragma redefine_extname t_listen	_xti_listen
1878329232Gordon Ross#pragma redefine_extname t_look		_xti_look
1888329232Gordon Ross#pragma redefine_extname t_open		_xti_open
1898329232Gordon Ross#pragma redefine_extname t_optmgmt	_xti_optmgmt
1908329232Gordon Ross#pragma redefine_extname t_rcv		_xti_rcv
1918329232Gordon Ross#pragma redefine_extname t_rcvconnect	_xti_rcvconnect
1928329232Gordon Ross#pragma redefine_extname t_rcvdis	_xti_rcvdis
1938329232Gordon Ross#pragma redefine_extname t_rcvrel	_xti_rcvrel
1948329232Gordon Ross#pragma redefine_extname t_rcvreldata	_xti_rcvreldata
1958329232Gordon Ross#pragma redefine_extname t_rcvudata	_xti_rcvudata
1968329232Gordon Ross#pragma redefine_extname t_rcvuderr	_xti_rcvuderr
1978329232Gordon Ross#pragma redefine_extname t_rcvv		_xti_rcvv
1988329232Gordon Ross#pragma redefine_extname t_rcvvudata	_xti_rcvvudata
1998329232Gordon Ross#if defined(_XOPEN_SOURCE) && !defined(_XPG5)
2008329232Gordon Ross#pragma redefine_extname t_snd		_xti_snd
2018329232Gordon Ross#else
2028329232Gordon Ross#pragma redefine_extname t_snd		_xti_xns5_snd
2038329232Gordon Ross#endif
2048329232Gordon Ross#pragma redefine_extname t_snddis	_xti_snddis
2058329232Gordon Ross#pragma redefine_extname t_sndrel	_xti_sndrel
2068329232Gordon Ross#pragma redefine_extname t_sndreldata	_xti_sndreldata
2078329232Gordon Ross#pragma redefine_extname t_sndudata	_xti_sndudata
2088329232Gordon Ross#pragma redefine_extname t_sndv		_xti_sndv
2098329232Gordon Ross#pragma redefine_extname t_sndvudata	_xti_sndvudata
2108329232Gordon Ross#pragma redefine_extname t_strerror	_xti_strerror
2118329232Gordon Ross#pragma redefine_extname t_sync		_xti_sync
2128329232Gordon Ross#pragma redefine_extname t_sysconf	_xti_sysconf
2138329232Gordon Ross#pragma redefine_extname t_unbind	_xti_unbind
2148329232Gordon Ross
2158329232Gordon Ross#else /* __PRAGMA_REDEFINE_EXTNAME */
2168329232Gordon Ross
2178329232Gordon Ross#if defined(_XOPEN_SOURCE) && !defined(_XPG5)
2188329232Gordon Ross#define	t_accept	_xti_accept
2198329232Gordon Ross#else
2208329232Gordon Ross#define	t_accept	_xti_xns5_accept
2218329232Gordon Ross#endif
2228329232Gordon Ross#define	t_alloc		_xti_alloc
2238329232Gordon Ross#define	t_bind(a,b,c)	_xti_bind(a,b,c)
2248329232Gordon Ross#define	t_close		_xti_close
2258329232Gordon Ross#define	t_connect	_xti_connect
2268329232Gordon Ross#define	t_error		_xti_error
2278329232Gordon Ross#define	t_free		_xti_free
2288329232Gordon Ross#define	t_getinfo	_xti_getinfo
2298329232Gordon Ross#define	t_getstate	_xti_getstate
2308329232Gordon Ross#define	t_getprotaddr	_xti_getprotaddr
2318329232Gordon Ross#define	t_listen	_xti_listen
2328329232Gordon Ross#define	t_look		_xti_look
2338329232Gordon Ross#define	t_open		_xti_open
2348329232Gordon Ross#define	t_optmgmt(a,b,c)	_xti_optmgmt(a,b,c)
2358329232Gordon Ross#define	t_rcv		_xti_rcv
2368329232Gordon Ross#define	t_rcvconnect	_xti_rcvconnect
2378329232Gordon Ross#define	t_rcvdis	_xti_rcvdis
2388329232Gordon Ross#define	t_rcvrel	_xti_rcvrel
2398329232Gordon Ross#define	t_rcvreldata	_xti_rcvreldata
2408329232Gordon Ross#define	t_rcvudata	_xti_rcvudata
2418329232Gordon Ross#define	t_rcvuderr	_xti_rcvuderr
2428329232Gordon Ross#define	t_rcvv		_xti_rcvv
2438329232Gordon Ross#define	t_rcvvudata	_xti_rcvvudata
2448329232Gordon Ross#if defined(_XOPEN_SOURCE) && !defined(_XPG5)
2458329232Gordon Ross#define	t_snd		_xti_snd
2468329232Gordon Ross#else
2478329232Gordon Ross#define	t_snd		_xti_xns5_snd
2488329232Gordon Ross#endif
2498329232Gordon Ross#define	t_snddis	_xti_snddis
2508329232Gordon Ross#define	t_sndrel	_xti_sndrel
2518329232Gordon Ross#define	t_sndreldata	_xti_sndreldata
2528329232Gordon Ross#define	t_sndudata	_xti_sndudata
2538329232Gordon Ross#define	t_sndv		_xti_sndv
2548329232Gordon Ross#define	t_sndvudata	_xti_sndvudata
2558329232Gordon Ross#define	t_strerror	_xti_strerror
2568329232Gordon Ross#define	t_sync		_xti_sync
2578329232Gordon Ross#define	t_sysconf	_xti_sysconf
2588329232Gordon Ross#define	t_unbind	_xti_unbind
2598329232Gordon Ross
2608329232Gordon Ross#endif /* __PRAGMA_REDEFINE_EXTNAME */
2618329232Gordon Ross
2628329232Gordon Ross/*
2638329232Gordon Ross * All the rest of the standard xti.h removed because the structs:
2648329232Gordon Ross * netbuf, t_info, t_opthdr, t_optmgmt, t_bind, t_call, ...
2658329232Gordon Ross * all conflict with definitions in tiuser.h which we need
2668329232Gordon Ross * for the (simulated) kernel interfaces in fake_ktli.c.
2678329232Gordon Ross *
2688329232Gordon Ross * The XTI library functions below would normally be defined by
2698329232Gordon Ross * including tiuser.h after the defines above, which we can't.
2708329232Gordon Ross */
2718329232Gordon Ross
2728329232Gordon Rossint _xti_accept(int, int, struct t_call *);
2738329232Gordon Rossint _xti_xns5_accept(int, int, struct t_call *);
2748329232Gordon Rosschar *_xti_alloc(int, int, int);
2758329232Gordon Rossint _xti_bind(int, struct t_bind *, struct t_bind *);
2768329232Gordon Rossint _xti_close(int);
2778329232Gordon Rossint _xti_connect(int, struct t_call *, struct t_call *);
2788329232Gordon Rossint _xti_error(char *);
2798329232Gordon Rossint _xti_free(char *, int);
2808329232Gordon Rossint _xti_getinfo(int, struct t_info *);
2818329232Gordon Rossint _xti_getprotaddr(int, struct t_bind *, struct t_bind *);
2828329232Gordon Rossint _xti_getstate(int);
2838329232Gordon Rossint _xti_listen(int, struct t_call *);
2848329232Gordon Rossint _xti_look(int);
2858329232Gordon Rossint _xti_open(char *, int, struct t_info *);
2868329232Gordon Rossint _xti_optmgmt(int, struct t_optmgmt *, struct t_optmgmt *);
2878329232Gordon Rossint _xti_rcv(int, char *, unsigned int, int *);
2888329232Gordon Rossint _xti_rcvconnect(int, struct t_call *);
2898329232Gordon Rossint _xti_rcvdis(int, struct t_discon *);
2908329232Gordon Rossint _xti_rcvrel(int);
2918329232Gordon Rossint _xti_rcvreldata(int, struct t_discon *);
2928329232Gordon Rossint _xti_rcvudata(int, struct t_unitdata *, int *);
2938329232Gordon Rossint _xti_rcvuderr(int, struct t_uderr *);
2948329232Gordon Rossint _xti_rcvv(int, struct t_iovec *, unsigned int, int *);
2958329232Gordon Rossint _xti_rcvvudata(int, struct t_unitdata *, struct t_iovec *,
2968329232Gordon Ross    unsigned int, int *);
2978329232Gordon Rossint _xti_snd(int, char *, unsigned int, int);
2988329232Gordon Rossint _xti_xns5_snd(int, char *, unsigned int, int);
2998329232Gordon Rossint _xti_snddis(int, struct t_call *);
3008329232Gordon Rossint _xti_sndrel(int);
3018329232Gordon Rossint _xti_sndreldata(int, struct t_discon *);
3028329232Gordon Rossint _xti_sndudata(int, struct t_unitdata *);
3038329232Gordon Rossint _xti_sndv(int, const struct t_iovec *, unsigned int, int);
3048329232Gordon Rossint _xti_sndvudata(int, struct t_unitdata *, struct t_iovec *, unsigned int);
3058329232Gordon Rosschar *_xti_strerror(int);
3068329232Gordon Rossint _xti_sync(int);
3078329232Gordon Rossint _xti_sysconf(int);
3088329232Gordon Rossint _xti_unbind(int);
3098329232Gordon Ross
3108329232Gordon Ross#ifdef	__cplusplus
3118329232Gordon Ross}
3128329232Gordon Ross#endif
3138329232Gordon Ross
3148329232Gordon Ross#endif	/* _XTI_H */
315