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