xref: /illumos-gate/usr/src/uts/common/sys/tpicommon.h (revision 6dde88b51419b99fe0aab8e56184c693945826b8)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_TPICOMMON_H
28 #define	_SYS_TPICOMMON_H
29 
30 #include <sys/feature_tests.h>
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * WARNING: This header should not ever be included directly by application
38  * programs. It exists so that common definitions can be included by other
39  * system header files which define a documented interface. The interfaces
40  * that share and expose the definitions in this file are:
41  *
42  *	(1) TLI interface <tiuser.h>  (which includes <sys/tiuser.h> which
43  *				   includes this file)
44  *	(2) XTI interface <xti.h>
45  *	(3) Kernel Streams TPI message based inteface <sys/tihdr.h>
46  */
47 
48 
49 /*
50  * The following are "t_errno" error codes needed by both the kernel
51  * level transport providers and the user level interfaces.
52  */
53 
54 #define	TBADADDR	1	/* Incorrect address format */
55 #define	TBADOPT		2	/* Incorrect options format */
56 #define	TACCES		3	/* Illegal permissions */
57 #define	TBADF		4	/* Illegal file descriptor */
58 #define	TNOADDR		5	/* Couldn't allocate address */
59 #define	TOUTSTATE	6	/* Routine will place interface out of state */
60 #define	TBADSEQ		7	/* Illegal called/calling sequence number */
61 #define	TSYSERR		8	/* System error */
62 #define	TLOOK		9	/* An event requires attention */
63 #define	TBADDATA	10	/* Illegal amount of data */
64 #define	TBUFOVFLW	11	/* Buffer not large enough */
65 #define	TFLOW		12	/* Can't send message - (blocked) */
66 #define	TNODATA		13	/* No message currently available */
67 #define	TNODIS		14	/* Disconnect message not found */
68 #define	TNOUDERR	15	/* Unitdata error message not found */
69 #define	TBADFLAG	16	/* Incorrect flags specified */
70 #define	TNOREL		17	/* Orderly release message not found */
71 #define	TNOTSUPPORT	18	/* Primitive not supported by provider */
72 #define	TSTATECHNG	19	/* State is in process of changing */
73 /*
74  * Following new error codes added to namespace with introduction of XTI
75  */
76 #define	TNOSTRUCTYPE	20	/* Unsupported structure type requested */
77 #define	TBADNAME	21	/* Invalid transport provider name */
78 #define	TBADQLEN	22	/* Listener queue length limit is zero */
79 #define	TADDRBUSY	23	/* Transport address is in use */
80 #define	TINDOUT		24	/* Outstanding connection indications */
81 #define	TPROVMISMATCH	25
82 			/* Listener-acceptor transport provider mismatch */
83 
84 #define	TRESQLEN	26
85 /* Connection acceptor has listen queue length limit greater than zero */
86 
87 #define	TRESADDR	27
88 /* Connection acceptor-listener addresses not same but required by transport */
89 
90 #define	TQFULL		28	/* Incoming connection queue is full */
91 #define	TPROTO		29	/* Protocol error on transport primitive */
92 
93 /*
94  * Service type defines - used with T_info_ack
95  */
96 #define	T_COTS	   1	/* connection oriented transport service	*/
97 #define	T_COTS_ORD 2	/* connection oriented w/ orderly release	*/
98 #define	T_CLTS	   3	/* connectionless transport service		*/
99 /*
100  * NOT FOR PUBLIC USE, Solaris internal only.
101  * This value of nc_semantics is strictly for use of Remote Direct
102  * Memory Access provider interfaces in Solaris only and not for
103  * general use. Do not use this value for general purpose user or
104  * kernel programming. If used the behavior is undefined.
105  * This is a PRIVATE interface to be used by Solaris kRPC only.
106  */
107 #define	T_RDMA	   4	/* rdma transport service			*/
108 
109 
110 /*
111  * The following are the flag definitions needed by the
112  * user level library routines.
113  */
114 
115 /*
116  * flags for option management request primitives
117  * Note:
118  * - This namespace is distinct from the namespace for data
119  *   primitives.
120  * - Flags T_NEGOTIATE, T_CHECK, T_DEFAULT, T_CURRENT
121  *   are associated with an option request
122  * - Flags T_SUCCESS, T_FAILURE, T_PARTSUCCESS, T_READONLY,
123  *   T_NOTSUPPORT are associated with results of option request.
124  */
125 #define	T_NEGOTIATE	0x004	/* set opts request	*/
126 #define	T_CHECK		0x008	/* check opts request	*/
127 #define	T_DEFAULT	0x010	/* get default opts request */
128 #define	T_SUCCESS	0x020	/* successful result */
129 #define	T_FAILURE	0x040	/* failure result */
130 #define	T_CURRENT	0x080	/* get current options request */
131 #define	T_PARTSUCCESS	0x100	/* partial success result */
132 #define	T_READONLY	0x200	/* read-only result */
133 #define	T_NOTSUPPORT	0x400	/* not supported result */
134 
135 
136 /*
137  * General purpose defines - used in multiple options context.
138  * They (T_YES and T_NO) need to be bitwise distinct from T_GARBAGE
139  * used with TCP level options by XTI for historical XTI specification
140  * reasons.
141  * (T_GARBAGE declared in <sys/xti_inet.h> included by <xti.h>).
142  */
143 #define	T_YES			1
144 #define	T_NO			0
145 
146 /*
147  * Values used with struct T_info_ack fields
148  */
149 #define	T_INFINITE		-1
150 #define	T_INVALID		-2
151 
152 /*
153  * Constants used with option management "name" or "value" fields.
154  */
155 
156 /*
157  * XTI defined value reserved for stating 'unspecified' value used
158  * in some option namespaces.
159  */
160 #define	T_UNSPEC	(~0-2)	/* applicable to ulong_t, long, char */
161 
162 /*
163  * XTI inspired option management defined an option name T_ALLOPT
164  * to imply all options of a certain level.
165  * No option name (for any level) should be defined with constant value of
166  * T_ALLOPT (0).
167  */
168 #define	T_ALLOPT	0	/* all options at any level */
169 
170 /*
171  * An option specification consists of an opthdr, followed by the value of
172  * the option.  An options buffer contains one or more options.  The len
173  * field of opthdr specifies the length of the option value in bytes.  This
174  * length must be a multiple of sizeof (t_scalar_t) (use OPTLEN macro).
175  * This is an antique definition which is used (unofficially) by TLI but
176  * superceded in XTI.
177  */
178 /*
179  * The opthdr types are now t_uscalar_t - inspired by XTI
180  */
181 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
182 struct opthdr {
183 	t_uscalar_t	level;	/* protocol level affected */
184 	t_uscalar_t	name;	/* option to modify */
185 	t_uscalar_t	len;	/* length of option value */
186 };
187 
188 #define	OPTLEN(x) ((((x) + sizeof (t_uscalar_t) - 1) / \
189 		    sizeof (t_uscalar_t)) * sizeof (t_uscalar_t))
190 #define	OPTVAL(opt) ((char *)(opt + 1))
191 #endif	/* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
192 
193 #ifdef	__cplusplus
194 }
195 #endif
196 
197 #endif	/* _SYS_TPICOMMON_H */
198