|
|
1.1 root 1: /*
2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7: * Reserved. This file contains Original Code and/or Modifications of
8: * Original Code as defined in and that are subject to the Apple Public
9: * Source License Version 1.1 (the "License"). You may not use this file
10: * except in compliance with the License. Please obtain a copy of the
11: * License at http://www.apple.com/publicsource and read it before using
12: * this file.
13: *
14: * The Original Code and all software distributed under the License are
15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19: * License for the specific language governing rights and limitations
20: * under the License.
21: *
22: * @APPLE_LICENSE_HEADER_END@
23: */
24:
25: /*
26: * Copyright (c) 1984, 1985, 1986, 1987, 1993
27: * The Regents of the University of California. All rights reserved.
28: *
29: * Redistribution and use in source and binary forms, with or without
30: * modification, are permitted provided that the following conditions
31: * are met:
32: * 1. Redistributions of source code must retain the above copyright
33: * notice, this list of conditions and the following disclaimer.
34: * 2. Redistributions in binary form must reproduce the above copyright
35: * notice, this list of conditions and the following disclaimer in the
36: * documentation and/or other materials provided with the distribution.
37: * 3. All advertising materials mentioning features or use of this software
38: * must display the following acknowledgement:
39: * This product includes software developed by the University of
40: * California, Berkeley and its contributors.
41: * 4. Neither the name of the University nor the names of its contributors
42: * may be used to endorse or promote products derived from this software
43: * without specific prior written permission.
44: *
45: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
46: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
49: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55: * SUCH DAMAGE.
56: *
57: * @(#)spp_debug.c 8.1 (Berkeley) 6/10/93
58: */
59:
60: #include <sys/param.h>
61: #include <sys/systm.h>
62: #include <sys/mbuf.h>
63: #include <sys/socket.h>
64: #include <sys/socketvar.h>
65: #include <sys/protosw.h>
66: #include <sys/errno.h>
67:
68: #include <net/route.h>
69: #include <net/if.h>
70: #include <netinet/tcp_fsm.h>
71:
72: #include <netns/ns.h>
73: #include <netns/ns_pcb.h>
74: #include <netns/idp.h>
75: #include <netns/idp_var.h>
76: #include <netns/sp.h>
77: #include <netns/spidp.h>
78: #define SPPTIMERS
79: #include <netns/spp_timer.h>
80: #include <netns/spp_var.h>
81: #define SANAMES
82: #include <netns/spp_debug.h>
83:
84: int sppconsdebug = 0;
85: /*
86: * spp debug routines
87: */
88: spp_trace(act, ostate, sp, si, req)
89: short act;
90: u_char ostate;
91: struct sppcb *sp;
92: struct spidp *si;
93: int req;
94: {
95: #ifdef INET
96: #ifdef TCPDEBUG
97: u_short seq, ack, len, alo;
98: unsigned long iptime();
99: int flags;
100: struct spp_debug *sd = &spp_debug[spp_debx++];
101: extern char *prurequests[];
102: extern char *sanames[];
103: extern char *tcpstates[];
104: extern char *spptimers[];
105:
106: if (spp_debx == SPP_NDEBUG)
107: spp_debx = 0;
108: sd->sd_time = iptime();
109: sd->sd_act = act;
110: sd->sd_ostate = ostate;
111: sd->sd_cb = (caddr_t)sp;
112: if (sp)
113: sd->sd_sp = *sp;
114: else
115: bzero((caddr_t)&sd->sd_sp, sizeof (*sp));
116: if (si)
117: sd->sd_si = *si;
118: else
119: bzero((caddr_t)&sd->sd_si, sizeof (*si));
120: sd->sd_req = req;
121: if (sppconsdebug == 0)
122: return;
123: if (ostate >= TCP_NSTATES) ostate = 0;
124: if (act >= SA_DROP) act = SA_DROP;
125: if (sp)
126: printf("%x %s:", sp, tcpstates[ostate]);
127: else
128: printf("???????? ");
129: printf("%s ", sanames[act]);
130: switch (act) {
131:
132: case SA_RESPOND:
133: case SA_INPUT:
134: case SA_OUTPUT:
135: case SA_DROP:
136: if (si == 0)
137: break;
138: seq = si->si_seq;
139: ack = si->si_ack;
140: alo = si->si_alo;
141: len = si->si_len;
142: if (act == SA_OUTPUT) {
143: seq = ntohs(seq);
144: ack = ntohs(ack);
145: alo = ntohs(alo);
146: len = ntohs(len);
147: }
148: #ifndef lint
149: #define p1(f) { printf("%s = %x, ", "f", f); }
150: p1(seq); p1(ack); p1(alo); p1(len);
151: #endif
152: flags = si->si_cc;
153: if (flags) {
154: char *cp = "<";
155: #ifndef lint
156: #define pf(f) { if (flags&SP_/**/f) { printf("%s%s", cp, "f"); cp = ","; } }
157: pf(SP); pf(SA); pf(OB); pf(EM);
158: #else
159: cp = cp;
160: #endif
161: printf(">");
162: }
163: #ifndef lint
164: #define p2(f) { printf("%s = %x, ", "f", si->si_/**/f); }
165: p2(sid);p2(did);p2(dt);p2(pt);
166: #endif
167: ns_printhost(&si->si_sna);
168: ns_printhost(&si->si_dna);
169:
170: if (act==SA_RESPOND) {
171: printf("idp_len = %x, ",
172: ((struct idp *)si)->idp_len);
173: }
174: break;
175:
176: case SA_USER:
177: printf("%s", prurequests[req&0xff]);
178: if ((req & 0xff) == PRU_SLOWTIMO)
179: printf("<%s>", spptimers[req>>8]);
180: break;
181: }
182: if (sp)
183: printf(" -> %s", tcpstates[sp->s_state]);
184: /* print out internal state of sp !?! */
185: printf("\n");
186: if (sp == 0)
187: return;
188: #ifndef lint
189: #define p3(f) { printf("%s = %x, ", "f", sp->s_/**/f); }
190: printf("\t"); p3(rack);p3(ralo);p3(smax);p3(flags); printf("\n");
191: #endif
192: #endif
193: #endif
194: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.