This manual page documents a tool used
for debugging failures in
the Xerox NS Sequenced packet protocol layer
. It is adapted from
the Internet equivalent
trpt(8c
).
* Copyright (c) 1985 Regents of the University of California.
* %sccs.include.redist.c%
"@(#) Copyright (c) 1985 Regents of the University of California.\n\
static char sccsid
[] = "@(#)trsp.c 6.9 (Berkeley) %G%";
#include <sys/socketvar.h>
#include <netinet/tcp_fsm.h>
#include <netinet/tcp_timer.h>
#include <netns/spp_timer.h>
#include <netns/spp_var.h>
#include <netns/ns_pcb.h>
#include <netns/idp_var.h>
#include <netns/spp_debug.h>
struct spp_debug spp_debug
[SPP_NDEBUG
];
caddr_t spp_pcbs
[SPP_NDEBUG
];
int i
, mask
= 0, npcbs
= 0;
if (argc
> 0 && !strcmp(*argv
, "-a")) {
if (argc
> 0 && !strcmp(*argv
, "-z")) {
if (argc
> 0 && !strcmp(*argv
, "-s")) {
if (argc
> 0 && !strcmp(*argv
, "-t")) {
if (argc
> 0 && !strcmp(*argv
, "-j")) {
if (argc
> 0 && !strcmp(*argv
, "-p")) {
fprintf(stderr
, "-p: missing sppcb address\n");
if (npcbs
>= SPP_NDEBUG
) {
fprintf(stderr
, "-p: too many pcb's specified\n");
sscanf(*argv
, "%x", &spp_pcbs
[npcbs
++]);
* Discard setgid privileges if not the running kernel so that
* bad guys can't print interesting stuff from kernel memory.
(void) nlist(system
, nl
);
if (nl
[0].n_value
== 0) {
fprintf(stderr
, "trsp: %s: no namelist\n", system
);
fprintf(stderr
, "trsp: "); perror(core
);
nl
[0].n_value
&= 0x7fffffff;
nl
[1].n_value
&= 0x7fffffff;
(void) lseek(0, nl
[1].n_value
, 0);
if (read(0, &spp_debx
, sizeof (spp_debx
)) != sizeof (spp_debx
)) {
fprintf(stderr
, "trsp: "); perror("spp_debx");
printf("spp_debx=%d\n", spp_debx
);
(void) lseek(0, nl
[0].n_value
, 0);
if (read(0, spp_debug
, sizeof (spp_debug
)) != sizeof (spp_debug
)) {
fprintf(stderr
, "trsp: "); perror("spp_debug");
* Here, we just want to clear out the old trace data and start over.
char *cp
= (char *) spp_debug
,
*cplim
= cp
+ sizeof(spp_debug
);
fprintf(stderr
, "trsp: "); perror(core
);
while(cp
< cplim
) *cp
++ = 0;
(void) lseek(0, nl
[0].n_value
, 0);
if (write(0, spp_debug
, sizeof (spp_debug
)) != sizeof (spp_debug
)) {
fprintf(stderr
, "trsp: "); perror("spp_debug");
(void) lseek(0, nl
[1].n_value
, 0);
if (write(0, &spp_debx
, sizeof (spp_debx
)) != sizeof (spp_debx
)) {
fprintf(stderr
, "trsp: "); perror("spp_debx");
* 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
for (i
= 0; i
< SPP_NDEBUG
; i
++) {
register struct spp_debug
*sd
= &spp_debug
[i
];
for (j
= 0; j
< npcbs
; j
++)
if (spp_pcbs
[j
] == sd
->sd_cb
)
spp_pcbs
[npcbs
++] = sd
->sd_cb
;
qsort(spp_pcbs
, npcbs
, sizeof (caddr_t
), numeric
);
for (i
= 0; i
< npcbs
; i
++) {
printf("%s%x", cp
, spp_pcbs
[i
]);
for (i
= 0; i
< npcbs
; i
++) {
printf("\n%x:\n", spp_pcbs
[i
]);
register struct spp_debug
*sd
;
for (i
= spp_debx
% SPP_NDEBUG
; i
< SPP_NDEBUG
; i
++) {
if (sppcb
&& sd
->sd_cb
!= sppcb
)
ntime
= ntohl(sd
->sd_time
);
spp_trace(sd
->sd_act
, sd
->sd_ostate
, sd
->sd_cb
, &sd
->sd_sp
,
for (i
= 0; i
< spp_debx
% SPP_NDEBUG
; i
++) {
if (sppcb
&& sd
->sd_cb
!= sppcb
)
ntime
= ntohl(sd
->sd_time
);
spp_trace(sd
->sd_act
, sd
->sd_ostate
, sd
->sd_cb
, &sd
->sd_sp
,
printf("%03d ", (ms
/10) % 1000);
spp_trace(act
, ostate
, asp
, sp
, si
, req
)
u_short seq
, ack
, len
, alo
;
if(ostate
>= TCP_NSTATES
) ostate
= 0;
if(act
> SA_DROP
) act
= SA_DROP
;
printf("%s:%s", tcpstates
[ostate
], sanames
[act
]);
ns_printhost(&si
->si_sna
);
ns_printhost(&si
->si_dna
);
printf("%s = %x, ", name, f); \
printf("flags=%x", flags
);
printf("%s%s", cp, name); \
printf("%s = %x, ", name, f); \
ns_printhost(&si
->si_sna
);
ns_printhost(&si
->si_dna
);
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("%s = %x, ", name, f); \
p3("flags", sp
->s_flags
);
printf("%s%s", cp, name); \
if (flags
|| sp
->s_oobflags
) {
p3("force", sp
->s_force
);
p3("rtseq", sp
->s_rtseq
);
for (i
= 0; i
< TCPT_NTIMERS
; i
++) {
printf("%s%s=%d", cp
, tcptimers
[i
], sp
->s_timer
[i
]);
printf(" (s_rxtshft=%d)", sp
->s_rxtshift
);
register struct ns_addr
*p
;
printf("<net:%x%x,host:%4.4x%4.4x%4.4x,port:%x>",