1*8329232eSGordon Ross /* 2*8329232eSGordon Ross * CDDL HEADER START 3*8329232eSGordon Ross * 4*8329232eSGordon Ross * The contents of this file are subject to the terms of the 5*8329232eSGordon Ross * Common Development and Distribution License, Version 1.0 only 6*8329232eSGordon Ross * (the "License"). You may not use this file except in compliance 7*8329232eSGordon Ross * with the License. 8*8329232eSGordon Ross * 9*8329232eSGordon Ross * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*8329232eSGordon Ross * or http://www.opensolaris.org/os/licensing. 11*8329232eSGordon Ross * See the License for the specific language governing permissions 12*8329232eSGordon Ross * and limitations under the License. 13*8329232eSGordon Ross * 14*8329232eSGordon Ross * When distributing Covered Code, include this CDDL HEADER in each 15*8329232eSGordon Ross * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*8329232eSGordon Ross * If applicable, add the following below this CDDL HEADER, with the 17*8329232eSGordon Ross * fields enclosed by brackets "[]" replaced with your own identifying 18*8329232eSGordon Ross * information: Portions Copyright [yyyy] [name of copyright owner] 19*8329232eSGordon Ross * 20*8329232eSGordon Ross * CDDL HEADER END 21*8329232eSGordon Ross */ 22*8329232eSGordon Ross /* 23*8329232eSGordon Ross * Copyright 2014 Garrett D'Amore <garrett@damore.org> 24*8329232eSGordon Ross */ 25*8329232eSGordon Ross /* Copyright (c) 1996 Sun Microsystems, Inc. */ 26*8329232eSGordon Ross /* All Rights Reserved */ 27*8329232eSGordon Ross /* 28*8329232eSGordon Ross * Copyright 2017 Nexenta Systems, Inc. All rights reserved. 29*8329232eSGordon Ross */ 30*8329232eSGordon Ross 31*8329232eSGordon Ross #ifndef _XTI_H 32*8329232eSGordon Ross #define _XTI_H 33*8329232eSGordon Ross 34*8329232eSGordon Ross #include <sys/types.h> 35*8329232eSGordon Ross 36*8329232eSGordon Ross /* 37*8329232eSGordon Ross * The following include file has declarations needed by both the kernel 38*8329232eSGordon Ross * level transport providers and the user level library. This file includes 39*8329232eSGordon Ross * it to expose its namespaces to XTI user level interface. 40*8329232eSGordon Ross */ 41*8329232eSGordon Ross #include <sys/tpicommon.h> 42*8329232eSGordon Ross 43*8329232eSGordon Ross /* 44*8329232eSGordon Ross * Include XTI interface level options management declarations 45*8329232eSGordon Ross */ 46*8329232eSGordon Ross #include <sys/xti_xtiopt.h> 47*8329232eSGordon Ross 48*8329232eSGordon Ross #if !defined(_XPG5) 49*8329232eSGordon Ross 50*8329232eSGordon Ross /* 51*8329232eSGordon Ross * Include declarations related to OSI transport and management data 52*8329232eSGordon Ross * structures, and the Internet Protocol Suite. 53*8329232eSGordon Ross * Note: The older Unix95/XNS4 XTI spec required these to be 54*8329232eSGordon Ross * exposed through the generic interface header. 55*8329232eSGordon Ross */ 56*8329232eSGordon Ross #include <sys/xti_osi.h> 57*8329232eSGordon Ross #include <sys/xti_inet.h> 58*8329232eSGordon Ross 59*8329232eSGordon Ross #endif /* !defined(_XPG5) */ 60*8329232eSGordon Ross 61*8329232eSGordon Ross #ifdef __cplusplus 62*8329232eSGordon Ross extern "C" { 63*8329232eSGordon Ross #endif 64*8329232eSGordon Ross 65*8329232eSGordon Ross /* 66*8329232eSGordon Ross * The following t_errno error codes are included in the namespace by 67*8329232eSGordon Ross * inclusion of <sys/tpicommon.h> above. The english language error strings 68*8329232eSGordon Ross * associated with the error values are reproduced here for easy reference. 69*8329232eSGordon Ross * 70*8329232eSGordon Ross * Error Value Error message string 71*8329232eSGordon Ross * ---- ----- -------------------- 72*8329232eSGordon Ross * TBADADDR 1 Incorrect address format 73*8329232eSGordon Ross * TBADOPT 2 Incorrect options format 74*8329232eSGordon Ross * TACCES 3 Illegal permissions 75*8329232eSGordon Ross * TBADF 4 Illegal file descriptor 76*8329232eSGordon Ross * TNOADDR 5 Couldn't allocate address 77*8329232eSGordon Ross * TOUTSTATE 6 Routine will place interface out of state 78*8329232eSGordon Ross * TBADSEQ 7 Illegal called/calling sequence number 79*8329232eSGordon Ross * TSYSERR 8 System error 80*8329232eSGordon Ross * TLOOK 9 An event requires attention 81*8329232eSGordon Ross * TBADDATA 10 Illegal amount of data 82*8329232eSGordon Ross * TBUFOVFLW 11 Buffer not large enough 83*8329232eSGordon Ross * TFLOW 12 Can't send message - (blocked) 84*8329232eSGordon Ross * TNODATA 13 No message currently available 85*8329232eSGordon Ross * TNODIS 14 Disconnect message not found 86*8329232eSGordon Ross * TNOUDERR 15 Unitdata error message not found 87*8329232eSGordon Ross * TBADFLAG 16 Incorrect flags specified 88*8329232eSGordon Ross * TNOREL 17 Orderly release message not found 89*8329232eSGordon Ross * TNOTSUPPORT 18 Primitive not supported by provider 90*8329232eSGordon Ross * TSTATECHNG 19 State is in process of changing 91*8329232eSGordon Ross * TNOSTRUCTYPE 20 Unsupported structure type requested 92*8329232eSGordon Ross * TBADNAME 21 Invalid transport provider name 93*8329232eSGordon Ross * TBADQLEN 22 Listener queue length limit is zero 94*8329232eSGordon Ross * TADDRBUSY 23 Transport address is in use 95*8329232eSGordon Ross * TINDOUT 24 Outstanding connection indications 96*8329232eSGordon Ross * TPROVMISMATCH 25 Listener-acceptor transport provider mismatch 97*8329232eSGordon Ross * TRESQLEN 26 Connection acceptor has listen queue length 98*8329232eSGordon Ross * limit greater than zero 99*8329232eSGordon Ross * TRESADDR 27 Connection acceptor-listener addresses not 100*8329232eSGordon Ross * same but required by transport 101*8329232eSGordon Ross * TQFULL 28 Incoming connection queue is full 102*8329232eSGordon Ross * TPROTO 29 Protocol error on transport primitive 103*8329232eSGordon Ross * 104*8329232eSGordon Ross */ 105*8329232eSGordon Ross 106*8329232eSGordon Ross /* 107*8329232eSGordon Ross * The following are the events returned by t_look 108*8329232eSGordon Ross */ 109*8329232eSGordon Ross #define T_LISTEN 0x0001 /* connection indication received */ 110*8329232eSGordon Ross #define T_CONNECT 0x0002 /* connect confirmation received */ 111*8329232eSGordon Ross #define T_DATA 0x0004 /* normal data received */ 112*8329232eSGordon Ross #define T_EXDATA 0x0008 /* expedited data received */ 113*8329232eSGordon Ross #define T_DISCONNECT 0x0010 /* disconnect received */ 114*8329232eSGordon Ross #define T_UDERR 0x0040 /* data gram error indication */ 115*8329232eSGordon Ross #define T_ORDREL 0x0080 /* orderly release indication */ 116*8329232eSGordon Ross #define T_GODATA 0x0100 /* sending normal data is again possible */ 117*8329232eSGordon Ross #define T_GOEXDATA 0x0200 /* sending expedited data is again possible */ 118*8329232eSGordon Ross 119*8329232eSGordon Ross /* 120*8329232eSGordon Ross * Flags for data primitives 121*8329232eSGordon Ross */ 122*8329232eSGordon Ross #define T_MORE 0x001 /* more data */ 123*8329232eSGordon Ross #define T_EXPEDITED 0x002 /* expedited data */ 124*8329232eSGordon Ross #define T_PUSH 0x004 /* send data immediately */ 125*8329232eSGordon Ross 126*8329232eSGordon Ross /* 127*8329232eSGordon Ross * XTI error return 128*8329232eSGordon Ross */ 129*8329232eSGordon Ross #if defined(_REENTRANT) || defined(_TS_ERRNO) 130*8329232eSGordon Ross extern int *__t_errno(); 131*8329232eSGordon Ross #define t_errno (*(__t_errno())) 132*8329232eSGordon Ross #else 133*8329232eSGordon Ross #error "extern int t_errno?" 134*8329232eSGordon Ross #endif /* defined(_REENTRANT) || defined(_TS_ERRNO) */ 135*8329232eSGordon Ross 136*8329232eSGordon Ross 137*8329232eSGordon Ross /* 138*8329232eSGordon Ross * The following are for t_sysconf() 139*8329232eSGordon Ross */ 140*8329232eSGordon Ross #ifndef T_IOV_MAX 141*8329232eSGordon Ross #define T_IOV_MAX 16 /* Maximum number of scatter/gather buffers */ 142*8329232eSGordon Ross #endif /* Should be <= IOV_MAX */ 143*8329232eSGordon Ross 144*8329232eSGordon Ross #ifndef _SC_T_IOV_MAX 145*8329232eSGordon Ross #define _SC_T_IOV_MAX 79 /* Should be same in <unistd.h> for use by */ 146*8329232eSGordon Ross #endif /* sysconf() */ 147*8329232eSGordon Ross 148*8329232eSGordon Ross struct t_iovec { 149*8329232eSGordon Ross void *iov_base; 150*8329232eSGordon Ross size_t iov_len; 151*8329232eSGordon Ross }; 152*8329232eSGordon Ross 153*8329232eSGordon Ross /* 154*8329232eSGordon Ross * Translate source level interface to binary entry point names. 155*8329232eSGordon Ross * 156*8329232eSGordon Ross * Note: This is done to maintain co-existence of TLI and XTI 157*8329232eSGordon Ross * interfaces which have identical names for most functions but 158*8329232eSGordon Ross * different semantics. The XTI names are moved to the different 159*8329232eSGordon Ross * prefix space in the ABI. The #ifdef is required to make use of 160*8329232eSGordon Ross * of the compiler feature to allow redefinition of external names 161*8329232eSGordon Ross * where available. Otherwise a simple #define is used when this 162*8329232eSGordon Ross * header is used with other compilers. 163*8329232eSGordon Ross * The use of #define also has the effect of renaming all names (not 164*8329232eSGordon Ross * just function names) to the new name. The TLI function names 165*8329232eSGordon Ross * (e.g. t_bind) can have identical names for structure names 166*8329232eSGordon Ross * (e.g struct t_bind). Therefore, this redefinition of names needs 167*8329232eSGordon Ross * to be before all structure and function name declarations in the header. 168*8329232eSGordon Ross */ 169*8329232eSGordon Ross 170*8329232eSGordon Ross #ifdef __PRAGMA_REDEFINE_EXTNAME 171*8329232eSGordon Ross 172*8329232eSGordon Ross #if defined(_XOPEN_SOURCE) && !defined(_XPG5) 173*8329232eSGordon Ross #pragma redefine_extname t_accept _xti_accept 174*8329232eSGordon Ross #else 175*8329232eSGordon Ross #pragma redefine_extname t_accept _xti_xns5_accept 176*8329232eSGordon Ross #endif 177*8329232eSGordon Ross #pragma redefine_extname t_alloc _xti_alloc 178*8329232eSGordon Ross #pragma redefine_extname t_bind _xti_bind 179*8329232eSGordon Ross #pragma redefine_extname t_close _xti_close 180*8329232eSGordon Ross #pragma redefine_extname t_connect _xti_connect 181*8329232eSGordon Ross #pragma redefine_extname t_error _xti_error 182*8329232eSGordon Ross #pragma redefine_extname t_free _xti_free 183*8329232eSGordon Ross #pragma redefine_extname t_getinfo _xti_getinfo 184*8329232eSGordon Ross #pragma redefine_extname t_getstate _xti_getstate 185*8329232eSGordon Ross #pragma redefine_extname t_getprotaddr _xti_getprotaddr 186*8329232eSGordon Ross #pragma redefine_extname t_listen _xti_listen 187*8329232eSGordon Ross #pragma redefine_extname t_look _xti_look 188*8329232eSGordon Ross #pragma redefine_extname t_open _xti_open 189*8329232eSGordon Ross #pragma redefine_extname t_optmgmt _xti_optmgmt 190*8329232eSGordon Ross #pragma redefine_extname t_rcv _xti_rcv 191*8329232eSGordon Ross #pragma redefine_extname t_rcvconnect _xti_rcvconnect 192*8329232eSGordon Ross #pragma redefine_extname t_rcvdis _xti_rcvdis 193*8329232eSGordon Ross #pragma redefine_extname t_rcvrel _xti_rcvrel 194*8329232eSGordon Ross #pragma redefine_extname t_rcvreldata _xti_rcvreldata 195*8329232eSGordon Ross #pragma redefine_extname t_rcvudata _xti_rcvudata 196*8329232eSGordon Ross #pragma redefine_extname t_rcvuderr _xti_rcvuderr 197*8329232eSGordon Ross #pragma redefine_extname t_rcvv _xti_rcvv 198*8329232eSGordon Ross #pragma redefine_extname t_rcvvudata _xti_rcvvudata 199*8329232eSGordon Ross #if defined(_XOPEN_SOURCE) && !defined(_XPG5) 200*8329232eSGordon Ross #pragma redefine_extname t_snd _xti_snd 201*8329232eSGordon Ross #else 202*8329232eSGordon Ross #pragma redefine_extname t_snd _xti_xns5_snd 203*8329232eSGordon Ross #endif 204*8329232eSGordon Ross #pragma redefine_extname t_snddis _xti_snddis 205*8329232eSGordon Ross #pragma redefine_extname t_sndrel _xti_sndrel 206*8329232eSGordon Ross #pragma redefine_extname t_sndreldata _xti_sndreldata 207*8329232eSGordon Ross #pragma redefine_extname t_sndudata _xti_sndudata 208*8329232eSGordon Ross #pragma redefine_extname t_sndv _xti_sndv 209*8329232eSGordon Ross #pragma redefine_extname t_sndvudata _xti_sndvudata 210*8329232eSGordon Ross #pragma redefine_extname t_strerror _xti_strerror 211*8329232eSGordon Ross #pragma redefine_extname t_sync _xti_sync 212*8329232eSGordon Ross #pragma redefine_extname t_sysconf _xti_sysconf 213*8329232eSGordon Ross #pragma redefine_extname t_unbind _xti_unbind 214*8329232eSGordon Ross 215*8329232eSGordon Ross #else /* __PRAGMA_REDEFINE_EXTNAME */ 216*8329232eSGordon Ross 217*8329232eSGordon Ross #if defined(_XOPEN_SOURCE) && !defined(_XPG5) 218*8329232eSGordon Ross #define t_accept _xti_accept 219*8329232eSGordon Ross #else 220*8329232eSGordon Ross #define t_accept _xti_xns5_accept 221*8329232eSGordon Ross #endif 222*8329232eSGordon Ross #define t_alloc _xti_alloc 223*8329232eSGordon Ross #define t_bind(a,b,c) _xti_bind(a,b,c) 224*8329232eSGordon Ross #define t_close _xti_close 225*8329232eSGordon Ross #define t_connect _xti_connect 226*8329232eSGordon Ross #define t_error _xti_error 227*8329232eSGordon Ross #define t_free _xti_free 228*8329232eSGordon Ross #define t_getinfo _xti_getinfo 229*8329232eSGordon Ross #define t_getstate _xti_getstate 230*8329232eSGordon Ross #define t_getprotaddr _xti_getprotaddr 231*8329232eSGordon Ross #define t_listen _xti_listen 232*8329232eSGordon Ross #define t_look _xti_look 233*8329232eSGordon Ross #define t_open _xti_open 234*8329232eSGordon Ross #define t_optmgmt(a,b,c) _xti_optmgmt(a,b,c) 235*8329232eSGordon Ross #define t_rcv _xti_rcv 236*8329232eSGordon Ross #define t_rcvconnect _xti_rcvconnect 237*8329232eSGordon Ross #define t_rcvdis _xti_rcvdis 238*8329232eSGordon Ross #define t_rcvrel _xti_rcvrel 239*8329232eSGordon Ross #define t_rcvreldata _xti_rcvreldata 240*8329232eSGordon Ross #define t_rcvudata _xti_rcvudata 241*8329232eSGordon Ross #define t_rcvuderr _xti_rcvuderr 242*8329232eSGordon Ross #define t_rcvv _xti_rcvv 243*8329232eSGordon Ross #define t_rcvvudata _xti_rcvvudata 244*8329232eSGordon Ross #if defined(_XOPEN_SOURCE) && !defined(_XPG5) 245*8329232eSGordon Ross #define t_snd _xti_snd 246*8329232eSGordon Ross #else 247*8329232eSGordon Ross #define t_snd _xti_xns5_snd 248*8329232eSGordon Ross #endif 249*8329232eSGordon Ross #define t_snddis _xti_snddis 250*8329232eSGordon Ross #define t_sndrel _xti_sndrel 251*8329232eSGordon Ross #define t_sndreldata _xti_sndreldata 252*8329232eSGordon Ross #define t_sndudata _xti_sndudata 253*8329232eSGordon Ross #define t_sndv _xti_sndv 254*8329232eSGordon Ross #define t_sndvudata _xti_sndvudata 255*8329232eSGordon Ross #define t_strerror _xti_strerror 256*8329232eSGordon Ross #define t_sync _xti_sync 257*8329232eSGordon Ross #define t_sysconf _xti_sysconf 258*8329232eSGordon Ross #define t_unbind _xti_unbind 259*8329232eSGordon Ross 260*8329232eSGordon Ross #endif /* __PRAGMA_REDEFINE_EXTNAME */ 261*8329232eSGordon Ross 262*8329232eSGordon Ross /* 263*8329232eSGordon Ross * All the rest of the standard xti.h removed because the structs: 264*8329232eSGordon Ross * netbuf, t_info, t_opthdr, t_optmgmt, t_bind, t_call, ... 265*8329232eSGordon Ross * all conflict with definitions in tiuser.h which we need 266*8329232eSGordon Ross * for the (simulated) kernel interfaces in fake_ktli.c. 267*8329232eSGordon Ross * 268*8329232eSGordon Ross * The XTI library functions below would normally be defined by 269*8329232eSGordon Ross * including tiuser.h after the defines above, which we can't. 270*8329232eSGordon Ross */ 271*8329232eSGordon Ross 272*8329232eSGordon Ross int _xti_accept(int, int, struct t_call *); 273*8329232eSGordon Ross int _xti_xns5_accept(int, int, struct t_call *); 274*8329232eSGordon Ross char *_xti_alloc(int, int, int); 275*8329232eSGordon Ross int _xti_bind(int, struct t_bind *, struct t_bind *); 276*8329232eSGordon Ross int _xti_close(int); 277*8329232eSGordon Ross int _xti_connect(int, struct t_call *, struct t_call *); 278*8329232eSGordon Ross int _xti_error(char *); 279*8329232eSGordon Ross int _xti_free(char *, int); 280*8329232eSGordon Ross int _xti_getinfo(int, struct t_info *); 281*8329232eSGordon Ross int _xti_getprotaddr(int, struct t_bind *, struct t_bind *); 282*8329232eSGordon Ross int _xti_getstate(int); 283*8329232eSGordon Ross int _xti_listen(int, struct t_call *); 284*8329232eSGordon Ross int _xti_look(int); 285*8329232eSGordon Ross int _xti_open(char *, int, struct t_info *); 286*8329232eSGordon Ross int _xti_optmgmt(int, struct t_optmgmt *, struct t_optmgmt *); 287*8329232eSGordon Ross int _xti_rcv(int, char *, unsigned int, int *); 288*8329232eSGordon Ross int _xti_rcvconnect(int, struct t_call *); 289*8329232eSGordon Ross int _xti_rcvdis(int, struct t_discon *); 290*8329232eSGordon Ross int _xti_rcvrel(int); 291*8329232eSGordon Ross int _xti_rcvreldata(int, struct t_discon *); 292*8329232eSGordon Ross int _xti_rcvudata(int, struct t_unitdata *, int *); 293*8329232eSGordon Ross int _xti_rcvuderr(int, struct t_uderr *); 294*8329232eSGordon Ross int _xti_rcvv(int, struct t_iovec *, unsigned int, int *); 295*8329232eSGordon Ross int _xti_rcvvudata(int, struct t_unitdata *, struct t_iovec *, 296*8329232eSGordon Ross unsigned int, int *); 297*8329232eSGordon Ross int _xti_snd(int, char *, unsigned int, int); 298*8329232eSGordon Ross int _xti_xns5_snd(int, char *, unsigned int, int); 299*8329232eSGordon Ross int _xti_snddis(int, struct t_call *); 300*8329232eSGordon Ross int _xti_sndrel(int); 301*8329232eSGordon Ross int _xti_sndreldata(int, struct t_discon *); 302*8329232eSGordon Ross int _xti_sndudata(int, struct t_unitdata *); 303*8329232eSGordon Ross int _xti_sndv(int, const struct t_iovec *, unsigned int, int); 304*8329232eSGordon Ross int _xti_sndvudata(int, struct t_unitdata *, struct t_iovec *, unsigned int); 305*8329232eSGordon Ross char *_xti_strerror(int); 306*8329232eSGordon Ross int _xti_sync(int); 307*8329232eSGordon Ross int _xti_sysconf(int); 308*8329232eSGordon Ross int _xti_unbind(int); 309*8329232eSGordon Ross 310*8329232eSGordon Ross #ifdef __cplusplus 311*8329232eSGordon Ross } 312*8329232eSGordon Ross #endif 313*8329232eSGordon Ross 314*8329232eSGordon Ross #endif /* _XTI_H */ 315