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 633371Ssklower * provided that this notice is preserved and that due credit is given 733371Ssklower * to the University of California at Berkeley. The name of the University 833371Ssklower * may not be used to endorse or promote products derived from this 933371Ssklower * software without specific prior written permission. This software 1033371Ssklower * is provided ``as is'' without express or implied warranty. 1133371Ssklower * 12*33719Skarels * @(#)spp_debug.c 7.4 (Berkeley) 03/12/88 1323214Smckusick */ 1421494Ssklower 1521494Ssklower #include "param.h" 1621494Ssklower #include "systm.h" 1721494Ssklower #include "mbuf.h" 1821494Ssklower #include "socket.h" 1921494Ssklower #include "socketvar.h" 2021494Ssklower #include "protosw.h" 2121494Ssklower #include "errno.h" 2221494Ssklower 2321494Ssklower #include "../net/route.h" 2421494Ssklower #include "../net/if.h" 2521494Ssklower #include "../netinet/tcp_fsm.h" 2621494Ssklower 2721494Ssklower #include "ns.h" 2821494Ssklower #include "ns_pcb.h" 2921494Ssklower #include "idp.h" 3021494Ssklower #include "idp_var.h" 3121494Ssklower #include "sp.h" 3221494Ssklower #include "spidp.h" 33*33719Skarels #define SPPTIMERS 34*33719Skarels #include "spp_timer.h" 3521494Ssklower #include "spp_var.h" 3621494Ssklower #define SANAMES 3721494Ssklower #include "spp_debug.h" 3821494Ssklower 3921494Ssklower int sppconsdebug = 0; 4021494Ssklower /* 4121494Ssklower * spp debug routines 4221494Ssklower */ 4321494Ssklower spp_trace(act, ostate, sp, si, req) 4421494Ssklower short act; 4521494Ssklower u_char ostate; 4621494Ssklower struct sppcb *sp; 4721494Ssklower struct spidp *si; 4821494Ssklower int req; 4921494Ssklower { 5025034Skarels #ifdef INET 5121494Ssklower u_short seq, ack, len, alo; 5221494Ssklower unsigned long iptime(); 5321494Ssklower int flags; 5421494Ssklower struct spp_debug *sd = &spp_debug[spp_debx++]; 5524413Swalsh extern char *prurequests[]; 5626472Ssklower extern char *sanames[]; 5724413Swalsh extern char *tcpstates[]; 58*33719Skarels extern char *spptimers[]; 5921494Ssklower 6021494Ssklower if (spp_debx == SPP_NDEBUG) 6121494Ssklower spp_debx = 0; 6221494Ssklower sd->sd_time = iptime(); 6321494Ssklower sd->sd_act = act; 6421494Ssklower sd->sd_ostate = ostate; 6521494Ssklower sd->sd_cb = (caddr_t)sp; 6621494Ssklower if (sp) 6721494Ssklower sd->sd_sp = *sp; 6821494Ssklower else 6921494Ssklower bzero((caddr_t)&sd->sd_sp, sizeof (*sp)); 7021494Ssklower if (si) 7121494Ssklower sd->sd_si = *si; 7221494Ssklower else 7321494Ssklower bzero((caddr_t)&sd->sd_si, sizeof (*si)); 7421494Ssklower sd->sd_req = req; 7521494Ssklower if (sppconsdebug == 0) 7621494Ssklower return; 7721494Ssklower if (ostate >= TCP_NSTATES) ostate = 0; 7821494Ssklower if (act >= SA_DROP) act = SA_DROP; 7921494Ssklower if (sp) 8021494Ssklower printf("%x %s:", sp, tcpstates[ostate]); 8121494Ssklower else 8221494Ssklower printf("???????? "); 8326472Ssklower printf("%s ", sanames[act]); 8421494Ssklower switch (act) { 8521494Ssklower 8621494Ssklower case SA_RESPOND: 8721494Ssklower case SA_INPUT: 8821494Ssklower case SA_OUTPUT: 8921494Ssklower case SA_DROP: 9021494Ssklower if (si == 0) 9121494Ssklower break; 9221494Ssklower seq = si->si_seq; 9321494Ssklower ack = si->si_ack; 9421494Ssklower alo = si->si_alo; 9521494Ssklower len = si->si_len; 9621494Ssklower if (act == SA_OUTPUT) { 9721494Ssklower seq = ntohs(seq); 9821494Ssklower ack = ntohs(ack); 9921494Ssklower alo = ntohs(alo); 10021494Ssklower len = ntohs(len); 10121494Ssklower } 10221494Ssklower #ifndef lint 10321494Ssklower #define p1(f) { printf("%s = %x, ", "f", f); } 10421494Ssklower p1(seq); p1(ack); p1(alo); p1(len); 10521494Ssklower #endif 10621494Ssklower flags = si->si_cc; 10721494Ssklower if (flags) { 10821494Ssklower char *cp = "<"; 10921494Ssklower #ifndef lint 11021494Ssklower #define pf(f) { if (flags&SP_/**/f) { printf("%s%s", cp, "f"); cp = ","; } } 11121494Ssklower pf(SP); pf(SA); pf(OB); pf(EM); 11224225Ssklower #else 11324225Ssklower cp = cp; 11421494Ssklower #endif 11521494Ssklower printf(">"); 11621494Ssklower } 11721494Ssklower #ifndef lint 11821494Ssklower #define p2(f) { printf("%s = %x, ", "f", si->si_/**/f); } 11921494Ssklower p2(sid);p2(did);p2(dt);p2(pt); 12021494Ssklower #endif 12121494Ssklower ns_printhost(&si->si_sna); 12221494Ssklower ns_printhost(&si->si_dna); 12321494Ssklower 12421494Ssklower if (act==SA_RESPOND) { 12521494Ssklower printf("idp_len = %x, ", 12621494Ssklower ((struct idp *)si)->idp_len); 12721494Ssklower } 12821494Ssklower break; 12921494Ssklower 13021494Ssklower case SA_USER: 13121494Ssklower printf("%s", prurequests[req&0xff]); 13221494Ssklower if ((req & 0xff) == PRU_SLOWTIMO) 133*33719Skarels printf("<%s>", spptimers[req>>8]); 13421494Ssklower break; 13521494Ssklower } 13621494Ssklower if (sp) 13721494Ssklower printf(" -> %s", tcpstates[sp->s_state]); 13821494Ssklower /* print out internal state of sp !?! */ 13921494Ssklower printf("\n"); 14021494Ssklower if (sp == 0) 14121494Ssklower return; 14221494Ssklower #ifndef lint 14321494Ssklower #define p3(f) { printf("%s = %x, ", "f", sp->s_/**/f); } 14432597Ssklower printf("\t"); p3(rack);p3(ralo);p3(smax);p3(flags); printf("\n"); 14521494Ssklower #endif 14624413Swalsh #endif 14721494Ssklower } 148