spx_debug.c revision 169463
1/*- 2 * Copyright (c) 1984, 1985, 1986, 1987, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 4. Neither the name of the University nor the names of its contributors 14 * may be used to endorse or promote products derived from this software 15 * without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * Copyright (c) 1995, Mike Mitchell 30 * 31 * Redistribution and use in source and binary forms, with or without 32 * modification, are permitted provided that the following conditions 33 * are met: 34 * 1. Redistributions of source code must retain the above copyright 35 * notice, this list of conditions and the following disclaimer. 36 * 2. Redistributions in binary form must reproduce the above copyright 37 * notice, this list of conditions and the following disclaimer in the 38 * documentation and/or other materials provided with the distribution. 39 * 3. All advertising materials mentioning features or use of this software 40 * must display the following acknowledgement: 41 * This product includes software developed by the University of 42 * California, Berkeley and its contributors. 43 * 4. Neither the name of the University nor the names of its contributors 44 * may be used to endorse or promote products derived from this software 45 * without specific prior written permission. 46 * 47 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 48 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 50 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 51 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 52 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 53 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 57 * SUCH DAMAGE. 58 * 59 * @(#)spx_debug.c 60 */ 61 62#include <sys/cdefs.h> 63__FBSDID("$FreeBSD: head/sys/netipx/spx_debug.c 169463 2007-05-11 10:38:34Z rwatson $"); 64 65#include "opt_inet.h" 66#include "opt_tcpdebug.h" 67 68#include <sys/param.h> 69#include <sys/systm.h> 70#include <sys/protosw.h> 71 72#include <netinet/in_systm.h> 73#include <netinet/tcp_fsm.h> 74 75#include <netipx/ipx.h> 76#include <netipx/ipx_var.h> 77#include <netipx/spx.h> 78#define SPXTIMERS 79#include <netipx/spx_timer.h> 80#define SANAMES 81#include <netipx/spx_debug.h> 82 83#ifdef TCPDEBUG 84static int spxconsdebug = 0; 85static struct spx_debug spx_debug[SPX_NDEBUG]; 86static int spx_debx; 87#endif 88 89/* 90 * spx debug routines 91 */ 92void 93spx_trace(short act, u_char ostate, struct spxpcb *sp, struct spx *si, 94 int req) 95{ 96#ifdef INET 97#ifdef TCPDEBUG 98 u_short seq, ack, len, alo; 99 int flags; 100 struct spx_debug *sd = &spx_debug[spx_debx++]; 101 102 if (spx_debx == SPX_NDEBUG) 103 spx_debx = 0; 104 sd->sd_time = iptime(); 105 sd->sd_act = act; 106 sd->sd_ostate = ostate; 107 sd->sd_cb = (caddr_t)sp; 108 if (sp != NULL) 109 sd->sd_sp = *sp; 110 else 111 bzero((caddr_t)&sd->sd_sp, sizeof(*sp)); 112 if (si != NULL) 113 sd->sd_si = *si; 114 else 115 bzero((caddr_t)&sd->sd_si, sizeof(*si)); 116 sd->sd_req = req; 117 if (spxconsdebug == 0) 118 return; 119 if (ostate >= TCP_NSTATES) 120 ostate = 0; 121 if (act >= SA_DROP) 122 act = SA_DROP; 123 if (sp != NULL) 124 printf("%p %s:", (void *)sp, tcpstates[ostate]); 125 else 126 printf("???????? "); 127 printf("%s ", spxnames[act]); 128 switch (act) { 129 130 case SA_RESPOND: 131 case SA_INPUT: 132 case SA_OUTPUT: 133 case SA_DROP: 134 if (si == NULL) 135 break; 136 seq = si->si_seq; 137 ack = si->si_ack; 138 alo = si->si_alo; 139 len = si->si_len; 140 if (act == SA_OUTPUT) { 141 seq = ntohs(seq); 142 ack = ntohs(ack); 143 alo = ntohs(alo); 144 len = ntohs(len); 145 } 146#ifndef lint 147#define p1(f) { printf("%s = %x, ", "f", f); } 148 p1(seq); p1(ack); p1(alo); p1(len); 149#endif 150 flags = si->si_cc; 151 if (flags) { 152 char *cp = "<"; 153#ifndef lint 154#define pf(f) { if (flags & SPX_ ## f) { printf("%s%s", cp, "f"); cp = ","; } } 155 pf(SP); pf(SA); pf(OB); pf(EM); 156#else 157 cp = cp; 158#endif 159 printf(">"); 160 } 161#ifndef lint 162#define p2(f) { printf("%s = %x, ", "f", si->si_ ## f); } 163 p2(sid);p2(did);p2(dt);p2(pt); 164#endif 165 ipx_printhost(&si->si_sna); 166 ipx_printhost(&si->si_dna); 167 168 if (act == SA_RESPOND) { 169 printf("ipx_len = %x, ", 170 ((struct ipx *)si)->ipx_len); 171 } 172 break; 173 174 case SA_USER: 175 printf("%s", prurequests[req&0xff]); 176 if ((req & 0xff) == PRU_SLOWTIMO) 177 printf("<%s>", spxtimers[req>>8]); 178 break; 179 } 180 if (sp) 181 printf(" -> %s", tcpstates[sp->s_state]); 182 /* print out internal state of sp !?! */ 183 printf("\n"); 184 if (sp == 0) 185 return; 186#ifndef lint 187#define p3(f) { printf("%s = %x, ", "f", sp->s_ ## f); } 188 printf("\t"); p3(rack);p3(ralo);p3(smax);p3(flags); printf("\n"); 189#endif 190#endif 191#endif 192} 193