svn commit: r193703 - projects/mesh11s/sbin/ifconfig
Rui Paulo
rpaulo at FreeBSD.org
Mon Jun 8 11:05:05 UTC 2009
Author: rpaulo
Date: Mon Jun 8 11:05:04 2009
New Revision: 193703
URL: http://svn.freebsd.org/changeset/base/193703
Log:
Add a new ifconfig list command, ifconfig list routes that prints the
HWMP routing table.
Sponsored by: The FreeBSD Foundation
Modified:
projects/mesh11s/sbin/ifconfig/ifieee80211.c
Modified: projects/mesh11s/sbin/ifconfig/ifieee80211.c
==============================================================================
--- projects/mesh11s/sbin/ifconfig/ifieee80211.c Mon Jun 8 10:53:18 2009 (r193702)
+++ projects/mesh11s/sbin/ifconfig/ifieee80211.c Mon Jun 8 11:05:04 2009 (r193703)
@@ -84,6 +84,7 @@
#include <net80211/ieee80211_superg.h>
#include <net80211/ieee80211_tdma.h>
#include <net80211/ieee80211_mesh.h>
+#include <net80211/ieee80211_hwmp.h>
#include <assert.h>
#include <ctype.h>
@@ -3878,6 +3879,42 @@ list_regdomain(int s, int channelsalso)
print_regdomain(®domain, verbose);
}
+static void
+list_routes(int s)
+{
+ int i;
+ struct ieee80211req ireq;
+ struct ieee80211_hwmp_fi routes[100];
+
+ (void) memset(&ireq, 0, sizeof(ireq));
+ (void) strncpy(ireq.i_name, name, sizeof(ireq.i_name));
+ ireq.i_type = IEEE80211_IOC_HWMP_TABLE;
+ ireq.i_data = &routes;
+ ireq.i_len = sizeof(routes);
+ if (ioctl(s, SIOCG80211, &ireq) < 0)
+ err(1, "unable to get HWMP routing table");
+
+ printf("%-17.17s %-17.17s %4s %4s %4s %4s %4s\n"
+ , "DEST"
+ , "NEXT HOP"
+ , "HOPS"
+ , "METRIC"
+ , "LIFETIME"
+ , "SEQ"
+ , "PREQID");
+
+ for (i = 0; i < ireq.i_len / sizeof(*routes); i++) {
+ printf("%s %s %4u %4d %6d %4d %6d\n",
+ ether_ntoa((const struct ether_addr *)
+ routes[i].fi_dest),
+ ether_ntoa((const struct ether_addr *)
+ routes[i].fi_nexthop),
+ routes[i].fi_nhops, routes[i].fi_metric,
+ routes[i].fi_lifetime, routes[i].fi_seq,
+ routes[i].fi_preqid);
+ }
+}
+
static
DECL_CMD_FUNC(set80211list, arg, d)
{
@@ -3913,6 +3950,8 @@ DECL_CMD_FUNC(set80211list, arg, d)
list_countries();
else if (iseq(arg, "mesh"))
list_mesh(s);
+ else if (iseq(arg, "routes"))
+ list_routes(s);
else
errx(1, "Don't know how to list %s for %s", arg, name);
LINE_BREAK();
More information about the svn-src-projects
mailing list