The nl80211 wiphy may support KHz scan frequencies. Use the new NL80211_ATTR_SCAN_FREQ_KHZ if available in case the configured scan list requires it. Signed-off-by: Thomas Pedersen <thomas@xxxxxxxxxxxx> --- src/drivers/driver.h | 1 + src/drivers/driver_nl80211_capa.c | 3 +++ src/drivers/driver_nl80211_event.c | 33 ++++++++++++++++++++++++------ src/drivers/driver_nl80211_scan.c | 16 ++++++++++++++- 4 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 4627c8b95e9a..f135accae1ec 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -1933,6 +1933,7 @@ struct wpa_driver_capa { /** Driver supports a separate control port RX for EAPOL frames */ #define WPA_DRIVER_FLAGS2_CONTROL_PORT_RX 0x0000000000000001ULL +#define WPA_DRIVER_FLAGS2_SCAN_FREQ_KHZ 0x0000000000000002ULL u64 flags2; #define FULL_AP_CLIENT_STATE_SUPP(drv_flags) \ diff --git a/src/drivers/driver_nl80211_capa.c b/src/drivers/driver_nl80211_capa.c index f84a9988623d..408a6e9ce196 100644 --- a/src/drivers/driver_nl80211_capa.c +++ b/src/drivers/driver_nl80211_capa.c @@ -639,6 +639,9 @@ static void wiphy_info_ext_feature_flags(struct wiphy_info_data *info, if (ext_feature_isset(ext_features, len, NL80211_EXT_FEATURE_MULTICAST_REGISTRATIONS)) info->drv->multicast_registrations = 1; + if (ext_feature_isset(ext_features, len, + NL80211_EXT_FEATURE_SCAN_FREQ_KHZ)) + capa->flags2 |= WPA_DRIVER_FLAGS2_SCAN_FREQ_KHZ; } diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c index e02533fe8107..def78937b5a7 100644 --- a/src/drivers/driver_nl80211_event.c +++ b/src/drivers/driver_nl80211_event.c @@ -1180,7 +1180,10 @@ static void send_scan_event(struct wpa_driver_nl80211_data *drv, int aborted, struct scan_info *info; #define MAX_REPORT_FREQS 50 int freqs[MAX_REPORT_FREQS]; + char msg[300], *pos, *end; int num_freqs = 0; + int res; + if (!external_scan && drv->scan_for_auth) { drv->scan_for_auth = 0; @@ -1209,19 +1212,37 @@ static void send_scan_event(struct wpa_driver_nl80211_data *drv, int aborted, break; } } - if (tb[NL80211_ATTR_SCAN_FREQUENCIES]) { - char msg[300], *pos, *end; - int res; + if (tb[NL80211_ATTR_SCAN_FREQ_KHZ]) { pos = msg; end = pos + sizeof(msg); *pos = '\0'; - nla_for_each_nested(nl, tb[NL80211_ATTR_SCAN_FREQUENCIES], rem) + nla_for_each_nested(nl, tb[NL80211_ATTR_SCAN_FREQ_KHZ], rem) { freqs[num_freqs] = nla_get_u32(nl); - res = os_snprintf(pos, end - pos, " %d", - freqs[num_freqs]); + res = os_snprintf(pos, end - pos, " %g", + PR_KHZ(freqs[num_freqs])); + if (!os_snprintf_error(end - pos, res)) + pos += res; + num_freqs++; + if (num_freqs == MAX_REPORT_FREQS - 1) + break; + } + info->freqs = freqs; + info->num_freqs = num_freqs; + wpa_printf(MSG_DEBUG, "nl80211: Scan included frequencies:%s", + msg); + } else if (tb[NL80211_ATTR_SCAN_FREQUENCIES]) { + pos = msg; + end = pos + sizeof(msg); + *pos = '\0'; + + nla_for_each_nested(nl, tb[NL80211_ATTR_SCAN_FREQUENCIES], rem) + { + freqs[num_freqs] = KHZ(nla_get_u32(nl)); + res = os_snprintf(pos, end - pos, " %g", + PR_KHZ(freqs[num_freqs])); if (!os_snprintf_error(end - pos, res)) pos += res; num_freqs++; diff --git a/src/drivers/driver_nl80211_scan.c b/src/drivers/driver_nl80211_scan.c index fad5234b7c6b..9386cc3f5201 100644 --- a/src/drivers/driver_nl80211_scan.c +++ b/src/drivers/driver_nl80211_scan.c @@ -214,7 +214,21 @@ nl80211_scan_common(struct i802_bss *bss, u8 cmd, goto fail; } - if (params->freqs) { + if (params->freqs && + drv->capa.flags2 & WPA_DRIVER_FLAGS2_SCAN_FREQ_KHZ) { + struct nlattr *freqs; + freqs = nla_nest_start(msg, NL80211_ATTR_SCAN_FREQ_KHZ); + if (freqs == NULL) + goto fail; + for (i = 0; params->freqs[i]; i++) { + wpa_printf(MSG_MSGDUMP, "nl80211: Scan frequency %g " + "MHz", PR_KHZ(params->freqs[i])); + if (nla_put_u32(msg, i + 1, params->freqs[i])) + goto fail; + } + nla_nest_end(msg, freqs); + scan_flags |= NL80211_SCAN_FLAG_FREQ_KHZ; + } else if (params->freqs) { struct nlattr *freqs; freqs = nla_nest_start(msg, NL80211_ATTR_SCAN_FREQUENCIES); if (freqs == NULL) -- 2.20.1 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap