1 /* 2 * Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that this notice is preserved and that due credit is given 7 * to the University of California at Berkeley. The name of the University 8 * may not be used to endorse or promote products derived from this 9 * software without specific prior written permission. This software 10 * is provided ``as is'' without express or implied warranty. 11 * 12 * @(#)spp_debug.c 7.4 (Berkeley) 03/12/88 13 */ 14 15 #include "param.h" 16 #include "systm.h" 17 #include "mbuf.h" 18 #include "socket.h" 19 #include "socketvar.h" 20 #include "protosw.h" 21 #include "errno.h" 22 23 #include "../net/route.h" 24 #include "../net/if.h" 25 #include "../netinet/tcp_fsm.h" 26 27 #include "ns.h" 28 #include "ns_pcb.h" 29 #include "idp.h" 30 #include "idp_var.h" 31 #include "sp.h" 32 #include "spidp.h" 33 #define SPPTIMERS 34 #include "spp_timer.h" 35 #include "spp_var.h" 36 #define SANAMES 37 #include "spp_debug.h" 38 39 int sppconsdebug = 0; 40 /* 41 * spp debug routines 42 */ 43 spp_trace(act, ostate, sp, si, req) 44 short act; 45 u_char ostate; 46 struct sppcb *sp; 47 struct spidp *si; 48 int req; 49 { 50 #ifdef INET 51 u_short seq, ack, len, alo; 52 unsigned long iptime(); 53 int flags; 54 struct spp_debug *sd = &spp_debug[spp_debx++]; 55 extern char *prurequests[]; 56 extern char *sanames[]; 57 extern char *tcpstates[]; 58 extern char *spptimers[]; 59 60 if (spp_debx == SPP_NDEBUG) 61 spp_debx = 0; 62 sd->sd_time = iptime(); 63 sd->sd_act = act; 64 sd->sd_ostate = ostate; 65 sd->sd_cb = (caddr_t)sp; 66 if (sp) 67 sd->sd_sp = *sp; 68 else 69 bzero((caddr_t)&sd->sd_sp, sizeof (*sp)); 70 if (si) 71 sd->sd_si = *si; 72 else 73 bzero((caddr_t)&sd->sd_si, sizeof (*si)); 74 sd->sd_req = req; 75 if (sppconsdebug == 0) 76 return; 77 if (ostate >= TCP_NSTATES) ostate = 0; 78 if (act >= SA_DROP) act = SA_DROP; 79 if (sp) 80 printf("%x %s:", sp, tcpstates[ostate]); 81 else 82 printf("???????? "); 83 printf("%s ", sanames[act]); 84 switch (act) { 85 86 case SA_RESPOND: 87 case SA_INPUT: 88 case SA_OUTPUT: 89 case SA_DROP: 90 if (si == 0) 91 break; 92 seq = si->si_seq; 93 ack = si->si_ack; 94 alo = si->si_alo; 95 len = si->si_len; 96 if (act == SA_OUTPUT) { 97 seq = ntohs(seq); 98 ack = ntohs(ack); 99 alo = ntohs(alo); 100 len = ntohs(len); 101 } 102 #ifndef lint 103 #define p1(f) { printf("%s = %x, ", "f", f); } 104 p1(seq); p1(ack); p1(alo); p1(len); 105 #endif 106 flags = si->si_cc; 107 if (flags) { 108 char *cp = "<"; 109 #ifndef lint 110 #define pf(f) { if (flags&SP_/**/f) { printf("%s%s", cp, "f"); cp = ","; } } 111 pf(SP); pf(SA); pf(OB); pf(EM); 112 #else 113 cp = cp; 114 #endif 115 printf(">"); 116 } 117 #ifndef lint 118 #define p2(f) { printf("%s = %x, ", "f", si->si_/**/f); } 119 p2(sid);p2(did);p2(dt);p2(pt); 120 #endif 121 ns_printhost(&si->si_sna); 122 ns_printhost(&si->si_dna); 123 124 if (act==SA_RESPOND) { 125 printf("idp_len = %x, ", 126 ((struct idp *)si)->idp_len); 127 } 128 break; 129 130 case SA_USER: 131 printf("%s", prurequests[req&0xff]); 132 if ((req & 0xff) == PRU_SLOWTIMO) 133 printf("<%s>", spptimers[req>>8]); 134 break; 135 } 136 if (sp) 137 printf(" -> %s", tcpstates[sp->s_state]); 138 /* print out internal state of sp !?! */ 139 printf("\n"); 140 if (sp == 0) 141 return; 142 #ifndef lint 143 #define p3(f) { printf("%s = %x, ", "f", sp->s_/**/f); } 144 printf("\t"); p3(rack);p3(ralo);p3(smax);p3(flags); printf("\n"); 145 #endif 146 #endif 147 } 148