From cb06cf34565bca70a9ada4fbe48667d249faf54b Mon Sep 17 00:00:00 2001 From: David Spinadel Date: Mon, 15 Feb 2016 16:53:29 +0200 Subject: [PATCH] MBO: Prevent association to APs that explicitly disallow this Prevent association to MBO APs that have association disallowed attribute in MBO IE in Beacon or Probe Response frames. Signed-off-by: David Spinadel --- wpa_supplicant/events.c | 13 +++++++++++++ wpa_supplicant/mbo.c | 18 ++++++++++++++++++ wpa_supplicant/wpa_supplicant_i.h | 1 + 3 files changed, 32 insertions(+) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 3264dc07f..76835dec3 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -827,6 +827,9 @@ static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s, const u8 *ie; struct wpa_ssid *ssid; int osen; +#ifdef CONFIG_MBO + const u8 *assoc_disallow; +#endif /* CONFIG_MBO */ ie = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE); wpa_ie_len = ie ? ie[1] : 0; @@ -1064,6 +1067,16 @@ static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s, (unsigned int) diff.usec); continue; } +#ifdef CONFIG_MBO + assoc_disallow = wpas_mbo_get_bss_attr( + bss, MBO_ATTR_ID_ASSOC_DISALLOW); + if (assoc_disallow && assoc_disallow[1] >= 1) { + wpa_dbg(wpa_s, MSG_DEBUG, + " skip - MBO association disallowed (reason %u)", + assoc_disallow[2]); + continue; + } +#endif /* CONFIG_MBO */ /* Matching configuration found */ return ssid; diff --git a/wpa_supplicant/mbo.c b/wpa_supplicant/mbo.c index d6f2e769a..a60d1d326 100644 --- a/wpa_supplicant/mbo.c +++ b/wpa_supplicant/mbo.c @@ -36,6 +36,24 @@ static int wpas_mbo_validate_non_pref_chan(u8 oper_class, u8 chan, u8 reason) } +const u8 * wpas_mbo_get_bss_attr(struct wpa_bss *bss, enum mbo_attr_id attr) +{ + const u8 *mbo, *end; + + if (!bss) + return NULL; + + mbo = wpa_bss_get_vendor_ie(bss, MBO_IE_VENDOR_TYPE); + if (!mbo) + return NULL; + + end = mbo + 2 + mbo[1]; + mbo += MBO_IE_HEADER; + + return get_ie(mbo, end - mbo, attr); +} + + static void wpas_mbo_non_pref_chan_attr_body(struct wpa_supplicant *wpa_s, struct wpabuf *mbo, u8 start, u8 end) diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index d53bc961e..1a2973761 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1144,6 +1144,7 @@ void wpas_rrm_handle_link_measurement_request(struct wpa_supplicant *wpa_s, /* MBO functions */ int wpas_mbo_ie(struct wpa_supplicant *wpa_s, u8 *buf, size_t len); +const u8 * wpas_mbo_get_bss_attr(struct wpa_bss *bss, enum mbo_attr_id attr); int wpas_mbo_update_non_pref_chan(struct wpa_supplicant *wpa_s, const char *non_pref_chan); void wpas_mbo_scan_ie(struct wpa_supplicant *wpa_s, struct wpabuf *ie);