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