From e6955ba9f9eb7572539f890583995edcbd9a4730 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 16 Dec 2012 12:45:59 +0200 Subject: [PATCH] WNM: Add WNM-Sleep Mode into Extended Capabilities element Signed-hostap: Jouni Malinen --- wpa_supplicant/sme.c | 17 +++++++++++------ wpa_supplicant/wpa_supplicant.c | 17 +++++++++++------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c index e273cb3fd..885219ffc 100644 --- a/wpa_supplicant/sme.c +++ b/wpa_supplicant/sme.c @@ -94,6 +94,7 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s, #endif /* CONFIG_IEEE80211R */ int i, bssid_changed; struct wpabuf *resp = NULL; + u32 ext_capab; if (bss == NULL) { wpa_msg(wpa_s, MSG_ERROR, "SME: No scan result available for " @@ -308,8 +309,16 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s, } #endif /* CONFIG_HS20 */ + ext_capab = 0; #ifdef CONFIG_INTERWORKING - if (wpa_s->conf->interworking) { + if (wpa_s->conf->interworking) + ext_capab |= BIT(31); /* Interworking */ +#endif /* CONFIG_INTERWORKING */ +#ifdef CONFIG_WNM + ext_capab |= BIT(17); /* WNM-Sleep Mode */ +#endif /* CONFIG_WNM */ + + if (ext_capab) { u8 *pos = wpa_s->sme.assoc_req_ie; if (wpa_s->sme.assoc_req_ie_len > 0 && pos[0] == WLAN_EID_RSN) pos += 2 + pos[1]; @@ -319,12 +328,8 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s, wpa_s->sme.assoc_req_ie_len += 6; *pos++ = WLAN_EID_EXT_CAPAB; *pos++ = 4; - *pos++ = 0x00; - *pos++ = 0x00; - *pos++ = 0x00; - *pos++ = 0x80; /* Bit 31 - Interworking */ + WPA_PUT_LE32(pos, ext_capab); } -#endif /* CONFIG_INTERWORKING */ #ifdef CONFIG_SAE if (params.auth_alg == WPA_AUTH_ALG_SAE) { diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 784a47142..9d8055597 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -1251,6 +1251,7 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s, struct wpa_driver_capa capa; int assoc_failed = 0; struct wpa_ssid *old_ssid; + u32 ext_capab; #ifdef CONFIG_HT_OVERRIDES struct ieee80211_ht_capabilities htcaps; struct ieee80211_ht_capabilities htcaps_mask; @@ -1461,8 +1462,16 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s, } #endif /* CONFIG_HS20 */ + ext_capab = 0; #ifdef CONFIG_INTERWORKING - if (wpa_s->conf->interworking) { + if (wpa_s->conf->interworking) + ext_capab |= BIT(31); /* Interworking */ +#endif /* CONFIG_INTERWORKING */ +#ifdef CONFIG_WNM + ext_capab |= BIT(17); /* WNM-Sleep Mode */ +#endif /* CONFIG_WNM */ + + if (ext_capab) { u8 *pos = wpa_ie; if (wpa_ie_len > 0 && pos[0] == WLAN_EID_RSN) pos += 2 + pos[1]; @@ -1470,12 +1479,8 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s, wpa_ie_len += 6; *pos++ = WLAN_EID_EXT_CAPAB; *pos++ = 4; - *pos++ = 0x00; - *pos++ = 0x00; - *pos++ = 0x00; - *pos++ = 0x80; /* Bit 31 - Interworking */ + WPA_PUT_LE32(pos, ext_capab); } -#endif /* CONFIG_INTERWORKING */ wpa_clear_keys(wpa_s, bss ? bss->bssid : NULL); use_crypt = 1;