1 //==========================================================================
3 // sys/netinet/tcp_debug.c
7 //==========================================================================
8 //####BSDCOPYRIGHTBEGIN####
10 // -------------------------------------------
12 // Portions of this software may have been derived from OpenBSD or other sources,
13 // and are covered by the appropriate copyright disclaimers included herein.
15 // -------------------------------------------
17 //####BSDCOPYRIGHTEND####
18 //==========================================================================
19 //#####DESCRIPTIONBEGIN####
22 // Contributors: gthomas
28 //####DESCRIPTIONEND####
30 //==========================================================================
33 /* $OpenBSD: tcp_debug.c,v 1.6 1999/12/08 06:50:20 itojun Exp $ */
34 /* $NetBSD: tcp_debug.c,v 1.10 1996/02/13 23:43:36 christos Exp $ */
37 * Copyright (c) 1982, 1986, 1993
38 * The Regents of the University of California. All rights reserved.
40 * Redistribution and use in source and binary forms, with or without
41 * modification, are permitted provided that the following conditions
43 * 1. Redistributions of source code must retain the above copyright
44 * notice, this list of conditions and the following disclaimer.
45 * 2. Redistributions in binary form must reproduce the above copyright
46 * notice, this list of conditions and the following disclaimer in the
47 * documentation and/or other materials provided with the distribution.
48 * 3. All advertising materials mentioning features or use of this software
49 * must display the following acknowledgement:
50 * This product includes software developed by the University of
51 * California, Berkeley and its contributors.
52 * 4. Neither the name of the University nor the names of its contributors
53 * may be used to endorse or promote products derived from this software
54 * without specific prior written permission.
56 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
57 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
59 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
60 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
61 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
62 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
64 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
65 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 * @(#)tcp_debug.c 8.1 (Berkeley) 6/10/93
72 %%% portions-copyright-nrl-95
73 Portions of this software are Copyright 1995-1998 by Randall Atkinson,
74 Ronald Lee, Daniel McDonald, Bao Phan, and Chris Winters. All Rights
75 Reserved. All rights under this copyright have been assigned to the US
76 Naval Research Laboratory (NRL). The NRL Copyright Notice and License
77 Agreement Version 1.1 (January 17, 1995) applies to these portions of the
79 You should have received a copy of the license with this software. If you
80 didn't get a copy, you may request one from <license@ipv6.nrl.navy.mil>.
84 /* load symbolic names */
90 #include <sys/param.h>
92 #include <sys/systm.h>
95 #include <sys/socket.h>
96 #include <sys/socketvar.h>
97 #include <sys/protosw.h>
98 #include <sys/errno.h>
100 #include <net/route.h>
103 #include <netinet/in.h>
104 #include <netinet/in_systm.h>
105 #include <netinet/ip.h>
106 #include <netinet/in_pcb.h>
107 #include <netinet/ip_var.h>
108 #include <netinet/tcp.h>
109 #include <netinet/tcp_fsm.h>
110 #include <netinet/tcp_seq.h>
111 #include <netinet/tcp_timer.h>
112 #include <netinet/tcp_var.h>
113 #include <netinet/tcpip.h>
114 #include <netinet/tcp_debug.h>
118 #include <netinet/in.h>
120 #include <netinet6/ip6.h>
124 int tcpconsdebug = 1;
130 tcp_trace(act, ostate, tp, headers, req, len)
141 struct tcp_debug *td = &tcp_debug[tcp_debx++];
142 struct tcpiphdr *ti = (struct tcpiphdr *)headers;
145 struct tcpipv6hdr *ti6 = (struct tcpipv6hdr *)ti;
148 if (tcp_debx == TCP_NDEBUG)
150 td->td_time = iptime();
152 td->td_ostate = ostate;
153 td->td_tcb = (caddr_t)tp;
157 bzero((caddr_t)&td->td_cb, sizeof (*tp));
159 if (tp->pf == PF_INET6) {
164 bzero(&td->td_ti6, sizeof(struct tcpipv6hdr));
171 bzero(&td->td_ti, sizeof(struct tcpiphdr));
178 bzero((caddr_t)&td->td_ti, sizeof (*ti));
183 if (tcpconsdebug == 0)
186 printf("%x %s:", tp, tcpstates[ostate]);
189 printf("%s ", tanames[act]);
199 if (act == TA_OUTPUT) {
204 printf("[%x..%x)", seq, seq+len);
207 printf("@%x, urp=%x", ack, th->th_urp);
208 flags = th->th_flags;
212 #define pf(f) { if (th->th_flags&TH_/**/f) { printf("%s%s", cp, "f"); cp = ","; } }
213 pf(SYN); pf(ACK); pf(FIN); pf(RST); pf(PUSH); pf(URG);
220 printf("%s", prurequests[req&0xff]);
221 if ((req & 0xff) == PRU_SLOWTIMO)
222 printf("<%s>", tcptimers[req>>8]);
226 printf(" -> %s", tcpstates[tp->t_state]);
227 /* print out internal state of tp !?! */
231 printf("\trcv_(nxt,wnd,up) (%x,%x,%x) snd_(una,nxt,max) (%x,%x,%x)\n",
232 tp->rcv_nxt, tp->rcv_wnd, tp->rcv_up, tp->snd_una, tp->snd_nxt,
234 printf("\tsnd_(wl1,wl2,wnd) (%x,%x,%x)\n",
235 tp->snd_wl1, tp->snd_wl2, tp->snd_wnd);
236 #endif /* TCPDEBUG */