|
|
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: /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
26: /*
27: * Copyright (c) 1982, 1986, 1993
28: * The Regents of the University of California. All rights reserved.
29: *
30: * Redistribution and use in source and binary forms, with or without
31: * modification, are permitted provided that the following conditions
32: * are met:
33: * 1. Redistributions of source code must retain the above copyright
34: * notice, this list of conditions and the following disclaimer.
35: * 2. Redistributions in binary form must reproduce the above copyright
36: * notice, this list of conditions and the following disclaimer in the
37: * documentation and/or other materials provided with the distribution.
38: * 3. All advertising materials mentioning features or use of this software
39: * must display the following acknowledgement:
40: * This product includes software developed by the University of
41: * California, Berkeley and its contributors.
42: * 4. Neither the name of the University nor the names of its contributors
43: * may be used to endorse or promote products derived from this software
44: * without specific prior written permission.
45: *
46: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
47: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
50: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
51: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
52: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
54: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
55: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56: * SUCH DAMAGE.
57: *
58: * @(#)tcp_debug.c 8.1 (Berkeley) 6/10/93
59: */
60:
61: #ifdef TCPDEBUG
62: /* load symbolic names */
63: #define PRUREQUESTS
64: #define TCPSTATES
65: #define TCPTIMERS
66: #define TANAMES
67: #endif
68:
69: #include <sys/param.h>
70: #include <sys/systm.h>
71: #include <sys/mbuf.h>
72: #include <sys/socket.h>
73: #include <sys/socketvar.h>
74: #include <sys/protosw.h>
75: #include <sys/errno.h>
76:
77: #include <net/route.h>
78: #include <net/if.h>
79:
80: #include <netinet/in.h>
81: #include <netinet/in_systm.h>
82: #include <netinet/ip.h>
83: #include <netinet/in_pcb.h>
84: #include <netinet/ip_var.h>
85: #include <netinet/tcp.h>
86: #include <netinet/tcp_fsm.h>
87: #include <netinet/tcp_seq.h>
88: #include <netinet/tcp_timer.h>
89: #include <netinet/tcp_var.h>
90: #include <netinet/tcpip.h>
91: #include <netinet/tcp_debug.h>
92:
93: struct tcp_debug tcp_debug[TCP_NDEBUG];
94: int tcp_debx;
95:
96: #ifdef TCPDEBUG
97: int tcpconsdebug = 0;
98: #endif
99: /*
100: * Tcp debug routines
101: */
102: void
103: tcp_trace(act, ostate, tp, ti, req)
104: short act, ostate;
105: struct tcpcb *tp;
106: struct tcpiphdr *ti;
107: int req;
108: {
109: tcp_seq seq, ack;
110: int len, flags;
111: struct tcp_debug *td = &tcp_debug[tcp_debx++];
112:
113: if (tcp_debx == TCP_NDEBUG)
114: tcp_debx = 0;
115: td->td_time = iptime();
116: td->td_act = act;
117: td->td_ostate = ostate;
118: td->td_tcb = (caddr_t)tp;
119: if (tp)
120: td->td_cb = *tp;
121: else
122: bzero((caddr_t)&td->td_cb, sizeof (*tp));
123: if (ti)
124: td->td_ti = *ti;
125: else
126: bzero((caddr_t)&td->td_ti, sizeof (*ti));
127: td->td_req = req;
128: #ifdef TCPDEBUG
129: if (tcpconsdebug == 0)
130: return;
131: if (tp)
132: printf("%x %s:", tp, tcpstates[ostate]);
133: else
134: printf("???????? ");
135: printf("%s ", tanames[act]);
136: switch (act) {
137:
138: case TA_INPUT:
139: case TA_OUTPUT:
140: case TA_DROP:
141: if (ti == 0)
142: break;
143: seq = ti->ti_seq;
144: ack = ti->ti_ack;
145: len = ti->ti_len;
146: if (act == TA_OUTPUT) {
147: seq = ntohl(seq);
148: ack = ntohl(ack);
149: len = ntohs((u_short)len);
150: }
151: if (act == TA_OUTPUT)
152: len -= sizeof (struct tcphdr);
153: if (len)
154: printf("[%x..%x)", seq, seq+len);
155: else
156: printf("%x", seq);
157: printf("@%x, urp=%x", ack, ti->ti_urp);
158: flags = ti->ti_flags;
159: if (flags) {
160: #ifndef lint
161: char *cp = "<";
162: #define pf(f) { if (ti->ti_flags&TH_/**/f) { printf("%s%s", cp, "f"); cp = ","; } }
163: pf(SYN); pf(ACK); pf(FIN); pf(RST); pf(PUSH); pf(URG);
164: #endif
165: printf(">");
166: }
167: break;
168:
169: case TA_USER:
170: printf("%s", prurequests[req&0xff]);
171: if ((req & 0xff) == PRU_SLOWTIMO)
172: printf("<%s>", tcptimers[req>>8]);
173: break;
174: }
175: if (tp)
176: printf(" -> %s", tcpstates[tp->t_state]);
177: /* print out internal state of tp !?! */
178: printf("\n");
179: if (tp == 0)
180: return;
181: printf("\trcv_(nxt,wnd,up) (%x,%x,%x) snd_(una,nxt,max) (%x,%x,%x)\n",
182: tp->rcv_nxt, tp->rcv_wnd, tp->rcv_up, tp->snd_una, tp->snd_nxt,
183: tp->snd_max);
184: printf("\tsnd_(wl1,wl2,wnd) (%x,%x,%x)\n",
185: tp->snd_wl1, tp->snd_wl2, tp->snd_wnd);
186: #endif /* TCPDEBUG */
187: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.