summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat/mroute6.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/netstat/mroute6.c')
-rw-r--r--usr.bin/netstat/mroute6.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/usr.bin/netstat/mroute6.c b/usr.bin/netstat/mroute6.c
index c526d7c..ac31f5e 100644
--- a/usr.bin/netstat/mroute6.c
+++ b/usr.bin/netstat/mroute6.c
@@ -85,6 +85,7 @@ __FBSDID("$FreeBSD$");
#include <netinet/in.h>
#include <err.h>
+#include <nlist.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -95,17 +96,32 @@ __FBSDID("$FreeBSD$");
#include "netstat.h"
+/*
+ * kvm(3) bindings for every needed symbol
+ */
+static struct nlist mrl[] = {
+#define N_MF6CTABLE 0
+ { .n_name = "_mf6ctable" },
+#define N_MIF6TABLE 1
+ { .n_name = "_mif6table" },
+#define N_MRT6STAT 2
+ { .n_name = "_mrt6stat" },
+ { .n_name = NULL },
+};
+
+
#define WID_ORG (Wflag ? 39 : (numeric_addr ? 29 : 18)) /* width of origin column */
#define WID_GRP (Wflag ? 18 : (numeric_addr ? 16 : 18)) /* width of group column */
void
-mroute6pr(u_long mfcaddr, u_long mifaddr)
+mroute6pr()
{
struct mf6c *mf6ctable[MF6CTBLSIZ], *mfcp;
struct mif6 mif6table[MAXMIFS];
struct mf6c mfc;
struct rtdetq rte, *rtep;
struct mif6 *mifp;
+ u_long mfcaddr, mifaddr;
mifi_t mifi;
int i;
int banner_printed;
@@ -114,6 +130,15 @@ mroute6pr(u_long mfcaddr, u_long mifaddr)
long int waitings;
size_t len;
+ kresolve_list(mrl);
+ mfcaddr = mrl[N_MF6CTABLE].n_value;
+ mifaddr = mrl[N_MIF6TABLE].n_value;
+
+ if (mfcaddr == 0 || mifaddr == 0) {
+ fprintf(stderr, "No IPv6 MROUTING kernel support.\n");
+ return;
+ }
+
len = sizeof(mif6table);
if (live) {
if (sysctlbyname("net.inet6.ip6.mif6table", mif6table, &len,
@@ -217,11 +242,20 @@ mroute6pr(u_long mfcaddr, u_long mifaddr)
}
void
-mrt6_stats(u_long mstaddr)
+mrt6_stats()
{
struct mrt6stat mrtstat;
+ u_long mstaddr;
size_t len = sizeof mrtstat;
+ kresolve_list(mrl);
+ mstaddr = mrl[N_MRT6STAT].n_value;
+
+ if (mstaddr == 0) {
+ fprintf(stderr, "No IPv6 MROUTING kernel support.\n");
+ return;
+ }
+
if (live) {
if (sysctlbyname("net.inet6.ip6.mrt6stat", &mrtstat, &len,
NULL, 0) < 0) {
OpenPOWER on IntegriCloud