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