diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index b25e0f673..7a860b660 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -2584,6 +2584,7 @@ struct wpa_config * wpa_config_alloc_empty(const char *ctrl_interface, config->bss_expiration_scan_count = DEFAULT_BSS_EXPIRATION_SCAN_COUNT; config->max_num_sta = DEFAULT_MAX_NUM_STA; config->access_network_type = DEFAULT_ACCESS_NETWORK_TYPE; + config->scan_cur_freq = DEFAULT_SCAN_CUR_FREQ; config->wmm_ac_params[0] = ac_be; config->wmm_ac_params[1] = ac_bk; config->wmm_ac_params[2] = ac_vi; @@ -3105,6 +3106,7 @@ static const struct global_parse_data global_fields[] = { { FUNC(ap_vendor_elements), 0 }, { INT_RANGE(ignore_old_scan_res, 0, 1), 0 }, { FUNC(freq_list), 0 }, + { INT(scan_cur_freq), 0 }, { INT(sched_scan_interval), 0 }, }; diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h index a1a523992..1748cf3b8 100644 --- a/wpa_supplicant/config.h +++ b/wpa_supplicant/config.h @@ -24,6 +24,7 @@ #define DEFAULT_BSS_EXPIRATION_SCAN_COUNT 2 #define DEFAULT_MAX_NUM_STA 128 #define DEFAULT_ACCESS_NETWORK_TYPE 15 +#define DEFAULT_SCAN_CUR_FREQ 0 #include "config_ssid.h" #include "wps/wps.h" @@ -652,6 +653,14 @@ struct wpa_config { */ int *freq_list; + /** + * scan_cur_freq - Whether to scan only the current channel + * + * If true, attempt to scan only the current channel if any other + * VIFs on this radio are already associated on a particular channel. + */ + int scan_cur_freq; + /** * changed_parameters - Bitmap of changed parameters since last update */ diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c index 8ff42852d..d03de0b2a 100644 --- a/wpa_supplicant/config_file.c +++ b/wpa_supplicant/config_file.c @@ -1025,6 +1025,8 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config) } fprintf(f, "\n"); } + if (config->scan_cur_freq != DEFAULT_SCAN_CUR_FREQ) + fprintf(f, "scan_cur_freq=%d\n", config->scan_cur_freq); if (config->sched_scan_interval) fprintf(f, "sched_scan_interval=%u\n", diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index 239969244..682e1be70 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -481,6 +481,7 @@ static int non_p2p_network_enabled(struct wpa_supplicant *wpa_s) return 0; } +#endif /* CONFIG_P2P */ /* * Find the operating frequency of any other virtual interface that is using @@ -520,8 +521,6 @@ static int shared_vif_oper_freq(struct wpa_supplicant *wpa_s) return 0; } -#endif /* CONFIG_P2P */ - static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx) { @@ -756,6 +755,19 @@ ssid_list_set: int_array_concat(¶ms.freqs, wpa_s->conf->freq_list); } + /* Use current associated channel? */ + if (wpa_s->conf->scan_cur_freq && !params.freqs) { + int freq = shared_vif_oper_freq(wpa_s); + if (freq > 0) { + wpa_dbg(wpa_s, MSG_DEBUG, "Scan only the current " + "operating channel (%d MHz) since " + "scan_cur_freq is enabled", freq); + params.freqs = os_zalloc(sizeof(int) * 2); + if (params.freqs) + params.freqs[0] = freq; + } + } + params.filter_ssids = wpa_supplicant_build_filter_ssids( wpa_s->conf, ¶ms.num_filter_ssids); if (extra_ie) { diff --git a/wpa_supplicant/wpa_supplicant.conf b/wpa_supplicant/wpa_supplicant.conf index 87dd3970a..8e21a3aee 100644 --- a/wpa_supplicant/wpa_supplicant.conf +++ b/wpa_supplicant/wpa_supplicant.conf @@ -310,6 +310,10 @@ fast_reauth=1 # allowing it to update the internal BSS table. #ignore_old_scan_res=0 +# scan_cur_freq: Whether to scan only the current frequency +# 0: Scan all available frequencies. (Default) +# 1: Scan current operating frequency if another VIF on the same radio +# is already associated. # Interworking (IEEE 802.11u)