1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* Copyright (c) 1996 Sun Microsystems, Inc. */ 23*0Sstevel@tonic-gate /* All Rights Reserved */ 24*0Sstevel@tonic-gate 25*0Sstevel@tonic-gate 26*0Sstevel@tonic-gate #ifndef _XTI_H 27*0Sstevel@tonic-gate #define _XTI_H 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate #include <sys/types.h> 32*0Sstevel@tonic-gate 33*0Sstevel@tonic-gate /* 34*0Sstevel@tonic-gate * The following include file has declarations needed by both the kernel 35*0Sstevel@tonic-gate * level transport providers and the user level library. This file includes 36*0Sstevel@tonic-gate * it to expose its namespaces to XTI user level interface. 37*0Sstevel@tonic-gate */ 38*0Sstevel@tonic-gate #include <sys/tpicommon.h> 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate /* 41*0Sstevel@tonic-gate * Include XTI interface level options management declarations 42*0Sstevel@tonic-gate */ 43*0Sstevel@tonic-gate #include <sys/xti_xtiopt.h> 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gate #if !defined(_XPG5) 46*0Sstevel@tonic-gate 47*0Sstevel@tonic-gate /* 48*0Sstevel@tonic-gate * Include declarations related to OSI transport and management data 49*0Sstevel@tonic-gate * structures, and the Internet Protocol Suite. 50*0Sstevel@tonic-gate * Note: The older Unix95/XNS4 XTI spec required these to be 51*0Sstevel@tonic-gate * exposed through the generic interface header. 52*0Sstevel@tonic-gate */ 53*0Sstevel@tonic-gate #include <sys/xti_osi.h> 54*0Sstevel@tonic-gate #include <sys/xti_inet.h> 55*0Sstevel@tonic-gate 56*0Sstevel@tonic-gate #endif /* !defined(_XPG5) */ 57*0Sstevel@tonic-gate 58*0Sstevel@tonic-gate #ifdef __cplusplus 59*0Sstevel@tonic-gate extern "C" { 60*0Sstevel@tonic-gate #endif 61*0Sstevel@tonic-gate 62*0Sstevel@tonic-gate /* 63*0Sstevel@tonic-gate * The following t_errno error codes are included in the namespace by 64*0Sstevel@tonic-gate * inclusion of <sys/tpicommon.h> above. The english language error strings 65*0Sstevel@tonic-gate * associated with the error values are reproduced here for easy reference. 66*0Sstevel@tonic-gate * 67*0Sstevel@tonic-gate * Error Value Error message string 68*0Sstevel@tonic-gate * ---- ----- -------------------- 69*0Sstevel@tonic-gate * TBADADDR 1 Incorrect address format 70*0Sstevel@tonic-gate * TBADOPT 2 Incorrect options format 71*0Sstevel@tonic-gate * TACCES 3 Illegal permissions 72*0Sstevel@tonic-gate * TBADF 4 Illegal file descriptor 73*0Sstevel@tonic-gate * TNOADDR 5 Couldn't allocate address 74*0Sstevel@tonic-gate * TOUTSTATE 6 Routine will place interface out of state 75*0Sstevel@tonic-gate * TBADSEQ 7 Illegal called/calling sequence number 76*0Sstevel@tonic-gate * TSYSERR 8 System error 77*0Sstevel@tonic-gate * TLOOK 9 An event requires attention 78*0Sstevel@tonic-gate * TBADDATA 10 Illegal amount of data 79*0Sstevel@tonic-gate * TBUFOVFLW 11 Buffer not large enough 80*0Sstevel@tonic-gate * TFLOW 12 Can't send message - (blocked) 81*0Sstevel@tonic-gate * TNODATA 13 No message currently available 82*0Sstevel@tonic-gate * TNODIS 14 Disconnect message not found 83*0Sstevel@tonic-gate * TNOUDERR 15 Unitdata error message not found 84*0Sstevel@tonic-gate * TBADFLAG 16 Incorrect flags specified 85*0Sstevel@tonic-gate * TNOREL 17 Orderly release message not found 86*0Sstevel@tonic-gate * TNOTSUPPORT 18 Primitive not supported by provider 87*0Sstevel@tonic-gate * TSTATECHNG 19 State is in process of changing 88*0Sstevel@tonic-gate * TNOSTRUCTYPE 20 Unsupported structure type requested 89*0Sstevel@tonic-gate * TBADNAME 21 Invalid transport provider name 90*0Sstevel@tonic-gate * TBADQLEN 22 Listener queue length limit is zero 91*0Sstevel@tonic-gate * TADDRBUSY 23 Transport address is in use 92*0Sstevel@tonic-gate * TINDOUT 24 Outstanding connection indications 93*0Sstevel@tonic-gate * TPROVMISMATCH 25 Listener-acceptor transport provider mismatch 94*0Sstevel@tonic-gate * TRESQLEN 26 Connection acceptor has listen queue length 95*0Sstevel@tonic-gate * limit greater than zero 96*0Sstevel@tonic-gate * TRESADDR 27 Connection acceptor-listener addresses not 97*0Sstevel@tonic-gate * same but required by transport 98*0Sstevel@tonic-gate * TQFULL 28 Incoming connection queue is full 99*0Sstevel@tonic-gate * TPROTO 29 Protocol error on transport primitive 100*0Sstevel@tonic-gate * 101*0Sstevel@tonic-gate */ 102*0Sstevel@tonic-gate 103*0Sstevel@tonic-gate /* 104*0Sstevel@tonic-gate * The following are the events returned by t_look 105*0Sstevel@tonic-gate */ 106*0Sstevel@tonic-gate #define T_LISTEN 0x0001 /* connection indication received */ 107*0Sstevel@tonic-gate #define T_CONNECT 0x0002 /* connect confirmation received */ 108*0Sstevel@tonic-gate #define T_DATA 0x0004 /* normal data received */ 109*0Sstevel@tonic-gate #define T_EXDATA 0x0008 /* expedited data received */ 110*0Sstevel@tonic-gate #define T_DISCONNECT 0x0010 /* disconnect received */ 111*0Sstevel@tonic-gate #define T_UDERR 0x0040 /* data gram error indication */ 112*0Sstevel@tonic-gate #define T_ORDREL 0x0080 /* orderly release indication */ 113*0Sstevel@tonic-gate #define T_GODATA 0x0100 /* sending normal data is again possible */ 114*0Sstevel@tonic-gate #define T_GOEXDATA 0x0200 /* sending expedited data is again possible */ 115*0Sstevel@tonic-gate 116*0Sstevel@tonic-gate /* 117*0Sstevel@tonic-gate * Flags for data primitives 118*0Sstevel@tonic-gate */ 119*0Sstevel@tonic-gate #define T_MORE 0x001 /* more data */ 120*0Sstevel@tonic-gate #define T_EXPEDITED 0x002 /* expedited data */ 121*0Sstevel@tonic-gate #define T_PUSH 0x004 /* send data immediately */ 122*0Sstevel@tonic-gate 123*0Sstevel@tonic-gate /* 124*0Sstevel@tonic-gate * XTI error return 125*0Sstevel@tonic-gate */ 126*0Sstevel@tonic-gate #if defined(_REENTRANT) || defined(_TS_ERRNO) 127*0Sstevel@tonic-gate extern int *__t_errno(); 128*0Sstevel@tonic-gate #define t_errno (*(__t_errno())) 129*0Sstevel@tonic-gate #else 130*0Sstevel@tonic-gate extern int t_errno; 131*0Sstevel@tonic-gate #endif /* defined(_REENTRANT) || defined(_TS_ERRNO) */ 132*0Sstevel@tonic-gate 133*0Sstevel@tonic-gate 134*0Sstevel@tonic-gate /* 135*0Sstevel@tonic-gate * The following are for t_sysconf() 136*0Sstevel@tonic-gate */ 137*0Sstevel@tonic-gate #ifndef T_IOV_MAX 138*0Sstevel@tonic-gate #define T_IOV_MAX 16 /* Maximum number of scatter/gather buffers */ 139*0Sstevel@tonic-gate #endif /* Should be <= IOV_MAX */ 140*0Sstevel@tonic-gate 141*0Sstevel@tonic-gate #ifndef _SC_T_IOV_MAX 142*0Sstevel@tonic-gate #define _SC_T_IOV_MAX 79 /* Should be same in <unistd.h> for use by */ 143*0Sstevel@tonic-gate #endif /* sysconf() */ 144*0Sstevel@tonic-gate 145*0Sstevel@tonic-gate struct t_iovec { 146*0Sstevel@tonic-gate void *iov_base; 147*0Sstevel@tonic-gate size_t iov_len; 148*0Sstevel@tonic-gate }; 149*0Sstevel@tonic-gate 150*0Sstevel@tonic-gate /* 151*0Sstevel@tonic-gate * Translate source level interface to binary entry point names. 152*0Sstevel@tonic-gate * 153*0Sstevel@tonic-gate * Note: This is done to maintain co-existence of TLI and XTI 154*0Sstevel@tonic-gate * interfaces which have identical names for most functions but 155*0Sstevel@tonic-gate * different semantics. The XTI names are moved to the different 156*0Sstevel@tonic-gate * prefix space in the ABI. The #ifdef is required to make use of 157*0Sstevel@tonic-gate * of the compiler feature to allow redefinition of external names 158*0Sstevel@tonic-gate * where available. Otherwise a simple #define is used when this 159*0Sstevel@tonic-gate * header is used with other compilers. 160*0Sstevel@tonic-gate * The use of #define also has the effect of renaming all names (not 161*0Sstevel@tonic-gate * just function names) to the new name. The TLI function names 162*0Sstevel@tonic-gate * (e.g. t_bind) can have identical names for structure names 163*0Sstevel@tonic-gate * (e.g struct t_bind). Therefore, this redefinition of names needs 164*0Sstevel@tonic-gate * to be before all structure and function name declarations in the header. 165*0Sstevel@tonic-gate */ 166*0Sstevel@tonic-gate 167*0Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME 168*0Sstevel@tonic-gate 169*0Sstevel@tonic-gate #if defined(_XOPEN_SOURCE) && !defined(_XPG5) 170*0Sstevel@tonic-gate #pragma redefine_extname t_accept _xti_accept 171*0Sstevel@tonic-gate #else 172*0Sstevel@tonic-gate #pragma redefine_extname t_accept _xti_xns5_accept 173*0Sstevel@tonic-gate #endif 174*0Sstevel@tonic-gate #pragma redefine_extname t_alloc _xti_alloc 175*0Sstevel@tonic-gate #pragma redefine_extname t_bind _xti_bind 176*0Sstevel@tonic-gate #pragma redefine_extname t_close _xti_close 177*0Sstevel@tonic-gate #pragma redefine_extname t_connect _xti_connect 178*0Sstevel@tonic-gate #pragma redefine_extname t_error _xti_error 179*0Sstevel@tonic-gate #pragma redefine_extname t_free _xti_free 180*0Sstevel@tonic-gate #pragma redefine_extname t_getinfo _xti_getinfo 181*0Sstevel@tonic-gate #pragma redefine_extname t_getstate _xti_getstate 182*0Sstevel@tonic-gate #pragma redefine_extname t_getprotaddr _xti_getprotaddr 183*0Sstevel@tonic-gate #pragma redefine_extname t_listen _xti_listen 184*0Sstevel@tonic-gate #pragma redefine_extname t_look _xti_look 185*0Sstevel@tonic-gate #pragma redefine_extname t_open _xti_open 186*0Sstevel@tonic-gate #pragma redefine_extname t_optmgmt _xti_optmgmt 187*0Sstevel@tonic-gate #pragma redefine_extname t_rcv _xti_rcv 188*0Sstevel@tonic-gate #pragma redefine_extname t_rcvconnect _xti_rcvconnect 189*0Sstevel@tonic-gate #pragma redefine_extname t_rcvdis _xti_rcvdis 190*0Sstevel@tonic-gate #pragma redefine_extname t_rcvrel _xti_rcvrel 191*0Sstevel@tonic-gate #pragma redefine_extname t_rcvreldata _xti_rcvreldata 192*0Sstevel@tonic-gate #pragma redefine_extname t_rcvudata _xti_rcvudata 193*0Sstevel@tonic-gate #pragma redefine_extname t_rcvuderr _xti_rcvuderr 194*0Sstevel@tonic-gate #pragma redefine_extname t_rcvv _xti_rcvv 195*0Sstevel@tonic-gate #pragma redefine_extname t_rcvvudata _xti_rcvvudata 196*0Sstevel@tonic-gate #if defined(_XOPEN_SOURCE) && !defined(_XPG5) 197*0Sstevel@tonic-gate #pragma redefine_extname t_snd _xti_snd 198*0Sstevel@tonic-gate #else 199*0Sstevel@tonic-gate #pragma redefine_extname t_snd _xti_xns5_snd 200*0Sstevel@tonic-gate #endif 201*0Sstevel@tonic-gate #pragma redefine_extname t_snddis _xti_snddis 202*0Sstevel@tonic-gate #pragma redefine_extname t_sndrel _xti_sndrel 203*0Sstevel@tonic-gate #pragma redefine_extname t_sndreldata _xti_sndreldata 204*0Sstevel@tonic-gate #pragma redefine_extname t_sndudata _xti_sndudata 205*0Sstevel@tonic-gate #pragma redefine_extname t_sndv _xti_sndv 206*0Sstevel@tonic-gate #pragma redefine_extname t_sndvudata _xti_sndvudata 207*0Sstevel@tonic-gate #pragma redefine_extname t_strerror _xti_strerror 208*0Sstevel@tonic-gate #pragma redefine_extname t_sync _xti_sync 209*0Sstevel@tonic-gate #pragma redefine_extname t_sysconf _xti_sysconf 210*0Sstevel@tonic-gate #pragma redefine_extname t_unbind _xti_unbind 211*0Sstevel@tonic-gate 212*0Sstevel@tonic-gate #else /* __PRAGMA_REDEFINE_EXTNAME */ 213*0Sstevel@tonic-gate 214*0Sstevel@tonic-gate #if defined(_XOPEN_SOURCE) && !defined(_XPG5) 215*0Sstevel@tonic-gate #define t_accept _xti_accept 216*0Sstevel@tonic-gate #else 217*0Sstevel@tonic-gate #define t_accept _xti_xns5_accept 218*0Sstevel@tonic-gate #endif 219*0Sstevel@tonic-gate #define t_alloc _xti_alloc 220*0Sstevel@tonic-gate #define t_bind _xti_bind 221*0Sstevel@tonic-gate #define t_close _xti_close 222*0Sstevel@tonic-gate #define t_connect _xti_connect 223*0Sstevel@tonic-gate #define t_error _xti_error 224*0Sstevel@tonic-gate #define t_free _xti_free 225*0Sstevel@tonic-gate #define t_getinfo _xti_getinfo 226*0Sstevel@tonic-gate #define t_getstate _xti_getstate 227*0Sstevel@tonic-gate #define t_getprotaddr _xti_getprotaddr 228*0Sstevel@tonic-gate #define t_listen _xti_listen 229*0Sstevel@tonic-gate #define t_look _xti_look 230*0Sstevel@tonic-gate #define t_open _xti_open 231*0Sstevel@tonic-gate #define t_optmgmt _xti_optmgmt 232*0Sstevel@tonic-gate #define t_rcv _xti_rcv 233*0Sstevel@tonic-gate #define t_rcvconnect _xti_rcvconnect 234*0Sstevel@tonic-gate #define t_rcvdis _xti_rcvdis 235*0Sstevel@tonic-gate #define t_rcvrel _xti_rcvrel 236*0Sstevel@tonic-gate #define t_rcvreldata _xti_rcvreldata 237*0Sstevel@tonic-gate #define t_rcvudata _xti_rcvudata 238*0Sstevel@tonic-gate #define t_rcvuderr _xti_rcvuderr 239*0Sstevel@tonic-gate #define t_rcvv _xti_rcvv 240*0Sstevel@tonic-gate #define t_rcvvudata _xti_rcvvudata 241*0Sstevel@tonic-gate #if defined(_XOPEN_SOURCE) && !defined(_XPG5) 242*0Sstevel@tonic-gate #define t_snd _xti_snd 243*0Sstevel@tonic-gate #else 244*0Sstevel@tonic-gate #define t_snd _xti_xns5_snd 245*0Sstevel@tonic-gate #endif 246*0Sstevel@tonic-gate #define t_snddis _xti_snddis 247*0Sstevel@tonic-gate #define t_sndrel _xti_sndrel 248*0Sstevel@tonic-gate #define t_sndreldata _xti_sndreldata 249*0Sstevel@tonic-gate #define t_sndudata _xti_sndudata 250*0Sstevel@tonic-gate #define t_sndv _xti_sndv 251*0Sstevel@tonic-gate #define t_sndvudata _xti_sndvudata 252*0Sstevel@tonic-gate #define t_strerror _xti_strerror 253*0Sstevel@tonic-gate #define t_sync _xti_sync 254*0Sstevel@tonic-gate #define t_sysconf _xti_sysconf 255*0Sstevel@tonic-gate #define t_unbind _xti_unbind 256*0Sstevel@tonic-gate 257*0Sstevel@tonic-gate #endif /* __PRAGMA_REDEFINE_EXTNAME */ 258*0Sstevel@tonic-gate 259*0Sstevel@tonic-gate /* 260*0Sstevel@tonic-gate * protocol specific service limits 261*0Sstevel@tonic-gate */ 262*0Sstevel@tonic-gate struct t_info { 263*0Sstevel@tonic-gate t_scalar_t addr; /* max size of protocol address */ 264*0Sstevel@tonic-gate t_scalar_t options; /* max size of protocol options */ 265*0Sstevel@tonic-gate t_scalar_t tsdu; /* max size of max transport service */ 266*0Sstevel@tonic-gate /* data unit */ 267*0Sstevel@tonic-gate t_scalar_t etsdu; /* max size of max expedited tsdu */ 268*0Sstevel@tonic-gate t_scalar_t connect; /* max data for connection primitives */ 269*0Sstevel@tonic-gate t_scalar_t discon; /* max data for disconnect primitives */ 270*0Sstevel@tonic-gate t_scalar_t servtype; /* provider service type */ 271*0Sstevel@tonic-gate t_scalar_t flags; /* other info about transport providers */ 272*0Sstevel@tonic-gate }; 273*0Sstevel@tonic-gate 274*0Sstevel@tonic-gate /* 275*0Sstevel@tonic-gate * Flags definitions for the t_info structure 276*0Sstevel@tonic-gate */ 277*0Sstevel@tonic-gate #define T_SENDZERO 0x001 /* supports 0-length TSDUs */ 278*0Sstevel@tonic-gate #define T_ORDRELDATA 0x002 /* supports orderly release data */ 279*0Sstevel@tonic-gate 280*0Sstevel@tonic-gate /* 281*0Sstevel@tonic-gate * netbuf structure 282*0Sstevel@tonic-gate */ 283*0Sstevel@tonic-gate struct netbuf { 284*0Sstevel@tonic-gate unsigned int maxlen; 285*0Sstevel@tonic-gate unsigned int len; 286*0Sstevel@tonic-gate #if defined(_XPG5) 287*0Sstevel@tonic-gate void *buf; 288*0Sstevel@tonic-gate #else 289*0Sstevel@tonic-gate char *buf; 290*0Sstevel@tonic-gate #endif 291*0Sstevel@tonic-gate }; 292*0Sstevel@tonic-gate 293*0Sstevel@tonic-gate /* 294*0Sstevel@tonic-gate * t_opthdr structure 295*0Sstevel@tonic-gate */ 296*0Sstevel@tonic-gate struct t_opthdr { 297*0Sstevel@tonic-gate t_uscalar_t len; /* total length of option */ 298*0Sstevel@tonic-gate t_uscalar_t level; /* protocol level */ 299*0Sstevel@tonic-gate t_uscalar_t name; /* option name */ 300*0Sstevel@tonic-gate t_uscalar_t status; /* status value */ 301*0Sstevel@tonic-gate /* followed by option value */ 302*0Sstevel@tonic-gate }; 303*0Sstevel@tonic-gate 304*0Sstevel@tonic-gate /* 305*0Sstevel@tonic-gate * t_bind - format of the addres and options arguments of bind 306*0Sstevel@tonic-gate */ 307*0Sstevel@tonic-gate 308*0Sstevel@tonic-gate struct t_bind { 309*0Sstevel@tonic-gate struct netbuf addr; 310*0Sstevel@tonic-gate unsigned int qlen; 311*0Sstevel@tonic-gate }; 312*0Sstevel@tonic-gate 313*0Sstevel@tonic-gate /* 314*0Sstevel@tonic-gate * options management 315*0Sstevel@tonic-gate */ 316*0Sstevel@tonic-gate struct t_optmgmt { 317*0Sstevel@tonic-gate struct netbuf opt; 318*0Sstevel@tonic-gate t_scalar_t flags; 319*0Sstevel@tonic-gate }; 320*0Sstevel@tonic-gate 321*0Sstevel@tonic-gate /* 322*0Sstevel@tonic-gate * disconnect structure 323*0Sstevel@tonic-gate */ 324*0Sstevel@tonic-gate struct t_discon { 325*0Sstevel@tonic-gate struct netbuf udata; /* user data */ 326*0Sstevel@tonic-gate int reason; /* reason code */ 327*0Sstevel@tonic-gate int sequence; /* sequence number */ 328*0Sstevel@tonic-gate }; 329*0Sstevel@tonic-gate 330*0Sstevel@tonic-gate /* 331*0Sstevel@tonic-gate * call structure 332*0Sstevel@tonic-gate */ 333*0Sstevel@tonic-gate struct t_call { 334*0Sstevel@tonic-gate struct netbuf addr; /* address */ 335*0Sstevel@tonic-gate struct netbuf opt; /* options */ 336*0Sstevel@tonic-gate struct netbuf udata; /* user data */ 337*0Sstevel@tonic-gate int sequence; /* sequence number */ 338*0Sstevel@tonic-gate }; 339*0Sstevel@tonic-gate 340*0Sstevel@tonic-gate /* 341*0Sstevel@tonic-gate * data gram structure 342*0Sstevel@tonic-gate */ 343*0Sstevel@tonic-gate struct t_unitdata { 344*0Sstevel@tonic-gate struct netbuf addr; /* address */ 345*0Sstevel@tonic-gate struct netbuf opt; /* options */ 346*0Sstevel@tonic-gate struct netbuf udata; /* user data */ 347*0Sstevel@tonic-gate }; 348*0Sstevel@tonic-gate 349*0Sstevel@tonic-gate /* 350*0Sstevel@tonic-gate * unitdata error 351*0Sstevel@tonic-gate */ 352*0Sstevel@tonic-gate struct t_uderr { 353*0Sstevel@tonic-gate struct netbuf addr; /* address */ 354*0Sstevel@tonic-gate struct netbuf opt; /* options */ 355*0Sstevel@tonic-gate t_scalar_t error; /* error code */ 356*0Sstevel@tonic-gate }; 357*0Sstevel@tonic-gate 358*0Sstevel@tonic-gate /* 359*0Sstevel@tonic-gate * The following are structure types used when dynamically 360*0Sstevel@tonic-gate * allocating the above structures via t_structalloc(). 361*0Sstevel@tonic-gate */ 362*0Sstevel@tonic-gate #define T_BIND 1 /* struct t_bind */ 363*0Sstevel@tonic-gate #define T_OPTMGMT 2 /* struct t_optmgmt */ 364*0Sstevel@tonic-gate #define T_CALL 3 /* struct t_call */ 365*0Sstevel@tonic-gate #define T_DIS 4 /* struct t_discon */ 366*0Sstevel@tonic-gate #define T_UNITDATA 5 /* struct t_unitdata */ 367*0Sstevel@tonic-gate #define T_UDERROR 6 /* struct t_uderr */ 368*0Sstevel@tonic-gate #define T_INFO 7 /* struct t_info */ 369*0Sstevel@tonic-gate 370*0Sstevel@tonic-gate /* 371*0Sstevel@tonic-gate * The following bits specify which fields of the above 372*0Sstevel@tonic-gate * structures should be allocated by t_alloc(). 373*0Sstevel@tonic-gate */ 374*0Sstevel@tonic-gate #define T_ADDR 0x01 /* address */ 375*0Sstevel@tonic-gate #define T_OPT 0x02 /* options */ 376*0Sstevel@tonic-gate #define T_UDATA 0x04 /* user data */ 377*0Sstevel@tonic-gate #define T_ALL 0xffff /* all the above fields */ 378*0Sstevel@tonic-gate 379*0Sstevel@tonic-gate 380*0Sstevel@tonic-gate /* 381*0Sstevel@tonic-gate * the following are the states for the user 382*0Sstevel@tonic-gate */ 383*0Sstevel@tonic-gate 384*0Sstevel@tonic-gate #define T_UNINIT 0 /* uninitialized */ 385*0Sstevel@tonic-gate #define T_UNBND 1 /* unbound */ 386*0Sstevel@tonic-gate #define T_IDLE 2 /* idle */ 387*0Sstevel@tonic-gate #define T_OUTCON 3 /* outgoing connection pending */ 388*0Sstevel@tonic-gate #define T_INCON 4 /* incoming connection pending */ 389*0Sstevel@tonic-gate #define T_DATAXFER 5 /* data transfer */ 390*0Sstevel@tonic-gate #define T_OUTREL 6 /* outgoing release pending */ 391*0Sstevel@tonic-gate #define T_INREL 7 /* incoming release pending */ 392*0Sstevel@tonic-gate 393*0Sstevel@tonic-gate 394*0Sstevel@tonic-gate #define T_UNUSED -1 395*0Sstevel@tonic-gate #define T_NULL 0 396*0Sstevel@tonic-gate 397*0Sstevel@tonic-gate 398*0Sstevel@tonic-gate /* 399*0Sstevel@tonic-gate * Allegedly general purpose constant. Used with (and needs to be bitwise 400*0Sstevel@tonic-gate * distinct from) T_NOPROTECT, T_PASSIVEPROTECT and T_ACTIVEPROTECT 401*0Sstevel@tonic-gate * which are OSI specific constants but part of this header (defined 402*0Sstevel@tonic-gate * in <xti_osi.h> which is included in this header for historical 403*0Sstevel@tonic-gate * XTI specification reasons) 404*0Sstevel@tonic-gate */ 405*0Sstevel@tonic-gate #define T_ABSREQ 0x8000 406*0Sstevel@tonic-gate 407*0Sstevel@tonic-gate /* 408*0Sstevel@tonic-gate * General definitions for option management 409*0Sstevel@tonic-gate * 410*0Sstevel@tonic-gate * Multiple variable length options may be packed into a single option buffer. 411*0Sstevel@tonic-gate * Each option consists of a fixed length header followed by variable length 412*0Sstevel@tonic-gate * data. The header and data will have to be aligned at appropriate 413*0Sstevel@tonic-gate * boundaries. The following macros are used to manipulate the options. 414*0Sstevel@tonic-gate * 415*0Sstevel@tonic-gate * Helper Macros: Macros beginning with a "_T" prefix are helper macros. 416*0Sstevel@tonic-gate * They are private, not meant for public use and may 417*0Sstevel@tonic-gate * change without notice. Users should use the standard 418*0Sstevel@tonic-gate * XTI macros beginning with "T_" prefix 419*0Sstevel@tonic-gate */ 420*0Sstevel@tonic-gate 421*0Sstevel@tonic-gate #define _T_OPT_HALIGN_SZ (sizeof (t_scalar_t)) /* Hdr Alignment size */ 422*0Sstevel@tonic-gate #define _T_OPT_DALIGN_SZ (sizeof (int32_t)) /* Data Alignment size */ 423*0Sstevel@tonic-gate #define _T_OPTHDR_SZ (sizeof (struct t_opthdr)) 424*0Sstevel@tonic-gate 425*0Sstevel@tonic-gate /* Align 'x' to the next 'asize' alignment boundary */ 426*0Sstevel@tonic-gate #define _T_OPT_ALIGN(x, asize) \ 427*0Sstevel@tonic-gate (((uintptr_t)(x) + ((asize) - 1L)) & ~((asize) - 1L)) 428*0Sstevel@tonic-gate 429*0Sstevel@tonic-gate /* Align 'x' to the next header alignment boundary */ 430*0Sstevel@tonic-gate #define _T_OPTHDR_ALIGN(x) \ 431*0Sstevel@tonic-gate (_T_OPT_ALIGN((x), _T_OPT_HALIGN_SZ)) 432*0Sstevel@tonic-gate 433*0Sstevel@tonic-gate /* Align 'x' to the next data alignment boundary */ 434*0Sstevel@tonic-gate #define _T_OPTDATA_ALIGN(x) \ 435*0Sstevel@tonic-gate (_T_OPT_ALIGN((x), _T_OPT_DALIGN_SZ)) 436*0Sstevel@tonic-gate 437*0Sstevel@tonic-gate /* 438*0Sstevel@tonic-gate * struct t_opthdr *T_OPT_FIRSTHDR(struct netbuf *nbp): 439*0Sstevel@tonic-gate * Get aligned start of first option header 440*0Sstevel@tonic-gate * 441*0Sstevel@tonic-gate * unsigned char *T_OPT_DATA(struct t_opthdr *tohp): 442*0Sstevel@tonic-gate * Get aligned start of data part after option header 443*0Sstevel@tonic-gate * 444*0Sstevel@tonic-gate * struct t_opthdr *T_OPT_NEXTHDR(struct netbuf *nbp, struct t_opthdr *tohp): 445*0Sstevel@tonic-gate * Skip to next option header 446*0Sstevel@tonic-gate */ 447*0Sstevel@tonic-gate 448*0Sstevel@tonic-gate #define T_OPT_FIRSTHDR(nbp) \ 449*0Sstevel@tonic-gate ((nbp)->len >= _T_OPTHDR_SZ ? (struct t_opthdr *)(nbp)->buf : \ 450*0Sstevel@tonic-gate (struct t_opthdr *)0) 451*0Sstevel@tonic-gate 452*0Sstevel@tonic-gate #define T_OPT_DATA(tohp) \ 453*0Sstevel@tonic-gate ((unsigned char *)_T_OPTDATA_ALIGN((char *)(tohp) + _T_OPTHDR_SZ)) 454*0Sstevel@tonic-gate 455*0Sstevel@tonic-gate #define _T_NEXTHDR(pbuf, buflen, popt) \ 456*0Sstevel@tonic-gate (((char *)_T_OPTHDR_ALIGN((char *)(popt) + (popt)->len) + \ 457*0Sstevel@tonic-gate _T_OPTHDR_SZ <= ((char *)(pbuf) + (buflen))) ? \ 458*0Sstevel@tonic-gate (struct t_opthdr *)((char *)_T_OPTHDR_ALIGN((char *)(popt) + \ 459*0Sstevel@tonic-gate (popt)->len)) : (struct t_opthdr *)0) 460*0Sstevel@tonic-gate 461*0Sstevel@tonic-gate #define T_OPT_NEXTHDR(nbp, tohp) (_T_NEXTHDR((nbp)->buf, (nbp)->len, (tohp))) 462*0Sstevel@tonic-gate 463*0Sstevel@tonic-gate #if !defined(_XPG5) 464*0Sstevel@tonic-gate /* 465*0Sstevel@tonic-gate * The macros below are meant for older applications for compatibility. 466*0Sstevel@tonic-gate * New applications should use the T_OPT_* macros, obviating the need 467*0Sstevel@tonic-gate * to explicitly use the T_ALIGN macro 468*0Sstevel@tonic-gate * 469*0Sstevel@tonic-gate * struct t_opthdr *OPT_NEXTHDR(char *pbuf, unsigned int buflen, 470*0Sstevel@tonic-gate * struct t_opthdr *popt): 471*0Sstevel@tonic-gate * Skip to next option header 472*0Sstevel@tonic-gate */ 473*0Sstevel@tonic-gate #define T_ALIGN(p) (((uintptr_t)(p) + (sizeof (t_scalar_t) - 1))\ 474*0Sstevel@tonic-gate & ~(sizeof (t_scalar_t) - 1)) 475*0Sstevel@tonic-gate #define OPT_NEXTHDR(pbuf, buflen, popt) (_T_NEXTHDR((pbuf), (buflen), (popt))) 476*0Sstevel@tonic-gate #endif 477*0Sstevel@tonic-gate 478*0Sstevel@tonic-gate /* 479*0Sstevel@tonic-gate * XTI LIBRARY FUNCTIONS 480*0Sstevel@tonic-gate */ 481*0Sstevel@tonic-gate 482*0Sstevel@tonic-gate #if defined(__STDC__) 483*0Sstevel@tonic-gate 484*0Sstevel@tonic-gate #if defined(_XOPEN_SOURCE) && !defined(_XPG5) 485*0Sstevel@tonic-gate extern int t_accept(int, int, struct t_call *); 486*0Sstevel@tonic-gate extern char *t_alloc(int, int, int); 487*0Sstevel@tonic-gate extern int t_bind(int, struct t_bind *, struct t_bind *); 488*0Sstevel@tonic-gate extern int t_connect(int, struct t_call *, struct t_call *); 489*0Sstevel@tonic-gate extern int t_error(char *); 490*0Sstevel@tonic-gate extern int t_free(char *, int); 491*0Sstevel@tonic-gate extern int t_open(char *, int, struct t_info *); 492*0Sstevel@tonic-gate extern int t_optmgmt(int, struct t_optmgmt *, struct t_optmgmt *); 493*0Sstevel@tonic-gate extern int t_rcv(int, char *, unsigned int, int *); 494*0Sstevel@tonic-gate extern int t_snd(int, char *, unsigned int, int); 495*0Sstevel@tonic-gate extern int t_snddis(int, struct t_call *); 496*0Sstevel@tonic-gate extern int t_sndudata(int, struct t_unitdata *); 497*0Sstevel@tonic-gate extern char *t_strerror(int); 498*0Sstevel@tonic-gate #else 499*0Sstevel@tonic-gate extern int t_accept(int, int, const struct t_call *); 500*0Sstevel@tonic-gate extern void *t_alloc(int, int, int); 501*0Sstevel@tonic-gate extern int t_bind(int, const struct t_bind *, struct t_bind *); 502*0Sstevel@tonic-gate extern int t_connect(int, const struct t_call *, struct t_call *); 503*0Sstevel@tonic-gate extern int t_error(const char *); 504*0Sstevel@tonic-gate extern int t_free(void *, int); 505*0Sstevel@tonic-gate extern int t_open(const char *, int, struct t_info *); 506*0Sstevel@tonic-gate extern int t_optmgmt(int, const struct t_optmgmt *, struct t_optmgmt *); 507*0Sstevel@tonic-gate extern int t_rcv(int, void *, unsigned int, int *); 508*0Sstevel@tonic-gate extern int t_snd(int, void *, unsigned int, int); 509*0Sstevel@tonic-gate extern int t_snddis(int, const struct t_call *); 510*0Sstevel@tonic-gate extern int t_sndudata(int, const struct t_unitdata *); 511*0Sstevel@tonic-gate extern const char *t_strerror(int); 512*0Sstevel@tonic-gate #endif 513*0Sstevel@tonic-gate extern int t_close(int); 514*0Sstevel@tonic-gate extern int t_getinfo(int, struct t_info *); 515*0Sstevel@tonic-gate extern int t_getstate(int); 516*0Sstevel@tonic-gate extern int t_getprotaddr(int, struct t_bind *, struct t_bind *); 517*0Sstevel@tonic-gate extern int t_listen(int, struct t_call *); 518*0Sstevel@tonic-gate extern int t_look(int); 519*0Sstevel@tonic-gate extern int t_rcvconnect(int, struct t_call *); 520*0Sstevel@tonic-gate extern int t_rcvdis(int, struct t_discon *); 521*0Sstevel@tonic-gate extern int t_rcvrel(int); 522*0Sstevel@tonic-gate extern int t_rcvreldata(int, struct t_discon *); 523*0Sstevel@tonic-gate extern int t_rcvudata(int, struct t_unitdata *, int *); 524*0Sstevel@tonic-gate extern int t_rcvuderr(int, struct t_uderr *); 525*0Sstevel@tonic-gate extern int t_rcvv(int, struct t_iovec *, unsigned int, int *); 526*0Sstevel@tonic-gate extern int t_rcvvudata(int, struct t_unitdata *, struct t_iovec *, 527*0Sstevel@tonic-gate unsigned int, int *); 528*0Sstevel@tonic-gate extern int t_sndrel(int); 529*0Sstevel@tonic-gate extern int t_sndreldata(int, struct t_discon *); 530*0Sstevel@tonic-gate extern int t_sndv(int, const struct t_iovec *, unsigned int, int); 531*0Sstevel@tonic-gate extern int t_sndvudata(int, struct t_unitdata *, struct t_iovec *, 532*0Sstevel@tonic-gate unsigned int); 533*0Sstevel@tonic-gate extern int t_sync(int); 534*0Sstevel@tonic-gate extern int t_sysconf(int); 535*0Sstevel@tonic-gate extern int t_unbind(int); 536*0Sstevel@tonic-gate 537*0Sstevel@tonic-gate #endif /* __STDC__ */ 538*0Sstevel@tonic-gate 539*0Sstevel@tonic-gate #ifdef __cplusplus 540*0Sstevel@tonic-gate } 541*0Sstevel@tonic-gate #endif 542*0Sstevel@tonic-gate 543*0Sstevel@tonic-gate #endif /* _XTI_H */ 544