1998-07-06 11:50:18 +04:00
|
|
|
/* $NetBSD: trsp.c,v 1.5 1998/07/06 07:50:21 mrg Exp $ */
|
1997-07-23 22:20:46 +04:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
|
|
|
|
* NASA Ames Research Center.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
|
|
|
*/
|
1997-07-23 10:16:44 +04:00
|
|
|
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
/*
|
1997-07-23 10:16:44 +04:00
|
|
|
* Copyright (c) 1985, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
1997-07-23 22:20:46 +04:00
|
|
|
#include <sys/cdefs.h>
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
#ifndef lint
|
1997-07-23 22:20:46 +04:00
|
|
|
__COPYRIGHT(
|
1997-07-23 10:16:44 +04:00
|
|
|
"@(#) Copyright (c) 1985, 1993\n\
|
1997-07-23 22:20:46 +04:00
|
|
|
The Regents of the University of California. All rights reserved.\n");
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
#ifndef lint
|
1997-07-23 10:16:44 +04:00
|
|
|
#if 0
|
|
|
|
static char sccsid[] = "@(#)trsp.c 8.1 (Berkeley) 6/6/93";
|
|
|
|
#else
|
1998-07-06 11:50:18 +04:00
|
|
|
__RCSID("$NetBSD: trsp.c,v 1.5 1998/07/06 07:50:21 mrg Exp $");
|
1997-07-23 10:16:44 +04:00
|
|
|
#endif
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/socketvar.h>
|
|
|
|
#define PRUREQUESTS
|
|
|
|
#include <sys/protosw.h>
|
|
|
|
|
|
|
|
#include <net/route.h>
|
|
|
|
#include <net/if.h>
|
|
|
|
|
|
|
|
#define TCPSTATES
|
|
|
|
#include <netinet/tcp_fsm.h>
|
|
|
|
#define TCPTIMERS
|
|
|
|
#include <netinet/tcp_timer.h>
|
|
|
|
|
|
|
|
#include <netns/ns.h>
|
|
|
|
#include <netns/sp.h>
|
|
|
|
#include <netns/idp.h>
|
|
|
|
#include <netns/spidp.h>
|
|
|
|
#include <netns/spp_timer.h>
|
|
|
|
#include <netns/spp_var.h>
|
|
|
|
#include <netns/ns_pcb.h>
|
|
|
|
#include <netns/idp_var.h>
|
|
|
|
#define SANAMES
|
|
|
|
#include <netns/spp_debug.h>
|
|
|
|
|
1997-07-23 22:20:46 +04:00
|
|
|
#include <err.h>
|
|
|
|
#include <fcntl.h>
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
1997-07-23 22:20:46 +04:00
|
|
|
#include <kvm.h>
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
#include <nlist.h>
|
|
|
|
#include <paths.h>
|
1997-07-23 22:20:46 +04:00
|
|
|
#include <limits.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
|
1997-07-23 22:20:46 +04:00
|
|
|
u_int32_t ntime;
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
int sflag;
|
|
|
|
int tflag;
|
|
|
|
int jflag;
|
|
|
|
int aflag;
|
|
|
|
int zflag;
|
|
|
|
struct nlist nl[] = {
|
1997-07-23 22:20:46 +04:00
|
|
|
#define N_SPP_DEBUG 0
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
{ "_spp_debug" },
|
1997-07-23 22:20:46 +04:00
|
|
|
#define N_SPP_DEBX 1
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
{ "_spp_debx" },
|
1997-07-23 22:20:46 +04:00
|
|
|
{ NULL },
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
};
|
1997-07-23 22:20:46 +04:00
|
|
|
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
struct spp_debug spp_debug[SPP_NDEBUG];
|
|
|
|
caddr_t spp_pcbs[SPP_NDEBUG];
|
|
|
|
int spp_debx;
|
|
|
|
|
1997-07-23 22:20:46 +04:00
|
|
|
kvm_t *kd;
|
|
|
|
|
|
|
|
extern char *__progname;
|
|
|
|
|
|
|
|
int main __P((int, char *[]));
|
|
|
|
void dotrace __P((caddr_t));
|
|
|
|
int numeric __P((const void *, const void *));
|
|
|
|
void spp_trace __P((short, short, struct sppcb *, struct sppcb *,
|
|
|
|
struct spidp *, int));
|
|
|
|
void usage __P((void));
|
|
|
|
|
|
|
|
int
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
main(argc, argv)
|
|
|
|
int argc;
|
1997-07-23 22:20:46 +04:00
|
|
|
char *argv[];
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
{
|
1997-07-23 22:20:46 +04:00
|
|
|
int ch, i, npcbs = 0;
|
|
|
|
char *system, *core, *cp, errbuf[_POSIX2_LINE_MAX];
|
1998-07-06 11:50:18 +04:00
|
|
|
gid_t egid = getegid();
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
|
1998-07-06 11:50:18 +04:00
|
|
|
(void)setegid(getgid());
|
1997-07-23 22:20:46 +04:00
|
|
|
system = core = NULL;
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
|
1997-07-23 22:20:46 +04:00
|
|
|
while ((ch = getopt(argc, argv, "azstjp:N:M:")) != -1) {
|
|
|
|
switch (ch) {
|
|
|
|
case 'a':
|
|
|
|
++aflag;
|
|
|
|
break;
|
|
|
|
case 'z':
|
|
|
|
++zflag;
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
++sflag;
|
|
|
|
break;
|
|
|
|
case 't':
|
|
|
|
++tflag;
|
|
|
|
break;
|
|
|
|
case 'j':
|
|
|
|
++jflag;
|
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
if (npcbs >= SPP_NDEBUG)
|
|
|
|
errx(1, "too many pcbs specified");
|
|
|
|
errno = 0;
|
|
|
|
spp_pcbs[npcbs++] = (caddr_t)strtoul(optarg, &cp, 16);
|
|
|
|
if (*cp != '\0' || errno == ERANGE)
|
|
|
|
errx(1, "invalid address: %s", optarg);
|
|
|
|
break;
|
|
|
|
case 'N':
|
|
|
|
system = optarg;
|
|
|
|
break;
|
|
|
|
case 'M':
|
|
|
|
core = optarg;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
usage();
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
}
|
|
|
|
}
|
1997-07-23 22:20:46 +04:00
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
|
|
|
|
|
|
|
if (argc)
|
|
|
|
usage();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Discard setgid privileges if not the running kernel so that bad
|
|
|
|
* guys can't print interesting stuff from kernel memory.
|
|
|
|
*/
|
|
|
|
if (core != NULL || system != NULL)
|
1997-07-23 10:16:44 +04:00
|
|
|
setgid(getgid());
|
1998-07-06 11:50:18 +04:00
|
|
|
else
|
|
|
|
setegid(egid);
|
1997-07-23 22:20:46 +04:00
|
|
|
|
|
|
|
kd = kvm_openfiles(system, core, NULL, zflag ? O_RDWR : O_RDONLY,
|
|
|
|
errbuf);
|
|
|
|
if (kd == NULL)
|
|
|
|
errx(1, "can't open kmem: %s", errbuf);
|
|
|
|
|
1998-07-06 11:50:18 +04:00
|
|
|
/* get rid of it now anyway */
|
|
|
|
if (core == NULL && system == NULL)
|
|
|
|
setgid(getgid());
|
|
|
|
|
1997-07-23 22:20:46 +04:00
|
|
|
if (kvm_nlist(kd, nl))
|
|
|
|
errx(2, "%s: no namelist", system ? system : _PATH_UNIX);
|
|
|
|
|
|
|
|
if (kvm_read(kd, nl[N_SPP_DEBX].n_value, &spp_debx,
|
|
|
|
sizeof(spp_debx)) != sizeof(spp_debx))
|
|
|
|
errx(3, "spp_debx: %s", kvm_geterr(kd));
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
printf("spp_debx=%d\n", spp_debx);
|
1997-07-23 22:20:46 +04:00
|
|
|
|
|
|
|
if (kvm_read(kd, nl[N_SPP_DEBUG].n_value, spp_debug,
|
|
|
|
sizeof(spp_debug)) != sizeof(spp_debug))
|
|
|
|
errx(3, "spp_debug: %s", kvm_geterr(kd));
|
|
|
|
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
/*
|
|
|
|
* Here, we just want to clear out the old trace data and start over.
|
|
|
|
*/
|
|
|
|
if (zflag) {
|
|
|
|
spp_debx = 0;
|
1997-07-23 22:20:46 +04:00
|
|
|
(void) memset(spp_debug, 0, sizeof(spp_debug));
|
|
|
|
|
|
|
|
if (kvm_write(kd, nl[N_SPP_DEBX].n_value, &spp_debx,
|
|
|
|
sizeof(spp_debx)) != sizeof(spp_debx))
|
|
|
|
errx(4, "write spp_debx: %s\n", kvm_geterr(kd));
|
|
|
|
|
|
|
|
if (kvm_write(kd, nl[N_SPP_DEBUG].n_value, spp_debug,
|
|
|
|
sizeof(spp_debug)) != sizeof(spp_debug))
|
|
|
|
errx(4, "write spp_debug: %s\n", kvm_geterr(kd));
|
|
|
|
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
exit(0);
|
|
|
|
}
|
1997-07-23 22:20:46 +04:00
|
|
|
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
/*
|
|
|
|
* If no control blocks have been specified, figure
|
|
|
|
* out how many distinct one we have and summarize
|
|
|
|
* them in spp_pcbs for sorting the trace records
|
|
|
|
* below.
|
|
|
|
*/
|
|
|
|
if (npcbs == 0) {
|
|
|
|
for (i = 0; i < SPP_NDEBUG; i++) {
|
1997-07-23 22:20:46 +04:00
|
|
|
struct spp_debug *sd = &spp_debug[i];
|
|
|
|
int j;
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
|
|
|
|
if (sd->sd_cb == 0)
|
|
|
|
continue;
|
|
|
|
for (j = 0; j < npcbs; j++)
|
|
|
|
if (spp_pcbs[j] == sd->sd_cb)
|
|
|
|
break;
|
|
|
|
if (j >= npcbs)
|
|
|
|
spp_pcbs[npcbs++] = sd->sd_cb;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
qsort(spp_pcbs, npcbs, sizeof (caddr_t), numeric);
|
|
|
|
if (jflag) {
|
1997-07-23 22:20:46 +04:00
|
|
|
cp = "";
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
|
|
|
|
for (i = 0; i < npcbs; i++) {
|
1997-07-23 22:20:46 +04:00
|
|
|
printf("%s%lx", cp, (long)spp_pcbs[i]);
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
cp = ", ";
|
|
|
|
}
|
|
|
|
if (*cp)
|
|
|
|
putchar('\n');
|
1997-07-23 22:20:46 +04:00
|
|
|
} else {
|
|
|
|
for (i = 0; i < npcbs; i++) {
|
|
|
|
printf("\n%lx:\n", (long)spp_pcbs[i]);
|
|
|
|
dotrace(spp_pcbs[i]);
|
|
|
|
}
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
}
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
1997-07-23 22:20:46 +04:00
|
|
|
void
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
dotrace(sppcb)
|
1997-07-23 22:20:46 +04:00
|
|
|
caddr_t sppcb;
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
{
|
1997-07-23 22:20:46 +04:00
|
|
|
struct spp_debug *sd;
|
|
|
|
int i;
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
|
|
|
|
for (i = spp_debx % SPP_NDEBUG; i < SPP_NDEBUG; i++) {
|
|
|
|
sd = &spp_debug[i];
|
|
|
|
if (sppcb && sd->sd_cb != sppcb)
|
|
|
|
continue;
|
|
|
|
ntime = ntohl(sd->sd_time);
|
1997-07-23 22:20:46 +04:00
|
|
|
spp_trace(sd->sd_act, sd->sd_ostate, (struct sppcb *)sd->sd_cb,
|
|
|
|
&sd->sd_sp, &sd->sd_si, sd->sd_req);
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
}
|
|
|
|
for (i = 0; i < spp_debx % SPP_NDEBUG; i++) {
|
|
|
|
sd = &spp_debug[i];
|
|
|
|
if (sppcb && sd->sd_cb != sppcb)
|
|
|
|
continue;
|
|
|
|
ntime = ntohl(sd->sd_time);
|
1997-07-23 22:20:46 +04:00
|
|
|
spp_trace(sd->sd_act, sd->sd_ostate, (struct sppcb *)sd->sd_cb,
|
|
|
|
&sd->sd_sp, &sd->sd_si, sd->sd_req);
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-07-23 22:20:46 +04:00
|
|
|
int
|
|
|
|
numeric(v1, v2)
|
|
|
|
const void *v1, *v2;
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
{
|
1997-07-23 22:20:46 +04:00
|
|
|
const caddr_t *c1 = v1;
|
|
|
|
const caddr_t *c2 = v2;
|
|
|
|
int rv;
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
|
1997-07-23 22:20:46 +04:00
|
|
|
if (*c1 < *c2)
|
|
|
|
rv = -1;
|
|
|
|
else if (*c1 > *c2)
|
|
|
|
rv = 1;
|
|
|
|
else
|
|
|
|
rv = 0;
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
|
1997-07-23 22:20:46 +04:00
|
|
|
return (rv);
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
}
|
|
|
|
|
1997-07-23 22:20:46 +04:00
|
|
|
void
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
spp_trace(act, ostate, asp, sp, si, req)
|
|
|
|
short act, ostate;
|
|
|
|
struct sppcb *asp, *sp;
|
|
|
|
struct spidp *si;
|
|
|
|
int req;
|
|
|
|
{
|
1997-07-23 22:20:46 +04:00
|
|
|
u_int16_t seq, ack, len, alo;
|
|
|
|
int flags;
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
char *cp;
|
|
|
|
|
1997-07-23 22:20:46 +04:00
|
|
|
if (ostate >= TCP_NSTATES)
|
|
|
|
ostate = 0;
|
|
|
|
if (act > SA_DROP)
|
|
|
|
act = SA_DROP;
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
printf("\n");
|
1997-07-23 22:20:46 +04:00
|
|
|
printf("%03d %s:%s", (ntime/10) % 1000, tcpstates[ostate],
|
|
|
|
sanames[act]);
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
|
|
|
|
if (si != 0) {
|
|
|
|
seq = si->si_seq;
|
|
|
|
ack = si->si_ack;
|
|
|
|
alo = si->si_alo;
|
|
|
|
len = si->si_len;
|
|
|
|
switch (act) {
|
|
|
|
case SA_RESPOND:
|
|
|
|
case SA_OUTPUT:
|
1997-07-23 22:20:46 +04:00
|
|
|
NTOHS(seq);
|
|
|
|
NTOHS(ack);
|
|
|
|
NTOHS(alo);
|
|
|
|
NTOHS(len);
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
case SA_INPUT:
|
|
|
|
case SA_DROP:
|
1997-07-23 22:20:46 +04:00
|
|
|
if (aflag)
|
|
|
|
printf("\n\tsna=%s\tdna=%s",
|
|
|
|
ns_ntoa(si->si_sna), ns_ntoa(si->si_dna));
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
printf("\n\t");
|
|
|
|
#define p1(name, f) { \
|
|
|
|
printf("%s = %x, ", name, f); \
|
1997-07-23 22:20:46 +04:00
|
|
|
}
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
p1("seq", seq);
|
|
|
|
p1("ack", ack);
|
|
|
|
p1("alo", alo);
|
|
|
|
p1("len", len);
|
|
|
|
flags = si->si_cc;
|
|
|
|
printf("flags=%x", flags);
|
|
|
|
#define pf(name, f) { \
|
|
|
|
if (flags & f) { \
|
|
|
|
printf("%s%s", cp, name); \
|
|
|
|
cp = ","; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
if (flags) {
|
1997-07-23 22:20:46 +04:00
|
|
|
cp = "<";
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
pf("SP_SP", SP_SP);
|
|
|
|
pf("SP_SA", SP_SA);
|
|
|
|
pf("SP_OB", SP_OB);
|
|
|
|
pf("SP_EM", SP_EM);
|
|
|
|
printf(">");
|
|
|
|
}
|
|
|
|
printf(", ");
|
|
|
|
#define p2(name, f) { \
|
|
|
|
printf("%s = %x, ", name, f); \
|
|
|
|
}
|
|
|
|
p2("sid", si->si_sid);
|
|
|
|
p2("did", si->si_did);
|
|
|
|
p2("dt", si->si_dt);
|
1997-07-23 22:20:46 +04:00
|
|
|
printf("\n\tsna=%s\tdna=%s", ns_ntoa(si->si_sna),
|
|
|
|
ns_ntoa(si->si_dna));
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(act == SA_USER) {
|
|
|
|
printf("\treq=%s", prurequests[req&0xff]);
|
|
|
|
if ((req & 0xff) == PRU_SLOWTIMO)
|
|
|
|
printf("<%s>", tcptimers[req>>8]);
|
|
|
|
}
|
|
|
|
printf(" -> %s", tcpstates[sp->s_state]);
|
|
|
|
|
|
|
|
/* print out internal state of sp !?! */
|
|
|
|
printf("\n");
|
|
|
|
if (sp == 0)
|
|
|
|
return;
|
|
|
|
#define p3(name, f) { \
|
|
|
|
printf("%s = %x, ", name, f); \
|
|
|
|
}
|
|
|
|
if (sflag) {
|
|
|
|
printf("\t");
|
|
|
|
p3("rack", sp->s_rack);
|
|
|
|
p3("ralo", sp->s_ralo);
|
|
|
|
p3("smax", sp->s_smax);
|
|
|
|
p3("snxt", sp->s_snxt);
|
|
|
|
p3("flags", sp->s_flags);
|
|
|
|
#undef pf
|
|
|
|
#define pf(name, f) { \
|
|
|
|
if (flags & f) { \
|
|
|
|
printf("%s%s", cp, name); \
|
|
|
|
cp = ","; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
flags = sp->s_flags;
|
|
|
|
if (flags || sp->s_oobflags) {
|
1997-07-23 22:20:46 +04:00
|
|
|
cp = "<";
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
pf("ACKNOW", SF_ACKNOW);
|
|
|
|
pf("DELACK", SF_DELACK);
|
|
|
|
pf("HI", SF_HI);
|
|
|
|
pf("HO", SF_HO);
|
|
|
|
pf("PI", SF_PI);
|
|
|
|
pf("WIN", SF_WIN);
|
|
|
|
pf("RXT", SF_RXT);
|
|
|
|
pf("RVD", SF_RVD);
|
|
|
|
flags = sp->s_oobflags;
|
|
|
|
pf("SOOB", SF_SOOB);
|
|
|
|
pf("IOOB", SF_IOOB);
|
|
|
|
printf(">");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* print out timers? */
|
|
|
|
if (tflag) {
|
1997-07-23 22:20:46 +04:00
|
|
|
int i;
|
|
|
|
|
|
|
|
cp = "\t";
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
|
|
|
|
printf("\n\tTIMERS: ");
|
|
|
|
p3("idle", sp->s_idle);
|
|
|
|
p3("force", sp->s_force);
|
|
|
|
p3("rtseq", sp->s_rtseq);
|
|
|
|
for (i = 0; i < TCPT_NTIMERS; i++) {
|
|
|
|
if (sp->s_timer[i] == 0)
|
|
|
|
continue;
|
|
|
|
printf("%s%s=%d", cp, tcptimers[i], sp->s_timer[i]);
|
|
|
|
if (i == TCPT_REXMT)
|
|
|
|
printf(" (s_rxtshft=%d)", sp->s_rxtshift);
|
|
|
|
cp = ", ";
|
|
|
|
}
|
|
|
|
if (*cp != '\t')
|
|
|
|
putchar('\n');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-07-23 22:20:46 +04:00
|
|
|
void
|
|
|
|
usage()
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
{
|
|
|
|
|
1997-07-23 22:20:46 +04:00
|
|
|
fprintf(stderr, "usage: %s [-azstj] [-p hex-address]"
|
|
|
|
" [-N system] [-M core]\n", __progname);
|
|
|
|
exit(1);
|
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
1993-04-09 16:15:37 +04:00
|
|
|
}
|