From cb828507f5f1ce911248315033c0dfde55ff7e92 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Fri, 24 Aug 2018 13:27:44 -0700 Subject: [PATCH] Use disable_ht/vht to constrain supported operating class information If user has disabled HT or VHT, those related operating classes should not be advertised as supported. Signed-off-by: Ben Greear --- wpa_supplicant/op_classes.c | 41 ++++++++++++++++++++++++++++--- wpa_supplicant/sme.c | 2 +- wpa_supplicant/wpa_supplicant.c | 2 +- wpa_supplicant/wpa_supplicant_i.h | 5 ++-- 4 files changed, 43 insertions(+), 7 deletions(-) diff --git a/wpa_supplicant/op_classes.c b/wpa_supplicant/op_classes.c index d23b0094c..277f27038 100644 --- a/wpa_supplicant/op_classes.c +++ b/wpa_supplicant/op_classes.c @@ -208,6 +208,7 @@ enum chan_allowed verify_channel(struct hostapd_hw_modes *mode, u8 channel, static int wpas_op_class_supported(struct wpa_supplicant *wpa_s, + struct wpa_ssid *ssid, const struct oper_class_map *op_class) { int chan; @@ -219,6 +220,39 @@ static int wpas_op_class_supported(struct wpa_supplicant *wpa_s, if (!mode) return 0; +#ifdef CONFIG_HT_OVERRIDES + if (ssid->disable_ht) { + switch (op_class->op_class) { + case 83: + case 84: + case 104: + case 105: + case 116: + case 117: + case 119: + case 120: + case 122: + case 123: + case 126: + case 127: + case 128: + case 129: + case 130: + /* Disable >= 40 MHz channels if HT is disabled */ + return 0; + } + } +#endif /* CONFIG_HT_OVERRIDES */ + +#ifdef CONFIG_VHT_OVERRIDES + if (ssid->disable_vht) { + if (op_class->op_class >= 128 && op_class->op_class <= 130) { + /* Disable >= 80 MHz channels if VHT is disabled */ + return 0; + } + } +#endif /* CONFIG_VHT_OVERRIDES */ + if (op_class->op_class == 128) { u8 channels[] = { 42, 58, 106, 122, 138, 155 }; @@ -273,8 +307,9 @@ static int wpas_op_class_supported(struct wpa_supplicant *wpa_s, } -size_t wpas_supp_op_class_ie(struct wpa_supplicant *wpa_s, int freq, u8 *pos, - size_t len) +size_t wpas_supp_op_class_ie(struct wpa_supplicant *wpa_s, + struct wpa_ssid *ssid, + int freq, u8 *pos, size_t len) { struct wpabuf *buf; u8 op, current, chan; @@ -304,7 +339,7 @@ size_t wpas_supp_op_class_ie(struct wpa_supplicant *wpa_s, int freq, u8 *pos, wpabuf_put_u8(buf, current); for (op = 0; global_op_class[op].op_class; op++) { - if (wpas_op_class_supported(wpa_s, &global_op_class[op])) + if (wpas_op_class_supported(wpa_s, ssid, &global_op_class[op])) wpabuf_put_u8(buf, global_op_class[op].op_class); } diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c index 11ef5b7d6..ba22a93f4 100644 --- a/wpa_supplicant/sme.c +++ b/wpa_supplicant/sme.c @@ -520,7 +520,7 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s, sme_auth_handle_rrm(wpa_s, bss); wpa_s->sme.assoc_req_ie_len += wpas_supp_op_class_ie( - wpa_s, bss->freq, + wpa_s, ssid, bss->freq, wpa_s->sme.assoc_req_ie + wpa_s->sme.assoc_req_ie_len, sizeof(wpa_s->sme.assoc_req_ie) - wpa_s->sme.assoc_req_ie_len); diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 1132df269..def89f320 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -2668,7 +2668,7 @@ static u8 * wpas_populate_assoc_ies( #endif /* CONFIG_P2P */ if (bss) { - wpa_ie_len += wpas_supp_op_class_ie(wpa_s, bss->freq, + wpa_ie_len += wpas_supp_op_class_ie(wpa_s, ssid, bss->freq, wpa_ie + wpa_ie_len, max_wpa_ie_len - wpa_ie_len); diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index d5ce1fb17..2f2637ce7 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1407,8 +1407,9 @@ enum chan_allowed { enum chan_allowed verify_channel(struct hostapd_hw_modes *mode, u8 channel, u8 bw); -size_t wpas_supp_op_class_ie(struct wpa_supplicant *wpa_s, int freq, u8 *pos, - size_t len); +size_t wpas_supp_op_class_ie(struct wpa_supplicant *wpa_s, + struct wpa_ssid *ssid, + int freq, u8 *pos, size_t len); /** * wpa_supplicant_ctrl_iface_ctrl_rsp_handle - Handle a control response