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