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