summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat/inet.c
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>1997-08-25 16:57:05 +0000
committerwollman <wollman@FreeBSD.org>1997-08-25 16:57:05 +0000
commitfefb31984036c52416ff19dddb3e14a5227b987c (patch)
tree7368004271ebd0c62eb15378000f2a70831b7e39 /usr.bin/netstat/inet.c
parent143b9973292699a6d3c7ec53201c660848be6a17 (diff)
downloadFreeBSD-src-fefb31984036c52416ff19dddb3e14a5227b987c.zip
FreeBSD-src-fefb31984036c52416ff19dddb3e14a5227b987c.tar.gz
Print out the two new fields in the ICMP stats. While we're at it, also
convert icmp_stats() to use sysctl(3) to retrieve the information rather than kvm. This makes it easy to also print whether ICMP address mask responses are enabled, so do so.
Diffstat (limited to 'usr.bin/netstat/inet.c')
-rw-r--r--usr.bin/netstat/inet.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index cc9290e..0226107 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -36,13 +36,14 @@
static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95";
*/
static const char rcsid[] =
- "$Id$";
+ "$Id: inet.c,v 1.25 1997/02/22 19:56:21 peter Exp $";
#endif /* not lint */
#include <sys/param.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
+#include <sys/sysctl.h>
#include <sys/protosw.h>
#include <net/route.h>
@@ -378,11 +379,20 @@ icmp_stats(off, name)
char *name;
{
struct icmpstat icmpstat;
- register int i, first;
+ int i, first;
+ int mib[4]; /* CTL_NET + PF_INET + IPPROTO_ICMP + req */
+ size_t len;
+
+ mib[0] = CTL_NET;
+ mib[1] = PF_INET;
+ mib[2] = IPPROTO_ICMP;
+ mib[3] = ICMPCTL_STATS;
+
+ len = sizeof icmpstat;
+ memset(&icmpstat, 0, len);
+ if (sysctl(mib, 4, &icmpstat, &len, (void *)0, 0) < 0)
+ return; /* XXX should complain, but not traditional */
- if (off == 0)
- return;
- kread(off, (char *)&icmpstat, sizeof (icmpstat));
printf("%s:\n", name);
#define p(f, m) if (icmpstat.f || sflag <= 1) \
@@ -404,6 +414,8 @@ icmp_stats(off, name)
p(icps_tooshort, "\t%lu message%s < minimum length\n");
p(icps_checksum, "\t%lu bad checksum%s\n");
p(icps_badlen, "\t%lu message%s with bad length\n");
+ p(icps_bmcastecho, "\t%lu multicast echo requests ignored\n");
+ p(icps_bmcasttstamp, "\t%lu multicast timestamp requests ignored\n");
for (first = 1, i = 0; i < ICMP_MAXTYPE + 1; i++)
if (icmpstat.icps_inhist[i] != 0) {
if (first) {
@@ -415,6 +427,12 @@ icmp_stats(off, name)
}
p(icps_reflect, "\t%lu message response%s generated\n");
#undef p
+ mib[3] = ICMPCTL_MASKREPL;
+ len = sizeof i;
+ if (sysctl(mib, 4, &i, &len, (void *)0, 0) < 0)
+ return;
+ printf("\tICMP address mask responses are %sabled\n",
+ i ? "en" : "dis");
}
/*
OpenPOWER on IntegriCloud