From 1f6c0ab87229222e8f2f4bd933a85ff0c9e89bdd Mon Sep 17 00:00:00 2001 From: Bala Shanmugam Date: Fri, 30 Mar 2012 15:20:35 +0300 Subject: [PATCH] Allow background scan period to be configured A network block specific background scan period can now be configured for drivers that implement internal background scan mechanism for roaming and BSS selection. Signed-hostap: Bala Shanmugam --- src/drivers/driver.h | 7 +++++++ src/drivers/driver_nl80211.c | 12 ++++++++++++ wpa_supplicant/config.c | 2 ++ wpa_supplicant/config_file.c | 1 + wpa_supplicant/config_ssid.h | 7 +++++++ wpa_supplicant/sme.c | 2 ++ wpa_supplicant/wpa_supplicant.c | 1 + 7 files changed, 32 insertions(+) diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 6eb042115..c4f6b5f3d 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -332,6 +332,13 @@ struct wpa_driver_associate_params { */ int freq; + /** + * bg_scan_period - Background scan period in seconds, 0 to disable + * background scan, or -1 to indicate no change to default driver + * configuration + */ + int bg_scan_period; + /** * wpa_ie - WPA information element for (Re)Association Request * WPA information element to be included in (Re)Association diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 94fbca106..1cbbbadb4 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -6575,6 +6575,12 @@ static int wpa_driver_nl80211_connect( wpa_printf(MSG_DEBUG, " * freq=%d", params->freq); NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, params->freq); } + if (params->bg_scan_period >= 0) { + wpa_printf(MSG_DEBUG, " * bg scan period=%d", + params->bg_scan_period); + NLA_PUT_U16(msg, NL80211_ATTR_BG_SCAN_PERIOD, + params->bg_scan_period); + } if (params->ssid) { wpa_hexdump_ascii(MSG_DEBUG, " * SSID", params->ssid, params->ssid_len); @@ -6772,6 +6778,12 @@ static int wpa_driver_nl80211_associate( drv->assoc_freq = params->freq; } else drv->assoc_freq = 0; + if (params->bg_scan_period >= 0) { + wpa_printf(MSG_DEBUG, " * bg scan period=%d", + params->bg_scan_period); + NLA_PUT_U16(msg, NL80211_ATTR_BG_SCAN_PERIOD, + params->bg_scan_period); + } if (params->ssid) { wpa_hexdump_ascii(MSG_DEBUG, " * SSID", params->ssid, params->ssid_len); diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index 5675d2e63..ea0b6f468 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -1525,6 +1525,7 @@ static const struct parse_data ssid_fields[] = { { FUNC_KEY(psk) }, { FUNC(proto) }, { FUNC(key_mgmt) }, + { INT(bg_scan_period) }, { FUNC(pairwise) }, { FUNC(group) }, { FUNC(auth_alg) }, @@ -1978,6 +1979,7 @@ void wpa_config_set_network_defaults(struct wpa_ssid *ssid) ssid->pairwise_cipher = DEFAULT_PAIRWISE; ssid->group_cipher = DEFAULT_GROUP; ssid->key_mgmt = DEFAULT_KEY_MGMT; + ssid->bg_scan_period = DEFAULT_BG_SCAN_PERIOD; #ifdef IEEE8021X_EAPOL ssid->eapol_flags = DEFAULT_EAPOL_FLAGS; ssid->eap_workaround = DEFAULT_EAP_WORKAROUND; diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c index cf5332014..e7f3a7ccb 100644 --- a/wpa_supplicant/config_file.c +++ b/wpa_supplicant/config_file.c @@ -588,6 +588,7 @@ static void wpa_config_write_network(FILE *f, struct wpa_ssid *ssid) write_psk(f, ssid); write_proto(f, ssid); write_key_mgmt(f, ssid); + INT(bg_scan_period); write_pairwise(f, ssid); write_group(f, ssid); write_auth_alg(f, ssid); diff --git a/wpa_supplicant/config_ssid.h b/wpa_supplicant/config_ssid.h index fa18826e4..80d438248 100644 --- a/wpa_supplicant/config_ssid.h +++ b/wpa_supplicant/config_ssid.h @@ -25,6 +25,7 @@ WPA_CIPHER_WEP104 | WPA_CIPHER_WEP40) #define DEFAULT_FRAGMENT_SIZE 1398 +#define DEFAULT_BG_SCAN_PERIOD -1 #define DEFAULT_DISABLE_HT 0 #define DEFAULT_DISABLE_HT40 0 #define DEFAULT_DISABLE_MAX_AMSDU -1 /* no change */ @@ -156,6 +157,12 @@ struct wpa_ssid { */ int key_mgmt; + /** + * bg_scan_period - Background scan period in seconds, 0 to disable, or + * -1 to indicate no change to default driver configuration + */ + int bg_scan_period; + /** * proto - Bitfield of allowed protocols, WPA_PROTO_* */ diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c index 690f39505..b36684716 100644 --- a/wpa_supplicant/sme.c +++ b/wpa_supplicant/sme.c @@ -371,6 +371,8 @@ void sme_associate(struct wpa_supplicant *wpa_s, enum wpas_mode mode, params.ssid = wpa_s->sme.ssid; params.ssid_len = wpa_s->sme.ssid_len; params.freq = wpa_s->sme.freq; + params.bg_scan_period = wpa_s->current_ssid ? + wpa_s->current_ssid->bg_scan_period : -1; params.wpa_ie = wpa_s->sme.assoc_req_ie_len ? wpa_s->sme.assoc_req_ie : NULL; params.wpa_ie_len = wpa_s->sme.assoc_req_ie_len; diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 36074d582..71542f0ff 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -1355,6 +1355,7 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s, params.wpa_proto = wpa_s->wpa_proto; params.auth_alg = algs; params.mode = ssid->mode; + params.bg_scan_period = ssid->bg_scan_period; for (i = 0; i < NUM_WEP_KEYS; i++) { if (ssid->wep_key_len[i]) params.wep_key[i] = ssid->wep_key[i];