From fefb31984036c52416ff19dddb3e14a5227b987c Mon Sep 17 00:00:00 2001 From: wollman Date: Mon, 25 Aug 1997 16:57:05 +0000 Subject: 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. --- usr.bin/netstat/inet.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'usr.bin/netstat') 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 #include #include #include +#include #include #include @@ -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"); } /* -- cgit v1.1