1 From 978a59514ccde994b5c06e1cbb49cc8cebe6381c Mon Sep 17 00:00:00 2001
2 From: Markus Theil <markus.theil@tu-ilmenau.de>
3 Date: Tue, 30 Jun 2020 13:53:19 +0200
4 Subject: [PATCH 03/19] wpa_supplicant: handle HT40 and mode downgrade in AP
7 This patch adds some missing pieces to the interface configuration
8 of AP/mesh mode in wpa_supplicant.
9 - check for secondary channel and HT40 capability
10 - try to downgrade to 11b if 11g is not available
11 Especially with the HT40 check, this code now performs all settings,
12 which the deleted/duplicated mesh code did.
14 Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
16 wpa_supplicant/ap.c | 49 ++++++++++++++++++++++++++++++++++++---------
17 1 file changed, 40 insertions(+), 9 deletions(-)
19 --- a/wpa_supplicant/ap.c
20 +++ b/wpa_supplicant/ap.c
21 @@ -134,6 +134,23 @@ no_vht:
25 +static struct hostapd_hw_modes *wpa_supplicant_find_hw_mode(struct wpa_supplicant *wpa_s,
26 + enum hostapd_hw_mode hw_mode)
28 + struct hostapd_hw_modes *mode = NULL;
31 + for (i = 0; i < wpa_s->hw.num_modes; i++) {
32 + if (wpa_s->hw.modes[i].mode == hw_mode) {
33 + mode = &wpa_s->hw.modes[i];
42 int wpa_supplicant_conf_ap_ht(struct wpa_supplicant *wpa_s,
43 struct wpa_ssid *ssid,
44 struct hostapd_config *conf)
45 @@ -147,9 +164,6 @@ int wpa_supplicant_conf_ap_ht(struct wpa
49 - /* TODO: enable HT40 if driver supports it;
50 - * drop to 11b if driver does not support 11g */
53 * Enable HT20 if the driver supports it, by setting conf->ieee80211n
54 * and a mask of allowed capabilities within conf->ht_capab.
55 @@ -158,17 +172,27 @@ int wpa_supplicant_conf_ap_ht(struct wpa
57 if (wpa_s->hw.modes) {
58 struct hostapd_hw_modes *mode = NULL;
63 "Determining HT/VHT options based on driver capabilities (freq=%u chan=%u)",
64 ssid->frequency, conf->channel);
66 - for (i = 0; i < wpa_s->hw.num_modes; i++) {
67 - if (wpa_s->hw.modes[i].mode == conf->hw_mode) {
68 - mode = &wpa_s->hw.modes[i];
71 + mode = wpa_supplicant_find_hw_mode(wpa_s, conf->hw_mode);
73 + /* may drop drop to 11b if driver does not support 11g */
74 + if (!mode && conf->hw_mode == HOSTAPD_MODE_IEEE80211G) {
75 + conf->hw_mode = HOSTAPD_MODE_IEEE80211B;
76 + wpa_printf(MSG_INFO,
77 + "Try downgrade to IEEE 802.11b as 802.11g is not "
78 + "supported by the current hardware");
79 + mode = wpa_supplicant_find_hw_mode(wpa_s, conf->hw_mode);
83 + wpa_printf(MSG_ERROR,
84 + "No match between requested and supported hw modes found");
88 #ifdef CONFIG_HT_OVERRIDES
89 @@ -193,6 +217,13 @@ int wpa_supplicant_conf_ap_ht(struct wpa
90 HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET),
95 + mode->ht_capab & HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET)
96 + conf->secondary_channel = ssid->ht40;
98 + conf->secondary_channel = 0;
101 if (ssid->p2p_group &&
102 conf->hw_mode == HOSTAPD_MODE_IEEE80211A &&