From owner-svn-src-head@FreeBSD.ORG Fri Mar 7 17:47:54 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 40DE6FAD; Fri, 7 Mar 2014 17:47:54 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 2D6C2AE2; Fri, 7 Mar 2014 17:47:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s27HlsYX065337; Fri, 7 Mar 2014 17:47:54 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s27HlsJ2065336; Fri, 7 Mar 2014 17:47:54 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201403071747.s27HlsJ2065336@svn.freebsd.org> From: Eitan Adler Date: Fri, 7 Mar 2014 17:47:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262893 - head/tools/tools/iwn/iwnstats X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Mar 2014 17:47:54 -0000 Author: eadler Date: Fri Mar 7 17:47:53 2014 New Revision: 262893 URL: http://svnweb.freebsd.org/changeset/base/262893 Log: wlanstats: Add some logic to translate from a vap to its parent device. This isn't entirely correct (as the device may not necc. be called wlan*) but this will be further worked into a combined ath, iwn, wlan, etc. tool. Discussed with: jhb, adrian Modified: head/tools/tools/iwn/iwnstats/main.c Modified: head/tools/tools/iwn/iwnstats/main.c ============================================================================== --- head/tools/tools/iwn/iwnstats/main.c Fri Mar 7 16:43:08 2014 (r262892) +++ head/tools/tools/iwn/iwnstats/main.c Fri Mar 7 17:47:53 2014 (r262893) @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include "net80211/ieee80211_ioctl.h" #include "net80211/ieee80211_radiotap.h" @@ -269,6 +271,9 @@ main(int argc, char *argv[]) int ch; char *ifname; bool first; + char *sysctlname; + size_t len; + int ret; ifname = strdup(IWN_DEFAULT_IF); @@ -280,6 +285,19 @@ main(int argc, char *argv[]) if (ifname) free(ifname); ifname = strdup(optarg); + if (strncmp(ifname, "wlan", 4) == 0) { + free(ifname); + len = 0; + asprintf(&sysctlname, "net.wlan.%s.%%parent", ifname + 4); + ret = sysctlbyname(sysctlname, NULL, &len, NULL, 0); + if (ret != 0) + err(1, "sysctl failed"); + ifname = calloc(len, 1); + ret = sysctlbyname(sysctlname, ifname, &len, NULL, 0); + if (ret != 0) + err(1, "sysctl failed"); + free(sysctlname); + } break; default: case '?':