From owner-svn-src-projects@FreeBSD.ORG Mon Jun 8 11:05:04 2009 Return-Path: <owner-svn-src-projects@FreeBSD.ORG> Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E36DB106564A; Mon, 8 Jun 2009 11:05:04 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B83498FC1C; Mon, 8 Jun 2009 11:05:04 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n58B54Vq027440; Mon, 8 Jun 2009 11:05:04 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n58B54op027439; Mon, 8 Jun 2009 11:05:04 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <200906081105.n58B54op027439@svn.freebsd.org> From: Rui Paulo <rpaulo@FreeBSD.org> Date: Mon, 8 Jun 2009 11:05:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r193703 - projects/mesh11s/sbin/ifconfig X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" <svn-src-projects.freebsd.org> List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-projects>, <mailto:svn-src-projects-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/svn-src-projects> List-Post: <mailto:svn-src-projects@freebsd.org> List-Help: <mailto:svn-src-projects-request@freebsd.org?subject=help> List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-projects>, <mailto:svn-src-projects-request@freebsd.org?subject=subscribe> X-List-Received-Date: Mon, 08 Jun 2009 11:05:05 -0000 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();