xref: /original-bsd/sys/netiso/tp_param.h (revision 208c3823)
1 /***********************************************************
2 		Copyright IBM Corporation 1987
3 
4                       All Rights Reserved
5 
6 Permission to use, copy, modify, and distribute this software and its
7 documentation for any purpose and without fee is hereby granted,
8 provided that the above copyright notice appear in all copies and that
9 both that copyright notice and this permission notice appear in
10 supporting documentation, and that the name of IBM not be
11 used in advertising or publicity pertaining to distribution of the
12 software without specific, written prior permission.
13 
14 IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
15 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
16 IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
17 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
19 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
20 SOFTWARE.
21 
22 ******************************************************************/
23 
24 /*
25  * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
26  */
27 /*
28  * ARGO TP
29  *
30  * $Header: tp_param.h,v 5.3 88/11/18 17:28:18 nhall Exp $
31  * $Source: /usr/argo/sys/netiso/RCS/tp_param.h,v $
32  *	@(#)tp_param.h	7.5 (Berkeley) 01/16/90 *
33  *
34  */
35 
36 #ifndef __TP_PARAM__
37 #define __TP_PARAM__
38 
39 
40 /******************************************************
41  * compile time parameters that can be changed
42  *****************************************************/
43 
44 #define 	TP_CLASSES_IMPLEMENTED 0x11 /* zero and 4 */
45 
46 #define		TP_DECBIT_CLEAR_COUNT	3
47 
48 #define 	N_TPREF				100
49 
50 #define 	TP_SOCKBUFSIZE		((u_long)4096)
51 #define 	TP0_SOCKBUFSIZE		((u_long)512)
52 #define		MAX_TSAP_SEL_LEN	64
53 
54 /* maximum tpdu size we'll accept: */
55 #define 	TP_TPDUSIZE			0xc		/* 4096 octets for classes 1-4*/
56 #define 	TP0_TPDUSIZE		0xb		/* 2048 octets for class 0 */
57 #define 	TP_DFL_TPDUSIZE		0x7		/* 128 octets default */
58 	/* NOTE: don't ever negotiate 8192 because could get
59 	 * wraparound in checksumming
60 	 * (No mtu is likely to be larger than 4K anyway...)
61 	 */
62 #define		TP_NRETRANS			1
63 #define		TP_MAXPORT			0xefff
64 
65 #define		TP_RTT_NUM			0x7
66 /* ALPHA: to be used in the context: gain= 1/(2**alpha), or
67  * put another way, gaintimes(x) (x)>>alpha (forgetting the case alpha==0)
68  */
69 #define 	TP_RTT_ALPHA		3
70 #define 	TP_RTV_ALPHA		2
71 
72 /*
73  * not sure how to treat data on disconnect
74  */
75 #define 	T_CONN_DATA			0x1
76 #define 	T_DISCONNECT		0x2
77 #define 	T_DISC_DATA			0x4
78 #define 	T_XDATA				0x8
79 
80 #define ISO_CLNS	 0
81 #define IN_CLNS	 	 1
82 #define ISO_CONS	 2
83 #define ISO_COSNS	 3
84 #define TP_MAX_NETSERVICES 3
85 
86 /* Indices into tp stats ackreason[i] */
87 #define _ACK_DONT_ 0
88 #define _ACK_STRAT_EACH_ 0x1
89 #define _ACK_STRAT_FULLWIN_ 0x2
90 #define _ACK_DUP_ 0x3
91 #define _ACK_EOT_ 0x4
92 #define _ACK_REORDER_ 0x5
93 #define _ACK_USRRCV_ 0x6
94 #define _ACK_FCC_ 0x7
95 #define _ACK_NUM_REASONS_ 0x8
96 
97 /* masks for use in tp_stash() */
98 #define ACK_DONT 			0
99 #define ACK_STRAT_EACH		(1<< _ACK_STRAT_EACH_)
100 #define ACK_STRAT_FULLWIN	(1<< _ACK_STRAT_FULLWIN_)
101 #define ACK_DUP 			(1<< _ACK_DUP_)
102 #define ACK_EOT				(1<< _ACK_EOT_)
103 #define ACK_REORDER			(1<< _ACK_REORDER_)
104 
105 /******************************************************
106  * constants used in the protocol
107  *****************************************************/
108 
109 #define		TP_VERSION 			0x1
110 
111 #define 	TP_MAX_HEADER_LEN	256
112 
113 #define 	TP_MIN_TPDUSIZE		0x7		/* 128 octets */
114 #define 	TP_MAX_TPDUSIZE		0xd		/* 8192 octets */
115 
116 #define		TP_MAX_XPD_DATA		0x10	/* 16 octets */
117 #define		TP_MAX_CC_DATA		0x20	/* 32 octets */
118 #define		TP_MAX_CR_DATA		TP_MAX_CC_DATA
119 #define		TP_MAX_DR_DATA		0x40	/* 64 octets */
120 
121 #define		TP_XTD_FMT_BIT 	0x80000000
122 #define		TP_XTD_FMT_MASK	0x7fffffff
123 #define		TP_NML_FMT_BIT 	0x80
124 #define		TP_NML_FMT_MASK	0x7f
125 
126 /*
127  * values for the tpdu_type field, 2nd byte in a tpdu
128  */
129 
130 #define TP_MIN_TPDUTYPE 0x1
131 
132 #define XPD_TPDU_type	0x1
133 #define XAK_TPDU_type	0x2
134 #define GR_TPDU_type	0x3
135 #define AK_TPDU_type	0x6
136 #define ER_TPDU_type	0x7
137 #define DR_TPDU_type	0x8
138 #define DC_TPDU_type	0xc
139 #define CC_TPDU_type	0xd
140 #define CR_TPDU_type	0xe
141 #define DT_TPDU_type	0xf
142 
143 #define TP_MAX_TPDUTYPE 0xf
144 
145 /*
146  * identifiers for the variable-length options in tpdus
147  */
148 
149 #define		TPP_acktime			0x85
150 #define		TPP_residER			0x86
151 #define		TPP_priority		0x87
152 #define		TPP_transdelay		0x88
153 #define		TPP_throughput		0x89
154 #define		TPP_subseq			0x8a
155 #define		TPP_flow_cntl_conf	0x8c	/* not implemented */
156 #define		TPP_addl_info		0xe0
157 #define		TPP_tpdu_size		0xc0
158 #define		TPP_calling_sufx	0xc1
159 #define		TPP_invalid_tpdu	0xc1	/* the bozos used a value twice */
160 #define		TPP_called_sufx		0xc2
161 #define		TPP_checksum		0xc3
162 #define		TPP_vers			0xc4
163 #define		TPP_security		0xc5
164 #define		TPP_addl_opt		0xc6
165 #define		TPP_alt_class		0xc7
166 #define		TPP_perf_meas		0xc8	/* local item : perf meas on, svp */
167 
168 /******************************************************
169  * Some fundamental data types
170  *****************************************************/
171 #ifndef		TRUE
172 #define		TRUE				1
173 #endif		TRUE
174 
175 #ifndef		FALSE
176 #define		FALSE				0
177 #endif		FALSE
178 
179 #define		TP_LOCAL				22
180 #define		TP_FOREIGN				33
181 
182 #ifndef 	EOK
183 #define 	EOK 	0
184 #endif  	EOK
185 
186 #define 	TP_CLASS_0 	(1<<0)
187 #define 	TP_CLASS_1 	(1<<1)
188 #define 	TP_CLASS_2 	(1<<2)
189 #define 	TP_CLASS_3 	(1<<3)
190 #define 	TP_CLASS_4 	(1<<4)
191 
192 #define 	TP_FORCE 	0x1
193 #define 	TP_STRICT 	0x2
194 
195 #ifndef 	MNULL
196 #define 	MNULL				(struct mbuf *)0
197 #endif 	MNULL
198 	/* if ../sys/mbuf.h gets MT_types up to 0x40, these will
199 	 * have to be changed:
200 	 */
201 #define 	MT_XPD 				0x44
202 #define 	MT_EOT 				0x40
203 
204 #define		TP_ENOREF			0x80000000
205 
206 typedef 	unsigned int	SeqNum;
207 typedef		unsigned short	RefNum;
208 typedef		int				ProtoHook;
209 
210 
211 /******************************************************
212  * Some fundamental constants
213  *****************************************************/
214 
215 #define TP_MIN_WIN	2048
216 #define TP_MAX_WIN 16384
217 #define TP_MAX_WIN_UNPRIV 8192
218 
219 /******************************************************
220  * Macro used all over, for driver
221  *****************************************************/
222 
223 #define  DoEvent(x) \
224   ((E.ev_number=(x)),(tp_driver(tpcb,&E)))
225 
226 /******************************************************
227  * Some macros used all over, for timestamping
228  *****************************************************/
229 
230 #define GET_CUR_TIME(tvalp) ((*tvalp) = time)
231 
232 #define GET_TIME_SINCE(oldtvalp, diffp) {\
233 	(diffp)->tv_sec = time.tv_sec - (oldtvalp)->tv_sec;\
234 	(diffp)->tv_usec = time.tv_usec - (oldtvalp)->tv_usec;\
235 	if( (diffp)->tv_usec <0 ) {\
236 		(diffp)->tv_sec --;\
237 		(diffp)->tv_usec = 1000000 - (diffp)->tv_usec;\
238 	}\
239 }
240 
241 /******************************************************
242  * Some macros used for address families
243  *****************************************************/
244 
245 #define satosiso(ADDR) ((struct sockaddr_iso *)(ADDR))
246 #define satosin(ADDR) ((struct sockaddr_in *)(ADDR))
247 
248 /******************************************************
249  * Macro used for changing types of mbufs
250  *****************************************************/
251 
252 #define CHANGE_MTYPE(m, TYPE)\
253 	if((m)->m_type != TYPE) { \
254 		mbstat.m_mtypes[(m)->m_type]--; mbstat.m_mtypes[TYPE]++; \
255 		(m)->m_type = TYPE; \
256 	}
257 
258 /******************************************************
259  * Macros used for adding options to a tpdu header and for
260  * parsing the headers.
261  * Options are variable-length and must be bcopy-d because on the
262  * RT your assignments must be N-word aligned for objects of length
263  * N.  Such a drag.
264  *****************************************************/
265 
266 struct tp_vbp {
267 	u_char	tpv_code;
268 	char 	tpv_len;
269 	char	tpv_val;
270 };
271 #define vbptr(x) ((struct tp_vbp *)(x))
272 #define vbval(x,type) (*((type *)&(((struct tp_vbp *)(x))->tpv_val)))
273 #define vbcode(x) (vbptr(x)->tpv_code)
274 #define vblen(x) (vbptr(x)->tpv_len)
275 
276 #define vb_putval(dst,type,src)\
277 	bcopy((caddr_t)&(src),(caddr_t)&(((struct tp_vbp *)(dst))->tpv_val),\
278 	sizeof(type))
279 
280 #define vb_getval(src,type,dst)\
281 bcopy((caddr_t)&(((struct tp_vbp *)(src))->tpv_val),(caddr_t)&(dst),sizeof(type))
282 
283 #define ADDOPTION(type, DU, len, src)\
284 {	register caddr_t P;\
285 	P = (caddr_t)(DU) + (int)((DU)->tpdu_li);\
286 	vbptr(P)->tpv_code = type;\
287 	vbptr(P)->tpv_len = len;\
288 	bcopy((caddr_t)&src, (caddr_t)&(vbptr(P)->tpv_val), (unsigned)len);\
289 	DU->tpdu_li += len+2;/* 1 for code, 1 for length */\
290 }
291 /******************************************************
292  * Macro for the local credit:
293  * uses max transmission unit for the ll
294  * (as modified by the max TPDU size negotiated)
295  *****************************************************/
296 
297 #if defined(ARGO_DEBUG)&&!defined(LOCAL_CREDIT_EXPAND)
298 #define LOCAL_CREDIT(tpcb) tp_local_credit(tpcb)
299 #else
300 #define LOCAL_CREDIT( tpcb ) {\
301     register struct sockbuf *xxsb = &((tpcb)->tp_sock->so_rcv);\
302     register int xxi = ((xxsb)->sb_hiwat-(xxsb)->sb_cc);\
303     register int maxcredit = ((tpcb)->tp_xtd_format?0xffff:0xf);\
304     xxi = (xxi<0) ? 0 : ((xxi)>>(tpcb)->tp_tpdusize);\
305     xxi = MIN(xxi, maxcredit); \
306     if (!(tpcb->tp_cebit_off)) { \
307         (tpcb)->tp_lcredit = ROUND((tpcb)->tp_win_recv); \
308         if (xxi < (tpcb)->tp_lcredit) { \
309             (tpcb)->tp_lcredit = xxi; \
310         } \
311     } \
312     else { \
313         (tpcb)->tp_lcredit = xxi; \
314     } \
315 }
316 #endif ARGO_DEBUG
317 
318 #ifdef KERNEL
319 
320 #ifndef  tp_NSTATES
321 
322 #include "tp_states.h"
323 #include "tp_events.h"
324 
325 #endif  tp_NSTATES
326 #endif KERNEL
327 
328 #endif __TP_PARAM__
329