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