1994-05-26 05:23:31 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1983, 1988, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2017-02-28 23:42:47 +00:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1994-05-26 05:23:31 +00:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2003-05-03 21:06:42 +00:00
|
|
|
#if 0
|
1994-05-26 05:23:31 +00:00
|
|
|
#ifndef lint
|
1997-10-22 06:23:12 +00:00
|
|
|
static const char copyright[] =
|
1994-05-26 05:23:31 +00:00
|
|
|
"@(#) Copyright (c) 1983, 1988, 1993\n\
|
|
|
|
The Regents of the University of California. All rights reserved.\n";
|
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
#ifndef lint
|
|
|
|
static char sccsid[] = "@(#)trpt.c 8.1 (Berkeley) 6/6/93";
|
|
|
|
#endif /* not lint */
|
2003-05-03 21:06:42 +00:00
|
|
|
#endif
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
1994-05-26 05:23:31 +00:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
1996-03-11 13:02:44 +00:00
|
|
|
#include <sys/queue.h>
|
1994-05-26 05:23:31 +00:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/socketvar.h>
|
|
|
|
#define PRUREQUESTS
|
|
|
|
#include <sys/protosw.h>
|
|
|
|
#include <sys/file.h>
|
1996-12-10 17:11:53 +00:00
|
|
|
#include <sys/time.h>
|
1994-05-26 05:23:31 +00:00
|
|
|
|
|
|
|
#include <net/route.h>
|
|
|
|
#include <net/if.h>
|
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/ip.h>
|
2000-01-09 19:17:30 +00:00
|
|
|
#ifdef INET6
|
|
|
|
#include <netinet/ip6.h>
|
|
|
|
#endif
|
1994-05-26 05:23:31 +00:00
|
|
|
#include <netinet/ip_var.h>
|
|
|
|
#include <netinet/tcp.h>
|
|
|
|
#define TCPSTATES
|
|
|
|
#include <netinet/tcp_fsm.h>
|
|
|
|
#include <netinet/tcp_seq.h>
|
|
|
|
#define TCPTIMERS
|
|
|
|
#include <netinet/tcp_timer.h>
|
Hide struct inpcb, struct tcpcb from the userland.
This is a painful change, but it is needed. On the one hand, we avoid
modifying them, and this slows down some ideas, on the other hand we still
eventually modify them and tools like netstat(1) never work on next version of
FreeBSD. We maintain a ton of spares in them, and we already got some ifdef
hell at the end of tcpcb.
Details:
- Hide struct inpcb, struct tcpcb under _KERNEL || _WANT_FOO.
- Make struct xinpcb, struct xtcpcb pure API structures, not including
kernel structures inpcb and tcpcb inside. Export into these structures
the fields from inpcb and tcpcb that are known to be used, and put there
a ton of spare space.
- Make kernel and userland utilities compilable after these changes.
- Bump __FreeBSD_version.
Reviewed by: rrs, gnn
Differential Revision: D10018
2017-03-21 06:39:49 +00:00
|
|
|
#define _WANT_TCPCB
|
1994-05-26 05:23:31 +00:00
|
|
|
#include <netinet/tcp_var.h>
|
|
|
|
#include <netinet/tcpip.h>
|
|
|
|
#define TANAMES
|
|
|
|
#include <netinet/tcp_debug.h>
|
|
|
|
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
1997-10-22 06:23:12 +00:00
|
|
|
#include <err.h>
|
1994-05-26 05:23:31 +00:00
|
|
|
#include <nlist.h>
|
|
|
|
#include <paths.h>
|
1997-10-22 06:23:12 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2002-07-15 17:44:34 +00:00
|
|
|
#include <string.h>
|
1997-10-22 06:23:12 +00:00
|
|
|
#include <unistd.h>
|
1994-05-26 05:23:31 +00:00
|
|
|
|
2002-07-15 17:44:34 +00:00
|
|
|
struct nlist nl[3];
|
1994-05-26 05:23:31 +00:00
|
|
|
#define N_TCP_DEBUG 0
|
|
|
|
#define N_TCP_DEBX 1
|
|
|
|
|
|
|
|
static caddr_t tcp_pcbs[TCP_NDEBUG];
|
|
|
|
static n_time ntime;
|
|
|
|
static int aflag, kflag, memf, follow, sflag, tflag;
|
|
|
|
|
2002-07-15 17:44:34 +00:00
|
|
|
void dotrace(caddr_t);
|
|
|
|
void klseek(int, off_t, int);
|
|
|
|
int numeric(const void *, const void *);
|
|
|
|
void tcp_trace(short, short, struct tcpcb *, int, void *, struct tcphdr *, int);
|
|
|
|
static void usage(void);
|
1997-10-22 06:23:12 +00:00
|
|
|
|
|
|
|
int
|
2002-07-15 17:44:34 +00:00
|
|
|
main(int argc, char **argv)
|
1994-05-26 05:23:31 +00:00
|
|
|
{
|
1997-10-22 06:23:12 +00:00
|
|
|
int ch, i, jflag, npcbs;
|
2002-07-15 17:44:34 +00:00
|
|
|
const char *core, *syst;
|
|
|
|
|
|
|
|
nl[0].n_name = strdup("_tcp_debug");
|
|
|
|
nl[1].n_name = strdup("_tcp_debx");
|
1994-05-26 05:23:31 +00:00
|
|
|
|
|
|
|
jflag = npcbs = 0;
|
1997-03-31 05:11:47 +00:00
|
|
|
while ((ch = getopt(argc, argv, "afjp:st")) != -1)
|
1994-05-26 05:23:31 +00:00
|
|
|
switch (ch) {
|
|
|
|
case 'a':
|
|
|
|
++aflag;
|
|
|
|
break;
|
|
|
|
case 'f':
|
|
|
|
++follow;
|
|
|
|
setlinebuf(stdout);
|
|
|
|
break;
|
|
|
|
case 'j':
|
|
|
|
++jflag;
|
|
|
|
break;
|
|
|
|
case 'p':
|
1997-10-22 06:23:12 +00:00
|
|
|
if (npcbs >= TCP_NDEBUG)
|
|
|
|
errx(1, "too many pcb's specified");
|
1994-05-26 05:23:31 +00:00
|
|
|
(void)sscanf(optarg, "%x", (int *)&tcp_pcbs[npcbs++]);
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
++sflag;
|
|
|
|
break;
|
|
|
|
case 't':
|
|
|
|
++tflag;
|
|
|
|
break;
|
|
|
|
case '?':
|
|
|
|
default:
|
1997-10-22 06:23:12 +00:00
|
|
|
usage();
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
|
|
|
|
|
|
|
core = _PATH_KMEM;
|
|
|
|
if (argc > 0) {
|
2002-07-15 17:44:34 +00:00
|
|
|
syst = *argv;
|
1994-05-26 05:23:31 +00:00
|
|
|
argc--, argv++;
|
|
|
|
if (argc > 0) {
|
|
|
|
core = *argv;
|
|
|
|
argc--, argv++;
|
|
|
|
++kflag;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Discard setgid privileges if not the running kernel so that
|
|
|
|
* bad guys can't print interesting stuff from kernel memory.
|
|
|
|
*/
|
2015-09-01 06:32:02 +00:00
|
|
|
if (setgid(getgid()) != 0)
|
|
|
|
err(1, "setgid");
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
else
|
2002-07-15 17:44:34 +00:00
|
|
|
syst = getbootfile();
|
1994-05-26 05:23:31 +00:00
|
|
|
|
2002-07-15 17:44:34 +00:00
|
|
|
if (nlist(syst, nl) < 0 || !nl[0].n_value)
|
|
|
|
errx(1, "%s: no namelist", syst);
|
1997-10-22 06:23:12 +00:00
|
|
|
if ((memf = open(core, O_RDONLY)) < 0)
|
|
|
|
err(2, "%s", core);
|
2015-09-01 06:32:02 +00:00
|
|
|
if (setgid(getgid()) != 0)
|
|
|
|
err(1, "setgid");
|
1997-10-22 06:23:12 +00:00
|
|
|
if (kflag)
|
|
|
|
errx(1, "can't do core files yet");
|
1994-05-26 05:23:31 +00:00
|
|
|
(void)klseek(memf, (off_t)nl[N_TCP_DEBX].n_value, L_SET);
|
|
|
|
if (read(memf, (char *)&tcp_debx, sizeof(tcp_debx)) !=
|
1997-10-22 06:23:12 +00:00
|
|
|
sizeof(tcp_debx))
|
|
|
|
err(3, "tcp_debx");
|
1994-05-26 05:23:31 +00:00
|
|
|
(void)klseek(memf, (off_t)nl[N_TCP_DEBUG].n_value, L_SET);
|
|
|
|
if (read(memf, (char *)tcp_debug, sizeof(tcp_debug)) !=
|
1997-10-22 06:23:12 +00:00
|
|
|
sizeof(tcp_debug))
|
|
|
|
err(3, "tcp_debug");
|
1994-05-26 05:23:31 +00:00
|
|
|
/*
|
|
|
|
* If no control blocks have been specified, figure
|
|
|
|
* out how many distinct one we have and summarize
|
|
|
|
* them in tcp_pcbs for sorting the trace records
|
|
|
|
* below.
|
|
|
|
*/
|
|
|
|
if (!npcbs) {
|
|
|
|
for (i = 0; i < TCP_NDEBUG; i++) {
|
|
|
|
register struct tcp_debug *td = &tcp_debug[i];
|
|
|
|
register int j;
|
|
|
|
|
|
|
|
if (td->td_tcb == 0)
|
|
|
|
continue;
|
|
|
|
for (j = 0; j < npcbs; j++)
|
|
|
|
if (tcp_pcbs[j] == td->td_tcb)
|
|
|
|
break;
|
|
|
|
if (j >= npcbs)
|
|
|
|
tcp_pcbs[npcbs++] = td->td_tcb;
|
|
|
|
}
|
|
|
|
if (!npcbs)
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
qsort(tcp_pcbs, npcbs, sizeof(caddr_t), numeric);
|
|
|
|
if (jflag) {
|
|
|
|
for (i = 0;;) {
|
2002-07-15 17:44:34 +00:00
|
|
|
printf("%p", (void *)tcp_pcbs[i]);
|
1994-05-26 05:23:31 +00:00
|
|
|
if (++i == npcbs)
|
|
|
|
break;
|
|
|
|
fputs(", ", stdout);
|
|
|
|
}
|
|
|
|
putchar('\n');
|
|
|
|
}
|
|
|
|
else for (i = 0; i < npcbs; i++) {
|
2002-07-16 09:58:36 +00:00
|
|
|
printf("\n%p:\n", tcp_pcbs[i]);
|
1994-05-26 05:23:31 +00:00
|
|
|
dotrace(tcp_pcbs[i]);
|
|
|
|
}
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
1997-10-22 06:23:12 +00:00
|
|
|
static void
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
(void)fprintf(stderr,
|
|
|
|
"usage: trpt [-afjst] [-p hex-address] [system [core]]\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1994-05-26 05:23:31 +00:00
|
|
|
dotrace(tcpcb)
|
|
|
|
register caddr_t tcpcb;
|
|
|
|
{
|
|
|
|
register struct tcp_debug *td;
|
|
|
|
register int i;
|
2000-01-29 11:49:07 +00:00
|
|
|
int prev_debx = tcp_debx, family;
|
1994-05-26 05:23:31 +00:00
|
|
|
|
|
|
|
again: if (--tcp_debx < 0)
|
|
|
|
tcp_debx = TCP_NDEBUG - 1;
|
|
|
|
for (i = prev_debx % TCP_NDEBUG; i < TCP_NDEBUG; i++) {
|
|
|
|
td = &tcp_debug[i];
|
|
|
|
if (tcpcb && td->td_tcb != tcpcb)
|
|
|
|
continue;
|
|
|
|
ntime = ntohl(td->td_time);
|
2000-01-29 11:49:07 +00:00
|
|
|
#ifdef INET6
|
|
|
|
family = td->td_family;
|
|
|
|
#else
|
|
|
|
family = AF_INET;
|
|
|
|
#endif
|
|
|
|
switch(family) {
|
|
|
|
case AF_INET:
|
|
|
|
tcp_trace(td->td_act, td->td_ostate,
|
|
|
|
&td->td_cb, td->td_family, &td->td_ti.ti_i,
|
|
|
|
&td->td_ti.ti_t, td->td_req);
|
|
|
|
break;
|
|
|
|
#ifdef INET6
|
|
|
|
case AF_INET6:
|
|
|
|
tcp_trace(td->td_act, td->td_ostate,
|
|
|
|
&td->td_cb, td->td_family, &td->td_ti6.ip6,
|
|
|
|
&td->td_ti6.th, td->td_req);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
}
|
1994-05-26 05:23:31 +00:00
|
|
|
if (i == tcp_debx)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
for (i = 0; i <= tcp_debx % TCP_NDEBUG; i++) {
|
|
|
|
td = &tcp_debug[i];
|
|
|
|
if (tcpcb && td->td_tcb != tcpcb)
|
|
|
|
continue;
|
|
|
|
ntime = ntohl(td->td_time);
|
2000-01-29 11:49:07 +00:00
|
|
|
#ifdef INET6
|
|
|
|
family = td->td_family;
|
|
|
|
#else
|
|
|
|
family = AF_INET;
|
|
|
|
#endif
|
|
|
|
switch(family) {
|
|
|
|
case AF_INET:
|
|
|
|
tcp_trace(td->td_act, td->td_ostate,
|
|
|
|
&td->td_cb, td->td_family, &td->td_ti.ti_i,
|
|
|
|
&td->td_ti.ti_t, td->td_req);
|
|
|
|
break;
|
|
|
|
#ifdef INET6
|
|
|
|
case AF_INET6:
|
|
|
|
tcp_trace(td->td_act, td->td_ostate,
|
|
|
|
&td->td_cb, td->td_family, &td->td_ti6.ip6,
|
|
|
|
&td->td_ti6.th, td->td_req);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
}
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
done: if (follow) {
|
|
|
|
prev_debx = tcp_debx + 1;
|
|
|
|
if (prev_debx >= TCP_NDEBUG)
|
|
|
|
prev_debx = 0;
|
|
|
|
do {
|
|
|
|
sleep(1);
|
|
|
|
(void)klseek(memf, (off_t)nl[N_TCP_DEBX].n_value, L_SET);
|
|
|
|
if (read(memf, (char *)&tcp_debx, sizeof(tcp_debx)) !=
|
1997-10-22 06:23:12 +00:00
|
|
|
sizeof(tcp_debx))
|
|
|
|
err(3, "tcp_debx");
|
1994-05-26 05:23:31 +00:00
|
|
|
} while (tcp_debx == prev_debx);
|
|
|
|
(void)klseek(memf, (off_t)nl[N_TCP_DEBUG].n_value, L_SET);
|
|
|
|
if (read(memf, (char *)tcp_debug, sizeof(tcp_debug)) !=
|
1997-10-22 06:23:12 +00:00
|
|
|
sizeof(tcp_debug))
|
|
|
|
err(3, "tcp_debug");
|
1994-05-26 05:23:31 +00:00
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Tcp debug routines
|
|
|
|
*/
|
|
|
|
/*ARGSUSED*/
|
1997-10-22 06:23:12 +00:00
|
|
|
void
|
2009-02-26 20:59:05 +00:00
|
|
|
tcp_trace(short act, short ostate, struct tcpcb *tp, int family __unused,
|
|
|
|
void *ip, struct tcphdr *th, int req)
|
1994-05-26 05:23:31 +00:00
|
|
|
{
|
|
|
|
tcp_seq seq, ack;
|
|
|
|
int flags, len, win, timer;
|
2000-01-09 19:17:30 +00:00
|
|
|
struct ip *ip4;
|
|
|
|
#ifdef INET6
|
|
|
|
int isipv6, nopkt = 1;
|
|
|
|
struct ip6_hdr *ip6;
|
|
|
|
char ntop_buf[INET6_ADDRSTRLEN];
|
|
|
|
#endif
|
1994-05-26 05:23:31 +00:00
|
|
|
|
2000-01-09 19:17:30 +00:00
|
|
|
#ifdef INET6
|
2000-01-29 11:49:07 +00:00
|
|
|
switch (family) {
|
|
|
|
case AF_INET:
|
2000-01-09 19:17:30 +00:00
|
|
|
nopkt = 0;
|
2000-01-29 11:49:07 +00:00
|
|
|
isipv6 = 0;
|
2000-01-09 19:17:30 +00:00
|
|
|
ip4 = (struct ip *)ip;
|
|
|
|
break;
|
2000-01-29 11:49:07 +00:00
|
|
|
case AF_INET6:
|
2000-01-09 19:17:30 +00:00
|
|
|
nopkt = 0;
|
|
|
|
isipv6 = 1;
|
|
|
|
ip6 = (struct ip6_hdr *)ip;
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
ip4 = (struct ip *)ip;
|
|
|
|
#endif
|
2002-07-15 17:44:34 +00:00
|
|
|
printf("%03ld %s:%s ", (long)((ntime/10) % 1000), tcpstates[ostate],
|
1994-05-26 05:23:31 +00:00
|
|
|
tanames[act]);
|
|
|
|
switch (act) {
|
|
|
|
case TA_INPUT:
|
|
|
|
case TA_OUTPUT:
|
|
|
|
case TA_DROP:
|
2000-01-09 19:17:30 +00:00
|
|
|
#ifdef INET6
|
|
|
|
if (nopkt != 0)
|
|
|
|
break;
|
|
|
|
#endif
|
1994-05-26 05:23:31 +00:00
|
|
|
if (aflag) {
|
|
|
|
printf("(src=%s,%u, ",
|
2000-01-09 19:17:30 +00:00
|
|
|
|
|
|
|
#ifdef INET6
|
|
|
|
isipv6
|
|
|
|
? inet_ntop(AF_INET6, &ip6->ip6_src, ntop_buf,
|
|
|
|
sizeof(ntop_buf)) :
|
|
|
|
#endif
|
|
|
|
inet_ntoa(ip4->ip_src),
|
|
|
|
ntohs(th->th_sport));
|
1994-05-26 05:23:31 +00:00
|
|
|
printf("dst=%s,%u)",
|
2000-01-09 19:17:30 +00:00
|
|
|
#ifdef INET6
|
|
|
|
isipv6
|
|
|
|
? inet_ntop(AF_INET6, &ip6->ip6_dst, ntop_buf,
|
|
|
|
sizeof(ntop_buf)) :
|
|
|
|
#endif
|
|
|
|
inet_ntoa(ip4->ip_dst),
|
|
|
|
ntohs(th->th_dport));
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
2000-01-09 19:17:30 +00:00
|
|
|
seq = th->th_seq;
|
|
|
|
ack = th->th_ack;
|
|
|
|
|
|
|
|
len =
|
|
|
|
#ifdef INET6
|
|
|
|
isipv6 ? ip6->ip6_plen :
|
|
|
|
#endif
|
|
|
|
ip4->ip_len;
|
|
|
|
win = th->th_win;
|
1994-05-26 05:23:31 +00:00
|
|
|
if (act == TA_OUTPUT) {
|
|
|
|
seq = ntohl(seq);
|
|
|
|
ack = ntohl(ack);
|
|
|
|
len = ntohs(len);
|
|
|
|
win = ntohs(win);
|
|
|
|
}
|
|
|
|
if (act == TA_OUTPUT)
|
|
|
|
len -= sizeof(struct tcphdr);
|
|
|
|
if (len)
|
2002-07-15 17:44:34 +00:00
|
|
|
printf("[%lx..%lx)", (u_long)seq, (u_long)(seq + len));
|
1994-05-26 05:23:31 +00:00
|
|
|
else
|
2002-07-15 17:44:34 +00:00
|
|
|
printf("%lx", (u_long)seq);
|
|
|
|
printf("@%lx", (u_long)ack);
|
1994-05-26 05:23:31 +00:00
|
|
|
if (win)
|
|
|
|
printf("(win=%x)", win);
|
2000-01-09 19:17:30 +00:00
|
|
|
flags = th->th_flags;
|
1994-05-26 05:23:31 +00:00
|
|
|
if (flags) {
|
2002-07-15 17:44:34 +00:00
|
|
|
const char *cp = "<";
|
1994-05-26 05:23:31 +00:00
|
|
|
#define pf(flag, string) { \
|
2000-01-09 19:17:30 +00:00
|
|
|
if (th->th_flags&flag) { \
|
1994-05-26 05:23:31 +00:00
|
|
|
(void)printf("%s%s", cp, string); \
|
|
|
|
cp = ","; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
pf(TH_SYN, "SYN");
|
|
|
|
pf(TH_ACK, "ACK");
|
|
|
|
pf(TH_FIN, "FIN");
|
|
|
|
pf(TH_RST, "RST");
|
|
|
|
pf(TH_PUSH, "PUSH");
|
|
|
|
pf(TH_URG, "URG");
|
|
|
|
printf(">");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TA_USER:
|
|
|
|
timer = req >> 8;
|
|
|
|
req &= 0xff;
|
|
|
|
printf("%s", prurequests[req]);
|
|
|
|
if (req == PRU_SLOWTIMO || req == PRU_FASTTIMO)
|
|
|
|
printf("<%s>", tcptimers[timer]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
printf(" -> %s", tcpstates[tp->t_state]);
|
|
|
|
/* print out internal state of tp !?! */
|
|
|
|
printf("\n");
|
|
|
|
if (sflag) {
|
2002-07-15 17:44:34 +00:00
|
|
|
printf("\trcv_nxt %lx rcv_wnd %lx snd_una %lx snd_nxt %lx snd_max %lx\n",
|
2016-10-06 16:28:34 +00:00
|
|
|
(u_long)tp->rcv_nxt, (u_long)tp->rcv_wnd,
|
2002-07-15 17:44:34 +00:00
|
|
|
(u_long)tp->snd_una, (u_long)tp->snd_nxt,
|
|
|
|
(u_long)tp->snd_max);
|
|
|
|
printf("\tsnd_wl1 %lx snd_wl2 %lx snd_wnd %lx\n",
|
|
|
|
(u_long)tp->snd_wl1,
|
2016-10-06 16:28:34 +00:00
|
|
|
(u_long)tp->snd_wl2, (u_long)tp->snd_wnd);
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
/* print out timers? */
|
1999-08-31 02:32:14 +00:00
|
|
|
#if 0
|
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
* kernel now uses callouts, not integer time values.
|
|
|
|
*/
|
1994-05-26 05:23:31 +00:00
|
|
|
if (tflag) {
|
|
|
|
register char *cp = "\t";
|
|
|
|
register int i;
|
|
|
|
|
|
|
|
for (i = 0; i < TCPT_NTIMERS; i++) {
|
|
|
|
if (tp->t_timer[i] == 0)
|
|
|
|
continue;
|
|
|
|
printf("%s%s=%d", cp, tcptimers[i], tp->t_timer[i]);
|
|
|
|
if (i == TCPT_REXMT)
|
|
|
|
printf(" (t_rxtshft=%d)", tp->t_rxtshift);
|
|
|
|
cp = ", ";
|
|
|
|
}
|
|
|
|
if (*cp != '\t')
|
|
|
|
putchar('\n');
|
|
|
|
}
|
1999-08-31 02:32:14 +00:00
|
|
|
#endif
|
1994-05-26 05:23:31 +00:00
|
|
|
}
|
|
|
|
|
1997-10-22 06:23:12 +00:00
|
|
|
int
|
2001-03-05 12:13:12 +00:00
|
|
|
numeric(v1, v2)
|
|
|
|
const void *v1, *v2;
|
1994-05-26 05:23:31 +00:00
|
|
|
{
|
2001-03-05 12:13:12 +00:00
|
|
|
const caddr_t *c1 = v1, *c2 = v2;
|
1994-05-26 05:23:31 +00:00
|
|
|
return(*c1 - *c2);
|
|
|
|
}
|
|
|
|
|
1997-10-22 06:23:12 +00:00
|
|
|
void
|
1994-05-26 05:23:31 +00:00
|
|
|
klseek(fd, base, off)
|
|
|
|
int fd, off;
|
|
|
|
off_t base;
|
|
|
|
{
|
|
|
|
(void)lseek(fd, base, off);
|
|
|
|
}
|