PERFORCE change 166804 for review
Gabor Pali
pgj at FreeBSD.org
Thu Jul 30 16:59:55 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=166804
Change 166804 by pgj at petymeg-current on 2009/07/30 16:59:27
Integrate libnetstatified support for PIM6 stats into netstat(1).
Affected files ...
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/extern.h#21 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/inet6.c#4 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#29 edit
Differences ...
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/extern.h#21 (text+ko) ====
@@ -98,7 +98,7 @@
void ip6_ifstats(char *);
void icmp6_stats(const struct stat_type *);
void icmp6_ifstats(char *);
-void pim6_stats(u_long, const char *, int, int);
+void pim6_stats(const struct stat_type *);
void rip6_stats(u_long, const char *, int, int);
void mroute6pr(u_long, u_long);
void mrt6_stats(u_long);
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/inet6.c#4 (text+ko) ====
@@ -721,37 +721,20 @@
* Dump PIM statistics structure.
*/
void
-pim6_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
+pim6_stats(const struct stat_type *sttp)
{
- struct pim6stat pim6stat, zerostat;
- size_t len = sizeof pim6stat;
+ const struct pim6_stat *s;
- if (live) {
- if (zflag)
- memset(&zerostat, 0, len);
- if (sysctlbyname("net.inet6.pim.stats", &pim6stat, &len,
- zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
- if (errno != ENOENT)
- warn("sysctl: net.inet6.pim.stats");
- return;
- }
- } else {
- if (off == 0)
- return;
- kread(off, &pim6stat, len);
- }
-
- printf("%s:\n", name);
-
-#define p(f, m) if (pim6stat.f || sflag <= 1) \
- printf(m, (uintmax_t)pim6stat.f, plural(pim6stat.f))
- p(pim6s_rcv_total, "\t%ju message%s received\n");
- p(pim6s_rcv_tooshort, "\t%ju message%s received with too few bytes\n");
- p(pim6s_rcv_badsum, "\t%ju message%s received with bad checksum\n");
- p(pim6s_rcv_badversion, "\t%ju message%s received with bad version\n");
- p(pim6s_rcv_registers, "\t%ju register%s received\n");
- p(pim6s_rcv_badregisters, "\t%ju bad register%s received\n");
- p(pim6s_snd_registers, "\t%ju register%s sent\n");
+ s = netstat_get_pim6stats(sttp);
+#define p(f, m) if (netstat_pim6s_get_##f(s) || sflag <= 1) \
+ printf(m, netstat_pim6s_get_##f(s), plural(netstat_pim6s_get_##f(s)))
+ p(rcv_total, "\t%ju message%s received\n");
+ p(rcv_tooshort, "\t%ju message%s received with too few bytes\n");
+ p(rcv_badsum, "\t%ju message%s received with bad checksum\n");
+ p(rcv_badversion, "\t%ju message%s received with bad version\n");
+ p(rcv_registers, "\t%ju register%s received\n");
+ p(rcv_badregisters, "\t%ju bad register%s received\n");
+ p(snd_registers, "\t%ju register%s sent\n");
#undef p
}
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#29 (text+ko) ====
@@ -103,29 +103,27 @@
{ .n_name = "_ipsec4stat" },
#define N_IPSEC6STAT 12
{ .n_name = "_ipsec6stat" },
-#define N_PIM6STAT 13
- { .n_name = "_pim6stat" },
-#define N_MRT6STAT 14
+#define N_MRT6STAT 13
{ .n_name = "_mrt6stat" },
-#define N_MF6CTABLE 15
+#define N_MF6CTABLE 14
{ .n_name = "_mf6ctable" },
-#define N_MIF6TABLE 16
+#define N_MIF6TABLE 15
{ .n_name = "_mif6table" },
-#define N_PFKEYSTAT 17
+#define N_PFKEYSTAT 16
{ .n_name = "_pfkeystat" },
-#define N_RTTRASH 18
+#define N_RTTRASH 17
{ .n_name = "_rttrash" },
-#define N_PFSYNCSTAT 19
+#define N_PFSYNCSTAT 18
{ .n_name = "_pfsyncstats" },
-#define N_AHSTAT 20
+#define N_AHSTAT 19
{ .n_name = "_ahstat" },
-#define N_ESPSTAT 21
+#define N_ESPSTAT 20
{ .n_name = "_espstat" },
-#define N_IPCOMPSTAT 22
+#define N_IPCOMPSTAT 21
{ .n_name = "_ipcompstat" },
-#define N_RIP6STAT 23
+#define N_RIP6STAT 22
{ .n_name = "_rip6stat" },
-#define N_MFCTABLESIZE 24
+#define N_MFCTABLESIZE 23
{ .n_name = "_mfctablesize" },
{ .n_name = NULL },
};
@@ -196,8 +194,8 @@
ipsec_stats, NULL, "ipsec6", 0, 0 },
#endif
#ifdef notyet
- { -1, N_PIM6STAT, 1, NULL, NULL, stat_MAX,
- pim6_stats, NULL, "pim6", 1, 0 },
+ { -1, 0, 1, NULL, pim6_stats, stat_PIM6,
+ NULL, NULL, "pim6", 1, 0 },
#endif
{ -1, N_RIP6STAT, 1, NULL, NULL, stat_MAX,
rip6_stats, NULL, "rip6", 1, 0 },
More information about the p4-projects
mailing list