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