123214Smckusick /* 232597Ssklower * Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California. 333371Ssklower * All rights reserved. 423214Smckusick * 533371Ssklower * Redistribution and use in source and binary forms are permitted 6*34856Sbostic * provided that the above copyright notice and this paragraph are 7*34856Sbostic * duplicated in all such forms and that any documentation, 8*34856Sbostic * advertising materials, and other materials related to such 9*34856Sbostic * distribution and use acknowledge that the software was developed 10*34856Sbostic * by the University of California, Berkeley. The name of the 11*34856Sbostic * University may not be used to endorse or promote products derived 12*34856Sbostic * from this software without specific prior written permission. 13*34856Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14*34856Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15*34856Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1633371Ssklower * 17*34856Sbostic * @(#)spp_debug.c 7.5 (Berkeley) 06/29/88 1823214Smckusick */ 1921494Ssklower 2021494Ssklower #include "param.h" 2121494Ssklower #include "systm.h" 2221494Ssklower #include "mbuf.h" 2321494Ssklower #include "socket.h" 2421494Ssklower #include "socketvar.h" 2521494Ssklower #include "protosw.h" 2621494Ssklower #include "errno.h" 2721494Ssklower 2821494Ssklower #include "../net/route.h" 2921494Ssklower #include "../net/if.h" 3021494Ssklower #include "../netinet/tcp_fsm.h" 3121494Ssklower 3221494Ssklower #include "ns.h" 3321494Ssklower #include "ns_pcb.h" 3421494Ssklower #include "idp.h" 3521494Ssklower #include "idp_var.h" 3621494Ssklower #include "sp.h" 3721494Ssklower #include "spidp.h" 3833719Skarels #define SPPTIMERS 3933719Skarels #include "spp_timer.h" 4021494Ssklower #include "spp_var.h" 4121494Ssklower #define SANAMES 4221494Ssklower #include "spp_debug.h" 4321494Ssklower 4421494Ssklower int sppconsdebug = 0; 4521494Ssklower /* 4621494Ssklower * spp debug routines 4721494Ssklower */ 4821494Ssklower spp_trace(act, ostate, sp, si, req) 4921494Ssklower short act; 5021494Ssklower u_char ostate; 5121494Ssklower struct sppcb *sp; 5221494Ssklower struct spidp *si; 5321494Ssklower int req; 5421494Ssklower { 5525034Skarels #ifdef INET 5621494Ssklower u_short seq, ack, len, alo; 5721494Ssklower unsigned long iptime(); 5821494Ssklower int flags; 5921494Ssklower struct spp_debug *sd = &spp_debug[spp_debx++]; 6024413Swalsh extern char *prurequests[]; 6126472Ssklower extern char *sanames[]; 6224413Swalsh extern char *tcpstates[]; 6333719Skarels extern char *spptimers[]; 6421494Ssklower 6521494Ssklower if (spp_debx == SPP_NDEBUG) 6621494Ssklower spp_debx = 0; 6721494Ssklower sd->sd_time = iptime(); 6821494Ssklower sd->sd_act = act; 6921494Ssklower sd->sd_ostate = ostate; 7021494Ssklower sd->sd_cb = (caddr_t)sp; 7121494Ssklower if (sp) 7221494Ssklower sd->sd_sp = *sp; 7321494Ssklower else 7421494Ssklower bzero((caddr_t)&sd->sd_sp, sizeof (*sp)); 7521494Ssklower if (si) 7621494Ssklower sd->sd_si = *si; 7721494Ssklower else 7821494Ssklower bzero((caddr_t)&sd->sd_si, sizeof (*si)); 7921494Ssklower sd->sd_req = req; 8021494Ssklower if (sppconsdebug == 0) 8121494Ssklower return; 8221494Ssklower if (ostate >= TCP_NSTATES) ostate = 0; 8321494Ssklower if (act >= SA_DROP) act = SA_DROP; 8421494Ssklower if (sp) 8521494Ssklower printf("%x %s:", sp, tcpstates[ostate]); 8621494Ssklower else 8721494Ssklower printf("???????? "); 8826472Ssklower printf("%s ", sanames[act]); 8921494Ssklower switch (act) { 9021494Ssklower 9121494Ssklower case SA_RESPOND: 9221494Ssklower case SA_INPUT: 9321494Ssklower case SA_OUTPUT: 9421494Ssklower case SA_DROP: 9521494Ssklower if (si == 0) 9621494Ssklower break; 9721494Ssklower seq = si->si_seq; 9821494Ssklower ack = si->si_ack; 9921494Ssklower alo = si->si_alo; 10021494Ssklower len = si->si_len; 10121494Ssklower if (act == SA_OUTPUT) { 10221494Ssklower seq = ntohs(seq); 10321494Ssklower ack = ntohs(ack); 10421494Ssklower alo = ntohs(alo); 10521494Ssklower len = ntohs(len); 10621494Ssklower } 10721494Ssklower #ifndef lint 10821494Ssklower #define p1(f) { printf("%s = %x, ", "f", f); } 10921494Ssklower p1(seq); p1(ack); p1(alo); p1(len); 11021494Ssklower #endif 11121494Ssklower flags = si->si_cc; 11221494Ssklower if (flags) { 11321494Ssklower char *cp = "<"; 11421494Ssklower #ifndef lint 11521494Ssklower #define pf(f) { if (flags&SP_/**/f) { printf("%s%s", cp, "f"); cp = ","; } } 11621494Ssklower pf(SP); pf(SA); pf(OB); pf(EM); 11724225Ssklower #else 11824225Ssklower cp = cp; 11921494Ssklower #endif 12021494Ssklower printf(">"); 12121494Ssklower } 12221494Ssklower #ifndef lint 12321494Ssklower #define p2(f) { printf("%s = %x, ", "f", si->si_/**/f); } 12421494Ssklower p2(sid);p2(did);p2(dt);p2(pt); 12521494Ssklower #endif 12621494Ssklower ns_printhost(&si->si_sna); 12721494Ssklower ns_printhost(&si->si_dna); 12821494Ssklower 12921494Ssklower if (act==SA_RESPOND) { 13021494Ssklower printf("idp_len = %x, ", 13121494Ssklower ((struct idp *)si)->idp_len); 13221494Ssklower } 13321494Ssklower break; 13421494Ssklower 13521494Ssklower case SA_USER: 13621494Ssklower printf("%s", prurequests[req&0xff]); 13721494Ssklower if ((req & 0xff) == PRU_SLOWTIMO) 13833719Skarels printf("<%s>", spptimers[req>>8]); 13921494Ssklower break; 14021494Ssklower } 14121494Ssklower if (sp) 14221494Ssklower printf(" -> %s", tcpstates[sp->s_state]); 14321494Ssklower /* print out internal state of sp !?! */ 14421494Ssklower printf("\n"); 14521494Ssklower if (sp == 0) 14621494Ssklower return; 14721494Ssklower #ifndef lint 14821494Ssklower #define p3(f) { printf("%s = %x, ", "f", sp->s_/**/f); } 14932597Ssklower printf("\t"); p3(rack);p3(ralo);p3(smax);p3(flags); printf("\n"); 15021494Ssklower #endif 15124413Swalsh #endif 15221494Ssklower } 153