Commit | Line | Data |
---|---|---|
8ae0e4b4 | 1 | /* |
ad787160 C |
2 | * Copyright (c) 1984, 1985, 1986, 1987, 1993 |
3 | * The Regents of the University of California. All rights reserved. | |
8ae0e4b4 | 4 | * |
ad787160 C |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: | |
8 | * 1. Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * 2. Redistributions in binary form must reproduce the above copyright | |
11 | * notice, this list of conditions and the following disclaimer in the | |
12 | * documentation and/or other materials provided with the distribution. | |
13 | * 3. All advertising materials mentioning features or use of this software | |
14 | * must display the following acknowledgement: | |
15 | * This product includes software developed by the University of | |
16 | * California, Berkeley and its contributors. | |
17 | * 4. Neither the name of the University nor the names of its contributors | |
18 | * may be used to endorse or promote products derived from this software | |
19 | * without specific prior written permission. | |
240edf1f | 20 | * |
ad787160 C |
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
31 | * SUCH DAMAGE. | |
32 | * | |
33 | * @(#)spp_debug.c 8.1 (Berkeley) 6/10/93 | |
8ae0e4b4 | 34 | */ |
1c639e0e | 35 | |
5548a02f KB |
36 | #include <sys/param.h> |
37 | #include <sys/systm.h> | |
38 | #include <sys/mbuf.h> | |
39 | #include <sys/socket.h> | |
40 | #include <sys/socketvar.h> | |
41 | #include <sys/protosw.h> | |
42 | #include <sys/errno.h> | |
1c639e0e | 43 | |
5548a02f KB |
44 | #include <net/route.h> |
45 | #include <net/if.h> | |
46 | #include <netinet/tcp_fsm.h> | |
1c639e0e | 47 | |
5548a02f KB |
48 | #include <netns/ns.h> |
49 | #include <netns/ns_pcb.h> | |
50 | #include <netns/idp.h> | |
51 | #include <netns/idp_var.h> | |
52 | #include <netns/sp.h> | |
53 | #include <netns/spidp.h> | |
863250c1 | 54 | #define SPPTIMERS |
5548a02f KB |
55 | #include <netns/spp_timer.h> |
56 | #include <netns/spp_var.h> | |
1c639e0e | 57 | #define SANAMES |
5548a02f | 58 | #include <netns/spp_debug.h> |
1c639e0e KS |
59 | |
60 | int sppconsdebug = 0; | |
1c639e0e KS |
61 | /* |
62 | * spp debug routines | |
63 | */ | |
64 | spp_trace(act, ostate, sp, si, req) | |
65 | short act; | |
66 | u_char ostate; | |
67 | struct sppcb *sp; | |
68 | struct spidp *si; | |
69 | int req; | |
70 | { | |
302e850f | 71 | #ifdef INET |
467e460a | 72 | #ifdef TCPDEBUG |
1c639e0e KS |
73 | u_short seq, ack, len, alo; |
74 | unsigned long iptime(); | |
75 | int flags; | |
76 | struct spp_debug *sd = &spp_debug[spp_debx++]; | |
7b33241f | 77 | extern char *prurequests[]; |
60226d9a | 78 | extern char *sanames[]; |
7b33241f | 79 | extern char *tcpstates[]; |
863250c1 | 80 | extern char *spptimers[]; |
1c639e0e KS |
81 | |
82 | if (spp_debx == SPP_NDEBUG) | |
83 | spp_debx = 0; | |
84 | sd->sd_time = iptime(); | |
85 | sd->sd_act = act; | |
86 | sd->sd_ostate = ostate; | |
87 | sd->sd_cb = (caddr_t)sp; | |
88 | if (sp) | |
89 | sd->sd_sp = *sp; | |
90 | else | |
91 | bzero((caddr_t)&sd->sd_sp, sizeof (*sp)); | |
92 | if (si) | |
93 | sd->sd_si = *si; | |
94 | else | |
95 | bzero((caddr_t)&sd->sd_si, sizeof (*si)); | |
96 | sd->sd_req = req; | |
97 | if (sppconsdebug == 0) | |
98 | return; | |
99 | if (ostate >= TCP_NSTATES) ostate = 0; | |
100 | if (act >= SA_DROP) act = SA_DROP; | |
101 | if (sp) | |
102 | printf("%x %s:", sp, tcpstates[ostate]); | |
103 | else | |
104 | printf("???????? "); | |
60226d9a | 105 | printf("%s ", sanames[act]); |
1c639e0e KS |
106 | switch (act) { |
107 | ||
108 | case SA_RESPOND: | |
109 | case SA_INPUT: | |
110 | case SA_OUTPUT: | |
111 | case SA_DROP: | |
112 | if (si == 0) | |
113 | break; | |
114 | seq = si->si_seq; | |
115 | ack = si->si_ack; | |
116 | alo = si->si_alo; | |
117 | len = si->si_len; | |
118 | if (act == SA_OUTPUT) { | |
119 | seq = ntohs(seq); | |
120 | ack = ntohs(ack); | |
121 | alo = ntohs(alo); | |
122 | len = ntohs(len); | |
123 | } | |
124 | #ifndef lint | |
125 | #define p1(f) { printf("%s = %x, ", "f", f); } | |
126 | p1(seq); p1(ack); p1(alo); p1(len); | |
127 | #endif | |
128 | flags = si->si_cc; | |
129 | if (flags) { | |
130 | char *cp = "<"; | |
131 | #ifndef lint | |
132 | #define pf(f) { if (flags&SP_/**/f) { printf("%s%s", cp, "f"); cp = ","; } } | |
133 | pf(SP); pf(SA); pf(OB); pf(EM); | |
f97be0c9 KS |
134 | #else |
135 | cp = cp; | |
1c639e0e KS |
136 | #endif |
137 | printf(">"); | |
138 | } | |
139 | #ifndef lint | |
140 | #define p2(f) { printf("%s = %x, ", "f", si->si_/**/f); } | |
141 | p2(sid);p2(did);p2(dt);p2(pt); | |
142 | #endif | |
143 | ns_printhost(&si->si_sna); | |
144 | ns_printhost(&si->si_dna); | |
145 | ||
146 | if (act==SA_RESPOND) { | |
147 | printf("idp_len = %x, ", | |
148 | ((struct idp *)si)->idp_len); | |
149 | } | |
150 | break; | |
151 | ||
152 | case SA_USER: | |
153 | printf("%s", prurequests[req&0xff]); | |
154 | if ((req & 0xff) == PRU_SLOWTIMO) | |
863250c1 | 155 | printf("<%s>", spptimers[req>>8]); |
1c639e0e KS |
156 | break; |
157 | } | |
158 | if (sp) | |
159 | printf(" -> %s", tcpstates[sp->s_state]); | |
160 | /* print out internal state of sp !?! */ | |
161 | printf("\n"); | |
162 | if (sp == 0) | |
163 | return; | |
164 | #ifndef lint | |
165 | #define p3(f) { printf("%s = %x, ", "f", sp->s_/**/f); } | |
64b784d2 | 166 | printf("\t"); p3(rack);p3(ralo);p3(smax);p3(flags); printf("\n"); |
1c639e0e | 167 | #endif |
7b33241f | 168 | #endif |
467e460a | 169 | #endif |
1c639e0e | 170 | } |