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