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