/* * * Copyright (c) Digital Equipment Corporation, 1994 * All Rights Reserved. Unpublished rights reserved * under the copyright laws of the United States. * * The software contained on this media is proprietary * to and embodies the confidential technology of * Digital Equipment Corporation. Possession, use, * duplication or dissemination of the software and * media is authorized only pursuant to a valid written * license from Digital Equipment Corporation. * * RESTRICTED RIGHTS LEGEND Use, duplication, or * disclosure by the U.S. Government is subject to * restrictions as set forth in Subparagraph (c)(1)(ii) * of DFARS 252.227-7013, or in FAR 52.227-19, as * applicable. * * XTI header file (for users of XTI) * * Based on the X/Open CAE Specification (1992) * for the X/Open Transport Interface. * * Dave Porter, 24-Feb-1993 * * Revision History: * * X-2 DDG264 Dean D. Gagne 22-Jan-1996 * Merge in symbols from PWRK STP merges. * 8-Jun-1995 BMK Add support for new PATHWORKS special option * to enable/disable an Eventhandler * 7-Jul-1995 BMK Change #define name SPX_OPTMGT to SPX_SET_OPTS * to avoid name clash with a typedef name in * spx_app.h * * X-1 KCG Kirt Gillum 14-sept-1994 * Intigrate from DECnet/OSI developement group. */ #ifndef __XTI__ #define __XTI__ #ifdef __cplusplus extern "C" { #endif /* * XTI error codes */ #define TBADADDR 1 /* incorrect addr format */ #define TBADOPT 2 /* incorrect option format */ #define TACCES 3 /* incorrect permissions */ #define TBADF 4 /* illegal transport fd */ #define TNOADDR 5 /* couldn't allocate addr */ #define TOUTSTATE 6 /* out of state */ #define TBADSEQ 7 /* bad call sequence number */ #define TSYSERR 8 /* system error */ #define TLOOK 9 /* event requires attention */ #define TBADDATA 10 /* illegal amount of data */ #define TBUFOVFLW 11 /* buffer not large enough */ #define TFLOW 12 /* flow control */ #define TNODATA 13 /* no data */ #define TNODIS 14 /* discon_ind not found on queue */ #define TNOUDERR 15 /* unitdata error not found */ #define TBADFLAG 16 /* bad flags */ #define TNOREL 17 /* no ord rel found on queue */ #define TNOTSUPPORT 18 /* primitive/action not supported */ #define TSTATECHNG 19 /* state is in process of changing */ #define TNOSTRUCTYPE 20 /* unsupported struct-type requested */ #define TBADNAME 21 /* invalid transport provider name */ #define TBADQLEN 22 /* qlen is zero */ #define TADDRBUSY 23 /* address in use */ #define TINDOUT 24 /* outstanding connection indications */ #define TPROVMISMATCH 25 /* transport provider mismatch */ #define TRESQLEN 26 /* resfd specfied to accept w/ qlen>0 */ #define TRESADDR 27 /* resfd not bound to same addr as fd */ #define TQFULL 28 /* incoming connection queue full */ #define TPROTO 29 /* XTI protocol error */ /* * Events returned by t_look() */ #define T_LISTEN 0x0001 /* connection indication received */ #define T_CONNECT 0x0002 /* connect confirmation received */ #define T_DATA 0x0004 /* normal data received */ #define T_EXDATA 0x0008 /* expedited data received */ #define T_DISCONNECT 0x0010 /* disconnect received */ #define T_UDERR 0x0040 /* datagram error indication */ #define T_ORDREL 0x0080 /* orderly release indication */ #define T_GODATA 0x0100 /* sending norma data is again possible */ #define T_GOEXDATA 0x0200 /* sending expedited data is again possible */ /* * Flag definitions */ #define T_MORE 0x001 /* more data (t_snd, t_rcv, t_rcvudata) */ #define T_EXPEDITED 0x002 /* expedited data (t_snd, t_rcv) */ #define T_NEGOTIATE 0x004 /* set opts (t_optmgmt) */ #define T_CHECK 0x008 /* check opts (t_optmgmt) */ #define T_DEFAULT 0x010 /* get default opts (t_optmgmt) */ #define T_SUCCESS 0x020 /* successful (option status)*/ #define T_FAILURE 0x040 /* failure (option status) */ #define T_CURRENT 0x080 /* get current options (t_optmgmt) */ #define T_PARTSUCCESS 0x100 /* partial success (option status) */ #define T_READONLY 0x200 /* read-only (option status) */ #define T_NOTSUPPORT 0x400 /* not supported (option status) */ /* * XTI error return variables. * The preprocessor symbol XTI_TRANSPORT should only be * defined when compiling transport provider images; * they can't see the error variables in the XTI * library, so need to omit these declarations. */ #ifndef XTI_TRANSPORT #ifdef VAXC #pragma nostandard globalref int t_errno, t_syserrno; #pragma standard #else #pragma extern_model save #pragma extern_model strict_refdef extern int t_errno, t_syserrno; #pragma extern_model restore #endif #endif /* * Protocol-specific service limits */ struct t_info { long addr; /* max size of the transport protocol address */ long options; /* max size of protocol-specific options */ long tsdu; /* max size of a transport service data unit */ long etsdu; /* max size of expedited TSDU */ long connect; /* max data allowed on connection funcs */ long discon; /* max data allowed on disconnection funcs */ long servtype; /* service type supported by provider */ long flags; /* other info about the transport provider */ }; /* * Service type defines */ #define T_COTS 01 /* connection oriented transport service */ #define T_COTS_ORD 02 /* connection oriented with orderly release */ #define T_CLTS 03 /* connectionless transport service */ /* * Flags defines (in info structure) */ #define T_SENDZERO 0x001 /* supports zero-length TSDUs */ /* * netbuf structure */ struct netbuf { unsigned int maxlen; unsigned int len; char *buf; }; /* * format of the address and options arguments of bind */ struct t_bind { struct netbuf addr; unsigned qlen; }; /* * options management structure */ struct t_optmgmt { struct netbuf opt; long flags; }; /* * per-option header */ struct t_opthdr { unsigned long len; /* total length of option */ unsigned long level; /* protocol affected */ unsigned long name; /* option name */ unsigned long status; /* status value */ /* followed by the option value */ }; struct xtiopt { struct t_opthdr opthdr; int *optval; }; /* * disconnect structure */ struct t_discon { struct netbuf udata; /* user data */ int reason; /* reason code */ int sequence; /* sequence number */ }; /* * call structure */ struct t_call { struct netbuf addr; /* address */ struct netbuf opt; /* options */ struct netbuf udata; /* user data */ int sequence; /* sequence number */ }; /* * datagram structure */ struct t_unitdata { struct netbuf addr; /* address */ struct netbuf opt; /* options */ struct netbuf udata; /* user data */ }; /* * unitdata error structure */ struct t_uderr { struct netbuf addr; /* address */ struct netbuf opt; /* options */ long error; /* error code */ }; /* * Structure type codes for use with t_alloc() */ #define T_BIND 1 /* struct t_bind */ #define T_OPTMGMT 2 /* struct t_optmgmt */ #define T_CALL 3 /* struct t_call */ #define T_DIS 4 /* struct t_discon */ #define T_UNITDATA 5 /* struct t_unitdata */ #define T_UDERROR 6 /* struct t_uderr */ #define T_INFO 7 /* struct t_info */ /* * The following bits specify which fields of the above * structures should be allocated by t_alloc(). */ #define T_ADDR 0x01 /* address */ #define T_OPT 0x02 /* options */ #define T_UDATA 0x04 /* user data */ #define T_ALL 0xffff /* all the above fields */ /* * The following are the states for the user */ #define T_UNINIT 0 /* not initialized */ #define T_UNBND 1 /* unbound */ #define T_IDLE 2 /* idle */ #define T_OUTCON 3 /* outgoing connection pending */ #define T_INCON 4 /* incoming connection pending */ #define T_DATAXFER 5 /* data transfer */ #define T_OUTREL 6 /* outgoing release pending */ #define T_INREL 7 /* incoming release pending */ /* * General-purpose defines */ #define T_YES 1 #define T_NO 0 #define T_UNUSED -1 #define T_NULL 0 #define T_ABSREQ 0x8000 #define T_INFINITE -1 #define T_INVALID -2 /* * XTI library functions */ extern int t_accept(int fd, int resfd, struct t_call *call); extern char *t_alloc(int fd, int type, int fields); extern int t_bind(int fd, struct t_bind *req, struct t_bind *ret); extern int t_close(int fd); extern int t_connect(int fd, struct t_call *sndcall, struct t_call *rcvcall); extern int t_error(char *errmsg); extern int t_free(char *ptr, int struct_type); extern int t_getinfo(int fd, struct t_info *info); extern int t_getprotaddr(int fd, struct t_bind *boundaddr, struct t_bind *peeraddr); extern int t_getstate(int fd); extern int t_listen(int fd, struct t_call *call); extern int t_look(int fd); extern int t_open(char *name, int oflag, struct t_info *info); extern int t_optmgmt(int fd, struct t_optmgmt *req, struct t_optmgmt *ret); extern int t_rcv(int fd, char *buf, unsigned int nbytes, int *flags); extern int t_rcvconnect(int fd, struct t_call *call); extern int t_rcvdis(int fd, struct t_discon *discon); extern int t_rcvrel(int fd); extern int t_rcvudata(int fd, struct t_unitdata *unitdata, int *flags); extern int t_rcvuderr(int fd, struct t_uderr *uderr); extern int t_snd(int fd, char *buf, unsigned int nbytes, int flags); extern int t_snddis(int fd, struct t_call *call); extern int t_sndrel(int fd); extern int t_sndudata(int fd, struct t_unitdata *unitdata); extern char *t_strerror(int errnum); extern int t_sync(int fd); extern int t_unbind(int fd); /* * General definitions for option management */ #define T_UNSPEC (~0-2) #define T_ALLOPT 0 #define T_ALIGN(p) (((unsigned long)(p)+(sizeof(long)-1)) & ~(sizeof(long)-1)) #define OPT_NEXTHDR(pbuf,buflen,popt) ( \ ((char *)(popt) + T_ALIGN((popt)->len) < (pbuf)+(buflen)) ? \ (struct t_opthdr *)((char *)(popt) + T_ALIGN((popt)->len)) : \ (struct t_opthdr *) NULL \ ) /* * Protocol levels as specified in option header */ #define XTI_GENERIC 0xffff #define ISO_TP 0x0100 #define INET_TCP 0x0006 #define INET_UDP 0x0011 #define INET_IP 0x0000 /* * XTI-level options */ #define XTI_DEBUG 0x0001 /* enable debugging */ #define XTI_LINGER 0x0080 /* linger on close if data present */ #define XTI_RCVBUF 0x1002 /* receive buffer size */ #define XTI_RCVLOWAT 0x1004 /* receive low-water mark */ #define XTI_SNDBUF 0x1001 /* send buffer size */ #define XTI_SNDLOWAT 0x1003 /* send low-water mark */ /* * Structure used with linger option */ struct t_linger { long l_onoff; /* option off/on */ long l_linger; /* linger time */ }; /* SPECIFIC ISO OPTION AND MANAGEMENT PARAMETERS */ /* * Definition of the ISO transport classes */ #define T_CLASS0 0 #define T_CLASS1 1 #define T_CLASS2 2 #define T_CLASS3 3 #define T_CLASS4 4 /* * Definition of the priorities */ #define T_PRITOP 0 #define T_PRIHIGH 1 #define T_PRIMID 2 #define T_PRILOW 3 #define T_PRIDFLT 4 /* * Definition of the protection levels */ #define T_NOPROTECT 1 #define T_PASSIVEPROTECT 2 #define T_ACTIVEPROTECT 4 /* * Default value for the length of TPDUs */ #define T_LTPDUDFLT 128 /* * rate structure */ struct rate { long targetvalue; /* target value */ long minacceptvalue; /* minimum acceptable value */ }; /* * reqvalue structure */ struct reqvalue { struct rate called; /* called rate */ struct rate calling; /* calling rate */ }; /* * thrpt structure */ struct thrpt { struct reqvalue maxthrpt; /* maximum throughput */ struct reqvalue avgthrpt; /* average throughput */ }; /* * transdel structure */ struct transdel { struct reqvalue maxdel; /* maximum transit delay */ struct reqvalue avgdel; /* average transit delay */ }; /* * Options for quality of service and expedited data (ISO 8072:1986) */ #define TCO_THROUGHPUT 0x0001 #define TCO_TRANSDEL 0x0002 #define TCO_RESERRORRATE 0x0003 #define TCO_TRANSFFAILPROB 0x0004 #define TCO_ESTFAILPROB 0x0005 #define TCO_RELFAILPROB 0x0006 #define TCO_ESTDELAY 0x0007 #define TCO_RELDELAY 0x0008 #define TCO_CONNRESIL 0x0009 #define TCO_PROTECTION 0x000a #define TCO_PRIORITY 0x000b #define TCO_EXPD 0x000c #define TCL_TRANSDEL 0x000d #define TCL_RESERRORRATE TCO_RESERRORRATE #define TCL_PROTECTION TCO_PROTECTION #define TCL_PRIORITY TCO_PRIORITY /* * Management options */ #define TCO_LTPDU 0x0100 #define TCO_ACKTIME 0x0200 #define TCO_REASTIME 0x0300 #define TCO_EXTFORM 0x0400 #define TCO_FLOWCTRL 0x0500 #define TCO_CHECKSUM 0x0600 #define TCO_NETEXP 0x0700 #define TCO_NETRECPTCF 0x0800 #define TCO_PREFCLASS 0x0900 #define TCO_ALTCLASS1 0x0a00 #define TCO_ALTCLASS2 0x0b00 #define TCO_ALTCLASS3 0x0c00 #define TCO_ALTCLASS4 0x0d00 #define TCL_CHECKSUM TCO_CHECKSUM /* INTERNET SPECIFIC ENVIRONMENT */ /* * TCP-level options */ #define TCP_NODELAY 0x01 /* don't delay packets to coalesce */ #define TCP_MAXSEG 0x02 /* get maximum segment size */ #define TCP_KEEPALIVE 0x08 /* check if connections are alive */ /* * Structure used with TCP_KEEPALIVE option */ struct t_kpalive { long kp_onoff; /* option off/on */ long kp_timeout; /* timeout in minutes */ }; #define T_GARBAGE 0x02 /* * UDP-level options */ #define UDP_CHECKSUM TCO_CHECKSUM /* * IP-level options */ #define IP_OPTIONS 1 /* IP per-packet options */ #define IP_TOS 2 /* IP per-packet type of service */ #define IP_TTL 3 /* IP per-packet time to live */ #define IP_REUSEADDR 4 /* Allow local address reuse */ #define IP_DONTROUTE 0x10 /* Just use interface addresses */ #define IP_BROADCAST 0x20 /* permit sending of broadcast msgs */ /* * IP_TOS precedence levels */ #define T_ROUTINE 0 #define T_PRIORITY 1 #define T_IMMEDIATE 2 #define T_FLASH 3 #define T_OVERRIDEFLASH 4 #define T_CRITIC_ECP 5 #define T_INETCONTROL 6 #define T_NETCONTROL 7 /* * IP_TOS type of service */ #define T_NOTOS 0 #define T_LDELAY (1<<4) #define T_HITHRPT (1<<3) #define T_HIREL (1<<2) #define SET_TOS(prec,tos) ((0x7 & (prec)) << 5 | (0x1c & (tos))) /* NETBIOS DEFINITIONS */ /* * Name types and other parameters */ #define NB_UNIQUE 0 #define NB_GROUP 1 #define NB_NAMELEN 16 #define NB_BCAST_NAME "* " /* padded to 16 chars! */ /* * Disconnect reason codes */ #define NB_ABORT 0x18 /* session ended abnormally */ #define NB_CLOSED 0x0A /* session closed */ #define NB_NOANSWER 0x14 /* no answer */ #define NB_OPREJ 0x12 /* session open rejected */ /* * Disconnect reason codes returned by SPX. 8-Jun-1995 - BMK. */ #define SPX_CONNECTION_FAILED ((unsigned char) 0xED) #define SPX_CONNECTION_TERMINATED ((unsigned char) 0xEC) /* VMS-ONLY DEFINITIONS */ /* * Open modes (fcntl.h in UNIX) */ #define O_RDWR 0000002 /* open for read & write */ #define O_NONBLOCK 0400000 /* non-blocking I/O */ /* * OSI transport address format - not related to any structure * in the known universe, but as simple as I think I can get * away with. */ struct xtiaddr_osi { unsigned short osi_family; /* AF_OSI */ unsigned char osi_nsap_len; /* length of nsap address */ unsigned char osi_tsel_len; /* length of tsel (tsap-id) */ unsigned char osi_nsap[20]; /* nsap address */ unsigned char osi_tsel[32]; /* tsel (tsap-id) */ }; #define AF_OSI 19 /* * Internet address format - same as sockaddr_in used * by BSD-derived IP implementations, including UCX. */ struct xtiaddr_in { short in_family; /* AF_INET */ unsigned short in_port; /* tcp or udp port number */ unsigned long in_addr; /* ip address */ unsigned char in_zero[8]; /* pad for UCX compatibility */ }; #define AF_INET 2 /* * DECnet address format - a string in the form node::"objnum=objnam", * as supported by the DECnet-VAX QIO interface. The xtiaddr_dn structure * is a character array large enough for the largest DECnet address, but * the user can choose to allocate less space if desired. Access control * info and user data are not permitted in XTI DECnet addresses; they are * passed by other mechanisms. */ struct xtiaddr_dn { char dn_addr[256]; /* node::"objnum=objnam" */ }; /* * NetBIOS address structure */ struct xtiaddr_nb { unsigned char nb_type; /* type of name, NB_xxx */ char nb_name[NB_NAMELEN]; /* name string */ }; /* * IPX address structure. 8-Jun-1995 - BMK. */ struct xtiaddr_ipx { unsigned char net[4]; /* ipx network address */ unsigned char node[6]; /* ipx node address */ unsigned char sock[2]; /* ipx socket */ }; /* * Generic structure */ union xtiaddr { struct xtiaddr_osi osi; struct xtiaddr_in in; struct xtiaddr_dn dn; struct xtiaddr_nb nb; struct xtiaddr_ipx ipx; /* 8-Jun-1995 - BMK. */ }; /* * Poll structure (used with t_poll). * (The POLLxxx symbols are intended to provide some sort * of source compatibility with System V poll(); usage is * deprecated) */ struct xtipoll { int fd; /* file descriptor */ short events; /* events to be monitored */ short revents; /* events detected */ }; #define POLLIN (T_LISTEN|T_CONNECT|T_DATA|T_ORDREL|T_UDERR) #define POLLPRI (T_EXDATA) #define POLLOUT (T_GODATA|T_GOEXDATA) #define POLLHUP (T_DISCONNECT) /* define POLLERR ?? */ /* define POLLNVAL ?? */ /* * Time value (used with t_select). The specified time * value must be less than 2147483 seconds. */ struct xtitimeval { int tv_sec; /* time in secs */ int tv_usec; /* in usecs */ }; /* * VMS-specific XTI-level options (level = XTI_GENERIC). * All X/Open-defined options seem to have values which * fit into 16 bits, so we start at 0x10000 in the hope * that we'll avoid a clash. */ #define XTI_SETWAITF 0x10001 /* set wait functions */ /* * Option name codes for use with t_optmgmt to declare/delete * an EventHandler. 8-Jun-1995 - BMK. */ #define PWRK_EVHANDLER_ENABLE 8 #define PWRK_EVHANDLER_DISABLE 9 /* * Structure used as option value with XTI_SETWAITF. This * lets an application supply event synchronisation functions * (wait and wake) which are appropriate to its own thread * environment. The default is to use sys$hiber and sys$wake. */ struct xtiwaitf { int (*waitfunc)(); /* block execution */ int (*wakefunc)(); /* resume execution */ int waitprm; /* parameter for wait/wake */ }; /* * Structure used as option value with PWRK_EVHANDLER_ENABLE. * This lets an application declare an EventHandler routine on * a per FD basis to receive (and handle) asynchronous notification * of incomming XTI events for the specified FD. 8-Jun-1995 - BMK. */ struct opt_evthandler { void (*evt_handler)(); /* User specified eventhandler routine */ unsigned long uparam; /* User param to be passed to the eventhandler */ }; /* SPX SPECIFIC OPTIONS * 8-Jun-1995 - BMK. * Option name code and struct definitions for SPX specific options */ #define SPX_SET_OPTS 0x00fffd00 struct spx_options { unsigned char spxo_retry_count; unsigned char spxo_watchdog_flag; unsigned short spxo_min_retry_delay; unsigned char pad[4]; }; struct xti_spx_optmgmt { struct t_opthdr opthdr; struct spx_options optmgtval; }; #define SPX_CONN_OPT 0x00fffe00 struct spx_connect_opts { unsigned char spx_connectionID[2]; unsigned char spx_allocationNumber[2]; unsigned char pad1[4]; }; struct xti_spx_conn_opt { struct t_opthdr opthdr; struct spx_connect_opts optval; }; /* * VMS-specific library routines, most of which are provided * only for use by particular transports. Only t_poll and t_select * are of general applicability. */ extern int t_getmsg(int fd, struct netbuf *ctlbuf, struct netbuf *databuf, int *flags); extern int t_ioctl(int fd, int cmd, char *argp); extern int t_poll(struct xtipoll fds[], int nfds, int timeout); extern int t_putmsg(int fd, struct netbuf *ctlbuf, struct netbuf *databuf, int flags); extern int t_read(int fd, char *buf, unsigned int nbytes); extern int t_select(int nfds, int *readfds, int *writefds, int *exceptfds, struct xtitimeval *timeout); extern int t_write(int fd, char *buf, unsigned int nbytes); #ifdef __cplusplus } #endif #endif /* __XTI__ */