Date: Fri, 7 Mar 2014 17:47:54 +0000 (UTC) From: Eitan Adler <eadler@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262893 - head/tools/tools/iwn/iwnstats Message-ID: <201403071747.s27HlsJ2065336@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <err.h> #include <net/if.h> #include <sys/endian.h> +#include <sys/types.h> +#include <sys/sysctl.h> #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 '?':
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201403071747.s27HlsJ2065336>