From 62fa124ce2fb44f722ca26388956cc99f3115ada Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 17 Nov 2009 19:25:05 +0200 Subject: [PATCH] nl80211/SME: Use reassociation when roaming within the ESS --- src/drivers/driver.h | 8 ++++++++ src/drivers/driver_nl80211.c | 7 +++++++ wpa_supplicant/events.c | 5 +++++ wpa_supplicant/sme.c | 7 +++++++ wpa_supplicant/wpa_supplicant_i.h | 2 ++ 5 files changed, 29 insertions(+) diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 89400cd78..73658475b 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -409,6 +409,14 @@ struct wpa_driver_associate_params { * still be allowed for key negotiation. */ int drop_unencrypted; + + /** + * prev_bssid - Previously used BSSID in this ESS + * + * When not %NULL, this is a request to use reassociation instead of + * association. + */ + const u8 *prev_bssid; }; /** diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 97348ef29..ac3f4dd12 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -3599,6 +3599,13 @@ static int wpa_driver_nl80211_associate( NLA_PUT_FLAG(msg, NL80211_ATTR_CONTROL_PORT); + if (params->prev_bssid) { + wpa_printf(MSG_DEBUG, " * prev_bssid=" MACSTR, + MAC2STR(params->prev_bssid)); + NLA_PUT(msg, NL80211_ATTR_PREV_BSSID, ETH_ALEN, + params->prev_bssid); + } + ret = send_and_recv_msgs(drv, msg, NULL, NULL); msg = NULL; if (ret) { diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 896452db7..5f551808a 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -983,6 +983,11 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s, } } +#ifdef CONFIG_SME + os_memcpy(wpa_s->sme.prev_bssid, bssid, ETH_ALEN); + wpa_s->sme.prev_bssid_set = 1; +#endif /* CONFIG_SME */ + wpa_msg(wpa_s, MSG_INFO, "Associated with " MACSTR, MAC2STR(bssid)); if (wpa_s->current_ssid) { /* When using scanning (ap_scan=1), SIM PC/SC interface can be diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c index e148595f1..7b2764c2f 100644 --- a/wpa_supplicant/sme.c +++ b/wpa_supplicant/sme.c @@ -59,6 +59,10 @@ void sme_authenticate(struct wpa_supplicant *wpa_s, params.ssid = ie + 2; params.ssid_len = ie[1]; + if (wpa_s->sme.ssid_len != params.ssid_len || + os_memcmp(wpa_s->sme.ssid, params.ssid, params.ssid_len) != 0) + wpa_s->sme.prev_bssid_set = 0; + wpa_s->sme.freq = params.freq; os_memcpy(wpa_s->sme.ssid, params.ssid, params.ssid_len); wpa_s->sme.ssid_len = params.ssid_len; @@ -312,6 +316,8 @@ void sme_event_auth(struct wpa_supplicant *wpa_s, union wpa_event_data *data) #endif /* CONFIG_IEEE80211R */ params.mode = ssid->mode; params.mgmt_frame_protection = wpa_s->sme.mfp; + if (wpa_s->sme.prev_bssid_set) + params.prev_bssid = wpa_s->sme.prev_bssid; wpa_msg(wpa_s, MSG_INFO, "Trying to associate with " MACSTR " (SSID='%s' freq=%d MHz)", MAC2STR(params.bssid), @@ -378,6 +384,7 @@ void sme_event_assoc_reject(struct wpa_supplicant *wpa_s, wpa_msg(wpa_s, MSG_INFO, "Deauth request to the driver failed"); } + wpa_s->sme.prev_bssid_set = 0; if (wpa_blacklist_add(wpa_s, wpa_s->pending_bssid) == 0) { struct wpa_blacklist *b; diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 193baa34c..7cd242662 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -407,6 +407,8 @@ struct wpa_supplicant { u8 mobility_domain[2]; u8 *ft_ies; size_t ft_ies_len; + u8 prev_bssid[ETH_ALEN]; + int prev_bssid_set; } sme; #endif /* CONFIG_SME */