+ kread(off, (char *)&ipstat, sizeof (ipstat));
+ printf("%s:\n", name);
+
+#define p(f, m) if (ipstat.f || sflag <= 1) \
+ printf(m, ipstat.f, plural(ipstat.f))
+
+ p(ips_total, "\t%u total packet%s received\n");
+ p(ips_badsum, "\t%u bad header checksum%s\n");
+ p(ips_tooshort, "\t%u with size smaller than minimum\n");
+ p(ips_toosmall, "\t%u with data size < data length\n");
+ p(ips_badhlen, "\t%u with header length < data size\n");
+ p(ips_badlen, "\t%u with data length < header length\n");
+ p(ips_badoptions, "\t%u with bad options\n");
+ p(ips_badvers, "\t%u with incorrect version number\n");
+ p(ips_fragments, "\t%u fragment%s received\n");
+ p(ips_fragdropped, "\t%u fragment%s dropped (dup or out of space)\n");
+ p(ips_fragtimeout, "\t%u fragment%s dropped after timeout\n");
+ p(ips_reassembled, "\t%u packet%s reassembled ok\n");
+ p(ips_delivered, "\t%u packet%s for this host\n");
+ p(ips_noproto, "\t%u packet%s for unknown/unsupported protocol\n");
+ p(ips_forward, "\t%u packet%s forwarded\n");
+ p(ips_cantforward, "\t%u packet%s not forwardable\n");
+ p(ips_redirectsent, "\t%u redirect%s sent\n");
+ p(ips_localout, "\t%u packet%s sent from this host\n");
+ p(ips_rawout, "\t%u packet%s sent with fabricated ip header\n");
+ p(ips_odropped, "\t%u output packet%s dropped due to no bufs, etc.\n");
+ p(ips_noroute, "\t%u output packet%s discarded due to no route\n");
+ p(ips_fragmented, "\t%u output datagram%s fragmented\n");
+ p(ips_ofragments, "\t%u fragment%s created\n");
+ p(ips_cantfrag, "\t%u datagram%s that can't be fragmented\n");
+#undef p
+#endif
+}
+
+static char *icmpnames[] = {
+ "echo reply",
+ "#1",
+ "#2",
+ "destination unreachable",
+ "source quench",
+ "routing redirect",
+ "#6",
+ "#7",
+ "echo",
+ "#9",
+ "#10",
+ "time exceeded",
+ "parameter problem",
+ "time stamp",
+ "time stamp reply",
+ "information request",
+ "information request reply",
+ "address mask request",
+ "address mask reply",
+};
+
+/*
+ * Dump ICMP statistics.
+ */
+void
+icmp_stats(off, name)
+ u_long off;
+ char *name;
+{
+ struct icmpstat icmpstat;
+ register int i, first;
+
+ if (off == 0)
+ return;
+ kread(off, (char *)&icmpstat, sizeof (icmpstat));
+ printf("%s:\n", name);
+
+#define p(f, m) if (icmpstat.f || sflag <= 1) \
+ printf(m, icmpstat.f, plural(icmpstat.f))
+
+ p(icps_error, "\t%u call%s to icmp_error\n");
+ p(icps_oldicmp,
+ "\t%u error%s not generated 'cuz old message was icmp\n");
+ for (first = 1, i = 0; i < ICMP_MAXTYPE + 1; i++)
+ if (icmpstat.icps_outhist[i] != 0) {
+ if (first) {
+ printf("\tOutput histogram:\n");
+ first = 0;
+ }
+ printf("\t\t%s: %u\n", icmpnames[i],
+ icmpstat.icps_outhist[i]);
+ }
+ p(icps_badcode, "\t%u message%s with bad code fields\n");
+ p(icps_tooshort, "\t%u message%s < minimum length\n");
+ p(icps_checksum, "\t%u bad checksum%s\n");
+ p(icps_badlen, "\t%u message%s with bad length\n");
+ for (first = 1, i = 0; i < ICMP_MAXTYPE + 1; i++)
+ if (icmpstat.icps_inhist[i] != 0) {
+ if (first) {
+ printf("\tInput histogram:\n");
+ first = 0;
+ }
+ printf("\t\t%s: %u\n", icmpnames[i],
+ icmpstat.icps_inhist[i]);
+ }
+ p(icps_reflect, "\t%u message response%s generated\n");
+#undef p
+}
+
+/*
+ * Dump IGMP statistics structure.
+ */
+void
+igmp_stats(off, name)
+ u_long off;
+ char *name;
+{
+ struct igmpstat igmpstat;
+
+ if (off == 0)
+ return;
+ kread(off, (char *)&igmpstat, sizeof (igmpstat));
+ printf("%s:\n", name);
+
+#define p(f, m) if (igmpstat.f || sflag <= 1) \
+ printf(m, igmpstat.f, plural(igmpstat.f))
+#define py(f, m) if (igmpstat.f || sflag <= 1) \
+ printf(m, igmpstat.f, igmpstat.f != 1 ? "ies" : "y")
+ p(igps_rcv_total, "\t%u message%s received\n");
+ p(igps_rcv_tooshort, "\t%u message%s received with too few bytes\n");
+ p(igps_rcv_badsum, "\t%u message%s received with bad checksum\n");
+ py(igps_rcv_queries, "\t%u membership quer%s received\n");
+ py(igps_rcv_badqueries, "\t%u membership quer%s received with invalid field(s)\n");
+ p(igps_rcv_reports, "\t%u membership report%s received\n");
+ p(igps_rcv_badreports, "\t%u membership report%s received with invalid field(s)\n");
+ p(igps_rcv_ourreports, "\t%u membership report%s received for groups to which we belong\n");
+ p(igps_snd_reports, "\t%u membership report%s sent\n");
+#undef p
+#undef py