diff options
88 files changed, 11601 insertions, 9395 deletions
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index f28a9f79f04..4cf3e2f7fce 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_output.c,v 1.4 1996/03/03 22:30:41 niklas Exp $ */ +/* $OpenBSD: ip_output.c,v 1.5 1996/03/04 10:34:33 mickey Exp $ */ /* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */ /* @@ -65,7 +65,7 @@ static struct mbuf *ip_insertoptions __P((struct mbuf *, struct mbuf *, int *)); static void ip_mloopback __P((struct ifnet *, struct mbuf *, struct sockaddr_in *)); #if defined(IPFILTER) || defined(IPFILTER_LKM) -extern int (*fr_checkp) __P((struct ip *, int, struct ifnet *, int, struct mbuf **)); +int (*fr_checkp) __P((struct ip *, int, struct ifnet *, int, struct mbuf **)); #endif /* diff --git a/sys/netiso/argo_debug.h b/sys/netiso/argo_debug.h index 232aff53185..c1e7e02c7c0 100644 --- a/sys/netiso/argo_debug.h +++ b/sys/netiso/argo_debug.h @@ -1,4 +1,5 @@ -/* $NetBSD: argo_debug.h,v 1.6 1995/08/16 00:38:53 mycroft Exp $ */ +/* $OpenBSD: argo_debug.h,v 1.2 1996/03/04 10:34:40 mickey Exp $ */ +/* $NetBSD: argo_debug.h,v 1.7 1996/02/13 22:07:57 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -64,25 +65,15 @@ SOFTWARE. #ifndef _NETISO_ARGO_DEBUG_H_ #define _NETISO_ARGO_DEBUG_H_ - +void Dump_buf __P((caddr_t, int)); #define dump_buf(a, b) Dump_buf((caddr_t)(a), (int)(b)) /*********************************************** - * Lint stuff - **********************************************/ -#if defined(lint) -/* - * lint can't handle the flaky vacuous definitions - * of IFDEBUG, ENDDEBUG, etc. - */ -#endif /* defined(lint) */ - -/*********************************************** * DEBUG ON: **********************************************/ #ifndef ARGO_DEBUG #define ARGO_DEBUG -#endif /* ARGO_DEBUG */ +#endif /* ARGO_DEBUG */ #ifdef ARGO_DEBUG @@ -96,43 +87,27 @@ SOFTWARE. #endif TP_PERF_MEAS */ -unsigned char argo_debug[128]; - -#define IFDEBUG(ascii) \ - if(argo_debug[ascii]) { -#define ENDDEBUG ; } +unsigned char argo_debug[128]; -#else /* ARGO_DEBUG */ +#endif /* ARGO_DEBUG */ /*********************************************** - * DEBUG OFF: - **********************************************/ - -#ifndef STAR -#define STAR * -#endif /* STAR */ -#define IFDEBUG(ascii) //*beginning of comment*/STAR -#define ENDDEBUG STAR/*end of comment*// - -#endif /* ARGO_DEBUG */ - -/*********************************************** - * ASSERT + * ASSERT **********************************************/ #ifdef ARGO_DEBUG #ifndef lint #define ASSERT(phrase) \ if( !(phrase) ) printf("ASSERTION NOT VALID at line %d file %s\n",__LINE__,__FILE__) -#else /* lint */ -#define ASSERT(phrase) /* phrase */ -#endif /* lint */ +#else /* lint */ +#define ASSERT(phrase) /* phrase */ +#endif /* lint */ -#else /* ARGO_DEBUG */ +#else /* ARGO_DEBUG */ -#define ASSERT(phrase) /* phrase */ +#define ASSERT(phrase) /* phrase */ -#endif /* ARGO_DEBUG */ +#endif /* ARGO_DEBUG */ /*********************************************** @@ -158,23 +133,21 @@ if( !(phrase) ) printf("ASSERTION NOT VALID at line %d file %s\n",__LINE__,__FIL /* clnp over token ring */ #define D_ADCOM '\12' /* clnp over the adcom */ -#define D_ISO '\13' +#define D_ISO '\13' /* iso address family */ #define D_FORWARD '\14' /* clnp forwarding */ #define D_DUMPOUT '\15' /* dump clnp outgoing packets */ -#define D_DUMPIN '\16' +#define D_DUMPIN '\16' /* dump clnp input packets */ -#define D_DISCARD '\17' +#define D_DISCARD '\17' /* debug clnp packet discard/er function */ -#define D_FRAG '\20' +#define D_FRAG '\20' /* clnp fragmentation */ -#define D_REASS '\21' +#define D_REASS '\21' /* clnp reassembly */ -char *clnp_iso_addrp(); - /*********************************************** * ESIS DEBUG OPTIONS **********************************************/ @@ -256,8 +229,6 @@ char *clnp_iso_addrp(); #define D_TPISO '\176' #define D_QUENCH '\177' -void dump_mbuf(); - /*********************************************** * New mbuf types for debugging w/ netstat -m * This messes up 4.4 malloc for now. need bigger @@ -272,15 +243,17 @@ void dump_mbuf(); #define TPMT_EOT 0x40 #define TPMT_XPD 0x44 -#else /* ARGO_DEBUG */ +#else /* ARGO_DEBUG */ #define TPMT_DATA MT_DATA +#define TPMT_RCVRTC MT_DATA +#define TPMT_SNDRTC MT_DATA #define TPMT_IPHDR MT_HEADER #define TPMT_TPHDR MT_HEADER #define TPMT_SONAME MT_SONAME /* MT_EOT and MT_XPD are defined in tp_param.h */ #define TPMT_XPD MT_OOBDATA -#endif /* ARGO_DEBUG */ +#endif /* ARGO_DEBUG */ -#endif /* _NETISO_ARGO_DEBUG_H_ */ +#endif /* _NETISO_ARGO_DEBUG_H_ */ diff --git a/sys/netiso/clnl.h b/sys/netiso/clnl.h index db912385a00..ccc9f67b4fd 100644 --- a/sys/netiso/clnl.h +++ b/sys/netiso/clnl.h @@ -1,4 +1,5 @@ -/* $NetBSD: clnl.h,v 1.5 1994/06/29 06:39:04 cgd Exp $ */ +/* $OpenBSD: clnl.h,v 1.2 1996/03/04 10:34:42 mickey Exp $ */ +/* $NetBSD: clnl.h,v 1.6 1996/02/13 22:08:02 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -62,5 +63,6 @@ SOFTWARE. * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ struct clnl_protosw { - void (*clnl_input)(); /* input routine */ + /* input routine */ + void (*clnl_input) __P((struct mbuf *, ...)); }; diff --git a/sys/netiso/clnp.h b/sys/netiso/clnp.h index 4c7abbc1c14..c90f8f2c8a0 100644 --- a/sys/netiso/clnp.h +++ b/sys/netiso/clnp.h @@ -1,4 +1,5 @@ -/* $NetBSD: clnp.h,v 1.9 1995/06/13 07:13:14 mycroft Exp $ */ +/* $OpenBSD: clnp.h,v 1.2 1996/03/04 10:34:44 mickey Exp $ */ +/* $NetBSD: clnp.h,v 1.10 1996/02/13 22:08:09 christos Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -93,16 +94,19 @@ SOFTWARE. * Fixed part of clnp header */ struct clnp_fixed { - u_char cnf_proto_id; /* network layer protocol identifier */ - u_char cnf_hdr_len; /* length indicator (octets) */ - u_char cnf_vers; /* version/protocol identifier extension */ - u_char cnf_ttl; /* lifetime (500 milliseconds) */ - u_char cnf_type; /* type code */ - /* Includes err_ok, more_segs, and seg_ok */ - u_char cnf_seglen_msb; /* pdu segment length (octets) high byte */ - u_char cnf_seglen_lsb; /* pdu segment length (octets) low byte */ - u_char cnf_cksum_msb; /* checksum high byte */ - u_char cnf_cksum_lsb; /* checksum low byte */ + u_char cnf_proto_id; /* network layer protocol identifier */ + u_char cnf_hdr_len; /* length indicator (octets) */ + u_char cnf_vers; /* version/protocol identifier + * extension */ + u_char cnf_ttl;/* lifetime (500 milliseconds) */ + u_char cnf_type; /* type code */ + /* Includes err_ok, more_segs, and seg_ok */ + u_char cnf_seglen_msb; /* pdu segment length (octets) high + * byte */ + u_char cnf_seglen_lsb; /* pdu segment length (octets) low + * byte */ + u_char cnf_cksum_msb; /* checksum high byte */ + u_char cnf_cksum_lsb; /* checksum low byte */ }; #define CNF_TYPE 0x1f #define CNF_ERR_OK 0x20 @@ -117,17 +121,17 @@ struct clnp_fixed { * Segmentation part of clnp header */ struct clnp_segment { - u_short cng_id; /* data unit identifier */ - u_short cng_off; /* segment offset */ - u_short cng_tot_len; /* total length */ + u_short cng_id; /* data unit identifier */ + u_short cng_off;/* segment offset */ + u_short cng_tot_len; /* total length */ }; /* * Clnp fragment reassembly structures: * - * All packets undergoing reassembly are linked together in + * All packets undergoing reassembly are linked together in * clnp_fragl structures. Each clnp_fragl structure contains a - * pointer to the original clnp packet header, as well as a + * pointer to the original clnp packet header, as well as a * list of packet fragments. Each packet fragment * is headed by a clnp_frag structure. This structure contains the * offset of the first and last byte of the fragment, as well as @@ -136,31 +140,31 @@ struct clnp_segment { /* * NOTE: - * The clnp_frag structure is stored in an mbuf immedately preceeding - * the fragment data. Since there are words in this struct, - * it must be word aligned. + * The clnp_frag structure is stored in an mbuf immedately + * preceeding the fragment data. Since there are words in + * this struct, it must be word aligned. * * NOTE: - * All the fragment code assumes that the entire clnp header is - * contained in the first mbuf. + * All the fragment code assumes that the entire clnp header is + * contained in the first mbuf. */ struct clnp_frag { - u_int cfr_first; /* offset of first byte of this frag */ - u_int cfr_last; /* offset of last byte of this frag */ - u_int cfr_bytes; /* bytes to shave to get to data */ - struct mbuf *cfr_data; /* ptr to data for this frag */ - struct clnp_frag *cfr_next; /* next fragment in list */ + u_int cfr_first; /* offset of first byte of this frag */ + u_int cfr_last; /* offset of last byte of this frag */ + u_int cfr_bytes; /* bytes to shave to get to data */ + struct mbuf *cfr_data; /* ptr to data for this frag */ + struct clnp_frag *cfr_next; /* next fragment in list */ }; struct clnp_fragl { - struct iso_addr cfl_src; /* source of the pkt */ - struct iso_addr cfl_dst; /* destination of the pkt */ - u_short cfl_id; /* id of the pkt */ - u_char cfl_ttl; /* current ttl of pkt */ - u_short cfl_last; /* offset of last byte of packet */ - struct mbuf *cfl_orighdr; /* ptr to original header */ - struct clnp_frag *cfl_frags; /* linked list of fragments for pkt */ - struct clnp_fragl *cfl_next; /* next pkt being reassembled */ + struct iso_addr cfl_src;/* source of the pkt */ + struct iso_addr cfl_dst;/* destination of the pkt */ + u_short cfl_id; /* id of the pkt */ + u_char cfl_ttl;/* current ttl of pkt */ + u_short cfl_last; /* offset of last byte of packet */ + struct mbuf *cfl_orighdr; /* ptr to original header */ + struct clnp_frag *cfl_frags; /* linked list of fragments for pkt */ + struct clnp_fragl *cfl_next; /* next pkt being reassembled */ }; /* @@ -175,53 +179,53 @@ struct clnp_fragl { * does not include the option code or option length fields. */ struct clnp_optidx { - u_short cni_securep; /* ptr to beginning of security option */ - char cni_secure_len; /* length of entire security option */ + u_short cni_securep; /* ptr to start of security option */ + char cni_secure_len; /* length of entire security option */ - u_short cni_srcrt_s; /* offset of start of src rt option */ - u_short cni_srcrt_len; /* length of entire src rt option */ + u_short cni_srcrt_s; /* offset of start of src rt option */ + u_short cni_srcrt_len; /* length of entire src rt option */ - u_short cni_recrtp; /* ptr to beginning of recrt option */ - char cni_recrt_len; /* length of entire recrt option */ + u_short cni_recrtp; /* ptr to beginning of recrt option */ + char cni_recrt_len; /* length of entire recrt option */ - char cni_priorp; /* ptr to priority option */ + char cni_priorp; /* ptr to priority option */ - u_short cni_qos_formatp; /* ptr to format of qos option */ - char cni_qos_len; /* length of entire qos option */ + u_short cni_qos_formatp; /* ptr to format of qos + * option */ + char cni_qos_len; /* length of entire qos option */ - u_char cni_er_reason; /* reason from ER pdu option */ + u_char cni_er_reason; /* reason from ER pdu option */ - /* ESIS options */ + /* ESIS options */ - u_short cni_esct; /* value from ISH ESCT option */ + u_short cni_esct; /* value from ISH ESCT option */ - u_short cni_netmaskp; /* ptr to beginning of netmask option */ - char cni_netmask_len; /* length of entire netmask option */ + u_short cni_netmaskp; /* ptr to beginning of netmask option */ + char cni_netmask_len; /* length of entire netmask + * option */ - u_short cni_snpamaskp; /* ptr to beginning of snpamask option */ - char cni_snpamask_len; /* length of entire snpamask option */ + u_short cni_snpamaskp; /* ptr to start of snpamask option */ + char cni_snpamask_len; /* length of entire snpamask + * option */ }; #define ER_INVALREAS 0xff /* code for invalid ER pdu discard reason */ /* given an mbuf and addr of option, return offset from data of mbuf */ -#define CLNP_OPTTOOFF(m, opt)\ - ((u_short) (opt - mtod(m, caddr_t))) +#define CLNP_OPTTOOFF(m, opt) ((u_short) (opt - mtod(m, caddr_t))) /* given an mbuf and offset of option, return address of option */ -#define CLNP_OFFTOOPT(m, off)\ - ((caddr_t) (mtod(m, caddr_t) + off)) +#define CLNP_OFFTOOPT(m, off) ((caddr_t) (mtod(m, caddr_t) + off)) -/* return true iff src route is valid */ -#define CLNPSRCRT_VALID(oidx)\ - ((oidx) && (oidx->cni_srcrt_s)) +/* return true iff src route is valid */ +#define CLNPSRCRT_VALID(oidx) ((oidx) && (oidx->cni_srcrt_s)) -/* return the offset field of the src rt */ +/* return the offset field of the src rt */ #define CLNPSRCRT_OFF(oidx, options)\ (*((u_char *)(CLNP_OFFTOOPT(options, oidx->cni_srcrt_s) + 1))) -/* return the type field of the src rt */ +/* return the type field of the src rt */ #define CLNPSRCRT_TYPE(oidx, options)\ ((u_char)(*(CLNP_OFFTOOPT(options, oidx->cni_srcrt_s)))) @@ -233,9 +237,9 @@ struct clnp_optidx { #define CLNPSRCRT_CADDR(oidx, options)\ ((caddr_t)(CLNP_OFFTOOPT(options, oidx->cni_srcrt_s) + CLNPSRCRT_OFF(oidx, options))) -/* - * return true if the src route has run out of routes - * this is true if the offset of next route is greater than the end of the rt +/* + * return true if the src route has run out of routes this is true if the + * offset of next route is greater than the end of the rt */ #define CLNPSRCRT_TERM(oidx, options)\ (CLNPSRCRT_OFF(oidx, options) > oidx->cni_srcrt_len) @@ -270,37 +274,38 @@ struct clnp_optidx { #define CLNPOVAL_COMPRT 0x01 /* complete source routing */ /* - * Clnp flags used in a control block flags field. + * Clnp flags used in a control block flags field. * NOTE: these must be out of the range of bits defined in ../net/raw_cb.h */ #define CLNP_NO_SEG 0x010 /* segmentation not permitted */ #define CLNP_NO_ER 0x020 /* do not generate ERs */ -#define CLNP_SEND_RAW 0x080 /* send pkt as RAW DT rather than TP DT */ -#define CLNP_NO_CKSUM 0x100 /* don't use clnp checksum */ +#define CLNP_SEND_RAW 0x080 /* send pkt as RAW DT not TP DT */ +#define CLNP_NO_CKSUM 0x100 /* don't use clnp checksum */ #define CLNP_ECHO 0x200 /* send echo request */ -#define CLNP_NOCACHE 0x400 /* don't store cache information */ +#define CLNP_NOCACHE 0x400 /* don't store cache information */ #define CLNP_ECHOR 0x800 /* send echo reply */ /* valid clnp flags */ -#define CLNP_VFLAGS (CLNP_SEND_RAW|CLNP_NO_SEG|CLNP_NO_ER|CLNP_NO_CKSUM\ - |CLNP_ECHO|CLNP_NOCACHE|CLNP_ECHOR) +#define CLNP_VFLAGS \ + (CLNP_SEND_RAW|CLNP_NO_SEG|CLNP_NO_ER|CLNP_NO_CKSUM|\ + CLNP_ECHO|CLNP_NOCACHE|CLNP_ECHOR) -/* - * Constants used by clnp +/* + * Constants used by clnp */ #define CLNP_HDR_MIN (sizeof (struct clnp_fixed)) #define CLNP_HDR_MAX (254) -#define CLNP_TTL_UNITS 2 /* 500 milliseconds */ -#define CLNP_TTL 15*CLNP_TTL_UNITS /* time to live (seconds) */ -#define ISO8473_V1 0x01 +#define CLNP_TTL_UNITS 2 /* 500 milliseconds */ +#define CLNP_TTL 15*CLNP_TTL_UNITS /* time to live (seconds) */ +#define ISO8473_V1 0x01 /* * Clnp packet types * In order to test raw clnp and tp/clnp simultaneously, a third type of * packet has been defined: CLNP_RAW. This is done so that the input * routine can switch to the correct input routine (rclnp_input or - * tpclnp_input) based on the type field. If clnp had a higher level protocol - * field, this would not be necessary. + * tpclnp_input) based on the type field. If clnp had a higher level + * protocol field, this would not be necessary. */ #define CLNP_DT 0x1C /* normal data */ #define CLNP_ER 0x01 /* error report */ @@ -311,14 +316,14 @@ struct clnp_optidx { /* * ER pdu error codes */ -#define GEN_NOREAS 0x00 /* reason not specified */ +#define GEN_NOREAS 0x00 /* reason not specified */ #define GEN_PROTOERR 0x01 /* protocol procedure error */ -#define GEN_BADCSUM 0x02 /* incorrect checksum */ -#define GEN_CONGEST 0x03 /* pdu discarded due to congestion */ +#define GEN_BADCSUM 0x02 /* incorrect checksum */ +#define GEN_CONGEST 0x03 /* pdu discarded due to congestion */ #define GEN_HDRSYNTAX 0x04 /* header syntax error */ -#define GEN_SEGNEEDED 0x05 /* segmentation needed, but not permitted */ +#define GEN_SEGNEEDED 0x05 /* need segmentation but not allowed */ #define GEN_INCOMPLETE 0x06 /* incomplete pdu received */ -#define GEN_DUPOPT 0x07 /* duplicate option */ +#define GEN_DUPOPT 0x07 /* duplicate option */ /* address errors */ #define ADDR_DESTUNREACH 0x80 /* destination address unreachable */ @@ -346,19 +351,16 @@ struct clnp_optidx { #define CLNP_ERRORS 22 -#ifdef _KERNEL -int clnp_er_index(); -#endif - #ifdef CLNP_ER_CODES -u_char clnp_er_codes[CLNP_ERRORS] = { -GEN_NOREAS, GEN_PROTOERR, GEN_BADCSUM, GEN_CONGEST, -GEN_HDRSYNTAX, GEN_SEGNEEDED, GEN_INCOMPLETE, GEN_DUPOPT, -ADDR_DESTUNREACH, ADDR_DESTUNKNOWN, -SRCRT_UNSPECERR, SRCRT_SYNTAX, SRCRT_UNKNOWNADDR, SRCRT_BADPATH, -TTL_EXPTRANSIT, TTL_EXPREASS, -DISC_UNSUPPOPT, DISC_UNSUPPVERS, DISC_UNSUPPSECURE, -DISC_UNSUPPSRCRT, DISC_UNSUPPRECRT, REASS_INTERFERE }; +u_char clnp_er_codes[CLNP_ERRORS] = { + GEN_NOREAS, GEN_PROTOERR, GEN_BADCSUM, GEN_CONGEST, + GEN_HDRSYNTAX, GEN_SEGNEEDED, GEN_INCOMPLETE, GEN_DUPOPT, + ADDR_DESTUNREACH, ADDR_DESTUNKNOWN, + SRCRT_UNSPECERR, SRCRT_SYNTAX, SRCRT_UNKNOWNADDR, SRCRT_BADPATH, + TTL_EXPTRANSIT, TTL_EXPREASS, + DISC_UNSUPPOPT, DISC_UNSUPPVERS, DISC_UNSUPPSECURE, + DISC_UNSUPPSRCRT, DISC_UNSUPPRECRT, REASS_INTERFERE +}; #endif #ifdef TROLL @@ -370,15 +372,17 @@ DISC_UNSUPPSRCRT, DISC_UNSUPPRECRT, REASS_INTERFERE }; #define TR_CHANGE 0x10 /* change bytes in packet */ #define TR_MTU 0x20 /* delta to change device mtu */ #define TR_CHUCK 0x40 /* drop packet in rclnp_input */ -#define TR_BLAST 0x80 /* force rclnp_output to blast many packet */ -#define TR_RAWLOOP 0x100 /* make if_loop call clnpintr directly */ +#define TR_BLAST 0x80 /* force rclnp_output to blast many + * packet */ +#define TR_RAWLOOP 0x100 /* make if_loop call clnpintr + * directly */ struct troll { - int tr_ops; /* operations to perform */ - float tr_dup_size; /* % to duplicate */ - float tr_dup_freq; /* frequency to duplicate packets */ - float tr_drop_freq; /* frequence to drop packets */ - int tr_mtu_adj; /* delta to adjust if mtu */ - int tr_blast_cnt; /* # of pkts to blast out */ + int tr_ops; /* operations to perform */ + float tr_dup_size; /* % to duplicate */ + float tr_dup_freq; /* frequency to duplicate packets */ + float tr_drop_freq; /* frequence to drop packets */ + int tr_mtu_adj; /* delta to adjust if mtu */ + int tr_blast_cnt; /* # of pkts to blast out */ }; #define SN_OUTPUT(clcp, m)\ @@ -389,18 +393,19 @@ struct troll { - trollctl.tr_mtu_adj) #ifdef _KERNEL -extern float troll_random; +extern float troll_random; #endif -#else /* NO TROLL */ +#else /* NO TROLL */ #define SN_OUTPUT(clcp, m)\ - (*clcp->clc_ifp->if_output)(clcp->clc_ifp, m, clcp->clc_firsthop, clcp->clc_rt) + (*clcp->clc_ifp->if_output)(clcp->clc_ifp, m, clcp->clc_firsthop, \ + clcp->clc_rt) #define SN_MTU(ifp, rt) (((rt && rt->rt_rmx.rmx_mtu) ?\ rt->rt_rmx.rmx_mtu : clnp_badmtu(ifp, rt, __LINE__, __FILE__))) -#endif /* TROLL */ +#endif /* TROLL */ /* * Macro to remove an address from a clnp header @@ -412,7 +417,8 @@ extern float troll_random; (isoa.isoa_len > 20) || (isoa.isoa_len == 0)) {\ hoff = (caddr_t)0;\ } else {\ - (void) bcopy(hoff, (caddr_t)isoa.isoa_genaddr, isoa.isoa_len);\ + (void) bcopy(hoff, (caddr_t)isoa.isoa_genaddr, \ + isoa.isoa_len);\ hoff += isoa.isoa_len;\ }\ } @@ -434,25 +440,109 @@ extern float troll_random; */ struct clnp_cache { /* these fields are used to check the validity of the cache */ - struct iso_addr clc_dst; /* destination of packet */ - struct mbuf *clc_options; /* ptr to options mbuf */ - int clc_flags; /* flags passed to clnp_output */ + struct iso_addr clc_dst;/* destination of packet */ + struct mbuf *clc_options; /* ptr to options mbuf */ + int clc_flags; /* flags passed to clnp_output */ /* these fields are state that clnp_output requires to finish the pkt */ - int clc_segoff; /* offset of seg part of header */ - struct rtentry *clc_rt; /* ptr to rtentry (points into - the route structure) */ - struct sockaddr *clc_firsthop; /* first hop of packet */ - struct ifnet *clc_ifp; /* ptr to interface structure */ - struct iso_ifaddr *clc_ifa; /* ptr to interface address */ - struct mbuf *clc_hdr; /* cached pkt hdr (finally)! */ + int clc_segoff; /* offset of seg part of header */ + struct rtentry *clc_rt; /* ptr to rtentry (points into the route + * structure) */ + struct sockaddr *clc_firsthop; /* first hop of packet */ + struct ifnet *clc_ifp;/* ptr to interface structure */ + struct iso_ifaddr + *clc_ifa;/* ptr to interface address */ + struct mbuf *clc_hdr;/* cached pkt hdr (finally)! */ }; #ifdef _KERNEL -caddr_t clnp_insert_addr(); -struct iso_addr *clnp_srcaddr(); -struct mbuf *clnp_reass(); +struct iso_addr; +struct sockaddr_iso; +struct mbuf; +struct clnp_segment; +struct sockaddr; +struct rt_entry; +struct clnp_fragl; +struct clnp_optidx; +struct isopcb; +struct snpa_hdr; +struct iso_ifaddr; +struct route_iso; + +/* clnp_debug.c */ +char *clnp_hexp __P((char *, int, char *)); +char *clnp_iso_addrp __P((struct iso_addr *)); +char *clnp_saddr_isop __P((struct sockaddr_iso *)); + +/* clnp_er.c */ +void clnp_er_input __P((struct mbuf *, struct iso_addr *, u_int)); +void clnp_discard __P((struct mbuf *, u_int)); +void clnp_emit_er __P((struct mbuf *, u_int)); +int clnp_er_index __P((u_int)); + +int clnp_fragment __P((struct ifnet *, struct mbuf *, struct sockaddr *, + int, int, int, struct rtentry *)); +struct mbuf *clnp_reass __P((struct mbuf *, struct iso_addr *, + struct iso_addr *, struct clnp_segment *)); +int clnp_newpkt __P((struct mbuf *, struct iso_addr *, struct iso_addr *, + struct clnp_segment *)); +void clnp_insert_frag __P((struct clnp_fragl *, struct mbuf *, + struct clnp_segment *)); +struct mbuf *clnp_comp_pdu __P((struct clnp_fragl *)); +#ifdef TROLL +float troll_random __P((void)); +int troll_output __P((struct ifnet *, struct mbuf *, struct sockaddr *, + struct rtentry *)); +#endif + +/* clnp_input.c */ +void clnp_init __P((void)); +void clnlintr __P((void)); +void clnp_input __P((struct mbuf *, ...)); + +/* clnp_options.c */ +void clnp_update_srcrt __P((struct mbuf *, struct clnp_optidx *)); +void clnp_dooptions __P((struct mbuf *, struct clnp_optidx *, struct ifnet *, + struct iso_addr *)); +int clnp_set_opts __P((struct mbuf **, struct mbuf **)); +int clnp_opt_sanity __P((struct mbuf *, caddr_t, int, struct clnp_optidx *)); + +/* clnp_output.c */ +int clnp_output __P((struct mbuf *, ...)); +void clnp_ctloutput __P((void)); + +/* clnp_raw.c */ +void rclnp_input __P((struct mbuf *, ...)); +int rclnp_output __P((struct mbuf *, ...)); +int rclnp_ctloutput __P((int, struct socket *, int, int, struct mbuf **)); +int clnp_usrreq __P((struct socket *, int, struct mbuf *, struct mbuf *, + struct mbuf *)); + +/* clnp_subr.c */ +struct mbuf *clnp_data_ck __P((struct mbuf *, int)); +caddr_t clnp_extract_addr __P((caddr_t, int, struct iso_addr *, + struct iso_addr *)); +int clnp_ours __P((struct iso_addr *)); +void clnp_forward __P((struct mbuf *, int, struct iso_addr *, + struct clnp_optidx *, int, struct snpa_hdr *)); +caddr_t clnp_insert_addr __P((caddr_t, struct iso_addr *, struct iso_addr *)); +int clnp_route __P((struct iso_addr *, struct route_iso *, int, + struct sockaddr **, struct iso_ifaddr **)); +int clnp_srcroute __P((struct mbuf *, struct clnp_optidx *, struct route_iso *, + struct sockaddr **, struct iso_ifaddr **, + struct iso_addr *)); +int clnp_echoreply __P((struct mbuf *, int, struct sockaddr_iso *, + struct sockaddr_iso *, struct clnp_optidx *)); +int clnp_badmtu __P((struct ifnet *, struct rtentry *, int, char *)); +void clnp_ypocb __P((caddr_t, caddr_t, u_int)); + +/* clnp_timer.c */ +struct clnp_fragl *clnp_freefrags __P((struct clnp_fragl *)); +void clnp_slowtimo __P((void)); +void clnp_drain __P((void)); + #ifdef TROLL -struct troll trollctl; -#endif /* TROLL */ -#endif /* _KERNEL */ +struct troll trollctl; +#endif /* TROLL */ + +#endif /* _KERNEL */ diff --git a/sys/netiso/clnp_debug.c b/sys/netiso/clnp_debug.c index 9c682a0f047..53493e5bf16 100644 --- a/sys/netiso/clnp_debug.c +++ b/sys/netiso/clnp_debug.c @@ -1,4 +1,5 @@ -/* $NetBSD: clnp_debug.c,v 1.5 1994/06/29 06:39:07 cgd Exp $ */ +/* $OpenBSD: clnp_debug.c,v 1.2 1996/03/04 10:34:46 mickey Exp $ */ +/* $NetBSD: clnp_debug.c,v 1.6 1996/02/13 22:08:13 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -69,6 +70,7 @@ SOFTWARE. #include <sys/socket.h> #include <sys/socketvar.h> #include <sys/errno.h> +#include <sys/systm.h> #include <net/if.h> #include <net/route.h> @@ -82,15 +84,15 @@ SOFTWARE. #ifdef TESTDEBUG #ifdef notdef -struct addr_37 u_37 = { - {0x00, 0x02, 0x00, 0x10, 0x20, 0x30, 0x35}, +struct addr_37 u_37 = { + {0x00, 0x02, 0x00, 0x10, 0x20, 0x30, 0x35}, {0x01, 0x02, 0x03, 0x04, 0x50, 0x60, 0x70, 0x80, 0x90} }; struct addr_osinet u_osinet = { {0x00, 0x04}, {0x00, 0x02, 0x00, 0x01, 0x23, 0x42, 0x78, 0x20, 0x01, 0x05, 0x00} }; -#endif /* notdef */ +#endif /* notdef */ struct addr_rfc986 u_rfc986 = { {0x00, 0x06}, {0x01, 0xc0, 0x0c, 0x0c, 0xab, 0x11} @@ -99,10 +101,13 @@ struct addr_rfc986 u_bad = { {0x00, 0x01}, {0x01, 0xc0, 0x0c, 0x0c, 0xab, 0x11} }; +int main __P((void)); + #include <stdio.h> +int main() { - struct iso_addr a; + struct iso_addr a; a.isoa_afi = AFI_37; a.isoa_u.addr_37 = u_37; @@ -128,11 +133,16 @@ main() a.isoa_u.addr_rfc986 = u_bad; a.isoa_len = 9; printf("type bad idi: %s\n", clnp_iso_addrp(&a)); + return 0; } -#endif /* TESTDEBUG */ +#endif /* TESTDEBUG */ -unsigned int clnp_debug; -static char letters[] = "0123456789abcdef"; +unsigned int clnp_debug; +static char letters[] = "0123456789abcdef"; + +char *clnp_hexp __P((char *, int, char *)); +char *clnp_iso_addrp __P((struct iso_addr *)); +char *clnp_saddr_isop __P((struct sockaddr_iso *)); /* * Print buffer in hex, return addr of where we left off. @@ -140,14 +150,14 @@ static char letters[] = "0123456789abcdef"; */ char * clnp_hexp(src, len, where) -char *src; /* src of data to print */ -int len; /* lengthof src */ -char *where; /* where to put data */ + char *src; /* src of data to print */ + int len; /* lengthof src */ + char *where; /* where to put data */ { - int i; + int i; - for (i=0; i<len; i++) { - register int j = ((u_char *)src)[i]; + for (i = 0; i < len; i++) { + register int j = ((u_char *) src)[i]; *where++ = letters[j >> 4]; *where++ = letters[j & 0x0f]; } @@ -155,16 +165,19 @@ char *where; /* where to put data */ } /* - * Return a ptr to a human readable form of an iso addr + * Return a ptr to a human readable form of an iso addr */ -static char iso_addr_b[50]; +static char iso_addr_b[50]; #define DELIM '.'; char * clnp_iso_addrp(isoa) -struct iso_addr *isoa; + struct iso_addr *isoa; { - char *cp; + char *cp; +#ifdef notdef + u_short idi; +#endif /* print length */ sprintf(iso_addr_b, "[%d] ", isoa->isoa_len); @@ -175,86 +188,88 @@ struct iso_addr *isoa; cp++; /* print afi */ - cp = clnp_hexp(isoa->isoa_genaddr, (int)isoa->isoa_len, cp); + cp = clnp_hexp(isoa->isoa_genaddr, (int) isoa->isoa_len, cp); #ifdef notdef *cp++ = DELIM; /* print type specific part */ - switch(isoa->isoa_afi) { - case AFI_37: - cp = clnp_hexp(isoa->t37_idi, ADDR37_IDI_LEN, cp); + switch (isoa->isoa_afi) { + case AFI_37: + cp = clnp_hexp(isoa->t37_idi, ADDR37_IDI_LEN, cp); + *cp++ = DELIM; + cp = clnp_hexp(isoa->t37_dsp, ADDR37_DSP_LEN, cp); + break; + + /* case AFI_OSINET: */ + case AFI_RFC986: + + /* osinet and rfc986 have idi in the same place */ + /* print idi */ + cp = clnp_hexp(isoa->rfc986_idi, + ADDROSINET_IDI_LEN, cp); + *cp++ = DELIM; + CTOH(isoa->rfc986_idi[0], isoa->rfc986_idi[1], idi); + + if (idi == IDI_OSINET) { + struct ovl_osinet *oosi = (struct ovl_osinet *) isoa; + cp = clnp_hexp(oosi->oosi_orgid, + OVLOSINET_ORGID_LEN, cp); *cp++ = DELIM; - cp = clnp_hexp(isoa->t37_dsp, ADDR37_DSP_LEN, cp); - break; - -/* case AFI_OSINET:*/ - case AFI_RFC986: { - u_short idi; - - /* osinet and rfc986 have idi in the same place */ - /* print idi */ - cp = clnp_hexp(isoa->rfc986_idi, ADDROSINET_IDI_LEN, cp); + cp = clnp_hexp(oosi->oosi_snetid, + OVLOSINET_SNETID_LEN, cp); + *cp++ = DELIM; + cp = clnp_hexp(oosi->oosi_snpa, OVLOSINET_SNPA_LEN, cp); + *cp++ = DELIM; + cp = clnp_hexp(oosi->oosi_nsap, OVLOSINET_NSAP_LEN, cp); + } else if (idi == IDI_RFC986) { + struct ovl_rfc986 *o986 = (struct ovl_rfc986 *) isoa; + cp = clnp_hexp(&o986->o986_vers, 1, cp); *cp++ = DELIM; - CTOH(isoa->rfc986_idi[0], isoa->rfc986_idi[1], idi); - - if (idi == IDI_OSINET) { - struct ovl_osinet *oosi = (struct ovl_osinet *)isoa; - cp = clnp_hexp(oosi->oosi_orgid, OVLOSINET_ORGID_LEN, cp); - *cp++ = DELIM; - cp = clnp_hexp(oosi->oosi_snetid, OVLOSINET_SNETID_LEN, cp); - *cp++ = DELIM; - cp = clnp_hexp(oosi->oosi_snpa, OVLOSINET_SNPA_LEN, cp); - *cp++ = DELIM; - cp = clnp_hexp(oosi->oosi_nsap, OVLOSINET_NSAP_LEN, cp); - } else if (idi == IDI_RFC986) { - struct ovl_rfc986 *o986 = (struct ovl_rfc986 *)isoa; - cp = clnp_hexp(&o986->o986_vers, 1, cp); - *cp++ = DELIM; #ifdef vax - sprintf(cp, "%d.%d.%d.%d.%d", + sprintf(cp, "%d.%d.%d.%d.%d", o986->o986_inetaddr[0] & 0xff, o986->o986_inetaddr[1] & 0xff, o986->o986_inetaddr[2] & 0xff, o986->o986_inetaddr[3] & 0xff, o986->o986_upid & 0xff); - return(iso_addr_b); + return (iso_addr_b); #else - cp = clnp_hexp(&o986->o986_inetaddr[0], 1, cp); - *cp++ = DELIM; - cp = clnp_hexp(&o986->o986_inetaddr[1], 1, cp); - *cp++ = DELIM; - cp = clnp_hexp(&o986->o986_inetaddr[2], 1, cp); - *cp++ = DELIM; - cp = clnp_hexp(&o986->o986_inetaddr[3], 1, cp); - *cp++ = DELIM; - cp = clnp_hexp(&o986->o986_upid, 1, cp); -#endif /* vax */ - } - - } break; - - default: - *cp++ = '?'; - break; + cp = clnp_hexp(&o986->o986_inetaddr[0], 1, cp); + *cp++ = DELIM; + cp = clnp_hexp(&o986->o986_inetaddr[1], 1, cp); + *cp++ = DELIM; + cp = clnp_hexp(&o986->o986_inetaddr[2], 1, cp); + *cp++ = DELIM; + cp = clnp_hexp(&o986->o986_inetaddr[3], 1, cp); + *cp++ = DELIM; + cp = clnp_hexp(&o986->o986_upid, 1, cp); +#endif /* vax */ + } + break; + + default: + *cp++ = '?'; + break; } #endif /* notdef */ - *cp = (char)0; - - return(iso_addr_b); + *cp = (char) 0; + + return (iso_addr_b); } char * clnp_saddr_isop(s) -register struct sockaddr_iso *s; + register struct sockaddr_iso *s; { - register char *cp = clnp_iso_addrp(&s->siso_addr); + register char *cp = clnp_iso_addrp(&s->siso_addr); - while (*cp) cp++; + while (*cp) + cp++; *cp++ = '('; - cp = clnp_hexp(TSEL(s), (int)s->siso_tlen, cp); + cp = clnp_hexp(TSEL(s), (int) s->siso_tlen, cp); *cp++ = ')'; *cp++ = 0; return (iso_addr_b); } -#endif /* ARGO_DEBUG */ +#endif /* ARGO_DEBUG */ diff --git a/sys/netiso/clnp_er.c b/sys/netiso/clnp_er.c index 98d81ada21f..f2eb126286c 100644 --- a/sys/netiso/clnp_er.c +++ b/sys/netiso/clnp_er.c @@ -1,4 +1,5 @@ -/* $NetBSD: clnp_er.c,v 1.6 1995/06/13 07:13:17 mycroft Exp $ */ +/* $OpenBSD: clnp_er.c,v 1.2 1996/03/04 10:34:48 mickey Exp $ */ +/* $NetBSD: clnp_er.c,v 1.7 1996/02/13 22:08:17 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -69,6 +70,7 @@ SOFTWARE. #include <sys/socket.h> #include <sys/socketvar.h> #include <sys/errno.h> +#include <sys/systm.h> #include <net/if.h> #include <net/route.h> @@ -80,15 +82,17 @@ SOFTWARE. #include <netiso/clnp.h> #include <netiso/clnp_stat.h> #include <netiso/argo_debug.h> +#include <netiso/tp_param.h> +#include <netiso/tp_var.h> static struct clnp_fixed er_template = { - ISO8473_CLNP, /* network identifier */ - 0, /* length */ + ISO8473_CLNP, /* network identifier */ + 0, /* length */ ISO8473_V1, /* version */ CLNP_TTL, /* ttl */ CLNP_ER, /* type */ - 0, /* segment length */ - 0 /* checksum */ + 0, /* segment length */ + 0 /* checksum */ }; /* @@ -96,76 +100,78 @@ static struct clnp_fixed er_template = { * * PURPOSE: Process an ER pdu. * - * RETURNS: + * RETURNS: * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ +void clnp_er_input(m, src, reason) -struct mbuf *m; /* ptr to packet itself */ -struct iso_addr *src; /* ptr to src of er */ -u_char reason; /* reason code of er */ + struct mbuf *m; /* ptr to packet itself */ + struct iso_addr *src; /* ptr to src of er */ + u_int reason; /* reason code of er */ { - int cmd = -1; - extern u_char clnp_protox[]; + int cmd = -1; - IFDEBUG(D_CTLINPUT) - printf("clnp_er_input: m x%x, src %s, reason x%x\n", m, - clnp_iso_addrp(src), reason); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_CTLINPUT]) { + printf("clnp_er_input: m x%x, src %s, reason x%x\n", + (unsigned int) m, clnp_iso_addrp(src), reason); + } +#endif INCSTAT(cns_er_inhist[clnp_er_index(reason)]); switch (reason) { - case GEN_NOREAS: - case GEN_PROTOERR: - break; - case GEN_BADCSUM: - cmd = PRC_PARAMPROB; - break; - case GEN_CONGEST: - cmd = PRC_QUENCH; - break; - case GEN_HDRSYNTAX: - cmd = PRC_PARAMPROB; - break; - case GEN_SEGNEEDED: - cmd = PRC_MSGSIZE; - break; - case GEN_INCOMPLETE: - cmd = PRC_PARAMPROB; - break; - case GEN_DUPOPT: - cmd = PRC_PARAMPROB; - break; - case ADDR_DESTUNREACH: - cmd = PRC_UNREACH_HOST; - break; - case ADDR_DESTUNKNOWN: - cmd = PRC_UNREACH_PROTOCOL; - break; - case SRCRT_UNSPECERR: - case SRCRT_SYNTAX: - case SRCRT_UNKNOWNADDR: - case SRCRT_BADPATH: - cmd = PRC_UNREACH_SRCFAIL; - break; - case TTL_EXPTRANSIT: - cmd = PRC_TIMXCEED_INTRANS; - break; - case TTL_EXPREASS: - cmd = PRC_TIMXCEED_REASS; - break; - case DISC_UNSUPPOPT: - case DISC_UNSUPPVERS: - case DISC_UNSUPPSECURE: - case DISC_UNSUPPSRCRT: - case DISC_UNSUPPRECRT: - cmd = PRC_PARAMPROB; - break; - case REASS_INTERFERE: - cmd = PRC_TIMXCEED_REASS; - break; + case GEN_NOREAS: + case GEN_PROTOERR: + break; + case GEN_BADCSUM: + cmd = PRC_PARAMPROB; + break; + case GEN_CONGEST: + cmd = PRC_QUENCH; + break; + case GEN_HDRSYNTAX: + cmd = PRC_PARAMPROB; + break; + case GEN_SEGNEEDED: + cmd = PRC_MSGSIZE; + break; + case GEN_INCOMPLETE: + cmd = PRC_PARAMPROB; + break; + case GEN_DUPOPT: + cmd = PRC_PARAMPROB; + break; + case ADDR_DESTUNREACH: + cmd = PRC_UNREACH_HOST; + break; + case ADDR_DESTUNKNOWN: + cmd = PRC_UNREACH_PROTOCOL; + break; + case SRCRT_UNSPECERR: + case SRCRT_SYNTAX: + case SRCRT_UNKNOWNADDR: + case SRCRT_BADPATH: + cmd = PRC_UNREACH_SRCFAIL; + break; + case TTL_EXPTRANSIT: + cmd = PRC_TIMXCEED_INTRANS; + break; + case TTL_EXPREASS: + cmd = PRC_TIMXCEED_REASS; + break; + case DISC_UNSUPPOPT: + case DISC_UNSUPPVERS: + case DISC_UNSUPPSECURE: + case DISC_UNSUPPSRCRT: + case DISC_UNSUPPRECRT: + cmd = PRC_PARAMPROB; + break; + case REASS_INTERFERE: + cmd = PRC_TIMXCEED_REASS; + break; } /* @@ -181,31 +187,36 @@ u_char reason; /* reason code of er */ /* * FUNCTION: clnp_discard * - * PURPOSE: Discard a clnp datagram + * PURPOSE: Discard a clnp datagram * - * RETURNS: nothing + * RETURNS: nothing * * SIDE EFFECTS: Will emit an ER pdu if possible * - * NOTES: This code assumes that we have previously tried to pull - * up the header of the datagram into one mbuf. + * NOTES: This code assumes that we have previously tried to pull + * up the header of the datagram into one mbuf. */ +void clnp_discard(m, reason) -struct mbuf *m; /* header of packet to discard */ -char reason; /* reason for discard */ + struct mbuf *m; /* header of packet to discard */ + u_int reason; /* reason for discard */ { - IFDEBUG(D_DISCARD) - printf("clnp_discard: m x%x, reason x%x\n", m, reason); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_DISCARD]) { + printf("clnp_discard: m x%x, reason x%x\n", + (unsigned int) m, reason); + } +#endif if (m != NULL) { if (m->m_len >= sizeof(struct clnp_fixed)) { - register struct clnp_fixed *clnp = mtod(m, struct clnp_fixed *); + register struct clnp_fixed *clnp = + mtod(m, struct clnp_fixed *); if (((clnp->cnf_type & CNF_TYPE) != CLNP_ER) && - (clnp->cnf_type & CNF_ERR_OK)) { - clnp_emit_er(m, reason); - return; + (clnp->cnf_type & CNF_ERR_OK)) { + clnp_emit_er(m, reason); + return; } } m_freem(m); @@ -215,113 +226,119 @@ char reason; /* reason for discard */ /* * FUNCTION: clnp_emit_er * - * PURPOSE: Send an ER pdu. - * The src of the of the ER pdu is the host that is sending - * the ER (ie. us), *not* the original destination of the - * packet. + * PURPOSE: Send an ER pdu. + * The src of the of the ER pdu is the host that is sending + * the ER (ie. us), *not* the original destination of the + * packet. * - * RETURNS: nothing + * RETURNS: nothing * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: Takes responsibility for freeing mbuf passed - * This function may be called with a packet that - * was created by us; in this case, do not send - * an ER. + * NOTES: Takes responsibility for freeing mbuf passed + * This function may be called with a packet that + * was created by us; in this case, do not send + * an ER. */ +void clnp_emit_er(m, reason) -struct mbuf *m; /* header of packet to discard */ -char reason; /* reason for discard */ + struct mbuf *m; /* header of packet to discard */ + u_int reason; /* reason for discard */ { - register struct clnp_fixed *clnp = mtod(m, struct clnp_fixed *); - register struct clnp_fixed *er; - struct route_iso route; - struct ifnet *ifp; - struct sockaddr *first_hop; - struct iso_addr src, dst, *our_addr; - caddr_t hoff, hend; - int total_len; /* total len of dg */ - struct mbuf *m0; /* contains er pdu hdr */ - struct iso_ifaddr *ia = 0; - - IFDEBUG(D_DISCARD) - printf("clnp_emit_er: m x%x, hdr len %d\n", m, clnp->cnf_hdr_len); - ENDDEBUG - - bzero((caddr_t)&route, sizeof(route)); + register struct clnp_fixed *clnp = mtod(m, struct clnp_fixed *); + register struct clnp_fixed *er; + struct route_iso route; + struct ifnet *ifp; + struct sockaddr *first_hop; + struct iso_addr src, dst, *our_addr; + caddr_t hoff, hend; + int total_len; /* total len of dg */ + struct mbuf *m0; /* contains er pdu hdr */ + struct iso_ifaddr *ia = 0; + +#ifdef ARGO_DEBUG + if (argo_debug[D_DISCARD]) { + printf("clnp_emit_er: m x%x, hdr len %d\n", + (unsigned int) m, clnp->cnf_hdr_len); + } +#endif + + bzero((caddr_t) & route, sizeof(route)); /* - * If header length is incorrect, or entire header is not contained - * in this mbuf, we punt + * If header length is incorrect, or entire header is not contained + * in this mbuf, we punt */ if ((clnp->cnf_hdr_len < CLNP_HDR_MIN) || - (clnp->cnf_hdr_len > CLNP_HDR_MAX) || - (clnp->cnf_hdr_len > m->m_len)) + (clnp->cnf_hdr_len > CLNP_HDR_MAX) || + (clnp->cnf_hdr_len > m->m_len)) goto bad; - + /* extract src, dest address */ - hend = (caddr_t)clnp + clnp->cnf_hdr_len; - hoff = (caddr_t)clnp + sizeof(struct clnp_fixed); + hend = (caddr_t) clnp + clnp->cnf_hdr_len; + hoff = (caddr_t) clnp + sizeof(struct clnp_fixed); CLNP_EXTRACT_ADDR(dst, hoff, hend); - if (hoff == (caddr_t)0) { + if (hoff == (caddr_t) 0) { goto bad; } CLNP_EXTRACT_ADDR(src, hoff, hend); - if (hoff == (caddr_t)0) { + if (hoff == (caddr_t) 0) { goto bad; } - /* - * Do not send ER if we generated the packet. + * Do not send ER if we generated the packet. */ if (clnp_ours(&src)) goto bad; - /* - * Trim mbuf to hold only the header. - * This mbuf will be the 'data' of the er pdu + /* + * Trim mbuf to hold only the header. This mbuf will be the 'data' of + * the er pdu */ if (m->m_next != NULL) { m_freem(m->m_next); m->m_next = NULL; } - if (m->m_len > clnp->cnf_hdr_len) - m_adj(m, (int)-(m->m_len - (int)clnp->cnf_hdr_len)); + m_adj(m, (int) -(m->m_len - (int) clnp->cnf_hdr_len)); /* route er pdu: note we send pkt to src of original packet */ - if (clnp_route(&src, &route, /* flags */0, &first_hop, &ia) != 0) + if (clnp_route(&src, &route, /* flags */ 0, &first_hop, &ia) != 0) goto bad; /* compute our address based upon firsthop/ifp */ if (ia) - our_addr = &ia->ia_addr.siso_addr; + our_addr = &ia->ia_addr.siso_addr; else - goto bad; + goto bad; ifp = ia->ia_ifp; - IFDEBUG(D_DISCARD) +#ifdef ARGO_DEBUG + if (argo_debug[D_DISCARD]) { printf("clnp_emit_er: to %s", clnp_iso_addrp(&src)); printf(" from %s\n", clnp_iso_addrp(our_addr)); - ENDDEBUG + } +#endif - IFDEBUG(D_DISCARD) - printf("clnp_emit_er: packet routed to %s\n", - clnp_iso_addrp(&satosiso(first_hop)->siso_addr)); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_DISCARD]) { + printf("clnp_emit_er: packet routed to %s\n", + clnp_iso_addrp(&satosiso(first_hop)->siso_addr)); + } +#endif /* allocate mbuf for er pdu header: punt on no space */ MGET(m0, M_DONTWAIT, MT_HEADER); if (m0 == 0) goto bad; - + m0->m_next = m; er = mtod(m0, struct clnp_fixed *); *er = er_template; /* setup src/dst on er pdu */ /* NOTE REVERSAL OF SRC/DST */ - hoff = (caddr_t)er + sizeof(struct clnp_fixed); + hoff = (caddr_t) er + sizeof(struct clnp_fixed); CLNP_INSERT_ADDR(hoff, src); CLNP_INSERT_ADDR(hoff, *our_addr); @@ -332,25 +349,25 @@ char reason; /* reason for discard */ /* add er option */ *hoff++ = CLNPOVAL_ERREAS; /* code */ - *hoff++ = 2; /* length */ - *hoff++ = reason; /* discard reason */ - *hoff++ = 0; /* error localization = not specified */ + *hoff++ = 2; /* length */ + *hoff++ = reason; /* discard reason */ + *hoff++ = 0; /* error localization = not specified */ /* set length */ - er->cnf_hdr_len = m0->m_len = (u_char)(hoff - (caddr_t)er); + er->cnf_hdr_len = m0->m_len = (u_char) (hoff - (caddr_t) er); total_len = m0->m_len + m->m_len; HTOC(er->cnf_seglen_msb, er->cnf_seglen_lsb, total_len); /* compute checksum (on header only) */ - iso_gen_csum(m0, CLNP_CKSUM_OFF, (int)er->cnf_hdr_len); + iso_gen_csum(m0, CLNP_CKSUM_OFF, (int) er->cnf_hdr_len); /* trim packet if too large for interface */ if (total_len > ifp->if_mtu) m_adj(m0, -(total_len - ifp->if_mtu)); - + /* send packet */ INCSTAT(cns_er_outhist[clnp_er_index(reason)]); - (void) (*ifp->if_output)(ifp, m0, first_hop, route.ro_rt); + (void) (*ifp->if_output) (ifp, m0, first_hop, route.ro_rt); goto done; bad: @@ -362,8 +379,9 @@ done: RTFREE(route.ro_rt); } +int clnp_er_index(p) -u_char p; + u_int p; { register u_char *cp = clnp_er_codes + CLNP_ERRORS; while (cp > clnp_er_codes) { diff --git a/sys/netiso/clnp_frag.c b/sys/netiso/clnp_frag.c index 951cdb86269..a3227ab7589 100644 --- a/sys/netiso/clnp_frag.c +++ b/sys/netiso/clnp_frag.c @@ -1,4 +1,5 @@ -/* $NetBSD: clnp_frag.c,v 1.6 1995/03/08 02:16:07 cgd Exp $ */ +/* $OpenBSD: clnp_frag.c,v 1.2 1996/03/04 10:34:50 mickey Exp $ */ +/* $NetBSD: clnp_frag.c,v 1.7 1996/02/13 22:08:21 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -81,127 +82,136 @@ SOFTWARE. #include <netiso/argo_debug.h> /* all fragments are hung off this list */ -struct clnp_fragl *clnp_frags = NULL; - -struct mbuf *clnp_comp_pdu(); - +struct clnp_fragl *clnp_frags = NULL; /* * FUNCTION: clnp_fragment * - * PURPOSE: Fragment a datagram, and send the itty bitty pieces - * out over an interface. + * PURPOSE: Fragment a datagram, and send the itty bitty pieces + * out over an interface. * - * RETURNS: success - 0 - * failure - unix error code + * RETURNS: success - 0 + * failure - unix error code * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: If there is an error sending the packet, clnp_discard - * is called to discard the packet and send an ER. If - * clnp_fragment was called from clnp_output, then - * we generated the packet, and should not send an - * ER -- clnp_emit_er will check for this. Otherwise, - * the packet was fragmented during forwarding. In this - * case, we ought to send an ER back. + * NOTES: If there is an error sending the packet, clnp_discard + * is called to discard the packet and send an ER. If + * clnp_fragment was called from clnp_output, then + * we generated the packet, and should not send an + * ER -- clnp_emit_er will check for this. Otherwise, + * the packet was fragmented during forwarding. In this + * case, we ought to send an ER back. */ +int clnp_fragment(ifp, m, first_hop, total_len, segoff, flags, rt) -struct ifnet *ifp; /* ptr to outgoing interface */ -struct mbuf *m; /* ptr to packet */ -struct sockaddr *first_hop; /* ptr to first hop */ -int total_len; /* length of datagram */ -int segoff; /* offset of segpart in hdr */ -int flags; /* flags passed to clnp_output */ -struct rtentry *rt; /* route if direct ether */ + struct ifnet *ifp; /* ptr to outgoing interface */ + struct mbuf *m; /* ptr to packet */ + struct sockaddr *first_hop; /* ptr to first hop */ + int total_len; /* length of datagram */ + int segoff; /* offset of segpart in hdr */ + int flags; /* flags passed to clnp_output */ + struct rtentry *rt; /* route if direct ether */ { - struct clnp_fixed *clnp = mtod(m, struct clnp_fixed *); - int hdr_len = (int)clnp->cnf_hdr_len; - int frag_size = (SN_MTU(ifp, rt) - hdr_len) & ~7; + struct clnp_fixed *clnp = mtod(m, struct clnp_fixed *); + int hdr_len = (int) clnp->cnf_hdr_len; + int frag_size = (SN_MTU(ifp, rt) - hdr_len) & ~7; total_len -= hdr_len; if ((clnp->cnf_type & CNF_SEG_OK) && - (total_len >= 8) && - (frag_size > 8 || (frag_size == 8 && !(total_len & 7)))) { - - struct mbuf *hdr = NULL; /* save copy of clnp hdr */ - struct mbuf *frag_hdr = NULL; - struct mbuf *frag_data = NULL; - struct clnp_segment seg_part; /* segmentation header */ - int frag_base; - int error = 0; + (total_len >= 8) && + (frag_size > 8 || (frag_size == 8 && !(total_len & 7)))) { + struct mbuf *hdr = NULL; /* save copy of clnp hdr */ + struct mbuf *frag_hdr = NULL; + struct mbuf *frag_data = NULL; + struct clnp_segment seg_part; /* segmentation header */ + int frag_base; + int error = 0; INCSTAT(cns_fragmented); - (void) bcopy(segoff + mtod(m, caddr_t), (caddr_t)&seg_part, - sizeof(seg_part)); + (void) bcopy(segoff + mtod(m, caddr_t), (caddr_t) & seg_part, + sizeof(seg_part)); frag_base = ntohs(seg_part.cng_off); /* * Duplicate header, and remove from packet */ if ((hdr = m_copy(m, 0, hdr_len)) == NULL) { clnp_discard(m, GEN_CONGEST); - return(ENOBUFS); + return (ENOBUFS); } m_adj(m, hdr_len); while (total_len > 0) { - int remaining, last_frag; - - IFDEBUG(D_FRAG) - struct mbuf *mdump = frag_hdr; - int tot_mlen = 0; - printf("clnp_fragment: total_len %d:\n", total_len); + int remaining, last_frag; + +#ifdef ARGO_DEBUG + if (argo_debug[D_FRAG]) { + struct mbuf *mdump = frag_hdr; + int tot_mlen = 0; + printf("clnp_fragment: total_len %d:\n", + total_len); while (mdump != NULL) { - printf("\tmbuf x%x, m_len %d\n", - mdump, mdump->m_len); + printf("\tmbuf x%x, m_len %d\n", + (unsigned int) mdump, + mdump->m_len); tot_mlen += mdump->m_len; mdump = mdump->m_next; } - printf("clnp_fragment: sum of mbuf chain %d:\n", tot_mlen); - ENDDEBUG - + printf("clnp_fragment: sum of mbuf chain %d:\n", + tot_mlen); + } +#endif + frag_size = min(total_len, frag_size); if ((remaining = total_len - frag_size) == 0) last_frag = 1; else { /* - * If this fragment will cause the last one to - * be less than 8 bytes, shorten this fragment a bit. - * The obscure test on frag_size above ensures that - * frag_size will be positive. + * If this fragment will cause the last one to + * be less than 8 bytes, shorten this fragment + * a bit. The obscure test on frag_size above + * ensures that frag_size will be positive. */ last_frag = 0; if (remaining < 8) - frag_size -= 8; + frag_size -= 8; } - - IFDEBUG(D_FRAG) - printf("clnp_fragment: seg off %d, size %d, remaining %d\n", - ntohs(seg_part.cng_off), frag_size, total_len-frag_size); + +#ifdef ARGO_DEBUG + if (argo_debug[D_FRAG]) { + printf( + "clnp_fragment: seg off %d, size %d, rem %d\n", + ntohs(seg_part.cng_off), frag_size, + total_len - frag_size); if (last_frag) - printf("clnp_fragment: last fragment\n"); - ENDDEBUG + printf( + "clnp_fragment: last fragment\n"); + } +#endif if (last_frag) { - /* - * this is the last fragment; we don't need to get any other - * mbufs. + /* + * this is the last fragment; we don't need + * to get any other mbufs. */ frag_hdr = hdr; frag_data = m; } else { /* duplicate header and data mbufs */ - if ((frag_hdr = m_copy(hdr, 0, (int)M_COPYALL)) == NULL) { + frag_hdr = m_copy(hdr, 0, (int) M_COPYALL); + if (frag_hdr == NULL) { clnp_discard(hdr, GEN_CONGEST); m_freem(m); - return(ENOBUFS); + return (ENOBUFS); } - if ((frag_data = m_copy(m, 0, frag_size)) == NULL) { + frag_data = m_copy(m, 0, frag_size); + if (frag_data == NULL) { clnp_discard(hdr, GEN_CONGEST); m_freem(m); m_freem(frag_hdr); - return(ENOBUFS); + return (ENOBUFS); } INCSTAT(cns_fragments); } @@ -209,81 +219,93 @@ struct rtentry *rt; /* route if direct ether */ if (!last_frag) clnp->cnf_type |= CNF_MORE_SEGS; - + /* link together */ m_cat(frag_hdr, frag_data); /* insert segmentation part; updated below */ - bcopy((caddr_t)&seg_part, mtod(frag_hdr, caddr_t) + segoff, - sizeof(struct clnp_segment)); + bcopy((caddr_t) & seg_part, + mtod(frag_hdr, caddr_t) + segoff, + sizeof(struct clnp_segment)); { - int derived_len = hdr_len + frag_size; - HTOC(clnp->cnf_seglen_msb, clnp->cnf_seglen_lsb, derived_len); + int derived_len = hdr_len + frag_size; + HTOC(clnp->cnf_seglen_msb, + clnp->cnf_seglen_lsb, derived_len); if ((frag_hdr->m_flags & M_PKTHDR) == 0) panic("clnp_frag:lost header"); frag_hdr->m_pkthdr.len = derived_len; } + /* compute clnp checksum (on header only) */ if (flags & CLNP_NO_CKSUM) { - HTOC(clnp->cnf_cksum_msb, clnp->cnf_cksum_lsb, 0); + HTOC(clnp->cnf_cksum_msb, + clnp->cnf_cksum_lsb, 0); } else { iso_gen_csum(frag_hdr, CLNP_CKSUM_OFF, hdr_len); } - IFDEBUG(D_DUMPOUT) - struct mbuf *mdump = frag_hdr; +#ifdef ARGO_DEBUG + if (argo_debug[D_DUMPOUT]) { + struct mbuf *mdump = frag_hdr; printf("clnp_fragment: sending dg:\n"); while (mdump != NULL) { - printf("\tmbuf x%x, m_len %d\n", mdump, mdump->m_len); + printf("\tmbuf x%x, m_len %d\n", + (unsigned int) mdump, + mdump->m_len); mdump = mdump->m_next; } - ENDDEBUG + } +#endif #ifdef TROLL error = troll_output(ifp, frag_hdr, first_hop, rt); #else - error = (*ifp->if_output)(ifp, frag_hdr, first_hop, rt); -#endif /* TROLL */ + error = (*ifp->if_output) (ifp, frag_hdr, first_hop, rt); +#endif /* TROLL */ /* - * Tough situation: if the error occured on the last - * fragment, we can not send an ER, as the if_output - * routine consumed the packet. If the error occured - * on any intermediate packets, we can send an ER - * because we still have the original header in (m). + * Tough situation: if the error occured on the last + * fragment, we can not send an ER, as the if_output + * routine consumed the packet. If the error occured + * on any intermediate packets, we can send an ER + * because we still have the original header in (m). */ if (error) { if (frag_hdr != hdr) { - /* - * The error was not on the last fragment. We must - * free hdr and m before returning + /* + * The error was not on the last + * fragment. We must free hdr and m + * before returning */ clnp_discard(hdr, GEN_NOREAS); m_freem(m); } - return(error); + return (error); } - - /* bump segment offset, trim data mbuf, and decrement count left */ + /* + * bump segment offset, trim data mbuf, and decrement + * count left + */ #ifdef TROLL /* - * Decrement frag_size by some fraction. This will cause the - * next fragment to start 'early', thus duplicating the end - * of the current fragment. troll.tr_dup_size controls - * the fraction. If positive, it specifies the fraction. If - * negative, a random fraction is used. + * Decrement frag_size by some fraction. This will + * cause the next fragment to start 'early', thus + * duplicating the end of the current fragment. + * troll.tr_dup_size controls the fraction. If + * positive, it specifies the fraction. If + * negative, a random fraction is used. */ if ((trollctl.tr_ops & TR_DUPEND) && (!last_frag)) { - int num_bytes = frag_size; + int num_bytes = frag_size; - if (trollctl.tr_dup_size > 0) + if (trollctl.tr_dup_size > 0) num_bytes *= trollctl.tr_dup_size; else num_bytes *= troll_random(); frag_size -= num_bytes; } -#endif /* TROLL */ +#endif /* TROLL */ total_len -= frag_size; if (!last_frag) { frag_base += frag_size; @@ -291,112 +313,117 @@ struct rtentry *rt; /* route if direct ether */ m_adj(m, frag_size); } } - return(0); + return (0); } else { - cantfrag: INCSTAT(cns_cantfrag); clnp_discard(m, GEN_SEGNEEDED); - return(EMSGSIZE); + return (EMSGSIZE); } } /* * FUNCTION: clnp_reass * - * PURPOSE: Attempt to reassemble a clnp packet given the current - * fragment. If reassembly succeeds (all the fragments - * are present), then return a pointer to an mbuf chain - * containing the reassembled packet. This packet will - * appear in the mbufs as if it had just arrived in - * one piece. + * PURPOSE: Attempt to reassemble a clnp packet given the current + * fragment. If reassembly succeeds (all the fragments + * are present), then return a pointer to an mbuf chain + * containing the reassembled packet. This packet will + * appear in the mbufs as if it had just arrived in + * one piece. * - * If reassembly fails, then save this fragment and - * return 0. + * If reassembly fails, then save this fragment and + * return 0. * - * RETURNS: Ptr to assembled packet, or 0 + * RETURNS: Ptr to assembled packet, or 0 * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: - * clnp_slowtimo can not affect this code because clnpintr, and thus - * this code, is called at a higher priority than clnp_slowtimo. + * NOTES: clnp_slowtimo can not affect this code because + * clnpintr, and thus this code, is called at a higher + * priority than clnp_slowtimo. */ -struct mbuf * +struct mbuf * clnp_reass(m, src, dst, seg) -struct mbuf *m; /* new fragment */ -struct iso_addr *src; /* src of new fragment */ -struct iso_addr *dst; /* dst of new fragment */ -struct clnp_segment *seg; /* segment part of fragment header */ + struct mbuf *m; /* new fragment */ + struct iso_addr *src; /* src of new fragment */ + struct iso_addr *dst; /* dst of new fragment */ + struct clnp_segment *seg; /* segment part of fragment header */ { - register struct clnp_fragl *cfh; + register struct clnp_fragl *cfh; /* look for other fragments of this datagram */ for (cfh = clnp_frags; cfh != NULL; cfh = cfh->cfl_next) { if (seg->cng_id == cfh->cfl_id && - iso_addrmatch1(src, &cfh->cfl_src) && - iso_addrmatch1(dst, &cfh->cfl_dst)) { - IFDEBUG(D_REASS) + iso_addrmatch1(src, &cfh->cfl_src) && + iso_addrmatch1(dst, &cfh->cfl_dst)) { +#ifdef ARGO_DEBUG + if (argo_debug[D_REASS]) { printf("clnp_reass: found packet\n"); - ENDDEBUG + } +#endif /* - * There are other fragments here already. Lets see if - * this fragment is of any help + * There are other fragments here already. Lets see if + * this fragment is of any help */ clnp_insert_frag(cfh, m, seg); - if (m = clnp_comp_pdu(cfh)) { - register struct clnp_fixed *clnp = mtod(m, struct clnp_fixed *); - HTOC(clnp->cnf_seglen_msb, clnp->cnf_seglen_lsb, - seg->cng_tot_len); + if ((m = clnp_comp_pdu(cfh)) != NULL) { + struct clnp_fixed *clnp = + mtod(m, struct clnp_fixed *); + HTOC(clnp->cnf_seglen_msb, + clnp->cnf_seglen_lsb, + seg->cng_tot_len); } return (m); } } - IFDEBUG(D_REASS) +#ifdef ARGO_DEBUG + if (argo_debug[D_REASS]) { printf("clnp_reass: new packet!\n"); - ENDDEBUG + } +#endif /* - * This is the first fragment. If src is not consuming too many - * resources, then create a new fragment list and add - * this fragment to the list. + * This is the first fragment. If src is not consuming too many + * resources, then create a new fragment list and add + * this fragment to the list. */ /* TODO: don't let one src hog all the reassembly buffers */ - if (!clnp_newpkt(m, src, dst, seg) /* || this src is a hog */) { + if (!clnp_newpkt(m, src, dst, seg) /* || this src is a hog */ ) { INCSTAT(cns_fragdropped); clnp_discard(m, GEN_CONGEST); } - - return(NULL); + return (NULL); } /* * FUNCTION: clnp_newpkt * - * PURPOSE: Create the necessary structures to handle a new - * fragmented clnp packet. + * PURPOSE: Create the necessary structures to handle a new + * fragmented clnp packet. * - * RETURNS: non-zero if it succeeds, zero if fails. + * RETURNS: non-zero if it succeeds, zero if fails. * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: Failure is only due to insufficient resources. + * NOTES: Failure is only due to insufficient resources. */ +int clnp_newpkt(m, src, dst, seg) -struct mbuf *m; /* new fragment */ -struct iso_addr *src; /* src of new fragment */ -struct iso_addr *dst; /* dst of new fragment */ -struct clnp_segment *seg; /* segment part of fragment header */ + struct mbuf *m; /* new fragment */ + struct iso_addr *src; /* src of new fragment */ + struct iso_addr *dst; /* dst of new fragment */ + struct clnp_segment *seg; /* segment part of fragment header */ { - register struct clnp_fragl *cfh; - register struct clnp_fixed *clnp; - struct mbuf *m0; - + register struct clnp_fragl *cfh; + register struct clnp_fixed *clnp; + struct mbuf *m0; + clnp = mtod(m, struct clnp_fixed *); - /* - * Allocate new clnp fragl structure to act as header of all fragments - * for this datagram. + /* + * Allocate new clnp fragl structure to act as header of all + * fragments for this datagram. */ MGET(m0, M_DONTWAIT, MT_FTABLE); if (m0 == NULL) { @@ -404,18 +431,18 @@ struct clnp_segment *seg; /* segment part of fragment header */ } cfh = mtod(m0, struct clnp_fragl *); - /* - * Duplicate the header of this fragment, and save in cfh. - * Free m0 and return if m_copy does not succeed. + /* + * Duplicate the header of this fragment, and save in cfh. Free m0 + * and return if m_copy does not succeed. */ - if ((cfh->cfl_orighdr = m_copy(m, 0, (int)clnp->cnf_hdr_len)) == NULL) { + cfh->cfl_orighdr = m_copy(m, 0, (int) clnp->cnf_hdr_len); + if (cfh->cfl_orighdr == NULL) { m_freem(m0); return (0); } - /* Fill in rest of fragl structure */ - bcopy((caddr_t)src, (caddr_t)&cfh->cfl_src, sizeof(struct iso_addr)); - bcopy((caddr_t)dst, (caddr_t)&cfh->cfl_dst, sizeof(struct iso_addr)); + bcopy((caddr_t) src, (caddr_t) & cfh->cfl_src, sizeof(struct iso_addr)); + bcopy((caddr_t) dst, (caddr_t) & cfh->cfl_dst, sizeof(struct iso_addr)); cfh->cfl_id = seg->cng_id; cfh->cfl_ttl = clnp->cnf_ttl; cfh->cfl_last = (seg->cng_tot_len - clnp->cnf_hdr_len) - 1; @@ -428,108 +455,127 @@ struct clnp_segment *seg; /* segment part of fragment header */ /* Insert this fragment into list headed by cfh */ clnp_insert_frag(cfh, m, seg); - return(1); + return (1); } /* * FUNCTION: clnp_insert_frag * - * PURPOSE: Insert fragment into list headed by 'cf'. + * PURPOSE: Insert fragment into list headed by 'cf'. * - * RETURNS: nothing + * RETURNS: nothing * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: This is the 'guts' of the reassembly algorithm. - * Each fragment in this list contains a clnp_frag - * structure followed by the data of the fragment. - * The clnp_frag structure actually lies on top of - * part of the old clnp header. + * NOTES: This is the 'guts' of the reassembly algorithm. + * Each fragment in this list contains a clnp_frag + * structure followed by the data of the fragment. + * The clnp_frag structure actually lies on top of + * part of the old clnp header. */ +void clnp_insert_frag(cfh, m, seg) -struct clnp_fragl *cfh; /* header of list of packet fragments */ -struct mbuf *m; /* new fragment */ -struct clnp_segment *seg; /* segment part of fragment header */ + struct clnp_fragl *cfh; /* header of list of packet fragments */ + struct mbuf *m; /* new fragment */ + struct clnp_segment *seg; /* segment part of fragment header */ { - register struct clnp_fixed *clnp; /* clnp hdr of fragment */ - register struct clnp_frag *cf; /* generic fragment ptr */ - register struct clnp_frag *cf_sub = NULL; /* frag subsequent to new one */ - register struct clnp_frag *cf_prev = NULL; /* frag previous to new one */ - u_short first; /* offset of first byte of initial pdu*/ - u_short last; /* offset of last byte of initial pdu */ - u_short fraglen;/* length of fragment */ - + register struct clnp_fixed *clnp; /* clnp hdr of fragment */ + register struct clnp_frag *cf; /* generic fragment ptr */ + register struct clnp_frag *cf_sub = NULL; /* frag subseq to new + * one */ + register struct clnp_frag *cf_prev = NULL; /* frag prev to new one */ + u_short first; /* offset of first byte of initial pdu */ + u_short last; /* offset of last byte of initial pdu */ + u_short fraglen;/* length of fragment */ + clnp = mtod(m, struct clnp_fixed *); first = seg->cng_off; CTOH(clnp->cnf_seglen_msb, clnp->cnf_seglen_lsb, fraglen); fraglen -= clnp->cnf_hdr_len; last = (first + fraglen) - 1; - IFDEBUG(D_REASS) - printf("clnp_insert_frag: New fragment: [%d ... %d], len %d\n", - first, last, fraglen); +#ifdef ARGO_DEBUG + if (argo_debug[D_REASS]) { + printf("clnp_insert_frag: New fragment: [%d-%d], len %d\n", + first, last, fraglen); printf("clnp_insert_frag: current fragments:\n"); for (cf = cfh->cfl_frags; cf != NULL; cf = cf->cfr_next) { - printf("\tcf x%x: [%d ... %d]\n", cf, cf->cfr_first, cf->cfr_last); + printf("\tcf x%x: [%d-%d]\n", + (unsigned int) cf, cf->cfr_first, cf->cfr_last); } - ENDDEBUG + } +#endif if (cfh->cfl_frags != NULL) { /* - * Find fragment which begins after the new one + * Find fragment which begins after the new one */ - for (cf = cfh->cfl_frags; cf != NULL; cf_prev = cf, cf = cf->cfr_next) { + for (cf = cfh->cfl_frags; cf != NULL; + cf_prev = cf, cf = cf->cfr_next) { if (cf->cfr_first > first) { cf_sub = cf; break; } } - IFDEBUG(D_REASS) +#ifdef ARGO_DEBUG + if (argo_debug[D_REASS]) { printf("clnp_insert_frag: Previous frag is "); if (cf_prev == NULL) printf("NULL\n"); - else - printf("[%d ... %d]\n", cf_prev->cfr_first, cf_prev->cfr_last); + else + printf("[%d-%d]\n", cf_prev->cfr_first, + cf_prev->cfr_last); printf("clnp_insert_frag: Subsequent frag is "); if (cf_sub == NULL) printf("NULL\n"); - else - printf("[%d ... %d]\n", cf_sub->cfr_first, cf_sub->cfr_last); - ENDDEBUG + else + printf("[%d-%d]\n", cf_sub->cfr_first, + cf_sub->cfr_last); + } +#endif /* - * If there is a fragment before the new one, check if it - * overlaps the new one. If so, then trim the end of the - * previous one. + * If there is a fragment before the new one, check if it + * overlaps the new one. If so, then trim the end of the + * previous one. */ if (cf_prev != NULL) { if (cf_prev->cfr_last > first) { - u_short overlap = cf_prev->cfr_last - first; + u_short overlap = cf_prev->cfr_last - first; - IFDEBUG(D_REASS) - printf("clnp_insert_frag: previous overlaps by %d\n", - overlap); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_REASS]) { + printf( + "clnp_insert_frag: previous overlaps by %d\n", + overlap); + } +#endif if (overlap > fraglen) { /* - * The new fragment is entirely contained in the - * preceeding one. We can punt on the new frag - * completely. + * The new fragment is entirely + * contained in the preceeding one. + * We can punt on the new frag + * completely. */ m_freem(m); return; } else { - /* Trim data off of end of previous fragment */ - /* inc overlap to prevent duplication of last byte */ + /* + * Trim data off of end of previous + * fragment + */ + /* + * inc overlap to prevent duplication + * of last byte + */ overlap++; - m_adj(cf_prev->cfr_data, -(int)overlap); + m_adj(cf_prev->cfr_data, -(int) overlap); cf_prev->cfr_last -= overlap; } } } - /* * For all fragments past the new one, check if any data on * the new one overlaps data on existing fragments. If so, @@ -537,64 +583,75 @@ struct clnp_segment *seg; /* segment part of fragment header */ */ for (cf = cf_sub; cf != NULL; cf = cf->cfr_next) { if (cf->cfr_first < last) { - u_short overlap = last - cf->cfr_first; + u_short overlap = last - cf->cfr_first; - IFDEBUG(D_REASS) - printf("clnp_insert_frag: subsequent overlaps by %d\n", - overlap); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_REASS]) { + printf( + "clnp_insert_frag: subsequent overlaps by %d\n", + overlap); + } +#endif if (overlap > fraglen) { /* - * The new fragment is entirely contained in the - * succeeding one. This should not happen, because - * early on in this code we scanned for the fragment - * which started after the new one! + * The new fragment is entirely + * contained in the succeeding one. + * This should not happen, because + * early on in this code we scanned + * for the fragment which started + * after the new one! */ m_freem(m); - printf("clnp_insert_frag: internal error!\n"); + printf( + "clnp_insert_frag: internal error!\n"); return; } else { - /* Trim data off of end of new fragment */ - /* inc overlap to prevent duplication of last byte */ + /* + * Trim data off of end of new fragment + * inc overlap to prevent duplication + * of last byte + */ overlap++; - m_adj(m, -(int)overlap); + m_adj(m, -(int) overlap); last -= overlap; } } } } - /* - * Insert the new fragment beween cf_prev and cf_sub + * Insert the new fragment beween cf_prev and cf_sub * - * Note: the clnp hdr is still in the mbuf. - * If the data of the mbuf is not word aligned, shave off enough - * so that it is. Then, cast the clnp_frag structure on top - * of the clnp header. - * The clnp_hdr will not be used again (as we already have - * saved a copy of it). + * Note: the clnp hdr is still in the mbuf. + * If the data of the mbuf is not word aligned, shave off enough + * so that it is. Then, cast the clnp_frag structure on top + * of the clnp header. + * The clnp_hdr will not be used again (as we already have + * saved a copy of it). * - * Save in cfr_bytes the number of bytes to shave off to get to - * the data of the packet. This is used when we coalesce fragments; - * the clnp_frag structure must be removed before joining mbufs. + * Save in cfr_bytes the number of bytes to shave off to get to + * the data of the packet. This is used when we coalesce fragments; + * the clnp_frag structure must be removed before joining mbufs. */ { - int pad; - u_int bytes; + int pad; + u_int bytes; /* determine if header is not word aligned */ - pad = (long)clnp % 4; + pad = (long) clnp % 4; if (pad < 0) pad = -pad; /* bytes is number of bytes left in front of data */ bytes = clnp->cnf_hdr_len - pad; - IFDEBUG(D_REASS) - printf("clnp_insert_frag: clnp x%x requires %d alignment\n", - clnp, pad); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_REASS]) { + printf( + "clnp_insert_frag: clnp x%x requires %d alignment\n", + (unsigned int) clnp, pad); + } +#endif /* make it word aligned if necessary */ if (pad) @@ -603,18 +660,20 @@ struct clnp_segment *seg; /* segment part of fragment header */ cf = mtod(m, struct clnp_frag *); cf->cfr_bytes = bytes; - IFDEBUG(D_REASS) - printf("clnp_insert_frag: cf now x%x, cfr_bytes %d\n", cf, - cf->cfr_bytes); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_REASS]) { + printf("clnp_insert_frag: cf now x%x, cfr_bytes %d\n", + (unsigned int) cf, cf->cfr_bytes); + } +#endif } cf->cfr_first = first; cf->cfr_last = last; /* - * The data is the mbuf itself, although we must remember that the - * first few bytes are actually a clnp_frag structure + * The data is the mbuf itself, although we must remember that the + * first few bytes are actually a clnp_frag structure */ cf->cfr_data = m; @@ -629,85 +688,102 @@ struct clnp_segment *seg; /* segment part of fragment header */ /* * FUNCTION: clnp_comp_pdu * - * PURPOSE: Scan the list of fragments headed by cfh. Merge - * any contigious fragments into one. If, after - * traversing all the fragments, it is determined that - * the packet is complete, then return a pointer to - * the packet (with header prepended). Otherwise, - * return NULL. + * PURPOSE: Scan the list of fragments headed by cfh. Merge + * any contigious fragments into one. If, after + * traversing all the fragments, it is determined that + * the packet is complete, then return a pointer to + * the packet (with header prepended). Otherwise, + * return NULL. * - * RETURNS: NULL, or a pointer to the assembled pdu in an mbuf chain. + * RETURNS: NULL, or a pointer to the assembled pdu in an mbuf + * chain. * * SIDE EFFECTS: Will colapse contigious fragments into one. * - * NOTES: This code assumes that there are no overlaps of - * fragment pdus. + * NOTES: This code assumes that there are no overlaps of + * fragment pdus. */ -struct mbuf * +struct mbuf * clnp_comp_pdu(cfh) -struct clnp_fragl *cfh; /* fragment header */ + struct clnp_fragl *cfh; /* fragment header */ { - register struct clnp_frag *cf = cfh->cfl_frags; + register struct clnp_frag *cf = cfh->cfl_frags; while (cf->cfr_next != NULL) { - register struct clnp_frag *cf_next = cf->cfr_next; + register struct clnp_frag *cf_next = cf->cfr_next; - IFDEBUG(D_REASS) - printf("clnp_comp_pdu: comparing: [%d ... %d] to [%d ... %d]\n", - cf->cfr_first, cf->cfr_last, cf_next->cfr_first, - cf_next->cfr_last); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_REASS]) { + printf("clnp_comp_pdu: comparing: [%d-%d] to [%d-%d]\n", + cf->cfr_first, cf->cfr_last, cf_next->cfr_first, + cf_next->cfr_last); + } +#endif if (cf->cfr_last == (cf_next->cfr_first - 1)) { /* - * Merge fragment cf and cf_next + * Merge fragment cf and cf_next * - * - update cf header - * - trim clnp_frag structure off of cf_next - * - append cf_next to cf + * - update cf header + * - trim clnp_frag structure off of cf_next + * - append cf_next to cf */ - struct clnp_frag cf_next_hdr; - struct clnp_frag *next_frag; + struct clnp_frag cf_next_hdr; + struct clnp_frag *next_frag; cf_next_hdr = *cf_next; next_frag = cf_next->cfr_next; - IFDEBUG(D_REASS) - struct mbuf *mdump; - int l; +#ifdef ARGO_DEBUG + if (argo_debug[D_REASS]) { + struct mbuf *mdump; + int l; printf("clnp_comp_pdu: merging fragments\n"); - printf("clnp_comp_pdu: 1st: [%d ... %d] (bytes %d)\n", - cf->cfr_first, cf->cfr_last, cf->cfr_bytes); + printf( + "clnp_comp_pdu: 1st: [%d-%d] (bytes %d)\n", + cf->cfr_first, cf->cfr_last, + cf->cfr_bytes); mdump = cf->cfr_data; l = 0; while (mdump != NULL) { - printf("\tmbuf x%x, m_len %d\n", mdump, mdump->m_len); + printf("\tmbuf x%x, m_len %d\n", + (unsigned int) mdump, + mdump->m_len); l += mdump->m_len; mdump = mdump->m_next; } printf("\ttotal len: %d\n", l); - printf("clnp_comp_pdu: 2nd: [%d ... %d] (bytes %d)\n", - cf_next->cfr_first, cf_next->cfr_last, cf_next->cfr_bytes); + printf( + "clnp_comp_pdu: 2nd: [%d-%d] (bytes %d)\n", + cf_next->cfr_first, cf_next->cfr_last, + cf_next->cfr_bytes); mdump = cf_next->cfr_data; l = 0; while (mdump != NULL) { - printf("\tmbuf x%x, m_len %d\n", mdump, mdump->m_len); + printf("\tmbuf x%x, m_len %d\n", + (unsigned int) mdump, + mdump->m_len); l += mdump->m_len; mdump = mdump->m_next; } printf("\ttotal len: %d\n", l); - ENDDEBUG + } +#endif cf->cfr_last = cf_next->cfr_last; /* - * After this m_adj, the cf_next ptr is useless because we - * have adjusted the clnp_frag structure away... + * After this m_adj, the cf_next ptr is useless + * because we have adjusted the clnp_frag structure + * away... */ - IFDEBUG(D_REASS) - printf("clnp_comp_pdu: shaving off %d bytes\n", - cf_next_hdr.cfr_bytes); - ENDDEBUG - m_adj(cf_next_hdr.cfr_data, (int)cf_next_hdr.cfr_bytes); +#ifdef ARGO_DEBUG + if (argo_debug[D_REASS]) { + printf("clnp_comp_pdu: shaving off %d bytes\n", + cf_next_hdr.cfr_bytes); + } +#endif + m_adj(cf_next_hdr.cfr_data, + (int) cf_next_hdr.cfr_bytes); m_cat(cf->cfr_data, cf_next_hdr.cfr_data); cf->cfr_next = next_frag; } else { @@ -717,55 +793,67 @@ struct clnp_fragl *cfh; /* fragment header */ cf = cfh->cfl_frags; - IFDEBUG(D_REASS) - struct mbuf *mdump = cf->cfr_data; - printf("clnp_comp_pdu: first frag now: [%d ... %d]\n", cf->cfr_first, - cf->cfr_last); +#ifdef ARGO_DEBUG + if (argo_debug[D_REASS]) { + struct mbuf *mdump = cf->cfr_data; + printf("clnp_comp_pdu: first frag now: [%d-%d]\n", + cf->cfr_first, cf->cfr_last); printf("clnp_comp_pdu: data for frag:\n"); while (mdump != NULL) { - printf("mbuf x%x, m_len %d\n", mdump, mdump->m_len); -/* dump_buf(mtod(mdump, caddr_t), mdump->m_len);*/ + printf("mbuf x%x, m_len %d\n", (unsigned int) mdump, + mdump->m_len); + /* dump_buf(mtod(mdump, caddr_t), mdump->m_len); */ mdump = mdump->m_next; } - ENDDEBUG + } +#endif /* Check if datagram is complete */ if ((cf->cfr_first == 0) && (cf->cfr_last == cfh->cfl_last)) { /* - * We have a complete pdu! - * - Remove the frag header from (only) remaining fragment - * (which is not really a fragment anymore, as the datagram is - * complete). - * - Prepend a clnp header + * We have a complete pdu! + * - Remove the frag header from (only) remaining fragment + * (which is not really a fragment anymore, as the datagram + * is complete). + * - Prepend a clnp header */ - struct mbuf *data = cf->cfr_data; - struct mbuf *hdr = cfh->cfl_orighdr; + struct mbuf *data = cf->cfr_data; + struct mbuf *hdr = cfh->cfl_orighdr; struct clnp_fragl *scan; - IFDEBUG(D_REASS) +#ifdef ARGO_DEBUG + if (argo_debug[D_REASS]) { printf("clnp_comp_pdu: complete pdu!\n"); - ENDDEBUG + } +#endif - m_adj(data, (int)cf->cfr_bytes); + m_adj(data, (int) cf->cfr_bytes); m_cat(hdr, data); - IFDEBUG(D_DUMPIN) - struct mbuf *mdump = hdr; +#ifdef ARGO_DEBUG + if (argo_debug[D_DUMPIN]) { + struct mbuf *mdump = hdr; printf("clnp_comp_pdu: pdu is:\n"); while (mdump != NULL) { - printf("mbuf x%x, m_len %d\n", mdump, mdump->m_len); -/* dump_buf(mtod(mdump, caddr_t), mdump->m_len);*/ + printf("mbuf x%x, m_len %d\n", + (unsigned int) mdump, + mdump->m_len); +#if 0 + dump_buf(mtod(mdump, caddr_t), mdump->m_len); +#endif mdump = mdump->m_next; } - ENDDEBUG + } +#endif /* - * Remove cfh from the list of fragmented pdus + * Remove cfh from the list of fragmented pdus */ if (clnp_frags == cfh) { clnp_frags = cfh->cfl_next; } else { - for (scan = clnp_frags; scan != NULL; scan = scan->cfl_next) { + for (scan = clnp_frags; scan != NULL; + scan = scan->cfl_next) { if (scan->cfl_next == cfh) { scan->cfl_next = cfh->cfl_next; break; @@ -776,57 +864,58 @@ struct clnp_fragl *cfh; /* fragment header */ /* free cfh */ m_freem(dtom(cfh)); - return(hdr); + return (hdr); } - - return(NULL); + return (NULL); } #ifdef TROLL -static int troll_cnt; +static int troll_cnt; #include <sys/time.h> /* * FUNCTION: troll_random * - * PURPOSE: generate a pseudo-random number between 0 and 1 + * PURPOSE: generate a pseudo-random number between 0 and 1 * - * RETURNS: the random number + * RETURNS: the random number * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: This is based on the clock. + * NOTES: This is based on the clock. */ -float troll_random() +float +troll_random() { extern struct timeval time; - long t = time.tv_usec % 100; + long t = time.tv_usec % 100; - return((float)t / (float) 100); + return ((float) t / (float) 100); } /* * FUNCTION: troll_output * - * PURPOSE: Do something sneaky with the datagram passed. Possible - * operations are: - * Duplicate the packet - * Drop the packet - * Trim some number of bytes from the packet - * Munge some byte in the packet + * PURPOSE: Do something sneaky with the datagram passed. Possible + * operations are: + * Duplicate the packet + * Drop the packet + * Trim some number of bytes from the packet + * Munge some byte in the packet * - * RETURNS: 0, or unix error code + * RETURNS: 0, or unix error code * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: The operation of this procedure is regulated by the - * troll control structure (Troll). + * NOTES: The operation of this procedure is regulated by the + * troll control structure (Troll). */ +int troll_output(ifp, m, dst, rt) -struct ifnet *ifp; -struct mbuf *m; -struct sockaddr *dst; -struct rtentry *rt; + struct ifnet *ifp; + struct mbuf *m; + struct sockaddr *dst; + struct rtentry *rt; { - int err = 0; + int err = 0; troll_cnt++; if (trollctl.tr_ops & TR_DUPPKT) { @@ -834,26 +923,26 @@ struct rtentry *rt; * Duplicate every Nth packet * TODO: random? */ - float f_freq = troll_cnt * trollctl.tr_dup_freq; - int i_freq = troll_cnt * trollctl.tr_dup_freq; + float f_freq = troll_cnt * trollctl.tr_dup_freq; + int i_freq = troll_cnt * trollctl.tr_dup_freq; if (i_freq == f_freq) { - struct mbuf *dup = m_copy(m, 0, (int)M_COPYALL); + struct mbuf *dup = m_copy(m, 0, (int) M_COPYALL); if (dup != NULL) - err = (*ifp->if_output)(ifp, dup, dst, rt); + err = (*ifp->if_output) (ifp, dup, dst, rt); } if (!err) - err = (*ifp->if_output)(ifp, m, dst, rt); - return(err); + err = (*ifp->if_output) (ifp, m, dst, rt); + return (err); } else if (trollctl.tr_ops & TR_DROPPKT) { } else if (trollctl.tr_ops & TR_CHANGE) { struct clnp_fixed *clnp = mtod(m, struct clnp_fixed *); clnp->cnf_cksum_msb = 0; - err = (*ifp->if_output)(ifp, m, dst, rt); - return(err); + err = (*ifp->if_output) (ifp, m, dst, rt); + return (err); } else { - err = (*ifp->if_output)(ifp, m, dst, rt); - return(err); + err = (*ifp->if_output) (ifp, m, dst, rt); + return (err); } } -#endif /* TROLL */ +#endif /* TROLL */ diff --git a/sys/netiso/clnp_input.c b/sys/netiso/clnp_input.c index ecdbf3ff56f..ebe4c49afc5 100644 --- a/sys/netiso/clnp_input.c +++ b/sys/netiso/clnp_input.c @@ -1,4 +1,5 @@ -/* $NetBSD: clnp_input.c,v 1.10 1995/07/27 20:36:14 mycroft Exp $ */ +/* $OpenBSD: clnp_input.c,v 1.2 1996/03/04 10:34:53 mickey Exp $ */ +/* $NetBSD: clnp_input.c,v 1.11 1996/02/13 22:08:26 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -70,6 +71,7 @@ SOFTWARE. #include <sys/socketvar.h> #include <sys/errno.h> #include <sys/time.h> +#include <sys/systm.h> #include <net/if.h> #include <net/if_types.h> @@ -88,28 +90,30 @@ SOFTWARE. #include <netiso/clnp_stat.h> #include <netiso/argo_debug.h> +#include <machine/stdarg.h> + #ifdef ISO -u_char clnp_protox[ISOPROTO_MAX]; +u_char clnp_protox[ISOPROTO_MAX]; struct clnl_protosw clnl_protox[256]; -int clnpqmaxlen = IFQ_MAXLEN; /* RAH? why is this a variable */ -struct mbuf *clnp_data_ck(); - -void clnp_input(), esis_input(); +int clnpqmaxlen = IFQ_MAXLEN; /* RAH? why is this a + * variable */ #ifdef ISO_X25ESIS -void x25esis_input(); -#endif /* ISO_X25ESIS */ +#if 0 +void x25esis_input(); +#endif +#endif /* ISO_X25ESIS */ /* * FUNCTION: clnp_init * - * PURPOSE: clnp initialization. Fill in clnp switch tables. + * PURPOSE: clnp initialization. Fill in clnp switch tables. * - * RETURNS: none + * RETURNS: none * * SIDE EFFECTS: fills in clnp_protox table with correct offsets into - * the isosw table. + * the isosw table. * - * NOTES: + * NOTES: */ void clnp_init() @@ -117,7 +121,7 @@ clnp_init() register struct protosw *pr; /* - * CLNP protox initialization + * CLNP protox initialization */ if ((pr = pffindproto(PF_ISO, ISOPROTO_RAW, SOCK_RAW)) == 0) printf("clnl_init: no raw CLNP\n"); @@ -142,28 +146,30 @@ clnp_init() /* * FUNCTION: clnlintr * - * PURPOSE: Process a packet on the clnl input queue + * PURPOSE: Process a packet on the clnl input queue * - * RETURNS: nothing. + * RETURNS: nothing. * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ +void clnlintr() { - register struct mbuf *m; /* ptr to first mbuf of pkt */ - register struct clnl_fixed *clnl; /* ptr to fixed part of clnl hdr */ - int s; /* save and restore priority */ - struct clnl_protosw *clnlsw;/* ptr to protocol switch */ - struct snpa_hdr sh; /* subnetwork hdr */ + register struct mbuf *m;/* ptr to first mbuf of pkt */ + register struct clnl_fixed *clnl; /* ptr to fixed part of clnl + * hdr */ + int s; /* save and restore priority */ + struct clnl_protosw *clnlsw; /* ptr to protocol switch */ + struct snpa_hdr sh; /* subnetwork hdr */ /* * Get next datagram off clnl input queue */ next: s = splimp(); - /* IF_DEQUEUESNPAHDR(&clnlintrq, m, sh);*/ + /* IF_DEQUEUESNPAHDR(&clnlintrq, m, sh); */ IF_DEQUEUE(&clnlintrq, m); splx(s); @@ -176,7 +182,7 @@ next: } else { register struct ifaddr *ifa; for (ifa = m->m_pkthdr.rcvif->if_addrlist.tqh_first; ifa != 0; - ifa = ifa->ifa_list.tqe_next) + ifa = ifa->ifa_list.tqe_next) if (ifa->ifa_addr->sa_family == AF_ISO) break; if (ifa == 0) { @@ -184,16 +190,15 @@ next: goto next; } } - bzero((caddr_t)&sh, sizeof(sh)); - sh.snh_flags = m->m_flags & (M_MCAST|M_BCAST); - switch((sh.snh_ifp = m->m_pkthdr.rcvif)->if_type) { - extern int ether_output(); + bzero((caddr_t) & sh, sizeof(sh)); + sh.snh_flags = m->m_flags & (M_MCAST | M_BCAST); + switch ((sh.snh_ifp = m->m_pkthdr.rcvif)->if_type) { case IFT_EON: - bcopy(mtod(m, caddr_t), (caddr_t)sh.snh_dhost, sizeof(u_long)); + bcopy(mtod(m, caddr_t), (caddr_t) sh.snh_dhost, sizeof(u_long)); bcopy(sizeof(u_long) + mtod(m, caddr_t), - (caddr_t)sh.snh_shost, sizeof(u_long)); + (caddr_t) sh.snh_shost, sizeof(u_long)); sh.snh_dhost[4] = mtod(m, u_char *)[sizeof(struct ip) + - _offsetof(struct eon_hdr, eonh_class)]; + _offsetof(struct eon_hdr, eonh_class)]; m->m_data += EONIPLEN; m->m_len -= EONIPLEN; m->m_pkthdr.len -= EONIPLEN; @@ -201,61 +206,62 @@ next: default: if (sh.snh_ifp->if_output == ether_output) { - bcopy((caddr_t)(mtod(m, struct ether_header *)->ether_dhost), - (caddr_t)sh.snh_dhost, 2*sizeof(sh.snh_dhost)); - m->m_data += sizeof (struct ether_header); - m->m_len -= sizeof (struct ether_header); - m->m_pkthdr.len -= sizeof (struct ether_header); + bcopy((caddr_t) (mtod(m, struct ether_header *)->ether_dhost), + (caddr_t) sh.snh_dhost, 2 * sizeof(sh.snh_dhost)); + m->m_data += sizeof(struct ether_header); + m->m_len -= sizeof(struct ether_header); + m->m_pkthdr.len -= sizeof(struct ether_header); } } - IFDEBUG(D_INPUT) - int i; +#ifdef ARGO_DEBUG + if (argo_debug[D_INPUT]) { + int i; printf("clnlintr: src:"); - for (i=0; i<6; i++) - printf("%x%c", sh.snh_shost[i] & 0xff, (i<5) ? ':' : ' '); + for (i = 0; i < 6; i++) + printf("%x%c", sh.snh_shost[i] & 0xff, + (i < 5) ? ':' : ' '); printf(" dst:"); - for (i=0; i<6; i++) - printf("%x%c", sh.snh_dhost[i] & 0xff, (i<5) ? ':' : ' '); + for (i = 0; i < 6; i++) + printf("%x%c", sh.snh_dhost[i] & 0xff, + (i < 5) ? ':' : ' '); printf("\n"); - ENDDEBUG + } +#endif /* - * Get the fixed part of the clnl header into the first mbuf. - * Drop the packet if this fails. - * Do not call m_pullup if we have a cluster mbuf or the - * data is not there. + * Get the fixed part of the clnl header into the first mbuf. + * Drop the packet if this fails. + * Do not call m_pullup if we have a cluster mbuf or the + * data is not there. */ if ((IS_CLUSTER(m) || (m->m_len < sizeof(struct clnl_fixed))) && - ((m = m_pullup(m, sizeof(struct clnl_fixed))) == 0)) { + ((m = m_pullup(m, sizeof(struct clnl_fixed))) == 0)) { INCSTAT(cns_toosmall); /* TODO: use clnl stats */ - goto next; /* m_pullup discards mbuf */ + goto next; /* m_pullup discards mbuf */ } - clnl = mtod(m, struct clnl_fixed *); /* - * Drop packet if the length of the header is not reasonable. + * Drop packet if the length of the header is not reasonable. */ - if ((clnl->cnf_hdr_len < CLNP_HDR_MIN) || - (clnl->cnf_hdr_len > CLNP_HDR_MAX)) { + if ((clnl->cnf_hdr_len < CLNP_HDR_MIN) || + (clnl->cnf_hdr_len > CLNP_HDR_MAX)) { INCSTAT(cns_badhlen); /* TODO: use clnl stats */ m_freem(m); goto next; } - /* * If the header is not contained in this mbuf, make it so. * Drop packet if this fails. * Note: m_pullup will allocate a cluster mbuf if necessary */ if (clnl->cnf_hdr_len > m->m_len) { - if ((m = m_pullup(m, (int)clnl->cnf_hdr_len)) == 0) { + if ((m = m_pullup(m, (int) clnl->cnf_hdr_len)) == 0) { INCSTAT(cns_badhlen); /* TODO: use clnl stats */ goto next; /* m_pullup discards mbuf */ } clnl = mtod(m, struct clnl_fixed *); } - clnlsw = &clnl_protox[clnl->cnf_proto_id]; @@ -270,44 +276,58 @@ next: /* * FUNCTION: clnp_input * - * PURPOSE: process an incoming clnp packet + * PURPOSE: process an incoming clnp packet * - * RETURNS: nothing + * RETURNS: nothing * * SIDE EFFECTS: increments fields of clnp_stat structure. - * + * * NOTES: - * TODO: I would like to make seg_part a pointer into the mbuf, but + * TODO: I would like to make seg_part a pointer into the mbuf, but * will it be correctly aligned? */ void -clnp_input(m, shp) -struct mbuf *m; /* ptr to first mbuf of pkt */ -struct snpa_hdr *shp; /* subnetwork header */ +#if __STDC__ +clnp_input(struct mbuf *m, ...) +#else +clnp_input(m, va_alist) + struct mbuf *m; /* ptr to first mbuf of pkt */ + va_dcl +#endif { - register struct clnp_fixed *clnp; /* ptr to fixed part of header */ - struct sockaddr_iso source; /* source address of pkt */ - struct sockaddr_iso target; /* destination address of pkt */ + struct snpa_hdr *shp; /* subnetwork header */ + register struct clnp_fixed *clnp; /* ptr to fixed part of + * header */ + struct sockaddr_iso source; /* source address of pkt */ + struct sockaddr_iso target; /* destination address of pkt */ #define src source.siso_addr #define dst target.siso_addr - caddr_t hoff; /* current offset in packet */ - caddr_t hend; /* address of end of header info */ - struct clnp_segment seg_part; /* segment part of hdr */ - int seg_off=0; /* offset of segment part of hdr */ - int seg_len;/* length of packet data&hdr in bytes */ - struct clnp_optidx oidx, *oidxp = NULL; /* option index */ - extern int iso_systype; /* used by ESIS config resp */ - extern struct sockaddr_iso blank_siso; /* used for initializing */ - int need_afrin = 0; - /* true if congestion experienced */ - /* which means you need afrin nose */ - /* spray. How clever! */ - - IFDEBUG(D_INPUT) + caddr_t hoff; /* current offset in packet */ + caddr_t hend; /* address of end of header info */ + struct clnp_segment seg_part; /* segment part of hdr */ + int seg_off = 0; /* offset of segment part of hdr */ + int seg_len;/* length of packet data&hdr in bytes */ + struct clnp_optidx oidx, *oidxp = NULL; /* option index */ + extern int iso_systype; /* used by ESIS config resp */ + extern struct sockaddr_iso blank_siso; /* used for initializing */ + int need_afrin = 0; + /* true if congestion experienced */ + /* which means you need afrin nose */ + /* spray. How clever! */ + va_list ap; + + va_start(ap, m); + shp = va_arg(ap, struct snpa_hdr *); + va_end(ap); + + +#ifdef ARGO_DEBUG + if (argo_debug[D_INPUT]) { printf( - "clnp_input: proccessing dg; First mbuf m_len %d, m_type x%x, %s\n", - m->m_len, m->m_type, IS_CLUSTER(m) ? "cluster" : "normal"); - ENDDEBUG + "clnp_input: proccessing dg; First mbuf m_len %d, m_type x%x, %s\n", + m->m_len, m->m_type, IS_CLUSTER(m) ? "cluster" : "normal"); + } +#endif need_afrin = 0; /* @@ -318,149 +338,153 @@ struct snpa_hdr *shp; /* subnetwork header */ clnp_discard(m, ADDR_DESTUNREACH); return; } - INCSTAT(cns_total); clnp = mtod(m, struct clnp_fixed *); - IFDEBUG(D_DUMPIN) - struct mbuf *mhead; - int total_len = 0; +#ifdef ARGO_DEBUG + if (argo_debug[D_DUMPIN]) { + struct mbuf *mhead; + int total_len = 0; printf("clnp_input: clnp header:\n"); dump_buf(mtod(m, caddr_t), clnp->cnf_hdr_len); printf("clnp_input: mbuf chain:\n"); - for (mhead = m; mhead != NULL; mhead=mhead->m_next) { - printf("m x%x, len %d\n", mhead, mhead->m_len); + for (mhead = m; mhead != NULL; mhead = mhead->m_next) { + printf("m x%x, len %d\n", (unsigned int) mhead, + mhead->m_len); total_len += mhead->m_len; } - printf("clnp_input: total length of mbuf chain %d:\n", total_len); - ENDDEBUG + printf("clnp_input: total length of mbuf chain %d:\n", + total_len); + } +#endif /* * Compute checksum (if necessary) and drop packet if * checksum does not match */ - if (CKSUM_REQUIRED(clnp) && iso_check_csum(m, (int)clnp->cnf_hdr_len)) { + if (CKSUM_REQUIRED(clnp) && + iso_check_csum(m, (int) clnp->cnf_hdr_len)) { INCSTAT(cns_badcsum); clnp_discard(m, GEN_BADCSUM); return; } - if (clnp->cnf_vers != ISO8473_V1) { INCSTAT(cns_badvers); clnp_discard(m, DISC_UNSUPPVERS); return; } - - - /* check mbuf data length: clnp_data_ck will free mbuf upon error */ + /* check mbuf data length: clnp_data_ck will free mbuf upon error */ CTOH(clnp->cnf_seglen_msb, clnp->cnf_seglen_lsb, seg_len); if ((m = clnp_data_ck(m, seg_len)) == 0) return; - + clnp = mtod(m, struct clnp_fixed *); - hend = (caddr_t)clnp + clnp->cnf_hdr_len; + hend = (caddr_t) clnp + clnp->cnf_hdr_len; - /* - * extract the source and destination address - * drop packet on failure + /* + * extract the source and destination address drop packet on failure */ source = target = blank_siso; - hoff = (caddr_t)clnp + sizeof(struct clnp_fixed); + hoff = (caddr_t) clnp + sizeof(struct clnp_fixed); CLNP_EXTRACT_ADDR(dst, hoff, hend); - if (hoff == (caddr_t)0) { + if (hoff == (caddr_t) 0) { INCSTAT(cns_badaddr); clnp_discard(m, GEN_INCOMPLETE); return; } CLNP_EXTRACT_ADDR(src, hoff, hend); - if (hoff == (caddr_t)0) { + if (hoff == (caddr_t) 0) { INCSTAT(cns_badaddr); clnp_discard(m, GEN_INCOMPLETE); return; } - - IFDEBUG(D_INPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_INPUT]) { printf("clnp_input: from %s", clnp_iso_addrp(&src)); printf(" to %s\n", clnp_iso_addrp(&dst)); - ENDDEBUG + } +#endif /* - * extract the segmentation information, if it is present. - * drop packet on failure + * extract the segmentation information, if it is present. + * drop packet on failure */ if (((clnp->cnf_type & CNF_TYPE) != CLNP_ER) && - (clnp->cnf_type & CNF_SEG_OK)) { + (clnp->cnf_type & CNF_SEG_OK)) { if (hoff + sizeof(struct clnp_segment) > hend) { INCSTAT(cns_noseg); clnp_discard(m, GEN_INCOMPLETE); return; } else { - (void) bcopy(hoff, (caddr_t)&seg_part, sizeof(struct clnp_segment)); + (void) bcopy(hoff, (caddr_t) & seg_part, + sizeof(struct clnp_segment)); /* make sure segmentation fields are in host order */ seg_part.cng_id = ntohs(seg_part.cng_id); seg_part.cng_off = ntohs(seg_part.cng_off); seg_part.cng_tot_len = ntohs(seg_part.cng_tot_len); - seg_off = hoff - (caddr_t)clnp; + seg_off = hoff - (caddr_t) clnp; hoff += sizeof(struct clnp_segment); } } - /* - * process options if present. If clnp_opt_sanity returns - * false (indicating an error was found in the options) or - * an unsupported option was found - * then drop packet and emit an ER. + * process options if present. If clnp_opt_sanity returns + * false (indicating an error was found in the options) or + * an unsupported option was found + * then drop packet and emit an ER. */ if (hoff < hend) { - int errcode; + int errcode; oidxp = &oidx; - errcode = clnp_opt_sanity(m, hoff, hend-hoff, oidxp); + errcode = clnp_opt_sanity(m, hoff, hend - hoff, oidxp); /* we do not support security */ if ((errcode == 0) && (oidxp->cni_securep)) errcode = DISC_UNSUPPSECURE; /* the er option is valid with ER pdus only */ - if ((errcode == 0) && (oidxp->cni_er_reason != ER_INVALREAS) && - ((clnp->cnf_type & CNF_TYPE) != CLNP_ER)) + if ((errcode == 0) && (oidxp->cni_er_reason != ER_INVALREAS) && + ((clnp->cnf_type & CNF_TYPE) != CLNP_ER)) errcode = DISC_UNSUPPOPT; #ifdef DECBIT /* check if the congestion experienced bit is set */ if (oidxp->cni_qos_formatp) { - caddr_t qosp = CLNP_OFFTOOPT(m, oidxp->cni_qos_formatp); - u_char qos = *qosp; + caddr_t qosp = CLNP_OFFTOOPT(m, oidxp->cni_qos_formatp); + u_char qos = *qosp; - need_afrin = ((qos & (CLNPOVAL_GLOBAL|CLNPOVAL_CONGESTED)) == - (CLNPOVAL_GLOBAL|CLNPOVAL_CONGESTED)); + need_afrin = ((qos & (CLNPOVAL_GLOBAL | CLNPOVAL_CONGESTED)) == + (CLNPOVAL_GLOBAL | CLNPOVAL_CONGESTED)); if (need_afrin) INCSTAT(cns_congest_rcvd); } -#endif /* DECBIT */ +#endif /* DECBIT */ if (errcode != 0) { - clnp_discard(m, (char)errcode); - IFDEBUG(D_INPUT) - printf("clnp_input: dropped (err x%x) due to bad options\n", - errcode); - ENDDEBUG + clnp_discard(m, (char) errcode); +#ifdef ARGO_DEBUG + if (argo_debug[D_INPUT]) { + printf( + "clnp_input: dropped (err x%x) due to bad options\n", + errcode); + } +#endif return; } } - /* * check if this packet is for us. if not, then forward */ if (clnp_ours(&dst) == 0) { - IFDEBUG(D_INPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_INPUT]) { printf("clnp_input: forwarding packet not for us\n"); - ENDDEBUG - clnp_forward(m, seg_len, &dst, oidxp, seg_off, shp); + } +#endif + clnp_forward(m, seg_len, &dst, oidxp, seg_off, shp); return; } - /* * ESIS Configuration Response Function * @@ -468,23 +492,22 @@ struct snpa_hdr *shp; /* subnetwork header */ * all end systems, then send an esh to the source */ if ((shp->snh_flags & M_MCAST) && (iso_systype == SNPA_ES)) { - extern short esis_holding_time; + extern short esis_holding_time; esis_shoutput(shp->snh_ifp, ESIS_ESH, esis_holding_time, - shp->snh_shost, 6, &dst); + shp->snh_shost, 6, &dst); } - /* - * If this is a fragment, then try to reassemble it. If clnp_reass - * returns non NULL, the packet has been reassembled, and should - * be give to TP. Otherwise the fragment has been delt with - * by the reassembly code (either stored or deleted). In either case - * we should have nothing more to do with it. + * If this is a fragment, then try to reassemble it. If clnp_reass + * returns non NULL, the packet has been reassembled, and should + * be give to TP. Otherwise the fragment has been delt with + * by the reassembly code (either stored or deleted). In either case + * we should have nothing more to do with it. */ if (((clnp->cnf_type & CNF_TYPE) != CLNP_ER) && - (clnp->cnf_type & CNF_SEG_OK) && - (seg_len != seg_part.cng_tot_len)) { - struct mbuf *m0; + (clnp->cnf_type & CNF_SEG_OK) && + (seg_len != seg_part.cng_tot_len)) { + struct mbuf *m0; if ((m0 = clnp_reass(m, &src, &dst, &seg_part)) != NULL) { m = m0; @@ -494,7 +517,6 @@ struct snpa_hdr *shp; /* subnetwork header */ return; } } - /* * give the packet to the higher layer * @@ -519,35 +541,41 @@ struct snpa_hdr *shp; /* subnetwork header */ case CLNP_DT: (*isosw[clnp_protox[ISOPROTO_TP]].pr_input)(m, &source, &target, - clnp->cnf_hdr_len, need_afrin); + clnp->cnf_hdr_len, need_afrin); break; - case CLNP_RAW: + case CLNP_RAW: case CLNP_ECR: - IFDEBUG(D_INPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_INPUT]) { printf("clnp_input: raw input of %d bytes\n", - clnp->cnf_type & CNF_SEG_OK ? seg_part.cng_tot_len : seg_len); - ENDDEBUG - (*isosw[clnp_protox[ISOPROTO_RAW]].pr_input)(m, &source, &target, - clnp->cnf_hdr_len); + clnp->cnf_type & CNF_SEG_OK ? + seg_part.cng_tot_len : seg_len); + } +#endif + (*isosw[clnp_protox[ISOPROTO_RAW]].pr_input)(m, &source, + &target, + clnp->cnf_hdr_len); break; case CLNP_EC: - IFDEBUG(D_INPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_INPUT]) { printf("clnp_input: echoing packet\n"); - ENDDEBUG - (void)clnp_echoreply(m, - (clnp->cnf_type & CNF_SEG_OK ? (int)seg_part.cng_tot_len : seg_len), - &source, &target, oidxp); + } +#endif + (void) clnp_echoreply(m, (clnp->cnf_type & CNF_SEG_OK ? + (int) seg_part.cng_tot_len : seg_len), + &source, &target, oidxp); break; default: - printf("clnp_input: unknown clnp pkt type %d\n", - clnp->cnf_type & CNF_TYPE); + printf("clnp_input: unknown clnp pkt type %d\n", + clnp->cnf_type & CNF_TYPE); clnp_stat.cns_delivered--; clnp_stat.cns_noproto++; clnp_discard(m, GEN_HDRSYNTAX); - break; + break; } } -#endif /* ISO */ +#endif /* ISO */ diff --git a/sys/netiso/clnp_options.c b/sys/netiso/clnp_options.c index 8779f180daf..1ae69c809df 100644 --- a/sys/netiso/clnp_options.c +++ b/sys/netiso/clnp_options.c @@ -1,4 +1,5 @@ -/* $NetBSD: clnp_options.c,v 1.5 1994/06/29 06:39:14 cgd Exp $ */ +/* $OpenBSD: clnp_options.c,v 1.2 1996/03/04 10:34:55 mickey Exp $ */ +/* $NetBSD: clnp_options.c,v 1.6 1996/02/13 22:08:32 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -71,6 +72,7 @@ SOFTWARE. #include <sys/socket.h> #include <sys/socketvar.h> #include <sys/errno.h> +#include <sys/systm.h> #include <net/if.h> #include <net/route.h> @@ -83,46 +85,52 @@ SOFTWARE. /* * FUNCTION: clnp_update_srcrt * - * PURPOSE: Process src rt option accompanying a clnp datagram. - * - bump src route ptr if src routing and - * we appear current in src route list. + * PURPOSE: Process src rt option accompanying a clnp datagram. + * - bump src route ptr if src routing and + * we appear current in src route list. * - * RETURNS: none + * RETURNS: none * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: If source routing has been terminated, do nothing. + * NOTES: If source routing has been terminated, do nothing. */ +void clnp_update_srcrt(options, oidx) -struct mbuf *options; /* ptr to options mbuf */ -struct clnp_optidx *oidx; /* ptr to option index */ + struct mbuf *options;/* ptr to options mbuf */ + struct clnp_optidx *oidx; /* ptr to option index */ { - u_char len; /* length of current address */ - struct iso_addr isoa; /* copy current address into here */ + u_char len; /* length of current address */ + struct iso_addr isoa; /* copy current address into here */ if (CLNPSRCRT_TERM(oidx, options)) { - IFDEBUG(D_OPTIONS) +#ifdef ARGO_DEBUG + if (argo_debug[D_OPTIONS]) { printf("clnp_update_srcrt: src rt terminated\n"); - ENDDEBUG + } +#endif return; } - len = CLNPSRCRT_CLEN(oidx, options); - bcopy(CLNPSRCRT_CADDR(oidx, options), (caddr_t)&isoa, len); + bcopy(CLNPSRCRT_CADDR(oidx, options), (caddr_t) & isoa, len); isoa.isoa_len = len; - - IFDEBUG(D_OPTIONS) - printf("clnp_update_srcrt: current src rt: %s\n", - clnp_iso_addrp(&isoa)); - ENDDEBUG + +#ifdef ARGO_DEBUG + if (argo_debug[D_OPTIONS]) { + printf("clnp_update_srcrt: current src rt: %s\n", + clnp_iso_addrp(&isoa)); + } +#endif if (clnp_ours(&isoa)) { - IFDEBUG(D_OPTIONS) +#ifdef ARGO_DEBUG + if (argo_debug[D_OPTIONS]) { printf("clnp_update_srcrt: updating src rt\n"); - ENDDEBUG + } +#endif /* update pointer to next src route */ - len++; /* count length byte too! */ + len++; /* count length byte too! */ CLNPSRCRT_OFF(oidx, options) += len; } } @@ -130,21 +138,22 @@ struct clnp_optidx *oidx; /* ptr to option index */ /* * FUNCTION: clnp_dooptions * - * PURPOSE: Process options accompanying a clnp datagram. - * Processing includes - * - log our address if recording route + * PURPOSE: Process options accompanying a clnp datagram. + * Processing includes + * - log our address if recording route * * RETURNS: none * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ +void clnp_dooptions(options, oidx, ifp, isoa) -struct mbuf *options; /* ptr to options mbuf */ -struct clnp_optidx *oidx; /* ptr to option index */ -struct ifnet *ifp; /* ptr to interface pkt is leaving on */ -struct iso_addr *isoa; /* ptr to our address for this ifp */ + struct mbuf *options;/* ptr to options mbuf */ + struct clnp_optidx *oidx; /* ptr to option index */ + struct ifnet *ifp; /* ptr to interface pkt is leaving on */ + struct iso_addr *isoa; /* ptr to our address for this ifp */ { /* * If record route is specified, move all @@ -152,48 +161,56 @@ struct iso_addr *isoa; /* ptr to our address for this ifp */ * interface passed */ if (oidx->cni_recrtp) { - char *opt; /* ptr to beginning of recrt option */ - u_char off; /* offset from opt of first free byte */ - char *rec_start; /* beginning of new rt recorded */ + char *opt; /* ptr to beginning of recrt option */ + u_char off; /* offset from opt of first free byte */ + char *rec_start; /* beginning of new rt + * recorded */ opt = CLNP_OFFTOOPT(options, oidx->cni_recrtp); off = *(opt + 1); rec_start = opt + off - 1; - IFDEBUG(D_OPTIONS) +#ifdef ARGO_DEBUG + if (argo_debug[D_OPTIONS]) { printf("clnp_dooptions: record route: option x%x for %d bytes\n", - opt, oidx->cni_recrt_len); + (unsigned int) opt, oidx->cni_recrt_len); printf("\tfree slot offset x%x\n", off); printf("clnp_dooptions: recording %s\n", clnp_iso_addrp(isoa)); printf("clnp_dooptions: option dump:\n"); dump_buf(opt, oidx->cni_recrt_len); - ENDDEBUG + } +#endif /* proceed only if recording has not been terminated */ if (off != 0xff) { - int new_addrlen = isoa->isoa_len + 1; - /* - * if there is insufficient room to store the next address, - * then terminate recording. Plus 1 on isoa_len is for the - * length byte itself + int new_addrlen = isoa->isoa_len + 1; + /* + * if there is insufficient room to store the next + * address, then terminate recording. Plus 1 on + * isoa_len is for the length byte itself */ if (oidx->cni_recrt_len - (off - 1) < new_addrlen) { *(opt + 1) = 0xff; /* terminate recording */ } else { - IFDEBUG(D_OPTIONS) +#ifdef ARGO_DEBUG + if (argo_debug[D_OPTIONS]) { printf("clnp_dooptions: new addr at x%x for %d\n", - rec_start, new_addrlen); - ENDDEBUG + (unsigned int) rec_start, + new_addrlen); + } +#endif - bcopy((caddr_t)isoa, rec_start, new_addrlen); + bcopy((caddr_t) isoa, rec_start, new_addrlen); /* update offset field */ *(opt + 1) += new_addrlen; - IFDEBUG(D_OPTIONS) +#ifdef ARGO_DEBUG + if (argo_debug[D_OPTIONS]) { printf("clnp_dooptions: new option dump:\n"); dump_buf(opt, oidx->cni_recrt_len); - ENDDEBUG + } +#endif } } } @@ -202,24 +219,25 @@ struct iso_addr *isoa; /* ptr to our address for this ifp */ /* * FUNCTION: clnp_set_opts * - * PURPOSE: Check the data mbuf passed for option sanity. If it is - * ok, then set the options ptr to address the data mbuf. - * If an options mbuf exists, free it. This implies that - * any old options will be lost. If data is NULL, simply - * free any old options. + * PURPOSE: Check the data mbuf passed for option sanity. If it is + * ok, then set the options ptr to address the data mbuf. + * If an options mbuf exists, free it. This implies that + * any old options will be lost. If data is NULL, simply + * free any old options. * - * RETURNS: unix error code + * RETURNS: unix error code * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ +int clnp_set_opts(options, data) -struct mbuf **options; /* target for option information */ -struct mbuf **data; /* source of option information */ + struct mbuf **options;/* target for option information */ + struct mbuf **data; /* source of option information */ { - int error = 0; /* error return value */ - struct clnp_optidx dummy; /* dummy index - not used */ + int error = 0; /* error return value */ + struct clnp_optidx dummy; /* dummy index - not used */ /* * remove any existing options @@ -228,7 +246,6 @@ struct mbuf **data; /* source of option information */ m_freem(*options); *options = NULL; } - if (*data != NULL) { /* * Insure that the options are reasonable. @@ -238,11 +255,11 @@ struct mbuf **data; /* source of option information */ * * The QOS parameter is checked for the DECBIT. */ - if ((clnp_opt_sanity(*data, mtod(*data, caddr_t), (*data)->m_len, - &dummy) != 0) || - (dummy.cni_securep) || - (dummy.cni_priorp) || - (dummy.cni_er_reason != ER_INVALREAS)) { + if ((clnp_opt_sanity(*data, mtod(*data, caddr_t), (*data)->m_len, + &dummy) != 0) || + (dummy.cni_securep) || + (dummy.cni_priorp) || + (dummy.cni_er_reason != ER_INVALREAS)) { error = EINVAL; } else { *options = *data; @@ -255,38 +272,43 @@ struct mbuf **data; /* source of option information */ /* * FUNCTION: clnp_opt_sanity * - * PURPOSE: Check the options (beginning at opts for len bytes) for - * sanity. In addition, fill in the option index structure - * in with information about each option discovered. + * PURPOSE: Check the options (beginning at opts for len bytes) for + * sanity. In addition, fill in the option index structure + * in with information about each option discovered. * - * RETURNS: success (options check out) - 0 - * failure - an ER pdu error code describing failure + * RETURNS: success (options check out) - 0 + * failure - an ER pdu error code describing failure * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: Each pointer field of the option index is filled in with - * the offset from the beginning of the mbuf data, not the - * actual address. + * NOTES: Each pointer field of the option index is filled in with + * the offset from the beginning of the mbuf data, not the + * actual address. */ +int clnp_opt_sanity(m, opts, len, oidx) -struct mbuf *m; /* mbuf options reside in */ -caddr_t opts; /* ptr to buffer containing options */ -int len; /* length of buffer */ -struct clnp_optidx *oidx; /* RETURN: filled in with option idx info */ + struct mbuf *m; /* mbuf options reside in */ + caddr_t opts; /* ptr to buffer containing options */ + int len; /* length of buffer */ + struct clnp_optidx *oidx; /* RETURN: filled in with option idx + * info */ { - u_char opcode; /* code of particular option */ - u_char oplen; /* length of a particular option */ - caddr_t opts_end; /* ptr to end of options */ - u_char pad = 0, secure = 0, srcrt = 0, recrt = 0, qos = 0, prior = 0; - /* flags for catching duplicate options */ - - IFDEBUG(D_OPTIONS) + u_char opcode = 0; /* code of particular option */ + u_char oplen; /* length of a particular option */ + caddr_t opts_end; /* ptr to end of options */ + u_char pad = 0, secure = 0, srcrt = 0, recrt = 0, + qos = 0, prior = 0; + /* flags for catching duplicate options */ + +#ifdef ARGO_DEBUG + if (argo_debug[D_OPTIONS]) { printf("clnp_opt_sanity: checking %d bytes of data:\n", len); dump_buf(opts, len); - ENDDEBUG + } +#endif /* clear option index field if passed */ - bzero((caddr_t)oidx, sizeof(struct clnp_optidx)); + bzero((caddr_t) oidx, sizeof(struct clnp_optidx)); /* * We need to indicate whether the ER option is present. This is done @@ -300,61 +322,63 @@ struct clnp_optidx *oidx; /* RETURN: filled in with option idx info */ while (opts < opts_end) { /* must have at least 2 bytes per option (opcode and len) */ if (opts + 2 > opts_end) - return(GEN_INCOMPLETE); - + return (GEN_INCOMPLETE); + opcode = *opts++; oplen = *opts++; - IFDEBUG(D_OPTIONS) +#ifdef ARGO_DEBUG + if (argo_debug[D_OPTIONS]) { printf("clnp_opt_sanity: opcode is %x and oplen %d\n", - opcode, oplen); + opcode, oplen); printf("clnp_opt_sanity: clnpoval_SRCRT is %x\n", CLNPOVAL_SRCRT); - switch (opcode) { - case CLNPOVAL_PAD: { - printf("CLNPOVAL_PAD\n"); - } break; - case CLNPOVAL_SECURE: { - printf("CLNPOVAL_SECURE\n"); - } break; - case CLNPOVAL_SRCRT: { - printf("CLNPOVAL_SRCRT\n"); - } break; - case CLNPOVAL_RECRT: { - printf("CLNPOVAL_RECRT\n"); - } break; - case CLNPOVAL_QOS: { - printf("CLNPOVAL_QOS\n"); - } break; - case CLNPOVAL_PRIOR: { - printf("CLNPOVAL_PRIOR\n"); - } break; - case CLNPOVAL_ERREAS: { - printf("CLNPOVAL_ERREAS\n"); - } break; - default: - printf("UKNOWN option %x\n", opcode); - } - ENDDEBUG + switch (opcode) { + case CLNPOVAL_PAD:{ + printf("CLNPOVAL_PAD\n"); + } break; + case CLNPOVAL_SECURE:{ + printf("CLNPOVAL_SECURE\n"); + } break; + case CLNPOVAL_SRCRT:{ + printf("CLNPOVAL_SRCRT\n"); + } break; + case CLNPOVAL_RECRT:{ + printf("CLNPOVAL_RECRT\n"); + } break; + case CLNPOVAL_QOS:{ + printf("CLNPOVAL_QOS\n"); + } break; + case CLNPOVAL_PRIOR:{ + printf("CLNPOVAL_PRIOR\n"); + } break; + case CLNPOVAL_ERREAS:{ + printf("CLNPOVAL_ERREAS\n"); + } break; + default: + printf("UKNOWN option %x\n", opcode); + } + } +#endif /* don't allow crazy length values */ if (opts + oplen > opts_end) - return(GEN_INCOMPLETE); + return (GEN_INCOMPLETE); switch (opcode) { - case CLNPOVAL_PAD: - /* - * Padding: increment pointer by length of padding - */ - if (pad++) /* duplicate ? */ - return(GEN_DUPOPT); - opts += oplen; - break; + case CLNPOVAL_PAD: + /* + * Padding: increment pointer by length of padding + */ + if (pad++) /* duplicate ? */ + return (GEN_DUPOPT); + opts += oplen; + break; - case CLNPOVAL_SECURE: { - u_char format = *opts; + case CLNPOVAL_SECURE:{ + u_char format = *opts; - if (secure++) /* duplicate ? */ - return(GEN_DUPOPT); + if (secure++) /* duplicate ? */ + return (GEN_DUPOPT); /* * Security: high 2 bits of first octet indicate format * (00 in high bits is reserved). @@ -362,83 +386,95 @@ struct clnp_optidx *oidx; /* RETURN: filled in with option idx info */ * actual security */ if (((format & 0x3f) > 0) || /* low 6 bits set ? */ - ((format & 0xc0) == 0)) /* high 2 bits zero ? */ - return(GEN_HDRSYNTAX); + ((format & 0xc0) == 0)) /* high 2 bits zero ? */ + return (GEN_HDRSYNTAX); oidx->cni_securep = CLNP_OPTTOOFF(m, opts); oidx->cni_secure_len = oplen; opts += oplen; } break; - case CLNPOVAL_SRCRT: { - u_char type, offset; /* type of rt, offset of start */ - caddr_t route_end; /* address of end of route option */ + case CLNPOVAL_SRCRT:{ + u_char type, offset; /* type of rt, offset of + * start */ + caddr_t route_end; /* address of end of + * route option */ - IFDEBUG(D_OPTIONS) +#ifdef ARGO_DEBUG + if (argo_debug[D_OPTIONS]) { printf("clnp_opt_sanity: SRC RT\n"); - ENDDEBUG - - if (srcrt++) /* duplicate ? */ - return(GEN_DUPOPT); - /* - * source route: There must be 2 bytes following the length - * field: type and offset. The type must be either - * partial route or complete route. The offset field must - * be within the option. A single exception is made, however. - * The offset may be 1 greater than the length. This case - * occurs when the last source route record is consumed. - * In this case, we ignore the source route option. - * RAH? You should be able to set offset to 'ff' like in record - * route! - * Following this is a series of address fields. - * Each address field is composed of a (length, address) pair. - * Insure that the offset and each address length is reasonable + } +#endif + + if (srcrt++) /* duplicate ? */ + return (GEN_DUPOPT); + /* + * source route: There must be 2 bytes + * following the length field: type and + * offset. The type must be either partial + * route or complete route. The offset field + * must be within the option. A single + * exception is made, however. The offset may + * be 1 greater than the length. This case + * occurs when the last source route record + * is consumed. In this case, we ignore the + * source route option. RAH? You should be + * able to set offset to 'ff' like in record + * route! Following this is a series of + * address fields. Each address field is + * composed of a (length, address) pair. + * Insure that the offset and each address + * length is reasonable */ route_end = opts + oplen; if (opts + 2 > route_end) - return(SRCRT_SYNTAX); + return (SRCRT_SYNTAX); type = *opts; - offset = *(opts+1); + offset = *(opts + 1); /* type must be partial or complete */ if (!((type == CLNPOVAL_PARTRT) || (type == CLNPOVAL_COMPRT))) - return(SRCRT_SYNTAX); - + return (SRCRT_SYNTAX); + oidx->cni_srcrt_s = CLNP_OPTTOOFF(m, opts); oidx->cni_srcrt_len = oplen; - opts += offset-1; /*set opts to first addr in rt */ + opts += offset - 1; /* set opts to first + * addr in rt */ - /* - * Offset must be reasonable: - * less than end of options, or equal to end of options + /* + * Offset must be reasonable: less than end + * of options, or equal to end of options */ if (opts >= route_end) { if (opts == route_end) { - IFDEBUG(D_OPTIONS) +#ifdef ARGO_DEBUG + if (argo_debug[D_OPTIONS]) { printf("clnp_opt_sanity: end of src route info\n"); - ENDDEBUG + } +#endif break; - } else - return(SRCRT_SYNTAX); + } else + return (SRCRT_SYNTAX); } - while (opts < route_end) { - u_char addrlen = *opts++; + u_char addrlen = *opts++; if (opts + addrlen > route_end) - return(SRCRT_SYNTAX); + return (SRCRT_SYNTAX); opts += addrlen; } } break; - case CLNPOVAL_RECRT: { - u_char type, offset; /* type of rt, offset of start */ - caddr_t record_end; /* address of end of record option */ - - if (recrt++) /* duplicate ? */ - return(GEN_DUPOPT); + case CLNPOVAL_RECRT:{ + u_char type, offset; /* type of rt, offset of + * start */ + caddr_t record_end; /* address of end of + * record option */ + + if (recrt++) /* duplicate ? */ + return (GEN_DUPOPT); /* * record route: after the length field, expect a * type and offset. Type must be partial or complete. @@ -452,25 +488,25 @@ struct clnp_optidx *oidx; /* RETURN: filled in with option idx info */ oidx->cni_recrt_len = oplen; if (opts + 2 > record_end) - return(GEN_INCOMPLETE); + return (GEN_INCOMPLETE); type = *opts; - offset = *(opts+1); + offset = *(opts + 1); /* type must be partial or complete */ if (!((type == CLNPOVAL_PARTRT) || (type == CLNPOVAL_COMPRT))) - return(GEN_HDRSYNTAX); - + return (GEN_HDRSYNTAX); + /* offset must be reasonable */ if ((offset < 0xff) && (opts + offset > record_end)) - return(GEN_HDRSYNTAX); + return (GEN_HDRSYNTAX); opts += oplen; } break; - case CLNPOVAL_QOS: { - u_char format = *opts; + case CLNPOVAL_QOS:{ + u_char format = *opts; - if (qos++) /* duplicate ? */ - return(GEN_DUPOPT); + if (qos++) /* duplicate ? */ + return (GEN_DUPOPT); /* * qos: high 2 bits of first octet indicate format * (00 in high bits is reserved). @@ -480,53 +516,58 @@ struct clnp_optidx *oidx; /* RETURN: filled in with option idx info */ * remaining octets indicate actual qos. */ if (((format & 0xc0) == 0) || /* high 2 bits zero ? */ - (((format & 0xc0) != CLNPOVAL_GLOBAL) && - ((format & 0x3f) > 0))) /* not global,low bits used ? */ - return(GEN_HDRSYNTAX); - + (((format & 0xc0) != CLNPOVAL_GLOBAL) && + ((format & 0x3f) > 0))) /* not global,low bits + * used ? */ + return (GEN_HDRSYNTAX); + oidx->cni_qos_formatp = CLNP_OPTTOOFF(m, opts); oidx->cni_qos_len = oplen; opts += oplen; } break; - case CLNPOVAL_PRIOR: { - if (prior++) /* duplicate ? */ - return(GEN_DUPOPT); + case CLNPOVAL_PRIOR:{ + if (prior++) /* duplicate ? */ + return (GEN_DUPOPT); /* * priority: value must be one byte long */ if (oplen != 1) - return(GEN_HDRSYNTAX); - + return (GEN_HDRSYNTAX); + oidx->cni_priorp = CLNP_OPTTOOFF(m, opts); opts += oplen; } break; - case CLNPOVAL_ERREAS: { + case CLNPOVAL_ERREAS:{ /* * er reason: value must be two bytes long */ if (oplen != 2) - return(GEN_HDRSYNTAX); + return (GEN_HDRSYNTAX); oidx->cni_er_reason = *opts; opts += oplen; } break; - default: { - IFDEBUG(D_OPTIONS) + default:{ +#ifdef ARGO_DEBUG + if (argo_debug[D_OPTIONS]) { printf("clnp_opt_sanity: UNKNOWN OPTION 0x%x\n", opcode); - ENDDEBUG - return(DISC_UNSUPPOPT); + } +#endif + return (DISC_UNSUPPOPT); } } } - IFDEBUG(D_OPTIONS) - printf("clnp_opt_sanity: return(0)\n", opcode); - ENDDEBUG - return(0); +#ifdef ARGO_DEBUG + if (argo_debug[D_OPTIONS]) { + printf("clnp_opt_sanity: return(0)\n"); + } +#endif + return (0); } -#endif /* ISO */ +#endif /* ISO */ diff --git a/sys/netiso/clnp_output.c b/sys/netiso/clnp_output.c index 423ef31a6b3..6db45c626b6 100644 --- a/sys/netiso/clnp_output.c +++ b/sys/netiso/clnp_output.c @@ -1,4 +1,5 @@ -/* $NetBSD: clnp_output.c,v 1.7 1995/06/13 07:58:10 mycroft Exp $ */ +/* $OpenBSD: clnp_output.c,v 1.2 1996/03/04 10:34:57 mickey Exp $ */ +/* $NetBSD: clnp_output.c,v 1.8 1996/02/13 22:08:39 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -70,6 +71,7 @@ SOFTWARE. #include <sys/socketvar.h> #include <sys/errno.h> #include <sys/time.h> +#include <sys/systm.h> #include <net/if.h> #include <net/route.h> @@ -81,116 +83,132 @@ SOFTWARE. #include <netiso/clnp_stat.h> #include <netiso/argo_debug.h> +#include <machine/stdarg.h> + static struct clnp_fixed dt_template = { - ISO8473_CLNP, /* network identifier */ - 0, /* length */ + ISO8473_CLNP, /* network identifier */ + 0, /* length */ ISO8473_V1, /* version */ CLNP_TTL, /* ttl */ - CLNP_DT|CNF_SEG_OK|CNF_ERR_OK, /* type */ - 0, /* segment length */ - 0 /* checksum */ + CLNP_DT | CNF_SEG_OK | CNF_ERR_OK, /* type */ + 0, /* segment length */ + 0 /* checksum */ }; static struct clnp_fixed raw_template = { - ISO8473_CLNP, /* network identifier */ - 0, /* length */ + ISO8473_CLNP, /* network identifier */ + 0, /* length */ ISO8473_V1, /* version */ CLNP_TTL, /* ttl */ - CLNP_RAW|CNF_SEG_OK|CNF_ERR_OK, /* type */ - 0, /* segment length */ - 0 /* checksum */ + CLNP_RAW | CNF_SEG_OK | CNF_ERR_OK, /* type */ + 0, /* segment length */ + 0 /* checksum */ }; static struct clnp_fixed echo_template = { - ISO8473_CLNP, /* network identifier */ - 0, /* length */ + ISO8473_CLNP, /* network identifier */ + 0, /* length */ ISO8473_V1, /* version */ CLNP_TTL, /* ttl */ - CLNP_EC|CNF_SEG_OK|CNF_ERR_OK, /* type */ - 0, /* segment length */ - 0 /* checksum */ + CLNP_EC | CNF_SEG_OK | CNF_ERR_OK, /* type */ + 0, /* segment length */ + 0 /* checksum */ }; static struct clnp_fixed echor_template = { - ISO8473_CLNP, /* network identifier */ - 0, /* length */ + ISO8473_CLNP, /* network identifier */ + 0, /* length */ ISO8473_V1, /* version */ CLNP_TTL, /* ttl */ - CLNP_ECR|CNF_SEG_OK|CNF_ERR_OK, /* type */ - 0, /* segment length */ - 0 /* checksum */ + CLNP_ECR | CNF_SEG_OK | CNF_ERR_OK, /* type */ + 0, /* segment length */ + 0 /* checksum */ }; #ifdef DECBIT -u_char qos_option[] = {CLNPOVAL_QOS, 1, - CLNPOVAL_GLOBAL|CLNPOVAL_SEQUENCING|CLNPOVAL_LOWDELAY}; -#endif /* DECBIT */ +u_char qos_option[] = {CLNPOVAL_QOS, 1, +CLNPOVAL_GLOBAL | CLNPOVAL_SEQUENCING | CLNPOVAL_LOWDELAY}; +#endif /* DECBIT */ -int clnp_id = 0; /* id for segmented dgrams */ +int clnp_id = 0; /* id for segmented dgrams */ /* * FUNCTION: clnp_output * - * PURPOSE: output the data in the mbuf as a clnp datagram + * PURPOSE: output the data in the mbuf as a clnp datagram * - * The data specified by m0 is sent as a clnp datagram. - * The mbuf chain m0 will be freed when this routine has - * returned. + * The data specified by m0 is sent as a clnp datagram. + * The mbuf chain m0 will be freed when this routine has + * returned. * - * If options is non-null, it points to an mbuf which contains - * options to be sent with the datagram. The options must - * be formatted in the mbuf according to clnp rules. Options - * will not be freed. + * If options is non-null, it points to an mbuf which + * contains options to be sent with the datagram. The + * options must be formatted in the mbuf according to + * clnp rules. Options will not be freed. * - * Datalen specifies the length of the data in m0. + * Datalen specifies the length of the data in m0. * - * Src and dst are the addresses for the packet. + * Src and dst are the addresses for the packet. * - * If route is non-null, it is used as the route for - * the packet. + * If route is non-null, it is used as the route for + * the packet. * - * By default, a DT is sent. However, if flags & CNLP_SEND_ER - * then an ER will be sent. If flags & CLNP_SEND_RAW, then - * the packet will be send as raw clnp. + * By default, a DT is sent. However, + * if flags & CNLP_SEND_ER then an ER will be sent. + * If flags & CLNP_SEND_RAW, then the packet will + * be send as raw clnp. * - * RETURNS: 0 success - * appropriate error code + * RETURNS: 0 success + * appropriate error code * * SIDE EFFECTS: none * - * NOTES: - * Flags are interpretated as follows: - * CLNP_NO_SEG - do not allow this pkt to be segmented. - * CLNP_NO_ER - have pkt request ER suppression. - * CLNP_SEND_RAW - send pkt as RAW DT rather than TP DT - * CLNP_NO_CKSUM - don't compute clnp checksum - * CLNP_ECHO - send as ECHO packet + * NOTES: Flags are interpretated as follows: + * CLNP_NO_SEG - do not allow this pkt to be segmented. + * CLNP_NO_ER - have pkt request ER suppression. + * CLNP_SEND_RAW - send pkt as RAW DT rather than TP DT + * CLNP_NO_CKSUM - don't compute clnp checksum + * CLNP_ECHO - send as ECHO packet * - * When checking for a cached packet, clnp checks - * that the route taken is still up. It does not - * check that the route is still to the same destination. - * This means that any entity that alters an existing - * route for an isopcb (such as when a redirect arrives) - * must invalidate the clnp cache. It might be perferable - * to have clnp check that the route has the same dest, but - * by avoiding this check, we save a call to iso_addrmatch1. + * When checking for a cached packet, clnp checks + * that the route taken is still up. It does not + * check that the route is still to the same destination. + * This means that any entity that alters an existing + * route for an isopcb (such as when a redirect arrives) + * must invalidate the clnp cache. It might be perferable + * to have clnp check that the route has the same dest, but + * by avoiding this check, we save a call to + * iso_addrmatch1. */ -clnp_output(m0, isop, datalen, flags) -struct mbuf *m0; /* data for the packet */ -struct isopcb *isop; /* iso pcb */ -int datalen; /* number of bytes of data in m0 */ -int flags; /* flags */ +int +#if __STDC__ +clnp_output(struct mbuf *m0, ...) +#else +clnp_output(m0, va_alist) + struct mbuf *m0; /* data for the packet */ + va_dcl +#endif { - int error = 0; /* return value of function */ - register struct mbuf *m = m0; /* mbuf for clnp header chain */ - register struct clnp_fixed *clnp; /* ptr to fixed part of hdr */ - register caddr_t hoff; /* offset into header */ - int total_len; /* total length of packet */ - struct iso_addr *src; /* ptr to source address */ - struct iso_addr *dst; /* ptr to destination address */ - struct clnp_cache clc; /* storage for cache information */ - struct clnp_cache *clcp = NULL; /* ptr to clc */ - int hdrlen = 0; + struct isopcb *isop; /* iso pcb */ + int datalen;/* number of bytes of data in m0 */ + int flags; /* flags */ + int error = 0; /* return value of function */ + register struct mbuf *m = m0; /* mbuf for clnp header chain */ + register struct clnp_fixed *clnp; /* ptr to fixed part of hdr */ + register caddr_t hoff; /* offset into header */ + int total_len; /* total length of packet */ + struct iso_addr *src; /* ptr to source address */ + struct iso_addr *dst; /* ptr to destination address */ + struct clnp_cache clc; /* storage for cache information */ + struct clnp_cache *clcp = NULL; /* ptr to clc */ + int hdrlen = 0; + va_list ap; + + va_start(ap, m0); + isop = va_arg(ap, struct isopcb *); + datalen = va_arg(ap, int); + flags = va_arg(ap, int); + va_end(ap); dst = &isop->isop_faddr->siso_addr; if (isop->isop_laddr == 0) { @@ -202,55 +220,64 @@ int flags; /* flags */ } else src = &isop->isop_laddr->siso_addr; - IFDEBUG(D_OUTPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_OUTPUT]) { printf("clnp_output: to %s", clnp_iso_addrp(dst)); printf(" from %s of %d bytes\n", clnp_iso_addrp(src), datalen); - printf("\toptions x%x, flags x%x, isop_clnpcache x%x\n", - isop->isop_options, flags, isop->isop_clnpcache); - ENDDEBUG + printf("\toptions x%x, flags x%x, isop_clnpcache x%x\n", + (unsigned int) isop->isop_options, flags, + (unsigned int) isop->isop_clnpcache); + } +#endif if (isop->isop_clnpcache != NULL) { clcp = mtod(isop->isop_clnpcache, struct clnp_cache *); } - /* * Check if cache is valid ... */ - IFDEBUG(D_OUTPUT) - printf("clnp_output: ck cache: clcp %x\n", clcp); +#ifdef ARGO_DEBUG + if (argo_debug[D_OUTPUT]) { + printf("clnp_output: ck cache: clcp %x\n", (unsigned int) clcp); if (clcp != NULL) { printf("\tclc_dst %s\n", clnp_iso_addrp(&clcp->clc_dst)); - printf("\tisop_opts x%x, clc_opts x%x\n", isop->isop_options, - clcp->clc_options); + printf("\tisop_opts x%x, clc_opts x%x\n", + (unsigned int) isop->isop_options, + (unsigned int) clcp->clc_options); if (isop->isop_route.ro_rt) printf("\tro_rt x%x, rt_flags x%x\n", - isop->isop_route.ro_rt, isop->isop_route.ro_rt->rt_flags); - printf("\tflags x%x, clc_flags x%x\n", flags, clcp->clc_flags); - printf("\tclc_hdr x%x\n", clcp->clc_hdr); + (unsigned int) isop->isop_route.ro_rt, + isop->isop_route.ro_rt->rt_flags); + printf("\tflags x%x, clc_flags x%x\n", flags, + clcp->clc_flags); + printf("\tclc_hdr x%x\n", (unsigned int) clcp->clc_hdr); } - ENDDEBUG - if ((clcp != NULL) && /* cache exists */ - (isop->isop_options == clcp->clc_options) && /* same options */ - (iso_addrmatch1(dst, &clcp->clc_dst)) && /* dst still same */ - (isop->isop_route.ro_rt != NULL) && /* route exists */ - (isop->isop_route.ro_rt == clcp->clc_rt) && /* and is cached */ - (isop->isop_route.ro_rt->rt_flags & RTF_UP) && /* route still up */ - (flags == clcp->clc_flags) && /* same flags */ - (clcp->clc_hdr != NULL)) { /* hdr mbuf exists */ + } +#endif + if ((clcp != NULL) && /* cache exists */ + (isop->isop_options == clcp->clc_options) && /* same options */ + (iso_addrmatch1(dst, &clcp->clc_dst)) && /* dst still same */ + (isop->isop_route.ro_rt != NULL) && /* route exists */ + (isop->isop_route.ro_rt == clcp->clc_rt) && /* and is cached */ + (isop->isop_route.ro_rt->rt_flags & RTF_UP) && /* route still up */ + (flags == clcp->clc_flags) && /* same flags */ + (clcp->clc_hdr != NULL)) { /* hdr mbuf exists */ /* - * The cache is valid + * The cache is valid */ - IFDEBUG(D_OUTPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_OUTPUT]) { printf("clnp_output: using cache\n"); - ENDDEBUG + } +#endif - m = m_copy(clcp->clc_hdr, 0, (int)M_COPYALL); + m = m_copy(clcp->clc_hdr, 0, (int) M_COPYALL); if (m == NULL) { /* - * No buffers left to copy cached packet header. Use - * the cached packet header this time, and - * mark the hdr as vacant + * No buffers left to copy cached packet header. Use + * the cached packet header this time, and + * mark the hdr as vacant */ m = clcp->clc_hdr; clcp->clc_hdr = NULL; @@ -258,12 +285,12 @@ int flags; /* flags */ m->m_next = m0; /* ASSUMES pkt hdr is 1 mbuf long */ clnp = mtod(m, struct clnp_fixed *); } else { - struct clnp_optidx *oidx = NULL; /* index to clnp options */ + struct clnp_optidx *oidx = NULL; /* index to clnp options */ /* - * The cache is not valid. Allocate an mbuf (if necessary) - * to hold cached info. If one is not available, then - * don't bother with the cache + * The cache is not valid. Allocate an mbuf (if necessary) + * to hold cached info. If one is not available, then + * don't bother with the cache */ INCSTAT(cns_cachemiss); if (flags & CLNP_NOCACHE) { @@ -271,95 +298,110 @@ int flags; /* flags */ } else { if (isop->isop_clnpcache == NULL) { /* - * There is no clnpcache. Allocate an mbuf to hold one + * There is no clnpcache. Allocate an mbuf + * to hold one */ if ((isop->isop_clnpcache = m_get(M_DONTWAIT, MT_HEADER)) - == NULL) { + == NULL) { /* - * No mbufs available. Pretend that we don't want - * caching this time. + * No mbufs available. Pretend that we + * don't want caching this time. */ - IFDEBUG(D_OUTPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_OUTPUT]) { printf("clnp_output: no mbufs to allocate to cache\n"); - ENDDEBUG - flags |= CLNP_NOCACHE; + } +#endif + flags |= CLNP_NOCACHE; clcp = &clc; } else { clcp = mtod(isop->isop_clnpcache, struct clnp_cache *); } } else { /* - * A clnpcache mbuf exists. If the clc_hdr is not null, - * we must free it, as a new one is about to be created. + * A clnpcache mbuf exists. If the clc_hdr + * is not null, we must free it, as a new one + * is about to be created. */ clcp = mtod(isop->isop_clnpcache, struct clnp_cache *); if (clcp->clc_hdr != NULL) { /* - * The clc_hdr is not null but a clnpcache mbuf exists. - * This means that there was a cache, but the existing - * copy of the hdr is no longer valid. Free it now - * before we lose the pointer to it. + * The clc_hdr is not null but a + * clnpcache mbuf exists. This means + * that there was a cache, but the + * existing copy of the hdr is no + * longer valid. Free it now + * before we lose the pointer to it. */ - IFDEBUG(D_OUTPUT) - printf("clnp_output: freeing old clc_hdr 0x%x\n", - clcp->clc_hdr); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_OUTPUT]) { + printf( + "clnp_output: freeing old clc_hdr 0x%x\n", + (unsigned int) clcp->clc_hdr); + } +#endif m_free(clcp->clc_hdr); - IFDEBUG(D_OUTPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_OUTPUT]) { printf("clnp_output: freed old clc_hdr (done)\n"); - ENDDEBUG + } +#endif } } } - IFDEBUG(D_OUTPUT) - printf("clnp_output: NEW clcp x%x\n",clcp); - ENDDEBUG - bzero((caddr_t)clcp, sizeof(struct clnp_cache)); +#ifdef ARGO_DEBUG + if (argo_debug[D_OUTPUT]) { + printf("clnp_output: NEW clcp x%x\n", + (unsigned int) clcp); + } +#endif + bzero((caddr_t) clcp, sizeof(struct clnp_cache)); if (isop->isop_optindex) oidx = mtod(isop->isop_optindex, struct clnp_optidx *); /* - * Don't allow packets with security, quality of service, - * priority, or error report options to be sent. + * Don't allow packets with security, quality of service, + * priority, or error report options to be sent. */ if ((isop->isop_options) && (oidx)) { if ((oidx->cni_securep) || - (oidx->cni_priorp) || - (oidx->cni_qos_formatp) || - (oidx->cni_er_reason != ER_INVALREAS)) { - IFDEBUG(D_OUTPUT) + (oidx->cni_priorp) || + (oidx->cni_qos_formatp) || + (oidx->cni_er_reason != ER_INVALREAS)) { +#ifdef ARGO_DEBUG + if (argo_debug[D_OUTPUT]) { printf("clnp_output: pkt dropped - option unsupported\n"); - ENDDEBUG + } +#endif m_freem(m0); - return(EINVAL); + return (EINVAL); } } - /* - * Don't allow any invalid flags to be set + * Don't allow any invalid flags to be set */ if ((flags & (CLNP_VFLAGS)) != flags) { - IFDEBUG(D_OUTPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_OUTPUT]) { printf("clnp_output: packet dropped - flags unsupported\n"); - ENDDEBUG + } +#endif INCSTAT(cns_odropped); m_freem(m0); - return(EINVAL); + return (EINVAL); } - /* - * Don't allow funny lengths on dst; src may be zero in which - * case we insert the source address based upon the interface + * Don't allow funny lengths on dst; src may be zero in which + * case we insert the source address based upon the interface */ - if ((src->isoa_len > sizeof(struct iso_addr)) || - (dst->isoa_len == 0) || - (dst->isoa_len > sizeof(struct iso_addr))) { + if ((src->isoa_len > sizeof(struct iso_addr)) || + (dst->isoa_len == 0) || + (dst->isoa_len > sizeof(struct iso_addr))) { m_freem(m0); INCSTAT(cns_odropped); - return(ENAMETOOLONG); + return (ENAMETOOLONG); } - /* * Grab mbuf to contain header */ @@ -367,7 +409,7 @@ int flags; /* flags */ if (m == 0) { m_freem(m0); INCSTAT(cns_odropped); - return(ENOBUFS); + return (ENOBUFS); } INCSTAT(cns_sent); m->m_next = m0; @@ -375,7 +417,7 @@ int flags; /* flags */ clcp->clc_segoff = 0; /* - * Fill in all of fixed hdr except lengths and checksum + * Fill in all of fixed hdr except lengths and checksum */ if (flags & CLNP_SEND_RAW) { *clnp = raw_template; @@ -395,84 +437,93 @@ int flags; /* flags */ * Route packet; special case for source rt */ if ((isop->isop_options) && CLNPSRCRT_VALID(oidx)) { - IFDEBUG(D_OUTPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_OUTPUT]) { printf("clnp_output: calling clnp_srcroute\n"); - ENDDEBUG + } +#endif error = clnp_srcroute(isop->isop_options, oidx, &isop->isop_route, - &clcp->clc_firsthop, &clcp->clc_ifa, dst); + &clcp->clc_firsthop, &clcp->clc_ifa, dst); } else { - IFDEBUG(D_OUTPUT) - ENDDEBUG - error = clnp_route(dst, &isop->isop_route, flags, - &clcp->clc_firsthop, &clcp->clc_ifa); +#ifdef ARGO_DEBUG + if (argo_debug[D_OUTPUT]) { + } +#endif + error = clnp_route(dst, &isop->isop_route, flags, + &clcp->clc_firsthop, &clcp->clc_ifa); } if (error || (clcp->clc_ifa == 0)) { - IFDEBUG(D_OUTPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_OUTPUT]) { printf("clnp_output: route failed, errno %d\n", error); printf("@clcp:\n"); - dump_buf(clcp, sizeof (struct clnp_cache)); - ENDDEBUG + dump_buf(clcp, sizeof(struct clnp_cache)); + } +#endif goto bad; } clcp->clc_rt = isop->isop_route.ro_rt; /* XXX */ - clcp->clc_ifp = clcp->clc_ifa->ia_ifp; /* XXX */ - - IFDEBUG(D_OUTPUT) - printf("clnp_output: packet routed to %s\n", - clnp_iso_addrp( - &satosiso(clcp->clc_firsthop)->siso_addr)); - ENDDEBUG - + clcp->clc_ifp = clcp->clc_ifa->ia_ifp; /* XXX */ + +#ifdef ARGO_DEBUG + if (argo_debug[D_OUTPUT]) { + printf("clnp_output: packet routed to %s\n", + clnp_iso_addrp( + &satosiso(clcp->clc_firsthop)->siso_addr)); + } +#endif + /* - * If src address is not yet specified, use address of - * interface. NOTE: this will now update the laddr field in - * the isopcb. Is this desirable? RAH? + * If src address is not yet specified, use address of + * interface. NOTE: this will now update the laddr field in + * the isopcb. Is this desirable? RAH? */ if (src->isoa_len == 0) { src = &(clcp->clc_ifa->ia_addr.siso_addr); - IFDEBUG(D_OUTPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_OUTPUT]) { printf("clnp_output: new src %s\n", clnp_iso_addrp(src)); - ENDDEBUG + } +#endif } - /* - * Insert the source and destination address, + * Insert the source and destination address, */ - hoff = (caddr_t)clnp + sizeof(struct clnp_fixed); + hoff = (caddr_t) clnp + sizeof(struct clnp_fixed); CLNP_INSERT_ADDR(hoff, *dst); CLNP_INSERT_ADDR(hoff, *src); /* - * Leave room for the segment part, if segmenting is selected + * Leave room for the segment part, if segmenting is selected */ if (clnp->cnf_type & CNF_SEG_OK) { - clcp->clc_segoff = hoff - (caddr_t)clnp; + clcp->clc_segoff = hoff - (caddr_t) clnp; hoff += sizeof(struct clnp_segment); } - - clnp->cnf_hdr_len = m->m_len = (u_char)(hoff - (caddr_t)clnp); + clnp->cnf_hdr_len = m->m_len = (u_char) (hoff - (caddr_t) clnp); hdrlen = clnp->cnf_hdr_len; #ifdef DECBIT /* - * Add the globally unique QOS (with room for congestion experienced - * bit). I can safely assume that this option is not in the options - * mbuf below because I checked that the option was not specified - * previously + * Add the globally unique QOS (with room for congestion + * experienced bit). I can safely assume that this option + * is not in the options mbuf below because I checked that + * the option was not specified previously */ if ((m->m_len + sizeof(qos_option)) < MLEN) { - bcopy((caddr_t)qos_option, hoff, sizeof(qos_option)); + bcopy((caddr_t) qos_option, hoff, sizeof(qos_option)); clnp->cnf_hdr_len += sizeof(qos_option); hdrlen += sizeof(qos_option); m->m_len += sizeof(qos_option); } -#endif /* DECBIT */ +#endif /* DECBIT */ /* - * If an options mbuf is present, concatenate a copy to the hdr mbuf. + * If an options mbuf is present, concatenate a copy to the hdr mbuf. */ if (isop->isop_options) { - struct mbuf *opt_copy = m_copy(isop->isop_options, 0, (int)M_COPYALL); + struct mbuf *opt_copy = + m_copy(isop->isop_options, 0, (int) M_COPYALL); if (opt_copy == NULL) { error = ENOBUFS; goto bad; @@ -485,18 +536,17 @@ int flags; /* flags */ clnp->cnf_hdr_len += opt_copy->m_len; hdrlen += opt_copy->m_len; } - if (hdrlen > CLNP_HDR_MAX) { error = EMSGSIZE; goto bad; } - /* - * Now set up the cache entry in the pcb + * Now set up the cache entry in the pcb */ if ((flags & CLNP_NOCACHE) == 0) { - if (clcp->clc_hdr = m_copy(m, 0, (int)clnp->cnf_hdr_len)) { - clcp->clc_dst = *dst; + clcp->clc_hdr = m_copy(m, 0, (int) clnp->cnf_hdr_len); + if (clcp->clc_hdr) { + clcp->clc_dst = *dst; clcp->clc_flags = flags; clcp->clc_options = isop->isop_options; } @@ -508,12 +558,12 @@ int flags; /* flags */ */ total_len = clnp->cnf_hdr_len + datalen; if (clnp->cnf_type & CNF_SEG_OK) { - struct clnp_segment seg_part; /* segment part of hdr */ + struct clnp_segment seg_part; /* segment part of hdr */ seg_part.cng_id = htons(clnp_id++); seg_part.cng_off = htons(0); seg_part.cng_tot_len = htons(total_len); - (void) bcopy((caddr_t)&seg_part, (caddr_t) clnp + clcp->clc_segoff, - sizeof(seg_part)); + (void) bcopy((caddr_t) & seg_part, (caddr_t) clnp + clcp->clc_segoff, + sizeof(seg_part)); } if (total_len <= SN_MTU(clcp->clc_ifp, clcp->clc_rt)) { HTOC(clnp->cnf_seglen_msb, clnp->cnf_seglen_lsb, total_len); @@ -524,17 +574,19 @@ int flags; /* flags */ if (flags & CLNP_NO_CKSUM) { HTOC(clnp->cnf_cksum_msb, clnp->cnf_cksum_lsb, 0); } else { - iso_gen_csum(m, CLNP_CKSUM_OFF, (int)clnp->cnf_hdr_len); + iso_gen_csum(m, CLNP_CKSUM_OFF, (int) clnp->cnf_hdr_len); } - IFDEBUG(D_DUMPOUT) - struct mbuf *mdump = m; +#ifdef ARGO_DEBUG + if (argo_debug[D_DUMPOUT]) { + struct mbuf *mdump = m; printf("clnp_output: sending dg:\n"); while (mdump != NULL) { dump_buf(mtod(mdump, caddr_t), mdump->m_len); mdump = mdump->m_next; } - ENDDEBUG + } +#endif error = SN_OUTPUT(clcp, m); goto done; @@ -543,7 +595,7 @@ int flags; /* flags */ * Too large for interface; fragment if possible. */ error = clnp_fragment(clcp->clc_ifp, m, clcp->clc_firsthop, - total_len, clcp->clc_segoff, flags, clcp->clc_rt); + total_len, clcp->clc_segoff, flags, clcp->clc_rt); goto done; } bad: @@ -556,6 +608,7 @@ done: return (error); } -int clnp_ctloutput() +void +clnp_ctloutput() { } diff --git a/sys/netiso/clnp_raw.c b/sys/netiso/clnp_raw.c index e09411038b7..67694c2b68d 100644 --- a/sys/netiso/clnp_raw.c +++ b/sys/netiso/clnp_raw.c @@ -1,4 +1,5 @@ -/* $NetBSD: clnp_raw.c,v 1.8 1995/08/17 02:57:30 mycroft Exp $ */ +/* $OpenBSD: clnp_raw.c,v 1.2 1996/03/04 10:34:59 mickey Exp $ */ +/* $NetBSD: clnp_raw.c,v 1.9 1996/02/13 22:08:42 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -70,6 +71,7 @@ SOFTWARE. #include <sys/socketvar.h> #include <sys/errno.h> #include <sys/time.h> +#include <sys/systm.h> #include <net/if.h> #include <net/route.h> @@ -81,36 +83,50 @@ SOFTWARE. #include <netiso/clnp_stat.h> #include <netiso/argo_debug.h> -#include <netiso/tp_user.h> /* XXX -- defines SOL_NETWORK */ +#include <netiso/tp_user.h> /* XXX -- defines SOL_NETWORK */ -struct sockproto rclnp_proto = { PF_ISO, 0 }; +#include <machine/stdarg.h> + +struct sockproto rclnp_proto = {PF_ISO, 0}; /* * FUNCTION: rclnp_input * - * PURPOSE: Setup generic address an protocol structures for - * raw input routine, then pass them along with the - * mbuf chain. + * PURPOSE: Setup generic address an protocol structures for + * raw input routine, then pass them along with the + * mbuf chain. * - * RETURNS: none + * RETURNS: none * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: The protocol field of rclnp_proto is set to zero indicating - * no protocol. + * NOTES: The protocol field of rclnp_proto is set to zero + * indicating no protocol. */ void -rclnp_input(m, src, dst, hdrlen) -struct mbuf *m; /* ptr to packet */ -struct sockaddr_iso *src; /* ptr to src address */ -struct sockaddr_iso *dst; /* ptr to dest address */ -int hdrlen; /* length (in bytes) of clnp header */ +#if __STDC__ +rclnp_input(struct mbuf *m, ...) +#else +rclnp_input(m, va_alist) + struct mbuf *m; /* ptr to packet */ + va_dcl +#endif { + struct sockaddr_iso *src; /* ptr to src address */ + struct sockaddr_iso *dst; /* ptr to dest address */ + int hdrlen; /* length (in bytes) of clnp header */ + va_list ap; + + va_start(ap, m); + src = va_arg(ap, struct sockaddr_iso *); + dst = va_arg(ap, struct sockaddr_iso *); + hdrlen = va_arg(ap, int); + va_end(ap); #ifdef TROLL if (trollctl.tr_ops & TR_CHUCK) { m_freem(m); return; } -#endif /* TROLL */ +#endif /* TROLL */ raw_input(m, &rclnp_proto, sisotosa(src), sisotosa(dst)); } @@ -125,31 +141,41 @@ int hdrlen; /* length (in bytes) of clnp header */ * RETURNS: success - 0 * failure - an appropriate error code * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ -rclnp_output(m0, so) -struct mbuf *m0; /* packet to send */ -struct socket *so; /* socket to send from */ +int +#if __STDC__ +rclnp_output(struct mbuf *m0, ...) +#else +rclnp_output(m0, va_alist) + struct mbuf *m0; /* packet to send */ + va_dcl +#endif { - register struct mbuf *m; /* used to scan a chain */ - int len = 0; /* store length of chain here */ - struct rawisopcb *rp = sotorawisopcb(so); /* ptr to raw cb */ - int error; /* return value of function */ - int flags; /* flags for clnp_output */ + struct socket *so; /* socket to send from */ + struct rawisopcb *rp; /* ptr to raw cb */ + int error; /* return value of function */ + int flags; /* flags for clnp_output */ + va_list ap; + + va_start(ap, m0); + so = va_arg(ap, struct socket *); + va_end(ap); + rp = sotorawisopcb(so); - if (0 == (m0->m_flags & M_PKTHDR)) + if ((m0->m_flags & M_PKTHDR) == 0) return (EINVAL); /* - * Set up src address. If user has bound socket to an address, use it. - * Otherwise, do not specify src (clnp_output will fill it in). + * Set up src address. If user has bound socket to an address, use it. + * Otherwise, do not specify src (clnp_output will fill it in). */ if (rp->risop_rcb.rcb_laddr) { if (rp->risop_isop.isop_sladdr.siso_family != AF_ISO) { -bad: + bad: m_freem(m0); - return(EAFNOSUPPORT); + return (EAFNOSUPPORT); } } /* set up dest address */ @@ -162,7 +188,7 @@ bad: flags = rp->risop_flags & CLNP_VFLAGS; error = clnp_output(m0, &rp->risop_isop, m0->m_pkthdr.len, - flags|CLNP_NOCACHE); + flags | CLNP_NOCACHE); return (error); } @@ -171,7 +197,7 @@ bad: * FUNCTION: rclnp_ctloutput * * PURPOSE: Raw clnp socket option processing - * All options are stored inside an mbuf. + * All options are stored inside an mbuf. * * RETURNS: success - 0 * failure - unix error code @@ -179,101 +205,106 @@ bad: * SIDE EFFECTS: If the options mbuf does not exist, it the mbuf passed * is used. * - * NOTES: + * NOTES: */ +int rclnp_ctloutput(op, so, level, optname, m) -int op; /* type of operation */ -struct socket *so; /* ptr to socket */ -int level; /* level of option */ -int optname; /* name of option */ -struct mbuf **m; /* ptr to ptr to option data */ + int op; /* type of operation */ + struct socket *so; /* ptr to socket */ + int level; /* level of option */ + int optname;/* name of option */ + struct mbuf **m; /* ptr to ptr to option data */ { - int error = 0; - register struct rawisopcb *rp = sotorawisopcb(so);/* raw cb ptr */ + int error = 0; + register struct rawisopcb *rp = sotorawisopcb(so); /* raw cb ptr */ - IFDEBUG(D_CTLOUTPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_CTLOUTPUT]) { printf("rclnp_ctloutput: op = x%x, level = x%x, name = x%x\n", - op, level, optname); + op, level, optname); if (*m != NULL) { printf("rclnp_ctloutput: %d bytes of mbuf data\n", (*m)->m_len); dump_buf(mtod((*m), caddr_t), (*m)->m_len); } - ENDDEBUG + } +#endif #ifdef SOL_NETWORK if (level != SOL_NETWORK) error = EINVAL; - else switch (op) { + else + switch (op) { #else switch (op) { -#endif /* SOL_NETWORK */ - case PRCO_SETOPT: - switch (optname) { - case CLNPOPT_FLAGS: { - u_short usr_flags; - /* - * Insure that the data passed has exactly one short in it - */ - if ((*m == NULL) || ((*m)->m_len != sizeof(short))) { - error = EINVAL; - break; - } - - /* - * Don't allow invalid flags to be set - */ - usr_flags = (*mtod((*m), short *)); - - if ((usr_flags & (CLNP_VFLAGS)) != usr_flags) { - error = EINVAL; - } else - rp->risop_flags |= usr_flags; - - } break; - - case CLNPOPT_OPTS: - if (error = clnp_set_opts(&rp->risop_isop.isop_options, m)) - break; - rp->risop_isop.isop_optindex = m_get(M_WAIT, MT_SOOPTS); - (void) clnp_opt_sanity(rp->risop_isop.isop_options, - mtod(rp->risop_isop.isop_options, caddr_t), - rp->risop_isop.isop_options->m_len, - mtod(rp->risop_isop.isop_optindex, - struct clnp_optidx *)); +#endif /* SOL_NETWORK */ + case PRCO_SETOPT: + switch (optname) { + case CLNPOPT_FLAGS:{ + u_short usr_flags; + /* + * Insure that the data passed has exactly + * one short in it + */ + if ((*m == NULL) || ((*m)->m_len != sizeof(short))) { + error = EINVAL; break; - } - break; + } + /* + * Don't allow invalid flags to be set + */ + usr_flags = (*mtod((*m), short *)); - case PRCO_GETOPT: -#ifdef notdef - /* commented out to keep hi C quiet */ - switch (optname) { - default: + if ((usr_flags & (CLNP_VFLAGS)) != usr_flags) { error = EINVAL; - break; - } -#endif /* notdef */ + } else + rp->risop_flags |= usr_flags; + + } break; + + case CLNPOPT_OPTS: + error = clnp_set_opts(&rp->risop_isop.isop_options, m); + if (error) + break; + rp->risop_isop.isop_optindex = m_get(M_WAIT, MT_SOOPTS); + (void) clnp_opt_sanity(rp->risop_isop.isop_options, + mtod(rp->risop_isop.isop_options, caddr_t), + rp->risop_isop.isop_options->m_len, + mtod(rp->risop_isop.isop_optindex, + struct clnp_optidx *)); break; + } + break; + + case PRCO_GETOPT: +#ifdef notdef + /* commented out to keep hi C quiet */ + switch (optname) { default: error = EINVAL; break; + } +#endif /* notdef */ + break; + default: + error = EINVAL; + break; } if (op == PRCO_SETOPT) { /* note: m_freem does not barf is *m is NULL */ m_freem(*m); *m = NULL; } - return error; } -/*ARGSUSED*/ +/* ARGSUSED */ +int clnp_usrreq(so, req, m, nam, control) register struct socket *so; - int req; - struct mbuf *m, *nam, *control; + int req; + struct mbuf *m, *nam, *control; { - register int error = 0; + register int error = 0; register struct rawisopcb *rp = sotorawisopcb(so); rp = sotorawisopcb(so); @@ -285,7 +316,7 @@ clnp_usrreq(so, req, m, nam, control) MALLOC(rp, struct rawisopcb *, sizeof *rp, M_PCB, M_WAITOK); if (rp == 0) return (ENOBUFS); - bzero((caddr_t)rp, sizeof *rp); + bzero(rp, sizeof *rp); so->so_pcb = rp; break; @@ -300,8 +331,8 @@ clnp_usrreq(so, req, m, nam, control) rp->risop_rcb.rcb_laddr = 0; /* free clnp cached hdr if necessary */ if (rp->risop_isop.isop_clnpcache != NULL) { - struct clnp_cache *clcp = - mtod(rp->risop_isop.isop_clnpcache, struct clnp_cache *); + struct clnp_cache *clcp = + mtod(rp->risop_isop.isop_clnpcache, struct clnp_cache *); if (clcp->clc_hdr != NULL) { m_free(clcp->clc_hdr); } @@ -313,40 +344,40 @@ clnp_usrreq(so, req, m, nam, control) break; case PRU_BIND: - { - struct sockaddr_iso *addr = mtod(nam, struct sockaddr_iso *); - - if (nam->m_len != sizeof(*addr)) - return (EINVAL); - if ((ifnet.tqh_first == 0) || - (addr->siso_family != AF_ISO) || - (addr->siso_addr.isoa_len && - ifa_ifwithaddr(sisotosa(addr)) == 0)) - return (EADDRNOTAVAIL); - rp->risop_isop.isop_sladdr = *addr; - rp->risop_rcb.rcb_laddr = sisotosa( - (rp->risop_isop.isop_laddr = &rp->risop_isop.isop_sladdr)); - return (0); - } + { + struct sockaddr_iso *addr = mtod(nam, struct sockaddr_iso *); + + if (nam->m_len != sizeof(*addr)) + return (EINVAL); + if ((ifnet.tqh_first == 0) || + (addr->siso_family != AF_ISO) || + (addr->siso_addr.isoa_len && + ifa_ifwithaddr(sisotosa(addr)) == 0)) + return (EADDRNOTAVAIL); + rp->risop_isop.isop_sladdr = *addr; + rp->risop_rcb.rcb_laddr = sisotosa( + (rp->risop_isop.isop_laddr = &rp->risop_isop.isop_sladdr)); + return (0); + } case PRU_CONNECT: - { - struct sockaddr_iso *addr = mtod(nam, struct sockaddr_iso *); - - if ((nam->m_len > sizeof(*addr)) || (addr->siso_len > sizeof(*addr))) - return (EINVAL); - if (ifnet.tqh_first == 0) - return (EADDRNOTAVAIL); - if (addr->siso_family != AF_ISO) - rp->risop_isop.isop_sfaddr = *addr; - rp->risop_rcb.rcb_faddr = sisotosa( - (rp->risop_isop.isop_faddr = &rp->risop_isop.isop_sfaddr)); - soisconnected(so); - return (0); - } + { + struct sockaddr_iso *addr = mtod(nam, struct sockaddr_iso *); + + if ((nam->m_len > sizeof(*addr)) || (addr->siso_len > sizeof(*addr))) + return (EINVAL); + if (ifnet.tqh_first == 0) + return (EADDRNOTAVAIL); + if (addr->siso_family != AF_ISO) + rp->risop_isop.isop_sfaddr = *addr; + rp->risop_rcb.rcb_faddr = sisotosa( + (rp->risop_isop.isop_faddr = &rp->risop_isop.isop_sfaddr)); + soisconnected(so); + return (0); + } } - error = raw_usrreq(so, req, m, nam, control); + error = raw_usrreq(so, req, m, nam, control); if (error && req == PRU_ATTACH && so->so_pcb) - free((caddr_t)rp, M_PCB); + free((caddr_t) rp, M_PCB); return (error); } diff --git a/sys/netiso/clnp_stat.h b/sys/netiso/clnp_stat.h index 3cc5193aa51..9158b85cea1 100644 --- a/sys/netiso/clnp_stat.h +++ b/sys/netiso/clnp_stat.h @@ -1,4 +1,5 @@ -/* $NetBSD: clnp_stat.h,v 1.5 1994/06/29 06:39:18 cgd Exp $ */ +/* $OpenBSD: clnp_stat.h,v 1.2 1996/03/04 10:35:01 mickey Exp $ */ +/* $NetBSD: clnp_stat.h,v 1.6 1996/02/13 22:08:46 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -66,37 +67,40 @@ SOFTWARE. #define _NETISO_CLNP_STAT_H_ struct clnp_stat { - int cns_total; /* total pkts received */ - int cns_toosmall; /* fixed part of header too small */ - int cns_badhlen; /* header length is not reasonable */ - int cns_badcsum; /* checksum on packet failed */ - int cns_badaddr; /* address fields were not reasonable */ - int cns_badvers; /* incorrect version */ - int cns_noseg; /* segment information forgotten */ - int cns_noproto; /* incorrect protocol id */ - int cns_delivered; /* packets consumed by protocol */ - int cns_ttlexpired; /* ttl has expired */ - int cns_forward; /* forwarded packets */ - int cns_sent; /* total packets sent */ - int cns_odropped; /* o.k. packets discarded, e.g. ENOBUFS */ - int cns_cantforward; /* non-forwarded packets */ - int cns_fragmented; /* packets fragmented */ - int cns_fragments; /* fragments received */ - int cns_fragdropped; /* fragments discarded */ - int cns_fragtimeout; /* fragments timed out */ - int cns_ofragments; /* fragments generated */ - int cns_cantfrag; /* fragmentation prohibited */ - int cns_reassembled; /* packets reconstructed */ - int cns_cachemiss; /* cache misses */ - int cns_congest_set; /* congestion experienced bit set */ - int cns_congest_rcvd; /* congestion experienced bit received */ - int cns_er_inhist[CLNP_ERRORS + 1]; - int cns_er_outhist[CLNP_ERRORS + 1]; -} clnp_stat ; + int cns_total; /* total pkts received */ + int cns_toosmall; /* fixed part of header too small */ + int cns_badhlen; /* header length is not reasonable */ + int cns_badcsum; /* checksum on packet failed */ + int cns_badaddr; /* address fields were not reasonable */ + int cns_badvers; /* incorrect version */ + int cns_noseg; /* segment information forgotten */ + int cns_noproto; /* incorrect protocol id */ + int cns_delivered; /* packets consumed by protocol */ + int cns_ttlexpired; /* ttl has expired */ + int cns_forward; /* forwarded packets */ + int cns_sent; /* total packets sent */ + int cns_odropped; /* o.k. packets discarded, e.g. + * ENOBUFS */ + int cns_cantforward; /* non-forwarded packets */ + int cns_fragmented; /* packets fragmented */ + int cns_fragments; /* fragments received */ + int cns_fragdropped; /* fragments discarded */ + int cns_fragtimeout; /* fragments timed out */ + int cns_ofragments; /* fragments generated */ + int cns_cantfrag; /* fragmentation prohibited */ + int cns_reassembled; /* packets reconstructed */ + int cns_cachemiss; /* cache misses */ + int cns_congest_set; /* congestion experienced bit + * set */ + int cns_congest_rcvd; /* congestion experienced bit + * received */ + int cns_er_inhist[CLNP_ERRORS + 1]; + int cns_er_outhist[CLNP_ERRORS + 1]; +} clnp_stat; #ifdef INCSTAT #undef INCSTAT -#endif /* INCSTAT */ +#endif /* INCSTAT */ #define INCSTAT(x) clnp_stat./**/x/**/++ -#endif /* _NETISO_CLNP_STAT_H_ */ +#endif /* _NETISO_CLNP_STAT_H_ */ diff --git a/sys/netiso/clnp_subr.c b/sys/netiso/clnp_subr.c index 2c68c44fe4c..4b634c9f279 100644 --- a/sys/netiso/clnp_subr.c +++ b/sys/netiso/clnp_subr.c @@ -1,4 +1,5 @@ -/* $NetBSD: clnp_subr.c,v 1.6 1995/06/13 07:13:22 mycroft Exp $ */ +/* $OpenBSD: clnp_subr.c,v 1.2 1996/03/04 10:35:02 mickey Exp $ */ +/* $NetBSD: clnp_subr.c,v 1.7 1996/02/13 22:08:49 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -72,6 +73,7 @@ SOFTWARE. #include <sys/socketvar.h> #include <sys/errno.h> #include <sys/time.h> +#include <sys/systm.h> #include <net/if.h> #include <net/route.h> @@ -84,29 +86,30 @@ SOFTWARE. #include <netiso/clnp.h> #include <netiso/clnp_stat.h> #include <netiso/argo_debug.h> +#include <netiso/esis.h> /* * FUNCTION: clnp_data_ck * - * PURPOSE: Check that the amount of data in the mbuf chain is - * at least as much as the clnp header would have us - * expect. Trim mbufs if longer than expected, drop - * packet if shorter than expected. + * PURPOSE: Check that the amount of data in the mbuf chain is + * at least as much as the clnp header would have us + * expect. Trim mbufs if longer than expected, drop + * packet if shorter than expected. * - * RETURNS: success - ptr to mbuf chain - * failure - 0 + * RETURNS: success - ptr to mbuf chain + * failure - 0 * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ -struct mbuf * +struct mbuf * clnp_data_ck(m, length) -register struct mbuf *m; /* ptr to mbuf chain containing hdr & data */ -int length; /* length (in bytes) of packet */ - { - register int len; /* length of data */ - register struct mbuf *mhead; /* ptr to head of chain */ + register struct mbuf *m;/* ptr to mbuf chain containing hdr & data */ + int length; /* length (in bytes) of packet */ +{ + register int len; /* length of data */ + register struct mbuf *mhead; /* ptr to head of chain */ len = -length; mhead = m; @@ -134,46 +137,47 @@ int length; /* length (in bytes) of packet */ /* * FUNCTION: clnp_extract_addr * - * PURPOSE: Extract the source and destination address from the - * supplied buffer. Place them in the supplied address buffers. - * If insufficient data is supplied, then fail. + * PURPOSE: Extract the source and destination address from the + * supplied buffer. Place them in the supplied address buffers. + * If insufficient data is supplied, then fail. * - * RETURNS: success - Address of first byte in the packet past - * the address part. - * failure - 0 + * RETURNS: success - Address of first byte in the packet past + * the address part. + * failure - 0 * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ caddr_t clnp_extract_addr(bufp, buflen, srcp, destp) -caddr_t bufp; /* ptr to buffer containing addresses */ -int buflen; /* length of buffer */ -register struct iso_addr *srcp; /* ptr to source address buffer */ -register struct iso_addr *destp; /* ptr to destination address buffer */ - { - int len; /* argument to bcopy */ - - /* - * check that we have enough data. Plus1 is for length octet + caddr_t bufp; /* ptr to buffer containing addresses */ + int buflen; /* length of buffer */ + register struct iso_addr *srcp; /* ptr to source address buffer */ + register struct iso_addr *destp; /* ptr to destination address + * buffer */ +{ + int len; /* argument to bcopy */ + + /* + * check that we have enough data. Plus1 is for length octet */ - if ((u_char)*bufp + 1 > buflen) { - return((caddr_t)0); + if ((u_char) * bufp + 1 > buflen) { + return ((caddr_t) 0); } - len = destp->isoa_len = (u_char)*bufp++; - (void) bcopy(bufp, (caddr_t)destp, len); + len = destp->isoa_len = (u_char) * bufp++; + (void) bcopy(bufp, (caddr_t) destp, len); buflen -= len; bufp += len; - /* - * check that we have enough data. Plus1 is for length octet + /* + * check that we have enough data. Plus1 is for length octet */ - if ((u_char)*bufp + 1 > buflen) { - return((caddr_t)0); + if ((u_char) * bufp + 1 > buflen) { + return ((caddr_t) 0); } - len = srcp->isoa_len = (u_char)* bufp++; - (void) bcopy(bufp, (caddr_t)srcp, len); + len = srcp->isoa_len = (u_char) * bufp++; + (void) bcopy(bufp, (caddr_t) srcp, len); bufp += len; /* @@ -184,107 +188,119 @@ register struct iso_addr *destp; /* ptr to destination address buffer */ else return (caddr_t) 0; } -#endif /* notdef */ +#endif /* notdef */ /* * FUNCTION: clnp_ours * - * PURPOSE: Decide whether the supplied packet is destined for - * us, or that it should be forwarded on. + * PURPOSE: Decide whether the supplied packet is destined for + * us, or that it should be forwarded on. * - * RETURNS: packet is for us - 1 - * packet is not for us - 0 + * RETURNS: packet is for us - 1 + * packet is not for us - 0 * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ +int clnp_ours(dst) -register struct iso_addr *dst; /* ptr to destination address */ + register struct iso_addr *dst; /* ptr to destination address */ { register struct iso_ifaddr *ia; /* scan through interface addresses */ for (ia = iso_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next) { - IFDEBUG(D_ROUTE) - printf("clnp_ours: ia_sis x%x, dst x%x\n", &ia->ia_addr, - dst); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_ROUTE]) { + printf("clnp_ours: ia_sis x%x, dst x%x\n", + (unsigned int) &ia->ia_addr, + (unsigned int) dst); + } +#endif /* * XXX Warning: * We are overloading siso_tlen in the if's address, as an nsel length. */ if (dst->isoa_len == ia->ia_addr.siso_nlen && - bcmp((caddr_t)ia->ia_addr.siso_addr.isoa_genaddr, - (caddr_t)dst->isoa_genaddr, - ia->ia_addr.siso_nlen - ia->ia_addr.siso_tlen) == 0) - return 1; + bcmp((caddr_t) ia->ia_addr.siso_addr.isoa_genaddr, + (caddr_t) dst->isoa_genaddr, + ia->ia_addr.siso_nlen - ia->ia_addr.siso_tlen) == 0) + return 1; } return 0; } /* Dec bit set if ifp qlen is greater than congest_threshold */ -int congest_threshold = 0; +int congest_threshold = 0; /* * FUNCTION: clnp_forward * - * PURPOSE: Forward the datagram passed - * clnpintr guarantees that the header will be - * contigious (a cluster mbuf will be used if necessary). + * PURPOSE: Forward the datagram passed + * clnpintr guarantees that the header will be + * contigious (a cluster mbuf will be used if necessary). * - * If oidx is NULL, no options are present. + * If oidx is NULL, no options are present. * - * RETURNS: nothing + * RETURNS: nothing * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ +void clnp_forward(m, len, dst, oidx, seg_off, inbound_shp) -struct mbuf *m; /* pkt to forward */ -int len; /* length of pkt */ -struct iso_addr *dst; /* destination address */ -struct clnp_optidx *oidx; /* option index */ -int seg_off;/* offset of segmentation part */ -struct snpa_hdr *inbound_shp; /* subnetwork header of inbound packet */ + struct mbuf *m; /* pkt to forward */ + int len; /* length of pkt */ + struct iso_addr *dst; /* destination address */ + struct clnp_optidx *oidx; /* option index */ + int seg_off;/* offset of segmentation part */ + struct snpa_hdr *inbound_shp; /* subnetwork header of inbound + * packet */ { - struct clnp_fixed *clnp; /* ptr to fixed part of header */ - int error; /* return value of route function */ - struct sockaddr *next_hop; /* next hop for dgram */ - struct ifnet *ifp; /* ptr to outgoing interface */ - struct iso_ifaddr *ia = 0;/* ptr to iso name for ifp */ - struct route_iso route; /* filled in by clnp_route */ - extern int iso_systype; + struct clnp_fixed *clnp;/* ptr to fixed part of header */ + int error; /* return value of route function */ + struct sockaddr *next_hop; /* next hop for dgram */ + struct ifnet *ifp; /* ptr to outgoing interface */ + struct iso_ifaddr *ia = 0; /* ptr to iso name for ifp */ + struct route_iso route; /* filled in by clnp_route */ + extern int iso_systype; clnp = mtod(m, struct clnp_fixed *); - bzero((caddr_t)&route, sizeof(route)); /* MUST be done before "bad:" */ + bzero((caddr_t) & route, sizeof(route)); /* MUST be done before + * "bad:" */ /* * Don't forward multicast or broadcast packets */ if ((inbound_shp) && (IS_MULTICAST(inbound_shp->snh_dhost))) { - IFDEBUG(D_FORWARD) +#ifdef ARGO_DEBUG + if (argo_debug[D_FORWARD]) { printf("clnp_forward: dropping multicast packet\n"); - ENDDEBUG - clnp->cnf_type &= ~CNF_ERR_OK; /* so we don't generate an ER */ + } +#endif + clnp->cnf_type &= ~CNF_ERR_OK; /* so we don't generate an ER */ clnp_discard(m, 0); INCSTAT(cns_cantforward); goto done; } - - IFDEBUG(D_FORWARD) +#ifdef ARGO_DEBUG + if (argo_debug[D_FORWARD]) { printf("clnp_forward: %d bytes, to %s, options x%x\n", len, - clnp_iso_addrp(dst), oidx); - ENDDEBUG + clnp_iso_addrp(dst), (unsigned int) oidx); + } +#endif /* * Decrement ttl, and if zero drop datagram * Can't compare ttl as less than zero 'cause its a unsigned */ if ((clnp->cnf_ttl == 0) || (--clnp->cnf_ttl == 0)) { - IFDEBUG(D_FORWARD) +#ifdef ARGO_DEBUG + if (argo_debug[D_FORWARD]) { printf("clnp_forward: discarding datagram because ttl is zero\n"); - ENDDEBUG + } +#endif INCSTAT(cns_ttlexpired); clnp_discard(m, TTL_EXPTRANSIT); goto done; @@ -292,7 +308,8 @@ struct snpa_hdr *inbound_shp; /* subnetwork header of inbound packet */ /* * Route packet; special case for source rt */ - if CLNPSRCRT_VALID(oidx) { + if CLNPSRCRT_VALID + (oidx) { /* * Update src route first */ @@ -302,36 +319,40 @@ struct snpa_hdr *inbound_shp; /* subnetwork header of inbound packet */ error = clnp_route(dst, &route, 0, &next_hop, &ia); } if (error || ia == 0) { - IFDEBUG(D_FORWARD) +#ifdef ARGO_DEBUG + if (argo_debug[D_FORWARD]) { printf("clnp_forward: can't route packet (errno %d)\n", error); - ENDDEBUG + } +#endif clnp_discard(m, ADDR_DESTUNREACH); INCSTAT(cns_cantforward); goto done; } ifp = ia->ia_ifp; - IFDEBUG(D_FORWARD) - printf("clnp_forward: packet routed to %s\n", - clnp_iso_addrp(&satosiso(next_hop)->siso_addr)); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_FORWARD]) { + printf("clnp_forward: packet routed to %s\n", + clnp_iso_addrp(&satosiso(next_hop)->siso_addr)); + } +#endif INCSTAT(cns_forward); /* * If we are an intermediate system and * we are routing outbound on the same ifp that the packet - * arrived upon, and we know the next hop snpa, + * arrived upon, and we know the next hop snpa, * then generate a redirect request */ - if ((iso_systype & SNPA_IS) && (inbound_shp) && - (ifp == inbound_shp->snh_ifp)) - esis_rdoutput(inbound_shp, m, oidx, dst, route.ro_rt); + if ((iso_systype & SNPA_IS) && (inbound_shp) && + (ifp == inbound_shp->snh_ifp)) + esis_rdoutput(inbound_shp, m, oidx, dst, route.ro_rt); /* * If options are present, update them */ if (oidx) { - struct iso_addr *mysrc = &ia->ia_addr.siso_addr; + struct iso_addr *mysrc = &ia->ia_addr.siso_addr; if (mysrc == NULL) { clnp_discard(m, ADDR_DESTUNREACH); INCSTAT(cns_cantforward); @@ -341,21 +362,24 @@ struct snpa_hdr *inbound_shp; /* subnetwork header of inbound packet */ (void) clnp_dooptions(m, oidx, ifp, mysrc); } } - #ifdef DECBIT if (ifp->if_snd.ifq_len > congest_threshold) { /* * Congestion! Set the Dec Bit and thank Dave Oran */ - IFDEBUG(D_FORWARD) +#ifdef ARGO_DEBUG + if (argo_debug[D_FORWARD]) { printf("clnp_forward: congestion experienced\n"); - ENDDEBUG + } +#endif if ((oidx) && (oidx->cni_qos_formatp)) { - caddr_t qosp = CLNP_OFFTOOPT(m, oidx->cni_qos_formatp); - u_char qos = *qosp; - IFDEBUG(D_FORWARD) + caddr_t qosp = CLNP_OFFTOOPT(m, oidx->cni_qos_formatp); + u_char qos = *qosp; +#ifdef ARGO_DEBUG + if (argo_debug[D_FORWARD]) { printf("clnp_forward: setting congestion bit (qos x%x)\n", qos); - ENDDEBUG + } +#endif if ((qos & CLNPOVAL_GLOBAL) == CLNPOVAL_GLOBAL) { qos |= CLNPOVAL_CONGESTED; INCSTAT(cns_congest_set); @@ -363,18 +387,18 @@ struct snpa_hdr *inbound_shp; /* subnetwork header of inbound packet */ } } } -#endif /* DECBIT */ - +#endif /* DECBIT */ + /* * Dispatch the datagram if it is small enough, otherwise fragment */ if (len <= SN_MTU(ifp, route.ro_rt)) { - iso_gen_csum(m, CLNP_CKSUM_OFF, (int)clnp->cnf_hdr_len); - (void) (*ifp->if_output)(ifp, m, next_hop, route.ro_rt); + iso_gen_csum(m, CLNP_CKSUM_OFF, (int) clnp->cnf_hdr_len); + (void) (*ifp->if_output) (ifp, m, next_hop, route.ro_rt); } else { - (void) clnp_fragment(ifp, m, next_hop, len, seg_off, /* flags */0, route.ro_rt); + (void) clnp_fragment(ifp, m, next_hop, len, seg_off, /* flags */ 0, route.ro_rt); } - + done: /* * Free route @@ -392,54 +416,56 @@ done: * * RETURNS: Address of first byte after address part in datagram. * - * SIDE EFFECTS: + * SIDE EFFECTS: * * NOTES: Assume that there is enough space for the address part. */ caddr_t clnp_insert_addr(bufp, srcp, dstp) -caddr_t bufp; /* address of where addr part goes */ -register struct iso_addr *srcp; /* ptr to src addr */ -register struct iso_addr *dstp; /* ptr to dst addr */ + caddr_t bufp; /* address of where addr part goes */ + register struct iso_addr *srcp; /* ptr to src addr */ + register struct iso_addr *dstp; /* ptr to dst addr */ { *bufp++ = dstp->isoa_len; - (void) bcopy((caddr_t)dstp, bufp, dstp->isoa_len); + (void) bcopy((caddr_t) dstp, bufp, dstp->isoa_len); bufp += dstp->isoa_len; *bufp++ = srcp->isoa_len; - (void) bcopy((caddr_t)srcp, bufp, srcp->isoa_len); + (void) bcopy((caddr_t) srcp, bufp, srcp->isoa_len); bufp += srcp->isoa_len; return bufp; } -#endif /* notdef */ +#endif /* notdef */ /* * FUNCTION: clnp_route * - * PURPOSE: Route a clnp datagram to the first hop toward its - * destination. In many cases, the first hop will be - * the destination. The address of a route - * is specified. If a routing entry is present in - * that route, and it is still up to the same destination, - * then no further action is necessary. Otherwise, a - * new routing entry will be allocated. + * PURPOSE: Route a clnp datagram to the first hop toward its + * destination. In many cases, the first hop will be + * the destination. The address of a route + * is specified. If a routing entry is present in + * that route, and it is still up to the same destination, + * then no further action is necessary. Otherwise, a + * new routing entry will be allocated. * - * RETURNS: route found - 0 - * unix error code + * RETURNS: route found - 0 + * unix error code * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: It is up to the caller to free the routing entry - * allocated in route. + * NOTES: It is up to the caller to free the routing entry + * allocated in route. */ +int clnp_route(dst, ro, flags, first_hop, ifa) - struct iso_addr *dst; /* ptr to datagram destination */ - register struct route_iso *ro; /* existing route structure */ - int flags; /* flags for routing */ - struct sockaddr **first_hop; /* result: fill in with ptr to firsthop */ - struct iso_ifaddr **ifa; /* result: fill in with ptr to interface */ + struct iso_addr *dst; /* ptr to datagram destination */ + register struct route_iso *ro; /* existing route structure */ + int flags; /* flags for routing */ + struct sockaddr **first_hop; /* result: fill in with ptr to + * firsthop */ + struct iso_ifaddr **ifa;/* result: fill in with ptr to interface */ { if (flags & SO_DONTROUTE) { struct iso_ifaddr *ia; @@ -448,9 +474,9 @@ clnp_route(dst, ro, flags, first_hop, ifa) RTFREE(ro->ro_rt); ro->ro_rt = 0; } - bzero((caddr_t)&ro->ro_dst, sizeof(ro->ro_dst)); - bcopy((caddr_t)dst, (caddr_t)&ro->ro_dst.siso_addr, - 1 + (unsigned)dst->isoa_len); + bzero((caddr_t) & ro->ro_dst, sizeof(ro->ro_dst)); + bcopy((caddr_t) dst, (caddr_t) & ro->ro_dst.siso_addr, + 1 + (unsigned) dst->isoa_len); ro->ro_dst.siso_family = AF_ISO; ro->ro_dst.siso_len = sizeof(ro->ro_dst); ia = iso_localifa(&ro->ro_dst); @@ -467,41 +493,47 @@ clnp_route(dst, ro, flags, first_hop, ifa) * the same destination. If not, free it and try again. */ if (ro->ro_rt && ((ro->ro_rt->rt_flags & RTF_UP) == 0 || - (Bcmp(ro->ro_dst.siso_data, dst->isoa_genaddr, dst->isoa_len)))) { - IFDEBUG(D_ROUTE) + (Bcmp(ro->ro_dst.siso_data, dst->isoa_genaddr, dst->isoa_len)))) { +#ifdef ARGO_DEBUG + if (argo_debug[D_ROUTE]) { printf("clnp_route: freeing old route: ro->ro_rt 0x%x\n", - ro->ro_rt); + (unsigned int) ro->ro_rt); printf("clnp_route: old route refcnt: 0x%x\n", - ro->ro_rt->rt_refcnt); - ENDDEBUG + ro->ro_rt->rt_refcnt); + } +#endif /* free old route entry */ RTFREE(ro->ro_rt); - ro->ro_rt = (struct rtentry *)0; + ro->ro_rt = (struct rtentry *) 0; } else { - IFDEBUG(D_ROUTE) +#ifdef ARGO_DEBUG + if (argo_debug[D_ROUTE]) { printf("clnp_route: OK route exists\n"); - ENDDEBUG + } +#endif } if (ro->ro_rt == 0) { /* set up new route structure */ - bzero((caddr_t)&ro->ro_dst, sizeof(ro->ro_dst)); + bzero((caddr_t) & ro->ro_dst, sizeof(ro->ro_dst)); ro->ro_dst.siso_len = sizeof(ro->ro_dst); ro->ro_dst.siso_family = AF_ISO; Bcopy(dst, &ro->ro_dst.siso_addr, 1 + dst->isoa_len); /* allocate new route */ - IFDEBUG(D_ROUTE) +#ifdef ARGO_DEBUG + if (argo_debug[D_ROUTE]) { printf("clnp_route: allocating new route to %s\n", - clnp_iso_addrp(dst)); - ENDDEBUG - rtalloc((struct route *)ro); + clnp_iso_addrp(dst)); + } +#endif + rtalloc((struct route *) ro); } if (ro->ro_rt == 0) - return(ENETUNREACH); /* rtalloc failed */ + return (ENETUNREACH); /* rtalloc failed */ ro->ro_rt->rt_use++; if (ifa) - if ((*ifa = (struct iso_ifaddr *)ro->ro_rt->rt_ifa) == 0) + if ((*ifa = (struct iso_ifaddr *) ro->ro_rt->rt_ifa) == 0) panic("clnp_route"); if (first_hop) { if (ro->ro_rt->rt_flags & RTF_GATEWAY) @@ -509,42 +541,45 @@ clnp_route(dst, ro, flags, first_hop, ifa) else *first_hop = sisotosa(&ro->ro_dst); } - return(0); + return (0); } /* * FUNCTION: clnp_srcroute * - * PURPOSE: Source route the datagram. If complete source - * routing is specified but not possible, then - * return an error. If src routing is terminated, then - * try routing on destination. - * Usage of first_hop, - * ifp, and error return is identical to clnp_route. + * PURPOSE: Source route the datagram. If complete source + * routing is specified but not possible, then + * return an error. If src routing is terminated, then + * try routing on destination. + * Usage of first_hop, + * ifp, and error return is identical to clnp_route. * - * RETURNS: 0 or unix error code + * RETURNS: 0 or unix error code * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: Remember that option index pointers are really - * offsets from the beginning of the mbuf. + * NOTES: Remember that option index pointers are really + * offsets from the beginning of the mbuf. */ +int clnp_srcroute(options, oidx, ro, first_hop, ifa, final_dst) -struct mbuf *options; /* ptr to options */ -struct clnp_optidx *oidx; /* index to options */ -struct route_iso *ro; /* route structure */ -struct sockaddr **first_hop; /* RETURN: fill in with ptr to firsthop */ -struct iso_ifaddr **ifa; /* RETURN: fill in with ptr to interface */ -struct iso_addr *final_dst; /* final destination */ + struct mbuf *options;/* ptr to options */ + struct clnp_optidx *oidx; /* index to options */ + struct route_iso *ro; /* route structure */ + struct sockaddr **first_hop; /* RETURN: fill in with ptr to + * firsthop */ + struct iso_ifaddr **ifa;/* RETURN: fill in with ptr to interface */ + struct iso_addr *final_dst; /* final destination */ { - struct iso_addr dst; /* first hop specified by src rt */ - int error = 0; /* return code */ + struct iso_addr dst; /* first hop specified by src rt */ + int error = 0; /* return code */ /* - * Check if we have run out of routes + * Check if we have run out of routes * If so, then try to route on destination. */ - if CLNPSRCRT_TERM(oidx, options) { + if CLNPSRCRT_TERM + (oidx, options) { dst.isoa_len = final_dst->isoa_len; bcopy(final_dst->isoa_genaddr, dst.isoa_genaddr, dst.isoa_len); } else { @@ -561,18 +596,19 @@ struct iso_addr *final_dst; /* final destination */ error = clnp_route(&dst, ro, 0, first_hop, ifa); if (error != 0) return error; - + /* * If complete src rt, first hop must be equal to dst */ if ((CLNPSRCRT_TYPE(oidx, options) == CLNPOVAL_COMPRT) && - (!iso_addrmatch1(&satosiso(*first_hop)->siso_addr, &dst))){ - IFDEBUG(D_OPTIONS) + (!iso_addrmatch1(&satosiso(*first_hop)->siso_addr, &dst))) { +#ifdef ARGO_DEBUG + if (argo_debug[D_OPTIONS]) { printf("clnp_srcroute: complete src route failed\n"); - ENDDEBUG - return EHOSTUNREACH; /* RAH? would like ESRCRTFAILED */ + } +#endif + return EHOSTUNREACH; /* RAH? would like ESRCRTFAILED */ } - return error; } @@ -583,55 +619,61 @@ struct iso_addr *final_dst; /* final destination */ * * RETURNS: result of clnp_output * - * SIDE EFFECTS: + * SIDE EFFECTS: */ +int clnp_echoreply(ec_m, ec_len, ec_src, ec_dst, ec_oidxp) -struct mbuf *ec_m; /* echo request */ -int ec_len; /* length of ec */ -struct sockaddr_iso *ec_src; /* src of ec */ -struct sockaddr_iso *ec_dst; /* destination of ec (i.e., us) */ -struct clnp_optidx *ec_oidxp; /* options index to ec packet */ + struct mbuf *ec_m; /* echo request */ + int ec_len; /* length of ec */ + struct sockaddr_iso *ec_src; /* src of ec */ + struct sockaddr_iso *ec_dst; /* destination of ec (i.e., us) */ + struct clnp_optidx *ec_oidxp; /* options index to ec packet */ { - struct isopcb isopcb; - int flags = CLNP_NOCACHE|CLNP_ECHOR; - int ret; + struct isopcb isopcb; + int flags = CLNP_NOCACHE | CLNP_ECHOR; + int ret; /* fill in fake isopcb to pass to output function */ bzero(&isopcb, sizeof(isopcb)); isopcb.isop_laddr = ec_dst; isopcb.isop_faddr = ec_src; - /* forget copying the options for now. If implemented, need only - * copy record route option, but it must be reset to zero length */ + /* + * forget copying the options for now. If implemented, need only copy + * record route option, but it must be reset to zero length + */ ret = clnp_output(ec_m, &isopcb, ec_len, flags); - IFDEBUG(D_OUTPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_OUTPUT]) { printf("clnp_echoreply: output returns %d\n", ret); - ENDDEBUG + } +#endif return ret; } /* * FUNCTION: clnp_badmtu * - * PURPOSE: print notice of route with mtu not initialized. + * PURPOSE: print notice of route with mtu not initialized. * - * RETURNS: mtu of ifp. + * RETURNS: mtu of ifp. * * SIDE EFFECTS: prints notice, slows down system. */ +int clnp_badmtu(ifp, rt, line, file) -struct ifnet *ifp; /* outgoing interface */ -struct rtentry *rt; /* dst route */ -int line; /* where the dirty deed occured */ -char *file; /* where the dirty deed occured */ + struct ifnet *ifp; /* outgoing interface */ + struct rtentry *rt; /* dst route */ + int line; /* where the dirty deed occured */ + char *file; /* where the dirty deed occured */ { printf("sending on route 0x%x with no mtu, line %d of file %s\n", - rt, line, file); + (unsigned int) rt, line, file); #ifdef ARGO_DEBUG printf("route dst is "); - dump_isoaddr(rt_key(rt)); + dump_isoaddr((struct sockaddr_iso *) rt_key(rt)); #endif return ifp->if_mtu; } @@ -639,20 +681,21 @@ char *file; /* where the dirty deed occured */ /* * FUNCTION: clnp_ypocb - backwards bcopy * - * PURPOSE: bcopy starting at end of src rather than beginning. + * PURPOSE: bcopy starting at end of src rather than beginning. * - * RETURNS: none + * RETURNS: none * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: No attempt has been made to make this efficient + * NOTES: No attempt has been made to make this efficient */ +void clnp_ypocb(from, to, len) -caddr_t from; /* src buffer */ -caddr_t to; /* dst buffer */ -u_int len; /* number of bytes */ + caddr_t from; /* src buffer */ + caddr_t to; /* dst buffer */ + u_int len; /* number of bytes */ { while (len--) *(to + len) = *(from + len); } -#endif /* ISO */ +#endif /* ISO */ diff --git a/sys/netiso/clnp_timer.c b/sys/netiso/clnp_timer.c index 3f03c4b80a6..9adaee55847 100644 --- a/sys/netiso/clnp_timer.c +++ b/sys/netiso/clnp_timer.c @@ -1,4 +1,5 @@ -/* $NetBSD: clnp_timer.c,v 1.6 1995/08/12 23:59:44 mycroft Exp $ */ +/* $OpenBSD: clnp_timer.c,v 1.2 1996/03/04 10:35:04 mickey Exp $ */ +/* $NetBSD: clnp_timer.c,v 1.7 1996/02/13 22:08:55 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -87,22 +88,22 @@ extern struct clnp_fragl *clnp_frags; * * RETURNS: pointer to next fragment in list of fragments * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: * TODO: send ER back to source */ struct clnp_fragl * clnp_freefrags(cfh) -register struct clnp_fragl *cfh; /* fragment header to delete */ + register struct clnp_fragl *cfh; /* fragment header to delete */ { - struct clnp_fragl *next = cfh->cfl_next; - struct clnp_frag *cf; + struct clnp_fragl *next = cfh->cfl_next; + struct clnp_frag *cf; /* free any frags hanging around */ cf = cfh->cfl_frags; while (cf != NULL) { - struct clnp_frag *cf_next = cf->cfr_next; + struct clnp_frag *cf_next = cf->cfr_next; INCSTAT(cns_fragdropped); m_freem(cf->cfr_data); cf = cf_next; @@ -115,7 +116,7 @@ register struct clnp_fragl *cfh; /* fragment header to delete */ if (clnp_frags == cfh) { clnp_frags = cfh->cfl_next; } else { - struct clnp_fragl *scan; + struct clnp_fragl *scan; for (scan = clnp_frags; scan != NULL; scan = scan->cfl_next) { if (scan->cfl_next == cfh) { @@ -128,26 +129,26 @@ register struct clnp_fragl *cfh; /* fragment header to delete */ /* free the fragment header */ m_freem(dtom(cfh)); - return(next); + return (next); } /* * FUNCTION: clnp_slowtimo * - * PURPOSE: clnp timer processing; if the ttl expires on a + * PURPOSE: clnp timer processing; if the ttl expires on a * packet on the reassembly queue, discard it. * * RETURNS: none * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ void clnp_slowtimo() { - register struct clnp_fragl *cfh = clnp_frags; - int s = splsoftnet(); + register struct clnp_fragl *cfh = clnp_frags; + int s = splsoftnet(); while (cfh != NULL) { if (--cfh->cfl_ttl == 0) { @@ -167,15 +168,15 @@ clnp_slowtimo() * * RETURNS: none * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: * TODO: should send back ER */ void clnp_drain() { - register struct clnp_fragl *cfh = clnp_frags; + register struct clnp_fragl *cfh = clnp_frags; while (cfh != NULL) cfh = clnp_freefrags(cfh); diff --git a/sys/netiso/cltp_usrreq.c b/sys/netiso/cltp_usrreq.c index 2c14c10fa22..2be18dbdda0 100644 --- a/sys/netiso/cltp_usrreq.c +++ b/sys/netiso/cltp_usrreq.c @@ -1,4 +1,5 @@ -/* $NetBSD: cltp_usrreq.c,v 1.8 1995/08/12 23:59:46 mycroft Exp $ */ +/* $OpenBSD: cltp_usrreq.c,v 1.2 1996/03/04 10:35:06 mickey Exp $ */ +/* $NetBSD: cltp_usrreq.c,v 1.9 1996/02/13 22:08:59 christos Exp $ */ /* * Copyright (c) 1989, 1993 @@ -35,7 +36,7 @@ * @(#)cltp_usrreq.c 8.1 (Berkeley) 6/10/93 */ -#ifndef CLTPOVAL_SRC /* XXX -- till files gets changed */ +#ifndef CLTPOVAL_SRC /* XXX -- till files gets changed */ #include <sys/param.h> #include <sys/malloc.h> #include <sys/mbuf.h> @@ -44,6 +45,7 @@ #include <sys/socketvar.h> #include <sys/errno.h> #include <sys/stat.h> +#include <sys/systm.h> #include <net/if.h> #include <net/route.h> @@ -54,8 +56,13 @@ #include <netiso/iso_var.h> #include <netiso/clnp.h> #include <netiso/cltp_var.h> +#include <netiso/tp_param.h> +#include <netiso/tp_var.h> + +#include <machine/stdarg.h> #endif + /* * CLTP protocol implementation. * Per ISO 8602, December, 1987. @@ -67,65 +74,78 @@ cltp_init() cltb.isop_next = cltb.isop_prev = &cltb; } -int cltp_cksum = 1; +int cltp_cksum = 1; /* ARGUSED */ void -cltp_input(m0, srcsa, dstsa, cons_channel, output) - struct mbuf *m0; - struct sockaddr *srcsa, *dstsa; - u_int cons_channel; - int (*output)(); +#if __STDC__ +cltp_input(struct mbuf *m0, ...) +#else +cltp_input(m0, va_alist) + struct mbuf *m0; + va_dcl +#endif { + struct sockaddr *srcsa, *dstsa; + u_int cons_channel; register struct isopcb *isop; register struct mbuf *m = m0; register u_char *up = mtod(m, u_char *); - register struct sockaddr_iso *src = satosiso(srcsa); - int len, hdrlen = *up + 1, dlen = 0; - u_char *uplim = up + hdrlen; - caddr_t dtsap; + register struct sockaddr_iso *src; + int len, hdrlen = *up + 1, dlen = 0; + u_char *uplim = up + hdrlen; + caddr_t dtsap = NULL; + va_list ap; + + va_start(ap, m0); + srcsa = va_arg(ap, struct sockaddr *); + dstsa = va_arg(ap, struct sockaddr *); + cons_channel = va_arg(ap, int); + va_end(ap); + src = satosiso(srcsa); for (len = 0; m; m = m->m_next) len += m->m_len; - up += 2; /* skip header */ - while (up < uplim) switch (*up) { /* process options */ - case CLTPOVAL_SRC: - src->siso_tlen = up[1]; - src->siso_len = up[1] + TSEL(src) - (caddr_t)src; - if (src->siso_len < sizeof(*src)) - src->siso_len = sizeof(*src); - else if (src->siso_len > sizeof(*src)) { - MGET(m, M_DONTWAIT, MT_SONAME); - if (m == 0) + up += 2; /* skip header */ + while (up < uplim) + switch (*up) { /* process options */ + case CLTPOVAL_SRC: + src->siso_tlen = up[1]; + src->siso_len = up[1] + TSEL(src) - (caddr_t) src; + if (src->siso_len < sizeof(*src)) + src->siso_len = sizeof(*src); + else if (src->siso_len > sizeof(*src)) { + MGET(m, M_DONTWAIT, MT_SONAME); + if (m == 0) + goto bad; + m->m_len = src->siso_len; + src = mtod(m, struct sockaddr_iso *); + bcopy((caddr_t) srcsa, (caddr_t) src, srcsa->sa_len); + } + bcopy((caddr_t) up + 2, TSEL(src), up[1]); + up += 2 + src->siso_tlen; + continue; + + case CLTPOVAL_DST: + dtsap = 2 + (caddr_t) up; + dlen = up[1]; + up += 2 + dlen; + continue; + + case CLTPOVAL_CSM: + if (iso_check_csum(m0, len)) { + cltpstat.cltps_badsum++; goto bad; - m->m_len = src->siso_len; - src = mtod(m, struct sockaddr_iso *); - bcopy((caddr_t)srcsa, (caddr_t)src, srcsa->sa_len); - } - bcopy((caddr_t)up + 2, TSEL(src), up[1]); - up += 2 + src->siso_tlen; - continue; - - case CLTPOVAL_DST: - dtsap = 2 + (caddr_t)up; - dlen = up[1]; - up += 2 + dlen; - continue; - - case CLTPOVAL_CSM: - if (iso_check_csum(m0, len)) { - cltpstat.cltps_badsum++; + } + up += 4; + continue; + + default: + printf("clts: unknown option (%x)\n", up[0]); + cltpstat.cltps_hdrops++; goto bad; } - up += 4; - continue; - - default: - printf("clts: unknown option (%x)\n", up[0]); - cltpstat.cltps_hdrops++; - goto bad; - } if (dlen == 0 || src->siso_tlen == 0) goto bad; for (isop = cltb.isop_next;; isop = isop->isop_next) { @@ -141,7 +161,7 @@ cltp_input(m0, srcsa, dstsa, cons_channel, output) m->m_len -= hdrlen; m->m_data += hdrlen; if (sbappendaddr(&isop->isop_socket->so_rcv, sisotosa(src), m, - (struct mbuf *)0) == 0) + (struct mbuf *) 0) == 0) goto bad; cltpstat.cltps_ipackets++; sorwakeup(isop->isop_socket); @@ -157,6 +177,7 @@ bad: * Notify a cltp user of an asynchronous error; * just wake up so that he can collect error status. */ +void cltp_notify(isop) register struct isopcb *isop; { @@ -166,15 +187,15 @@ cltp_notify(isop) } void -cltp_ctlinput(cmd, sa) - int cmd; +cltp_ctlinput(cmd, sa, dummy) + int cmd; struct sockaddr *sa; + void *dummy; { - extern u_char inetctlerrmap[]; + extern u_char inetctlerrmap[]; struct sockaddr_iso *siso; - int iso_rtchange(); - if ((unsigned)cmd > PRC_NCMDS) + if ((unsigned) cmd > PRC_NCMDS) return; if (sa->sa_family != AF_ISO && sa->sa_family != AF_CCITT) return; @@ -189,25 +210,36 @@ cltp_ctlinput(cmd, sa) case PRC_REDIRECT_TOSNET: case PRC_REDIRECT_TOSHOST: iso_pcbnotify(&cltb, siso, - (int)inetctlerrmap[cmd], iso_rtchange); + (int) inetctlerrmap[cmd], iso_rtchange); break; default: if (inetctlerrmap[cmd] == 0) - return; /* XXX */ - iso_pcbnotify(&cltb, siso, (int)inetctlerrmap[cmd], - cltp_notify); + return; /* XXX */ + iso_pcbnotify(&cltb, siso, (int) inetctlerrmap[cmd], + cltp_notify); } } -cltp_output(isop, m) - register struct isopcb *isop; - register struct mbuf *m; +int +#if __STDC__ +cltp_output(struct mbuf *m, ...) +#else +cltp_output(m, va_alist) + struct mbuf *m; + va_dcl +#endif { - register int len; + register struct isopcb *isop; + register int len; register struct sockaddr_iso *siso; - int hdrlen, error = 0, docsum; + int hdrlen, error = 0, docsum; register u_char *up; + va_list ap; + + va_start(ap, m); + isop = va_arg(ap, struct isopcb *); + va_end(ap); if (isop->isop_laddr == 0 || isop->isop_faddr == 0) { error = ENOTCONN; @@ -217,8 +249,9 @@ cltp_output(isop, m) * Calculate data length and get a mbuf for CLTP header. */ hdrlen = 2 + 2 + isop->isop_laddr->siso_tlen - + 2 + isop->isop_faddr->siso_tlen; - if (docsum = /*isop->isop_flags & CLNP_NO_CKSUM*/ cltp_cksum) + + 2 + isop->isop_faddr->siso_tlen; + docsum = /* isop->isop_flags & CLNP_NO_CKSUM */ cltp_cksum; + if (docsum) hdrlen += 4; M_PREPEND(m, hdrlen, M_WAIT); len = m->m_pkthdr.len; @@ -231,12 +264,12 @@ cltp_output(isop, m) up[2] = CLTPOVAL_SRC; up[3] = (siso = isop->isop_laddr)->siso_tlen; up += 4; - bcopy(TSEL(siso), (caddr_t)up, siso->siso_tlen); + bcopy(TSEL(siso), (caddr_t) up, siso->siso_tlen); up += siso->siso_tlen; up[0] = CLTPOVAL_DST; up[1] = (siso = isop->isop_faddr)->siso_tlen; up += 2; - bcopy(TSEL(siso), (caddr_t)up, siso->siso_tlen); + bcopy(TSEL(siso), (caddr_t) up, siso->siso_tlen); /* * Stuff checksum and output datagram. */ @@ -247,29 +280,30 @@ cltp_output(isop, m) iso_gen_csum(m, 2 + up - mtod(m, u_char *), len); } cltpstat.cltps_opackets++; - return (tpclnp_output(isop, m, len, !docsum)); + return (tpclnp_output(m, len, isop, !docsum)); bad: m_freem(m); return (error); } -u_long cltp_sendspace = 9216; /* really max datagram size */ -u_long cltp_recvspace = 40 * (1024 + sizeof(struct sockaddr_iso)); - /* 40 1K datagrams */ +u_long cltp_sendspace = 9216; /* really max datagram size */ +u_long cltp_recvspace = 40 * (1024 + sizeof(struct sockaddr_iso)); +/* 40 1K datagrams */ -/*ARGSUSED*/ +/* ARGSUSED */ +int cltp_usrreq(so, req, m, nam, control) - struct socket *so; - int req; - struct mbuf *m, *nam, *control; + struct socket *so; + int req; + struct mbuf *m, *nam, *control; { register struct isopcb *isop = sotoisopcb(so); - int s, error = 0; + int s = 0, error = 0; if (req == PRU_CONTROL) - return (iso_control(so, (long)m, (caddr_t)nam, - (struct ifnet *)control)); + return (iso_control(so, (long) m, (caddr_t) nam, + (struct ifnet *) control)); if ((isop == NULL && req != PRU_ATTACH) || (control && control->m_len)) { error = EINVAL; @@ -326,7 +360,7 @@ cltp_usrreq(so, req, m, nam, control) break; } iso_pcbdisconnect(isop); - so->so_state &= ~SS_ISCONNECTED; /* XXX */ + so->so_state &= ~SS_ISCONNECTED; /* XXX */ break; case PRU_SHUTDOWN: @@ -354,7 +388,7 @@ cltp_usrreq(so, req, m, nam, control) break; } } - error = cltp_output(isop, m); + error = cltp_output(m, isop); m = 0; if (nam) { iso_pcbdisconnect(isop); @@ -369,14 +403,14 @@ cltp_usrreq(so, req, m, nam, control) case PRU_SOCKADDR: if (isop->isop_laddr) - bcopy((caddr_t)isop->isop_laddr, mtod(m, caddr_t), - nam->m_len = isop->isop_laddr->siso_len); + bcopy((caddr_t) isop->isop_laddr, mtod(m, caddr_t), + nam->m_len = isop->isop_laddr->siso_len); break; case PRU_PEERADDR: if (isop->isop_faddr) - bcopy((caddr_t)isop->isop_faddr, mtod(m, caddr_t), - nam->m_len = isop->isop_faddr->siso_len); + bcopy((caddr_t) isop->isop_faddr, mtod(m, caddr_t), + nam->m_len = isop->isop_faddr->siso_len); break; case PRU_SENSE: @@ -390,7 +424,7 @@ cltp_usrreq(so, req, m, nam, control) case PRU_SLOWTIMO: case PRU_PROTORCV: case PRU_PROTOSEND: - error = EOPNOTSUPP; + error = EOPNOTSUPP; break; case PRU_RCVD: diff --git a/sys/netiso/cltp_var.h b/sys/netiso/cltp_var.h index 57a3d6fe743..d25098bf780 100644 --- a/sys/netiso/cltp_var.h +++ b/sys/netiso/cltp_var.h @@ -1,4 +1,5 @@ -/* $NetBSD: cltp_var.h,v 1.6 1995/03/26 20:35:15 jtc Exp $ */ +/* $OpenBSD: cltp_var.h,v 1.2 1996/03/04 10:35:08 mickey Exp $ */ +/* $NetBSD: cltp_var.h,v 1.7 1996/02/13 22:09:03 christos Exp $ */ /* * Copyright (c) 1989, 1993 @@ -41,16 +42,25 @@ #define CLTPOVAL_DST 0xc2 /* Destination TSAP -- required */ #define CLTPOVAL_CSM 0xc3 /* Checksum parameter -- optional */ -struct cltpstat { - int cltps_hdrops; - int cltps_badsum; - int cltps_badlen; - int cltps_noport; - int cltps_ipackets; - int cltps_opackets; +struct cltpstat { + int cltps_hdrops; + int cltps_badsum; + int cltps_badlen; + int cltps_noport; + int cltps_ipackets; + int cltps_opackets; }; #ifdef _KERNEL -struct isopcb cltb; -struct cltpstat cltpstat; +struct isopcb cltb; +struct cltpstat cltpstat; + +/* cltp_usrreq.c */ +void cltp_init __P((void)); +void cltp_input __P((struct mbuf *, ...)); +void cltp_notify __P((struct isopcb *)); +void cltp_ctlinput __P((int, struct sockaddr *, void *)); +int cltp_output __P((struct mbuf *, ...)); +int cltp_usrreq __P((struct socket *, int, struct mbuf *, struct mbuf *, + struct mbuf *)); #endif diff --git a/sys/netiso/cons.h b/sys/netiso/cons.h index 5c9c4bccf90..14d2d31cf14 100644 --- a/sys/netiso/cons.h +++ b/sys/netiso/cons.h @@ -1,4 +1,5 @@ -/* $NetBSD: cons.h,v 1.7 1995/03/29 22:09:44 briggs Exp $ */ +/* $OpenBSD: cons.h,v 1.2 1996/03/04 10:35:10 mickey Exp $ */ +/* $NetBSD: cons.h,v 1.8 1996/02/13 22:09:10 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -65,11 +66,11 @@ SOFTWARE. * interface between TP and CONS */ -#define CONSOPT_X25CRUD 0x01 /* set x.25 call request user data */ +#define CONSOPT_X25CRUD 0x01 /* set x.25 call request user data */ struct dte_addr { - u_char dtea_addr[7]; - u_char dtea_niblen; + u_char dtea_addr[7]; + u_char dtea_niblen; }; #ifdef _KERNEL @@ -84,8 +85,8 @@ struct dte_addr { #ifndef PRC_NCMDS #include <sys/protosw.h> -#endif /* PRC_NCMDS */ +#endif /* PRC_NCMDS */ -#define PRC_CONS_SEND_DONE 2 /* something unused in protosw.h */ +#define PRC_CONS_SEND_DONE 2 /* something unused in protosw.h */ -#endif /* _KERNEL */ +#endif /* _KERNEL */ diff --git a/sys/netiso/cons_pcb.h b/sys/netiso/cons_pcb.h index 7c04a31cf5f..3569a010e4c 100644 --- a/sys/netiso/cons_pcb.h +++ b/sys/netiso/cons_pcb.h @@ -1,4 +1,5 @@ -/* $NetBSD: cons_pcb.h,v 1.6 1995/03/26 20:35:18 jtc Exp $ */ +/* $OpenBSD: cons_pcb.h,v 1.2 1996/03/04 10:35:11 mickey Exp $ */ +/* $NetBSD: cons_pcb.h,v 1.7 1996/02/13 22:09:14 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -77,15 +78,15 @@ SOFTWARE. #define X25_PARTIAL_PKT_LEN_MAX (MLEN - sizeof(struct cons_pcb)) #ifndef ARGO_DEBUG -#define X25_TTL 600 /* 5 min */ -#else /* ARGO_DEBUG */ -#define X25_TTL 120 /* 1 min */ -#endif /* ARGO_DEBUG */ +#define X25_TTL 600 /* 5 min */ +#else /* ARGO_DEBUG */ +#define X25_TTL 120 /* 1 min */ +#endif /* ARGO_DEBUG */ struct cons_pcb { - struct isopcb _co_isopcb; + struct isopcb _co_isopcb; #define co_next _co_isopcb.isop_next -/* prev used for netstat only */ + /* prev used for netstat only */ #define co_prev _co_isopcb.isop_prev #define co_head _co_isopcb.isop_head #define co_laddr _co_isopcb.isop_laddr @@ -98,27 +99,27 @@ struct cons_pcb { #define co_negchanmask _co_isopcb.isop_negchanmask #define co_x25crud _co_isopcb.isop_x25crud #define co_x25crud_len _co_isopcb.isop_x25crud_len - u_short co_state; - u_char co_flags; - u_short co_ttl; /* time to live timer */ - u_short co_init_ttl; /* initial value of ttl */ - int co_channel; /* logical channel */ - struct ifnet * co_ifp; /* interface */ - struct protosw *co_proto; - - struct ifqueue co_pending; /* queue data to send when connection - completes*/ -#define MAX_DTE_LEN 0x7 /* 17 bcd digits */ - struct dte_addr co_peer_dte; - struct cons_pcb *co_myself; /* DEBUGGING AID */ + u_short co_state; + u_char co_flags; + u_short co_ttl; /* time to live timer */ + u_short co_init_ttl; /* initial value of ttl */ + int co_channel; /* logical channel */ + struct ifnet *co_ifp; /* interface */ + struct protosw *co_proto; + + struct ifqueue co_pending; /* queue data to send when connection + * completes */ +#define MAX_DTE_LEN 0x7 /* 17 bcd digits */ + struct dte_addr co_peer_dte; + struct cons_pcb *co_myself; /* DEBUGGING AID */ }; /* - * X.25 Packet types + * X.25 Packet types */ #define XPKT_DATA 1 #define XPKT_INTERRUPT 2 -#define XPKT_FLOWCONTROL 3 /* not delivered? */ +#define XPKT_FLOWCONTROL 3 /* not delivered? */ /* * pcb xtates @@ -137,57 +138,65 @@ struct cons_pcb { /* type */ -#define CONSF_OCRE 0x40 /* created on OUTPUT */ -#define CONSF_ICRE 0x20 /* created on INPUT */ -#define CONSF_unused 0x10 /* not used */ -#define CONSF_unused2 0x08 /* not used */ -#define CONSF_DGM 0x04 /* for dgm use only */ -#define CONSF_XTS 0x02 /* for cons-as-transport-service */ -#define CONSF_LOOPBACK 0x01 /* loopback was on when connection commenced */ +#define CONSF_OCRE 0x40 /* created on OUTPUT */ +#define CONSF_ICRE 0x20 /* created on INPUT */ +#define CONSF_unused 0x10 /* not used */ +#define CONSF_unused2 0x08 /* not used */ +#define CONSF_DGM 0x04 /* for dgm use only */ +#define CONSF_XTS 0x02 /* for cons-as-transport-service */ +#define CONSF_LOOPBACK 0x01 /* loopback was on when connection commenced */ #define X_NOCHANNEL 0x80 struct cons_stat { - u_int co_intr; /* input from eicon board */ - u_int co_restart; /* ecn_restart() request issued to board */ - u_int co_slowtimo; /* times slowtimo called */ - u_int co_timedout; /* connections closed by slowtimo */ - u_int co_ack; /* ECN_ACK indication came from eicon board */ - u_int co_receive; /* ECN_RECEIVE indication came from eicon board */ - u_int co_send; /* ECN_SEND request issued to board */ - u_int co_reset_in; /* ECN_RESET indication came from eicon board */ - u_int co_reset_out; /* ECN_RESET issued to the eicon board */ - u_int co_clear_in; /* ECN_CLEAR indication came from eicon board */ - u_int co_clear_out; /* ECN_CLEAR request issued to board */ - u_int co_refuse; /* ECN_REFUSE indication came from eicon board */ - u_int co_accept; /* ECN_ACCEPT indication came from eicon board */ - u_int co_connect; /* ECN_CONNECT indication came from eicon board */ - u_int co_call; /* ECN_CALL request issued to board */ - u_int co_Rdrops; /* bad pkt came from ll */ - u_int co_Xdrops; /* can't keep up */ - - u_int co_intrpt_pkts_in; /* interrupt packets in */ - u_int co_avg_qlen; - u_int co_avg_qdrop; - u_int co_active; - - u_int co_noresources; - u_int co_parse_facil_err; - u_int co_addr_proto_consist_err; - u_int co_no_copcb; -} cons_stat; - -u_char x25_error_stats[CONL_ERROR_MAX + 1]; - -struct ifqueue consintrq; + u_int co_intr;/* input from eicon board */ + u_int co_restart; /* ecn_restart() request issued to + * board */ + u_int co_slowtimo; /* times slowtimo called */ + u_int co_timedout; /* connections closed by slowtimo */ + u_int co_ack; /* ECN_ACK indication came from eicon board */ + u_int co_receive; /* ECN_RECEIVE indication came from + * eicon board */ + u_int co_send;/* ECN_SEND request issued to board */ + u_int co_reset_in; /* ECN_RESET indication came from + * eicon board */ + u_int co_reset_out; /* ECN_RESET issued to the eicon + * board */ + u_int co_clear_in; /* ECN_CLEAR indication came from + * eicon board */ + u_int co_clear_out; /* ECN_CLEAR request issued to board */ + u_int co_refuse; /* ECN_REFUSE indication came from + * eicon board */ + u_int co_accept; /* ECN_ACCEPT indication came from + * eicon board */ + u_int co_connect; /* ECN_CONNECT indication came from + * eicon board */ + u_int co_call;/* ECN_CALL request issued to board */ + u_int co_Rdrops; /* bad pkt came from ll */ + u_int co_Xdrops; /* can't keep up */ + + u_int co_intrpt_pkts_in; /* interrupt packets in */ + u_int co_avg_qlen; + u_int co_avg_qdrop; + u_int co_active; + + u_int co_noresources; + u_int co_parse_facil_err; + u_int co_addr_proto_consist_err; + u_int co_no_copcb; +} cons_stat; + +u_char x25_error_stats[CONL_ERROR_MAX + 1]; + +struct ifqueue consintrq; /* reasons for clear are in a data mbuf chained to a clear ecn_request */ -struct e_clear_data { - u_char ecd_cause; - u_char ecd_diagnostic; +struct e_clear_data { + u_char ecd_cause; + u_char ecd_diagnostic; }; #ifdef _KERNEL #define IncStat(XYZ) cons_stat.XYZ++ -#endif /* _KERNEL */ +#endif /* _KERNEL */ diff --git a/sys/netiso/eonvar.h b/sys/netiso/eonvar.h index faa1bad8b12..2d0aadd4745 100644 --- a/sys/netiso/eonvar.h +++ b/sys/netiso/eonvar.h @@ -1,4 +1,5 @@ -/* $NetBSD: eonvar.h,v 1.5 1994/06/29 06:39:30 cgd Exp $ */ +/* $OpenBSD: eonvar.h,v 1.2 1996/03/04 10:35:13 mickey Exp $ */ +/* $NetBSD: eonvar.h,v 1.6 1996/02/13 22:09:18 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -71,41 +72,42 @@ SOFTWARE. #define E_LINK 2 #define E_ES 3 #define E_IS 4 - -/* + +/* * this overlays a sockaddr_iso */ struct sockaddr_eon { - u_char seon_len; /* Length */ - u_char seon_family; /* AF_ISO */ - u_char seon_status; /* overlays session suffixlen */ + u_char seon_len; /* Length */ + u_char seon_family; /* AF_ISO */ + u_char seon_status; /* overlays session suffixlen */ #define EON_ESLINK_UP 0x1 #define EON_ESLINK_DOWN 0x2 #define EON_ISLINK_UP 0x10 #define EON_ISLINK_DOWN 0x20 -/* no change is neither up or down */ - u_char seon_pad1; /* 0, overlays tsfxlen */ - u_char seon_adrlen; - u_char seon_afi; /* 47 */ - u_char seon_idi[2]; /* 0006 */ - u_char seon_vers; /* 03 */ - u_char seon_glbnum[2]; /* see RFC 1069 */ - u_char seon_RDN[2]; /* see RFC 1070 */ - u_char seon_pad2[3]; /* see RFC 1070 */ - u_char seon_LAREA[2]; /* see RFC 1070 */ - u_char seon_pad3[2]; /* see RFC 1070 */ - /* right now ip addr is aligned -- be careful -- - * future revisions may have it u_char[4] - */ - u_int seon_ipaddr; /* a.b.c.d */ - u_char seon_protoid; /* NSEL */ + /* no change is neither up or down */ + u_char seon_pad1; /* 0, overlays tsfxlen */ + u_char seon_adrlen; + u_char seon_afi; /* 47 */ + u_char seon_idi[2]; /* 0006 */ + u_char seon_vers; /* 03 */ + u_char seon_glbnum[2]; /* see RFC 1069 */ + u_char seon_RDN[2]; /* see RFC 1070 */ + u_char seon_pad2[3]; /* see RFC 1070 */ + u_char seon_LAREA[2]; /* see RFC 1070 */ + u_char seon_pad3[2]; /* see RFC 1070 */ + /* + * right now ip addr is aligned -- be careful -- future revisions + * may have it u_char[4] + */ + u_int seon_ipaddr; /* a.b.c.d */ + u_char seon_protoid; /* NSEL */ }; #ifdef EON_TEMPLATE struct sockaddr_eon eon_template = { - sizeof (eon_template), AF_ISO, 0, 0, 0x14, + sizeof(eon_template), AF_ISO, 0, 0, 0x14, 0x47, 0x0, 0x6, 0x3, 0 }; #endif @@ -113,21 +115,21 @@ struct sockaddr_eon eon_template = { #define DOWNBITS ( EON_ESLINK_DOWN | EON_ISLINK_DOWN ) #define UPBITS ( EON_ESLINK_UP | EON_ISLINK_UP ) -#define SIOCSEONCORE _IOWR('i',10, struct iso_ifreq) /* EON core member */ -#define SIOCGEONCORE _IOWR('i',11, struct iso_ifreq) /* EON core member */ +#define SIOCSEONCORE _IOWR('i',10, struct iso_ifreq) /* EON core member */ +#define SIOCGEONCORE _IOWR('i',11, struct iso_ifreq) /* EON core member */ struct eon_hdr { - u_char eonh_vers; /* value 1 */ - u_char eonh_class; /* address multicast class, below */ + u_char eonh_vers; /* value 1 */ + u_char eonh_class; /* address multicast class, below */ #define EON_NORMAL_ADDR 0x0 #define EON_MULTICAST_ES 0x1 #define EON_MULTICAST_IS 0x2 #define EON_BROADCAST 0x3 - u_short eonh_csum; /* osi checksum (choke)*/ + u_short eonh_csum; /* osi checksum (choke) */ }; struct eon_iphdr { - struct ip ei_ip; - struct eon_hdr ei_eh; + struct ip ei_ip; + struct eon_hdr ei_eh; }; #define EONIPLEN (sizeof(struct eon_hdr) + sizeof(struct ip)) @@ -136,37 +138,49 @@ struct eon_iphdr { #define IFF_IS 0x800 struct eon_stat { - int es_in_multi_es; - int es_in_multi_is; - int es_in_broad; - int es_in_normal; - int es_out_multi_es; - int es_out_multi_is; - int es_out_broad; - int es_out_normal; - int es_ipout; - - int es_icmp[PRC_NCMDS]; + int es_in_multi_es; + int es_in_multi_is; + int es_in_broad; + int es_in_normal; + int es_out_multi_es; + int es_out_multi_is; + int es_out_broad; + int es_out_normal; + int es_ipout; + + int es_icmp[PRC_NCMDS]; /* errors */ - int es_badcsum; - int es_badhdr; -} eonstat; + int es_badcsum; + int es_badhdr; +} eonstat; #undef IncStat #define IncStat(xxx) eonstat.xxx++ typedef struct qhdr { - struct qhdr *link, *rlink; -} *queue_t; + struct qhdr *link, *rlink; +} *queue_t; struct eon_llinfo { - struct qhdr el_qhdr; /* keep all in a list */ - int el_flags; /* cache valid ? */ - int el_snpaoffset; /* IP address contained in dst nsap */ - struct rtentry *el_rt; /* back pointer to parent route */ - struct eon_iphdr el_ei; /* precomputed portion of hdr */ - struct route el_iproute; /* if direct route cache IP info */ - /* if gateway, cache secondary route */ + struct qhdr el_qhdr;/* keep all in a list */ + int el_flags; /* cache valid ? */ + int el_snpaoffset; /* IP address contained in dst nsap */ + struct rtentry *el_rt; /* back pointer to parent route */ + struct eon_iphdr el_ei; /* precomputed portion of hdr */ + struct route el_iproute; /* if direct route cache IP info */ + /* if gateway, cache secondary route */ }; #define el_iphdr el_ei.ei_ip #define el_eonhdr el_ei.ei_eh + +#ifdef _KERNEL +void eonprotoinit __P((void)); +void eonattach __P((void)); +int eonioctl __P((struct ifnet *, u_long, caddr_t)); +void eoniphdr __P((struct eon_iphdr *, caddr_t, struct route *, int, int)); +void eonrtrequest __P((int, struct rtentry *, struct sockaddr *)); +int eonoutput __P((struct ifnet *, struct mbuf *, struct sockaddr *, + struct rtentry *)); +void eoninput __P((struct mbuf *, ...)); +void *eonctlinput __P((int, struct sockaddr *, void *)); +#endif diff --git a/sys/netiso/esis.c b/sys/netiso/esis.c index e5c1479bef8..1db53269def 100644 --- a/sys/netiso/esis.c +++ b/sys/netiso/esis.c @@ -1,4 +1,5 @@ -/* $NetBSD: esis.c,v 1.11 1995/08/17 02:57:31 mycroft Exp $ */ +/* $OpenBSD: esis.c,v 1.2 1996/03/04 10:35:15 mickey Exp $ */ +/* $NetBSD: esis.c,v 1.12 1996/02/13 22:09:23 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -89,25 +90,24 @@ SOFTWARE. #include <netiso/esis.h> #include <netiso/argo_debug.h> +#include <machine/stdarg.h> /* * Global variables to esis implementation * * esis_holding_time - the holding time (sec) parameter for outgoing pdus * esis_config_time - the frequency (sec) that hellos are generated - * esis_esconfig_time - suggested es configuration time placed in the - * ish. + * esis_esconfig_time - suggested es configuration time placed in the ish. * */ LIST_HEAD(, rawcb) esis_pcb; -void esis_config(), snpac_age(); -int esis_sendspace = 2048; -int esis_recvspace = 2048; -short esis_holding_time = ESIS_HT; -short esis_config_time = ESIS_CONFIG; -short esis_esconfig_time = ESIS_CONFIG; -extern int iso_systype; -struct sockaddr_dl esis_dl = { sizeof(esis_dl), AF_LINK }; -extern char all_es_snpa[], all_is_snpa[]; +int esis_sendspace = 2048; +int esis_recvspace = 2048; +short esis_holding_time = ESIS_HT; +short esis_config_time = ESIS_CONFIG; +short esis_esconfig_time = ESIS_CONFIG; +extern int iso_systype; +struct sockaddr_dl esis_dl = {sizeof(esis_dl), AF_LINK}; +extern char all_es_snpa[], all_is_snpa[]; #define EXTEND_PACKET(m, mhdr, cp)\ if (((m)->m_next = m_getclr(M_DONTWAIT, MT_HEADER)) == NULL) {\ @@ -119,21 +119,16 @@ extern char all_es_snpa[], all_is_snpa[]; (cp) = mtod((m), caddr_t);\ } -void esis_input(), isis_input(); -#ifdef ISO_X25ESIS -void x25esis_input(); -#endif /* ISO_X25ESIS */ - /* * FUNCTION: esis_init * - * PURPOSE: Initialize the kernel portion of esis protocol + * PURPOSE: Initialize the kernel portion of esis protocol * - * RETURNS: nothing + * RETURNS: nothing * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ void esis_init() @@ -142,36 +137,37 @@ esis_init() LIST_INIT(&esis_pcb); - timeout(snpac_age, (caddr_t)0, hz); - timeout(esis_config, (caddr_t)0, hz); + timeout(snpac_age, (caddr_t) 0, hz); + timeout(esis_config, (caddr_t) 0, hz); clnl_protox[ISO9542_ESIS].clnl_input = esis_input; clnl_protox[ISO10589_ISIS].clnl_input = isis_input; #ifdef ISO_X25ESIS clnl_protox[ISO9542X25_ESIS].clnl_input = x25esis_input; -#endif /* ISO_X25ESIS */ +#endif /* ISO_X25ESIS */ } /* * FUNCTION: esis_usrreq * - * PURPOSE: Handle user level esis requests + * PURPOSE: Handle user level esis requests * - * RETURNS: 0 or appropriate errno + * RETURNS: 0 or appropriate errno * - * SIDE EFFECTS: + * SIDE EFFECTS: * */ -/*ARGSUSED*/ +/* ARGSUSED */ +int esis_usrreq(so, req, m, nam, control) -struct socket *so; /* socket: used only to get to this code */ -int req; /* request */ -struct mbuf *m; /* data for request */ -struct mbuf *nam; /* optional name */ -struct mbuf *control; /* optional control */ + struct socket *so; /* socket: used only to get to this code */ + int req; /* request */ + struct mbuf *m; /* data for request */ + struct mbuf *nam; /* optional name */ + struct mbuf *control;/* optional control */ { - struct rawcb *rp = sotorawcb(so); - int error = 0; + struct rawcb *rp = sotorawcb(so); + int error = 0; if ((so->so_state & SS_PRIV) == 0) { error = EACCES; @@ -181,7 +177,6 @@ struct mbuf *control; /* optional control */ error = EINVAL; goto release; } - switch (req) { case PRU_ATTACH: if (rp != NULL) { @@ -189,8 +184,8 @@ struct mbuf *control; /* optional control */ break; } MALLOC(rp, struct rawcb *, sizeof(*rp), M_PCB, M_WAITOK); - if (so->so_pcb = rp) { - bzero((caddr_t)so->so_pcb, sizeof(*rp)); + if ((so->so_pcb = rp) != NULL) { + bzero(so->so_pcb, sizeof(*rp)); LIST_INSERT_HEAD(&esis_pcb, rp, rcb_list); rp->rcb_socket = so; error = soreserve(so, esis_sendspace, esis_recvspace); @@ -204,7 +199,7 @@ struct mbuf *control; /* optional control */ break; } /* error checking here */ - error = isis_output(mtod(nam,struct sockaddr_dl *), m); + error = isis_output(m, mtod(nam, struct sockaddr_dl *)); m = NULL; break; @@ -237,30 +232,40 @@ release: /* * FUNCTION: esis_input * - * PURPOSE: Process an incoming esis packet + * PURPOSE: Process an incoming esis packet * - * RETURNS: nothing + * RETURNS: nothing * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ void -esis_input(m0, shp) -struct mbuf *m0; /* ptr to first mbuf of pkt */ -struct snpa_hdr *shp; /* subnetwork header */ +#if __STDC__ +esis_input(struct mbuf *m0, ...) +#else +esis_input(m0, va_alist) + struct mbuf *m0; + va_dcl +#endif { - register struct esis_fixed *pdu = mtod(m0, struct esis_fixed *); - register int type; + struct snpa_hdr *shp; /* subnetwork header */ + register struct esis_fixed *pdu = mtod(m0, struct esis_fixed *); + register int type; + va_list ap; + + va_start(ap, m0); + shp = va_arg(ap, struct snpa_hdr *); + va_end(ap); /* * check checksum if necessary */ - if (ESIS_CKSUM_REQUIRED(pdu) && iso_check_csum(m0, (int)pdu->esis_hdr_len)) { + if (ESIS_CKSUM_REQUIRED(pdu) && + iso_check_csum(m0, (int) pdu->esis_hdr_len)) { esis_stat.es_badcsum++; goto bad; } - /* check version */ if (pdu->esis_vers != ESIS_VERSION) { esis_stat.es_badvers++; @@ -268,20 +273,20 @@ struct snpa_hdr *shp; /* subnetwork header */ } type = pdu->esis_type & 0x1f; switch (type) { - case ESIS_ESH: - esis_eshinput(m0, shp); - break; + case ESIS_ESH: + esis_eshinput(m0, shp); + break; - case ESIS_ISH: - esis_ishinput(m0, shp); - break; + case ESIS_ISH: + esis_ishinput(m0, shp); + break; - case ESIS_RD: - esis_rdinput(m0, shp); - break; + case ESIS_RD: + esis_rdinput(m0, shp); + break; - default: - esis_stat.es_badtype++; + default: + esis_stat.es_badtype++; } bad: @@ -294,29 +299,30 @@ bad: /* * FUNCTION: esis_rdoutput * - * PURPOSE: Transmit a redirect pdu + * PURPOSE: Transmit a redirect pdu * - * RETURNS: nothing + * RETURNS: nothing * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: Assumes there is enough space for fixed part of header, - * DA, BSNPA and NET in first mbuf. + * NOTES: Assumes there is enough space for fixed part of header, + * DA, BSNPA and NET in first mbuf. */ +void esis_rdoutput(inbound_shp, inbound_m, inbound_oidx, rd_dstnsap, rt) -struct snpa_hdr *inbound_shp; /* snpa hdr from incoming packet */ -struct mbuf *inbound_m; /* incoming pkt itself */ -struct clnp_optidx *inbound_oidx; /* clnp options assoc with incoming pkt */ -struct iso_addr *rd_dstnsap; /* ultimate destination of pkt */ -struct rtentry *rt; /* snpa cache info regarding next hop of - pkt */ + struct snpa_hdr *inbound_shp; /* snpa hdr from incoming packet */ + struct mbuf *inbound_m; /* incoming pkt itself */ + struct clnp_optidx *inbound_oidx; /* clnp options assoc with + * incoming pkt */ + struct iso_addr *rd_dstnsap; /* ultimate destination of pkt */ + struct rtentry *rt; /* snpa cache info regarding next hop of pkt */ { - struct mbuf *m, *m0; - caddr_t cp; - struct esis_fixed *pdu; - int len, total_len = 0; - struct sockaddr_iso siso; - struct ifnet *ifp = inbound_shp->snh_ifp; + struct mbuf *m, *m0; + caddr_t cp; + struct esis_fixed *pdu; + int len; + struct sockaddr_iso siso; + struct ifnet *ifp = inbound_shp->snh_ifp; struct sockaddr_dl *sdl; struct iso_addr *rd_gwnsap; @@ -325,23 +331,29 @@ struct rtentry *rt; /* snpa cache info regarding next hop of rt = rtalloc1(rt->rt_gateway, 0); } else rd_gwnsap = &satosiso(rt_key(rt))->siso_addr; - if (rt == 0 || (sdl = (struct sockaddr_dl *)rt->rt_gateway) == 0 || - sdl->sdl_family != AF_LINK) { - /* maybe we should have a function that you - could put in the iso_ifaddr structure - which could translate iso_addrs into snpa's - where there is a known mapping for that address type */ + if (rt == 0 || (sdl = (struct sockaddr_dl *) rt->rt_gateway) == 0 || + sdl->sdl_family != AF_LINK) { + /* + * maybe we should have a function that you could put in the + * iso_ifaddr structure which could translate iso_addrs into + * snpa's where there is a known mapping for that address + * type + */ esis_stat.es_badtype++; return; } esis_stat.es_rdsent++; - IFDEBUG(D_ESISOUTPUT) - printf("esis_rdoutput: ifp x%x (%s%d), ht %d, m x%x, oidx x%x\n", - ifp, ifp->if_name, ifp->if_unit, esis_holding_time, inbound_m, - inbound_oidx); +#ifdef ARGO_DEBUG + if (argo_debug[D_ESISOUTPUT]) { + printf( + "esis_rdoutput: ifp x%x (%s%d), ht %d, m x%x, oidx x%x\n", + (unsigned int) ifp, ifp->if_name, ifp->if_unit, + esis_holding_time, + (unsigned int) inbound_m, (unsigned int) inbound_oidx); printf("\tdestination: %s\n", clnp_iso_addrp(rd_dstnsap)); printf("\tredirected toward:%s\n", clnp_iso_addrp(rd_gwnsap)); - ENDDEBUG + } +#endif if ((m0 = m = m_gethdr(M_DONTWAIT, MT_HEADER)) == NULL) { esis_stat.es_nomem++; @@ -350,7 +362,8 @@ struct rtentry *rt; /* snpa cache info regarding next hop of bzero(mtod(m, caddr_t), MHLEN); pdu = mtod(m, struct esis_fixed *); - cp = (caddr_t)(pdu + 1); /*pointer arith.; 1st byte after header */ + cp = (caddr_t) (pdu + 1); /* pointer arith.; 1st byte after + * header */ len = sizeof(struct esis_fixed); /* @@ -370,19 +383,21 @@ struct rtentry *rt; /* snpa cache info regarding next hop of cp += sdl->sdl_alen; len += (sdl->sdl_alen + 1); - /* - * If the next hop is not the destination, then it ought to be - * an IS and it should be inserted next. Else, set the - * NETL to 0 + /* + * If the next hop is not the destination, then it ought to be an IS + * and it should be inserted next. Else, set the NETL to 0 */ /* PHASE2 use mask from ifp of outgoing interface */ if (!iso_addrmatch1(rd_dstnsap, rd_gwnsap)) { - /* this should not happen: +#if 0 + /* this should not happen: */ if ((nhop_sc->sc_flags & SNPA_IS) == 0) { - printf("esis_rdoutput: next hop is not dst and not an IS\n"); + printf( + "esis_rdoutput: next hop is not dst and not an IS\n"); m_freem(m0); return; - } */ + } +#endif (void) esis_insert_addr(&cp, &len, rd_gwnsap, m, 0); } else { *cp++ = 0; /* NETL */ @@ -391,21 +406,22 @@ struct rtentry *rt; /* snpa cache info regarding next hop of m->m_len = len; /* - * PHASE2 - * If redirect is to an IS, add an address mask. The mask to be - * used should be the mask present in the routing entry used to - * forward the original data packet. + * PHASE2 + * If redirect is to an IS, add an address mask. The mask to be + * used should be the mask present in the routing entry used to + * forward the original data packet. */ - + /* - * Copy Qos, priority, or security options present in original npdu + * Copy Qos, priority, or security options present in original npdu */ if (inbound_oidx) { /* THIS CODE IS CURRENTLY (mostly) UNTESTED */ - int optlen = 0; + int optlen = 0; if (inbound_oidx->cni_qos_formatp) optlen += (inbound_oidx->cni_qos_len + 2); - if (inbound_oidx->cni_priorp) /* priority option is 1 byte long */ + if (inbound_oidx->cni_priorp) /* priority option is 1 byte + * long */ optlen += 3; if (inbound_oidx->cni_securep) optlen += (inbound_oidx->cni_secure_len + 2); @@ -415,65 +431,67 @@ struct rtentry *rt; /* snpa cache info regarding next hop of /* assumes MLEN > optlen */ } /* assume MLEN-len > optlen */ - /* - * When copying options, copy from ptr - 2 in order to grab - * the option code and length + /* + * When copying options, copy from ptr - 2 in order to grab + * the option code and length */ if (inbound_oidx->cni_qos_formatp) { - bcopy(mtod(inbound_m, caddr_t) + inbound_oidx->cni_qos_formatp - 2, - cp, (unsigned)(inbound_oidx->cni_qos_len + 2)); + bcopy(mtod(inbound_m, caddr_t) + + inbound_oidx->cni_qos_formatp - 2, + cp, (unsigned) (inbound_oidx->cni_qos_len + 2)); cp += inbound_oidx->cni_qos_len + 2; } if (inbound_oidx->cni_priorp) { - bcopy(mtod(inbound_m, caddr_t) + inbound_oidx->cni_priorp - 2, - cp, 3); + bcopy(mtod(inbound_m, caddr_t) + + inbound_oidx->cni_priorp - 2, cp, 3); cp += 3; } if (inbound_oidx->cni_securep) { - bcopy(mtod(inbound_m, caddr_t) + inbound_oidx->cni_securep - 2, cp, - (unsigned)(inbound_oidx->cni_secure_len + 2)); + bcopy(mtod(inbound_m, caddr_t) + + inbound_oidx->cni_securep - 2, cp, + (unsigned) (inbound_oidx->cni_secure_len + 2)); cp += inbound_oidx->cni_secure_len + 2; } m->m_len += optlen; len += optlen; } - pdu->esis_hdr_len = m0->m_pkthdr.len = len; - iso_gen_csum(m0, ESIS_CKSUM_OFF, (int)pdu->esis_hdr_len); + iso_gen_csum(m0, ESIS_CKSUM_OFF, (int) pdu->esis_hdr_len); - bzero((caddr_t)&siso, sizeof(siso)); + bzero((caddr_t) & siso, sizeof(siso)); siso.siso_family = AF_ISO; siso.siso_data[0] = AFI_SNA; siso.siso_nlen = 6 + 1; /* should be taken from snpa_hdr */ - /* +1 is for AFI */ + /* +1 is for AFI */ bcopy(inbound_shp->snh_shost, siso.siso_data + 1, 6); - (ifp->if_output)(ifp, m0, sisotosa(&siso), 0); + (ifp->if_output) (ifp, m0, sisotosa(&siso), 0); } /* * FUNCTION: esis_insert_addr * - * PURPOSE: Insert an iso_addr into a buffer + * PURPOSE: Insert an iso_addr into a buffer * - * RETURNS: true if buffer was big enough, else false + * RETURNS: true if buffer was big enough, else false * * SIDE EFFECTS: Increment buf & len according to size of iso_addr * - * NOTES: Plus 1 here is for length byte + * NOTES: Plus 1 here is for length byte */ +int esis_insert_addr(buf, len, isoa, m, nsellen) -register caddr_t *buf; /* ptr to buffer to put address into */ -int *len; /* ptr to length of buffer so far */ -register struct iso_addr *isoa; /* ptr to address */ -register struct mbuf *m; /* determine if there remains space */ -int nsellen; + register caddr_t *buf; /* ptr to buffer to put address into */ + int *len; /* ptr to length of buffer so far */ + register struct iso_addr *isoa; /* ptr to address */ + register struct mbuf *m;/* determine if there remains space */ + int nsellen; { - register int newlen, result = 0; + register int newlen, result = 0; isoa->isoa_len -= nsellen; newlen = isoa->isoa_len + 1; - if (newlen <= M_TRAILINGSPACE(m)) { - bcopy((caddr_t)isoa, *buf, newlen); + if (newlen <= M_TRAILINGSPACE(m)) { + bcopy((caddr_t) isoa, *buf, newlen); *len += newlen; *buf += newlen; m->m_len += newlen; @@ -487,31 +505,31 @@ int nsellen; if (b > buflim) {esis_stat.es_toosmall++; goto bad;}} #define ESIS_NEXT_OPTION(b) { b += (2 + b[1]); \ if (b > buflim) {esis_stat.es_toosmall++; goto bad;}} -int ESHonly = 0; -/* - +int ESHonly = 0; + /* * FUNCTION: esis_eshinput * - * PURPOSE: Process an incoming ESH pdu + * PURPOSE: Process an incoming ESH pdu * - * RETURNS: nothing + * RETURNS: nothing * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ +void esis_eshinput(m, shp) -struct mbuf *m; /* esh pdu */ -struct snpa_hdr *shp; /* subnetwork header */ + struct mbuf *m; /* esh pdu */ + struct snpa_hdr *shp; /* subnetwork header */ { - struct esis_fixed *pdu = mtod(m, struct esis_fixed *); - u_short ht; /* holding time */ - struct iso_addr *nsap; - int naddr; - u_char *buf = (u_char *)(pdu + 1); - u_char *buflim = pdu->esis_hdr_len + (u_char *)pdu; - int new_entry = 0; + struct esis_fixed *pdu = mtod(m, struct esis_fixed *); + u_short ht; /* holding time */ + struct iso_addr *nsap = NULL; + int naddr; + u_char *buf = (u_char *) (pdu + 1); + u_char *buflim = pdu->esis_hdr_len + (u_char *) pdu; + int new_entry = 0; esis_stat.es_eshrcvd++; @@ -523,54 +541,70 @@ struct snpa_hdr *shp; /* subnetwork header */ if (naddr == 1) { ESIS_EXTRACT_ADDR(nsap, buf); new_entry = snpac_add(shp->snh_ifp, - nsap, shp->snh_shost, SNPA_ES, ht, 0); + nsap, shp->snh_shost, SNPA_ES, ht, 0); } else { - int nsellength = 0, nlen = 0; - { - /* See if we want to compress out multiple nsaps differing - only by nsel */ - register struct ifaddr *ifa; - for (ifa = shp->snh_ifp->if_addrlist.tqh_first; ifa != 0; - ifa = ifa->ifa_list.tqe_next) - if (ifa->ifa_addr->sa_family == AF_ISO) { - nsellength = ((struct iso_ifaddr *)ifa)->ia_addr.siso_tlen; - break; + int nsellength = 0, nlen = 0; + struct ifaddr *ifa; + /* + * See if we want to compress out multiple nsaps + * differing only by nsel + */ + for (ifa = shp->snh_ifp->if_addrlist.tqh_first; ifa != 0; + ifa = ifa->ifa_list.tqe_next) + if (ifa->ifa_addr->sa_family == AF_ISO) { + nsellength = + ((struct iso_ifaddr *) ifa)->ia_addr.siso_tlen; + break; } +#ifdef ARGO_DEBUG + if (argo_debug[D_ESISINPUT]) { + printf( + "esis_eshinput: esh: ht %d, naddr %d nsellength %d\n", + ht, naddr, nsellength); } - IFDEBUG(D_ESISINPUT) - printf("esis_eshinput: esh: ht %d, naddr %d nsellength %d\n", - ht, naddr, nsellength); - ENDDEBUG +#endif while (naddr-- > 0) { - struct iso_addr *nsap2; u_char *buf2; + struct iso_addr *nsap2; + u_char *buf2; ESIS_EXTRACT_ADDR(nsap, buf); - /* see if there is at least one more nsap in ESH differing - only by nsel */ - if (nsellength != 0) for (buf2 = buf; buf2 < buflim;) { - ESIS_EXTRACT_ADDR(nsap2, buf2); - IFDEBUG(D_ESISINPUT) - printf("esis_eshinput: comparing %s ", - clnp_iso_addrp(nsap)); - printf("and %s\n", clnp_iso_addrp(nsap2)); - ENDDEBUG - if (Bcmp(nsap->isoa_genaddr, nsap2->isoa_genaddr, - nsap->isoa_len - nsellength) == 0) { - nlen = nsellength; - break; + /* + * see if there is at least one more nsap in ESH + * differing only by nsel + */ + if (nsellength != 0) + for (buf2 = buf; buf2 < buflim;) { + ESIS_EXTRACT_ADDR(nsap2, buf2); +#ifdef ARGO_DEBUG + if (argo_debug[D_ESISINPUT]) { + printf( + "esis_eshinput: comparing %s ", + clnp_iso_addrp(nsap)); + printf("and %s\n", + clnp_iso_addrp(nsap2)); + } +#endif + if (Bcmp(nsap->isoa_genaddr, + nsap2->isoa_genaddr, + nsap->isoa_len - nsellength) + == 0) { + nlen = nsellength; + break; + } } - } new_entry |= snpac_add(shp->snh_ifp, - nsap, shp->snh_shost, SNPA_ES, ht, nlen); + nsap, shp->snh_shost, SNPA_ES, ht, nlen); nlen = 0; } } - IFDEBUG(D_ESISINPUT) - printf("esis_eshinput: nsap %s is %s\n", - clnp_iso_addrp(nsap), new_entry ? "new" : "old"); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_ESISINPUT]) { + printf("esis_eshinput: nsap %s is %s\n", + clnp_iso_addrp(nsap), new_entry ? "new" : "old"); + } +#endif if (new_entry && (iso_systype & SNPA_IS)) esis_shoutput(shp->snh_ifp, ESIS_ISH, esis_holding_time, - shp->snh_shost, 6, (struct iso_addr *)0); + shp->snh_shost, 6, (struct iso_addr *) 0); bad: return; } @@ -578,31 +612,34 @@ bad: /* * FUNCTION: esis_ishinput * - * PURPOSE: process an incoming ISH pdu + * PURPOSE: process an incoming ISH pdu * - * RETURNS: + * RETURNS: * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ +void esis_ishinput(m, shp) -struct mbuf *m; /* esh pdu */ -struct snpa_hdr *shp; /* subnetwork header */ + struct mbuf *m; /* esh pdu */ + struct snpa_hdr *shp; /* subnetwork header */ { - struct esis_fixed *pdu = mtod(m, struct esis_fixed *); - u_short ht, newct; /* holding time */ - struct iso_addr *nsap; /* Network Entity Title */ - register u_char *buf = (u_char *) (pdu + 1); - register u_char *buflim = pdu->esis_hdr_len + (u_char *)pdu; - int new_entry; + struct esis_fixed *pdu = mtod(m, struct esis_fixed *); + u_short ht, newct; /* holding time */ + struct iso_addr *nsap; /* Network Entity Title */ + register u_char *buf = (u_char *) (pdu + 1); + register u_char *buflim = pdu->esis_hdr_len + (u_char *) pdu; + int new_entry; esis_stat.es_ishrcvd++; CTOH(pdu->esis_ht_msb, pdu->esis_ht_lsb, ht); - IFDEBUG(D_ESISINPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_ESISINPUT]) { printf("esis_ishinput: ish: ht %d\n", ht); - ENDDEBUG + } +#endif if (ESHonly) goto bad; @@ -616,28 +653,31 @@ struct snpa_hdr *shp; /* subnetwork header */ if (buf[1] != 2) goto bad; CTOH(buf[2], buf[3], newct); - if (esis_config_time != newct) { - untimeout(esis_config,0); + if ((u_short) esis_config_time != newct) { + untimeout(esis_config, 0); esis_config_time = newct; - esis_config(); + esis_config(NULL); } break; - + default: printf("Unknown ISH option: %x\n", *buf); } ESIS_NEXT_OPTION(buf); } - new_entry = snpac_add(shp->snh_ifp, nsap, shp->snh_shost, SNPA_IS, ht, 0); - IFDEBUG(D_ESISINPUT) - printf("esis_ishinput: nsap %s is %s\n", - clnp_iso_addrp(nsap), new_entry ? "new" : "old"); - ENDDEBUG + new_entry = snpac_add(shp->snh_ifp, nsap, shp->snh_shost, SNPA_IS, + ht, 0); +#ifdef ARGO_DEBUG + if (argo_debug[D_ESISINPUT]) { + printf("esis_ishinput: nsap %s is %s\n", + clnp_iso_addrp(nsap), new_entry ? "new" : "old"); + } +#endif if (new_entry) - esis_shoutput(shp->snh_ifp, - iso_systype & SNPA_ES ? ESIS_ESH : ESIS_ISH, - esis_holding_time, shp->snh_shost, 6, (struct iso_addr *)0); + esis_shoutput(shp->snh_ifp, + iso_systype & SNPA_ES ? ESIS_ESH : ESIS_ISH, + esis_holding_time, shp->snh_shost, 6, (struct iso_addr *) 0); bad: return; } @@ -645,24 +685,25 @@ bad: /* * FUNCTION: esis_rdinput * - * PURPOSE: Process an incoming RD pdu + * PURPOSE: Process an incoming RD pdu * - * RETURNS: + * RETURNS: * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ +void esis_rdinput(m0, shp) -struct mbuf *m0; /* esh pdu */ -struct snpa_hdr *shp; /* subnetwork header */ + struct mbuf *m0; /* esh pdu */ + struct snpa_hdr *shp; /* subnetwork header */ { - struct esis_fixed *pdu = mtod(m0, struct esis_fixed *); - u_short ht; /* holding time */ - struct iso_addr *da, *net = 0, *netmask = 0, *snpamask = 0; + struct esis_fixed *pdu = mtod(m0, struct esis_fixed *); + u_short ht; /* holding time */ + struct iso_addr *da, *net = 0, *netmask = 0, *snpamask = 0; register struct iso_addr *bsnpa; - register u_char *buf = (u_char *)(pdu + 1); - register u_char *buflim = pdu->esis_hdr_len + (u_char *)pdu; + register u_char *buf = (u_char *) (pdu + 1); + register u_char *buflim = pdu->esis_hdr_len + (u_char *) pdu; esis_stat.es_rdrcvd++; @@ -685,24 +726,23 @@ struct snpa_hdr *shp; /* subnetwork header */ /* Extract NET if present */ if (buf < buflim) { if (*buf == 0) - buf++; /* no NET present, skip NETL anyway */ + buf++; /* no NET present, skip NETL anyway */ else ESIS_EXTRACT_ADDR(net, buf); } - /* process options */ while (buf < buflim) { switch (*buf) { case ESISOVAL_SNPAMASK: - if (snpamask) /* duplicate */ + if (snpamask) /* duplicate */ return; - snpamask = (struct iso_addr *)(buf + 1); + snpamask = (struct iso_addr *) (buf + 1); break; case ESISOVAL_NETMASK: - if (netmask) /* duplicate */ + if (netmask) /* duplicate */ return; - netmask = (struct iso_addr *)(buf + 1); + netmask = (struct iso_addr *) (buf + 1); break; default: @@ -711,76 +751,80 @@ struct snpa_hdr *shp; /* subnetwork header */ ESIS_NEXT_OPTION(buf); } - IFDEBUG(D_ESISINPUT) - printf("esis_rdinput: rd: ht %d, da %s\n", ht, clnp_iso_addrp(da)); +#ifdef ARGO_DEBUG + if (argo_debug[D_ESISINPUT]) { + printf("esis_rdinput: rd: ht %d, da %s\n", ht, + clnp_iso_addrp(da)); if (net) printf("\t: net %s\n", clnp_iso_addrp(net)); - ENDDEBUG + } +#endif /* - * If netl is zero, then redirect is to an ES. We need to add an entry - * to the snpa cache for (destination, better snpa). - * If netl is not zero, then the redirect is to an IS. In this - * case, add an snpa cache entry for (net, better snpa). + * If netl is zero, then redirect is to an ES. We need to add an entry + * to the snpa cache for (destination, better snpa). + * If netl is not zero, then the redirect is to an IS. In this + * case, add an snpa cache entry for (net, better snpa). * - * If the redirect is to an IS, add a route entry towards that - * IS. + * If the redirect is to an IS, add a route entry towards that + * IS. */ if (net == 0 || net->isoa_len == 0 || snpamask) { /* redirect to an ES */ snpac_add(shp->snh_ifp, da, - bsnpa->isoa_genaddr, SNPA_ES, ht, 0); + bsnpa->isoa_genaddr, SNPA_ES, ht, 0); } else { snpac_add(shp->snh_ifp, net, - bsnpa->isoa_genaddr, SNPA_IS, ht, 0); + bsnpa->isoa_genaddr, SNPA_IS, ht, 0); snpac_addrt(shp->snh_ifp, da, net, netmask); } -bad: ; /* Needed by ESIS_NEXT_OPTION */ +bad: ; /* Needed by ESIS_NEXT_OPTION */ } /* * FUNCTION: esis_config * - * PURPOSE: Report configuration + * PURPOSE: Report configuration * - * RETURNS: + * RETURNS: * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: Called every esis_config_time seconds + * NOTES: Called every esis_config_time seconds */ +/*ARGSUSED*/ void -esis_config() +esis_config(v) + void *v; { - register struct ifnet *ifp; + register struct ifnet *ifp; - timeout(esis_config, (caddr_t)0, hz * esis_config_time); + timeout(esis_config, (caddr_t) 0, hz * esis_config_time); - /* - * Report configuration for each interface that - * - is UP - * - has BROADCAST capability - * - has an ISO address + /* + * Report configuration for each interface that - is UP - has + * BROADCAST capability - has an ISO address */ - /* Todo: a better way would be to construct the esh or ish - * once and copy it out for all devices, possibly calling - * a method in the iso_ifaddr structure to encapsulate and - * transmit it. This could work to advantage for non-broadcast media + /* + * Todo: a better way would be to construct the esh or ish once and + * copy it out for all devices, possibly calling a method in the + * iso_ifaddr structure to encapsulate and transmit it. This could + * work to advantage for non-broadcast media */ - + for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next) { if ((ifp->if_flags & IFF_UP) && (ifp->if_flags & IFF_BROADCAST)) { /* search for an ISO address family */ - struct ifaddr *ifa; + struct ifaddr *ifa; for (ifa = ifp->if_addrlist.tqh_first; ifa != 0; - ifa = ifa->ifa_list.tqe_next) { + ifa = ifa->ifa_list.tqe_next) { if (ifa->ifa_addr->sa_family == AF_ISO) { - esis_shoutput(ifp, - iso_systype & SNPA_ES ? ESIS_ESH : ESIS_ISH, - esis_holding_time, - (caddr_t)(iso_systype & SNPA_ES ? all_is_snpa : - all_es_snpa), 6, (struct iso_addr *)0); + esis_shoutput(ifp, + iso_systype & SNPA_ES ? ESIS_ESH : ESIS_ISH, + esis_holding_time, + (caddr_t) (iso_systype & SNPA_ES ? all_is_snpa : + all_es_snpa), 6, (struct iso_addr *) 0); break; } } @@ -791,48 +835,53 @@ esis_config() /* * FUNCTION: esis_shoutput * - * PURPOSE: Transmit an esh or ish pdu + * PURPOSE: Transmit an esh or ish pdu * - * RETURNS: nothing + * RETURNS: nothing * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ +void esis_shoutput(ifp, type, ht, sn_addr, sn_len, isoa) -struct ifnet *ifp; -int type; -short ht; -caddr_t sn_addr; -int sn_len; -struct iso_addr *isoa; + struct ifnet *ifp; + int type; + short ht; + caddr_t sn_addr; + int sn_len; + struct iso_addr *isoa; { - struct mbuf *m, *m0; - caddr_t cp, naddrp; - int naddr = 0; - struct esis_fixed *pdu; - struct iso_ifaddr *ia; - int len; - struct sockaddr_iso siso; + struct mbuf *m, *m0; + caddr_t cp, naddrp; + int naddr = 0; + struct esis_fixed *pdu; + struct iso_ifaddr *ia; + int len; + struct sockaddr_iso siso; if (type == ESIS_ESH) esis_stat.es_eshsent++; - else if (type == ESIS_ISH) + else if (type == ESIS_ISH) esis_stat.es_ishsent++; else { printf("esis_shoutput: bad pdu type\n"); return; } - IFDEBUG(D_ESISOUTPUT) - int i; +#ifdef ARGO_DEBUG + if (argo_debug[D_ESISOUTPUT]) { + int i; printf("esis_shoutput: ifp x%x (%s%d), %s, ht %d, to: [%d] ", - ifp, ifp->if_name, ifp->if_unit, type == ESIS_ESH ? "esh" : "ish", - ht, sn_len); - for (i=0; i<sn_len; i++) - printf("%x%c", *(sn_addr+i), i < (sn_len-1) ? ':' : ' '); + (unsigned int) ifp, ifp->if_name, ifp->if_unit, + type == ESIS_ESH ? "esh" : "ish", + ht, sn_len); + for (i = 0; i < sn_len; i++) + printf("%x%c", *(sn_addr + i), + i < (sn_len - 1) ? ':' : ' '); printf("\n"); - ENDDEBUG + } +#endif if ((m0 = m = m_gethdr(M_DONTWAIT, MT_HEADER)) == NULL) { esis_stat.es_nomem++; @@ -841,7 +890,7 @@ struct iso_addr *isoa; bzero(mtod(m, caddr_t), MHLEN); pdu = mtod(m, struct esis_fixed *); - naddrp = cp = (caddr_t)(pdu + 1); + naddrp = cp = (caddr_t) (pdu + 1); len = sizeof(struct esis_fixed); /* @@ -856,7 +905,6 @@ struct iso_addr *isoa; cp++; len++; } - m->m_len = len; if (isoa) { /* @@ -865,36 +913,44 @@ struct iso_addr *isoa; * It is possible that we did not specifically advertise this * NSAP, even though it is ours, so we will respond * directly to the sender that we are here. If we do have - * multiple NSEL's we'll tack them on so he can compress them out. + * multiple NSEL's we'll tack them on so he can compress + * them out. */ (void) esis_insert_addr(&cp, &len, isoa, m, 0); naddr = 1; } for (ia = iso_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next) { - int nsellen = (type == ESIS_ISH ? ia->ia_addr.siso_tlen : 0); + int nsellen = (type == ESIS_ISH ? ia->ia_addr.siso_tlen : 0); int n = ia->ia_addr.siso_nlen; register struct iso_ifaddr *ia2; if (type == ESIS_ISH && naddr > 0) break; - for (ia2 = iso_ifaddr.tqh_first; ia2 != ia; ia2 = ia2->ia_list.tqe_next) - if (Bcmp(ia->ia_addr.siso_data, ia2->ia_addr.siso_data, n) == 0) + for (ia2 = iso_ifaddr.tqh_first; ia2 != ia; + ia2 = ia2->ia_list.tqe_next) + if (Bcmp(ia->ia_addr.siso_data, + ia2->ia_addr.siso_data, n) == 0) break; if (ia2 != ia) - continue; /* Means we have previously copied this nsap */ - if (isoa && Bcmp(ia->ia_addr.siso_data, isoa->isoa_genaddr, n) == 0) { + continue; /* Means we have previously copied + * this nsap */ + if (isoa && Bcmp(ia->ia_addr.siso_data, + isoa->isoa_genaddr, n) == 0) { isoa = 0; continue; /* Ditto */ } - IFDEBUG(D_ESISOUTPUT) - printf("esis_shoutput: adding NSAP %s\n", - clnp_iso_addrp(&ia->ia_addr.siso_addr)); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_ESISOUTPUT]) { + printf("esis_shoutput: adding NSAP %s\n", + clnp_iso_addrp(&ia->ia_addr.siso_addr)); + } +#endif if (!esis_insert_addr(&cp, &len, - &ia->ia_addr.siso_addr, m, nsellen)) { + &ia->ia_addr.siso_addr, m, nsellen)) { EXTEND_PACKET(m, m0, cp); - (void) esis_insert_addr(&cp, &len, &ia->ia_addr.siso_addr, m, - nsellen); + (void) esis_insert_addr(&cp, &len, + &ia->ia_addr.siso_addr, m, + nsellen); } naddr++; } @@ -909,165 +965,211 @@ struct iso_addr *isoa; } *cp++ = ESISOVAL_ESCT; *cp++ = 2; - HTOC(*cp, *(cp+1), esis_esconfig_time); + HTOC(*cp, *(cp + 1), esis_esconfig_time); len += 4; m->m_len += 4; - IFDEBUG(D_ESISOUTPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_ESISOUTPUT]) { printf("m0 0x%x, m 0x%x, data 0x%x, len %d, cp 0x%x\n", - m0, m, m->m_data, m->m_len, cp); - ENDDEBUG + (unsigned int) m0, (unsigned int) m, + (unsigned int) m->m_data, m->m_len, + (unsigned int) cp); + } +#endif } m0->m_pkthdr.len = len; pdu->esis_hdr_len = len; - iso_gen_csum(m0, ESIS_CKSUM_OFF, (int)pdu->esis_hdr_len); + iso_gen_csum(m0, ESIS_CKSUM_OFF, (int) pdu->esis_hdr_len); - bzero((caddr_t)&siso, sizeof(siso)); + bzero((caddr_t) & siso, sizeof(siso)); siso.siso_family = AF_ISO; siso.siso_data[0] = AFI_SNA; siso.siso_nlen = sn_len + 1; - bcopy(sn_addr, siso.siso_data + 1, (unsigned)sn_len); - (ifp->if_output)(ifp, m0, sisotosa(&siso), 0); + bcopy(sn_addr, siso.siso_data + 1, (unsigned) sn_len); + (ifp->if_output) (ifp, m0, sisotosa(&siso), 0); } /* * FUNCTION: isis_input * - * PURPOSE: Process an incoming isis packet + * PURPOSE: Process an incoming isis packet * - * RETURNS: nothing + * RETURNS: nothing * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ void -isis_input(m0, shp) -struct mbuf *m0; /* ptr to first mbuf of pkt */ -struct snpa_hdr *shp; /* subnetwork header */ +#if __STDC__ +isis_input(struct mbuf *m0, ...) +#else +isis_input(m0, va_alist) + struct mbuf *m0; + va_dcl +#endif { - register int type; + struct snpa_hdr *shp; /* subnetwork header */ register struct rawcb *rp, *first_rp = 0; - struct ifnet *ifp = shp->snh_ifp; - char workbuf[16]; - struct mbuf *mm; - - IFDEBUG(D_ISISINPUT) - int i; - - printf("isis_input: pkt on ifp x%x (%s%d): from:", ifp, - ifp->if_name, ifp->if_unit); - for (i=0; i<6; i++) - printf("%x%c", shp->snh_shost[i]&0xff, (i<5) ? ':' : ' '); + struct ifnet *ifp; + struct mbuf *mm; + va_list ap; + + va_start(ap, m0); + shp = va_arg(ap, struct snpa_hdr *); + va_end(ap); + ifp = shp->snh_ifp; + +#ifdef ARGO_DEBUG + if (argo_debug[D_ISISINPUT]) { + int i; + + printf("isis_input: pkt on ifp x%x (%s%d): from:", + (unsigned int) ifp, + ifp->if_name, ifp->if_unit); + for (i = 0; i < 6; i++) + printf("%x%c", shp->snh_shost[i] & 0xff, + (i < 5) ? ':' : ' '); printf(" to:"); - for (i=0; i<6; i++) - printf("%x%c", shp->snh_dhost[i]&0xff, (i<5) ? ':' : ' '); + for (i = 0; i < 6; i++) + printf("%x%c", shp->snh_dhost[i] & 0xff, + (i < 5) ? ':' : ' '); printf("\n"); - ENDDEBUG + } +#endif esis_dl.sdl_alen = ifp->if_addrlen; esis_dl.sdl_index = ifp->if_index; - bcopy(shp->snh_shost, (caddr_t)esis_dl.sdl_data, esis_dl.sdl_alen); + bcopy(shp->snh_shost, (caddr_t) esis_dl.sdl_data, esis_dl.sdl_alen); for (rp = esis_pcb.lh_first; rp != 0; rp = rp->rcb_list.le_next) { if (first_rp == 0) { first_rp = rp; continue; } - if (mm = m_copy(m0, 0, M_COPYALL)) { /*can't block at interrupt level */ + /* can't block at interrupt level */ + if ((mm = m_copy(m0, 0, M_COPYALL)) != NULL) { if (sbappendaddr(&rp->rcb_socket->so_rcv, - (struct sockaddr *)&esis_dl, mm, - (struct mbuf *)0) != 0) { + (struct sockaddr *) & esis_dl, mm, + (struct mbuf *) 0) != 0) { sorwakeup(rp->rcb_socket); - } else { - IFDEBUG(D_ISISINPUT) - printf("Error in sbappenaddr, mm = 0x%x\n", mm); - ENDDEBUG + } else { +#ifdef ARGO_DEBUG + if (argo_debug[D_ISISINPUT]) { + printf( + "Error in sbappenaddr, mm = 0x%x\n", + (unsigned int) mm); + } +#endif m_freem(mm); } } } if (first_rp && sbappendaddr(&first_rp->rcb_socket->so_rcv, - (struct sockaddr *)&esis_dl, m0, (struct mbuf *)0) != 0) { + (struct sockaddr *) & esis_dl, m0, (struct mbuf *) 0) != 0) { sorwakeup(first_rp->rcb_socket); return; } m_freem(m0); } -isis_output(sdl, m) -register struct sockaddr_dl *sdl; -struct mbuf *m; +int +#if __STDC__ +isis_output(struct mbuf *m, ...) +#else +isis_output(m, va_alist) + struct mbuf *m; + va_dcl +#endif { + register struct sockaddr_dl *sdl; register struct ifnet *ifp; - struct ifaddr *ifa, *ifa_ifwithnet(); + struct ifaddr *ifa; struct sockaddr_iso siso; - int error = 0; - unsigned sn_len; + int error = 0; + unsigned sn_len; + va_list ap; - ifa = ifa_ifwithnet((struct sockaddr *)sdl); /* get ifp from sdl */ + va_start(ap, m); + sdl = va_arg(ap, struct sockaddr_dl *); + va_end(ap); + + ifa = ifa_ifwithnet((struct sockaddr *) sdl); /* get ifp from sdl */ if (ifa == 0) { - IFDEBUG(D_ISISOUTPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_ISISOUTPUT]) { printf("isis_output: interface not found\n"); - ENDDEBUG + } +#endif error = EINVAL; goto release; } ifp = ifa->ifa_ifp; sn_len = sdl->sdl_alen; - IFDEBUG(D_ISISOUTPUT) - u_char *cp = (u_char *)LLADDR(sdl), *cplim = cp + sn_len; +#ifdef ARGO_DEBUG + if (argo_debug[D_ISISOUTPUT]) { + u_char *cp = (u_char *) LLADDR(sdl), *cplim = cp + sn_len; printf("isis_output: ifp 0x%x (%s%d), to: ", - ifp, ifp->if_name, ifp->if_unit); + (unsigned int) ifp, ifp->if_name, ifp->if_unit); while (cp < cplim) { printf("%x", *cp++); printf("%c", (cp < cplim) ? ':' : ' '); } printf("\n"); - ENDDEBUG - bzero((caddr_t)&siso, sizeof(siso)); - siso.siso_family = AF_ISO; /* This convention may be useful for X.25 */ + } +#endif + bzero((caddr_t) & siso, sizeof(siso)); + siso.siso_family = AF_ISO; /* This convention may be useful for + * X.25 */ siso.siso_data[0] = AFI_SNA; siso.siso_nlen = sn_len + 1; bcopy(LLADDR(sdl), siso.siso_data + 1, sn_len); - error = (ifp->if_output)(ifp, m, sisotosa(&siso), 0); + error = (ifp->if_output) (ifp, m, sisotosa(&siso), 0); if (error) { - IFDEBUG(D_ISISOUTPUT) - printf("isis_output: error from ether_output is %d\n", error); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_ISISOUTPUT]) { + printf("isis_output: error from ether_output is %d\n", + error); + } +#endif } return (error); release: if (m != NULL) m_freem(m); - return(error); + return (error); } /* * FUNCTION: esis_ctlinput * - * PURPOSE: Handle the PRC_IFDOWN transition + * PURPOSE: Handle the PRC_IFDOWN transition * - * RETURNS: nothing + * RETURNS: nothing * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: Calls snpac_flush for interface specified. - * The loop through iso_ifaddr is stupid because - * back in if_down, we knew the ifp... + * NOTES: Calls snpac_flush for interface specified. + * The loop through iso_ifaddr is stupid because + * back in if_down, we knew the ifp... */ -void -esis_ctlinput(req, siso) -int req; /* request: we handle only PRC_IFDOWN */ -struct sockaddr_iso *siso; /* address of ifp */ +void * +esis_ctlinput(req, siso, dummy) + int req; /* request: we handle only PRC_IFDOWN */ + struct sockaddr *siso; /* address of ifp */ + void *dummy; { register struct iso_ifaddr *ia; /* scan through interface addresses */ if (req == PRC_IFDOWN) - for (ia = iso_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next) { - if (iso_addrmatch(IA_SIS(ia), siso)) + for (ia = iso_ifaddr.tqh_first; ia != 0; + ia = ia->ia_list.tqe_next) { + if (iso_addrmatch(IA_SIS(ia), + (struct sockaddr_iso *) siso)) snpac_flushifp(ia->ia_ifp); } + return NULL; } -#endif /* ISO */ +#endif /* ISO */ diff --git a/sys/netiso/esis.h b/sys/netiso/esis.h index 89127e1485f..54698241120 100644 --- a/sys/netiso/esis.h +++ b/sys/netiso/esis.h @@ -1,4 +1,5 @@ -/* $NetBSD: esis.h,v 1.8 1995/03/29 22:09:46 briggs Exp $ */ +/* $OpenBSD: esis.h,v 1.2 1996/03/04 10:35:18 mickey Exp $ */ +/* $NetBSD: esis.h,v 1.9 1996/02/13 22:09:29 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -64,34 +65,36 @@ SOFTWARE. #include <machine/endian.h> -#define SNPAC_AGE 60 /* seconds */ -#define ESIS_CONFIG 60 /* seconds */ +#define SNPAC_AGE 60 /* seconds */ +#define ESIS_CONFIG 60 /* seconds */ #define ESIS_HT (ESIS_CONFIG * 2) /* * Fixed part of an ESIS header */ struct esis_fixed { - u_char esis_proto_id; /* network layer protocol identifier */ - u_char esis_hdr_len; /* length indicator (octets) */ - u_char esis_vers; /* version/protocol identifier extension */ - u_char esis_res1; /* reserved */ - u_char esis_type; /* type code */ -/* technically, type should be &='d 0x1f */ -#define ESIS_ESH 0x02 /* End System Hello */ -#define ESIS_ISH 0x04 /* Intermediate System Hello */ -#define ESIS_RD 0x06 /* Redirect */ - u_char esis_ht_msb; /* holding time (seconds) high byte */ - u_char esis_ht_lsb; /* holding time (seconds) low byte */ - u_char esis_cksum_msb; /* checksum high byte */ - u_char esis_cksum_lsb; /* checksum low byte */ + u_char esis_proto_id; /* network layer protocol identifier */ + u_char esis_hdr_len; /* length indicator (octets) */ + u_char esis_vers; /* version/protocol identifier + * extension */ + u_char esis_res1; /* reserved */ + u_char esis_type; /* type code */ + /* technically, type should be &='d 0x1f */ +#define ESIS_ESH 0x02 /* End System Hello */ +#define ESIS_ISH 0x04 /* Intermediate System Hello */ +#define ESIS_RD 0x06 /* Redirect */ + u_char esis_ht_msb; /* holding time (seconds) high byte */ + u_char esis_ht_lsb; /* holding time (seconds) low byte */ + u_char esis_cksum_msb; /* checksum high byte */ + u_char esis_cksum_lsb; /* checksum low byte */ }; /* * Values for ESIS datagram options */ #define ESISOVAL_NETMASK 0xe1 /* address mask option, RD PDU only */ #define ESISOVAL_SNPAMASK 0xe2 /* snpa mask option, RD PDU only */ -#define ESISOVAL_ESCT 0xc6 /* end system conf. timer, ISH PDU only */ +#define ESISOVAL_ESCT 0xc6 /* end system conf. timer, ISH PDU + * only */ #define ESIS_CKSUM_OFF 0x07 @@ -101,19 +104,44 @@ struct esis_fixed { #define ESIS_VERSION 1 struct esis_stat { - u_short es_nomem; /* insufficient memory to send hello */ - u_short es_badcsum; /* incorrect checksum */ - u_short es_badvers; /* incorrect version number */ - u_short es_badtype; /* unknown pdu type field */ - u_short es_toosmall; /* packet too small */ - u_short es_eshsent; /* ESH sent */ - u_short es_eshrcvd; /* ESH rcvd */ - u_short es_ishsent; /* ISH sent */ - u_short es_ishrcvd; /* ISH rcvd */ - u_short es_rdsent; /* RD sent */ - u_short es_rdrcvd; /* RD rcvd */ + u_short es_nomem; /* insufficient memory to send hello */ + u_short es_badcsum; /* incorrect checksum */ + u_short es_badvers; /* incorrect version number */ + u_short es_badtype; /* unknown pdu type field */ + u_short es_toosmall; /* packet too small */ + u_short es_eshsent; /* ESH sent */ + u_short es_eshrcvd; /* ESH rcvd */ + u_short es_ishsent; /* ISH sent */ + u_short es_ishrcvd; /* ISH rcvd */ + u_short es_rdsent; /* RD sent */ + u_short es_rdrcvd; /* RD rcvd */ }; #ifdef _KERNEL struct esis_stat esis_stat; -#endif /* _KERNEL */ +struct socket; +struct mbuf; +struct snpa_hdr; +struct clnp_optidx; +struct iso_addr; +struct rtentry; +struct sockaddr_dl; + +void esis_init __P((void)); +int esis_usrreq __P((struct socket *, int, struct mbuf *, struct mbuf *, + struct mbuf *)); +void esis_input __P((struct mbuf *, ...)); +void esis_rdoutput __P((struct snpa_hdr *, struct mbuf *, struct clnp_optidx *, + struct iso_addr *, struct rtentry *)); +int esis_insert_addr __P((caddr_t *, int *, struct iso_addr *, struct mbuf *, + int)); +void esis_eshinput __P((struct mbuf *, struct snpa_hdr *)); +void esis_ishinput __P((struct mbuf *, struct snpa_hdr *)); +void esis_rdinput __P((struct mbuf *, struct snpa_hdr *)); +void esis_config __P((void *)); +void esis_shoutput __P((struct ifnet *, int, int, caddr_t, int, + struct iso_addr *)); +void isis_input __P((struct mbuf *, ...)); +int isis_output __P((struct mbuf *, ...)); +void *esis_ctlinput __P((int, struct sockaddr *, void *)); +#endif /* _KERNEL */ diff --git a/sys/netiso/idrp_usrreq.c b/sys/netiso/idrp_usrreq.c index 2dfe2bd99f3..c050d256de2 100644 --- a/sys/netiso/idrp_usrreq.c +++ b/sys/netiso/idrp_usrreq.c @@ -1,4 +1,5 @@ -/* $NetBSD: idrp_usrreq.c,v 1.4 1995/08/12 23:59:47 mycroft Exp $ */ +/* $OpenBSD: idrp_usrreq.c,v 1.2 1996/03/04 10:35:20 mickey Exp $ */ +/* $NetBSD: idrp_usrreq.c,v 1.5 1996/02/13 22:09:33 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -54,11 +55,13 @@ #include <netiso/clnl.h> #include <netiso/iso_pcb.h> #include <netiso/iso_var.h> +#include <netiso/idrp_var.h> -void idrp_input(); -struct isopcb idrp_isop; -static struct sockaddr_iso idrp_addrs[2] = -{ { sizeof(idrp_addrs), AF_ISO, }, { sizeof(idrp_addrs[1]), AF_ISO, } }; +#include <machine/stdarg.h> + +struct isopcb idrp_isop; +static struct sockaddr_iso idrp_addrs[2] = +{{sizeof(idrp_addrs), AF_ISO,}, {sizeof(idrp_addrs[1]), AF_ISO,}}; /* * IDRP initialization @@ -82,58 +85,84 @@ idrp_init() * FUNCTION and ARGUMENTS: * Take a packet (m) from clnp, strip off the clnp header * and mke suitable for the idrp socket. - * No return value. + * No return value. */ void -idrp_input(m, src, dst) - register struct mbuf *m; - struct sockaddr_iso *src, *dst; +#if __STDC__ +idrp_input(struct mbuf *m, ...) +#else +idrp_input(m, va_alist) + struct mbuf *m; + va_dcl +#endif { + struct sockaddr_iso *src, *dst; + va_list ap; + + va_start(ap, m); + src = va_arg(ap, struct sockaddr_iso *); + dst = va_arg(ap, struct sockaddr_iso *); + va_end(ap); + if (idrp_isop.isop_socket == 0) { - bad: m_freem(m); +bad: m_freem(m); return; } bzero(idrp_addrs[0].siso_data, sizeof(idrp_addrs[0].siso_data)); - bcopy((caddr_t)&(src->siso_addr), (caddr_t)&idrp_addrs[0].siso_addr, - 1 + src->siso_nlen); + bcopy((caddr_t) & (src->siso_addr), (caddr_t) & idrp_addrs[0].siso_addr, + 1 + src->siso_nlen); bzero(idrp_addrs[1].siso_data, sizeof(idrp_addrs[1].siso_data)); - bcopy((caddr_t)&(dst->siso_addr), (caddr_t)&idrp_addrs[1].siso_addr, - 1 + dst->siso_nlen); + bcopy((caddr_t) & (dst->siso_addr), (caddr_t) & idrp_addrs[1].siso_addr, + 1 + dst->siso_nlen); if (sbappendaddr(&idrp_isop.isop_socket->so_rcv, - sisotosa(idrp_addrs), m, (struct mbuf *)0) == 0) + sisotosa(idrp_addrs), m, (struct mbuf *) 0) == 0) goto bad; sorwakeup(idrp_isop.isop_socket); } -idrp_output(m, addr) - struct mbuf *m, *addr; +int +#if __STDC__ +idrp_output(struct mbuf *m, ...) +#else +idrp_output(m, va_alist) + struct mbuf *m; + va_dcl +#endif { - register struct sockaddr_iso *siso = mtod(addr, struct sockaddr_iso *); - int s = splsoftnet(), i; - - bcopy((caddr_t)&(siso->siso_addr), - (caddr_t)&idrp_isop.isop_sfaddr.siso_addr, 1 + siso->siso_nlen); + struct mbuf *addr; + register struct sockaddr_iso *siso; + int s = splsoftnet(), i; + va_list ap; + va_start(ap, m); + addr = va_arg(ap, struct mbuf *); + va_end(ap); + siso = mtod(addr, struct sockaddr_iso *); + + bcopy((caddr_t) & (siso->siso_addr), + (caddr_t) & idrp_isop.isop_sfaddr.siso_addr, 1 + siso->siso_nlen); siso++; - bcopy((caddr_t)&(siso->siso_addr), - (caddr_t)&idrp_isop.isop_sladdr.siso_addr, 1 + siso->siso_nlen); + bcopy((caddr_t) & (siso->siso_addr), + (caddr_t) & idrp_isop.isop_sladdr.siso_addr, 1 + siso->siso_nlen); i = clnp_output(m, idrp_isop, m->m_pkthdr.len, 0); splx(s); return (i); } -u_long idrp_sendspace = 3072; /* really max datagram size */ -u_long idrp_recvspace = 40 * 1024; /* 40 1K datagrams */ +u_long idrp_sendspace = 3072; /* really max datagram size */ +u_long idrp_recvspace = 40 * 1024; /* 40 1K datagrams */ -/*ARGSUSED*/ +/* ARGSUSED */ +int idrp_usrreq(so, req, m, addr, control) - struct socket *so; - int req; - struct mbuf *m, *addr, *control; + struct socket *so; + int req; + struct mbuf *m, *addr, *control; { - int error = 0; + int error = 0; - /* Note: need to block idrp_input while changing - * the udp pcb queue and/or pcb addresses. + /* + * Note: need to block idrp_input while changing the udp pcb queue + * and/or pcb addresses. */ switch (req) { @@ -170,7 +199,6 @@ idrp_usrreq(so, req, m, addr, control) return (EOPNOTSUPP); /* do not free mbuf's */ } -release: if (control) { printf("idrp control data unexpectedly retained\n"); m_freem(control); diff --git a/sys/netiso/if_cons.c b/sys/netiso/if_cons.c index 6800a3b6892..99af200fc70 100644 --- a/sys/netiso/if_cons.c +++ b/sys/netiso/if_cons.c @@ -1,4 +1,5 @@ -/* $NetBSD: if_cons.c,v 1.6 1995/03/28 20:01:29 jtc Exp $ */ +/* $OpenBSD: if_cons.c,v 1.2 1996/03/04 10:35:21 mickey Exp $ */ +/* $NetBSD: if_cons.c,v 1.7 1996/02/13 22:09:44 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -63,18 +64,18 @@ SOFTWARE. */ /* * cons.c - Connection Oriented Network Service: - * including support for a) user transport-level service, + * including support for a) user transport-level service, * b) COSNS below CLNP, and c) CONS below TP. */ #ifdef TPCONS #ifdef _KERNEL #ifdef ARGO_DEBUG -#define Static -unsigned LAST_CALL_PCB; -#else /* ARGO_DEBUG */ +#define Static +unsigned LAST_CALL_PCB; +#else /* ARGO_DEBUG */ #define Static static -#endif /* ARGO_DEBUG */ +#endif /* ARGO_DEBUG */ #ifndef SOCK_STREAM #include <sys/param.h> @@ -85,7 +86,6 @@ unsigned LAST_CALL_PCB; #include <sys/socketvar.h> #include <sys/errno.h> #include <sys/ioctl.h> -#include <sys/tsleep.h> #include <net/if.h> #include <net/netisr.h> @@ -97,10 +97,14 @@ unsigned LAST_CALL_PCB; #include <netiso/iso.h> #include <netiso/cons.h> #include <netiso/iso_pcb.h> +#include <netiso/iso_var.h> +#include <netiso/tp_var.h> +#include <netiso/clnp.h> #include <netccitt/x25.h> #include <netccitt/pk.h> #include <netccitt/pk_var.h> +#include <netccitt/pk_extern.h> #endif #ifdef ARGO_DEBUG @@ -115,11 +119,11 @@ unsigned LAST_CALL_PCB; #define MT_XCONFIRM MT_DATA #define MT_XDATA MT_DATA #define MT_XHEADER MT_HEADER -#endif /* ARGO_DEBUG */ +#endif /* ARGO_DEBUG */ #define DONTCLEAR -1 -/********************************************************************* +/********************************************************************* * cons.c - CONS interface to the x.25 layer * * TODO: figure out what resources we might run out of besides mbufs. @@ -127,56 +131,49 @@ unsigned LAST_CALL_PCB; * lru x% of the connections, for some parameter x. * * There are 2 interfaces from above: - * 1) from TP0: + * 1) from TP0: * cons CO network service * TP associates a transport connection with a network connection. - * cons_output( isop, m, len, isdgm==0 ) + * cons_output( isop, m, len, isdgm==0 ) * co_flags == 0 * 2) from TP4: * It's a datagram service, like clnp is. - even though it calls - * cons_output( isop, m, len, isdgm==1 ) + * cons_output( isop, m, len, isdgm==1 ) * it eventually goes through * cosns_output(ifp, m, dst). - * TP4 permits multiplexing (reuse, possibly simultaneously) of the + * TP4 permits multiplexing (reuse, possibly simultaneously) of the * network connections. * This means that many sockets (many tpcbs) may be associated with * this pklcd, hence cannot have a back ptr from pklcd to a tpcb. - * co_flags & CONSF_DGM + * co_flags & CONSF_DGM * co_socket is null since there may be many sockets that use this pklcd. + * NOTE: + * streams would really be nice. sigh. + * NOTE: + * PVCs could be handled by config-ing a cons with an address and with the + * IFF_POINTTOPOINT flag on. This code would then have to skip the + * connection setup stuff for pt-to-pt links. * -NOTE: - streams would really be nice. sigh. -NOTE: - PVCs could be handled by config-ing a cons with an address and with the - IFF_POINTTOPOINT flag on. This code would then have to skip the - connection setup stuff for pt-to-pt links. - - *********************************************************************/ #define CONS_IFQMAXLEN 5 +Static int make_partial_x25_packet __P((struct isopcb *, struct pklcd *)); +Static int NSAPtoDTE __P((struct sockaddr_iso *, struct sockaddr_x25 *)); +Static int FACILtoNSAP __P((struct sockaddr_iso *, u_char *)); +Static void init_siso __P((struct sockaddr_iso *)); +Static int DTEtoNSAP __P((struct sockaddr_iso *, struct sockaddr_x25 *)); +Static int parse_facil __P((struct pklcd *, struct isopcb *, caddr_t, u_char)); /* protosw pointers for getting to higher layer */ -Static struct protosw *CLNP_proto; -Static struct protosw *TP_proto; -Static struct protosw *X25_proto; -Static int issue_clear_req(); - -#ifndef PHASEONE -extern struct ifaddr *ifa_ifwithnet(); -#endif /* PHASEONE */ - -extern struct ifaddr *ifa_ifwithaddr(); +Static struct protosw *CLNP_proto; +Static struct protosw *TP_proto; +Static struct protosw *X25_proto; -extern struct isopcb tp_isopcb; /* chain of all TP pcbs */ +extern struct isopcb tp_isopcb; /* chain of all TP pcbs */ -Static int parse_facil(), NSAPtoDTE(), make_partial_x25_packet(); -Static int FACILtoNSAP(), DTEtoNSAP(); -Static struct pklcd *cons_chan_to_pcb(); - #define HIGH_NIBBLE 1 #define LOW_NIBBLE 0 @@ -192,42 +189,46 @@ Static struct pklcd *cons_chan_to_pcb(); */ void nibble_copy(src_octet, src_nibble, dst_octet, dst_nibble, len) - register char *src_octet; - register char *dst_octet; - register unsigned src_nibble; - register unsigned dst_nibble; - int len; + register char *src_octet; + register char *dst_octet; + register unsigned src_nibble; + register unsigned dst_nibble; + int len; { - register i; - register unsigned dshift, sshift; + register i; + register unsigned dshift, sshift; - IFDEBUG(D_CADDR) - printf("nibble_copy ( 0x%x, 0x%x, 0x%x, 0x%x 0x%x)\n", - src_octet, src_nibble, dst_octet, dst_nibble, len); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_CADDR]) { + printf("nibble_copy ( 0x%x, 0x%x, 0x%x, 0x%x 0x%x)\n", + src_octet, src_nibble, dst_octet, dst_nibble, len); + } +#endif #define SHIFT 0x4 dshift = dst_nibble << 2; sshift = src_nibble << 2; - for (i=0; i<len; i++) { + for (i = 0; i < len; i++) { /* clear dst_nibble */ - *dst_octet &= ~(0xf<< dshift); + *dst_octet &= ~(0xf << dshift); /* set dst nibble */ - *dst_octet |= ( 0xf & (*src_octet >> sshift))<< dshift; - - dshift ^= SHIFT; - sshift ^= SHIFT; - src_nibble = 1-src_nibble; - dst_nibble = 1-dst_nibble; - src_octet += src_nibble; - dst_octet += dst_nibble; + *dst_octet |= (0xf & (*src_octet >> sshift)) << dshift; + + dshift ^= SHIFT; + sshift ^= SHIFT; + src_nibble = 1 - src_nibble; + dst_nibble = 1 - dst_nibble; + src_octet += src_nibble; + dst_octet += dst_nibble; } - IFDEBUG(D_CADDR) +#ifdef ARGO_DEBUG + if (argo_debug[D_CADDR]) { printf("nibble_copy DONE\n"); - ENDDEBUG + } +#endif } /* @@ -237,43 +238,47 @@ nibble_copy(src_octet, src_nibble, dst_octet, dst_nibble, len) * RETURNS: 0 if they differ, 1 if they are the same. */ int -nibble_match( src_octet, src_nibble, dst_octet, dst_nibble, len) - register char *src_octet; - register char *dst_octet; - register unsigned src_nibble; - register unsigned dst_nibble; - int len; +nibble_match(src_octet, src_nibble, dst_octet, dst_nibble, len) + register char *src_octet; + register char *dst_octet; + register unsigned src_nibble; + register unsigned dst_nibble; + int len; { - register i; - register unsigned dshift, sshift; - u_char nibble_a, nibble_b; + register i; + register unsigned dshift, sshift; + u_char nibble_a, nibble_b; - IFDEBUG(D_CADDR) - printf("nibble_match ( 0x%x, 0x%x, 0x%x, 0x%x 0x%x)\n", - src_octet, src_nibble, dst_octet, dst_nibble, len); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_CADDR]) { + printf("nibble_match ( 0x%x, 0x%x, 0x%x, 0x%x 0x%x)\n", + src_octet, src_nibble, dst_octet, dst_nibble, len); + } +#endif #define SHIFT 0x4 dshift = dst_nibble << 2; sshift = src_nibble << 2; - for (i=0; i<len; i++) { - nibble_b = ((*dst_octet)>>dshift) & 0xf; - nibble_a = ( 0xf & (*src_octet >> sshift)); + for (i = 0; i < len; i++) { + nibble_b = ((*dst_octet) >> dshift) & 0xf; + nibble_a = (0xf & (*src_octet >> sshift)); if (nibble_b != nibble_a) return 0; - dshift ^= SHIFT; - sshift ^= SHIFT; - src_nibble = 1-src_nibble; - dst_nibble = 1-dst_nibble; - src_octet += src_nibble; - dst_octet += dst_nibble; + dshift ^= SHIFT; + sshift ^= SHIFT; + src_nibble = 1 - src_nibble; + dst_nibble = 1 - dst_nibble; + src_octet += src_nibble; + dst_octet += dst_nibble; } - IFDEBUG(D_CADDR) +#ifdef ARGO_DEBUG + if (argo_debug[D_CADDR]) { printf("nibble_match DONE\n"); - ENDDEBUG + } +#endif return 1; } @@ -290,16 +295,15 @@ nibble_match( src_octet, src_nibble, dst_octet, dst_nibble, len) void cons_init() { - int tp_incoming(), clnp_incoming(); - - - CLNP_proto = pffindproto(AF_ISO, ISOPROTO_CLNP, SOCK_DGRAM); + CLNP_proto = pffindproto(AF_ISO, ISOPROTO_CLNP, SOCK_DGRAM); X25_proto = pffindproto(AF_ISO, ISOPROTO_X25, SOCK_STREAM); TP_proto = pffindproto(AF_ISO, ISOPROTO_TP0, SOCK_SEQPACKET); - IFDEBUG(D_CCONS) +#ifdef ARGO_DEBUG + if (argo_debug[D_CCONS]) { printf("cons_init end : cnlp_proto 0x%x cons proto 0x%x tp proto 0x%x\n", - CLNP_proto, X25_proto, TP_proto); - ENDDEBUG + CLNP_proto, X25_proto, TP_proto); + } +#endif #ifdef notdef pk_protolisten(0x81, 0, clnp_incoming); pk_protolisten(0x82, 0, esis_incoming); @@ -308,112 +312,121 @@ cons_init() #endif } -tp_incoming(lcp, m) -struct pklcd *lcp; -register struct mbuf *m; +int +tp_incoming(m, v) + register struct mbuf *m; + void *v; { + struct pklcd *lcp = v; register struct isopcb *isop; - int cons_tpinput(); - if (iso_pcballoc((struct socket *)0, &tp_isopcb)) { + if (iso_pcballoc(NULL, &tp_isopcb)) { pk_close(lcp); - return; + return 0; } isop = tp_isopcb.isop_next; lcp->lcd_upper = cons_tpinput; - lcp->lcd_upnext = (caddr_t)isop; - lcp->lcd_send(lcp); /* Confirms call */ - isop->isop_chan = (caddr_t)lcp; + lcp->lcd_upnext = (caddr_t) isop; + lcp->lcd_send(lcp); /* Confirms call */ + isop->isop_chan = (caddr_t) lcp; isop->isop_laddr = &isop->isop_sladdr; isop->isop_faddr = &isop->isop_sfaddr; DTEtoNSAP(isop->isop_laddr, &lcp->lcd_laddr); DTEtoNSAP(isop->isop_faddr, &lcp->lcd_faddr); parse_facil(lcp, isop, &(mtod(m, struct x25_packet *)->packet_data), - m->m_pkthdr.len - PKHEADERLN); + m->m_pkthdr.len - PKHEADERLN); + return 0; } -cons_tpinput(lcp, m0) -struct mbuf *m0; -struct pklcd *lcp; +int +cons_tpinput(m0, v) + struct mbuf *m0; + void *v; { - register struct isopcb *isop = (struct isopcb *)lcp->lcd_upnext; - register struct x25_packet *xp; - int cmd, ptype = CLEAR; + struct pklcd *lcp = v; + register struct isopcb *isop = (struct isopcb *) lcp->lcd_upnext; + int cmd, ptype = PK_CLEAR; if (isop == 0) - return; + return 0; if (m0 == 0) goto dead; - switch(m0->m_type) { + switch (m0->m_type) { case MT_DATA: case MT_OOBDATA: - tpcons_input(m0, isop->isop_faddr, isop->isop_laddr, (caddr_t)lcp); - return; + tpcons_input(m0, isop->isop_faddr, isop->isop_laddr, + (caddr_t) lcp); + return 0; case MT_CONTROL: switch (ptype = pk_decode(mtod(m0, struct x25_packet *))) { - case RR: + case PK_RR: cmd = PRC_CONS_SEND_DONE; break; - case CALL_ACCEPTED: + case PK_CALL_ACCEPTED: if (lcp->lcd_sb.sb_mb) - lcp->lcd_send(lcp); /* XXX - fix this */ - /*FALLTHROUGH*/ + lcp->lcd_send(lcp); /* XXX - fix this */ + /* FALLTHROUGH */ default: - return; + return 0; - dead: - case CLEAR: - case CLEAR_CONF: + dead: + case PK_CLEAR: + case PK_CLEAR_CONF: lcp->lcd_upper = 0; lcp->lcd_upnext = 0; isop->isop_chan = 0; - case RESET: + case PK_RESET: cmd = PRC_ROUTEDEAD; } - tpcons_ctlinput(cmd, isop->isop_faddr, isop); - if (cmd = PRC_ROUTEDEAD && isop->isop_refcnt == 0) + tpcons_ctlinput(cmd, (struct sockaddr *) isop->isop_faddr, + isop); + if (cmd == PRC_ROUTEDEAD && isop->isop_refcnt == 0) iso_pcbdetach(isop); } + return 0; } /* * NAME: cons_connect() * CALLED FROM: - * tpcons_pcbconnect() when opening a new connection. + * tpcons_pcbconnect() when opening a new connection. * FUNCTION anD ARGUMENTS: * Figures out which device to use, finding a route if one doesn't * already exist. * RETURN VALUE: * returns E* */ +int cons_connect(isop) register struct isopcb *isop; { - register struct pklcd *lcp = (struct pklcd *)isop->isop_chan; - register struct mbuf *m; - struct ifaddr *ifa; - int error; + register struct pklcd *lcp = (struct pklcd *) isop->isop_chan; + int error; - IFDEBUG(D_CCONN) +#ifdef ARGO_DEBUG + if (argo_debug[D_CCONN]) { printf("cons_connect(0x%x): ", isop); dump_isoaddr(isop->isop_faddr); printf("myaddr: "); dump_isoaddr(isop->isop_laddr); - printf("\n" ); - ENDDEBUG + printf("\n"); + } +#endif NSAPtoDTE(isop->isop_faddr, &lcp->lcd_faddr); lcp->lcd_upper = cons_tpinput; - lcp->lcd_upnext = (caddr_t)isop; - IFDEBUG(D_CCONN) + lcp->lcd_upnext = (caddr_t) isop; +#ifdef ARGO_DEBUG + if (argo_debug[D_CCONN]) { printf( - "calling make_partial_x25_packet( 0x%x, 0x%x, 0x%x)\n", - &lcp->lcd_faddr, &lcp->lcd_laddr, - isop->isop_socket->so_proto->pr_protocol); - ENDDEBUG - if ((error = make_partial_x25_packet(isop, lcp, m)) == 0) + "calling make_partial_x25_packet( 0x%x, 0x%x, 0x%x)\n", + &lcp->lcd_faddr, &lcp->lcd_laddr, + isop->isop_socket->so_proto->pr_protocol); + } +#endif + if ((error = make_partial_x25_packet(isop, lcp)) == 0) error = pk_connect(lcp, &lcp->lcd_faddr); return error; } @@ -423,98 +436,95 @@ cons_connect(isop) */ -/* - * NAME: cons_ctlinput() - * CALLED FROM: - * lower layer when ECN_CLEAR occurs : this routine is here - * for consistency - cons subnet service calls its higher layer - * through the protosw entry. - * FUNCTION & ARGUMENTS: - * cmd is a PRC_* command, list found in ../sys/protosw.h - * copcb is the obvious. - * This serves the higher-layer cons service. - * NOTE: this takes 3rd arg. because cons uses it to inform itself - * of things (timeouts, etc) but has a pcb instead of an address. +/* + * NAME: cons_ctlinput() CALLED FROM: lower layer when ECN_CLEAR + * occurs : this routine is here for consistency - cons subnet service calls + * its higher layer through the protosw entry. FUNCTION & ARGUMENTS: cmd is a + * PRC_* command, list found in ../sys/protosw.h copcb is the obvious. This + * serves the higher-layer cons service. NOTE: this takes 3rd arg. because + * cons uses it to inform itself of things (timeouts, etc) but has a pcb + * instead of an address. */ -void -cons_ctlinput(cmd, sa, copcb) - int cmd; +void * +cons_ctlinput(cmd, sa, v) + int cmd; struct sockaddr *sa; - register struct pklcd *copcb; + void *v; { + return NULL; } -find_error_reason( xp ) +int +find_error_reason(xp) register struct x25_packet *xp; { - extern u_char x25_error_stats[]; - int error, cause; + int error, cause = 0; if (xp) { - cause = 4[(char *)xp]; + cause = 4[(char *) xp]; switch (cause) { - case 0x00: - case 0x80: - /* DTE originated; look at the diagnostic */ - error = (CONL_ERROR_MASK | cause); - goto done; - - case 0x01: /* number busy */ - case 0x81: - case 0x09: /* Out of order */ - case 0x89: - case 0x11: /* Remot Procedure Error */ - case 0x91: - case 0x19: /* reverse charging accept not subscribed */ - case 0x99: - case 0x21: /* Incampat destination */ - case 0xa1: - case 0x29: /* fast select accept not subscribed */ - case 0xa9: - case 0x39: /* ship absent */ - case 0xb9: - case 0x03: /* invalid facil request */ - case 0x83: - case 0x0b: /* access barred */ - case 0x8b: - case 0x13: /* local procedure error */ - case 0x93: - case 0x05: /* network congestion */ - case 0x85: - case 0x8d: /* not obtainable */ - case 0x0d: - case 0x95: /* RPOA out of order */ - case 0x15: - /* take out bit 8 - * so we don't have to have so many perror entries - */ - error = (CONL_ERROR_MASK | 0x100 | (cause & ~0x80)); - goto done; - - case 0xc1: /* gateway-detected proc error */ - case 0xc3: /* gateway congestion */ - - error = (CONL_ERROR_MASK | 0x100 | cause); - goto done; - } - } + case 0x00: + case 0x80: + /* DTE originated; look at the diagnostic */ + error = (CONL_ERROR_MASK | cause); + goto done; + + case 0x01: /* number busy */ + case 0x81: + case 0x09: /* Out of order */ + case 0x89: + case 0x11: /* Remot Procedure Error */ + case 0x91: + case 0x19: /* reverse charging accept not subscribed */ + case 0x99: + case 0x21: /* Incampat destination */ + case 0xa1: + case 0x29: /* fast select accept not subscribed */ + case 0xa9: + case 0x39: /* ship absent */ + case 0xb9: + case 0x03: /* invalid facil request */ + case 0x83: + case 0x0b: /* access barred */ + case 0x8b: + case 0x13: /* local procedure error */ + case 0x93: + case 0x05: /* network congestion */ + case 0x85: + case 0x8d: /* not obtainable */ + case 0x0d: + case 0x95: /* RPOA out of order */ + case 0x15: + /* + * take out bit 8 so we don't have to have so many + * perror entries + */ + error = (CONL_ERROR_MASK | 0x100 | (cause & ~0x80)); + goto done; + + case 0xc1: /* gateway-detected proc error */ + case 0xc3: /* gateway congestion */ + + error = (CONL_ERROR_MASK | 0x100 | cause); + goto done; + } + } /* otherwise, a *hopefully* valid perror exists in the e_reason field */ error = xp->packet_data; - if (error = 0) { + if (error == 0) { printf("Incoming PKT TYPE 0x%x with reason 0x%x\n", - pk_decode(xp), - cause); + pk_decode(xp), + cause); error = E_CO_HLI_DISCA; - } - + } done: return error; } -#endif /* _KERNEL */ +#endif /* _KERNEL */ /* * NAME: make_partial_x25_packet() @@ -530,9 +540,9 @@ done: * m+1 facil param len (for >2-byte facilities) in octets * m+2..p facil param field * q user data (protocol identification octet) - * * - * RETURNS: + * + * RETURNS: * 0 if OK * E* if failed. * @@ -541,45 +551,45 @@ done: * routine knows where to look for it. */ -#ifdef X25_1984 -int cons_use_facils = 1; +#ifdef X25_1984 +int cons_use_facils = 1; #else /* X25_1984 */ -int cons_use_facils = 0; +int cons_use_facils = 0; #endif /* X25_1984 */ -int cons_use_udata = 1; /* KLUDGE FOR DEBUGGING */ +int cons_use_udata = 1; /* KLUDGE FOR DEBUGGING */ Static int make_partial_x25_packet(isop, lcp) - struct isopcb *isop; - struct pklcd *lcp; + struct isopcb *isop; + struct pklcd *lcp; { - u_int proto; - int flag; - caddr_t buf; - register caddr_t ptr; - register int len = 0; - int buflen =0; - caddr_t facil_len; - int oddness = 0; - struct mbuf *m; - - - IFDEBUG(D_CCONN) + u_int proto = 0; + int flag = 0; + caddr_t buf; + register caddr_t ptr; + register int len = 0; + int buflen = 0; + caddr_t facil_len; + struct mbuf *m = NULL; + + +#ifdef ARGO_DEBUG + if (argo_debug[D_CCONN]) { printf("make_partial_x25_packet(0x%x, 0x%x, 0x%x, 0x%x, 0x%x)\n", - isop->isop_laddr, isop->isop_faddr, proto, m, flag); - ENDDEBUG + isop->isop_laddr, isop->isop_faddr, proto, m, flag); + } +#endif if (cons_use_udata) { if (isop->isop_x25crud_len > 0) { /* * The user specified something. Stick it in */ bcopy(isop->isop_x25crud, lcp->lcd_faddr.x25_udata, - isop->isop_x25crud_len); + isop->isop_x25crud_len); lcp->lcd_faddr.x25_udlen = isop->isop_x25crud_len; } } - if (cons_use_facils == 0) { lcp->lcd_facilities = 0; return 0; @@ -589,46 +599,54 @@ make_partial_x25_packet(isop, lcp) return ENOBUFS; buf = mtod(m, caddr_t); ptr = buf; - + /* ptr now points to facil length (len of whole facil field in OCTETS */ - facil_len = ptr ++; + facil_len = ptr++; m->m_len = 0; pk_build_facilities(m, &lcp->lcd_faddr, 0); - IFDEBUG(D_CADDR) - printf("make_partial calling: ptr 0x%x, len 0x%x\n", ptr, - isop->isop_laddr->siso_addr.isoa_len); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_CADDR]) { + printf("make_partial calling: ptr 0x%x, len 0x%x\n", ptr, + isop->isop_laddr->siso_addr.isoa_len); + } +#endif if (cons_use_facils) { - *ptr++ = 0; /* Marker to separate X.25 facitilies from CCITT ones */ + *ptr++ = 0; /* Marker to separate X.25 facitilies from + * CCITT ones */ *ptr++ = 0x0f; - *ptr = 0xcb; /* calling facility code */ - ptr ++; - ptr ++; /* leave room for facil param len (in OCTETS + 1) */ - ptr ++; /* leave room for the facil param len (in nibbles), - * high two bits of which indicate full/partial NSAP - */ + *ptr = 0xcb; /* calling facility code */ + ptr++; + ptr++; /* leave room for facil param len (in OCTETS + * + 1) */ + ptr++; /* leave room for the facil param len (in + * nibbles), high two bits of which indicate + * full/partial NSAP */ len = isop->isop_laddr->siso_addr.isoa_len; - bcopy( isop->isop_laddr->siso_data, ptr, len); - *(ptr-2) = len+1; /* facil param len in octets */ - *(ptr-1) = len<<1; /* facil param len in nibbles */ + bcopy(isop->isop_laddr->siso_data, ptr, len); + *(ptr - 2) = len + 1; /* facil param len in octets */ + *(ptr - 1) = len << 1; /* facil param len in nibbles */ ptr += len; - IFDEBUG(D_CADDR) - printf("make_partial called: ptr 0x%x, len 0x%x\n", ptr, - isop->isop_faddr->siso_addr.isoa_len); - ENDDEBUG - *ptr = 0xc9; /* called facility code */ - ptr ++; - ptr ++; /* leave room for facil param len (in OCTETS + 1) */ - ptr ++; /* leave room for the facil param len (in nibbles), - * high two bits of which indicate full/partial NSAP - */ +#ifdef ARGO_DEBUG + if (argo_debug[D_CADDR]) { + printf("make_partial called: ptr 0x%x, len 0x%x\n", ptr, + isop->isop_faddr->siso_addr.isoa_len); + } +#endif + *ptr = 0xc9; /* called facility code */ + ptr++; + ptr++; /* leave room for facil param len (in OCTETS + * + 1) */ + ptr++; /* leave room for the facil param len (in + * nibbles), high two bits of which indicate + * full/partial NSAP */ len = isop->isop_faddr->siso_nlen; bcopy(isop->isop_faddr->siso_data, ptr, len); - *(ptr-2) = len+1; /* facil param len = addr len + 1 for each of these - * two length fields, in octets */ - *(ptr-1) = len<<1; /* facil param len in nibbles */ + *(ptr - 2) = len + 1; /* facil param len = addr len + 1 for + * each of these two length fields, + * in octets */ + *(ptr - 1) = len << 1; /* facil param len in nibbles */ ptr += len; } @@ -636,39 +654,43 @@ make_partial_x25_packet(isop, lcp) if (*facil_len > MAX_FACILITIES) return E_CO_PNA_LONG; - buflen = (int)(ptr - buf); + buflen = (int) (ptr - buf); - IFDEBUG(D_CDUMP_REQ) - register int i; +#ifdef ARGO_DEBUG + if (argo_debug[D_CDUMP_REQ]) { + register int i; - printf("ECN_CONNECT DATA buf 0x%x len %d (0x%x)\n", - buf, buflen, buflen); - for( i=0; i < buflen; ) { + printf("ECN_CONNECT DATA buf 0x%x len %d (0x%x)\n", + buf, buflen, buflen); + for (i = 0; i < buflen;) { printf("+%d: %x %x %x %x %x %x %x %x\n", - i, - *(buf+i), *(buf+i+1), *(buf+i+2), *(buf+i+3), - *(buf+i+4), *(buf+i+5), *(buf+i+6), *(buf+i+7)); - i+=8; + i, + *(buf + i), *(buf + i + 1), *(buf + i + 2), *(buf + i + 3), + *(buf + i + 4), *(buf + i + 5), *(buf + i + 6), *(buf + i + 7)); + i += 8; } - ENDDEBUG - IFDEBUG(D_CADDR) - printf("make_partial returns buf 0x%x size 0x%x bytes\n", - mtod(m, caddr_t), buflen); - ENDDEBUG + } +#endif +#ifdef ARGO_DEBUG + if (argo_debug[D_CADDR]) { + printf("make_partial returns buf 0x%x size 0x%x bytes\n", + mtod(m, caddr_t), buflen); + } +#endif if (buflen > MHLEN) return E_CO_PNA_LONG; m->m_pkthdr.len = m->m_len = buflen; lcp->lcd_facilities = m; - return 0; + return 0; } /* * NAME: NSAPtoDTE() * CALLED FROM: * make_partial_x25_packet() - * FUNCTION and ARGUMENTS: + * FUNCTION and ARGUMENTS: * get a DTE address from an NSAP-address (struct sockaddr_iso) * (dst_octet) is the octet into which to begin stashing the DTE addr * (dst_nibble) takes 0 or 1. 1 means begin filling in the DTE addr @@ -694,19 +716,22 @@ NSAPtoDTE(siso, sx25) register struct sockaddr_iso *siso; register struct sockaddr_x25 *sx25; { - int dtelen = -1; + int dtelen = -1; - IFDEBUG(D_CADDR) - printf("NSAPtoDTE: nsap: %s\n", clnp_iso_addrp(&siso->siso_addr)); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_CADDR]) { + printf("NSAPtoDTE: nsap: %s\n", + clnp_iso_addrp(&siso->siso_addr)); + } +#endif if (siso->siso_data[0] == AFI_37) { - register char *out = sx25->x25_addr; - register char *in = siso->siso_data + 1; - register int nibble; - char *lim = siso->siso_data + siso->siso_nlen; - char *olim = out+15; - int lowNibble = 0; + register char *out = sx25->x25_addr; + register char *in = siso->siso_data + 1; + register int nibble; + char *lim = siso->siso_data + siso->siso_nlen; + char *olim = out + 15; + int lowNibble = 0; while (in < lim) { nibble = ((lowNibble ? *in++ : (*in >> 4)) & 0xf) | 0x30; @@ -717,23 +742,27 @@ NSAPtoDTE(siso, sx25) dtelen = out - sx25->x25_addr; *out++ = 0; } else { - /* error = iso_8208snparesolve(addr, x121string, &x121strlen);*/ + /* + * error = iso_8208snparesolve(addr, x121string, + * &x121strlen); + */ register struct rtentry *rt; extern struct sockaddr_iso blank_siso; struct sockaddr_iso nsiso; nsiso = blank_siso; bcopy(nsiso.siso_data, siso->siso_data, - nsiso.siso_nlen = siso->siso_nlen); - if (rt = rtalloc1(&nsiso, 1)) { + nsiso.siso_nlen = siso->siso_nlen); + if ((rt = rtalloc1((struct sockaddr *) &nsiso, 1)) != NULL) { register struct sockaddr_x25 *sxx = - (struct sockaddr_x25 *)rt->rt_gateway; - register char *in = sxx->x25_addr; + (struct sockaddr_x25 *) rt->rt_gateway; + register char *in = sxx->x25_addr; rt->rt_use--; if (sxx && sxx->x25_family == AF_CCITT) { bcopy(sx25->x25_addr, sxx->x25_addr, sizeof(sx25->x25_addr)); - while (*in++) {} + while (*in++) { + } dtelen = in - sxx->x25_addr; } } @@ -754,47 +783,52 @@ NSAPtoDTE(siso, sx25) Static int FACILtoNSAP(addr, buf) - register u_char *buf; + register u_char *buf; register struct sockaddr_iso *addr; { - int len_in_nibbles = *++buf & 0x3f; - u_char buf_len = (len_in_nibbles + 1) >> 1;; /* in bytes */ + int len_in_nibbles = *++buf & 0x3f; + u_char buf_len = (len_in_nibbles + 1) >> 1;; /* in bytes */ - IFDEBUG(D_CADDR) - printf("FACILtoNSAP( 0x%x, 0x%x, 0x%x )\n", - buf, buf_len, addr ); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_CADDR]) { + printf("FACILtoNSAP( 0x%x, 0x%x, 0x%x )\n", + buf, buf_len, addr); + } +#endif len_in_nibbles = *buf & 0x3f; - /* despite the fact that X.25 makes us put a length in nibbles - * here, the NSAP-addrs are always in full octets + /* + * despite the fact that X.25 makes us put a length in nibbles here, + * the NSAP-addrs are always in full octets */ switch (*buf++ & 0xc0) { case 0: /* Entire OSI NSAP address */ - bcopy((caddr_t)buf, addr->siso_data, addr->siso_nlen = buf_len); + bcopy((caddr_t) buf, addr->siso_data, addr->siso_nlen = buf_len); break; case 40: /* Partial OSI NSAP address, assume trailing */ if (buf_len + addr->siso_nlen > sizeof(addr->siso_addr)) return -1; - bcopy((caddr_t)buf, TSEL(addr), buf_len); + bcopy((caddr_t) buf, TSEL(addr), buf_len); addr->siso_nlen += buf_len; break; default: - /* Rather than blow away the connection, just ignore and use - NSAP from DTE */; + /* + * Rather than blow away the connection, just ignore and use + * NSAP from DTE + */ ; } return 0; } -Static +Static void init_siso(siso) -register struct sockaddr_iso *siso; + register struct sockaddr_iso *siso; { - siso->siso_len = sizeof (*siso); + siso->siso_len = sizeof(*siso); siso->siso_family = AF_ISO; siso->siso_data[0] = AFI_37; siso->siso_nlen = 8; @@ -807,20 +841,20 @@ register struct sockaddr_iso *siso; * FUNCTION and ARGUMENTS: * Creates a type 37 NSAP in the sockaddr_iso (addr) * from a DTE address found in a sockaddr_x25. - * + * * RETURNS: * 0 if ok; E* otherwise. */ -Static int +Static int DTEtoNSAP(addr, sx) struct sockaddr_iso *addr; struct sockaddr_x25 *sx; { - register char *in, *out; - register int first; - int pad_tail = 0; - int src_len; + register char *in, *out; + register int first; + int pad_tail = 0; + int src_len; init_siso(addr); @@ -838,12 +872,12 @@ DTEtoNSAP(addr, sx) if (src_len & 1) { *out++ = first; first = 0; - } - else first <<= 4; + } else + first <<= 4; } if (pad_tail) out[-1] |= 0xf; - return 0; /* ok */ + return 0; /* ok */ } /* @@ -856,106 +890,122 @@ DTEtoNSAP(addr, sx) Static int parse_facil(lcp, isop, buf, buf_len) - caddr_t buf; - u_char buf_len; /* in bytes */ - struct isopcb *isop; - struct pklcd *lcp; + caddr_t buf; + u_char buf_len;/* in bytes */ + struct isopcb *isop; + struct pklcd *lcp; { - register int i; - register u_char *ptr = (u_char *)buf; - u_char *ptr_lim, *facil_lim; - int facil_param_len, facil_len; - - IFDEBUG(D_CADDR) - printf("parse_facil(0x%x, 0x%x, 0x%x, 0x%x)\n", - lcp, isop, buf, buf_len); + register int i; + register u_char *ptr = (u_char *) buf; + u_char *facil_lim; + int facil_param_len = 0, facil_len; + +#ifdef ARGO_DEBUG + if (argo_debug[D_CADDR]) { + printf("parse_facil(0x%x, 0x%x, 0x%x, 0x%x)\n", + lcp, isop, buf, buf_len); dump_buf(buf, buf_len); - ENDDEBUG + } +#endif - /* find the beginnings of the facility fields in buf - * by skipping over the called & calling DTE addresses - * i <- # nibbles in called + # nibbles in calling - * i += 1 so that an odd nibble gets rounded up to even - * before dividing by 2, then divide by two to get # octets + /* + * find the beginnings of the facility fields in buf by skipping over + * the called & calling DTE addresses i <- # nibbles in called + # + * nibbles in calling i += 1 so that an odd nibble gets rounded up to + * even before dividing by 2, then divide by two to get # octets */ - i = (int)(*ptr >> 4) + (int)(*ptr&0xf); + i = (int) (*ptr >> 4) + (int) (*ptr & 0xf); i++; ptr += i >> 1; - ptr ++; /* plus one for the DTE lengths byte */ + ptr++; /* plus one for the DTE lengths byte */ /* ptr now is at facil_length field */ facil_len = *ptr++; facil_lim = ptr + facil_len; - IFDEBUG(D_CADDR) +#ifdef ARGO_DEBUG + if (argo_debug[D_CADDR]) { printf("parse_facils: facil length is 0x%x\n", (int) facil_len); - ENDDEBUG + } +#endif while (ptr < facil_lim) { /* get NSAP addresses from facilities */ switch (*ptr++) { - case 0xcb: - /* calling NSAP */ - facil_param_len = FACILtoNSAP(isop->isop_faddr, ptr); - break; - case 0xc9: - /* called NSAP */ - facil_param_len = FACILtoNSAP(isop->isop_laddr, ptr); - break; + case 0xcb: + /* calling NSAP */ + facil_param_len = FACILtoNSAP(isop->isop_faddr, ptr); + break; + case 0xc9: + /* called NSAP */ + facil_param_len = FACILtoNSAP(isop->isop_laddr, ptr); + break; - /* from here to default are legit cases that I ignore */ - /* variable length */ - case 0xca: /* end-to-end transit delay negot */ - case 0xc6: /* network user id */ - case 0xc5: /* charging info : indicating monetary unit */ - case 0xc2: /* charging info : indicating segment count */ - case 0xc1: /* charging info : indicating call duration */ - case 0xc4: /* RPOA extended format */ - case 0xc3: /* call redirection notification */ - facil_param_len = 0; - break; + /* from here to default are legit cases that I ignore */ + /* variable length */ + case 0xca: /* end-to-end transit delay negot */ + case 0xc6: /* network user id */ + case 0xc5: /* charging info : indicating monetary unit */ + case 0xc2: /* charging info : indicating segment count */ + case 0xc1: /* charging info : indicating call duration */ + case 0xc4: /* RPOA extended format */ + case 0xc3: /* call redirection notification */ + facil_param_len = 0; + break; + + /* 1 octet */ + case 0x0a: /* min. throughput class negot */ + case 0x02: /* throughput class */ + case 0x03: + case 0x47: /* CUG shit */ + case 0x0b: /* expedited data negot */ + case 0x01: /* Fast select or reverse charging (example + * of intelligent protocol design) */ + case 0x04: /* charging info : requesting service */ + case 0x08: /* called line addr modified notification */ + case 0x00: /* marker to indicate beginning of CCITT + * facils */ + facil_param_len = 1; + break; - /* 1 octet */ - case 0x0a: /* min. throughput class negot */ - case 0x02: /* throughput class */ - case 0x03: case 0x47: /* CUG shit */ - case 0x0b: /* expedited data negot */ - case 0x01: /* Fast select or reverse charging - (example of intelligent protocol design) */ - case 0x04: /* charging info : requesting service */ - case 0x08: /* called line addr modified notification */ - case 0x00: /* marker to indicate beginning of CCITT facils */ + /* any 2 octets */ + case 0x42: /* pkt size */ + case 0x43: /* win size */ + case 0x44: /* RPOA basic format */ + case 0x41: /* bilateral CUG shit */ + case 0x49: /* transit delay selection and indication */ + facil_param_len = 2; + break; + + default: + printf( + "BOGUS FACILITY CODE facil_lim 0x%x facil_len %d, ptr 0x%x *ptr 0x%x\n", + facil_lim, facil_len, ptr - 1, ptr[-1]); + /* + * facil that we don't handle return E_CO_HLI_REJI; + */ + switch (ptr[-1] & 0xc0) { + case 0x00: facil_param_len = 1; break; - - /* any 2 octets */ - case 0x42: /* pkt size */ - case 0x43: /* win size */ - case 0x44: /* RPOA basic format */ - case 0x41: /* bilateral CUG shit */ - case 0x49: /* transit delay selection and indication */ + case 0x40: facil_param_len = 2; break; - - default: - printf( -"BOGUS FACILITY CODE facil_lim 0x%x facil_len %d, ptr 0x%x *ptr 0x%x\n", - facil_lim, facil_len, ptr - 1, ptr[-1]); - /* facil that we don't handle - return E_CO_HLI_REJI; */ - switch (ptr[-1] & 0xc0) { - case 0x00: facil_param_len = 1; break; - case 0x40: facil_param_len = 2; break; - case 0x80: facil_param_len = 3; break; - case 0xc0: facil_param_len = 0; break; - } + case 0x80: + facil_param_len = 3; + break; + case 0xc0: + facil_param_len = 0; + break; + } } if (facil_param_len == -1) return E_CO_REG_ICDA; - if (facil_param_len == 0) /* variable length */ - facil_param_len = (int)*ptr++; /* 1 + the real facil param */ + if (facil_param_len == 0) /* variable length */ + facil_param_len = (int) *ptr++; /* 1 + the real facil + * param */ ptr += facil_param_len; } return 0; } -#endif /* TPCONS */ +#endif /* TPCONS */ diff --git a/sys/netiso/if_eon.c b/sys/netiso/if_eon.c index 926cfec802f..5916cf62e99 100644 --- a/sys/netiso/if_eon.c +++ b/sys/netiso/if_eon.c @@ -1,4 +1,5 @@ -/* $NetBSD: if_eon.c,v 1.11 1995/06/13 07:13:28 mycroft Exp $ */ +/* $OpenBSD: if_eon.c,v 1.2 1996/03/04 10:35:24 mickey Exp $ */ +/* $NetBSD: if_eon.c,v 1.12 1996/02/13 22:09:50 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -62,7 +63,7 @@ SOFTWARE. * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ /* - * EON rfc + * EON rfc * Layer between IP and CLNL * * TODO: @@ -104,19 +105,18 @@ SOFTWARE. #include <netiso/iso_errno.h> #include <netiso/eonvar.h> +#include <machine/stdarg.h> + extern struct timeval time; extern struct ifnet loif; #define EOK 0 -int eoninput(); -int eonoutput(); -int eonioctl(); -int eonattach(); -void eonrtrequest(); -struct ifnet eonif[1]; +struct ifnet eonif[1]; -eonprotoinit() { +void +eonprotoinit() +{ (void) eonattach(); } @@ -132,17 +132,20 @@ struct eon_llinfo eon_llinfo; * RETURNS: void */ +void eonattach() { register struct ifnet *ifp = eonif; - IFDEBUG(D_EON) +#ifdef ARGO_DEBUG + if (argo_debug[D_EON]) { printf("eonattach()\n"); - ENDDEBUG + } +#endif ifp->if_unit = 0; ifp->if_name = "eon"; - ifp->if_mtu = ETHERMTU; - /* since everything will go out over ether or token ring */ + ifp->if_mtu = ETHERMTU; + /* since everything will go out over ether or token ring */ ifp->if_ioctl = eonioctl; ifp->if_output = eonoutput; @@ -151,13 +154,15 @@ eonattach() ifp->if_hdrlen = EONIPLEN; ifp->if_flags = IFF_BROADCAST; if_attach(ifp); - eonioctl(ifp, SIOCSIFADDR, (caddr_t)ifp->if_addrlist.tqh_first); - eon_llinfo.el_qhdr.link = + eonioctl(ifp, SIOCSIFADDR, (caddr_t) ifp->if_addrlist.tqh_first); + eon_llinfo.el_qhdr.link = eon_llinfo.el_qhdr.rlink = &(eon_llinfo.el_qhdr); - IFDEBUG(D_EON) +#ifdef ARGO_DEBUG + if (argo_debug[D_EON]) { printf("eonattach()\n"); - ENDDEBUG + } +#endif } @@ -165,30 +170,33 @@ eonattach() * FUNCTION: eonioctl * * PURPOSE: io controls - ifconfig - * need commands to + * need commands to * link-UP (core addr) (flags: ES, IS) * link-DOWN (core addr) (flags: ES, IS) * must be callable from kernel or user * * RETURNS: nothing */ +int eonioctl(ifp, cmd, data) register struct ifnet *ifp; - u_long cmd; + u_long cmd; register caddr_t data; { - int s = splimp(); - register int error = 0; + int s = splimp(); + register int error = 0; - IFDEBUG(D_EON) +#ifdef ARGO_DEBUG + if (argo_debug[D_EON]) { printf("eonioctl (cmd 0x%lx) \n", cmd); - ENDDEBUG + } +#endif switch (cmd) { register struct ifaddr *ifa; case SIOCSIFADDR: - if (ifa = (struct ifaddr *)data) { + if ((ifa = (struct ifaddr *) data) != NULL) { ifp->if_flags |= IFF_UP; if (ifa->ifa_addr->sa_family != AF_LINK) ifa->ifa_rtrequest = eonrtrequest; @@ -196,24 +204,26 @@ eonioctl(ifp, cmd, data) break; } splx(s); - return(error); + return (error); } +void eoniphdr(hdr, loc, ro, class, zero) -struct route *ro; -register struct eon_iphdr *hdr; -caddr_t loc; + struct route *ro; + register struct eon_iphdr *hdr; + caddr_t loc; + int class, zero; { - struct mbuf mhead; + struct mbuf mhead; register struct sockaddr_in *sin = satosin(&ro->ro_dst); if (zero) { - bzero((caddr_t)hdr, sizeof (*hdr)); - bzero((caddr_t)ro, sizeof (*ro)); + bzero((caddr_t) hdr, sizeof(*hdr)); + bzero((caddr_t) ro, sizeof(*ro)); } sin->sin_family = AF_INET; - sin->sin_len = sizeof (*sin); - bcopy(loc, (caddr_t)&sin->sin_addr, sizeof(struct in_addr)); + sin->sin_len = sizeof(*sin); + bcopy(loc, (caddr_t) & sin->sin_addr, sizeof(struct in_addr)); /* * If there is a cached route, * check that it is to the same destination @@ -222,9 +232,9 @@ caddr_t loc; if (ro->ro_rt) { struct sockaddr_in *dst = satosin(rt_key(ro->ro_rt)); if ((ro->ro_rt->rt_flags & RTF_UP) == 0 || - sin->sin_addr.s_addr != dst->sin_addr.s_addr) { + sin->sin_addr.s_addr != dst->sin_addr.s_addr) { RTFREE(ro->ro_rt); - ro->ro_rt = (struct rtentry *)0; + ro->ro_rt = (struct rtentry *) 0; } } rtalloc(ro); @@ -232,20 +242,22 @@ caddr_t loc; ro->ro_rt->rt_use++; hdr->ei_ip.ip_dst = sin->sin_addr; hdr->ei_ip.ip_p = IPPROTO_EON; - hdr->ei_ip.ip_ttl = MAXTTL; + hdr->ei_ip.ip_ttl = MAXTTL; hdr->ei_eh.eonh_class = class; hdr->ei_eh.eonh_vers = EON_VERSION; hdr->ei_eh.eonh_csum = 0; - mhead.m_data = (caddr_t) &hdr->ei_eh; + mhead.m_data = (caddr_t) & hdr->ei_eh; mhead.m_len = sizeof(struct eon_hdr); mhead.m_next = 0; - IFDEBUG(D_EON) - printf("eonoutput : gen csum (0x%x, offset %d, datalen %d)\n", - &mhead, - _offsetof(struct eon_hdr, eonh_csum), sizeof(struct eon_hdr)); - ENDDEBUG - iso_gen_csum(&mhead, - _offsetof(struct eon_hdr, eonh_csum), sizeof(struct eon_hdr)); +#ifdef ARGO_DEBUG + if (argo_debug[D_EON]) { + printf("eonoutput : gen csum (0x%x, offset %d, datalen %d)\n", + (unsigned int) &mhead, + _offsetof(struct eon_hdr, eonh_csum), sizeof(struct eon_hdr)); + } +#endif + iso_gen_csum(&mhead, + _offsetof(struct eon_hdr, eonh_csum), sizeof(struct eon_hdr)); } /* * FUNCTION: eonrtrequest @@ -257,12 +269,13 @@ caddr_t loc; */ void eonrtrequest(cmd, rt, gate) -register struct rtentry *rt; -register struct sockaddr *gate; + int cmd; + register struct rtentry *rt; + register struct sockaddr *gate; { - unsigned long zerodst = 0; - caddr_t ipaddrloc = (caddr_t) &zerodst; - register struct eon_llinfo *el = (struct eon_llinfo *)rt->rt_llinfo; + unsigned long zerodst = 0; + caddr_t ipaddrloc = (caddr_t) & zerodst; + register struct eon_llinfo *el = (struct eon_llinfo *) rt->rt_llinfo; /* * Common Housekeeping @@ -280,9 +293,9 @@ register struct sockaddr *gate; case RTM_ADD: case RTM_RESOLVE: - rt->rt_rmx.rmx_mtu = loif.if_mtu; /* unless better below */ + rt->rt_rmx.rmx_mtu = loif.if_mtu; /* unless better below */ R_Malloc(el, struct eon_llinfo *, sizeof(*el)); - rt->rt_llinfo = (caddr_t)el; + rt->rt_llinfo = (caddr_t) el; if (el == 0) return; Bzero(el, sizeof(*el)); @@ -290,76 +303,82 @@ register struct sockaddr *gate; el->el_rt = rt; break; } - if (gate || (gate = rt->rt_gateway)) switch (gate->sa_family) { + if (gate || (gate = rt->rt_gateway)) + switch (gate->sa_family) { case AF_LINK: #define SDL(x) ((struct sockaddr_dl *)x) if (SDL(gate)->sdl_alen == 1) - el->el_snpaoffset = *(u_char *)LLADDR(SDL(gate)); + el->el_snpaoffset = *(u_char *) LLADDR(SDL(gate)); else ipaddrloc = LLADDR(SDL(gate)); break; case AF_INET: - ipaddrloc = (caddr_t) &satosin(gate)->sin_addr; + ipaddrloc = (caddr_t) & satosin(gate)->sin_addr; break; default: return; - } + } el->el_flags |= RTF_UP; eoniphdr(&el->el_ei, ipaddrloc, &el->el_iproute, EON_NORMAL_ADDR, 0); if (el->el_iproute.ro_rt) rt->rt_rmx.rmx_mtu = el->el_iproute.ro_rt->rt_rmx.rmx_mtu - - sizeof(el->el_ei); + - sizeof(el->el_ei); } /* * FUNCTION: eonoutput * - * PURPOSE: prepend an eon header and hand to IP - * ARGUMENTS: (ifp) is points to the ifnet structure for this unit/device - * (m) is an mbuf *, *m is a CLNL packet - * (dst) is a destination address - have to interp. as - * multicast or broadcast or real address. + * PURPOSE: prepend an eon header and hand to IP + * ARGUMENTS: (ifp) is points to the ifnet structure for this + * unit/device (m) is an mbuf *, *m is a CLNL packet + * (dst) is a destination address - have to interp. as + * multicast or broadcast or real address. * - * RETURNS: unix error code + * RETURNS: unix error code * - * NOTES: + * NOTES: * */ -eonoutput(ifp, m, dst, rt) - struct ifnet *ifp; - register struct mbuf *m; /* packet */ - struct sockaddr_iso *dst; /* destination addr */ +int +eonoutput(ifp, m, sdst, rt) + struct ifnet *ifp; + register struct mbuf *m; /* packet */ + struct sockaddr *sdst; /* destination addr */ struct rtentry *rt; { + struct sockaddr_iso *dst = (struct sockaddr_iso *) sdst; register struct eon_llinfo *el; register struct eon_iphdr *ei; - struct route *ro; - int datalen; - struct mbuf *mh; - int error = 0, class = 0, alen = 0; - caddr_t ipaddrloc; + struct route *ro; + int datalen; + struct mbuf *mh; + int error = 0, class = 0, alen = 0; + caddr_t ipaddrloc = NULL; static struct eon_iphdr eon_iphdr; static struct route route; - IFDEBUG(D_EON) - printf("eonoutput \n" ); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_EON]) { + printf("eonoutput \n"); + } +#endif ifp->if_lastchange = time; ifp->if_opackets++; - if (rt == 0 || (el = (struct eon_llinfo *)rt->rt_llinfo) == 0) { + if (rt == 0 || (el = (struct eon_llinfo *) rt->rt_llinfo) == 0) { if (dst->siso_family == AF_LINK) { - register struct sockaddr_dl *sdl = (struct sockaddr_dl *)dst; + register struct sockaddr_dl *sdl = (struct sockaddr_dl *) dst; ipaddrloc = LLADDR(sdl); alen = sdl->sdl_alen; - } else if (dst->siso_family == AF_ISO && dst->siso_data[0] == AFI_SNA) { + } else if (dst->siso_family == AF_ISO && + dst->siso_data[0] == AFI_SNA) { alen = dst->siso_nlen - 1; ipaddrloc = (caddr_t) dst->siso_data + 1; } switch (alen) { case 5: - class = 4[(u_char *)ipaddrloc]; + class = 4[(u_char *) ipaddrloc]; case 4: ro = &route; ei = &eon_iphdr; @@ -367,11 +386,11 @@ eonoutput(ifp, m, dst, rt) goto send; } einval: - error = EINVAL; + error = EINVAL; goto flush; } if ((el->el_flags & RTF_UP) == 0) { - eonrtrequest(RTM_CHANGE, rt, (struct sockaddr *)0); + eonrtrequest(RTM_CHANGE, rt, (struct sockaddr *) 0); if ((el->el_flags & RTF_UP) == 0) { error = EHOSTUNREACH; goto flush; @@ -385,8 +404,8 @@ einval: ro = &el->el_iproute; if (el->el_snpaoffset) { if (dst->siso_family == AF_ISO) { - bcopy((caddr_t) &dst->siso_data[el->el_snpaoffset], - (caddr_t) &ei->ei_ip.ip_dst, sizeof(ei->ei_ip.ip_dst)); + bcopy((caddr_t) & dst->siso_data[el->el_snpaoffset], + (caddr_t) & ei->ei_ip.ip_dst, sizeof(ei->ei_ip.ip_dst)); } else goto einval; } @@ -394,23 +413,25 @@ send: /* put an eon_hdr in the buffer, prepended by an ip header */ datalen = m->m_pkthdr.len + EONIPLEN; MGETHDR(mh, M_DONTWAIT, MT_HEADER); - if(mh == (struct mbuf *)0) + if (mh == (struct mbuf *) 0) goto flush; mh->m_next = m; m = mh; MH_ALIGN(m, sizeof(struct eon_iphdr)); m->m_len = sizeof(struct eon_iphdr); ifp->if_obytes += - (ei->ei_ip.ip_len = (u_short)(m->m_pkthdr.len = datalen)); + (ei->ei_ip.ip_len = (u_short) (m->m_pkthdr.len = datalen)); *mtod(m, struct eon_iphdr *) = *ei; - IFDEBUG(D_EON) - printf("eonoutput dst ip addr : %x\n", ei->ei_ip.ip_dst.s_addr); +#ifdef ARGO_DEBUG + if (argo_debug[D_EON]) { + printf("eonoutput dst ip addr : %x\n", ei->ei_ip.ip_dst.s_addr); printf("eonoutput ip_output : eonip header:\n"); dump_buf(ei, sizeof(struct eon_iphdr)); - ENDDEBUG + } +#endif - error = ip_output(m, (struct mbuf *)0, ro, 0, NULL); + error = ip_output(m, (struct mbuf *) 0, ro, 0, NULL); m = 0; if (error) { ifp->if_oerrors++; @@ -423,36 +444,51 @@ flush: return error; } -eoninput(m, iphlen) - register struct mbuf *m; - int iphlen; +void +#if __STDC__ +eoninput(struct mbuf *m, ...) +#else +eoninput(m, va_alist) + struct mbuf *m; + va_dcl +#endif { - register struct eon_hdr *eonhdr; - register struct ip *iphdr; - struct ifnet *eonifp; - int s; - - eonifp = &eonif[0]; /* kludge - really want to give CLNP - * the ifp for eon, not for the real device - */ - - IFDEBUG(D_EON) + int iphlen; + register struct eon_hdr *eonhdr; + register struct ip *iphdr; + struct ifnet *eonifp; + int s; + va_list ap; + + va_start(ap, m); + iphlen = va_arg(ap, int); + va_end(ap); + + eonifp = &eonif[0]; /* kludge - really want to give CLNP the ifp + * for eon, not for the real device */ + +#ifdef ARGO_DEBUG + if (argo_debug[D_EON]) { printf("eoninput() 0x%x m_data 0x%x m_len 0x%x dequeued\n", - m, m?m->m_data:0, m?m->m_len:0); - ENDDEBUG + (unsigned int) m, + (unsigned int) (m ? m->m_data : 0), m ? m->m_len : 0); + } +#endif if (m == 0) return; - if (iphlen > sizeof (struct ip)) - ip_stripoptions(m, (struct mbuf *)0); + if (iphlen > sizeof(struct ip)) + ip_stripoptions(m, (struct mbuf *) 0); if (m->m_len < EONIPLEN) { if ((m = m_pullup(m, EONIPLEN)) == 0) { IncStat(es_badhdr); -drop: - IFDEBUG(D_EON) - printf("eoninput: DROP \n" ); - ENDDEBUG - eonifp->if_ierrors ++; + drop: +#ifdef ARGO_DEBUG + if (argo_debug[D_EON]) { + printf("eoninput: DROP \n"); + } +#endif + eonifp->if_ierrors++; m_freem(m); return; } @@ -461,59 +497,63 @@ drop: eonif->if_lastchange = time; iphdr = mtod(m, struct ip *); /* do a few checks for debugging */ - if( iphdr->ip_p != IPPROTO_EON ) { + if (iphdr->ip_p != IPPROTO_EON) { IncStat(es_badhdr); goto drop; } /* temporarily drop ip header from the mbuf */ m->m_data += sizeof(struct ip); eonhdr = mtod(m, struct eon_hdr *); - if( iso_check_csum( m, sizeof(struct eon_hdr) ) != EOK ) { + if (iso_check_csum(m, sizeof(struct eon_hdr)) != EOK) { IncStat(es_badcsum); goto drop; } m->m_data -= sizeof(struct ip); - - IFDEBUG(D_EON) - printf("eoninput csum ok class 0x%x\n", eonhdr->eonh_class ); + +#ifdef ARGO_DEBUG + if (argo_debug[D_EON]) { + printf("eoninput csum ok class 0x%x\n", eonhdr->eonh_class); printf("eoninput: eon header:\n"); dump_buf(eonhdr, sizeof(struct eon_hdr)); - ENDDEBUG + } +#endif /* checks for debugging */ - if( eonhdr->eonh_vers != EON_VERSION) { + if (eonhdr->eonh_vers != EON_VERSION) { IncStat(es_badhdr); goto drop; } - m->m_flags &= ~(M_BCAST|M_MCAST); - switch( eonhdr->eonh_class) { - case EON_BROADCAST: - IncStat(es_in_broad); - m->m_flags |= M_BCAST; - break; - case EON_NORMAL_ADDR: - IncStat(es_in_normal); - break; - case EON_MULTICAST_ES: - IncStat(es_in_multi_es); - m->m_flags |= M_MCAST; - break; - case EON_MULTICAST_IS: - IncStat(es_in_multi_is); - m->m_flags |= M_MCAST; - break; + m->m_flags &= ~(M_BCAST | M_MCAST); + switch (eonhdr->eonh_class) { + case EON_BROADCAST: + IncStat(es_in_broad); + m->m_flags |= M_BCAST; + break; + case EON_NORMAL_ADDR: + IncStat(es_in_normal); + break; + case EON_MULTICAST_ES: + IncStat(es_in_multi_es); + m->m_flags |= M_MCAST; + break; + case EON_MULTICAST_IS: + IncStat(es_in_multi_is); + m->m_flags |= M_MCAST; + break; } eonifp->if_ipackets++; { /* put it on the CLNP queue and set soft interrupt */ - struct ifqueue *ifq; - extern struct ifqueue clnlintrq; + struct ifqueue *ifq; + extern struct ifqueue clnlintrq; - m->m_pkthdr.rcvif = eonifp; /* KLUDGE */ - IFDEBUG(D_EON) + m->m_pkthdr.rcvif = eonifp; /* KLUDGE */ +#ifdef ARGO_DEBUG + if (argo_debug[D_EON]) { printf("eoninput to clnl IFQ\n"); - ENDDEBUG + } +#endif ifq = &clnlintrq; s = splimp(); if (IF_QFULL(ifq)) { @@ -525,64 +565,69 @@ drop: return; } IF_ENQUEUE(ifq, m); - IFDEBUG(D_EON) +#ifdef ARGO_DEBUG + if (argo_debug[D_EON]) { printf( - "0x%x enqueued on clnp Q: m_len 0x%x m_type 0x%x m_data 0x%x\n", - m, m->m_len, m->m_type, m->m_data); + "0x%x enqueued on clnp Q: m_len 0x%x m_type 0x%x m_data 0x%x\n", + (unsigned int) m, m->m_len, m->m_type, + (unsigned int) m->m_data); dump_buf(mtod(m, caddr_t), m->m_len); - ENDDEBUG + } +#endif schednetisr(NETISR_ISO); splx(s); } } -int -eonctlinput(cmd, sin) - int cmd; - struct sockaddr_in *sin; +void * +eonctlinput(cmd, sa, dummy) + int cmd; + struct sockaddr *sa; + void *dummy; { - extern u_char inetctlerrmap[]; - - IFDEBUG(D_EON) + struct sockaddr_in *sin = (struct sockaddr_in *) sa; +#ifdef ARGO_DEBUG + if (argo_debug[D_EON]) { printf("eonctlinput: cmd 0x%x addr: ", cmd); - dump_isoaddr(sin); + dump_isoaddr((struct sockaddr_iso *) sin); printf("\n"); - ENDDEBUG + } +#endif if (cmd < 0 || cmd > PRC_NCMDS) - return 0; + return NULL; IncStat(es_icmp[cmd]); switch (cmd) { - case PRC_QUENCH: - case PRC_QUENCH2: - /* TODO: set the dec bit */ - break; - case PRC_TIMXCEED_REASS: - case PRC_ROUTEDEAD: - case PRC_HOSTUNREACH: - case PRC_UNREACH_NET: - case PRC_IFDOWN: - case PRC_UNREACH_HOST: - case PRC_HOSTDEAD: - case PRC_TIMXCEED_INTRANS: - /* TODO: mark the link down */ - break; + case PRC_QUENCH: + case PRC_QUENCH2: + /* TODO: set the dec bit */ + break; + case PRC_TIMXCEED_REASS: + case PRC_ROUTEDEAD: + case PRC_HOSTUNREACH: + case PRC_UNREACH_NET: + case PRC_IFDOWN: + case PRC_UNREACH_HOST: + case PRC_HOSTDEAD: + case PRC_TIMXCEED_INTRANS: + /* TODO: mark the link down */ + break; - case PRC_UNREACH_PROTOCOL: - case PRC_UNREACH_PORT: - case PRC_UNREACH_SRCFAIL: - case PRC_REDIRECT_NET: - case PRC_REDIRECT_HOST: - case PRC_REDIRECT_TOSNET: - case PRC_REDIRECT_TOSHOST: - case PRC_MSGSIZE: - case PRC_PARAMPROB: - /* printf("eonctlinput: ICMP cmd 0x%x\n", cmd );*/ + case PRC_UNREACH_PROTOCOL: + case PRC_UNREACH_PORT: + case PRC_UNREACH_SRCFAIL: + case PRC_REDIRECT_NET: + case PRC_REDIRECT_HOST: + case PRC_REDIRECT_TOSNET: + case PRC_REDIRECT_TOSHOST: + case PRC_MSGSIZE: + case PRC_PARAMPROB: + /* printf("eonctlinput: ICMP cmd 0x%x\n", cmd ); */ break; } - return 0; + return NULL; } #endif diff --git a/sys/netiso/iso.c b/sys/netiso/iso.c index 8b1a656fd6b..dce15a0fb2b 100644 --- a/sys/netiso/iso.c +++ b/sys/netiso/iso.c @@ -1,4 +1,5 @@ -/* $NetBSD: iso.c,v 1.12 1995/06/13 07:13:29 mycroft Exp $ */ +/* $OpenBSD: iso.c,v 1.2 1996/03/04 10:35:26 mickey Exp $ */ +/* $NetBSD: iso.c,v 1.13 1996/02/13 22:09:54 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -90,119 +91,128 @@ SOFTWARE. #ifdef ISO -int iso_interfaces = 0; /* number of external interfaces */ -int ether_output(); -void llc_rtrequest(); +int iso_interfaces = 0; /* number of external interfaces */ /* * FUNCTION: iso_addrmatch1 * - * PURPOSE: decide if the two iso_addrs passed are equal + * PURPOSE: decide if the two iso_addrs passed are equal * - * RETURNS: true if the addrs match, false if they do not + * RETURNS: true if the addrs match, false if they do not * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ +int iso_addrmatch1(isoaa, isoab) -register struct iso_addr *isoaa, *isoab; /* addresses to check */ + register struct iso_addr *isoaa, *isoab; /* addresses to check */ { - u_int compare_len; + u_int compare_len; - IFDEBUG(D_ROUTE) +#ifdef ARGO_DEBUG + if (argo_debug[D_ROUTE]) { printf("iso_addrmatch1: comparing lengths: %d to %d\n", isoaa->isoa_len, - isoab->isoa_len); + isoab->isoa_len); printf("a:\n"); dump_buf(isoaa->isoa_genaddr, isoaa->isoa_len); printf("b:\n"); dump_buf(isoab->isoa_genaddr, isoab->isoa_len); - ENDDEBUG + } +#endif if ((compare_len = isoaa->isoa_len) != isoab->isoa_len) { - IFDEBUG(D_ROUTE) +#ifdef ARGO_DEBUG + if (argo_debug[D_ROUTE]) { printf("iso_addrmatch1: returning false because of lengths\n"); - ENDDEBUG + } +#endif return 0; } - #ifdef notdef /* TODO : generalize this to all afis with masks */ - if( isoaa->isoa_afi == AFI_37 ) { - /* must not compare 2 least significant digits, or for - * that matter, the DSP + if (isoaa->isoa_afi == AFI_37) { + /* + * must not compare 2 least significant digits, or for that + * matter, the DSP */ - compare_len = ADDR37_IDI_LEN - 1; + compare_len = ADDR37_IDI_LEN - 1; } #endif - IFDEBUG(D_ROUTE) - int i; - char *a, *b; +#ifdef ARGO_DEBUG + if (argo_debug[D_ROUTE]) { + int i; + char *a, *b; a = isoaa->isoa_genaddr; b = isoab->isoa_genaddr; - for (i=0; i<compare_len; i++) { - printf("<%x=%x>", a[i]&0xff, b[i]&0xff); + for (i = 0; i < compare_len; i++) { + printf("<%x=%x>", a[i] & 0xff, b[i] & 0xff); if (a[i] != b[i]) { printf("\naddrs are not equal at byte %d\n", i); - return(0); + return (0); } } printf("\n"); printf("addrs are equal\n"); return (1); - ENDDEBUG + } +#endif return (!bcmp(isoaa->isoa_genaddr, isoab->isoa_genaddr, compare_len)); } /* * FUNCTION: iso_addrmatch * - * PURPOSE: decide if the two sockadrr_isos passed are equal + * PURPOSE: decide if the two sockadrr_isos passed are equal * - * RETURNS: true if the addrs match, false if they do not + * RETURNS: true if the addrs match, false if they do not * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ +int iso_addrmatch(sisoa, sisob) -struct sockaddr_iso *sisoa, *sisob; /* addresses to check */ + struct sockaddr_iso *sisoa, *sisob; /* addresses to check */ { - return(iso_addrmatch1(&sisoa->siso_addr, &sisob->siso_addr)); + return (iso_addrmatch1(&sisoa->siso_addr, &sisob->siso_addr)); } #ifdef notdef /* * FUNCTION: iso_netmatch * - * PURPOSE: similar to iso_addrmatch but takes sockaddr_iso - * as argument. + * PURPOSE: similar to iso_addrmatch but takes sockaddr_iso + * as argument. * - * RETURNS: true if same net, false if not + * RETURNS: true if same net, false if not * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ +int iso_netmatch(sisoa, sisob) -struct sockaddr_iso *sisoa, *sisob; + struct sockaddr_iso *sisoa, *sisob; { - u_char bufa[sizeof(struct sockaddr_iso)]; - u_char bufb[sizeof(struct sockaddr_iso)]; - register int lena, lenb; + u_char bufa[sizeof(struct sockaddr_iso)]; + u_char bufb[sizeof(struct sockaddr_iso)]; + register int lena, lenb; lena = iso_netof(&sisoa->siso_addr, bufa); lenb = iso_netof(&sisob->siso_addr, bufb); - IFDEBUG(D_ROUTE) +#ifdef ARGO_DEBUG + if (argo_debug[D_ROUTE]) { printf("iso_netmatch: comparing lengths: %d to %d\n", lena, lenb); printf("a:\n"); dump_buf(bufa, lena); printf("b:\n"); dump_buf(bufb, lenb); - ENDDEBUG + } +#endif return ((lena == lenb) && (!bcmp(bufa, bufb, lena))); } @@ -211,210 +221,240 @@ struct sockaddr_iso *sisoa, *sisob; /* * FUNCTION: iso_hashchar * - * PURPOSE: Hash all character in the buffer specified into - * a long. Return the long. + * PURPOSE: Hash all character in the buffer specified into + * a long. Return the long. * - * RETURNS: The hash value. + * RETURNS: The hash value. * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: The hash is achieved by exclusive ORing 4 byte - * quantities. + * NOTES: The hash is achieved by exclusive ORing 4 byte + * quantities. */ u_long iso_hashchar(buf, len) -register caddr_t buf; /* buffer to pack from */ -register int len; /* length of buffer */ + register caddr_t buf; /* buffer to pack from */ + register int len; /* length of buffer */ { - register u_long h = 0; - register int i; + register u_long h = 0; + register int i; - for (i=0; i<len; i+=4) { - register u_long l = 0; + for (i = 0; i < len; i += 4) { + register u_long l = 0; if ((len - i) < 4) { /* buffer not multiple of 4 */ switch (len - i) { - case 3: - l |= buf[i+2] << 8; - case 2: - l |= buf[i+1] << 16; - case 1: - l |= buf[i] << 24; - break; - default: - printf("iso_hashchar: unexpected value x%x\n", len - i); - break; + case 3: + l |= buf[i + 2] << 8; + case 2: + l |= buf[i + 1] << 16; + case 1: + l |= buf[i] << 24; + break; + default: + printf("iso_hashchar: unexpected value x%x\n", len - i); + break; } } else { l |= buf[i] << 24; - l |= buf[i+1] << 16; - l |= buf[i+2] << 8; - l |= buf[i+3]; + l |= buf[i + 1] << 16; + l |= buf[i + 2] << 8; + l |= buf[i + 3]; } h ^= l; } - + h ^= (u_long) (len % 4); - return(h); + return (h); } + #ifdef notdef /* * FUNCTION: iso_hash * - * PURPOSE: Fill in fields of afhash structure based upon addr passed. + * PURPOSE: Fill in fields of afhash structure based upon addr + * passed. * - * RETURNS: none + * RETURNS: none * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ +void iso_hash(siso, hp) -struct sockaddr_iso *siso; /* address to perform hash on */ -struct afhash *hp; /* RETURN: hash info here */ + struct sockaddr_iso *siso; /* address to perform hash on */ + struct afhash *hp; /* RETURN: hash info here */ { - u_long buf[sizeof(struct sockaddr_iso)+1/4]; - register int bufsize; + u_long buf[sizeof(struct sockaddr_iso) + 1 / 4]; + register int bufsize; bzero(buf, sizeof(buf)); bufsize = iso_netof(&siso->siso_addr, buf); - hp->afh_nethash = iso_hashchar((caddr_t)buf, bufsize); + hp->afh_nethash = iso_hashchar((caddr_t) buf, bufsize); - IFDEBUG(D_ROUTE) +#ifdef ARGO_DEBUG + if (argo_debug[D_ROUTE]) { printf("iso_hash: iso_netof: bufsize = %d\n", bufsize); - ENDDEBUG + } +#endif - hp->afh_hosthash = iso_hashchar((caddr_t)&siso->siso_addr, - siso->siso_addr.isoa_len); + hp->afh_hosthash = iso_hashchar((caddr_t) & siso->siso_addr, + siso->siso_addr.isoa_len); - IFDEBUG(D_ROUTE) +#ifdef ARGO_DEBUG + if (argo_debug[D_ROUTE]) { printf("iso_hash: %s: nethash = x%x, hosthash = x%x\n", - clnp_iso_addrp(&siso->siso_addr), hp->afh_nethash, - hp->afh_hosthash); - ENDDEBUG + clnp_iso_addrp(&siso->siso_addr), hp->afh_nethash, + hp->afh_hosthash); + } +#endif } /* * FUNCTION: iso_netof * - * PURPOSE: Extract the network portion of the iso address. - * The network portion of the iso address varies depending - * on the type of address. The network portion of the - * address will include the IDP. The network portion is: - * - * TYPE DESC - * t37 The AFI and x.121 (IDI) - * osinet The AFI, orgid, snetid - * rfc986 The AFI, vers and network part of - * internet address. + * PURPOSE: Extract the network portion of the iso address. + * The network portion of the iso address varies depending + * on the type of address. The network portion of the + * address will include the IDP. The network portion is: + * + * TYPE DESC + * t37 The AFI and x.121 (IDI) + * osinet The AFI, orgid, snetid + * rfc986 The AFI, vers and network part + * of internet address. * - * RETURNS: number of bytes placed into buf. + * RETURNS: number of bytes placed into buf. * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: Buf is assumed to be big enough + * NOTES: Buf is assumed to be big enough */ +u_int iso_netof(isoa, buf) -struct iso_addr *isoa; /* address */ -caddr_t buf; /* RESULT: network portion of address here */ + struct iso_addr *isoa; /* address */ + caddr_t buf; /* RESULT: network portion of address here */ { - u_int len = 1; /* length of afi */ + u_int len = 1;/* length of afi */ switch (isoa->isoa_afi) { - case AFI_37: - /* - * Due to classic x.25 tunnel vision, there is no - * net portion of an x.121 address. For our purposes - * the AFI will do, so that all x.25 -type addresses - * map to the single x.25 SNPA. (Cannot have more than - * one, obviously). - */ + case AFI_37: + /* + * Due to classic x.25 tunnel vision, there is no + * net portion of an x.121 address. For our purposes + * the AFI will do, so that all x.25 -type addresses + * map to the single x.25 SNPA. (Cannot have more than + * one, obviously). + */ - break; + break; -/* case AFI_OSINET:*/ - case AFI_RFC986: { - u_short idi; /* value of idi */ + /* case AFI_OSINET: */ + case AFI_RFC986:{ + u_short idi; /* value of idi */ /* osinet and rfc986 have idi in the same place */ CTOH(isoa->rfc986_idi[0], isoa->rfc986_idi[1], idi); if (idi == IDI_OSINET) -/* - * Network portion of OSINET address can only be the IDI. Clearly, - * with one x25 interface, one could get to several orgids, and - * several snetids. - len += (ADDROSINET_IDI_LEN + OVLOSINET_ORGID_LEN + - OVLOSINET_SNETID_LEN); - */ + /* + * Network portion of OSINET address can only + * be the IDI. Clearly, with one x25 interface, + * one could get to several orgids, and + * several snetids. + */ +#if 0 + len += (ADDROSINET_IDI_LEN + + OVLOSINET_ORGID_LEN + + OVLOSINET_SNETID_LEN); +#endif len += ADDROSINET_IDI_LEN; else if (idi == IDI_RFC986) { - struct ovl_rfc986 *o986 = (struct ovl_rfc986 *)isoa; + struct ovl_rfc986 *o986 = + (struct ovl_rfc986 *) isoa; - /* bump len to include idi and version (1 byte) */ + /* + * bump len to include idi and version (1 + * byte) + */ len += ADDRRFC986_IDI_LEN + 1; - IFDEBUG(D_ROUTE) +#ifdef ARGO_DEBUG + if (argo_debug[D_ROUTE]) { printf("iso_netof: isoa "); dump_buf(isoa, sizeof(*isoa)); - printf("iso_netof: inetaddr 0x%x ", inetaddr); - ENDDEBUG + printf("iso_netof: inetaddr 0x%x ", + inetaddr); + } +#endif - /* bump len by size of network portion of inet address */ + /* + * bump len by size of network portion of + * inet address + */ if (IN_CLASSA(o986->o986_inetaddr)) { - len += 4-IN_CLASSA_NSHIFT/8; - IFDEBUG(D_ROUTE) + len += 4 - IN_CLASSA_NSHIFT / 8; +#ifdef ARGO_DEBUG + if (argo_debug[D_ROUTE]) { printf("iso_netof: class A net len is now %d\n", len); - ENDDEBUG + } +#endif } else if (IN_CLASSB(o986->o986_inetaddr)) { - len += 4-IN_CLASSB_NSHIFT/8; - IFDEBUG(D_ROUTE) + len += 4 - IN_CLASSB_NSHIFT / 8; +#ifdef ARGO_DEBUG + if (argo_debug[D_ROUTE]) { printf("iso_netof: class B net len is now %d\n", len); - ENDDEBUG + } +#endif } else { - len += 4-IN_CLASSC_NSHIFT/8; - IFDEBUG(D_ROUTE) + len += 4 - IN_CLASSC_NSHIFT / 8; +#ifdef ARGO_DEBUG + if (argo_debug[D_ROUTE]) { printf("iso_netof: class C net len is now %d\n", len); - ENDDEBUG + } +#endif } } else len = 0; } break; - default: - len = 0; + default: + len = 0; } - bcopy((caddr_t)isoa, buf, len); - IFDEBUG(D_ROUTE) + bcopy((caddr_t) isoa, buf, len); +#ifdef ARGO_DEBUG + if (argo_debug[D_ROUTE]) { printf("iso_netof: isoa "); dump_buf(isoa, len); printf("iso_netof: net "); dump_buf(buf, len); - ENDDEBUG + } +#endif return len; } -#endif /* notdef */ +#endif /* notdef */ /* * Generic iso control operations (ioctl's). * Ifp is 0 if not an interface-specific ioctl. */ /* ARGSUSED */ +int iso_control(so, cmd, data, ifp) - struct socket *so; - u_long cmd; - caddr_t data; + struct socket *so; + u_long cmd; + caddr_t data; register struct ifnet *ifp; { - register struct iso_ifreq *ifr = (struct iso_ifreq *)data; + register struct iso_ifreq *ifr = (struct iso_ifreq *) data; register struct iso_ifaddr *ia = 0; - register struct ifaddr *ifa; - struct iso_aliasreq *ifra = (struct iso_aliasreq *)data; - int error, hostIsNew, maskIsNew; + struct iso_aliasreq *ifra = (struct iso_aliasreq *) data; + int error, hostIsNew, maskIsNew; /* * Find address for this interface, if it exists. @@ -429,11 +469,11 @@ iso_control(so, cmd, data, ifp) case SIOCAIFADDR_ISO: case SIOCDIFADDR_ISO: if (ifra->ifra_addr.siso_family == AF_ISO) - for (; ia; ia = ia->ia_list.tqe_next) { - if (ia->ia_ifp == ifp && - SAME_ISOADDR(&ia->ia_addr, &ifra->ifra_addr)) - break; - } + for (; ia; ia = ia->ia_list.tqe_next) { + if (ia->ia_ifp == ifp && + SAME_ISOADDR(&ia->ia_addr, &ifra->ifra_addr)) + break; + } if ((so->so_state & SS_PRIV) == 0) return (EPERM); if (ifp == 0) @@ -447,13 +487,13 @@ iso_control(so, cmd, data, ifp) tuba_table_init(); #endif MALLOC(ia, struct iso_ifaddr *, sizeof(*ia), - M_IFADDR, M_WAITOK); + M_IFADDR, M_WAITOK); if (ia == 0) return (ENOBUFS); - bzero((caddr_t)ia, sizeof(*ia)); + bzero((caddr_t) ia, sizeof(*ia)); TAILQ_INSERT_TAIL(&iso_ifaddr, ia, ia_list); - TAILQ_INSERT_TAIL(&ifp->if_addrlist, (struct ifaddr *)ia, - ifa_list); + TAILQ_INSERT_TAIL(&ifp->if_addrlist, (struct ifaddr *) ia, + ifa_list); ia->ia_ifa.ifa_addr = sisotosa(&ia->ia_addr); ia->ia_ifa.ifa_dstaddr = sisotosa(&ia->ia_dstaddr); ia->ia_ifa.ifa_netmask = sisotosa(&ia->ia_sockmask); @@ -488,7 +528,9 @@ iso_control(so, cmd, data, ifp) break; case SIOCAIFADDR_ISO: - maskIsNew = 0; hostIsNew = 1; error = 0; + maskIsNew = 0; + hostIsNew = 1; + error = 0; if (ia->ia_addr.siso_family == AF_ISO) { if (ifra->ifra_addr.siso_len == 0) { ifra->ifra_addr = ia->ia_addr; @@ -505,10 +547,10 @@ iso_control(so, cmd, data, ifp) (ifra->ifra_dstaddr.siso_family == AF_ISO)) { iso_ifscrub(ifp, ia); ia->ia_dstaddr = ifra->ifra_dstaddr; - maskIsNew = 1; /* We lie; but the effect's the same */ + maskIsNew = 1; /* We lie; but the effect's the same */ } if (ifra->ifra_addr.siso_family == AF_ISO && - (hostIsNew || maskIsNew)) { + (hostIsNew || maskIsNew)) { error = iso_ifinit(ifp, ia, &ifra->ifra_addr, 0); } if (ifra->ifra_snpaoffset) @@ -517,7 +559,7 @@ iso_control(so, cmd, data, ifp) case SIOCDIFADDR_ISO: iso_ifscrub(ifp, ia); - TAILQ_REMOVE(&ifp->if_addrlist, (struct ifaddr *)ia, ifa_list); + TAILQ_REMOVE(&ifp->if_addrlist, (struct ifaddr *) ia, ifa_list); TAILQ_REMOVE(&iso_ifaddr, ia, ia_list); IFAFREE((&ia->ia_ifa)); break; @@ -525,7 +567,7 @@ iso_control(so, cmd, data, ifp) default: if (ifp == 0 || ifp->if_ioctl == 0) return (EOPNOTSUPP); - return ((*ifp->if_ioctl)(ifp, cmd, data)); + return ((*ifp->if_ioctl) (ifp, cmd, data)); } return (0); } @@ -533,20 +575,21 @@ iso_control(so, cmd, data, ifp) /* * Delete any existing route for an interface. */ +void iso_ifscrub(ifp, ia) register struct ifnet *ifp; register struct iso_ifaddr *ia; { - int nsellength = ia->ia_addr.siso_tlen; + int nsellength = ia->ia_addr.siso_tlen; if ((ia->ia_flags & IFA_ROUTE) == 0) return; ia->ia_addr.siso_tlen = 0; if (ifp->if_flags & IFF_LOOPBACK) - rtinit(&(ia->ia_ifa), (int)RTM_DELETE, RTF_HOST); + rtinit(&(ia->ia_ifa), (int) RTM_DELETE, RTF_HOST); else if (ifp->if_flags & IFF_POINTOPOINT) - rtinit(&(ia->ia_ifa), (int)RTM_DELETE, RTF_HOST); + rtinit(&(ia->ia_ifa), (int) RTM_DELETE, RTF_HOST); else { - rtinit(&(ia->ia_ifa), (int)RTM_DELETE, 0); + rtinit(&(ia->ia_ifa), (int) RTM_DELETE, 0); } ia->ia_addr.siso_tlen = nsellength; ia->ia_flags &= ~IFA_ROUTE; @@ -556,13 +599,15 @@ iso_ifscrub(ifp, ia) * Initialize an interface's internet address * and routing table entry. */ +int iso_ifinit(ifp, ia, siso, scrub) register struct ifnet *ifp; register struct iso_ifaddr *ia; struct sockaddr_iso *siso; + int scrub; { struct sockaddr_iso oldaddr; - int s = splimp(), error, nsellength; + int s = splimp(), error, nsellength; oldaddr = ia->ia_addr; ia->ia_addr = *siso; @@ -572,7 +617,7 @@ iso_ifinit(ifp, ia, siso, scrub) * and to validate the address if necessary. */ if (ifp->if_ioctl && - (error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (caddr_t)ia))) { + (error = (*ifp->if_ioctl) (ifp, SIOCSIFADDR, (caddr_t) ia))) { splx(s); ia->ia_addr = oldaddr; return (error); @@ -582,8 +627,10 @@ iso_ifinit(ifp, ia, siso, scrub) iso_ifscrub(ifp, ia); ia->ia_ifa.ifa_addr = sisotosa(&ia->ia_addr); } - /* XXX -- The following is here temporarily out of laziness - in not changing every ethernet driver's if_ioctl routine */ + /* + * XXX -- The following is here temporarily out of laziness in not + * changing every ethernet driver's if_ioctl routine + */ if (ifp->if_output == ether_output) { ia->ia_ifa.ifa_rtrequest = llc_rtrequest; ia->ia_ifa.ifa_flags |= RTF_CLONING; @@ -595,16 +642,16 @@ iso_ifinit(ifp, ia, siso, scrub) ia->ia_addr.siso_tlen = 0; if (ifp->if_flags & IFF_LOOPBACK) { ia->ia_ifa.ifa_dstaddr = ia->ia_ifa.ifa_addr; - error = rtinit(&(ia->ia_ifa), (int)RTM_ADD, RTF_HOST|RTF_UP); + error = rtinit(&(ia->ia_ifa), (int) RTM_ADD, RTF_HOST | RTF_UP); } else if (ifp->if_flags & IFF_POINTOPOINT && - ia->ia_dstaddr.siso_family == AF_ISO) - error = rtinit(&(ia->ia_ifa), (int)RTM_ADD, RTF_HOST|RTF_UP); + ia->ia_dstaddr.siso_family == AF_ISO) + error = rtinit(&(ia->ia_ifa), (int) RTM_ADD, RTF_HOST | RTF_UP); else { rt_maskedcopy(ia->ia_ifa.ifa_addr, ia->ia_ifa.ifa_dstaddr, - ia->ia_ifa.ifa_netmask); + ia->ia_ifa.ifa_netmask); ia->ia_dstaddr.siso_nlen = min(ia->ia_addr.siso_nlen, (ia->ia_sockmask.siso_len - 6)); - error = rtinit(&(ia->ia_ifa), (int)RTM_ADD, RTF_UP); + error = rtinit(&(ia->ia_ifa), (int) RTM_ADD, RTF_UP); } ia->ia_addr.siso_tlen = nsellength; ia->ia_flags |= IFA_ROUTE; @@ -613,70 +660,83 @@ iso_ifinit(ifp, ia, siso, scrub) } #ifdef notdef -struct ifaddr * +struct ifaddr * iso_ifwithidi(addr) register struct sockaddr *addr; { register struct ifnet *ifp; register struct ifaddr *ifa; - register u_int af = addr->sa_family; + register u_int af = addr->sa_family; if (af != AF_ISO) return (0); - IFDEBUG(D_ROUTE) +#ifdef ARGO_DEBUG + if (argo_debug[D_ROUTE]) { printf(">>> iso_ifwithidi addr\n"); dump_isoaddr(satosiso(addr)); printf("\n"); - ENDDEBUG + } +#endif for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next) { - IFDEBUG(D_ROUTE) +#ifdef ARGO_DEBUG + if (argo_debug[D_ROUTE]) { printf("iso_ifwithidi ifnet %s\n", ifp->if_name); - ENDDEBUG + } +#endif for (ifa = ifp->if_addrlist.tqh_first; ifa != 0; - ifa = ifa->ifa_list.tqe_next) { - IFDEBUG(D_ROUTE) + ifa = ifa->ifa_list.tqe_next) { +#ifdef ARGO_DEBUG + if (argo_debug[D_ROUTE]) { printf("iso_ifwithidi address "); dump_isoaddr(satosiso(ifa->ifa_addr)); - ENDDEBUG + } +#endif if (ifa->ifa_addr->sa_family != addr->sa_family) continue; - IFDEBUG(D_ROUTE) +#ifdef ARGO_DEBUG + if (argo_debug[D_ROUTE]) { printf(" af same, args to iso_eqtype:\n"); printf("0x%x ", satosiso(ifa->ifa_addr)->siso_addr); printf(" 0x%x\n", - &satosiso(addr)->siso_addr)); - ENDDEBUG + &satosiso(addr)->siso_addr)); + } +#endif - if (iso_eqtype(&satosiso(ifa->ifa_addr)->siso_addr, - &satosiso(addr)->siso_addr)) { - IFDEBUG(D_ROUTE) + if (iso_eqtype(&satosiso(ifa->ifa_addr)->siso_addr, + &satosiso(addr)->siso_addr)) { +#ifdef ARGO_DEBUG + if (argo_debug[D_ROUTE]) { printf("ifa_ifwithidi: ifa found\n"); - ENDDEBUG + } +#endif return (ifa); } - IFDEBUG(D_ROUTE) +#ifdef ARGO_DEBUG + if (argo_debug[D_ROUTE]) { printf(" iso_eqtype failed\n"); - ENDDEBUG + } +#endif } } - return ((struct ifaddr *)0); + return ((struct ifaddr *) 0); } -#endif /* notdef */ +#endif /* notdef */ /* * FUNCTION: iso_ck_addr * - * PURPOSE: return true if the iso_addr passed is - * within the legal size limit for an iso address. + * PURPOSE: return true if the iso_addr passed is + * within the legal size limit for an iso address. * - * RETURNS: true or false + * RETURNS: true or false * - * SIDE EFFECTS: + * SIDE EFFECTS: * */ +int iso_ck_addr(isoa) -struct iso_addr *isoa; /* address to check */ + struct iso_addr *isoa; /* address to check */ { return (isoa->isoa_len <= 20); @@ -686,51 +746,52 @@ struct iso_addr *isoa; /* address to check */ /* * FUNCTION: iso_eqtype * - * PURPOSE: Determine if two iso addresses are of the same type. - * This is flaky. Really we should consider all type 47 addrs to be the - * same - but there do exist different structures for 47 addrs. - * Gosip adds a 3rd. + * PURPOSE: Determine if two iso addresses are of the same type. + * This is flaky. Really we should consider all type + * 47 addrs to be the same - but there do exist different + * structures for 47 addrs. Gosip adds a 3rd. * - * RETURNS: true if the addresses are the same type + * RETURNS: true if the addresses are the same type * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: By type, I mean rfc986, t37, or osinet + * NOTES: By type, I mean rfc986, t37, or osinet * - * This will first compare afis. If they match, then - * if the addr is not t37, the idis must be compared. + * This will first compare afis. If they match, then + * if the addr is not t37, the idis must be compared. */ +int iso_eqtype(isoaa, isoab) -struct iso_addr *isoaa; /* first addr to check */ -struct iso_addr *isoab; /* other addr to check */ + struct iso_addr *isoaa; /* first addr to check */ + struct iso_addr *isoab; /* other addr to check */ { if (isoaa->isoa_afi == isoab->isoa_afi) { if (isoaa->isoa_afi == AFI_37) - return(1); - else + return (1); + else return (!bcmp(&isoaa->isoa_u, &isoab->isoa_u, 2)); } - return(0); + return (0); } #endif /* notdef */ /* * FUNCTION: iso_localifa() * - * PURPOSE: Find an interface addresss having a given destination - * or at least matching the net. + * PURPOSE: Find an interface addresss having a given destination + * or at least matching the net. * - * RETURNS: ptr to an interface address + * RETURNS: ptr to an interface address * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ struct iso_ifaddr * iso_localifa(siso) register struct sockaddr_iso *siso; { register struct iso_ifaddr *ia; - register char *cp1, *cp2, *cp3; + register char *cp1, *cp2, *cp3; register struct ifnet *ifp; struct iso_ifaddr *ia_maybe = 0; /* @@ -742,15 +803,15 @@ iso_localifa(siso) continue; if (ifp->if_flags & IFF_POINTOPOINT) { if ((ia->ia_dstaddr.siso_family == AF_ISO) && - SAME_ISOADDR(&ia->ia_dstaddr, siso)) + SAME_ISOADDR(&ia->ia_dstaddr, siso)) return (ia); - else - if (SAME_ISOADDR(&ia->ia_addr, siso)) - ia_maybe = ia; + else if (SAME_ISOADDR(&ia->ia_addr, siso)) + ia_maybe = ia; continue; } if (ia->ia_sockmask.siso_len) { - char *cplim = ia->ia_sockmask.siso_len + (char *)&ia->ia_sockmask; + char *cplim = ia->ia_sockmask.siso_len + + (char *) &ia->ia_sockmask; cp1 = ia->ia_sockmask.siso_data; cp2 = siso->siso_data; cp3 = ia->ia_addr.siso_data; @@ -761,7 +822,7 @@ iso_localifa(siso) } if (SAME_ISOADDR(&ia->ia_addr, siso)) return ia; - next:; +next: ; } return ia_maybe; } @@ -772,67 +833,74 @@ iso_localifa(siso) /* * FUNCTION: iso_nlctloutput * - * PURPOSE: Set options at the network level + * PURPOSE: Set options at the network level * - * RETURNS: E* + * RETURNS: E* * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: This could embody some of the functions of - * rclnp_ctloutput and cons_ctloutput. + * NOTES: This could embody some of the functions of + * rclnp_ctloutput and cons_ctloutput. */ +int iso_nlctloutput(cmd, optname, pcb, m) -int cmd; /* command:set or get */ -int optname; /* option of interest */ -caddr_t pcb; /* nl pcb */ -struct mbuf *m; /* data for set, buffer for get */ + int cmd; /* command:set or get */ + int optname;/* option of interest */ + caddr_t pcb; /* nl pcb */ + struct mbuf *m; /* data for set, buffer for get */ { - struct isopcb *isop = (struct isopcb *)pcb; - int error = 0; /* return value */ - caddr_t data; /* data for option */ - int data_len; /* data's length */ +#ifdef TPCONS + struct isopcb *isop = (struct isopcb *) pcb; +#endif + int error = 0; /* return value */ + caddr_t data; /* data for option */ + int data_len; /* data's length */ - IFDEBUG(D_ISO) +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { printf("iso_nlctloutput: cmd %x, opt %x, pcb %x, m %x\n", - cmd, optname, pcb, m); - ENDDEBUG + cmd, optname, (unsigned int) pcb, (unsigned int) m); + } +#endif if ((cmd != PRCO_GETOPT) && (cmd != PRCO_SETOPT)) - return(EOPNOTSUPP); + return (EOPNOTSUPP); data = mtod(m, caddr_t); data_len = (m)->m_len; - IFDEBUG(D_ISO) +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { printf("iso_nlctloutput: data is:\n"); dump_buf(data, data_len); - ENDDEBUG + } +#endif switch (optname) { #ifdef TPCONS - case CONSOPT_X25CRUD: - if (cmd == PRCO_GETOPT) { - error = EOPNOTSUPP; - break; - } - - if (data_len > MAXX25CRUDLEN) { - error = EINVAL; - break; - } - - IFDEBUG(D_ISO) - printf("iso_nlctloutput: setting x25 crud\n"); - ENDDEBUG - - bcopy(data, (caddr_t)isop->isop_x25crud, (unsigned)data_len); - isop->isop_x25crud_len = data_len; + case CONSOPT_X25CRUD: + if (cmd == PRCO_GETOPT) { + error = EOPNOTSUPP; break; -#endif /* TPCONS */ + } + if (data_len > MAXX25CRUDLEN) { + error = EINVAL; + break; + } +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { + printf("iso_nlctloutput: setting x25 crud\n"); + } +#endif - default: - error = EOPNOTSUPP; + bcopy(data, (caddr_t) isop->isop_x25crud, (unsigned) data_len); + isop->isop_x25crud_len = data_len; + break; +#endif /* TPCONS */ + + default: + error = EOPNOTSUPP; } if (cmd == PRCO_SETOPT) m_freem(m); @@ -845,30 +913,28 @@ struct mbuf *m; /* data for set, buffer for get */ /* * FUNCTION: dump_isoaddr * - * PURPOSE: debugging + * PURPOSE: debugging * - * RETURNS: nada + * RETURNS: nada * */ +void dump_isoaddr(s) struct sockaddr_iso *s; { - char *clnp_saddr_isop(); - register int i; - - if( s->siso_family == AF_ISO) { + if (s->siso_family == AF_ISO) { printf("ISO address: suffixlen %d, %s\n", - s->siso_tlen, clnp_saddr_isop(s)); - } else if( s->siso_family == AF_INET) { + s->siso_tlen, clnp_saddr_isop(s)); + } else if (s->siso_family == AF_INET) { /* hack */ struct sockaddr_in *sin = satosin(s); - printf("%d.%d.%d.%d: %d", - (sin->sin_addr.s_addr>>24)&0xff, - (sin->sin_addr.s_addr>>16)&0xff, - (sin->sin_addr.s_addr>>8)&0xff, - (sin->sin_addr.s_addr)&0xff, - sin->sin_port); + printf("%d.%d.%d.%d: %d", + (sin->sin_addr.s_addr >> 24) & 0xff, + (sin->sin_addr.s_addr >> 16) & 0xff, + (sin->sin_addr.s_addr >> 8) & 0xff, + (sin->sin_addr.s_addr) & 0xff, + sin->sin_port); } } diff --git a/sys/netiso/iso.h b/sys/netiso/iso.h index 01af3ed2860..de615248e1d 100644 --- a/sys/netiso/iso.h +++ b/sys/netiso/iso.h @@ -1,4 +1,5 @@ -/* $NetBSD: iso.h,v 1.7 1995/06/13 07:13:31 mycroft Exp $ */ +/* $OpenBSD: iso.h,v 1.2 1996/03/04 10:35:28 mickey Exp $ */ +/* $NetBSD: iso.h,v 1.8 1996/02/13 22:09:58 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -67,34 +68,34 @@ SOFTWARE. /* * Return true if this is a multicast address - * This assumes that the bit transmission is lsb first. This + * This assumes that the bit transmission is lsb first. This * assumption is valid for 802.3 but not 802.5. There is a * kludge to get around this for 802.5 -- see if_lan.c * where subnetwork header is setup. */ #define IS_MULTICAST(snpa)\ ((snpa)[0] & 0x01) - + /* * Protocols */ -#define ISOPROTO_TCP 6 /* IETF experiment */ -#define ISOPROTO_UDP 17 /* IETF experiment */ -#define ISOPROTO_TP0 25 /* connection oriented transport protocol */ -#define ISOPROTO_TP1 26 /* not implemented */ -#define ISOPROTO_TP2 27 /* not implemented */ -#define ISOPROTO_TP3 28 /* not implemented */ -#define ISOPROTO_TP4 29 /* connection oriented transport protocol */ -#define ISOPROTO_TP ISOPROTO_TP4 /* tp-4 with negotiation */ -#define ISOPROTO_CLTP 30 /* connectionless transport (not yet impl.) */ -#define ISOPROTO_CLNP 31 /* connectionless internetworking protocol */ -#define ISOPROTO_X25 32 /* cons */ +#define ISOPROTO_TCP 6 /* IETF experiment */ +#define ISOPROTO_UDP 17 /* IETF experiment */ +#define ISOPROTO_TP0 25 /* connection oriented transport protocol */ +#define ISOPROTO_TP1 26 /* not implemented */ +#define ISOPROTO_TP2 27 /* not implemented */ +#define ISOPROTO_TP3 28 /* not implemented */ +#define ISOPROTO_TP4 29 /* connection oriented transport protocol */ +#define ISOPROTO_TP ISOPROTO_TP4 /* tp-4 with negotiation */ +#define ISOPROTO_CLTP 30 /* connectionless transport (not yet impl.) */ +#define ISOPROTO_CLNP 31 /* connectionless internetworking protocol */ +#define ISOPROTO_X25 32 /* cons */ #define ISOPROTO_INACT_NL 33 /* inactive network layer! */ -#define ISOPROTO_ESIS 34 /* ES-IS protocol */ -#define ISOPROTO_INTRAISIS 35 /* IS-IS protocol */ -#define ISOPROTO_IDRP 36 /* Interdomain Routing Protocol */ +#define ISOPROTO_ESIS 34 /* ES-IS protocol */ +#define ISOPROTO_INTRAISIS 35 /* IS-IS protocol */ +#define ISOPROTO_IDRP 36 /* Interdomain Routing Protocol */ -#define ISOPROTO_RAW 255 /* raw clnp */ +#define ISOPROTO_RAW 255 /* raw clnp */ #define ISOPROTO_MAX 256 #define ISO_PORT_RESERVED 1024 @@ -115,7 +116,7 @@ SOFTWARE. /* * Port/socket numbers: public use */ -#define ISO_PORT_PUBLIC 1024 /* high bit set --> public */ +#define ISO_PORT_PUBLIC 1024 /* high bit set --> public */ /* * Network layer protocol identifiers @@ -130,26 +131,28 @@ SOFTWARE. #ifndef IN_CLASSA_NET #include <netinet/in.h> -#endif /* IN_CLASSA_NET */ +#endif /* IN_CLASSA_NET */ -/* The following looks like a sockaddr - * to facilitate using tree lookup routines */ +/* + * The following looks like a sockaddr to facilitate using tree lookup + * routines + */ struct iso_addr { - u_char isoa_len; /* length (in bytes) */ - char isoa_genaddr[20]; /* general opaque address */ + u_char isoa_len; /* length (in bytes) */ + char isoa_genaddr[20]; /* general opaque address */ }; struct sockaddr_iso { - u_char siso_len; /* length */ - u_char siso_family; /* family */ - u_char siso_plen; /* presentation selector length */ - u_char siso_slen; /* session selector length */ - u_char siso_tlen; /* transport selector length */ - struct iso_addr siso_addr; /* network address */ - u_char siso_pad[6]; /* space for gosip v2 sels */ - /* makes struct 32 bytes long */ + u_char siso_len; /* length */ + u_char siso_family; /* family */ + u_char siso_plen; /* presentation selector length */ + u_char siso_slen; /* session selector length */ + u_char siso_tlen; /* transport selector length */ + struct iso_addr siso_addr; /* network address */ + u_char siso_pad[6]; /* space for gosip v2 sels */ + /* makes struct 32 bytes long */ }; #define siso_nlen siso_addr.isoa_len #define siso_data siso_addr.isoa_genaddr @@ -165,16 +168,12 @@ struct sockaddr_iso { #define AFI_37 0x37 /* bcd of "37" */ #define AFI_OSINET 0x47 /* bcd of "47" */ #define AFI_RFC986 0x47 /* bcd of "47" */ -#define AFI_SNA 0x00 /* SubNetwork Address; invalid really...*/ +#define AFI_SNA 0x00 /* SubNetwork Address; invalid really... */ #ifdef _KERNEL -extern int iso_netmatch(); -extern int iso_hash(); -extern int iso_addrmatch(); -extern struct iso_ifaddr *iso_iaonnetof(); -extern struct domain isodomain; -extern struct protosw isosw[]; +extern struct domain isodomain; +extern struct protosw isosw[]; #define satosiso(sa) ((struct sockaddr_iso *)(sa)) #define sisotosa(siso) ((struct sockaddr *)(siso)) @@ -186,7 +185,7 @@ extern struct protosw isosw[]; __BEGIN_DECLS struct iso_addr *iso_addr __P((const char *)); -char *iso_ntoa __P((const struct iso_addr *)); +char *iso_ntoa __P((const struct iso_addr *)); /* THESE DON'T EXIST YET */ struct hostent *iso_gethostbyname(), *iso_gethostbyaddr(); diff --git a/sys/netiso/iso_chksum.c b/sys/netiso/iso_chksum.c index 38839508754..7e64c84ddd8 100644 --- a/sys/netiso/iso_chksum.c +++ b/sys/netiso/iso_chksum.c @@ -1,4 +1,5 @@ -/* $NetBSD: iso_chksum.c,v 1.5 1994/06/29 06:39:43 cgd Exp $ */ +/* $OpenBSD: iso_chksum.c,v 1.2 1996/03/04 10:35:30 mickey Exp $ */ +/* $NetBSD: iso_chksum.c,v 1.6 1996/02/13 22:10:01 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -61,100 +62,104 @@ SOFTWARE. /* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ -/* +/* * ISO CHECKSUM * - * The checksum generation and check routines are here. - * The checksum is 2 bytes such that the sum of all the bytes b(i) == 0 - * and the sum of i * b(i) == 0. + * The checksum generation and check routines are here. The checksum is 2 bytes + * such that the sum of all the bytes b(i) == 0 and the sum of i * b(i) == 0. * The whole thing is complicated by the fact that the data are in mbuf - * chains. - * Furthermore, there is the possibility of wraparound in the running - * sums after adding up 4102 octets. In order to avoid doing a mod - * operation after EACH add, we have restricted this implementation to - * negotiating a maximum of 4096-octets per TPDU (for the transport layer). - * The routine iso_check_csum doesn't need to know where the checksum - * octets are. - * The routine iso_gen_csum takes a pointer to an mbuf chain (logically - * a chunk of data), an offset into the chunk at which the 2 octets are to - * be stuffed, and the length of the chunk. The 2 octets have to be - * logically adjacent, but may be physically located in separate mbufs. + * chains. Furthermore, there is the possibility of wraparound in the running + * sums after adding up 4102 octets. In order to avoid doing a mod operation + * after EACH add, we have restricted this implementation to negotiating a + * maximum of 4096-octets per TPDU (for the transport layer). The routine + * iso_check_csum doesn't need to know where the checksum octets are. The + * routine iso_gen_csum takes a pointer to an mbuf chain (logically a chunk + * of data), an offset into the chunk at which the 2 octets are to be + * stuffed, and the length of the chunk. The 2 octets have to be logically + * adjacent, but may be physically located in separate mbufs. */ #ifdef ISO -#include <netiso/argo_debug.h> #include <sys/param.h> #include <sys/systm.h> #include <sys/mbuf.h> +#include <sys/socket.h> +#include <net/if.h> +#include <netiso/argo_debug.h> +#include <netiso/iso.h> +#include <netiso/iso_var.h> #endif /* ISO */ -#ifndef MNULL -#define MNULL (struct mbuf *)0 -#endif /* MNULL */ - /* * FUNCTION: iso_check_csum * - * PURPOSE: To check the checksum of the packet in the mbuf chain (m). - * The total length of the packet is (len). - * Called from tp_input() and clnp_intr() + * PURPOSE: To check the checksum of the packet in the mbuf chain (m). + * The total length of the packet is (len). + * Called from tp_input() and clnp_intr() * - * RETURNS: TRUE (something non-zero) if there is a checksum error, - * FALSE if there was NO checksum error. + * RETURNS: TRUE (something non-zero) if there is a checksum error, + * FALSE if there was NO checksum error. * * SIDE EFFECTS: none * - * NOTES: It might be possible to gain something by optimizing + * NOTES: It might be possible to gain something by optimizing * this routine (unrolling loops, etc). But it is such - * a horrible thing to fiddle with anyway, it probably - * isn't worth it. + * a horrible thing to fiddle with anyway, it probably + * isn't worth it. */ -int +int iso_check_csum(m, len) - struct mbuf *m; - int len; + struct mbuf *m; + int len; { register u_char *p = mtod(m, u_char *); - register u_long c0=0, c1=0; - register int i=0; - int cum = 0; /* cumulative length */ - int l; + register u_long c0 = 0, c1 = 0; + register int i = 0; + int cum = 0;/* cumulative length */ + int l; l = len; len = min(m->m_len, len); i = 0; - IFDEBUG(D_CHKSUM) - printf("iso_check_csum: m x%x, l x%x, m->m_len x%x\n", m, l, m->m_len); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_CHKSUM]) { + printf("iso_check_csum: m x%x, l x%x, m->m_len x%x\n", + (unsigned int) m, l, m->m_len); + } +#endif - while( i<l ) { + while (i < l) { cum += len; - while (i<cum) { + while (i < cum) { c0 = c0 + *(p++); c1 += c0; i++; } - if(i < l) { + if (i < l) { m = m->m_next; - IFDEBUG(D_CHKSUM) +#ifdef ARGO_DEBUG + if (argo_debug[D_CHKSUM]) { printf("iso_check_csum: new mbuf\n"); - if(l-i < m->m_len) + if (l - i < m->m_len) printf( - "bad mbuf chain in check csum l 0x%x i 0x%x m_data 0x%x", - l,i,m->m_data); - ENDDEBUG - ASSERT( m != MNULL); - len = min( m->m_len, l-i); + "bad mbuf chain in check csum l 0x%x i 0x%x m_data 0x%x", + l, i, (unsigned int) m->m_data); + } +#endif + ASSERT(m != NULL); + len = min(m->m_len, l - i); p = mtod(m, u_char *); } } - if ( ((int)c0 % 255) || ((int)c1 % 255) ) { - IFDEBUG(D_CHKSUM) - printf("BAD iso_check_csum l 0x%x cum 0x%x len 0x%x, i 0x%x", - l, cum, len, i); - ENDDEBUG - return ((int)c0 % 255)<<8 | ((int)c1 % 255); + if (((int) c0 % 255) || ((int) c1 % 255)) { +#ifdef ARGO_DEBUG + if (argo_debug[D_CHKSUM]) { + printf("BAD iso_check_csum l 0x%x cum 0x%x len 0x%x, i 0x%x", + l, cum, len, i); + } +#endif + return ((int) c0 % 255) << 8 | ((int) c1 % 255); } return 0; } @@ -162,115 +167,139 @@ iso_check_csum(m, len) /* * FUNCTION: iso_gen_csum * - * PURPOSE: To generate the checksum of the packet in the mbuf chain (m). - * The first of the 2 (logically) adjacent checksum bytes - * (x and y) go at offset (n). - * (n) is an offset relative to the beginning of the data, - * not the beginning of the mbuf. - * (l) is the length of the total mbuf chain's data. - * Called from tp_emit(), tp_error_emit() - * clnp_emit_er(), clnp_forward(), clnp_output(). + * PURPOSE: To generate the checksum of the packet in the mbuf chain (m). + * The first of the 2 (logically) adjacent checksum bytes + * (x and y) go at offset (n). + * (n) is an offset relative to the beginning of the data, + * not the beginning of the mbuf. + * (l) is the length of the total mbuf chain's data. + * Called from tp_emit(), tp_error_emit() + * clnp_emit_er(), clnp_forward(), clnp_output(). * - * RETURNS: Rien + * RETURNS: Rien * * SIDE EFFECTS: Puts the 2 checksum bytes into the packet. * - * NOTES: Ditto the note for iso_check_csum(). + * NOTES: Ditto the note for iso_check_csum(). */ void -iso_gen_csum(m,n,l) - struct mbuf *m; - int n; /* offset of 2 checksum bytes */ - int l; +iso_gen_csum(m, n, l) + struct mbuf *m; + int n; /* offset of 2 checksum bytes */ + int l; { register u_char *p = mtod(m, u_char *); - register int c0=0, c1=0; - register int i=0; - int loc = n++, len=0; /* n is position, loc is offset */ - u_char *xloc; - u_char *yloc; - int cum=0; /* cum == cumulative length */ - - IFDEBUG(D_CHKSUM) - printf("enter gen csum m 0x%x n 0x%x l 0x%x\n",m, n-1 ,l ); - ENDDEBUG + register int c0 = 0, c1 = 0; + register int i = 0; + int loc = n++, len = 0; /* n is position, loc is + * offset */ + u_char *xloc = NULL; + u_char *yloc = NULL; + int cum = 0;/* cum == cumulative length */ + +#ifdef ARGO_DEBUG + if (argo_debug[D_CHKSUM]) { + printf("enter gen csum m 0x%x n 0x%x l 0x%x\n", + (unsigned int) m, n - 1, l); + } +#endif - while(i < l) { + while (i < l) { len = min(m->m_len, CLBYTES); /* RAH: don't cksum more than l bytes */ len = min(len, l - i); - cum +=len; + cum += len; p = mtod(m, u_char *); - if(loc>=0) { + if (loc >= 0) { if (loc < len) { xloc = loc + mtod(m, u_char *); - IFDEBUG(D_CHKSUM) - printf("1: zeroing xloc 0x%x loc 0x%x\n",xloc, loc ); - ENDDEBUG - *xloc = (u_char)0; - if (loc+1 < len) { - /* both xloc and yloc are in same mbuf */ - yloc = 1 + xloc; - IFDEBUG(D_CHKSUM) - printf("2: zeroing yloc 0x%x loc 0x%x\n",yloc, loc ); - ENDDEBUG - *yloc = (u_char)0; +#ifdef ARGO_DEBUG + if (argo_debug[D_CHKSUM]) { + printf( + "1: zeroing xloc 0x%x loc 0x%x\n", + (unsigned int) xloc, + (unsigned int) loc); + } +#endif + *xloc = (u_char) 0; + if (loc + 1 < len) { + /* + * both xloc and yloc are in same + * mbuf + */ + yloc = 1 + xloc; +#ifdef ARGO_DEBUG + if (argo_debug[D_CHKSUM]) { + printf( + "2: zeroing yloc 0x%x loc 0x%x\n", + (unsigned int) yloc, loc); + } +#endif + *yloc = (u_char) 0; } else { /* crosses boundary of mbufs */ yloc = mtod(m->m_next, u_char *); - IFDEBUG(D_CHKSUM) - printf("3: zeroing yloc 0x%x \n",yloc ); - ENDDEBUG - *yloc = (u_char)0; +#ifdef ARGO_DEBUG + if (argo_debug[D_CHKSUM]) { + printf( + "3: zeroing yloc 0x%x \n", + (unsigned int) yloc); + } +#endif + *yloc = (u_char) 0; } } loc -= len; } - - while(i < cum) { + while (i < cum) { c0 = (c0 + *p); - c1 += c0 ; - i++; + c1 += c0; + i++; p++; } m = m->m_next; } - IFDEBUG(D_CHKSUM) - printf("gen csum final xloc 0x%x yloc 0x%x\n",xloc, yloc ); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_CHKSUM]) { + printf("gen csum final xloc 0x%x yloc 0x%x\n", + (unsigned int) xloc, (unsigned int) yloc); + } +#endif - c1 = (((c0 * (l-n))-c1)%255) ; - *xloc = (u_char) ((c1 < 0)? c1+255 : c1); + c1 = (((c0 * (l - n)) - c1) % 255); + *xloc = (u_char) ((c1 < 0) ? c1 + 255 : c1); - c1 = (-(int)(c1+c0))%255; - *yloc = (u_char) (c1 < 0? c1 + 255 : c1); + c1 = (-(int) (c1 + c0)) % 255; + *yloc = (u_char) (c1 < 0 ? c1 + 255 : c1); - IFDEBUG(D_CHKSUM) +#ifdef ARGO_DEBUG + if (argo_debug[D_CHKSUM]) { printf("gen csum end \n"); - ENDDEBUG + } +#endif } /* * FUNCTION: m_datalen * - * PURPOSE: returns length of the mbuf chain. - * used all over the iso code. + * PURPOSE: returns length of the mbuf chain. + * used all over the iso code. * - * RETURNS: integer + * RETURNS: integer * * SIDE EFFECTS: none * - * NOTES: + * NOTES: */ int -m_datalen (m) +m_datalen(m) register struct mbuf *m; -{ - register int datalen; +{ + register int datalen; for (datalen = 0; m; m = m->m_next) datalen += m->m_len; @@ -281,79 +310,93 @@ int m_compress(in, out) register struct mbuf *in, **out; { - register int datalen = 0; - int s = splimp(); + register int datalen = 0; + int s = splimp(); - if( in->m_next == MNULL ) { + if (in->m_next == NULL) { *out = in; - IFDEBUG(D_REQUEST) +#ifdef ARGO_DEBUG + if (argo_debug[D_REQUEST]) { printf("m_compress returning 0x%x: A\n", in->m_len); - ENDDEBUG + } +#endif splx(s); return in->m_len; } MGET((*out), M_DONTWAIT, MT_DATA); - if((*out) == MNULL) { + if ((*out) == NULL) { *out = in; - IFDEBUG(D_REQUEST) +#ifdef ARGO_DEBUG + if (argo_debug[D_REQUEST]) { printf("m_compress returning -1: B\n"); - ENDDEBUG + } +#endif splx(s); - return -1; + return -1; } (*out)->m_len = 0; - (*out)->m_act = MNULL; + (*out)->m_act = NULL; while (in) { - IFDEBUG(D_REQUEST) - printf("m_compress in 0x%x *out 0x%x\n", in, *out); - printf("m_compress in: len 0x%x, off 0x%x\n", in->m_len, in->m_data); - printf("m_compress *out: len 0x%x, off 0x%x\n", (*out)->m_len, - (*out)->m_data); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_REQUEST]) { + printf("m_compress in 0x%x *out 0x%x\n", + (unsigned int) in, (unsigned int) *out); + printf("m_compress in: len 0x%x, off 0x%x\n", + in->m_len, (unsigned int) in->m_data); + printf("m_compress *out: len 0x%x, off 0x%x\n", + (*out)->m_len, (unsigned int) (*out)->m_data); + } +#endif if (in->m_flags & M_EXT) { ASSERT(in->m_len == 0); } - if ( in->m_len == 0) { + if (in->m_len == 0) { in = in->m_next; continue; } if (((*out)->m_flags & M_EXT) == 0) { - int len; + int len; len = M_TRAILINGSPACE(*out); len = min(len, in->m_len); datalen += len; - IFDEBUG(D_REQUEST) +#ifdef ARGO_DEBUG + if (argo_debug[D_REQUEST]) { printf("m_compress copying len %d\n", len); - ENDDEBUG + } +#endif bcopy(mtod(in, caddr_t), mtod((*out), caddr_t) + (*out)->m_len, - (unsigned)len); + (unsigned) len); (*out)->m_len += len; in->m_len -= len; continue; } else { /* (*out) is full */ - if(( (*out)->m_next = m_get(M_DONTWAIT, MT_DATA) ) == MNULL) { + if (((*out)->m_next = m_get(M_DONTWAIT, MT_DATA)) == NULL) { m_freem(*out); *out = in; - IFDEBUG(D_REQUEST) +#ifdef ARGO_DEBUG + if (argo_debug[D_REQUEST]) { printf("m_compress returning -1: B\n"); - ENDDEBUG + } +#endif splx(s); return -1; } (*out)->m_len = 0; - (*out)->m_act = MNULL; + (*out)->m_act = NULL; *out = (*out)->m_next; } } m_freem(in); - IFDEBUG(D_REQUEST) +#ifdef ARGO_DEBUG + if (argo_debug[D_REQUEST]) { printf("m_compress returning 0x%x: A\n", datalen); - ENDDEBUG + } +#endif splx(s); return datalen; } diff --git a/sys/netiso/iso_errno.h b/sys/netiso/iso_errno.h index 6c511120ee9..78d3c00d8a4 100644 --- a/sys/netiso/iso_errno.h +++ b/sys/netiso/iso_errno.h @@ -1,4 +1,5 @@ -/* $NetBSD: iso_errno.h,v 1.6 1995/03/08 02:16:13 cgd Exp $ */ +/* $OpenBSD: iso_errno.h,v 1.2 1996/03/04 10:35:32 mickey Exp $ */ +/* $NetBSD: iso_errno.h,v 1.7 1996/02/13 22:10:08 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -68,67 +69,69 @@ SOFTWARE. #define ISO_ERROR_MASK 0x8000 #define BSD_ERROR_MASK 0x0000 #define TP_ERROR_MASK 0x8800 /* transport layer */ -#define CONL_ERROR_MASK 0x8400 /* co network layer */ +#define CONL_ERROR_MASK 0x8400 /* co network layer */ #define CLNL_ERROR_MASK 0x8200 /* cl network layer */ #define TP_ERROR_SNDC 0x10000 /* kludge to force DC's on certain errors */ #define E_CO_NOERROR (CONL_ERROR_MASK | 0x0) /* no add'l info */ /******************************************************************************/ -/* */ -/* */ -/* Transport Layer */ -/* */ -/* */ +/* */ +/* */ +/* Transport Layer */ +/* */ +/* */ /******************************************************************************/ -#define E_TP_DR_NO_REAS (TP_ERROR_MASK | 0x0) /* dr reason not specified*/ -#define E_TP_CONGEST (TP_ERROR_MASK | 0x1) /* dr reason congestion */ -#define E_TP_NO_SESSION (TP_ERROR_MASK | 0x2) /* dr reason no sess ent */ -#define E_TP_ADDR_UNK (TP_ERROR_MASK | 0x3) /* dr reason addr unknown */ +#define E_TP_DR_NO_REAS (TP_ERROR_MASK | 0x0) /* dr reason not specified */ +#define E_TP_CONGEST (TP_ERROR_MASK | 0x1) /* dr reason congestion */ +#define E_TP_NO_SESSION (TP_ERROR_MASK | 0x2) /* dr reason no sess ent */ +#define E_TP_ADDR_UNK (TP_ERROR_MASK | 0x3) /* dr reason addr unknown */ -#define E_TP_ER_NO_REAS (TP_ERROR_MASK | 0x40) /* er reas not specified */ -#define E_TP_INV_PCODE (TP_ERROR_MASK | 0x41) /* er reas invalid parm code */ -#define E_TP_INV_TPDU (TP_ERROR_MASK | 0x42) /* er reas invalid tpdu type */ -#define E_TP_INV_PVAL (TP_ERROR_MASK | 0x43) /* er reas invalid parm value*/ +#define E_TP_ER_NO_REAS (TP_ERROR_MASK | 0x40) /* er reas not specified */ +#define E_TP_INV_PCODE (TP_ERROR_MASK | 0x41) /* er reas invalid parm code */ +#define E_TP_INV_TPDU (TP_ERROR_MASK | 0x42) /* er reas invalid tpdu type */ +#define E_TP_INV_PVAL (TP_ERROR_MASK | 0x43) /* er reas invalid parm value */ -#define E_TP_NORMAL_DISC (TP_ERROR_MASK | 0x80) /* dr reas normal disc */ -#define E_TP_CONGEST_2 (TP_ERROR_MASK | 0x81) /* dr reason congestion */ -#define E_TP_NEGOT_FAILED (TP_ERROR_MASK | 0x82) /* dr negotiation failed */ -#define E_TP_DUPL_SRCREF (TP_ERROR_MASK | 0x83) /* dr duplicate src ref */ -#define E_TP_MISM_REFS (TP_ERROR_MASK | 0x84) /* dr mismatched references*/ -#define E_TP_PROTO_ERR (TP_ERROR_MASK | 0x85) /* dr protocol error*/ +#define E_TP_NORMAL_DISC (TP_ERROR_MASK | 0x80) /* dr reas normal disc */ +#define E_TP_CONGEST_2 (TP_ERROR_MASK | 0x81) /* dr reason congestion */ +#define E_TP_NEGOT_FAILED (TP_ERROR_MASK | 0x82) /* dr negotiation failed */ +#define E_TP_DUPL_SRCREF (TP_ERROR_MASK | 0x83) /* dr duplicate src ref */ +#define E_TP_MISM_REFS (TP_ERROR_MASK | 0x84) /* dr mismatched references */ +#define E_TP_PROTO_ERR (TP_ERROR_MASK | 0x85) /* dr protocol error */ /* 0x86 not used */ -#define E_TP_REF_OVERFLOW (TP_ERROR_MASK | 0x87) /* dr reference overflow */ -#define E_TP_NO_CR_ON_NC (TP_ERROR_MASK | 0x88) /* dr cr refused on this nc */ +#define E_TP_REF_OVERFLOW (TP_ERROR_MASK | 0x87) /* dr reference overflow */ +#define E_TP_NO_CR_ON_NC (TP_ERROR_MASK | 0x88) /* dr cr refused on this nc */ /* 0x89 not used */ -#define E_TP_LENGTH_INVAL (TP_ERROR_MASK | 0x8a) /* dr inval length in hdr*/ +#define E_TP_LENGTH_INVAL (TP_ERROR_MASK | 0x8a) /* dr inval length in + * hdr */ /******************************************************************************/ -/* */ -/* */ -/* Connection Less Network Layer */ -/* */ -/* */ +/* */ +/* */ +/* Connection Less Network Layer */ +/* */ +/* */ /******************************************************************************/ -#ifdef notdef /* This doesn't look like legal C to me or the compiler. */ -#define E_CLNL_??? (CLNL_ERROR_MASK | 0x1) /* explanation */ +#ifdef notdef /* This doesn't look like legal C to me or + * the compiler. */ +#define E_CLNL_??? (CLNL_ERROR_MASK | 0x1) /* explanation */ #endif /******************************************************************************/ -/* */ -/* */ -/* Connection Oriented Network Layer */ -/* */ -/* */ +/* */ +/* */ +/* Connection Oriented Network Layer */ +/* */ +/* */ /******************************************************************************/ - /* see p. 149 of ISO 8208 */ +/* see p. 149 of ISO 8208 */ #define E_CO_NOERROR (CONL_ERROR_MASK | 0x0) /* no add'l info */ #define E_CO_INV_PS (CONL_ERROR_MASK | 0x1) /* invalid p(s) */ #define E_CO_INV_PR (CONL_ERROR_MASK | 0x2) /* invalid p(r) */ - /* dot dot dot */ -#define E_CO_INV_PKT_TYPE (CONL_ERROR_MASK | 0x10) /* packet type invalid*/ +/* dot dot dot */ +#define E_CO_INV_PKT_TYPE (CONL_ERROR_MASK | 0x10) /* packet type invalid */ #define E_CO_INV_PKT_R1 (CONL_ERROR_MASK | 0x11) /* for state r1 */ #define E_CO_INV_PKT_R2 (CONL_ERROR_MASK | 0x12) /* for state r2 */ #define E_CO_INV_PKT_R3 (CONL_ERROR_MASK | 0x13) /* for state r3 */ @@ -142,76 +145,82 @@ SOFTWARE. #define E_CO_INV_PKT_D1 (CONL_ERROR_MASK | 0x1b) /* for state d1 */ #define E_CO_INV_PKT_D2 (CONL_ERROR_MASK | 0x1c) /* for state d2 */ #define E_CO_INV_PKT_D3 (CONL_ERROR_MASK | 0x1d) /* for state d3 */ - /* dot dot dot */ -#define E_CO_PKT_NOT_ALWD (CONL_ERROR_MASK | 0x20) /* packet not allowed */ -#define E_CO_PNA_UNIDENT (CONL_ERROR_MASK | 0x21) /* unidentifiable pkt */ -#define E_CO_PNA_ONEWAY (CONL_ERROR_MASK | 0x22) /* call on 1-way lc */ -#define E_CO_PNA_PVC (CONL_ERROR_MASK | 0x23) /* inv pkt type on a pvc */ -#define E_CO_PNA_UNASSLC (CONL_ERROR_MASK | 0x24) /* pkt on unassigned lc */ -#define E_CO_PNA_REJECT (CONL_ERROR_MASK | 0x25) /* REJ not subscribed to*/ -#define E_CO_PNA_SHORT (CONL_ERROR_MASK | 0x26) /* pkt too short */ -#define E_CO_PNA_LONG (CONL_ERROR_MASK | 0x27) /* pkt too long */ -#define E_CO_PNA_INVGFI (CONL_ERROR_MASK | 0x28) /* inv gen format id */ +/* dot dot dot */ +#define E_CO_PKT_NOT_ALWD (CONL_ERROR_MASK | 0x20) /* packet not allowed */ +#define E_CO_PNA_UNIDENT (CONL_ERROR_MASK | 0x21) /* unidentifiable pkt */ +#define E_CO_PNA_ONEWAY (CONL_ERROR_MASK | 0x22) /* call on 1-way lc */ +#define E_CO_PNA_PVC (CONL_ERROR_MASK | 0x23) /* inv pkt type on a pvc */ +#define E_CO_PNA_UNASSLC (CONL_ERROR_MASK | 0x24) /* pkt on unassigned lc */ +#define E_CO_PNA_REJECT (CONL_ERROR_MASK | 0x25) /* REJ not subscribed to */ +#define E_CO_PNA_SHORT (CONL_ERROR_MASK | 0x26) /* pkt too short */ +#define E_CO_PNA_LONG (CONL_ERROR_MASK | 0x27) /* pkt too long */ +#define E_CO_PNA_INVGFI (CONL_ERROR_MASK | 0x28) /* inv gen format id */ #define E_CO_PNA_NZLCI (CONL_ERROR_MASK | 0x29) \ - /* restart or reg pkt with nonzero logical channel identifier */ + /* restart or reg pkt with nonzero logical + * channel identifier */ #define E_CO_PNA_FACIL (CONL_ERROR_MASK | 0x2a) \ - /* pkt type not compat with facility */ + /* pkt type not compat with facility */ #define E_CO_PNA_UINTCON (CONL_ERROR_MASK | 0x2b) /* unauthor intrpt conf */ -#define E_CO_PNA_UINTRPT (CONL_ERROR_MASK | 0x2c) /* unauthorized intrpt */ -#define E_CO_PNA_UREJECT (CONL_ERROR_MASK | 0x2d) /* unauthorized reject */ +#define E_CO_PNA_UINTRPT (CONL_ERROR_MASK | 0x2c) /* unauthorized intrpt */ +#define E_CO_PNA_UREJECT (CONL_ERROR_MASK | 0x2d) /* unauthorized reject */ -#define E_CO_TMR_EXP (CONL_ERROR_MASK | 0x30) /* timer expired */ -#define E_CO_TMR_CALR (CONL_ERROR_MASK | 0x31) /* inc. call or call req */ -#define E_CO_TMR_CLRI (CONL_ERROR_MASK | 0x32) /* clear indication */ -#define E_CO_TMR_RSTI (CONL_ERROR_MASK | 0x33) /* reset indication */ -#define E_CO_TMR_RRTI (CONL_ERROR_MASK | 0x34) /* restart indication */ +#define E_CO_TMR_EXP (CONL_ERROR_MASK | 0x30) /* timer expired */ +#define E_CO_TMR_CALR (CONL_ERROR_MASK | 0x31) /* inc. call or call req */ +#define E_CO_TMR_CLRI (CONL_ERROR_MASK | 0x32) /* clear indication */ +#define E_CO_TMR_RSTI (CONL_ERROR_MASK | 0x33) /* reset indication */ +#define E_CO_TMR_RRTI (CONL_ERROR_MASK | 0x34) /* restart indication */ #define E_CO_REG_PROB (CONL_ERROR_MASK | 0x40)\ - /* call setup, clear, or registration problem */ -#define E_CO_REG_CODE (CONL_ERROR_MASK | 0x41) /* code not allowed */ -#define E_CO_REG_PARM (CONL_ERROR_MASK | 0x42) /* parameter not allowed */ -#define E_CO_REG_ICDA (CONL_ERROR_MASK | 0x43) /* invalid called addr */ -#define E_CO_REG_ICGA (CONL_ERROR_MASK | 0x44) /* invalid calling addr */ -#define E_CO_REG_ILEN (CONL_ERROR_MASK | 0x45) /* invalid facil length */ -#define E_CO_REG_IBAR (CONL_ERROR_MASK | 0x46) /* incoming call barred */ -#define E_CO_REG_NOLC (CONL_ERROR_MASK | 0x47) /* no logical chan avail*/ -#define E_CO_REG_COLL (CONL_ERROR_MASK | 0x48) /* call collision */ -#define E_CO_REG_DUPF (CONL_ERROR_MASK | 0x49) /* dupl facil requested */ -#define E_CO_REG_NZAL (CONL_ERROR_MASK | 0x4a) /* non-zero addr length */ -#define E_CO_REG_NZFL (CONL_ERROR_MASK | 0x4b) /* non-zero facil length */ + /* call setup, clear, or registration problem */ +#define E_CO_REG_CODE (CONL_ERROR_MASK | 0x41) /* code not allowed */ +#define E_CO_REG_PARM (CONL_ERROR_MASK | 0x42) /* parameter not allowed */ +#define E_CO_REG_ICDA (CONL_ERROR_MASK | 0x43) /* invalid called addr */ +#define E_CO_REG_ICGA (CONL_ERROR_MASK | 0x44) /* invalid calling addr */ +#define E_CO_REG_ILEN (CONL_ERROR_MASK | 0x45) /* invalid facil length */ +#define E_CO_REG_IBAR (CONL_ERROR_MASK | 0x46) /* incoming call barred */ +#define E_CO_REG_NOLC (CONL_ERROR_MASK | 0x47) /* no logical chan avail */ +#define E_CO_REG_COLL (CONL_ERROR_MASK | 0x48) /* call collision */ +#define E_CO_REG_DUPF (CONL_ERROR_MASK | 0x49) /* dupl facil requested */ +#define E_CO_REG_NZAL (CONL_ERROR_MASK | 0x4a) /* non-zero addr length */ +#define E_CO_REG_NZFL (CONL_ERROR_MASK | 0x4b) /* non-zero facil length */ #define E_CO_REG_EFNP (CONL_ERROR_MASK | 0x4c) \ - /* expected facil not provided */ + /* expected facil not provided */ #define E_CO_REG_ICCITT (CONL_ERROR_MASK | 0x4d) \ - /* invalid CCITT-specified DTE facil */ + /* invalid CCITT-specified DTE facil */ -#define E_CO_MISC (CONL_ERROR_MASK | 0x50) /* miscellaneous */ -#define E_CO_MISC_CAUSE (CONL_ERROR_MASK | 0x51) /* improper cause code */ -#define E_CO_MISC_ALIGN (CONL_ERROR_MASK | 0x52) /* not octet-aligned */ +#define E_CO_MISC (CONL_ERROR_MASK | 0x50) /* miscellaneous */ +#define E_CO_MISC_CAUSE (CONL_ERROR_MASK | 0x51) /* improper cause code */ +#define E_CO_MISC_ALIGN (CONL_ERROR_MASK | 0x52) /* not octet-aligned */ #define E_CO_MISC_IQBS (CONL_ERROR_MASK | 0x53) \ - /* inconsistent Q bit settings */ + /* inconsistent Q bit settings */ -#define E_CO_INTL (CONL_ERROR_MASK | 0x70) /* international problem */ -#define E_CO_IREMNWK (CONL_ERROR_MASK | 0x71) /* remote network problem */ -#define E_CO_INPROTO (CONL_ERROR_MASK | 0x72) /* int'l protocol problem */ -#define E_CO_ILINKDWN (CONL_ERROR_MASK | 0x73) /* int'l link down */ -#define E_CO_ILINKBSY (CONL_ERROR_MASK | 0x74) /* int'l link busy */ -#define E_CO_IXNETFAC (CONL_ERROR_MASK | 0x75) /* transit netwk facil */ -#define E_CO_IRNETFAC (CONL_ERROR_MASK | 0x76) /* remote netwk facil */ -#define E_CO_IROUTING (CONL_ERROR_MASK | 0x77) /* int'l routing prob */ -#define E_CO_ITMPRTG (CONL_ERROR_MASK | 0x78) /* temporary routing prob */ -#define E_CO_IUNKDNIC (CONL_ERROR_MASK | 0x79) /* unknown called DNIC */ +#define E_CO_INTL (CONL_ERROR_MASK | 0x70) /* international problem */ +#define E_CO_IREMNWK (CONL_ERROR_MASK | 0x71) /* remote network + * problem */ +#define E_CO_INPROTO (CONL_ERROR_MASK | 0x72) /* int'l protocol + * problem */ +#define E_CO_ILINKDWN (CONL_ERROR_MASK | 0x73) /* int'l link down */ +#define E_CO_ILINKBSY (CONL_ERROR_MASK | 0x74) /* int'l link busy */ +#define E_CO_IXNETFAC (CONL_ERROR_MASK | 0x75) /* transit netwk facil */ +#define E_CO_IRNETFAC (CONL_ERROR_MASK | 0x76) /* remote netwk facil */ +#define E_CO_IROUTING (CONL_ERROR_MASK | 0x77) /* int'l routing prob */ +#define E_CO_ITMPRTG (CONL_ERROR_MASK | 0x78) /* temporary routing + * prob */ +#define E_CO_IUNKDNIC (CONL_ERROR_MASK | 0x79) /* unknown called DNIC */ #define E_CO_IMAINT (CONL_ERROR_MASK | 0x7a) /* maintenance action */ #define E_CO_TIMO (CONL_ERROR_MASK | 0x90) \ - /* timer expired or retransmission count surpassed */ + /* timer expired or retransmission count + * surpassed */ #define E_CO_TIM_INTRP (CONL_ERROR_MASK | 0x91) /* for interrupt */ -#define E_CO_TIM_DATA (CONL_ERROR_MASK | 0x92) /* for data */ -#define E_CO_TIM_REJ (CONL_ERROR_MASK | 0x93) /* for reject */ +#define E_CO_TIM_DATA (CONL_ERROR_MASK | 0x92) /* for data */ +#define E_CO_TIM_REJ (CONL_ERROR_MASK | 0x93) /* for reject */ #define E_CO_DTE_SPEC (CONL_ERROR_MASK | 0xa0) /* DTE-specific */ #define E_CO_DTE_OK (CONL_ERROR_MASK | 0xa1) /* DTE operational */ #define E_CO_DTE_NOK (CONL_ERROR_MASK | 0xa2) /* DTE not operational */ -#define E_CO_DTE_RSRC (CONL_ERROR_MASK | 0xa3) /* DTE resource constraint*/ +#define E_CO_DTE_RSRC (CONL_ERROR_MASK | 0xa3) /* DTE resource + * constraint */ #define E_CO_DTE_FSLCT (CONL_ERROR_MASK | 0xa4) /* fast select not subsc */ #define E_CO_DTE_PFPKT (CONL_ERROR_MASK | 0xa5) /* partially full pkt */ #define E_CO_DTE_DBIT (CONL_ERROR_MASK | 0xa6) /* D-bit proc not supp */ @@ -224,16 +233,21 @@ SOFTWARE. #define E_CO_OSI_REJP (CONL_ERROR_MASK | 0xe4) /* reject permanent */ #define E_CO_OSI_QOST (CONL_ERROR_MASK | 0xe5) /* reject QOS transient */ #define E_CO_OSI_QOSP (CONL_ERROR_MASK | 0xe6) /* reject QOS permanent */ -#define E_CO_OSI_NSAPT (CONL_ERROR_MASK | 0xe7) /* NSAP unreach transient */ -#define E_CO_OSI_NSAPP (CONL_ERROR_MASK | 0xe8) /* NSAP unreach permanent */ +#define E_CO_OSI_NSAPT (CONL_ERROR_MASK | 0xe7) /* NSAP unreach + * transient */ +#define E_CO_OSI_NSAPP (CONL_ERROR_MASK | 0xe8) /* NSAP unreach + * permanent */ #define E_CO_OSI_RESET (CONL_ERROR_MASK | 0xe9) /* reset no reason */ #define E_CO_OSI_CONGEST (CONL_ERROR_MASK | 0xea) /* reset congestion */ -#define E_CO_OSI_UNSAP (CONL_ERROR_MASK | 0xeb) /* unknown NSAP permanent */ +#define E_CO_OSI_UNSAP (CONL_ERROR_MASK | 0xeb) /* unknown NSAP + * permanent */ -#define E_CO_HLI_INIT (CONL_ERROR_MASK | 0xf0) /* higher level initiated*/ +#define E_CO_HLI_INIT (CONL_ERROR_MASK | 0xf0) /* higher level + * initiated */ #define E_CO_HLI_DISCN (CONL_ERROR_MASK | 0xf1) /* disconnect normal */ #define E_CO_HLI_DISCA (CONL_ERROR_MASK | 0xf2) /* disconnect abnormal */ -#define E_CO_HLI_DISCI (CONL_ERROR_MASK | 0xf3) /* disconnect incompatible*/ +#define E_CO_HLI_DISCI (CONL_ERROR_MASK | 0xf3) /* disconnect + * incompatible */ #define E_CO_HLI_REJT (CONL_ERROR_MASK | 0xf4) /* reject transient */ #define E_CO_HLI_REJP (CONL_ERROR_MASK | 0xf5) /* reject permanent */ #define E_CO_HLI_QOST (CONL_ERROR_MASK | 0xf6) /* reject QOS transient */ @@ -243,26 +257,27 @@ SOFTWARE. #define E_CO_HLI_RESYNC (CONL_ERROR_MASK | 0xfa) /* reset - user resync */ /* Cause on 8208 CLEAR field */ -#define E_CO_NUMBERBUSY (CONL_ERROR_MASK | 0x101) /* Number busy */ -#define E_CO_INVFACREQ (CONL_ERROR_MASK | 0x103) /* invalid facil req */ -#define E_CO_NETCONGEST (CONL_ERROR_MASK | 0x105) /* Network congestion */ -#define E_CO_OUTOFORDER (CONL_ERROR_MASK | 0x109) /* Out of order */ -#define E_CO_ACCESSBAR (CONL_ERROR_MASK | 0x10b) /* access barred */ -#define E_CO_NOTOBTAIN (CONL_ERROR_MASK | 0x10d) /* not obtainable */ -#define E_CO_REMPROCERR (CONL_ERROR_MASK | 0x111) /* Remote procedure err */ -#define E_CO_LOCPROCERR (CONL_ERROR_MASK | 0x113) /* Local procedure err */ -#define E_CO_RPOAOOO (CONL_ERROR_MASK | 0x115) /* RPOA out of order */ -#define E_CO_NOREVCHG (CONL_ERROR_MASK | 0x119) /* Revs chg not accepted*/ -#define E_CO_INCOMPAT (CONL_ERROR_MASK | 0x121) /* Incompatible dest */ -#define E_CO_NOFASTSEL (CONL_ERROR_MASK | 0x129) - /* Fast select accpt not subscribed */ -#define E_CO_NOSHIP (CONL_ERROR_MASK | 0x139) /* ship absent */ -#define E_CO_GWPROCERR (CONL_ERROR_MASK | 0x1c1) /* Gateway-detected err*/ -#define E_CO_GWCONGEST (CONL_ERROR_MASK | 0x1c3) /* Gateway congestion*/ +#define E_CO_NUMBERBUSY (CONL_ERROR_MASK | 0x101) /* Number busy */ +#define E_CO_INVFACREQ (CONL_ERROR_MASK | 0x103) /* invalid facil req */ +#define E_CO_NETCONGEST (CONL_ERROR_MASK | 0x105) /* Network congestion */ +#define E_CO_OUTOFORDER (CONL_ERROR_MASK | 0x109) /* Out of order */ +#define E_CO_ACCESSBAR (CONL_ERROR_MASK | 0x10b) /* access barred */ +#define E_CO_NOTOBTAIN (CONL_ERROR_MASK | 0x10d) /* not obtainable */ +#define E_CO_REMPROCERR (CONL_ERROR_MASK | 0x111) /* Remote procedure err */ +#define E_CO_LOCPROCERR (CONL_ERROR_MASK | 0x113) /* Local procedure err */ +#define E_CO_RPOAOOO (CONL_ERROR_MASK | 0x115) /* RPOA out of order */ +#define E_CO_NOREVCHG (CONL_ERROR_MASK | 0x119) /* Revs chg not accepted */ +#define E_CO_INCOMPAT (CONL_ERROR_MASK | 0x121) /* Incompatible dest */ +#define E_CO_NOFASTSEL (CONL_ERROR_MASK | 0x129) +/* Fast select accpt not subscribed */ +#define E_CO_NOSHIP (CONL_ERROR_MASK | 0x139) /* ship absent */ +#define E_CO_GWPROCERR (CONL_ERROR_MASK | 0x1c1) /* Gateway-detected err */ +#define E_CO_GWCONGEST (CONL_ERROR_MASK | 0x1c3) /* Gateway congestion */ /* ARGO only */ -#define E_CO_QFULL (CONL_ERROR_MASK | 0x100) /* dropped packet - queue full*/ -#define E_CO_AIWP (CONL_ERROR_MASK | 0x102) /* addr incompat w/proto */ +#define E_CO_QFULL (CONL_ERROR_MASK | 0x100) /* dropped packet - + * queue full */ +#define E_CO_AIWP (CONL_ERROR_MASK | 0x102) /* addr incompat w/proto */ #define E_CO_CHAN (CONL_ERROR_MASK | 0x104) /* bad channel number */ /* ARGO only; driver specific */ @@ -275,4 +290,4 @@ SOFTWARE. #define CONL_ERROR_MAX 0x1c3 -#endif /* _NETISO_ISO_ERRNO_H_ */ +#endif /* _NETISO_ISO_ERRNO_H_ */ diff --git a/sys/netiso/iso_pcb.c b/sys/netiso/iso_pcb.c index 9e4b30ba0e6..2bc72461025 100644 --- a/sys/netiso/iso_pcb.c +++ b/sys/netiso/iso_pcb.c @@ -1,4 +1,5 @@ -/* $NetBSD: iso_pcb.c,v 1.8 1995/08/17 02:57:33 mycroft Exp $ */ +/* $OpenBSD: iso_pcb.c,v 1.2 1996/03/04 10:35:34 mickey Exp $ */ +/* $NetBSD: iso_pcb.c,v 1.9 1996/02/13 22:10:13 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -88,10 +89,11 @@ SOFTWARE. #include <netccitt/x25.h> #include <netccitt/pk.h> #include <netccitt/pk_var.h> +#include <netccitt/pk_extern.h> #endif #define PCBNULL (struct isopcb *)0 -struct iso_addr zeroiso_addr = { +struct iso_addr zeroiso_addr = { 0 }; @@ -99,26 +101,29 @@ struct iso_addr zeroiso_addr = { /* * FUNCTION: iso_pcballoc * - * PURPOSE: creates an isopcb structure in an mbuf, - * with socket (so), and - * puts it in the queue with head (head) + * PURPOSE: creates an isopcb structure in an mbuf, + * with socket (so), and + * puts it in the queue with head (head) * - * RETURNS: 0 if OK, ENOBUFS if can't alloc the necessary mbuf + * RETURNS: 0 if OK, ENOBUFS if can't alloc the necessary mbuf */ int -iso_pcballoc(so, head) - struct socket *so; - struct isopcb *head; +iso_pcballoc(so, v) + struct socket *so; + void *v; { + struct isopcb *head = v; register struct isopcb *isop; - IFDEBUG(D_ISO) - printf("iso_pcballoc(so 0x%x)\n", so); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { + printf("iso_pcballoc(so 0x%x)\n", (unsigned int) so); + } +#endif MALLOC(isop, struct isopcb *, sizeof(*isop), M_PCB, M_NOWAIT); if (isop == NULL) return ENOBUFS; - bzero((caddr_t)isop, sizeof(*isop)); + bzero(isop, sizeof(*isop)); isop->isop_head = head; isop->isop_socket = so; insque(isop, head); @@ -126,46 +131,50 @@ iso_pcballoc(so, head) so->so_pcb = isop; return 0; } - + /* * FUNCTION: iso_pcbbind * - * PURPOSE: binds the address given in *(nam) to the socket - * specified by the isopcb in *(isop) - * If the given address is zero, it makes sure the - * address isn't already in use and if it's got a network - * portion, we look for an interface with that network - * address. If the address given is zero, we allocate - * a port and stuff it in the (nam) structure. + * PURPOSE: binds the address given in *(nam) to the socket + * specified by the isopcb in *(isop) + * If the given address is zero, it makes sure the + * address isn't already in use and if it's got a network + * portion, we look for an interface with that network + * address. If the address given is zero, we allocate + * a port and stuff it in the (nam) structure. * - * RETURNS: errno E* or 0 if ok. + * RETURNS: errno E* or 0 if ok. * * SIDE EFFECTS: increments head->isop_lport if it allocates a port # * - * NOTES: + * NOTES: */ int -iso_pcbbind(isop, nam) - register struct isopcb *isop; - struct mbuf *nam; +iso_pcbbind(v, nam) + register void *v; + struct mbuf *nam; { + register struct isopcb *isop = v; register struct isopcb *head = isop->isop_head; register struct sockaddr_iso *siso; struct iso_ifaddr *ia; union { - char data[2]; - u_short s; + char data[2]; + u_short s; } suf; - IFDEBUG(D_ISO) - printf("iso_pcbbind(isop 0x%x, nam 0x%x)\n", isop, nam); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { + printf("iso_pcbbind(isop 0x%x, nam 0x%x)\n", + (unsigned int) isop, (unsigned int) nam); + } +#endif suf.s = 0; - if (iso_ifaddr.tqh_first == 0) /* any interfaces attached? */ + if (iso_ifaddr.tqh_first == 0) /* any interfaces attached? */ return EADDRNOTAVAIL; - if (isop->isop_laddr) /* already bound */ + if (isop->isop_laddr) /* already bound */ return EADDRINUSE; - if(nam == (struct mbuf *)0) { + if (nam == (struct mbuf *) 0) { isop->isop_laddr = &isop->isop_sladdr; isop->isop_sladdr.siso_len = sizeof(struct sockaddr_iso); isop->isop_sladdr.siso_family = AF_ISO; @@ -176,10 +185,12 @@ iso_pcbbind(isop, nam) goto noname; } siso = mtod(nam, struct sockaddr_iso *); - IFDEBUG(D_ISO) +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { printf("iso_pcbbind(name len 0x%x)\n", nam->m_len); printf("The address is %s\n", clnp_iso_addrp(&siso->siso_addr)); - ENDDEBUG + } +#endif /* * We would like sort of length check but since some OSI addrs * do not have fixed length, we can't really do much. @@ -189,46 +200,50 @@ iso_pcbbind(isop, nam) * However, in fact the size of the whole thing is a struct * sockaddr_iso, so probably this is what we should check for. */ - if( (nam->m_len < 2) || (nam->m_len < siso->siso_len)) { - return ENAMETOOLONG; + if ((nam->m_len < 2) || (nam->m_len < siso->siso_len)) { + return ENAMETOOLONG; } if (siso->siso_nlen) { /* non-zero net addr- better match one of our interfaces */ - IFDEBUG(D_ISO) +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { printf("iso_pcbbind: bind to NOT zeroisoaddr\n"); - ENDDEBUG - for (ia = iso_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next) + } +#endif + for (ia = iso_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next) if (SAME_ISOADDR(siso, &ia->ia_addr)) break; if (ia == 0) return EADDRNOTAVAIL; - } - if (siso->siso_len <= sizeof (isop->isop_sladdr)) { + } + if (siso->siso_len <= sizeof(isop->isop_sladdr)) { isop->isop_laddr = &isop->isop_sladdr; } else { - if ((nam = m_copy(nam, 0, (int)M_COPYALL)) == 0) + if ((nam = m_copy(nam, 0, (int) M_COPYALL)) == 0) return ENOBUFS; isop->isop_laddr = mtod(nam, struct sockaddr_iso *); } - bcopy((caddr_t)siso, (caddr_t)isop->isop_laddr, siso->siso_len); + bcopy((caddr_t) siso, (caddr_t) isop->isop_laddr, siso->siso_len); if (siso->siso_tlen == 0) goto noname; if ((isop->isop_socket->so_options & SO_REUSEADDR) == 0 && - iso_pcblookup(head, 0, (caddr_t)0, isop->isop_laddr)) + iso_pcblookup(head, 0, (caddr_t) 0, isop->isop_laddr)) return EADDRINUSE; if (siso->siso_tlen <= 2) { bcopy(TSEL(siso), suf.data, sizeof(suf.data)); suf.s = ntohs(suf.s); - if((suf.s < ISO_PORT_RESERVED) && - (isop->isop_socket->so_state && SS_PRIV) == 0) + if ((suf.s < ISO_PORT_RESERVED) && + (isop->isop_socket->so_state && SS_PRIV) == 0) return EACCES; } else { - register char *cp; + register char *cp; noname: cp = TSEL(isop->isop_laddr); - IFDEBUG(D_ISO) - printf("iso_pcbbind noname\n"); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { + printf("iso_pcbbind noname\n"); + } +#endif do { if (head->isop_lport++ < ISO_PORT_RESERVED || head->isop_lport > ISO_PORT_USERRESERVED) @@ -236,60 +251,66 @@ noname: suf.s = htons(head->isop_lport); cp[0] = suf.data[0]; cp[1] = suf.data[1]; - } while (iso_pcblookup(head, 0, (caddr_t)0, isop->isop_laddr)); + } while (iso_pcblookup(head, 0, (caddr_t) 0, isop->isop_laddr)); + } +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { + printf("iso_pcbbind returns 0, suf 0x%x\n", suf.s); } - IFDEBUG(D_ISO) - printf("iso_pcbbind returns 0, suf 0x%x\n", suf); - ENDDEBUG +#endif return 0; } /* * FUNCTION: iso_pcbconnect * - * PURPOSE: Make the isopcb (isop) look like it's connected. - * In other words, give it the peer address given in - * the mbuf * (nam). Make sure such a combination - * of local, peer addresses doesn't already exist - * for this protocol. Internet mentality prevails here, - * wherein a src,dst pair uniquely identifies a connection. - * Both net address and port must be specified in argument - * (nam). - * If we don't have a local address for this socket yet, - * we pick one by calling iso_pcbbind(). + * PURPOSE: Make the isopcb (isop) look like it's connected. + * In other words, give it the peer address given in + * the mbuf * (nam). Make sure such a combination + * of local, peer addresses doesn't already exist + * for this protocol. Internet mentality prevails here, + * wherein a src,dst pair uniquely identifies a connection. + * Both net address and port must be specified in argument + * (nam). + * If we don't have a local address for this socket yet, + * we pick one by calling iso_pcbbind(). * - * RETURNS: errno E* or 0 if ok. + * RETURNS: errno E* or 0 if ok. * * SIDE EFFECTS: Looks up a route, which may cause one to be left - * in the isopcb. + * in the isopcb. * - * NOTES: + * NOTES: */ int -iso_pcbconnect(isop, nam) - register struct isopcb *isop; - struct mbuf *nam; +iso_pcbconnect(v, nam) + void *v; + struct mbuf *nam; { - register struct sockaddr_iso *siso = mtod(nam, struct sockaddr_iso *); - int local_zero, error = 0; - struct iso_ifaddr *ia; + register struct isopcb *isop = v; + register struct sockaddr_iso *siso = mtod(nam, struct sockaddr_iso *); + int local_zero, error = 0; + struct iso_ifaddr *ia; - IFDEBUG(D_ISO) +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { printf("iso_pcbconnect(isop 0x%x sock 0x%x nam 0x%x", - isop, isop->isop_socket, nam); + (unsigned int) isop, (unsigned int) isop->isop_socket, + (unsigned int) nam); printf("nam->m_len 0x%x), addr:\n", nam->m_len); dump_isoaddr(siso); - ENDDEBUG + } +#endif if (nam->m_len < siso->siso_len) - return EINVAL; + return EINVAL; if (siso->siso_family != AF_ISO) return EAFNOSUPPORT; if (siso->siso_nlen == 0) { - if (ia = iso_ifaddr.tqh_first) { - int nlen = ia->ia_addr.siso_nlen; + if ((ia = iso_ifaddr.tqh_first) != NULL) { + int nlen = ia->ia_addr.siso_nlen; ovbcopy(TSEL(siso), nlen + TSEL(siso), - siso->siso_plen + siso->siso_tlen + siso->siso_slen); - bcopy((caddr_t)&ia->ia_addr.siso_addr, - (caddr_t)&siso->siso_addr, nlen + 1); + siso->siso_plen + siso->siso_tlen + siso->siso_slen); + bcopy((caddr_t) & ia->ia_addr.siso_addr, + (caddr_t) & siso->siso_addr, nlen + 1); /* includes siso->siso_nlen = nlen; */ } else return EADDRNOTAVAIL; @@ -299,37 +320,45 @@ iso_pcbconnect(isop, nam) * particular local interface. So, if we want to send somebody * we need to choose a return address. */ - local_zero = + local_zero = ((isop->isop_laddr == 0) || (isop->isop_laddr->siso_nlen == 0)); if (local_zero) { - int flags; + int flags; - IFDEBUG(D_ISO) +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { printf("iso_pcbconnect localzero 1\n"); - ENDDEBUG - /* - * If route is known or can be allocated now, - * our src addr is taken from the i/f, else punt. + } +#endif + /* + * If route is known or can be allocated now, our src addr is + * taken from the i/f, else punt. */ flags = isop->isop_socket->so_options & SO_DONTROUTE; - if (error = clnp_route(&siso->siso_addr, &isop->isop_route, flags, - (struct sockaddr **)0, &ia)) + error = clnp_route(&siso->siso_addr, &isop->isop_route, flags, + NULL, &ia); + if (error) return error; - IFDEBUG(D_ISO) +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { printf("iso_pcbconnect localzero 2, ro->ro_rt 0x%x", - isop->isop_route.ro_rt); - printf(" ia 0x%x\n", ia); - ENDDEBUG - } - IFDEBUG(D_ISO) - printf("in iso_pcbconnect before lookup isop 0x%x isop->sock 0x%x\n", - isop, isop->isop_socket); - ENDDEBUG + (unsigned int) isop->isop_route.ro_rt); + printf(" ia 0x%x\n", (unsigned int) ia); + } +#endif + } +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { + printf("in iso_pcbconnect before lookup isop 0x%x isop->sock 0x%x\n", + (unsigned int) isop, (unsigned int) isop->isop_socket); + } +#endif if (local_zero) { - int nlen, tlen, totlen; caddr_t oldtsel, newtsel; + int nlen, tlen, totlen; + caddr_t oldtsel, newtsel; siso = isop->isop_laddr; if (siso == 0 || siso->siso_tlen == 0) - (void)iso_pcbbind(isop, (struct mbuf *)0); + (void) iso_pcbbind(isop, NULL); /* * Here we have problem of squezeing in a definite network address * into an existing sockaddr_iso, which in fact may not have room @@ -341,10 +370,10 @@ iso_pcbconnect(isop, nam) nlen = ia->ia_addr.siso_nlen; totlen = tlen + nlen + _offsetof(struct sockaddr_iso, siso_data[0]); if ((siso == &isop->isop_sladdr) && - (totlen > sizeof(isop->isop_sladdr))) { - struct mbuf *m = m_get(M_DONTWAIT, MT_SONAME); + (totlen > sizeof(isop->isop_sladdr))) { + struct mbuf *m = m_get(M_DONTWAIT, MT_SONAME); if (m == 0) - return ENOBUFS; + return ENOBUFS; m->m_len = totlen; isop->isop_laddr = siso = mtod(m, struct sockaddr_iso *); } @@ -357,10 +386,12 @@ iso_pcbconnect(isop, nam) siso->siso_len = totlen; siso = mtod(nam, struct sockaddr_iso *); } - IFDEBUG(D_ISO) - printf("in iso_pcbconnect before bcopy isop 0x%x isop->sock 0x%x\n", - isop, isop->isop_socket); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { + printf("in iso_pcbconnect before bcopy isop 0x%x isop->sock 0x%x\n", + (unsigned int) isop, (unsigned int) isop->isop_socket); + } +#endif /* * If we had to allocate space to a previous big foreign address, * and for some reason we didn't free it, we reuse it knowing @@ -373,53 +404,57 @@ iso_pcbconnect(isop, nam) if (siso->siso_len <= sizeof(isop->isop_sfaddr)) isop->isop_faddr = &isop->isop_sfaddr; else { - struct mbuf *m = m_get(M_DONTWAIT, MT_SONAME); + struct mbuf *m = m_get(M_DONTWAIT, MT_SONAME); if (m == 0) return ENOBUFS; isop->isop_faddr = mtod(m, struct sockaddr_iso *); } } - bcopy((caddr_t)siso, (caddr_t)isop->isop_faddr, siso->siso_len); - IFDEBUG(D_ISO) - printf("in iso_pcbconnect after bcopy isop 0x%x isop->sock 0x%x\n", - isop, isop->isop_socket); + bcopy((caddr_t) siso, (caddr_t) isop->isop_faddr, siso->siso_len); +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { + printf("in iso_pcbconnect after bcopy isop 0x%x isop->sock 0x%x\n", + (unsigned int) isop, (unsigned int) isop->isop_socket); printf("iso_pcbconnect connected to addr:\n"); dump_isoaddr(isop->isop_faddr); printf("iso_pcbconnect end: src addr:\n"); dump_isoaddr(isop->isop_laddr); - ENDDEBUG + } +#endif return 0; } /* * FUNCTION: iso_pcbdisconnect() * - * PURPOSE: washes away the peer address info so the socket - * appears to be disconnected. - * If there's no file descriptor associated with the socket - * it detaches the pcb. + * PURPOSE: washes away the peer address info so the socket + * appears to be disconnected. + * If there's no file descriptor associated with the socket + * it detaches the pcb. * - * RETURNS: Nada. + * RETURNS: Nada. * * SIDE EFFECTS: May detach the pcb. * - * NOTES: + * NOTES: */ void -iso_pcbdisconnect(isop) - struct isopcb *isop; +iso_pcbdisconnect(v) + void *v; { - void iso_pcbdetach(); + struct isopcb *isop = v; register struct sockaddr_iso *siso; - IFDEBUG(D_ISO) - printf("iso_pcbdisconnect(isop 0x%x)\n", isop); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { + printf("iso_pcbdisconnect(isop 0x%x)\n", (unsigned int) isop); + } +#endif /* * Preserver binding infnormation if already bound. */ if ((siso = isop->isop_laddr) && siso->siso_nlen && siso->siso_tlen) { - caddr_t otsel = TSEL(siso); + caddr_t otsel = TSEL(siso); siso->siso_nlen = 0; ovbcopy(otsel, TSEL(siso), siso->siso_tlen); } @@ -433,29 +468,33 @@ iso_pcbdisconnect(isop) /* * FUNCTION: iso_pcbdetach * - * PURPOSE: detach the pcb at *(isop) from it's socket and free - * the mbufs associated with the pcb.. - * Dequeues (isop) from its head. + * PURPOSE: detach the pcb at *(isop) from it's socket and free + * the mbufs associated with the pcb.. + * Dequeues (isop) from its head. * - * RETURNS: Nada. + * RETURNS: Nada. * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ void -iso_pcbdetach(isop) - struct isopcb *isop; +iso_pcbdetach(v) + void *v; { - struct socket *so = isop->isop_socket; + struct isopcb *isop = v; + struct socket *so = isop->isop_socket; - IFDEBUG(D_ISO) - printf("iso_pcbdetach(isop 0x%x socket 0x%x so 0x%x)\n", - isop, isop->isop_socket, so); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { + printf("iso_pcbdetach(isop 0x%x socket 0x%x so 0x%x)\n", + (unsigned int) isop, (unsigned int) isop->isop_socket, + (unsigned int) so); + } +#endif #ifdef TPCONS if (isop->isop_chan) { - register struct pklcd *lcp = (struct pklcd *)isop->isop_chan; + register struct pklcd *lcp = (struct pklcd *) isop->isop_chan; if (--isop->isop_refcnt > 0) return; if (lcp && lcp->lcd_state == DATA_TRANSFER) { @@ -466,128 +505,157 @@ iso_pcbdetach(isop) isop->isop_chan = 0; } #endif - if (so) { /* in the x.25 domain, we sometimes have no socket */ + if (so) { /* in the x.25 domain, we sometimes have no + * socket */ so->so_pcb = 0; - sofree(so); + sofree(so); } - IFDEBUG(D_ISO) +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { printf("iso_pcbdetach 2 \n"); - ENDDEBUG + } +#endif if (isop->isop_options) - (void)m_free(isop->isop_options); - IFDEBUG(D_ISO) + (void) m_free(isop->isop_options); +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { printf("iso_pcbdetach 3 \n"); - ENDDEBUG + } +#endif if (isop->isop_route.ro_rt) rtfree(isop->isop_route.ro_rt); - IFDEBUG(D_ISO) +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { printf("iso_pcbdetach 3.1\n"); - ENDDEBUG + } +#endif if (isop->isop_clnpcache != NULL) { struct clnp_cache *clcp = - mtod(isop->isop_clnpcache, struct clnp_cache *); - IFDEBUG(D_ISO) - printf("iso_pcbdetach 3.2: clcp 0x%x freeing clc_hdr x%x\n", - clcp, clcp->clc_hdr); - ENDDEBUG + mtod(isop->isop_clnpcache, struct clnp_cache *); +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { + printf("iso_pcbdetach 3.2: clcp 0x%x freeing clc_hdr x%x\n", + (unsigned int) clcp, + (unsigned int) clcp->clc_hdr); + } +#endif if (clcp->clc_hdr != NULL) m_free(clcp->clc_hdr); - IFDEBUG(D_ISO) - printf("iso_pcbdetach 3.3: freeing cache x%x\n", - isop->isop_clnpcache); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { + printf("iso_pcbdetach 3.3: freeing cache x%x\n", + (unsigned int) isop->isop_clnpcache); + } +#endif m_free(isop->isop_clnpcache); } - IFDEBUG(D_ISO) +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { printf("iso_pcbdetach 4 \n"); - ENDDEBUG + } +#endif remque(isop); - IFDEBUG(D_ISO) +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { printf("iso_pcbdetach 5 \n"); - ENDDEBUG + } +#endif if (isop->isop_laddr && (isop->isop_laddr != &isop->isop_sladdr)) m_freem(dtom(isop->isop_laddr)); - free((caddr_t)isop, M_PCB); + free((caddr_t) isop, M_PCB); } /* * FUNCTION: iso_pcbnotify * - * PURPOSE: notify all connections in this protocol's queue (head) - * that have peer address (dst) of the problem (errno) - * by calling (notify) on the connections' isopcbs. + * PURPOSE: notify all connections in this protocol's queue (head) + * that have peer address (dst) of the problem (errno) + * by calling (notify) on the connections' isopcbs. * - * RETURNS: Rien. + * RETURNS: Rien. * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: (notify) is called at splimp! + * NOTES: (notify) is called at splimp! */ void iso_pcbnotify(head, siso, errno, notify) - struct isopcb *head; + struct isopcb *head; register struct sockaddr_iso *siso; - int errno, (*notify)(); + int errno; + void (*notify) __P((struct isopcb *)); { register struct isopcb *isop; - int s = splimp(); + int s = splimp(); - IFDEBUG(D_ISO) - printf("iso_pcbnotify(head 0x%x, notify 0x%x) dst:\n", head, notify); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { + printf("iso_pcbnotify(head 0x%x, notify 0x%x) dst:\n", + (unsigned int) head, (unsigned int) notify); + } +#endif for (isop = head->isop_next; isop != head; isop = isop->isop_next) { if (isop->isop_socket == 0 || isop->isop_faddr == 0 || - !SAME_ISOADDR(siso, isop->isop_faddr)) { - IFDEBUG(D_ISO) - printf("iso_pcbnotify: CONTINUE isop 0x%x, sock 0x%x\n" , - isop, isop->isop_socket); - printf("addrmatch cmp'd with (0x%x):\n", isop->isop_faddr); + !SAME_ISOADDR(siso, isop->isop_faddr)) { +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { + printf("iso_pcbnotify: CONTINUE isop 0x%x, sock 0x%x\n", + (unsigned int) isop, + (unsigned int) isop->isop_socket); + printf("addrmatch cmp'd with (0x%x):\n", + (unsigned int) isop->isop_faddr); dump_isoaddr(isop->isop_faddr); - ENDDEBUG + } +#endif continue; } - if (errno) + if (errno) isop->isop_socket->so_error = errno; if (notify) - (*notify)(isop); + (*notify) (isop); } splx(s); - IFDEBUG(D_ISO) - printf("END OF iso_pcbnotify\n" ); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { + printf("END OF iso_pcbnotify\n"); + } +#endif } /* * FUNCTION: iso_pcblookup * - * PURPOSE: looks for a given combination of (faddr), (fport), - * (lport), (laddr) in the queue named by (head). - * Argument (flags) is ignored. + * PURPOSE: looks for a given combination of (faddr), (fport), + * (lport), (laddr) in the queue named by (head). + * Argument (flags) is ignored. * - * RETURNS: ptr to the isopcb if it finds a connection matching - * these arguments, o.w. returns zero. + * RETURNS: ptr to the isopcb if it finds a connection matching + * these arguments, o.w. returns zero. * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ -struct isopcb * +struct isopcb * iso_pcblookup(head, fportlen, fport, laddr) - struct isopcb *head; + struct isopcb *head; register struct sockaddr_iso *laddr; - caddr_t fport; - int fportlen; + caddr_t fport; + int fportlen; { register struct isopcb *isop; register caddr_t lp = TSEL(laddr); - unsigned int llen = laddr->siso_tlen; + unsigned int llen = laddr->siso_tlen; - IFDEBUG(D_ISO) - printf("iso_pcblookup(head 0x%x laddr 0x%x fport 0x%x)\n", - head, laddr, fport); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_ISO]) { + printf("iso_pcblookup(head 0x%x laddr 0x%x fport 0x%x)\n", + (unsigned int) head, (unsigned int) laddr, + (unsigned int) fport); + } +#endif for (isop = head->isop_next; isop != head; isop = isop->isop_next) { if (isop->isop_laddr == 0 || isop->isop_laddr == laddr) continue; @@ -596,20 +664,19 @@ iso_pcblookup(head, fportlen, fport, laddr) if (bcmp(lp, TSEL(isop->isop_laddr), llen)) continue; if (fportlen && isop->isop_faddr && - bcmp(fport, TSEL(isop->isop_faddr), (unsigned)fportlen)) + bcmp(fport, TSEL(isop->isop_faddr), (unsigned) fportlen)) continue; - /* PHASE2 - * addrmatch1 should be iso_addrmatch(a, b, mask) - * where mask is taken from isop->isop_laddrmask (new field) - * isop_lnetmask will also be available in isop - if (laddr != &zeroiso_addr && - !iso_addrmatch1(laddr, &(isop->isop_laddr.siso_addr))) - continue; - */ + /* + * PHASE2 addrmatch1 should be iso_addrmatch(a, b, mask) + * where mask is taken from isop->isop_laddrmask (new field) + * isop_lnetmask will also be available in isop if (laddr != + * &zeroiso_addr && !iso_addrmatch1(laddr, + * &(isop->isop_laddr.siso_addr))) continue; + */ if (laddr->siso_nlen && (!SAME_ISOADDR(laddr, isop->isop_laddr))) continue; return (isop); } - return (struct isopcb *)0; + return (struct isopcb *) 0; } #endif /* ISO */ diff --git a/sys/netiso/iso_pcb.h b/sys/netiso/iso_pcb.h index 0d2631558f0..88c10543aee 100644 --- a/sys/netiso/iso_pcb.h +++ b/sys/netiso/iso_pcb.h @@ -1,4 +1,5 @@ -/* $NetBSD: iso_pcb.h,v 1.6 1995/03/26 20:35:23 jtc Exp $ */ +/* $OpenBSD: iso_pcb.h,v 1.2 1996/03/04 10:35:36 mickey Exp $ */ +/* $NetBSD: iso_pcb.h,v 1.7 1996/02/13 22:10:18 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -68,28 +69,28 @@ SOFTWARE. * Common structure pcb for argo protocol implementation. */ struct isopcb { - struct isopcb *isop_next,*isop_prev; /* pointers to other pcb's */ - struct isopcb *isop_head; /* pointer back to chain of pcbs for - this protocol */ - struct socket *isop_socket; /* back pointer to socket */ - struct sockaddr_iso *isop_laddr; - struct sockaddr_iso *isop_faddr; - struct route_iso { - struct rtentry *ro_rt; - struct sockaddr_iso ro_dst; - } isop_route; /* CLNP routing entry */ - struct mbuf *isop_options; /* CLNP options */ - struct mbuf *isop_optindex; /* CLNP options index */ - struct mbuf *isop_clnpcache; /* CLNP cached hdr */ - caddr_t isop_chan; /* actually struct pklcb * */ - u_short isop_refcnt; /* mult TP4 tpcb's -> here */ - u_short isop_lport; /* MISLEADLING work var */ - u_short isop_tuba_cached; /* for tuba address ref cnts */ - int isop_x25crud_len; /* x25 call request ud */ - char isop_x25crud[MAXX25CRUDLEN]; - struct ifaddr *isop_ifa; /* ESIS interface assoc w/sock */ - struct sockaddr_iso isop_sladdr, /* preallocated laddr */ - isop_sfaddr; /* preallocated faddr */ + struct isopcb *isop_next, *isop_prev; /* pointers to other pcb's */ + struct isopcb *isop_head; /* pointer back to chain of pcbs for + * this protocol */ + struct socket *isop_socket; /* back pointer to socket */ + struct sockaddr_iso *isop_laddr; + struct sockaddr_iso *isop_faddr; + struct route_iso { + struct rtentry *ro_rt; + struct sockaddr_iso ro_dst; + } isop_route; /* CLNP routing entry */ + struct mbuf *isop_options; /* CLNP options */ + struct mbuf *isop_optindex; /* CLNP options index */ + struct mbuf *isop_clnpcache; /* CLNP cached hdr */ + caddr_t isop_chan; /* actually struct pklcb * */ + u_short isop_refcnt; /* mult TP4 tpcb's -> here */ + u_short isop_lport; /* MISLEADLING work var */ + u_short isop_tuba_cached; /* for tuba address ref cnts */ + int isop_x25crud_len; /* x25 call request ud */ + char isop_x25crud[MAXX25CRUDLEN]; + struct ifaddr *isop_ifa; /* ESIS interface assoc w/sock */ + struct sockaddr_iso isop_sladdr, /* preallocated laddr */ + isop_sfaddr; /* preallocated faddr */ }; #ifdef sotorawcb @@ -99,9 +100,10 @@ struct isopcb { * and space is allocated to the necessary sockaddrs. */ struct rawisopcb { - struct rawcb risop_rcb; /* common control block prefix */ - int risop_flags; /* flags, e.g. raw sockopts */ - struct isopcb risop_isop; /* space for bound addresses, routes etc.*/ + struct rawcb risop_rcb; /* common control block prefix */ + int risop_flags; /* flags, e.g. raw sockopts */ + struct isopcb risop_isop; /* space for bound addresses, routes + * etc. */ }; #endif @@ -109,5 +111,19 @@ struct rawisopcb { #define sotorawisopcb(so) ((struct rawisopcb *)(so)->so_pcb) #ifdef _KERNEL -struct isopcb *iso_pcblookup(); +struct socket; +struct isopcb; +struct inpcb; +struct mbuf; +struct sockaddr_iso; + +int iso_pcballoc __P((struct socket *, void *)); +int iso_pcbbind __P((void *, struct mbuf *)); +int iso_pcbconnect __P((void *, struct mbuf *)); +void iso_pcbdisconnect __P((void *)); +void iso_pcbdetach __P((void *)); +void iso_pcbnotify __P((struct isopcb *, struct sockaddr_iso *, int, + void (*) (struct isopcb *))); +struct isopcb *iso_pcblookup __P((struct isopcb *, int, caddr_t, + struct sockaddr_iso *)); #endif diff --git a/sys/netiso/iso_proto.c b/sys/netiso/iso_proto.c index 1577d9e7951..b0caaf21eea 100644 --- a/sys/netiso/iso_proto.c +++ b/sys/netiso/iso_proto.c @@ -1,4 +1,5 @@ -/* $NetBSD: iso_proto.c,v 1.5 1994/06/29 06:39:49 cgd Exp $ */ +/* $OpenBSD: iso_proto.c,v 1.2 1996/03/04 10:35:38 mickey Exp $ */ +/* $NetBSD: iso_proto.c,v 1.6 1996/02/13 22:10:21 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -79,118 +80,111 @@ SOFTWARE. #include <netiso/iso.h> -int clnp_output(), rclnp_output(), rclnp_ctloutput(); -int raw_usrreq(), clnp_usrreq(); -void clnp_init(), clnp_slowtimo(), clnp_drain(), rclnp_input(); - -int tp_ctloutput(), tp_usrreq(), tpcons_input(); -void tp_init(), tp_fasttimo(), tp_slowtimo(), tp_drain(), cons_init(); -void tpclnp_input(), tpclnp_ctlinput(); - -int esis_usrreq(), idrp_usrreq(), cltp_usrreq(), cltp_output(); -void esis_init(), idrp_init(), cltp_init(), isis_input(), esis_input(); -void idrp_input(), cltp_input(), esis_ctlinput(), cltp_ctlinput(); - +#include <netiso/clnp.h> +#include <netiso/tp_param.h> +#include <netiso/tp_var.h> +#include <netiso/esis.h> #ifdef TUBA -int tuba_usrreq(), tuba_ctloutput(), tuba_tcpinput(); -void tuba_init(), tuba_slowtimo(), tuba_fasttimo(); +#include <netiso/tuba_table.h> #endif - -struct protosw isosw[] = { -/* - * We need a datagram entry through which net mgmt programs can get - * to the iso_control procedure (iso ioctls). Thus, a minimal - * SOCK_DGRAM interface is provided here. - * THIS ONE MUST BE FIRST: Kludge city : socket() says if(!proto) call - * pffindtype, which gets the first entry that matches the type. - * sigh. - */ -{ SOCK_DGRAM, &isodomain, ISOPROTO_CLTP, PR_ATOMIC|PR_ADDR, - 0, cltp_output, 0, 0, - cltp_usrreq, - cltp_init, 0, 0, 0 -}, - -/* - * A datagram interface for clnp cannot co-exist with TP/CLNP - * because CLNP has no way to discriminate incoming TP packets from - * packets coming in for any other higher layer protocol. - * Old way: set it up so that pffindproto(... dgm, clnp) fails. - * New way: let pffindproto work (for x.25, thank you) but create - * a clnp_usrreq() that returns error on PRU_ATTACH. - */ -{SOCK_DGRAM, &isodomain, ISOPROTO_CLNP, 0, - 0, clnp_output, 0, 0, - clnp_usrreq, - clnp_init, 0, clnp_slowtimo, clnp_drain, -}, - -/* raw clnp */ -{ SOCK_RAW, &isodomain, ISOPROTO_RAW, PR_ATOMIC|PR_ADDR, - rclnp_input, rclnp_output, 0, rclnp_ctloutput, - clnp_usrreq, - 0, 0, 0, 0 -}, - -/* ES-IS protocol */ -{ SOCK_DGRAM, &isodomain, ISOPROTO_ESIS, PR_ATOMIC|PR_ADDR, - esis_input, 0, esis_ctlinput, 0, - esis_usrreq, - esis_init, 0, 0, 0 -}, - -/* ISOPROTO_INTRAISIS */ -{ SOCK_DGRAM, &isodomain, ISOPROTO_INTRAISIS, PR_ATOMIC|PR_ADDR, - isis_input, 0, 0, 0, - esis_usrreq, - 0, 0, 0, 0 -}, - -/* ISOPROTO_IDRP */ -{ SOCK_DGRAM, &isodomain, ISOPROTO_IDRP, PR_ATOMIC|PR_ADDR, - idrp_input, 0, 0, 0, - idrp_usrreq, - idrp_init, 0, 0, 0 -}, - -/* ISOPROTO_TP */ -{ SOCK_SEQPACKET, &isodomain, ISOPROTO_TP, PR_CONNREQUIRED|PR_WANTRCVD, - tpclnp_input, 0, tpclnp_ctlinput, tp_ctloutput, - tp_usrreq, - tp_init, tp_fasttimo, tp_slowtimo, tp_drain, -}, +#include <netiso/idrp_var.h> +#include <netiso/iso_pcb.h> +#include <netiso/cltp_var.h> + +struct protosw isosw[] = { + /* + * We need a datagram entry through which net mgmt programs can get + * to the iso_control procedure (iso ioctls). Thus, a minimal + * SOCK_DGRAM interface is provided here. + * THIS ONE MUST BE FIRST: Kludge city : socket() says if(!proto) call + * pffindtype, which gets the first entry that matches the type. + * sigh. + */ + {SOCK_DGRAM, &isodomain, ISOPROTO_CLTP, PR_ATOMIC | PR_ADDR, + 0, cltp_output, 0, 0, + cltp_usrreq, + cltp_init, 0, 0, 0 + }, + + /* + * A datagram interface for clnp cannot co-exist with TP/CLNP + * because CLNP has no way to discriminate incoming TP packets from + * packets coming in for any other higher layer protocol. + * Old way: set it up so that pffindproto(... dgm, clnp) fails. + * New way: let pffindproto work (for x.25, thank you) but create + * a clnp_usrreq() that returns error on PRU_ATTACH. + */ + {SOCK_DGRAM, &isodomain, ISOPROTO_CLNP, 0, + 0, clnp_output, 0, 0, + clnp_usrreq, + clnp_init, 0, clnp_slowtimo, clnp_drain, + }, + + /* raw clnp */ + {SOCK_RAW, &isodomain, ISOPROTO_RAW, PR_ATOMIC | PR_ADDR, + rclnp_input, rclnp_output, 0, rclnp_ctloutput, + clnp_usrreq, + 0, 0, 0, 0 + }, + + /* ES-IS protocol */ + {SOCK_DGRAM, &isodomain, ISOPROTO_ESIS, PR_ATOMIC | PR_ADDR, + esis_input, 0, esis_ctlinput, 0, + esis_usrreq, + esis_init, 0, 0, 0 + }, + + /* ISOPROTO_INTRAISIS */ + {SOCK_DGRAM, &isodomain, ISOPROTO_INTRAISIS, PR_ATOMIC | PR_ADDR, + isis_input, 0, 0, 0, + esis_usrreq, + 0, 0, 0, 0 + }, + + /* ISOPROTO_IDRP */ + {SOCK_DGRAM, &isodomain, ISOPROTO_IDRP, PR_ATOMIC | PR_ADDR, + idrp_input, 0, 0, 0, + idrp_usrreq, + idrp_init, 0, 0, 0 + }, + + /* ISOPROTO_TP */ + {SOCK_SEQPACKET, &isodomain, ISOPROTO_TP, PR_CONNREQUIRED | PR_WANTRCVD, + tpclnp_input, 0, tpclnp_ctlinput, tp_ctloutput, + tp_usrreq, + tp_init, tp_fasttimo, tp_slowtimo, tp_drain, + }, #ifdef TUBA -{ SOCK_STREAM, &isodomain, ISOPROTO_TCP, PR_CONNREQUIRED|PR_WANTRCVD, - tuba_tcpinput, 0, 0, tuba_ctloutput, - tuba_usrreq, - tuba_init, tuba_fasttimo, tuba_fasttimo, 0 -}, + {SOCK_STREAM, &isodomain, ISOPROTO_TCP, PR_CONNREQUIRED | PR_WANTRCVD, + tuba_tcpinput, 0, 0, tuba_ctloutput, + tuba_usrreq, + tuba_init, tuba_fasttimo, tuba_fasttimo, 0 + }, #endif #ifdef TPCONS -/* ISOPROTO_TP */ -{ SOCK_SEQPACKET, &isodomain, ISOPROTO_TP0, PR_CONNREQUIRED|PR_WANTRCVD, - tpcons_input, 0, 0, tp_ctloutput, - tp_usrreq, - cons_init, 0, 0, 0, -}, + /* ISOPROTO_TP */ + {SOCK_SEQPACKET, &isodomain, ISOPROTO_TP0, PR_CONNREQUIRED | PR_WANTRCVD, + tpcons_input, 0, 0, tp_ctloutput, + tp_usrreq, + cons_init, 0, 0, 0, + }, #endif - }; -struct domain isodomain = { - AF_ISO, /* family */ - "iso-domain", /* name */ - 0, /* initialize routine */ - 0, /* externalize access rights */ - 0, /* dispose of internalized rights */ - isosw, /* protosw */ - &isosw[sizeof(isosw)/sizeof(isosw[0])], /* NPROTOSW */ - 0, /* next */ +struct domain isodomain = { + AF_ISO, /* family */ + "iso-domain", /* name */ + 0, /* initialize routine */ + 0, /* externalize access rights */ + 0, /* dispose of internalized rights */ + isosw, /* protosw */ + &isosw[sizeof(isosw) / sizeof(isosw[0])], /* NPROTOSW */ + 0, /* next */ rn_inithead, /* rtattach */ - 48, /* rtoffset */ - sizeof(struct sockaddr_iso) /* maxkeylen */ + 48, /* rtoffset */ + sizeof(struct sockaddr_iso) /* maxkeylen */ }; -#endif /* ISO */ +#endif /* ISO */ diff --git a/sys/netiso/iso_snpac.c b/sys/netiso/iso_snpac.c index f03c7bc68f3..55138723796 100644 --- a/sys/netiso/iso_snpac.c +++ b/sys/netiso/iso_snpac.c @@ -1,4 +1,5 @@ -/* $NetBSD: iso_snpac.c,v 1.10 1995/06/13 08:12:41 mycroft Exp $ */ +/* $OpenBSD: iso_snpac.c,v 1.2 1996/03/04 10:35:39 mickey Exp $ */ +/* $NetBSD: iso_snpac.c,v 1.11 1996/02/13 22:10:25 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -79,6 +80,9 @@ SOFTWARE. #include <net/if_dl.h> #include <net/route.h> +#include <netinet/in.h> +#include <netinet/if_ether.h> + #include <netiso/iso.h> #include <netiso/iso_var.h> #include <netiso/iso_snpac.h> @@ -87,23 +91,23 @@ SOFTWARE. #include <netiso/esis.h> #include <netiso/argo_debug.h> -int iso_systype = SNPA_ES; /* default to be an ES */ -extern short esis_holding_time, esis_config_time, esis_esconfig_time; -extern struct timeval time; -extern void esis_config(); -extern int hz; -static void snpac_fixdstandmask(); +int iso_systype = SNPA_ES; /* default to be an ES */ +extern short esis_holding_time, esis_config_time, esis_esconfig_time; +extern struct timeval time; +extern int hz; LIST_HEAD(, llinfo_llc) llinfo_llc; struct sockaddr_iso blank_siso = {sizeof(blank_siso), AF_ISO}; -extern u_long iso_hashchar(); static struct sockaddr_iso - dst = {sizeof(dst), AF_ISO}, - gte = {sizeof(dst), AF_ISO}, - src = {sizeof(dst), AF_ISO}, - msk = {sizeof(dst), AF_ISO}, - zmk = {0}; + dst = {sizeof(dst), AF_ISO}, + gte = {sizeof(gte), AF_ISO}, +#if 0 + src = {sizeof(src), AF_ISO}, +#endif + msk = {sizeof(msk), AF_ISO}, + zmk = {0, 0}; + #define zsi blank_siso #define zero_isoa zsi.siso_addr #define zap_isoaddr(a, b) {Bzero(&a.siso_addr, sizeof(*r)); r = b; \ @@ -115,10 +119,12 @@ static struct sockaddr_dl gte_dl; #define zap_linkaddr(a, b, c, i) \ (*a = blank_dl, bcopy(b, a->sdl_data, a->sdl_alen = c), a->sdl_index = i) +static void snpac_fixdstandmask __P((int)); + /* * We only keep track of a single IS at a time. */ -struct rtentry *known_is; +struct rtentry *known_is; /* * Addresses taken from NBS agreements, December 1987. @@ -137,199 +143,211 @@ struct rtentry *known_is; * lan_output() That means that if these multicast addresses change * the token ring driver must be altered. */ -char all_es_snpa[] = { 0x09, 0x00, 0x2b, 0x00, 0x00, 0x04 }; -char all_is_snpa[] = { 0x09, 0x00, 0x2b, 0x00, 0x00, 0x05 }; -char all_l1is_snpa[] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x14}; -char all_l2is_snpa[] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x15}; +char all_es_snpa[] = {0x09, 0x00, 0x2b, 0x00, 0x00, 0x04}; +char all_is_snpa[] = {0x09, 0x00, 0x2b, 0x00, 0x00, 0x05}; +char all_l1is_snpa[] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x14}; +char all_l2is_snpa[] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x15}; union sockunion { struct sockaddr_iso siso; - struct sockaddr_dl sdl; - struct sockaddr sa; + struct sockaddr_dl sdl; + struct sockaddr sa; }; /* * FUNCTION: llc_rtrequest * - * PURPOSE: Manage routing table entries specific to LLC for ISO. + * PURPOSE: Manage routing table entries specific to LLC for ISO. * - * NOTES: This does a lot of obscure magic; + * NOTES: This does a lot of obscure magic; */ +void llc_rtrequest(req, rt, sa) -int req; -register struct rtentry *rt; -struct sockaddr *sa; + int req; + register struct rtentry *rt; + struct sockaddr *sa; { - register union sockunion *gate = (union sockunion *)rt->rt_gateway; - register struct llinfo_llc *lc = (struct llinfo_llc *)rt->rt_llinfo, *lc2; - struct rtentry *rt2; - struct ifnet *ifp = rt->rt_ifp; - int addrlen = ifp->if_addrlen; -#define LLC_SIZE 3 /* XXXXXX do this right later */ - - IFDEBUG (D_SNPA) - printf("llc_rtrequest(%d, %x, %x)\n", req, rt, sa); - ENDDEBUG + register union sockunion *gate = (union sockunion *) rt->rt_gateway; + register struct llinfo_llc *lc = (struct llinfo_llc *) rt->rt_llinfo; + struct ifnet *ifp = rt->rt_ifp; + int addrlen = ifp->if_addrlen; +#define LLC_SIZE 3 /* XXXXXX do this right later */ + +#ifdef ARGO_DEBUG + if (argo_debug[D_SNPA]) { + printf("llc_rtrequest(%d, %x, %x)\n", req, + (unsigned int) rt, (unsigned int) sa); + } +#endif if (rt->rt_flags & RTF_GATEWAY) return; - else switch (req) { - case RTM_ADD: - /* - * Case 1: This route may come from a route to iface with mask - * or from a default route. - */ - if (rt->rt_flags & RTF_CLONING) { - iso_setmcasts(ifp, req); - rt_setgate(rt, rt_key(rt), - (struct sockaddr *)&blank_dl); - return; - } - if (lc != 0) - return; /* happens on a route change */ - /* FALLTHROUGH */ - case RTM_RESOLVE: - /* - * Case 2: This route may come from cloning, or a manual route - * add with a LL address. - */ - if (gate->sdl.sdl_family != AF_LINK) { - log(LOG_DEBUG, "llc_rtrequest: got non-link non-gateway route\n"); + else + switch (req) { + case RTM_ADD: + /* + * Case 1: This route may come from a route to iface with mask + * or from a default route. + */ + if (rt->rt_flags & RTF_CLONING) { + iso_setmcasts(ifp, req); + rt_setgate(rt, rt_key(rt), + (struct sockaddr *) & blank_dl); + return; + } + if (lc != 0) + return; /* happens on a route change */ + /* FALLTHROUGH */ + case RTM_RESOLVE: + /* + * Case 2: This route may come from cloning, or a manual route + * add with a LL address. + */ + if (gate->sdl.sdl_family != AF_LINK) { + log(LOG_DEBUG, "llc_rtrequest: got non-link non-gateway route\n"); + break; + } + R_Malloc(lc, struct llinfo_llc *, sizeof(*lc)); + rt->rt_llinfo = (caddr_t) lc; + if (lc == 0) { + log(LOG_DEBUG, "llc_rtrequest: malloc failed\n"); + break; + } + Bzero(lc, sizeof(*lc)); + lc->lc_rt = rt; + rt->rt_flags |= RTF_LLINFO; + LIST_INSERT_HEAD(&llinfo_llc, lc, lc_list); + if (gate->sdl.sdl_alen == sizeof(struct esis_req) + addrlen) { + gate->sdl.sdl_alen -= sizeof(struct esis_req); + bcopy(addrlen + LLADDR(&gate->sdl), + (caddr_t) & lc->lc_er, sizeof(lc->lc_er)); + } else if (gate->sdl.sdl_alen == addrlen) + lc->lc_flags = (SNPA_ES | SNPA_VALID | SNPA_PERM); break; - } - R_Malloc(lc, struct llinfo_llc *, sizeof (*lc)); - rt->rt_llinfo = (caddr_t)lc; - if (lc == 0) { - log(LOG_DEBUG, "llc_rtrequest: malloc failed\n"); + case RTM_DELETE: + if (rt->rt_flags & RTF_CLONING) + iso_setmcasts(ifp, req); + if (lc == 0) + return; + LIST_REMOVE(lc, lc_list); + Free(lc); + rt->rt_llinfo = 0; + rt->rt_flags &= ~RTF_LLINFO; break; } - Bzero(lc, sizeof(*lc)); - lc->lc_rt = rt; - rt->rt_flags |= RTF_LLINFO; - LIST_INSERT_HEAD(&llinfo_llc, lc, lc_list); - if (gate->sdl.sdl_alen == sizeof(struct esis_req) + addrlen) { - gate->sdl.sdl_alen -= sizeof(struct esis_req); - bcopy(addrlen + LLADDR(&gate->sdl), - (caddr_t)&lc->lc_er, sizeof(lc->lc_er)); - } else if (gate->sdl.sdl_alen == addrlen) - lc->lc_flags = (SNPA_ES | SNPA_VALID | SNPA_PERM); - break; - case RTM_DELETE: - if (rt->rt_flags & RTF_CLONING) - iso_setmcasts(ifp, req); - if (lc == 0) - return; - LIST_REMOVE(lc, lc_list); - Free(lc); - rt->rt_llinfo = 0; - rt->rt_flags &= ~RTF_LLINFO; - break; - } if (rt->rt_rmx.rmx_mtu == 0) { - rt->rt_rmx.rmx_mtu = rt->rt_ifp->if_mtu - LLC_SIZE; + rt->rt_rmx.rmx_mtu = rt->rt_ifp->if_mtu - LLC_SIZE; } } + /* * FUNCTION: iso_setmcasts * - * PURPOSE: Enable/Disable ESIS/ISIS multicast reception on interfaces. + * PURPOSE: Enable/Disable ESIS/ISIS multicast reception on + * interfaces. * - * NOTES: This also does a lot of obscure magic; + * NOTES: This also does a lot of obscure magic; */ +void iso_setmcasts(ifp, req) - struct ifnet *ifp; - int req; + struct ifnet *ifp; + int req; { - static char *addrlist[] = - { all_es_snpa, all_is_snpa, all_l1is_snpa, all_l2is_snpa, 0}; - struct ifreq ifr; + static char *addrlist[] = + {all_es_snpa, all_is_snpa, all_l1is_snpa, all_l2is_snpa, 0}; + struct ifreq ifr; register caddr_t *cpp; - int doreset = 0; + int doreset = 0; - bzero((caddr_t)&ifr, sizeof(ifr)); - for (cpp = (caddr_t *)addrlist; *cpp; cpp++) { - bcopy(*cpp, (caddr_t)ifr.ifr_addr.sa_data, 6); + bzero((caddr_t) & ifr, sizeof(ifr)); + for (cpp = (caddr_t *) addrlist; *cpp; cpp++) { + bcopy(*cpp, (caddr_t) ifr.ifr_addr.sa_data, 6); if (req == RTM_ADD) - if (ether_addmulti(&ifr, (struct arpcom *)ifp) == ENETRESET) + if (ether_addmulti(&ifr, (struct arpcom *) ifp) == ENETRESET) doreset++; - else - if (ether_delmulti(&ifr, (struct arpcom *)ifp) == ENETRESET) + else if (ether_delmulti(&ifr, (struct arpcom *) ifp) == ENETRESET) doreset++; } if (doreset) { if (ifp->if_reset) - (*ifp->if_reset)(ifp->if_unit); + (*ifp->if_reset) (ifp->if_unit); else printf("iso_setmcasts: %s%d needs reseting to receive iso mcasts\n", - ifp->if_name, ifp->if_unit); + ifp->if_name, ifp->if_unit); } } + /* * FUNCTION: iso_snparesolve * - * PURPOSE: Resolve an iso address into snpa address + * PURPOSE: Resolve an iso address into snpa address * - * RETURNS: 0 if addr is resolved - * errno if addr is unknown + * RETURNS: 0 if addr is resolved + * errno if addr is unknown * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: Now that we have folded the snpa cache into the routing - * table, we know there is no snpa address known for this - * destination. If we know of a default IS, then the address - * of the IS is returned. If no IS is known, then return the - * multi-cast address for "all ES" for this interface. + * NOTES: Now that we have folded the snpa cache into the routing + * table, we know there is no snpa address known for this + * destination. If we know of a default IS, then the + * address of the IS is returned. If no IS is known, + * then return the multi-cast address for "all ES" for + * this interface. * - * NB: the last case described above constitutes the - * query configuration function 9542, sec 6.5 - * A mechanism is needed to prevent this function from - * being invoked if the system is an IS. + * NB: the last case described above constitutes the + * query configuration function 9542, sec 6.5 + * A mechanism is needed to prevent this function from + * being invoked if the system is an IS. */ +int iso_snparesolve(ifp, dest, snpa, snpa_len) -struct ifnet *ifp; /* outgoing interface */ -struct sockaddr_iso *dest; /* destination */ -caddr_t snpa; /* RESULT: snpa to be used */ -int *snpa_len; /* RESULT: length of snpa */ + struct ifnet *ifp; /* outgoing interface */ + struct sockaddr_iso *dest; /* destination */ + caddr_t snpa; /* RESULT: snpa to be used */ + int *snpa_len; /* RESULT: length of snpa */ { - struct llinfo_llc *sc; /* ptr to snpa table entry */ - caddr_t found_snpa; - int addrlen; + struct llinfo_llc *sc; /* ptr to snpa table entry */ + caddr_t found_snpa; + int addrlen; /* - * This hack allows us to send esis packets that have the destination snpa - * addresss embedded in the destination nsap address + * This hack allows us to send esis packets that have the destination + * snpa addresss embedded in the destination nsap address */ if (dest->siso_data[0] == AFI_SNA) { /* * This is a subnetwork address. Return it immediately */ - IFDEBUG(D_SNPA) +#ifdef ARGO_DEBUG + if (argo_debug[D_SNPA]) { printf("iso_snparesolve: return SN address\n"); - ENDDEBUG + } +#endif addrlen = dest->siso_nlen - 1; /* subtract size of AFI */ found_snpa = (caddr_t) dest->siso_data + 1; - /* - * If we are an IS, we can't do much with the packet; - * Check if we know about an IS. - */ + /* + * If we are an IS, we can't do much with the packet; Check + * if we know about an IS. + */ } else if (iso_systype != SNPA_IS && known_is != 0 && - (sc = (struct llinfo_llc *)known_is->rt_llinfo) && - (sc->lc_flags & SNPA_VALID)) { + (sc = (struct llinfo_llc *) known_is->rt_llinfo) && + (sc->lc_flags & SNPA_VALID)) { register struct sockaddr_dl *sdl = - (struct sockaddr_dl *)(known_is->rt_gateway); + (struct sockaddr_dl *) (known_is->rt_gateway); found_snpa = LLADDR(sdl); addrlen = sdl->sdl_alen; } else if (ifp->if_flags & IFF_BROADCAST) { - /* - * no IS, no match. Return "all es" multicast address for this - * interface, as per Query Configuration Function (9542 sec 6.5) + /* + * no IS, no match. Return "all es" multicast address for + * this interface, as per Query Configuration Function (9542 + * sec 6.5) * - * Note: there is a potential problem here. If the destination - * is on the subnet and it does not respond with a ESH, but - * does send back a TP CC, a connection could be established - * where we always transmit the CLNP packet to "all es" + * Note: there is a potential problem here. If the destination + * is on the subnet and it does not respond with a ESH, but + * does send back a TP CC, a connection could be established + * where we always transmit the CLNP packet to "all es" */ addrlen = ifp->if_addrlen; - found_snpa = (caddr_t)all_es_snpa; + found_snpa = (caddr_t) all_es_snpa; } else return (ENETUNREACH); bcopy(found_snpa, snpa, *snpa_len = addrlen); @@ -340,28 +358,28 @@ int *snpa_len; /* RESULT: length of snpa */ /* * FUNCTION: snpac_free * - * PURPOSE: free an entry in the iso address map table + * PURPOSE: free an entry in the iso address map table * - * RETURNS: nothing + * RETURNS: nothing * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: If there is a route entry associated with cache - * entry, then delete that as well + * NOTES: If there is a route entry associated with cache + * entry, then delete that as well */ +void snpac_free(lc) -register struct llinfo_llc *lc; /* entry to free */ + register struct llinfo_llc *lc; /* entry to free */ { register struct rtentry *rt = lc->lc_rt; - register struct iso_addr *r; if (known_is == rt) known_is = 0; if (rt && (rt->rt_flags & RTF_UP) && - (rt->rt_flags & (RTF_DYNAMIC | RTF_MODIFIED))) { - RTFREE(rt); - rtrequest(RTM_DELETE, rt_key(rt), rt->rt_gateway, rt_mask(rt), - rt->rt_flags, (struct rtentry **)0); + (rt->rt_flags & (RTF_DYNAMIC | RTF_MODIFIED))) { + RTFREE(rt); + rtrequest(RTM_DELETE, rt_key(rt), rt->rt_gateway, rt_mask(rt), + rt->rt_flags, (struct rtentry **) 0); RTFREE(rt); } } @@ -369,79 +387,90 @@ register struct llinfo_llc *lc; /* entry to free */ /* * FUNCTION: snpac_add * - * PURPOSE: Add an entry to the snpa cache + * PURPOSE: Add an entry to the snpa cache * - * RETURNS: + * RETURNS: * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: If entry already exists, then update holding time. + * NOTES: If entry already exists, then update holding time. */ +int snpac_add(ifp, nsap, snpa, type, ht, nsellength) -struct ifnet *ifp; /* interface info is related to */ -struct iso_addr *nsap; /* nsap to add */ -caddr_t snpa; /* translation */ -char type; /* SNPA_IS or SNPA_ES */ -u_short ht; /* holding time (in seconds) */ -int nsellength; /* nsaps may differ only in trailing bytes */ + struct ifnet *ifp; /* interface info is related to */ + struct iso_addr *nsap; /* nsap to add */ + caddr_t snpa; /* translation */ + char type; /* SNPA_IS or SNPA_ES */ + u_short ht; /* holding time (in seconds) */ + int nsellength; /* nsaps may differ only in trailing + * bytes */ { - register struct llinfo_llc *lc; + register struct llinfo_llc *lc; register struct rtentry *rt; - struct rtentry *mrt = 0; - register struct iso_addr *r; /* for zap_isoaddr macro */ - int snpalen = min(ifp->if_addrlen, MAX_SNPALEN); - int new_entry = 0, index = ifp->if_index, iftype = ifp->if_type; + struct rtentry *mrt = 0; + register struct iso_addr *r; /* for zap_isoaddr macro */ + int snpalen = min(ifp->if_addrlen, MAX_SNPALEN); + int new_entry = 0, index = ifp->if_index, iftype = ifp->if_type; - IFDEBUG(D_SNPA) +#ifdef ARGO_DEBUG + if (argo_debug[D_SNPA]) { printf("snpac_add(%x, %x, %x, %x, %x, %x)\n", - ifp, nsap, snpa, type, ht, nsellength); - ENDDEBUG + (unsigned int) ifp, + (unsigned int) nsap, + (unsigned int) snpa, type, ht, nsellength); + } +#endif zap_isoaddr(dst, nsap); rt = rtalloc1(sisotosa(&dst), 0); - IFDEBUG(D_SNPA) - printf("snpac_add: rtalloc1 returns %x\n", rt); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_SNPA]) { + printf("snpac_add: rtalloc1 returns %x\n", (unsigned int) rt); + } +#endif if (rt == 0) { struct sockaddr *netmask; - int flags; - add: + int flags; +add: if (nsellength) { - netmask = sisotosa(&msk); flags = RTF_UP; + netmask = sisotosa(&msk); + flags = RTF_UP; snpac_fixdstandmask(nsellength); } else { - netmask = 0; flags = RTF_UP | RTF_HOST; + netmask = 0; + flags = RTF_UP | RTF_HOST; } new_entry = 1; zap_linkaddr((>e_dl), snpa, snpalen, index); gte_dl.sdl_type = iftype; if (rtrequest(RTM_ADD, sisotosa(&dst), S(gte_dl), netmask, - flags, &mrt) || mrt == 0) + flags, &mrt) || mrt == 0) return (0); rt = mrt; rt->rt_refcnt--; } else { - register struct sockaddr_dl *sdl = (struct sockaddr_dl *)rt->rt_gateway; + register struct sockaddr_dl *sdl = (struct sockaddr_dl *) rt->rt_gateway; rt->rt_refcnt--; if ((rt->rt_flags & RTF_LLINFO) == 0) goto add; if (nsellength && (rt->rt_flags & RTF_HOST)) { if (rt->rt_refcnt == 0) { rtrequest(RTM_DELETE, sisotosa(&dst), - (struct sockaddr *)0, (struct sockaddr *)0, - 0, (struct rtentry **)0); + (struct sockaddr *) 0, (struct sockaddr *) 0, + 0, (struct rtentry **) 0); rt = 0; goto add; } else { - static struct iso_addr nsap2; register char *cp; + static struct iso_addr nsap2; + register char *cp; nsap2 = *nsap; cp = nsap2.isoa_genaddr + nsap->isoa_len - nsellength; - while (cp < (char *)(1 + &nsap2)) + while (cp < (char *) (1 + &nsap2)) *cp++ = 0; (void) snpac_add(ifp, &nsap2, snpa, type, ht, nsellength); } } if (sdl->sdl_family != AF_LINK || sdl->sdl_alen == 0) { - int old_sdl_len = sdl->sdl_len; + int old_sdl_len = sdl->sdl_len; if (old_sdl_len < sizeof(*sdl)) { log(LOG_DEBUG, "snpac_add: cant make room for lladdr\n"); return (0); @@ -452,7 +481,7 @@ int nsellength; /* nsaps may differ only in trailing bytes */ new_entry = 1; } } - if ((lc = (struct llinfo_llc *)rt->rt_llinfo) == 0) + if ((lc = (struct llinfo_llc *) rt->rt_llinfo) == 0) panic("snpac_rtrequest"); rt->rt_rmx.rmx_expire = ht + time.tv_sec; lc->lc_flags = SNPA_VALID | type; @@ -463,17 +492,18 @@ int nsellength; /* nsaps may differ only in trailing bytes */ static void snpac_fixdstandmask(nsellength) + int nsellength; { - register char *cp = msk.siso_data, *cplim; + register char *cp = msk.siso_data, *cplim; cplim = cp + (dst.siso_nlen -= nsellength); - msk.siso_len = cplim - (char *)&msk; + msk.siso_len = cplim - (char *) &msk; msk.siso_nlen = 0; while (cp < cplim) *cp++ = -1; - while (cp < (char *)msk.siso_pad) + while (cp < (char *) msk.siso_pad) *cp++ = 0; - for (cp = dst.siso_data + dst.siso_nlen; cp < (char *)dst.siso_pad; ) + for (cp = dst.siso_data + dst.siso_nlen; cp < (char *) dst.siso_pad;) *cp++ = 0; } @@ -484,43 +514,46 @@ snpac_fixdstandmask(nsellength) * * RETURNS: 0 on success, or unix error code * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ -snpac_ioctl (so, cmd, data) -struct socket *so; -u_long cmd; /* ioctl to process */ -caddr_t data; /* data for the cmd */ +int +snpac_ioctl(so, cmd, data) + struct socket *so; + u_long cmd; /* ioctl to process */ + caddr_t data; /* data for the cmd */ { - register struct systype_req *rq = (struct systype_req *)data; + register struct systype_req *rq = (struct systype_req *) data; - IFDEBUG(D_IOCTL) +#ifdef ARGO_DEBUG + if (argo_debug[D_IOCTL]) { if (cmd == SIOCSSTYPE) printf("snpac_ioctl: cmd set, type x%x, ht %d, ct %d\n", - rq->sr_type, rq->sr_holdt, rq->sr_configt); + rq->sr_type, rq->sr_holdt, rq->sr_configt); else printf("snpac_ioctl: cmd get\n"); - ENDDEBUG + } +#endif if (cmd == SIOCSSTYPE) { if ((so->so_state & SS_PRIV) == 0) return (EPERM); - if ((rq->sr_type & (SNPA_ES|SNPA_IS)) == (SNPA_ES|SNPA_IS)) - return(EINVAL); + if ((rq->sr_type & (SNPA_ES | SNPA_IS)) == (SNPA_ES | SNPA_IS)) + return (EINVAL); if (rq->sr_type & SNPA_ES) { iso_systype = SNPA_ES; } else if (rq->sr_type & SNPA_IS) { iso_systype = SNPA_IS; } else { - return(EINVAL); + return (EINVAL); } esis_holding_time = rq->sr_holdt; esis_config_time = rq->sr_configt; if (esis_esconfig_time != rq->sr_esconfigt) { - untimeout(esis_config, (caddr_t)0); + untimeout(esis_config, (caddr_t) 0); esis_esconfig_time = rq->sr_esconfigt; - esis_config(); + esis_config(NULL); } } else if (cmd == SIOCGSTYPE) { rq->sr_type = iso_systype; @@ -540,15 +573,14 @@ caddr_t data; /* data for the cmd */ * * RETURNS: nothing * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ +void snpac_logdefis(sc) -register struct rtentry *sc; + register struct rtentry *sc; { - register struct iso_addr *r; - register struct sockaddr_dl *sdl = (struct sockaddr_dl *)sc->rt_gateway; register struct rtentry *rt; if (known_is == sc || !(sc->rt_flags & RTF_HOST)) @@ -558,12 +590,12 @@ register struct rtentry *sc; } known_is = sc; sc->rt_refcnt++; - rt = rtalloc1((struct sockaddr *)&zsi, 0); + rt = rtalloc1((struct sockaddr *) & zsi, 0); if (rt == 0) rtrequest(RTM_ADD, sisotosa(&zsi), rt_key(sc), sisotosa(&zmk), - RTF_DYNAMIC|RTF_GATEWAY, 0); + RTF_DYNAMIC | RTF_GATEWAY, 0); else { - if ((rt->rt_flags & RTF_DYNAMIC) && + if ((rt->rt_flags & RTF_DYNAMIC) && (rt->rt_flags & RTF_GATEWAY) && rt_mask(rt)->sa_len == 0) rt_setgate(rt, rt_key(rt), rt_key(sc)); } @@ -572,31 +604,33 @@ register struct rtentry *sc; /* * FUNCTION: snpac_age * - * PURPOSE: Time out snpac entries + * PURPOSE: Time out snpac entries * - * RETURNS: + * RETURNS: * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: When encountering an entry for the first time, snpac_age - * may delete up to SNPAC_AGE too many seconds. Ie. - * if the entry is added a moment before snpac_age is - * called, the entry will immediately have SNPAC_AGE - * seconds taken off the holding time, even though - * it has only been held a brief moment. + * NOTES: When encountering an entry for the first time, snpac_age + * may delete up to SNPAC_AGE too many seconds. Ie. + * if the entry is added a moment before snpac_age is + * called, the entry will immediately have SNPAC_AGE + * seconds taken off the holding time, even though + * it has only been held a brief moment. * - * The proper way to do this is set an expiry timeval - * equal to current time + holding time. Then snpac_age - * would time out entries where expiry date is older - * than the current time. + * The proper way to do this is set an expiry timeval + * equal to current time + holding time. Then snpac_age + * would time out entries where expiry date is older + * than the current time. */ +/*ARGSUSED*/ void -snpac_age() +snpac_age(v) + void *v; { - register struct llinfo_llc *lc, *nlc; - register struct rtentry *rt; + register struct llinfo_llc *lc, *nlc; + register struct rtentry *rt; - timeout(snpac_age, (caddr_t)0, SNPAC_AGE * hz); + timeout(snpac_age, (caddr_t) 0, SNPAC_AGE * hz); for (lc = llinfo_llc.lh_first; lc != 0; lc = nlc) { nlc = lc->lc_list.le_next; @@ -611,42 +645,44 @@ snpac_age() /* * FUNCTION: snpac_ownmulti * - * PURPOSE: Determine if the snpa address is a multicast address - * of the same type as the system. + * PURPOSE: Determine if the snpa address is a multicast address + * of the same type as the system. * - * RETURNS: true or false + * RETURNS: true or false * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: Used by interface drivers when not in eavesdrop mode - * as interm kludge until - * real multicast addresses can be configured + * NOTES: Used by interface drivers when not in eavesdrop mode + * as interm kludge until + * real multicast addresses can be configured */ +int snpac_ownmulti(snpa, len) -caddr_t snpa; -u_int len; + caddr_t snpa; + u_int len; { return (((iso_systype & SNPA_ES) && - (!bcmp(snpa, (caddr_t)all_es_snpa, len))) || - ((iso_systype & SNPA_IS) && - (!bcmp(snpa, (caddr_t)all_is_snpa, len)))); + (!bcmp(snpa, (caddr_t) all_es_snpa, len))) || + ((iso_systype & SNPA_IS) && + (!bcmp(snpa, (caddr_t) all_is_snpa, len)))); } /* * FUNCTION: snpac_flushifp * - * PURPOSE: Flush entries associated with specific ifp + * PURPOSE: Flush entries associated with specific ifp * - * RETURNS: nothing + * RETURNS: nothing * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ +void snpac_flushifp(ifp) -struct ifnet *ifp; + struct ifnet *ifp; { - register struct llinfo_llc *lc; + register struct llinfo_llc *lc; for (lc = llinfo_llc.lh_first; lc != 0; lc = lc->lc_list.le_next) { if (lc->lc_rt->rt_ifp == ifp && (lc->lc_flags & SNPA_VALID)) @@ -657,36 +693,39 @@ struct ifnet *ifp; /* * FUNCTION: snpac_rtrequest * - * PURPOSE: Make a routing request + * PURPOSE: Make a routing request * - * RETURNS: nothing + * RETURNS: nothing * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: In the future, this should make a request of a user - * level routing daemon. + * NOTES: In the future, this should make a request of a user + * level routing daemon. */ +void snpac_rtrequest(req, host, gateway, netmask, flags, ret_nrt) -int req; -struct iso_addr *host; -struct iso_addr *gateway; -struct iso_addr *netmask; -short flags; -struct rtentry **ret_nrt; + int req; + struct iso_addr *host; + struct iso_addr *gateway; + struct iso_addr *netmask; + short flags; + struct rtentry **ret_nrt; { register struct iso_addr *r; - IFDEBUG(D_SNPA) +#ifdef ARGO_DEBUG + if (argo_debug[D_SNPA]) { printf("snpac_rtrequest: "); if (req == RTM_ADD) printf("add"); else if (req == RTM_DELETE) printf("delete"); - else + else printf("unknown command"); printf(" dst: %s\n", clnp_iso_addrp(host)); printf("\tgateway: %s\n", clnp_iso_addrp(gateway)); - ENDDEBUG + } +#endif zap_isoaddr(dst, host); @@ -694,35 +733,35 @@ struct rtentry **ret_nrt; if (netmask) { zap_isoaddr(msk, netmask); msk.siso_nlen = 0; - msk.siso_len = msk.siso_pad - (u_char *)&msk; + msk.siso_len = msk.siso_pad - (u_char *) & msk; } - rtrequest(req, sisotosa(&dst), sisotosa(>e), - (netmask ? sisotosa(&msk) : (struct sockaddr *)0), flags, ret_nrt); + (netmask ? sisotosa(&msk) : (struct sockaddr *) 0), flags, ret_nrt); } /* * FUNCTION: snpac_addrt * - * PURPOSE: Associate a routing entry with an snpac entry + * PURPOSE: Associate a routing entry with an snpac entry * - * RETURNS: nothing + * RETURNS: nothing * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: If a cache entry exists for gateway, then - * make a routing entry (host, gateway) and associate - * with gateway. + * NOTES: If a cache entry exists for gateway, then + * make a routing entry (host, gateway) and associate + * with gateway. * - * If a route already exists and is different, first delete - * it. + * If a route already exists and is different, first delete + * it. * - * This could be made more efficient by checking - * the existing route before adding a new one. + * This could be made more efficient by checking + * the existing route before adding a new one. */ +void snpac_addrt(ifp, host, gateway, netmask) -struct ifnet *ifp; -struct iso_addr *host, *gateway, *netmask; + struct ifnet *ifp; + struct iso_addr *host, *gateway, *netmask; { register struct iso_addr *r; @@ -731,11 +770,11 @@ struct iso_addr *host, *gateway, *netmask; if (netmask) { zap_isoaddr(msk, netmask); msk.siso_nlen = 0; - msk.siso_len = msk.siso_pad - (u_char *)&msk; + msk.siso_len = msk.siso_pad - (u_char *) & msk; rtredirect(sisotosa(&dst), sisotosa(>e), sisotosa(&msk), - RTF_DONE, sisotosa(>e), 0); + RTF_DONE, sisotosa(>e), 0); } else - rtredirect(sisotosa(&dst), sisotosa(>e), (struct sockaddr *)0, - RTF_DONE | RTF_HOST, sisotosa(>e), 0); + rtredirect(sisotosa(&dst), sisotosa(>e), (struct sockaddr *) 0, + RTF_DONE | RTF_HOST, sisotosa(>e), 0); } -#endif /* ISO */ +#endif /* ISO */ diff --git a/sys/netiso/iso_snpac.h b/sys/netiso/iso_snpac.h index 612bf460a14..d0a462a9c86 100644 --- a/sys/netiso/iso_snpac.h +++ b/sys/netiso/iso_snpac.h @@ -1,4 +1,5 @@ -/* $NetBSD: iso_snpac.h,v 1.8 1995/06/13 08:12:46 mycroft Exp $ */ +/* $OpenBSD: iso_snpac.h,v 1.2 1996/03/04 10:35:42 mickey Exp $ */ +/* $NetBSD: iso_snpac.h,v 1.9 1996/02/13 22:10:29 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -62,15 +63,15 @@ SOFTWARE. * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ -#define MAX_SNPALEN 8 /* curiously equal to sizeof x.121 ( - plus 1 for nibble len) addr */ +#define MAX_SNPALEN 8 /* curiously equal to sizeof x.121 ( + * plus 1 for nibble len) addr */ struct snpa_req { - struct iso_addr sr_isoa; /* nsap address */ - u_char sr_len; /* length of snpa */ - u_char sr_snpa[MAX_SNPALEN]; /* snpa associated - with nsap address */ - u_char sr_flags; /* true if entry is valid */ - u_short sr_ht; /* holding time */ + struct iso_addr sr_isoa;/* nsap address */ + u_char sr_len; /* length of snpa */ + u_char sr_snpa[MAX_SNPALEN]; /* snpa associated with nsap + * address */ + u_char sr_flags; /* true if entry is valid */ + u_short sr_ht; /* holding time */ }; #define SNPA_VALID 0x01 @@ -79,15 +80,15 @@ struct snpa_req { #define SNPA_PERM 0x10 struct systype_req { - short sr_holdt; /* holding timer */ - short sr_configt; /* configuration timer */ - short sr_esconfigt; /* suggested ES configuration timer */ - char sr_type; /* SNPA_ES or SNPA_IS */ + short sr_holdt; /* holding timer */ + short sr_configt; /* configuration timer */ + short sr_esconfigt; /* suggested ES configuration timer */ + char sr_type;/* SNPA_ES or SNPA_IS */ }; struct esis_req { - short er_ht; /* holding time */ - u_char er_flags; /* type and validity */ + short er_ht; /* holding time */ + u_char er_flags; /* type and validity */ }; /* * Space for this structure gets added onto the end of a route @@ -96,8 +97,8 @@ struct esis_req { struct llinfo_llc { LIST_ENTRY(llinfo_llc) lc_list; - struct rtentry *lc_rt; /* backpointer to route */ - struct esis_req lc_er; /* holding time, etc */ + struct rtentry *lc_rt; /* backpointer to route */ + struct esis_req lc_er; /* holding time, etc */ #define lc_ht lc_er.er_ht #define lc_flags lc_er.er_flags }; @@ -105,5 +106,5 @@ struct llinfo_llc { /* ISO arp IOCTL data structures */ -#define SIOCSSTYPE _IOW('a', 39, struct systype_req) /* set system type */ -#define SIOCGSTYPE _IOR('a', 40, struct systype_req) /* get system type */ +#define SIOCSSTYPE _IOW('a', 39, struct systype_req) /* set system type */ +#define SIOCGSTYPE _IOR('a', 40, struct systype_req) /* get system type */ diff --git a/sys/netiso/iso_var.h b/sys/netiso/iso_var.h index 320052cb52b..fe533687f6b 100644 --- a/sys/netiso/iso_var.h +++ b/sys/netiso/iso_var.h @@ -1,4 +1,5 @@ -/* $NetBSD: iso_var.h,v 1.7 1995/06/13 07:13:35 mycroft Exp $ */ +/* $OpenBSD: iso_var.h,v 1.2 1996/03/04 10:35:43 mickey Exp $ */ +/* $NetBSD: iso_var.h,v 1.8 1996/02/13 22:10:32 christos Exp $ */ /*- * Copyright (c) 1988, 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -57,40 +58,42 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ - +#ifndef _NETISO_ISO_VAR_H_ +#define _NETISO_ISO_VAR_H_ /* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ /* - * Interface address, iso version. One of these structures is + * Interface address, iso version. One of these structures is * allocated for each interface with an osi address. The ifaddr * structure conatins the protocol-independent part * of the structure, and is assumed to be first. */ struct iso_ifaddr { - struct ifaddr ia_ifa; /* protocol-independent info */ + struct ifaddr ia_ifa; /* protocol-independent info */ #define ia_ifp ia_ifa.ifa_ifp #define ia_flags ia_ifa.ifa_flags - int ia_snpaoffset; - TAILQ_ENTRY(iso_ifaddr) ia_list; /* list of iso addresses */ - struct sockaddr_iso ia_addr; /* reserve space for interface name */ - struct sockaddr_iso ia_dstaddr; /* reserve space for broadcast addr */ + int ia_snpaoffset; + TAILQ_ENTRY(iso_ifaddr) ia_list; /* list of iso addresses */ + struct sockaddr_iso ia_addr; /* reserve space for interface name */ + struct sockaddr_iso ia_dstaddr; /* reserve space for broadcast addr */ #define ia_broadaddr ia_dstaddr - struct sockaddr_iso ia_sockmask; /* reserve space for general netmask */ + struct sockaddr_iso ia_sockmask; /* reserve space for general + * netmask */ }; -struct iso_aliasreq { - char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ - struct sockaddr_iso ifra_addr; - struct sockaddr_iso ifra_dstaddr; - struct sockaddr_iso ifra_mask; - int ifra_snpaoffset; +struct iso_aliasreq { + char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + struct sockaddr_iso ifra_addr; + struct sockaddr_iso ifra_dstaddr; + struct sockaddr_iso ifra_mask; + int ifra_snpaoffset; }; -struct iso_ifreq { - char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ - struct sockaddr_iso ifr_Addr; +struct iso_ifreq { + char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + struct sockaddr_iso ifr_Addr; }; /* @@ -100,10 +103,10 @@ struct iso_ifreq { #define IA_SIS(ia) (&(((struct iso_ifaddr *)(ia))->ia_addr)) #define SIOCDIFADDR_ISO _IOW('i',25, struct iso_ifreq) /* delete IF addr */ -#define SIOCAIFADDR_ISO _IOW('i',26, struct iso_aliasreq)/* add/chg IFalias */ +#define SIOCAIFADDR_ISO _IOW('i',26, struct iso_aliasreq) /* add/chg IFalias */ #define SIOCGIFADDR_ISO _IOWR('i',33, struct iso_ifreq) /* get ifnet address */ -#define SIOCGIFDSTADDR_ISO _IOWR('i',34, struct iso_ifreq) /* get dst address */ -#define SIOCGIFNETMASK_ISO _IOWR('i',37, struct iso_ifreq) /* get dst address */ +#define SIOCGIFDSTADDR_ISO _IOWR('i',34, struct iso_ifreq) /* get dst address */ +#define SIOCGIFNETMASK_ISO _IOWR('i',37, struct iso_ifreq) /* get dst address */ /* * This stuff should go in if.h or if_llc.h or someplace else, @@ -111,23 +114,67 @@ struct iso_ifreq { */ struct llc_etherhdr { - char dst[6]; - char src[6]; - char len[2]; - char llc_dsap; - char llc_ssap; - char llc_ui_byte; + char dst[6]; + char src[6]; + char len[2]; + char llc_dsap; + char llc_ssap; + char llc_ui_byte; }; struct snpa_hdr { - struct ifnet *snh_ifp; - char snh_dhost[6]; - char snh_shost[6]; - short snh_flags; + struct ifnet *snh_ifp; + char snh_dhost[6]; + char snh_shost[6]; + short snh_flags; }; #ifdef _KERNEL TAILQ_HEAD(iso_ifaddrhead, iso_ifaddr); -struct iso_ifaddrhead iso_ifaddr; /* linked list of iso address ifaces */ -struct iso_ifaddr *iso_localifa(); /* linked list of iso address ifaces */ -struct ifqueue clnlintrq; /* clnl packet input queue */ +struct iso_ifaddrhead iso_ifaddr; /* linked list of iso address ifaces */ +struct ifqueue clnlintrq; /* clnl packet input queue */ +struct afhash; +struct llinfo_llc; + +/* iso.c */ +int iso_addrmatch1 __P((struct iso_addr *, struct iso_addr *)); +int iso_addrmatch __P((struct sockaddr_iso *, struct sockaddr_iso *)); +int iso_netmatch __P((struct sockaddr_iso *, struct sockaddr_iso *)); +u_long iso_hashchar __P((caddr_t, int)); +int iso_hash __P((struct sockaddr_iso *, struct afhash *)); +int iso_netof __P((struct iso_addr *, caddr_t)); +int iso_control __P((struct socket *, u_long, caddr_t, struct ifnet *)); +void iso_ifscrub __P((struct ifnet *, struct iso_ifaddr *)); +int iso_ifinit __P((struct ifnet *, struct iso_ifaddr *, struct sockaddr_iso *, + int )); +struct ifaddr *iso_ifwithidi __P((struct sockaddr *)); +int iso_ck_addr __P((struct iso_addr *)); +int iso_eqtype __P((struct iso_addr *, struct iso_addr *)); +struct iso_ifaddr *iso_localifa __P((struct sockaddr_iso *)); +int iso_nlctloutput __P((int, int, caddr_t, struct mbuf *)); +void dump_isoaddr __P((struct sockaddr_iso *)); + +/* iso_chksum.c */ +int iso_check_csum __P((struct mbuf *, int)); +void iso_gen_csum __P((struct mbuf *, int, int)); +int m_datalen __P((struct mbuf *)); +int m_compress __P((struct mbuf *, struct mbuf **)); + +/* iso_snpac.c */ +void llc_rtrequest __P((int, struct rtentry *, struct sockaddr *)); +void iso_setmcasts __P((struct ifnet *, int)); +int iso_snparesolve __P((struct ifnet *, struct sockaddr_iso *, + caddr_t, int *)); +void snpac_free __P((struct llinfo_llc *)); +int snpac_add __P((struct ifnet *, struct iso_addr *, caddr_t, int, + u_short, int)); +int snpac_ioctl __P((struct socket *, u_long, caddr_t)); +void snpac_logdefis __P((struct rtentry *)); +void snpac_age __P((void *)); +int snpac_ownmulti __P((caddr_t, u_int)); +void snpac_flushifp __P((struct ifnet *)); +void snpac_rtrequest __P((int, struct iso_addr *, struct iso_addr *, + struct iso_addr *, int, struct rtentry **)); +void snpac_addrt __P((struct ifnet *, struct iso_addr *, struct iso_addr *, + struct iso_addr *)); #endif /* _KERNEL */ +#endif /* _NETISO_ISO_VAR_H_ */ diff --git a/sys/netiso/tp.trans b/sys/netiso/tp.trans index 570b44bdd6a..f8ec072e064 100644 --- a/sys/netiso/tp.trans +++ b/sys/netiso/tp.trans @@ -1,3 +1,4 @@ +/* $OpenBSD: tp.trans,v 1.2 1996/03/04 10:35:46 mickey Exp $ */ /* $NetBSD: tp.trans,v 1.4 1994/06/29 06:39:55 cgd Exp $ */ /* NEW */ diff --git a/sys/netiso/tp_astring.c b/sys/netiso/tp_astring.c index 7fb636f92ad..7a96972bfe9 100644 --- a/sys/netiso/tp_astring.c +++ b/sys/netiso/tp_astring.c @@ -1,4 +1,5 @@ -/* $NetBSD: tp_astring.c,v 1.2 1994/06/29 06:39:57 cgd Exp $ */ +/* $OpenBSD: tp_astring.c,v 1.2 1996/03/04 10:35:48 mickey Exp $ */ +/* $NetBSD: tp_astring.c,v 1.3 1996/02/13 22:10:37 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -35,42 +36,42 @@ * @(#)tp_astring.c 8.1 (Berkeley) 6/10/93 */ -char *tp_sstring[] = { -"ST_ERROR(0x0)", -"TP_CLOSED(0x1)", -"TP_CRSENT(0x2)", -"TP_AKWAIT(0x3)", -"TP_OPEN(0x4)", -"TP_CLOSING(0x5)", -"TP_REFWAIT(0x6)", -"TP_LISTENING(0x7)", -"TP_CONFIRMING(0x8)", +char *tp_sstring[] = { + "ST_ERROR(0x0)", + "TP_CLOSED(0x1)", + "TP_CRSENT(0x2)", + "TP_AKWAIT(0x3)", + "TP_OPEN(0x4)", + "TP_CLOSING(0x5)", + "TP_REFWAIT(0x6)", + "TP_LISTENING(0x7)", + "TP_CONFIRMING(0x8)", }; -char *tp_estring[] = { -"TM_inact(0x0)", -"TM_retrans(0x1)", -"TM_sendack(0x2)", -"TM_notused(0x3)", -"TM_reference(0x4)", -"TM_data_retrans(0x5)", -"ER_TPDU(0x6)", -"CR_TPDU(0x7)", -"DR_TPDU(0x8)", -"DC_TPDU(0x9)", -"CC_TPDU(0xa)", -"AK_TPDU(0xb)", -"DT_TPDU(0xc)", -"XPD_TPDU(0xd)", -"XAK_TPDU(0xe)", -"T_CONN_req(0xf)", -"T_DISC_req(0x10)", -"T_LISTEN_req(0x11)", -"T_DATA_req(0x12)", -"T_XPD_req(0x13)", -"T_USR_rcvd(0x14)", -"T_USR_Xrcvd(0x15)", -"T_DETACH(0x16)", -"T_NETRESET(0x17)", -"T_ACPT_req(0x18)", +char *tp_estring[] = { + "TM_inact(0x0)", + "TM_retrans(0x1)", + "TM_sendack(0x2)", + "TM_notused(0x3)", + "TM_reference(0x4)", + "TM_data_retrans(0x5)", + "ER_TPDU(0x6)", + "CR_TPDU(0x7)", + "DR_TPDU(0x8)", + "DC_TPDU(0x9)", + "CC_TPDU(0xa)", + "AK_TPDU(0xb)", + "DT_TPDU(0xc)", + "XPD_TPDU(0xd)", + "XAK_TPDU(0xe)", + "T_CONN_req(0xf)", + "T_DISC_req(0x10)", + "T_LISTEN_req(0x11)", + "T_DATA_req(0x12)", + "T_XPD_req(0x13)", + "T_USR_rcvd(0x14)", + "T_USR_Xrcvd(0x15)", + "T_DETACH(0x16)", + "T_NETRESET(0x17)", + "T_ACPT_req(0x18)", }; diff --git a/sys/netiso/tp_clnp.h b/sys/netiso/tp_clnp.h index b8e2e6b3dae..b268b1b1e8b 100644 --- a/sys/netiso/tp_clnp.h +++ b/sys/netiso/tp_clnp.h @@ -1,4 +1,5 @@ -/* $NetBSD: tp_clnp.h,v 1.5 1994/06/29 06:39:58 cgd Exp $ */ +/* $OpenBSD: tp_clnp.h,v 1.2 1996/03/04 10:35:50 mickey Exp $ */ +/* $NetBSD: tp_clnp.h,v 1.6 1996/02/13 22:10:42 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -61,7 +62,7 @@ SOFTWARE. /* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ -/* +/* * AF_ISO net-dependent structures and include files */ @@ -70,7 +71,7 @@ SOFTWARE. #ifndef SOCK_STREAM #include <sys/socket.h> -#endif /* SOCK_STREAM */ +#endif /* SOCK_STREAM */ #ifndef RTFREE #include <net/route.h> @@ -83,7 +84,7 @@ SOFTWARE. #endif #include <netiso/iso_var.h> -struct isopcb tp_isopcb; - /* queue of active inpcbs for tp ; for tp with dod ip */ +struct isopcb tp_isopcb; +/* queue of active inpcbs for tp ; for tp with dod ip */ -#endif /* _NETISO_TP_CLNP_H_ */ +#endif /* _NETISO_TP_CLNP_H_ */ diff --git a/sys/netiso/tp_cons.c b/sys/netiso/tp_cons.c index 49bba861e2e..cafa0166682 100644 --- a/sys/netiso/tp_cons.c +++ b/sys/netiso/tp_cons.c @@ -1,4 +1,5 @@ -/* $NetBSD: tp_cons.c,v 1.6 1994/06/29 06:39:59 cgd Exp $ */ +/* $OpenBSD: tp_cons.c,v 1.2 1996/03/04 10:35:51 mickey Exp $ */ +/* $NetBSD: tp_cons.c,v 1.8 1996/02/14 21:32:37 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -61,22 +62,21 @@ SOFTWARE. /* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ -/* - * Here is where you find the iso- and cons-dependent code. We've tried - * keep all net-level and (primarily) address-family-dependent stuff - * out of the tp source, and everthing here is reached indirectly - * through a switch table (struct nl_protosw *) tpcb->tp_nlproto - * (see tp_pcb.c). - * The routines here are: - * tpcons_input: pullup and call tp_input w/ correct arguments - * tpcons_output: package a pkt for cons given an isopcb & some data - * cons_chan_to_tpcb: find a tpcb based on the channel # +/* + * Here is where you find the iso- and cons-dependent code. We've tried keep + * all net-level and (primarily) address-family-dependent stuff out of the tp + * source, and everthing here is reached indirectly through a switch table + * (struct nl_protosw *) tpcb->tp_nlproto (see tp_pcb.c). The routines here + * are: tpcons_input: pullup and call tp_input w/ correct arguments + * tpcons_output: package a pkt for cons given an isopcb & some data + * cons_chan_to_tpcb: find a tpcb based on the channel # */ #ifdef ISO #ifdef TPCONS #include <sys/param.h> +#include <sys/systm.h> #include <sys/socket.h> #include <sys/domain.h> #include <sys/mbuf.h> @@ -96,17 +96,23 @@ SOFTWARE. #include <netiso/iso.h> #include <netiso/iso_errno.h> #include <netiso/iso_pcb.h> +#include <netiso/iso_var.h> #include <netiso/cons.h> #include <netiso/tp_seq.h> +#include <netiso/tp_var.h> +#include <netiso/clnp.h> #undef FALSE #undef TRUE #include <netccitt/x25.h> #include <netccitt/pk.h> #include <netccitt/pk_var.h> +#include <netccitt/pk_extern.h> + +#include <machine/stdarg.h> #include <netiso/if_cons.c> -int tpcons_output(); + /* * CALLED FROM: @@ -115,24 +121,28 @@ int tpcons_output(); * version of the previous procedure for X.25 */ -tpcons_pcbconnect(isop, nam) -struct isopcb *isop; -register struct mbuf *nam; +int +tpcons_pcbconnect(v, nam) + void *v; + register struct mbuf *nam; { - int error; - if (error = iso_pcbconnect(isop, nam)) + struct isopcb *isop = v; + int error; + if ((error = iso_pcbconnect(isop, nam)) != 0) return error; - if ((isop->isop_chan = (caddr_t) pk_attach((struct socket *)0)) == 0) { - IFDEBUG(D_CCONS) + if ((isop->isop_chan = (caddr_t) pk_attach((struct socket *) 0)) == 0) { +#ifdef ARGO_DEBUG + if (argo_debug[D_CCONS]) { printf("tpcons_pcbconnect: no pklcd; returns 0x%x\n", error); - ENDDEBUG + } +#endif return ENOBUFS; } - if (error = cons_connect(isop)) { /* if it doesn't work */ + if ((error = cons_connect(isop)) != 0) { /* if it doesn't work */ /* oh, dear, throw packet away */ - pk_disconnect((struct pklcd *)isop->isop_chan); + pk_disconnect((struct pklcd *) isop->isop_chan); isop->isop_chan = 0; - } else + } else isop->isop_refcnt = 1; return error; } @@ -144,57 +154,63 @@ register struct mbuf *nam; * FUNCTION and ARGUMENTS: * THIS MAYBE BELONGS IN SOME OTHER PLACE??? but i think not - */ -void -tpcons_ctlinput(cmd, siso, isop) - int cmd; - struct sockaddr_iso *siso; - struct isopcb *isop; +void * +tpcons_ctlinput(cmd, siso, v) + int cmd; + struct sockaddr *siso; + void *v; { + struct isopcb *isop = v; register struct tp_pcb *tpcb = 0; if (isop->isop_socket) - tpcb = (struct tp_pcb *)isop->isop_socket->so_pcb; + tpcb = (struct tp_pcb *) isop->isop_socket->so_pcb; switch (cmd) { case PRC_CONS_SEND_DONE: if (tpcb) { - struct tp_event E; - int error = 0; + struct tp_event E; + int error = 0; if (tpcb->tp_class == TP_CLASS_0) { - /* only if class is exactly class zero, not + /* + * only if class is exactly class zero, not * still in class negotiation */ /* fake an ack */ - register SeqNum seq = SEQ_ADD(tpcb, tpcb->tp_snduna, 1); - - IFTRACE(D_DATA) - tptrace(TPPTmisc, "FAKE ACK seq cdt 1", - seq, 0,0,0); - ENDTRACE - IFDEBUG(D_DATA) - printf("FAKE ACK seq 0x%x cdt 1\n", seq ); - ENDDEBUG - E.ATTR(AK_TPDU).e_cdt = 1; - E.ATTR(AK_TPDU).e_seq = seq; - E.ATTR(AK_TPDU).e_subseq = 0; - E.ATTR(AK_TPDU).e_fcc_present = 0; - error = DoEvent(AK_TPDU); - if( error ) { + register SeqNum seq = SEQ_ADD(tpcb, tpcb->tp_snduna, 1); + +#ifdef TPPT + if(tp_traceflags[D_DATA]) + tptrace(TPPTmisc, "FAKE ACK seq cdt 1", + seq, 0, 0, 0); +#endif +#ifdef ARGO_DEBUG + if (argo_debug[D_DATA]) { + printf("FAKE ACK seq 0x%x cdt 1\n", seq); + } +#endif + E.TP_ATTR(AK_TPDU).e_cdt = 1; + E.TP_ATTR(AK_TPDU).e_seq = seq; + E.TP_ATTR(AK_TPDU).e_subseq = 0; + E.TP_ATTR(AK_TPDU).e_fcc_present = 0; + error = DoEvent(AK_TPDU); + if (error) { tpcb->tp_sock->so_error = error; } - } /* else ignore it */ + } /* else ignore it */ } break; case PRC_ROUTEDEAD: if (tpcb && tpcb->tp_class == TP_CLASS_0) { tpiso_reset(isop); break; - } /* else drop through */ + } /* else drop through */ default: - tpclnp_ctlinput(cmd, siso); + tpclnp_ctlinput(cmd, siso, NULL); break; } + return NULL; } /* @@ -202,24 +218,37 @@ tpcons_ctlinput(cmd, siso, isop) * cons's intr routine * FUNCTION and ARGUMENTS: * Take a packet (m) from cons, pullup m as required by tp, - * ignore the socket argument, and call tp_input. - * No return value. + * ignore the socket argument, and call tp_input. + * No return value. */ void -tpcons_input(m, faddr, laddr, channel) - struct mbuf *m; - struct sockaddr_iso *faddr, *laddr; - caddr_t channel; +#if __STDC__ +tpcons_input(struct mbuf *m, ...) +#else +tpcons_input(m, va_alist) + struct mbuf *m; + va_dcl +#endif { - if( m == MNULL) + struct sockaddr *faddr, *laddr; + caddr_t channel; + va_list ap; + if (m == NULL) return; + va_start(ap, m); + faddr = va_arg(ap, struct sockaddr *); + laddr = va_arg(ap, struct sockaddr *); + channel = va_arg(ap, caddr_t); + - m = (struct mbuf *)tp_inputprep(m); + m = (struct mbuf *) tp_inputprep(m); - IFDEBUG(D_TPINPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { printf("tpcons_input before tp_input(m 0x%x)\n", m); - dump_buf( m, 12+ m->m_len); - ENDDEBUG + dump_buf(m, 12 + m->m_len); + } +#endif tp_input(m, faddr, laddr, channel, tpcons_output, 0); } @@ -237,21 +266,35 @@ tpcons_input(m, faddr, laddr, channel) */ int -tpcons_output(isop, m0, datalen, nochksum) - struct isopcb *isop; - struct mbuf *m0; - int datalen; - int nochksum; +#if __STDC__ +tpcons_output(struct mbuf *m0, ...) +#else +tpcons_output(m0, va_alist) + struct mbuf *m0; + va_dcl +#endif { - register struct mbuf *m = m0; - int error; + struct isopcb *isop; + int datalen; + int nochksum; + register struct mbuf *m = m0; + int error; + va_list ap; + + va_start(ap, m0); + datalen = va_arg(ap, int); + isop = va_arg(ap, struct isopcb *); + nochksum = va_arg(ap, int); + va_end(ap); - IFDEBUG(D_EMIT) +#ifdef ARGO_DEBUG + if (argo_debug[D_EMIT]) { printf( - "tpcons_output(isop 0x%x, m 0x%x, len 0x%x socket 0x%x\n", - isop, m0, datalen, isop->isop_socket); - ENDDEBUG - if (m == MNULL) + "tpcons_output(isop 0x%x, m 0x%x, len 0x%x socket 0x%x\n", + isop, m0, datalen, isop->isop_socket); + } +#endif + if (m == NULL) return 0; if ((m->m_flags & M_PKTHDR) == 0) { MGETHDR(m, M_DONTWAIT, MT_DATA); @@ -262,21 +305,25 @@ tpcons_output(isop, m0, datalen, nochksum) m->m_pkthdr.len = datalen; if (isop->isop_chan == 0) { /* got a restart maybe? */ - if ((isop->isop_chan = (caddr_t) pk_attach((struct socket *)0)) == 0) { - IFDEBUG(D_CCONS) + if ((isop->isop_chan = (caddr_t) pk_attach((struct socket *) 0)) == 0) { +#ifdef ARGO_DEBUG + if (argo_debug[D_CCONS]) { printf("tpcons_output: no pklcd\n"); - ENDDEBUG + } +#endif error = ENOBUFS; } - if (error = cons_connect(isop)) { - pk_disconnect((struct pklcd *)isop->isop_chan); + if ((error = cons_connect(isop)) != 0) { + pk_disconnect((struct pklcd *) isop->isop_chan); isop->isop_chan = 0; - IFDEBUG(D_CCONS) +#ifdef ARGO_DEBUG + if (argo_debug[D_CCONS]) { printf("tpcons_output: can't reconnect\n"); - ENDDEBUG + } +#endif } } else { - error = pk_send(isop->isop_chan, m); + error = pk_send(m, isop->isop_chan); IncStat(ts_tpdu_sent); } return error; @@ -293,12 +340,45 @@ tpcons_output(isop, m0, datalen, nochksum) */ int -tpcons_dg_output(chan, m0, datalen) - caddr_t chan; - struct mbuf *m0; - int datalen; +#if __STDC__ +tpcons_output_dg(struct mbuf *m0, ...) +#else +tpcons_output_dg(m0, va_alist) + struct mbuf *m0; + va_dcl +#endif +{ + int datalen; + caddr_t chan; + va_list ap; + + va_start(ap, m0); + datalen = va_arg(ap, int); + chan = va_arg(ap, caddr_t); + va_end(ap); + + return tpcons_output(m0, datalen, + ((struct pklcd *) chan)->lcd_upnext, + 0); +} +#else + +#include <sys/param.h> + +struct mbuf; + +int tpcons_output __P((struct mbuf *m0, ...)); + +int +#if __STDC__ +tpcons_output(struct mbuf *m0, ...) +#else +tpcons_output(m0, va_alist) + struct mbuf *m0; + va_dcl +#endif { - return tpcons_output(((struct pklcd *)chan)->lcd_upnext, m0, datalen, 0); + return 0; } #endif /* TPCONS */ #endif /* ISO */ diff --git a/sys/netiso/tp_driver.c b/sys/netiso/tp_driver.c index 0a781abcfa0..1e19566d4c0 100644 --- a/sys/netiso/tp_driver.c +++ b/sys/netiso/tp_driver.c @@ -1,13 +1,14 @@ -/* $NetBSD: tp_driver.c,v 1.6 1994/06/29 06:40:01 cgd Exp $ */ - -#define _XEBEC_PG static +/* $OpenBSD: tp_driver.c,v 1.2 1996/03/04 10:35:53 mickey Exp $ */ +/* $NetBSD: tp_driver.c,v 1.7 1996/02/13 22:10:49 christos Exp $ */ #include "tp_states.h" static struct act_ent { - int a_newstate; - int a_action; -} statetable[] = { {0,0}, + int a_newstate; + int a_action; +} statetable[] = {{ + 0, 0 +}, #include "tp_states.init" }; @@ -30,179 +31,166 @@ static struct act_ent { #include <netiso/tp_trace.h> #include <netiso/iso_errno.h> #include <netiso/tp_seq.h> +#include <netiso/tp_var.h> #include <netiso/cons.h> #define DRIVERTRACE TPPTdriver #define sbwakeup(sb) sowakeup(p->tp_sock, sb); #define MCPY(d, w) (d ? m_copym(d, 0, (int)M_COPYALL, w): 0) -static trick_hc = 1; - -int tp_emit(), - tp_goodack(), tp_goodXack(), - tp_stash() -; -void tp_indicate(), tp_getoptions(), - tp_soisdisconnecting(), tp_soisdisconnected(), - tp_recycle_tsuffix(), -#ifdef TP_DEBUG_TIMERS - tp_etimeout(), tp_euntimeout(), - tp_ctimeout(), tp_cuntimeout(), - tp_ctimeout_MIN(), -#endif - tp_freeref(), tp_detach(), - tp0_stash(), tp0_send(), - tp_netcmd(), tp_send() -; - -typedef struct tp_pcb tpcb_struct; - - - -typedef tpcb_struct tp_PCB_; +static trick_hc = 1; #include "tp_events.h" +static int _Xebec_action __P((int, struct tp_event *, struct tp_pcb *)); +static int _Xebec_index __P((struct tp_event *, struct tp_pcb *)); -_XEBEC_PG int _Xebec_action(a,e,p) -int a; -struct tp_event *e; -tp_PCB_ *p; +static int +_Xebec_action(a, e, p) + int a; + struct tp_event *e; + struct tp_pcb *p; { -switch(a) { -case -1: return tp_protocol_error(e,p); -case 0x1: - { - (void) tp_emit(DC_TPDU_type, p, 0, 0, MNULL); - } - break; -case 0x2: - { -# ifdef TP_DEBUG - if( e->ev_number != AK_TPDU ) + int error; + struct mbuf *data = NULL; + int doack; + struct socket *so = p->tp_sock; + struct sockbuf *sb; + int timo; + + switch (a) { + case -1: + return tp_protocol_error(e, p); + case 0x1: + (void) tp_emit(DC_TPDU_type, p, 0, 0, NULL); + break; + case 0x2: +#ifdef TP_DEBUG + if (e->ev_number != AK_TPDU) printf("TPDU 0x%x in REFWAIT!!!!\n", e->ev_number); -# endif TP_DEBUG - } - break; -case 0x3: - { +#endif /* TP_DEBUG */ + break; + case 0x3: /* oh, man is this grotesque or what? */ - (void) tp_goodack(p, e->ev_union.EV_AK_TPDU.e_cdt, e->ev_union.EV_AK_TPDU.e_seq, e->ev_union.EV_AK_TPDU.e_subseq); - /* but it's necessary because this pseudo-ack may happen - * before the CC arrives, but we HAVE to adjust the - * snduna as a result of the ack, WHENEVER it arrives + (void) tp_goodack(p, e->ev_union.EV_AK_TPDU.e_cdt, e->ev_union.EV_AK_TPDU.e_seq, e->ev_union.EV_AK_TPDU.e_subseq); + /* + * but it's necessary because this pseudo-ack may + * happen before the CC arrives, but we HAVE to + * adjust the snduna as a result of the ack, WHENEVER + * it arrives */ - } - break; -case 0x4: - { + break; + case 0x4: tp_detach(p); - } - break; -case 0x5: - { - p->tp_refstate = REF_OPEN; /* has timers ??? */ - } - break; -case 0x6: - { - IFTRACE(D_CONN) - tptrace(TPPTmisc, "CR datalen data", e->ev_union.EV_CR_TPDU.e_datalen, e->ev_union.EV_CR_TPDU.e_data,0,0); - ENDTRACE - IFDEBUG(D_CONN) - printf("CR datalen 0x%x data 0x%x", e->ev_union.EV_CR_TPDU.e_datalen, e->ev_union.EV_CR_TPDU.e_data); - ENDDEBUG - p->tp_refstate = REF_OPEN; /* has timers */ + break; + case 0x5: + p->tp_refstate = REF_OPEN; /* has timers ??? */ + break; + case 0x6: +#ifdef TPPT + if (tp_traceflags[D_CONN]) + tptrace(TPPTmisc, "CR datalen data", + e->ev_union.EV_CR_TPDU.e_datalen, + e->ev_union.EV_CR_TPDU.e_data, 0, 0); +#endif +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { + printf("CR datalen 0x%x data 0x%x", + e->ev_union.EV_CR_TPDU.e_datalen, + e->ev_union.EV_CR_TPDU.e_data); + } +#endif + p->tp_refstate = REF_OPEN; /* has timers */ p->tp_fcredit = e->ev_union.EV_CR_TPDU.e_cdt; if (e->ev_union.EV_CR_TPDU.e_datalen > 0) { /* n/a for class 0 */ - ASSERT(p->tp_Xrcv.sb_cc == 0); - sbappendrecord(&p->tp_Xrcv, e->ev_union.EV_CR_TPDU.e_data); - e->ev_union.EV_CR_TPDU.e_data = MNULL; - } - } - break; -case 0x7: - { + ASSERT(p->tp_Xrcv.sb_cc == 0); + sbappendrecord(&p->tp_Xrcv, + e->ev_union.EV_CR_TPDU.e_data); + e->ev_union.EV_CR_TPDU.e_data = NULL; + } + break; + case 0x7: IncStat(ts_tp0_conn); - IFTRACE(D_CONN) - tptrace(TPPTmisc, "Confiming", p, 0,0,0); - ENDTRACE - IFDEBUG(D_CONN) - printf("Confirming connection: p" ); - ENDDEBUG +#ifdef TPPT + if (tp_traceflags[D_CONN]) + tptrace(TPPTmisc, "Confiming", p, 0, 0, 0); +#endif +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { + printf("Confirming connection: p"); + } +#endif soisconnected(p->tp_sock); - (void) tp_emit(CC_TPDU_type, p, 0,0, MNULL) ; + (void) tp_emit(CC_TPDU_type, p, 0, 0, NULL); p->tp_fcredit = 1; - } - break; -case 0x8: - { - IncStat(ts_tp4_conn); /* even though not quite open */ - IFTRACE(D_CONN) - tptrace(TPPTmisc, "Confiming", p, 0,0,0); - ENDTRACE - IFDEBUG(D_CONN) - printf("Confirming connection: p" ); - ENDDEBUG + break; + case 0x8: + IncStat(ts_tp4_conn); /* even though not quite open */ +#ifdef TPPT + if (tp_traceflags[D_CONN]) + tptrace(TPPTmisc, "Confiming", p, 0, 0, 0); +#endif +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { + printf("Confirming connection: p"); + } +#endif tp_getoptions(p); soisconnecting(p->tp_sock); if ((p->tp_rx_strat & TPRX_FASTSTART) && (p->tp_fcredit > 0)) p->tp_cong_win = p->tp_fcredit * p->tp_l_tpdusize; p->tp_retrans = p->tp_Nretrans; - tp_ctimeout(p, TM_retrans, (int)p->tp_cc_ticks); - } - break; -case 0x9: - { - IFDEBUG(D_CONN) - printf("event: CR_TPDU emit CC failed done " ); - ENDDEBUG + tp_ctimeout(p, TM_retrans, (int) p->tp_cc_ticks); + break; + case 0x9: +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { + printf("event: CR_TPDU emit CC failed done "); + } +#endif soisdisconnected(p->tp_sock); tp_recycle_tsuffix(p); tp_freeref(p->tp_lref); tp_detach(p); - } - break; -case 0xa: - { - int error; - struct mbuf *data = MNULL; - - IFTRACE(D_CONN) - tptrace(TPPTmisc, "T_CONN_req flags ucddata", (int)p->tp_flags, - p->tp_ucddata, 0, 0); - ENDTRACE - data = MCPY(p->tp_ucddata, M_WAIT); + break; + case 0xa: +#ifdef TPPT + if (tp_traceflags[D_CONN]) + tptrace(TPPTmisc, "T_CONN_req flags ucddata", + (int) p->tp_flags, p->tp_ucddata, 0, 0); +#endif + data = MCPY(p->tp_ucddata, M_WAIT); if (data) { - IFDEBUG(D_CONN) - printf("T_CONN_req.trans m_copy cc 0x%x\n", - p->tp_ucddata); +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { + printf("T_CONN_req.trans m_copy cc 0x%x\n", + p->tp_ucddata); dump_mbuf(data, "sosnd @ T_CONN_req"); - ENDDEBUG + } +#endif } + if ((error = tp_emit(CR_TPDU_type, p, 0, 0, data)) != 0) + return error; /* driver WON'T change state; + * will return error */ - if (error = tp_emit(CR_TPDU_type, p, 0, 0, data) ) - return error; /* driver WON'T change state; will return error */ - - p->tp_refstate = REF_OPEN; /* has timers */ - if(p->tp_class != TP_CLASS_0) { + p->tp_refstate = REF_OPEN; /* has timers */ + if (p->tp_class != TP_CLASS_0) { p->tp_retrans = p->tp_Nretrans; - tp_ctimeout(p, TM_retrans, (int)p->tp_cr_ticks); + tp_ctimeout(p, TM_retrans, (int) p->tp_cr_ticks); } - } - break; -case 0xb: - { - sbflush(&p->tp_Xrcv); /* purge non-delivered data data */ + break; + case 0xb: + sbflush(&p->tp_Xrcv); /* purge non-delivered data + * data */ if (e->ev_union.EV_DR_TPDU.e_datalen > 0) { sbappendrecord(&p->tp_Xrcv, e->ev_union.EV_DR_TPDU.e_data); - e->ev_union.EV_DR_TPDU.e_data = MNULL; - } + e->ev_union.EV_DR_TPDU.e_data = NULL; + } if (p->tp_state == TP_OPEN) tp_indicate(T_DISCONNECT, p, 0); else { - int so_error = ECONNREFUSED; + int so_error = ECONNREFUSED; if (e->ev_union.EV_DR_TPDU.e_reason != (E_TP_NO_SESSION ^ TP_ERROR_MASK) && e->ev_union.EV_DR_TPDU.e_reason != (E_TP_NO_CR_ON_NC ^ TP_ERROR_MASK) && e->ev_union.EV_DR_TPDU.e_reason != (E_TP_REF_OVERFLOW ^ TP_ERROR_MASK)) @@ -211,170 +199,148 @@ case 0xb: } tp_soisdisconnected(p); if (p->tp_class != TP_CLASS_0) { - if (p->tp_state == TP_OPEN ) { - tp_euntimeout(p, TM_data_retrans); /* all */ + if (p->tp_state == TP_OPEN) { + tp_euntimeout(p, TM_data_retrans);/* all */ tp_cuntimeout(p, TM_retrans); tp_cuntimeout(p, TM_inact); tp_cuntimeout(p, TM_sendack); p->tp_flags &= ~TPF_DELACK; } tp_cuntimeout(p, TM_retrans); - if( e->ev_union.EV_DR_TPDU.e_sref != 0 ) - (void) tp_emit(DC_TPDU_type, p, 0, 0, MNULL); + if (e->ev_union.EV_DR_TPDU.e_sref != 0) + (void) tp_emit(DC_TPDU_type, p, 0, 0, NULL); } - } - break; -case 0xc: - { - if( e->ev_union.EV_DR_TPDU.e_sref != 0 ) - (void) tp_emit(DC_TPDU_type, p, 0, 0, MNULL); - /* reference timer already set - reset it to be safe (???) */ - tp_euntimeout(p, TM_reference); /* all */ - tp_etimeout(p, TM_reference, (int)p->tp_refer_ticks); - } - break; -case 0xd: - { + break; + case 0xc: + if (e->ev_union.EV_DR_TPDU.e_sref != 0) + (void) tp_emit(DC_TPDU_type, p, 0, 0, NULL); + /* + * reference timer already set - reset it to be safe + * (???) + */ + tp_euntimeout(p, TM_reference); /* all */ + tp_etimeout(p, TM_reference, (int) p->tp_refer_ticks); + break; + case 0xd: tp_cuntimeout(p, TM_retrans); tp_indicate(ER_TPDU, p, e->ev_union.EV_ER_TPDU.e_reason); tp_soisdisconnected(p); - } - break; -case 0xe: - { + break; + case 0xe: tp_cuntimeout(p, TM_retrans); tp_soisdisconnected(p); - } - break; -case 0xf: - { + break; + case 0xf: tp_indicate(ER_TPDU, p, e->ev_union.EV_ER_TPDU.e_reason); tp_cuntimeout(p, TM_retrans); tp_soisdisconnected(p); - } - break; -case 0x10: - { + break; + case 0x10: tp_cuntimeout(p, TM_retrans); tp_soisdisconnected(p); - } - break; -case 0x11: - { /* don't ask me why we have to do this - spec says so */ - (void) tp_emit(DR_TPDU_type, p, 0, E_TP_NO_SESSION, MNULL); + break; + case 0x11: + /* don't ask me why we have to do this - spec + * says so */ + (void) tp_emit(DR_TPDU_type, p, 0, E_TP_NO_SESSION, NULL); /* don't bother with retransmissions of the DR */ - } - break; -case 0x12: - { + break; + case 0x12: tp_soisdisconnecting(p->tp_sock); tp_indicate(ER_TPDU, p, e->ev_union.EV_ER_TPDU.e_reason); tp_soisdisconnected(p); - tp_netcmd( p, CONN_CLOSE ); - } - break; -case 0x13: - { + tp_netcmd(p, CONN_CLOSE); + break; + case 0x13: if (p->tp_state == TP_OPEN) { - tp_euntimeout(p, TM_data_retrans); /* all */ + tp_euntimeout(p, TM_data_retrans); /* all */ tp_cuntimeout(p, TM_inact); tp_cuntimeout(p, TM_sendack); } tp_soisdisconnecting(p->tp_sock); tp_indicate(ER_TPDU, p, e->ev_union.EV_ER_TPDU.e_reason); p->tp_retrans = p->tp_Nretrans; - tp_ctimeout(p, TM_retrans, (int)p->tp_dr_ticks); - (void) tp_emit(DR_TPDU_type, p, 0, E_TP_PROTO_ERR, MNULL); - } - break; -case 0x14: - { + tp_ctimeout(p, TM_retrans, (int) p->tp_dr_ticks); + (void) tp_emit(DR_TPDU_type, p, 0, E_TP_PROTO_ERR, NULL); + break; + case 0x14: tp_cuntimeout(p, TM_retrans); IncStat(ts_tp0_conn); p->tp_fcredit = 1; soisconnected(p->tp_sock); - } - break; -case 0x15: - { - IFDEBUG(D_CONN) - printf("trans: CC_TPDU in CRSENT state flags 0x%x\n", - (int)p->tp_flags); - ENDDEBUG + break; + case 0x15: +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { + printf("trans: CC_TPDU in CRSENT state flags 0x%x\n", + (int) p->tp_flags); + } +#endif IncStat(ts_tp4_conn); p->tp_fref = e->ev_union.EV_CC_TPDU.e_sref; p->tp_fcredit = e->ev_union.EV_CC_TPDU.e_cdt; - if ((p->tp_rx_strat & TPRX_FASTSTART) && (e->ev_union.EV_CC_TPDU.e_cdt > 0)) + if ((p->tp_rx_strat & TPRX_FASTSTART) && + (e->ev_union.EV_CC_TPDU.e_cdt > 0)) p->tp_cong_win = e->ev_union.EV_CC_TPDU.e_cdt * p->tp_l_tpdusize; tp_getoptions(p); tp_cuntimeout(p, TM_retrans); if (p->tp_ucddata) { - IFDEBUG(D_CONN) +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("dropping user connect data cc 0x%x\n", - p->tp_ucddata->m_len); - ENDDEBUG + p->tp_ucddata->m_len); + } +#endif m_freem(p->tp_ucddata); p->tp_ucddata = 0; } soisconnected(p->tp_sock); if (e->ev_union.EV_CC_TPDU.e_datalen > 0) { - ASSERT(p->tp_Xrcv.sb_cc == 0); /* should be empty */ - sbappendrecord(&p->tp_Xrcv, e->ev_union.EV_CC_TPDU.e_data); - e->ev_union.EV_CC_TPDU.e_data = MNULL; + ASSERT(p->tp_Xrcv.sb_cc == 0); /* should be empty */ + sbappendrecord(&p->tp_Xrcv, + e->ev_union.EV_CC_TPDU.e_data); + e->ev_union.EV_CC_TPDU.e_data = NULL; } - - (void) tp_emit(AK_TPDU_type, p, p->tp_rcvnxt, 0, MNULL); - tp_ctimeout(p, TM_inact, (int)p->tp_inact_ticks); - } - break; -case 0x16: - { - struct mbuf *data = MNULL; - int error; - + (void) tp_emit(AK_TPDU_type, p, p->tp_rcvnxt, 0, NULL); + tp_ctimeout(p, TM_inact, (int) p->tp_inact_ticks); + break; + case 0x16: IncStat(ts_retrans_cr); p->tp_cong_win = 1 * p->tp_l_tpdusize; data = MCPY(p->tp_ucddata, M_NOWAIT); - if(p->tp_ucddata) { - IFDEBUG(D_CONN) - printf("TM_retrans.trans m_copy cc 0x%x\n", data); + if (p->tp_ucddata) { +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { + printf("TM_retrans.trans m_copy cc 0x%x\n", + data); dump_mbuf(p->tp_ucddata, "sosnd @ TM_retrans"); - ENDDEBUG - if( data == MNULL ) + } +#endif + if (data == NULL) return ENOBUFS; } - - p->tp_retrans --; - if( error = tp_emit(CR_TPDU_type, p, 0, 0, data) ) { + p->tp_retrans--; + if ((error = tp_emit(CR_TPDU_type, p, 0, 0, data)) != 0) { p->tp_sock->so_error = error; } - tp_ctimeout(p, TM_retrans, (int)p->tp_cr_ticks); - } - break; -case 0x17: - { + tp_ctimeout(p, TM_retrans, (int) p->tp_cr_ticks); + break; + case 0x17: IncStat(ts_conn_gaveup); p->tp_sock->so_error = ETIMEDOUT; tp_indicate(T_DISCONNECT, p, ETIMEDOUT); tp_soisdisconnected(p); - } - break; -case 0x18: - { - int error; - struct mbuf *data = MCPY(p->tp_ucddata, M_WAIT); + break; + case 0x18: + data = MCPY(p->tp_ucddata, M_WAIT); - if( error = tp_emit(CC_TPDU_type, p, 0, 0, data) ) { + if ((error = tp_emit(CC_TPDU_type, p, 0, 0, data)) != 0) { p->tp_sock->so_error = error; } p->tp_retrans = p->tp_Nretrans; - tp_ctimeout(p, TM_retrans, (int)p->tp_cc_ticks); - } - break; -case 0x19: - { - int doack; - + tp_ctimeout(p, TM_retrans, (int) p->tp_cc_ticks); + break; + case 0x19: /* * Get rid of any confirm or connect data, so that if we * crash or close, it isn't thought of as disconnect data. @@ -383,75 +349,80 @@ case 0x19: m_freem(p->tp_ucddata); p->tp_ucddata = 0; } - tp_ctimeout(p, TM_inact, (int)p->tp_inact_ticks); + tp_ctimeout(p, TM_inact, (int) p->tp_inact_ticks); tp_cuntimeout(p, TM_retrans); soisconnected(p->tp_sock); - tp_ctimeout(p, TM_inact, (int)p->tp_inact_ticks); + tp_ctimeout(p, TM_inact, (int) p->tp_inact_ticks); - /* see also next 2 transitions, if you make any changes */ + /* + * see also next 2 transitions, if you make any + * changes + */ doack = tp_stash(p, e); - IFDEBUG(D_DATA) - printf("tp_stash returns %d\n",doack); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_DATA]) { + printf("tp_stash returns %d\n", doack); + } +#endif if (doack) { - (void) tp_emit(AK_TPDU_type, p, p->tp_rcvnxt, 0, MNULL ); - tp_ctimeout(p, TM_sendack, (int)p->tp_keepalive_ticks); + (void) tp_emit(AK_TPDU_type, p, p->tp_rcvnxt, 0, NULL); + tp_ctimeout(p, TM_sendack, (int) p->tp_keepalive_ticks); } else - tp_ctimeout( p, TM_sendack, (int)p->tp_sendack_ticks); - - IFDEBUG(D_DATA) + tp_ctimeout(p, TM_sendack, (int) p->tp_sendack_ticks); + +#ifdef ARGO_DEBUG + if (argo_debug[D_DATA]) { printf("after stash calling sbwakeup\n"); - ENDDEBUG - } - break; -case 0x1a: - { + } +#endif + break; + case 0x1a: tp0_stash(p, e); - sbwakeup( &p->tp_sock->so_rcv ); + sbwakeup(&p->tp_sock->so_rcv); - IFDEBUG(D_DATA) +#ifdef ARGO_DEBUG + if (argo_debug[D_DATA]) { printf("after stash calling sbwakeup\n"); - ENDDEBUG - } - break; -case 0x1b: - { - int doack; /* tells if we must ack immediately */ - - tp_ctimeout(p, TM_inact, (int)p->tp_inact_ticks); - sbwakeup( &p->tp_sock->so_rcv ); + } +#endif + break; + case 0x1b: + tp_ctimeout(p, TM_inact, (int) p->tp_inact_ticks); + sbwakeup(&p->tp_sock->so_rcv); doack = tp_stash(p, e); - IFDEBUG(D_DATA) - printf("tp_stash returns %d\n",doack); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_DATA]) { + printf("tp_stash returns %d\n", doack); + } +#endif - if(doack) - (void) tp_emit(AK_TPDU_type, p, p->tp_rcvnxt, 0, MNULL ); + if (doack) + (void) tp_emit(AK_TPDU_type, p, p->tp_rcvnxt, 0, NULL); else - tp_ctimeout_MIN( p, TM_sendack, (int)p->tp_sendack_ticks); - - IFDEBUG(D_DATA) + tp_ctimeout_MIN(p, TM_sendack, (int) p->tp_sendack_ticks); + +#ifdef ARGO_DEBUG + if (argo_debug[D_DATA]) { printf("after stash calling sbwakeup\n"); - ENDDEBUG - } - break; -case 0x1c: - { - IFTRACE(D_DATA) + } +#endif + break; + case 0x1c: +#ifdef TPPT + if (tp_traceflags[D_DATA]) tptrace(TPPTmisc, "NIW seq rcvnxt lcredit ", - e->ev_union.EV_DT_TPDU.e_seq, p->tp_rcvnxt, p->tp_lcredit, 0); - ENDTRACE + e->ev_union.EV_DT_TPDU.e_seq, + p->tp_rcvnxt, p->tp_lcredit, 0); +#endif IncStat(ts_dt_niw); m_freem(e->ev_union.EV_DT_TPDU.e_data); - tp_ctimeout(p, TM_inact, (int)p->tp_inact_ticks); - (void) tp_emit(AK_TPDU_type, p, p->tp_rcvnxt, 0, MNULL ); - } - break; -case 0x1d: - { + tp_ctimeout(p, TM_inact, (int) p->tp_inact_ticks); + (void) tp_emit(AK_TPDU_type, p, p->tp_rcvnxt, 0, NULL); + break; + case 0x1d: if (p->tp_ucddata) { m_freem(p->tp_ucddata); p->tp_ucddata = 0; @@ -460,82 +431,87 @@ case 0x1d: tp_cuntimeout(p, TM_retrans); soisconnected(p->tp_sock); - IFTRACE(D_CONN) - struct socket *so = p->tp_sock; - tptrace(TPPTmisc, +#ifdef TPPT + if (tp_traceflags[D_CONN]) { + struct socket *so = p->tp_sock; + tptrace(TPPTmisc, "called sosiconn: so so_state rcv.sb_sel rcv.sb_flags", - so, so->so_state, so->so_rcv.sb_sel, so->so_rcv.sb_flags); - tptrace(TPPTmisc, - "called sosiconn 2: so_qlen so_error so_rcv.sb_cc so_head", - so->so_qlen, so->so_error, so->so_rcv.sb_cc, so->so_head); - ENDTRACE - - tp_ctimeout(p, TM_sendack, (int)p->tp_keepalive_ticks); - tp_ctimeout(p, TM_inact, (int)p->tp_inact_ticks); - } - break; -case 0x1e: - { - if( p->tp_state == TP_AKWAIT ) { + so, so->so_state, so->so_rcv.sb_sel, + so->so_rcv.sb_flags); + tptrace(TPPTmisc, + "called sosiconn 2: so_qlen so_error so_rcv.sb_cc so_head", + so->so_qlen, so->so_error, so->so_rcv.sb_cc, + so->so_head); + } +#endif + + tp_ctimeout(p, TM_sendack, (int) p->tp_keepalive_ticks); + tp_ctimeout(p, TM_inact, (int) p->tp_inact_ticks); + break; + case 0x1e: + if (p->tp_state == TP_AKWAIT) { if (p->tp_ucddata) { m_freem(p->tp_ucddata); p->tp_ucddata = 0; } tp_cuntimeout(p, TM_retrans); soisconnected(p->tp_sock); - tp_ctimeout(p, TM_sendack, (int)p->tp_keepalive_ticks); - tp_ctimeout(p, TM_inact, (int)p->tp_inact_ticks); - } - IFTRACE(D_XPD) - tptrace(TPPTmisc, "XPD tpdu accepted Xrcvnxt, e_seq datalen m_len\n", - p->tp_Xrcvnxt,e->ev_union.EV_XPD_TPDU.e_seq, e->ev_union.EV_XPD_TPDU.e_datalen, e->ev_union.EV_XPD_TPDU.e_data->m_len); - ENDTRACE + tp_ctimeout(p, TM_sendack, (int) p->tp_keepalive_ticks); + tp_ctimeout(p, TM_inact, (int) p->tp_inact_ticks); + } +#ifdef TPPT + if (tp_traceflags[D_XPD]) { + tptrace(TPPTmisc, "XPD tpdu accepted Xrcvnxt, + e_seq datalen m_len\n", p->tp_Xrcvnxt, + e->ev_union.EV_XPD_TPDU.e_seq, + e->ev_union.EV_XPD_TPDU.e_datalen, + e->ev_union.EV_XPD_TPDU.e_data->m_len); + } +#endif p->tp_sock->so_state |= SS_RCVATMARK; e->ev_union.EV_XPD_TPDU.e_data->m_flags |= M_EOR; sbinsertoob(&p->tp_Xrcv, e->ev_union.EV_XPD_TPDU.e_data); - IFDEBUG(D_XPD) +#ifdef ARGO_DEBUG + if (argo_debug[D_XPD]) { dump_mbuf(e->ev_union.EV_XPD_TPDU.e_data, "XPD TPDU: tp_Xrcv"); - ENDDEBUG + } +#endif tp_indicate(T_XDATA, p, 0); - sbwakeup( &p->tp_Xrcv ); + sbwakeup(&p->tp_Xrcv); - (void) tp_emit(XAK_TPDU_type, p, p->tp_Xrcvnxt, 0, MNULL); + (void) tp_emit(XAK_TPDU_type, p, p->tp_Xrcvnxt, 0, NULL); SEQ_INC(p, p->tp_Xrcvnxt); - } - break; -case 0x1f: - { - if( p->tp_Xrcv.sb_cc == 0 ) { - /* kludge for select(): */ + break; + case 0x1f: + if (p->tp_Xrcv.sb_cc == 0) { + /* kludge for select(): */ /* p->tp_sock->so_state &= ~SS_OOBAVAIL; */ } - } - break; -case 0x20: - { - IFTRACE(D_XPD) - tptrace(TPPTmisc, "XPD tpdu niw (Xrcvnxt, e_seq) or not cdt (cc)\n", - p->tp_Xrcvnxt, e->ev_union.EV_XPD_TPDU.e_seq, p->tp_Xrcv.sb_cc , 0); - ENDTRACE - if( p->tp_Xrcvnxt != e->ev_union.EV_XPD_TPDU.e_seq ) + break; + case 0x20: +#ifdef TPPT + if (tp_traceflags[D_XPD]) + tptrace(TPPTmisc, + "XPD tpdu niw (Xrcvnxt, e_seq) or not cdt (cc)\n", + p->tp_Xrcvnxt, e->ev_union.EV_XPD_TPDU.e_seq, + p->tp_Xrcv.sb_cc, 0); +#endif + if (p->tp_Xrcvnxt != e->ev_union.EV_XPD_TPDU.e_seq) IncStat(ts_xpd_niw); - if( p->tp_Xrcv.sb_cc ) { + if (p->tp_Xrcv.sb_cc) { /* might as well kick 'em again */ tp_indicate(T_XDATA, p, 0); IncStat(ts_xpd_dup); } m_freem(e->ev_union.EV_XPD_TPDU.e_data); - tp_ctimeout(p, TM_inact, (int)p->tp_inact_ticks); - /* don't send an xack because the xak gives "last one received", not - * "next one i expect" (dumb) + tp_ctimeout(p, TM_inact, (int) p->tp_inact_ticks); + /* + * don't send an xack because the xak gives "last one + * received", not "next one i expect" (dumb) */ - } - break; -case 0x21: - { - struct socket *so = p->tp_sock; - + break; + case 0x21: /* detach from parent socket so it can finish closing */ if (so->so_head) { if (!soqremque(so, 0) && !soqremque(so, 1)) @@ -543,15 +519,10 @@ case 0x21: so->so_head = 0; } tp_soisdisconnecting(p->tp_sock); - tp_netcmd( p, CONN_CLOSE); + tp_netcmd(p, CONN_CLOSE); tp_soisdisconnected(p); - } - break; -case 0x22: - { - struct socket *so = p->tp_sock; - struct mbuf *data = MNULL; - + break; + case 0x22: /* detach from parent socket so it can finish closing */ if (so->so_head) { if (!soqremque(so, 0) && !soqremque(so, 1)) @@ -563,248 +534,242 @@ case 0x22: data = MCPY(p->tp_ucddata, M_NOWAIT); (void) tp_emit(DR_TPDU_type, p, 0, E_TP_NORMAL_DISC, data); p->tp_retrans = p->tp_Nretrans; - tp_ctimeout(p, TM_retrans, (int)p->tp_dr_ticks); + tp_ctimeout(p, TM_retrans, (int) p->tp_dr_ticks); } - } - break; -case 0x23: - { + break; + case 0x23: tp_soisdisconnecting(p->tp_sock); - tp_netcmd( p, CONN_CLOSE); + tp_netcmd(p, CONN_CLOSE); tp_soisdisconnected(p); - } - break; -case 0x24: - { - struct mbuf *data = MCPY(p->tp_ucddata, M_WAIT); + break; + case 0x24: + data = MCPY(p->tp_ucddata, M_WAIT); - if(p->tp_state == TP_OPEN) { - tp_euntimeout(p, TM_data_retrans); /* all */ + if (p->tp_state == TP_OPEN) { + tp_euntimeout(p, TM_data_retrans); /* all */ tp_cuntimeout(p, TM_inact); tp_cuntimeout(p, TM_sendack); p->tp_flags &= ~TPF_DELACK; } if (data) { - IFDEBUG(D_CONN) - printf("T_DISC_req.trans tp_ucddata 0x%x\n", - p->tp_ucddata); +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { + printf("T_DISC_req.trans tp_ucddata 0x%x\n", + p->tp_ucddata); dump_mbuf(data, "ucddata @ T_DISC_req"); - ENDDEBUG + } +#endif } tp_soisdisconnecting(p->tp_sock); p->tp_retrans = p->tp_Nretrans; - tp_ctimeout(p, TM_retrans, (int)p->tp_dr_ticks); + tp_ctimeout(p, TM_retrans, (int) p->tp_dr_ticks); - if( trick_hc ) - return tp_emit(DR_TPDU_type, p, 0, e->ev_union.EV_T_DISC_req.e_reason, data); - } - break; -case 0x25: - { - int error; - struct mbuf *data = MCPY(p->tp_ucddata, M_WAIT); + if (trick_hc) + return tp_emit(DR_TPDU_type, p, 0, + e->ev_union.EV_REQ_TPDU.e_reason, + data); + break; + case 0x25: + data = MCPY(p->tp_ucddata, M_WAIT); IncStat(ts_retrans_cc); - p->tp_retrans --; + p->tp_retrans--; p->tp_cong_win = 1 * p->tp_l_tpdusize; - if( error = tp_emit(CC_TPDU_type, p, 0, 0, data) ) + if ((error = tp_emit(CC_TPDU_type, p, 0, 0, data)) != 0) p->tp_sock->so_error = error; - tp_ctimeout(p, TM_retrans, (int)p->tp_cc_ticks); - } - break; -case 0x26: - { + tp_ctimeout(p, TM_retrans, (int) p->tp_cc_ticks); + break; + case 0x26: IncStat(ts_conn_gaveup); tp_soisdisconnecting(p->tp_sock); p->tp_sock->so_error = ETIMEDOUT; tp_indicate(T_DISCONNECT, p, ETIMEDOUT); - (void) tp_emit(DR_TPDU_type, p, 0, E_TP_CONGEST, MNULL); + (void) tp_emit(DR_TPDU_type, p, 0, E_TP_CONGEST, NULL); p->tp_retrans = p->tp_Nretrans; - tp_ctimeout(p, TM_retrans, (int)p->tp_dr_ticks); - } - break; -case 0x27: - { - tp_euntimeout(p, TM_data_retrans); /* all */ - tp_cuntimeout(p, TM_inact); + tp_ctimeout(p, TM_retrans, (int) p->tp_dr_ticks); + break; + case 0x27: + tp_euntimeout(p, TM_data_retrans); /* all */ + tp_cuntimeout(p, TM_inact); tp_cuntimeout(p, TM_sendack); IncStat(ts_conn_gaveup); tp_soisdisconnecting(p->tp_sock); p->tp_sock->so_error = ETIMEDOUT; tp_indicate(T_DISCONNECT, p, ETIMEDOUT); - (void) tp_emit(DR_TPDU_type, p, 0, E_TP_CONGEST_2, MNULL); + (void) tp_emit(DR_TPDU_type, p, 0, E_TP_CONGEST_2, NULL); p->tp_retrans = p->tp_Nretrans; - tp_ctimeout(p, TM_retrans, (int)p->tp_dr_ticks); - } - break; -case 0x28: - { + tp_ctimeout(p, TM_retrans, (int) p->tp_dr_ticks); + break; + case 0x28: p->tp_cong_win = 1 * p->tp_l_tpdusize; /* resume XPD */ - if ( p->tp_Xsnd.sb_mb ) { - struct mbuf *m = m_copy(p->tp_Xsnd.sb_mb, 0, (int)p->tp_Xsnd.sb_cc); - int shift; - - IFTRACE(D_XPD) - tptrace(TPPTmisc, "XPD retrans: Xuna Xsndnxt sndnxt snduna", - p->tp_Xuna, p->tp_Xsndnxt, p->tp_sndnxt, - p->tp_snduna); - ENDTRACE - IFDEBUG(D_XPD) + if (p->tp_Xsnd.sb_mb) { + struct mbuf *m = m_copy(p->tp_Xsnd.sb_mb, 0, + (int) p->tp_Xsnd.sb_cc); + int shift; + +#ifdef TPPT + if (tp_traceflags[D_XPD]) { + tptrace(TPPTmisc, + "XPD retrans: Xuna Xsndnxt sndnxt snduna", + p->tp_Xuna, p->tp_Xsndnxt, p->tp_sndnxt, + p->tp_snduna); + } +#endif +#ifdef ARGO_DEBUG + if (argo_debug[D_XPD]) { dump_mbuf(m, "XPD retrans emitting M"); - ENDDEBUG + } +#endif IncStat(ts_retrans_xpd); - p->tp_retrans --; + p->tp_retrans--; shift = max(p->tp_Nretrans - p->tp_retrans, 6); (void) tp_emit(XPD_TPDU_type, p, p->tp_Xuna, 1, m); - tp_ctimeout(p, TM_retrans, ((int)p->tp_dt_ticks) << shift); + tp_ctimeout(p, TM_retrans, ((int) p->tp_dt_ticks) << shift); } - } - break; -case 0x29: - { + break; + case 0x29: p->tp_rxtshift++; (void) tp_data_retrans(p); - } - break; -case 0x2a: - { - p->tp_retrans --; - (void) tp_emit(DR_TPDU_type, p, 0, E_TP_DR_NO_REAS, MNULL); + break; + case 0x2a: + p->tp_retrans--; + (void) tp_emit(DR_TPDU_type, p, 0, E_TP_DR_NO_REAS, NULL); IncStat(ts_retrans_dr); - tp_ctimeout(p, TM_retrans, (int)p->tp_dr_ticks); - } - break; -case 0x2b: - { + tp_ctimeout(p, TM_retrans, (int) p->tp_dr_ticks); + break; + case 0x2b: p->tp_sock->so_error = ETIMEDOUT; p->tp_refstate = REF_FROZEN; - tp_recycle_tsuffix( p ); - tp_etimeout(p, TM_reference, (int)p->tp_refer_ticks); - } - break; -case 0x2c: - { + tp_recycle_tsuffix(p); + tp_etimeout(p, TM_reference, (int) p->tp_refer_ticks); + break; + case 0x2c: tp_freeref(p->tp_lref); tp_detach(p); - } - break; -case 0x2d: - { - if( p->tp_class != TP_CLASS_0) { - tp_ctimeout(p, TM_inact, (int)p->tp_inact_ticks); - if ( e->ev_number == CC_TPDU ) - (void) tp_emit(AK_TPDU_type, p, p->tp_rcvnxt, 0, MNULL); - } - /* ignore it if class 0 - state tables are blank for this */ - } - break; -case 0x2e: - { - IFTRACE(D_DATA) - tptrace(TPPTmisc, "T_DATA_req sndnxt snduna fcredit, tpcb", + break; + case 0x2d: + if (p->tp_class != TP_CLASS_0) { + tp_ctimeout(p, TM_inact, (int) p->tp_inact_ticks); + if (e->ev_number == CC_TPDU) + (void) tp_emit(AK_TPDU_type, p, p->tp_rcvnxt, 0, NULL); + } + /* + * ignore it if class 0 - state tables are blank for + * this + */ + break; + case 0x2e: +#ifdef TPPT + if (tp_traceflags[D_DATA]) + tptrace(TPPTmisc, + "T_DATA_req sndnxt snduna fcredit, tpcb", p->tp_sndnxt, p->tp_snduna, p->tp_fcredit, p); - ENDTRACE +#endif tp_send(p); - } - break; -case 0x2f: - { - int error = 0; + break; + case 0x2f: + error = 0; /* resume XPD */ - if ( p->tp_Xsnd.sb_mb ) { - struct mbuf *m = m_copy(p->tp_Xsnd.sb_mb, 0, (int)p->tp_Xsnd.sb_cc); - /* m_copy doesn't preserve the m_xlink field, but at this pt. - * that doesn't matter + if (p->tp_Xsnd.sb_mb) { + struct mbuf *m = m_copy(p->tp_Xsnd.sb_mb, 0, (int) p->tp_Xsnd.sb_cc); + /* + * m_copy doesn't preserve the m_xlink field, + * but at this pt. that doesn't matter */ - IFTRACE(D_XPD) - tptrace(TPPTmisc, "XPD req: Xuna Xsndnxt sndnxt snduna", - p->tp_Xuna, p->tp_Xsndnxt, p->tp_sndnxt, - p->tp_snduna); - ENDTRACE - IFDEBUG(D_XPD) +#ifdef TPPT + if (tp_traceflags[D_XPD]) + tptrace(TPPTmisc, + "XPD req: Xuna Xsndnxt sndnxt snduna", + p->tp_Xuna, p->tp_Xsndnxt, p->tp_sndnxt, + p->tp_snduna); +#endif +#ifdef ARGO_DEBUG + if (argo_debug[D_XPD]) { printf("T_XPD_req: sb_cc 0x%x\n", p->tp_Xsnd.sb_cc); dump_mbuf(m, "XPD req emitting M"); - ENDDEBUG - error = + } +#endif + error = tp_emit(XPD_TPDU_type, p, p->tp_Xuna, 1, m); p->tp_retrans = p->tp_Nretrans; - tp_ctimeout(p, TM_retrans, (int)p->tp_rxtcur); + tp_ctimeout(p, TM_retrans, (int) p->tp_rxtcur); SEQ_INC(p, p->tp_Xsndnxt); - } - if(trick_hc) + } + if (trick_hc) return error; - } - break; -case 0x30: - { - struct sockbuf *sb = &p->tp_sock->so_snd; + break; + case 0x30: + sb = &p->tp_sock->so_snd; - IFDEBUG(D_ACKRECV) +#ifdef ARGO_DEBUG + if (argo_debug[D_ACKRECV]) { printf("GOOD ACK seq 0x%x cdt 0x%x\n", e->ev_union.EV_AK_TPDU.e_seq, e->ev_union.EV_AK_TPDU.e_cdt); - ENDDEBUG - if( p->tp_class != TP_CLASS_0) { - tp_ctimeout(p, TM_inact, (int)p->tp_inact_ticks); + } +#endif + if (p->tp_class != TP_CLASS_0) { + tp_ctimeout(p, TM_inact, (int) p->tp_inact_ticks); } sbwakeup(sb); - IFDEBUG(D_ACKRECV) +#ifdef ARGO_DEBUG + if (argo_debug[D_ACKRECV]) { printf("GOOD ACK new sndnxt 0x%x\n", p->tp_sndnxt); - ENDDEBUG - } - break; -case 0x31: - { - IFTRACE(D_ACKRECV) - tptrace(TPPTmisc, "BOGUS ACK fcc_present, tp_r_subseq e_subseq", - e->ev_union.EV_AK_TPDU.e_fcc_present, p->tp_r_subseq, e->ev_union.EV_AK_TPDU.e_subseq, 0); - ENDTRACE - if( p->tp_class != TP_CLASS_0 ) { - - if ( !e->ev_union.EV_AK_TPDU.e_fcc_present ) { + } +#endif + break; + case 0x31: +#ifdef TPPT + if (tp_traceflags[D_ACKRECV]) + tptrace(TPPTmisc, "BOGUS ACK fcc_present, + tp_r_subseq e_subseq", + e->ev_union.EV_AK_TPDU.e_fcc_present, + p->tp_r_subseq, + e->ev_union.EV_AK_TPDU.e_subseq, 0); +#endif + if (p->tp_class != TP_CLASS_0) { + + if (!e->ev_union.EV_AK_TPDU.e_fcc_present) { /* send ACK with FCC */ - IncStat( ts_ackreason[_ACK_FCC_] ); - (void) tp_emit(AK_TPDU_type, p, p->tp_rcvnxt, 1, MNULL); + IncStat(ts_ackreason[_ACK_FCC_]); + (void) tp_emit(AK_TPDU_type, p, p->tp_rcvnxt, + 1, NULL); } - tp_ctimeout(p, TM_inact, (int)p->tp_inact_ticks); - } - } - break; -case 0x32: - { - tp_ctimeout(p, TM_inact, (int)p->tp_inact_ticks); + tp_ctimeout(p, TM_inact, (int) p->tp_inact_ticks); + } + break; + case 0x32: + tp_ctimeout(p, TM_inact, (int) p->tp_inact_ticks); tp_cuntimeout(p, TM_retrans); - sbwakeup( &p->tp_sock->so_snd ); + sbwakeup(&p->tp_sock->so_snd); /* resume normal data */ tp_send(p); - } - break; -case 0x33: - { - IFTRACE(D_ACKRECV) - tptrace(TPPTmisc, "BOGUS XACK eventtype ", e->ev_number, 0, 0,0); - ENDTRACE - if( p->tp_class != TP_CLASS_0 ) { - tp_ctimeout(p, TM_inact, (int)p->tp_inact_ticks); - } - } - break; -case 0x34: - { - int timo; - IFTRACE(D_TIMER) - tptrace(TPPTsendack, -1, p->tp_lcredit, p->tp_sent_uwe, - p->tp_sent_lcdt, 0); - ENDTRACE + break; + case 0x33: +#ifdef TPPT + if (tp_traceflags[D_ACKRECV]) + tptrace(TPPTmisc, "BOGUS XACK eventtype ", + e->ev_number, 0, 0, 0); +#endif + if (p->tp_class != TP_CLASS_0) { + tp_ctimeout(p, TM_inact, (int) p->tp_inact_ticks); + } + break; + case 0x34: +#ifdef TPPT + if (tp_traceflags[D_TIMER]) + tptrace(TPPTsendack, -1, p->tp_lcredit, p->tp_sent_uwe, + p->tp_sent_lcdt, 0); +#endif IncPStat(p, tps_n_TMsendack); - (void) tp_emit(AK_TPDU_type, p, p->tp_rcvnxt, 0, MNULL); + (void) tp_emit(AK_TPDU_type, p, p->tp_rcvnxt, 0, NULL); if (p->tp_fcredit == 0) { if (p->tp_rxtshift < TP_MAXRXTSHIFT) p->tp_rxtshift++; @@ -812,18 +777,14 @@ case 0x34: } else timo = p->tp_sendack_ticks; tp_ctimeout(p, TM_sendack, timo); - } - break; -case 0x35: - { + break; + case 0x35: if (sbspace(&p->tp_sock->so_rcv) > 0) tp0_openflow(p); - } - break; -case 0x36: - { - if( trick_hc ) { - SeqNum ack_thresh; + break; + case 0x36: + if (trick_hc) { + SeqNum ack_thresh; /* * If the upper window edge has advanced a reasonable * amount beyond what was known, send an ACK. @@ -833,165 +794,217 @@ case 0x36: */ LOCAL_CREDIT(p); ack_thresh = SEQ_SUB(p, p->tp_lcredit + p->tp_rcvnxt, - (p->tp_maxlcredit > 2 ? 2 : 1)); + (p->tp_maxlcredit > 2 ? 2 : 1)); if (SEQ_GT(p, ack_thresh, p->tp_sent_uwe)) { IncStat(ts_ackreason[_ACK_USRRCV_]); p->tp_flags &= ~TPF_DELACK; - return tp_emit(AK_TPDU_type, p, p->tp_rcvnxt, 0, MNULL); + return tp_emit(AK_TPDU_type, p, p->tp_rcvnxt, 0, NULL); } } - } - break; -case 0x37: - { - if(trick_hc) - return ECONNABORTED; - } - break; -case 0x38: - { - ASSERT( p->tp_state != TP_LISTENING ); + break; + case 0x37: + if (trick_hc) + return ECONNABORTED; + break; + case 0x38: + ASSERT(p->tp_state != TP_LISTENING); tp_indicate(T_DISCONNECT, p, ECONNRESET); tp_soisdisconnected(p); + break; } - break; - } -return 0; + return 0; } -_XEBEC_PG int -_Xebec_index( e,p ) +static int +_Xebec_index(e, p) struct tp_event *e; - tp_PCB_ *p; + struct tp_pcb *p; { -switch( (e->ev_number<<4)+(p->tp_state) ) { -case 0x12: - if ( p->tp_retrans > 0 ) return 0x1e; - else return 0x1f; -case 0x13: - if ( p->tp_retrans > 0 ) return 0x2f; - else return 0x30; -case 0x14: - if ( p->tp_retrans > 0 ) return 0x32; - else return 0x31; -case 0x15: - if ( p->tp_retrans > 0 ) return 0x34; - else return 0x35; -case 0x54: - if (p->tp_rxtshift < TP_NRETRANS) return 0x33; - else return 0x31; -case 0x64: - if (p->tp_class == TP_CLASS_0) return 0x1a; - else return 0x1b; -case 0x77: - if ( p->tp_class == TP_CLASS_0) return 0xd; - else return 0xe; -case 0x86: - if ( e->ev_union.EV_DR_TPDU.e_sref != 0 ) return 0x2; - else return 0x3; -case 0xa2: - if (p->tp_class == TP_CLASS_0) return 0x1c; - else return 0x1d; -case 0xb2: - if (p->tp_class == TP_CLASS_0) return 0x5; - else return 0x0; -case 0xb4: - if ( tp_goodack(p, e->ev_union.EV_AK_TPDU.e_cdt, e->ev_union.EV_AK_TPDU.e_seq, e->ev_union.EV_AK_TPDU.e_subseq) ) return 0x3a; - else return 0x3b; -case 0xc3: - if ( IN_RWINDOW( p, e->ev_union.EV_DT_TPDU.e_seq, - p->tp_rcvnxt, SEQ(p, p->tp_rcvnxt + p->tp_lcredit)) ) return 0x21; - else return 0x24; -case 0xc4: - if ( p->tp_class == TP_CLASS_0 ) return 0x22; - else if ( IN_RWINDOW( p, e->ev_union.EV_DT_TPDU.e_seq, - p->tp_rcvnxt, SEQ(p, p->tp_rcvnxt + p->tp_lcredit)) ) return 0x23; - else return 0x25; -case 0xd3: - if (p->tp_Xrcvnxt == e->ev_union.EV_XPD_TPDU.e_seq) return 0x27; - else return 0x2a; -case 0xd4: - if (p->tp_Xrcvnxt == e->ev_union.EV_XPD_TPDU.e_seq) return 0x27; - else return 0x29; -case 0xe4: - if ( tp_goodXack(p, e->ev_union.EV_XAK_TPDU.e_seq) ) return 0x3c; - else return 0x3d; -case 0x102: - if ( p->tp_class == TP_CLASS_0 ) return 0x2d; - else return 0x2e; -case 0x104: - if ( p->tp_class == TP_CLASS_0 ) return 0x2d; - else return 0x2e; -case 0x144: - if (p->tp_class == TP_CLASS_0) return 0x3f; - else return 0x40; -case 0x162: - if (p->tp_class == TP_CLASS_0) return 0x2b; - else return 0x2c; -case 0x172: - if ( p->tp_class != TP_CLASS_4 ) return 0x42; - else return 0x46; -case 0x174: - if ( p->tp_class != TP_CLASS_4 ) return 0x42; - else return 0x47; -case 0x177: - if ( p->tp_class != TP_CLASS_4 ) return 0x42; - else return 0x43; -case 0x188: - if ( p->tp_class == TP_CLASS_0 ) return 0xf; - else if (tp_emit(CC_TPDU_type, p, 0,0, MCPY(p->tp_ucddata, M_NOWAIT)) == 0) return 0x10; - else return 0x11; -default: return 0; -} /* end switch */ -} /* _Xebec_index() */ -static int inx[26][9] = { {0,0,0,0,0,0,0,0,0,}, - {0x0,0x0,0x0,0x0,0x31,0x0,0x0,0x0,0x0, }, - {0x0,0x0,-1,-1,-1,-1,0x0,0x0,0x0, }, - {0x0,0x0,0x0,0x0,0x3e,0x0,0x0,0x0,0x0, }, - {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, }, - {0x0,0x0,0x0,0x0,0x0,0x0,0x36,0x0,0x0, }, - {0x0,0x0,0x0,0x0,-1,0x0,0x0,0x0,0x0, }, - {0x0,0x7,0x15,0x1b,-1,0x17,0x3,0xa,0x0, }, - {0x0,0x19,0x6,0x20,0x37,0x8,0x3,-1,0x0, }, - {0x0,0x14,0x13,0x13,0x13,0x16,-1,0xa,0x0, }, - {0x0,0x7,0x6,0x1,0x9,0x18,0x3,0xa,0x0, }, - {0x0,0x19,-1,0x1,0x37,0x8,0x3,0xa,0x0, }, - {0x0,0x7,-1,0x26,-1,0x8,0x3,0xa,0x0, }, - {0x0,0x7,0x6,-1,-1,0x8,0x3,0xa,0x0, }, - {0x0,0x7,0x6,-1,-1,0x8,0x3,0xa,0x0, }, - {0x0,0x7,0x6,0x1,-1,0x8,0x3,0xa,0x0, }, - {0x0,0x12,0x0,0x0,0x0,0x0,0x0,0x0,0x0, }, - {0x0,0x0,-1,0x2e,-1,0x0,0x4,0x0,0x2e, }, - {0x0,0xb,0x0,0x0,0x0,0x0,0x0,0x0,0x0, }, - {0x0,0x0,0x0,0x0,0x38,0x0,0x0,0x0,0x0, }, - {0x0,0x0,0x0,0x0,0x39,0x0,0x0,0x0,0x0, }, - {0x0,0x0,0x0,0x0,-1,0x0,0x41,0x0,0x0, }, - {0x0,0x0,0x0,0x0,0x28,0x0,0x41,0x0,0x0, }, - {0x0,0xc,-1,0x2c,0x0,0x2c,0x4,0xc,0x2c, }, - {0x0,0x49,-1,0x45,-1,0x44,0x48,-1,0x0, }, - {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,-1, }, + switch ((e->ev_number << 4) + (p->tp_state)) { + case 0x12: + if (p->tp_retrans > 0) + return 0x1e; + else + return 0x1f; + case 0x13: + if (p->tp_retrans > 0) + return 0x2f; + else + return 0x30; + case 0x14: + if (p->tp_retrans > 0) + return 0x32; + else + return 0x31; + case 0x15: + if (p->tp_retrans > 0) + return 0x34; + else + return 0x35; + case 0x54: + if (p->tp_rxtshift < TP_NRETRANS) + return 0x33; + else + return 0x31; + case 0x64: + if (p->tp_class == TP_CLASS_0) + return 0x1a; + else + return 0x1b; + case 0x77: + if (p->tp_class == TP_CLASS_0) + return 0xd; + else + return 0xe; + case 0x86: + if (e->ev_union.EV_DR_TPDU.e_sref != 0) + return 0x2; + else + return 0x3; + case 0xa2: + if (p->tp_class == TP_CLASS_0) + return 0x1c; + else + return 0x1d; + case 0xb2: + if (p->tp_class == TP_CLASS_0) + return 0x5; + else + return 0x0; + case 0xb4: + if (tp_goodack(p, e->ev_union.EV_AK_TPDU.e_cdt, e->ev_union.EV_AK_TPDU.e_seq, e->ev_union.EV_AK_TPDU.e_subseq)) + return 0x3a; + else + return 0x3b; + case 0xc3: + if (IN_RWINDOW(p, e->ev_union.EV_DT_TPDU.e_seq, + p->tp_rcvnxt, SEQ(p, p->tp_rcvnxt + p->tp_lcredit))) + return 0x21; + else + return 0x24; + case 0xc4: + if (p->tp_class == TP_CLASS_0) + return 0x22; + else if (IN_RWINDOW(p, e->ev_union.EV_DT_TPDU.e_seq, + p->tp_rcvnxt, SEQ(p, p->tp_rcvnxt + p->tp_lcredit))) + return 0x23; + else + return 0x25; + case 0xd3: + if (p->tp_Xrcvnxt == e->ev_union.EV_XPD_TPDU.e_seq) + return 0x27; + else + return 0x2a; + case 0xd4: + if (p->tp_Xrcvnxt == e->ev_union.EV_XPD_TPDU.e_seq) + return 0x27; + else + return 0x29; + case 0xe4: + if (tp_goodXack(p, e->ev_union.EV_XAK_TPDU.e_seq)) + return 0x3c; + else + return 0x3d; + case 0x102: + if (p->tp_class == TP_CLASS_0) + return 0x2d; + else + return 0x2e; + case 0x104: + if (p->tp_class == TP_CLASS_0) + return 0x2d; + else + return 0x2e; + case 0x144: + if (p->tp_class == TP_CLASS_0) + return 0x3f; + else + return 0x40; + case 0x162: + if (p->tp_class == TP_CLASS_0) + return 0x2b; + else + return 0x2c; + case 0x172: + if (p->tp_class != TP_CLASS_4) + return 0x42; + else + return 0x46; + case 0x174: + if (p->tp_class != TP_CLASS_4) + return 0x42; + else + return 0x47; + case 0x177: + if (p->tp_class != TP_CLASS_4) + return 0x42; + else + return 0x43; + case 0x188: + if (p->tp_class == TP_CLASS_0) + return 0xf; + else if (tp_emit(CC_TPDU_type, p, 0, 0, MCPY(p->tp_ucddata, M_NOWAIT)) == 0) + return 0x10; + else + return 0x11; + default: + return 0; + } /* end switch */ +} /* _Xebec_index() */ +static int inx[26][9] = +{ + {0, 0, 0, 0, 0, 0, 0, 0, 0,}, + {0x0, 0x0, 0x0, 0x0, 0x31, 0x0, 0x0, 0x0, 0x0,}, + {0x0, 0x0, -1, -1, -1, -1, 0x0, 0x0, 0x0,}, + {0x0, 0x0, 0x0, 0x0, 0x3e, 0x0, 0x0, 0x0, 0x0,}, + {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,}, + {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x36, 0x0, 0x0,}, + {0x0, 0x0, 0x0, 0x0, -1, 0x0, 0x0, 0x0, 0x0,}, + {0x0, 0x7, 0x15, 0x1b, -1, 0x17, 0x3, 0xa, 0x0,}, + {0x0, 0x19, 0x6, 0x20, 0x37, 0x8, 0x3, -1, 0x0,}, + {0x0, 0x14, 0x13, 0x13, 0x13, 0x16, -1, 0xa, 0x0,}, + {0x0, 0x7, 0x6, 0x1, 0x9, 0x18, 0x3, 0xa, 0x0,}, + {0x0, 0x19, -1, 0x1, 0x37, 0x8, 0x3, 0xa, 0x0,}, + {0x0, 0x7, -1, 0x26, -1, 0x8, 0x3, 0xa, 0x0,}, + {0x0, 0x7, 0x6, -1, -1, 0x8, 0x3, 0xa, 0x0,}, + {0x0, 0x7, 0x6, -1, -1, 0x8, 0x3, 0xa, 0x0,}, + {0x0, 0x7, 0x6, 0x1, -1, 0x8, 0x3, 0xa, 0x0,}, + {0x0, 0x12, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,}, + {0x0, 0x0, -1, 0x2e, -1, 0x0, 0x4, 0x0, 0x2e,}, + {0x0, 0xb, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,}, + {0x0, 0x0, 0x0, 0x0, 0x38, 0x0, 0x0, 0x0, 0x0,}, + {0x0, 0x0, 0x0, 0x0, 0x39, 0x0, 0x0, 0x0, 0x0,}, + {0x0, 0x0, 0x0, 0x0, -1, 0x0, 0x41, 0x0, 0x0,}, + {0x0, 0x0, 0x0, 0x0, 0x28, 0x0, 0x41, 0x0, 0x0,}, + {0x0, 0xc, -1, 0x2c, 0x0, 0x2c, 0x4, 0xc, 0x2c,}, + {0x0, 0x49, -1, 0x45, -1, 0x44, 0x48, -1, 0x0,}, + {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, -1,}, }; +int tp_driver(p, e) -register tp_PCB_ *p; -register struct tp_event *e; + register struct tp_pcb *p; + register struct tp_event *e; { - register int index, error=0; + register int index, error = 0; struct act_ent *a; - static struct act_ent erroraction = {0,-1}; + static struct act_ent erroraction = {0, -1}; index = inx[1 + e->ev_number][p->tp_state]; - if(index<0) index=_Xebec_index(e, p); - if (index==0) { + if (index < 0) + index = _Xebec_index(e, p); + if (index == 0) { a = &erroraction; } else a = &statetable[index]; - if(a->a_action) - error = _Xebec_action( a->a_action, e, p ); - IFTRACE(D_DRIVER) - tptrace(DRIVERTRACE, a->a_newstate, p->tp_state, e->ev_number, a->a_action, 0); - ENDTRACE - if(error==0) - p->tp_state = a->a_newstate; + if (a->a_action) + error = _Xebec_action(a->a_action, e, p); +#ifdef TPPT + if (tp_traceflag[D_DRIVER]) + tptrace(DRIVERTRACE, a->a_newstate, p->tp_state, + e->ev_number, a->a_action, 0); +#endif + if (error == 0) + p->tp_state = a->a_newstate; return error; } diff --git a/sys/netiso/tp_emit.c b/sys/netiso/tp_emit.c index e99b1095c1c..12b8f8cc3f1 100644 --- a/sys/netiso/tp_emit.c +++ b/sys/netiso/tp_emit.c @@ -1,4 +1,5 @@ -/* $NetBSD: tp_emit.c,v 1.6 1995/06/13 07:13:37 mycroft Exp $ */ +/* $OpenBSD: tp_emit.c,v 1.2 1996/03/04 10:35:56 mickey Exp $ */ +/* $NetBSD: tp_emit.c,v 1.7 1996/02/13 22:10:54 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -61,19 +62,18 @@ SOFTWARE. /* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ -/* - * This file contains tp_emit() and tp_error_emit(), which - * form TPDUs and hand them to ip. - * They take data in the form of mbuf chain, allocate mbufs as - * necessary for headers, and set the fields as appropriate from +/* + * This file contains tp_emit() and tp_error_emit(), which form TPDUs and + * hand them to ip. They take data in the form of mbuf chain, allocate mbufs + * as necessary for headers, and set the fields as appropriate from * information found in the tpcb and net-level pcb. * - * The worst thing about this code is adding the variable-length - * options on a machine that requires alignment for any memory access - * that isn't of size 1. See the macro ADDOPTION() below. + * The worst thing about this code is adding the variable-length options on a + * machine that requires alignment for any memory access that isn't of size + * 1. See the macro ADDOPTION() below. * - * We don't do any concatenation. (There's a kludge to test the - * basic mechanism of separation under the 'w' tpdebug option, that's all.) + * We don't do any concatenation. (There's a kludge to test the basic mechanism + * of separation under the 'w' tpdebug option, that's all.) */ #include <sys/param.h> @@ -85,6 +85,8 @@ SOFTWARE. #include <sys/errno.h> #include <sys/time.h> +#include <net/if.h> + #include <netiso/iso.h> #include <netiso/iso_pcb.h> #include <netiso/argo_debug.h> @@ -96,9 +98,10 @@ SOFTWARE. #include <netiso/tp_trace.h> #include <netiso/tp_meas.h> #include <netiso/tp_seq.h> +#include <netiso/tp_var.h> #include <netiso/iso_errno.h> +#include <netiso/iso_var.h> -#include <net/if.h> #ifdef TRUE #undef FALSE #undef TRUE @@ -107,14 +110,12 @@ SOFTWARE. #include <netccitt/pk.h> #include <netccitt/pk_var.h> -void iso_gen_csum(); - - -/* Here is a mighty kludge. The token ring misorders packets if you - * fire them at it too fast, and TP sans checksum is "too fast", so - * we have introduced a delay when checksumming isn't used. +/* + * Here is a mighty kludge. The token ring misorders packets if you fire + * them at it too fast, and TP sans checksum is "too fast", so we have + * introduced a delay when checksumming isn't used. */ -char tp_delay = 0x00; /* delay to keep token ring from blowing it */ +char tp_delay = 0x00;/* delay to keep token ring from blowing it */ /* * NAME: tp_emit() @@ -129,19 +130,19 @@ char tp_delay = 0x00; /* delay to keep token ring from blowing it */ * For DR and ER tpdus, the argument (eot) is * the reason for issuing the tpdu rather than an end-of-tsdu indicator. * - * RETURNS: + * RETURNS: * 0 OK - * ENOBUFS - * E* returned from net layer output rtn + * ENOBUFS + * E* returned from net layer output rtn + * + * SIDE EFFECTS: * - * SIDE EFFECTS: + * NOTES: * - * NOTES: - * - * WE ASSUME that the tp header + all options will fit in ONE mbuf. + * WE ASSUME that the tp header + all options will fit in ONE mbuf. * If mbufs are 256 this will most likely be true, but if they are 128 it's - * possible that they won't. - * If you used every option on the CR + max. user data you'd overrun + * possible that they won't. + * If you used every option on the CR + max. user data you'd overrun * 112 but unless you used > 115 bytes for the security * parameter, it would fit in a 256-byte mbuf (240 bytes for the header) * We don't support the security parameter, so this isn't a problem. @@ -160,35 +161,37 @@ char tp_delay = 0x00; /* delay to keep token ring from blowing it */ */ int -tp_emit(dutype, tpcb, seq, eot, data) - int dutype; - struct tp_pcb *tpcb; - SeqNum seq; - u_int eot; - struct mbuf *data; +tp_emit(dutype, tpcb, seq, eot, data) + int dutype; + struct tp_pcb *tpcb; + SeqNum seq; + u_int eot; + struct mbuf *data; { - register struct tpdu *hdr; + register struct tpdu *hdr; register struct mbuf *m; - int csum_offset=0; - int datalen = 0; - int error = 0; - SeqNum olduwe; - int acking_ooo; - - /* NOTE: - * here we treat tpdu_li as if it DID include the li field, up until - * the end, at which time we subtract 1 - * THis is because if we subtract 1 right away, we end up adding - * one every time we add an option. + int csum_offset = 0; + int datalen = 0; + int error = 0; + SeqNum olduwe; + int acking_ooo; + + /* + * NOTE: here we treat tpdu_li as if it DID include the li field, up + * until the end, at which time we subtract 1 THis is because if we + * subtract 1 right away, we end up adding one every time we add an + * option. */ - IFDEBUG(D_EMIT) +#ifdef ARGO_DEBUG + if (argo_debug[D_EMIT]) { printf( - "tp_emit dutype 0x%x, tpcb 0x%x, eot 0x%x, seq 0x%x, data 0x%x", - dutype, tpcb, eot, seq, data); - ENDDEBUG + "tp_emit dutype 0x%x, tpcb 0x%x, eot 0x%x, seq 0x%x, data 0x%x", + dutype, tpcb, eot, seq, data); + } +#endif if (dutype == CR_TPDU || dutype == CC_TPDU) { - m = (struct mbuf *) malloc((u_long)256, M_MBUF, M_DONTWAIT); + m = (struct mbuf *) malloc((u_long) 256, M_MBUF, M_DONTWAIT); if (m) { m->m_type = TPMT_TPHDR; mbstat.m_mtypes[TPMT_TPHDR]++; @@ -198,11 +201,11 @@ tp_emit(dutype, tpcb, seq, eot, data) m->m_flags = M_PKTHDR; } } else { - MGETHDR(m, M_DONTWAIT, TPMT_TPHDR); + MGETHDR(m, M_DONTWAIT, TPMT_TPHDR); } m->m_data += max_hdr; if (m == NULL) { - if(data != (struct mbuf *)0) + if (data != (struct mbuf *) 0) m_freem(data); error = ENOBUFS; goto done; @@ -211,36 +214,36 @@ tp_emit(dutype, tpcb, seq, eot, data) m->m_act = MNULL; hdr = mtod(m, struct tpdu *); - bzero((caddr_t)hdr, sizeof(struct tpdu)); + bzero((caddr_t) hdr, sizeof(struct tpdu)); { - int tp_headersize(); - hdr->tpdu_type = dutype; - hdr->tpdu_li = tp_headersize(dutype, tpcb); + hdr->tpdu_li = tp_headersize(dutype, tpcb); /* * class 0 doesn't use this for DT - * it'll just get overwritten below + * it'll just get overwritten below */ - hdr->tpdu_dref = htons(tpcb->tp_fref); - if( tpcb->tp_use_checksum || - (dutype == CR_TPDU_type && (tpcb->tp_class & TP_CLASS_4) )) { - csum_offset = hdr->tpdu_li + 2; /* DOESN'T include csum */ - ADDOPTION(TPP_checksum, hdr, 2, eot /* dummy arg */); - IFDEBUG(D_CHKSUM) + hdr->tpdu_dref = htons(tpcb->tp_fref); + if (tpcb->tp_use_checksum || + (dutype == CR_TPDU_type && (tpcb->tp_class & TP_CLASS_4))) { + csum_offset = hdr->tpdu_li + 2; /* DOESN'T include csum */ + ADDOPTION(TPP_checksum, hdr, 2, eot /* dummy arg */ ); +#ifdef ARGO_DEBUG + if (argo_debug[D_CHKSUM]) { printf( - "tp_emit: csum_offset 0x%x, hdr->tpdu_li 0x%x\n", - csum_offset, hdr->tpdu_li); - ENDDEBUG - } + "tp_emit: csum_offset 0x%x, hdr->tpdu_li 0x%x\n", + csum_offset, hdr->tpdu_li); + } +#endif + } /* * VARIABLE PARTS... */ - switch( dutype ) { + switch (dutype) { case CR_TPDU_type: hdr->tpdu_CRdref_0 = 0; /* must be zero */ - case CC_TPDU_type: + case CC_TPDU_type: if (!tpcb->tp_cebit_off) { tpcb->tp_win_recv = tp_start_win << 8; LOCAL_CREDIT(tpcb); @@ -248,69 +251,72 @@ tp_emit(dutype, tpcb, seq, eot, data) } else LOCAL_CREDIT(tpcb); -/* Case CC_TPDU_type used to be here */ - { - u_char x; + /* Case CC_TPDU_type used to be here */ + { + u_char x; - hdr->tpdu_CCsref = htons(tpcb->tp_lref); /* same as CRsref */ + hdr->tpdu_CCsref = htons(tpcb->tp_lref); /* same as CRsref */ - if( tpcb->tp_class > TP_CLASS_1 ) { - tpcb->tp_sent_uwe = tpcb->tp_lcredit -1; + if (tpcb->tp_class > TP_CLASS_1) { + tpcb->tp_sent_uwe = tpcb->tp_lcredit - 1; tpcb->tp_sent_rcvnxt = 1; tpcb->tp_sent_lcdt = tpcb->tp_lcredit; hdr->tpdu_cdt = tpcb->tp_lcredit; } else { #ifdef TPCONS if (tpcb->tp_netservice == ISO_CONS) { - struct isopcb *isop = (struct isopcb *)tpcb->tp_npcb; - struct pklcd *lcp = (struct pklcd *)(isop->isop_chan); + struct isopcb *isop = (struct isopcb *) tpcb->tp_npcb; + struct pklcd *lcp = (struct pklcd *) (isop->isop_chan); lcp->lcd_flags &= ~X25_DG_CIRCUIT; } #endif hdr->tpdu_cdt = 0; } hdr->tpdu_CCclass = tp_mask_to_num(tpcb->tp_class); - hdr->tpdu_CCoptions = - (tpcb->tp_xtd_format? TPO_XTD_FMT:0) | - (tpcb->tp_use_efc? TPO_USE_EFC:0); - - IFPERF(tpcb) - u_char perf_meas = tpcb->tp_perf_on; - ADDOPTION(TPP_perf_meas, hdr, sizeof(perf_meas), perf_meas); - ENDPERF + hdr->tpdu_CCoptions = + (tpcb->tp_xtd_format ? TPO_XTD_FMT : 0) | + (tpcb->tp_use_efc ? TPO_USE_EFC : 0); + +#ifdef TP_PERF_MEAS + if (DOPERF(tpcb)) { + u_char perf_meas = tpcb->tp_perf_on; + ADDOPTION(TPP_perf_meas, hdr, + sizeof(perf_meas), perf_meas); + } +#endif - if( dutype == CR_TPDU_type ) { + if (dutype == CR_TPDU_type) { IncStat(ts_CR_sent); - ASSERT( tpcb->tp_lsuffixlen > 0 ); - ASSERT( tpcb->tp_fsuffixlen > 0 ); + ASSERT(tpcb->tp_lsuffixlen > 0); + ASSERT(tpcb->tp_fsuffixlen > 0); ADDOPTION(TPP_calling_sufx, hdr, - tpcb->tp_lsuffixlen, tpcb->tp_lsuffix[0]); + tpcb->tp_lsuffixlen, tpcb->tp_lsuffix[0]); ADDOPTION(TPP_called_sufx, hdr, - tpcb->tp_fsuffixlen, tpcb->tp_fsuffix[0]); + tpcb->tp_fsuffixlen, tpcb->tp_fsuffix[0]); } else { IncStat(ts_CC_sent); } - ADDOPTION(TPP_tpdu_size, hdr, - sizeof(tpcb->tp_tpdusize), tpcb->tp_tpdusize); + ADDOPTION(TPP_tpdu_size, hdr, + sizeof(tpcb->tp_tpdusize), tpcb->tp_tpdusize); if (tpcb->tp_class != TP_CLASS_0) { - short millisec = 500*(tpcb->tp_sendack_ticks); + short millisec = 500 * (tpcb->tp_sendack_ticks); millisec = htons(millisec); ADDOPTION(TPP_acktime, hdr, sizeof(short), millisec); - x = (tpcb->tp_use_nxpd? TPAO_USE_NXPD: 0) - | (tpcb->tp_use_rcc? TPAO_USE_RCC : 0) - | (tpcb->tp_use_checksum?0: TPAO_NO_CSUM) - | (tpcb->tp_xpd_service? TPAO_USE_TXPD: 0); + x = (tpcb->tp_use_nxpd ? TPAO_USE_NXPD : 0) + | (tpcb->tp_use_rcc ? TPAO_USE_RCC : 0) + | (tpcb->tp_use_checksum ? 0 : TPAO_NO_CSUM) + | (tpcb->tp_xpd_service ? TPAO_USE_TXPD : 0); ADDOPTION(TPP_addl_opt, hdr, 1, x); if ((tpcb->tp_l_tpdusize ^ (1 << tpcb->tp_tpdusize)) != 0) { - u_short size_s = tpcb->tp_l_tpdusize >> 7; - u_char size_c = size_s; + u_short size_s = tpcb->tp_l_tpdusize >> 7; + u_char size_c = size_s; ASSERT(tpcb->tp_l_tpdusize < 65536 * 128); if (dutype == CR_TPDU_type) tpcb->tp_ptpdusize = size_s; @@ -322,70 +328,71 @@ tp_emit(dutype, tpcb, seq, eot, data) } } } - - if( (dutype == CR_TPDU_type) && (tpcb->tp_class != TP_CLASS_0)){ + if ((dutype == CR_TPDU_type) && (tpcb->tp_class != TP_CLASS_0)) { - ASSERT( 1 == sizeof(tpcb->tp_vers) ); + ASSERT(1 == sizeof(tpcb->tp_vers)); ADDOPTION(TPP_vers, hdr, 1, tpcb->tp_vers); - /* for each alt protocol class x, - * x = x<<4; - * option = concat(option, x); - * Well, for now we only have TP0 for an - * alternative so... this is easy. + /* + * for each alt protocol class x, x = + * x<<4; option = concat(option, x); + * Well, for now we only have TP0 for + * an alternative so... this is easy. * - * HOWEVER... There should be NO alt protocol - * class over CLNS. Need to see if the route suggests - * CONS, and iff so add alt class. + * HOWEVER... There should be NO alt + * protocol class over CLNS. Need to + * see if the route suggests CONS, + * and iff so add alt class. */ x = 0; ADDOPTION(TPP_alt_class, hdr, 1, x); } - - if( hdr->tpdu_li > MLEN) + if (hdr->tpdu_li > MLEN) panic("tp_emit CR/CC"); } break; case DR_TPDU_type: - if( hdr->tpdu_DRdref == 0 ) { + if (hdr->tpdu_DRdref == 0) { /* don't issue the DR */ goto done; } hdr->tpdu_cdt = 0; hdr->tpdu_DRsref = htons(tpcb->tp_lref); - hdr->tpdu_DRreason = (u_char)eot; /* WHICH BYTE OF THIS??? */ + hdr->tpdu_DRreason = (u_char) eot; /* WHICH BYTE OF THIS??? */ /* forget the add'l information variable part */ IncStat(ts_DR_sent); break; - case DC_TPDU_type: /* not used in class 0 */ - ASSERT( tpcb->tp_class != TP_CLASS_0); - hdr->tpdu_DCsref = htons(tpcb->tp_lref); + case DC_TPDU_type: /* not used in class 0 */ + ASSERT(tpcb->tp_class != TP_CLASS_0); + hdr->tpdu_DCsref = htons(tpcb->tp_lref); hdr->tpdu_cdt = 0; - data = (struct mbuf *)0; + data = (struct mbuf *) 0; IncStat(ts_DC_sent); break; - case XAK_TPDU_type: /* xak not used in class 0 */ - ASSERT( tpcb->tp_class != TP_CLASS_0); /* fall through */ + case XAK_TPDU_type: /* xak not used in class 0 */ + ASSERT(tpcb->tp_class != TP_CLASS_0); /* fall through */ hdr->tpdu_cdt = 0; - IFTRACE(D_XPD) +#ifdef TPPT + if (tp_traceflags[D_XPD]) { tptraceTPCB(TPPTXack, seq, 0, 0, 0, 0); - ENDTRACE - data = (struct mbuf *)0; + } +#endif + data = (struct mbuf *) 0; if (tpcb->tp_xtd_format) { #ifdef BYTE_ORDER - union seq_type seqeotX; + union seq_type seqeotX; seqeotX.s_seq = seq; seqeotX.s_eot = 1; hdr->tpdu_seqeotX = htonl(seqeotX.s_seqeot); #else hdr->tpdu_XAKseqX = seq; -#endif /* BYTE_ORDER */ +#endif /* BYTE_ORDER */ } else { hdr->tpdu_XAKseq = seq; } @@ -393,45 +400,51 @@ tp_emit(dutype, tpcb, seq, eot, data) IncPStat(tpcb, tps_XAK_sent); break; - case XPD_TPDU_type: /* xpd not used in class 0 */ - ASSERT( tpcb->tp_class != TP_CLASS_0); /* fall through */ + case XPD_TPDU_type: /* xpd not used in class 0 */ + ASSERT(tpcb->tp_class != TP_CLASS_0); /* fall through */ hdr->tpdu_cdt = 0; if (tpcb->tp_xtd_format) { #ifdef BYTE_ORDER - union seq_type seqeotX; + union seq_type seqeotX; seqeotX.s_seq = seq; seqeotX.s_eot = 1; hdr->tpdu_seqeotX = htonl(seqeotX.s_seqeot); #else hdr->tpdu_XPDseqX = seq; - hdr->tpdu_XPDeotX = 1; /* always 1 for XPD tpdu */ -#endif /* BYTE_ORDER */ + hdr->tpdu_XPDeotX = 1; /* always 1 for XPD tpdu */ +#endif /* BYTE_ORDER */ } else { hdr->tpdu_XPDseq = seq; - hdr->tpdu_XPDeot = 1; /* always 1 for XPD tpdu */ + hdr->tpdu_XPDeot = 1; /* always 1 for XPD tpdu */ } IncStat(ts_XPD_sent); IncPStat(tpcb, tps_XPD_sent); /* kludge to test the input size checking */ - IFDEBUG(D_SIZE_CHECK) - /*if(data->m_len <= 16 && data->m_off < (MLEN-18) ) { - printf("Sending too much data on XPD: 18 bytes\n"); - data->m_len = 18; - }*/ - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_SIZE_CHECK]) { + /* + * if(data->m_len <= 16 && data->m_off < (MLEN-18) ) + * { printf("Sending too much data on XPD: 18 + * bytes\n"); data->m_len = 18; } + */ + } +#endif break; case DT_TPDU_type: hdr->tpdu_cdt = 0; - IFTRACE(D_DATA) - tptraceTPCB(TPPTmisc, "emit DT: eot seq tpdu_li", eot, seq, - hdr->tpdu_li, 0); - ENDTRACE +#ifdef TPPT + if (tp_traceflags[D_DATA]) { + tptraceTPCB(TPPTmisc, + "emit DT: eot seq tpdu_li", eot, + seq, hdr->tpdu_li, 0); + } +#endif if (tpcb->tp_xtd_format) { #ifdef BYTE_ORDER - union seq_type seqeotX; + union seq_type seqeotX; seqeotX.s_seq = seq; seqeotX.s_eot = eot; @@ -439,164 +452,200 @@ tp_emit(dutype, tpcb, seq, eot, data) #else hdr->tpdu_DTseqX = seq; hdr->tpdu_DTeotX = eot; -#endif /* BYTE_ORDER */ +#endif /* BYTE_ORDER */ } else if (tpcb->tp_class == TP_CLASS_0) { - IFDEBUG(D_EMIT) +#ifdef ARGO_DEBUG + if (argo_debug[D_EMIT]) { printf("DT tpdu: class 0 m 0x%x hdr 0x%x\n", m, hdr); - dump_buf( hdr, hdr->tpdu_li + 1 ); - ENDDEBUG - ((struct tp0du *)hdr)->tp0du_eot = eot; - ((struct tp0du *)hdr)->tp0du_mbz = 0; - IFDEBUG(D_EMIT) + dump_buf(hdr, hdr->tpdu_li + 1); + } +#endif + ((struct tp0du *) hdr)->tp0du_eot = eot; + ((struct tp0du *) hdr)->tp0du_mbz = 0; +#ifdef ARGO_DEBUG + if (argo_debug[D_EMIT]) { printf("DT 2 tpdu: class 0 m 0x%x hdr 0x%x\n", m, hdr); - dump_buf( hdr, hdr->tpdu_li + 1 ); - ENDDEBUG + dump_buf(hdr, hdr->tpdu_li + 1); + } +#endif } else { hdr->tpdu_DTseq = seq; hdr->tpdu_DTeot = eot; } - if(eot) { + if (eot) { IncStat(ts_EOT_sent); } IncStat(ts_DT_sent); IncPStat(tpcb, tps_DT_sent); break; - case AK_TPDU_type:/* ak not used in class 0 */ - ASSERT( tpcb->tp_class != TP_CLASS_0); - data = (struct mbuf *)0; + case AK_TPDU_type: /* ak not used in class 0 */ + ASSERT(tpcb->tp_class != TP_CLASS_0); + data = (struct mbuf *) 0; olduwe = tpcb->tp_sent_uwe; if (seq != tpcb->tp_sent_rcvnxt || tpcb->tp_rsycnt == 0) { - LOCAL_CREDIT( tpcb ); - tpcb->tp_sent_uwe = - SEQ(tpcb,tpcb->tp_rcvnxt + tpcb->tp_lcredit -1); + LOCAL_CREDIT(tpcb); + tpcb->tp_sent_uwe = + SEQ(tpcb, tpcb->tp_rcvnxt + tpcb->tp_lcredit - 1); tpcb->tp_sent_lcdt = tpcb->tp_lcredit; acking_ooo = 0; } else acking_ooo = 1; - IFDEBUG(D_RENEG) - /* occasionally fake a reneging so - you can test subsequencing */ - if( olduwe & 0x1 ) { +#ifdef ARGO_DEBUG + if (argo_debug[D_RENEG]) { + /* + * occasionally fake a reneging so you can test + * subsequencing + */ + if (olduwe & 0x1) { tpcb->tp_reneged = 1; IncStat(ts_ldebug); } - ENDDEBUG - /* Are we about to reneg on credit? - * When might we do so? - * a) when using optimistic credit (which we no longer do). - * b) when drain() gets implemented (not in the plans). - * c) when D_RENEG is on. - * d) when DEC BIT response is implemented. - * (not- when we do this, we'll need to implement flow control - * confirmation) + } +#endif + /* + * Are we about to reneg on credit? When might we do + * so? a) when using optimistic credit (which we no + * longer do). b) when drain() gets implemented (not + * in the plans). c) when D_RENEG is on. d) when DEC + * BIT response is implemented. (not- when we do + * this, we'll need to implement flow control + * confirmation) */ - if( SEQ_LT(tpcb, tpcb->tp_sent_uwe, olduwe) ) { + if (SEQ_LT(tpcb, tpcb->tp_sent_uwe, olduwe)) { tpcb->tp_reneged = 1; IncStat(ts_lcdt_reduced); - IFTRACE(D_CREDIT) - tptraceTPCB(TPPTmisc, - "RENEG: olduwe newuwe lcredit rcvnxt", - olduwe, - tpcb->tp_sent_uwe, tpcb->tp_lcredit, - tpcb->tp_rcvnxt); - ENDTRACE +#ifdef TPPT + if (tp_traceflags[D_CREDIT]) { + tptraceTPCB(TPPTmisc, + "RENEG: olduwe newuwe lcredit rcvnxt", + olduwe, + tpcb->tp_sent_uwe, tpcb->tp_lcredit, + tpcb->tp_rcvnxt); + } +#endif } - IFPERF(tpcb) - /* new lwe is less than old uwe means we're +#ifdef TP_PERF_MEAS + if (DOPERF(tpcb)) { + /* + * new lwe is less than old uwe means we're * acking before we received a whole window full */ - if( SEQ_LT( tpcb, tpcb->tp_rcvnxt, olduwe) ) { - /* tmp1 = number of pkts fewer than the full window */ - register int tmp1 = - (int) SEQ_SUB( tpcb, olduwe, tpcb->tp_rcvnxt); + if (SEQ_LT(tpcb, tpcb->tp_rcvnxt, olduwe)) { + /* + * tmp1 = number of pkts fewer than + * the full window + */ + register int tmp1 = + (int) SEQ_SUB(tpcb, olduwe, + tpcb->tp_rcvnxt); - if(tmp1 > TP_PM_MAX) + if (tmp1 > TP_PM_MAX) tmp1 = TP_PM_MAX; - IncPStat( tpcb, tps_ack_early[tmp1] ); + IncPStat(tpcb, tps_ack_early[tmp1]); - /* tmp1 = amt of new cdt we're advertising */ - tmp1 = SEQ_SUB( tpcb, seq, tpcb->tp_sent_rcvnxt); - if(tmp1 > TP_PM_MAX ) + /* + * tmp1 = amt of new cdt we're + * advertising + */ + tmp1 = SEQ_SUB(tpcb, seq, + tpcb->tp_sent_rcvnxt); + if (tmp1 > TP_PM_MAX) tmp1 = TP_PM_MAX; - IncPStat( tpcb, - tps_cdt_acked [ tmp1 ] - [ ((tpcb->tp_lcredit > TP_PM_MAX)? - TP_PM_MAX:tpcb->tp_lcredit) ] ); + IncPStat(tpcb, + tps_cdt_acked[tmp1] + [((tpcb->tp_lcredit > + TP_PM_MAX) ? + TP_PM_MAX : + tpcb->tp_lcredit)]); } - ENDPERF + } +#endif - IFTRACE(D_ACKSEND) - tptraceTPCB(TPPTack, seq, tpcb->tp_lcredit, tpcb->tp_sent_uwe, - tpcb->tp_r_subseq, 0); - ENDTRACE +#ifdef TPPT + if (tp_traceflags[D_ACKSEND]) { + tptraceTPCB(TPPTack, seq, tpcb->tp_lcredit, + tpcb->tp_sent_uwe, + tpcb->tp_r_subseq, 0); + } +#endif if (tpcb->tp_xtd_format) { #ifdef BYTE_ORDER - union seq_type seqeotX; + union seq_type seqeotX; seqeotX.s_seq = seq; seqeotX.s_eot = 0; hdr->tpdu_seqeotX = htonl(seqeotX.s_seqeot); hdr->tpdu_AKcdtX = htons(tpcb->tp_lcredit); #else - hdr->tpdu_cdt = 0; + hdr->tpdu_cdt = 0; hdr->tpdu_AKseqX = seq; hdr->tpdu_AKcdtX = tpcb->tp_lcredit; -#endif /* BYTE_ORDER */ +#endif /* BYTE_ORDER */ } else { hdr->tpdu_AKseq = seq; hdr->tpdu_AKcdt = tpcb->tp_lcredit; } if ((tpcb->tp_class == TP_CLASS_4) && - (tpcb->tp_reneged || acking_ooo)) { - /* - * Ack subsequence parameter req'd if WE reneged on - * credit offered. (ISO 8073, 12.2.3.8.2, p. 74) + (tpcb->tp_reneged || acking_ooo)) { + /* + * Ack subsequence parameter req'd if WE + * reneged on credit offered. (ISO 8073, + * 12.2.3.8.2, p. 74) */ - IFDEBUG(D_RENEG) +#ifdef ARGO_DEBUG + if (argo_debug[D_RENEG]) { printf("Adding subseq 0x%x\n", tpcb->tp_s_subseq); - ENDDEBUG + } +#endif tpcb->tp_s_subseq++; /* * add tmp subseq and do a htons on it. */ - ADDOPTION(TPP_subseq, hdr, - sizeof(tpcb->tp_s_subseq), tpcb->tp_s_subseq); + ADDOPTION(TPP_subseq, hdr, + sizeof(tpcb->tp_s_subseq), tpcb->tp_s_subseq); } else tpcb->tp_s_subseq = 0; - if ( tpcb->tp_sendfcc || eot ) /* overloaded to mean SEND FCC */ { - /* - * Rules for sending FCC ("should" send when) : - * %a) received an ack from peer with NO NEWS whatsoever, - * and it did not contain an FCC - * b) received an ack from peer that opens its closed window. - * c) received an ack from peer after it reneged on its - * offered credit, AND this ack raises UWE but LWE is same - * and below UWE at time of reneging (reduction) - * Now, ISO 8073 12.2.3.8.3 says - * that a retransmitted AK shall not contain the FCC - * parameter. Now, how the hell you tell the difference - * between a retransmitted ack and an ack that's sent in - * response to a received ack, I don't know, because without - * any local activity, and w/o any received DTs, they - * will contain exactly the same credit/seq# information. - * Anyway, given that the "retransmission of acks" - * procedure (ISO 8073 12.2.3.8.3) is optional, and we - * don't do it (although the peer can't tell that), we - * ignore this last rule. + if (tpcb->tp_sendfcc || eot) { /* overloaded to mean + * SEND FCC */ + /* + * Rules for sending FCC ("should" send when) + * : %a) received an ack from peer with NO + * NEWS whatsoever, and it did not contain an + * FCC b) received an ack from peer that + * opens its closed window. c) received an + * ack from peer after it reneged on its + * offered credit, AND this ack raises UWE + * but LWE is same and below UWE at time of + * reneging (reduction) Now, ISO 8073 + * 12.2.3.8.3 says that a retransmitted AK + * shall not contain the FCC parameter. Now, + * how the hell you tell the difference + * between a retransmitted ack and an ack + * that's sent in response to a received ack, + * I don't know, because without any local + * activity, and w/o any received DTs, they + * will contain exactly the same credit/seq# + * information. Anyway, given that the + * "retransmission of acks" procedure (ISO + * 8073 12.2.3.8.3) is optional, and we don't + * do it (although the peer can't tell that), + * we ignore this last rule. + * + * We send FCC for reasons a) and b) only. To + * add reason c) would require a ridiculous + * amount of state. * - * We send FCC for reasons a) and b) only. - * To add reason c) would require a ridiculous amount of state. - * */ - u_short bogus[4]; /* lwe(32), subseq(16), cdt(16) */ - SeqNum lwe; - u_short subseq, fcredit; + u_short bogus[4]; /* lwe(32), subseq(16), + * cdt(16) */ + SeqNum lwe; + u_short subseq, fcredit; tpcb->tp_sendfcc = 0; @@ -604,142 +653,168 @@ tp_emit(dutype, tpcb, seq, eot, data) subseq = htons(tpcb->tp_r_subseq); fcredit = htons(tpcb->tp_fcredit); - bcopy((caddr_t) &lwe, (caddr_t)&bogus[0], sizeof(SeqNum)); - bcopy((caddr_t) &subseq, (caddr_t)&bogus[2], sizeof(u_short)); - bcopy((caddr_t) &fcredit, (caddr_t)&bogus[3], sizeof(u_short)); + bcopy((caddr_t) & lwe, (caddr_t) & bogus[0], sizeof(SeqNum)); + bcopy((caddr_t) & subseq, (caddr_t) & bogus[2], sizeof(u_short)); + bcopy((caddr_t) & fcredit, (caddr_t) & bogus[3], sizeof(u_short)); - IFTRACE(D_ACKSEND) - tptraceTPCB(TPPTmisc, - "emit w/FCC: snduna r_subseq fcredit", - tpcb->tp_snduna, tpcb->tp_r_subseq, - tpcb->tp_fcredit, 0); - ENDTRACE +#ifdef TPPT + if (tp_traceflags[D_ACKSEND]) { + tptraceTPCB(TPPTmisc, + "emit w/FCC: snduna r_subseq fcredit", + tpcb->tp_snduna, tpcb->tp_r_subseq, + tpcb->tp_fcredit, 0); + } +#endif - IFDEBUG(D_ACKSEND) +#ifdef ARGO_DEBUG + if (argo_debug[D_ACKSEND]) { printf("Calling ADDOPTION 0x%x, 0x%x, 0x%x,0x%x\n", - TPP_flow_cntl_conf, - hdr, sizeof(bogus), bogus[0]); - ENDDEBUG + TPP_flow_cntl_conf, + hdr, sizeof(bogus), bogus[0]); + } +#endif ADDOPTION(TPP_flow_cntl_conf, hdr, sizeof(bogus), bogus[0]); - IFDEBUG(D_ACKSEND) +#ifdef ARGO_DEBUG + if (argo_debug[D_ACKSEND]) { printf("after ADDOPTION hdr 0x%x hdr->tpdu_li 0x%x\n", - hdr, hdr->tpdu_li); + hdr, hdr->tpdu_li); printf( - "after ADDOPTION csum_offset 0x%x, hdr->tpdu_li 0x%x\n", - csum_offset, hdr->tpdu_li); - ENDDEBUG - + "after ADDOPTION csum_offset 0x%x, hdr->tpdu_li 0x%x\n", + csum_offset, hdr->tpdu_li); + } +#endif + } tpcb->tp_reneged = 0; tpcb->tp_sent_rcvnxt = seq; if (tpcb->tp_fcredit == 0) { - int timo = tpcb->tp_keepalive_ticks; + int timo = tpcb->tp_keepalive_ticks; if (tpcb->tp_rxtshift < TP_MAXRXTSHIFT) tpcb->tp_rxtshift++; - timo = min(timo, ((int)tpcb->tp_dt_ticks) << tpcb->tp_rxtshift); + timo = min(timo, ((int) tpcb->tp_dt_ticks) << tpcb->tp_rxtshift); tp_ctimeout(tpcb, TM_sendack, timo); } else tp_ctimeout(tpcb, TM_sendack, tpcb->tp_keepalive_ticks); IncStat(ts_AK_sent); IncPStat(tpcb, tps_AK_sent); - IFDEBUG(D_ACKSEND) +#ifdef ARGO_DEBUG + if (argo_debug[D_ACKSEND]) { printf( - "2 after rADDOPTION csum_offset 0x%x, hdr->tpdu_li 0x%x\n", - csum_offset, hdr->tpdu_li); - ENDDEBUG + "2 after rADDOPTION csum_offset 0x%x, hdr->tpdu_li 0x%x\n", + csum_offset, hdr->tpdu_li); + } +#endif break; case ER_TPDU_type: - hdr->tpdu_ERreason = eot; + hdr->tpdu_ERreason = eot; hdr->tpdu_cdt = 0; /* no user data */ - data = (struct mbuf *)0; + data = (struct mbuf *) 0; IncStat(ts_ER_sent); break; } } - ASSERT( ((int)hdr->tpdu_li > 0) && ((int)hdr->tpdu_li < MLEN) ); + ASSERT(((int) hdr->tpdu_li > 0) && ((int) hdr->tpdu_li < MLEN)); m->m_next = data; - ASSERT( hdr->tpdu_li < MLEN ); /* leave this in */ - ASSERT( hdr->tpdu_li != 0 ); /* leave this in */ + ASSERT(hdr->tpdu_li < MLEN); /* leave this in */ + ASSERT(hdr->tpdu_li != 0); /* leave this in */ - m->m_len = hdr->tpdu_li ; - hdr->tpdu_li --; /* doesn't include the li field */ + m->m_len = hdr->tpdu_li; + hdr->tpdu_li--; /* doesn't include the li field */ - datalen = m_datalen( m ); /* total len */ + datalen = m_datalen(m); /* total len */ - ASSERT( datalen <= tpcb->tp_l_tpdusize ); /* may become a problem - when CLNP is used; leave in here for the time being */ - IFDEBUG(D_ACKSEND) - printf( - "4 after rADDOPTION csum_offset 0x%x, hdr->tpdu_li 0x%x\n", - csum_offset, hdr->tpdu_li); - ENDDEBUG - if( datalen > tpcb->tp_l_tpdusize ) { - printf("data len 0x%x tpcb->tp_l_tpdusize 0x%x\n", - datalen, tpcb->tp_l_tpdusize); + ASSERT(datalen <= tpcb->tp_l_tpdusize); /* may become a problem when + * CLNP is used; leave in + * here for the time being */ +#ifdef ARGO_DEBUG + if (argo_debug[D_ACKSEND]) { + printf( + "4 after rADDOPTION csum_offset 0x%x, hdr->tpdu_li 0x%x\n", + csum_offset, hdr->tpdu_li); } - IFDEBUG(D_EMIT) +#endif + if (datalen > tpcb->tp_l_tpdusize) { + printf("data len 0x%x tpcb->tp_l_tpdusize 0x%x\n", + datalen, tpcb->tp_l_tpdusize); + } +#ifdef ARGO_DEBUG + if (argo_debug[D_EMIT]) { printf( - "tp_emit before gen_csum m_len 0x%x, csum_offset 0x%x, datalen 0x%x\n", - m->m_len, csum_offset, datalen); - ENDDEBUG - if( tpcb->tp_use_checksum || - (dutype == CR_TPDU_type && (tpcb->tp_class & TP_CLASS_4)) ) { + "tp_emit before gen_csum m_len 0x%x, csum_offset 0x%x, datalen 0x%x\n", + m->m_len, csum_offset, datalen); + } +#endif + if (tpcb->tp_use_checksum || + (dutype == CR_TPDU_type && (tpcb->tp_class & TP_CLASS_4))) { iso_gen_csum(m, csum_offset, datalen); } - - IFDEBUG(D_EMIT) - printf("tp_emit before tpxxx_output tpcb 0x%x, dutype 0x%x, datalen 0x%x\n", - tpcb, dutype, datalen); +#ifdef ARGO_DEBUG + if (argo_debug[D_EMIT]) { + printf("tp_emit before tpxxx_output tpcb 0x%x, dutype 0x%x, datalen 0x%x\n", + tpcb, dutype, datalen); dump_buf(mtod(m, caddr_t), datalen); - ENDDEBUG + } +#endif - IFPERF(tpcb) - if( dutype == DT_TPDU_type ) { +#ifdef TP_PERF_MEAS + if (DOPERF(tpcb)) { + if (dutype == DT_TPDU_type) { PStat(tpcb, Nb_to_ll) += (datalen - m->m_len); - tpmeas( tpcb->tp_lref, TPtime_to_ll, (struct timeval *)0, - seq, PStat(tpcb, Nb_to_ll), (datalen - m->m_len)); + tpmeas(tpcb->tp_lref, TPtime_to_ll, NULL, + seq, PStat(tpcb, Nb_to_ll), + (datalen - m->m_len)); } - ENDPERF + } +#endif - IFTRACE(D_EMIT) - tptraceTPCB(TPPTtpduout, dutype, hdr, hdr->tpdu_li+1, datalen, 0); - ENDTRACE - IFDEBUG(D_EMIT) +#ifdef TPPT + if (tp_traceflags[D_EMIT]) { + tptraceTPCB(TPPTtpduout, dutype, hdr, hdr->tpdu_li + 1, datalen, 0); + } +#endif +#ifdef ARGO_DEBUG + if (argo_debug[D_EMIT]) { printf("OUTPUT: tpcb 0x%x, isop 0x%x, so 0x%x\n", - tpcb, tpcb->tp_npcb, tpcb->tp_sock); - ENDDEBUG + tpcb, tpcb->tp_npcb, tpcb->tp_sock); + } +#endif - { extern char tp_delay; + { + extern char tp_delay; - if( tp_delay ) - if( tpcb->tp_use_checksum == 0 ) { - register u_int i = tp_delay; - for (; i!= 0; i--) + if (tp_delay) + if (tpcb->tp_use_checksum == 0) { + register u_int i = tp_delay; + for (; i != 0; i--) (void) iso_check_csum(m, datalen); } } - ASSERT( m->m_len > 0 ); - error = (tpcb->tp_nlproto->nlp_output)(tpcb->tp_npcb, m, datalen, - !tpcb->tp_use_checksum); - IFDEBUG(D_EMIT) + ASSERT(m->m_len > 0); + error = (tpcb->tp_nlproto->nlp_output) (m, datalen, tpcb->tp_npcb, + !tpcb->tp_use_checksum); +#ifdef ARGO_DEBUG + if (argo_debug[D_EMIT]) { printf("OUTPUT: returned 0x%x\n", error); - ENDDEBUG - IFTRACE(D_EMIT) - tptraceTPCB(TPPTmisc, - "tp_emit nlproto->output netservice returns datalen", - tpcb->tp_nlproto->nlp_output, tpcb->tp_netservice, error, datalen); - ENDTRACE + } +#endif +#ifdef TPPT + if (tp_traceflags[D_EMIT]) { + tptraceTPCB(TPPTmisc, + "tp_emit nlproto->output netservice returns datalen", + tpcb->tp_nlproto->nlp_output, tpcb->tp_netservice, error, datalen); + } +#endif done: if (error) { if (dutype == AK_TPDU_type) tp_ctimeout(tpcb, TM_sendack, 1); if (error == E_CO_QFULL) { - tp_quench(tpcb, PRC_QUENCH); + tp_quench((struct inpcb *) tpcb, PRC_QUENCH); return 0; } } @@ -748,57 +823,61 @@ done: /* * NAME: tp_error_emit() * CALLED FROM: tp_input() when a DR or ER is to be issued in - * response to an input error. + * response to an input error. * FUNCTION and ARGUMENTS: - * The error type is the first argument. - * The argument (sref) is the source reference on the bad incoming tpdu, - * and is used for a destination reference on the outgoing packet. - * (faddr) and (laddr) are the foreign and local addresses for this - * connection. - * (erdata) is a ptr to the errant incoming tpdu, and is copied into the - * outgoing ER, if an ER is to be issued. - * (erlen) is the number of octets of the errant tpdu that we should - * try to copy. - * (tpcb) is the pcb that describes the connection for which the bad tpdu - * arrived. + * The error type is the first argument. + * The argument (sref) is the source reference on the bad incoming tpdu, + * and is used for a destination reference on the outgoing packet. + * (faddr) and (laddr) are the foreign and local addresses for this + * connection. + * (erdata) is a ptr to the errant incoming tpdu, and is copied into the + * outgoing ER, if an ER is to be issued. + * (erlen) is the number of octets of the errant tpdu that we should + * try to copy. + * (tpcb) is the pcb that describes the connection for which the bad tpdu + * arrived. * RETURN VALUES: * 0 OK * ENOBUFS * E* from net layer datagram output routine - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ int tp_error_emit(error, sref, faddr, laddr, erdata, erlen, tpcb, cons_channel, - dgout_routine) - int error; - u_long sref; + dgout_routine) + int error; + u_long sref; struct sockaddr_iso *faddr, *laddr; - struct mbuf *erdata; - int erlen; - struct tp_pcb *tpcb; - caddr_t cons_channel; - int (*dgout_routine)(); + struct mbuf *erdata; + int erlen; + struct tp_pcb *tpcb; + caddr_t cons_channel; + int (*dgout_routine) __P((struct mbuf *, ...)); { - int dutype; - int datalen = 0; - register struct tpdu *hdr; - register struct mbuf *m; - int csum_offset; - - IFTRACE(D_ERROR_EMIT) - tptrace(TPPTmisc, "tp_error_emit error sref tpcb erlen", + int dutype; + int datalen = 0; + register struct tpdu *hdr; + register struct mbuf *m; + int csum_offset; + +#ifdef TPPT + if (tp_traceflags[D_ERROR_EMIT]) { + tptrace(TPPTmisc, "tp_error_emit error sref tpcb erlen", error, sref, tpcb, erlen); - ENDTRACE - IFDEBUG(D_ERROR_EMIT) + } +#endif +#ifdef ARGO_DEBUG + if (argo_debug[D_ERROR_EMIT]) { printf( - "tp_error_emit error 0x%x sref 0x%x tpcb 0x%x erlen 0x%x chan 0x%x\n", - error, sref, tpcb, erlen, cons_channel); - ENDDEBUG + "tp_error_emit error 0x%x sref 0x%x tpcb 0x%x erlen 0x%x chan 0x%x\n", + error, sref, tpcb, erlen, cons_channel); + } +#endif - MGET(m, M_DONTWAIT, TPMT_TPHDR); + MGET(m, M_DONTWAIT, TPMT_TPHDR); if (m == NULL) { return ENOBUFS; } @@ -807,10 +886,12 @@ tp_error_emit(error, sref, faddr, laddr, erdata, erlen, tpcb, cons_channel, hdr = mtod(m, struct tpdu *); - IFDEBUG(D_ERROR_EMIT) +#ifdef ARGO_DEBUG + if (argo_debug[D_ERROR_EMIT]) { printf("[error 0x%x] [error&0xff 0x%x] [(char)error 0x%x]\n", - error, error&0xff, (char)error); - ENDDEBUG + error, error & 0xff, (char) error); + } +#endif if (error & TP_ERROR_SNDC) @@ -825,17 +906,19 @@ tp_error_emit(error, sref, faddr, laddr, erdata, erlen, tpcb, cons_channel, hdr->tpdu_type = dutype; hdr->tpdu_cdt = 0; - switch( dutype ) { + switch (dutype) { case DC_TPDU_type: IncStat(ts_DC_sent); hdr->tpdu_li = 6; hdr->tpdu_DCdref = htons(sref); hdr->tpdu_DCsref = tpcb ? htons(tpcb->tp_lref) : 0; - IFDEBUG(D_ERROR_EMIT) +#ifdef ARGO_DEBUG + if (argo_debug[D_ERROR_EMIT]) { printf("DC case:\n"); - dump_buf( hdr, 6); - ENDDEBUG + dump_buf(hdr, 6); + } +#endif /* forget the add'l information variable part */ break; @@ -844,18 +927,20 @@ tp_error_emit(error, sref, faddr, laddr, erdata, erlen, tpcb, cons_channel, hdr->tpdu_li = 7; hdr->tpdu_DRdref = htons(sref); hdr->tpdu_DRsref = 0; - hdr->tpdu_DRreason = (char)error; - IFDEBUG(D_ERROR_EMIT) + hdr->tpdu_DRreason = (char) error; +#ifdef ARGO_DEBUG + if (argo_debug[D_ERROR_EMIT]) { printf("DR case:\n"); - dump_buf( hdr, 7); - ENDDEBUG + dump_buf(hdr, 7); + } +#endif /* forget the add'l information variable part */ break; case ER_TPDU_type: IncStat(ts_ER_sent); - hdr->tpdu_li = 5; - hdr->tpdu_ERreason = (char)error; + hdr->tpdu_li = 5; + hdr->tpdu_ERreason = (char) error; hdr->tpdu_ERdref = htons(sref); break; @@ -864,130 +949,156 @@ tp_error_emit(error, sref, faddr, laddr, erdata, erlen, tpcb, cons_channel, printf("TP PANIC: bad dutype 0x%x\n", dutype); } - if(tpcb) - if( tpcb->tp_use_checksum ) { - ADDOPTION(TPP_checksum, hdr, 2, csum_offset /* dummy argument */); - csum_offset = hdr->tpdu_li - 2; + if (tpcb) + if (tpcb->tp_use_checksum) { + ADDOPTION(TPP_checksum, hdr, 2, csum_offset /* dummy argument */ ); + csum_offset = hdr->tpdu_li - 2; } - - ASSERT( hdr->tpdu_li < MLEN ); + ASSERT(hdr->tpdu_li < MLEN); if (dutype == ER_TPDU_type) { /* copy the errant tpdu into another 'variable part' */ register caddr_t P; - IFTRACE(D_ERROR_EMIT) +#ifdef TPPT + if (tp_traceflags[D_ERROR_EMIT]) { tptrace(TPPTmisc, "error_emit ER len tpduli", erlen, hdr->tpdu_li, - 0,0); - ENDTRACE - IFDEBUG(D_ERROR_EMIT) + 0, 0); + } +#endif +#ifdef ARGO_DEBUG + if (argo_debug[D_ERROR_EMIT]) { printf("error_emit ER len 0x%x tpduli 0x%x\n", erlen, hdr->tpdu_li); - ENDDEBUG + } +#endif /* copy at most as many octets for which you have room */ if (erlen + hdr->tpdu_li + 2 > TP_MAX_HEADER_LEN) erlen = TP_MAX_HEADER_LEN - hdr->tpdu_li - 2; - + /* add the "invalid tpdu" parameter : required in class 0 */ - P = (caddr_t)hdr + (int)(hdr->tpdu_li); - vbptr(P)->tpv_code = TPP_invalid_tpdu; /* parameter code */ + P = (caddr_t) hdr + (int) (hdr->tpdu_li); + vbptr(P)->tpv_code = TPP_invalid_tpdu; /* parameter code */ vbptr(P)->tpv_len = erlen; /* parameter length */ - m->m_len = hdr->tpdu_li + 2; /* 1 for code, 1 for length */ + m->m_len = hdr->tpdu_li + 2; /* 1 for code, 1 for length */ - /* tp_input very likely handed us an mbuf chain w/ nothing in + /* + * tp_input very likely handed us an mbuf chain w/ nothing in * the first mbuf and the data following the empty mbuf */ - if(erdata->m_len == 0) { - erdata = m_free(erdata); /* returns the next mbuf on the chain */ + if (erdata->m_len == 0) { + erdata = m_free(erdata); /* returns the next mbuf + * on the chain */ } /* * copy only up to the bad octet * (or max that will fit in a header */ m->m_next = m_copy(erdata, 0, erlen); - hdr->tpdu_li += erlen + 2; + hdr->tpdu_li += erlen + 2; m_freem(erdata); } else { - IFDEBUG(D_ERROR_EMIT) +#ifdef ARGO_DEBUG + if (argo_debug[D_ERROR_EMIT]) { printf("error_emit DR error tpduli 0x%x\n", error, hdr->tpdu_li); - dump_buf( (char *)hdr, hdr->tpdu_li ); - ENDDEBUG - m->m_len = hdr->tpdu_li ; + dump_buf((char *) hdr, hdr->tpdu_li); + } +#endif + m->m_len = hdr->tpdu_li; m_freem(erdata); } - hdr->tpdu_li --; - IFTRACE(D_ERROR_EMIT) - tptrace(TPPTtpduout, 2, hdr, hdr->tpdu_li+1, 0, 0); - ENDTRACE + hdr->tpdu_li--; +#ifdef TPPT + if (tp_traceflags[D_ERROR_EMIT]) { + tptrace(TPPTtpduout, 2, hdr, hdr->tpdu_li + 1, 0, 0); + } +#endif - datalen = m_datalen( m); + datalen = m_datalen(m); if (tpcb) { - if( tpcb->tp_use_checksum ) { - IFTRACE(D_ERROR_EMIT) - tptrace(TPPTmisc, "before gen csum datalen", datalen,0,0,0); - ENDTRACE - IFDEBUG(D_ERROR_EMIT) - printf("before gen csum datalen 0x%x, csum_offset 0x%x\n", - datalen, csum_offset); - ENDDEBUG + if (tpcb->tp_use_checksum) { +#ifdef TPPT + if (tp_traceflags[D_ERROR_EMIT]) { + tptrace(TPPTmisc, "before gen csum datalen", datalen, 0, 0, 0); + } +#endif +#ifdef ARGO_DEBUG + if (argo_debug[D_ERROR_EMIT]) { + printf("before gen csum datalen 0x%x, csum_offset 0x%x\n", + datalen, csum_offset); + } +#endif iso_gen_csum(m, csum_offset, datalen); } - - IFDEBUG(D_ERROR_EMIT) +#ifdef ARGO_DEBUG + if (argo_debug[D_ERROR_EMIT]) { printf("OUTPUT: tpcb 0x%x, isop 0x%x, so 0x%x\n", - tpcb, tpcb->tp_npcb, tpcb->tp_sock); - ENDDEBUG + tpcb, tpcb->tp_npcb, tpcb->tp_sock); + } +#endif } if (cons_channel) { #ifdef TPCONS - struct pklcd *lcp = (struct pklcd *)cons_channel; - struct isopcb *isop = (struct isopcb *)lcp->lcd_upnext; - - tpcons_dg_output(cons_channel, m, datalen); - /* was if (tpcb == 0) iso_pcbdetach(isop); */ - /* but other side may want to try again over same VC, - so, we'll depend on him closing it, but in case it gets forgotten - we'll mark it for garbage collection */ + struct pklcd *lcp = (struct pklcd *) cons_channel; +#ifdef notdef + struct isopcb *isop = (struct isopcb *) lcp->lcd_upnext; +#endif + tpcons_output_dg(m, datalen, cons_channel); +#ifdef notdef + if (tpcb == 0) iso_pcbdetach(isop); +#endif + /* + * but other side may want to try again over same VC, so, + * we'll depend on him closing it, but in case it gets + * forgotten we'll mark it for garbage collection + */ lcp->lcd_flags |= X25_DG_CIRCUIT; - IFDEBUG(D_ERROR_EMIT) +#ifdef ARGO_DEBUG + if (argo_debug[D_ERROR_EMIT]) { printf("OUTPUT: dutype 0x%x channel 0x%x\n", - dutype, cons_channel); - ENDDEBUG + dutype, cons_channel); + } +#endif #else printf("TP panic! cons channel 0x%x but not cons configured\n", - cons_channel); + cons_channel); #endif + return 0; } else if (tpcb) { - IFDEBUG(D_ERROR_EMIT) +#ifdef ARGO_DEBUG + if (argo_debug[D_ERROR_EMIT]) { printf("tp_error_emit 1 sending DG: Laddr\n"); dump_addr(sisotosa(laddr)); printf("Faddr\n"); dump_addr(sisotosa(faddr)); - ENDDEBUG - return (tpcb->tp_nlproto->nlp_dgoutput)( - &laddr->siso_addr, - &faddr->siso_addr, - m, datalen, - /* no route */ (caddr_t)0, !tpcb->tp_use_checksum); + } +#endif + return (*tpcb->tp_nlproto->nlp_dgoutput) (m, datalen, + &laddr->siso_addr, + &faddr->siso_addr, + /* no route */ (caddr_t) 0, !tpcb->tp_use_checksum); } else if (dgout_routine) { - IFDEBUG(D_ERROR_EMIT) - printf("tp_error_emit sending DG: Laddr\n"); - dump_addr(sisotosa(laddr)); - printf("Faddr\n"); - dump_addr(sisotosa(faddr)); - ENDDEBUG - return (*dgout_routine)( &laddr->siso_addr, &faddr->siso_addr, - m, datalen, /* no route */ - (caddr_t)0, /* nochecksum==false */0); +#ifdef ARGO_DEBUG + if (argo_debug[D_ERROR_EMIT]) { + printf("tp_error_emit sending DG: Laddr\n"); + dump_addr(sisotosa(laddr)); + printf("Faddr\n"); + dump_addr(sisotosa(faddr)); + } +#endif + return (*dgout_routine) (m, datalen, &laddr->siso_addr, &faddr->siso_addr, + (caddr_t) 0, /* nochecksum==false */ 0); } else { - IFDEBUG(D_ERROR_EMIT) - printf("tp_error_emit DROPPING \n", m); - ENDDEBUG - IncStat(ts_send_drop); - m_freem(m); - return 0; +#ifdef ARGO_DEBUG + if (argo_debug[D_ERROR_EMIT]) { + printf("tp_error_emit DROPPING \n", m); + } +#endif + IncStat(ts_send_drop); + m_freem(m); + return 0; } } diff --git a/sys/netiso/tp_events.h b/sys/netiso/tp_events.h index 0ca402882fa..0c3499d5dd7 100644 --- a/sys/netiso/tp_events.h +++ b/sys/netiso/tp_events.h @@ -1,71 +1,90 @@ -/* $NetBSD: tp_events.h,v 1.4 1994/06/29 06:40:08 cgd Exp $ */ +/* $OpenBSD: tp_events.h,v 1.2 1996/03/04 10:35:58 mickey Exp $ */ +/* $NetBSD: tp_events.h,v 1.5 1996/02/13 22:10:58 christos Exp $ */ struct tp_event { - int ev_number; - struct timeval e_time; + int ev_number; + struct timeval e_time; #define TM_inact 0x0 #define TM_retrans 0x1 #define TM_sendack 0x2 #define TM_notused 0x3 - union{ -struct { SeqNum e_low; SeqNum e_high; int e_retrans; } EV_TM_reference; + union { + struct { + SeqNum e_low; + SeqNum e_high; + int e_retrans; + } EV_TM_reference; #define TM_reference 0x4 -struct { SeqNum e_low; SeqNum e_high; int e_retrans; } EV_TM_data_retrans; + struct { + SeqNum e_low; + SeqNum e_high; + int e_retrans; + } EV_TM_data_retrans; #define TM_data_retrans 0x5 -struct { - u_char e_reason; - } EV_ER_TPDU; + struct { + u_char e_reason; + } EV_ER_TPDU; #define ER_TPDU 0x6 -struct { struct mbuf *e_data; /* first field */ - int e_datalen; /* 2nd field */ - u_int e_cdt; - } EV_CR_TPDU; + struct { + struct mbuf *e_data; /* first field */ + int e_datalen; /* 2nd field */ + u_int e_cdt; + } EV_CR_TPDU; #define CR_TPDU 0x7 -struct { struct mbuf *e_data; /* first field */ - int e_datalen; /* 2nd field */ - u_short e_sref; - u_char e_reason; - } EV_DR_TPDU; + struct { + struct mbuf *e_data; /* first field */ + int e_datalen; /* 2nd field */ + u_short e_sref; + u_char e_reason; + } EV_DR_TPDU; #define DR_TPDU 0x8 #define DC_TPDU 0x9 -struct { struct mbuf *e_data; /* first field */ - int e_datalen; /* 2nd field */ - u_short e_sref; - u_int e_cdt; - } EV_CC_TPDU; + struct { + struct mbuf *e_data; /* first field */ + int e_datalen; /* 2nd field */ + u_short e_sref; + u_int e_cdt; + } EV_CC_TPDU; #define CC_TPDU 0xa -struct { u_int e_cdt; - SeqNum e_seq; - SeqNum e_subseq; - u_char e_fcc_present; - } EV_AK_TPDU; + struct { + u_int e_cdt; + SeqNum e_seq; + SeqNum e_subseq; + u_char e_fcc_present; + } EV_AK_TPDU; #define AK_TPDU 0xb -struct { struct mbuf *e_data; /* first field */ - int e_datalen; /* 2nd field */ - u_int e_eot; - SeqNum e_seq; - } EV_DT_TPDU; + struct { + struct mbuf *e_data; /* first field */ + int e_datalen; /* 2nd field */ + u_int e_eot; + SeqNum e_seq; + } EV_DT_TPDU; #define DT_TPDU 0xc -struct { struct mbuf *e_data; /* first field */ - int e_datalen; /* 2nd field */ - SeqNum e_seq; - } EV_XPD_TPDU; + struct { + struct mbuf *e_data; /* first field */ + int e_datalen; /* 2nd field */ + SeqNum e_seq; + } EV_XPD_TPDU; #define XPD_TPDU 0xd -struct { SeqNum e_seq; } EV_XAK_TPDU; + struct { + SeqNum e_seq; + } EV_XAK_TPDU; #define XAK_TPDU 0xe #define T_CONN_req 0xf -struct { u_char e_reason; } EV_T_DISC_req; + struct { + u_char e_reason; + } EV_REQ_TPDU; #define T_DISC_req 0x10 #define T_LISTEN_req 0x11 @@ -76,9 +95,7 @@ struct { u_char e_reason; } EV_T_DISC_req; #define T_DETACH 0x16 #define T_NETRESET 0x17 #define T_ACPT_req 0x18 - }ev_union; -};/* end struct event */ + } ev_union; +}; /* end struct event */ #define tp_NEVENTS 0x19 - -#define ATTR(X)ev_union.EV_/**/X/**/ diff --git a/sys/netiso/tp_inet.c b/sys/netiso/tp_inet.c index 943d2da72e0..60f53d36954 100644 --- a/sys/netiso/tp_inet.c +++ b/sys/netiso/tp_inet.c @@ -1,4 +1,5 @@ -/* $NetBSD: tp_inet.c,v 1.9 1995/08/12 23:59:48 mycroft Exp $ */ +/* $OpenBSD: tp_inet.c,v 1.2 1996/03/04 10:36:00 mickey Exp $ */ +/* $NetBSD: tp_inet.c,v 1.10 1996/02/13 22:11:02 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -61,23 +62,19 @@ SOFTWARE. /* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ -/* - * Here is where you find the inet-dependent code. We've tried - * keep all net-level and (primarily) address-family-dependent stuff - * out of the tp source, and everthing here is reached indirectly - * through a switch table (struct nl_protosw *) tpcb->tp_nlproto - * (see tp_pcb.c). - * The routines here are: - * in_getsufx: gets transport suffix out of an inpcb structure. - * in_putsufx: put transport suffix into an inpcb structure. - * in_putnetaddr: put a whole net addr into an inpcb. - * in_getnetaddr: get a whole net addr from an inpcb. - * in_cmpnetaddr: compare a whole net addr from an isopcb. - * in_recycle_suffix: clear suffix for reuse in inpcb - * tpip_mtu: figure out what size tpdu to use - * tpip_input: take a pkt from ip, strip off its ip header, give to tp - * tpip_output_dg: package a pkt for ip given 2 addresses & some data - * tpip_output: package a pkt for ip given an inpcb & some data +/* + * Here is where you find the inet-dependent code. We've tried keep all + * net-level and (primarily) address-family-dependent stuff out of the tp + * source, and everthing here is reached indirectly through a switch table + * (struct nl_protosw *) tpcb->tp_nlproto (see tp_pcb.c). The routines here + * are: in_getsufx: gets transport suffix out of an inpcb structure. + * in_putsufx: put transport suffix into an inpcb structure. in_putnetaddr: + * put a whole net addr into an inpcb. in_getnetaddr: get a whole net addr + * from an inpcb. in_cmpnetaddr: compare a whole net addr from an isopcb. + * in_recycle_suffix: clear suffix for reuse in inpcb tpip_mtu: figure out + * what size tpdu to use tpip_input: take a pkt from ip, strip off its ip + * header, give to tp tpip_output_dg: package a pkt for ip given 2 addresses + * & some data tpip_output: package a pkt for ip given an inpcb & some data */ #ifdef INET @@ -88,6 +85,7 @@ SOFTWARE. #include <sys/mbuf.h> #include <sys/errno.h> #include <sys/time.h> +#include <sys/systm.h> #include <net/if.h> @@ -99,17 +97,20 @@ SOFTWARE. #include <netiso/tp_trace.h> #include <netiso/tp_stat.h> #include <netiso/tp_tpdu.h> +#include <netiso/tp_var.h> #include <netinet/in_var.h> #ifndef ISO #include <netiso/iso_chksum.c> #endif -/* - * NAME: in_getsufx() +#include <machine/stdarg.h> - * CALLED FROM: pr_usrreq() on PRU_BIND, - * PRU_CONNECT, PRU_ACCEPT, and PRU_PEERADDR +/* + * NAME: in_getsufx() + * + * CALLED FROM: pr_usrreq() on PRU_BIND, + * PRU_CONNECT, PRU_ACCEPT, and PRU_PEERADDR * * FUNCTION, ARGUMENTS, and RETURN VALUE: * Get a transport suffix from an inpcb structure (inp). @@ -118,78 +119,83 @@ SOFTWARE. * RETURNS: internet port / transport suffix * (CAST TO AN INT) * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ -in_getsufx(inp, lenp, data_out, which) - struct inpcb *inp; - u_short *lenp; - caddr_t data_out; - int which; +void +in_getsufx(v, lenp, data_out, which) + void *v; + u_short *lenp; + caddr_t data_out; + int which; { + struct inpcb *inp = v; *lenp = sizeof(u_short); switch (which) { case TP_LOCAL: - *(u_short *)data_out = inp->inp_lport; + *(u_short *) data_out = inp->inp_lport; return; case TP_FOREIGN: - *(u_short *)data_out = inp->inp_fport; + *(u_short *) data_out = inp->inp_fport; } } /* - * NAME: in_putsufx() + * NAME: in_putsufx() * - * CALLED FROM: tp_newsocket(); i.e., when a connection + * CALLED FROM: tp_newsocket(); i.e., when a connection * is being established by an incoming CR_TPDU. * * FUNCTION, ARGUMENTS: * Put a transport suffix (found in name) into an inpcb structure (inp). * The argument (which) takes the value TP_LOCAL or TP_FOREIGN. * - * RETURNS: Nada + * RETURNS: Nada * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ -/*ARGSUSED*/ +/* ARGSUSED */ void -in_putsufx(inp, sufxloc, sufxlen, which) - struct inpcb *inp; - caddr_t sufxloc; - int which; +in_putsufx(v, sufxloc, sufxlen, which) + void *v; + caddr_t sufxloc; + int sufxlen; + int which; { + struct inpcb *inp = v; if (which == TP_FOREIGN) { - bcopy(sufxloc, (caddr_t)&inp->inp_fport, sizeof(inp->inp_fport)); + bcopy(sufxloc, (caddr_t) & inp->inp_fport, sizeof(inp->inp_fport)); } } /* - * NAME: in_recycle_tsuffix() + * NAME: in_recycle_tsuffix() * * CALLED FROM: tp.trans whenever we go into REFWAIT state. * * FUNCTION and ARGUMENT: - * Called when a ref is frozen, to allow the suffix to be reused. - * (inp) is the net level pcb. + * Called when a ref is frozen, to allow the suffix to be reused. + * (inp) is the net level pcb. * * RETURNS: Nada * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: This really shouldn't have to be done in a NET level pcb + * NOTES: This really shouldn't have to be done in a NET level pcb * but... for the internet world that just the way it is done in BSD... * The alternative is to have the port unusable until the reference * timer goes off. */ void -in_recycle_tsuffix(inp) - struct inpcb *inp; +in_recycle_tsuffix(v) + void *v; { + struct inpcb *inp = v; inp->inp_fport = inp->inp_lport = 0; } @@ -207,33 +213,35 @@ in_recycle_tsuffix(inp) * * RETURNS: Nada * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: - */ + * NOTES: + */ void -in_putnetaddr(inp, name, which) - register struct inpcb *inp; - struct sockaddr_in *name; - int which; +in_putnetaddr(v, nm, which) + register void *v; + struct sockaddr *nm; + int which; { + register struct inpcb *inp = v; + struct sockaddr_in *name = (struct sockaddr_in *) nm; switch (which) { case TP_LOCAL: - bcopy((caddr_t)&name->sin_addr, - (caddr_t)&inp->inp_laddr, sizeof(struct in_addr)); - /* won't work if the dst address (name) is INADDR_ANY */ + bcopy((caddr_t) & name->sin_addr, + (caddr_t) & inp->inp_laddr, sizeof(struct in_addr)); + /* won't work if the dst address (name) is INADDR_ANY */ break; case TP_FOREIGN: - if( name != (struct sockaddr_in *)0 ) { - bcopy((caddr_t)&name->sin_addr, - (caddr_t)&inp->inp_faddr, sizeof(struct in_addr)); + if (name != (struct sockaddr_in *) 0) { + bcopy((caddr_t) & name->sin_addr, + (caddr_t) & inp->inp_faddr, sizeof(struct in_addr)); } } } /* - * NAME: in_putnetaddr() + * NAME: in_cmpnetaddr() * * CALLED FROM: * tp_input() when a connection is being established by an @@ -246,15 +254,18 @@ in_putnetaddr(inp, name, which) * * RETURNS: Nada * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: - */ -in_cmpnetaddr(inp, name, which) - register struct inpcb *inp; - register struct sockaddr_in *name; - int which; + * NOTES: + */ +int +in_cmpnetaddr(v, nm, which) + register void *v; + register struct sockaddr *nm; + int which; { + register struct inpcb *inp = v; + struct sockaddr_in *name = (struct sockaddr_in *) nm; if (which == TP_LOCAL) { if (name->sin_port && name->sin_port != inp->inp_lport) return 0; @@ -277,19 +288,20 @@ in_cmpnetaddr(inp, name, which) * * RETURNS: Nada * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: - */ + * NOTES: + */ void -in_getnetaddr( inp, name, which) +in_getnetaddr(v, name, which) + void *v; register struct mbuf *name; - struct inpcb *inp; - int which; + int which; { + struct inpcb *inp = v; register struct sockaddr_in *sin = mtod(name, struct sockaddr_in *); - bzero((caddr_t)sin, sizeof(*sin)); + bzero((caddr_t) sin, sizeof(*sin)); switch (which) { case TP_LOCAL: sin->sin_addr = inp->inp_laddr; @@ -302,7 +314,7 @@ in_getnetaddr( inp, name, which) default: return; } - name->m_len = sin->sin_len = sizeof (*sin); + name->m_len = sin->sin_len = sizeof(*sin); sin->sin_family = AF_INET; } @@ -318,24 +330,27 @@ in_getnetaddr( inp, name, which) * It appears that setting a double pointer to the rtentry associated with * the destination, and returning the header size for the network protocol * suffices. - * + * * SIDE EFFECTS: * Sets tp_routep pointer in pcb. * * NOTES: */ - -tpip_mtu(tpcb) -register struct tp_pcb *tpcb; +int +tpip_mtu(v) + void *v; { - struct inpcb *inp = (struct inpcb *)tpcb->tp_npcb; + register struct tp_pcb *tpcb = v; + struct inpcb *inp = (struct inpcb *) tpcb->tp_npcb; - IFDEBUG(D_CONN) +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("tpip_mtu(tpcb)\n", tpcb); printf("tpip_mtu routing to addr 0x%x\n", inp->inp_faddr.s_addr); - ENDDEBUG + } +#endif tpcb->tp_routep = &(inp->inp_route.ro_rt); - return (sizeof (struct ip)); + return (sizeof(struct ip)); } @@ -350,23 +365,36 @@ register struct tp_pcb *tpcb; * of the fields. * inp is the inpcb structure; datalen is the length of the data in the * mbuf string m0. - * RETURNS: + * RETURNS: * whatever (E*) is returned form the net layer output routine. * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ int -tpip_output(inp, m0, datalen, nochksum) - struct inpcb *inp; - struct mbuf *m0; - int datalen; - int nochksum; +#if __STDC__ +tpip_output(struct mbuf *m0, ...) +#else +tpip_output(m0, va_alist) + struct mbuf *m0; + va_dcl +#endif { - return tpip_output_dg( &inp->inp_laddr, &inp->inp_faddr, m0, datalen, - &inp->inp_route, nochksum); + int datalen; + struct inpcb *inp; + int nochksum; + va_list ap; + + va_start(ap, m0); + datalen = va_arg(ap, int); + inp = va_arg(ap, struct inpcb *); + nochksum = va_arg(ap, int); + va_end(ap); + + return tpip_output_dg(m0, datalen, &inp->inp_laddr, &inp->inp_faddr, + &inp->inp_route, nochksum); } /* @@ -379,30 +407,46 @@ tpip_output(inp, m0, datalen, nochksum) * instead of a pcb. It's used by the tp_error_emit, when we * don't have an in_pcb with which to call the normal output rtn. * - * RETURNS: ENOBUFS or whatever (E*) is + * RETURNS: ENOBUFS or whatever (E*) is * returned form the net layer output routine. * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ -/*ARGSUSED*/ +/* ARGSUSED */ int -tpip_output_dg(laddr, faddr, m0, datalen, ro, nochksum) - struct in_addr *laddr, *faddr; - struct mbuf *m0; - int datalen; - struct route *ro; - int nochksum; +#if __STDC__ +tpip_output_dg(struct mbuf *m0, ...) +#else +tpip_output_dg(m0, va_alist) + struct mbuf *m0; + va_dcl +#endif { - register struct mbuf *m; + int datalen; + struct in_addr *laddr, *faddr; + struct route *ro; + int nochksum; + register struct mbuf *m; register struct ip *ip; - int error; + int error; + va_list ap; - IFDEBUG(D_EMIT) + va_start(ap, m0); + datalen = va_arg(ap, int); + laddr = va_arg(ap, struct in_addr *); + faddr = va_arg(ap, struct in_addr *); + ro = va_arg(ap, struct route *); + nochksum = va_arg(ap, int); + va_end(ap); + +#ifdef ARGO_DEBUG + if (argo_debug[D_EMIT]) { printf("tpip_output_dg datalen 0x%x m0 0x%x\n", datalen, m0); - ENDDEBUG + } +#endif MGETHDR(m, M_DONTWAIT, TPMT_IPHDR); @@ -415,28 +459,33 @@ tpip_output_dg(laddr, faddr, m0, datalen, ro, nochksum) m->m_len = sizeof(struct ip); ip = mtod(m, struct ip *); - bzero((caddr_t)ip, sizeof *ip); + bzero((caddr_t) ip, sizeof *ip); ip->ip_p = IPPROTO_TP; m->m_pkthdr.len = ip->ip_len = sizeof(struct ip) + datalen; - ip->ip_ttl = MAXTTL; - /* don't know why you need to set ttl; - * overlay doesn't even make this available - */ + ip->ip_ttl = MAXTTL; + /* + * don't know why you need to set ttl; overlay doesn't even make this + * available + */ ip->ip_src = *laddr; ip->ip_dst = *faddr; IncStat(ts_tpdu_sent); - IFDEBUG(D_EMIT) +#ifdef ARGO_DEBUG + if (argo_debug[D_EMIT]) { dump_mbuf(m, "tpip_output_dg before ip_output\n"); - ENDDEBUG + } +#endif - error = ip_output(m, (struct mbuf *)0, ro, IP_ALLOWBROADCAST, NULL); + error = ip_output(m, (struct mbuf *) 0, ro, IP_ALLOWBROADCAST, NULL); - IFDEBUG(D_EMIT) +#ifdef ARGO_DEBUG + if (argo_debug[D_EMIT]) { printf("tpip_output_dg after ip_output\n"); - ENDDEBUG + } +#endif return error; @@ -455,20 +504,30 @@ bad: * FUNCTION and ARGUMENTS: * Take a packet (m) from ip, strip off the ip header and give it to tp * - * RETURNS: No return value. - * + * RETURNS: No return value. + * * SIDE EFFECTS: * * NOTES: */ void -tpip_input(m, iplen) - struct mbuf *m; - int iplen; +#if __STDC__ +tpip_input(struct mbuf *m, ...) +#else +tpip_input(m, va_alist) + struct mbuf *m; + va_dcl +#endif { - struct sockaddr_in src, dst; - register struct ip *ip; - int s = splsoftnet(), hdrlen; + int iplen; + struct sockaddr_in src, dst; + register struct ip *ip; + int s = splsoftnet(), hdrlen; + va_list ap; + + va_start(ap, m); + iplen = va_arg(ap, int); + va_end(ap); IncStat(ts_pkt_rcvd); @@ -482,10 +541,10 @@ tpip_input(m, iplen) */ - if((m = m_pullup(m, iplen + 1)) == MNULL) + if ((m = m_pullup(m, iplen + 1)) == MNULL) goto discard; CHANGE_MTYPE(m, TPMT_DATA); - + /* * Now pull up the whole tp header: * Unfortunately, there may be IP options to skip past so we @@ -493,23 +552,27 @@ tpip_input(m, iplen) */ hdrlen = iplen + 1 + mtod(m, u_char *)[iplen]; - if( m->m_len < hdrlen ) { - if((m = m_pullup(m, hdrlen)) == MNULL){ - IFDEBUG(D_TPINPUT) + if (m->m_len < hdrlen) { + if ((m = m_pullup(m, hdrlen)) == MNULL) { +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { printf("tp_input, pullup 2!\n"); - ENDDEBUG + } +#endif goto discard; } } - /* - * cannot use tp_inputprep() here 'cause you don't - * have quite the same situation + /* + * cannot use tp_inputprep() here 'cause you don't have quite the + * same situation */ - IFDEBUG(D_TPINPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { dump_mbuf(m, "after tpip_input both pullups"); - ENDDEBUG - /* + } +#endif + /* * m_pullup may have returned a different mbuf */ ip = mtod(m, struct ip *); @@ -521,24 +584,28 @@ tpip_input(m, iplen) m->m_len -= iplen; m->m_data += iplen; - src.sin_addr = *(struct in_addr *)&(ip->ip_src); - src.sin_family = AF_INET; - src.sin_len = sizeof(src); - dst.sin_addr = *(struct in_addr *)&(ip->ip_dst); - dst.sin_family = AF_INET; - dst.sin_len = sizeof(dst); + src.sin_addr = *(struct in_addr *) & (ip->ip_src); + src.sin_family = AF_INET; + src.sin_len = sizeof(src); + dst.sin_addr = *(struct in_addr *) & (ip->ip_dst); + dst.sin_family = AF_INET; + dst.sin_len = sizeof(dst); tp_input(m, sintosa(&src), sintosa(&dst), 0, tpip_output_dg, 0); return; discard: - IFDEBUG(D_TPINPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { printf("tpip_input DISCARD\n"); - ENDDEBUG - IFTRACE(D_TPINPUT) - tptrace(TPPTmisc, "tpip_input DISCARD m", m,0,0,0); - ENDTRACE - m_freem(m); + } +#endif +#ifdef TPPT + if (tp_traceflags[D_TPINPUT]) { + tptrace(TPPTmisc, "tpip_input DISCARD m", m, 0, 0, 0); + } +#endif + m_freem(m); IncStat(ts_recv_drop); splx(s); } @@ -547,7 +614,6 @@ discard: #include <sys/protosw.h> #include <netinet/ip_icmp.h> -extern void tp_quench(); /* * NAME: tpin_quench() * @@ -557,16 +623,17 @@ extern void tp_quench(); * * RETURNS: Nada * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ void -tpin_quench(inp) - struct inpcb *inp; +tpin_quench(inp, dummy) + struct inpcb *inp; + int dummy; { - tp_quench((struct tp_pcb *)inp->inp_socket->so_pcb, PRC_QUENCH); + tp_quench((struct inpcb *) inp->inp_socket->so_pcb, PRC_QUENCH); } /* @@ -580,48 +647,48 @@ tpin_quench(inp) * It either returns an error status to the user or * causes all connections on this address to be aborted * by calling the appropriate xx_notify() routine. - * (cmd) is the type of ICMP error. + * (cmd) is the type of ICMP error. * (sa) the address of the sender * * RETURNS: Nothing * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ -void -tpip_ctlinput(cmd, sin) - int cmd; - struct sockaddr_in *sin; +void * +tpip_ctlinput(cmd, sa, dummy) + int cmd; + struct sockaddr *sa; + void *dummy; { - extern int inetctlerrmap[]; - void (*notify) __P((struct inpcb *, int)); - void tp_quench __P((struct inpcb *, int)); - void tpin_abort __P((struct inpcb *, int)); - int errno; + struct sockaddr_in *sin = (struct sockaddr_in *) sa; + extern int inetctlerrmap[]; + void (*notify) __P((struct inpcb *, int)); + int errno; if (cmd < 0 || cmd >= PRC_NCMDS) - return; + return NULL; if (sin->sin_family != AF_INET && sin->sin_family != AF_IMPLINK) - return; + return NULL; if (sin->sin_addr.s_addr == INADDR_ANY) - return; + return NULL; errno = inetctlerrmap[cmd]; switch (cmd) { - case PRC_QUENCH: - notify = tp_quench; - break; + case PRC_QUENCH: + notify = tp_quench; + break; - case PRC_ROUTEDEAD: - case PRC_HOSTUNREACH: - case PRC_UNREACH_NET: - case PRC_IFDOWN: - case PRC_HOSTDEAD: - notify = in_rtchange; - break; + case PRC_ROUTEDEAD: + case PRC_HOSTUNREACH: + case PRC_UNREACH_NET: + case PRC_IFDOWN: + case PRC_HOSTDEAD: + notify = in_rtchange; + break; - default: + default: /* case PRC_MSGSIZE: case PRC_UNREACH_HOST: @@ -637,10 +704,11 @@ tpip_ctlinput(cmd, sin) case PRC_TIMXCEED_REASS: case PRC_PARAMPROB: */ - notify = tpin_abort; - break; + notify = tpin_abort; + break; } in_pcbnotifyall(&tp_inpcb, sintosa(sin), errno, notify); + return NULL; } /* @@ -657,28 +725,29 @@ tpip_ctlinput(cmd, sin) * * RETURNS: Nothing * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ void tpin_abort(inp, n) - struct inpcb *inp; - int n; + struct inpcb *inp; + int n; { struct tp_event e; e.ev_number = ER_TPDU; - e.ATTR(ER_TPDU).e_reason = ENETRESET; - tp_driver((struct tp_pcb *)inp->inp_ppcb, &e); + e.TPDU_ATTR(ER).e_reason = ENETRESET; + tp_driver((struct tp_pcb *) inp->inp_ppcb, &e); } #ifdef ARGO_DEBUG +void dump_inaddr(addr) register struct sockaddr_in *addr; { printf("INET: port 0x%x; addr 0x%x\n", addr->sin_port, addr->sin_addr); } -#endif /* ARGO_DEBUG */ -#endif /* INET */ +#endif /* ARGO_DEBUG */ +#endif /* INET */ diff --git a/sys/netiso/tp_input.c b/sys/netiso/tp_input.c index 404803d749a..b1645c57b03 100644 --- a/sys/netiso/tp_input.c +++ b/sys/netiso/tp_input.c @@ -1,4 +1,5 @@ -/* $NetBSD: tp_input.c,v 1.7 1995/06/13 07:13:42 mycroft Exp $ */ +/* $OpenBSD: tp_input.c,v 1.2 1996/03/04 10:36:02 mickey Exp $ */ +/* $NetBSD: tp_input.c,v 1.8 1996/02/13 22:11:08 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -61,26 +62,25 @@ SOFTWARE. /* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ -/* - * tp_input() gets an mbuf chain from ip. Actually, not directly - * from ip, because ip calls a net-level routine that strips off - * the net header and then calls tp_input(), passing the proper type - * of addresses for the address family in use (how it figures out - * which AF is not yet determined.) +/* + * tp_input() gets an mbuf chain from ip. Actually, not directly from ip, + * because ip calls a net-level routine that strips off the net header and + * then calls tp_input(), passing the proper type of addresses for the + * address family in use (how it figures out which AF is not yet determined.) * * Decomposing the tpdu is some of the most laughable code. The variable-length - * parameters and the problem of non-aligned memory references - * necessitates such abominations as the macros WHILE_OPTIONS (q.v. below) - * to loop through the header and decompose it. + * parameters and the problem of non-aligned memory references necessitates + * such abominations as the macros WHILE_OPTIONS (q.v. below) to loop through + * the header and decompose it. * * The routine tp_newsocket() is called when a CR comes in for a listening * socket. tp_input calls sonewconn() and tp_newsocket() to set up the - * "child" socket. Most tpcb values are copied from the parent tpcb into - * the child. - * - * Also in here is tp_headersize() (grot) which tells the expected size - * of a tp header, to be used by other layers. It's in here because it - * uses the static structure tpdu_info. + * "child" socket. Most tpcb values are copied from the parent tpcb into the + * child. + * + * Also in here is tp_headersize() (grot) which tells the expected size of a tp + * header, to be used by other layers. It's in here because it uses the + * static structure tpdu_info. */ #include <sys/param.h> @@ -94,6 +94,8 @@ SOFTWARE. #include <sys/time.h> #include <sys/kernel.h> +#include <net/if.h> + #include <netiso/iso.h> #include <netiso/iso_errno.h> #include <netiso/iso_pcb.h> @@ -104,8 +106,9 @@ SOFTWARE. #include <netiso/argo_debug.h> #include <netiso/tp_trace.h> #include <netiso/tp_tpdu.h> +#include <netiso/tp_var.h> +#include <netiso/iso_var.h> -#include <net/if.h> #ifdef TRUE #undef FALSE #undef TRUE @@ -114,115 +117,116 @@ SOFTWARE. #include <netccitt/pk.h> #include <netccitt/pk_var.h> -int iso_check_csum(), tp_driver(), tp_headersize(), tp_error_emit(); +#include <machine/stdarg.h> -/* - #ifdef lint - #undef ATTR - #define ATTR(X)ev_number - #endif lint -*/ - -struct mbuf * -tp_inputprep(m) +static struct socket *tp_newsocket __P((struct socket *, struct sockaddr *, + caddr_t, u_int, u_int)); + +struct mbuf * +tp_inputprep(m) register struct mbuf *m; { - int hdrlen; - - IFDEBUG(D_TPINPUT) - printf("tp_inputprep: m 0x%x\n", m) ; - ENDDEBUG - - while( m->m_len < 1 ) { - /* The "m_free" logic - * if( (m = m_free(m)) == MNULL ) - * return (struct mbuf *)0; - * would cause a system crash if ever executed. - * This logic will be executed if the first mbuf - * in the chain only contains a CLNP header. The m_free routine - * will release the mbuf containing the CLNP header from the - * chain and the new head of the chain will not have the - * M_PKTHDR bit set. This routine, tp_inputprep, will - * eventually call the "sbappendaddr" routine. "sbappendaddr" - * calls "panic" if M_PKTHDR is not set. m_pullup is a cheap - * way of keeping the head of the chain from being freed. + int hdrlen; + +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { + printf("tp_inputprep: m 0x%x\n", m); + } +#endif + + while (m->m_len < 1) { + /* + * The "m_free" logic if( (m = m_free(m)) == MNULL ) return + * (struct mbuf *)0; would cause a system crash if ever + * executed. This logic will be executed if the first mbuf in + * the chain only contains a CLNP header. The m_free routine + * will release the mbuf containing the CLNP header from the + * chain and the new head of the chain will not have the + * M_PKTHDR bit set. This routine, tp_inputprep, will + * eventually call the "sbappendaddr" routine. "sbappendaddr" + * calls "panic" if M_PKTHDR is not set. m_pullup is a cheap + * way of keeping the head of the chain from being freed. */ - if((m = m_pullup(m, 1)) == MNULL) + if ((m = m_pullup(m, 1)) == MNULL) return (MNULL); } - if(((long)m->m_data) & 0x3) { - /* If we are not 4-byte aligned, we have to be - * above the beginning of the mbuf, and it is ok just - * to slide it back. + if (((long) m->m_data) & 0x3) { + /* + * If we are not 4-byte aligned, we have to be above the + * beginning of the mbuf, and it is ok just to slide it back. */ - caddr_t ocp = m->m_data; + caddr_t ocp = m->m_data; - m->m_data = (caddr_t)(((long)m->m_data) & ~0x3); - bcopy(ocp, m->m_data, (unsigned)m->m_len); + m->m_data = (caddr_t) (((long) m->m_data) & ~0x3); + bcopy(ocp, m->m_data, (unsigned) m->m_len); } CHANGE_MTYPE(m, TPMT_DATA); - /* we KNOW that there is at least 1 byte in this mbuf - and that it is hdr->tpdu_li XXXXXXX! */ + /* + * we KNOW that there is at least 1 byte in this mbuf and that it is + * hdr->tpdu_li XXXXXXX! + */ - hdrlen = 1 + *mtod( m, u_char *); + hdrlen = 1 + *mtod(m, u_char *); /* - * now pull up the whole tp header + * now pull up the whole tp header */ - if ( m->m_len < hdrlen) { - if ((m = m_pullup(m, hdrlen)) == MNULL ) { + if (m->m_len < hdrlen) { + if ((m = m_pullup(m, hdrlen)) == MNULL) { IncStat(ts_recv_drop); - return (struct mbuf *)0; + return (struct mbuf *) 0; } } - IFDEBUG(D_INPUT) - printf( - " at end: m 0x%x hdr->tpdu_li 0x%x m_len 0x%x\n",m, - hdrlen, m->m_len); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_INPUT]) { + printf( + " at end: m 0x%x hdr->tpdu_li 0x%x m_len 0x%x\n", m, + hdrlen, m->m_len); + } +#endif return m; } -/* begin groan - * -- this array and the following macros allow you to step through the - * parameters of the variable part of a header - * note that if for any reason the values of the **_TPDU macros (in tp_events.h) - * should change, this array has to be rearranged +/* + * begin groan -- this array and the following macros allow you to step + * through the parameters of the variable part of a header note that if for + * any reason the values of the **_TPDU macros (in tp_events.h) should + * change, this array has to be rearranged */ #define TP_LEN_CLASS_0_INDEX 2 #define TP_MAX_DATA_INDEX 3 -static u_char tpdu_info[][4] = +static u_char tpdu_info[][4] = { -/* length max data len */ -/* reg fmt xtd fmt class 0 */ - /* UNUSED 0x0 */ 0x0 , 0x0, 0x0, 0x0, - /* XPD_TPDU_type 0x1 */ 0x5, 0x8, 0x0, TP_MAX_XPD_DATA, - /* XAK_TPDU_type 0x2 */ 0x5 , 0x8, 0x0, 0x0, - /* GR_TPDU_type 0x3 */ 0x0 , 0x0, 0x0, 0x0, - /* UNUSED 0x4 */ 0x0 , 0x0, 0x0, 0x0, - /* UNUSED 0x5 */ 0x0 , 0x0, 0x0, 0x0, - /* AK_TPDU_type 0x6 */ 0x5, 0xa, 0x0, 0x0, - /* ER_TPDU_type 0x7 */ 0x5, 0x5, 0x0, 0x0, - /* DR_TPDU_type 0x8 */ 0x7, 0x7, 0x7, TP_MAX_DR_DATA, - /* UNUSED 0x9 */ 0x0 , 0x0, 0x0, 0x0, - /* UNUSED 0xa */ 0x0 , 0x0, 0x0, 0x0, - /* UNUSED 0xb */ 0x0 , 0x0, 0x0, 0x0, - /* DC_TPDU_type 0xc */ 0x6, 0x6, 0x0, 0x0, - /* CC_TPDU_type 0xd */ 0x7, 0x7, 0x7, TP_MAX_CC_DATA, - /* CR_TPDU_type 0xe */ 0x7, 0x7, 0x7, TP_MAX_CR_DATA, - /* DT_TPDU_type 0xf */ 0x5, 0x8, 0x3, 0x0, + /* length max data len */ + /* reg fmt xtd fmt class 0 */ + /* UNUSED 0x0 */ { 0x0, 0x0, 0x0, 0x0 }, + /* XPD_TPDU_type 0x1 */ { 0x5, 0x8, 0x0, TP_MAX_XPD_DATA }, + /* XAK_TPDU_type 0x2 */ { 0x5, 0x8, 0x0, 0x0 }, + /* GR_TPDU_type 0x3 */ { 0x0, 0x0, 0x0, 0x0 }, + /* UNUSED 0x4 */ { 0x0, 0x0, 0x0, 0x0 }, + /* UNUSED 0x5 */ { 0x0, 0x0, 0x0, 0x0 }, + /* AK_TPDU_type 0x6 */ { 0x5, 0xa, 0x0, 0x0 }, + /* ER_TPDU_type 0x7 */ { 0x5, 0x5, 0x0, 0x0 }, + /* DR_TPDU_type 0x8 */ { 0x7, 0x7, 0x7, TP_MAX_DR_DATA }, + /* UNUSED 0x9 */ { 0x0, 0x0, 0x0, 0x0 }, + /* UNUSED 0xa */ { 0x0, 0x0, 0x0, 0x0 }, + /* UNUSED 0xb */ { 0x0, 0x0, 0x0, 0x0 }, + /* DC_TPDU_type 0xc */ { 0x6, 0x6, 0x0, 0x0 }, + /* CC_TPDU_type 0xd */ { 0x7, 0x7, 0x7, TP_MAX_CC_DATA }, + /* CR_TPDU_type 0xe */ { 0x7, 0x7, 0x7, TP_MAX_CR_DATA }, + /* DT_TPDU_type 0xf */ { 0x5, 0x8, 0x3, 0x0 }, }; #define CHECK(Phrase, Erval, Stat, Whattodo, Loc)\ if (Phrase) {error = (Erval); errlen = (int)(Loc); IncStat(Stat);\ goto Whattodo; } -/* - * WHENEVER YOU USE THE FOLLOWING MACRO, - * BE SURE THE TPDUTYPE IS A LEGIT VALUE FIRST! +/* + * WHENEVER YOU USE THE FOLLOWING MACRO, BE SURE THE TPDUTYPE IS A LEGIT + * VALUE FIRST! */ #define WHILE_OPTIONS(P, hdr, format)\ @@ -260,51 +264,58 @@ static u_char tpdu_info[][4] = */ static struct socket * tp_newsocket(so, fname, cons_channel, class_to_use, netservice) - struct socket *so; - struct sockaddr *fname; - caddr_t cons_channel; - u_char class_to_use; - u_int netservice; + struct socket *so; + struct sockaddr *fname; + caddr_t cons_channel; + u_int class_to_use; + u_int netservice; { - register struct tp_pcb *tpcb = sototpcb(so); /* old tpcb, needed below */ - register struct tp_pcb *newtpcb; + register struct tp_pcb *tpcb = sototpcb(so); /* old tpcb, needed + * below */ + register struct tp_pcb *newtpcb; - /* - * sonewconn() gets a new socket structure, - * a new lower layer pcb and a new tpcb, - * but the pcbs are unnamed (not bound) + /* + * sonewconn() gets a new socket structure, a new lower layer pcb and + * a new tpcb, but the pcbs are unnamed (not bound) */ - IFTRACE(D_NEWSOCK) +#ifdef TPPT + if (tp_traceflags[D_NEWSOCK]) { tptraceTPCB(TPPTmisc, "newsock: listg_so, _tpcb, so_head", - so, tpcb, so->so_head, 0); - ENDTRACE + so, tpcb, so->so_head, 0); + } +#endif - if ((so = sonewconn(so, SS_ISCONFIRMING)) == (struct socket *)0) + if ((so = sonewconn(so, SS_ISCONFIRMING)) == (struct socket *) 0) return so; - IFTRACE(D_NEWSOCK) +#ifdef TPPT + if (tp_traceflags[D_NEWSOCK]) { tptraceTPCB(TPPTmisc, "newsock: after newconn so, so_head", - so, so->so_head, 0, 0); - ENDTRACE + so, so->so_head, 0, 0); + } +#endif - IFDEBUG(D_NEWSOCK) +#ifdef ARGO_DEBUG + if (argo_debug[D_NEWSOCK]) { printf("tp_newsocket(channel 0x%x) after sonewconn so 0x%x \n", - cons_channel, so); + cons_channel, so); dump_addr(fname); - { - struct socket *t, *head ; + { + struct socket *t, *head; head = so->so_head; t = so; printf("so 0x%x so_head 0x%x so_q0 0x%x, q0len %d\n", - t, t->so_head, t->so_q0, t->so_q0len); - while( (t=t->so_q0) && t!= so && t!= head) + t, t->so_head, t->so_q0, t->so_q0len); + while ((t = t->so_q0) && t != so && t != head) printf("so 0x%x so_head 0x%x so_q0 0x%x, q0len %d\n", - t, t->so_head, t->so_q0, t->so_q0len); + t, t->so_head, t->so_q0, t->so_q0len); } - ENDDEBUG + } +#endif - /* - * before we clobber the old tpcb ptr, get these items from the parent pcb + /* + * before we clobber the old tpcb ptr, get these items from the + * parent pcb */ newtpcb = sototpcb(so); newtpcb->_tp_param = tpcb->_tp_param; @@ -312,36 +323,39 @@ tp_newsocket(so, fname, cons_channel, class_to_use, netservice) newtpcb->tp_lcredit = tpcb->tp_lcredit; newtpcb->tp_l_tpdusize = tpcb->tp_l_tpdusize; newtpcb->tp_lsuffixlen = tpcb->tp_lsuffixlen; - bcopy( tpcb->tp_lsuffix, newtpcb->tp_lsuffix, newtpcb->tp_lsuffixlen); + bcopy(tpcb->tp_lsuffix, newtpcb->tp_lsuffix, newtpcb->tp_lsuffixlen); - if( /* old */ tpcb->tp_ucddata) { - /* - * These data are the connect- , confirm- or disconnect- data. + if ( /* old */ tpcb->tp_ucddata) { + /* + * These data are the connect- , confirm- or disconnect- + * data. */ - struct mbuf *conndata; + struct mbuf *conndata; - conndata = m_copy(tpcb->tp_ucddata, 0, (int)M_COPYALL); - IFDEBUG(D_CONN) + conndata = m_copy(tpcb->tp_ucddata, 0, (int) M_COPYALL); +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { dump_mbuf(conndata, "conndata after mcopy"); - ENDDEBUG + } +#endif newtpcb->tp_ucddata = conndata; } - tpcb = newtpcb; tpcb->tp_state = TP_LISTENING; tpcb->tp_class = class_to_use; tpcb->tp_netservice = netservice; - ASSERT( fname != 0 ) ; /* just checking */ - if ( fname ) { + ASSERT(fname != 0); /* just checking */ + if (fname) { /* * tp_route_to takes its address argument in the form of an mbuf. */ - struct mbuf *m; - int err; + struct mbuf *m; + int err; - MGET(m, M_DONTWAIT, MT_SONAME); /* mbuf type used is confusing */ + MGET(m, M_DONTWAIT, MT_SONAME); /* mbuf type used is + * confusing */ if (m) { /* * this seems a bit grotesque, but tp_route_to expects @@ -349,337 +363,389 @@ tp_newsocket(so, fname, cons_channel, class_to_use, netservice) * pcb_connect, which expects the name/addr in an mbuf as well. * sigh. */ - bcopy((caddr_t)fname, mtod(m, caddr_t), fname->sa_len); + bcopy((caddr_t) fname, mtod(m, caddr_t), fname->sa_len); m->m_len = fname->sa_len; - /* grot : have to say the kernel can override params in - * the passive open case + /* + * grot : have to say the kernel can override params + * in the passive open case */ tpcb->tp_dont_change_params = 0; - err = tp_route_to( m, tpcb, cons_channel); + err = tp_route_to(m, tpcb, cons_channel); m_free(m); if (!err) goto ok; } - IFDEBUG(D_CONN) +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("tp_route_to FAILED! detaching tpcb 0x%x, so 0x%x\n", - tpcb, so); - ENDDEBUG - (void) tp_detach(tpcb); + tpcb, so); + } +#endif + (void) tp_detach(tpcb); return 0; } ok: - IFDEBUG(D_TPINPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { printf("tp_newsocket returning so 0x%x, sototpcb(so) 0x%x\n", - so, sototpcb(so)); - ENDDEBUG + so, sototpcb(so)); + } +#endif return so; } -#ifndef TPCONS -tpcons_output() -{ - return(0); -} -#endif /* !CONS */ - -/* +/* * NAME: tp_input() * - * CALLED FROM: - * net layer input routine + * CALLED FROM: net layer input routine * - * FUNCTION and ARGUMENTS: - * Process an incoming TPDU (m), finding the associated tpcb if there - * is one. Create the appropriate type of event and call the driver. - * (faddr) and (laddr) are the foreign and local addresses. - * - * When tp_input() is called we KNOW that the ENTIRE TP HEADER - * has been m_pullup-ed. + * FUNCTION and ARGUMENTS: Process an incoming TPDU (m), finding the associated + * tpcb if there is one. Create the appropriate type of event and call the + * driver. (faddr) and (laddr) are the foreign and local addresses. + * + * When tp_input() is called we KNOW that the ENTIRE TP HEADER has been + * m_pullup-ed. * * RETURN VALUE: Nada - * - * SIDE EFFECTS: - * When using COSNS it may affect the state of the net-level pcb * - * NOTE: - * The initial value of acktime is 2 so that we will never - * have a 0 value for tp_peer_acktime. It gets used in the - * computation of the retransmission timer value, and so it - * mustn't be zero. - * 2 seems like a reasonable minimum. + * SIDE EFFECTS: When using COSNS it may affect the state of the net-level pcb + * + * NOTE: The initial value of acktime is 2 so that we will never have a 0 value + * for tp_peer_acktime. It gets used in the computation of the + * retransmission timer value, and so it mustn't be zero. 2 seems like a + * reasonable minimum. */ void -tp_input(m, faddr, laddr, cons_channel, dgout_routine, ce_bit) - register struct mbuf *m; - struct sockaddr *faddr, *laddr; /* NSAP addresses */ - caddr_t cons_channel; - int (*dgout_routine)(); - int ce_bit; - +#if __STDC__ +tp_input(struct mbuf *m, ...) +#else +tp_input(m, va_alist) + struct mbuf *m; + va_dcl +#endif { - register struct tp_pcb *tpcb; - register struct tpdu *hdr; - struct socket *so; - struct tp_event e; - int error; - unsigned dutype; - u_short dref, sref, acktime, subseq; - u_char preferred_class, class_to_use, pdusize; - u_char opt, dusize, addlopt, version; + struct sockaddr *faddr, *laddr; /* NSAP addresses */ + caddr_t cons_channel; + int (*dgout_routine) __P((struct mbuf *, ...)); + int ce_bit; + register struct tp_pcb *tpcb; + register struct tpdu *hdr; + struct socket *so; + struct tp_event e; + int error; + unsigned dutype; + u_short dref, sref, acktime, subseq; + u_char preferred_class, class_to_use, pdusize; + u_char opt, dusize, addlopt, version = 0; #ifdef TP_PERF_MEAS - u_char perf_meas; -#endif /* TP_PERF_MEAS */ - u_char fsufxlen, lsufxlen; - caddr_t fsufxloc, lsufxloc; - int tpdu_len; - u_int takes_data; - u_int fcc_present; - int errlen; - struct tp_conn_param tpp; - int tpcons_output(); + u_char perf_meas; +#endif /* TP_PERF_MEAS */ + u_char fsufxlen, lsufxlen; + caddr_t fsufxloc, lsufxloc; + int tpdu_len; + u_int takes_data; + u_int fcc_present; + int errlen; + struct tp_conn_param tpp; + va_list ap; + + va_start(ap, m); + faddr = va_arg(ap, struct sockaddr *); + laddr = va_arg(ap, struct sockaddr *); + cons_channel = va_arg(ap, caddr_t); + /* XXX: Does va_arg does not work for function ptrs */ + dgout_routine = (int (*) __P((struct mbuf *, ...))) va_arg(ap, void *); + ce_bit = va_arg(ap, int); + va_end(ap); again: hdr = mtod(m, struct tpdu *); tpcb = 0; error = errlen = tpdu_len = 0; takes_data = fcc_present = FALSE; - acktime = 2; sref = subseq = 0; + acktime = 2; + sref = subseq = 0; fsufxloc = lsufxloc = NULL; fsufxlen = lsufxlen = preferred_class = class_to_use = pdusize = addlopt = 0; dusize = TP_DFL_TPDUSIZE; #ifdef TP_PERF_MEAS - GET_CUR_TIME( &e.e_time ); perf_meas = 0; -#endif /* TP_PERF_MEAS */ - - IFDEBUG(D_TPINPUT) + GET_CUR_TIME(&e.e_time); + perf_meas = 0; +#endif /* TP_PERF_MEAS */ + +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { printf("tp_input(0x%x, ... 0x%x)\n", m, cons_channel); - ENDDEBUG + } +#endif - /* - * get the actual tpdu length - necessary for monitoring - * and for checksumming - * + /* + * get the actual tpdu length - necessary for monitoring and for + * checksumming + * * Also, maybe measure the mbuf chain lengths and sizes. */ - { register struct mbuf *n=m; -# ifdef ARGO_DEBUG - int chain_length = 0; -# endif ARGO_DEBUG + { + register struct mbuf *n = m; +#ifdef ARGO_DEBUG + int chain_length = 0; +#endif /* ARGO_DEBUG */ - for(;;) { + for (;;) { tpdu_len += n->m_len; - IFDEBUG(D_MBUF_MEAS) - if( n->m_flags & M_EXT) { +#ifdef ARGO_DEBUG + if (argo_debug[D_MBUF_MEAS]) { + if (n->m_flags & M_EXT) { IncStat(ts_mb_cluster); } else { IncStat(ts_mb_small); } - chain_length ++; - ENDDEBUG - if (n->m_next == MNULL ) { + chain_length++; + } +#endif + if (n->m_next == MNULL) { break; } n = n->m_next; } - IFDEBUG(D_MBUF_MEAS) - if(chain_length > 16) - chain_length = 0; /* zero used for anything > 16 */ - tp_stat.ts_mb_len_distr[chain_length] ++; - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_MBUF_MEAS]) { + if (chain_length > 16) + chain_length = 0; /* zero used for + * anything > 16 */ + tp_stat.ts_mb_len_distr[chain_length]++; + } +#endif + } +#ifdef TPPT + if (tp_traceflags[D_TPINPUT]) { + tptraceTPCB(TPPTtpduin, hdr->tpdu_type, hdr, hdr->tpdu_li + 1, + tpdu_len, 0); } - IFTRACE(D_TPINPUT) - tptraceTPCB(TPPTtpduin, hdr->tpdu_type, hdr, hdr->tpdu_li+1, tpdu_len, - 0); - ENDTRACE +#endif - dref = ntohs((short)hdr->tpdu_dref); - sref = ntohs((short)hdr->tpdu_sref); - dutype = (int)hdr->tpdu_type; + dref = ntohs((short) hdr->tpdu_dref); + sref = ntohs((short) hdr->tpdu_sref); + dutype = (int) hdr->tpdu_type; - IFDEBUG(D_TPINPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { printf("input: dutype 0x%x cons_channel 0x%x dref 0x%x\n", dutype, - cons_channel, dref); + cons_channel, dref); printf("input: dref 0x%x sref 0x%x\n", dref, sref); - ENDDEBUG - IFTRACE(D_TPINPUT) - tptrace(TPPTmisc, "channel dutype dref ", + } +#endif +#ifdef TPPT + if (tp_traceflags[D_TPINPUT]) { + tptrace(TPPTmisc, "channel dutype dref ", cons_channel, dutype, dref, 0); - ENDTRACE + } +#endif #ifdef ARGO_DEBUG - if( (dutype < TP_MIN_TPDUTYPE) || (dutype > TP_MAX_TPDUTYPE)) { + if ((dutype < TP_MIN_TPDUTYPE) || (dutype > TP_MAX_TPDUTYPE)) { printf("BAD dutype! 0x%x, channel 0x%x dref 0x%x\n", - dutype, cons_channel, dref); - dump_buf (m, sizeof( struct mbuf )); + dutype, cons_channel, dref); + dump_buf(m, sizeof(struct mbuf)); IncStat(ts_inv_dutype); goto discard; } -#endif /* ARGO_DEBUG */ +#endif /* ARGO_DEBUG */ - CHECK( (dutype < TP_MIN_TPDUTYPE || dutype > TP_MAX_TPDUTYPE), - E_TP_INV_TPDU, ts_inv_dutype, respond, - 2 ); - /* unfortunately we can't take the address of the tpdu_type field, - * since it's a bit field - so we just use the constant offset 2 - */ + CHECK((dutype < TP_MIN_TPDUTYPE || dutype > TP_MAX_TPDUTYPE), + E_TP_INV_TPDU, ts_inv_dutype, respond, + 2); + /* + * unfortunately we can't take the address of the tpdu_type field, + * since it's a bit field - so we just use the constant offset 2 + */ - /* Now this isn't very neat but since you locate a pcb one way - * at the beginning of connection establishment, and by - * the dref for each tpdu after that, we have to treat CRs differently + /* + * Now this isn't very neat but since you locate a pcb one way at the + * beginning of connection establishment, and by the dref for each + * tpdu after that, we have to treat CRs differently */ - if ( dutype == CR_TPDU_type ) { - u_char alt_classes = 0; + if (dutype == CR_TPDU_type) { + u_char alt_classes = 0; preferred_class = 1 << hdr->tpdu_CRclass; opt = hdr->tpdu_CRoptions; - WHILE_OPTIONS(P, hdr, 1 ) /* { */ - - switch( vbptr(P)->tpv_code ) { + WHILE_OPTIONS(P, hdr, 1) /* { */ + switch (vbptr(P)->tpv_code) { - case TPP_tpdu_size: - vb_getval(P, u_char, dusize); - IFDEBUG(D_TPINPUT) - printf("CR dusize 0x%x\n", dusize); - ENDDEBUG - /* COS tests: NBS IA (Dec. 1987) Sec. 4.5.2.1 */ - if (dusize < TP_MIN_TPDUSIZE || dusize > TP_MAX_TPDUSIZE) - dusize = TP_DFL_TPDUSIZE; + case TPP_tpdu_size: + vb_getval(P, u_char, dusize); +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { + printf("CR dusize 0x%x\n", dusize); + } +#endif + /* COS tests: NBS IA (Dec. 1987) Sec. 4.5.2.1 */ + if (dusize < TP_MIN_TPDUSIZE || dusize > TP_MAX_TPDUSIZE) + dusize = TP_DFL_TPDUSIZE; + break; + case TPP_ptpdu_size: + switch (vbptr(P)->tpv_len) { + case 1: + pdusize = vbval(P, u_char); break; - case TPP_ptpdu_size: - switch (vbptr(P)->tpv_len) { - case 1: pdusize = vbval(P, u_char); break; - case 2: pdusize = ntohs(vbval(P, u_short)); break; - default: ; - IFDEBUG(D_TPINPUT) + case 2: + pdusize = ntohs(vbval(P, u_short)); + break; + default:; +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { printf("malformed prefered TPDU option\n"); - ENDDEBUG } - break; - case TPP_addl_opt: - vb_getval(P, u_char, addlopt); - break; - case TPP_calling_sufx: - /* could use vb_getval, but we want to save the loc & len - * for later use - */ - fsufxloc = (caddr_t) &vbptr(P)->tpv_val; - fsufxlen = vbptr(P)->tpv_len; - IFDEBUG(D_TPINPUT) - printf("CR fsufx:"); - { register int j; - for(j=0; j<fsufxlen; j++ ) { - printf(" 0x%x. ", *((caddr_t)(fsufxloc+j)) ); - } - printf("\n"); - } - ENDDEBUG - break; - case TPP_called_sufx: - /* could use vb_getval, but we want to save the loc & len - * for later use - */ - lsufxloc = (caddr_t) &vbptr(P)->tpv_val; - lsufxlen = vbptr(P)->tpv_len; - IFDEBUG(D_TPINPUT) - printf("CR lsufx:"); - { register int j; - for(j=0; j<lsufxlen; j++ ) { - printf(" 0x%x. ", *((u_char *)(lsufxloc+j)) ); - } - printf("\n"); +#endif + } + break; + case TPP_addl_opt: + vb_getval(P, u_char, addlopt); + break; + case TPP_calling_sufx: + /* + * could use vb_getval, but we want to save the loc & + * len for later use + */ + fsufxloc = (caddr_t) & vbptr(P)->tpv_val; + fsufxlen = vbptr(P)->tpv_len; +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { + printf("CR fsufx:"); + { + register int j; + for (j = 0; j < fsufxlen; j++) { + printf(" 0x%x. ", *((caddr_t) (fsufxloc + j))); } - ENDDEBUG - break; - -#ifdef TP_PERF_MEAS - case TPP_perf_meas: - vb_getval(P, u_char, perf_meas); - break; -#endif /* TP_PERF_MEAS */ - - case TPP_vers: - /* not in class 0; 1 octet; in CR_TPDU only */ - /* COS tests says if version wrong, use default version!?XXX */ - CHECK( (vbval(P, u_char) != TP_VERSION ), - E_TP_INV_PVAL, ts_inv_pval, setversion, - (1 + (caddr_t)&vbptr(P)->tpv_val - (caddr_t)hdr) ); - setversion: - version = vbval(P, u_char); - break; - case TPP_acktime: - vb_getval(P, u_short, acktime); - acktime = ntohs(acktime); - acktime = acktime/500; /* convert to slowtimo ticks */ - if((short)acktime <=0 ) - acktime = 2; /* don't allow a bad peer to screw us up */ - IFDEBUG(D_TPINPUT) - printf("CR acktime 0x%x\n", acktime); - ENDDEBUG - break; - - case TPP_alt_class: + printf("\n"); + } + } +#endif + break; + case TPP_called_sufx: + /* + * could use vb_getval, but we want to save the loc & + * len for later use + */ + lsufxloc = (caddr_t) & vbptr(P)->tpv_val; + lsufxlen = vbptr(P)->tpv_len; +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { + printf("CR lsufx:"); { - u_char *aclass = 0; - register int i; - static u_char bad_alt_classes[5] = - { ~0, ~3, ~5, ~0xf, ~0x1f}; - - aclass = - (u_char *) &(((struct tp_vbp *)P)->tpv_val); - for (i = ((struct tp_vbp *)P)->tpv_len; i>0; i--) { - alt_classes |= (1<<((*aclass++)>>4)); + register int j; + for (j = 0; j < lsufxlen; j++) { + printf(" 0x%x. ", *((u_char *) (lsufxloc + j))); } - CHECK( (bad_alt_classes[hdr->tpdu_CRclass] & alt_classes), - E_TP_INV_PVAL, ts_inv_aclass, respond, - ((caddr_t)aclass) - (caddr_t)hdr); - IFDEBUG(D_TPINPUT) - printf("alt_classes 0x%x\n", alt_classes); - ENDDEBUG + printf("\n"); } - break; + } +#endif + break; - case TPP_security: - case TPP_residER: - case TPP_priority: - case TPP_transdelay: - case TPP_throughput: - case TPP_addl_info: - case TPP_subseq: - default: - IFDEBUG(D_TPINPUT) - printf("param ignored CR_TPDU code= 0x%x\n", - vbptr(P)->tpv_code); - ENDDEBUG - IncStat(ts_param_ignored); - break; +#ifdef TP_PERF_MEAS + case TPP_perf_meas: + vb_getval(P, u_char, perf_meas); + break; +#endif /* TP_PERF_MEAS */ + + case TPP_vers: + /* not in class 0; 1 octet; in CR_TPDU only */ + /* + * COS tests says if version wrong, use default + * version!?XXX + */ + CHECK((vbval(P, u_char) != TP_VERSION), + E_TP_INV_PVAL, ts_inv_pval, setversion, + (1 + (caddr_t) & vbptr(P)->tpv_val - (caddr_t) hdr)); + setversion: + version = vbval(P, u_char); + break; + case TPP_acktime: + vb_getval(P, u_short, acktime); + acktime = ntohs(acktime); + acktime = acktime / 500; /* convert to slowtimo + * ticks */ + if ((short) acktime <= 0) + acktime = 2; /* don't allow a bad peer to + * screw us up */ +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { + printf("CR acktime 0x%x\n", acktime); + } +#endif + break; - case TPP_checksum: - IFDEBUG(D_TPINPUT) - printf("CR before cksum\n"); - ENDDEBUG + case TPP_alt_class: + { + u_char *aclass = 0; + register int i; + static u_char bad_alt_classes[5] = + {~0, ~3, ~5, ~0xf, ~0x1f}; + + aclass = + (u_char *) & (((struct tp_vbp *) P)->tpv_val); + for (i = ((struct tp_vbp *) P)->tpv_len; i > 0; i--) { + alt_classes |= (1 << ((*aclass++) >> 4)); + } + CHECK((bad_alt_classes[hdr->tpdu_CRclass] & alt_classes), + E_TP_INV_PVAL, ts_inv_aclass, respond, + ((caddr_t) aclass) - (caddr_t) hdr); +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { + printf("alt_classes 0x%x\n", alt_classes); + } +#endif + } + break; - CHECK( iso_check_csum(m, tpdu_len), - E_TP_INV_PVAL, ts_bad_csum, discard, 0) + case TPP_security: + case TPP_residER: + case TPP_priority: + case TPP_transdelay: + case TPP_throughput: + case TPP_addl_info: + case TPP_subseq: + default: +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { + printf("param ignored CR_TPDU code= 0x%x\n", + vbptr(P)->tpv_code); + } +#endif + IncStat(ts_param_ignored); + break; - IFDEBUG(D_TPINPUT) - printf("CR before cksum\n"); - ENDDEBUG - break; + case TPP_checksum: +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { + printf("CR before cksum\n"); } +#endif - /* } */ END_WHILE_OPTIONS(P) + CHECK(iso_check_csum(m, tpdu_len), + E_TP_INV_PVAL, ts_bad_csum, discard, 0) +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { + printf("CR before cksum\n"); + } +#endif + break; + } - if (lsufxlen == 0) { + /* } */ END_WHILE_OPTIONS(P) + if (lsufxlen == 0) { /* can't look for a tpcb w/o any called sufx */ - error = E_TP_LENGTH_INVAL; + error = E_TP_LENGTH_INVAL; IncStat(ts_inv_sufx); goto respond; } else { @@ -695,60 +761,71 @@ again: * listen over any network service provider, * (cons or clns or ip). */ - for (t = tp_listeners; t ; t = t->tp_nextlisten) + for (t = tp_listeners; t; t = t->tp_nextlisten) if ((t->tp_lsuffixlen == 0 || - (lsufxlen == t->tp_lsuffixlen && - bcmp(lsufxloc, t->tp_lsuffix, lsufxlen) == 0)) && - ((t->tp_flags & TPF_GENERAL_ADDR) || - (laddr->sa_family == t->tp_domain && - (*t->tp_nlproto->nlp_cmpnetaddr) - (t->tp_npcb, laddr, TP_LOCAL)))) + (lsufxlen == t->tp_lsuffixlen && + bcmp(lsufxloc, t->tp_lsuffix, lsufxlen) == 0)) && + ((t->tp_flags & TPF_GENERAL_ADDR) || + (laddr->sa_family == t->tp_domain && + (*t->tp_nlproto->nlp_cmpnetaddr) + (t->tp_npcb, laddr, TP_LOCAL)))) break; CHECK(t == 0, E_TP_NO_SESSION, ts_inv_sufx, respond, - (1 + 2 + (caddr_t)&hdr->_tpduf - (caddr_t)hdr)) - /* _tpduf is the fixed part; add 2 to get the dref bits of - * the fixed part (can't take the address of a bit field) - */ - IFDEBUG(D_TPINPUT) + (1 + 2 + (caddr_t) & hdr->_tpduf - (caddr_t) hdr)) + /* + * _tpduf is the fixed part; add 2 to get the dref + * bits of the fixed part (can't take the address of + * a bit field) + */ +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { printf("checking if dup CR\n"); - ENDDEBUG + } +#endif tpcb = t; for (t = tpcb->tp_next; t != tpcb; t = t->tp_next) { if (sref != t->tp_fref) continue; - if ((*tpcb->tp_nlproto->nlp_cmpnetaddr)( - t->tp_npcb, faddr, TP_FOREIGN)) { - IFDEBUG(D_TPINPUT) + if ((*tpcb->tp_nlproto->nlp_cmpnetaddr) ( + t->tp_npcb, faddr, TP_FOREIGN)) { +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { printf("duplicate CR discarded\n"); - ENDDEBUG + } +#endif goto discard; } } - IFTRACE(D_TPINPUT) - tptrace(TPPTmisc, "tp_input: tpcb *lsufxloc tpstate", +#ifdef TPPT + if (tp_traceflags[D_TPINPUT]) { + tptrace(TPPTmisc, "tp_input: tpcb *lsufxloc tpstate", tpcb, *lsufxloc, tpcb->tp_state, 0); - ENDTRACE + } +#endif } - /* - * WE HAVE A TPCB - * already know that the classes in the CR match at least - * one class implemented, but we don't know yet if they - * include any classes permitted by this server. + /* + * WE HAVE A TPCB already know that the classes in the CR + * match at least one class implemented, but we don't know + * yet if they include any classes permitted by this server. */ - IFDEBUG(D_TPINPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { printf("HAVE A TPCB 1: 0x%x\n", tpcb); - ENDDEBUG - IFDEBUG(D_CONN) + } +#endif +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf( -"CR: bef CHKS: flags 0x%x class_to_use 0x%x alt 0x%x opt 0x%x tp_class 0x%x\n", - tpcb->tp_flags, class_to_use, alt_classes, opt, tpcb->tp_class); - ENDDEBUG + "CR: bef CHKS: flags 0x%x class_to_use 0x%x alt 0x%x opt 0x%x tp_class 0x%x\n", + tpcb->tp_flags, class_to_use, alt_classes, opt, tpcb->tp_class); + } +#endif /* tpcb->tp_class doesn't include any classes not implemented */ class_to_use = (preferred_class & tpcb->tp_class); - if( (class_to_use = preferred_class & tpcb->tp_class) == 0 ) + if ((class_to_use = preferred_class & tpcb->tp_class) == 0) class_to_use = alt_classes & tpcb->tp_class; class_to_use = 1 << tp_mask_to_num(class_to_use); @@ -760,69 +837,78 @@ again: tpp.p_ptpdusize = pdusize; tpp.p_xtd_format = (opt & TPO_XTD_FMT) == TPO_XTD_FMT; tpp.p_xpd_service = (addlopt & TPAO_USE_TXPD) == TPAO_USE_TXPD; - tpp.p_use_checksum = (tpp.p_class == TP_CLASS_0)?0: + tpp.p_use_checksum = (tpp.p_class == TP_CLASS_0) ? 0 : (addlopt & TPAO_NO_CSUM) == 0; tpp.p_version = version; #ifdef notdef tpp.p_use_efc = (opt & TPO_USE_EFC) == TPO_USE_EFC; tpp.p_use_nxpd = (addlopt & TPAO_USE_NXPD) == TPAO_USE_NXPD; tpp.p_use_rcc = (addlopt & TPAO_USE_RCC) == TPAO_USE_RCC; -#endif /* notdef */ +#endif /* notdef */ - CHECK( - tp_consistency(tpcb, 0 /* not force or strict */, &tpp) != 0, + CHECK( + tp_consistency(tpcb, 0 /* not force or strict */ , &tpp) != 0, E_TP_NEGOT_FAILED, ts_negotfailed, clear_parent_tcb, - (1 + 2 + (caddr_t)&hdr->_tpdufr.CRCC - (caddr_t)hdr) - /* ^ more or less the location of class */ - ) + (1 + 2 + (caddr_t) & hdr->_tpdufr.CRCC - (caddr_t) hdr) + /* ^ more or less the location of class */ + ) } - IFTRACE(D_CONN) - tptrace(TPPTmisc, - "after 1 consist class_to_use class, out, tpconsout", - class_to_use, +#ifdef TPPT + if (tp_traceflags[D_CONN]) { + tptrace(TPPTmisc, + "after 1 consist class_to_use class, out, tpconsout", + class_to_use, tpcb->tp_class, dgout_routine, tpcons_output - ); - ENDTRACE - CHECK( - ((class_to_use == TP_CLASS_0)&&(dgout_routine != tpcons_output)), + ); + } +#endif + CHECK(((class_to_use == TP_CLASS_0) && + (dgout_routine != tpcons_output)), E_TP_NEGOT_FAILED, ts_negotfailed, clear_parent_tcb, - (1 + 2 + (caddr_t)&hdr->_tpdufr.CRCC - (caddr_t)hdr) - /* ^ more or less the location of class */ + (1 + 2 + (caddr_t) & hdr->_tpdufr.CRCC - (caddr_t) hdr) + /* ^ more or less the location of class */ ) - IFDEBUG(D_CONN) - printf("CR: after CRCCCHECKS: tpcb 0x%x, flags 0x%x\n", - tpcb, tpcb->tp_flags); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { + printf("CR: after CRCCCHECKS: tpcb 0x%x, flags 0x%x\n", + tpcb, tpcb->tp_flags); + } +#endif takes_data = TRUE; - e.ATTR(CR_TPDU).e_cdt = hdr->tpdu_CRcdt; + e.TPDU_ATTR(CR).e_cdt = hdr->tpdu_CRcdt; e.ev_number = CR_TPDU; so = tpcb->tp_sock; if (so->so_options & SO_ACCEPTCONN) { - struct tp_pcb *parent_tpcb = tpcb; - /* - * Create a socket, tpcb, ll pcb, etc. - * for this newborn connection, and fill in all the values. + struct tp_pcb *parent_tpcb = tpcb; + /* + * Create a socket, tpcb, ll pcb, etc. for this + * newborn connection, and fill in all the values. */ - IFDEBUG(D_CONN) +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("abt to call tp_newsocket(0x%x, 0x%x, 0x%x, 0x%x)\n", - so, laddr, faddr, cons_channel); - ENDDEBUG - if( (so = - tp_newsocket(so, faddr, cons_channel, - class_to_use, - ((tpcb->tp_netservice == IN_CLNS) ? IN_CLNS : - (dgout_routine == tpcons_output)?ISO_CONS:ISO_CLNS)) - ) == (struct socket *)0 ) { - /* note - even if netservice is IN_CLNS, as far as - * the tp entity is concerned, the only differences - * are CO vs CL + so, laddr, faddr, cons_channel); + } +#endif + if ((so = + tp_newsocket(so, faddr, cons_channel, + class_to_use, + ((tpcb->tp_netservice == IN_CLNS) ? IN_CLNS : + (dgout_routine == tpcons_output) ? ISO_CONS : ISO_CLNS)) + ) == (struct socket *) 0) { + /* + * note - even if netservice is IN_CLNS, as + * far as the tp entity is concerned, the + * only differences are CO vs CL */ - IFDEBUG(D_CONN) +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("tp_newsocket returns 0\n"); - ENDDEBUG + } +#endif goto discard; - clear_parent_tcb: + clear_parent_tcb: tpcb = 0; goto respond; } @@ -830,58 +916,64 @@ again: insque(tpcb, parent_tpcb); /* - * Stash the addresses in the net level pcb + * Stash the addresses in the net level pcb * kind of like a pcbconnect() but don't need * or want all those checks. */ - (tpcb->tp_nlproto->nlp_putnetaddr)(tpcb->tp_npcb, faddr, TP_FOREIGN); - (tpcb->tp_nlproto->nlp_putnetaddr)(tpcb->tp_npcb, laddr, TP_LOCAL); + (tpcb->tp_nlproto->nlp_putnetaddr) (tpcb->tp_npcb, faddr, TP_FOREIGN); + (tpcb->tp_nlproto->nlp_putnetaddr) (tpcb->tp_npcb, laddr, TP_LOCAL); /* stash the f suffix in the new tpcb */ - if (tpcb->tp_fsuffixlen = fsufxlen) { + if ((tpcb->tp_fsuffixlen = fsufxlen) != 0) { bcopy(fsufxloc, tpcb->tp_fsuffix, fsufxlen); (tpcb->tp_nlproto->nlp_putsufx) - (tpcb->tp_npcb, fsufxloc, fsufxlen, TP_FOREIGN); + (tpcb->tp_npcb, fsufxloc, fsufxlen, TP_FOREIGN); } /* stash the l suffix in the new tpcb */ tpcb->tp_lsuffixlen = lsufxlen; bcopy(lsufxloc, tpcb->tp_lsuffix, lsufxlen); (tpcb->tp_nlproto->nlp_putsufx) - (tpcb->tp_npcb, lsufxloc, lsufxlen, TP_LOCAL); + (tpcb->tp_npcb, lsufxloc, lsufxlen, TP_LOCAL); #ifdef TP_PERF_MEAS - if( tpcb->tp_perf_on = perf_meas ) { /* assignment */ - /* ok, let's create an mbuf for stashing the - * statistics if one doesn't already exist + if (tpcb->tp_perf_on = perf_meas) { /* assignment */ + /* + * ok, let's create an mbuf for stashing the + * statistics if one doesn't already exist */ (void) tp_setup_perf(tpcb); } -#endif /* TP_PERF_MEAS */ +#endif /* TP_PERF_MEAS */ tpcb->tp_fref = sref; - /* We've already checked for consistency with the options - * set in tpp, but we couldn't set them earlier because - * we didn't want to change options in the LISTENING tpcb. - * Now we set the options in the new socket's tpcb. + /* + * We've already checked for consistency with the + * options set in tpp, but we couldn't set them + * earlier because we didn't want to change options + * in the LISTENING tpcb. Now we set the options in + * the new socket's tpcb. */ - (void) tp_consistency( tpcb, TP_FORCE, &tpp); + (void) tp_consistency(tpcb, TP_FORCE, &tpp); - if(!tpcb->tp_use_checksum) + if (!tpcb->tp_use_checksum) IncStat(ts_csum_off); - if(tpcb->tp_xpd_service) + if (tpcb->tp_xpd_service) IncStat(ts_use_txpd); - if(tpcb->tp_xtd_format) + if (tpcb->tp_xtd_format) IncStat(ts_xtd_fmt); tpcb->tp_peer_acktime = acktime; - /* - * The following kludge is used to test retransmissions and - * timeout during connection establishment. + /* + * The following kludge is used to test + * retransmissions and timeout during connection + * establishment. */ - IFDEBUG(D_ZDREF) +#ifdef ARGO_DEBUG + if (argo_debug[D_ZDREF]) { IncStat(ts_zdebug); - /*tpcb->tp_fref = 0;*/ - ENDDEBUG + /* tpcb->tp_fref = 0; */ + } +#endif } LOCAL_CREDIT(tpcb); IncStat(ts_CR_rcvd); @@ -891,244 +983,269 @@ again: CONG_INIT_SAMPLE(tpcb); CONG_UPDATE_SAMPLE(tpcb, ce_bit); } - } else if ( dutype == ER_TPDU_type ) { - /* - * ER TPDUs have to be recognized separately - * because they don't necessarily have a tpcb - * with them and we don't want err out looking for such - * a beast. - * We could put a bunch of little kludges in the - * next section of code so it would avoid references to tpcb - * if dutype == ER_TPDU_type but we don't want code for ERs to - * mess up code for data transfer. + } else if (dutype == ER_TPDU_type) { + /* + * ER TPDUs have to be recognized separately because they + * don't necessarily have a tpcb with them and we don't want + * err out looking for such a beast. We could put a bunch of + * little kludges in the next section of code so it would + * avoid references to tpcb if dutype == ER_TPDU_type but we + * don't want code for ERs to mess up code for data transfer. */ IncStat(ts_ER_rcvd); e.ev_number = ER_TPDU; - e.ATTR(ER_TPDU).e_reason = (u_char)hdr->tpdu_ERreason; - CHECK (((int)dref <= 0 || dref >= tp_refinfo.tpr_size || - (tpcb = tp_ref[dref].tpr_pcb ) == (struct tp_pcb *) 0 || - tpcb->tp_refstate == REF_FREE || - tpcb->tp_refstate == REF_FROZEN), - E_TP_MISM_REFS, ts_inv_dref, discard, 0) - + e.TPDU_ATTR(ER).e_reason = (u_char) hdr->tpdu_ERreason; + CHECK(((int) dref <= 0 || dref >= tp_refinfo.tpr_size || + (tpcb = tp_ref[dref].tpr_pcb) == (struct tp_pcb *) 0 || + tpcb->tp_refstate == REF_FREE || + tpcb->tp_refstate == REF_FROZEN), + E_TP_MISM_REFS, ts_inv_dref, discard, 0) } else { /* tpdu type is CC, XPD, XAK, GR, AK, DR, DC, or DT */ - /* In the next 4 checks, - * _tpduf is the fixed part; add 2 to get the dref bits of - * the fixed part (can't take the address of a bit field) + /* + * In the next 4 checks, _tpduf is the fixed part; add 2 to + * get the dref bits of the fixed part (can't take the + * address of a bit field) */ #ifdef TPCONS if (cons_channel && dutype == DT_TPDU_type) { - struct isopcb *isop = ((struct isopcb *) - ((struct pklcd *)cons_channel)->lcd_upnext); + struct isopcb *isop = ((struct isopcb *) + ((struct pklcd *) cons_channel)->lcd_upnext); if (isop && isop->isop_refcnt == 1 && isop->isop_socket && - (tpcb = sototpcb(isop->isop_socket)) && - (tpcb->tp_class == TP_CLASS_0/* || == CLASS_1 */)) { - IFDEBUG(D_TPINPUT) + (tpcb = sototpcb(isop->isop_socket)) && + (tpcb->tp_class == TP_CLASS_0 /* || == CLASS_1 */ )) { +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { printf("tpinput_dt: class 0 short circuit\n"); - ENDDEBUG + } +#endif dref = tpcb->tp_lref; sref = tpcb->tp_fref; - CHECK( (tpcb->tp_refstate == REF_FREE), - E_TP_MISM_REFS,ts_inv_dref, nonx_dref, - (1 + 2 + (caddr_t)&hdr->_tpduf - (caddr_t)hdr)) - goto tp0_data; + CHECK((tpcb->tp_refstate == REF_FREE), + E_TP_MISM_REFS, ts_inv_dref, nonx_dref, + (1 + 2 + (caddr_t) & hdr->_tpduf - (caddr_t) hdr)) + goto tp0_data; } - } #endif { - CHECK( ((int)dref <= 0 || dref >= tp_refinfo.tpr_size) , - E_TP_MISM_REFS,ts_inv_dref, nonx_dref, - (1 + 2 + (caddr_t)&hdr->_tpduf - (caddr_t)hdr)) - CHECK( ((tpcb = tp_ref[dref].tpr_pcb ) == (struct tp_pcb *) 0 ), - E_TP_MISM_REFS,ts_inv_dref, nonx_dref, - (1 + 2 + (caddr_t)&hdr->_tpduf - (caddr_t)hdr)) - CHECK( (tpcb->tp_refstate == REF_FREE), - E_TP_MISM_REFS,ts_inv_dref, nonx_dref, - (1 + 2 + (caddr_t)&hdr->_tpduf - (caddr_t)hdr)) + CHECK(((int) dref <= 0 || dref >= tp_refinfo.tpr_size), + E_TP_MISM_REFS, ts_inv_dref, nonx_dref, + (1 + 2 + (caddr_t) & hdr->_tpduf - (caddr_t) hdr)) + CHECK(((tpcb = tp_ref[dref].tpr_pcb) == (struct tp_pcb *) 0), + E_TP_MISM_REFS, ts_inv_dref, nonx_dref, + (1 + 2 + (caddr_t) & hdr->_tpduf - (caddr_t) hdr)) + CHECK((tpcb->tp_refstate == REF_FREE), + E_TP_MISM_REFS, ts_inv_dref, nonx_dref, + (1 + 2 + (caddr_t) & hdr->_tpduf - (caddr_t) hdr)) } - IFDEBUG(D_TPINPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { printf("HAVE A TPCB 2: 0x%x\n", tpcb); - ENDDEBUG + } +#endif /* causes a DR to be sent for CC; ER for all else */ - CHECK( (tpcb->tp_refstate == REF_FROZEN), - (dutype == CC_TPDU_type?E_TP_NO_SESSION:E_TP_MISM_REFS), - ts_inv_dref, respond, - (1 + 2 + (caddr_t)&hdr->_tpduf - (caddr_t)hdr)) - - IFDEBUG(D_TPINPUT) - printf("state of dref %d ok, tpcb 0x%x\n", dref,tpcb); - ENDDEBUG - /* - * At this point the state of the dref could be - * FROZEN: tpr_pcb == NULL, has ( reference only) timers - * for example, DC may arrive after the close() has detached - * the tpcb (e.g., if user turned off SO_LISTEN option) - * OPENING : a tpcb exists but no timers yet - * OPEN : tpcb exists & timers are outstanding + CHECK((tpcb->tp_refstate == REF_FROZEN), + (dutype == CC_TPDU_type ? E_TP_NO_SESSION : E_TP_MISM_REFS), + ts_inv_dref, respond, + (1 + 2 + (caddr_t) & hdr->_tpduf - (caddr_t) hdr)) +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { + printf("state of dref %d ok, tpcb 0x%x\n", dref, tpcb); + } +#endif + /* + * At this point the state of the dref could be FROZEN: + * tpr_pcb == NULL, has ( reference only) timers for + * example, DC may arrive after the close() has detached the + * tpcb (e.g., if user turned off SO_LISTEN option) OPENING : + * a tpcb exists but no timers yet OPEN : tpcb exists & + * timers are outstanding */ - if (!tpcb->tp_cebit_off) - CONG_UPDATE_SAMPLE(tpcb, ce_bit); + if (!tpcb->tp_cebit_off) + CONG_UPDATE_SAMPLE(tpcb, ce_bit); dusize = tpcb->tp_tpdusize; pdusize = tpcb->tp_ptpdusize; - dutype = hdr->tpdu_type << 8; /* for the switch below */ - - WHILE_OPTIONS(P, hdr, tpcb->tp_xtd_format) /* { */ + dutype = hdr->tpdu_type << 8; /* for the switch below */ + WHILE_OPTIONS(P, hdr, tpcb->tp_xtd_format) /* { */ #define caseof(x,y) case (((x)<<8)+(y)) - switch( dutype | vbptr(P)->tpv_code ) { + switch (dutype | vbptr(P)->tpv_code) { - caseof( CC_TPDU_type, TPP_addl_opt ): - /* not in class 0; 1 octet */ - vb_getval(P, u_char, addlopt); - break; - caseof( CC_TPDU_type, TPP_tpdu_size ): - { - u_char odusize = dusize; - vb_getval(P, u_char, dusize); - CHECK( (dusize < TP_MIN_TPDUSIZE || - dusize > TP_MAX_TPDUSIZE || dusize > odusize), - E_TP_INV_PVAL, ts_inv_pval, respond, - (1 + (caddr_t)&vbptr(P)->tpv_val - (caddr_t)hdr) ) - IFDEBUG(D_TPINPUT) - printf("CC dusize 0x%x\n", dusize); - ENDDEBUG + caseof(CC_TPDU_type, TPP_addl_opt): + /* not in class 0; 1 octet */ + vb_getval(P, u_char, addlopt); + break; + caseof(CC_TPDU_type, TPP_tpdu_size): + { + u_char odusize = dusize; + vb_getval(P, u_char, dusize); + CHECK((dusize < TP_MIN_TPDUSIZE || + dusize > TP_MAX_TPDUSIZE || dusize > odusize), + E_TP_INV_PVAL, ts_inv_pval, respond, + (1 + (caddr_t) & vbptr(P)->tpv_val - (caddr_t) hdr)) +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { + printf("CC dusize 0x%x\n", dusize); } +#endif + } + break; + caseof(CC_TPDU_type, TPP_ptpdu_size): + { + u_short opdusize = pdusize; + switch (vbptr(P)->tpv_len) { + case 1: + pdusize = vbval(P, u_char); break; - caseof( CC_TPDU_type, TPP_ptpdu_size ): - { - u_short opdusize = pdusize; - switch (vbptr(P)->tpv_len) { - case 1: pdusize = vbval(P, u_char); break; - case 2: pdusize = ntohs(vbval(P, u_short)); break; - default: ; - IFDEBUG(D_TPINPUT) + case 2: + pdusize = ntohs(vbval(P, u_short)); + break; + default:; +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { printf("malformed prefered TPDU option\n"); - ENDDEBUG } - CHECK( (pdusize == 0 || - (opdusize && (pdusize > opdusize))), - E_TP_INV_PVAL, ts_inv_pval, respond, - (1 + (caddr_t)&vbptr(P)->tpv_val - (caddr_t)hdr) ) +#endif } - break; - caseof( CC_TPDU_type, TPP_calling_sufx): - IFDEBUG(D_TPINPUT) - printf("CC calling (local) sufxlen 0x%x\n", lsufxlen); - ENDDEBUG - lsufxloc = (caddr_t) &vbptr(P)->tpv_val; - lsufxlen = vbptr(P)->tpv_len; - break; - caseof( CC_TPDU_type, TPP_acktime ): - /* class 4 only, 2 octets */ - vb_getval(P, u_short, acktime); - acktime = ntohs(acktime); - acktime = acktime/500; /* convert to slowtimo ticks */ - if( (short)acktime <=0 ) - acktime = 2; - break; - caseof( CC_TPDU_type, TPP_called_sufx): - fsufxloc = (caddr_t) &vbptr(P)->tpv_val; - fsufxlen = vbptr(P)->tpv_len; - IFDEBUG(D_TPINPUT) - printf("CC called (foreign) sufx len %d\n", fsufxlen); - ENDDEBUG - break; + CHECK((pdusize == 0 || + (opdusize && (pdusize > opdusize))), + E_TP_INV_PVAL, ts_inv_pval, respond, + (1 + (caddr_t) & vbptr(P)->tpv_val - (caddr_t) hdr)) + } + break; + caseof(CC_TPDU_type, TPP_calling_sufx): +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { + printf("CC calling (local) sufxlen 0x%x\n", lsufxlen); + } +#endif + lsufxloc = (caddr_t) & vbptr(P)->tpv_val; + lsufxlen = vbptr(P)->tpv_len; + break; + caseof(CC_TPDU_type, TPP_acktime): + /* class 4 only, 2 octets */ + vb_getval(P, u_short, acktime); + acktime = ntohs(acktime); + acktime = acktime / 500; /* convert to slowtimo + * ticks */ + if ((short) acktime <= 0) + acktime = 2; + break; + caseof(CC_TPDU_type, TPP_called_sufx): + fsufxloc = (caddr_t) & vbptr(P)->tpv_val; + fsufxlen = vbptr(P)->tpv_len; +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { + printf("CC called (foreign) sufx len %d\n", fsufxlen); + } +#endif + break; - caseof( CC_TPDU_type, TPP_checksum): - caseof( DR_TPDU_type, TPP_checksum): - caseof( DT_TPDU_type, TPP_checksum): - caseof( XPD_TPDU_type, TPP_checksum): - if( tpcb->tp_use_checksum ) { - CHECK( iso_check_csum(m, tpdu_len), - E_TP_INV_PVAL, ts_bad_csum, discard, 0) - } - break; + caseof(CC_TPDU_type, TPP_checksum): + caseof(DR_TPDU_type, TPP_checksum): + caseof(DT_TPDU_type, TPP_checksum): + caseof(XPD_TPDU_type, TPP_checksum): + if (tpcb->tp_use_checksum) { + CHECK(iso_check_csum(m, tpdu_len), + E_TP_INV_PVAL, ts_bad_csum, discard, 0) + } + break; - /* this is different from the above because in the context - * of concat/ sep tpdu_len might not be the same as hdr len + /* + * this is different from the above because in the + * context of concat/ sep tpdu_len might not be the + * same as hdr len */ - caseof( AK_TPDU_type, TPP_checksum): - caseof( XAK_TPDU_type, TPP_checksum): - caseof( DC_TPDU_type, TPP_checksum): - if( tpcb->tp_use_checksum ) { - CHECK( iso_check_csum(m, (int)hdr->tpdu_li + 1), - E_TP_INV_PVAL, ts_bad_csum, discard, 0) - } - break; + caseof(AK_TPDU_type, TPP_checksum): + caseof(XAK_TPDU_type, TPP_checksum): + caseof(DC_TPDU_type, TPP_checksum): + if (tpcb->tp_use_checksum) { + CHECK(iso_check_csum(m, (int) hdr->tpdu_li + 1), + E_TP_INV_PVAL, ts_bad_csum, discard, 0) + } + break; #ifdef notdef - caseof( DR_TPDU_type, TPP_addl_info ): - /* ignore - its length and meaning are - * user defined and there's no way - * to pass this info to the user anyway - */ - break; -#endif /* notdef */ - - caseof( AK_TPDU_type, TPP_subseq ): - /* used after reduction of window */ - vb_getval(P, u_short, subseq); - subseq = ntohs(subseq); - IFDEBUG(D_ACKRECV) - printf("AK dref 0x%x Subseq 0x%x\n", dref, subseq); - ENDDEBUG - break; + caseof(DR_TPDU_type, TPP_addl_info): + /* + * ignore - its length and meaning are user defined + * and there's no way to pass this info to the user + * anyway + */ + break; +#endif /* notdef */ - caseof( AK_TPDU_type, TPP_flow_cntl_conf ): - { - u_int ylwe; - u_short ysubseq, ycredit; - - fcc_present = TRUE; - vb_getval(P, u_int, ylwe); - vb_getval(P, u_short, ysubseq); - vb_getval(P, u_short, ycredit); - ylwe = ntohl(ylwe); - ysubseq = ntohs(ysubseq); - ycredit = ntohs(ycredit); - IFDEBUG(D_ACKRECV) - printf("%s%x, subseq 0x%x, cdt 0x%x dref 0x%x\n", - "AK FCC lwe 0x", ylwe, ysubseq, ycredit, dref); - ENDDEBUG + caseof(AK_TPDU_type, TPP_subseq): + /* used after reduction of window */ + vb_getval(P, u_short, subseq); + subseq = ntohs(subseq); +#ifdef ARGO_DEBUG + if (argo_debug[D_ACKRECV]) { + printf("AK dref 0x%x Subseq 0x%x\n", dref, subseq); + } +#endif + break; + + caseof(AK_TPDU_type, TPP_flow_cntl_conf): + { + u_int ylwe; + u_short ysubseq, ycredit; + + fcc_present = TRUE; + vb_getval(P, u_int, ylwe); + vb_getval(P, u_short, ysubseq); + vb_getval(P, u_short, ycredit); + ylwe = ntohl(ylwe); + ysubseq = ntohs(ysubseq); + ycredit = ntohs(ycredit); +#ifdef ARGO_DEBUG + if (argo_debug[D_ACKRECV]) { + printf("%s%x, subseq 0x%x, cdt 0x%x dref 0x%x\n", + "AK FCC lwe 0x", ylwe, ysubseq, ycredit, dref); } - break; +#endif + } + break; - default: - IFDEBUG(D_TPINPUT) - printf("param ignored dutype 0x%x, code 0x%x\n", - dutype, vbptr(P)->tpv_code); - ENDDEBUG - IFTRACE(D_TPINPUT) - tptrace(TPPTmisc, "param ignored dutype code ", - dutype, vbptr(P)->tpv_code ,0,0); - ENDTRACE - IncStat(ts_param_ignored); - break; + default: +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { + printf("param ignored dutype 0x%x, code 0x%x\n", + dutype, vbptr(P)->tpv_code); + } +#endif +#ifdef TPPT + if (tp_traceflags[D_TPINPUT]) { + tptrace(TPPTmisc, "param ignored dutype code ", + dutype, vbptr(P)->tpv_code, 0, 0); + } +#endif + IncStat(ts_param_ignored); + break; #undef caseof } - /* } */ END_WHILE_OPTIONS(P) - + /* } */ END_WHILE_OPTIONS(P) /* NOTE: the variable dutype has been shifted left! */ - switch( hdr->tpdu_type ) { - case CC_TPDU_type: - /* If CC comes back with an unacceptable class + switch (hdr->tpdu_type) { + case CC_TPDU_type: + /* + * If CC comes back with an unacceptable class * respond with a DR or ER */ - opt = hdr->tpdu_CCoptions; /* 1 byte */ + opt = hdr->tpdu_CCoptions; /* 1 byte */ { tpp = tpcb->_tp_param; - tpp.p_class = (1<<hdr->tpdu_CCclass); + tpp.p_class = (1 << hdr->tpdu_CCclass); tpp.p_tpdusize = dusize; tpp.p_ptpdusize = pdusize; tpp.p_dont_change_params = 0; @@ -1139,67 +1256,71 @@ again: tpp.p_use_efc = (opt & TPO_USE_EFC) == TPO_USE_EFC; tpp.p_use_nxpd = (addlopt & TPAO_USE_NXPD) == TPAO_USE_NXPD; tpp.p_use_rcc = (addlopt & TPAO_USE_RCC) == TPAO_USE_RCC; -#endif /* notdef */ +#endif /* notdef */ - CHECK( - tp_consistency(tpcb, TP_FORCE, &tpp) != 0, - E_TP_NEGOT_FAILED, ts_negotfailed, respond, - (1 + 2 + (caddr_t)&hdr->_tpdufr.CRCC - (caddr_t)hdr) - /* ^ more or less the location of class */ - ) - IFTRACE(D_CONN) - tptrace(TPPTmisc, - "after 1 consist class, out, tpconsout", - tpcb->tp_class, dgout_routine, tpcons_output, 0 + CHECK( + tp_consistency(tpcb, TP_FORCE, &tpp) != 0, + E_TP_NEGOT_FAILED, ts_negotfailed, respond, + (1 + 2 + (caddr_t) & hdr->_tpdufr.CRCC - (caddr_t) hdr) + /* ^ more or less the location of class */ + ) +#ifdef TPPT + if (tp_traceflags[D_CONN]) { + tptrace(TPPTmisc, + "after 1 consist class, out, tpconsout", + tpcb->tp_class, dgout_routine, tpcons_output, 0 ); - ENDTRACE - CHECK( - ((class_to_use == TP_CLASS_0)&& - (dgout_routine != tpcons_output)), - E_TP_NEGOT_FAILED, ts_negotfailed, respond, - (1 + 2 + (caddr_t)&hdr->_tpdufr.CRCC - (caddr_t)hdr) - /* ^ more or less the location of class */ - ) + } +#endif + CHECK( + ((class_to_use == TP_CLASS_0) && + (dgout_routine != tpcons_output)), + E_TP_NEGOT_FAILED, ts_negotfailed, respond, + (1 + 2 + (caddr_t) & hdr->_tpdufr.CRCC - (caddr_t) hdr) + /* ^ more or less the location of class */ + ) #ifdef TPCONS - if (tpcb->tp_netservice == ISO_CONS && - class_to_use == TP_CLASS_0) { - struct isopcb *isop = (struct isopcb *)tpcb->tp_npcb; - struct pklcd *lcp = (struct pklcd *)isop->isop_chan; + if (tpcb->tp_netservice == ISO_CONS && + class_to_use == TP_CLASS_0) { + struct isopcb *isop = (struct isopcb *) tpcb->tp_npcb; + struct pklcd *lcp = (struct pklcd *) isop->isop_chan; lcp->lcd_flags &= ~X25_DG_CIRCUIT; } #endif } - if( ! tpcb->tp_use_checksum) + if (!tpcb->tp_use_checksum) IncStat(ts_csum_off); - if(tpcb->tp_xpd_service) + if (tpcb->tp_xpd_service) IncStat(ts_use_txpd); - if(tpcb->tp_xtd_format) + if (tpcb->tp_xtd_format) IncStat(ts_xtd_fmt); - IFTRACE(D_CONN) +#ifdef TPPT + if (tp_traceflags[D_CONN]) { tptrace(TPPTmisc, "after CC class flags dusize CCclass", - tpcb->tp_class, tpcb->tp_flags, tpcb->tp_tpdusize, + tpcb->tp_class, tpcb->tp_flags, tpcb->tp_tpdusize, hdr->tpdu_CCclass); - ENDTRACE + } +#endif - /* if called or calling suffices appeared on the CC, + /* + * if called or calling suffices appeared on the CC, * they'd better jive with what's in the pcb */ - if( fsufxlen ) { - CHECK( ((tpcb->tp_fsuffixlen != fsufxlen) || - bcmp(fsufxloc, tpcb->tp_fsuffix, fsufxlen)), - E_TP_INV_PVAL,ts_inv_sufx, respond, - (1+fsufxloc - (caddr_t)hdr)) + if (fsufxlen) { + CHECK(((tpcb->tp_fsuffixlen != fsufxlen) || + bcmp(fsufxloc, tpcb->tp_fsuffix, fsufxlen)), + E_TP_INV_PVAL, ts_inv_sufx, respond, + (1 + fsufxloc - (caddr_t) hdr)) } - if( lsufxlen ) { - CHECK( ((tpcb->tp_lsuffixlen != lsufxlen) || - bcmp(lsufxloc, tpcb->tp_lsuffix, lsufxlen)), - E_TP_INV_PVAL,ts_inv_sufx, respond, - (1+lsufxloc - (caddr_t)hdr)) + if (lsufxlen) { + CHECK(((tpcb->tp_lsuffixlen != lsufxlen) || + bcmp(lsufxloc, tpcb->tp_lsuffix, lsufxlen)), + E_TP_INV_PVAL, ts_inv_sufx, respond, + (1 + lsufxloc - (caddr_t) hdr)) } - - e.ATTR(CC_TPDU).e_sref = sref; - e.ATTR(CC_TPDU).e_cdt = hdr->tpdu_CCcdt; + e.TPDU_ATTR(CC).e_sref = sref; + e.TPDU_ATTR(CC).e_cdt = hdr->tpdu_CCcdt; takes_data = TRUE; e.ev_number = CC_TPDU; IncStat(ts_CC_rcvd); @@ -1208,107 +1329,110 @@ again: case DC_TPDU_type: if (sref != tpcb->tp_fref) printf("INPUT: inv sufx DCsref 0x%x, tp_fref 0x%x\n", - sref, tpcb->tp_fref); - - CHECK( (sref != tpcb->tp_fref), - E_TP_MISM_REFS, ts_inv_sufx, discard, - (1 + (caddr_t)&hdr->tpdu_DCsref - (caddr_t)hdr)) - - e.ev_number = DC_TPDU; + sref, tpcb->tp_fref); + + CHECK((sref != tpcb->tp_fref), + E_TP_MISM_REFS, ts_inv_sufx, discard, + (1 + (caddr_t) & hdr->tpdu_DCsref - (caddr_t) hdr)) + e.ev_number = DC_TPDU; IncStat(ts_DC_rcvd); break; - case DR_TPDU_type: - IFTRACE(D_TPINPUT) + case DR_TPDU_type: +#ifdef TPPT + if (tp_traceflags[D_TPINPUT]) { tptrace(TPPTmisc, "DR recvd", hdr->tpdu_DRreason, 0, 0, 0); - ENDTRACE - if (sref != tpcb->tp_fref) { + } +#endif + if (sref != tpcb->tp_fref) { printf("INPUT: inv sufx DRsref 0x%x tp_fref 0x%x\n", - sref, tpcb->tp_fref); + sref, tpcb->tp_fref); } - - CHECK( (sref != 0 && sref != tpcb->tp_fref && - tpcb->tp_state != TP_CRSENT), - (TP_ERROR_SNDC | E_TP_MISM_REFS),ts_inv_sufx, respond, - (1 + (caddr_t)&hdr->tpdu_DRsref - (caddr_t)hdr)) - - e.ATTR(DR_TPDU).e_reason = hdr->tpdu_DRreason; - e.ATTR(DR_TPDU).e_sref = (u_short)sref; + CHECK((sref != 0 && sref != tpcb->tp_fref && + tpcb->tp_state != TP_CRSENT), + (TP_ERROR_SNDC | E_TP_MISM_REFS), ts_inv_sufx, respond, + (1 + (caddr_t) & hdr->tpdu_DRsref - (caddr_t) hdr)) + e.TPDU_ATTR(DR).e_reason = hdr->tpdu_DRreason; + e.TPDU_ATTR(DR).e_sref = (u_short) sref; takes_data = TRUE; e.ev_number = DR_TPDU; IncStat(ts_DR_rcvd); break; case ER_TPDU_type: - IFTRACE(D_TPINPUT) - tptrace(TPPTmisc, "ER recvd", hdr->tpdu_ERreason,0,0,0); - ENDTRACE - e.ev_number = ER_TPDU; - e.ATTR(ER_TPDU).e_reason = hdr->tpdu_ERreason; +#ifdef TPPT + if (tp_traceflags[D_TPINPUT]) { + tptrace(TPPTmisc, "ER recvd", hdr->tpdu_ERreason, 0, 0, 0); + } +#endif + e.ev_number = ER_TPDU; + e.TPDU_ATTR(ER).e_reason = hdr->tpdu_ERreason; IncStat(ts_ER_rcvd); break; - case AK_TPDU_type: + case AK_TPDU_type: - e.ATTR(AK_TPDU).e_subseq = subseq; - e.ATTR(AK_TPDU).e_fcc_present = fcc_present; + e.TPDU_ATTR(AK).e_subseq = subseq; + e.TPDU_ATTR(AK).e_fcc_present = fcc_present; if (tpcb->tp_xtd_format) { #ifdef BYTE_ORDER - union seq_type seqeotX; + union seq_type seqeotX; seqeotX.s_seqeot = ntohl(hdr->tpdu_seqeotX); - e.ATTR(AK_TPDU).e_seq = seqeotX.s_seq; - e.ATTR(AK_TPDU).e_cdt = ntohs(hdr->tpdu_AKcdtX); + e.TPDU_ATTR(AK).e_seq = seqeotX.s_seq; + e.TPDU_ATTR(AK).e_cdt = ntohs(hdr->tpdu_AKcdtX); #else - e.ATTR(AK_TPDU).e_cdt = hdr->tpdu_AKcdtX; - e.ATTR(AK_TPDU).e_seq = hdr->tpdu_AKseqX; -#endif /* BYTE_ORDER */ + e.TPDU_ATTR(AK).e_cdt = hdr->tpdu_AKcdtX; + e.TPDU_ATTR(AK).e_seq = hdr->tpdu_AKseqX; +#endif /* BYTE_ORDER */ } else { - e.ATTR(AK_TPDU).e_cdt = hdr->tpdu_AKcdt; - e.ATTR(AK_TPDU).e_seq = hdr->tpdu_AKseq; + e.TPDU_ATTR(AK).e_cdt = hdr->tpdu_AKcdt; + e.TPDU_ATTR(AK).e_seq = hdr->tpdu_AKseq; } - IFTRACE(D_TPINPUT) - tptrace(TPPTmisc, "AK recvd seq cdt subseq fcc_pres", - e.ATTR(AK_TPDU).e_seq, e.ATTR(AK_TPDU).e_cdt, +#ifdef TPPT + if (tp_traceflags[D_TPINPUT]) { + tptrace(TPPTmisc, "AK recvd seq cdt subseq fcc_pres", + e.TPDU_ATTR(AK).e_seq, e.TPDU_ATTR(AK).e_cdt, subseq, fcc_present); - ENDTRACE + } +#endif - e.ev_number = AK_TPDU; + e.ev_number = AK_TPDU; IncStat(ts_AK_rcvd); IncPStat(tpcb, tps_AK_rcvd); break; - case XAK_TPDU_type: + case XAK_TPDU_type: if (tpcb->tp_xtd_format) { #ifdef BYTE_ORDER - union seq_type seqeotX; + union seq_type seqeotX; seqeotX.s_seqeot = ntohl(hdr->tpdu_seqeotX); - e.ATTR(XAK_TPDU).e_seq = seqeotX.s_seq; + e.TPDU_ATTR(XAK).e_seq = seqeotX.s_seq; #else - e.ATTR(XAK_TPDU).e_seq = hdr->tpdu_XAKseqX; -#endif /* BYTE_ORDER */ + e.TPDU_ATTR(XAK).e_seq = hdr->tpdu_XAKseqX; +#endif /* BYTE_ORDER */ } else { - e.ATTR(XAK_TPDU).e_seq = hdr->tpdu_XAKseq; + e.TPDU_ATTR(XAK).e_seq = hdr->tpdu_XAKseq; } e.ev_number = XAK_TPDU; IncStat(ts_XAK_rcvd); IncPStat(tpcb, tps_XAK_rcvd); break; - case XPD_TPDU_type: + case XPD_TPDU_type: if (tpcb->tp_xtd_format) { #ifdef BYTE_ORDER - union seq_type seqeotX; + union seq_type seqeotX; seqeotX.s_seqeot = ntohl(hdr->tpdu_seqeotX); - e.ATTR(XPD_TPDU).e_seq = seqeotX.s_seq; + e.TPDU_ATTR(XPD).e_seq = seqeotX.s_seq; #else - e.ATTR(XPD_TPDU).e_seq = hdr->tpdu_XPDseqX; -#endif /* BYTE_ORDER */ + e.TPDU_ATTR(XPD).e_seq = hdr->tpdu_XPDseqX; +#endif /* BYTE_ORDER */ } else { - e.ATTR(XPD_TPDU).e_seq = hdr->tpdu_XPDseq; + e.TPDU_ATTR(XPD).e_seq = hdr->tpdu_XPDseq; } takes_data = TRUE; e.ev_number = XPD_TPDU; @@ -1317,37 +1441,43 @@ again: break; case DT_TPDU_type: - { /* the y option will cause occasional packets to be dropped. - * A little crude but it works. - */ - - IFDEBUG(D_DROP) - if(time.tv_usec & 0x4 && hdr->tpdu_DTseq & 0x1) { - IncStat(ts_ydebug); - goto discard; - } - ENDDEBUG + /* + * the y option will cause occasional packets + * to be dropped. A little crude but it + * works. + */ + +#ifdef ARGO_DEBUG + if (argo_debug[D_DROP]) { + if (time.tv_usec & 0x4 && + hdr->tpdu_DTseq & 0x1) { + IncStat(ts_ydebug); + goto discard; + } } +#endif if (tpcb->tp_class == TP_CLASS_0) { - tp0_data: - e.ATTR(DT_TPDU).e_seq = 0; /* actually don't care */ - e.ATTR(DT_TPDU).e_eot = (((struct tp0du *)hdr)->tp0du_eot); +#ifdef TPCONS + tp0_data: +#endif + e.TPDU_ATTR(DT).e_seq = 0; /* actually don't care */ + e.TPDU_ATTR(DT).e_eot = (((struct tp0du *) hdr)->tp0du_eot); } else if (tpcb->tp_xtd_format) { #ifdef BYTE_ORDER - union seq_type seqeotX; + union seq_type seqeotX; seqeotX.s_seqeot = ntohl(hdr->tpdu_seqeotX); - e.ATTR(DT_TPDU).e_seq = seqeotX.s_seq; - e.ATTR(DT_TPDU).e_eot = seqeotX.s_eot; + e.TPDU_ATTR(DT).e_seq = seqeotX.s_seq; + e.TPDU_ATTR(DT).e_eot = seqeotX.s_eot; #else - e.ATTR(DT_TPDU).e_seq = hdr->tpdu_DTseqX; - e.ATTR(DT_TPDU).e_eot = hdr->tpdu_DTeotX; -#endif /* BYTE_ORDER */ + e.TPDU_ATTR(DT).e_seq = hdr->tpdu_DTseqX; + e.TPDU_ATTR(DT).e_eot = hdr->tpdu_DTeotX; +#endif /* BYTE_ORDER */ } else { - e.ATTR(DT_TPDU).e_seq = hdr->tpdu_DTseq; - e.ATTR(DT_TPDU).e_eot = hdr->tpdu_DTeot; + e.TPDU_ATTR(DT).e_seq = hdr->tpdu_DTseq; + e.TPDU_ATTR(DT).e_eot = hdr->tpdu_DTeot; } - if(e.ATTR(DT_TPDU).e_eot) + if (e.TPDU_ATTR(DT).e_eot) IncStat(ts_eot_input); takes_data = TRUE; e.ev_number = DT_TPDU; @@ -1355,43 +1485,47 @@ again: IncPStat(tpcb, tps_DT_rcvd); break; - case GR_TPDU_type: + case GR_TPDU_type: tp_indicate(T_DISCONNECT, tpcb, ECONNABORTED); /* drop through */ default: - /* this should NEVER happen because there is a - * check for dutype well above here + /* + * this should NEVER happen because there is a check + * for dutype well above here */ - error = E_TP_INV_TPDU; /* causes an ER */ - IFDEBUG(D_TPINPUT) + error = E_TP_INV_TPDU; /* causes an ER */ +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { printf("INVALID dutype 0x%x\n", hdr->tpdu_type); - ENDDEBUG + } +#endif IncStat(ts_inv_dutype); goto respond; } } - /* peel off the tp header; - * remember that the du_li doesn't count itself. - * This may leave us w/ an empty mbuf at the front of a chain. - * We can't just throw away the empty mbuf because hdr still points - * into the mbuf's data area and we're still using hdr (the tpdu header) + /* + * peel off the tp header; remember that the du_li doesn't count + * itself. This may leave us w/ an empty mbuf at the front of a + * chain. We can't just throw away the empty mbuf because hdr still + * points into the mbuf's data area and we're still using hdr (the + * tpdu header) */ - m->m_len -= ((int)hdr->tpdu_li + 1); - m->m_data += ((int)hdr->tpdu_li + 1); + m->m_len -= ((int) hdr->tpdu_li + 1); + m->m_data += ((int) hdr->tpdu_li + 1); if (takes_data) { - int max = tpdu_info[ hdr->tpdu_type ] [TP_MAX_DATA_INDEX]; - int datalen = tpdu_len - hdr->tpdu_li - 1, mbtype = MT_DATA; + int max = tpdu_info[hdr->tpdu_type][TP_MAX_DATA_INDEX]; + int datalen = tpdu_len - hdr->tpdu_li - 1, mbtype = MT_DATA; struct { struct tp_disc_reason dr; - struct cmsghdr x_hdr; - } x; + struct cmsghdr x_hdr; + } x; #define c_hdr x.x_hdr register struct mbuf *n; - CHECK( (max && datalen > max), E_TP_LENGTH_INVAL, - ts_inv_length, respond, (max + hdr->tpdu_li + 1) ); - switch( hdr->tpdu_type ) { + CHECK((max && datalen > max), E_TP_LENGTH_INVAL, + ts_inv_length, respond, (max + hdr->tpdu_li + 1)); + switch (hdr->tpdu_type) { case CR_TPDU_type: c_hdr.cmsg_type = TPOPT_CONN_DATA; @@ -1407,20 +1541,24 @@ again: x.dr.dr_hdr.cmsg_level = SOL_TRANSPORT; x.dr.dr_reason = hdr->tpdu_DRreason; c_hdr.cmsg_type = TPOPT_DISC_DATA; - make_control_msg: + make_control_msg: datalen += sizeof(c_hdr); c_hdr.cmsg_len = datalen; c_hdr.cmsg_level = SOL_TRANSPORT; mbtype = MT_CONTROL; MGET(n, M_DONTWAIT, MT_DATA); - if (n == 0) - {m_freem(m); m = 0; datalen = 0; goto invoke; } + if (n == 0) { + m_freem(m); + m = 0; + datalen = 0; + goto invoke; + } if (hdr->tpdu_type == DR_TPDU_type) { datalen += sizeof(x) - sizeof(c_hdr); - bcopy((caddr_t)&x, mtod(n, caddr_t), n->m_len = sizeof(x)); + bcopy((caddr_t) & x, mtod(n, caddr_t), n->m_len = sizeof(x)); } else - bcopy((caddr_t)&c_hdr, mtod(n, caddr_t), - n->m_len = sizeof(c_hdr)); + bcopy((caddr_t) & c_hdr, mtod(n, caddr_t), + n->m_len = sizeof(c_hdr)); n->m_next = m; m = n; /* FALLTHROUGH */ @@ -1432,106 +1570,125 @@ again: /* FALLTHROUGH */ case DT_TPDU_type: - for (n = m; n; n = n->m_next) { + for (n = m; n; n = n->m_next) { MCHTYPE(n, mbtype); } - invoke: - e.ATTR(DT_TPDU).e_datalen = datalen; - e.ATTR(DT_TPDU).e_data = m; + invoke: + e.TPDU_ATTR(DT).e_datalen = datalen; + e.TPDU_ATTR(DT).e_data = m; break; default: printf( - "ERROR in tp_input! hdr->tpdu_type 0x%x takes_data 0x%x m 0x%x\n", - hdr->tpdu_type, takes_data, m); + "ERROR in tp_input! hdr->tpdu_type 0x%x takes_data 0x%x m 0x%x\n", + hdr->tpdu_type, takes_data, m); break; } - /* prevent m_freem() after tp_driver() from throwing it all away */ + /* + * prevent m_freem() after tp_driver() from throwing it all + * away + */ m = MNULL; } - IncStat(ts_tpdu_rcvd); - IFDEBUG(D_TPINPUT) - printf( "tp_input: before driver, state 0x%x event 0x%x m 0x%x", - tpcb->tp_state, e.ev_number, m ); - printf(" e.e_data 0x%x\n", e.ATTR(DT_TPDU).e_data); +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { + printf("tp_input: before driver, state 0x%x event 0x%x m 0x%x", + tpcb->tp_state, e.ev_number, m); + printf(" e.e_data 0x%x\n", e.TPDU_ATTR(DT).e_data); printf("takes_data 0x%x m_len 0x%x, tpdu_len 0x%x\n", - takes_data, (m==MNULL)?0:m->m_len, tpdu_len); - ENDDEBUG + takes_data, (m == MNULL) ? 0 : m->m_len, tpdu_len); + } +#endif error = tp_driver(tpcb, &e); - ASSERT(tpcb != (struct tp_pcb *)0); - ASSERT(tpcb->tp_sock != (struct socket *)0); - if( tpcb->tp_sock->so_error == 0 ) + ASSERT(tpcb != (struct tp_pcb *) 0); + ASSERT(tpcb->tp_sock != (struct socket *) 0); + if (tpcb->tp_sock->so_error == 0) tpcb->tp_sock->so_error = error; - /* Kludge to keep the state tables under control (adding - * data on connect & disconnect & freeing the mbuf containing - * the data would have exploded the tables and made a big mess ). + /* + * Kludge to keep the state tables under control (adding data on + * connect & disconnect & freeing the mbuf containing the data would + * have exploded the tables and made a big mess ). */ - switch(e.ev_number) { - case CC_TPDU: - case DR_TPDU: - case CR_TPDU: - m = e.ATTR(CC_TPDU).e_data; /* same field for all three dutypes */ - IFDEBUG(D_TPINPUT) - printf("after driver, restoring m to 0x%x, takes_data 0x%x\n", - m, takes_data); - ENDDEBUG - break; - default: - break; + switch (e.ev_number) { + case CC_TPDU: + case DR_TPDU: + case CR_TPDU: + m = e.TPDU_ATTR(CC).e_data; /* same field for all three + * dutypes */ +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { + printf("after driver, restoring m to 0x%x, takes_data 0x%x\n", + m, takes_data); + } +#endif + break; + default: + break; } - /* Concatenated sequences are terminated by any tpdu that - * carries data: CR, CC, DT, XPD, DR. - * All other tpdu types may be concatenated: AK, XAK, DC, ER. + /* + * Concatenated sequences are terminated by any tpdu that carries + * data: CR, CC, DT, XPD, DR. All other tpdu types may be + * concatenated: AK, XAK, DC, ER. */ -separate: - if ( takes_data == 0 ) { - ASSERT( m != MNULL ); - /* - * we already peeled off the prev. tp header so - * we can just pull up some more and repeat + if (takes_data == 0) { + ASSERT(m != MNULL); + /* + * we already peeled off the prev. tp header so we can just + * pull up some more and repeat */ - if( m = tp_inputprep(m) ) { - IFDEBUG(D_TPINPUT) - hdr = mtod(m, struct tpdu *); - printf("tp_input @ separate: hdr 0x%x size %d m 0x%x\n", - hdr, (int) hdr->tpdu_li + 1, m); - dump_mbuf(m, "tp_input after driver, at separate"); - ENDDEBUG + if ((m = tp_inputprep(m)) != NULL) { +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { + hdr = mtod(m, struct tpdu *); + printf("tp_input @ separate: hdr 0x%x size %d m 0x%x\n", + hdr, (int) hdr->tpdu_li + 1, m); + dump_mbuf(m, "tp_input after driver, at separate"); + } +#endif IncStat(ts_concat_rcvd); goto again; } } - if ( m != MNULL ) { - IFDEBUG(D_TPINPUT) + if (m != MNULL) { +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { printf("tp_input : m_freem(0x%x)\n", m); - ENDDEBUG + } +#endif m_freem(m); - IFDEBUG(D_TPINPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { printf("tp_input : after m_freem 0x%x\n", m); - ENDDEBUG + } +#endif } return; discard: /* class 4: drop the tpdu */ - /* class 2,0: Should drop the net connection, if you can figure out + /* + * class 2,0: Should drop the net connection, if you can figure out * to which connection it applies */ - IFDEBUG(D_TPINPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { printf("tp_input DISCARD\n"); - ENDDEBUG - IFTRACE(D_TPINPUT) - tptrace(TPPTmisc, "tp_input DISCARD m", m,0,0,0); - ENDTRACE - m_freem(m); + } +#endif +#ifdef TPPT + if (tp_traceflags[D_TPINPUT]) { + tptrace(TPPTmisc, "tp_input DISCARD m", m, 0, 0, 0); + } +#endif + m_freem(m); IncStat(ts_recv_drop); return; @@ -1546,24 +1703,30 @@ nonx_dref: error |= TP_ERROR_SNDC; } respond: - IFDEBUG(D_TPINPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { printf("RESPOND: error 0x%x, errlen 0x%x\n", error, errlen); - ENDDEBUG - IFTRACE(D_TPINPUT) + } +#endif +#ifdef TPPT + if (tp_traceflags[D_TPINPUT]) { tptrace(TPPTmisc, "tp_input RESPOND m error sref", m, error, sref, 0); - ENDTRACE - if (sref == 0) + } +#endif + if (sref == 0) goto discard; - (void) tp_error_emit(error, (u_long)sref, satosiso(faddr), - satosiso(laddr), m, errlen, tpcb, - cons_channel, dgout_routine); - IFDEBUG(D_ERROR_EMIT) + (void) tp_error_emit(error, (u_long) sref, satosiso(faddr), + satosiso(laddr), m, errlen, tpcb, + cons_channel, dgout_routine); +#ifdef ARGO_DEBUG + if (argo_debug[D_ERROR_EMIT]) { printf("tp_input after error_emit\n"); - ENDDEBUG + } +#endif #ifdef lint - printf("",sref,opt); -#endif /* lint */ + printf("", sref, opt); +#endif /* lint */ IncStat(ts_recv_drop); } @@ -1577,44 +1740,46 @@ respond: * much data to put in each tpdu. * * FUNCTION, ARGUMENTS, and RETURN VALUE: - * For a given connection, represented by (tpcb), and + * For a given connection, represented by (tpcb), and * tpdu type (dutype), return the size of a tp header. * * RETURNS: the expected size of the heade in bytesr * - * SIDE EFFECTS: + * SIDE EFFECTS: * * NOTES: It would be nice if it got the network header size as well. */ int -tp_headersize(dutype, tpcb) - int dutype; - struct tp_pcb *tpcb; +tp_headersize(dutype, tpcb) + int dutype; + struct tp_pcb *tpcb; { - register int size = 0; + register int size = 0; - IFTRACE(D_CONN) +#ifdef TPPT + if (tp_traceflags[D_CONN]) { tptrace(TPPTmisc, "tp_headersize dutype class xtd_format", dutype, tpcb->tp_class, tpcb->tp_xtd_format, 0); - ENDTRACE - if( !( (tpcb->tp_class == TP_CLASS_0) || - (tpcb->tp_class == TP_CLASS_4) || - (dutype == DR_TPDU_type) || - (dutype == CR_TPDU_type) )) { - printf("tp_headersize:dutype 0x%x, class 0x%x", - dutype, tpcb->tp_class); - /* TODO: identify this and GET RID OF IT */ } - ASSERT( (tpcb->tp_class == TP_CLASS_0) || - (tpcb->tp_class == TP_CLASS_4) || - (dutype == DR_TPDU_type) || - (dutype == CR_TPDU_type) ); - - if( tpcb->tp_class == TP_CLASS_0 ) { - size = tpdu_info[ dutype ] [TP_LEN_CLASS_0_INDEX]; - } else { - size = tpdu_info[ dutype ] [tpcb->tp_xtd_format]; - } +#endif + if (!((tpcb->tp_class == TP_CLASS_0) || + (tpcb->tp_class == TP_CLASS_4) || + (dutype == DR_TPDU_type) || + (dutype == CR_TPDU_type))) { + printf("tp_headersize:dutype 0x%x, class 0x%x", + dutype, tpcb->tp_class); + /* TODO: identify this and GET RID OF IT */ + } + ASSERT((tpcb->tp_class == TP_CLASS_0) || + (tpcb->tp_class == TP_CLASS_4) || + (dutype == DR_TPDU_type) || + (dutype == CR_TPDU_type)); + + if (tpcb->tp_class == TP_CLASS_0) { + size = tpdu_info[dutype][TP_LEN_CLASS_0_INDEX]; + } else { + size = tpdu_info[dutype][tpcb->tp_xtd_format]; + } return size; /* caller must get network level header size separately */ } diff --git a/sys/netiso/tp_ip.h b/sys/netiso/tp_ip.h index 27662f590db..e3c953ad449 100644 --- a/sys/netiso/tp_ip.h +++ b/sys/netiso/tp_ip.h @@ -1,4 +1,5 @@ -/* $NetBSD: tp_ip.h,v 1.6 1995/06/13 07:58:19 mycroft Exp $ */ +/* $OpenBSD: tp_ip.h,v 1.2 1996/03/04 10:36:05 mickey Exp $ */ +/* $NetBSD: tp_ip.h,v 1.7 1996/02/13 22:11:12 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -61,7 +62,7 @@ SOFTWARE. /* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ -/* +/* * internet IP-dependent structures and include files */ @@ -81,6 +82,6 @@ SOFTWARE. struct inpcbtable tp_inpcb; - /* queue of active inpcbs for tp ; for tp with dod ip */ +/* queue of active inpcbs for tp ; for tp with dod ip */ -#endif /* _NETISO_TP_IP_H_ */ +#endif /* _NETISO_TP_IP_H_ */ diff --git a/sys/netiso/tp_iso.c b/sys/netiso/tp_iso.c index 8208d51f1a5..d9d0a452a06 100644 --- a/sys/netiso/tp_iso.c +++ b/sys/netiso/tp_iso.c @@ -1,4 +1,5 @@ -/* $NetBSD: tp_iso.c,v 1.6 1994/09/20 06:41:35 cgd Exp $ */ +/* $OpenBSD: tp_iso.c,v 1.2 1996/03/04 10:36:07 mickey Exp $ */ +/* $NetBSD: tp_iso.c,v 1.7 1996/02/13 22:11:15 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -61,25 +62,21 @@ SOFTWARE. /* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ -/* - * Here is where you find the iso-dependent code. We've tried - * keep all net-level and (primarily) address-family-dependent stuff - * out of the tp source, and everthing here is reached indirectly - * through a switch table (struct nl_protosw *) tpcb->tp_nlproto - * (see tp_pcb.c). - * The routines here are: - * iso_getsufx: gets transport suffix out of an isopcb structure. - * iso_putsufx: put transport suffix into an isopcb structure. - * iso_putnetaddr: put a whole net addr into an isopcb. - * iso_getnetaddr: get a whole net addr from an isopcb. - * iso_cmpnetaddr: compare a whole net addr from an isopcb. - * iso_recycle_suffix: clear suffix for reuse in isopcb - * tpclnp_ctlinput: handle ER CNLPdu : icmp-like stuff - * tpclnp_mtu: figure out what size tpdu to use - * tpclnp_input: take a pkt from clnp, strip off its clnp header, - * give to tp - * tpclnp_output_dg: package a pkt for clnp given 2 addresses & some data - * tpclnp_output: package a pkt for clnp given an isopcb & some data +/* + * Here is where you find the iso-dependent code. We've tried keep all + * net-level and (primarily) address-family-dependent stuff out of the tp + * source, and everthing here is reached indirectly through a switch table + * (struct nl_protosw *) tpcb->tp_nlproto (see tp_pcb.c). The routines here + * are: iso_getsufx: gets transport suffix out of an isopcb structure. + * iso_putsufx: put transport suffix into an isopcb structure. + * iso_putnetaddr: put a whole net addr into an isopcb. iso_getnetaddr: get a + * whole net addr from an isopcb. iso_cmpnetaddr: compare a whole net addr + * from an isopcb. iso_recycle_suffix: clear suffix for reuse in isopcb + * tpclnp_ctlinput: handle ER CNLPdu : icmp-like stuff tpclnp_mtu: figure out + * what size tpdu to use tpclnp_input: take a pkt from clnp, strip off its + * clnp header, give to tp tpclnp_output_dg: package a pkt for clnp given 2 + * addresses & some data tpclnp_output: package a pkt for clnp given an + * isopcb & some data */ #ifdef ISO @@ -93,6 +90,7 @@ SOFTWARE. #include <sys/errno.h> #include <sys/time.h> #include <sys/protosw.h> +#include <sys/systm.h> #include <sys/kernel.h> #include <net/if.h> @@ -106,9 +104,15 @@ SOFTWARE. #include <netiso/tp_stat.h> #include <netiso/tp_tpdu.h> #include <netiso/tp_clnp.h> +#include <netiso/tp_var.h> #include <netiso/cltp_var.h> +#include <netiso/idrp_var.h> + +#ifdef TUBA +#include <netiso/tuba_table.h> +#endif -void tpclnp_ctlinput(); +#include <machine/stdarg.h> /* * CALLED FROM: @@ -117,12 +121,14 @@ void tpclnp_ctlinput(); * The argument (which) takes the value TP_LOCAL or TP_FOREIGN. */ -iso_getsufx(isop, lenp, data_out, which) - struct isopcb *isop; - u_short *lenp; - caddr_t data_out; - int which; +void +iso_getsufx(v, lenp, data_out, which) + void *v; + u_short *lenp; + caddr_t data_out; + int which; { + struct isopcb *isop = v; register struct sockaddr_iso *addr = 0; switch (which) { @@ -137,24 +143,25 @@ iso_getsufx(isop, lenp, data_out, which) bcopy(TSEL(addr), data_out, (*lenp = addr->siso_tlen)); } -/* CALLED FROM: - * tp_newsocket(); i.e., when a connection is being established by an - * incoming CR_TPDU. +/* + * CALLED FROM: tp_newsocket(); i.e., when a connection is being established + * by an incoming CR_TPDU. * - * FUNCTION, ARGUMENTS: - * Put a transport suffix (found in name) into an isopcb structure (isop). - * The argument (which) takes the value TP_LOCAL or TP_FOREIGN. + * FUNCTION, ARGUMENTS: Put a transport suffix (found in name) into an isopcb + * structure (isop). The argument (which) takes the value TP_LOCAL or + * TP_FOREIGN. */ void -iso_putsufx(isop, sufxloc, sufxlen, which) - struct isopcb *isop; - caddr_t sufxloc; - int sufxlen, which; +iso_putsufx(v, sufxloc, sufxlen, which) + void *v; + caddr_t sufxloc; + int sufxlen, which; { + struct isopcb *isop = v; struct sockaddr_iso **dst, *backup; register struct sockaddr_iso *addr; - struct mbuf *m; - int len; + struct mbuf *m; + int len; switch (which) { default: @@ -177,15 +184,15 @@ iso_putsufx(isop, sufxloc, sufxlen, which) printf("iso_putsufx on un-initialized isopcb\n"); } len = sufxlen + addr->siso_nlen + - (sizeof(*addr) - sizeof(addr->siso_data)); + (sizeof(*addr) - sizeof(addr->siso_data)); if (addr == backup) { if (len > sizeof(*addr)) { - m = m_getclr(M_DONTWAIT, MT_SONAME); - if (m == 0) - return; - addr = *dst = mtod(m, struct sockaddr_iso *); - *addr = *backup; - m->m_len = len; + m = m_getclr(M_DONTWAIT, MT_SONAME); + if (m == 0) + return; + addr = *dst = mtod(m, struct sockaddr_iso *); + *addr = *backup; + m->m_len = len; } } bcopy(sufxloc, TSEL(addr), sufxlen); @@ -197,7 +204,7 @@ iso_putsufx(isop, sufxloc, sufxlen, which) * CALLED FROM: * tp.trans whenever we go into REFWAIT state. * FUNCTION and ARGUMENT: - * Called when a ref is frozen, to allow the suffix to be reused. + * Called when a ref is frozen, to allow the suffix to be reused. * (isop) is the net level pcb. This really shouldn't have to be * done in a NET level pcb but... for the internet world that just * the way it is done in BSD... @@ -205,9 +212,10 @@ iso_putsufx(isop, sufxloc, sufxlen, which) * timer goes off. */ void -iso_recycle_tsuffix(isop) - struct isopcb *isop; +iso_recycle_tsuffix(v) + void *v; { + struct isopcb *isop = v; isop->isop_laddr->siso_tlen = isop->isop_faddr->siso_tlen = 0; } @@ -220,13 +228,15 @@ iso_recycle_tsuffix(isop) * Copy a whole net addr from a struct sockaddr (name). * into an isopcb (isop). * The argument (which) takes values TP_LOCAL or TP_FOREIGN - */ + */ void -iso_putnetaddr(isop, name, which) - register struct isopcb *isop; - struct sockaddr_iso *name; - int which; +iso_putnetaddr(v, nm, which) + register void *v; + struct sockaddr *nm; + int which; { + register struct isopcb *isop = v; + struct sockaddr_iso *name = (struct sockaddr_iso *) nm; struct sockaddr_iso **sisop, *backup; register struct sockaddr_iso *siso; @@ -243,10 +253,12 @@ iso_putnetaddr(isop, name, which) backup = &isop->isop_sfaddr; } siso = ((*sisop == 0) ? (*sisop = backup) : *sisop); - IFDEBUG(D_TPISO) +#ifdef ARGO_DEBUG + if (argo_debug[D_TPISO]) { printf("ISO_PUTNETADDR\n"); dump_isoaddr(isop->isop_faddr); - ENDDEBUG + } +#endif siso->siso_addr = name->siso_addr; } @@ -259,12 +271,15 @@ iso_putnetaddr(isop, name, which) * compare a whole net addr from a struct sockaddr (name), * with that implicitly stored in an isopcb (isop). * The argument (which) takes values TP_LOCAL or TP_FOREIGN. - */ -iso_cmpnetaddr(isop, name, which) - register struct isopcb *isop; - register struct sockaddr_iso *name; - int which; + */ +int +iso_cmpnetaddr(v, nm, which) + register void *v; + struct sockaddr *nm; + int which; { + register struct isopcb *isop = v; + struct sockaddr_iso *name = (struct sockaddr_iso *) nm; struct sockaddr_iso **sisop, *backup; register struct sockaddr_iso *siso; @@ -281,14 +296,16 @@ iso_cmpnetaddr(isop, name, which) backup = &isop->isop_sfaddr; } siso = ((*sisop == 0) ? (*sisop = backup) : *sisop); - IFDEBUG(D_TPISO) +#ifdef ARGO_DEBUG + if (argo_debug[D_TPISO]) { printf("ISO_CMPNETADDR\n"); dump_isoaddr(siso); - ENDDEBUG + } +#endif if (name->siso_tlen && bcmp(TSEL(name), TSEL(siso), name->siso_tlen)) return (0); - return (bcmp((caddr_t)name->siso_data, - (caddr_t)siso->siso_data, name->siso_nlen) == 0); + return (bcmp((caddr_t) name->siso_data, + (caddr_t) siso->siso_data, name->siso_nlen) == 0); } /* @@ -298,19 +315,21 @@ iso_cmpnetaddr(isop, name, which) * Copy a whole net addr from an isopcb (isop) into * a struct sockaddr (name). * The argument (which) takes values TP_LOCAL or TP_FOREIGN. - */ + */ void -iso_getnetaddr( isop, name, which) - struct isopcb *isop; - struct mbuf *name; - int which; +iso_getnetaddr(v, name, which) + register void *v; + struct mbuf *name; + int which; { + register struct inpcb *inp = v; + register struct isopcb *isop = (struct isopcb *) inp; struct sockaddr_iso *siso = - (which == TP_LOCAL ? isop->isop_laddr : isop->isop_faddr); + (which == TP_LOCAL ? isop->isop_laddr : isop->isop_faddr); if (siso) - bcopy((caddr_t)siso, mtod(name, caddr_t), - (unsigned)(name->m_len = siso->siso_len)); + bcopy((caddr_t) siso, mtod(name, caddr_t), + (unsigned) (name->m_len = siso->siso_len)); else name->m_len = 0; } @@ -326,20 +345,24 @@ iso_getnetaddr( isop, name, which) * It appears that setting a double pointer to the rtentry associated with * the destination, and returning the header size for the network protocol * suffices. - * + * * SIDE EFFECTS: * Sets tp_routep pointer in pcb. * * NOTES: */ -tpclnp_mtu(tpcb) -register struct tp_pcb *tpcb; +int +tpclnp_mtu(v) + void *v; { - struct isopcb *isop = (struct isopcb *)tpcb->tp_npcb; + register struct tp_pcb *tpcb = v; + struct isopcb *isop = (struct isopcb *) tpcb->tp_npcb; - IFDEBUG(D_CONN) +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("tpclnp_mtu(tpcb)\n", tpcb); - ENDDEBUG + } +#endif tpcb->tp_routep = &(isop->isop_route.ro_rt); if (tpcb->tp_netservice == ISO_CONS) return 0; @@ -363,30 +386,44 @@ register struct tp_pcb *tpcb; */ int -tpclnp_output(isop, m0, datalen, nochksum) - struct isopcb *isop; - struct mbuf *m0; - int datalen; - int nochksum; +#if __STDC__ +tpclnp_output(struct mbuf *m0, ...) +#else +tpclnp_output(m0, va_alist) + struct mbuf *m0; + va_dcl +#endif { - register struct mbuf *m = m0; + int datalen; + struct isopcb *isop; + int nochksum; + va_list ap; + + va_start(ap, m0); + datalen = va_arg(ap, int); + isop = va_arg(ap, struct isopcb *); + nochksum = va_arg(ap, int); + va_end(ap); + IncStat(ts_tpdu_sent); - IFDEBUG(D_TPISO) - struct tpdu *hdr = mtod(m0, struct tpdu *); +#ifdef ARGO_DEBUG + if (argo_debug[D_TPISO]) { + struct tpdu *hdr = mtod(m0, struct tpdu *); printf( -"abt to call clnp_output: datalen 0x%x, hdr.li 0x%x, hdr.dutype 0x%x nocsum x%x dst addr:\n", - datalen, - (int)hdr->tpdu_li, (int)hdr->tpdu_type, nochksum); + "abt to call clnp_output: datalen 0x%x, hdr.li 0x%x, hdr.dutype 0x%x nocsum x%x dst addr:\n", + datalen, + (int) hdr->tpdu_li, (int) hdr->tpdu_type, nochksum); dump_isoaddr(isop->isop_faddr); printf("\nsrc addr:\n"); dump_isoaddr(isop->isop_laddr); dump_mbuf(m0, "at tpclnp_output"); - ENDDEBUG + } +#endif - return - clnp_output(m0, isop, datalen, /* flags */nochksum ? CLNP_NO_CKSUM : 0); + return + clnp_output(m0, isop, datalen, /* flags */ nochksum ? CLNP_NO_CKSUM : 0); } /* @@ -402,79 +439,110 @@ tpclnp_output(isop, m0, datalen, nochksum) */ int -tpclnp_output_dg(laddr, faddr, m0, datalen, ro, nochksum) - struct iso_addr *laddr, *faddr; - struct mbuf *m0; - int datalen; - struct route *ro; - int nochksum; +#if __STDC__ +tpclnp_output_dg(struct mbuf *m0, ...) +#else +tpclnp_output_dg(m0, va_alist) + struct mbuf *m0; + va_dcl +#endif { - struct isopcb tmppcb; - int err; - int flags; - register struct mbuf *m = m0; - - IFDEBUG(D_TPISO) + struct isopcb tmppcb; + int err; + int flags; + int datalen; + struct iso_addr *laddr, *faddr; + struct route *ro; + int nochksum; + va_list ap; + + va_start(ap, m0); + datalen = va_arg(ap, int); + laddr = va_arg(ap, struct iso_addr *); + faddr = va_arg(ap, struct iso_addr *); + ro = va_arg(ap, struct route *); + nochksum = va_arg(ap, int); + va_end(ap); + +#ifdef ARGO_DEBUG + if (argo_debug[D_TPISO]) { printf("tpclnp_output_dg datalen 0x%x m0 0x%x\n", datalen, m0); - ENDDEBUG + } +#endif /* * Fill in minimal portion of isopcb so that clnp can send the * packet. */ - bzero((caddr_t)&tmppcb, sizeof(tmppcb)); + bzero((caddr_t) & tmppcb, sizeof(tmppcb)); tmppcb.isop_laddr = &tmppcb.isop_sladdr; tmppcb.isop_laddr->siso_addr = *laddr; tmppcb.isop_faddr = &tmppcb.isop_sfaddr; tmppcb.isop_faddr->siso_addr = *faddr; - IFDEBUG(D_TPISO) +#ifdef ARGO_DEBUG + if (argo_debug[D_TPISO]) { printf("tpclnp_output_dg faddr: \n"); dump_isoaddr(&tmppcb.isop_sfaddr); printf("\ntpclnp_output_dg laddr: \n"); dump_isoaddr(&tmppcb.isop_sladdr); printf("\n"); - ENDDEBUG + } +#endif /* * Do not use packet cache since this is a one shot error packet */ - flags = (CLNP_NOCACHE|(nochksum?CLNP_NO_CKSUM:0)); + flags = (CLNP_NOCACHE | (nochksum ? CLNP_NO_CKSUM : 0)); IncStat(ts_tpdu_sent); - err = clnp_output(m0, &tmppcb, datalen, flags); - + err = clnp_output(m0, &tmppcb, datalen, flags); + /* * Free route allocated by clnp (if the route was indeed allocated) */ if (tmppcb.isop_route.ro_rt) RTFREE(tmppcb.isop_route.ro_rt); - - return(err); + + return (err); } /* * CALLED FROM: * clnp's input routine, indirectly through the protosw. * FUNCTION and ARGUMENTS: * Take a packet (m) from clnp, strip off the clnp header and give it to tp - * No return value. + * No return value. */ void -tpclnp_input(m, src, dst, clnp_len, ce_bit) - register struct mbuf *m; - struct sockaddr_iso *src, *dst; - int clnp_len, ce_bit; +#if __STDC__ +tpclnp_input(struct mbuf *m, ...) +#else +tpclnp_input(m, va_alist) + struct mbuf *m; + va_dcl +#endif { - struct mbuf *tp_inputprep(); - void tp_input(), cltp_input(), (*input)() = tp_input; + struct sockaddr_iso *src, *dst; + int clnp_len, ce_bit; + void (*input) __P((struct mbuf *, ...)) = tp_input; + va_list ap; + + va_start(ap, m); + src = va_arg(ap, struct sockaddr_iso *); + dst = va_arg(ap, struct sockaddr_iso *); + clnp_len = va_arg(ap, int); + ce_bit = va_arg(ap, int); + va_end(ap); IncStat(ts_pkt_rcvd); - IFDEBUG(D_TPINPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { printf("tpclnp_input: m 0x%x clnp_len 0x%x\n", m, clnp_len); dump_mbuf(m, "at tpclnp_input"); - ENDDEBUG + } +#endif /* * CLNP gives us an mbuf chain WITH the clnp header pulled up, * and the length of the clnp header. @@ -505,37 +573,48 @@ tpclnp_input(m, src, dst, clnp_len, ce_bit) if (mtod(m, u_char *)[1] == UD_TPDU_type) input = cltp_input; - IFDEBUG(D_TPINPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { dump_mbuf(m, "after tpclnp_input both pullups"); - ENDDEBUG + } +#endif - IFDEBUG(D_TPISO) - printf("calling %sinput : src 0x%x, dst 0x%x, src addr:\n", - (input == tp_input ? "tp_" : "clts_"), src, dst); +#ifdef ARGO_DEBUG + if (argo_debug[D_TPISO]) { + printf("calling %sinput : src 0x%x, dst 0x%x, src addr:\n", + (input == tp_input ? "tp_" : "clts_"), src, dst); dump_isoaddr(src); printf(" dst addr:\n"); dump_isoaddr(dst); - ENDDEBUG + } +#endif - (*input)(m, (struct sockaddr *)src, (struct sockaddr *)dst, 0, - tpclnp_output_dg, ce_bit); + (*input) (m, (struct sockaddr *) src, (struct sockaddr *) dst, 0, + tpclnp_output_dg, ce_bit); - IFDEBUG(D_QUENCH) - { - if(time.tv_usec & 0x4 && time.tv_usec & 0x40) { - printf("tpclnp_input: FAKING %s\n", - tp_stat.ts_pkt_rcvd & 0x1?"QUENCH":"QUENCH2"); +#ifdef ARGO_DEBUG + if (argo_debug[D_QUENCH]) {{ + if (time.tv_usec & 0x4 && time.tv_usec & 0x40) { + printf("tpclnp_input: FAKING %s\n", + tp_stat.ts_pkt_rcvd & 0x1 ? "QUENCH" : "QUENCH2"); if (tp_stat.ts_pkt_rcvd & 0x1) - tpclnp_ctlinput(PRC_QUENCH, &src); + tpclnp_ctlinput(PRC_QUENCH, + (struct sockaddr *) + &src, NULL); else - tpclnp_ctlinput(PRC_QUENCH2, &src); + tpclnp_ctlinput(PRC_QUENCH2, + (struct sockaddr *) + &src, NULL); } - } - ENDDEBUG + } + } +#endif } +/*ARGSUSED*/ void -iso_rtchange() +iso_rtchange(pcb) + struct isopcb *pcb; { } @@ -548,9 +627,9 @@ iso_rtchange() */ void tpiso_decbit(isop) - struct isopcb *isop; + struct isopcb *isop; { - tp_quench((struct tp_pcb *)isop->isop_socket->so_pcb, PRC_QUENCH2); + tp_quench((struct inpcb *) isop->isop_socket->so_pcb, PRC_QUENCH2); } /* * CALLED FROM: @@ -560,9 +639,9 @@ tpiso_decbit(isop) */ void tpiso_quench(isop) - struct isopcb *isop; + struct isopcb *isop; { - tp_quench((struct tp_pcb *)isop->isop_socket->so_pcb, PRC_QUENCH); + tp_quench((struct inpcb *) isop->isop_socket->so_pcb, PRC_QUENCH); } /* @@ -573,50 +652,53 @@ tpiso_quench(isop) * It either returns an error status to the user or * it causes all connections on this address to be aborted * by calling the appropriate xx_notify() routine. - * (cmd) is the type of ICMP error. + * (cmd) is the type of ICMP error. * (siso) is the address of the guy who sent the ER CLNPDU */ -void -tpclnp_ctlinput(cmd, siso) - int cmd; - struct sockaddr_iso *siso; +void * +tpclnp_ctlinput(cmd, saddr, dummy) + int cmd; + struct sockaddr *saddr; + void *dummy; { - extern u_char inetctlerrmap[]; - void tpiso_abort(), iso_rtchange(), tpiso_reset(), iso_pcbnotify(); + struct sockaddr_iso *siso = (struct sockaddr_iso *) saddr; + extern u_char inetctlerrmap[]; - IFDEBUG(D_TPINPUT) +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { printf("tpclnp_ctlinput1: cmd 0x%x addr: \n", cmd); dump_isoaddr(siso); - ENDDEBUG + } +#endif if (cmd < 0 || cmd > PRC_NCMDS) - return; + return NULL; if (siso->siso_family != AF_ISO) - return; + return NULL; switch (cmd) { - case PRC_QUENCH2: - iso_pcbnotify(&tp_isopcb, siso, 0, (int (*)())tpiso_decbit); - break; + case PRC_QUENCH2: + iso_pcbnotify(&tp_isopcb, siso, 0, tpiso_decbit); + break; - case PRC_QUENCH: - iso_pcbnotify(&tp_isopcb, siso, 0, (int (*)())tpiso_quench); - break; + case PRC_QUENCH: + iso_pcbnotify(&tp_isopcb, siso, 0, tpiso_quench); + break; - case PRC_TIMXCEED_REASS: - case PRC_ROUTEDEAD: - iso_pcbnotify(&tp_isopcb, siso, 0, tpiso_reset); - break; + case PRC_TIMXCEED_REASS: + case PRC_ROUTEDEAD: + iso_pcbnotify(&tp_isopcb, siso, 0, tpiso_reset); + break; - case PRC_HOSTUNREACH: - case PRC_UNREACH_NET: - case PRC_IFDOWN: - case PRC_HOSTDEAD: - iso_pcbnotify(&tp_isopcb, siso, - (int)inetctlerrmap[cmd], iso_rtchange); - break; + case PRC_HOSTUNREACH: + case PRC_UNREACH_NET: + case PRC_IFDOWN: + case PRC_HOSTDEAD: + iso_pcbnotify(&tp_isopcb, siso, + (int) inetctlerrmap[cmd], iso_rtchange); + break; - default: + default: /* case PRC_MSGSIZE: case PRC_UNREACH_HOST: @@ -631,9 +713,10 @@ tpclnp_ctlinput(cmd, siso) case PRC_TIMXCEED_INTRANS: case PRC_PARAMPROB: */ - iso_pcbnotify(&tp_isopcb, siso, (int)inetctlerrmap[cmd], tpiso_abort); + iso_pcbnotify(&tp_isopcb, siso, (int) inetctlerrmap[cmd], tpiso_abort); break; } + return NULL; } /* * XXX - Variant which is called by clnp_er.c with an isoaddr rather @@ -641,13 +724,14 @@ tpclnp_ctlinput(cmd, siso) */ static struct sockaddr_iso siso = {sizeof(siso), AF_ISO}; +void tpclnp_ctlinput1(cmd, isoa) - int cmd; + int cmd; struct iso_addr *isoa; { - bzero((caddr_t)&siso.siso_addr, sizeof(siso.siso_addr)); - bcopy((caddr_t)isoa, (caddr_t)&siso.siso_addr, isoa->isoa_len); - tpclnp_ctlinput(cmd, &siso); + bzero((caddr_t) & siso.siso_addr, sizeof(siso.siso_addr)); + bcopy((caddr_t) isoa, (caddr_t) & siso.siso_addr, isoa->isoa_len); + tpclnp_ctlinput(cmd, (struct sockaddr *) &siso, NULL); } /* @@ -664,27 +748,29 @@ tpclnp_ctlinput1(cmd, isoa) */ void tpiso_abort(isop) - struct isopcb *isop; + struct isopcb *isop; { struct tp_event e; - IFDEBUG(D_CONN) +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("tpiso_abort 0x%x\n", isop); - ENDDEBUG + } +#endif e.ev_number = ER_TPDU; - e.ATTR(ER_TPDU).e_reason = ECONNABORTED; - tp_driver((struct tp_pcb *)isop->isop_socket->so_pcb, &e); + e.TPDU_ATTR(ER).e_reason = ECONNABORTED; + tp_driver((struct tp_pcb *) isop->isop_socket->so_pcb, &e); } void tpiso_reset(isop) - struct isopcb *isop; + struct isopcb *isop; { struct tp_event e; e.ev_number = T_NETRESET; - tp_driver((struct tp_pcb *)isop->isop_socket->so_pcb, &e); + tp_driver((struct tp_pcb *) isop->isop_socket->so_pcb, &e); } -#endif /* ISO */ +#endif /* ISO */ diff --git a/sys/netiso/tp_meas.c b/sys/netiso/tp_meas.c index 53783cfc0dd..ccd438d75f3 100644 --- a/sys/netiso/tp_meas.c +++ b/sys/netiso/tp_meas.c @@ -1,4 +1,5 @@ -/* $NetBSD: tp_meas.c,v 1.6 1994/06/29 06:40:19 cgd Exp $ */ +/* $OpenBSD: tp_meas.c,v 1.2 1996/03/04 10:36:09 mickey Exp $ */ +/* $NetBSD: tp_meas.c,v 1.7 1996/02/13 22:11:18 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -75,8 +76,8 @@ SOFTWARE. extern struct timeval time; #ifdef TP_PERF_MEAS -int tp_Measn = 0; -struct tp_Meas tp_Meas[TPMEASN]; +int tp_Measn = 0; +struct tp_Meas tp_Meas[TPMEASN]; /* * NAME: tpmeas() @@ -88,24 +89,24 @@ struct tp_Meas tp_Meas[TPMEASN]; * stashes a performance-measurement event for the given reference (ref) * (kind) tells which kind of event, timev is the time to be stored * with this event, (seq), (win), and (size) are integers that usually - * refer to the sequence number, window number (on send) and + * refer to the sequence number, window number (on send) and * size of tpdu or window. * * RETURNS: Nada * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ void Tpmeas(ref, kind, timev, seq, win, size) - u_int ref; - u_int kind; - struct timeval *timev; - u_int seq, win, size; + u_int ref; + u_int kind; + struct timeval *timev; + u_int seq, win, size; { register struct tp_Meas *tpm; - static int mseq; + static int mseq; tpm = &tp_Meas[tp_Measn++]; tp_Measn %= TPMEASN; @@ -113,14 +114,14 @@ Tpmeas(ref, kind, timev, seq, win, size) tpm->tpm_kind = kind; tpm->tpm_tseq = mseq++; tpm->tpm_ref = ref; - if(kind == TPtime_from_ll) - bcopy((caddr_t)timev, (caddr_t)&tpm->tpm_time, sizeof(struct timeval)); + if (kind == TPtime_from_ll) + bcopy((caddr_t) timev, (caddr_t) & tpm->tpm_time, sizeof(struct timeval)); else - bcopy( (caddr_t)&time, - (caddr_t)&tpm->tpm_time, sizeof(struct timeval) ); + bcopy((caddr_t) & time, + (caddr_t) & tpm->tpm_time, sizeof(struct timeval)); tpm->tpm_seq = seq; tpm->tpm_window = win; tpm->tpm_size = size; } -#endif /* TP_PERF_MEAS */ +#endif /* TP_PERF_MEAS */ diff --git a/sys/netiso/tp_meas.h b/sys/netiso/tp_meas.h index db327405bf8..c22aedc404b 100644 --- a/sys/netiso/tp_meas.h +++ b/sys/netiso/tp_meas.h @@ -1,4 +1,5 @@ -/* $NetBSD: tp_meas.h,v 1.5 1994/06/29 06:40:22 cgd Exp $ */ +/* $OpenBSD: tp_meas.h,v 1.2 1996/03/04 10:36:11 mickey Exp $ */ +/* $NetBSD: tp_meas.h,v 1.6 1996/02/13 22:11:21 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -66,17 +67,17 @@ SOFTWARE. Tpmeas((u_int)(a), (u_int)(b), t, (u_int)(c), (u_int)(d), (u_int)(e)) struct tp_Meas { - int tpm_tseq; - u_char tpm_kind; - u_short tpm_ref; - u_short tpm_size; - u_short tpm_window; - u_int tpm_seq; - struct timeval tpm_time; + int tpm_tseq; + u_char tpm_kind; + u_short tpm_ref; + u_short tpm_size; + u_short tpm_window; + u_int tpm_seq; + struct timeval tpm_time; }; #define TPMEASN 4000 -extern int tp_Measn; +extern int tp_Measn; extern struct tp_Meas tp_Meas[]; /* @@ -84,13 +85,13 @@ extern struct tp_Meas tp_Meas[]; */ #define TPtime_from_session 0x01 #define TPtime_to_session 0x02 -#define TPtime_ack_rcvd 0x03 +#define TPtime_ack_rcvd 0x03 #define TPtime_ack_sent 0x04 #define TPtime_from_ll 0x05 #define TPtime_to_ll 0x06 -#define TPsbsend 0x07 +#define TPsbsend 0x07 #define TPtime_open 0x08 -#define TPtime_open_X 0x28 /* xtd format */ +#define TPtime_open_X 0x28 /* xtd format */ #define TPtime_close 0x09 -#endif /* TP_PERF_MEAS */ +#endif /* TP_PERF_MEAS */ diff --git a/sys/netiso/tp_output.c b/sys/netiso/tp_output.c index d6339d9414b..817405c596c 100644 --- a/sys/netiso/tp_output.c +++ b/sys/netiso/tp_output.c @@ -1,4 +1,5 @@ -/* $NetBSD: tp_output.c,v 1.10 1995/08/17 02:57:34 mycroft Exp $ */ +/* $OpenBSD: tp_output.c,v 1.2 1996/03/04 10:36:13 mickey Exp $ */ +/* $NetBSD: tp_output.c,v 1.11 1996/02/13 22:11:25 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -61,7 +62,7 @@ SOFTWARE. /* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ -/* +/* * In here is tp_ctloutput(), the guy called by [sg]etsockopt(), */ @@ -84,6 +85,7 @@ SOFTWARE. #include <netiso/argo_debug.h> #include <netiso/tp_pcb.h> #include <netiso/tp_trace.h> +#include <netiso/tp_var.h> #define TPDUSIZESHIFT 24 #define CLASSHIFT 16 @@ -102,8 +104,8 @@ SOFTWARE. * the input arguements iff no errors were encountered. * Strict means that no inconsistency will be tolerated. If it's * not used, checksum and tpdusize inconsistencies will be tolerated. - * The reason for this is that in some cases, when we're negotiating down - * from class 4, these options should be changed but should not + * The reason for this is that in some cases, when we're negotiating down + * from class 4, these options should be changed but should not * cause negotiation to fail. * * RETURNS @@ -113,80 +115,98 @@ SOFTWARE. */ int -tp_consistency( tpcb, cmd, param ) - u_int cmd; +tp_consistency(tpcb, cmd, param) + u_int cmd; struct tp_conn_param *param; - struct tp_pcb *tpcb; + struct tp_pcb *tpcb; { - register int error = EOK; - int class_to_use = tp_mask_to_num(param->p_class); - - IFTRACE(D_SETPARAMS) - tptrace(TPPTmisc, - "tp_consist enter class_to_use dontchange param.class cmd", - class_to_use, param->p_dont_change_params, param->p_class, cmd); - ENDTRACE - IFDEBUG(D_SETPARAMS) - printf("tp_consistency %s %s\n", - cmd& TP_FORCE? "TP_FORCE": "", - cmd& TP_STRICT? "TP_STRICT":""); - ENDDEBUG + register int error = EOK; + int class_to_use = tp_mask_to_num(param->p_class); + +#ifdef TPPT + if (tp_traceflags[D_SETPARAMS]) { + tptrace(TPPTmisc, + "tp_consist enter class_to_use dontchange param.class cmd", + class_to_use, param->p_dont_change_params, param->p_class, cmd); + } +#endif +#ifdef ARGO_DEBUG + if (argo_debug[D_SETPARAMS]) { + printf("tp_consistency %s %s\n", + cmd & TP_FORCE ? "TP_FORCE" : "", + cmd & TP_STRICT ? "TP_STRICT" : ""); + } +#endif if ((cmd & TP_FORCE) && (param->p_dont_change_params)) { cmd &= ~TP_FORCE; } - /* can switch net services within a domain, but - * cannot switch domains + /* + * can switch net services within a domain, but cannot switch domains */ - switch( param->p_netservice) { + switch (param->p_netservice) { case ISO_CONS: case ISO_CLNS: case ISO_COSNS: /* param->p_netservice in ISO DOMAIN */ - if(tpcb->tp_domain != AF_ISO ) { - error = EINVAL; goto done; + if (tpcb->tp_domain != AF_ISO) { + error = EINVAL; + goto done; } break; case IN_CLNS: /* param->p_netservice in INET DOMAIN */ - if( tpcb->tp_domain != AF_INET ) { - error = EINVAL; goto done; + if (tpcb->tp_domain != AF_INET) { + error = EINVAL; + goto done; } break; /* no others not possible-> netservice is a 2-bit field! */ } - IFDEBUG(D_SETPARAMS) - printf("p_class 0x%x, class_to_use 0x%x\n", param->p_class, - class_to_use); - ENDDEBUG - if((param->p_netservice > TP_MAX_NETSERVICES)){ - error = EINVAL; goto done; +#ifdef ARGO_DEBUG + if (argo_debug[D_SETPARAMS]) { + printf("p_class 0x%x, class_to_use 0x%x\n", param->p_class, + class_to_use); + } +#endif + if ((param->p_netservice > TP_MAX_NETSERVICES)) { + error = EINVAL; + goto done; + } + if ((param->p_class & TP_CLASSES_IMPLEMENTED) == 0) { + error = EINVAL; + goto done; } - if( (param->p_class & TP_CLASSES_IMPLEMENTED) == 0 ) { - error = EINVAL; goto done; - } - IFDEBUG(D_SETPARAMS) - printf("Nretrans 0x%x\n", param->p_Nretrans ); - ENDDEBUG - if( ( param->p_Nretrans < 1 ) || - (param->p_cr_ticks < 1) || (param->p_cc_ticks < 1) ) { - /* bad for any class because negot has to be done a la class 4 */ - error = EINVAL; goto done; +#ifdef ARGO_DEBUG + if (argo_debug[D_SETPARAMS]) { + printf("Nretrans 0x%x\n", param->p_Nretrans); } - IFDEBUG(D_SETPARAMS) - printf("use_csum 0x%x\n", param->p_use_checksum ); - printf("xtd_format 0x%x\n", param->p_xtd_format ); - printf("xpd_service 0x%x\n", param->p_xpd_service ); - printf("tpdusize 0x%x\n", param->p_tpdusize ); - printf("tpcb->flags 0x%x\n", tpcb->tp_flags ); - ENDDEBUG - switch( class_to_use ) { +#endif + if ((param->p_Nretrans < 1) || + (param->p_cr_ticks < 1) || (param->p_cc_ticks < 1)) { + /* + * bad for any class because negot has to be done a la class + * 4 + */ + error = EINVAL; + goto done; + } +#ifdef ARGO_DEBUG + if (argo_debug[D_SETPARAMS]) { + printf("use_csum 0x%x\n", param->p_use_checksum); + printf("xtd_format 0x%x\n", param->p_xtd_format); + printf("xpd_service 0x%x\n", param->p_xpd_service); + printf("tpdusize 0x%x\n", param->p_tpdusize); + printf("tpcb->flags 0x%x\n", tpcb->tp_flags); + } +#endif + switch (class_to_use) { case 0: /* do not use checksums, xtd format, or XPD */ - if( param->p_use_checksum | param->p_xtd_format | param->p_xpd_service ) { - if(cmd & TP_STRICT) { + if (param->p_use_checksum | param->p_xtd_format | param->p_xpd_service) { + if (cmd & TP_STRICT) { error = EINVAL; } else { param->p_use_checksum = 0; @@ -195,70 +215,74 @@ tp_consistency( tpcb, cmd, param ) } break; } - if (param->p_tpdusize < TP_MIN_TPDUSIZE) { - if(cmd & TP_STRICT) { + if (cmd & TP_STRICT) { error = EINVAL; } else { param->p_tpdusize = TP_MIN_TPDUSIZE; } break; } - if (param->p_tpdusize > TP0_TPDUSIZE) { + if (param->p_tpdusize > TP0_TPDUSIZE) { if (cmd & TP_STRICT) { - error = EINVAL; + error = EINVAL; } else { param->p_tpdusize = TP0_TPDUSIZE; } break; - } - + } /* connect/disc data not allowed for class 0 */ if (tpcb->tp_ucddata) { - if(cmd & TP_STRICT) { + if (cmd & TP_STRICT) { error = EINVAL; - } else if(cmd & TP_FORCE) { + } else if (cmd & TP_FORCE) { m_freem(tpcb->tp_ucddata); tpcb->tp_ucddata = 0; } } break; - + case 4: - IFDEBUG(D_SETPARAMS) - printf("dt_ticks 0x%x\n", param->p_dt_ticks ); - printf("x_ticks 0x%x\n", param->p_x_ticks ); - printf("dr_ticks 0x%x\n", param->p_dr_ticks ); - printf("keepalive 0x%x\n", param->p_keepalive_ticks ); - printf("sendack 0x%x\n", param->p_sendack_ticks ); - printf("inact 0x%x\n", param->p_inact_ticks ); - printf("ref 0x%x\n", param->p_ref_ticks ); - ENDDEBUG - if( (param->p_class & TP_CLASS_4 ) && ( - (param->p_dt_ticks < 1) || (param->p_dr_ticks < 1) || - (param->p_x_ticks < 1) || (param->p_keepalive_ticks < 1) || - (param->p_sendack_ticks < 1) || (param->p_ref_ticks < 1) || - (param->p_inact_ticks < 1) ) ) { +#ifdef ARGO_DEBUG + if (argo_debug[D_SETPARAMS]) { + printf("dt_ticks 0x%x\n", param->p_dt_ticks); + printf("x_ticks 0x%x\n", param->p_x_ticks); + printf("dr_ticks 0x%x\n", param->p_dr_ticks); + printf("keepalive 0x%x\n", param->p_keepalive_ticks); + printf("sendack 0x%x\n", param->p_sendack_ticks); + printf("inact 0x%x\n", param->p_inact_ticks); + printf("ref 0x%x\n", param->p_ref_ticks); + } +#endif + if ((param->p_class & TP_CLASS_4) && ( + (param->p_dt_ticks < 1) || (param->p_dr_ticks < 1) || + (param->p_x_ticks < 1) || (param->p_keepalive_ticks < 1) || + (param->p_sendack_ticks < 1) || (param->p_ref_ticks < 1) || + (param->p_inact_ticks < 1))) { + error = EINVAL; + break; + } +#ifdef ARGO_DEBUG + if (argo_debug[D_SETPARAMS]) { + printf("rx_strat 0x%x\n", param->p_rx_strat); + } +#endif + if (param->p_rx_strat > + (TPRX_USE_CW | TPRX_EACH | TPRX_FASTSTART)) { + if (cmd & TP_STRICT) { error = EINVAL; - break; - } - IFDEBUG(D_SETPARAMS) - printf("rx_strat 0x%x\n", param->p_rx_strat ); - ENDDEBUG - if(param->p_rx_strat > - ( TPRX_USE_CW | TPRX_EACH | TPRX_FASTSTART) ) { - if(cmd & TP_STRICT) { - error = EINVAL; - } else { - param->p_rx_strat = TPRX_USE_CW; - } - break; - } - IFDEBUG(D_SETPARAMS) - printf("ack_strat 0x%x\n", param->p_ack_strat ); - ENDDEBUG - if((param->p_ack_strat != 0) && (param->p_ack_strat != 1)) { - if(cmd & TP_STRICT) { + } else { + param->p_rx_strat = TPRX_USE_CW; + } + break; + } +#ifdef ARGO_DEBUG + if (argo_debug[D_SETPARAMS]) { + printf("ack_strat 0x%x\n", param->p_ack_strat); + } +#endif + if ((param->p_ack_strat != 0) && (param->p_ack_strat != 1)) { + if (cmd & TP_STRICT) { error = EINVAL; } else { param->p_ack_strat = TPACK_WINDOW; @@ -266,26 +290,26 @@ tp_consistency( tpcb, cmd, param ) break; } if (param->p_tpdusize < TP_MIN_TPDUSIZE) { - if(cmd & TP_STRICT) { + if (cmd & TP_STRICT) { error = EINVAL; } else { param->p_tpdusize = TP_MIN_TPDUSIZE; } break; } - if (param->p_tpdusize > TP_TPDUSIZE) { - if(cmd & TP_STRICT) { - error = EINVAL; + if (param->p_tpdusize > TP_TPDUSIZE) { + if (cmd & TP_STRICT) { + error = EINVAL; } else { param->p_tpdusize = TP_TPDUSIZE; } break; - } + } break; } - if ((error==0) && (cmd & TP_FORCE)) { - long dusize = ((long)param->p_ptpdusize) << 7; + if ((error == 0) && (cmd & TP_FORCE)) { + long dusize = ((long) param->p_ptpdusize) << 7; /* Enforce Negotation rules below */ tpcb->tp_class = param->p_class; if (tpcb->tp_use_checksum || param->p_use_checksum) @@ -298,26 +322,30 @@ tp_consistency( tpcb, cmd, param ) if (tpcb->tp_l_tpdusize > dusize) tpcb->tp_l_tpdusize = dusize; if (tpcb->tp_ptpdusize == 0 || - tpcb->tp_ptpdusize > param->p_ptpdusize) + tpcb->tp_ptpdusize > param->p_ptpdusize) tpcb->tp_ptpdusize = param->p_ptpdusize; } else { if (param->p_tpdusize != 0 && - tpcb->tp_tpdusize > param->p_tpdusize) + tpcb->tp_tpdusize > param->p_tpdusize) tpcb->tp_tpdusize = param->p_tpdusize; tpcb->tp_l_tpdusize = 1 << tpcb->tp_tpdusize; } } done: - IFTRACE(D_CONN) - tptrace(TPPTmisc, "tp_consist returns class xtdfmt cmd", +#ifdef TPPT + if (tp_traceflags[D_CONN]) { + tptrace(TPPTmisc, "tp_consist returns class xtdfmt cmd", error, tpcb->tp_class, tpcb->tp_xtd_format, cmd); - ENDTRACE - IFDEBUG(D_CONN) + } +#endif +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf( - "tp_consist rtns 0x%x class 0x%x xtd_fmt 0x%x cmd 0x%x\n", - error, tpcb->tp_class, tpcb->tp_xtd_format, cmd); - ENDDEBUG + "tp_consist rtns 0x%x class 0x%x xtd_fmt 0x%x cmd 0x%x\n", + error, tpcb->tp_class, tpcb->tp_xtd_format, cmd); + } +#endif return error; } @@ -325,7 +353,7 @@ done: * NAME: tp_ctloutput() * * CALLED FROM: - * [sg]etsockopt(), via so[sg]etopt(). + * [sg]etsockopt(), via so[sg]etopt(). * * FUNCTION and ARGUMENTS: * Implements the socket options at transport level. @@ -333,18 +361,18 @@ done: * (so) is the socket. * (level) is SOL_TRANSPORT (see ../sys/socket.h) * (optname) is the particular command or option to be set. - * (**mp) is an mbuf structure. + * (**mp) is an mbuf structure. * * RETURN VALUE: * ENOTSOCK if the socket hasn't got an associated tpcb - * EINVAL if + * EINVAL if * trying to set window too big - * trying to set illegal max tpdu size + * trying to set illegal max tpdu size * trying to set illegal credit fraction * trying to use unknown or unimplemented class of TP * structure passed to set timer values is wrong size - * illegal combination of command/GET-SET option, - * e.g., GET w/ TPOPT_CDDATA_CLEAR: + * illegal combination of command/GET-SET option, + * e.g., GET w/ TPOPT_CDDATA_CLEAR: * EOPNOTSUPP if the level isn't transport, or command is neither GET nor SET * or if the transport-specific command is not implemented * EISCONN if trying a command that isn't allowed after a connection @@ -359,32 +387,37 @@ done: */ int tp_ctloutput(cmd, so, level, optname, mp) - int cmd, level, optname; - struct socket *so; - struct mbuf **mp; + int cmd, level, optname; + struct socket *so; + struct mbuf **mp; { - struct tp_pcb *tpcb = sototpcb(so); - int s = splsoftnet(); - caddr_t value; - unsigned val_len; - int error = 0; - - IFTRACE(D_REQUEST) - tptrace(TPPTmisc, "tp_ctloutput cmd so optname mp", + struct tp_pcb *tpcb = sototpcb(so); + int s = splsoftnet(); + caddr_t value; + unsigned val_len; + int error = 0; + +#ifdef TPPT + if (tp_traceflags[D_REQUEST]) { + tptrace(TPPTmisc, "tp_ctloutput cmd so optname mp", cmd, so, optname, mp); - ENDTRACE - IFDEBUG(D_REQUEST) + } +#endif +#ifdef ARGO_DEBUG + if (argo_debug[D_REQUEST]) { printf( - "tp_ctloutput so 0x%x cmd 0x%x optname 0x%x, mp 0x%x *mp 0x%x tpcb 0x%x\n", - so, cmd, optname, mp, mp?*mp:0, tpcb); - ENDDEBUG - if( tpcb == (struct tp_pcb *)0 ) { - error = ENOTSOCK; goto done; + "tp_ctloutput so 0x%x cmd 0x%x optname 0x%x, mp 0x%x *mp 0x%x tpcb 0x%x\n", + so, cmd, optname, mp, mp ? *mp : 0, tpcb); + } +#endif + if (tpcb == (struct tp_pcb *) 0) { + error = ENOTSOCK; + goto done; } - if(*mp == MNULL) { + if (*mp == MNULL) { register struct mbuf *m; - MGET(m, M_DONTWAIT, TPMT_SONAME); /* does off, type, next */ + MGET(m, M_DONTWAIT, TPMT_SONAME); /* does off, type, next */ if (m == NULL) { splx(s); return ENOBUFS; @@ -393,22 +426,21 @@ tp_ctloutput(cmd, so, level, optname, mp) m->m_act = 0; *mp = m; } - /* * Hook so one can set network options via a tp socket. */ - if ( level == SOL_NETWORK ) { + if (level == SOL_NETWORK) { if ((tpcb->tp_nlproto == NULL) || (tpcb->tp_npcb == NULL)) error = ENOTSOCK; else if (tpcb->tp_nlproto->nlp_ctloutput == NULL) error = EOPNOTSUPP; else - return ((tpcb->tp_nlproto->nlp_ctloutput)(cmd, optname, - tpcb->tp_npcb, *mp)); + return ((tpcb->tp_nlproto->nlp_ctloutput) (cmd, optname, + tpcb->tp_npcb, *mp)); goto done; - } else if ( level == SOL_SOCKET) { + } else if (level == SOL_SOCKET) { if (optname == SO_RCVBUF && cmd == PRCO_SETOPT) { - u_long old_credit = tpcb->tp_maxlcredit; + u_long old_credit = tpcb->tp_maxlcredit; tp_rsyset(tpcb); if (tpcb->tp_rhiwat != so->so_rcv.sb_hiwat && tpcb->tp_state == TP_OPEN && @@ -418,46 +450,50 @@ tp_ctloutput(cmd, so, level, optname, mp) tpcb->tp_rhiwat = so->so_rcv.sb_hiwat; } goto done; - } else if ( level != SOL_TRANSPORT ) { - error = EOPNOTSUPP; goto done; - } + } else if (level != SOL_TRANSPORT) { + error = EOPNOTSUPP; + goto done; + } if (cmd != PRCO_GETOPT && cmd != PRCO_SETOPT) { - error = EOPNOTSUPP; goto done; - } - if ( so->so_error ) { - error = so->so_error; goto done; + error = EOPNOTSUPP; + goto done; } - - /* The only options allowed after connection is established - * are GET (anything) and SET DISC DATA and SET PERF MEAS + if (so->so_error) { + error = so->so_error; + goto done; + } + /* + * The only options allowed after connection is established are GET + * (anything) and SET DISC DATA and SET PERF MEAS */ - if ( ((so->so_state & SS_ISCONNECTING)||(so->so_state & SS_ISCONNECTED)) - && - (cmd == PRCO_SETOPT && - optname != TPOPT_DISC_DATA && - optname != TPOPT_CFRM_DATA && - optname != TPOPT_PERF_MEAS && - optname != TPOPT_CDDATA_CLEAR ) ) { - error = EISCONN; goto done; - } - /* The only options allowed after disconnection are GET DISC DATA, - * and TPOPT_PSTATISTICS - * and they're not allowed if the ref timer has gone off, because - * the tpcb is gone + if (((so->so_state & SS_ISCONNECTING) || (so->so_state & SS_ISCONNECTED)) + && + (cmd == PRCO_SETOPT && + optname != TPOPT_DISC_DATA && + optname != TPOPT_CFRM_DATA && + optname != TPOPT_PERF_MEAS && + optname != TPOPT_CDDATA_CLEAR)) { + error = EISCONN; + goto done; + } + /* + * The only options allowed after disconnection are GET DISC DATA, + * and TPOPT_PSTATISTICS and they're not allowed if the ref timer has + * gone off, because the tpcb is gone */ - if ((so->so_state & (SS_ISCONNECTED | SS_ISCONFIRMING)) == 0) { - if ( so->so_pcb == 0 ) { - error = ENOTCONN; goto done; + if ((so->so_state & (SS_ISCONNECTED | SS_ISCONFIRMING)) == 0) { + if (so->so_pcb == 0) { + error = ENOTCONN; + goto done; } - if ( (tpcb->tp_state == TP_REFWAIT || tpcb->tp_state == TP_CLOSING) && - (optname != TPOPT_DISC_DATA && optname != TPOPT_PSTATISTICS)) { - error = ENOTCONN; goto done; + if ((tpcb->tp_state == TP_REFWAIT || tpcb->tp_state == TP_CLOSING) && + (optname != TPOPT_DISC_DATA && optname != TPOPT_PSTATISTICS)) { + error = ENOTCONN; + goto done; } } - - value = mtod(*mp, caddr_t); /* it's aligned, don't worry, - * but lint complains about it - */ + value = mtod(*mp, caddr_t); /* it's aligned, don't worry, but + * lint complains about it */ val_len = (*mp)->m_len; switch (optname) { @@ -469,15 +505,15 @@ tp_ctloutput(cmd, so, level, optname, mp) if ((so->so_state & SS_PRIV) == 0) { error = EPERM; } else if (cmd != PRCO_SETOPT || tpcb->tp_state != TP_CLOSED || - (tpcb->tp_flags & TPF_GENERAL_ADDR) || - tpcb->tp_next == 0) + (tpcb->tp_flags & TPF_GENERAL_ADDR) || + tpcb->tp_next == 0) error = EINVAL; else { register struct tp_pcb *t; error = EADDRINUSE; for (t = tp_listeners; t; t = t->tp_nextlisten) if ((t->tp_flags & TPF_GENERAL_ADDR) == 0 && - t->tp_domain == tpcb->tp_domain) + t->tp_domain == tpcb->tp_domain) switch (tpcb->tp_domain) { default: goto done; @@ -490,7 +526,7 @@ tp_ctloutput(cmd, so, level, optname, mp) #ifdef ISO case AF_ISO: if (bcmp(ISOA(t).isoa_genaddr, ISOA(tpcb).isoa_genaddr, - ISOA(t).isoa_len) == 0) + ISOA(t).isoa_len) == 0) goto done; continue; #endif @@ -506,109 +542,119 @@ tp_ctloutput(cmd, so, level, optname, mp) break; case TPOPT_MY_TSEL: - if ( cmd == PRCO_GETOPT ) { - ASSERT( tpcb->tp_lsuffixlen <= MAX_TSAP_SEL_LEN ); - bcopy((caddr_t)tpcb->tp_lsuffix, value, tpcb->tp_lsuffixlen); + if (cmd == PRCO_GETOPT) { + ASSERT(tpcb->tp_lsuffixlen <= MAX_TSAP_SEL_LEN); + bcopy((caddr_t) tpcb->tp_lsuffix, value, tpcb->tp_lsuffixlen); (*mp)->m_len = tpcb->tp_lsuffixlen; - } else /* cmd == PRCO_SETOPT */ { - if( (val_len > MAX_TSAP_SEL_LEN) || (val_len <= 0 )) { + } else { /* cmd == PRCO_SETOPT */ + if ((val_len > MAX_TSAP_SEL_LEN) || (val_len <= 0)) { printf("val_len 0x%x (*mp)->m_len 0x%x\n", val_len, (*mp)); error = EINVAL; } else { - bcopy(value, (caddr_t)tpcb->tp_lsuffix, val_len); + bcopy(value, (caddr_t) tpcb->tp_lsuffix, val_len); tpcb->tp_lsuffixlen = val_len; } } break; case TPOPT_PEER_TSEL: - if ( cmd == PRCO_GETOPT ) { - ASSERT( tpcb->tp_fsuffixlen <= MAX_TSAP_SEL_LEN ); - bcopy((caddr_t)tpcb->tp_fsuffix, value, tpcb->tp_fsuffixlen); + if (cmd == PRCO_GETOPT) { + ASSERT(tpcb->tp_fsuffixlen <= MAX_TSAP_SEL_LEN); + bcopy((caddr_t) tpcb->tp_fsuffix, value, tpcb->tp_fsuffixlen); (*mp)->m_len = tpcb->tp_fsuffixlen; - } else /* cmd == PRCO_SETOPT */ { - if( (val_len > MAX_TSAP_SEL_LEN) || (val_len <= 0 )) { + } else { /* cmd == PRCO_SETOPT */ + if ((val_len > MAX_TSAP_SEL_LEN) || (val_len <= 0)) { printf("val_len 0x%x (*mp)->m_len 0x%x\n", val_len, (*mp)); - error = EINVAL; + error = EINVAL; } else { - bcopy(value, (caddr_t)tpcb->tp_fsuffix, val_len); + bcopy(value, (caddr_t) tpcb->tp_fsuffix, val_len); tpcb->tp_fsuffixlen = val_len; } } break; case TPOPT_FLAGS: - IFDEBUG(D_REQUEST) - printf("%s TPOPT_FLAGS value 0x%x *value 0x%x, flags 0x%x \n", - cmd==PRCO_GETOPT?"GET":"SET", - value, - *value, - tpcb->tp_flags); - ENDDEBUG - - if ( cmd == PRCO_GETOPT ) { - *(int *)value = (int)tpcb->tp_flags; +#ifdef ARGO_DEBUG + if (argo_debug[D_REQUEST]) { + printf("%s TPOPT_FLAGS value 0x%x *value 0x%x, flags 0x%x \n", + cmd == PRCO_GETOPT ? "GET" : "SET", + value, + *value, + tpcb->tp_flags); + } +#endif + + if (cmd == PRCO_GETOPT) { + *(int *) value = (int) tpcb->tp_flags; (*mp)->m_len = sizeof(u_int); - } else /* cmd == PRCO_SETOPT */ { - error = EINVAL; goto done; + } else { /* cmd == PRCO_SETOPT */ + error = EINVAL; + goto done; } break; case TPOPT_PARAMS: - /* This handles: - * timer values, - * class, use of transport expedited data, - * max tpdu size, checksum, xtd format and - * disconnect indications, and may get rid of connect/disc data + /* + * This handles: timer values, class, use of transport + * expedited data, max tpdu size, checksum, xtd format and + * disconnect indications, and may get rid of connect/disc + * data */ - IFDEBUG(D_SETPARAMS) +#ifdef ARGO_DEBUG + if (argo_debug[D_SETPARAMS]) { printf("TPOPT_PARAMS value 0x%x, cmd %s \n", value, - cmd==PRCO_GETOPT?"GET":"SET"); - ENDDEBUG - IFDEBUG(D_REQUEST) + cmd == PRCO_GETOPT ? "GET" : "SET"); + } +#endif +#ifdef ARGO_DEBUG + if (argo_debug[D_REQUEST]) { printf("TPOPT_PARAMS value 0x%x, cmd %s \n", value, - cmd==PRCO_GETOPT?"GET":"SET"); - ENDDEBUG + cmd == PRCO_GETOPT ? "GET" : "SET"); + } +#endif - if ( cmd == PRCO_GETOPT ) { - *(struct tp_conn_param *)value = tpcb->_tp_param; + if (cmd == PRCO_GETOPT) { + *(struct tp_conn_param *) value = tpcb->_tp_param; (*mp)->m_len = sizeof(tpcb->_tp_param); - } else /* cmd == PRCO_SETOPT */ { - if( (error = - tp_consistency(tpcb, TP_STRICT | TP_FORCE, - (struct tp_conn_param *)value))==0) { - /* - * tp_consistency doesn't copy the whole set of params + } else { /* cmd == PRCO_SETOPT */ + if ((error = + tp_consistency(tpcb, TP_STRICT | TP_FORCE, + (struct tp_conn_param *) value)) == 0) { + /* + * tp_consistency doesn't copy the whole set + * of params */ - tpcb->_tp_param = *(struct tp_conn_param *)value; + tpcb->_tp_param = *(struct tp_conn_param *) value; (*mp)->m_len = sizeof(tpcb->_tp_param); } } break; - case TPOPT_PSTATISTICS: + case TPOPT_PSTATISTICS: #ifdef TP_PERF_MEAS if (cmd == PRCO_SETOPT) { - error = EINVAL; goto done; - } - IFPERF(tpcb) + error = EINVAL; + goto done; + } + if (tpcb->tp_perf_on) { MCLGET(*mp, M_WAITOK); if (((*mp)->m_flags & M_EXT) == 0) { error = ENOBUFS; goto done; } (*mp)->m_len = sizeof(struct tp_pmeas); bcopy(tpcb->tp_p_meas, mtod(*mp), sizeof(struct tp_pmeas)); - ENDPERF + } else { - error = EINVAL; goto done; - } + error = EINVAL; + goto done; + } break; #else error = EOPNOTSUPP; goto done; -#endif /* TP_PERF_MEAS */ - - case TPOPT_CDDATA_CLEAR: +#endif /* TP_PERF_MEAS */ + + case TPOPT_CDDATA_CLEAR: if (cmd == PRCO_GETOPT) { error = EINVAL; } else { @@ -620,86 +666,98 @@ tp_ctloutput(cmd, so, level, optname, mp) break; case TPOPT_CFRM_DATA: - case TPOPT_DISC_DATA: - case TPOPT_CONN_DATA: - if( tpcb->tp_class == TP_CLASS_0 ) { + case TPOPT_DISC_DATA: + case TPOPT_CONN_DATA: + if (tpcb->tp_class == TP_CLASS_0) { error = EOPNOTSUPP; break; } - IFDEBUG(D_REQUEST) - printf("%s\n", optname==TPOPT_DISC_DATA?"DISC data":"CONN data"); - printf("m_len 0x%x, vallen 0x%x so_snd.cc 0x%x\n", - (*mp)->m_len, val_len, so->so_snd.sb_cc); +#ifdef ARGO_DEBUG + if (argo_debug[D_REQUEST]) { + printf("%s\n", optname == TPOPT_DISC_DATA ? "DISC data" : "CONN data"); + printf("m_len 0x%x, vallen 0x%x so_snd.cc 0x%x\n", + (*mp)->m_len, val_len, so->so_snd.sb_cc); dump_mbuf(so->so_snd.sb_mb, "tp_ctloutput: sosnd "); - ENDDEBUG + } +#endif if (cmd == PRCO_SETOPT) { - int len = tpcb->tp_ucddata ? tpcb->tp_ucddata->m_len : 0; + int len = tpcb->tp_ucddata ? tpcb->tp_ucddata->m_len : 0; /* can append connect data in several calls */ - if (len + val_len > - (optname==TPOPT_CONN_DATA?TP_MAX_CR_DATA:TP_MAX_DR_DATA) ) { - error = EMSGSIZE; goto done; - } + if (len + val_len > + (optname == TPOPT_CONN_DATA ? TP_MAX_CR_DATA : TP_MAX_DR_DATA)) { + error = EMSGSIZE; + goto done; + } (*mp)->m_next = MNULL; (*mp)->m_act = 0; if (tpcb->tp_ucddata) m_cat(tpcb->tp_ucddata, *mp); else tpcb->tp_ucddata = *mp; - IFDEBUG(D_REQUEST) +#ifdef ARGO_DEBUG + if (argo_debug[D_REQUEST]) { dump_mbuf(tpcb->tp_ucddata, "tp_ctloutput after CONN_DATA"); - ENDDEBUG - IFTRACE(D_REQUEST) - tptrace(TPPTmisc,"C/D DATA: flags snd.sbcc val_len", - tpcb->tp_flags, so->so_snd.sb_cc,val_len,0); - ENDTRACE + } +#endif +#ifdef TPPT + if (tp_traceflags[D_REQUEST]) { + tptrace(TPPTmisc, "C/D DATA: flags snd.sbcc val_len", + tpcb->tp_flags, so->so_snd.sb_cc, val_len, 0); + } +#endif *mp = MNULL; if (optname == TPOPT_CFRM_DATA && (so->so_state & SS_ISCONFIRMING)) (void) tp_confirm(tpcb); } break; - case TPOPT_PERF_MEAS: + case TPOPT_PERF_MEAS: #ifdef TP_PERF_MEAS if (cmd == PRCO_GETOPT) { - *value = (u_int)tpcb->tp_perf_on; + *value = (u_int) tpcb->tp_perf_on; (*mp)->m_len = sizeof(u_int); } else if (cmd == PRCO_SETOPT) { (*mp)->m_len = 0; - if ((*value) != 0 && (*value) != 1 ) + if ((*value) != 0 && (*value) != 1) error = EINVAL; - else tpcb->tp_perf_on = (*value); + else + tpcb->tp_perf_on = (*value); } - if( tpcb->tp_perf_on ) + if (tpcb->tp_perf_on) error = tp_setup_perf(tpcb); -#else /* TP_PERF_MEAS */ +#else /* TP_PERF_MEAS */ error = EOPNOTSUPP; -#endif /* TP_PERF_MEAS */ +#endif /* TP_PERF_MEAS */ break; default: error = EOPNOTSUPP; } - + done: - IFDEBUG(D_REQUEST) +#ifdef ARGO_DEBUG + if (argo_debug[D_REQUEST]) { dump_mbuf(so->so_snd.sb_mb, "tp_ctloutput sosnd at end"); dump_mbuf(*mp, "tp_ctloutput *mp"); - ENDDEBUG - /* - * sigh: getsockopt looks only at m_len : all output data must - * reside in the first mbuf + } +#endif + /* + * sigh: getsockopt looks only at m_len : all output data must reside + * in the first mbuf */ if (*mp) { if (cmd == PRCO_SETOPT) { m_freem(*mp); *mp = MNULL; } else { - ASSERT ( m_compress(*mp, mp) <= MLEN ); + ASSERT(m_compress(*mp, mp) <= MLEN); if (error) (*mp)->m_len = 0; - IFDEBUG(D_REQUEST) +#ifdef ARGO_DEBUG + if (argo_debug[D_REQUEST]) { dump_mbuf(*mp, "tp_ctloutput *mp after compress"); - ENDDEBUG + } +#endif } } splx(s); diff --git a/sys/netiso/tp_param.h b/sys/netiso/tp_param.h index 7bd87cc5f0d..41dac3afc44 100644 --- a/sys/netiso/tp_param.h +++ b/sys/netiso/tp_param.h @@ -1,4 +1,5 @@ -/* $NetBSD: tp_param.h,v 1.8 1995/06/13 07:13:44 mycroft Exp $ */ +/* $OpenBSD: tp_param.h,v 1.2 1996/03/04 10:36:16 mickey Exp $ */ +/* $NetBSD: tp_param.h,v 1.9 1996/02/13 22:11:32 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -69,13 +70,13 @@ SOFTWARE. * compile time parameters that can be changed *****************************************************/ -#define TP_CLASSES_IMPLEMENTED 0x11 /* zero and 4 */ +#define TP_CLASSES_IMPLEMENTED 0x11 /* zero and 4 */ #define TP_DECBIT_CLEAR_COUNT 3 -/*#define N_TPREF 100 */ +/* #define N_TPREF 100 */ #ifdef _KERNEL -extern int N_TPREF; +extern int N_TPREF; #endif #define TP_SOCKBUFSIZE ((u_long)4096) @@ -83,29 +84,31 @@ extern int N_TPREF; #define MAX_TSAP_SEL_LEN 64 /* maximum tpdu size we'll accept: */ -#define TP_TPDUSIZE 0xc /* 4096 octets for classes 1-4*/ -#define TP0_TPDUSIZE 0xb /* 2048 octets for class 0 */ -#define TP_DFL_TPDUSIZE 0x7 /* 128 octets default */ - /* NOTE: don't ever negotiate 8192 because could get - * wraparound in checksumming - * (No mtu is likely to be larger than 4K anyway...) - */ -#define TP_NRETRANS 12 /* TCP_MAXRXTSHIFT + 1 */ -#define TP_MAXRXTSHIFT 6 /* factor of 64 */ +#define TP_TPDUSIZE 0xc /* 4096 octets for + * classes 1-4 */ +#define TP0_TPDUSIZE 0xb /* 2048 octets for class 0 */ +#define TP_DFL_TPDUSIZE 0x7 /* 128 octets default */ +/* + * NOTE: don't ever negotiate 8192 because could get wraparound in + * checksumming (No mtu is likely to be larger than 4K anyway...) + */ +#define TP_NRETRANS 12 /* TCP_MAXRXTSHIFT + 1 */ +#define TP_MAXRXTSHIFT 6 /* factor of 64 */ #define TP_MAXPORT 0xefff -/* ALPHA: to be used in the context: gain= 1/(2**alpha), or - * put another way, gaintimes(x) (x)>>alpha (forgetting the case alpha==0) +/* + * ALPHA: to be used in the context: gain= 1/(2**alpha), or put another way, + * gaintimes(x) (x)>>alpha (forgetting the case alpha==0) */ -#define TP_RTT_ALPHA 3 +#define TP_RTT_ALPHA 3 #define TP_RTV_ALPHA 2 #define TP_REXMTVAL(tpcb)\ - ((tp_rttadd + (tpcb)->tp_rtt + ((tpcb)->tp_rtv) << 2) / tp_rttdiv) + (((tp_rttadd + (tpcb)->tp_rtt + ((tpcb)->tp_rtv)) << 2) / tp_rttdiv) #define TP_RANGESET(tv, value, min, max) \ ((tv = value) > (max) ? (tv = max) : (tv < min ? tv = min : tv)) /* - * not sure how to treat data on disconnect + * not sure how to treat data on disconnect */ #define T_CONN_DATA 0x1 #define T_DISCONNECT 0x2 @@ -138,15 +141,15 @@ extern int N_TPREF; #define ACK_REORDER (1<< _ACK_REORDER_) /****************************************************** - * constants used in the protocol + * constants used in the protocol *****************************************************/ #define TP_VERSION 0x1 #define TP_MAX_HEADER_LEN 256 -#define TP_MIN_TPDUSIZE 0x7 /* 128 octets */ -#define TP_MAX_TPDUSIZE 0xd /* 8192 octets */ +#define TP_MIN_TPDUSIZE 0x7 /* 128 octets */ +#define TP_MAX_TPDUSIZE 0xd /* 8192 octets */ #define TP_MAX_XPD_DATA 0x10 /* 16 octets */ #define TP_MAX_CC_DATA 0x20 /* 32 octets */ @@ -158,15 +161,15 @@ extern int N_TPREF; #define TP_NML_FMT_BIT 0x80 #define TP_NML_FMT_MASK 0x7f -/* - * values for the tpdu_type field, 2nd byte in a tpdu +/* + * values for the tpdu_type field, 2nd byte in a tpdu */ #define TP_MIN_TPDUTYPE 0x1 #define XPD_TPDU_type 0x1 #define XAK_TPDU_type 0x2 -#define GR_TPDU_type 0x3 +#define GR_TPDU_type 0x3 #define AK_TPDU_type 0x6 #define ER_TPDU_type 0x7 #define DR_TPDU_type 0x8 @@ -178,7 +181,7 @@ extern int N_TPREF; #define TP_MAX_TPDUTYPE 0xf /* - * identifiers for the variable-length options in tpdus + * identifiers for the variable-length options in tpdus */ #define TPP_acktime 0x85 @@ -191,14 +194,16 @@ extern int N_TPREF; #define TPP_addl_info 0xe0 #define TPP_tpdu_size 0xc0 #define TPP_calling_sufx 0xc1 -#define TPP_invalid_tpdu 0xc1 /* the bozos used a value twice */ +#define TPP_invalid_tpdu 0xc1 /* the bozos used a value + * twice */ #define TPP_called_sufx 0xc2 #define TPP_checksum 0xc3 #define TPP_vers 0xc4 #define TPP_security 0xc5 #define TPP_addl_opt 0xc6 #define TPP_alt_class 0xc7 -#define TPP_perf_meas 0xc8 /* local item : perf meas on, svp */ +#define TPP_perf_meas 0xc8 /* local item : perf meas on, + * svp */ #define TPP_ptpdu_size 0xf0 /* preferred TPDU size */ #define TPP_inact_time 0xf2 /* inactivity time exchanged */ @@ -208,18 +213,18 @@ extern int N_TPREF; *****************************************************/ #ifndef TRUE #define TRUE 1 -#endif /* TRUE */ +#endif /* TRUE */ #ifndef FALSE #define FALSE 0 -#endif /* FALSE */ +#endif /* FALSE */ #define TP_LOCAL 22 #define TP_FOREIGN 33 #ifndef EOK #define EOK 0 -#endif /* EOK */ +#endif /* EOK */ #define TP_CLASS_0 (1<<0) #define TP_CLASS_1 (1<<1) @@ -232,17 +237,17 @@ extern int N_TPREF; #ifndef MNULL #define MNULL (struct mbuf *)0 -#endif /* MNULL */ - /* if ../sys/mbuf.h gets MT_types up to 0x40, these will - * have to be changed: - */ -#define MT_XPD 0x44 +#endif /* MNULL */ +/* + * if ../sys/mbuf.h gets MT_types up to 0x40, these will have to be changed: + */ +#define MT_XPD 0x44 #define MT_EOT 0x40 #define TP_ENOREF 0x80000000 -typedef unsigned int SeqNum; -typedef unsigned short RefNum; +typedef unsigned int SeqNum; +typedef unsigned short RefNum; /****************************************************** * Macro used all over, for driver @@ -265,7 +270,7 @@ typedef unsigned short RefNum; (diffp)->tv_usec = 1000000 - (diffp)->tv_usec;\ }\ } - + /****************************************************** * Macro used for changing types of mbufs *****************************************************/ @@ -285,9 +290,9 @@ typedef unsigned short RefNum; *****************************************************/ struct tp_vbp { - u_char tpv_code; - char tpv_len; - char tpv_val; + u_char tpv_code; + char tpv_len; + char tpv_val; }; #define vbptr(x) ((struct tp_vbp *)(x)) #define vbval(x,type) (*((type *)&(((struct tp_vbp *)(x))->tpv_val))) @@ -312,7 +317,7 @@ bcopy((caddr_t)&(((struct tp_vbp *)(src))->tpv_val),(caddr_t)&(dst),sizeof(type) /****************************************************** * Macro for the local credit: * uses max transmission unit for the ll - * (as modified by the max TPDU size negotiated) + * (as modified by the max TPDU size negotiated) *****************************************************/ #if defined(ARGO_DEBUG)&&!defined(LOCAL_CREDIT_EXPAND) @@ -331,23 +336,29 @@ bcopy((caddr_t)&(((struct tp_vbp *)(src))->tpv_val),(caddr_t)&(dst),sizeof(type) } else \ (tpcb)->tp_lcredit = xxi; \ } } -#endif /* ARGO_DEBUG */ +#endif /* ARGO_DEBUG */ #ifdef _KERNEL -extern int tp_rttadd, tp_rttdiv; +extern int tp_rttadd, tp_rttdiv; #include <sys/syslog.h> #define printf logpri(LOG_DEBUG),addlog -#ifndef tp_NSTATES +#ifndef tp_NSTATES #include <netiso/tp_states.h> #include <netiso/tp_events.h> -#if defined(__STDC__) || defined(__cplusplus) -#undef ATTR -#define ATTR(X) ev_union.EV_ ## X -#endif /* defined(__STDC__) || defined(__cplusplus) */ -#endif /* tp_NSTATES */ +#ifndef __CONCAT3 +# if __STDC__ +# define __CONCAT3(a,b,c) a ## b ## c +# else +# define __CONCAT3(a,b,c) a/**/b/**/c +# endif /* __STDC__ */ +#endif + +#define TPDU_ATTR(X) __CONCAT3(ev_union.EV_,X,_TPDU) + +#endif /* tp_NSTATES */ #endif /* _KERNEL */ #endif /* _NETISO_TP_PARAM_H_ */ diff --git a/sys/netiso/tp_pcb.c b/sys/netiso/tp_pcb.c index a0696b08d65..fb02766666a 100644 --- a/sys/netiso/tp_pcb.c +++ b/sys/netiso/tp_pcb.c @@ -1,4 +1,5 @@ -/* $NetBSD: tp_pcb.c,v 1.10 1995/08/17 02:57:36 mycroft Exp $ */ +/* $OpenBSD: tp_pcb.c,v 1.2 1996/03/04 10:36:18 mickey Exp $ */ +/* $NetBSD: tp_pcb.c,v 1.12 1996/02/13 22:11:39 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -61,16 +62,14 @@ SOFTWARE. /* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ -/* - * This is the initialization and cleanup stuff - - * for the tp machine in general as well as for the individual pcbs. - * tp_init() is called at system startup. tp_attach() and tp_getref() are - * called when a socket is created. tp_detach() and tp_freeref() - * are called during the closing stage and/or when the reference timer - * goes off. - * tp_soisdisconnecting() and tp_soisdisconnected() are tp-specific - * versions of soisconnect* - * and are called (obviously) during the closing phase. +/* + * This is the initialization and cleanup stuff - for the tp machine in + * general as well as for the individual pcbs. tp_init() is called at system + * startup. tp_attach() and tp_getref() are called when a socket is created. + * tp_detach() and tp_freeref() are called during the closing stage and/or + * when the reference timer goes off. tp_soisdisconnecting() and + * tp_soisdisconnected() are tp-specific versions of soisconnect* and are + * called (obviously) during the closing phase. */ #include <sys/param.h> @@ -94,260 +93,218 @@ SOFTWARE. #include <netiso/tp_meas.h> #include <netiso/tp_seq.h> #include <netiso/tp_clnp.h> +#include <netiso/tp_var.h> -/* ticks are in units of: - * 500 nano-fortnights ;-) or - * 500 ms or - * 1/2 second +/* + * ticks are in units of: 500 nano-fortnights ;-) or 500 ms or 1/2 second */ struct tp_conn_param tp_conn_param[] = { /* ISO_CLNS: TP4 CONNECTION LESS */ { - TP_NRETRANS, /* short p_Nretrans; */ - 20, /* 10 sec */ /* short p_dr_ticks; */ + TP_NRETRANS, /* short p_Nretrans; */ + 20, /* 10 sec *//* short p_dr_ticks; */ - 20, /* 10 sec */ /* short p_cc_ticks; */ - 20, /* 10 sec */ /* short p_dt_ticks; */ + 20, /* 10 sec *//* short p_cc_ticks; */ + 20, /* 10 sec *//* short p_dt_ticks; */ - 40, /* 20 sec */ /* short p_x_ticks; */ - 80, /* 40 sec */ /* short p_cr_ticks;*/ + 40, /* 20 sec *//* short p_x_ticks; */ + 80, /* 40 sec *//* short p_cr_ticks; */ - 240, /* 2 min */ /* short p_keepalive_ticks;*/ - 10, /* 5 sec */ /* short p_sendack_ticks; */ + 240, /* 2 min *//* short p_keepalive_ticks; */ + 10, /* 5 sec *//* short p_sendack_ticks; */ - 600, /* 5 min */ /* short p_ref_ticks; */ - 360, /* 3 min */ /* short p_inact_ticks; */ + 600, /* 5 min *//* short p_ref_ticks; */ + 360, /* 3 min *//* short p_inact_ticks; */ - (short) 100, /* short p_lcdtfract */ + (short) 100, /* short p_lcdtfract */ (short) TP_SOCKBUFSIZE, /* short p_winsize */ - TP_TPDUSIZE, /* u_char p_tpdusize */ - - TPACK_WINDOW, /* 4 bits p_ack_strat */ - TPRX_USE_CW | TPRX_FASTSTART, - /* 4 bits p_rx_strat*/ - TP_CLASS_4 | TP_CLASS_0,/* 5 bits p_class */ - 1, /* 1 bit xtd format */ - 1, /* 1 bit xpd service */ - 1, /* 1 bit use_checksum */ - 0, /* 1 bit use net xpd */ - 0, /* 1 bit use rcc */ - 0, /* 1 bit use efc */ - 1, /* no disc indications */ - 0, /* don't change params */ - ISO_CLNS, /* p_netservice */ + TP_TPDUSIZE, /* u_char p_tpdusize */ + + TPACK_WINDOW, /* 4 bits p_ack_strat */ + TPRX_USE_CW | TPRX_FASTSTART, + /* 4 bits p_rx_strat */ + TP_CLASS_4 | TP_CLASS_0, /* 5 bits p_class */ + 1, /* 1 bit xtd format */ + 1, /* 1 bit xpd service */ + 1, /* 1 bit use_checksum */ + 0, /* 1 bit use net xpd */ + 0, /* 1 bit use rcc */ + 0, /* 1 bit use efc */ + 1, /* no disc indications */ + 0, /* don't change params */ + ISO_CLNS, /* p_netservice */ }, /* IN_CLNS: TP4 CONNECTION LESS */ { - TP_NRETRANS, /* short p_Nretrans; */ - 20, /* 10 sec */ /* short p_dr_ticks; */ + TP_NRETRANS, /* short p_Nretrans; */ + 20, /* 10 sec *//* short p_dr_ticks; */ - 20, /* 10 sec */ /* short p_cc_ticks; */ - 20, /* 10 sec */ /* short p_dt_ticks; */ + 20, /* 10 sec *//* short p_cc_ticks; */ + 20, /* 10 sec *//* short p_dt_ticks; */ - 40, /* 20 sec */ /* short p_x_ticks; */ - 80, /* 40 sec */ /* short p_cr_ticks;*/ + 40, /* 20 sec *//* short p_x_ticks; */ + 80, /* 40 sec *//* short p_cr_ticks; */ - 240, /* 2 min */ /* short p_keepalive_ticks;*/ - 10, /* 5 sec */ /* short p_sendack_ticks; */ + 240, /* 2 min *//* short p_keepalive_ticks; */ + 10, /* 5 sec *//* short p_sendack_ticks; */ - 600, /* 5 min */ /* short p_ref_ticks; */ - 360, /* 3 min */ /* short p_inact_ticks; */ + 600, /* 5 min *//* short p_ref_ticks; */ + 360, /* 3 min *//* short p_inact_ticks; */ - (short) 100, /* short p_lcdtfract */ + (short) 100, /* short p_lcdtfract */ (short) TP_SOCKBUFSIZE, /* short p_winsize */ - TP_TPDUSIZE, /* u_char p_tpdusize */ - - TPACK_WINDOW, /* 4 bits p_ack_strat */ - TPRX_USE_CW | TPRX_FASTSTART, - /* 4 bits p_rx_strat*/ - TP_CLASS_4, /* 5 bits p_class */ - 1, /* 1 bit xtd format */ - 1, /* 1 bit xpd service */ - 1, /* 1 bit use_checksum */ - 0, /* 1 bit use net xpd */ - 0, /* 1 bit use rcc */ - 0, /* 1 bit use efc */ - 1, /* no disc indications */ - 0, /* don't change params */ - IN_CLNS, /* p_netservice */ + TP_TPDUSIZE, /* u_char p_tpdusize */ + + TPACK_WINDOW, /* 4 bits p_ack_strat */ + TPRX_USE_CW | TPRX_FASTSTART, + /* 4 bits p_rx_strat */ + TP_CLASS_4, /* 5 bits p_class */ + 1, /* 1 bit xtd format */ + 1, /* 1 bit xpd service */ + 1, /* 1 bit use_checksum */ + 0, /* 1 bit use net xpd */ + 0, /* 1 bit use rcc */ + 0, /* 1 bit use efc */ + 1, /* no disc indications */ + 0, /* don't change params */ + IN_CLNS, /* p_netservice */ }, /* ISO_CONS: TP0 CONNECTION MODE */ { - TP_NRETRANS, /* short p_Nretrans; */ - 0, /* n/a */ /* short p_dr_ticks; */ + TP_NRETRANS, /* short p_Nretrans; */ + 0, /* n/a *//* short p_dr_ticks; */ - 40, /* 20 sec */ /* short p_cc_ticks; */ - 0, /* n/a */ /* short p_dt_ticks; */ + 40, /* 20 sec *//* short p_cc_ticks; */ + 0, /* n/a *//* short p_dt_ticks; */ - 0, /* n/a */ /* short p_x_ticks; */ - 360, /* 3 min */ /* short p_cr_ticks;*/ + 0, /* n/a *//* short p_x_ticks; */ + 360, /* 3 min *//* short p_cr_ticks; */ - 0, /* n/a */ /* short p_keepalive_ticks;*/ - 0, /* n/a */ /* short p_sendack_ticks; */ + 0, /* n/a *//* short p_keepalive_ticks; */ + 0, /* n/a *//* short p_sendack_ticks; */ - 600, /* for cr/cc to clear *//* short p_ref_ticks; */ - 0, /* n/a */ /* short p_inact_ticks; */ + 600, /* for cr/cc to clear *//* short p_ref_ticks; */ + 0, /* n/a *//* short p_inact_ticks; */ - /* Use tp4 defaults just in case the user changes ONLY - * the class + /* + * Use tp4 defaults just in case the user changes ONLY the + * class */ - (short) 100, /* short p_lcdtfract */ + (short) 100, /* short p_lcdtfract */ (short) TP0_SOCKBUFSIZE, /* short p_winsize */ - TP0_TPDUSIZE, /* 8 bits p_tpdusize */ - - 0, /* 4 bits p_ack_strat */ - 0, /* 4 bits p_rx_strat*/ - TP_CLASS_0, /* 5 bits p_class */ - 0, /* 1 bit xtd format */ - 0, /* 1 bit xpd service */ - 0, /* 1 bit use_checksum */ - 0, /* 1 bit use net xpd */ - 0, /* 1 bit use rcc */ - 0, /* 1 bit use efc */ - 0, /* no disc indications */ - 0, /* don't change params */ - ISO_CONS, /* p_netservice */ + TP0_TPDUSIZE, /* 8 bits p_tpdusize */ + + 0, /* 4 bits p_ack_strat */ + 0, /* 4 bits p_rx_strat */ + TP_CLASS_0, /* 5 bits p_class */ + 0, /* 1 bit xtd format */ + 0, /* 1 bit xpd service */ + 0, /* 1 bit use_checksum */ + 0, /* 1 bit use net xpd */ + 0, /* 1 bit use rcc */ + 0, /* 1 bit use efc */ + 0, /* no disc indications */ + 0, /* don't change params */ + ISO_CONS, /* p_netservice */ }, /* ISO_COSNS: TP4 CONNECTION LESS SERVICE over CONSNS */ { - TP_NRETRANS, /* short p_Nretrans; */ - 40, /* 20 sec */ /* short p_dr_ticks; */ + TP_NRETRANS, /* short p_Nretrans; */ + 40, /* 20 sec *//* short p_dr_ticks; */ - 40, /* 20 sec */ /* short p_cc_ticks; */ - 80, /* 40 sec */ /* short p_dt_ticks; */ + 40, /* 20 sec *//* short p_cc_ticks; */ + 80, /* 40 sec *//* short p_dt_ticks; */ - 120, /* 1 min */ /* short p_x_ticks; */ - 360, /* 3 min */ /* short p_cr_ticks;*/ + 120, /* 1 min *//* short p_x_ticks; */ + 360, /* 3 min *//* short p_cr_ticks; */ - 360, /* 3 min */ /* short p_keepalive_ticks;*/ - 20, /* 10 sec */ /* short p_sendack_ticks; */ + 360, /* 3 min *//* short p_keepalive_ticks; */ + 20, /* 10 sec *//* short p_sendack_ticks; */ - 600, /* 5 min */ /* short p_ref_ticks; */ - 480, /* 4 min */ /* short p_inact_ticks; */ + 600, /* 5 min *//* short p_ref_ticks; */ + 480, /* 4 min *//* short p_inact_ticks; */ - (short) 100, /* short p_lcdtfract */ + (short) 100, /* short p_lcdtfract */ (short) TP0_SOCKBUFSIZE, /* short p_winsize */ - TP0_TPDUSIZE, /* u_char p_tpdusize */ - - TPACK_WINDOW, /* 4 bits p_ack_strat */ - TPRX_USE_CW , /* No fast start */ - /* 4 bits p_rx_strat*/ - TP_CLASS_4 | TP_CLASS_0,/* 5 bits p_class */ - 0, /* 1 bit xtd format */ - 1, /* 1 bit xpd service */ - 1, /* 1 bit use_checksum */ - 0, /* 1 bit use net xpd */ - 0, /* 1 bit use rcc */ - 0, /* 1 bit use efc */ - 0, /* no disc indications */ - 0, /* don't change params */ - ISO_COSNS, /* p_netservice */ + TP0_TPDUSIZE, /* u_char p_tpdusize */ + + TPACK_WINDOW, /* 4 bits p_ack_strat */ + TPRX_USE_CW, /* No fast start */ + /* 4 bits p_rx_strat */ + TP_CLASS_4 | TP_CLASS_0, /* 5 bits p_class */ + 0, /* 1 bit xtd format */ + 1, /* 1 bit xpd service */ + 1, /* 1 bit use_checksum */ + 0, /* 1 bit use net xpd */ + 0, /* 1 bit use rcc */ + 0, /* 1 bit use efc */ + 0, /* no disc indications */ + 0, /* don't change params */ + ISO_COSNS, /* p_netservice */ }, }; #ifdef INET -int in_putnetaddr(); -int in_getnetaddr(); -int in_cmpnetaddr(); -int in_putsufx(); -int in_getsufx(); -int in_recycle_tsuffix(); -int tpip_mtu(); -int in_pcbbind(); -int in_pcbconnect(); -int in_pcbdisconnect(); -int in_pcbdetach(); -int in_pcballoc(); -int tpip_output(); -int tpip_output_dg(); -struct inpcbtable tp_inpcb; -#endif /* INET */ +struct inpcbtable tp_inpcb; +#endif /* INET */ #ifdef ISO -int iso_putnetaddr(); -int iso_getnetaddr(); -int iso_cmpnetaddr(); -int iso_putsufx(); -int iso_getsufx(); -int iso_recycle_tsuffix(); -int tpclnp_mtu(); -int iso_pcbbind(); -int iso_pcbconnect(); -int iso_pcbdisconnect(); -int iso_pcbdetach(); -int iso_pcballoc(); -int tpclnp_output(); -int tpclnp_output_dg(); -int iso_nlctloutput(); -struct isopcb tp_isopcb; -#endif /* ISO */ +struct isopcb tp_isopcb; +#endif /* ISO */ #ifdef TPCONS -int iso_putnetaddr(); -int iso_getnetaddr(); -int iso_cmpnetaddr(); -int iso_putsufx(); -int iso_getsufx(); -int iso_recycle_tsuffix(); -int iso_pcbbind(); -int tpcons_pcbconnect(); -int tpclnp_mtu(); -int iso_pcbdisconnect(); -int iso_pcbdetach(); -int iso_pcballoc(); -int tpcons_output(); -struct isopcb tp_isopcb; -#endif /* TPCONS */ +struct isopcb tp_isopcb; +#endif /* TPCONS */ struct nl_protosw nl_protosw[] = { /* ISO_CLNS */ #ifdef ISO - { AF_ISO, iso_putnetaddr, iso_getnetaddr, iso_cmpnetaddr, + {AF_ISO, iso_putnetaddr, iso_getnetaddr, iso_cmpnetaddr, iso_putsufx, iso_getsufx, iso_recycle_tsuffix, tpclnp_mtu, iso_pcbbind, iso_pcbconnect, - iso_pcbdisconnect, iso_pcbdetach, + iso_pcbdisconnect, iso_pcbdetach, iso_pcballoc, tpclnp_output, tpclnp_output_dg, iso_nlctloutput, - (caddr_t) &tp_isopcb, - }, + (caddr_t) & tp_isopcb, + }, #else - { 0 }, -#endif /* ISO */ + {0}, +#endif /* ISO */ /* IN_CLNS */ #ifdef INET - { AF_INET, in_putnetaddr, in_getnetaddr, in_cmpnetaddr, + {AF_INET, in_putnetaddr, in_getnetaddr, in_cmpnetaddr, in_putsufx, in_getsufx, in_recycle_tsuffix, tpip_mtu, in_pcbbind, in_pcbconnect, - in_pcbdisconnect, in_pcbdetach, + in_pcbdisconnect, in_pcbdetach, in_pcballoc, tpip_output, tpip_output_dg, /* nl_ctloutput */ NULL, - (caddr_t) &tp_inpcb, - }, + (caddr_t) & tp_inpcb, + }, #else - { 0 }, -#endif /* INET */ + {0}, +#endif /* INET */ /* ISO_CONS */ #if defined(ISO) && defined(TPCONS) - { AF_ISO, iso_putnetaddr, iso_getnetaddr, iso_cmpnetaddr, + {AF_ISO, iso_putnetaddr, iso_getnetaddr, iso_cmpnetaddr, iso_putsufx, iso_getsufx, iso_recycle_tsuffix, tpclnp_mtu, iso_pcbbind, tpcons_pcbconnect, - iso_pcbdisconnect, iso_pcbdetach, + iso_pcbdisconnect, iso_pcbdetach, iso_pcballoc, tpcons_output, tpcons_output, iso_nlctloutput, - (caddr_t) &tp_isopcb, - }, + (caddr_t) & tp_isopcb, + }, #else - { 0 }, -#endif /* ISO_CONS */ + {0}, +#endif /* ISO_CONS */ /* End of protosw marker */ - { 0 } + {0} }; -u_long tp_sendspace = 1024 * 4; -u_long tp_recvspace = 1024 * 4; +u_long tp_sendspace = 1024 * 4; +u_long tp_recvspace = 1024 * 4; /* * NAME: tp_init() @@ -361,27 +318,26 @@ u_long tp_recvspace = 1024 * 4; * RETURNS: Nada * * SIDE EFFECTS: - * + * * NOTES: */ void tp_init() { - static int init_done=0; - void tp_timerinit(); + static int init_done = 0; if (init_done++) return; /* FOR INET */ - in_pcbinit(&tp_inpcb); + in_pcbinit(&tp_inpcb, 1); /* FOR ISO */ tp_isopcb.isop_next = tp_isopcb.isop_prev = &tp_isopcb; - tp_start_win = 2; + tp_start_win = 2; tp_timerinit(); - bzero((caddr_t)&tp_stat, sizeof(struct tp_stat)); + bzero((caddr_t) & tp_stat, sizeof(struct tp_stat)); } /* @@ -410,16 +366,21 @@ tp_soisdisconnecting(so) { soisdisconnecting(so); so->so_state &= ~SS_CANTSENDMORE; - IFPERF(sototpcb(so)) +#ifdef TP_PERF_MEAS + if (DOPERF(sototpcb(so))) { register struct tp_pcb *tpcb = sototpcb(so); - u_int fsufx, lsufx; + u_int fsufx, lsufx; - bcopy ((caddr_t)tpcb->tp_fsuffix, (caddr_t)&fsufx, sizeof(u_int) ); - bcopy ((caddr_t)tpcb->tp_lsuffix, (caddr_t)&lsufx, sizeof(u_int) ); + bcopy((caddr_t) tpcb->tp_fsuffix, (caddr_t) &fsufx, + sizeof(u_int)); + bcopy((caddr_t) tpcb->tp_lsuffix, (caddr_t) &lsufx, + sizeof(u_int)); - tpmeas(tpcb->tp_lref, TPtime_close, &time, fsufx, lsufx, tpcb->tp_fref); - tpcb->tp_perf_on = 0; /* turn perf off */ - ENDPERF + tpmeas(tpcb->tp_lref, TPtime_close, &time, fsufx, lsufx, + tpcb->tp_fref); + tpcb->tp_perf_on = 0; /* turn perf off */ + } +#endif } @@ -427,7 +388,7 @@ tp_soisdisconnecting(so) * NAME: tp_soisdisconnected() * * CALLED FROM: - * tp.trans + * tp.trans * * FUNCTION and ARGUMENTS: * Set state of the socket (so) to reflect that fact that we're disconnectED @@ -448,28 +409,32 @@ tp_soisdisconnecting(so) */ void tp_soisdisconnected(tpcb) - register struct tp_pcb *tpcb; + register struct tp_pcb *tpcb; { - register struct socket *so = tpcb->tp_sock; + register struct socket *so = tpcb->tp_sock; soisdisconnecting(so); so->so_state &= ~SS_CANTSENDMORE; - IFPERF(tpcb) +#ifdef TP_PERF_MEAS + if (DOPERF(tpcb)) { register struct tp_pcb *ttpcb = sototpcb(so); - u_int fsufx, lsufx; + u_int fsufx, lsufx; /* CHOKE */ - bcopy ((caddr_t)ttpcb->tp_fsuffix, (caddr_t)&fsufx, sizeof(u_int) ); - bcopy ((caddr_t)ttpcb->tp_lsuffix, (caddr_t)&lsufx, sizeof(u_int) ); - - tpmeas(ttpcb->tp_lref, TPtime_close, - &time, &lsufx, &fsufx, ttpcb->tp_fref); - tpcb->tp_perf_on = 0; /* turn perf off */ - ENDPERF + bcopy((caddr_t) ttpcb->tp_fsuffix, (caddr_t) &fsufx, + sizeof(u_int)); + bcopy((caddr_t) ttpcb->tp_lsuffix, (caddr_t) &lsufx, + sizeof(u_int)); + + tpmeas(ttpcb->tp_lref, TPtime_close, + &time, &lsufx, &fsufx, ttpcb->tp_fref); + tpcb->tp_perf_on = 0; /* turn perf off */ + } +#endif tpcb->tp_refstate = REF_FROZEN; tp_recycle_tsuffix(tpcb); - tp_etimeout(tpcb, TM_reference, (int)tpcb->tp_refer_ticks); + tp_etimeout(tpcb, TM_reference, (int) tpcb->tp_refer_ticks); } /* @@ -485,33 +450,39 @@ tp_soisdisconnected(tpcb) * Frees the reference represented by (r) for re-use. * * RETURNS: Nothing - * + * * SIDE EFFECTS: * * NOTES: better be called at clock priority !!!!! */ void tp_freeref(n) -RefNum n; + RefNum n; { register struct tp_ref *r = tp_ref + n; register struct tp_pcb *tpcb; tpcb = r->tpr_pcb; - IFDEBUG(D_TIMER) - printf("tp_freeref called for ref %d pcb %x maxrefopen %d\n", - n, tpcb, tp_refinfo.tpr_maxopen); - ENDDEBUG - IFTRACE(D_TIMER) +#ifdef ARGO_DEBUG + if (argo_debug[D_TIMER]) { + printf("tp_freeref called for ref %d pcb %x maxrefopen %d\n", + n, tpcb, tp_refinfo.tpr_maxopen); + } +#endif +#ifdef TPPT + if (tp_traceflags[D_TIMER]) { tptrace(TPPTmisc, "tp_freeref ref maxrefopen pcb", - n, tp_refinfo.tpr_maxopen, tpcb, 0); - ENDTRACE + n, tp_refinfo.tpr_maxopen, tpcb, 0); + } +#endif if (tpcb == 0) return; - IFDEBUG(D_CONN) +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("tp_freeref: CLEARING tpr_pcb 0x%x\n", tpcb); - ENDDEBUG - r->tpr_pcb = (struct tp_pcb *)0; + } +#endif + r->tpr_pcb = (struct tp_pcb *) 0; tpcb->tp_refstate = REF_FREE; for (r = tp_ref + tp_refinfo.tpr_maxopen; r > tp_ref; r--) @@ -520,9 +491,11 @@ RefNum n; tp_refinfo.tpr_maxopen = r - tp_ref; tp_refinfo.tpr_numopen--; - IFDEBUG(D_TIMER) +#ifdef ARGO_DEBUG + if (argo_debug[D_TIMER]) { printf("tp_freeref ends w/ maxrefopen %d\n", tp_refinfo.tpr_maxopen); - ENDDEBUG + } +#endif } /* @@ -533,7 +506,7 @@ RefNum n; * * FUNCTION and ARGUMENTS: * obtains the next free reference and allocates the appropriate - * ref structure, links that structure to (tpcb) + * ref structure, links that structure to (tpcb) * * RETURN VALUE: * a reference number @@ -544,40 +517,40 @@ RefNum n; * NOTES: */ u_long -tp_getref(tpcb) +tp_getref(tpcb) register struct tp_pcb *tpcb; { - register struct tp_ref *r, *rlim; - register int i; - caddr_t obase; - unsigned size; + register struct tp_ref *r, *rlim; + register int i; + caddr_t obase; + unsigned size; if (++tp_refinfo.tpr_numopen < tp_refinfo.tpr_size) for (r = tp_refinfo.tpr_base, rlim = r + tp_refinfo.tpr_size; - ++r < rlim; ) /* tp_ref[0] is never used */ + ++r < rlim;) /* tp_ref[0] is never used */ if (r->tpr_pcb == 0) goto got_one; /* else have to allocate more space */ - obase = (caddr_t)tp_refinfo.tpr_base; + obase = (caddr_t) tp_refinfo.tpr_base; size = tp_refinfo.tpr_size * sizeof(struct tp_ref); r = (struct tp_ref *) malloc(size + size, M_PCB, M_NOWAIT); if (r == 0) return (--tp_refinfo.tpr_numopen, TP_ENOREF); tp_refinfo.tpr_base = tp_ref = r; tp_refinfo.tpr_size *= 2; - bcopy(obase, (caddr_t)r, size); + bcopy(obase, (caddr_t) r, size); free(obase, M_PCB); - r = (struct tp_ref *)(size + (caddr_t)r); - bzero((caddr_t)r, size); + r = (struct tp_ref *) (size + (caddr_t) r); + bzero((caddr_t) r, size); got_one: r->tpr_pcb = tpcb; tpcb->tp_refstate = REF_OPENING; i = r - tp_refinfo.tpr_base; - if (tp_refinfo.tpr_maxopen < i) + if (tp_refinfo.tpr_maxopen < i) tp_refinfo.tpr_maxopen = i; - return (u_long)i; + return (u_long) i; } /* @@ -590,21 +563,23 @@ got_one: * given a tpcb, allocate an appropriate lower-lever npcb, freeing * any old ones that might need re-assigning. */ +int tp_set_npcb(tpcb) -register struct tp_pcb *tpcb; + register struct tp_pcb *tpcb; { register struct socket *so = tpcb->tp_sock; - int error; + int error; if (tpcb->tp_nlproto && tpcb->tp_npcb) { - short so_state = so->so_state; + short so_state = so->so_state; so->so_state &= ~SS_NOFDREF; - tpcb->tp_nlproto->nlp_pcbdetach(tpcb->tp_npcb); + (*tpcb->tp_nlproto->nlp_pcbdetach)(tpcb->tp_npcb); so->so_state = so_state; } tpcb->tp_nlproto = &nl_protosw[tpcb->tp_netservice]; /* xx_pcballoc sets so_pcb */ - error = tpcb->tp_nlproto->nlp_pcballoc(so, tpcb->tp_nlproto->nlp_pcblist); + error = (*tpcb->tp_nlproto->nlp_pcballoc)(so, + tpcb->tp_nlproto->nlp_pcblist); tpcb->tp_npcb = so->so_pcb; so->so_pcb = tpcb; return (error); @@ -634,30 +609,34 @@ register struct tp_pcb *tpcb; * * NOTES: */ +int tp_attach(so, protocol) - struct socket *so; - long protocol; + struct socket *so; + long protocol; { - register struct tp_pcb *tpcb; - int error = 0; - int dom = so->so_proto->pr_domain->dom_family; - u_long lref; + register struct tp_pcb *tpcb; + int error = 0; + int dom = so->so_proto->pr_domain->dom_family; + u_long lref; extern struct tp_conn_param tp_conn_param[]; - IFDEBUG(D_CONN) +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("tp_attach:dom 0x%x so 0x%x ", dom, so); - ENDDEBUG - IFTRACE(D_CONN) + } +#endif +#ifdef TPPT + if (tp_traceflags[D_CONN]) { tptrace(TPPTmisc, "tp_attach:dom so", dom, so, 0, 0); - ENDTRACE - - if (so->so_pcb != 0) { - return EISCONN; /* socket already part of a connection*/ } +#endif + if (so->so_pcb != NULL) { + return EISCONN; /* socket already part of a connection */ + } if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) error = soreserve(so, tp_sendspace, tp_recvspace); - /* later an ioctl will allow reallocation IF still in closed state */ + /* later an ioctl will allow reallocation IF still in closed state */ if (error) goto bad2; @@ -667,82 +646,90 @@ tp_attach(so, protocol) error = ENOBUFS; goto bad2; } - bzero( (caddr_t)tpcb, sizeof (struct tp_pcb) ); + bzero((caddr_t) tpcb, sizeof(struct tp_pcb)); - if ( ((lref = tp_getref(tpcb)) & TP_ENOREF) != 0 ) { - error = ETOOMANYREFS; + if (((lref = tp_getref(tpcb)) & TP_ENOREF) != 0) { + error = ETOOMANYREFS; goto bad3; } tpcb->tp_lref = lref; - tpcb->tp_sock = so; + tpcb->tp_sock = so; tpcb->tp_domain = dom; tpcb->tp_rhiwat = so->so_rcv.sb_hiwat; /* tpcb->tp_proto = protocol; someday maybe? */ - if (protocol && protocol<ISOPROTO_TP4) { + if (protocol && protocol < ISOPROTO_TP4) { tpcb->tp_netservice = ISO_CONS; - tpcb->tp_snduna = (SeqNum) -1;/* kludge so the pseudo-ack from the CR/CC - * will generate correct fake-ack values - */ + tpcb->tp_snduna = (SeqNum) - 1; /* kludge so the pseudo-ack + * from the CR/CC will + * generate correct fake-ack + * values */ } else { - tpcb->tp_netservice = (dom== AF_INET)?IN_CLNS:ISO_CLNS; + tpcb->tp_netservice = (dom == AF_INET) ? IN_CLNS : ISO_CLNS; /* the default */ } tpcb->_tp_param = tp_conn_param[tpcb->tp_netservice]; tpcb->tp_state = TP_CLOSED; - tpcb->tp_vers = TP_VERSION; + tpcb->tp_vers = TP_VERSION; tpcb->tp_notdetached = 1; - /* Spec says default is 128 octets, - * that is, if the tpdusize argument never appears, use 128. - * As the initiator, we will always "propose" the 2048 - * size, that is, we will put this argument in the CR - * always, but accept what the other side sends on the CC. - * If the initiator sends us something larger on a CR, - * we'll respond w/ this. - * Our maximum is 4096. See tp_chksum.c comments. - */ - tpcb->tp_cong_win = + /* + * Spec says default is 128 octets, that is, if the tpdusize argument + * never appears, use 128. As the initiator, we will always "propose" + * the 2048 size, that is, we will put this argument in the CR + * always, but accept what the other side sends on the CC. If the + * initiator sends us something larger on a CR, we'll respond w/ + * this. Our maximum is 4096. See tp_chksum.c comments. + */ + tpcb->tp_cong_win = tpcb->tp_l_tpdusize = 1 << tpcb->tp_tpdusize; - tpcb->tp_seqmask = TP_NML_FMT_MASK; - tpcb->tp_seqbit = TP_NML_FMT_BIT; - tpcb->tp_seqhalf = tpcb->tp_seqbit >> 1; + tpcb->tp_seqmask = TP_NML_FMT_MASK; + tpcb->tp_seqbit = TP_NML_FMT_BIT; + tpcb->tp_seqhalf = tpcb->tp_seqbit >> 1; /* attach to a network-layer protoswitch */ - if ( error = tp_set_npcb(tpcb)) + if ((error = tp_set_npcb(tpcb)) != 0) goto bad4; - ASSERT( tpcb->tp_nlproto->nlp_afamily == tpcb->tp_domain); + ASSERT(tpcb->tp_nlproto->nlp_afamily == tpcb->tp_domain); /* nothing to do for iso case */ - if( dom == AF_INET ) + if (dom == AF_INET) sotoinpcb(so)->inp_ppcb = (caddr_t) tpcb; return 0; bad4: - IFDEBUG(D_CONN) +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("BAD4 in tp_attach, so 0x%x\n", so); - ENDDEBUG + } +#endif tp_freeref(tpcb->tp_lref); bad3: - IFDEBUG(D_CONN) +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("BAD3 in tp_attach, so 0x%x\n", so); - ENDDEBUG + } +#endif - free((caddr_t)tpcb, M_PCB); /* never a cluster */ + free((caddr_t) tpcb, M_PCB); /* never a cluster */ bad2: - IFDEBUG(D_CONN) +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("BAD2 in tp_attach, so 0x%x\n", so); - ENDDEBUG + } +#endif so->so_pcb = 0; -/*bad:*/ - IFDEBUG(D_CONN) + /* bad: */ +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("BAD in tp_attach, so 0x%x\n", so); - ENDDEBUG + } +#endif return error; } @@ -752,7 +739,7 @@ bad2: * CALLED FROM: * tp.trans, on behalf of a user close request * and when the reference timer goes off - * (if the disconnect was initiated by the protocol entity + * (if the disconnect was initiated by the protocol entity * rather than by the user) * * FUNCTION and ARGUMENTS: @@ -771,26 +758,31 @@ bad2: */ void tp_detach(tpcb) - register struct tp_pcb *tpcb; + register struct tp_pcb *tpcb; { - void tp_freeref(), tp_rsyflush(); - register struct socket *so = tpcb->tp_sock; + register struct socket *so = tpcb->tp_sock; - IFDEBUG(D_CONN) +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("tp_detach(tpcb 0x%x, so 0x%x)\n", - tpcb,so); - ENDDEBUG - IFTRACE(D_CONN) - tptraceTPCB(TPPTmisc, "tp_detach tpcb so lsufx", - tpcb, so, *(u_short *)(tpcb->tp_lsuffix), 0); - ENDTRACE - - IFDEBUG(D_CONN) + tpcb, so); + } +#endif +#ifdef TPPT + if (tp_traceflags[D_CONN]) { + tptraceTPCB(TPPTmisc, "tp_detach tpcb so lsufx", + tpcb, so, *(u_short *) (tpcb->tp_lsuffix), 0); + } +#endif + +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("so_snd at 0x%x so_rcv at 0x%x\n", &so->so_snd, &so->so_rcv); dump_mbuf(so->so_snd.sb_mb, "so_snd at detach "); printf("about to call LL detach, nlproto 0x%x, nl_detach 0x%x\n", - tpcb->tp_nlproto, tpcb->tp_nlproto->nlp_pcbdetach); - ENDDEBUG + tpcb->tp_nlproto, tpcb->tp_nlproto->nlp_pcbdetach); + } +#endif if (tpcb->tp_Xsnd.sb_mb) { printf("Unsent Xdata on detach; would panic"); @@ -799,10 +791,12 @@ tp_detach(tpcb) if (tpcb->tp_ucddata) m_freem(tpcb->tp_ucddata); - IFDEBUG(D_CONN) +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("reassembly info cnt %d rsyq 0x%x\n", - tpcb->tp_rsycnt, tpcb->tp_rsyq); - ENDDEBUG + tpcb->tp_rsycnt, tpcb->tp_rsyq); + } +#endif if (tpcb->tp_rsyq) tp_rsyflush(tpcb); @@ -812,20 +806,24 @@ tp_detach(tpcb) } tpcb->tp_notdetached = 0; - IFDEBUG(D_CONN) - printf("calling (...nlproto->...)(0x%x, so 0x%x)\n", - tpcb->tp_npcb, so); - printf("so 0x%x so_head 0x%x, qlen %d q0len %d qlimit %d\n", - so, so->so_head, - so->so_q0len, so->so_qlen, so->so_qlimit); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { + printf("calling (...nlproto->...)(0x%x, so 0x%x)\n", + tpcb->tp_npcb, so); + printf("so 0x%x so_head 0x%x, qlen %d q0len %d qlimit %d\n", + so, so->so_head, + so->so_q0len, so->so_qlen, so->so_qlimit); + } +#endif - (tpcb->tp_nlproto->nlp_pcbdetach)(tpcb->tp_npcb); - /* does an so->so_pcb = 0; sofree(so) */ + (*tpcb->tp_nlproto->nlp_pcbdetach)(tpcb->tp_npcb); + /* does an so->so_pcb = 0; sofree(so) */ - IFDEBUG(D_CONN) +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("after xxx_pcbdetach\n"); - ENDDEBUG + } +#endif if (tpcb->tp_state == TP_LISTENING) { register struct tp_pcb **tt; @@ -837,57 +835,76 @@ tp_detach(tpcb) else printf("tp_detach from listen: should panic\n"); } - if (tpcb->tp_refstate == REF_OPENING ) { - /* no connection existed here so no reference timer will be called */ - IFDEBUG(D_CONN) + if (tpcb->tp_refstate == REF_OPENING) { + /* + * no connection existed here so no reference timer will be + * called + */ +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("SETTING ref %d to REF_FREE\n", tpcb->tp_lref); - ENDDEBUG + } +#endif tp_freeref(tpcb->tp_lref); } #ifdef TP_PERF_MEAS - /* - * Get rid of the cluster mbuf allocated for performance measurements, if - * there is one. Note that tpcb->tp_perf_on says nothing about whether or - * not a cluster mbuf was allocated, so you have to check for a pointer - * to one (that is, we need the TP_PERF_MEASs around the following section - * of code, not the IFPERFs) + /* + * Get rid of the cluster mbuf allocated for performance + * measurements, if there is one. Note that tpcb->tp_perf_on says + * nothing about whether or not a cluster mbuf was allocated, so you + * have to check for a pointer to one (that is, we need the + * TP_PERF_MEASs around the following section of code, not the + * IFPERFs) */ if (tpcb->tp_p_meas) { - IFDEBUG(D_PERF_MEAS) + register struct mbuf *m = tpcb->tp_p_mbuf; + struct mbuf *n; +#ifdef ARGO_DEBUG + if (argo_debug[D_PERF_MEAS]) { printf("freeing tp_p_meas 0x%x ", tpcb->tp_p_meas); - ENDDEBUG + } +#endif free(tpcb->tp_p_meas, M_PCB); tpcb->tp_p_meas = 0; } -#endif /* TP_PERF_MEAS */ +#endif /* TP_PERF_MEAS */ - IFDEBUG(D_CONN) - printf( "end of detach, NOT single, tpcb 0x%x\n", tpcb); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { + printf("end of detach, NOT single, tpcb 0x%x\n", tpcb); + } +#endif /* free((caddr_t)tpcb, M_PCB); WHere to put this ? */ } struct que { - struct tp_pcb *next; - struct tp_pcb *prev; -} tp_bound_pcbs = -{(struct tp_pcb *)&tp_bound_pcbs, (struct tp_pcb *)&tp_bound_pcbs}; + struct tp_pcb *next; + struct tp_pcb *prev; +} tp_bound_pcbs = +{ + (struct tp_pcb *) & tp_bound_pcbs, (struct tp_pcb *) & tp_bound_pcbs +}; -u_short tp_unique; +u_short tp_unique; +int tp_tselinuse(tlen, tsel, siso, reuseaddr) -caddr_t tsel; -register struct sockaddr_iso *siso; + int tlen; + caddr_t tsel; + register struct sockaddr_iso *siso; + int reuseaddr; { - struct tp_pcb *b = tp_bound_pcbs.next, *l = tp_listeners; + struct tp_pcb *b = tp_bound_pcbs.next, *l = tp_listeners; register struct tp_pcb *t; for (;;) { - if (b != (struct tp_pcb *)&tp_bound_pcbs) { - t = b; b = t->tp_next; + if (b != (struct tp_pcb *) & tp_bound_pcbs) { + t = b; + b = t->tp_next; } else if (l) { - t = l; l = t->tp_nextlisten; + t = l; + l = t->tp_nextlisten; } else break; if (tlen == t->tp_lsuffixlen && bcmp(tsel, t->tp_lsuffix, tlen) == 0) { @@ -896,10 +913,11 @@ register struct sockaddr_iso *siso; return 1; } else if (siso) { if (siso->siso_family == t->tp_domain && - t->tp_nlproto->nlp_cmpnetaddr(t->tp_npcb, siso, TP_LOCAL)) - return 1; + (*t->tp_nlproto->nlp_cmpnetaddr)(t->tp_npcb, + (struct sockaddr *) siso, TP_LOCAL)) + return 1; } else if (reuseaddr == 0) - return 1; + return 1; } } return 0; @@ -907,14 +925,16 @@ register struct sockaddr_iso *siso; } -tp_pcbbind(tpcb, nam) -register struct tp_pcb *tpcb; -register struct mbuf *nam; +int +tp_pcbbind(v, nam) + register void *v; + register struct mbuf *nam; { + register struct tp_pcb *tpcb = v; register struct sockaddr_iso *siso = 0; - int tlen = 0, wrapped = 0; - caddr_t tsel; - u_short tutil; + int tlen = 0, wrapped = 0; + caddr_t tsel = NULL; + u_short tutil; if (tpcb->tp_state != TP_CLOSED) return (EINVAL); @@ -933,8 +953,8 @@ register struct mbuf *nam; #endif #ifdef INET case AF_INET: - tsel = (caddr_t)&tutil; - if (tutil = satosin(siso)->sin_port) + tsel = (caddr_t) & tutil; + if ((tutil = satosin(siso)->sin_port) != 0) tlen = 2; if (satosin(siso)->sin_addr.s_addr == 0) siso = 0; @@ -944,21 +964,22 @@ register struct mbuf *nam; if (tpcb->tp_lsuffixlen == 0) { if (tlen) { if (tp_tselinuse(tlen, tsel, siso, - tpcb->tp_sock->so_options & SO_REUSEADDR)) + tpcb->tp_sock->so_options & SO_REUSEADDR)) return (EINVAL); } else { - for (tsel = (caddr_t)&tutil, tlen = 2;;){ + for (tsel = (caddr_t) & tutil, tlen = 2;;) { if (tp_unique++ < ISO_PORT_RESERVED || - tp_unique > ISO_PORT_USERRESERVED) { - if (wrapped++) - return ESRCH; - tp_unique = ISO_PORT_RESERVED; + tp_unique > ISO_PORT_USERRESERVED) { + if (wrapped++) + return ESRCH; + tp_unique = ISO_PORT_RESERVED; } tutil = htons(tp_unique); if (tp_tselinuse(tlen, tsel, siso, 0) == 0) break; } - if (siso) switch (siso->siso_family) { + if (siso) + switch (siso->siso_family) { #ifdef ISO case AF_ISO: bcopy(tsel, TSEL(siso), tlen); @@ -981,5 +1002,5 @@ register struct mbuf *nam; tpcb->tp_flags |= TPF_GENERAL_ADDR; return (0); } - return tpcb->tp_nlproto->nlp_pcbbind(tpcb->tp_npcb, nam); + return (*tpcb->tp_nlproto->nlp_pcbbind)(tpcb->tp_npcb, nam); } diff --git a/sys/netiso/tp_pcb.h b/sys/netiso/tp_pcb.h index 99e1216d53b..68af0d3d2c0 100644 --- a/sys/netiso/tp_pcb.h +++ b/sys/netiso/tp_pcb.h @@ -1,4 +1,5 @@ -/* $NetBSD: tp_pcb.h,v 1.8 1995/08/16 00:38:57 mycroft Exp $ */ +/* $OpenBSD: tp_pcb.h,v 1.2 1996/03/04 10:36:20 mickey Exp $ */ +/* $NetBSD: tp_pcb.h,v 1.9 1996/02/13 22:11:44 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -38,15 +39,15 @@ /*********************************************************** Copyright IBM Corporation 1987 - All Rights Reserved + All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -61,194 +62,214 @@ SOFTWARE. /* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ -/* - * This file defines the transport protocol control block (tpcb). - * and a bunch of #define values that are used in the tpcb. +/* + * This file defines the transport protocol control block (tpcb). and a bunch + * of #define values that are used in the tpcb. */ -#ifndef _NETISO_TP_PCB_H_ -#define _NETISO_TP_PCB_H_ +#ifndef _NETISO_TP_PCB_H_ +#define _NETISO_TP_PCB_H_ #include <netiso/tp_param.h> #include <netiso/tp_timer.h> #include <netiso/tp_user.h> #ifndef sblock #include <sys/socketvar.h> -#endif /* sblock */ +#endif /* sblock */ -/* NOTE: the code depends on REF_CLOSED > REF_OPEN > the rest, and - * on REF_FREE being zero - * - * Possible improvement: - * think about merging the tp_ref w/ the tpcb and doing a search - * through the tpcb list, from tpb. This would slow down lookup - * during data transfer - * It would be a little nicer also to have something based on the - * clock (like top n bits of the reference is part of the clock, to - * minimize the likelihood of reuse after a crash) - * also, need to keep the timer servicing part to a minimum (although - * the cost of this is probably independent of whether the timers are - * in the pcb or in an array.. - * Last, would have to make the number of timers a function of the amount of - * mbufs available, plus some for the frozen references. - * - * Possible improvement: - * Might not need the ref_state stuff either... - * REF_FREE could correspond to tp_state == CLOSED or nonexistend tpcb, - * REF_OPEN to tp_state anywhere from AK_WAIT or CR_SENT to CLOSING - * REF_OPENING could correspond to LISTENING, because that's the - * way it's used, not because the correspondence is exact. - * REF_CLOSED could correspond to REFWAIT +/* + * NOTE: the code depends on REF_CLOSED > REF_OPEN > the rest, and on + * REF_FREE being zero + * + * Possible improvement: think about merging the tp_ref w/ the tpcb and doing a + * search through the tpcb list, from tpb. This would slow down lookup during + * data transfer It would be a little nicer also to have something based on + * the clock (like top n bits of the reference is part of the clock, to + * minimize the likelihood of reuse after a crash) also, need to keep the + * timer servicing part to a minimum (although the cost of this is probably + * independent of whether the timers are in the pcb or in an array.. Last, + * would have to make the number of timers a function of the amount of mbufs + * available, plus some for the frozen references. + * + * Possible improvement: Might not need the ref_state stuff either... REF_FREE + * could correspond to tp_state == CLOSED or nonexistend tpcb, REF_OPEN to + * tp_state anywhere from AK_WAIT or CR_SENT to CLOSING REF_OPENING could + * correspond to LISTENING, because that's the way it's used, not because the + * correspondence is exact. REF_CLOSED could correspond to REFWAIT */ -#define REF_FROZEN 3 /* has ref timer only */ +#define REF_FROZEN 3 /* has ref timer only */ #define REF_OPEN 2 /* has timers, possibly active */ -#define REF_OPENING 1 /* in use (has a pcb) but no timers */ +#define REF_OPENING 1 /* in use (has a pcb) but no timers */ #define REF_FREE 0 /* free to reallocate */ -#define TM_NTIMERS 6 +#define TM_NTIMERS 6 +struct iso_addr; +struct sockaddr; +struct socket; +struct tp_pcb; +struct inpcb; struct tp_ref { - struct tp_pcb *tpr_pcb; /* back ptr to PCB */ + struct tp_pcb *tpr_pcb;/* back ptr to PCB */ }; /* PER system stuff (one static structure instead of a bunch of names) */ struct tp_refinfo { - struct tp_ref *tpr_base; - int tpr_size; - int tpr_maxopen; - int tpr_numopen; + struct tp_ref *tpr_base; + int tpr_size; + int tpr_maxopen; + int tpr_numopen; }; struct nl_protosw { - int nlp_afamily; /* address family */ - int (*nlp_putnetaddr)(); /* puts addresses in nl pcb */ - int (*nlp_getnetaddr)(); /* gets addresses from nl pcb */ - int (*nlp_cmpnetaddr)(); /* compares address in pcb with sockaddr */ - int (*nlp_putsufx)(); /* puts transport suffixes in nl pcb */ - int (*nlp_getsufx)(); /* gets transport suffixes from nl pcb */ - int (*nlp_recycle_suffix)();/* clears suffix from nl pcb */ - int (*nlp_mtu)(); /* figures out mtu based on nl used */ - int (*nlp_pcbbind)(); /* bind to pcb for net level */ - int (*nlp_pcbconn)(); /* connect for net level */ - int (*nlp_pcbdisc)(); /* disconnect net level */ - int (*nlp_pcbdetach)(); /* detach net level pcb */ - int (*nlp_pcballoc)(); /* allocate a net level pcb */ - int (*nlp_output)(); /* prepare a packet to give to nl */ - int (*nlp_dgoutput)(); /* prepare a packet to give to nl */ - int (*nlp_ctloutput)(); /* hook for network set/get options */ - caddr_t nlp_pcblist; /* list of xx_pcb's for connections */ + int nlp_afamily; /* address family */ + void (*nlp_putnetaddr) /* puts addresses in nl pcb */ + __P((void *, struct sockaddr *, int)); + void (*nlp_getnetaddr) /* gets addresses from nl pcb */ + __P((void *, struct mbuf *, int)); + int (*nlp_cmpnetaddr) /* compares address in pcb */ + __P((void *, struct sockaddr *, int)); + /* with sockaddr */ + void (*nlp_putsufx) /* puts transport suffixes in */ + __P((void *, caddr_t, int, int)); + /* nl pcb */ + void (*nlp_getsufx) /* gets transport suffixes */ + __P((void *, u_short *, caddr_t, int)); + /* from nl pcb */ + void (*nlp_recycle_suffix) /* clears suffix from nl pcb */ + __P((void *)); + int (*nlp_mtu) /* figures out mtu based on */ + __P((void *)); /* nl used */ + int (*nlp_pcbbind) /* bind to pcb for net level */ + __P((void *, struct mbuf *)); + int (*nlp_pcbconn) /* connect for net level */ + __P((void *, struct mbuf *)); + void (*nlp_pcbdisc) /* disconnect net level */ + __P((void *)); + void (*nlp_pcbdetach) /* detach net level pcb */ + __P((void *)); + int (*nlp_pcballoc) /* allocate a net level pcb */ + __P((struct socket *, void *)); + int (*nlp_output) /* prepare a packet to give */ + __P((struct mbuf *, ...)); /* to nl */ + int (*nlp_dgoutput) /* prepare a packet to give */ + __P((struct mbuf *, ...)); /*to nl*/ + int (*nlp_ctloutput) /* hook for network set/get */ + __P((int, int, caddr_t, struct mbuf *)); + /* options */ + caddr_t nlp_pcblist; /* list of xx_pcb's for connections */ }; struct tp_pcb { - struct tp_pcb *tp_next; - struct tp_pcb *tp_prev; - struct tp_pcb *tp_nextlisten; /* chain all listeners */ - struct socket *tp_sock; /* back ptr */ - u_short tp_state; /* state of fsm */ - short tp_retrans; /* # times can still retrans */ - caddr_t tp_npcb; /* to lower layer pcb */ - struct nl_protosw *tp_nlproto; /* lower-layer dependent routines */ - struct rtentry **tp_routep; /* obtain mtu; inside npcb */ + struct tp_pcb *tp_next; + struct tp_pcb *tp_prev; + struct tp_pcb *tp_nextlisten; /* chain all listeners */ + struct socket *tp_sock;/* back ptr */ + u_short tp_state; /* state of fsm */ + short tp_retrans; /* # times can still retrans */ + caddr_t tp_npcb;/* to lower layer pcb */ + struct nl_protosw *tp_nlproto; /* lower-layer dependent routines */ + struct rtentry **tp_routep; /* obtain mtu; inside npcb */ - RefNum tp_lref; /* local reference */ - RefNum tp_fref; /* foreign reference */ + RefNum tp_lref;/* local reference */ + RefNum tp_fref;/* foreign reference */ - u_int tp_seqmask; /* mask for seq space */ - u_int tp_seqbit; /* bit for seq number wraparound */ - u_int tp_seqhalf; /* half the seq space */ + u_int tp_seqmask; /* mask for seq space */ + u_int tp_seqbit; /* bit for seq number wraparound */ + u_int tp_seqhalf; /* half the seq space */ - struct mbuf *tp_ucddata; /* user connect/disconnect data */ + struct mbuf *tp_ucddata; /* user connect/disconnect data */ /* credit & sequencing info for SENDING */ - u_short tp_fcredit; /* current remote credit in # packets */ - u_short tp_maxfcredit; /* max remote credit in # packets */ - u_short tp_dupacks; /* intuit packet loss before rxt timo */ - u_long tp_cong_win; /* congestion window in bytes. - * see profuse comments in TCP code - */ - u_long tp_ssthresh; /* cong_win threshold for slow start - * exponential to linear switch - */ - SeqNum tp_snduna; /* seq # of lowest unacked DT */ - SeqNum tp_sndnew; /* seq # of lowest unsent DT */ - SeqNum tp_sndnum; /* next seq # to be assigned */ - SeqNum tp_sndnxt; /* what to do next; poss. rxt */ - struct mbuf *tp_sndnxt_m; /* packet corres. to sndnxt*/ - int tp_Nwindow; /* for perf. measurement */ + u_short tp_fcredit; /* current remote credit in # packets */ + u_short tp_maxfcredit; /* max remote credit in # packets */ + u_short tp_dupacks; /* intuit packet loss before rxt timo */ + u_long tp_cong_win; /* congestion window in bytes. see + * profuse comments in TCP code */ + u_long tp_ssthresh; /* cong_win threshold for slow start + * exponential to linear switch */ + SeqNum tp_snduna; /* seq # of lowest unacked DT */ + SeqNum tp_sndnew; /* seq # of lowest unsent DT */ + SeqNum tp_sndnum; /* next seq # to be assigned */ + SeqNum tp_sndnxt; /* what to do next; poss. rxt */ + struct mbuf *tp_sndnxt_m; /* packet corres. to sndnxt */ + int tp_Nwindow; /* for perf. measurement */ /* credit & sequencing info for RECEIVING */ - SeqNum tp_rcvnxt; /* next DT seq # expect to recv */ - SeqNum tp_sent_lcdt; /* cdt according to last ack sent */ - SeqNum tp_sent_uwe; /* uwe according to last ack sent */ - SeqNum tp_sent_rcvnxt; /* rcvnxt according to last ack sent - * needed for perf measurements only - */ - u_short tp_lcredit; /* current local credit in # packets */ - u_short tp_maxlcredit; /* needed for reassembly queue */ - struct mbuf **tp_rsyq; /* unacked stuff recvd out of order */ - int tp_rsycnt; /* number of packets "" "" "" "" */ - u_long tp_rhiwat; /* remember original RCVBUF size */ - - /* receiver congestion state stuff ... */ - u_int tp_win_recv; + SeqNum tp_rcvnxt; /* next DT seq # expect to recv */ + SeqNum tp_sent_lcdt; /* cdt according to last ack sent */ + SeqNum tp_sent_uwe; /* uwe according to last ack sent */ + SeqNum tp_sent_rcvnxt; /* rcvnxt according to last ack sent + * needed for perf measurements only */ + u_short tp_lcredit; /* current local credit in # packets */ + u_short tp_maxlcredit; /* needed for reassembly queue */ + struct mbuf **tp_rsyq;/* unacked stuff recvd out of order */ + int tp_rsycnt; /* number of packets "" "" "" "" */ + u_long tp_rhiwat; /* remember original RCVBUF size */ + + /* receiver congestion state stuff ... */ + u_int tp_win_recv; /* receive window as a scaled int (8 bit fraction part) */ struct cong_sample { - ushort cs_size; /* current window size */ - ushort cs_received; /* PDUs received in this sample */ - ushort cs_ce_set; /* PDUs received in this sample with CE bit set */ - } tp_cong_sample; + ushort cs_size; /* current window size */ + ushort cs_received; /* PDUs received in this + * sample */ + ushort cs_ce_set; /* PDUs received in this + * sample with CE bit set */ + } tp_cong_sample; /* parameters per-connection controllable by user */ - struct tp_conn_param _tp_param; - -#define tp_Nretrans _tp_param.p_Nretrans -#define tp_dr_ticks _tp_param.p_dr_ticks -#define tp_cc_ticks _tp_param.p_cc_ticks -#define tp_dt_ticks _tp_param.p_dt_ticks -#define tp_xpd_ticks _tp_param.p_x_ticks -#define tp_cr_ticks _tp_param.p_cr_ticks -#define tp_keepalive_ticks _tp_param.p_keepalive_ticks -#define tp_sendack_ticks _tp_param.p_sendack_ticks -#define tp_refer_ticks _tp_param.p_ref_ticks -#define tp_inact_ticks _tp_param.p_inact_ticks -#define tp_xtd_format _tp_param.p_xtd_format -#define tp_xpd_service _tp_param.p_xpd_service -#define tp_ack_strat _tp_param.p_ack_strat -#define tp_rx_strat _tp_param.p_rx_strat -#define tp_use_checksum _tp_param.p_use_checksum -#define tp_use_efc _tp_param.p_use_efc -#define tp_use_nxpd _tp_param.p_use_nxpd -#define tp_use_rcc _tp_param.p_use_rcc -#define tp_tpdusize _tp_param.p_tpdusize -#define tp_class _tp_param.p_class -#define tp_winsize _tp_param.p_winsize -#define tp_no_disc_indications _tp_param.p_no_disc_indications -#define tp_dont_change_params _tp_param.p_dont_change_params -#define tp_netservice _tp_param.p_netservice -#define tp_version _tp_param.p_version -#define tp_ptpdusize _tp_param.p_ptpdusize - - int tp_l_tpdusize; - /* whereas tp_tpdusize is log2(the negotiated max size) - * l_tpdusize is the size we'll use when sending, in # chars - */ - - int tp_rtv; /* max round-trip time variance */ - int tp_rtt; /* smoothed round-trip time */ - SeqNum tp_rttseq; /* packet being timed */ - int tp_rttemit; /* when emitted, in ticks */ - int tp_idle; /* last activity, in ticks */ - short tp_rxtcur; /* current retransmit value */ - short tp_rxtshift; /* log(2) of rexmt exp. backoff */ - u_char tp_cebit_off; /* real DEC bit algorithms not in use */ - u_char tp_oktonagle; /* Last unsent pckt may be append to */ - u_char tp_flags; /* values: */ -#define TPF_NLQOS_PDN TPFLAG_NLQOS_PDN + struct tp_conn_param _tp_param; + +#define tp_Nretrans _tp_param.p_Nretrans +#define tp_dr_ticks _tp_param.p_dr_ticks +#define tp_cc_ticks _tp_param.p_cc_ticks +#define tp_dt_ticks _tp_param.p_dt_ticks +#define tp_xpd_ticks _tp_param.p_x_ticks +#define tp_cr_ticks _tp_param.p_cr_ticks +#define tp_keepalive_ticks _tp_param.p_keepalive_ticks +#define tp_sendack_ticks _tp_param.p_sendack_ticks +#define tp_refer_ticks _tp_param.p_ref_ticks +#define tp_inact_ticks _tp_param.p_inact_ticks +#define tp_xtd_format _tp_param.p_xtd_format +#define tp_xpd_service _tp_param.p_xpd_service +#define tp_ack_strat _tp_param.p_ack_strat +#define tp_rx_strat _tp_param.p_rx_strat +#define tp_use_checksum _tp_param.p_use_checksum +#define tp_use_efc _tp_param.p_use_efc +#define tp_use_nxpd _tp_param.p_use_nxpd +#define tp_use_rcc _tp_param.p_use_rcc +#define tp_tpdusize _tp_param.p_tpdusize +#define tp_class _tp_param.p_class +#define tp_winsize _tp_param.p_winsize +#define tp_no_disc_indications _tp_param.p_no_disc_indications +#define tp_dont_change_params _tp_param.p_dont_change_params +#define tp_netservice _tp_param.p_netservice +#define tp_version _tp_param.p_version +#define tp_ptpdusize _tp_param.p_ptpdusize + + int tp_l_tpdusize; + /* + * whereas tp_tpdusize is log2(the negotiated max size) l_tpdusize is + * the size we'll use when sending, in # chars + */ + + int tp_rtv; /* max round-trip time variance */ + int tp_rtt; /* smoothed round-trip time */ + SeqNum tp_rttseq; /* packet being timed */ + int tp_rttemit; /* when emitted, in ticks */ + int tp_idle;/* last activity, in ticks */ + short tp_rxtcur; /* current retransmit value */ + short tp_rxtshift; /* log(2) of rexmt exp. backoff */ + u_char tp_cebit_off; /* real DEC bit algorithms not in use */ + u_char tp_oktonagle; /* Last unsent pckt may be append to */ + u_char tp_flags; /* values: */ +#define TPF_NLQOS_PDN TPFLAG_NLQOS_PDN #define TPF_PEER_ON_SAMENET TPFLAG_PEER_ON_SAMENET #define TPF_GENERAL_ADDR TPFLAG_GENERAL_ADDR #define TPF_DELACK 0x8 @@ -258,53 +279,62 @@ struct tp_pcb { #define USES_PDN(t) (((t)->tp_flags & TPF_NLQOS_PDN) != 0) - unsigned - tp_sendfcc:1, /* shall next ack include FCC parameter? */ - tp_trace:1, /* is this pcb being traced? (not used yet) */ - tp_perf_on:1, /* 0/1 -> performance measuring on */ - tp_reneged:1, /* have we reneged on cdt since last ack? */ - tp_decbit:3, /* dec bit was set, we're in reneg mode */ - tp_notdetached:1; /* Call tp_detach before freeing XXXXXXX */ + unsigned + tp_sendfcc:1, /* shall next ack include FCC + * parameter? */ + tp_trace:1, /* is this pcb being traced? (not + * used yet) */ + tp_perf_on:1, /* 0/1 -> performance measuring on */ + tp_reneged:1, /* have we reneged on cdt since last + * ack? */ + tp_decbit:3, /* dec bit was set, we're in reneg + * mode */ + tp_notdetached:1; /* Call tp_detach before + * freeing XXXXXXX */ #ifdef TP_PERF_MEAS /* performance stats - see tp_stat.h */ - struct tp_pmeas *tp_p_meas; -#endif /* TP_PERF_MEAS */ + struct tp_pmeas *tp_p_meas; +#endif /* TP_PERF_MEAS */ /* addressing */ - u_short tp_domain; /* domain (INET, ISO) */ - /* for compatibility with the *old* way and with INET, be sure that - * that lsuffix and fsuffix are aligned to a short addr. - * having them follow the u_short *suffixlen should suffice (choke) + u_short tp_domain; /* domain (INET, ISO) */ + /* + * for compatibility with the *old* way and with INET, be sure that + * that lsuffix and fsuffix are aligned to a short addr. having them + * follow the u_short *suffixlen should suffice (choke) */ - u_short tp_fsuffixlen; /* foreign suffix */ - char tp_fsuffix[MAX_TSAP_SEL_LEN]; - u_short tp_lsuffixlen; /* local suffix */ - char tp_lsuffix[MAX_TSAP_SEL_LEN]; + u_short tp_fsuffixlen; /* foreign suffix */ + char tp_fsuffix[MAX_TSAP_SEL_LEN]; + u_short tp_lsuffixlen; /* local suffix */ + char tp_lsuffix[MAX_TSAP_SEL_LEN]; #define SHORT_LSUFXP(tpcb) ((short *)((tpcb)->tp_lsuffix)) #define SHORT_FSUFXP(tpcb) ((short *)((tpcb)->tp_fsuffix)) /* Timer stuff */ - u_char tp_vers; /* protocol version */ - u_char tp_peer_acktime; /* used for DT retrans time */ - u_char tp_refstate; /* values REF_FROZEN, etc. above */ - struct tp_pcb *tp_fasttimeo; /* limit pcbs to examine */ - u_int tp_timer[TM_NTIMERS]; /* C timers */ - - struct sockbuf tp_Xsnd; /* for expedited data */ -/* struct sockbuf tp_Xrcv; /* for expedited data */ + u_char tp_vers;/* protocol version */ + u_char tp_peer_acktime; /* used for DT retrans time */ + u_char tp_refstate; /* values REF_FROZEN, etc. above */ + struct tp_pcb *tp_fasttimeo; /* limit pcbs to examine */ + u_int tp_timer[TM_NTIMERS]; /* C timers */ + + struct sockbuf tp_Xsnd; /* for expedited data */ +#if 0 + struct sockbuf tp_Xrcv; /* for expedited data */ +#else #define tp_Xrcv tp_sock->so_rcv - SeqNum tp_Xsndnxt; /* next XPD seq # to send */ - SeqNum tp_Xuna; /* seq # of unacked XPD */ - SeqNum tp_Xrcvnxt; /* next XPD seq # expect to recv */ +#endif + SeqNum tp_Xsndnxt; /* next XPD seq # to send */ + SeqNum tp_Xuna;/* seq # of unacked XPD */ + SeqNum tp_Xrcvnxt; /* next XPD seq # expect to recv */ /* AK subsequencing */ - u_short tp_s_subseq; /* next subseq to send */ - u_short tp_r_subseq; /* highest recv subseq */ + u_short tp_s_subseq; /* next subseq to send */ + u_short tp_r_subseq; /* highest recv subseq */ }; -u_int tp_start_win; +u_int tp_start_win; #define ROUND(scaled_int) (((scaled_int) >> 8) + (((scaled_int) & 0x80) ? 1:0)) @@ -318,33 +348,33 @@ u_int tp_start_win; #define CONG_UPDATE_SAMPLE(pcb, ce_bit) \ pcb->tp_cong_sample.cs_received++; \ if (ce_bit) { \ - pcb->tp_cong_sample.cs_ce_set++; \ + pcb->tp_cong_sample.cs_ce_set++; \ } \ if (pcb->tp_cong_sample.cs_size <= pcb->tp_cong_sample.cs_received) { \ - if ((pcb->tp_cong_sample.cs_ce_set << 1) >= \ - pcb->tp_cong_sample.cs_size ) { \ - pcb->tp_win_recv -= pcb->tp_win_recv >> 3; /* multiply by .875 */ \ - pcb->tp_win_recv = max(1 << 8, pcb->tp_win_recv); \ - } \ - else { \ - pcb->tp_win_recv += (1 << 8); /* add one to the scaled int */ \ - } \ - pcb->tp_lcredit = ROUND(pcb->tp_win_recv); \ - CONG_INIT_SAMPLE(pcb); \ + if ((pcb->tp_cong_sample.cs_ce_set << 1) >= \ + pcb->tp_cong_sample.cs_size ) { \ + pcb->tp_win_recv -= pcb->tp_win_recv >> 3; /* multiply by .875 */ \ + pcb->tp_win_recv = max(1 << 8, pcb->tp_win_recv); \ + } \ + else { \ + pcb->tp_win_recv += (1 << 8); /* add one to the scaled int */ \ + } \ + pcb->tp_lcredit = ROUND(pcb->tp_win_recv); \ + CONG_INIT_SAMPLE(pcb); \ } #ifdef _KERNEL -extern struct tp_refinfo tp_refinfo; -extern struct tp_ref *tp_ref; -extern struct tp_param tp_param; -extern struct nl_protosw nl_protosw[]; -extern struct tp_pcb *tp_listeners; -extern struct tp_pcb *tp_ftimeolist; +extern struct tp_refinfo tp_refinfo; +extern struct tp_ref *tp_ref; +extern struct tp_param tp_param; +extern struct nl_protosw nl_protosw[]; +extern struct tp_pcb *tp_listeners; +extern struct tp_pcb *tp_ftimeolist; #endif -#define sototpcb(so) ((struct tp_pcb *)(so->so_pcb)) -#define sototpref(so) ((sototpcb(so)->tp_ref)) -#define tpcbtoso(tp) ((struct socket *)((tp)->tp_sock)) -#define tpcbtoref(tp) ((struct tp_ref *)((tp)->tp_ref)) +#define sototpcb(so) ((struct tp_pcb *)(so->so_pcb)) +#define sototpref(so) ((sototpcb(so)->tp_ref)) +#define tpcbtoso(tp) ((struct socket *)((tp)->tp_sock)) +#define tpcbtoref(tp) ((struct tp_ref *)((tp)->tp_ref)) -#endif /* _NETISO_TP_PCB_H_ */ +#endif /* _NETISO_TP_PCB_H_ */ diff --git a/sys/netiso/tp_seq.h b/sys/netiso/tp_seq.h index 66ed817bdad..bdedc71c84c 100644 --- a/sys/netiso/tp_seq.h +++ b/sys/netiso/tp_seq.h @@ -1,4 +1,5 @@ -/* $NetBSD: tp_seq.h,v 1.5 1994/06/29 06:40:29 cgd Exp $ */ +/* $OpenBSD: tp_seq.h,v 1.2 1996/03/04 10:36:22 mickey Exp $ */ +/* $NetBSD: tp_seq.h,v 1.6 1996/02/13 22:11:48 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -61,13 +62,12 @@ SOFTWARE. /* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ -/* +/* * These macros perform sequence number arithmetic modulo (2**7 or 2**31). - * The relevant fields in the tpcb are: - * tp_seqmask : the mask of bits that define the sequence space. - * tp_seqbit : 1 + tp_seqmask - * tp_seqhalf : tp_seqbit / 2 or half the sequence space (rounded up) - * Not exactly fast, but at least it's maintainable. + * The relevant fields in the tpcb are: tp_seqmask : the mask of bits that + * define the sequence space. tp_seqbit : 1 + tp_seqmask tp_seqhalf : + * tp_seqbit / 2 or half the sequence space (rounded up) Not exactly fast, + * but at least it's maintainable. */ #ifndef _NETISO_TP_SEQ_H_ @@ -95,7 +95,7 @@ SOFTWARE. ( ((int)((seq)-(operand)) < 0)\ ? ((-(int)((seq)-(operand))) < (int)(tpcb)->tp_seqhalf)\ : !(((int)(seq)-(operand)) < (int)(tpcb)->tp_seqhalf)) - + #define SEQ_MIN(tpcb, a, b) ( SEQ_GT(tpcb, a, b) ? b : a) #define SEQ_MAX(tpcb, a, b) ( SEQ_GT(tpcb, a, b) ? a : b) @@ -118,4 +118,4 @@ SOFTWARE. #define IN_SWINDOW(tpcb, seq, lwe, uwe)\ ( SEQ_GT(tpcb, seq, lwe) && SEQ_LEQ(tpcb, seq, uwe) ) -#endif /* _NETISO_TP_SEQ_H_ */ +#endif /* _NETISO_TP_SEQ_H_ */ diff --git a/sys/netiso/tp_stat.h b/sys/netiso/tp_stat.h index 1743463aa40..e0d3efc22e1 100644 --- a/sys/netiso/tp_stat.h +++ b/sys/netiso/tp_stat.h @@ -1,4 +1,5 @@ -/* $NetBSD: tp_stat.h,v 1.5 1994/06/29 06:40:30 cgd Exp $ */ +/* $OpenBSD: tp_stat.h,v 1.2 1996/03/04 10:36:24 mickey Exp $ */ +/* $NetBSD: tp_stat.h,v 1.6 1996/02/13 22:11:53 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -61,220 +62,223 @@ SOFTWARE. /* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ -/* - * Here are the data structures in which the global - * statistics(counters) are gathered. +/* + * Here are the data structures in which the global statistics(counters) are + * gathered. */ #ifndef _NETISO_TP_STAT_H_ #define _NETISO_TP_STAT_H_ struct tp_stat { - u_long ts_param_ignored; - u_long ts_unused3; - u_long ts_bad_csum; - - u_long ts_inv_length; - u_long ts_inv_pcode; - u_long ts_inv_dutype; - u_long ts_negotfailed; - u_long ts_inv_dref; - u_long ts_inv_pval; - u_long ts_inv_sufx; - u_long ts_inv_aclass; - - u_long ts_xtd_fmt; - u_long ts_use_txpd; - u_long ts_csum_off; - u_long ts_send_drop; - u_long ts_recv_drop; - - u_long ts_xpd_intheway;/* xpd mark caused data flow to stop */ - u_long ts_xpdmark_del; /* xpd markers thrown away */ - u_long ts_dt_ooo; /* dt tpdus received out of order */ - u_long ts_dt_niw; /* dt tpdus received & not in window */ - u_long ts_xpd_niw; /* xpd tpdus received & not in window */ - u_long ts_xpd_dup; - u_long ts_dt_dup; /* dt tpdus received & are duplicates */ - - u_long ts_zfcdt; /* # times f credit went down to 0 */ - u_long ts_lcdt_reduced; /* - # times local cdt reduced on an acknowledgement. - */ - - u_long ts_pkt_rcvd; /* from ip */ - u_long ts_tpdu_rcvd; /* accepted as a TPDU in tp_input */ - u_long ts_tpdu_sent; - u_long ts_unused2; - - u_long ts_retrans_cr; - u_long ts_retrans_cc; - u_long ts_retrans_dr; - u_long ts_retrans_dt; - u_long ts_retrans_xpd; - u_long ts_conn_gaveup; - - u_long ts_ER_sent; - u_long ts_DT_sent; - u_long ts_XPD_sent; - u_long ts_AK_sent; - u_long ts_XAK_sent; - u_long ts_DR_sent; - u_long ts_DC_sent; - u_long ts_CR_sent; - u_long ts_CC_sent; - - u_long ts_ER_rcvd; - u_long ts_DT_rcvd; - u_long ts_XPD_rcvd; - u_long ts_AK_rcvd; - u_long ts_XAK_rcvd; - u_long ts_DR_rcvd; - u_long ts_DC_rcvd; - u_long ts_CR_rcvd; - u_long ts_CC_rcvd; - - u_long ts_Eticks; - u_long ts_Eexpired; - u_long ts_Eset; - u_long ts_Ecan_act; - u_long ts_Cticks; - u_long ts_Cexpired; - u_long ts_Cset; - u_long ts_Ccan_act; - u_long ts_Ccan_inact; - u_long ts_Fdelack; - u_long ts_Fpruned; - - u_long ts_concat_rcvd; - - u_long ts_zdebug; /* zero dref to test timeout on conn estab tp_input.c */ - u_long ts_ydebug; /* throw away pseudo-random pkts tp_input.c */ - u_long ts_unused5; - u_long ts_unused; /* kludged concat to test separation tp_emit.c */ - u_long ts_vdebug; /* kludge to test input size checking tp_emit.c */ - u_long ts_unused4; - u_long ts_ldebug; /* faked a renegging of credit */ - - u_long ts_mb_small; - u_long ts_mb_cluster; - u_long ts_mb_len_distr[17]; - - u_long ts_eot_input; - u_long ts_eot_user; - u_long ts_EOT_sent; - u_long ts_tp0_conn; - u_long ts_tp4_conn; - u_long ts_quench; - u_long ts_rcvdecbit; + u_long ts_param_ignored; + u_long ts_unused3; + u_long ts_bad_csum; + + u_long ts_inv_length; + u_long ts_inv_pcode; + u_long ts_inv_dutype; + u_long ts_negotfailed; + u_long ts_inv_dref; + u_long ts_inv_pval; + u_long ts_inv_sufx; + u_long ts_inv_aclass; + + u_long ts_xtd_fmt; + u_long ts_use_txpd; + u_long ts_csum_off; + u_long ts_send_drop; + u_long ts_recv_drop; + + u_long ts_xpd_intheway; /* xpd mark caused data flow + * to stop */ + u_long ts_xpdmark_del; /* xpd markers thrown away */ + u_long ts_dt_ooo; /* dt tpdus received out of order */ + u_long ts_dt_niw; /* dt tpdus received & not in window */ + u_long ts_xpd_niw; /* xpd tpdus received & not in window */ + u_long ts_xpd_dup; + u_long ts_dt_dup; /* dt tpdus received & are duplicates */ + + u_long ts_zfcdt; /* # times f credit went down to 0 */ + u_long ts_lcdt_reduced; /* # times local cdt reduced + * on an acknowledgement. */ + + u_long ts_pkt_rcvd; /* from ip */ + u_long ts_tpdu_rcvd; /* accepted as a TPDU in tp_input */ + u_long ts_tpdu_sent; + u_long ts_unused2; + + u_long ts_retrans_cr; + u_long ts_retrans_cc; + u_long ts_retrans_dr; + u_long ts_retrans_dt; + u_long ts_retrans_xpd; + u_long ts_conn_gaveup; + + u_long ts_ER_sent; + u_long ts_DT_sent; + u_long ts_XPD_sent; + u_long ts_AK_sent; + u_long ts_XAK_sent; + u_long ts_DR_sent; + u_long ts_DC_sent; + u_long ts_CR_sent; + u_long ts_CC_sent; + + u_long ts_ER_rcvd; + u_long ts_DT_rcvd; + u_long ts_XPD_rcvd; + u_long ts_AK_rcvd; + u_long ts_XAK_rcvd; + u_long ts_DR_rcvd; + u_long ts_DC_rcvd; + u_long ts_CR_rcvd; + u_long ts_CC_rcvd; + + u_long ts_Eticks; + u_long ts_Eexpired; + u_long ts_Eset; + u_long ts_Ecan_act; + u_long ts_Cticks; + u_long ts_Cexpired; + u_long ts_Cset; + u_long ts_Ccan_act; + u_long ts_Ccan_inact; + u_long ts_Fdelack; + u_long ts_Fpruned; + + u_long ts_concat_rcvd; + + u_long ts_zdebug; /* zero dref to test timeout on conn + * estab tp_input.c */ + u_long ts_ydebug; /* throw away pseudo-random pkts + * tp_input.c */ + u_long ts_unused5; + u_long ts_unused; /* kludged concat to test separation + * tp_emit.c */ + u_long ts_vdebug; /* kludge to test input size checking + * tp_emit.c */ + u_long ts_unused4; + u_long ts_ldebug; /* faked a renegging of credit */ + + u_long ts_mb_small; + u_long ts_mb_cluster; + u_long ts_mb_len_distr[17]; + + u_long ts_eot_input; + u_long ts_eot_user; + u_long ts_EOT_sent; + u_long ts_tp0_conn; + u_long ts_tp4_conn; + u_long ts_quench; + u_long ts_rcvdecbit; #define NRTT_CATEGORIES 4 - /* The 4 categories are: - * 0 --> tp_flags: ~TPF_PEER_ON_SAMENET | TPF_NL_PDN - * 1 --> tp_flags: ~TPF_PEER_ON_SAMENET | ~TPF_NL_PDN - * 2 --> tp_flags: TPF_PEER_ON_SAMENET | ~TPF_NL_PDN - * 3 --> tp_flags: TPF_PEER_ON_SAMENET | TPF_NL_PDN + /* + * The 4 categories are: 0 --> tp_flags: ~TPF_PEER_ON_SAMENET | + * TPF_NL_PDN 1 --> tp_flags: ~TPF_PEER_ON_SAMENET | ~TPF_NL_PDN 2 + * --> tp_flags: TPF_PEER_ON_SAMENET | ~TPF_NL_PDN 3 --> tp_flags: + * TPF_PEER_ON_SAMENET | TPF_NL_PDN + */ + int ts_rtt[NRTT_CATEGORIES]; + int ts_rtv[NRTT_CATEGORIES]; + + u_long ts_ackreason[_ACK_NUM_REASONS_]; + /* + * ACK_DONT 0 / ACK_STRAT_EACH 0x1 / ACK_STRAT_FULLWIN 0x4 ACK_DUP + * 0x8 / ACK_EOT 0x10 / ACK_REORDER 0x20 ACK_USRRCV ** ACK_FCC ** */ - int ts_rtt[NRTT_CATEGORIES]; - int ts_rtv[NRTT_CATEGORIES]; - - u_long ts_ackreason[_ACK_NUM_REASONS_]; - /* ACK_DONT 0 / ACK_STRAT_EACH 0x1 / ACK_STRAT_FULLWIN 0x4 - * ACK_DUP 0x8 / ACK_EOT 0x10 / ACK_REORDER 0x20 - * ACK_USRRCV ** - * ACK_FCC ** - */ -} tp_stat ; -#define TP_PM_MAX 0xa /* 10 decimal */ +} tp_stat; +#define TP_PM_MAX 0xa /* 10 decimal */ #define IncStat(x) tp_stat./**/x/**/++ #ifdef TP_PERF_MEAS -#define PStat(Tpcb, X) (Tpcb)->tp_p_meas->/**/X/**/ +#define PStat(Tpcb, X) (Tpcb)->tp_p_meas->/**/X /**/ #define IncPStat(Tpcb, X) if((Tpcb)->tp_perf_on) (Tpcb)->tp_p_meas->/**/X/**/++ -/* BEWARE OF MACROS like this ^^^ must be sure it's surrounded by {} if - * it's used in an if-else statement. +/* + * BEWARE OF MACROS like this ^^^ must be sure it's surrounded by {} if it's + * used in an if-else statement. */ /* for perf measurement stuff: maximum window size it can handle */ struct tp_pmeas { - /* the first few are distributions as a fn of window size - * only keep enough space for normal format plus 1 slot for - * extended format, in case any windows larger than 15 are used - */ - - /* - * tps_npdusent: for each call to tp_sbsend, we inc the - * element representing the number of pdus sent in this call - */ - int tps_win_lim_by_cdt[TP_PM_MAX+1]; - int tps_win_lim_by_data[TP_PM_MAX+1]; - /* - * tps_sendtime: Each call to tp_sbsend() is timed. For - * Each window size, we keep the running average of the time - * taken by tp_sbsend() for each window size. - */ - int tps_sendtime[TP_PM_MAX+1]; - /* - * n_TMsendack: # times ack sent because timer went off - * n_ack_cuz_eot: # times ack sent due to EOTSDU on incoming packet - * n_ack_cuz_dup: # times ack sent for receiving a duplicate pkt. - * n_ack_cuz_fullwin: # times ack sent for receiving the full window. - * n_ack_cuz_doack: # times ack sent for having just reordered data. - */ - int tps_n_TMsendack; - int tps_n_ack_cuz_eot; - int tps_n_ack_cuz_fullwin; - int tps_n_ack_cuz_reorder; - int tps_n_ack_cuz_dup; - int tps_n_ack_cuz_strat; - /* - * when we send an ack: how much less than the "expected" window - * did we actually ack. For example: if we last sent a credit - * of 10, and we're acking now for whatever reason, and have - * only received 6 since our last credit advertisement, we'll - * keep the difference, 4, in this variable. - */ - int tps_ack_early[TP_PM_MAX+1]; - /* - * when we ack, for the # pkts we actually acked w/ this ack, - * how much cdt are we advertising? - * [ size of window acknowledged ] [ cdt we're giving ] - */ - int tps_cdt_acked[TP_PM_MAX+1][TP_PM_MAX+1]; - - int tps_AK_sent; - int tps_XAK_sent; - int tps_DT_sent; - int tps_XPD_sent; - int tps_AK_rcvd; - int tps_XAK_rcvd; - int tps_DT_rcvd; - int tps_XPD_rcvd; - - int Nb_from_sess; - int Nb_to_sess; - int Nb_to_ll; - int Nb_from_ll; + /* + * the first few are distributions as a fn of window size only keep + * enough space for normal format plus 1 slot for extended format, in + * case any windows larger than 15 are used + */ + + /* + * tps_npdusent: for each call to tp_sbsend, we inc the element + * representing the number of pdus sent in this call + */ + int tps_win_lim_by_cdt[TP_PM_MAX + 1]; + int tps_win_lim_by_data[TP_PM_MAX + 1]; + /* + * tps_sendtime: Each call to tp_sbsend() is timed. For Each window + * size, we keep the running average of the time taken by tp_sbsend() + * for each window size. + */ + int tps_sendtime[TP_PM_MAX + 1]; + /* + * n_TMsendack: # times ack sent because timer went off + * n_ack_cuz_eot: # times ack sent due to EOTSDU on incoming packet + * n_ack_cuz_dup: # times ack sent for receiving a duplicate pkt. + * n_ack_cuz_fullwin: # times ack sent for receiving the full window. + * n_ack_cuz_doack: # times ack sent for having just reordered data. + */ + int tps_n_TMsendack; + int tps_n_ack_cuz_eot; + int tps_n_ack_cuz_fullwin; + int tps_n_ack_cuz_reorder; + int tps_n_ack_cuz_dup; + int tps_n_ack_cuz_strat; + /* + * when we send an ack: how much less than the "expected" window + * did we actually ack. For example: if we last sent a credit + * of 10, and we're acking now for whatever reason, and have + * only received 6 since our last credit advertisement, we'll + * keep the difference, 4, in this variable. + */ + int tps_ack_early[TP_PM_MAX + 1]; + /* + * when we ack, for the # pkts we actually acked w/ this ack, + * how much cdt are we advertising? + * [ size of window acknowledged ] [ cdt we're giving ] + */ + int tps_cdt_acked[TP_PM_MAX + 1][TP_PM_MAX + 1]; + + int tps_AK_sent; + int tps_XAK_sent; + int tps_DT_sent; + int tps_XPD_sent; + int tps_AK_rcvd; + int tps_XAK_rcvd; + int tps_DT_rcvd; + int tps_XPD_rcvd; + + int Nb_from_sess; + int Nb_to_sess; + int Nb_to_ll; + int Nb_from_ll; }; -#define IFPERF(tpcb) if (tpcb->tp_perf_on && tpcb->tp_p_meas) { -#define ENDPERF } #else -int PStat_Junk; +int PStat_Junk; #define PStat(tpcb, x) PStat_Junk -#define IncPStat(tpcb, x) /* no-op */ +#define IncPStat(tpcb, x) /* no-op */ #define tpmeas(a,b,c,d,e,f) 0 -#define IFPERF(x) if (0) { -#define ENDPERF } +#endif /* TP_PERF_MEAS */ + -#endif /* TP_PERF_MEAS */ +#define DOPERF(tpcb) (tpcb->tp_perf_on && tpcb->tp_p_meas) -#endif /* _NETISO_TP_STAT_H_ */ +#endif /* _NETISO_TP_STAT_H_ */ diff --git a/sys/netiso/tp_states.h b/sys/netiso/tp_states.h index 155cfd2b986..bf8ab602bdb 100644 --- a/sys/netiso/tp_states.h +++ b/sys/netiso/tp_states.h @@ -1,3 +1,4 @@ +/* $OpenBSD: tp_states.h,v 1.2 1996/03/04 10:36:26 mickey Exp $ */ /* $NetBSD: tp_states.h,v 1.4 1994/06/29 06:40:31 cgd Exp $ */ #define ST_ERROR 0x0 diff --git a/sys/netiso/tp_states.init b/sys/netiso/tp_states.init index d6a599696e3..47e35fb0bff 100644 --- a/sys/netiso/tp_states.init +++ b/sys/netiso/tp_states.init @@ -1,3 +1,4 @@ +/* $OpenBSD: tp_states.init,v 1.2 1996/03/04 10:36:27 mickey Exp $ */ /* $NetBSD: tp_states.init,v 1.4 1994/06/29 06:40:33 cgd Exp $ */ {0x3,0x0}, diff --git a/sys/netiso/tp_subr.c b/sys/netiso/tp_subr.c index c16c842c3f2..6334e4faf80 100644 --- a/sys/netiso/tp_subr.c +++ b/sys/netiso/tp_subr.c @@ -1,4 +1,5 @@ -/* $NetBSD: tp_subr.c,v 1.6 1995/08/04 01:13:29 mycroft Exp $ */ +/* $OpenBSD: tp_subr.c,v 1.2 1996/03/04 10:36:29 mickey Exp $ */ +/* $NetBSD: tp_subr.c,v 1.7 1996/02/13 22:11:59 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -61,14 +62,13 @@ SOFTWARE. /* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ -/* - * The main work of data transfer is done here. - * These routines are called from tp.trans. - * They include the routines that check the validity of acks and Xacks, - * (tp_goodack() and tp_goodXack() ) - * take packets from socket buffers and send them (tp_send()), - * drop the data from the socket buffers (tp_sbdrop()), - * and put incoming packet data into socket buffers (tp_stash()). +/* + * The main work of data transfer is done here. These routines are called + * from tp.trans. They include the routines that check the validity of acks + * and Xacks, (tp_goodack() and tp_goodXack() ) take packets from socket + * buffers and send them (tp_send()), drop the data from the socket buffers + * (tp_sbdrop()), and put incoming packet data into socket buffers + * (tp_stash()). */ #include <sys/param.h> @@ -92,17 +92,16 @@ SOFTWARE. #include <netiso/tp_trace.h> #include <netiso/tp_meas.h> #include <netiso/tp_seq.h> +#include <netiso/tp_var.h> -int tp_emit(), tp_sbdrop(); -int tprexmtthresh = 3; -extern int ticks; -void tp_send(); +int tprexmtthresh = 3; +extern int ticks; /* * CALLED FROM: * tp.trans, when an XAK arrives * FUNCTION and ARGUMENTS: - * Determines if the sequence number (seq) from the XAK + * Determines if the sequence number (seq) from the XAK * acks anything new. If so, drop the appropriate tpdu * from the XPD send queue. * RETURN VALUE: @@ -110,40 +109,46 @@ void tp_send(); */ int tp_goodXack(tpcb, seq) - struct tp_pcb *tpcb; - SeqNum seq; + struct tp_pcb *tpcb; + SeqNum seq; { - IFTRACE(D_XPD) - tptraceTPCB(TPPTgotXack, - seq, tpcb->tp_Xuna, tpcb->tp_Xsndnxt, tpcb->tp_sndnew, - tpcb->tp_snduna); - ENDTRACE - - if ( seq == tpcb->tp_Xuna ) { - tpcb->tp_Xuna = tpcb->tp_Xsndnxt; - - /* DROP 1 packet from the Xsnd socket buf - just so happens - * that only one packet can be there at any time - * so drop the whole thing. If you allow > 1 packet - * the socket buffer, then you'll have to keep - * track of how many characters went w/ each XPD tpdu, so this - * will get messier - */ - IFDEBUG(D_XPD) - dump_mbuf(tpcb->tp_Xsnd.sb_mb, - "tp_goodXack Xsnd before sbdrop"); - ENDDEBUG - - IFTRACE(D_XPD) - tptraceTPCB(TPPTmisc, - "goodXack: dropping cc ", - (int)(tpcb->tp_Xsnd.sb_cc), - 0,0,0); - ENDTRACE - sbdroprecord(&tpcb->tp_Xsnd); - return 1; - } +#ifdef TPPT + if (tp_traceflags[D_XPD]) { + tptraceTPCB(TPPTgotXack, + seq, tpcb->tp_Xuna, tpcb->tp_Xsndnxt, tpcb->tp_sndnew, + tpcb->tp_snduna); + } +#endif + + if (seq == tpcb->tp_Xuna) { + tpcb->tp_Xuna = tpcb->tp_Xsndnxt; + + /* + * DROP 1 packet from the Xsnd socket buf - just so happens + * that only one packet can be there at any time so drop the + * whole thing. If you allow > 1 packet the socket buffer, + * then you'll have to keep track of how many characters went + * w/ each XPD tpdu, so this will get messier + */ +#ifdef ARGO_DEBUG + if (argo_debug[D_XPD]) { + dump_mbuf(tpcb->tp_Xsnd.sb_mb, + "tp_goodXack Xsnd before sbdrop"); + } +#endif + +#ifdef TPPT + if (tp_traceflags[D_XPD]) { + tptraceTPCB(TPPTmisc, + "goodXack: dropping cc ", + (int) (tpcb->tp_Xsnd.sb_cc), + 0, 0, 0); + } +#endif + sbdroprecord(&tpcb->tp_Xsnd); + return 1; + } return 0; } @@ -161,19 +166,22 @@ tp_goodXack(tpcb, seq) void tp_rtt_rtv(tpcb) -register struct tp_pcb *tpcb; + register struct tp_pcb *tpcb; { - int old = tpcb->tp_rtt; - int delta, elapsed = ticks - tpcb->tp_rttemit; + int old = tpcb->tp_rtt; + int delta = 0, + elapsed = ticks - tpcb->tp_rttemit; if (tpcb->tp_rtt != 0) { /* - * rtt is the smoothed round trip time in machine clock ticks (hz). - * It is stored as a fixed point number, unscaled (unlike the tcp - * srtt). The rationale here is that it is only significant to the - * nearest unit of slowtimo, which is at least 8 machine clock ticks - * so there is no need to scale. The smoothing is done according - * to the same formula as TCP (rtt = rtt*7/8 + measured_rtt/8). + * rtt is the smoothed round trip time in machine clock + * ticks (hz). It is stored as a fixed point number, + * unscaled (unlike the tcp srtt). The rationale here + * is that it is only significant to the nearest unit of + * slowtimo, which is at least 8 machine clock ticks + * so there is no need to scale. The smoothing is done + * according to the same formula as TCP (rtt = rtt*7/8 + * + measured_rtt/8). */ delta = elapsed - tpcb->tp_rtt; if ((tpcb->tp_rtt += (delta >> TP_RTT_ALPHA)) <= 0) @@ -189,10 +197,10 @@ register struct tp_pcb *tpcb; if ((tpcb->tp_rtv += ((delta - tpcb->tp_rtv) >> TP_RTV_ALPHA)) <= 0) tpcb->tp_rtv = 1; } else { - /* - * No rtt measurement yet - use the unsmoothed rtt. - * Set the variance to half the rtt (so our first - * retransmit happens at 3*rtt) + /* + * No rtt measurement yet - use the unsmoothed rtt. Set the + * variance to half the rtt (so our first retransmit happens + * at 3*rtt) */ tpcb->tp_rtt = elapsed; tpcb->tp_rtv = elapsed >> 1; @@ -211,11 +219,13 @@ register struct tp_pcb *tpcb; * the minimum feasible timer (which is 2 ticks)." */ TP_RANGESET(tpcb->tp_dt_ticks, TP_REXMTVAL(tpcb), - tpcb->tp_peer_acktime, 128 /* XXX */); - IFDEBUG(D_RTT) + tpcb->tp_peer_acktime, 128 /* XXX */ ); +#ifdef ARGO_DEBUG + if (argo_debug[D_RTT]) { printf("%s tpcb 0x%x, elapsed %d, delta %d, rtt %d, rtv %d, old %d\n", - "tp_rtt_rtv:",tpcb,elapsed,delta,tpcb->tp_rtt,tpcb->tp_rtv,old); - ENDDEBUG + "tp_rtt_rtv:", tpcb, elapsed, delta, tpcb->tp_rtt, tpcb->tp_rtv, old); + } +#endif tpcb->tp_rxtcur = tpcb->tp_dt_ticks; } @@ -223,7 +233,7 @@ register struct tp_pcb *tpcb; * CALLED FROM: * tp.trans when an AK arrives * FUNCTION and ARGUMENTS: - * Given (cdt), the credit from the AK tpdu, and + * Given (cdt), the credit from the AK tpdu, and * (seq), the sequence number from the AK tpdu, * tp_goodack() determines if the AK acknowledges something in the send * window, and if so, drops the appropriate packets from the retransmission @@ -240,55 +250,71 @@ register struct tp_pcb *tpcb; */ int tp_goodack(tpcb, cdt, seq, subseq) - register struct tp_pcb *tpcb; - u_int cdt; - register SeqNum seq; - u_int subseq; + register struct tp_pcb *tpcb; + u_int cdt; + register SeqNum seq; + u_int subseq; { - int old_fcredit; - int bang = 0; /* bang --> ack for something heretofore unacked */ - u_int bytes_acked; + int old_fcredit = 0; + int bang = 0; /* bang --> ack for something + * heretofore unacked */ + u_int bytes_acked; - IFDEBUG(D_ACKRECV) +#ifdef ARGO_DEBUG + if (argo_debug[D_ACKRECV]) { printf("goodack tpcb 0x%x seq 0x%x cdt %d una 0x%x new 0x%x nxt 0x%x\n", - tpcb, seq, cdt, tpcb->tp_snduna, tpcb->tp_sndnew, tpcb->tp_sndnxt); - ENDDEBUG - IFTRACE(D_ACKRECV) - tptraceTPCB(TPPTgotack, - seq,cdt, tpcb->tp_snduna,tpcb->tp_sndnew,subseq); - ENDTRACE + tpcb, seq, cdt, tpcb->tp_snduna, tpcb->tp_sndnew, tpcb->tp_sndnxt); + } +#endif - IFPERF(tpcb) - tpmeas(tpcb->tp_lref, TPtime_ack_rcvd, (struct timeval *)0, seq, 0, 0); - ENDPERF +#ifdef TPPT + if (tp_traceflags[D_ACKRECV]) { + tptraceTPCB(TPPTgotack, + seq, cdt, tpcb->tp_snduna, tpcb->tp_sndnew, subseq); + } +#endif + +#ifdef TP_PERF_MEAS + if (DOPERF(tpcb)) { + tpmeas(tpcb->tp_lref, TPtime_ack_rcvd, (struct timeval *) 0, seq, 0, 0); + } +#endif if (seq == tpcb->tp_snduna) { if (subseq < tpcb->tp_r_subseq || - (subseq == tpcb->tp_r_subseq && cdt <= tpcb->tp_fcredit)) { - discard_the_ack: - IFDEBUG(D_ACKRECV) + (subseq == tpcb->tp_r_subseq && cdt <= tpcb->tp_fcredit)) { + discard_the_ack: +#ifdef ARGO_DEBUG + if (argo_debug[D_ACKRECV]) { printf("goodack discard : tpcb 0x%x subseq %d r_subseq %d\n", - tpcb, subseq, tpcb->tp_r_subseq); - ENDDEBUG + tpcb, subseq, tpcb->tp_r_subseq); + } +#endif goto done; } - if (cdt == tpcb->tp_fcredit /*&& thus subseq > tpcb->tp_r_subseq */) { + if (cdt == tpcb->tp_fcredit /* && thus subseq > + tpcb->tp_r_subseq */ ) { tpcb->tp_r_subseq = subseq; if (tpcb->tp_timer[TM_data_retrans] == 0) tpcb->tp_dupacks = 0; else if (++tpcb->tp_dupacks == tprexmtthresh) { - /* partner went out of his way to signal with different - subsequences that he has the same lack of an expected - packet. This may be an early indiciation of a loss */ - - SeqNum onxt = tpcb->tp_sndnxt; - struct mbuf *onxt_m = tpcb->tp_sndnxt_m; - u_int win = min(tpcb->tp_fcredit, - tpcb->tp_cong_win / tpcb->tp_l_tpdusize) / 2; - IFDEBUG(D_ACKRECV) + /* + * partner went out of his way to signal with + * different subsequences that he has the + * same lack of an expected packet. This may + * be an early indiciation of a loss + */ + + SeqNum onxt = tpcb->tp_sndnxt; + struct mbuf *onxt_m = tpcb->tp_sndnxt_m; + u_int win = min(tpcb->tp_fcredit, + tpcb->tp_cong_win / tpcb->tp_l_tpdusize) / 2; +#ifdef ARGO_DEBUG + if (argo_debug[D_ACKRECV]) { printf("%s tpcb 0x%x seq 0x%x rttseq 0x%x onxt 0x%x\n", - "goodack dupacks:", tpcb, seq, tpcb->tp_rttseq, onxt); - ENDDEBUG + "goodack dupacks:", tpcb, seq, tpcb->tp_rttseq, onxt); + } +#endif if (win < 2) win = 2; tpcb->tp_ssthresh = win * tpcb->tp_l_tpdusize; @@ -304,7 +330,6 @@ tp_goodack(tpcb, cdt, seq, subseq) tpcb->tp_sndnxt = onxt; tpcb->tp_sndnxt_m = onxt_m; } - } else if (tpcb->tp_dupacks > tprexmtthresh) { tpcb->tp_cong_win += tpcb->tp_l_tpdusize; } @@ -317,8 +342,8 @@ tp_goodack(tpcb, cdt, seq, subseq) * for the other side's cached packets, retract it. */ if (tpcb->tp_dupacks > tprexmtthresh && - tpcb->tp_cong_win > tpcb->tp_ssthresh) - tpcb->tp_cong_win = tpcb->tp_ssthresh; + tpcb->tp_cong_win > tpcb->tp_ssthresh) + tpcb->tp_cong_win = tpcb->tp_ssthresh; tpcb->tp_r_subseq = subseq; old_fcredit = tpcb->tp_fcredit; tpcb->tp_fcredit = cdt; @@ -360,7 +385,7 @@ tp_goodack(tpcb, cdt, seq, subseq) * open quickly enough. */ { - u_int cw = tpcb->tp_cong_win, incr = tpcb->tp_l_tpdusize; + u_int cw = tpcb->tp_cong_win, incr = tpcb->tp_l_tpdusize; incr = min(incr, bytes_acked); if (cw > tpcb->tp_ssthresh) @@ -370,13 +395,12 @@ tp_goodack(tpcb, cdt, seq, subseq) } tpcb->tp_snduna = seq; if (SEQ_LT(tpcb, tpcb->tp_sndnxt, seq)) { - tpcb->tp_sndnxt = seq; - tpcb->tp_sndnxt_m = 0; + tpcb->tp_sndnxt = seq; + tpcb->tp_sndnxt_m = 0; } bang++; - } - - if( cdt != 0 && old_fcredit == 0 ) { + } + if (cdt != 0 && old_fcredit == 0) { tpcb->tp_sendfcc = 1; } if (cdt == 0) { @@ -396,12 +420,17 @@ tp_goodack(tpcb, cdt, seq, subseq) bang |= (old_fcredit < cdt); done: - IFDEBUG(D_ACKRECV) +#ifdef ARGO_DEBUG + if (argo_debug[D_ACKRECV]) { printf("goodack returns 0x%x, cdt 0x%x ocdt 0x%x cwin 0x%x\n", - bang, cdt, old_fcredit, tpcb->tp_cong_win); - ENDDEBUG - /* if (bang) XXXXX Very bad to remove this test, but somethings broken */ - tp_send(tpcb); + bang, cdt, old_fcredit, tpcb->tp_cong_win); + } +#endif + /* + * if (bang) XXXXX Very bad to remove this test, but somethings + * broken + */ + tp_send(tpcb); return (bang); } @@ -412,22 +441,25 @@ done: * drops everything up TO but not INCLUDING seq # (seq) * from the retransmission queue. */ -tp_sbdrop(tpcb, seq) - register struct tp_pcb *tpcb; - SeqNum seq; +int +tp_sbdrop(tpcb, seq) + register struct tp_pcb *tpcb; + SeqNum seq; { struct sockbuf *sb = &tpcb->tp_sock->so_snd; - register int i = SEQ_SUB(tpcb, seq, tpcb->tp_snduna); - int oldcc = sb->sb_cc, oldi = i; + register int i = SEQ_SUB(tpcb, seq, tpcb->tp_snduna); + int oldcc = sb->sb_cc, oldi = i; if (i >= tpcb->tp_seqhalf) printf("tp_spdropping too much -- should panic"); while (i-- > 0) sbdroprecord(sb); - IFDEBUG(D_ACKRECV) +#ifdef ARGO_DEBUG + if (argo_debug[D_ACKRECV]) { printf("tp_sbdroping %d pkts %d bytes on %x at 0x%x\n", - oldi, oldcc - sb->sb_cc, tpcb, seq); - ENDDEBUG + oldi, oldcc - sb->sb_cc, tpcb, seq); + } +#endif if (sb_notify(sb)) sowwakeup(tpcb->tp_sock); return (oldcc - sb->sb_cc); @@ -453,18 +485,18 @@ tp_sbdrop(tpcb, seq) */ void tp_send(tpcb) - register struct tp_pcb *tpcb; + register struct tp_pcb *tpcb; { - register int len; - register struct mbuf *m; - struct mbuf *mb = 0; - struct sockbuf *sb = &tpcb->tp_sock->so_snd; - unsigned int eotsdu = 0; - SeqNum highseq, checkseq; - int idle, idleticks, off, cong_win; + register int len; + register struct mbuf *m; + struct mbuf *mb = 0; + struct sockbuf *sb = &tpcb->tp_sock->so_snd; + unsigned int eotsdu = 0; + SeqNum highseq, checkseq; + int idle, idleticks, off, cong_win; #ifdef TP_PERF_MEAS - int send_start_time = ticks; - SeqNum oldnxt = tpcb->tp_sndnxt; + int send_start_time = ticks; + SeqNum oldnxt = tpcb->tp_sndnxt; #endif /* TP_PERF_MEAS */ idle = (tpcb->tp_snduna == tpcb->tp_sndnew); @@ -478,74 +510,86 @@ tp_send(tpcb) */ tpcb->tp_cong_win = tpcb->tp_l_tpdusize; } - cong_win = tpcb->tp_cong_win; highseq = SEQ(tpcb, tpcb->tp_fcredit + tpcb->tp_snduna); if (tpcb->tp_Xsnd.sb_mb) highseq = SEQ_MIN(tpcb, highseq, tpcb->tp_sndnew); - - IFDEBUG(D_DATA) + +#ifdef ARGO_DEBUG + if (argo_debug[D_DATA]) { printf("tp_send enter tpcb 0x%x nxt 0x%x win %d high 0x%x\n", - tpcb, tpcb->tp_sndnxt, cong_win, highseq); - ENDDEBUG - IFTRACE(D_DATA) - tptraceTPCB( TPPTmisc, "tp_send sndnew snduna", - tpcb->tp_sndnew, tpcb->tp_snduna, 0, 0); - tptraceTPCB( TPPTmisc, "tp_send tpcb->tp_sndnxt win fcredit congwin", - tpcb->tp_sndnxt, cong_win, tpcb->tp_fcredit, tpcb->tp_cong_win); - ENDTRACE - IFTRACE(D_DATA) - tptraceTPCB( TPPTmisc, "tp_send 2 nxt high fcredit congwin", - tpcb->tp_sndnxt, highseq, tpcb->tp_fcredit, cong_win); - ENDTRACE - - if (tpcb->tp_sndnxt_m) + tpcb, tpcb->tp_sndnxt, cong_win, highseq); + } +#endif +#ifdef TPPT + if (tp_traceflags[D_DATA]) { + tptraceTPCB(TPPTmisc, "tp_send sndnew snduna", + tpcb->tp_sndnew, tpcb->tp_snduna, 0, 0); + tptraceTPCB(TPPTmisc, "tp_send tpcb->tp_sndnxt win fcredit congwin", + tpcb->tp_sndnxt, cong_win, tpcb->tp_fcredit, tpcb->tp_cong_win); + } +#endif +#ifdef TPPT + if (tp_traceflags[D_DATA]) { + tptraceTPCB(TPPTmisc, "tp_send 2 nxt high fcredit congwin", + tpcb->tp_sndnxt, highseq, tpcb->tp_fcredit, cong_win); + } +#endif + + if (tpcb->tp_sndnxt_m) m = tpcb->tp_sndnxt_m; else { off = SEQ_SUB(tpcb, tpcb->tp_sndnxt, tpcb->tp_snduna); for (m = sb->sb_mb; m && off > 0; m = m->m_next) off--; } -send: /* * Avoid silly window syndrome here . . . figure out how! */ checkseq = tpcb->tp_sndnum; if (idle && SEQ_LT(tpcb, tpcb->tp_sndnum, highseq)) - checkseq = highseq; /* i.e. DON'T retain highest assigned packet */ + checkseq = highseq; /* i.e. DON'T retain highest assigned + * packet */ while ((SEQ_LT(tpcb, tpcb->tp_sndnxt, highseq)) && m && cong_win > 0) { eotsdu = (m->m_flags & M_EOR) != 0; len = m->m_pkthdr.len; if (tpcb->tp_sndnxt == checkseq && eotsdu == 0 && - len < (tpcb->tp_l_tpdusize / 2)) - break; /* Nagle . . . . . */ + len < (tpcb->tp_l_tpdusize / 2)) + break; /* Nagle . . . . . */ cong_win -= len; - /* make a copy - mb goes into the retransmission list - * while m gets emitted. m_copy won't copy a zero-length mbuf. + /* + * make a copy - mb goes into the retransmission list while m + * gets emitted. m_copy won't copy a zero-length mbuf. */ mb = m; m = m_copy(mb, 0, M_COPYALL); if (m == MNULL) - break; - IFTRACE(D_STASH) - tptraceTPCB( TPPTmisc, - "tp_send mcopy nxt high eotsdu len", - tpcb->tp_sndnxt, highseq, eotsdu, len); - ENDTRACE - - IFDEBUG(D_DATA) + break; +#ifdef TPPT + if (tp_traceflags[D_STASH]) { + tptraceTPCB(TPPTmisc, + "tp_send mcopy nxt high eotsdu len", + tpcb->tp_sndnxt, highseq, eotsdu, len); + } +#endif + +#ifdef ARGO_DEBUG + if (argo_debug[D_DATA]) { printf("tp_sending tpcb 0x%x nxt 0x%x\n", - tpcb, tpcb->tp_sndnxt); - ENDDEBUG - /* when headers are precomputed, may need to fill - in checksum here */ - if (tpcb->tp_sock->so_error = - tp_emit(DT_TPDU_type, tpcb, tpcb->tp_sndnxt, eotsdu, m)) { + tpcb, tpcb->tp_sndnxt); + } +#endif + /* + * when headers are precomputed, may need to fill in checksum + * here + */ + tpcb->tp_sock->so_error = + tp_emit(DT_TPDU_type, tpcb, tpcb->tp_sndnxt, eotsdu, m); + if (tpcb->tp_sock->so_error != 0) /* error */ break; - } m = mb->m_nextpkt; tpcb->tp_sndnxt_m = m; if (tpcb->tp_sndnxt == tpcb->tp_sndnew) { @@ -569,7 +613,7 @@ send: * of retransmit time. */ if (tpcb->tp_timer[TM_data_retrans] == 0 && - tpcb->tp_class != TP_CLASS_0) { + tpcb->tp_class != TP_CLASS_0) { tpcb->tp_timer[TM_data_retrans] = tpcb->tp_dt_ticks; tpcb->tp_timer[TM_sendack] = tpcb->tp_keepalive_ticks; tpcb->tp_rxtshift = 0; @@ -578,61 +622,63 @@ send: if (SEQ_GT(tpcb, tpcb->tp_sndnew, tpcb->tp_sndnum)) tpcb->tp_oktonagle = 0; #ifdef TP_PERF_MEAS - IFPERF(tpcb) - { - register int npkts; - int elapsed = ticks - send_start_time, *t; - struct timeval now; + if (DOPERF(tpcb)) { + register int npkts; + int elapsed = ticks - send_start_time, *t; + struct timeval now; - npkts = SEQ_SUB(tpcb, tpcb->tp_sndnxt, oldnxt); + npkts = SEQ_SUB(tpcb, tpcb->tp_sndnxt, oldnxt); - if (npkts > 0) - tpcb->tp_Nwindow++; + if (npkts > 0) + tpcb->tp_Nwindow++; - if (npkts > TP_PM_MAX) - npkts = TP_PM_MAX; + if (npkts > TP_PM_MAX) + npkts = TP_PM_MAX; - t = &(tpcb->tp_p_meas->tps_sendtime[npkts]); - *t += (t - elapsed) >> TP_RTT_ALPHA; + t = &(tpcb->tp_p_meas->tps_sendtime[npkts]); + *t += (t - elapsed) >> TP_RTT_ALPHA; - if (mb == 0) { - IncPStat(tpcb, tps_win_lim_by_data[npkts] ); - } else { - IncPStat(tpcb, tps_win_lim_by_cdt[npkts] ); - /* not true with congestion-window being used */ - } - now.tv_sec = elapsed / hz; - now.tv_usec = (elapsed - (hz * now.tv_sec)) * 1000000 / hz; - tpmeas( tpcb->tp_lref, - TPsbsend, &elapsed, newseq, tpcb->tp_Nwindow, npkts); + if (mb == 0) { + IncPStat(tpcb, tps_win_lim_by_data[npkts]); + } else { + IncPStat(tpcb, tps_win_lim_by_cdt[npkts]); + /* not true with congestion-window being used */ } - ENDPERF -#endif /* TP_PERF_MEAS */ + now.tv_sec = elapsed / hz; + now.tv_usec = (elapsed - (hz * now.tv_sec)) * 1000000 / hz; + tpmeas(tpcb->tp_lref, + TPsbsend, &elapsed, newseq, tpcb->tp_Nwindow, npkts); + } +#endif /* TP_PERF_MEAS */ + +#ifdef TPPT + if (tp_traceflags[D_DATA]) { + tptraceTPCB(TPPTmisc, + "tp_send at end: new nxt eotsdu error", + tpcb->tp_sndnew, tpcb->tp_sndnxt, eotsdu, + tpcb->tp_sock->so_error); - IFTRACE(D_DATA) - tptraceTPCB( TPPTmisc, - "tp_send at end: new nxt eotsdu error", - tpcb->tp_sndnew, tpcb->tp_sndnxt, eotsdu, tpcb->tp_sock->so_error); - - ENDTRACE + } +#endif } -int TPNagleok; -int TPNagled; +int TPNagleok; +int TPNagled; +int tp_packetize(tpcb, m, eotsdu) -register struct tp_pcb *tpcb; -register struct mbuf *m; -int eotsdu; + register struct tp_pcb *tpcb; + register struct mbuf *m; + int eotsdu; { - register struct mbuf *n; + register struct mbuf *n = NULL; register struct sockbuf *sb = &tpcb->tp_sock->so_snd; - int maxsize = tpcb->tp_l_tpdusize - - tp_headersize(DT_TPDU_type, tpcb) - - (tpcb->tp_use_checksum?4:0) ; - int totlen = m->m_pkthdr.len; - struct mbuf *m_split(); + int maxsize = tpcb->tp_l_tpdusize + - tp_headersize(DT_TPDU_type, tpcb) + - (tpcb->tp_use_checksum ? 4 : 0); + int totlen = m->m_pkthdr.len; + /* * Pre-packetize the data in the sockbuf * according to negotiated mtu. Do it here @@ -641,10 +687,12 @@ int eotsdu; * This presumes knowledge of sockbuf conventions. * TODO: allocate space for header and fill it in (once!). */ - IFDEBUG(D_DATA) +#ifdef ARGO_DEBUG + if (argo_debug[D_DATA]) { printf("SEND BF: maxsize %d totlen %d eotsdu %d sndnum 0x%x\n", - maxsize, totlen, eotsdu, tpcb->tp_sndnum); - ENDTRACE + maxsize, totlen, eotsdu, tpcb->tp_sndnum); + } +#endif if (tpcb->tp_oktonagle) { if ((n = sb->sb_mb) == 0) panic("tp_packetize"); @@ -654,19 +702,23 @@ int eotsdu; panic("tp_packetize 2"); SEQ_INC(tpcb, tpcb->tp_sndnum); if (totlen + n->m_pkthdr.len < maxsize) { - /* There is an unsent packet with space, combine data */ - struct mbuf *old_n = n; - tpsbcheck(tpcb,3); + /* + * There is an unsent packet with space, + * combine data + */ + struct mbuf *old_n = n; + tpsbcheck(tpcb, 3); n->m_pkthdr.len += totlen; while (n->m_next) n = n->m_next; sbcompress(sb, m, n); - tpsbcheck(tpcb,4); + tpsbcheck(tpcb, 4); n = old_n; TPNagled++; goto out; } } + while (m) { n = m; if (totlen > maxsize) { @@ -682,17 +734,20 @@ int eotsdu; } out: if (eotsdu) { - n->m_flags |= M_EOR; /* XXX belongs at end */ + n->m_flags |= M_EOR; /* XXX belongs at end */ tpcb->tp_oktonagle = 0; } else { SEQ_DEC(tpcb, tpcb->tp_sndnum); tpcb->tp_oktonagle = 1; TPNagleok++; } - IFDEBUG(D_DATA) + +#ifdef ARGO_DEBUG + if (argo_debug[D_DATA]) { printf("SEND out: oktonagle %d sndnum 0x%x\n", - tpcb->tp_oktonagle, tpcb->tp_sndnum); - ENDTRACE + tpcb->tp_oktonagle, tpcb->tp_sndnum); + } +#endif return 0; } @@ -702,77 +757,85 @@ out: * CALLED FROM: * tp.trans on arrival of a DT tpdu * FUNCTION, ARGUMENTS, and RETURN VALUE: - * Returns 1 if - * a) something new arrived and it's got eotsdu_reached bit on, - * b) this arrival was caused other out-of-sequence things to be + * Returns 1 if + * a) something new arrived and it's got eotsdu_reached bit on, + * b) this arrival was caused other out-of-sequence things to be * accepted, or - * c) this arrival is the highest seq # for which we last gave credit + * c) this arrival is the highest seq # for which we last gave credit * (sender just sent a whole window) - * In other words, returns 1 if tp should send an ack immediately, 0 if + * In other words, returns 1 if tp should send an ack immediately, 0 if * the ack can wait a while. * * Note: this implementation no longer renegs on credit, (except * when debugging option D_RENEG is on, for the purpose of testing - * ack subsequencing), so we don't need to check for incoming tpdus + * ack subsequencing), so we don't need to check for incoming tpdus * being in a reneged portion of the window. */ +int tp_stash(tpcb, e) - register struct tp_pcb *tpcb; - register struct tp_event *e; + register struct tp_pcb *tpcb; + register struct tp_event *e; { - register int ack_reason= tpcb->tp_ack_strat & ACK_STRAT_EACH; - /* 0--> delay acks until full window */ - /* 1--> ack each tpdu */ -#ifndef lint -#define E e->ATTR(DT_TPDU) -#else /* lint */ -#define E e->ev_union.EV_DT_TPDU -#endif /* lint */ - - if ( E.e_eot ) { + register int ack_reason = tpcb->tp_ack_strat & ACK_STRAT_EACH; + /* 0--> delay acks until full window */ + /* 1--> ack each tpdu */ +#define E e->TPDU_ATTR(DT) + + if (E.e_eot) { register struct mbuf *n = E.e_data; n->m_flags |= M_EOR; n->m_act = 0; } - IFDEBUG(D_STASH) - dump_mbuf(tpcb->tp_sock->so_rcv.sb_mb, - "stash: so_rcv before appending"); - dump_mbuf(E.e_data, - "stash: e_data before appending"); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_STASH]) { + dump_mbuf(tpcb->tp_sock->so_rcv.sb_mb, + "stash: so_rcv before appending"); + dump_mbuf(E.e_data, + "stash: e_data before appending"); + } +#endif - IFPERF(tpcb) +#ifdef TP_PERF_MEAS + if (DOPERF(tpcb)) { PStat(tpcb, Nb_from_ll) += E.e_datalen; - tpmeas(tpcb->tp_lref, TPtime_from_ll, &e->e_time, - E.e_seq, (u_int)PStat(tpcb, Nb_from_ll), (u_int)E.e_datalen); - ENDPERF + tpmeas(tpcb->tp_lref, TPtime_from_ll, + &e->e_time, E.e_seq, + (u_int) PStat(tpcb, Nb_from_ll), + (u_int) E.e_datalen); + } +#endif if (E.e_seq == tpcb->tp_rcvnxt) { - IFDEBUG(D_STASH) - printf("stash EQ: seq 0x%x datalen 0x%x eot 0x%x\n", - E.e_seq, E.e_datalen, E.e_eot); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_STASH]) { + printf("stash EQ: seq 0x%x datalen 0x%x eot 0x%x\n", + E.e_seq, E.e_datalen, E.e_eot); + } +#endif - IFTRACE(D_STASH) - tptraceTPCB(TPPTmisc, "stash EQ: seq len eot", - E.e_seq, E.e_datalen, E.e_eot, 0); - ENDTRACE +#ifdef TPPT + if (tp_traceflags[D_STASH]) { + tptraceTPCB(TPPTmisc, "stash EQ: seq len eot", + E.e_seq, E.e_datalen, E.e_eot, 0); + } +#endif SET_DELACK(tpcb); sbappend(&tpcb->tp_sock->so_rcv, E.e_data); - SEQ_INC( tpcb, tpcb->tp_rcvnxt ); - /* + SEQ_INC(tpcb, tpcb->tp_rcvnxt); + /* * move chains from the reassembly queue to the socket buffer */ if (tpcb->tp_rsycnt) { register struct mbuf **mp; - struct mbuf **mplim; + struct mbuf **mplim; - mp = tpcb->tp_rsyq + (tpcb->tp_rcvnxt % tpcb->tp_maxlcredit); + mp = tpcb->tp_rsyq + (tpcb->tp_rcvnxt % + tpcb->tp_maxlcredit); mplim = tpcb->tp_rsyq + tpcb->tp_maxlcredit; while (tpcb->tp_rsycnt && *mp) { @@ -785,39 +848,52 @@ tp_stash(tpcb, e) mp = tpcb->tp_rsyq; } } - IFDEBUG(D_STASH) - dump_mbuf(tpcb->tp_sock->so_rcv.sb_mb, - "stash: so_rcv after appending"); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_STASH]) { + dump_mbuf(tpcb->tp_sock->so_rcv.sb_mb, + "stash: so_rcv after appending"); + } +#endif } else { register struct mbuf **mp; - SeqNum uwe; + SeqNum uwe; - IFTRACE(D_STASH) - tptraceTPCB(TPPTmisc, "stash Reseq: seq rcvnxt lcdt", - E.e_seq, tpcb->tp_rcvnxt, tpcb->tp_lcredit, 0); - ENDTRACE +#ifdef TPPT + if (tp_traceflags[D_STASH]) { + tptraceTPCB(TPPTmisc, "stash Reseq: seq rcvnxt lcdt", + E.e_seq, tpcb->tp_rcvnxt, + tpcb->tp_lcredit, 0); + } +#endif if (tpcb->tp_rsyq == 0) tp_rsyset(tpcb); uwe = SEQ(tpcb, tpcb->tp_rcvnxt + tpcb->tp_maxlcredit); if (tpcb->tp_rsyq == 0 || - !IN_RWINDOW(tpcb, E.e_seq, tpcb->tp_rcvnxt, uwe)) { + !IN_RWINDOW(tpcb, E.e_seq, tpcb->tp_rcvnxt, uwe)) { ack_reason = ACK_DONT; m_freem(E.e_data); - } else if (*(mp = tpcb->tp_rsyq + (E.e_seq % tpcb->tp_maxlcredit))) { - IFDEBUG(D_STASH) + } else if (*(mp = tpcb->tp_rsyq + + (E.e_seq % tpcb->tp_maxlcredit)) != NULL ) { +#ifdef ARGO_DEBUG + if (argo_debug[D_STASH]) { printf("tp_stash - drop & ack\n"); - ENDDEBUG + } +#endif - /* retransmission - drop it and force an ack */ + /* + * retransmission - drop it and force + * an ack + */ IncStat(ts_dt_dup); - IFPERF(tpcb) +#ifdef TP_PERF_MEAS + if (DOPERF(tpcb)) { IncPStat(tpcb, tps_n_ack_cuz_dup); - ENDPERF + } +#endif - m_freem(E.e_data); + m_freem(E.e_data); ack_reason |= ACK_DUP; } else { *mp = E.e_data; @@ -825,41 +901,51 @@ tp_stash(tpcb, e) ack_reason = ACK_DONT; } } - /* there were some comments of historical interest here. */ + /* + * there were some comments of historical interest + * here. + */ { LOCAL_CREDIT(tpcb); - if ( E.e_seq == tpcb->tp_sent_uwe ) + if (E.e_seq == tpcb->tp_sent_uwe) ack_reason |= ACK_STRAT_FULLWIN; - IFTRACE(D_STASH) - tptraceTPCB(TPPTmisc, - "end of stash, eot, ack_reason, sent_uwe ", - E.e_eot, ack_reason, tpcb->tp_sent_uwe, 0); - ENDTRACE +#ifdef TPPT + if (tp_traceflags[D_STASH]) { + tptraceTPCB(TPPTmisc, + "end of stash, eot, ack_reason, sent_uwe ", + E.e_eot, ack_reason, tpcb->tp_sent_uwe, 0); + } +#endif - if ( ack_reason == ACK_DONT ) { - IncStat( ts_ackreason[ACK_DONT] ); + if (ack_reason == ACK_DONT) { + IncStat(ts_ackreason[ACK_DONT]); return 0; } else { - IFPERF(tpcb) - if(ack_reason & ACK_STRAT_EACH) { - IncPStat(tpcb, tps_n_ack_cuz_strat); - } else if(ack_reason & ACK_STRAT_FULLWIN) { - IncPStat(tpcb, tps_n_ack_cuz_fullwin); - } else if(ack_reason & ACK_REORDER) { - IncPStat(tpcb, tps_n_ack_cuz_reorder); - } - tpmeas(tpcb->tp_lref, TPtime_ack_sent, 0, - SEQ_ADD(tpcb, E.e_seq, 1), 0, 0); - ENDPERF +#ifdef TP_PERF_MEAS + if (DOPERF(tpcb)) { + if (ack_reason & ACK_STRAT_EACH) { + IncPStat(tpcb, tps_n_ack_cuz_strat); + } else if (ack_reason & ACK_STRAT_FULLWIN) { + IncPStat(tpcb, tps_n_ack_cuz_fullwin); + } else if (ack_reason & ACK_REORDER) { + IncPStat(tpcb, tps_n_ack_cuz_reorder); + } + tpmeas(tpcb->tp_lref, TPtime_ack_sent, 0, + SEQ_ADD(tpcb, E.e_seq, 1), 0, 0); + } +#endif { - register int i; - - /* keep track of all reasons that apply */ - for( i=1; i<_ACK_NUM_REASONS_ ;i++) { - if( ack_reason & (1<<i) ) - IncStat( ts_ackreason[i] ); + register int i; + + /* + * keep track of all reasons + * that apply + */ + for (i = 1; i < _ACK_NUM_REASONS_; i++) { + if (ack_reason & (1 << i)) + IncStat(ts_ackreason[i]); } } return 1; @@ -872,13 +958,14 @@ tp_stash(tpcb, e) * Do this when closing the socket, or when somebody has changed * the space avaible in the receive socket (XXX). */ +void tp_rsyflush(tpcb) -register struct tp_pcb *tpcb; + register struct tp_pcb *tpcb; { - register struct mbuf *m, **mp; + register struct mbuf **mp; if (tpcb->tp_rsycnt) { - for (mp == tpcb->tp_rsyq + tpcb->tp_maxlcredit; - --mp >= tpcb->tp_rsyq; ) + for (mp = tpcb->tp_rsyq + tpcb->tp_maxlcredit; + --mp >= tpcb->tp_rsyq;) if (*mp) { tpcb->tp_rsycnt--; m_freem(*mp); @@ -888,43 +975,47 @@ register struct tp_pcb *tpcb; tpcb->tp_rsycnt = 0; } } - free((caddr_t)tpcb->tp_rsyq, M_PCB); + free((caddr_t) tpcb->tp_rsyq, M_PCB); tpcb->tp_rsyq = 0; } +void tp_rsyset(tpcb) -register struct tp_pcb *tpcb; + register struct tp_pcb *tpcb; { register struct socket *so = tpcb->tp_sock; - int maxcredit = tpcb->tp_xtd_format ? 0xffff : 0xf; - int old_credit = tpcb->tp_maxlcredit; - caddr_t rsyq; + int maxcredit = tpcb->tp_xtd_format ? 0xffff : 0xf; + int old_credit = tpcb->tp_maxlcredit; + caddr_t rsyq; tpcb->tp_maxlcredit = maxcredit = min(maxcredit, - (so->so_rcv.sb_hiwat + tpcb->tp_l_tpdusize)/ tpcb->tp_l_tpdusize); + (so->so_rcv.sb_hiwat + tpcb->tp_l_tpdusize) / tpcb->tp_l_tpdusize); if (old_credit == tpcb->tp_maxlcredit && tpcb->tp_rsyq != 0) return; maxcredit *= sizeof(struct mbuf *); if (tpcb->tp_rsyq) tp_rsyflush(tpcb); - if (rsyq = (caddr_t)malloc(maxcredit, M_PCB, M_NOWAIT)) + if ((rsyq = (caddr_t) malloc(maxcredit, M_PCB, M_NOWAIT)) != NULL) bzero(rsyq, maxcredit); - tpcb->tp_rsyq = (struct mbuf **)rsyq; + tpcb->tp_rsyq = (struct mbuf **) rsyq; } + +void tpsbcheck(tpcb, i) -struct tp_pcb *tpcb; + struct tp_pcb *tpcb; + int i; { register struct mbuf *n, *m; - register int len = 0, mbcnt = 0, pktlen; + register int len = 0, mbcnt = 0, pktlen; struct sockbuf *sb = &tpcb->tp_sock->so_snd; for (n = sb->sb_mb; n; n = n->m_nextpkt) { if ((n->m_flags & M_PKTHDR) == 0) panic("tpsbcheck nohdr"); pktlen = len + n->m_pkthdr.len; - for (m = n; m; m = m->m_next) { + for (m = n; m; m = m->m_next) { len += m->m_len; mbcnt += MSIZE; if (m->m_flags & M_EXT) @@ -932,13 +1023,13 @@ struct tp_pcb *tpcb; } if (len != pktlen) { printf("test %d; len %d != pktlen %d on mbuf 0x%x\n", - i, len, pktlen, n); + i, len, pktlen, n); panic("tpsbcheck short"); } } if (len != sb->sb_cc || mbcnt != sb->sb_mbcnt) { printf("test %d: cc %d != %d || mbcnt %d != %d\n", i, len, sb->sb_cc, - mbcnt, sb->sb_mbcnt); + mbcnt, sb->sb_mbcnt); panic("tpsbcheck"); } } diff --git a/sys/netiso/tp_subr2.c b/sys/netiso/tp_subr2.c index 6463cd24038..5358684ac9e 100644 --- a/sys/netiso/tp_subr2.c +++ b/sys/netiso/tp_subr2.c @@ -1,4 +1,5 @@ -/* $NetBSD: tp_subr2.c,v 1.8 1995/08/16 00:38:58 mycroft Exp $ */ +/* $OpenBSD: tp_subr2.c,v 1.2 1996/03/04 10:36:32 mickey Exp $ */ +/* $NetBSD: tp_subr2.c,v 1.9 1996/02/13 22:12:04 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -61,17 +62,17 @@ SOFTWARE. /* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ -/* - * Some auxiliary routines: - * tp_protocol_error: required by xebec- called when a combo of state, - * event, predicate isn't covered for by the transition file. - * tp_indicate: gives indications(signals) to the user process - * tp_getoptions: initializes variables that are affected by the options - * chosen. +/* + * Some auxiliary routines: tp_protocol_error: required by xebec- called when + * a combo of state, event, predicate isn't covered for by the transition + * file. tp_indicate: gives indications(signals) to the user process + * tp_getoptions: initializes variables that are affected by the options + * chosen. */ -/* this def'n is to cause the expansion of this macro in the - * routine tp_local_credit : +/* + * this def'n is to cause the expansion of this macro in the routine + * tp_local_credit : */ #define LOCAL_CREDIT_EXPAND @@ -85,14 +86,18 @@ SOFTWARE. #include <sys/errno.h> #include <sys/time.h> #include <sys/kernel.h> +#include <sys/queue.h> + +#include <net/if.h> +#include <net/if_types.h> -#undef MNULL #include <netiso/argo_debug.h> #include <netiso/tp_param.h> #include <netiso/tp_ip.h> #include <netiso/iso.h> #include <netiso/iso_errno.h> #include <netiso/iso_pcb.h> +#include <netiso/iso_var.h> #include <netiso/tp_timer.h> #include <netiso/tp_stat.h> #include <netiso/tp_tpdu.h> @@ -100,19 +105,28 @@ SOFTWARE. #include <netiso/tp_seq.h> #include <netiso/tp_trace.h> #include <netiso/tp_user.h> +#include <netiso/tp_var.h> #include <netiso/cons.h> +#include <netiso/clnp.h> + -#include <net/if.h> -#include <net/if_types.h> #ifdef TRUE +#undef MNULL #undef FALSE #undef TRUE #endif + #include <netccitt/x25.h> #include <netccitt/pk.h> #include <netccitt/pk_var.h> +#include <netccitt/pk_extern.h> -void tp_rsyset(); +#if 0 +static void copyQOSparms __P((struct tp_conn_param *, struct tp_conn_param *)); +#endif +#if 0 +static void pk_flowcontrol __P((struct pklcd *, int, int)); +#endif /* * NAME: tp_local_credit() @@ -129,30 +143,34 @@ void tp_rsyset(); * SIDE EFFECTS: * * NOTES: - * This doesn't actually get called in a production system - + * This doesn't actually get called in a production system - * the macro gets expanded instead in place of calls to this proc. * But for debugging, we call this and that allows us to add * debugging messages easily here. */ void tp_local_credit(tpcb) - struct tp_pcb *tpcb; + struct tp_pcb *tpcb; { LOCAL_CREDIT(tpcb); - IFDEBUG(D_CREDIT) +#ifdef ARGO_DEBUG + if (argo_debug[D_CREDIT]) { printf("ref 0x%x lcdt 0x%x l_tpdusize 0x%x decbit 0x%x\n", - tpcb->tp_lref, - tpcb->tp_lcredit, - tpcb->tp_l_tpdusize, - tpcb->tp_decbit, - tpcb->tp_cong_win + tpcb->tp_lref, + tpcb->tp_lcredit, + tpcb->tp_l_tpdusize, + tpcb->tp_decbit, + tpcb->tp_cong_win ); - ENDDEBUG - IFTRACE(D_CREDIT) + } +#endif +#ifdef TPPT + if (tp_traceflags[D_CREDIT]) { tptraceTPCB(TPPTmisc, - "lcdt tpdusz \n", - tpcb->tp_lcredit, tpcb->tp_l_tpdusize, 0, 0); - ENDTRACE + "lcdt tpdusz \n", + tpcb->tp_lcredit, tpcb->tp_l_tpdusize, 0, 0); + } +#endif } /* @@ -163,7 +181,7 @@ tp_local_credit(tpcb) * a combo of event, state, predicate * * FUNCTION and ARGUMENTS: - * print error mesg + * print error mesg * * RETURN VALUE: * EIO - always @@ -173,17 +191,19 @@ tp_local_credit(tpcb) * NOTES: */ int -tp_protocol_error(e,tpcb) - struct tp_event *e; - struct tp_pcb *tpcb; +tp_protocol_error(e, tpcb) + struct tp_event *e; + struct tp_pcb *tpcb; { printf("TP PROTOCOL ERROR! tpcb 0x%x event 0x%x, state 0x%x\n", - tpcb, e->ev_number, tpcb->tp_state); - IFTRACE(D_DRIVER) + tpcb, e->ev_number, tpcb->tp_state); +#ifdef TPPT + if (tp_traceflags[D_DRIVER]) { tptraceTPCB(TPPTmisc, "PROTOCOL ERROR tpcb event state", - tpcb, e->ev_number, tpcb->tp_state, 0 ); - ENDTRACE - return EIO; /* for lack of anything better */ + tpcb, e->ev_number, tpcb->tp_state, 0); + } +#endif + return EIO; /* for lack of anything better */ } @@ -191,7 +211,6 @@ tp_protocol_error(e,tpcb) void tp_drain() { - } @@ -210,46 +229,50 @@ tp_drain() * attached to the tpcb. * * RETURNS: Rien - * + * * SIDE EFFECTS: * * NOTES: */ void tp_indicate(ind, tpcb, error) - int ind; - u_short error; - register struct tp_pcb *tpcb; + int ind; + u_short error; + register struct tp_pcb *tpcb; { register struct socket *so = tpcb->tp_sock; - IFTRACE(D_INDICATION) - tptraceTPCB(TPPTindicate, ind, *(u_short *)(tpcb->tp_lsuffix), - *(u_short *)(tpcb->tp_fsuffix), error,so->so_pgid); - ENDTRACE - IFDEBUG(D_INDICATION) - char *ls, *fs; - ls = tpcb->tp_lsuffix, - fs = tpcb->tp_fsuffix, - - printf( -"indicate 0x%x lsuf 0x%02x%02x fsuf 0x%02x%02x err 0x%x noind 0x%x ref 0x%x\n", - ind, - *ls, *(ls+1), *fs, *(fs+1), - error, /*so->so_pgrp,*/ - tpcb->tp_no_disc_indications, - tpcb->tp_lref); - ENDDEBUG +#ifdef TPPT + if (tp_traceflags[D_INDICATION]) { + tptraceTPCB(TPPTindicate, ind, *(u_short *) (tpcb->tp_lsuffix), + *(u_short *) (tpcb->tp_fsuffix), error, so->so_pgid); + } +#endif +#ifdef ARGO_DEBUG + if (argo_debug[D_INDICATION]) { + char *ls, *fs; + ls = tpcb->tp_lsuffix, + fs = tpcb->tp_fsuffix, + + printf( + "indicate 0x%x lsuf 0x%02x%02x fsuf 0x%02x%02x err 0x%x noind 0x%x ref 0x%x\n", + ind, + *ls, *(ls + 1), *fs, *(fs + 1), + error, /* so->so_pgrp, */ + tpcb->tp_no_disc_indications, + tpcb->tp_lref); + } +#endif if (ind == ER_TPDU) { register struct mbuf *m; struct tp_disc_reason x; if ((so->so_state & SS_CANTRCVMORE) == 0 && - (m = m_get(M_DONTWAIT, MT_OOBDATA)) != 0) { + (m = m_get(M_DONTWAIT, MT_OOBDATA)) != 0) { x.dr_hdr.cmsg_len = m->m_len = sizeof(x); x.dr_hdr.cmsg_level = SOL_TRANSPORT; - x.dr_hdr.cmsg_type= TPOPT_DISC_REASON; + x.dr_hdr.cmsg_type = TPOPT_DISC_REASON; x.dr_reason = error; *mtod(m, struct tp_disc_reason *) = x; sbappendrecord(&tpcb->tp_Xrcv, m); @@ -259,15 +282,17 @@ tp_indicate(ind, tpcb, error) } so->so_error = error; - if (ind == T_DISCONNECT) { + if (ind == T_DISCONNECT) { if (error == 0) so->so_error = ENOTCONN; - if ( tpcb->tp_no_disc_indications ) + if (tpcb->tp_no_disc_indications) return; } - IFTRACE(D_INDICATION) - tptraceTPCB(TPPTmisc, "doing sohasoutofband(so)", so,0,0,0); - ENDTRACE +#ifdef TPPT + if (tp_traceflags[D_INDICATION]) { + tptraceTPCB(TPPTmisc, "doing sohasoutofband(so)", so, 0, 0, 0); + } +#endif sohasoutofband(so); } @@ -275,32 +300,32 @@ tp_indicate(ind, tpcb, error) * NAME : tp_getoptions() * * CALLED FROM: - * tp.trans whenever we go into OPEN state + * tp.trans whenever we go into OPEN state * * FUNCTION and ARGUMENTS: * sets the proper flags and values in the tpcb, to control * the appropriate actions for the given class, options, * sequence space, etc, etc. - * + * * RETURNS: Nada - * + * * SIDE EFFECTS: * * NOTES: */ void tp_getoptions(tpcb) -struct tp_pcb *tpcb; + struct tp_pcb *tpcb; { - tpcb->tp_seqmask = - tpcb->tp_xtd_format ? TP_XTD_FMT_MASK : TP_NML_FMT_MASK ; + tpcb->tp_seqmask = + tpcb->tp_xtd_format ? TP_XTD_FMT_MASK : TP_NML_FMT_MASK; tpcb->tp_seqbit = - tpcb->tp_xtd_format ? TP_XTD_FMT_BIT : TP_NML_FMT_BIT ; + tpcb->tp_xtd_format ? TP_XTD_FMT_BIT : TP_NML_FMT_BIT; tpcb->tp_seqhalf = tpcb->tp_seqbit >> 1; tpcb->tp_dt_ticks = max(tpcb->tp_dt_ticks, (tpcb->tp_peer_acktime + 2)); tp_rsyset(tpcb); - + } /* @@ -310,7 +335,7 @@ struct tp_pcb *tpcb; * Called when a ref is frozen. * * FUNCTION and ARGUMENTS: - * allows the suffix to be reused. + * allows the suffix to be reused. * * RETURNS: zilch * @@ -319,14 +344,15 @@ struct tp_pcb *tpcb; * NOTES: */ void -tp_recycle_tsuffix(tpcb) - struct tp_pcb *tpcb; +tp_recycle_tsuffix(v) + void *v; { - bzero((caddr_t)tpcb->tp_lsuffix, sizeof( tpcb->tp_lsuffix)); - bzero((caddr_t)tpcb->tp_fsuffix, sizeof( tpcb->tp_fsuffix)); + struct tp_pcb *tpcb = v; + bzero((caddr_t) tpcb->tp_lsuffix, sizeof(tpcb->tp_lsuffix)); + bzero((caddr_t) tpcb->tp_fsuffix, sizeof(tpcb->tp_fsuffix)); tpcb->tp_fsuffixlen = tpcb->tp_lsuffixlen = 0; - (tpcb->tp_nlproto->nlp_recycle_suffix)(tpcb->tp_npcb); + (tpcb->tp_nlproto->nlp_recycle_suffix) (tpcb->tp_npcb); } /* @@ -340,43 +366,47 @@ tp_recycle_tsuffix(tpcb) * Congestion window scheme: * Initial value is 1. ("slow start" as Nagle, et. al. call it) * For each good ack that arrives, the congestion window is increased - * by 1 (up to max size of logical infinity, which is to say, + * by 1 (up to max size of logical infinity, which is to say, * it doesn't wrap around). * Source quench causes it to drop back to 1. - * tp_send() uses the smaller of (regular window, congestion window). - * One retransmission strategy option is to have any retransmission + * tp_send() uses the smaller of (regular window, congestion window). + * One retransmission strategy option is to have any retransmission * cause reset the congestion window back to 1. * * (cmd) is either PRC_QUENCH: source quench, or * PRC_QUENCH2: dest. quench (dec bit) * * RETURNS: - * + * * SIDE EFFECTS: - * + * * NOTES: */ void -tp_quench( tpcb, cmd ) - struct tp_pcb *tpcb; - int cmd; +tp_quench(ipcb, cmd) + struct inpcb *ipcb; + int cmd; { - IFDEBUG(D_QUENCH) + struct tp_pcb *tpcb = (struct tp_pcb *) ipcb; +#ifdef ARGO_DEBUG + if (argo_debug[D_QUENCH]) { printf("tp_quench tpcb 0x%x ref 0x%x sufx 0x%x\n", - tpcb, tpcb->tp_lref, *(u_short *)(tpcb->tp_lsuffix)); + tpcb, tpcb->tp_lref, *(u_short *) (tpcb->tp_lsuffix)); printf("cong_win 0x%x decbit 0x%x \n", - tpcb->tp_cong_win, tpcb->tp_decbit); - ENDDEBUG - switch(cmd) { - case PRC_QUENCH: - tpcb->tp_cong_win = tpcb->tp_l_tpdusize; - IncStat(ts_quench); - break; - case PRC_QUENCH2: - tpcb->tp_cong_win = tpcb->tp_l_tpdusize; /* might as well quench source also */ - tpcb->tp_decbit = TP_DECBIT_CLEAR_COUNT; - IncStat(ts_rcvdecbit); - break; + tpcb->tp_cong_win, tpcb->tp_decbit); + } +#endif + switch (cmd) { + case PRC_QUENCH: + tpcb->tp_cong_win = tpcb->tp_l_tpdusize; + IncStat(ts_quench); + break; + case PRC_QUENCH2: + /* might as well quench source also */ + tpcb->tp_cong_win = tpcb->tp_l_tpdusize; + tpcb->tp_decbit = TP_DECBIT_CLEAR_COUNT; + IncStat(ts_rcvdecbit); + break; } } @@ -384,37 +414,40 @@ tp_quench( tpcb, cmd ) /* * NAME: tp_netcmd() * - * CALLED FROM: + * CALLED FROM: * - * FUNCTION and ARGUMENTS: + * FUNCTION and ARGUMENTS: * - * RETURNS: + * RETURNS: * - * SIDE EFFECTS: + * SIDE EFFECTS: * - * NOTES: + * NOTES: */ -tp_netcmd( tpcb, cmd ) - struct tp_pcb *tpcb; - int cmd; +void +tp_netcmd(tpcb, cmd) + struct tp_pcb *tpcb; + int cmd; { #ifdef TPCONS - struct isopcb *isop; - struct pklcd *lcp; + struct isopcb *isop; + struct pklcd *lcp; if (tpcb->tp_netservice != ISO_CONS) return; - isop = (struct isopcb *)tpcb->tp_npcb; - lcp = (struct pklcd *)isop->isop_chan; + isop = (struct isopcb *) tpcb->tp_npcb; + lcp = (struct pklcd *) isop->isop_chan; switch (cmd) { case CONN_CLOSE: case CONN_REFUSE: if (isop->isop_refcnt == 1) { - /* This is really superfluous, since it would happen - anyway in iso_pcbdetach, although it is a courtesy - to free up the x.25 channel before the refwait timer - expires. */ + /* + * This is really superfluous, since it would happen + * anyway in iso_pcbdetach, although it is a courtesy + * to free up the x.25 channel before the refwait + * timer expires. + */ lcp->lcd_upper = 0; lcp->lcd_upnext = 0; pk_disconnect(lcp); @@ -427,54 +460,61 @@ tp_netcmd( tpcb, cmd ) printf("tp_netcmd(0x%x, 0x%x) NOT IMPLEMENTED\n", tpcb, cmd); break; } -#else /* TPCONS */ +#else /* TPCONS */ printf("tp_netcmd(): X25 NOT CONFIGURED!!\n"); #endif } + /* * CALLED FROM: * tp_ctloutput() and tp_emit() * FUNCTION and ARGUMENTS: * Convert a class mask to the highest numeric value it represents. */ - int tp_mask_to_num(x) - u_char x; + u_char x; { - register int j; + register int j; - for(j = 4; j>=0 ;j--) { - if(x & (1<<j)) + for (j = 4; j >= 0; j--) { + if (x & (1 << j)) break; } - ASSERT( (j == 4) || (j == 0) ); /* for now */ - if( (j != 4) && (j != 0) ) { + ASSERT((j == 4) || (j == 0)); /* for now */ + if ((j != 4) && (j != 0)) { printf("ASSERTION ERROR: tp_mask_to_num: x 0x%x j %d\n", - x, j); + x, j); } - IFTRACE(D_TPINPUT) +#ifdef TPPT + if (tp_traceflags[D_TPINPUT]) { tptrace(TPPTmisc, "tp_mask_to_num(x) returns j", x, j, 0, 0); - ENDTRACE - IFDEBUG(D_TPINPUT) + } +#endif +#ifdef ARGO_DEBUG + if (argo_debug[D_TPINPUT]) { printf("tp_mask_to_num(0x%x) returns 0x%x\n", x, j); - ENDDEBUG + } +#endif return j; } -static +#if 0 +static void copyQOSparms(src, dst) struct tp_conn_param *src, *dst; { /* copy all but the bits stuff at the end */ #define COPYSIZE (12 * sizeof(short)) - bcopy((caddr_t)src, (caddr_t)dst, COPYSIZE); + bcopy((caddr_t) src, (caddr_t) dst, COPYSIZE); dst->p_tpdusize = src->p_tpdusize; dst->p_ack_strat = src->p_ack_strat; dst->p_rx_strat = src->p_rx_strat; #undef COPYSIZE } +#endif + /* * Determine a reasonable value for maxseg size. * If the route is known, check route for mtu. @@ -486,14 +526,14 @@ copyQOSparms(src, dst) void tp_mss(tpcb, nhdr_size) register struct tp_pcb *tpcb; - int nhdr_size; + int nhdr_size; { register struct rtentry *rt; - struct ifnet *ifp; - register int rtt, mss; - u_long bufsize; - int i, ssthresh = 0, rt_mss; - struct socket *so; + struct ifnet *ifp; + register int rtt, mss; + u_long bufsize; + int i, ssthresh = 0, rt_mss; + struct socket *so; if (tpcb->tp_ptpdusize) mss = tpcb->tp_ptpdusize << 7; @@ -506,7 +546,7 @@ tp_mss(tpcb, nhdr_size) } ifp = rt->rt_ifp; -#ifdef RTV_MTU /* if route characteristics exist ... */ +#ifdef RTV_MTU /* if route characteristics exist ... */ /* * While we're here, check if there's an initial rtt * or rttvar. Convert from the route-table units @@ -517,7 +557,7 @@ tp_mss(tpcb, nhdr_size) tpcb->tp_rtt = rtt * hz / RTM_RTTUNIT; if (rt->rt_rmx.rmx_rttvar) tpcb->tp_rtv = rt->rt_rmx.rmx_rttvar - * hz / RTM_RTTUNIT; + * hz / RTM_RTTUNIT; else tpcb->tp_rtv = tpcb->tp_rtt; } @@ -527,10 +567,10 @@ tp_mss(tpcb, nhdr_size) if (rt->rt_rmx.rmx_mtu) rt_mss = rt->rt_rmx.rmx_mtu - nhdr_size; else -#endif /* RTV_MTU */ +#endif /* RTV_MTU */ rt_mss = (ifp->if_mtu - nhdr_size); - if (tpcb->tp_ptpdusize == 0 || /* assume application doesn't care */ - mss > rt_mss /* network won't support what was asked for */) + if (tpcb->tp_ptpdusize == 0 || /* assume application doesn't care */ + mss > rt_mss /* network won't support what was asked for */ ) mss = rt_mss; /* can propose mtu which are multiples of 128 */ mss &= ~0x7f; @@ -575,7 +615,7 @@ punt_route: * signal packet loss by duplicate acks. */ mss = min(mss, bufsize >> 2) & ~0x7f; - mss = max(mss, 128); /* sanity */ + mss = max(mss, 128); /* sanity */ tpcb->tp_cong_win = (rt == 0 || (rt->rt_flags & RTF_GATEWAY)) ? mss : bufsize; tpcb->tp_l_tpdusize = mss; @@ -587,21 +627,21 @@ punt_route: break; i--; tpcb->tp_tpdusize = i; -#endif /* RTV_MTU */ +#endif /* RTV_MTU */ } /* * CALLED FROM: * tp_usrreq on PRU_CONNECT and tp_input on receipt of CR - * + * * FUNCTION and ARGUMENTS: * -- An mbuf containing the peer's network address. * -- Our control block, which will be modified * -- In the case of cons, a control block for that layer. * - * + * * RETURNS: - * errno value : + * errno value : * EAFNOSUPPORT if can't find an nl_protosw for x.25 (really could panic) * ECONNREFUSED if trying to run TP0 with non-type 37 address * possibly other E* returned from cons_netcmd() @@ -611,48 +651,54 @@ punt_route: * based on information cached on the route. */ int -tp_route_to( m, tpcb, channel) - struct mbuf *m; - register struct tp_pcb *tpcb; - caddr_t channel; +tp_route_to(m, tpcb, channel) + struct mbuf *m; + register struct tp_pcb *tpcb; + caddr_t channel; { - register struct sockaddr_iso *siso; /* NOTE: this may be a sockaddr_in */ - extern struct tp_conn_param tp_conn_param[]; - int error = 0, save_netservice = tpcb->tp_netservice; + register struct sockaddr_iso *siso; /* NOTE: this may be a + * sockaddr_in */ + int error = 0, save_netservice = tpcb->tp_netservice; register struct rtentry *rt = 0; - int nhdr_size, mtu, bufsize; + int nhdr_size; siso = mtod(m, struct sockaddr_iso *); - IFTRACE(D_CONN) - tptraceTPCB(TPPTmisc, - "route_to: so afi netservice class", - tpcb->tp_sock, siso->siso_addr.isoa_genaddr[0], tpcb->tp_netservice, - tpcb->tp_class); - ENDTRACE - IFDEBUG(D_CONN) - printf("tp_route_to( m x%x, channel 0x%x, tpcb 0x%x netserv 0x%x)\n", - m, channel, tpcb, tpcb->tp_netservice); +#ifdef TPPT + if (tp_traceflags[D_CONN]) { + tptraceTPCB(TPPTmisc, + "route_to: so afi netservice class", + tpcb->tp_sock, siso->siso_addr.isoa_genaddr[0], tpcb->tp_netservice, + tpcb->tp_class); + } +#endif +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { + printf("tp_route_to( m x%x, channel 0x%x, tpcb 0x%x netserv 0x%x)\n", + m, channel, tpcb, tpcb->tp_netservice); printf("m->mlen x%x, m->m_data:\n", m->m_len); dump_buf(mtod(m, caddr_t), m->m_len); - ENDDEBUG + } +#endif if (channel) { #ifdef TPCONS - struct pklcd *lcp = (struct pklcd *)channel; - struct isopcb *isop = (struct isopcb *)lcp->lcd_upnext, - *isop_new = (struct isopcb *)tpcb->tp_npcb; - /* The next 2 lines believe that you haven't - set any network level options or done a pcbconnect - and XXXXXXX'edly apply to both inpcb's and isopcb's */ + struct pklcd *lcp = (struct pklcd *) channel; + struct isopcb *isop = (struct isopcb *) lcp->lcd_upnext, + *isop_new = (struct isopcb *) tpcb->tp_npcb; + /* + * The next 2 lines believe that you haven't set any network + * level options or done a pcbconnect and XXXXXXX'edly apply + * to both inpcb's and isopcb's + */ remque(isop_new); free(isop_new, M_PCB); - tpcb->tp_npcb = (caddr_t)isop; + tpcb->tp_npcb = (caddr_t) isop; tpcb->tp_netservice = ISO_CONS; tpcb->tp_nlproto = nl_protosw + ISO_CONS; if (isop->isop_refcnt++ == 0) { - iso_putsufx(isop, tpcb->tp_lsuffix, tpcb->tp_lsuffixlen, TP_LOCAL); + iso_putsufx(isop, tpcb->tp_lsuffix, + tpcb->tp_lsuffixlen, TP_LOCAL); isop->isop_socket = tpcb->tp_sock; - } else - /* there are already connections sharing this */; + } #endif } else { switch (siso->siso_family) { @@ -661,17 +707,17 @@ tp_route_to( m, tpcb, channel) goto done; #ifdef ISO case AF_ISO: - { - struct isopcb *isop = (struct isopcb *)tpcb->tp_npcb; - int flags = tpcb->tp_sock->so_options & SO_DONTROUTE; - tpcb->tp_netservice = ISO_CLNS; - if (clnp_route(&siso->siso_addr, &isop->isop_route, - flags, (void **)0, (void **)0) == 0) { - rt = isop->isop_route.ro_rt; - if (rt && rt->rt_flags & RTF_PROTO1) - tpcb->tp_netservice = ISO_CONS; - } - } break; + { + struct isopcb *isop = (struct isopcb *) tpcb->tp_npcb; + int flags = tpcb->tp_sock->so_options & SO_DONTROUTE; + tpcb->tp_netservice = ISO_CLNS; + if (clnp_route(&siso->siso_addr, &isop->isop_route, + flags, NULL, NULL) == 0) { + rt = isop->isop_route.ro_rt; + if (rt && rt->rt_flags & RTF_PROTO1) + tpcb->tp_netservice = ISO_CONS; + } + } break; #endif #ifdef INET case AF_INET: @@ -679,97 +725,115 @@ tp_route_to( m, tpcb, channel) #endif } if (tpcb->tp_nlproto->nlp_afamily != siso->siso_family) { - IFDEBUG(D_CONN) - printf("tp_route_to( CHANGING nlproto old 0x%x new 0x%x)\n", - save_netservice, tpcb->tp_netservice); - ENDDEBUG - if (error = tp_set_npcb(tpcb)) +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { + printf("tp_route_to( CHANGING nlproto old 0x%x new 0x%x)\n", + save_netservice, tpcb->tp_netservice); + } +#endif + if ((error = tp_set_npcb(tpcb)) != 0) goto done; } - IFDEBUG(D_CONN) +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("tp_route_to calling nlp_pcbconn, netserv %d\n", - tpcb->tp_netservice); - ENDDEBUG + tpcb->tp_netservice); + } +#endif tpcb->tp_nlproto = nl_protosw + tpcb->tp_netservice; - error = (tpcb->tp_nlproto->nlp_pcbconn)(tpcb->tp_npcb, m); + error = (*tpcb->tp_nlproto->nlp_pcbconn) (tpcb->tp_npcb, m); } if (error) goto done; - nhdr_size = tpcb->tp_nlproto->nlp_mtu(tpcb); /* only gets common info */ + /* only gets common info */ + nhdr_size = (*tpcb->tp_nlproto->nlp_mtu)(tpcb); tp_mss(tpcb, nhdr_size); done: - IFDEBUG(D_CONN) +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("tp_route_to returns 0x%x\n", error); - ENDDEBUG - IFTRACE(D_CONN) - tptraceTPCB(TPPTmisc, "route_to: returns: error netserv class", error, - tpcb->tp_netservice, tpcb->tp_class, 0); - ENDTRACE + } +#endif +#ifdef TPPT + if (tp_traceflags[D_CONN]) { + tptraceTPCB(TPPTmisc, "route_to: returns: error netserv class", error, + tpcb->tp_netservice, tpcb->tp_class, 0); + } +#endif return error; } -#ifndef TPCONS +#if 0 static -pk_flowcontrol() {} +void +pk_flowcontrol(lcp, foo, bar) + struct pklcd *lcp; + int foo, bar; +{ +} #endif /* class zero version */ void -tp0_stash( tpcb, e ) - register struct tp_pcb *tpcb; - register struct tp_event *e; +tp0_stash(tpcb, e) + register struct tp_pcb *tpcb; + register struct tp_event *e; { -#ifndef lint -#define E e->ATTR(DT_TPDU) -#else /* lint */ -#define E e->ev_union.EV_DT_TPDU -#endif /* lint */ +#define E e->TPDU_ATTR(DT) register struct sockbuf *sb = &tpcb->tp_sock->so_rcv; - register struct isopcb *isop = (struct isopcb *)tpcb->tp_npcb; + register struct isopcb *isop = (struct isopcb *) tpcb->tp_npcb; - IFPERF(tpcb) +#ifdef TP_PERF_MEAS + if (DOPERF(tpcb)) { PStat(tpcb, Nb_from_ll) += E.e_datalen; - tpmeas(tpcb->tp_lref, TPtime_from_ll, &e->e_time, - E.e_seq, PStat(tpcb, Nb_from_ll), E.e_datalen); - ENDPERF + tpmeas(tpcb->tp_lref, TPtime_from_ll, &e->e_time, + E.e_seq, PStat(tpcb, Nb_from_ll), E.e_datalen); + } +#endif - IFDEBUG(D_STASH) - printf("stash EQ: seq 0x%x datalen 0x%x eot 0x%x", - E.e_seq, E.e_datalen, E.e_eot); - ENDDEBUG +#ifdef ARGO_DEBUG + if (argo_debug[D_STASH]) { + printf("stash EQ: seq 0x%x datalen 0x%x eot 0x%x", + E.e_seq, E.e_datalen, E.e_eot); + } +#endif - IFTRACE(D_STASH) - tptraceTPCB(TPPTmisc, "stash EQ: seq len eot", - E.e_seq, E.e_datalen, E.e_eot, 0); - ENDTRACE +#ifdef TPPT + if (tp_traceflags[D_STASH]) { + tptraceTPCB(TPPTmisc, "stash EQ: seq len eot", + E.e_seq, E.e_datalen, E.e_eot, 0); + } +#endif - if ( E.e_eot ) { + if (E.e_eot) { register struct mbuf *n = E.e_data; n->m_flags |= M_EOR; - n->m_act = MNULL; /* set on tp_input */ + n->m_act = NULL; /* set on tp_input */ } sbappend(sb, E.e_data); - IFDEBUG(D_STASH) +#ifdef ARGO_DEBUG + if (argo_debug[D_STASH]) { dump_mbuf(sb->sb_mb, "stash 0: so_rcv after appending"); - ENDDEBUG + } +#endif if (tpcb->tp_netservice != ISO_CONS) printf("tp0_stash: tp running over something wierd\n"); else { - register struct pklcd *lcp = (struct pklcd *)isop->isop_chan; + register struct pklcd *lcp = (struct pklcd *) isop->isop_chan; pk_flowcontrol(lcp, sbspace(sb) <= 0, 1); } -} +} void tp0_openflow(tpcb) -register struct tp_pcb *tpcb; + register struct tp_pcb *tpcb; { - register struct isopcb *isop = (struct isopcb *)tpcb->tp_npcb; + register struct isopcb *isop = (struct isopcb *) tpcb->tp_npcb; if (tpcb->tp_netservice != ISO_CONS) printf("tp0_openflow: tp running over something wierd\n"); else { - register struct pklcd *lcp = (struct pklcd *)isop->isop_chan; + register struct pklcd *lcp = (struct pklcd *) isop->isop_chan; if (lcp->lcd_rxrnr_condition) pk_flowcontrol(lcp, 0, 0); } @@ -779,7 +843,7 @@ register struct tp_pcb *tpcb; /* * CALLED FROM: * tp_ctloutput() when the user sets TPOPT_PERF_MEAS on - * and tp_newsocket() when a new connection is made from + * and tp_newsocket() when a new connection is made from * a listening socket with tp_perf_on == true. * FUNCTION and ARGUMENTS: * (tpcb) is the usual; this procedure gets a clear cluster mbuf for @@ -788,42 +852,44 @@ register struct tp_pcb *tpcb; * ENOBUFS if it cannot get a cluster mbuf. */ -int +int tp_setup_perf(tpcb) register struct tp_pcb *tpcb; { - - if( tpcb->tp_p_meas == 0 ) { + if (tpcb->tp_p_meas == 0) { tpcb->tp_p_meas = malloc(sizeof(struct tp_pmeas), M_PCB, M_WAITOK); bzero((caddr_t)tpcb->tp_p_meas, sizeof(struct tp_pmeas)); - IFDEBUG(D_PERF_MEAS) +#ifdef ARGO_DEBUG + if (argo_debug[D_PERF_MEAS]) { printf( - "tpcb 0x%x so 0x%x ref 0x%x tp_p_meas 0x%x tp_perf_on 0x%x\n", - tpcb, tpcb->tp_sock, tpcb->tp_lref, - tpcb->tp_p_meas, tpcb->tp_perf_on); - ENDDEBUG + "tpcb 0x%x so 0x%x ref 0x%x tp_p_meas 0x%x tp_perf_on 0x%x\n", + tpcb, tpcb->tp_sock, tpcb->tp_lref, + tpcb->tp_p_meas, tpcb->tp_perf_on); + } +#endif tpcb->tp_perf_on = 1; } return 0; } -#endif /* TP_PERF_MEAS */ +#endif /* TP_PERF_MEAS */ #ifdef ARGO_DEBUG -dump_addr (addr) +void +dump_addr(addr) register struct sockaddr *addr; { - switch( addr->sa_family ) { - case AF_INET: - dump_inaddr(satosin(addr)); - break; + switch (addr->sa_family) { + case AF_INET: + dump_inaddr(satosin(addr)); + break; #ifdef ISO - case AF_ISO: - dump_isoaddr(satosiso(addr)); - break; -#endif /* ISO */ - default: - printf("BAD AF: 0x%x\n", addr->sa_family); - break; + case AF_ISO: + dump_isoaddr(satosiso(addr)); + break; +#endif /* ISO */ + default: + printf("BAD AF: 0x%x\n", addr->sa_family); + break; } } @@ -835,18 +901,19 @@ dump_addr (addr) * columns of hex/dec numbers will be printed, followed by the * character representations (if printable). */ +void Dump_buf(buf, len) -caddr_t buf; -int len; + caddr_t buf; + int len; { - int i,j; + int i, j; #define Buf ((u_char *)buf) printf("Dump buf 0x%x len 0x%x\n", buf, len); for (i = 0; i < len; i += MAX_COLUMNS) { printf("+%d:\t", i); for (j = 0; j < MAX_COLUMNS; j++) { if (i + j < len) { - printf("%x/%d\t", Buf[i+j], Buf[i+j]); + printf("%x/%d\t", Buf[i + j], Buf[i + j]); } else { printf(" "); } @@ -854,8 +921,8 @@ int len; for (j = 0; j < MAX_COLUMNS; j++) { if (i + j < len) { - if (((Buf[i+j]) > 31) && ((Buf[i+j]) < 128)) - printf("%c", Buf[i+j]); + if (((Buf[i + j]) > 31) && ((Buf[i + j]) < 128)) + printf("%c", Buf[i + j]); else printf("."); } diff --git a/sys/netiso/tp_timer.c b/sys/netiso/tp_timer.c index 1fa2be948db..0daaf01f649 100644 --- a/sys/netiso/tp_timer.c +++ b/sys/netiso/tp_timer.c @@ -1,4 +1,5 @@ -/* $NetBSD: tp_timer.c,v 1.6 1995/08/12 23:59:51 mycroft Exp $ */ +/* $OpenBSD: tp_timer.c,v 1.2 1996/03/04 10:36:34 mickey Exp $ */ +/* $NetBSD: tp_timer.c,v 1.7 1996/02/13 22:12:10 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -78,15 +79,16 @@ SOFTWARE. #include <netiso/tp_tpdu.h> #include <netiso/tp_trace.h> #include <netiso/tp_seq.h> +#include <netiso/tp_var.h> -struct tp_ref *tp_ref; -int tp_rttdiv, tp_rttadd, N_TPREF = 127; -struct tp_refinfo tp_refinfo; -struct tp_pcb *tp_ftimeolist = (struct tp_pcb *)&tp_ftimeolist; +struct tp_ref *tp_ref; +int tp_rttdiv, tp_rttadd, N_TPREF = 127; +struct tp_refinfo tp_refinfo; +struct tp_pcb *tp_ftimeolist = (struct tp_pcb *) & tp_ftimeolist; /* * CALLED FROM: - * at autoconfig time from tp_init() + * at autoconfig time from tp_init() * a combo of event, state, predicate * FUNCTION and ARGUMENTS: * initialize data structures for the timers @@ -94,17 +96,17 @@ struct tp_pcb *tp_ftimeolist = (struct tp_pcb *)&tp_ftimeolist; void tp_timerinit() { - register int s; + register int s; /* * Initialize storage */ if (tp_refinfo.tpr_base) return; - tp_refinfo.tpr_size = N_TPREF + 1; /* Need to start somewhere */ + tp_refinfo.tpr_size = N_TPREF + 1; /* Need to start somewhere */ s = sizeof(*tp_ref) * tp_refinfo.tpr_size; if ((tp_ref = (struct tp_ref *) malloc(s, M_PCB, M_NOWAIT)) == 0) panic("tp_timerinit"); - bzero((caddr_t)tp_ref, (unsigned) s); + bzero((caddr_t) tp_ref, (unsigned) s); tp_refinfo.tpr_base = tp_ref; tp_rttdiv = hz / PR_SLOWHZ; tp_rttadd = (2 * tp_rttdiv) - 1; @@ -120,19 +122,23 @@ tp_timerinit() */ void tp_etimeout(tpcb, fun, ticks) - register struct tp_pcb *tpcb; - int fun; /* function to be called */ - int ticks; + register struct tp_pcb *tpcb; + int fun; /* function to be called */ + int ticks; { register u_int *callp; - IFDEBUG(D_TIMER) +#ifdef ARGO_DEBUG + if (argo_debug[D_TIMER]) { printf("etimeout pcb 0x%x state 0x%x\n", tpcb, tpcb->tp_state); - ENDDEBUG - IFTRACE(D_TIMER) + } +#endif +#ifdef TPPT + if (tp_traceflags[D_TIMER]) { tptrace(TPPTmisc, "tp_etimeout ref refstate tks Etick", tpcb->tp_lref, - tpcb->tp_state, ticks, tp_stat.ts_Eticks); - ENDTRACE + tpcb->tp_state, ticks, tp_stat.ts_Eticks); + } +#endif if (tpcb == 0) return; IncStat(ts_Eset); @@ -151,12 +157,14 @@ tp_etimeout(tpcb, fun, ticks) */ void tp_euntimeout(tpcb, fun) - register struct tp_pcb *tpcb; - int fun; + register struct tp_pcb *tpcb; + int fun; { - IFTRACE(D_TIMER) +#ifdef TPPT + if (tp_traceflags[D_TIMER]) { tptrace(TPPTmisc, "tp_euntimeout ref", tpcb->tp_lref, 0, 0, 0); - ENDTRACE + } +#endif if (tpcb) tpcb->tp_timer[fun] = 0; @@ -181,39 +189,43 @@ tp_euntimeout(tpcb, fun) void tp_slowtimo() { - register u_int *cp; - register struct tp_ref *rp; - struct tp_pcb *tpcb; - struct tp_event E; - int s = splsoftnet(), t; + register u_int *cp; + register struct tp_ref *rp; + struct tp_pcb *tpcb; + struct tp_event E; + int s = splsoftnet(), t; /* check only open reference structures */ IncStat(ts_Cticks); /* tp_ref[0] is never used */ for (rp = tp_ref + tp_refinfo.tpr_maxopen; rp > tp_ref; rp--) { - if ((tpcb = rp->tpr_pcb) == 0 || tpcb->tp_refstate < REF_OPEN) + if ((tpcb = rp->tpr_pcb) == 0 || tpcb->tp_refstate < REF_OPEN) continue; /* check the timers */ for (t = 0; t < TM_NTIMERS; t++) { cp = tpcb->tp_timer + t; - if (*cp && --(*cp) <= 0 ) { + if (*cp && --(*cp) <= 0) { *cp = 0; E.ev_number = t; - IFDEBUG(D_TIMER) +#ifdef ARGO_DEBUG + if (argo_debug[D_TIMER]) { printf("tp_slowtimo: pcb 0x%x t %d\n", - tpcb, t); - ENDDEBUG + tpcb, t); + } +#endif IncStat(ts_Cexpired); tp_driver(tpcb, &E); if (t == TM_reference && tpcb->tp_state == TP_CLOSED) { if (tpcb->tp_notdetached) { - IFDEBUG(D_CONN) +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("PRU_DETACH: not detached\n"); - ENDDEBUG + } +#endif tp_detach(tpcb); } /* XXX wart; where else to do it? */ - free((caddr_t)tpcb, M_PCB); + free((caddr_t) tpcb, M_PCB); } } } @@ -224,10 +236,11 @@ tp_slowtimo() /* * Called From: tp.trans from tp_slowtimo() -- retransmission timer went off. */ +void tp_data_retrans(tpcb) -register struct tp_pcb *tpcb; + register struct tp_pcb *tpcb; { - int rexmt, win; + int rexmt, win; tpcb->tp_rttemit = 0; /* cancel current round trip time */ tpcb->tp_dupacks = 0; tpcb->tp_sndnxt = tpcb->tp_snduna; @@ -239,10 +252,12 @@ register struct tp_pcb *tpcb; * bother shrinking the congestion windows, et. al. * The retransmission timer should have been reset in goodack() */ - IFDEBUG(D_ACKRECV) +#ifdef ARGO_DEBUG + if (argo_debug[D_ACKRECV]) { printf("tp_data_retrans: 0 window tpcb 0x%x una 0x%x\n", - tpcb, tpcb->tp_snduna); - ENDDEBUG + tpcb, tpcb->tp_snduna); + } +#endif tpcb->tp_rxtshift = 0; tpcb->tp_timer[TM_data_retrans] = 0; tpcb->tp_timer[TM_sendack] = tpcb->tp_dt_ticks; @@ -253,9 +268,10 @@ register struct tp_pcb *tpcb; win = max(win, 2); tpcb->tp_cong_win = tpcb->tp_l_tpdusize; /* slow start again. */ tpcb->tp_ssthresh = win * tpcb->tp_l_tpdusize; - /* We're losing; our srtt estimate is probably bogus. - * Clobber it so we'll take the next rtt measurement as our srtt; - * Maintain current rxt times until then. + /* + * We're losing; our srtt estimate is probably bogus. Clobber it so + * we'll take the next rtt measurement as our srtt; Maintain current + * rxt times until then. */ if (++tpcb->tp_rxtshift > TP_NRETRANS / 4) { /* tpcb->tp_nlprotosw->nlp_losing(tpcb->tp_npcb) someday */ @@ -270,14 +286,14 @@ void tp_fasttimo() { register struct tp_pcb *t; - int s = splsoftnet(); - struct tp_event E; + int s = splsoftnet(); + struct tp_event E; E.ev_number = TM_sendack; - while ((t = tp_ftimeolist) != (struct tp_pcb *)&tp_ftimeolist) { + while ((t = tp_ftimeolist) != (struct tp_pcb *) & tp_ftimeolist) { if (t == 0) { printf("tp_fasttimeo: should panic"); - tp_ftimeolist = (struct tp_pcb *)&tp_ftimeolist; + tp_ftimeolist = (struct tp_pcb *) & tp_ftimeolist; } else { if (t->tp_flags & TPF_DELACK) { IncStat(ts_Fdelack); @@ -301,15 +317,17 @@ tp_fasttimo() */ void tp_ctimeout(tpcb, which, ticks) - register struct tp_pcb *tpcb; - int which, ticks; + register struct tp_pcb *tpcb; + int which, ticks; { - IFTRACE(D_TIMER) - tptrace(TPPTmisc, "tp_ctimeout ref which tpcb active", +#ifdef TPPT + if (tp_traceflags[D_TIMER]) { + tptrace(TPPTmisc, "tp_ctimeout ref which tpcb active", tpcb->tp_lref, which, tpcb, tpcb->tp_timer[which]); - ENDTRACE - if(tpcb->tp_timer[which]) + } +#endif + if (tpcb->tp_timer[which]) IncStat(ts_Ccan_act); IncStat(ts_Cset); if (ticks <= 0) @@ -319,22 +337,24 @@ tp_ctimeout(tpcb, which, ticks) /* * CALLED FROM: - * tp.trans + * tp.trans * FUNCTION and ARGUMENTS: - * Version of tp_ctimeout that resets the C-type time if the + * Version of tp_ctimeout that resets the C-type time if the * parameter (ticks) is > the current value of the timer. */ void tp_ctimeout_MIN(tpcb, which, ticks) - register struct tp_pcb *tpcb; - int which, ticks; + register struct tp_pcb *tpcb; + int which, ticks; { - IFTRACE(D_TIMER) - tptrace(TPPTmisc, "tp_ctimeout_MIN ref which tpcb active", +#ifdef TPPT + if (tp_traceflags[D_TIMER]) { + tptrace(TPPTmisc, "tp_ctimeout_MIN ref which tpcb active", tpcb->tp_lref, which, tpcb, tpcb->tp_timer[which]); - ENDTRACE - IncStat(ts_Cset); - if (tpcb->tp_timer[which]) { + } +#endif + IncStat(ts_Cset); + if (tpcb->tp_timer[which]) { tpcb->tp_timer[which] = min(ticks, tpcb->tp_timer[which]); IncStat(ts_Ccan_act); } else @@ -349,18 +369,22 @@ tp_ctimeout_MIN(tpcb, which, ticks) */ void tp_cuntimeout(tpcb, which) - register struct tp_pcb *tpcb; - int which; + register struct tp_pcb *tpcb; + int which; { - IFDEBUG(D_TIMER) +#ifdef ARGO_DEBUG + if (argo_debug[D_TIMER]) { printf("tp_cuntimeout(0x%x, %d) active %d\n", - tpcb, which, tpcb->tp_timer[which]); - ENDDEBUG + tpcb, which, tpcb->tp_timer[which]); + } +#endif - IFTRACE(D_TIMER) - tptrace(TPPTmisc, "tp_cuntimeout ref which, active", refp-tp_ref, +#ifdef TPPT + if (tp_traceflags[D_TIMER]) { + tptrace(TPPTmisc, "tp_cuntimeout ref which, active", refp - tp_ref, which, tpcb->tp_timer[which], 0); - ENDTRACE + } +#endif if (tpcb->tp_timer[which]) IncStat(ts_Ccan_act); diff --git a/sys/netiso/tp_timer.h b/sys/netiso/tp_timer.h index 4d3463518d9..540eac583e7 100644 --- a/sys/netiso/tp_timer.h +++ b/sys/netiso/tp_timer.h @@ -1,4 +1,5 @@ -/* $NetBSD: tp_timer.h,v 1.5 1994/06/29 06:40:40 cgd Exp $ */ +/* $OpenBSD: tp_timer.h,v 1.2 1996/03/04 10:36:36 mickey Exp $ */ +/* $NetBSD: tp_timer.h,v 1.6 1996/02/13 22:12:13 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -61,7 +62,7 @@ SOFTWARE. /* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ -/* +/* * The callout structures used by the tp timers. */ @@ -84,6 +85,6 @@ SOFTWARE. #define tp_euntimeout tp_cuntimeout #define tp_ctimeout_MIN(p, w, t) \ { if((p)->tp_timer[w] > (t)) (p)->tp_timer[w] = (t);} -#endif /* TP_DEBUG_TIMERS */ +#endif /* TP_DEBUG_TIMERS */ -#endif /* _NETISO_TP_TIMER_H_ */ +#endif /* _NETISO_TP_TIMER_H_ */ diff --git a/sys/netiso/tp_tpdu.h b/sys/netiso/tp_tpdu.h index b5aeda962ca..6c7072fcdf7 100644 --- a/sys/netiso/tp_tpdu.h +++ b/sys/netiso/tp_tpdu.h @@ -1,4 +1,5 @@ -/* $NetBSD: tp_tpdu.h,v 1.7 1994/07/21 07:10:12 mycroft Exp $ */ +/* $OpenBSD: tp_tpdu.h,v 1.2 1996/03/04 10:36:38 mickey Exp $ */ +/* $NetBSD: tp_tpdu.h,v 1.8 1996/02/13 22:12:16 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -61,9 +62,9 @@ SOFTWARE. /* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ -/* - * This ghastly set of macros makes it possible to - * refer to tpdu structures without going mad. +/* + * This ghastly set of macros makes it possible to refer to tpdu structures + * without going mad. */ #ifndef _NETISO_TP_TPDU_H_ @@ -71,88 +72,89 @@ SOFTWARE. #include <machine/endian.h> /* for BYTE_ORDER */ -/* This much of a tpdu is the same for all types of tpdus (except - * DT tpdus in class 0; their exceptions are handled by the data - * structure below +/* + * This much of a tpdu is the same for all types of tpdus (except DT tpdus + * in class 0; their exceptions are handled by the data structure below */ struct tpdu_fixed { - u_char _tpduf_li:8, /* length indicator */ + u_char _tpduf_li:8, /* length indicator */ #if BYTE_ORDER == LITTLE_ENDIAN - _tpduf_cdt: 4, /* credit */ - _tpduf_type: 4; /* type of tpdu (DT, CR, etc.) */ + _tpduf_cdt:4, /* credit */ + _tpduf_type:4; /* type of tpdu (DT, CR, etc.) */ #endif #if BYTE_ORDER == BIG_ENDIAN - _tpduf_type: 4, /* type of tpdu (DT, CR, etc.) */ - _tpduf_cdt: 4; /* credit */ + _tpduf_type:4, /* type of tpdu (DT, CR, etc.) */ + _tpduf_cdt:4; /* credit */ #endif - u_short _tpduf_dref; /* destination ref; not in DT in class 0 */ + u_short _tpduf_dref; /* destination ref; not in DT in + * class 0 */ }; #define tpdu_li _tpduf._tpduf_li #define tpdu_type _tpduf._tpduf_type #define tpdu_cdt _tpduf._tpduf_cdt #define tpdu_dref _tpduf._tpduf_dref - + struct tp0du { - u_char _tp0_li, - _tp0_cdt_type, /* same as in tpdu_fixed */ + u_char _tp0_li, _tp0_cdt_type, /* same as in tpdu_fixed */ #if BYTE_ORDER == BIG_ENDIAN - _tp0_eot: 1, /* eot */ - _tp0_mbz: 7, /* must be zero */ + _tp0_eot:1, /* eot */ + _tp0_mbz:7, /* must be zero */ #endif #if BYTE_ORDER == LITTLE_ENDIAN - _tp0_mbz: 7, /* must be zero */ - _tp0_eot: 1, /* eot */ + _tp0_mbz:7, /* must be zero */ + _tp0_eot:1, /* eot */ #endif - _tp0_notused: 8; /* data begins on this octet */ + _tp0_notused:8; /* data begins on this octet */ }; #define tp0du_eot _tp0_eot #define tp0du_mbz _tp0_mbz - + /* * This is used when the extended format seqence numbers are - * being sent and received. + * being sent and received. + */ +/* + * the seqeot field is an int that overlays the seq + * and eot fields, this allows the htonl operation + * to be applied to the entire 32 bit quantity, and + * simplifies the structure definitions. */ - /* - * the seqeot field is an int that overlays the seq - * and eot fields, this allows the htonl operation - * to be applied to the entire 32 bit quantity, and - * simplifies the structure definitions. - */ union seq_type { struct { #if BYTE_ORDER == BIG_ENDIAN - unsigned int st_eot:1, /* end-of-tsdu */ - st_seq:31; /* 31 bit sequence number */ + unsigned int st_eot:1, /* end-of-tsdu */ + st_seq:31; /* 31 bit sequence number */ #endif #if BYTE_ORDER == LITTLE_ENDIAN - unsigned int st_seq:31, /* 31 bit sequence number */ - st_eot:1; /* end-of-tsdu */ + unsigned int st_seq:31, /* 31 bit sequence number */ + st_eot:1; /* end-of-tsdu */ #endif } st; - unsigned int s_seqeot; + unsigned int s_seqeot; #define s_eot st.st_eot #define s_seq st.st_seq }; -/* Then most tpdu types have a portion that is always present but - * differs among the tpdu types : +/* + * Then most tpdu types have a portion that is always present but differs + * among the tpdu types : */ -union tpdu_fixed_rest { +union tpdu_fixed_rest { - struct { - u_short _tpdufr_sref, /* source reference */ -#if BYTE_ORDER == BIG_ENDIAN - _tpdufr_class: 4, /* class [ ISO 8073 13.3.3.e ] */ - _tpdufr_opt: 4, /* options [ ISO 8073 13.3.3.e ] */ + struct { + u_short _tpdufr_sref, /* source reference */ +#if BYTE_ORDER == BIG_ENDIAN + _tpdufr_class:4, /* class [ISO 8073 13.3.3.e] */ + _tpdufr_opt:4, /* options [ISO 8073 13.3.3.e] */ #endif #if BYTE_ORDER == LITTLE_ENDIAN - _tpdufr_opt: 4, /* options [ ISO 8073 13.3.3.e ] */ - _tpdufr_class: 4, /* class [ ISO 8073 13.3.3.e ] */ + _tpdufr_opt:4, /* options [ISO 8073 13.3.3.e] */ + _tpdufr_class:4, /* class [ISO 8073 13.3.3.e] */ #endif - _tpdufr_xx: 8; /* unused */ - } CRCC; + _tpdufr_xx:8; /* unused */ + } CRCC; #define tpdu_CRli _tpduf._tpduf_li #define tpdu_CRtype _tpduf._tpduf_type @@ -171,7 +173,7 @@ union tpdu_fixed_rest { #define tpdu_CCclass _tpdufr.CRCC._tpdufr_class #define tpdu_CCoptions _tpdufr.CRCC._tpdufr_opt -/* OPTIONS and ADDL OPTIONS bits */ + /* OPTIONS and ADDL OPTIONS bits */ #define TPO_USE_EFC 0x1 #define TPO_XTD_FMT 0x2 #define TPAO_USE_TXPD 0x1 @@ -179,44 +181,46 @@ union tpdu_fixed_rest { #define TPAO_USE_RCC 0x4 #define TPAO_USE_NXPD 0x8 - struct { - unsigned short _tpdufr_sref; /* source reference */ - unsigned char _tpdufr_reason; /* [ ISO 8073 13.5.3.d ] */ - } DR; + struct { + unsigned short _tpdufr_sref; /* source reference */ + unsigned char _tpdufr_reason; /* [ ISO 8073 13.5.3.d ] */ + } DR; #define tpdu_DRli _tpduf._tpduf_li #define tpdu_DRtype _tpduf._tpduf_type #define tpdu_DRdref _tpduf._tpduf_dref #define tpdu_DRsref _tpdufr.DR._tpdufr_sref #define tpdu_DRreason _tpdufr.DR._tpdufr_reason - unsigned short _tpdufr_sref; /* source reference */ + unsigned short _tpdufr_sref; /* source reference */ #define tpdu_DCli _tpduf._tpduf_li #define tpdu_DCtype _tpduf._tpduf_type #define tpdu_DCdref _tpduf._tpduf_dref #define tpdu_DCsref _tpdufr._tpdufr_sref - struct { + struct { #if BYTE_ORDER == BIG_ENDIAN - unsigned char _tpdufr_eot:1, /* end-of-tsdu */ - _tpdufr_seq:7; /* 7 bit sequence number */ + unsigned char _tpdufr_eot:1, /* end-of-tsdu */ + _tpdufr_seq:7; /* 7 bit sequence number */ #endif #if BYTE_ORDER == LITTLE_ENDIAN - unsigned char _tpdufr_seq:7, /* 7 bit sequence number */ - _tpdufr_eot:1; /* end-of-tsdu */ + unsigned char _tpdufr_seq:7, /* 7 bit sequence number */ + _tpdufr_eot:1; /* end-of-tsdu */ #endif - }SEQEOT; - struct { + } SEQEOT; + struct { #if BYTE_ORDER == BIG_ENDIAN - unsigned int _tpdufr_Xeot:1, /* end-of-tsdu */ - _tpdufr_Xseq:31; /* 31 bit sequence number */ + unsigned int _tpdufr_Xeot:1, /* end-of-tsdu */ + _tpdufr_Xseq:31; /* 31 bit sequence + * number */ #endif #if BYTE_ORDER == LITTLE_ENDIAN - unsigned int _tpdufr_Xseq:31, /* 31 bit sequence number */ - _tpdufr_Xeot:1; /* end-of-tsdu */ + unsigned int _tpdufr_Xseq:31, /* 31 bit sequence + * number */ + _tpdufr_Xeot:1; /* end-of-tsdu */ #endif - }SEQEOT31; - unsigned int _tpdufr_Xseqeot; + } SEQEOT31; + unsigned int _tpdufr_Xseqeot; #define tpdu_seqeotX _tpdufr._tpdufr_Xseqeot #define tpdu_DTli _tpduf._tpduf_li @@ -235,24 +239,24 @@ union tpdu_fixed_rest { #define tpdu_XPDseqX _tpdufr.SEQEOT31._tpdufr_Xseq #define tpdu_XPDeotX _tpdufr.SEQEOT31._tpdufr_Xeot - struct { + struct { #if BYTE_ORDER == BIG_ENDIAN - unsigned _tpdufr_yrseq0:1, /* always zero */ - _tpdufr_yrseq:31; /* [ ISO 8073 13.9.3.d ] */ + unsigned _tpdufr_yrseq0:1, /* always zero */ + _tpdufr_yrseq:31; /* [ ISO 8073 13.9.3.d ] */ #endif #if BYTE_ORDER == LITTLE_ENDIAN - unsigned _tpdufr_yrseq:31, /* [ ISO 8073 13.9.3.d ] */ - _tpdufr_yrseq0:1; /* always zero */ + unsigned _tpdufr_yrseq:31, /* [ ISO 8073 13.9.3.d ] */ + _tpdufr_yrseq0:1; /* always zero */ #endif - unsigned short _tpdufr_cdt; /* [ ISO 8073 13.9.3.b ] */ - } AK31; + unsigned short _tpdufr_cdt; /* [ ISO 8073 13.9.3.b ] */ + } AK31; #define tpdu_AKli _tpduf._tpduf_li #define tpdu_AKtype _tpduf._tpduf_type #define tpdu_AKdref _tpduf._tpduf_dref #define tpdu_AKseq _tpdufr.SEQEOT._tpdufr_seq #define tpdu_AKseqX _tpdufr.AK31._tpdufr_yrseq -/* location of cdt depends on size of seq. numbers */ + /* location of cdt depends on size of seq. numbers */ #define tpdu_AKcdt _tpduf._tpduf_cdt #define tpdu_AKcdtX _tpdufr.AK31._tpdufr_cdt @@ -262,7 +266,7 @@ union tpdu_fixed_rest { #define tpdu_XAKseq _tpdufr.SEQEOT._tpdufr_seq #define tpdu_XAKseqX _tpdufr.SEQEOT31._tpdufr_Xseq - unsigned char _tpdu_ERreason; /* [ ISO 8073 13.12.3.c ] */ + unsigned char _tpdu_ERreason; /* [ ISO 8073 13.12.3.c ] */ #define tpdu_ERli _tpduf._tpduf_li #define tpdu_ERtype _tpduf._tpduf_type @@ -272,8 +276,8 @@ union tpdu_fixed_rest { }; struct tpdu { - struct tpdu_fixed _tpduf; - union tpdu_fixed_rest _tpdufr; + struct tpdu_fixed _tpduf; + union tpdu_fixed_rest _tpdufr; }; #endif /* _NETISO_TP_TPDU_H_ */ diff --git a/sys/netiso/tp_trace.c b/sys/netiso/tp_trace.c index 1fb9da6e805..93c0f5bb005 100644 --- a/sys/netiso/tp_trace.c +++ b/sys/netiso/tp_trace.c @@ -1,4 +1,5 @@ -/* $NetBSD: tp_trace.c,v 1.5 1994/06/29 06:40:44 cgd Exp $ */ +/* $OpenBSD: tp_trace.c,v 1.2 1996/03/04 10:36:40 mickey Exp $ */ +/* $NetBSD: tp_trace.c,v 1.6 1996/02/13 22:12:20 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -61,12 +62,11 @@ SOFTWARE. /* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ -/* - * The whole protocol trace module. - * We keep a circular buffer of trace structures, which are big - * unions of different structures we might want to see. - * Unfortunately this gets too big pretty easily. Pcbs were removed - * from the tracing when the kernel got too big to boot. +/* + * The whole protocol trace module. We keep a circular buffer of trace + * structures, which are big unions of different structures we might want to + * see. Unfortunately this gets too big pretty easily. Pcbs were removed from + * the tracing when the kernel got too big to boot. */ #define TP_TRACEFILE @@ -88,8 +88,8 @@ SOFTWARE. #include <netiso/tp_trace.h> #ifdef TPPT -static tp_seq = 0; -u_char tp_traceflags[128]; +static tp_seq = 0; +u_char tp_traceflags[128]; /* * The argument tpcb is the obvious. @@ -97,17 +97,17 @@ u_char tp_traceflags[128]; * The rest of the arguments have different uses depending * on the type of trace event. */ -/*ARGSUSED*/ -/*VARARGS*/ +/* ARGSUSED */ +/* VARARGS */ void tpTrace(tpcb, event, arg, src, len, arg4, arg5) - struct tp_pcb *tpcb; - u_int event, arg; - u_int src; - u_int len; - u_int arg4; - u_int arg5; + struct tp_pcb *tpcb; + u_int event, arg; + u_int src; + u_int len; + u_int arg4; + u_int arg5; { register struct tp_Trace *tp; @@ -117,56 +117,56 @@ tpTrace(tpcb, event, arg, src, len, arg4, arg5) tp->tpt_event = event; tp->tpt_tseq = tp_seq++; tp->tpt_arg = arg; - if(tpcb) + if (tpcb) tp->tpt_arg2 = tpcb->tp_lref; - bcopy( (caddr_t)&time, (caddr_t)&tp->tpt_time, sizeof(struct timeval) ); + bcopy((caddr_t) & time, (caddr_t) & tp->tpt_time, sizeof(struct timeval)); - switch(event) { + switch (event) { case TPPTertpdu: - bcopy((caddr_t)src, (caddr_t)&tp->tpt_ertpdu, - (unsigned)MIN((int)len, sizeof(struct tp_Trace))); + bcopy((caddr_t) src, (caddr_t) & tp->tpt_ertpdu, + (unsigned) MIN((int) len, sizeof(struct tp_Trace))); break; case TPPTusrreq: case TPPTmisc: /* arg is a string */ - bcopy((caddr_t)arg, (caddr_t)tp->tpt_str, - (unsigned)MIN(1+strlen((caddr_t) arg), TPTRACE_STRLEN)); - tp->tpt_m2 = src; + bcopy((caddr_t) arg, (caddr_t) tp->tpt_str, + (unsigned) MIN(1 + strlen((caddr_t) arg), TPTRACE_STRLEN)); + tp->tpt_m2 = src; tp->tpt_m3 = len; tp->tpt_m4 = arg4; tp->tpt_m1 = arg5; break; - case TPPTgotXack: - case TPPTXack: - case TPPTsendack: - case TPPTgotack: - case TPPTack: - case TPPTindicate: + case TPPTgotXack: + case TPPTXack: + case TPPTsendack: + case TPPTgotack: + case TPPTack: + case TPPTindicate: default: - case TPPTdriver: - tp->tpt_m2 = arg; + case TPPTdriver: + tp->tpt_m2 = arg; tp->tpt_m3 = src; tp->tpt_m4 = len; tp->tpt_m5 = arg4; - tp->tpt_m1 = arg5; + tp->tpt_m1 = arg5; break; case TPPTparam: - bcopy((caddr_t)src, (caddr_t)&tp->tpt_param, sizeof(struct tp_param)); + bcopy((caddr_t) src, (caddr_t) & tp->tpt_param, sizeof(struct tp_param)); break; case TPPTref: - bcopy((caddr_t)src, (caddr_t)&tp->tpt_ref, sizeof(struct tp_ref)); + bcopy((caddr_t) src, (caddr_t) & tp->tpt_ref, sizeof(struct tp_ref)); break; case TPPTtpduin: case TPPTtpduout: tp->tpt_arg2 = arg4; - bcopy((caddr_t)src, (caddr_t)&tp->tpt_tpdu, - (unsigned)MIN((int)len, sizeof(struct tp_Trace))); + bcopy((caddr_t) src, (caddr_t) & tp->tpt_tpdu, + (unsigned) MIN((int) len, sizeof(struct tp_Trace))); break; } } -#endif /* TPPT */ +#endif /* TPPT */ diff --git a/sys/netiso/tp_trace.h b/sys/netiso/tp_trace.h index 2d20e5a1733..011639ffaf4 100644 --- a/sys/netiso/tp_trace.h +++ b/sys/netiso/tp_trace.h @@ -1,4 +1,5 @@ -/* $NetBSD: tp_trace.h,v 1.6 1995/03/26 20:35:33 jtc Exp $ */ +/* $OpenBSD: tp_trace.h,v 1.2 1996/03/04 10:36:41 mickey Exp $ */ +/* $NetBSD: tp_trace.h,v 1.7 1996/02/13 22:12:23 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -61,7 +62,7 @@ SOFTWARE. /* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ -/* +/* * Definitions needed for the protocol trace mechanism. */ @@ -98,34 +99,35 @@ SOFTWARE. /* for packet tracing */ struct tp_timeval { - SeqNum tptv_seq; - u_int tptv_kind; - u_int tptv_window; - u_int tptv_size; + SeqNum tptv_seq; + u_int tptv_kind; + u_int tptv_window; + u_int tptv_size; }; -struct tp_Trace { - u_int tpt_event; - u_int tpt_arg; - u_int tpt_arg2; - int tpt_tseq; - struct timeval tpt_time; +struct tp_Trace { + u_int tpt_event; + u_int tpt_arg; + u_int tpt_arg2; + int tpt_tseq; + struct timeval tpt_time; union { - struct inpcb tpt_Inpcb; /* protocol control block */ - struct tp_ref tpt_Ref; /* ref part of pcb */ - struct tpdu tpt_Tpdu; /* header*/ - struct tp_refinfo tpt_Param; /* ?? bytes, make sure < 128??*/ + struct inpcb tpt_Inpcb; /* protocol control block */ + struct tp_ref tpt_Ref; /* ref part of pcb */ + struct tpdu tpt_Tpdu; /* header */ + struct tp_refinfo tpt_Param; /* ?? bytes, make sure < + * 128?? */ struct tp_timeval tpt_Time; struct { - u_int tptm_2; - u_int tptm_3; - u_int tptm_4; - u_int tptm_5; - char tpt_Str[TPTRACE_STRLEN]; - u_int tptm_1; - } tptmisc; - u_char tpt_Ertpdu; /* use rest of structure */ - } tpt_stuff; + u_int tptm_2; + u_int tptm_3; + u_int tptm_4; + u_int tptm_5; + char tpt_Str[TPTRACE_STRLEN]; + u_int tptm_1; + } tptmisc; + u_char tpt_Ertpdu; /* use rest of structure */ + } tpt_stuff; }; #define tpt_inpcb tpt_stuff.tpt_Inpcb #define tpt_pcb tpt_stuff.tpt_Pcb @@ -145,7 +147,7 @@ struct tp_Trace { #define tpt_window tpt_stuff.tpt_Time.tptv_window #define tpt_size tpt_stuff.tpt_Time.tptv_size -#endif /* defined(TP_TRACEFILE)||!defined(_KERNEL) */ +#endif /* defined(TP_TRACEFILE)||!defined(_KERNEL) */ #ifdef TPPT @@ -160,20 +162,12 @@ struct tp_Trace { tpTrace(tpcb,\ (u_int)(A),(u_int)(B),(u_int)(C),(u_int)(D),(u_int)(E),(u_int)(F)) -extern void tpTrace(); +extern void tpTrace(); extern struct tp_Trace tp_Trace[]; -extern u_char tp_traceflags[]; -int tp_Tracen = 0; - -#define IFTRACE(ascii)\ - if(tp_traceflags[ascii]) { -/* - * for some reason lint complains about tp_param being undefined no - * matter where or how many times I define it. - */ -#define ENDTRACE } +extern u_char tp_traceflags[]; +int tp_Tracen = 0; -#else /* TPPT */ +#else /* TPPT */ /*********************************************** * NO TPPT TRACE STUFF @@ -183,9 +177,6 @@ int tp_Tracen = 0; #define tptrace(A,B,C,D,E,F) 0 #define tptraceTPCB(A,B,C,D,E,F) 0 -#define IFTRACE(ascii) if (0) { -#define ENDTRACE } - -#endif /* TPPT */ +#endif /* TPPT */ -#endif /* _NETISO_TP_TRACE_H_ */ +#endif /* _NETISO_TP_TRACE_H_ */ diff --git a/sys/netiso/tp_user.h b/sys/netiso/tp_user.h index dc113e12115..5cc6a837d3e 100644 --- a/sys/netiso/tp_user.h +++ b/sys/netiso/tp_user.h @@ -1,4 +1,5 @@ -/* $NetBSD: tp_user.h,v 1.5 1994/06/29 06:40:48 cgd Exp $ */ +/* $OpenBSD: tp_user.h,v 1.2 1996/03/04 10:36:43 mickey Exp $ */ +/* $NetBSD: tp_user.h,v 1.6 1996/02/13 22:12:25 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -61,8 +62,8 @@ SOFTWARE. /* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ -/* - * These are the values a real-live user ;-) needs. +/* + * These are the values a real-live user ;-) needs. */ #include <sys/types.h> @@ -72,39 +73,44 @@ SOFTWARE. struct tp_conn_param { /* PER CONNECTION parameters */ - short p_Nretrans; - short p_dr_ticks; - - short p_cc_ticks; - short p_dt_ticks; - - short p_x_ticks; - short p_cr_ticks; - - short p_keepalive_ticks; - short p_sendack_ticks; - - short p_ref_ticks; - short p_inact_ticks; - - short p_ptpdusize; /* preferred tpdusize/128 */ - short p_winsize; - - u_char p_tpdusize; /* log 2 of size */ - - u_char p_ack_strat; /* see comments in tp_pcb.h */ - u_char p_rx_strat; /* see comments in tp_pcb.h */ - u_char p_class; /* class bitmask */ - u_char p_xtd_format; - u_char p_xpd_service; - u_char p_use_checksum; - u_char p_use_nxpd; /* netwk expedited data: not implemented */ - u_char p_use_rcc; /* receipt confirmation: not implemented */ - u_char p_use_efc; /* explicit flow control: not implemented */ - u_char p_no_disc_indications; /* don't deliver indic on disc */ - u_char p_dont_change_params; /* use these params as they are */ - u_char p_netservice; - u_char p_version; /* only here for checking */ + short p_Nretrans; + short p_dr_ticks; + + short p_cc_ticks; + short p_dt_ticks; + + short p_x_ticks; + short p_cr_ticks; + + short p_keepalive_ticks; + short p_sendack_ticks; + + short p_ref_ticks; + short p_inact_ticks; + + short p_ptpdusize; /* preferred tpdusize/128 */ + short p_winsize; + + u_char p_tpdusize; /* log 2 of size */ + + u_char p_ack_strat; /* see comments in tp_pcb.h */ + u_char p_rx_strat; /* see comments in tp_pcb.h */ + u_char p_class;/* class bitmask */ + u_char p_xtd_format; + u_char p_xpd_service; + u_char p_use_checksum; + u_char p_use_nxpd; /* netwk expedited data: not + * implemented */ + u_char p_use_rcc; /* receipt confirmation: not + * implemented */ + u_char p_use_efc; /* explicit flow control: not + * implemented */ + u_char p_no_disc_indications; /* don't deliver indic on + * disc */ + u_char p_dont_change_params; /* use these params as they + * are */ + u_char p_netservice; + u_char p_version; /* only here for checking */ }; /* @@ -114,44 +120,47 @@ struct tp_conn_param { #define SOL_NETWORK 0xfffd /* get/set socket opt commands */ -#define TPACK_WINDOW 0x0 /* ack only on full window */ -#define TPACK_EACH 0x1 /* ack every packet */ +#define TPACK_WINDOW 0x0 /* ack only on full window */ +#define TPACK_EACH 0x1 /* ack every packet */ -#define TPRX_USE_CW 0x8 /* use congestion window transmit */ -#define TPRX_EACH 0x4 /* retrans each packet of a set */ -#define TPRX_FASTSTART 0x1 /* don't use slow start */ +#define TPRX_USE_CW 0x8 /* use congestion window + * transmit */ +#define TPRX_EACH 0x4 /* retrans each packet of a + * set */ +#define TPRX_FASTSTART 0x1 /* don't use slow start */ #define TPOPT_INTERCEPT 0x200 #define TPOPT_FLAGS 0x300 -#define TPOPT_CONN_DATA 0x400 -#define TPOPT_DISC_DATA 0x500 -#define TPOPT_CFRM_DATA 0x600 -#define TPOPT_CDDATA_CLEAR 0x700 -#define TPOPT_MY_TSEL 0x800 -#define TPOPT_PEER_TSEL 0x900 +#define TPOPT_CONN_DATA 0x400 +#define TPOPT_DISC_DATA 0x500 +#define TPOPT_CFRM_DATA 0x600 +#define TPOPT_CDDATA_CLEAR 0x700 +#define TPOPT_MY_TSEL 0x800 +#define TPOPT_PEER_TSEL 0x900 #define TPOPT_PERF_MEAS 0xa00 #define TPOPT_PSTATISTICS 0xb00 -#define TPOPT_PARAMS 0xc00 /* to replace a bunch of the others */ +#define TPOPT_PARAMS 0xc00 /* to replace a bunch of the others */ #define TPOPT_DISC_REASON 0xe00 struct tp_disc_reason { - struct cmsghdr dr_hdr; - u_int dr_reason; + struct cmsghdr dr_hdr; + u_int dr_reason; }; -/* - ***********************flags********************************** +/* + * **********************flags********************************** */ /* read only flags */ #define TPFLAG_NLQOS_PDN (u_char)0x01 #define TPFLAG_PEER_ON_SAMENET (u_char)0x02 -#define TPFLAG_GENERAL_ADDR (u_char)0x04 /* bound to wildcard addr */ +#define TPFLAG_GENERAL_ADDR (u_char)0x04 /* bound to wildcard + * addr */ -/* - ***********************end flags****************************** +/* + * **********************end flags****************************** */ -#endif /* _NETISO_TP_USER_H_ */ +#endif /* _NETISO_TP_USER_H_ */ diff --git a/sys/netiso/tp_usrreq.c b/sys/netiso/tp_usrreq.c index 2925f28ad07..2a2aff6939f 100644 --- a/sys/netiso/tp_usrreq.c +++ b/sys/netiso/tp_usrreq.c @@ -1,4 +1,5 @@ -/* $NetBSD: tp_usrreq.c,v 1.7 1995/08/12 23:59:52 mycroft Exp $ */ +/* $OpenBSD: tp_usrreq.c,v 1.2 1996/03/04 10:36:45 mickey Exp $ */ +/* $NetBSD: tp_usrreq.c,v 1.8 1996/02/13 22:12:27 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -40,13 +41,13 @@ All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of IBM not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -61,12 +62,11 @@ SOFTWARE. /* * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison */ -/* +/* * tp_usrreq(), the fellow that gets called from most of the socket code. - * Pretty straighforward. - * THe only really awful stuff here is the OOB processing, which is done - * wholly here. - * tp_rcvoob() and tp_sendoob() are contained here and called by tp_usrreq(). + * Pretty straighforward. THe only really awful stuff here is the OOB + * processing, which is done wholly here. tp_rcvoob() and tp_sendoob() are + * contained here and called by tp_usrreq(). */ #include <sys/param.h> @@ -78,6 +78,7 @@ SOFTWARE. #include <sys/protosw.h> #include <sys/errno.h> #include <sys/time.h> +#include <sys/proc.h> #include <netiso/tp_param.h> #include <netiso/tp_timer.h> @@ -85,16 +86,16 @@ SOFTWARE. #include <netiso/tp_seq.h> #include <netiso/tp_ip.h> #include <netiso/tp_pcb.h> +#include <netiso/tp_var.h> #include <netiso/argo_debug.h> #include <netiso/tp_trace.h> #include <netiso/tp_meas.h> #include <netiso/iso.h> #include <netiso/iso_errno.h> -int tp_attach(), tp_pcbbind(); -int TNew; -int TPNagle1, TPNagle2; -struct tp_pcb *tp_listeners, *tp_intercepts; +int TNew; +int TPNagle1, TPNagle2; +struct tp_pcb *tp_listeners, *tp_intercepts; #ifdef ARGO_DEBUG /* @@ -105,38 +106,37 @@ struct tp_pcb *tp_listeners, *tp_intercepts; */ void dump_mbuf(n, str) - struct mbuf *n; - char *str; + struct mbuf *n; + char *str; { - struct mbuf *nextrecord; + struct mbuf *nextrecord; printf("dump %s\n", str); - if (n == MNULL) { + if (n == MNULL) { printf("EMPTY:\n"); return; } - while (n) { nextrecord = n->m_act; printf("RECORD:\n"); while (n) { printf("%x : Len %x Data %x A %x Nx %x Tp %x\n", - n, n->m_len, n->m_data, n->m_act, n->m_next, n->m_type); + n, n->m_len, n->m_data, n->m_act, n->m_next, n->m_type); #ifdef notdef { - register char *p = mtod(n, char *); - register int i; + register char *p = mtod(n, char *); + register int i; printf("data: "); for (i = 0; i < n->m_len; i++) { - if (i%8 == 0) + if (i % 8 == 0) printf("\n"); - printf("0x%x ", *(p+i)); + printf("0x%x ", *(p + i)); } printf("\n"); } -#endif /* notdef */ +#endif /* notdef */ if (n->m_next == n) { printf("LOOP!\n"); return; @@ -148,7 +148,7 @@ dump_mbuf(n, str) printf("\n"); } -#endif /* ARGO_DEBUG */ +#endif /* ARGO_DEBUG */ /* * CALLED FROM: @@ -165,22 +165,25 @@ dump_mbuf(n, str) * xpd data in the buffer * E* whatever is returned from the fsm. */ +int tp_rcvoob(tpcb, so, m, outflags, inflags) - struct tp_pcb *tpcb; - register struct socket *so; - register struct mbuf *m; - int *outflags; - int inflags; + struct tp_pcb *tpcb; + register struct socket *so; + register struct mbuf *m; + int *outflags; + int inflags; { register struct mbuf *n; register struct sockbuf *sb = &so->so_rcv; struct tp_event E; - int error = 0; + int error = 0; register struct mbuf **nn; - IFDEBUG(D_XPD) +#ifdef ARGO_DEBUG + if (argo_debug[D_XPD]) { printf("PRU_RCVOOB, sostate 0x%x\n", so->so_state); - ENDDEBUG + } +#endif /* if you use soreceive */ if (m == MNULL) @@ -188,35 +191,36 @@ tp_rcvoob(tpcb, so, m, outflags, inflags) restart: if ((((so->so_state & SS_ISCONNECTED) == 0) - || (so->so_state & SS_ISDISCONNECTING) != 0) && - (so->so_proto->pr_flags & PR_CONNREQUIRED)) { - return ENOTCONN; + || (so->so_state & SS_ISDISCONNECTING) != 0) && + (so->so_proto->pr_flags & PR_CONNREQUIRED)) { + return ENOTCONN; } - - /* Take the first mbuf off the chain. - * Each XPD TPDU gives you a complete TSDU so the chains don't get - * coalesced, but one TSDU may span several mbufs. - * Nevertheless, since n should have a most 16 bytes, it - * will fit into m. (size was checked in tp_input() ) + /* + * Take the first mbuf off the chain. Each XPD TPDU gives you a + * complete TSDU so the chains don't get coalesced, but one TSDU may + * span several mbufs. Nevertheless, since n should have a most 16 + * bytes, it will fit into m. (size was checked in tp_input() ) */ /* * Code for excision of OOB data should be added to * uipc_socket2.c (like sbappend). */ - + sblock(sb, M_WAITOK); - for (nn = &sb->sb_mb; n = *nn; nn = &n->m_act) + for (nn = &sb->sb_mb; (n = *nn) != NULL; nn = &n->m_act) if (n->m_type == MT_OOBDATA) break; if (n == 0) { - IFDEBUG(D_XPD) +#ifdef ARGO_DEBUG + if (argo_debug[D_XPD]) { printf("RCVOOB: empty queue!\n"); - ENDDEBUG + } +#endif sbunlock(sb); if (so->so_state & SS_NBIO) { - return EWOULDBLOCK; + return EWOULDBLOCK; } sbwait(sb); goto restart; @@ -226,35 +230,38 @@ restart: /* Assuming at most one xpd tpdu is in the buffer at once */ while (n != MNULL) { m->m_len += n->m_len; - bcopy(mtod(n, caddr_t), mtod(m, caddr_t), (unsigned)n->m_len); - m->m_data += n->m_len; /* so mtod() in bcopy() above gives right addr */ + bcopy(mtod(n, caddr_t), mtod(m, caddr_t), (unsigned) n->m_len); + m->m_data += n->m_len; /* so mtod() in bcopy() above gives + * right addr */ n = n->m_next; } m->m_data = m->m_dat; m->m_flags |= M_EOR; - IFDEBUG(D_XPD) +#ifdef ARGO_DEBUG + if (argo_debug[D_XPD]) { printf("tp_rcvoob: xpdlen 0x%x\n", m->m_len); dump_mbuf(so->so_rcv.sb_mb, "RCVOOB: Rcv socketbuf"); dump_mbuf(sb->sb_mb, "RCVOOB: Xrcv socketbuf"); - ENDDEBUG + } +#endif if ((inflags & MSG_PEEK) == 0) { n = *nn; *nn = n->m_act; - for (; n; n = m_free(n)) + for (; n; n = m_free(n)) sbfree(sb, n); } - -release: sbunlock(sb); - IFTRACE(D_XPD) +#ifdef TPPT + if (tp_traceflags[D_XPD]) { tptraceTPCB(TPPTmisc, "PRU_RCVOOB @ release sb_cc m_len", - tpcb->tp_Xrcv.sb_cc, m->m_len, 0, 0); - ENDTRACE + tpcb->tp_Xrcv.sb_cc, m->m_len, 0, 0); + } +#endif if (error == 0) - error = DoEvent(T_USR_Xrcvd); + error = DoEvent(T_USR_Xrcvd); return error; } @@ -272,11 +279,12 @@ release: * EMSGSIZE if trying to send > max-xpd bytes (16) * ENOBUFS if ran out of mbufs */ +int tp_sendoob(tpcb, so, xdata, outflags) - struct tp_pcb *tpcb; - register struct socket *so; - register struct mbuf *xdata; - int *outflags; /* not used */ + struct tp_pcb *tpcb; + register struct socket *so; + register struct mbuf *xdata; + int *outflags; /* not used */ { /* * Each mbuf chain represents a sequence # in the XPD seq space. @@ -285,37 +293,40 @@ tp_sendoob(tpcb, so, xdata, outflags) * mbuf (mark) into the DATA queue, with its sequence number in m_next * to be assigned to this XPD tpdu, so data xfer can stop * when it reaches the zero-length mbuf if this XPD TPDU hasn't - * yet been acknowledged. + * yet been acknowledged. */ register struct sockbuf *sb = &(tpcb->tp_Xsnd); - register struct mbuf *xmark; - register int len=0; + register struct mbuf *xmark; + register int len = 0; struct tp_event E; - IFDEBUG(D_XPD) +#ifdef ARGO_DEBUG + if (argo_debug[D_XPD]) { printf("tp_sendoob:"); if (xdata) printf("xdata len 0x%x\n", xdata->m_len); - ENDDEBUG - /* DO NOT LOCK the Xsnd buffer!!!! You can have at MOST one - * socket buf locked at any time!!! (otherwise you might - * sleep() in sblock() w/ a signal pending and cause the - * system call to be aborted w/ a locked socketbuf, which - * is a problem. So the so_snd buffer lock + } +#endif + /* + * DO NOT LOCK the Xsnd buffer!!!! You can have at MOST one socket + * buf locked at any time!!! (otherwise you might sleep() in sblock() + * w/ a signal pending and cause the system call to be aborted w/ a + * locked socketbuf, which is a problem. So the so_snd buffer lock * (done in sosend()) serves as the lock for Xpd. */ - if (sb->sb_mb) { /* Anything already in eXpedited data sockbuf? */ + if (sb->sb_mb) { /* Anything already in eXpedited data + * sockbuf? */ if (so->so_state & SS_NBIO) { return EWOULDBLOCK; } while (sb->sb_mb) { - sbunlock(&so->so_snd); /* already locked by sosend */ + sbunlock(&so->so_snd); /* already locked by sosend */ sbwait(&so->so_snd); - sblock(&so->so_snd, M_WAITOK); /* sosend will unlock on return */ + sblock(&so->so_snd, M_WAITOK); /* sosend will unlock on + * return */ } } - - if (xdata == (struct mbuf *)0) { + if (xdata == (struct mbuf *) 0) { /* empty xpd packet */ MGETHDR(xdata, M_WAIT, MT_OOBDATA); if (xdata == NULL) { @@ -324,12 +335,14 @@ tp_sendoob(tpcb, so, xdata, outflags) xdata->m_len = 0; xdata->m_pkthdr.len = 0; } - IFDEBUG(D_XPD) +#ifdef ARGO_DEBUG + if (argo_debug[D_XPD]) { printf("tp_sendoob 1:"); if (xdata) printf("xdata len 0x%x\n", xdata->m_len); - ENDDEBUG - xmark = xdata; /* temporary use of variable xmark */ + } +#endif + xmark = xdata; /* temporary use of variable xmark */ while (xmark) { len += xmark->m_len; xmark = xmark->m_next; @@ -337,25 +350,31 @@ tp_sendoob(tpcb, so, xdata, outflags) if (len > TP_MAX_XPD_DATA) { return EMSGSIZE; } - IFDEBUG(D_XPD) +#ifdef ARGO_DEBUG + if (argo_debug[D_XPD]) { printf("tp_sendoob 2:"); if (xdata) printf("xdata len 0x%x\n", len); - ENDDEBUG + } +#endif - IFTRACE(D_XPD) +#ifdef TPPT + if (tp_traceflags[D_XPD]) { tptraceTPCB(TPPTmisc, "XPD mark m_next ", xdata->m_next, 0, 0, 0); - ENDTRACE + } +#endif - sbappendrecord(sb, xdata); + sbappendrecord(sb, xdata); - IFDEBUG(D_XPD) +#ifdef ARGO_DEBUG + if (argo_debug[D_XPD]) { printf("tp_sendoob len 0x%x\n", len); dump_mbuf(so->so_snd.sb_mb, "XPD request Regular sndbuf:"); dump_mbuf(tpcb->tp_Xsnd.sb_mb, "XPD request Xsndbuf:"); - ENDDEBUG - return DoEvent(T_XPD_req); + } +#endif + return DoEvent(T_XPD_req); } /* @@ -363,92 +382,103 @@ tp_sendoob(tpcb, so, xdata, outflags) * the socket routines * FUNCTION and ARGUMENTS: * Handles all "user requests" except the [gs]ockopts() requests. - * The argument (req) is the request type (PRU*), + * The argument (req) is the request type (PRU*), * (m) is an mbuf chain, generally used for send and * receive type requests only. * (nam) is used for addresses usually, in particular for the bind request. - * + * */ -/*ARGSUSED*/ +/* ARGSUSED */ int tp_usrreq(so, req, m, nam, controlp) - struct socket *so; - u_int req; - struct mbuf *m, *nam, *controlp; -{ - register struct tp_pcb *tpcb = sototpcb(so); - int s = splsoftnet(); - int error = 0; - int flags, *outflags = &flags; - u_long eotsdu = 0; + struct socket *so; + int req; + struct mbuf *m, *nam, *controlp; +{ + register struct tp_pcb *tpcb = sototpcb(so); + int s = splsoftnet(); + int error = 0; + int flags, *outflags = &flags; + u_long eotsdu = 0; struct tp_event E; - IFDEBUG(D_REQUEST) - printf("usrreq(0x%x,%d,0x%x,0x%x,0x%x)\n",so,req,m,nam,outflags); +#ifdef ARGO_DEBUG + if (argo_debug[D_REQUEST]) { + printf("usrreq(0x%x,%d,0x%x,0x%x,0x%x)\n", so, req, m, nam, outflags); if (so->so_error) printf("WARNING!!! so->so_error is 0x%x\n", so->so_error); - ENDDEBUG - IFTRACE(D_REQUEST) - tptraceTPCB(TPPTusrreq, "req so m state [", req, so, m, - tpcb?tpcb->tp_state:0); - ENDTRACE - - if ((u_long)tpcb == 0 && req != PRU_ATTACH) { - IFTRACE(D_REQUEST) + } +#endif +#ifdef TPPT + if (tp_traceflags[D_REQUEST]) { + tptraceTPCB(TPPTusrreq, "req so m state [", req, so, m, + tpcb ? tpcb->tp_state : 0); + } +#endif + + if ((u_long) tpcb == 0 && req != PRU_ATTACH) { +#ifdef TPPT + if (tp_traceflags[D_REQUEST]) { tptraceTPCB(TPPTusrreq, "req failed NO TPCB[", 0, 0, 0, 0); - ENDTRACE + } +#endif splx(s); return ENOTCONN; } - switch (req) { case PRU_ATTACH: if (tpcb) { error = EISCONN; - } else if ((error = tp_attach(so, (long)nam)) == 0) + } else if ((error = tp_attach(so, (long) nam)) == 0) tpcb = sototpcb(so); break; - case PRU_ABORT: /* called from close() */ - /* called for each incoming connect queued on the - * parent (accepting) socket + case PRU_ABORT: /* called from close() */ + /* + * called for each incoming connect queued on the parent + * (accepting) socket */ if (tpcb->tp_state == TP_OPEN || tpcb->tp_state == TP_CONFIRMING) { - E.ATTR(T_DISC_req).e_reason = E_TP_NO_SESSION ^ TP_ERROR_MASK; - error = DoEvent(T_DISC_req); /* pretend it was a close() */ + E.TPDU_ATTR(REQ).e_reason = E_TP_NO_SESSION ^ TP_ERROR_MASK; + error = DoEvent(T_DISC_req); /* pretend it was a + * close() */ break; - } /* else DROP THROUGH */ - - case PRU_DETACH: /* called from close() */ + } /* else DROP THROUGH */ + case PRU_DETACH: /* called from close() */ /* called only after disconnect was called */ error = DoEvent(T_DETACH); if (tpcb->tp_state == TP_CLOSED) { if (tpcb->tp_notdetached) { - IFDEBUG(D_CONN) +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("PRU_DETACH: not detached\n"); - ENDDEBUG + } +#endif tp_detach(tpcb); } - free((caddr_t)tpcb, M_PCB); + free((caddr_t) tpcb, M_PCB); tpcb = 0; } break; case PRU_SHUTDOWN: - /* recv end may have been released; local credit might be zero */ + /* + * recv end may have been released; local credit might be + * zero + */ case PRU_DISCONNECT: - E.ATTR(T_DISC_req).e_reason = E_TP_NORMAL_DISC ^ TP_ERROR_MASK; + E.TPDU_ATTR(REQ).e_reason = E_TP_NORMAL_DISC ^ TP_ERROR_MASK; error = DoEvent(T_DISC_req); break; case PRU_BIND: - error = tp_pcbbind(tpcb, nam); + error = tp_pcbbind(tpcb, nam); break; case PRU_LISTEN: if (tpcb->tp_state != TP_CLOSED || tpcb->tp_lsuffixlen == 0 || - tpcb->tp_next == 0) + tpcb->tp_next == 0) error = EINVAL; else { register struct tp_pcb **tt; @@ -464,79 +494,96 @@ tp_usrreq(so, req, m, nam, controlp) break; case PRU_CONNECT2: - error = EOPNOTSUPP; /* for unix domain sockets */ + error = EOPNOTSUPP; /* for unix domain sockets */ break; case PRU_CONNECT: - IFTRACE(D_CONN) - tptraceTPCB(TPPTmisc, - "PRU_CONNECT: so 0x%x *SHORT_LSUFXP(tpcb) 0x%x lsuflen 0x%x, class 0x%x", - tpcb->tp_sock, *SHORT_LSUFXP(tpcb), tpcb->tp_lsuffixlen, - tpcb->tp_class); - ENDTRACE - IFDEBUG(D_CONN) +#ifdef TPPT + if (tp_traceflags[D_CONN]) { + tptraceTPCB(TPPTmisc, + "PRU_CONNECT: so 0x%x *SHORT_LSUFXP(tpcb) 0x%x lsuflen 0x%x, class 0x%x", + tpcb->tp_sock, *SHORT_LSUFXP(tpcb), tpcb->tp_lsuffixlen, + tpcb->tp_class); + } +#endif +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("PRU_CONNECT: so *SHORT_LSUFXP(tpcb) 0x%x lsuflen 0x%x, class 0x%x", - tpcb->tp_sock, *SHORT_LSUFXP(tpcb), tpcb->tp_lsuffixlen, - tpcb->tp_class); - ENDDEBUG + tpcb->tp_sock, *SHORT_LSUFXP(tpcb), tpcb->tp_lsuffixlen, + tpcb->tp_class); + } +#endif if (tpcb->tp_lsuffixlen == 0) { - if (error = tp_pcbbind(tpcb, MNULL)) { - IFDEBUG(D_CONN) + if ((error = tp_pcbbind(tpcb, MNULL)) != 0) { +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("pcbbind returns error 0x%x\n", error); - ENDDEBUG + } +#endif break; } } - IFDEBUG(D_CONN) +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf("isop 0x%x isop->isop_socket offset 12 :\n", tpcb->tp_npcb); dump_buf(tpcb->tp_npcb, 16); - ENDDEBUG - if (error = tp_route_to(nam, tpcb, /* channel */0)) + } +#endif + if ((error = tp_route_to(nam, tpcb, /* channel */ 0)) != 0) break; - IFDEBUG(D_CONN) +#ifdef ARGO_DEBUG + if (argo_debug[D_CONN]) { printf( - "PRU_CONNECT after tpcb 0x%x so 0x%x npcb 0x%x flags 0x%x\n", - tpcb, so, tpcb->tp_npcb, tpcb->tp_flags); + "PRU_CONNECT after tpcb 0x%x so 0x%x npcb 0x%x flags 0x%x\n", + tpcb, so, tpcb->tp_npcb, tpcb->tp_flags); printf("isop 0x%x isop->isop_socket offset 12 :\n", tpcb->tp_npcb); dump_buf(tpcb->tp_npcb, 16); - ENDDEBUG - if (tpcb->tp_fsuffixlen == 0) { + } +#endif + if (tpcb->tp_fsuffixlen == 0) { /* didn't set peer extended suffix */ - (tpcb->tp_nlproto->nlp_getsufx)(tpcb->tp_npcb, &tpcb->tp_fsuffixlen, - tpcb->tp_fsuffix, TP_FOREIGN); + (tpcb->tp_nlproto->nlp_getsufx) (tpcb->tp_npcb, + &tpcb->tp_fsuffixlen, + tpcb->tp_fsuffix, TP_FOREIGN); } if (tpcb->tp_state == TP_CLOSED) { - soisconnecting(so); + soisconnecting(so); error = DoEvent(T_CONN_req); } else { - (tpcb->tp_nlproto->nlp_pcbdisc)(tpcb->tp_npcb); + (tpcb->tp_nlproto->nlp_pcbdisc) (tpcb->tp_npcb); error = EISCONN; } - IFPERF(tpcb) - u_int lsufx, fsufx; - lsufx = *(u_short *)(tpcb->tp_lsuffix); - fsufx = *(u_short *)(tpcb->tp_fsuffix); - - tpmeas(tpcb->tp_lref, - TPtime_open | (tpcb->tp_xtd_format << 4), - &time, lsufx, fsufx, tpcb->tp_fref); - ENDPERF +#ifdef TP_PERF_MEAS + if (DOPERF(tpcb)) { + u_int lsufx, fsufx; + lsufx = *(u_short *) (tpcb->tp_lsuffix); + fsufx = *(u_short *) (tpcb->tp_fsuffix); + + tpmeas(tpcb->tp_lref, + TPtime_open | (tpcb->tp_xtd_format << 4), + &time, lsufx, fsufx, tpcb->tp_fref); + } +#endif break; - case PRU_ACCEPT: - (tpcb->tp_nlproto->nlp_getnetaddr)(tpcb->tp_npcb, nam, TP_FOREIGN); - IFDEBUG(D_REQUEST) + case PRU_ACCEPT: + (tpcb->tp_nlproto->nlp_getnetaddr) (tpcb->tp_npcb, nam, TP_FOREIGN); +#ifdef ARGO_DEBUG + if (argo_debug[D_REQUEST]) { printf("ACCEPT PEERADDDR:"); dump_buf(mtod(nam, char *), nam->m_len); - ENDDEBUG - IFPERF(tpcb) - u_int lsufx, fsufx; - lsufx = *(u_short *)(tpcb->tp_lsuffix); - fsufx = *(u_short *)(tpcb->tp_fsuffix); - - tpmeas(tpcb->tp_lref, TPtime_open, - &time, lsufx, fsufx, tpcb->tp_fref); - ENDPERF + } +#endif +#ifdef TP_PERF_MEAS + if (DOPERF(tpcb)) { + u_int lsufx, fsufx; + lsufx = *(u_short *) (tpcb->tp_lsuffix); + fsufx = *(u_short *) (tpcb->tp_fsuffix); + + tpmeas(tpcb->tp_lref, TPtime_open, + &time, lsufx, fsufx, tpcb->tp_fref); + } +#endif break; case PRU_RCVD: @@ -545,26 +592,30 @@ tp_usrreq(so, req, m, nam, controlp) error = tp_confirm(tpcb); break; } - IFTRACE(D_DATA) +#ifdef TPPT + if (tp_traceflags[D_DATA]) { tptraceTPCB(TPPTmisc, - "RCVD BF: lcredit sent_lcdt cc hiwat \n", - tpcb->tp_lcredit, tpcb->tp_sent_lcdt, - so->so_rcv.sb_cc, so->so_rcv.sb_hiwat); + "RCVD BF: lcredit sent_lcdt cc hiwat \n", + tpcb->tp_lcredit, tpcb->tp_sent_lcdt, + so->so_rcv.sb_cc, so->so_rcv.sb_hiwat); LOCAL_CREDIT(tpcb); - tptraceTPCB(TPPTmisc, - "PRU_RCVD AF sbspace lcredit hiwat cc", - sbspace(&so->so_rcv), tpcb->tp_lcredit, - so->so_rcv.sb_cc, so->so_rcv.sb_hiwat); - ENDTRACE - IFDEBUG(D_REQUEST) + tptraceTPCB(TPPTmisc, + "PRU_RCVD AF sbspace lcredit hiwat cc", + sbspace(&so->so_rcv), tpcb->tp_lcredit, + so->so_rcv.sb_cc, so->so_rcv.sb_hiwat); + } +#endif +#ifdef ARGO_DEBUG + if (argo_debug[D_REQUEST]) { printf("RCVD: cc %d space %d hiwat %d\n", - so->so_rcv.sb_cc, sbspace(&so->so_rcv), - so->so_rcv.sb_hiwat); - ENDDEBUG - if (((long)nam) & MSG_OOB) - error = DoEvent(T_USR_Xrcvd); - else - error = DoEvent(T_USR_rcvd); + so->so_rcv.sb_cc, sbspace(&so->so_rcv), + so->so_rcv.sb_hiwat); + } +#endif + if (((long) nam) & MSG_OOB) + error = DoEvent(T_USR_Xrcvd); + else + error = DoEvent(T_USR_rcvd); break; case PRU_RCVOOB: @@ -572,12 +623,12 @@ tp_usrreq(so, req, m, nam, controlp) error = ENOTCONN; break; } - if (! tpcb->tp_xpd_service) { + if (!tpcb->tp_xpd_service) { error = EOPNOTSUPP; break; } /* kludge - nam is really flags here */ - error = tp_rcvoob(tpcb, so, m, outflags, (long)nam); + error = tp_rcvoob(tpcb, so, m, outflags, (long) nam); break; case PRU_SEND: @@ -591,10 +642,10 @@ tp_usrreq(so, req, m, nam, controlp) if ((so->so_state & SS_ISCONFIRMING) && (tpcb->tp_state == TP_CONFIRMING) && (error = tp_confirm(tpcb))) - break; + break; if (req == PRU_SENDOOB) { error = (tpcb->tp_xpd_service == 0) ? - EOPNOTSUPP : tp_sendoob(tpcb, so, m, outflags); + EOPNOTSUPP : tp_sendoob(tpcb, so, m, outflags); break; } if (m == 0) @@ -622,44 +673,52 @@ tp_usrreq(so, req, m, nam, controlp) { /* * Could have eotsdu and no data.(presently MUST have - * an mbuf though, even if its length == 0) + * an mbuf though, even if its length == 0) */ - int totlen = m->m_pkthdr.len; + int totlen = m->m_pkthdr.len; struct sockbuf *sb = &so->so_snd; - IFPERF(tpcb) - PStat(tpcb, Nb_from_sess) += totlen; - tpmeas(tpcb->tp_lref, TPtime_from_session, 0, 0, - PStat(tpcb, Nb_from_sess), totlen); - ENDPERF - IFDEBUG(D_SYSCALL) +#ifdef TP_PERF_MEAS + if (DOPERF(tpcb)) { + PStat(tpcb, Nb_from_sess) += totlen; + tpmeas(tpcb->tp_lref, TPtime_from_session, 0, 0, + PStat(tpcb, Nb_from_sess), totlen); + } +#endif +#ifdef ARGO_DEBUG + if (argo_debug[D_SYSCALL]) { printf( - "PRU_SEND: eot %d before sbappend 0x%x len 0x%x to sb @ 0x%x\n", - eotsdu, m, totlen, sb); + "PRU_SEND: eot %d before sbappend 0x%x len 0x%x to sb @ 0x%x\n", + eotsdu, m, totlen, sb); dump_mbuf(sb->sb_mb, "so_snd.sb_mb"); dump_mbuf(m, "m : to be added"); - ENDDEBUG + } +#endif tp_packetize(tpcb, m, eotsdu); - IFDEBUG(D_SYSCALL) +#ifdef ARGO_DEBUG + if (argo_debug[D_SYSCALL]) { printf("PRU_SEND: eot %d after sbappend 0x%x\n", eotsdu, m); dump_mbuf(sb->sb_mb, "so_snd.sb_mb"); - ENDDEBUG + } +#endif if (tpcb->tp_state == TP_OPEN) - error = DoEvent(T_DATA_req); - IFDEBUG(D_SYSCALL) - printf("PRU_SEND: after driver error 0x%x \n",error); + error = DoEvent(T_DATA_req); +#ifdef ARGO_DEBUG + if (argo_debug[D_SYSCALL]) { + printf("PRU_SEND: after driver error 0x%x \n", error); printf("so_snd 0x%x cc 0t%d mbcnt 0t%d\n", - sb, sb->sb_cc, sb->sb_mbcnt); + sb, sb->sb_cc, sb->sb_mbcnt); dump_mbuf(sb->sb_mb, "so_snd.sb_mb after driver"); - ENDDEBUG + } +#endif } break; case PRU_SOCKADDR: - (tpcb->tp_nlproto->nlp_getnetaddr)(tpcb->tp_npcb, nam, TP_LOCAL); + (tpcb->tp_nlproto->nlp_getnetaddr) (tpcb->tp_npcb, nam, TP_LOCAL); break; case PRU_PEERADDR: - (tpcb->tp_nlproto->nlp_getnetaddr)(tpcb->tp_npcb, nam, TP_FOREIGN); + (tpcb->tp_nlproto->nlp_getnetaddr) (tpcb->tp_npcb, nam, TP_FOREIGN); break; case PRU_CONTROL: @@ -677,19 +736,23 @@ tp_usrreq(so, req, m, nam, controlp) default: #ifdef ARGO_DEBUG printf("tp_usrreq UNKNOWN PRU %d\n", req); -#endif /* ARGO_DEBUG */ +#endif /* ARGO_DEBUG */ error = EOPNOTSUPP; } - IFDEBUG(D_REQUEST) +#ifdef ARGO_DEBUG + if (argo_debug[D_REQUEST]) { printf("%s, so 0x%x, tpcb 0x%x, error %d, state %d\n", - "returning from tp_usrreq", so, tpcb, error, - tpcb ? tpcb->tp_state : 0); - ENDDEBUG - IFTRACE(D_REQUEST) - tptraceTPCB(TPPTusrreq, "END req so m state [", req, so, m, - tpcb ? tpcb->tp_state : 0); - ENDTRACE + "returning from tp_usrreq", so, tpcb, error, + tpcb ? tpcb->tp_state : 0); + } +#endif +#ifdef TPPT + if (tp_traceflags[D_REQUEST]) { + tptraceTPCB(TPPTusrreq, "END req so m state [", req, so, m, + tpcb ? tpcb->tp_state : 0); + } +#endif if (controlp) { m_freem(controlp); printf("control data unexpectedly retained in tp_usrreq()"); @@ -697,54 +760,60 @@ tp_usrreq(so, req, m, nam, controlp) splx(s); return error; } + +void tp_ltrace(so, uio) -struct socket *so; -struct uio *uio; + struct socket *so; + struct uio *uio; { - IFTRACE(D_DATA) - register struct tp_pcb *tpcb = sototpcb(so); +#ifdef TPPT + if (tp_traceflags[D_DATA]) { + register struct tp_pcb *tpcb = sototpcb(so); if (tpcb) { tptraceTPCB(TPPTmisc, "sosend so resid iovcnt", so, - uio->uio_resid, uio->uio_iovcnt, 0); + uio->uio_resid, uio->uio_iovcnt, 0); } - ENDTRACE + } +#endif } +int tp_confirm(tpcb) -register struct tp_pcb *tpcb; + register struct tp_pcb *tpcb; { struct tp_event E; if (tpcb->tp_state == TP_CONFIRMING) - return DoEvent(T_ACPT_req); + return DoEvent(T_ACPT_req); printf("Tp confirm called when not confirming; tpcb 0x%x, state 0x%x\n", - tpcb, tpcb->tp_state); + tpcb, tpcb->tp_state); return 0; } /* * Process control data sent with sendmsg() */ +int tp_snd_control(m, so, data) - struct mbuf *m; - struct socket *so; + struct mbuf *m; + struct socket *so; register struct mbuf **data; { register struct cmsghdr *ch; - int error = 0; + int error = 0; if (m && m->m_len) { ch = mtod(m, struct cmsghdr *); - m->m_len -= sizeof (*ch); - m->m_data += sizeof (*ch); + m->m_len -= sizeof(*ch); + m->m_data += sizeof(*ch); error = tp_ctloutput(PRCO_SETOPT, - so, ch->cmsg_level, ch->cmsg_type, &m); + so, ch->cmsg_level, ch->cmsg_type, &m); if (ch->cmsg_type == TPOPT_DISC_DATA) { if (data && *data) { m_freem(*data); *data = 0; } - error = tp_usrreq(so, PRU_DISCONNECT, (struct mbuf *)0, - (caddr_t)0, (struct mbuf *)0); + error = tp_usrreq(so, PRU_DISCONNECT, NULL, + NULL, NULL); } } if (m) diff --git a/sys/netiso/tp_var.h b/sys/netiso/tp_var.h new file mode 100644 index 00000000000..82b7282403e --- /dev/null +++ b/sys/netiso/tp_var.h @@ -0,0 +1,194 @@ +/* $OpenBSD: tp_var.h,v 1.1 1996/03/04 10:36:47 mickey Exp $ */ +/* $NetBSD: tp_var.h,v 1.1 1996/02/13 22:12:29 christos Exp $ */ + +/* + * Copyright (c) 1995 Christos Zoulas. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christos Zoulas. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef _KERNEL +struct isopcb; +struct mbuf; +struct sockaddr_iso; +struct tp_pcb; +struct sockaddr_in; +struct iso_addr; +struct tp_conn_param; +struct tp_event; +struct inpcb; +struct route; +struct pklcd; +struct sockaddr; +struct x25_packet; +struct in_addr; + + +/* tp_cons.c */ +int tpcons_pcbconnect __P((void *, struct mbuf *)); +void *tpcons_ctlinput __P((int, struct sockaddr *, void *)); +void tpcons_input __P((struct mbuf *, ...)); +int tpcons_output __P((struct mbuf *, ...)); +int tpcons_output_dg __P((struct mbuf *, ...)); + +/* tp_driver.c */ +int tp_driver __P((struct tp_pcb *, struct tp_event *)); + +/* tp_emit.c */ +int tp_emit __P((int, struct tp_pcb *, SeqNum, u_int, struct mbuf *)); +int tp_error_emit __P((int, u_long, struct sockaddr_iso *, + struct sockaddr_iso *, struct mbuf *, int, + struct tp_pcb *, caddr_t, + int (*) (struct mbuf *, ...))); + +/* tp_inet.c */ +void in_getsufx __P((void *, u_short *, caddr_t, int)); +void in_putsufx __P((void *, caddr_t, int, int)); +void in_recycle_tsuffix __P((void *)); +void in_putnetaddr __P((void *, struct sockaddr *, int)); +int in_cmpnetaddr __P((void *, struct sockaddr *, int)); +void in_getnetaddr __P((void *, struct mbuf *, int)); +int tpip_mtu __P((void *)); +int tpip_output __P((struct mbuf *, ...)); +int tpip_output_dg __P((struct mbuf *, ...)); +void tpip_input __P((struct mbuf *, ...)); +void tpin_quench __P((struct inpcb *, int)); +void *tpip_ctlinput __P((int, struct sockaddr *, void *)); +void tpin_abort __P((struct inpcb *, int)); +void dump_inaddr __P((struct sockaddr_in *)); + +/* tp_input.c */ +struct mbuf *tp_inputprep __P((struct mbuf *)); +void tp_input __P((struct mbuf *, ...)); +int tp_headersize __P((int, struct tp_pcb *)); + +/* tp_iso.c */ +void iso_getsufx __P((void *, u_short *, caddr_t, int)); +void iso_putsufx __P((void *, caddr_t, int, int)); +void iso_recycle_tsuffix __P((void *)); +void iso_putnetaddr __P((void *, struct sockaddr *, int)); +int iso_cmpnetaddr __P((void *, struct sockaddr *, int)); +void iso_getnetaddr __P((void *, struct mbuf *, int)); +int tpclnp_mtu __P((void *)); +int tpclnp_output __P((struct mbuf *, ...)); +int tpclnp_output_dg __P((struct mbuf *, ...)); +void tpclnp_input __P((struct mbuf *, ...)); +void iso_rtchange __P((struct isopcb *)); +void tpiso_decbit __P((struct isopcb *)); +void tpiso_quench __P((struct isopcb *)); +void *tpclnp_ctlinput __P((int, struct sockaddr *, void *)); +void tpclnp_ctlinput1 __P((int, struct iso_addr *)); +void tpiso_abort __P((struct isopcb *)); +void tpiso_reset __P((struct isopcb *)); + +/* tp_meas.c */ +void Tpmeas __P((u_int, u_int, struct timeval *, u_int, u_int, u_int)); + +/* tp_output.c */ +int tp_consistency __P((struct tp_pcb *, u_int, struct tp_conn_param *)); +int tp_ctloutput __P((int, struct socket *, int, int, struct mbuf **)); + +/* tp_pcb.c */ +void tp_init __P((void)); +void tp_soisdisconnecting __P((struct socket *)); +void tp_soisdisconnected __P((struct tp_pcb *)); +void tp_freeref __P((RefNum)); +u_long tp_getref __P((struct tp_pcb *)); +int tp_set_npcb __P((struct tp_pcb *)); +int tp_attach __P((struct socket *, long)); +void tp_detach __P((struct tp_pcb *)); +int tp_tselinuse __P((int, caddr_t, struct sockaddr_iso *, int)); +int tp_pcbbind __P((void *, struct mbuf *)); + +/* tp_subr.c */ +int tp_goodXack __P((struct tp_pcb *, SeqNum)); +void tp_rtt_rtv __P((struct tp_pcb *)); +int tp_goodack __P((struct tp_pcb *, u_int, SeqNum, u_int)); +int tp_sbdrop __P((struct tp_pcb *, SeqNum)); +void tp_send __P((struct tp_pcb *)); +int tp_packetize __P((struct tp_pcb *, struct mbuf *, int)); +int tp_stash __P((struct tp_pcb *, struct tp_event *)); +void tp_rsyflush __P((struct tp_pcb *)); +void tp_rsyset __P((struct tp_pcb *)); +void tpsbcheck __P((struct tp_pcb *, int)); + +/* tp_subr2.c */ +void tp_local_credit __P((struct tp_pcb *)); +int tp_protocol_error __P((struct tp_event *, struct tp_pcb *)); +void tp_drain __P((void)); +void tp_indicate __P((int, struct tp_pcb *, u_short)); +void tp_getoptions __P((struct tp_pcb *)); +void tp_recycle_tsuffix __P((void *)); +void tp_quench __P((struct inpcb *, int)); +void tp_netcmd __P((struct tp_pcb *, int)); +int tp_mask_to_num __P((u_char)); +void tp_mss __P((struct tp_pcb *, int)); +int tp_route_to __P((struct mbuf *, struct tp_pcb *, caddr_t)); +void tp0_stash __P((struct tp_pcb *, struct tp_event *)); +void tp0_openflow __P((struct tp_pcb *)); +int tp_setup_perf __P((struct tp_pcb *)); +void dump_addr __P((struct sockaddr *)); +void Dump_buf __P((caddr_t, int)); + +/* tp_timer.c */ +void tp_timerinit __P((void)); +void tp_etimeout __P((struct tp_pcb *, int, int)); +void tp_euntimeout __P((struct tp_pcb *, int)); +void tp_slowtimo __P((void)); +void tp_data_retrans __P((struct tp_pcb *)); +void tp_fasttimo __P((void)); +void tp_ctimeout __P((struct tp_pcb *, int, int)); +void tp_ctimeout_MIN __P((struct tp_pcb *, int, int)); +void tp_cuntimeout __P((struct tp_pcb *, int)); + +/* tp_trace.c */ +void tpTrace __P((struct tp_pcb *, u_int, u_int, u_int, u_int, u_int, + u_int)); + +/* tp_usrreq.c */ +void dump_mbuf __P((struct mbuf *, char *)); +int tp_rcvoob __P((struct tp_pcb *, struct socket *, struct mbuf *, + int *, int)); +int tp_sendoob __P((struct tp_pcb *, struct socket *, struct mbuf *, int *)); +int tp_usrreq __P((struct socket *, int, struct mbuf *, struct mbuf *, + struct mbuf *)); +void tp_ltrace __P((struct socket *, struct uio *)); +int tp_confirm __P((struct tp_pcb *)); +int tp_snd_control __P((struct mbuf *, struct socket *, struct mbuf **)); + +#ifdef TPCONS +/* if_cons.c */ +void nibble_copy __P((char *, unsigned, char *, unsigned, int)); +int nibble_match __P((char *, unsigned, char *, unsigned, int)); +void cons_init __P((void)); +int tp_incoming __P((struct mbuf *, void *)); +int cons_tpinput __P((struct mbuf *, void *)); +int cons_connect __P((struct isopcb *)); +void *cons_ctlinput __P((int, struct sockaddr *, void *)); +int find_error_reason __P((struct x25_packet *)); +#endif + +#endif diff --git a/sys/netiso/tuba_subr.c b/sys/netiso/tuba_subr.c index 927fea34a12..0bc3fa9464c 100644 --- a/sys/netiso/tuba_subr.c +++ b/sys/netiso/tuba_subr.c @@ -1,4 +1,5 @@ -/* $NetBSD: tuba_subr.c,v 1.5 1995/11/21 01:07:54 cgd Exp $ */ +/* $OpenBSD: tuba_subr.c,v 1.3 1996/03/04 10:36:49 mickey Exp $ */ +/* $NetBSD: tuba_subr.c,v 1.7 1996/02/13 22:12:32 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -69,13 +70,29 @@ #include <netiso/iso_var.h> #include <netiso/tuba_table.h> -static struct sockaddr_iso null_siso = { sizeof(null_siso), AF_ISO, }; -extern int tuba_table_size, tcp_keepidle, tcp_keepintvl, tcp_maxidle; -extern int tcppcbcachemiss, tcppredack, tcppreddat, tcprexmtthresh; -extern struct tcpiphdr tcp_saveti; -struct inpcbtable tuba_inpcb; -struct inpcb *tuba_last_inpcb = 0; -struct isopcb tuba_isopcb; +#include <machine/stdarg.h> + +static struct sockaddr_iso null_siso = {sizeof(null_siso), AF_ISO,}; +extern int tuba_table_size, tcp_keepidle, tcp_keepintvl, tcp_maxidle; +extern int tcppcbcachemiss, tcppredack, tcppreddat, tcprexmtthresh; +extern struct tcpiphdr tcp_saveti; +struct inpcbtable tuba_inpcb; +struct isopcb tuba_isopcb; + +#ifndef TUBA_INPCBHASHSIZE +#define TUBA_INPCBHASHSIZE 128 +#endif +int tuba_inpcbhashsize = TUBA_INPCBHASHSIZE; + + +struct addr_arg { + int error; + int offset; + u_long sum; +}; + +static void tuba_getaddr __P((struct addr_arg *, struct sockaddr_iso **, + u_long)); /* * Tuba initialization */ @@ -85,7 +102,7 @@ tuba_init() #define TUBAHDRSIZE (3 /*LLC*/ + 9 /*CLNP Fixed*/ + 42 /*Addresses*/ \ + 6 /*CLNP Segment*/ + 20 /*TCP*/) - in_pcbinit(&tuba_inpcb); + in_pcbinit(&tuba_inpcb, tuba_inpcbhashsize); tuba_isopcb.isop_next = tuba_isopcb.isop_prev = &tuba_isopcb; tuba_isopcb.isop_faddr = &tuba_isopcb.isop_sfaddr; tuba_isopcb.isop_laddr = &tuba_isopcb.isop_sladdr; @@ -95,12 +112,6 @@ tuba_init() panic("tuba_init"); } -struct addr_arg { - int error; - int offset; - u_long sum; -}; - /* * Calculate contribution to fudge factor for TCP checksum, * and coincidentally set pointer for convenience of clnp_output @@ -110,29 +121,30 @@ static void tuba_getaddr(arg, siso, index) register struct addr_arg *arg; struct sockaddr_iso **siso; - u_long index; + u_long index; { register struct tuba_cache *tc; if (index <= tuba_table_size && (tc = tuba_table[index])) { if (siso) *siso = &tc->tc_siso; arg->sum += (arg->offset & 1 ? tc->tc_ssum : tc->tc_sum) - + (0xffff ^ index); + + (0xffff ^ index); arg->offset += tc->tc_siso.siso_nlen + 1; } else arg->error = 1; } +int tuba_output(m, tp) register struct mbuf *m; - struct tcpcb *tp; + struct tcpcb *tp; { register struct tcpiphdr *n; - struct isopcb *isop; - struct addr_arg arg; + struct isopcb *isop; + struct addr_arg arg; - if (tp == 0 || (n = tp->t_template) == 0 || - (isop = (struct isopcb *)tp->t_tuba_pcb) == 0) { + if (tp == 0 || (n = tp->t_template) == 0 || + (isop = (struct isopcb *) tp->t_tuba_pcb) == 0) { isop = &tuba_isopcb; n = mtod(m, struct tcpiphdr *); arg.error = arg.sum = arg.offset = 0; @@ -143,29 +155,31 @@ tuba_output(m, tp) } if (n->ti_sum == 0) { arg.error = arg.sum = arg.offset = 0; - tuba_getaddr(&arg, (struct sockaddr_iso **)0, n->ti_dst.s_addr); - tuba_getaddr(&arg, (struct sockaddr_iso **)0, n->ti_src.s_addr); + tuba_getaddr(&arg, (struct sockaddr_iso **) 0, n->ti_dst.s_addr); + tuba_getaddr(&arg, (struct sockaddr_iso **) 0, n->ti_src.s_addr); REDUCE(arg.sum, arg.sum); n->ti_sum = arg.sum; n = mtod(m, struct tcpiphdr *); - adjust: +adjust: if (arg.error) { m_freem(m); return (EADDRNOTAVAIL); } REDUCE(n->ti_sum, n->ti_sum + (0xffff ^ arg.sum)); } - m->m_len -= sizeof (struct ip); - m->m_pkthdr.len -= sizeof (struct ip); - m->m_data += sizeof (struct ip); + m->m_len -= sizeof(struct ip); + m->m_pkthdr.len -= sizeof(struct ip); + m->m_data += sizeof(struct ip); return (clnp_output(m, isop, m->m_pkthdr.len, 0)); } +void tuba_refcnt(isop, delta) - struct isopcb *isop; + struct isopcb *isop; + int delta; { register struct tuba_cache *tc; - unsigned index, sum; + unsigned index; if (delta != 1) delta = -1; @@ -175,16 +189,18 @@ tuba_refcnt(isop, delta) return; isop->isop_tuba_cached = (delta == 1); if ((index = tuba_lookup(isop->isop_faddr, M_DONTWAIT)) != 0 && - (tc = tuba_table[index]) != 0 && (delta == 1 || tc->tc_refcnt > 0)) + (tc = tuba_table[index]) != 0 && (delta == 1 || tc->tc_refcnt > 0)) tc->tc_refcnt += delta; if ((index = tuba_lookup(isop->isop_laddr, M_DONTWAIT)) != 0 && - (tc = tuba_table[index]) != 0 && (delta == 1 || tc->tc_refcnt > 0)) + (tc = tuba_table[index]) != 0 && (delta == 1 || tc->tc_refcnt > 0)) tc->tc_refcnt += delta; } -tuba_pcbdetach(isop) - struct isopcb *isop; +void +tuba_pcbdetach(v) + void *v; { + struct isopcb *isop = v; if (isop == 0) return; tuba_refcnt(isop, -1); @@ -195,21 +211,23 @@ tuba_pcbdetach(isop) /* * Avoid in_pcbconnect in faked out tcp_input() */ -tuba_pcbconnect(inp, nam) - register struct inpcb *inp; - struct mbuf *nam; +int +tuba_pcbconnect(v, nam) + void *v; + struct mbuf *nam; { + register struct inpcb *inp = v; register struct sockaddr_iso *siso; struct sockaddr_in *sin = mtod(nam, struct sockaddr_in *); - struct tcpcb *tp = intotcpcb(inp); - struct isopcb *isop = (struct isopcb *)tp->t_tuba_pcb; - int error; + struct tcpcb *tp = intotcpcb(inp); + struct isopcb *isop = (struct isopcb *) tp->t_tuba_pcb; + int error; /* hardwire iso_pcbbind() here */ siso = isop->isop_laddr = &isop->isop_sladdr; *siso = tuba_table[inp->inp_laddr.s_addr]->tc_siso; siso->siso_tlen = sizeof(inp->inp_lport); - bcopy((caddr_t)&inp->inp_lport, TSEL(siso), sizeof(inp->inp_lport)); + bcopy((caddr_t) & inp->inp_lport, TSEL(siso), sizeof(inp->inp_lport)); /* hardwire in_pcbconnect() here without assigning route */ inp->inp_fport = sin->sin_port; @@ -220,7 +238,7 @@ tuba_pcbconnect(inp, nam) siso = mtod(nam, struct sockaddr_iso *); *siso = tuba_table[inp->inp_faddr.s_addr]->tc_siso; siso->siso_tlen = sizeof(inp->inp_fport); - bcopy((caddr_t)&inp->inp_fport, TSEL(siso), sizeof(inp->inp_fport)); + bcopy((caddr_t) & inp->inp_fport, TSEL(siso), sizeof(inp->inp_fport)); if ((error = iso_pcbconnect(isop, nam)) == 0) tuba_refcnt(isop, 1); @@ -233,28 +251,41 @@ tuba_pcbconnect(inp, nam) * FUNCTION and ARGUMENTS: * Take a packet (m) from clnp, strip off the clnp header * and do tcp input processing. - * No return value. + * No return value. */ -tuba_tcpinput(m, src, dst) - register struct mbuf *m; - struct sockaddr_iso *src, *dst; +void +#if __STDC__ +tuba_tcpinput(struct mbuf *m, ...) +#else +tuba_tcpinput(m, va_alist) + struct mbuf *m; /* ptr to first mbuf of pkt */ + va_dcl +#endif { - unsigned long sum, lindex, findex; + unsigned long lindex, findex; register struct tcpiphdr *ti; register struct inpcb *inp; - caddr_t optp = NULL; - int optlen; - int len, tlen, off; + caddr_t optp = NULL; + int optlen = 0; + int len, tlen, off; register struct tcpcb *tp = 0; - int tiflags; - struct socket *so; - int todrop, acked, ourfinisacked, needoutput = 0; - short ostate; - struct in_addr laddr; - int dropsocket = 0, iss = 0; - u_long tiwin; - u_int32_t ts_val, ts_ecr; - int ts_present = 0; + int tiflags; + struct socket *so = NULL; + int todrop, acked, ourfinisacked, needoutput = 0; + short ostate = 0; + struct in_addr laddr; + int dropsocket = 0, iss = 0; + u_long tiwin; + u_int32_t ts_val, ts_ecr; + int ts_present = 0; + struct sockaddr_iso *src, *dst; + va_list ap; + + va_start(ap, m); + src = va_arg(ap, struct sockaddr_iso *); + dst = va_arg(ap, struct sockaddr_iso *); + va_end(ap); + if ((m->m_flags & M_PKTHDR) == 0) panic("tuba_tcpinput"); @@ -276,7 +307,8 @@ tuba_tcpinput(m, src, dst) m->m_data -= sizeof(struct ip); m->m_len += sizeof(struct ip); m->m_pkthdr.len += sizeof(struct ip); - m->m_flags &= ~(M_MCAST|M_BCAST); /* XXX should do this in clnp_input */ + m->m_flags &= ~(M_MCAST | M_BCAST); /* XXX should do this in + * clnp_input */ /* * The reassembly code assumes it will be overwriting a useless * part of the packet, which is why we need to have it point @@ -286,13 +318,13 @@ tuba_tcpinput(m, src, dst) * so that we can save copying the tcp header. * This code knows way too much about the structure of mbufs! */ - off = ((sizeof (long) - 1) & ((m->m_flags & M_EXT) ? - (m->m_data - m->m_ext.ext_buf) : (m->m_data - m->m_pktdat))); + off = ((sizeof(long) - 1) & ((m->m_flags & M_EXT) ? + (m->m_data - m->m_ext.ext_buf) : (m->m_data - m->m_pktdat))); if (off || len < sizeof(struct tcphdr)) { - struct mbuf *m0 = m; + struct mbuf *m0 = m; MGETHDR(m, M_DONTWAIT, MT_DATA); - if (m == 0) { + if (m == 0) { m = m0; goto drop; } @@ -328,8 +360,8 @@ tuba_tcpinput(m, src, dst) ti->ti_src.s_addr = tuba_table[findex]->tc_ssum; bzero(ti->ti_x1, sizeof ti->ti_x1); ti->ti_pr = ISOPROTO_TCP; - ti->ti_len = htons((u_short)tlen); - if (ti->ti_sum = in_cksum(m, m->m_pkthdr.len)) { + ti->ti_len = htons((u_short) tlen); + if ((ti->ti_sum = in_cksum(m, m->m_pkthdr.len)) != 0) { tcpstat.tcps_rcvbadsum++; goto drop; } @@ -341,7 +373,6 @@ tuba_tcpinput(m, src, dst) #define TUBA_INCLUDE #define in_pcbconnect tuba_pcbconnect #define tcb tuba_inpcb -#define tcp_last_inpcb tuba_last_inpcb #include <netinet/tcp_input.c> } diff --git a/sys/netiso/tuba_table.c b/sys/netiso/tuba_table.c index e9663a13539..c52f19956f3 100644 --- a/sys/netiso/tuba_table.c +++ b/sys/netiso/tuba_table.c @@ -1,4 +1,5 @@ -/* $NetBSD: tuba_table.c,v 1.5 1995/10/16 05:28:58 mycroft Exp $ */ +/* $OpenBSD: tuba_table.c,v 1.3 1996/03/04 10:36:50 mickey Exp $ */ +/* $NetBSD: tuba_table.c,v 1.6 1996/02/13 22:12:34 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -52,68 +53,71 @@ #include <netiso/iso.h> #include <netiso/tuba_table.h> -int tuba_table_size; -struct tuba_cache **tuba_table; -struct radix_node_head *tuba_tree; -extern int arpt_keep, arpt_prune; /* use same values as arp cache */ +int tuba_table_size; +struct tuba_cache **tuba_table; +struct radix_node_head *tuba_tree; +extern int arpt_keep, arpt_prune; /* use same values as arp cache */ void -tuba_timer() +tuba_timer(v) + void *v; { - int s = splsoftnet(); - int i; - register struct tuba_cache *tc; - long timelimit = time.tv_sec - arpt_keep; + int s = splsoftnet(); + int i; + register struct tuba_cache *tc; + long timelimit = time.tv_sec - arpt_keep; - timeout(tuba_timer, (caddr_t)0, arpt_prune * hz); + timeout(tuba_timer, (caddr_t) 0, arpt_prune * hz); for (i = tuba_table_size; i > 0; i--) if ((tc = tuba_table[i]) && (tc->tc_refcnt == 0) && (tc->tc_time < timelimit)) { tuba_table[i] = 0; rn_delete(&tc->tc_siso.siso_addr, NULL, tuba_tree); - free((caddr_t)tc, M_RTABLE); + free((caddr_t) tc, M_RTABLE); } splx(s); } +void tuba_table_init() { - rn_inithead((void **)&tuba_tree, 40); - timeout(tuba_timer, (caddr_t)0, arpt_prune * hz); + rn_inithead((void **) &tuba_tree, 40); + timeout(tuba_timer, (caddr_t) 0, arpt_prune * hz); } int tuba_lookup(siso, wait) register struct sockaddr_iso *siso; + int wait; { - struct radix_node *rn, *rn_match(); + struct radix_node *rn; register struct tuba_cache *tc; struct tuba_cache **new; - int dupentry = 0, sum_a = 0, sum_b = 0, old_size, i; + int dupentry = 0, sum_a = 0, sum_b = 0, old_size, i; - if ((rn = rn_match((caddr_t)&siso->siso_addr, tuba_tree)) - && ((rn->rn_flags & RNF_ROOT) == 0)) { - tc = (struct tuba_cache *)rn; + if ((rn = rn_match((caddr_t) &siso->siso_addr, tuba_tree)) != NULL + && ((rn->rn_flags & RNF_ROOT) == 0)) { + tc = (struct tuba_cache *) rn; tc->tc_time = time.tv_sec; return (tc->tc_index); } - if ((tc = (struct tuba_cache *)malloc(sizeof(*tc), M_RTABLE, wait)) - == NULL) + if ((tc = (struct tuba_cache *) malloc(sizeof(*tc), M_RTABLE, wait)) + == NULL) return (0); - bzero((caddr_t)tc, sizeof (*tc)); + bzero((caddr_t) tc, sizeof(*tc)); bcopy(siso->siso_data, tc->tc_siso.siso_data, - tc->tc_siso.siso_nlen = siso->siso_nlen); + tc->tc_siso.siso_nlen = siso->siso_nlen); rn_insert(&tc->tc_siso.siso_addr, tuba_tree, &dupentry, tc->tc_nodes); if (dupentry) panic("tuba_lookup 1"); tc->tc_siso.siso_family = AF_ISO; tc->tc_siso.siso_len = sizeof(tc->tc_siso); tc->tc_time = time.tv_sec; - for (i = sum_a = tc->tc_siso.siso_nlen; --i >= 0; ) + for (i = sum_a = tc->tc_siso.siso_nlen; --i >= 0;) if (i & 1) - sum_a += (u_char)tc->tc_siso.siso_data[i]; + sum_a += (u_char) tc->tc_siso.siso_data[i]; else - sum_b += (u_char)tc->tc_siso.siso_data[i]; + sum_b += (u_char) tc->tc_siso.siso_data[i]; REDUCE(tc->tc_sum, (sum_a << 8) + sum_b); HTONS(tc->tc_sum); SWAB(tc->tc_ssum, tc->tc_sum); @@ -127,17 +131,17 @@ tuba_lookup(siso, wait) return (0); tuba_table_size = 1 + 2 * tuba_table_size; i = (tuba_table_size + 1) * sizeof(tc); - new = (struct tuba_cache **)malloc((unsigned)i, M_RTABLE, wait); + new = (struct tuba_cache **) malloc((unsigned) i, M_RTABLE, wait); if (new == 0) { tuba_table_size = old_size; rn_delete(&tc->tc_siso.siso_addr, NULL, tuba_tree); - free((caddr_t)tc, M_RTABLE); + free((caddr_t) tc, M_RTABLE); return (0); } - bzero((caddr_t)new, (unsigned)i); + bzero((caddr_t) new, (unsigned) i); if (tuba_table) { - bcopy((caddr_t)tuba_table, (caddr_t)new, i >> 1); - free((caddr_t)tuba_table, M_RTABLE); + bcopy((caddr_t) tuba_table, (caddr_t) new, i >> 1); + free((caddr_t) tuba_table, M_RTABLE); } tuba_table = new; i = tuba_table_size; diff --git a/sys/netiso/tuba_table.h b/sys/netiso/tuba_table.h index c0a12a33240..87a348a0ed1 100644 --- a/sys/netiso/tuba_table.h +++ b/sys/netiso/tuba_table.h @@ -1,4 +1,5 @@ -/* $NetBSD: tuba_table.h,v 1.3 1995/03/26 20:35:36 jtc Exp $ */ +/* $OpenBSD: tuba_table.h,v 1.2 1996/03/04 10:36:52 mickey Exp $ */ +/* $NetBSD: tuba_table.h,v 1.4 1996/02/13 22:12:37 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -36,15 +37,15 @@ */ struct tuba_cache { - struct radix_node tc_nodes[2]; /* convenient lookup */ - int tc_refcnt; - int tc_time; /* last looked up */ - int tc_flags; + struct radix_node tc_nodes[2]; /* convenient lookup */ + int tc_refcnt; + int tc_time;/* last looked up */ + int tc_flags; #define TCF_PERM 1 - int tc_index; - u_short tc_sum; /* cksum of nsap inc. length */ - u_short tc_ssum; /* swab(tc_sum) */ - struct sockaddr_iso tc_siso; /* for responding */ + int tc_index; + u_short tc_sum; /* cksum of nsap inc. length */ + u_short tc_ssum;/* swab(tc_sum) */ + struct sockaddr_iso tc_siso; /* for responding */ }; #define ADDCARRY(x) (x >= 65535 ? x -= 65535 : x) @@ -55,7 +56,35 @@ struct tuba_cache { s.s = (b); t = s.c[0]; s.c[0] = s.c[1]; s.c[1] = t; a = s.s;} #ifdef _KERNEL -extern int tuba_table_size; -extern struct tuba_cache **tuba_table; -extern struct radix_node_head *tuba_tree; +extern int tuba_table_size; +extern struct tuba_cache **tuba_table; +extern struct radix_node_head *tuba_tree; + +struct mbuf; +struct tcpcb; +struct isopcb; +struct inpcb; +struct sockaddr_iso; +struct socket; + +/* tuba_subr.c */ +void tuba_init __P((void)); +int tuba_output __P((struct mbuf *, struct tcpcb *)); +void tuba_refcnt __P((struct isopcb *, int )); +void tuba_pcbdetach __P((void *)); +int tuba_pcbconnect __P((void *, struct mbuf *)); +void tuba_tcpinput __P((struct mbuf *, ...)); +int tuba_pcbconnect __P((void *, struct mbuf *)); +void tuba_slowtimo __P((void)); +void tuba_fasttimo __P((void)); + +/* tuba_table.c */ +void tuba_timer __P((void *)); +void tuba_table_init __P((void)); +int tuba_lookup __P((struct sockaddr_iso *, int )); + +/* tuba_usrreq.c */ +int tuba_usrreq __P((struct socket *, int, struct mbuf *, struct mbuf *, + struct mbuf *)); +int tuba_ctloutput __P((int, struct socket *, int, int , struct mbuf **)); #endif diff --git a/sys/netiso/tuba_usrreq.c b/sys/netiso/tuba_usrreq.c index 9887528021c..0fc605cdea5 100644 --- a/sys/netiso/tuba_usrreq.c +++ b/sys/netiso/tuba_usrreq.c @@ -1,4 +1,5 @@ -/* $NetBSD: tuba_usrreq.c,v 1.7 1995/08/12 23:59:55 mycroft Exp $ */ +/* $OpenBSD: tuba_usrreq.c,v 1.2 1996/03/04 10:36:54 mickey Exp $ */ +/* $NetBSD: tuba_usrreq.c,v 1.8 1996/02/13 22:12:40 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -70,32 +71,33 @@ /* * TCP protocol interface to socket abstraction. */ -extern char *tcpstates[]; -extern struct inpcbtable tuba_inpcb; -extern struct isopcb tuba_isopcb; +extern char *tcpstates[]; +extern struct inpcbtable tuba_inpcb; +extern struct isopcb tuba_isopcb; /* * Process a TCP user request for TCP tb. If this is a send request * then m is the mbuf chain of send data. If this is a timer expiration * (called from the software clock routine), then timertype tells which timer. */ -/*ARGSUSED*/ +/* ARGSUSED */ +int tuba_usrreq(so, req, m, nam, control) - struct socket *so; - int req; - struct mbuf *m, *nam, *control; + struct socket *so; + int req; + struct mbuf *m, *nam, *control; { register struct inpcb *inp; - register struct isopcb *isop; - register struct tcpcb *tp; - int s; - int error = 0; - int ostate; + register struct isopcb *isop = NULL; + register struct tcpcb *tp = NULL; + int s; + int error = 0; + int ostate; struct sockaddr_iso *siso; if (req == PRU_CONTROL) - return (iso_control(so, (long)m, (caddr_t)nam, - (struct ifnet *)control)); + return (iso_control(so, (long) m, (caddr_t) nam, + (struct ifnet *) control)); s = splsoftnet(); inp = sotoinpcb(so); @@ -104,42 +106,42 @@ tuba_usrreq(so, req, m, nam, control) * a (struct inpcb) pointed at by the socket, and this * structure will point at a subsidary (struct tcpcb). */ - if (inp == 0 && req != PRU_ATTACH) { + if (inp == 0 && req != PRU_ATTACH) { splx(s); - return (EINVAL); /* XXX */ + return (EINVAL);/* XXX */ } if (inp) { tp = intotcpcb(inp); if (tp == 0) panic("tuba_usrreq"); ostate = tp->t_state; - isop = (struct isopcb *)tp->t_tuba_pcb; + isop = (struct isopcb *) tp->t_tuba_pcb; if (isop == 0) panic("tuba_usrreq 2"); } else ostate = 0; switch (req) { - /* - * TCP attaches to socket via PRU_ATTACH, reserving space, - * and an internet control block. We also need to - * allocate an isopcb and separate the control block from - * tcp/ip ones. - */ + /* + * TCP attaches to socket via PRU_ATTACH, reserving space, + * and an internet control block. We also need to + * allocate an isopcb and separate the control block from + * tcp/ip ones. + */ case PRU_ATTACH: - if (error = iso_pcballoc(so, &tuba_isopcb)) + if ((error = iso_pcballoc(so, &tuba_isopcb)) != 0) break; - isop = (struct isopcb *)so->so_pcb; + isop = (struct isopcb *) so->so_pcb; so->so_pcb = 0; - if (error = tcp_usrreq(so, req, m, nam, control)) { + if ((error = tcp_usrreq(so, req, m, nam, control)) != 0) { isop->isop_socket = 0; iso_pcbdetach(isop); } else { inp = sotoinpcb(so); CIRCLEQ_REMOVE(&inp->inp_table->inpt_queue, inp, - inp_queue); + inp_queue); CIRCLEQ_INSERT_HEAD(&tuba_inpcb.inpt_queue, inp, - inp_queue); + inp_queue); inp->inp_table = &tuba_inpcb; tp = intotcpcb(inp); if (tp == 0) @@ -148,13 +150,13 @@ tuba_usrreq(so, req, m, nam, control) } goto notrace; - /* - * PRU_DETACH detaches the TCP protocol from the socket. - * If the protocol state is non-embryonic, then can't - * do this directly: have to initiate a PRU_DISCONNECT, - * which may finish later; embryonic TCB's can just - * be discarded here. - */ + /* + * PRU_DETACH detaches the TCP protocol from the socket. + * If the protocol state is non-embryonic, then can't + * do this directly: have to initiate a PRU_DISCONNECT, + * which may finish later; embryonic TCB's can just + * be discarded here. + */ case PRU_DETACH: if (tp->t_state > TCPS_LISTEN) tp = tcp_disconnect(tp); @@ -164,16 +166,16 @@ tuba_usrreq(so, req, m, nam, control) tuba_pcbdetach(isop); break; - /* - * Give the socket an address. - */ + /* + * Give the socket an address. + */ case PRU_BIND: siso = mtod(nam, struct sockaddr_iso *); if (siso->siso_tlen && siso->siso_tlen != 2) { error = EINVAL; break; } - if ((error = iso_pcbbind(isop, nam)) || + if ((error = iso_pcbbind(isop, nam)) || (siso = isop->isop_laddr) == 0) break; bcopy(TSEL(siso), &inp->inp_lport, 2); @@ -182,29 +184,29 @@ tuba_usrreq(so, req, m, nam, control) error = ENOBUFS; break; - /* - * Prepare to accept connections. - */ + /* + * Prepare to accept connections. + */ case PRU_CONNECT: case PRU_LISTEN: if (inp->inp_lport == 0 && - (error = iso_pcbbind(isop, (struct mbuf *)0))) + (error = iso_pcbbind(isop, NULL))) break; bcopy(TSEL(isop->isop_laddr), &inp->inp_lport, 2); if (req == PRU_LISTEN) { tp->t_state = TCPS_LISTEN; break; } - /*FALLTHROUGH*/ - /* - * Initiate connection to peer. - * Create a template for use in transmissions on this connection. - * Enter SYN_SENT state, and mark socket as connecting. - * Start keep-alive timer, and seed output sequence space. - * Send initial segment on connection. - */ - /* case PRU_CONNECT: */ - if (error = iso_pcbconnect(isop, nam)) + /* FALLTHROUGH */ + /* + * Initiate connection to peer. + * Create a template for use in transmissions on this connection. + * Enter SYN_SENT state, and mark socket as connecting. + * Start keep-alive timer, and seed output sequence space. + * Send initial segment on connection. + */ + /* case PRU_CONNECT: */ + if ((error = iso_pcbconnect(isop, nam)) != 0) break; if ((siso = isop->isop_laddr) && siso->siso_nlen > 1) siso->siso_data[siso->siso_nlen - 1] = ISOPROTO_TCP; @@ -212,15 +214,15 @@ tuba_usrreq(so, req, m, nam, control) panic("tuba_usrreq: connect"); siso = mtod(nam, struct sockaddr_iso *); if (!(inp->inp_faddr.s_addr = tuba_lookup(siso, M_WAITOK))) { - unconnect: + unconnect: iso_pcbdisconnect(isop); error = ENOBUFS; break; } bcopy(TSEL(isop->isop_faddr), &inp->inp_fport, 2); if (inp->inp_laddr.s_addr == 0 && - (inp->inp_laddr.s_addr = - tuba_lookup(isop->isop_laddr, M_WAITOK)) == 0) + (inp->inp_laddr.s_addr = + tuba_lookup(isop->isop_laddr, M_WAITOK)) == 0) goto unconnect; if ((tp->t_template = tcp_template(tp)) == 0) goto unconnect; @@ -228,41 +230,42 @@ tuba_usrreq(so, req, m, nam, control) tcpstat.tcps_connattempt++; tp->t_state = TCPS_SYN_SENT; tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; - tp->iss = tcp_iss; tcp_iss += TCP_ISSINCR/2; + tp->iss = tcp_iss; + tcp_iss += TCP_ISSINCR / 2; tcp_sendseqinit(tp); error = tcp_output(tp); tuba_refcnt(isop, 1); break; - /* - * Initiate disconnect from peer. - * If connection never passed embryonic stage, just drop; - * else if don't need to let data drain, then can just drop anyways, - * else have to begin TCP shutdown process: mark socket disconnecting, - * drain unread data, state switch to reflect user close, and - * send segment (e.g. FIN) to peer. Socket will be really disconnected - * when peer sends FIN and acks ours. - * - * SHOULD IMPLEMENT LATER PRU_CONNECT VIA REALLOC TCPCB. - */ + /* + * Initiate disconnect from peer. + * If connection never passed embryonic stage, just drop; + * else if don't need to let data drain, then can just drop anyways, + * else have to begin TCP shutdown process: mark socket disconnecting, + * drain unread data, state switch to reflect user close, and + * send segment (e.g. FIN) to peer. Socket will be really disconnected + * when peer sends FIN and acks ours. + * + * SHOULD IMPLEMENT LATER PRU_CONNECT VIA REALLOC TCPCB. + */ case PRU_DISCONNECT: if ((tp = tcp_disconnect(tp)) == 0) tuba_pcbdetach(isop); break; - /* - * Accept a connection. Essentially all the work is - * done at higher levels; just return the address - * of the peer, storing through addr. - */ + /* + * Accept a connection. Essentially all the work is + * done at higher levels; just return the address + * of the peer, storing through addr. + */ case PRU_ACCEPT: - bcopy((caddr_t)isop->isop_faddr, mtod(nam, caddr_t), - nam->m_len = isop->isop_faddr->siso_len); + bcopy((caddr_t) isop->isop_faddr, mtod(nam, caddr_t), + nam->m_len = isop->isop_faddr->siso_len); break; - /* - * Mark the connection as being incapable of further output. - */ + /* + * Mark the connection as being incapable of further output. + */ case PRU_SHUTDOWN: socantsendmore(so); tp = tcp_usrclosed(tp); @@ -271,9 +274,9 @@ tuba_usrreq(so, req, m, nam, control) else tuba_pcbdetach(isop); break; - /* - * Abort the TCP. - */ + /* + * Abort the TCP. + */ case PRU_ABORT: if ((tp = tcp_drop(tp, ECONNABORTED)) == 0) tuba_pcbdetach(isop); @@ -282,14 +285,14 @@ tuba_usrreq(so, req, m, nam, control) case PRU_SOCKADDR: if (isop->isop_laddr) - bcopy((caddr_t)isop->isop_laddr, mtod(nam, caddr_t), - nam->m_len = isop->isop_laddr->siso_len); + bcopy((caddr_t) isop->isop_laddr, mtod(nam, caddr_t), + nam->m_len = isop->isop_laddr->siso_len); break; case PRU_PEERADDR: if (isop->isop_faddr) - bcopy((caddr_t)isop->isop_faddr, mtod(nam, caddr_t), - nam->m_len = isop->isop_faddr->siso_len); + bcopy((caddr_t) isop->isop_faddr, mtod(nam, caddr_t), + nam->m_len = isop->isop_faddr->siso_len); break; default: @@ -297,20 +300,21 @@ tuba_usrreq(so, req, m, nam, control) goto notrace; } if (tp && (so->so_options & SO_DEBUG)) - tcp_trace(TA_USER, ostate, tp, (struct tcpiphdr *)0, req); + tcp_trace(TA_USER, ostate, tp, (struct tcpiphdr *) 0, req); notrace: splx(s); - return(error); + return (error); } +int tuba_ctloutput(op, so, level, optname, mp) - int op; - struct socket *so; - int level, optname; - struct mbuf **mp; + int op; + struct socket *so; + int level, optname; + struct mbuf **mp; { - int clnp_ctloutput(), tcp_ctloutput(); - - return ((level != IPPROTO_TCP ? clnp_ctloutput : tcp_ctloutput) - (op, so, level, optname, mp)); + if (level != IPPROTO_TCP) + return rclnp_ctloutput(op, so, level, optname, mp); + else + return tcp_ctloutput(op, so, level, optname, mp); } diff --git a/sys/netiso/xebec/Makefile b/sys/netiso/xebec/Makefile index ece942987c5..200d10088c7 100644 --- a/sys/netiso/xebec/Makefile +++ b/sys/netiso/xebec/Makefile @@ -1,3 +1,4 @@ +# $OpenBSD: Makefile,v 1.2 1996/03/04 10:37:00 mickey Exp $ # $NetBSD: Makefile,v 1.5 1994/06/29 06:40:59 cgd Exp $ # @(#)Makefile 5.16 (Berkeley) 4/26/91 diff --git a/sys/netiso/xebec/debug.h b/sys/netiso/xebec/debug.h index 2e69ba2bebe..05daceb3eae 100644 --- a/sys/netiso/xebec/debug.h +++ b/sys/netiso/xebec/debug.h @@ -1,3 +1,4 @@ +/* $OpenBSD: debug.h,v 1.2 1996/03/04 10:37:01 mickey Exp $ */ /* $NetBSD: debug.h,v 1.4 1994/06/29 06:41:00 cgd Exp $ */ #define OUT stdout diff --git a/sys/netiso/xebec/llparse.c b/sys/netiso/xebec/llparse.c index 0f7cb1d1cbb..bfb61a04cb4 100644 --- a/sys/netiso/xebec/llparse.c +++ b/sys/netiso/xebec/llparse.c @@ -1,3 +1,4 @@ +/* $OpenBSD: llparse.c,v 1.2 1996/03/04 10:37:03 mickey Exp $ */ /* $NetBSD: llparse.c,v 1.4 1994/06/29 06:41:02 cgd Exp $ */ /* diff --git a/sys/netiso/xebec/llparse.h b/sys/netiso/xebec/llparse.h index f996d88ab0e..43ad4418299 100644 --- a/sys/netiso/xebec/llparse.h +++ b/sys/netiso/xebec/llparse.h @@ -1,3 +1,4 @@ +/* $OpenBSD: llparse.h,v 1.2 1996/03/04 10:37:05 mickey Exp $ */ /* $NetBSD: llparse.h,v 1.4 1994/06/29 06:41:04 cgd Exp $ */ /************************************************************ diff --git a/sys/netiso/xebec/llscan.c b/sys/netiso/xebec/llscan.c index b41f9bd4c11..12ae482582d 100644 --- a/sys/netiso/xebec/llscan.c +++ b/sys/netiso/xebec/llscan.c @@ -1,3 +1,4 @@ +/* $OpenBSD: llscan.c,v 1.2 1996/03/04 10:37:07 mickey Exp $ */ /* $NetBSD: llscan.c,v 1.5 1994/06/29 06:41:05 cgd Exp $ */ /* diff --git a/sys/netiso/xebec/main.c b/sys/netiso/xebec/main.c index b39f1c1ea56..6b26122c426 100644 --- a/sys/netiso/xebec/main.c +++ b/sys/netiso/xebec/main.c @@ -1,3 +1,4 @@ +/* $OpenBSD: main.c,v 1.2 1996/03/04 10:37:09 mickey Exp $ */ /* $NetBSD: main.c,v 1.5 1994/06/29 06:41:07 cgd Exp $ */ /* diff --git a/sys/netiso/xebec/main.h b/sys/netiso/xebec/main.h index 920c4d3823c..0deabb0b4b8 100644 --- a/sys/netiso/xebec/main.h +++ b/sys/netiso/xebec/main.h @@ -1,3 +1,4 @@ +/* $OpenBSD: main.h,v 1.2 1996/03/04 10:37:10 mickey Exp $ */ /* $NetBSD: main.h,v 1.4 1994/06/29 06:41:08 cgd Exp $ */ #define TRUE 1 diff --git a/sys/netiso/xebec/malloc.c b/sys/netiso/xebec/malloc.c index e4e7e85a16d..191e69d996b 100644 --- a/sys/netiso/xebec/malloc.c +++ b/sys/netiso/xebec/malloc.c @@ -1,3 +1,4 @@ +/* $OpenBSD: malloc.c,v 1.2 1996/03/04 10:37:12 mickey Exp $ */ /* $NetBSD: malloc.c,v 1.4 1994/06/29 06:41:10 cgd Exp $ */ /* diff --git a/sys/netiso/xebec/malloc.h b/sys/netiso/xebec/malloc.h index 24fa30a3398..af371abd2c3 100644 --- a/sys/netiso/xebec/malloc.h +++ b/sys/netiso/xebec/malloc.h @@ -1,3 +1,4 @@ +/* $OpenBSD: malloc.h,v 1.2 1996/03/04 10:37:13 mickey Exp $ */ /* $NetBSD: malloc.h,v 1.4 1994/06/29 06:41:11 cgd Exp $ */ char *Malloc(); diff --git a/sys/netiso/xebec/procs.c b/sys/netiso/xebec/procs.c index 3eef7afea6c..57f76fd211e 100644 --- a/sys/netiso/xebec/procs.c +++ b/sys/netiso/xebec/procs.c @@ -1,3 +1,4 @@ +/* $OpenBSD: procs.c,v 1.2 1996/03/04 10:37:16 mickey Exp $ */ /* $NetBSD: procs.c,v 1.4 1994/06/29 06:41:12 cgd Exp $ */ /* diff --git a/sys/netiso/xebec/procs.h b/sys/netiso/xebec/procs.h index 624c85562e3..55c168f2f2f 100644 --- a/sys/netiso/xebec/procs.h +++ b/sys/netiso/xebec/procs.h @@ -1,3 +1,4 @@ +/* $OpenBSD: procs.h,v 1.2 1996/03/04 10:37:18 mickey Exp $ */ /* $NetBSD: procs.h,v 1.4 1994/06/29 06:41:13 cgd Exp $ */ extern char *stash(); diff --git a/sys/netiso/xebec/putdriver.c b/sys/netiso/xebec/putdriver.c index bf6a03771af..f39f480316f 100644 --- a/sys/netiso/xebec/putdriver.c +++ b/sys/netiso/xebec/putdriver.c @@ -1,3 +1,4 @@ +/* $OpenBSD: putdriver.c,v 1.2 1996/03/04 10:37:20 mickey Exp $ */ /* $NetBSD: putdriver.c,v 1.4 1994/06/29 06:41:15 cgd Exp $ */ /* diff --git a/sys/netiso/xebec/sets.c b/sys/netiso/xebec/sets.c index d2b3e83bf43..eb19b5ea79d 100644 --- a/sys/netiso/xebec/sets.c +++ b/sys/netiso/xebec/sets.c @@ -1,3 +1,4 @@ +/* $OpenBSD: sets.c,v 1.2 1996/03/04 10:37:22 mickey Exp $ */ /* $NetBSD: sets.c,v 1.4 1994/06/29 06:41:16 cgd Exp $ */ /* diff --git a/sys/netiso/xebec/sets.h b/sys/netiso/xebec/sets.h index a3b6bf44fa6..8459a45508d 100644 --- a/sys/netiso/xebec/sets.h +++ b/sys/netiso/xebec/sets.h @@ -1,3 +1,4 @@ +/* $OpenBSD: sets.h,v 1.2 1996/03/04 10:37:24 mickey Exp $ */ /* $NetBSD: sets.h,v 1.4 1994/06/29 06:41:17 cgd Exp $ */ #define MAXEVENTS 200 diff --git a/sys/netiso/xebec/test.trans b/sys/netiso/xebec/test.trans index bc0dcc2613a..07f002fa1de 100644 --- a/sys/netiso/xebec/test.trans +++ b/sys/netiso/xebec/test.trans @@ -1,3 +1,4 @@ +/* $OpenBSD: test.trans,v 1.2 1996/03/04 10:37:25 mickey Exp $ */ /* $NetBSD: test.trans,v 1.4 1994/06/29 06:41:18 cgd Exp $ */ *PROTOCOL test diff --git a/sys/netiso/xebec/test_def.h b/sys/netiso/xebec/test_def.h index 8bee12f8c34..ad54c14bf25 100644 --- a/sys/netiso/xebec/test_def.h +++ b/sys/netiso/xebec/test_def.h @@ -1,3 +1,4 @@ +/* $OpenBSD: test_def.h,v 1.2 1996/03/04 10:37:26 mickey Exp $ */ /* $NetBSD: test_def.h,v 1.4 1994/06/29 06:41:20 cgd Exp $ */ struct blah { diff --git a/sys/netiso/xebec/xebec.bnf b/sys/netiso/xebec/xebec.bnf index 210802c3211..1ad342b2e34 100644 --- a/sys/netiso/xebec/xebec.bnf +++ b/sys/netiso/xebec/xebec.bnf @@ -1,3 +1,4 @@ +/* $OpenBSD: xebec.bnf,v 1.2 1996/03/04 10:37:28 mickey Exp $ */ /* $NetBSD: xebec.bnf,v 1.4 1994/06/29 06:41:22 cgd Exp $ */ #include "main.h" diff --git a/sys/netiso/xebec/xebec.c b/sys/netiso/xebec/xebec.c index c92fbb467c4..31bd3161af0 100644 --- a/sys/netiso/xebec/xebec.c +++ b/sys/netiso/xebec/xebec.c @@ -1,3 +1,4 @@ +/* $OpenBSD: xebec.c,v 1.2 1996/03/04 10:37:30 mickey Exp $ */ /* $NetBSD: xebec.c,v 1.4 1994/06/29 06:41:23 cgd Exp $ */ #include "xebec.h" diff --git a/sys/netiso/xebec/xebec.h b/sys/netiso/xebec/xebec.h index a3c70d7191f..bb87d142679 100644 --- a/sys/netiso/xebec/xebec.h +++ b/sys/netiso/xebec/xebec.h @@ -1,3 +1,4 @@ +/* $OpenBSD: xebec.h,v 1.2 1996/03/04 10:37:31 mickey Exp $ */ /* $NetBSD: xebec.h,v 1.4 1994/06/29 06:41:25 cgd Exp $ */ union llattrib { |