Changeset View
Changeset View
Standalone View
Standalone View
tools/tools/iwn/iwnstats/main.c
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
#include "net80211/ieee80211_ioctl.h" | #include "net80211/ieee80211_ioctl.h" | ||||
#include "net80211/ieee80211_radiotap.h" | #include "net80211/ieee80211_radiotap.h" | ||||
#include "if_iwn_ioctl.h" | #include "if_iwn_ioctl.h" | ||||
#include "if_iwnreg.h" | #include "if_iwnreg.h" | ||||
#include "iwnstats.h" | #include "iwnstats.h" | ||||
#include "iwn_ioctl.h" | #include "iwn_ioctl.h" | ||||
#define IWN_DEFAULT_IF "iwn0" | #define IWN_DEFAULT_IF "wlan0" | ||||
static struct iwnstats * | static struct iwnstats * | ||||
iwnstats_new(const char *ifname) | iwnstats_new(const char *ifname) | ||||
{ | { | ||||
struct iwnstats *is; | struct iwnstats *is; | ||||
is = calloc(1, sizeof(struct iwnstats)); | is = calloc(1, sizeof(struct iwnstats)); | ||||
if (is == NULL) | if (is == NULL) | ||||
▲ Show 20 Lines • Show All 223 Lines • ▼ Show 20 Lines | main(int argc, char *argv[]) | ||||
/* Parse command line arguments */ | /* Parse command line arguments */ | ||||
while ((ch = getopt(argc, argv, | while ((ch = getopt(argc, argv, | ||||
"hi:")) != -1) { | "hi:")) != -1) { | ||||
switch (ch) { | switch (ch) { | ||||
case 'i': | case 'i': | ||||
if (ifname) | if (ifname) | ||||
free(ifname); | free(ifname); | ||||
ifname = strdup(optarg); | 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; | break; | ||||
default: | default: | ||||
case '?': | case '?': | ||||
case 'h': | case 'h': | ||||
usage(); | usage(); | ||||
exit(1); | exit(1); | ||||
} | } | ||||
} | } | ||||
Show All 28 Lines |