From c35e35ed8133bb6d7b96765c5f0b1d41efe09fc5 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 22 Jan 2015 20:50:01 +0200 Subject: [PATCH] Add passive_scan configuration parameter This new wpa_supplicant configuration parameter can be used to force passive scanning to be used for most scanning cases at the cost of increased latency and less reliably scans. This may be of use for both testing purposes and somewhat increased privacy due to no Probe Request frames with fixed MAC address being sent out. Signed-off-by: Jouni Malinen --- wpa_supplicant/config.c | 1 + wpa_supplicant/config.h | 12 ++++++++++++ wpa_supplicant/config_file.c | 3 +++ wpa_supplicant/p2p_supplicant.c | 1 + wpa_supplicant/scan.c | 5 ++++- 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index 5d7a063cd..4a56abc33 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -4129,6 +4129,7 @@ static const struct global_parse_data global_fields[] = { { INT(rand_addr_lifetime), 0 }, { INT(preassoc_mac_addr), 0 }, { INT(key_mgmt_offload), 0}, + { INT(passive_scan), 0 }, }; #undef FUNC diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h index eeb4ba7f8..6adf1eb38 100644 --- a/wpa_supplicant/config.h +++ b/wpa_supplicant/config.h @@ -1137,6 +1137,18 @@ struct wpa_config { * By default: 300 seconds. */ int mesh_max_inactivity; + + /** + * passive_scan - Whether to force passive scan for network connection + * + * This parameter can be used to force only passive scanning to be used + * for network connection cases. It should be noted that this will slow + * down scan operations and reduce likelihood of finding the AP. In + * addition, some use cases will override this due to functional + * requirements, e.g., for finding an AP that uses hidden SSID + * (scan_ssid=1) or P2P device discovery. + */ + int passive_scan; }; diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c index 9c9685a7d..33af428d2 100644 --- a/wpa_supplicant/config_file.c +++ b/wpa_supplicant/config_file.c @@ -1227,6 +1227,9 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config) if (config->mesh_max_inactivity != DEFAULT_MESH_MAX_INACTIVITY) fprintf(f, "mesh_max_inactivity=%d\n", config->mesh_max_inactivity); + + if (config->passive_scan) + fprintf(f, "cert_in_cb=%d\n", config->passive_scan); } #endif /* CONFIG_NO_CONFIG_WRITE */ diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 4364a0649..65c1b486f 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -1546,6 +1546,7 @@ static void wpas_p2p_clone_config(struct wpa_supplicant *dst, d->dtim_period = s->dtim_period; d->disassoc_low_ack = s->disassoc_low_ack; d->disable_scan_offload = s->disable_scan_offload; + d->passive_scan = s->passive_scan; if (s->wps_nfc_dh_privkey && s->wps_nfc_dh_pubkey) { d->wps_nfc_dh_privkey = wpabuf_dup(s->wps_nfc_dh_privkey); diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index 08af9fbac..0653cc28a 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -724,7 +724,7 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx) #ifdef CONFIG_P2P if ((wpa_s->p2p_in_provisioning || wpa_s->show_group_started) && - wpa_s->go_params) { + wpa_s->go_params && !wpa_s->conf->passive_scan) { wpa_printf(MSG_DEBUG, "P2P: Use specific SSID for scan during P2P group formation (p2p_in_provisioning=%d show_group_started=%d)", wpa_s->p2p_in_provisioning, wpa_s->show_group_started); @@ -878,6 +878,9 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx) } else if (wpa_s->last_scan_req == MANUAL_SCAN_REQ && wpa_s->manual_scan_passive && params.num_ssids == 0) { wpa_dbg(wpa_s, MSG_DEBUG, "Use passive scan based on manual request"); + } else if (wpa_s->conf->passive_scan) { + wpa_dbg(wpa_s, MSG_DEBUG, + "Use passive scan based on configuration"); } else { wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN; params.num_ssids++;