Remove the priority part of the priority|flags argument to tsleep(). Only
[dragonfly.git] / sys / netproto / ns / spp_debug.c
1 /*
2  * Copyright (c) 1984, 1985, 1986, 1987, 1993
3  *      The Regents of the University of California.  All rights reserved.
4  *
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.
20  *
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
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.2 2003/06/17 04:28:53 dillon Exp $
36  */
37
38 #include "opt_inet.h"
39
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/mbuf.h>
43 #include <sys/socket.h>
44 #include <sys/socketvar.h>
45 #include <sys/protosw.h>
46 #include <sys/errno.h>
47
48 #include <net/route.h>
49 #include <net/if.h>
50 #include <netinet/tcp_fsm.h>
51
52 #include <netns/ns.h>
53 #include <netns/ns_pcb.h>
54 #include <netns/idp.h>
55 #include <netns/idp_var.h>
56 #include <netns/sp.h>
57 #include <netns/spidp.h>
58 #define SPPTIMERS
59 #include <netns/spp_timer.h>
60 #include <netns/spp_var.h>
61 #define SANAMES
62 #include <netns/spp_debug.h>
63
64 int     sppconsdebug = 0;
65 /*
66  * spp debug routines
67  */
68 spp_trace(act, ostate, sp, si, req)
69         short act;
70         u_char ostate;
71         struct sppcb *sp;
72         struct spidp *si;
73         int req;
74 {
75 #ifdef INET
76 #ifdef TCPDEBUG
77         u_short seq, ack, len, alo;
78         unsigned long iptime();
79         int flags;
80         struct spp_debug *sd = &spp_debug[spp_debx++];
81         extern char *prurequests[];
82         extern char *sanames[];
83         extern char *tcpstates[];
84         extern char *spptimers[];
85
86         if (spp_debx == SPP_NDEBUG)
87                 spp_debx = 0;
88         sd->sd_time = iptime();
89         sd->sd_act = act;
90         sd->sd_ostate = ostate;
91         sd->sd_cb = (caddr_t)sp;
92         if (sp)
93                 sd->sd_sp = *sp;
94         else
95                 bzero((caddr_t)&sd->sd_sp, sizeof (*sp));
96         if (si)
97                 sd->sd_si = *si;
98         else
99                 bzero((caddr_t)&sd->sd_si, sizeof (*si));
100         sd->sd_req = req;
101         if (sppconsdebug == 0)
102                 return;
103         if (ostate >= TCP_NSTATES) ostate = 0;
104         if (act >= SA_DROP) act = SA_DROP;
105         if (sp)
106                 printf("%x %s:", sp, tcpstates[ostate]);
107         else
108                 printf("???????? ");
109         printf("%s ", sanames[act]);
110         switch (act) {
111
112         case SA_RESPOND:
113         case SA_INPUT:
114         case SA_OUTPUT:
115         case SA_DROP:
116                 if (si == 0)
117                         break;
118                 seq = si->si_seq;
119                 ack = si->si_ack;
120                 alo = si->si_alo;
121                 len = si->si_len;
122                 if (act == SA_OUTPUT) {
123                         seq = ntohs(seq);
124                         ack = ntohs(ack);
125                         alo = ntohs(alo);
126                         len = ntohs(len);
127                 }
128 #ifndef lint
129 #define p1(f)  { printf("%s = %x, ", "f", f); }
130                 p1(seq); p1(ack); p1(alo); p1(len);
131 #endif
132                 flags = si->si_cc;
133                 if (flags) {
134                         char *cp = "<";
135 #ifndef lint
136 #define pf(f) { if (flags&SP_/**/f) { printf("%s%s", cp, "f"); cp = ","; } }
137                         pf(SP); pf(SA); pf(OB); pf(EM);
138 #else
139                         cp = cp;
140 #endif
141                         printf(">");
142                 }
143 #ifndef lint
144 #define p2(f)  { printf("%s = %x, ", "f", si->si_/**/f); }
145                 p2(sid);p2(did);p2(dt);p2(pt);
146 #endif
147                 ns_printhost(&si->si_sna);
148                 ns_printhost(&si->si_dna);
149
150                 if (act==SA_RESPOND) {
151                         printf("idp_len = %x, ",
152                                 ((struct idp *)si)->idp_len);
153                 }
154                 break;
155
156         case SA_USER:
157                 printf("%s", prurequests[req&0xff]);
158                 if ((req & 0xff) == PRU_SLOWTIMO)
159                         printf("<%s>", spptimers[req>>8]);
160                 break;
161         }
162         if (sp)
163                 printf(" -> %s", tcpstates[sp->s_state]);
164         /* print out internal state of sp !?! */
165         printf("\n");
166         if (sp == 0)
167                 return;
168 #ifndef lint
169 #define p3(f)  { printf("%s = %x, ", "f", sp->s_/**/f); }
170         printf("\t"); p3(rack);p3(ralo);p3(smax);p3(flags); printf("\n");
171 #endif
172 #endif
173 #endif
174 }