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 the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 * 17 * @(#)spp_debug.c 7.6 (Berkeley) 06/13/90 18 */ 19 20 #include "param.h" 21 #include "systm.h" 22 #include "mbuf.h" 23 #include "socket.h" 24 #include "socketvar.h" 25 #include "protosw.h" 26 #include "errno.h" 27 28 #include "../net/route.h" 29 #include "../net/if.h" 30 #include "../netinet/tcp_fsm.h" 31 32 #include "ns.h" 33 #include "ns_pcb.h" 34 #include "idp.h" 35 #include "idp_var.h" 36 #include "sp.h" 37 #include "spidp.h" 38 #define SPPTIMERS 39 #include "spp_timer.h" 40 #include "spp_var.h" 41 #define SANAMES 42 #include "spp_debug.h" 43 44 int sppconsdebug = 0; 45 /* 46 * spp debug routines 47 */ 48 spp_trace(act, ostate, sp, si, req) 49 short act; 50 u_char ostate; 51 struct sppcb *sp; 52 struct spidp *si; 53 int req; 54 { 55 #ifdef INET 56 #ifdef TCPDEBUG 57 u_short seq, ack, len, alo; 58 unsigned long iptime(); 59 int flags; 60 struct spp_debug *sd = &spp_debug[spp_debx++]; 61 extern char *prurequests[]; 62 extern char *sanames[]; 63 extern char *tcpstates[]; 64 extern char *spptimers[]; 65 66 if (spp_debx == SPP_NDEBUG) 67 spp_debx = 0; 68 sd->sd_time = iptime(); 69 sd->sd_act = act; 70 sd->sd_ostate = ostate; 71 sd->sd_cb = (caddr_t)sp; 72 if (sp) 73 sd->sd_sp = *sp; 74 else 75 bzero((caddr_t)&sd->sd_sp, sizeof (*sp)); 76 if (si) 77 sd->sd_si = *si; 78 else 79 bzero((caddr_t)&sd->sd_si, sizeof (*si)); 80 sd->sd_req = req; 81 if (sppconsdebug == 0) 82 return; 83 if (ostate >= TCP_NSTATES) ostate = 0; 84 if (act >= SA_DROP) act = SA_DROP; 85 if (sp) 86 printf("%x %s:", sp, tcpstates[ostate]); 87 else 88 printf("???????? "); 89 printf("%s ", sanames[act]); 90 switch (act) { 91 92 case SA_RESPOND: 93 case SA_INPUT: 94 case SA_OUTPUT: 95 case SA_DROP: 96 if (si == 0) 97 break; 98 seq = si->si_seq; 99 ack = si->si_ack; 100 alo = si->si_alo; 101 len = si->si_len; 102 if (act == SA_OUTPUT) { 103 seq = ntohs(seq); 104 ack = ntohs(ack); 105 alo = ntohs(alo); 106 len = ntohs(len); 107 } 108 #ifndef lint 109 #define p1(f) { printf("%s = %x, ", "f", f); } 110 p1(seq); p1(ack); p1(alo); p1(len); 111 #endif 112 flags = si->si_cc; 113 if (flags) { 114 char *cp = "<"; 115 #ifndef lint 116 #define pf(f) { if (flags&SP_/**/f) { printf("%s%s", cp, "f"); cp = ","; } } 117 pf(SP); pf(SA); pf(OB); pf(EM); 118 #else 119 cp = cp; 120 #endif 121 printf(">"); 122 } 123 #ifndef lint 124 #define p2(f) { printf("%s = %x, ", "f", si->si_/**/f); } 125 p2(sid);p2(did);p2(dt);p2(pt); 126 #endif 127 ns_printhost(&si->si_sna); 128 ns_printhost(&si->si_dna); 129 130 if (act==SA_RESPOND) { 131 printf("idp_len = %x, ", 132 ((struct idp *)si)->idp_len); 133 } 134 break; 135 136 case SA_USER: 137 printf("%s", prurequests[req&0xff]); 138 if ((req & 0xff) == PRU_SLOWTIMO) 139 printf("<%s>", spptimers[req>>8]); 140 break; 141 } 142 if (sp) 143 printf(" -> %s", tcpstates[sp->s_state]); 144 /* print out internal state of sp !?! */ 145 printf("\n"); 146 if (sp == 0) 147 return; 148 #ifndef lint 149 #define p3(f) { printf("%s = %x, ", "f", sp->s_/**/f); } 150 printf("\t"); p3(rack);p3(ralo);p3(smax);p3(flags); printf("\n"); 151 #endif 152 #endif 153 #endif 154 } 155