spx_debug.c revision 14093
1139749Simp/* 2156000Smjacob * Copyright (c) 1995, Mike Mitchell 3101704Smjacob * Copyright (c) 1984, 1985, 1986, 1987, 1993 4101704Smjacob * The Regents of the University of California. All rights reserved. 5101704Smjacob * 6101704Smjacob * Redistribution and use in source and binary forms, with or without 7101704Smjacob * modification, are permitted provided that the following conditions 8101704Smjacob * are met: 9101704Smjacob * 1. Redistributions of source code must retain the above copyright 10101704Smjacob * notice, this list of conditions and the following disclaimer. 11101704Smjacob * 2. Redistributions in binary form must reproduce the above copyright 12101704Smjacob * notice, this list of conditions and the following disclaimer in the 13101704Smjacob * documentation and/or other materials provided with the distribution. 14101704Smjacob * 3. All advertising materials mentioning features or use of this software 15101704Smjacob * must display the following acknowledgement: 16101704Smjacob * This product includes software developed by the University of 17101704Smjacob * California, Berkeley and its contributors. 18101704Smjacob * 4. Neither the name of the University nor the names of its contributors 19101704Smjacob * may be used to endorse or promote products derived from this software 20101704Smjacob * without specific prior written permission. 21101704Smjacob * 22101704Smjacob * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23101704Smjacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24101704Smjacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25101704Smjacob * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26101704Smjacob * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27156000Smjacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28156000Smjacob * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29156000Smjacob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30156000Smjacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31156104Smjacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32156000Smjacob * SUCH DAMAGE. 33156000Smjacob * 34156000Smjacob * @(#)spx_debug.c 35156000Smjacob * 36156000Smjacob * $Id: spx_debug.c,v 1.3 1995/11/04 09:03:32 julian Exp $ 37156000Smjacob */ 38156000Smjacob 39156000Smjacob#include <sys/param.h> 40156000Smjacob#include <sys/systm.h> 41156000Smjacob#include <sys/mbuf.h> 42156000Smjacob#include <sys/socket.h> 43156000Smjacob#include <sys/socketvar.h> 44156000Smjacob#include <sys/protosw.h> 45156104Smjacob#include <sys/errno.h> 46156000Smjacob 47156000Smjacob#include <net/route.h> 48156000Smjacob#include <net/if.h> 49156000Smjacob#include <netinet/in_systm.h> 50156000Smjacob#include <netinet/tcp_fsm.h> 51156000Smjacob 52156000Smjacob#include <netipx/ipx.h> 53156000Smjacob#include <netipx/ipx_error.h> 54156000Smjacob#include <netipx/ipx_pcb.h> 55156000Smjacob#include <netipx/ipx.h> 56156000Smjacob#include <netipx/ipx_var.h> 57147883Sscottl#include <netipx/spx.h> 58156000Smjacob#define SPXTIMERS 59156000Smjacob#include <netipx/spx_timer.h> 60159052Smjacob#include <netipx/spx_var.h> 61159052Smjacob#define SANAMES 62159052Smjacob#include <netipx/spx_debug.h> 63159052Smjacob 64101704Smjacobint spxconsdebug = 0; 65156000Smjacob/* 66147883Sscottl * spx debug routines 67147883Sscottl */ 68147883Sscottlvoid 69147883Sscottlspx_trace(act, ostate, sp, si, req) 70156104Smjacob short act; 71147883Sscottl u_char ostate; 72147883Sscottl struct spxpcb *sp; 73147883Sscottl struct spx *si; 74147883Sscottl int req; 75147883Sscottl{ 76147883Sscottl#ifdef INET 77147883Sscottl#ifdef TCPDEBUG 78147883Sscottl u_short seq, ack, len, alo; 79147883Sscottl int flags; 80147883Sscottl struct spx_debug *sd = &spx_debug[spx_debx++]; 81148679Sgibbs 82148679Sgibbs if (spx_debx == SPX_NDEBUG) 83148679Sgibbs spx_debx = 0; 84156104Smjacob sd->sd_time = iptime(); 85147883Sscottl sd->sd_act = act; 86147883Sscottl sd->sd_ostate = ostate; 87147883Sscottl sd->sd_cb = (caddr_t)sp; 88147883Sscottl if (sp) 89147883Sscottl sd->sd_sp = *sp; 90147883Sscottl else 91147883Sscottl bzero((caddr_t)&sd->sd_sp, sizeof (*sp)); 92147883Sscottl if (si) 93147883Sscottl sd->sd_si = *si; 94147883Sscottl else 95147883Sscottl bzero((caddr_t)&sd->sd_si, sizeof (*si)); 96101704Smjacob sd->sd_req = req; 97101704Smjacob if (spxconsdebug == 0) 98134123Sobrien return; 99134123Sobrien if (ostate >= TCP_NSTATES) ostate = 0; 100134123Sobrien if (act >= SA_DROP) act = SA_DROP; 101147883Sscottl if (sp) 102147883Sscottl printf("%x %s:", sp, tcpstates[ostate]); 103147883Sscottl else 104102199Smjacob printf("???????? "); 105147883Sscottl printf("%s ", spxnames[act]); 106147883Sscottl switch (act) { 107157117Smjacob 108157117Smjacob case SA_RESPOND: 109147883Sscottl case SA_INPUT: 110147883Sscottl case SA_OUTPUT: 111147883Sscottl case SA_DROP: 112101704Smjacob if (si == 0) 113101704Smjacob break; 114101704Smjacob seq = si->si_seq; 115101704Smjacob ack = si->si_ack; 116101704Smjacob alo = si->si_alo; 117101704Smjacob len = si->si_len; 118101704Smjacob if (act == SA_OUTPUT) { 119162133Smjacob seq = ntohs(seq); 120147883Sscottl ack = ntohs(ack); 121101704Smjacob alo = ntohs(alo); 122147883Sscottl len = ntohs(len); 123147883Sscottl } 124147883Sscottl#ifndef lint 125147883Sscottl#define p1(f) { printf("%s = %x, ", "f", f); } 126147883Sscottl p1(seq); p1(ack); p1(alo); p1(len); 127147883Sscottl#endif 128155521Smjacob flags = si->si_cc; 129147883Sscottl if (flags) { 130147883Sscottl char *cp = "<"; 131147883Sscottl#ifndef lint 132157117Smjacob#define pf(f) { if (flags & SPX_ ## f) { printf("%s%s", cp, "f"); cp = ","; } } 133147883Sscottl pf(SP); pf(SA); pf(OB); pf(EM); 134147883Sscottl#else 135147883Sscottl cp = cp; 136147883Sscottl#endif 137147883Sscottl printf(">"); 138147883Sscottl } 139147883Sscottl#ifndef lint 140147883Sscottl#define p2(f) { printf("%s = %x, ", "f", si->si_ ## f); } 141147883Sscottl p2(sid);p2(did);p2(dt);p2(pt); 142147883Sscottl#endif 143147883Sscottl ipx_printhost(&si->si_sna); 144147883Sscottl ipx_printhost(&si->si_dna); 145147883Sscottl 146147883Sscottl if (act==SA_RESPOND) { 147101704Smjacob printf("ipx_len = %x, ", 148147883Sscottl ((struct ipx *)si)->ipx_len); 149147883Sscottl } 150147883Sscottl break; 151147883Sscottl 152147883Sscottl case SA_USER: 153147883Sscottl printf("%s", prurequests[req&0xff]); 154147883Sscottl if ((req & 0xff) == PRU_SLOWTIMO) 155147883Sscottl printf("<%s>", spxtimers[req>>8]); 156147883Sscottl break; 157147883Sscottl } 158147883Sscottl if (sp) 159157117Smjacob printf(" -> %s", tcpstates[sp->s_state]); 160147883Sscottl /* print out internal state of sp !?! */ 161147883Sscottl printf("\n"); 162147883Sscottl if (sp == 0) 163147883Sscottl return; 164147883Sscottl#ifndef lint 165147883Sscottl#define p3(f) { printf("%s = %x, ", "f", sp->s_ ## f); } 166147883Sscottl printf("\t"); p3(rack);p3(ralo);p3(smax);p3(flags); printf("\n"); 167147883Sscottl#endif 168147883Sscottl#endif 169147883Sscottl#endif 170147883Sscottl} 171147883Sscottl