From 8e5739c3ac31723d65444c9fbc7d29adc3dec974 Mon Sep 17 00:00:00 2001 From: Disha Das Date: Fri, 11 Sep 2020 10:13:52 +0530 Subject: [PATCH] DPP2: Check channel 6 validity before adding it to chirp channel list Check if the 2.4 GHz channel 6 is in the list of available channels advertised by the driver before adding in to the chirping frequency list. This fixes issues, e.g., with a 5 GHz only interface. Signed-off-by: Disha Das --- wpa_supplicant/dpp_supplicant.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/wpa_supplicant/dpp_supplicant.c b/wpa_supplicant/dpp_supplicant.c index 28404b8d7..023895072 100644 --- a/wpa_supplicant/dpp_supplicant.c +++ b/wpa_supplicant/dpp_supplicant.c @@ -3449,6 +3449,7 @@ static void wpas_dpp_chirp_scan_res_handler(struct wpa_supplicant *wpa_s, struct hostapd_hw_modes *mode; int c; struct wpa_bss *bss; + bool chan6; if (!bi && !wpa_s->dpp_reconfig_ssid) return; @@ -3466,7 +3467,22 @@ static void wpas_dpp_chirp_scan_res_handler(struct wpa_supplicant *wpa_s, } /* Preferred chirping channels */ - int_array_add_unique(&wpa_s->dpp_chirp_freqs, 2437); + mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, + HOSTAPD_MODE_IEEE80211G, 0); + chan6 = mode == NULL; + if (mode) { + for (c = 0; c < mode->num_channels; c++) { + struct hostapd_channel_data *chan = &mode->channels[c]; + + if ((chan->flag & HOSTAPD_CHAN_DISABLED) || + chan->freq != 2437) + continue; + chan6 = true; + break; + } + } + if (chan6) + int_array_add_unique(&wpa_s->dpp_chirp_freqs, 2437); mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes, HOSTAPD_MODE_IEEE80211A, 0);