149268Sbostic /*- 2*63222Sbostic * Copyright (c) 1991, 1993 3*63222Sbostic * The Regents of the University of California. All rights reserved. 449268Sbostic * 549268Sbostic * %sccs.include.redist.c% 649268Sbostic * 7*63222Sbostic * @(#)tp_param.h 8.1 (Berkeley) 06/10/93 849268Sbostic */ 949268Sbostic 1036407Ssklower /*********************************************************** 1136407Ssklower Copyright IBM Corporation 1987 1236407Ssklower 1336407Ssklower All Rights Reserved 1436407Ssklower 1536407Ssklower Permission to use, copy, modify, and distribute this software and its 1636407Ssklower documentation for any purpose and without fee is hereby granted, 1736407Ssklower provided that the above copyright notice appear in all copies and that 1836407Ssklower both that copyright notice and this permission notice appear in 1936407Ssklower supporting documentation, and that the name of IBM not be 2036407Ssklower used in advertising or publicity pertaining to distribution of the 2136407Ssklower software without specific, written prior permission. 2236407Ssklower 2336407Ssklower IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 2436407Ssklower ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 2536407Ssklower IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 2636407Ssklower ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 2736407Ssklower WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 2836407Ssklower ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 2936407Ssklower SOFTWARE. 3036407Ssklower 3136407Ssklower ******************************************************************/ 3236407Ssklower 3336407Ssklower /* 3436407Ssklower * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison 3536407Ssklower */ 3636407Ssklower /* 3736407Ssklower * ARGO TP 3836407Ssklower * 3936407Ssklower * $Header: tp_param.h,v 5.3 88/11/18 17:28:18 nhall Exp $ 4036407Ssklower * $Source: /usr/argo/sys/netiso/RCS/tp_param.h,v $ 4136407Ssklower * 4236407Ssklower */ 4336407Ssklower 4436407Ssklower #ifndef __TP_PARAM__ 4536407Ssklower #define __TP_PARAM__ 4636407Ssklower 4736407Ssklower 4836407Ssklower /****************************************************** 4936407Ssklower * compile time parameters that can be changed 5036407Ssklower *****************************************************/ 5136407Ssklower 5236407Ssklower #define TP_CLASSES_IMPLEMENTED 0x11 /* zero and 4 */ 5336407Ssklower 5436407Ssklower #define TP_DECBIT_CLEAR_COUNT 3 5536407Ssklower 5648750Ssklower /*#define N_TPREF 100 */ 5748750Ssklower #ifdef KERNEL 5848750Ssklower extern int N_TPREF; 5948750Ssklower #endif 6036407Ssklower 6137469Ssklower #define TP_SOCKBUFSIZE ((u_long)4096) 6237469Ssklower #define TP0_SOCKBUFSIZE ((u_long)512) 6336407Ssklower #define MAX_TSAP_SEL_LEN 64 6436407Ssklower 6536407Ssklower /* maximum tpdu size we'll accept: */ 6636407Ssklower #define TP_TPDUSIZE 0xc /* 4096 octets for classes 1-4*/ 6736407Ssklower #define TP0_TPDUSIZE 0xb /* 2048 octets for class 0 */ 6836407Ssklower #define TP_DFL_TPDUSIZE 0x7 /* 128 octets default */ 6936407Ssklower /* NOTE: don't ever negotiate 8192 because could get 7036407Ssklower * wraparound in checksumming 7136407Ssklower * (No mtu is likely to be larger than 4K anyway...) 7236407Ssklower */ 7351204Ssklower #define TP_NRETRANS 12 /* TCP_MAXRXTSHIFT + 1 */ 7451204Ssklower #define TP_MAXRXTSHIFT 6 /* factor of 64 */ 7536407Ssklower #define TP_MAXPORT 0xefff 7636407Ssklower 7736407Ssklower /* ALPHA: to be used in the context: gain= 1/(2**alpha), or 7836407Ssklower * put another way, gaintimes(x) (x)>>alpha (forgetting the case alpha==0) 7936407Ssklower */ 8036407Ssklower #define TP_RTT_ALPHA 3 8136407Ssklower #define TP_RTV_ALPHA 2 8251257Ssklower #define TP_REXMTVAL(tpcb)\ 8351257Ssklower ((tp_rttadd + (tpcb)->tp_rtt + ((tpcb)->tp_rtv) << 2) / tp_rttdiv) 8451257Ssklower #define TP_RANGESET(tv, value, min, max) \ 8551257Ssklower ((tv = value) > (max) ? (tv = max) : (tv < min ? tv = min : tv)) 8636407Ssklower 8736407Ssklower /* 8836407Ssklower * not sure how to treat data on disconnect 8936407Ssklower */ 9036407Ssklower #define T_CONN_DATA 0x1 9136407Ssklower #define T_DISCONNECT 0x2 9236407Ssklower #define T_DISC_DATA 0x4 9336407Ssklower #define T_XDATA 0x8 9436407Ssklower 9536407Ssklower #define ISO_CLNS 0 9636407Ssklower #define IN_CLNS 1 9736407Ssklower #define ISO_CONS 2 9836407Ssklower #define ISO_COSNS 3 9936407Ssklower #define TP_MAX_NETSERVICES 3 10036407Ssklower 10136407Ssklower /* Indices into tp stats ackreason[i] */ 10236407Ssklower #define _ACK_DONT_ 0 10336407Ssklower #define _ACK_STRAT_EACH_ 0x1 10436407Ssklower #define _ACK_STRAT_FULLWIN_ 0x2 10536407Ssklower #define _ACK_DUP_ 0x3 10636407Ssklower #define _ACK_EOT_ 0x4 10736407Ssklower #define _ACK_REORDER_ 0x5 10836407Ssklower #define _ACK_USRRCV_ 0x6 10936407Ssklower #define _ACK_FCC_ 0x7 11036407Ssklower #define _ACK_NUM_REASONS_ 0x8 11136407Ssklower 11236407Ssklower /* masks for use in tp_stash() */ 11336407Ssklower #define ACK_DONT 0 11436407Ssklower #define ACK_STRAT_EACH (1<< _ACK_STRAT_EACH_) 11536407Ssklower #define ACK_STRAT_FULLWIN (1<< _ACK_STRAT_FULLWIN_) 11636407Ssklower #define ACK_DUP (1<< _ACK_DUP_) 11736407Ssklower #define ACK_EOT (1<< _ACK_EOT_) 11836407Ssklower #define ACK_REORDER (1<< _ACK_REORDER_) 11936407Ssklower 12036407Ssklower /****************************************************** 12136407Ssklower * constants used in the protocol 12236407Ssklower *****************************************************/ 12336407Ssklower 12436407Ssklower #define TP_VERSION 0x1 12536407Ssklower 12636407Ssklower #define TP_MAX_HEADER_LEN 256 12736407Ssklower 12836407Ssklower #define TP_MIN_TPDUSIZE 0x7 /* 128 octets */ 12936407Ssklower #define TP_MAX_TPDUSIZE 0xd /* 8192 octets */ 13036407Ssklower 13136407Ssklower #define TP_MAX_XPD_DATA 0x10 /* 16 octets */ 13236407Ssklower #define TP_MAX_CC_DATA 0x20 /* 32 octets */ 13336407Ssklower #define TP_MAX_CR_DATA TP_MAX_CC_DATA 13436407Ssklower #define TP_MAX_DR_DATA 0x40 /* 64 octets */ 13536407Ssklower 13636407Ssklower #define TP_XTD_FMT_BIT 0x80000000 13736407Ssklower #define TP_XTD_FMT_MASK 0x7fffffff 13836407Ssklower #define TP_NML_FMT_BIT 0x80 13936407Ssklower #define TP_NML_FMT_MASK 0x7f 14036407Ssklower 14136407Ssklower /* 14236407Ssklower * values for the tpdu_type field, 2nd byte in a tpdu 14336407Ssklower */ 14436407Ssklower 14536407Ssklower #define TP_MIN_TPDUTYPE 0x1 14636407Ssklower 14736407Ssklower #define XPD_TPDU_type 0x1 14836407Ssklower #define XAK_TPDU_type 0x2 14936407Ssklower #define GR_TPDU_type 0x3 15036407Ssklower #define AK_TPDU_type 0x6 15136407Ssklower #define ER_TPDU_type 0x7 15236407Ssklower #define DR_TPDU_type 0x8 15336407Ssklower #define DC_TPDU_type 0xc 15436407Ssklower #define CC_TPDU_type 0xd 15536407Ssklower #define CR_TPDU_type 0xe 15636407Ssklower #define DT_TPDU_type 0xf 15736407Ssklower 15836407Ssklower #define TP_MAX_TPDUTYPE 0xf 15936407Ssklower 16036407Ssklower /* 16136407Ssklower * identifiers for the variable-length options in tpdus 16236407Ssklower */ 16336407Ssklower 16436407Ssklower #define TPP_acktime 0x85 16536407Ssklower #define TPP_residER 0x86 16636407Ssklower #define TPP_priority 0x87 16736407Ssklower #define TPP_transdelay 0x88 16836407Ssklower #define TPP_throughput 0x89 16936407Ssklower #define TPP_subseq 0x8a 17036407Ssklower #define TPP_flow_cntl_conf 0x8c /* not implemented */ 17136407Ssklower #define TPP_addl_info 0xe0 17236407Ssklower #define TPP_tpdu_size 0xc0 17336407Ssklower #define TPP_calling_sufx 0xc1 17436407Ssklower #define TPP_invalid_tpdu 0xc1 /* the bozos used a value twice */ 17536407Ssklower #define TPP_called_sufx 0xc2 17636407Ssklower #define TPP_checksum 0xc3 17736407Ssklower #define TPP_vers 0xc4 17836407Ssklower #define TPP_security 0xc5 17936407Ssklower #define TPP_addl_opt 0xc6 18036407Ssklower #define TPP_alt_class 0xc7 18136407Ssklower #define TPP_perf_meas 0xc8 /* local item : perf meas on, svp */ 18251257Ssklower #define TPP_ptpdu_size 0xf0 /* preferred TPDU size */ 18351257Ssklower #define TPP_inact_time 0xf2 /* inactivity time exchanged */ 18436407Ssklower 18551257Ssklower 18636407Ssklower /****************************************************** 18736407Ssklower * Some fundamental data types 18836407Ssklower *****************************************************/ 18936407Ssklower #ifndef TRUE 19036407Ssklower #define TRUE 1 19160359Sbostic #endif /* TRUE */ 19236407Ssklower 19336407Ssklower #ifndef FALSE 19436407Ssklower #define FALSE 0 19560359Sbostic #endif /* FALSE */ 19636407Ssklower 19736407Ssklower #define TP_LOCAL 22 19836407Ssklower #define TP_FOREIGN 33 19936407Ssklower 20036407Ssklower #ifndef EOK 20136407Ssklower #define EOK 0 20260359Sbostic #endif /* EOK */ 20336407Ssklower 20436407Ssklower #define TP_CLASS_0 (1<<0) 20536407Ssklower #define TP_CLASS_1 (1<<1) 20636407Ssklower #define TP_CLASS_2 (1<<2) 20736407Ssklower #define TP_CLASS_3 (1<<3) 20836407Ssklower #define TP_CLASS_4 (1<<4) 20936407Ssklower 21036407Ssklower #define TP_FORCE 0x1 21136407Ssklower #define TP_STRICT 0x2 21236407Ssklower 21336407Ssklower #ifndef MNULL 21436407Ssklower #define MNULL (struct mbuf *)0 21560359Sbostic #endif /* MNULL */ 21637536Smckusick /* if ../sys/mbuf.h gets MT_types up to 0x40, these will 21736407Ssklower * have to be changed: 21836407Ssklower */ 21936407Ssklower #define MT_XPD 0x44 22036407Ssklower #define MT_EOT 0x40 22136407Ssklower 22236407Ssklower #define TP_ENOREF 0x80000000 22336407Ssklower 22436407Ssklower typedef unsigned int SeqNum; 22536407Ssklower typedef unsigned short RefNum; 22636407Ssklower typedef int ProtoHook; 22736407Ssklower 22836407Ssklower /****************************************************** 22936407Ssklower * Macro used all over, for driver 23036407Ssklower *****************************************************/ 23136407Ssklower 23236407Ssklower #define DoEvent(x) \ 23336407Ssklower ((E.ev_number=(x)),(tp_driver(tpcb,&E))) 23436407Ssklower 23536407Ssklower /****************************************************** 23636407Ssklower * Some macros used all over, for timestamping 23736407Ssklower *****************************************************/ 23836407Ssklower 23936407Ssklower #define GET_CUR_TIME(tvalp) ((*tvalp) = time) 24036407Ssklower 24136407Ssklower #define GET_TIME_SINCE(oldtvalp, diffp) {\ 24236407Ssklower (diffp)->tv_sec = time.tv_sec - (oldtvalp)->tv_sec;\ 24336407Ssklower (diffp)->tv_usec = time.tv_usec - (oldtvalp)->tv_usec;\ 24436407Ssklower if( (diffp)->tv_usec <0 ) {\ 24536407Ssklower (diffp)->tv_sec --;\ 24636407Ssklower (diffp)->tv_usec = 1000000 - (diffp)->tv_usec;\ 24736407Ssklower }\ 24836407Ssklower } 24936407Ssklower 25036407Ssklower /****************************************************** 25136407Ssklower * Some macros used for address families 25236407Ssklower *****************************************************/ 25336407Ssklower 25436407Ssklower #define satosiso(ADDR) ((struct sockaddr_iso *)(ADDR)) 25536407Ssklower #define satosin(ADDR) ((struct sockaddr_in *)(ADDR)) 25636407Ssklower 25736407Ssklower /****************************************************** 25836407Ssklower * Macro used for changing types of mbufs 25936407Ssklower *****************************************************/ 26036407Ssklower 26136407Ssklower #define CHANGE_MTYPE(m, TYPE)\ 26236407Ssklower if((m)->m_type != TYPE) { \ 26336407Ssklower mbstat.m_mtypes[(m)->m_type]--; mbstat.m_mtypes[TYPE]++; \ 26436407Ssklower (m)->m_type = TYPE; \ 26536407Ssklower } 26636407Ssklower 26736407Ssklower /****************************************************** 26836407Ssklower * Macros used for adding options to a tpdu header and for 26936407Ssklower * parsing the headers. 27036407Ssklower * Options are variable-length and must be bcopy-d because on the 27136407Ssklower * RT your assignments must be N-word aligned for objects of length 27236407Ssklower * N. Such a drag. 27336407Ssklower *****************************************************/ 27436407Ssklower 27536407Ssklower struct tp_vbp { 27636407Ssklower u_char tpv_code; 27736407Ssklower char tpv_len; 27836407Ssklower char tpv_val; 27936407Ssklower }; 28036407Ssklower #define vbptr(x) ((struct tp_vbp *)(x)) 28136407Ssklower #define vbval(x,type) (*((type *)&(((struct tp_vbp *)(x))->tpv_val))) 28236407Ssklower #define vbcode(x) (vbptr(x)->tpv_code) 28336407Ssklower #define vblen(x) (vbptr(x)->tpv_len) 28436407Ssklower 28536407Ssklower #define vb_putval(dst,type,src)\ 28636407Ssklower bcopy((caddr_t)&(src),(caddr_t)&(((struct tp_vbp *)(dst))->tpv_val),\ 28736407Ssklower sizeof(type)) 28836407Ssklower 28936407Ssklower #define vb_getval(src,type,dst)\ 29036407Ssklower bcopy((caddr_t)&(((struct tp_vbp *)(src))->tpv_val),(caddr_t)&(dst),sizeof(type)) 29136407Ssklower 29236407Ssklower #define ADDOPTION(type, DU, len, src)\ 29336407Ssklower { register caddr_t P;\ 29436407Ssklower P = (caddr_t)(DU) + (int)((DU)->tpdu_li);\ 29536407Ssklower vbptr(P)->tpv_code = type;\ 29636407Ssklower vbptr(P)->tpv_len = len;\ 29737469Ssklower bcopy((caddr_t)&src, (caddr_t)&(vbptr(P)->tpv_val), (unsigned)len);\ 29836407Ssklower DU->tpdu_li += len+2;/* 1 for code, 1 for length */\ 29936407Ssklower } 30036407Ssklower /****************************************************** 30136407Ssklower * Macro for the local credit: 30236407Ssklower * uses max transmission unit for the ll 30336407Ssklower * (as modified by the max TPDU size negotiated) 30436407Ssklower *****************************************************/ 30536407Ssklower 30636407Ssklower #if defined(ARGO_DEBUG)&&!defined(LOCAL_CREDIT_EXPAND) 30736407Ssklower #define LOCAL_CREDIT(tpcb) tp_local_credit(tpcb) 30836407Ssklower #else 30951204Ssklower #define LOCAL_CREDIT(tpcb) { if (tpcb->tp_rsycnt == 0) {\ 31039920Ssklower register struct sockbuf *xxsb = &((tpcb)->tp_sock->so_rcv);\ 31150975Ssklower register int xxi = sbspace(xxsb);\ 31250975Ssklower xxi = (xxi<0) ? 0 : ((xxi) / (tpcb)->tp_l_tpdusize);\ 31350975Ssklower xxi = min(xxi, (tpcb)->tp_maxlcredit); \ 31439920Ssklower if (!(tpcb->tp_cebit_off)) { \ 31539920Ssklower (tpcb)->tp_lcredit = ROUND((tpcb)->tp_win_recv); \ 31639920Ssklower if (xxi < (tpcb)->tp_lcredit) { \ 31739920Ssklower (tpcb)->tp_lcredit = xxi; \ 31839920Ssklower } \ 31951204Ssklower } else \ 32039920Ssklower (tpcb)->tp_lcredit = xxi; \ 32151204Ssklower } } 32260359Sbostic #endif /* ARGO_DEBUG */ 32336407Ssklower 32436407Ssklower #ifdef KERNEL 32551257Ssklower extern int tp_rttadd, tp_rttdiv; 32656533Sbostic #include <sys/syslog.h> 32750975Ssklower #define printf logpri(LOG_DEBUG),addlog 32836407Ssklower 32936407Ssklower #ifndef tp_NSTATES 33036407Ssklower 33156533Sbostic #include <netiso/tp_states.h> 33256533Sbostic #include <netiso/tp_events.h> 33350236Ssklower #if defined(__STDC__) || defined(__cplusplus) 33450236Ssklower #undef ATTR 33550236Ssklower #define ATTR(X) ev_union.EV_ ## X 33650236Ssklower #endif /* defined(__STDC__) || defined(__cplusplus) */ 33736407Ssklower 33860359Sbostic #endif /* tp_NSTATES */ 33960359Sbostic #endif /* KERNEL */ 34036407Ssklower 34160359Sbostic #endif /* __TP_PARAM__ */ 342