fix(wifi): Disallow DPP and WPS concurrency

This commit is contained in:
Kapil Gupta 2023-11-01 19:09:58 +05:30
parent 5d5dac7754
commit 0c3440a5bc
4 changed files with 32 additions and 2 deletions

View File

@ -14,6 +14,7 @@
#include "esp_event.h"
#include "esp_wifi.h"
#include "common/ieee802_11_defs.h"
#include "esp_wps_i.h"
#ifdef CONFIG_DPP
static void *s_dpp_task_hdl = NULL;
@ -610,6 +611,11 @@ void esp_supp_dpp_stop_listen(void)
esp_wifi_remain_on_channel(WIFI_IF_STA, WIFI_ROC_CANCEL, 0, 0, NULL);
}
bool is_dpp_enabled(void)
{
return (s_dpp_ctx.dpp_global ? true : false);
}
esp_err_t esp_supp_dpp_init(esp_supp_dpp_event_cb_t cb)
{
wifi_mode_t mode = 0;
@ -617,6 +623,11 @@ esp_err_t esp_supp_dpp_init(esp_supp_dpp_event_cb_t cb)
wpa_printf(MSG_ERROR, "DPP: failed to init as not in station mode.");
return ESP_FAIL;
}
if (is_wps_enabled()) {
wpa_printf(MSG_ERROR, "DPP: failed to init since WPS is enabled");
return ESP_FAIL;
}
if (s_dpp_ctx.dpp_global) {
wpa_printf(MSG_ERROR, "DPP: failed to init as init already done.");
return ESP_FAIL;

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -55,4 +55,12 @@ struct esp_dpp_context_t {
int esp_supp_rx_action(uint8_t *hdr, uint8_t *payload, size_t len, uint8_t channel);
#ifdef CONFIG_ESP_WIFI_DPP_SUPPORT
bool is_dpp_enabled(void);
#else
static inline bool is_dpp_enabled(void)
{
return false;
}
#endif
#endif /* ESP_DPP_I_H */

View File

@ -26,6 +26,7 @@
#include "esp_err.h"
#include "esp_private/wifi.h"
#include "esp_wps_i.h"
#include "esp_dpp_i.h"
#include "esp_wps.h"
#include "eap_common/eap_wsc_common.h"
#include "esp_wpas_glue.h"
@ -1863,6 +1864,11 @@ int esp_wifi_wps_enable(const esp_wps_config_t *config)
#endif
}
bool is_wps_enabled(void)
{
return s_wps_enabled;
}
int wifi_wps_enable_internal(const esp_wps_config_t *config)
{
int ret = 0;
@ -1873,7 +1879,10 @@ int wifi_wps_enable_internal(const esp_wps_config_t *config)
wpa_printf(MSG_ERROR, "wps enable: invalid wps type");
return ESP_ERR_WIFI_WPS_TYPE;
}
if (is_dpp_enabled()) {
wpa_printf(MSG_ERROR, "wps enabled failed since DPP is initialized");
return ESP_FAIL;
}
wpa_printf(MSG_DEBUG, "Set factory information.");
ret = wps_set_factory_info(config);
if (ret != 0) {

View File

@ -125,5 +125,7 @@ static inline int wps_set_status(uint32_t status)
{
return esp_wifi_set_wps_status_internal(status);
}
bool is_wps_enabled(void);
int wps_init_cfg_pin(struct wps_config *cfg);
void wifi_station_wps_eapol_start_handle(void *data, void *user_ctx);