summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat/inet.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/netstat/inet.c')
-rw-r--r--usr.bin/netstat/inet.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index d608e1a..55994a1 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -58,6 +58,7 @@ static const char rcsid[] =
#include <netinet/icmp_var.h>
#include <netinet/igmp_var.h>
#include <netinet/ip_var.h>
+#include <netinet/pim_var.h>
#include <netinet/tcp.h>
#include <netinet/tcpip.h>
#include <netinet/tcp_seq.h>
@@ -706,6 +707,44 @@ igmp_stats(u_long off __unused, const char *name, int af1 __unused)
}
/*
+ * Dump PIM statistics structure.
+ */
+void
+pim_stats(u_long off __unused, const char *name, int af1 __unused)
+{
+ struct pimstat pimstat, zerostat;
+ size_t len = sizeof pimstat;
+
+ if (zflag)
+ memset(&zerostat, 0, len);
+ if (sysctlbyname("net.inet.pim.stats", &pimstat, &len,
+ zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
+ warn("sysctl: net.inet.pim.stats");
+ return;
+ }
+
+ printf("%s:\n", name);
+
+#define p(f, m) if (pimstat.f || sflag <= 1) \
+ printf(m, pimstat.f, plural(pimstat.f))
+#define py(f, m) if (pimstat.f || sflag <= 1) \
+ printf(m, pimstat.f, pimstat.f != 1 ? "ies" : "y")
+ p(pims_rcv_total_msgs, "\t%llu message%s received\n");
+ p(pims_rcv_total_bytes, "\t%llu byte%s received\n");
+ p(pims_rcv_tooshort, "\t%llu message%s received with too few bytes\n");
+ p(pims_rcv_badsum, "\t%llu message%s received with bad checksum\n");
+ p(pims_rcv_badversion, "\t%llu message%s received with bad version\n");
+ p(pims_rcv_registers_msgs, "\t%llu data register message%s received\n");
+ p(pims_rcv_registers_bytes, "\t%llu data register byte%s received\n");
+ p(pims_rcv_registers_wrongiif, "\t%llu data register message%s received on wrong iif\n");
+ p(pims_rcv_badregisters, "\t%llu bad register%s received\n");
+ p(pims_snd_registers_msgs, "\t%llu data register message%s sent\n");
+ p(pims_snd_registers_bytes, "\t%llu data register byte%s sent\n");
+#undef p
+#undef py
+}
+
+/*
* Pretty print an Internet address (net address + port).
*/
void
OpenPOWER on IntegriCloud