From 2cbbcd12f92769495a7a1e09d55dc18fdfc9a8f2 Mon Sep 17 00:00:00 2001 From: Hai Shalom Date: Mon, 8 Mar 2021 18:33:38 -0800 Subject: [PATCH] Support Passpoint frame filters in Android The conf->hs20 flag is not used in Android, but HS 2.0 configuration is still required when setting up the frame filters in the WPA driver. Split the is_hs20_network() to two functions, and moved the conf->hs20() check to a new is_hs20_config function. Added ANDROID compilation flag in hs20_configure_frame_filters() to skip the configuration check. Additionally, trigger a call to hs20_configure_frame_filters() upon succesful connection when state equals to WPA_COMPLETED. Bug: 168681498 Test: Verify wpa driver is called with the appropriate frame filter flags when connecting to Passpoint networks. Test: Verify wpa driver is not called to filter frames for other Enterprise networks. Change-Id: I3afea6018d5ddd2211974ca10a30180c6cc204e7 --- wpa_supplicant/hs20_supplicant.c | 13 +++++++++++-- wpa_supplicant/hs20_supplicant.h | 1 + wpa_supplicant/sme.c | 2 +- wpa_supplicant/wpa_supplicant.c | 8 +++++--- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/wpa_supplicant/hs20_supplicant.c b/wpa_supplicant/hs20_supplicant.c index 8aeb3b00..eaf0803d 100644 --- a/wpa_supplicant/hs20_supplicant.c +++ b/wpa_supplicant/hs20_supplicant.c @@ -73,7 +73,12 @@ void hs20_configure_frame_filters(struct wpa_supplicant *wpa_s) const u8 *ext_capa; u32 filter = 0; - if (!bss || !is_hs20_network(wpa_s, wpa_s->current_ssid, bss)) { + if (!bss || !is_hs20_network(wpa_s, wpa_s->current_ssid, bss) +#ifndef ANDROID + // HS 2.0 Configuration is not used in AOSP + || !is_hs20_config(wpa_s) +#endif + ) { wpa_printf(MSG_DEBUG, "Not configuring frame filtering - BSS " MACSTR " is not a Hotspot 2.0 network", MAC2STR(bssid)); @@ -158,11 +163,15 @@ int get_hs20_version(struct wpa_bss *bss) return ((ie[6] >> 4) & 0x0f) + 1; } +int is_hs20_config(struct wpa_supplicant *wpa_s) +{ + return wpa_s->conf->hs20; +} int is_hs20_network(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid, struct wpa_bss *bss) { - if (!wpa_s->conf->hs20 || !ssid) + if (!ssid) return 0; if (ssid->parent_cred) diff --git a/wpa_supplicant/hs20_supplicant.h b/wpa_supplicant/hs20_supplicant.h index e43414bc..2d478f4f 100644 --- a/wpa_supplicant/hs20_supplicant.h +++ b/wpa_supplicant/hs20_supplicant.h @@ -22,6 +22,7 @@ void hs20_parse_rx_hs20_anqp_resp(struct wpa_supplicant *wpa_s, struct wpa_bss *bss, const u8 *sa, const u8 *data, size_t slen, u8 dialog_token); int get_hs20_version(struct wpa_bss *bss); +int is_hs20_config(struct wpa_supplicant *wpa_s); int is_hs20_network(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid, struct wpa_bss *bss); int hs20_get_pps_mo_id(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid); diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c index c6cef5b1..36f4d3c4 100644 --- a/wpa_supplicant/sme.c +++ b/wpa_supplicant/sme.c @@ -663,7 +663,7 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s, } #ifdef CONFIG_HS20 - if (is_hs20_network(wpa_s, ssid, bss)) { + if (is_hs20_config(wpa_s) && is_hs20_network(wpa_s, ssid, bss)) { struct wpabuf *hs20; hs20 = wpabuf_alloc(20 + MAX_ROAMING_CONS_OI_LEN); diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 1fd65068..224fb10c 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -1016,6 +1016,9 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, if (ssid && (ssid->key_mgmt & WPA_KEY_MGMT_OWE)) wpas_update_owe_connect_params(wpa_s); #endif /* CONFIG_OWE */ +#ifdef CONFIG_HS20 + hs20_configure_frame_filters(wpa_s); +#endif } else if (state == WPA_DISCONNECTED || state == WPA_ASSOCIATING || state == WPA_ASSOCIATED) { wpa_s->new_connection = 1; @@ -3033,7 +3036,7 @@ static u8 * wpas_populate_assoc_ies( } #ifdef CONFIG_HS20 - if (is_hs20_network(wpa_s, ssid, bss)) { + if (is_hs20_config(wpa_s) && is_hs20_network(wpa_s, ssid, bss)) { struct wpabuf *hs20; hs20 = wpabuf_alloc(20 + MAX_ROAMING_CONS_OI_LEN); @@ -3051,10 +3054,9 @@ static u8 * wpas_populate_assoc_ies( wpa_ie_len += wpabuf_len(hs20); } wpabuf_free(hs20); - - hs20_configure_frame_filters(wpa_s); } } + hs20_configure_frame_filters(wpa_s); #endif /* CONFIG_HS20 */ if (wpa_s->vendor_elem[VENDOR_ELEM_ASSOC_REQ]) {