spx_debug.c revision 30806
111819Sjulian/* 211819Sjulian * Copyright (c) 1995, Mike Mitchell 311819Sjulian * Copyright (c) 1984, 1985, 1986, 1987, 1993 411819Sjulian * The Regents of the University of California. All rights reserved. 511819Sjulian * 611819Sjulian * Redistribution and use in source and binary forms, with or without 711819Sjulian * modification, are permitted provided that the following conditions 811819Sjulian * are met: 911819Sjulian * 1. Redistributions of source code must retain the above copyright 1011819Sjulian * notice, this list of conditions and the following disclaimer. 1111819Sjulian * 2. Redistributions in binary form must reproduce the above copyright 1211819Sjulian * notice, this list of conditions and the following disclaimer in the 1311819Sjulian * documentation and/or other materials provided with the distribution. 1411819Sjulian * 3. All advertising materials mentioning features or use of this software 1511819Sjulian * must display the following acknowledgement: 1611819Sjulian * This product includes software developed by the University of 1711819Sjulian * California, Berkeley and its contributors. 1811819Sjulian * 4. Neither the name of the University nor the names of its contributors 1911819Sjulian * may be used to endorse or promote products derived from this software 2011819Sjulian * without specific prior written permission. 2111819Sjulian * 2211819Sjulian * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2311819Sjulian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2411819Sjulian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2511819Sjulian * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2611819Sjulian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2711819Sjulian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2811819Sjulian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2911819Sjulian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3011819Sjulian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3111819Sjulian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3211819Sjulian * SUCH DAMAGE. 3311819Sjulian * 3412057Sjulian * @(#)spx_debug.c 3512057Sjulian * 3630806Sbde * $Id: spx_debug.c,v 1.10 1997/06/26 19:36:00 jhay Exp $ 3711819Sjulian */ 3811819Sjulian 3930806Sbde#include "opt_tcpdebug.h" 4030806Sbde 4111819Sjulian#include <sys/param.h> 4211819Sjulian#include <sys/systm.h> 4311819Sjulian#include <sys/protosw.h> 4411819Sjulian 4511819Sjulian#include <netinet/in_systm.h> 4611819Sjulian#include <netinet/tcp_fsm.h> 4711819Sjulian 4811819Sjulian#include <netipx/ipx.h> 4930806Sbde#include <netipx/ipx_var.h> 5011819Sjulian#include <netipx/spx.h> 5111819Sjulian#define SPXTIMERS 5211819Sjulian#include <netipx/spx_timer.h> 5311819Sjulian#define SANAMES 5411819Sjulian#include <netipx/spx_debug.h> 5511819Sjulian 5615239Sbde#ifdef TCPDEBUG 5725652Sjhaystatic int spxconsdebug = 0; 5825652Sjhaystatic struct spx_debug spx_debug[SPX_NDEBUG]; 5925652Sjhaystatic int spx_debx; 6015239Sbde#endif 6115239Sbde 6211819Sjulian/* 6311819Sjulian * spx debug routines 6411819Sjulian */ 6511819Sjulianvoid 6611819Sjulianspx_trace(act, ostate, sp, si, req) 6711819Sjulian short act; 6811819Sjulian u_char ostate; 6911819Sjulian struct spxpcb *sp; 7011819Sjulian struct spx *si; 7111819Sjulian int req; 7211819Sjulian{ 7311819Sjulian#ifdef INET 7411819Sjulian#ifdef TCPDEBUG 7511819Sjulian u_short seq, ack, len, alo; 7611819Sjulian int flags; 7711819Sjulian struct spx_debug *sd = &spx_debug[spx_debx++]; 7811819Sjulian 7911819Sjulian if (spx_debx == SPX_NDEBUG) 8011819Sjulian spx_debx = 0; 8111819Sjulian sd->sd_time = iptime(); 8211819Sjulian sd->sd_act = act; 8311819Sjulian sd->sd_ostate = ostate; 8411819Sjulian sd->sd_cb = (caddr_t)sp; 8525652Sjhay if (sp != NULL) 8611819Sjulian sd->sd_sp = *sp; 8711819Sjulian else 8825652Sjhay bzero((caddr_t)&sd->sd_sp, sizeof(*sp)); 8925652Sjhay if (si != NULL) 9011819Sjulian sd->sd_si = *si; 9111819Sjulian else 9225652Sjhay bzero((caddr_t)&sd->sd_si, sizeof(*si)); 9311819Sjulian sd->sd_req = req; 9411819Sjulian if (spxconsdebug == 0) 9511819Sjulian return; 9625652Sjhay if (ostate >= TCP_NSTATES) 9725652Sjhay ostate = 0; 9825652Sjhay if (act >= SA_DROP) 9925652Sjhay act = SA_DROP; 10025652Sjhay if (sp != NULL) 10111819Sjulian printf("%x %s:", sp, tcpstates[ostate]); 10211819Sjulian else 10311819Sjulian printf("???????? "); 10414093Swollman printf("%s ", spxnames[act]); 10511819Sjulian switch (act) { 10611819Sjulian 10711819Sjulian case SA_RESPOND: 10811819Sjulian case SA_INPUT: 10911819Sjulian case SA_OUTPUT: 11011819Sjulian case SA_DROP: 11125652Sjhay if (si == NULL) 11211819Sjulian break; 11311819Sjulian seq = si->si_seq; 11411819Sjulian ack = si->si_ack; 11511819Sjulian alo = si->si_alo; 11611819Sjulian len = si->si_len; 11711819Sjulian if (act == SA_OUTPUT) { 11811819Sjulian seq = ntohs(seq); 11911819Sjulian ack = ntohs(ack); 12011819Sjulian alo = ntohs(alo); 12111819Sjulian len = ntohs(len); 12211819Sjulian } 12311819Sjulian#ifndef lint 12411819Sjulian#define p1(f) { printf("%s = %x, ", "f", f); } 12511819Sjulian p1(seq); p1(ack); p1(alo); p1(len); 12611819Sjulian#endif 12711819Sjulian flags = si->si_cc; 12811819Sjulian if (flags) { 12911819Sjulian char *cp = "<"; 13011819Sjulian#ifndef lint 13111819Sjulian#define pf(f) { if (flags & SPX_ ## f) { printf("%s%s", cp, "f"); cp = ","; } } 13211819Sjulian pf(SP); pf(SA); pf(OB); pf(EM); 13311819Sjulian#else 13411819Sjulian cp = cp; 13511819Sjulian#endif 13611819Sjulian printf(">"); 13711819Sjulian } 13811819Sjulian#ifndef lint 13911819Sjulian#define p2(f) { printf("%s = %x, ", "f", si->si_ ## f); } 14011819Sjulian p2(sid);p2(did);p2(dt);p2(pt); 14111819Sjulian#endif 14211819Sjulian ipx_printhost(&si->si_sna); 14311819Sjulian ipx_printhost(&si->si_dna); 14411819Sjulian 14525652Sjhay if (act == SA_RESPOND) { 14611819Sjulian printf("ipx_len = %x, ", 14711819Sjulian ((struct ipx *)si)->ipx_len); 14811819Sjulian } 14911819Sjulian break; 15011819Sjulian 15111819Sjulian case SA_USER: 15211819Sjulian printf("%s", prurequests[req&0xff]); 15311819Sjulian if ((req & 0xff) == PRU_SLOWTIMO) 15411819Sjulian printf("<%s>", spxtimers[req>>8]); 15511819Sjulian break; 15611819Sjulian } 15711819Sjulian if (sp) 15811819Sjulian printf(" -> %s", tcpstates[sp->s_state]); 15911819Sjulian /* print out internal state of sp !?! */ 16011819Sjulian printf("\n"); 16111819Sjulian if (sp == 0) 16211819Sjulian return; 16311819Sjulian#ifndef lint 16411819Sjulian#define p3(f) { printf("%s = %x, ", "f", sp->s_ ## f); } 16511819Sjulian printf("\t"); p3(rack);p3(ralo);p3(smax);p3(flags); printf("\n"); 16611819Sjulian#endif 16711819Sjulian#endif 16811819Sjulian#endif 16911819Sjulian} 170