summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat/mroute.c
diff options
context:
space:
mode:
authorhsu <hsu@FreeBSD.org>2003-08-05 17:07:04 +0000
committerhsu <hsu@FreeBSD.org>2003-08-05 17:07:04 +0000
commit6d661f854b2cdb10870e75d98ba6764321ce173d (patch)
tree7dcd8e6436a452046b16134f5b4deb5bc4198e5d /usr.bin/netstat/mroute.c
parente3e094a1f909528238a5b880910cff77d28146b9 (diff)
downloadFreeBSD-src-6d661f854b2cdb10870e75d98ba6764321ce173d.zip
FreeBSD-src-6d661f854b2cdb10870e75d98ba6764321ce173d.tar.gz
* Use sysctlbyname(3) to print statistics about the MFC and
multicast VIF tables. This change is needed for consistency with the rest of the netstat/mroute.c implementation, and because in some cases "netstat -g" may fail to report the multicast forwarding information (e.g., if we run a multicast router on PicoBSD). * Remove "DVMRP" from the head comment of file netstat/mroute.c, because the printed multicast-related statistics are not DVMRP-specific anymore. Submitted by: Pavlin Radoslavov <pavlin@icir.org>
Diffstat (limited to 'usr.bin/netstat/mroute.c')
-rw-r--r--usr.bin/netstat/mroute.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/usr.bin/netstat/mroute.c b/usr.bin/netstat/mroute.c
index 3c42f45..398e115 100644
--- a/usr.bin/netstat/mroute.c
+++ b/usr.bin/netstat/mroute.c
@@ -43,7 +43,7 @@ static const char rcsid[] =
#endif /* not lint */
/*
- * Print DVMRP multicast routing structures and statistics.
+ * Print multicast routing structures and statistics.
*
* MROUTING 1.0
*/
@@ -80,16 +80,35 @@ mroutepr(u_long mfcaddr, u_long vifaddr)
int banner_printed;
int saved_numeric_addr;
vifi_t maxvif = 0;
+ size_t len;
- if (mfcaddr == 0 || vifaddr == 0) {
- printf("No IPv4 multicast routing compiled into this system.\n");
- return;
+ len = sizeof(mfctable);
+ if (sysctlbyname("net.inet.ip.mfctable", mfctable, &len, NULL, 0) < 0) {
+ warn("sysctl: net.inet.ip.mfctable");
+ /* Compatability with older kernels - candidate for removal */
+ if (mfcaddr == 0) {
+ printf("No IPv4 multicast routing compiled into this system.\n");
+ return;
+ }
+
+ kread(mfcaddr, (char *)mfctable, sizeof(mfctable));
+ }
+
+ len = sizeof(viftable);
+ if (sysctlbyname("net.inet.ip.viftable", viftable, &len, NULL, 0) < 0) {
+ warn("sysctl: net.inet.ip.viftable");
+ /* Compatability with older kernels - candidate for removal */
+ if (vifaddr == 0) {
+ printf("No IPv4 multicast routing compiled into this system.\n");
+ return;
+ }
+
+ kread(vifaddr, (char *)viftable, sizeof(viftable));
}
saved_numeric_addr = numeric_addr;
numeric_addr = 1;
- kread(vifaddr, (char *)&viftable, sizeof(viftable));
banner_printed = 0;
for (vifi = 0, v = viftable; vifi < MAXVIFS; ++vifi, ++v) {
if (v->v_lcl_addr.s_addr == 0)
@@ -115,7 +134,6 @@ mroutepr(u_long mfcaddr, u_long vifaddr)
if (!banner_printed)
printf("\nVirtual Interface Table is empty\n");
- kread(mfcaddr, (char *)&mfctable, sizeof(mfctable));
banner_printed = 0;
for (i = 0; i < MFCTBLSIZ; ++i) {
m = mfctable[i];
OpenPOWER on IntegriCloud