Commit | Line | Data |
---|---|---|
8ae0e4b4 | 1 | /* |
0880b18e | 2 | * Copyright (c) 1984, 1985, 1986 Regents of the University of California. |
8ae0e4b4 KM |
3 | * All rights reserved. The Berkeley software License Agreement |
4 | * specifies the terms and conditions for redistribution. | |
5 | * | |
0880b18e | 6 | * @(#)spp_debug.c 7.1 (Berkeley) %G% |
8ae0e4b4 | 7 | */ |
1c639e0e KS |
8 | |
9 | #include "param.h" | |
10 | #include "systm.h" | |
11 | #include "mbuf.h" | |
12 | #include "socket.h" | |
13 | #include "socketvar.h" | |
14 | #include "protosw.h" | |
15 | #include "errno.h" | |
16 | ||
17 | #include "../net/route.h" | |
18 | #include "../net/if.h" | |
19 | #include "../netinet/tcp_fsm.h" | |
20 | #include "../netinet/tcp_timer.h" | |
21 | ||
22 | #include "ns.h" | |
23 | #include "ns_pcb.h" | |
24 | #include "idp.h" | |
25 | #include "idp_var.h" | |
26 | #include "sp.h" | |
27 | #include "spidp.h" | |
28 | #include "spp_var.h" | |
29 | #define SANAMES | |
30 | #include "spp_debug.h" | |
31 | ||
32 | int sppconsdebug = 0; | |
1c639e0e KS |
33 | /* |
34 | * spp debug routines | |
35 | */ | |
36 | spp_trace(act, ostate, sp, si, req) | |
37 | short act; | |
38 | u_char ostate; | |
39 | struct sppcb *sp; | |
40 | struct spidp *si; | |
41 | int req; | |
42 | { | |
302e850f | 43 | #ifdef INET |
1c639e0e KS |
44 | u_short seq, ack, len, alo; |
45 | unsigned long iptime(); | |
46 | int flags; | |
47 | struct spp_debug *sd = &spp_debug[spp_debx++]; | |
7b33241f | 48 | extern char *prurequests[]; |
60226d9a | 49 | extern char *sanames[]; |
7b33241f DW |
50 | extern char *tcpstates[]; |
51 | extern char *tcptimers[]; | |
1c639e0e KS |
52 | |
53 | if (spp_debx == SPP_NDEBUG) | |
54 | spp_debx = 0; | |
55 | sd->sd_time = iptime(); | |
56 | sd->sd_act = act; | |
57 | sd->sd_ostate = ostate; | |
58 | sd->sd_cb = (caddr_t)sp; | |
59 | if (sp) | |
60 | sd->sd_sp = *sp; | |
61 | else | |
62 | bzero((caddr_t)&sd->sd_sp, sizeof (*sp)); | |
63 | if (si) | |
64 | sd->sd_si = *si; | |
65 | else | |
66 | bzero((caddr_t)&sd->sd_si, sizeof (*si)); | |
67 | sd->sd_req = req; | |
68 | if (sppconsdebug == 0) | |
69 | return; | |
70 | if (ostate >= TCP_NSTATES) ostate = 0; | |
71 | if (act >= SA_DROP) act = SA_DROP; | |
72 | if (sp) | |
73 | printf("%x %s:", sp, tcpstates[ostate]); | |
74 | else | |
75 | printf("???????? "); | |
60226d9a | 76 | printf("%s ", sanames[act]); |
1c639e0e KS |
77 | switch (act) { |
78 | ||
79 | case SA_RESPOND: | |
80 | case SA_INPUT: | |
81 | case SA_OUTPUT: | |
82 | case SA_DROP: | |
83 | if (si == 0) | |
84 | break; | |
85 | seq = si->si_seq; | |
86 | ack = si->si_ack; | |
87 | alo = si->si_alo; | |
88 | len = si->si_len; | |
89 | if (act == SA_OUTPUT) { | |
90 | seq = ntohs(seq); | |
91 | ack = ntohs(ack); | |
92 | alo = ntohs(alo); | |
93 | len = ntohs(len); | |
94 | } | |
95 | #ifndef lint | |
96 | #define p1(f) { printf("%s = %x, ", "f", f); } | |
97 | p1(seq); p1(ack); p1(alo); p1(len); | |
98 | #endif | |
99 | flags = si->si_cc; | |
100 | if (flags) { | |
101 | char *cp = "<"; | |
102 | #ifndef lint | |
103 | #define pf(f) { if (flags&SP_/**/f) { printf("%s%s", cp, "f"); cp = ","; } } | |
104 | pf(SP); pf(SA); pf(OB); pf(EM); | |
f97be0c9 KS |
105 | #else |
106 | cp = cp; | |
1c639e0e KS |
107 | #endif |
108 | printf(">"); | |
109 | } | |
110 | #ifndef lint | |
111 | #define p2(f) { printf("%s = %x, ", "f", si->si_/**/f); } | |
112 | p2(sid);p2(did);p2(dt);p2(pt); | |
113 | #endif | |
114 | ns_printhost(&si->si_sna); | |
115 | ns_printhost(&si->si_dna); | |
116 | ||
117 | if (act==SA_RESPOND) { | |
118 | printf("idp_len = %x, ", | |
119 | ((struct idp *)si)->idp_len); | |
120 | } | |
121 | break; | |
122 | ||
123 | case SA_USER: | |
124 | printf("%s", prurequests[req&0xff]); | |
125 | if ((req & 0xff) == PRU_SLOWTIMO) | |
126 | printf("<%s>", tcptimers[req>>8]); | |
127 | break; | |
128 | } | |
129 | if (sp) | |
130 | printf(" -> %s", tcpstates[sp->s_state]); | |
131 | /* print out internal state of sp !?! */ | |
132 | printf("\n"); | |
133 | if (sp == 0) | |
134 | return; | |
135 | #ifndef lint | |
136 | #define p3(f) { printf("%s = %x, ", "f", sp->s_/**/f); } | |
137 | printf("\t"); p3(rack);p3(ralo);p3(snt);p3(flags); printf("\n"); | |
138 | #endif | |
7b33241f | 139 | #endif |
1c639e0e | 140 | } |