o fix identification of ahdemo mode
o split out code to get the bssid for use in the future o include more information in error diags when unable to collect sta info/stats
This commit is contained in:
parent
30a4e0680d
commit
1e9ec798a1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=188187
@ -390,9 +390,12 @@ wlan_getopmode(struct wlanstatfoo *wf0)
|
|||||||
strlcpy(ifmr.ifm_name, wf->ifr.ifr_name, sizeof(ifmr.ifm_name));
|
strlcpy(ifmr.ifm_name, wf->ifr.ifr_name, sizeof(ifmr.ifm_name));
|
||||||
if (ioctl(wf->s, SIOCGIFMEDIA, &ifmr) < 0)
|
if (ioctl(wf->s, SIOCGIFMEDIA, &ifmr) < 0)
|
||||||
err(1, "%s (SIOCGIFMEDIA)", wf->ifr.ifr_name);
|
err(1, "%s (SIOCGIFMEDIA)", wf->ifr.ifr_name);
|
||||||
if (ifmr.ifm_current & IFM_IEEE80211_ADHOC)
|
if (ifmr.ifm_current & IFM_IEEE80211_ADHOC) {
|
||||||
wf->opmode = IEEE80211_M_IBSS; /* XXX ahdemo */
|
if (ifmr.ifm_current & IFM_FLAG0)
|
||||||
else if (ifmr.ifm_current & IFM_IEEE80211_HOSTAP)
|
wf->opmode = IEEE80211_M_AHDEMO;
|
||||||
|
else
|
||||||
|
wf->opmode = IEEE80211_M_IBSS;
|
||||||
|
} else if (ifmr.ifm_current & IFM_IEEE80211_HOSTAP)
|
||||||
wf->opmode = IEEE80211_M_HOSTAP;
|
wf->opmode = IEEE80211_M_HOSTAP;
|
||||||
else if (ifmr.ifm_current & IFM_IEEE80211_MONITOR)
|
else if (ifmr.ifm_current & IFM_IEEE80211_MONITOR)
|
||||||
wf->opmode = IEEE80211_M_MONITOR;
|
wf->opmode = IEEE80211_M_MONITOR;
|
||||||
@ -422,6 +425,15 @@ getlladdr(struct wlanstatfoo_p *wf)
|
|||||||
freeifaddrs(ifp);
|
freeifaddrs(ifp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
getbssid(struct wlanstatfoo_p *wf)
|
||||||
|
{
|
||||||
|
wf->ireq.i_type = IEEE80211_IOC_BSSID;
|
||||||
|
wf->ireq.i_data = wf->mac;
|
||||||
|
wf->ireq.i_len = IEEE80211_ADDR_LEN;
|
||||||
|
return ioctl(wf->s, SIOCG80211, &wf->ireq);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wlan_setstamac(struct wlanstatfoo *wf0, const uint8_t *mac)
|
wlan_setstamac(struct wlanstatfoo *wf0, const uint8_t *mac)
|
||||||
{
|
{
|
||||||
@ -436,11 +448,9 @@ wlan_setstamac(struct wlanstatfoo *wf0, const uint8_t *mac)
|
|||||||
getlladdr(wf);
|
getlladdr(wf);
|
||||||
break;
|
break;
|
||||||
case IEEE80211_M_STA:
|
case IEEE80211_M_STA:
|
||||||
wf->ireq.i_type = IEEE80211_IOC_BSSID;
|
if (getbssid(wf) < 0)
|
||||||
wf->ireq.i_data = wf->mac;
|
err(1, "%s (IEEE80211_IOC_BSSID)",
|
||||||
wf->ireq.i_len = IEEE80211_ADDR_LEN;
|
wf->ireq.i_name);
|
||||||
if (ioctl(wf->s, SIOCG80211, &wf->ireq) <0)
|
|
||||||
err(1, "%s (IEEE80211_IOC_BSSID)", wf->ireq.i_name);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@ -457,15 +467,18 @@ wlan_collect(struct wlanstatfoo_p *wf,
|
|||||||
wf->ireq.i_type = IEEE80211_IOC_STA_INFO;
|
wf->ireq.i_type = IEEE80211_IOC_STA_INFO;
|
||||||
wf->ireq.i_data = (caddr_t) &wf->u_info;
|
wf->ireq.i_data = (caddr_t) &wf->u_info;
|
||||||
wf->ireq.i_len = sizeof(wf->u_info);
|
wf->ireq.i_len = sizeof(wf->u_info);
|
||||||
if (ioctl(wf->s, SIOCG80211, &wf->ireq) < 0)
|
if (ioctl(wf->s, SIOCG80211, &wf->ireq) < 0) {
|
||||||
warn("%s (IEEE80211_IOC_STA_INFO)", wf->ireq.i_name);
|
warn("%s:%s (IEEE80211_IOC_STA_INFO)", wf->ireq.i_name,
|
||||||
|
ether_ntoa((const struct ether_addr*) wf->mac));
|
||||||
|
}
|
||||||
|
|
||||||
IEEE80211_ADDR_COPY(nstats->is_u.macaddr, wf->mac);
|
IEEE80211_ADDR_COPY(nstats->is_u.macaddr, wf->mac);
|
||||||
wf->ireq.i_type = IEEE80211_IOC_STA_STATS;
|
wf->ireq.i_type = IEEE80211_IOC_STA_STATS;
|
||||||
wf->ireq.i_data = (caddr_t) nstats;
|
wf->ireq.i_data = (caddr_t) nstats;
|
||||||
wf->ireq.i_len = sizeof(*nstats);
|
wf->ireq.i_len = sizeof(*nstats);
|
||||||
if (ioctl(wf->s, SIOCG80211, &wf->ireq) < 0)
|
if (ioctl(wf->s, SIOCG80211, &wf->ireq) < 0)
|
||||||
warn("%s (IEEE80211_IOC_STA_STATS)", wf->ireq.i_name);
|
warn("%s:%s (IEEE80211_IOC_STA_STATS)", wf->ireq.i_name,
|
||||||
|
ether_ntoa((const struct ether_addr*) wf->mac));
|
||||||
|
|
||||||
wf->ifr.ifr_data = (caddr_t) stats;
|
wf->ifr.ifr_data = (caddr_t) stats;
|
||||||
if (ioctl(wf->s, SIOCG80211STATS, &wf->ifr) < 0)
|
if (ioctl(wf->s, SIOCG80211STATS, &wf->ifr) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user