1 /*!\file netinet/tcp_debu.h
6 * Copyright (c) 1982, 1986, 1993
7 * The Regents of the University of California. All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * @(#)tcp_debug.h 8.1 (Berkeley) 6/10/93
38 * $Id: tcp_debug.h,v 1.5 1996/04/13 12:45:57 bde Exp $
41 #ifndef __NETINET_TCP_DEBUG_H
42 #define __NETINET_TCP_DEBUG_H
49 struct tcpiphdr td_ti;
61 static char *tanames[] = {
62 "input", "output", "user", "respond", "drop"
66 #define TCP_NDEBUG 100
69 #include <sys/wtime.h>
71 /* The following table is used as a circular buffer in which TCP
72 * autotuning statistics can be kept.
73 * It is intended that these statistics will be periodically read
74 * by a debugging application using kvm.
77 #define TAD_ENTRIES 1024 /* number of entries in monitor_table */
80 u_long seq_no; /* tad entry number */
81 struct timeval time; /* time of entry */
82 u_long snd_cwnd; /* congestion window */
83 u_long sb_hiwat; /* send socket buffer hi water mark */
84 u_long sb_target_hiwat; /* target for same */
85 u_long sb_cc; /* space used in send socket buf */
86 u_long m_clused; /* m_clusters - m_clfree */
87 u_short lport; /* local port number */
88 u_short rport; /* remote port number */
89 u_long debug; /* used for debugging */
90 tcp_seq snd_max; /* highest sequence number sent */
91 } tad_table[TAD_ENTRIES];
93 extern struct tad_entry *tad_index; /* insert point */
94 extern u_long tad_seq;
95 extern u_long tad_debug;
97 /* increment the index into the table
99 #define TAD_INDEX_INCR tad_index = (struct tad_entry*)((u_long)tad_index + \
100 sizeof(struct tad_entry)); \
101 if ((u_long) tad_index >= \
102 (u_long) &tad_table[TAD_ENTRIES]) \
103 tad_index = tad_table;
105 /* add a log entry to the table
107 #define TAD_SNAPSHOT(tp, so) tad_index->seq_no = tad_seq++; \
108 microtime(&(tad_index->time)); \
109 tad_index->snd_cwnd = tp->snd_cwnd; \
110 tad_index->sb_hiwat = so->so_snd.sb_hiwat; \
111 tad_index->sb_target_hiwat = so->so_snd.sb_net_target; \
112 tad_index->sb_cc = so->so_snd.sb_cc; \
113 tad_index->m_clused = mbstat.m_clusters - mbstat.m_clfree;\
114 tad_index->lport = tp->t_inpcb->inp_lport; \
115 tad_index->rport = tp->t_inpcb->inp_fport; \
116 tad_index->debug = tad_debug; \
117 tad_index->snd_max = tp->snd_max; \
120 #endif /* TCP_AUTO_DEBUG */
122 #endif /* __NETINET_TCP_DEBUG_H */