* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
static char sccsid
[] = "@(#)ns.c 5.5 (Berkeley) %G%";
#include <sys/socketvar.h>
#include <netinet/tcp_fsm.h>
#include <netinet/tcp_timer.h>
#include <netns/ns_pcb.h>
#include <netns/idp_var.h>
#include <netns/ns_error.h>
#include <netns/spp_var.h>
#include <netns/spp_debug.h>
* Print a summary of connections related to a Network Systems
* protocol. For SPP, also give state of connection.
* Listening processes (aflag) are suppressed unless the
* -a (all) flag is specified.
register struct nspcb
*prev
, *next
;
isspp
= strcmp(name
, "spp") == 0;
read(kmem
, (char *)&cb
, sizeof (struct nspcb
));
prev
= (struct nspcb
*)off
;
if (nspcb
.nsp_next
== (struct nspcb
*)off
)
for (;nspcb
.nsp_next
!= (struct nspcb
*)off
; prev
= next
) {
klseek(kmem
, (off_t
)next
, 0);
read(kmem
, (char *)&nspcb
, sizeof (nspcb
));
if (nspcb
.nsp_prev
!= prev
) {
if (!aflag
&& ns_nullhost(nspcb
.nsp_faddr
) ) {
klseek(kmem
, (off_t
)nspcb
.nsp_socket
, 0);
read(kmem
, (char *)&sockb
, sizeof (sockb
));
ppcb
= (off_t
) nspcb
.nsp_pcb
;
read(kmem
, (char *)&sppcb
, sizeof (sppcb
));
printf("Active NS connections");
printf(" (including servers)");
printf("%-8.8s ", "PCB");
"%-5.5s %-6.6s %-6.6s %-18.18s %-18.18s %s\n" :
"%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s %s\n",
"Proto", "Recv-Q", "Send-Q",
"Local Address", "Foreign Address", "(state)");
printf("%-5.5s %6d %6d ", name
, sockb
.so_rcv
.sb_cc
,
printf(" %-22.22s", ns_prpr(&nspcb
.nsp_laddr
));
printf(" %-22.22s", ns_prpr(&nspcb
.nsp_faddr
));
extern char *tcpstates
[];
if (sppcb
.s_state
>= TCP_NSTATES
)
printf(" %d", sppcb
.s_state
);
printf(" %s", tcpstates
[sppcb
.s_state
]);
#define ANY(x,y,z) ((x) ? printf("\t%u %s%s%s\n",x,y,plural(x),z) : 0)
* Dump SPP statistics structure.
struct spp_istat spp_istat
;
read(kmem
, (char *)&spp_istat
, sizeof (spp_istat
));
ANY(spp_istat
.nonucn
, "connection", " dropped due to no new sockets ");
ANY(spp_istat
.gonawy
, "connection", " terminated due to our end dying");
ANY(spp_istat
.nonucn
, "connection", " dropped due to inability to connect");
ANY(spp_istat
.noconn
, "connection", " dropped due to inability to connect");
ANY(spp_istat
.notme
, "connection", " incompleted due to mismatched id's");
ANY(spp_istat
.wrncon
, "connection", " dropped due to mismatched id's");
ANY(spp_istat
.bdreas
, "packet", " dropped out of sequence");
ANY(spp_istat
.lstdup
, "packet", " duplicating the highest packet");
ANY(spp_istat
.notyet
, "packet", " refused as exceeding allocation");
* Dump IDP statistics structure.
read(kmem
, (char *)&idpstat
, sizeof (idpstat
));
ANY(idpstat
.idps_toosmall
, "packet", " smaller than a header");
ANY(idpstat
.idps_tooshort
, "packet", " smaller than advertised");
ANY(idpstat
.idps_badsum
, "packet", " with bad checksums");
static char *((ns_errnames
[])[2]) = {
{"Unspecified Error", " at Destination"},
{"Bad Checksum", " at Destination"},
{"No Listener", " at Socket"},
{"Packet", " Refused due to lack of space at Destination"},
{"Unspecified Error", " while gatewayed"},
{"Bad Checksum", " while gatewayed"},
{"Packet", " forwarded too many times"},
{"Packet", " too large to be forwarded"},
* Dump NS Error statistics structure.
struct ns_errstat ns_errstat
;
register int histoprint
= 1;
read(kmem
, (char *)&ns_errstat
, sizeof (ns_errstat
));
printf("NS error statistics:\n");
ANY(ns_errstat
.ns_es_error
, "call", " to ns_error");
ANY(ns_errstat
.ns_es_oldshort
, "error",
" ignored due to insufficient addressing");
ANY(ns_errstat
.ns_es_oldns_err
, "error request",
" in response to error packets");
ANY(ns_errstat
.ns_es_tooshort
, "error packet",
ANY(ns_errstat
.ns_es_badcode
, "error packet",
" received of unknown type");
for(j
= 0; j
< NS_ERR_MAX
; j
++) {
z
= ns_errstat
.ns_es_outhist
[j
];
printf("Output Error Histogram:\n");
ANY(z
, ns_errnames
[j
][0], ns_errnames
[j
][1]);
for(j
= 0; j
< NS_ERR_MAX
; j
++) {
z
= ns_errstat
.ns_es_inhist
[j
];
printf("Input Error Histogram:\n");
ANY(z
, ns_errnames
[j
][0], ns_errnames
[j
][1]);
static struct sockaddr_ns ssns
= {AF_NS
};
struct sockaddr_ns
*sns
= &ssns
;