1139823Simp/*- 211819Sjulian * Copyright (c) 1984, 1985, 1986, 1987, 1993 311819Sjulian * The Regents of the University of California. All rights reserved. 411819Sjulian * 511819Sjulian * Redistribution and use in source and binary forms, with or without 611819Sjulian * modification, are permitted provided that the following conditions 711819Sjulian * are met: 811819Sjulian * 1. Redistributions of source code must retain the above copyright 911819Sjulian * notice, this list of conditions and the following disclaimer. 1011819Sjulian * 2. Redistributions in binary form must reproduce the above copyright 1111819Sjulian * notice, this list of conditions and the following disclaimer in the 1211819Sjulian * documentation and/or other materials provided with the distribution. 13165899Srwatson * 4. Neither the name of the University nor the names of its contributors 14165899Srwatson * may be used to endorse or promote products derived from this software 15165899Srwatson * without specific prior written permission. 16165899Srwatson * 17165899Srwatson * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18165899Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19165899Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20165899Srwatson * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21165899Srwatson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22165899Srwatson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23165899Srwatson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24165899Srwatson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25165899Srwatson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26165899Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27165899Srwatson * SUCH DAMAGE. 28165899Srwatson * 29165899Srwatson * Copyright (c) 1995, Mike Mitchell 30165899Srwatson * 31165899Srwatson * Redistribution and use in source and binary forms, with or without 32165899Srwatson * modification, are permitted provided that the following conditions 33165899Srwatson * are met: 34165899Srwatson * 1. Redistributions of source code must retain the above copyright 35165899Srwatson * notice, this list of conditions and the following disclaimer. 36165899Srwatson * 2. Redistributions in binary form must reproduce the above copyright 37165899Srwatson * notice, this list of conditions and the following disclaimer in the 38165899Srwatson * documentation and/or other materials provided with the distribution. 3911819Sjulian * 3. All advertising materials mentioning features or use of this software 4011819Sjulian * must display the following acknowledgement: 4111819Sjulian * This product includes software developed by the University of 4211819Sjulian * California, Berkeley and its contributors. 4311819Sjulian * 4. Neither the name of the University nor the names of its contributors 4411819Sjulian * may be used to endorse or promote products derived from this software 4511819Sjulian * without specific prior written permission. 4611819Sjulian * 4711819Sjulian * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 4811819Sjulian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 4911819Sjulian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 5011819Sjulian * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 5111819Sjulian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 5211819Sjulian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 5311819Sjulian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 5411819Sjulian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 5511819Sjulian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 5611819Sjulian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 5711819Sjulian * SUCH DAMAGE. 5811819Sjulian * 5912057Sjulian * @(#)spx_debug.c 6011819Sjulian */ 6111819Sjulian 62116189Sobrien#include <sys/cdefs.h> 63116189Sobrien__FBSDID("$FreeBSD$"); 64116189Sobrien 6532350Seivind#include "opt_inet.h" 6630806Sbde#include "opt_tcpdebug.h" 6730806Sbde 6811819Sjulian#include <sys/param.h> 6911819Sjulian#include <sys/systm.h> 7011819Sjulian#include <sys/protosw.h> 7111819Sjulian 72171656Sdes#define TCPSTATES /* for logging */ 73171656Sdes 7411819Sjulian#include <netinet/in_systm.h> 7511819Sjulian#include <netinet/tcp_fsm.h> 7611819Sjulian 7711819Sjulian#include <netipx/ipx.h> 7830806Sbde#include <netipx/ipx_var.h> 7911819Sjulian#include <netipx/spx.h> 8011819Sjulian#define SPXTIMERS 8111819Sjulian#include <netipx/spx_timer.h> 8211819Sjulian#define SANAMES 8311819Sjulian#include <netipx/spx_debug.h> 8411819Sjulian 85193892Sbz#ifdef INET 8615239Sbde#ifdef TCPDEBUG 8725652Sjhaystatic int spxconsdebug = 0; 8825652Sjhaystatic struct spx_debug spx_debug[SPX_NDEBUG]; 8925652Sjhaystatic int spx_debx; 9015239Sbde#endif 91193892Sbz#endif 9215239Sbde 9311819Sjulian/* 9411819Sjulian * spx debug routines 9511819Sjulian */ 9611819Sjulianvoid 97169463Srwatsonspx_trace(short act, u_char ostate, struct spxpcb *sp, struct spx *si, 98169463Srwatson int req) 9911819Sjulian{ 10011819Sjulian#ifdef INET 10111819Sjulian#ifdef TCPDEBUG 10211819Sjulian u_short seq, ack, len, alo; 10311819Sjulian int flags; 10411819Sjulian struct spx_debug *sd = &spx_debug[spx_debx++]; 10511819Sjulian 10611819Sjulian if (spx_debx == SPX_NDEBUG) 10711819Sjulian spx_debx = 0; 10811819Sjulian sd->sd_time = iptime(); 10911819Sjulian sd->sd_act = act; 11011819Sjulian sd->sd_ostate = ostate; 11111819Sjulian sd->sd_cb = (caddr_t)sp; 11225652Sjhay if (sp != NULL) 11311819Sjulian sd->sd_sp = *sp; 11411819Sjulian else 11525652Sjhay bzero((caddr_t)&sd->sd_sp, sizeof(*sp)); 11625652Sjhay if (si != NULL) 11711819Sjulian sd->sd_si = *si; 11811819Sjulian else 11925652Sjhay bzero((caddr_t)&sd->sd_si, sizeof(*si)); 12011819Sjulian sd->sd_req = req; 12111819Sjulian if (spxconsdebug == 0) 12211819Sjulian return; 12325652Sjhay if (ostate >= TCP_NSTATES) 12425652Sjhay ostate = 0; 12525652Sjhay if (act >= SA_DROP) 12625652Sjhay act = SA_DROP; 12725652Sjhay if (sp != NULL) 12838373Sbde printf("%p %s:", (void *)sp, tcpstates[ostate]); 12911819Sjulian else 13011819Sjulian printf("???????? "); 13114093Swollman printf("%s ", spxnames[act]); 13211819Sjulian switch (act) { 13311819Sjulian 13411819Sjulian case SA_RESPOND: 13511819Sjulian case SA_INPUT: 13611819Sjulian case SA_OUTPUT: 13711819Sjulian case SA_DROP: 13825652Sjhay if (si == NULL) 13911819Sjulian break; 14011819Sjulian seq = si->si_seq; 14111819Sjulian ack = si->si_ack; 14211819Sjulian alo = si->si_alo; 14311819Sjulian len = si->si_len; 14411819Sjulian if (act == SA_OUTPUT) { 14511819Sjulian seq = ntohs(seq); 14611819Sjulian ack = ntohs(ack); 14711819Sjulian alo = ntohs(alo); 14811819Sjulian len = ntohs(len); 14911819Sjulian } 15011819Sjulian#ifndef lint 15111819Sjulian#define p1(f) { printf("%s = %x, ", "f", f); } 15211819Sjulian p1(seq); p1(ack); p1(alo); p1(len); 15311819Sjulian#endif 15411819Sjulian flags = si->si_cc; 15511819Sjulian if (flags) { 15611819Sjulian char *cp = "<"; 15711819Sjulian#ifndef lint 15811819Sjulian#define pf(f) { if (flags & SPX_ ## f) { printf("%s%s", cp, "f"); cp = ","; } } 15911819Sjulian pf(SP); pf(SA); pf(OB); pf(EM); 16011819Sjulian#else 16111819Sjulian cp = cp; 16211819Sjulian#endif 16311819Sjulian printf(">"); 16411819Sjulian } 16511819Sjulian#ifndef lint 16611819Sjulian#define p2(f) { printf("%s = %x, ", "f", si->si_ ## f); } 16711819Sjulian p2(sid);p2(did);p2(dt);p2(pt); 16811819Sjulian#endif 16911819Sjulian ipx_printhost(&si->si_sna); 17011819Sjulian ipx_printhost(&si->si_dna); 17111819Sjulian 17225652Sjhay if (act == SA_RESPOND) { 17311819Sjulian printf("ipx_len = %x, ", 17411819Sjulian ((struct ipx *)si)->ipx_len); 17511819Sjulian } 17611819Sjulian break; 17711819Sjulian 17811819Sjulian case SA_USER: 17911819Sjulian printf("%s", prurequests[req&0xff]); 18011819Sjulian if ((req & 0xff) == PRU_SLOWTIMO) 18111819Sjulian printf("<%s>", spxtimers[req>>8]); 18211819Sjulian break; 18311819Sjulian } 18411819Sjulian if (sp) 18511819Sjulian printf(" -> %s", tcpstates[sp->s_state]); 18611819Sjulian /* print out internal state of sp !?! */ 18711819Sjulian printf("\n"); 18811819Sjulian if (sp == 0) 18911819Sjulian return; 19011819Sjulian#ifndef lint 19111819Sjulian#define p3(f) { printf("%s = %x, ", "f", sp->s_ ## f); } 19211819Sjulian printf("\t"); p3(rack);p3(ralo);p3(smax);p3(flags); printf("\n"); 19311819Sjulian#endif 19411819Sjulian#endif 19511819Sjulian#endif 19611819Sjulian} 197