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