From: Ben Greear <greearb@xxxxxxxxxxxxxxx> Allow doing X bss_transition_mgmt_query calls before falling back to scan. Example format to do 4 btm before attempting a scan: bgscan="simple:30:-65:300:4" Signed-off-by: Ben Greear <greearb@xxxxxxxxxxxxxxx> --- wpa_supplicant/bgscan_simple.c | 28 ++++++++++++++++++++++++++++ wpa_supplicant/wpa_supplicant.conf | 5 +++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/wpa_supplicant/bgscan_simple.c b/wpa_supplicant/bgscan_simple.c index 320ba92f5..51517ba0d 100644 --- a/wpa_supplicant/bgscan_simple.c +++ b/wpa_supplicant/bgscan_simple.c @@ -16,10 +16,14 @@ #include "driver_i.h" #include "scan.h" #include "bgscan.h" +#include "config.h" +#include "wnm_sta.h" struct bgscan_simple_data { struct wpa_supplicant *wpa_s; const struct wpa_ssid *ssid; + int use_wnm_query; + unsigned int scan_action_count; int scan_interval; int signal_threshold; int short_scan_count; /* counter for scans using short scan interval */ @@ -36,6 +40,22 @@ static void bgscan_simple_timeout(void *eloop_ctx, void *timeout_ctx) struct wpa_supplicant *wpa_s = data->wpa_s; struct wpa_driver_scan_params params; + if (data->use_wnm_query && !wpa_s->conf->disable_btm) { + int mod; + + /* try wnm x times, scan on x + 1 */ + data->scan_action_count++; + mod = data->scan_action_count % (data->use_wnm_query + 1); + if (mod < data->use_wnm_query) { + wpa_printf(MSG_DEBUG, "bgscan simple: Send bss transition mgt query %d/%d", + mod, data->use_wnm_query); + if (wnm_send_bss_transition_mgmt_query(wpa_s, 6 /* better AP found */, NULL, 0)) + wpa_printf(MSG_DEBUG, "bgscan simple: Failed send bss transition mgt query"); + else + goto scan_ok; + } + } + os_memset(¶ms, 0, sizeof(params)); params.num_ssids = 1; params.ssids[0].ssid = data->ssid->ssid; @@ -58,6 +78,7 @@ static void bgscan_simple_timeout(void *eloop_ctx, void *timeout_ctx) eloop_register_timeout(data->scan_interval, 0, bgscan_simple_timeout, data, NULL); } else { + scan_ok: if (data->scan_interval == data->short_interval) { data->short_scan_count++; if (data->short_scan_count >= data->max_short_scans) { @@ -84,6 +105,8 @@ static int bgscan_simple_get_params(struct bgscan_simple_data *data, { const char *pos; + data->use_wnm_query = 0; + data->short_interval = atoi(params); pos = os_strchr(params, ':'); @@ -99,6 +122,11 @@ static int bgscan_simple_get_params(struct bgscan_simple_data *data, } pos++; data->long_interval = atoi(pos); + pos = os_strchr(pos, ':'); + if (pos) { + pos++; + data->use_wnm_query = atoi(pos); + } return 0; } diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf index 29d6f6e7a..5e41139e0 100644 --- a/wpa_supplicant/wpa_supplicant.conf +++ b/wpa_supplicant/wpa_supplicant.conf @@ -1024,9 +1024,10 @@ fast_reauth=1 # parameter uses following format: "<bgscan module name>:<module parameters>" # Following bgscan modules are available: # simple - Periodic background scans based on signal strength +# send_wnm_query > 0 means do this many wnm queries before attempting a scan. # bgscan="simple:<short bgscan interval in seconds>:<signal strength threshold>: -# <long interval>" -# bgscan="simple:30:-45:300" +# <long interval>:<send_wnm_query>" +# bgscan="simple:30:-45:300:3" # learn - Learn channels used by the network and try to avoid bgscans on other # channels (experimental) # bgscan="learn:<short bgscan interval in seconds>:<signal strength threshold>: -- 2.40.1 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap