2 * Copyright (c) 1984, 1985, 1986, 1987, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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
33 * @(#)spp_debug.c 8.1 (Berkeley) 6/10/93
34 * $FreeBSD: src/sys/netns/spp_debug.c,v 1.10 1999/08/28 00:49:52 peter Exp $
35 * $DragonFly: src/sys/netproto/ns/spp_debug.c,v 1.7 2006/12/22 23:57:54 swildner Exp $
40 #include <sys/param.h>
41 #include <sys/systm.h>
43 #include <sys/socket.h>
44 #include <sys/socketvar.h>
45 #include <sys/protosw.h>
46 #include <sys/errno.h>
48 #include <net/route.h>
50 #include <netinet/tcp_fsm.h>
59 #include "spp_timer.h"
62 #include "spp_debug.h"
65 struct spp_debug spp_debug
[SPP_NDEBUG
];
72 spp_trace(short act
, u_char ostate
, struct sppcb
*sp
, struct spidp
*si
, int req
)
76 u_short seq
, ack
, len
, alo
;
77 unsigned long iptime();
79 struct spp_debug
*sd
= &spp_debug
[spp_debx
++];
80 extern char *prurequests
[];
81 extern char *sanames
[];
82 extern char *tcpstates
[];
83 extern char *spptimers
[];
85 if (spp_debx
== SPP_NDEBUG
)
87 sd
->sd_time
= iptime();
89 sd
->sd_ostate
= ostate
;
90 sd
->sd_cb
= (caddr_t
)sp
;
94 bzero((caddr_t
)&sd
->sd_sp
, sizeof (*sp
));
98 bzero((caddr_t
)&sd
->sd_si
, sizeof (*si
));
100 if (sppconsdebug
== 0)
102 if (ostate
>= TCP_NSTATES
) ostate
= 0;
103 if (act
>= SA_DROP
) act
= SA_DROP
;
105 kprintf("%x %s:", sp
, tcpstates
[ostate
]);
107 kprintf("???????? ");
108 kprintf("%s ", sanames
[act
]);
121 if (act
== SA_OUTPUT
) {
128 #define p1(f) { kprintf("%s = %x, ", "f", f); }
129 p1(seq
); p1(ack
); p1(alo
); p1(len
);
135 #define pf(f) { if (flags&SP_/**/f) { kprintf("%s%s", cp, "f"); cp = ","; } }
136 pf(SP
); pf(SA
); pf(OB
); pf(EM
);
143 #define p2(f) { kprintf("%s = %x, ", "f", si->si_/**/f); }
144 p2(sid
);p2(did
);p2(dt
);p2(pt
);
146 ns_printhost(&si
->si_sna
);
147 ns_printhost(&si
->si_dna
);
149 if (act
==SA_RESPOND
) {
150 kprintf("idp_len = %x, ",
151 ((struct idp
*)si
)->idp_len
);
156 kprintf("%s", prurequests
[req
&0xff]);
157 if ((req
& 0xff) == PRU_SLOWTIMO
)
158 kprintf("<%s>", spptimers
[req
>>8]);
162 kprintf(" -> %s", tcpstates
[sp
->s_state
]);
163 /* print out internal state of sp !?! */
168 #define p3(f) { kprintf("%s = %x, ", "f", sp->s_/**/f); }
169 kprintf("\t"); p3(rack
);p3(ralo
);p3(smax
);p3(flags
); kprintf("\n");