From d8ca0675bb99335b806e9b8c60bbb134a15677d4 Mon Sep 17 00:00:00 2001 From: Kapil Gupta Date: Sat, 21 Dec 2024 11:33:47 +0530 Subject: [PATCH] fix(esp_wifi): Address some review comments --- .../esp_supplicant/src/esp_common.c | 16 ++++++++-------- .../esp_supplicant/src/esp_common_i.h | 2 +- .../wpa_supplicant/esp_supplicant/src/esp_scan.c | 1 - .../esp_supplicant/src/esp_wpa_main.c | 4 +++- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_common.c b/components/wpa_supplicant/esp_supplicant/src/esp_common.c index 3b2c7b2518..b69e8c481c 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_common.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_common.c @@ -23,7 +23,6 @@ #include "rsn_supp/wpa_i.h" #include "rsn_supp/wpa.h" #include "esp_private/wifi.h" -#include "eloop.h" /* Utility Functions */ esp_err_t esp_supplicant_str_to_mac(const char *str, uint8_t dest[6]) @@ -36,9 +35,8 @@ esp_err_t esp_supplicant_str_to_mac(const char *str, uint8_t dest[6]) } struct wpa_supplicant g_wpa_supp; -#if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) -static int mgmt_rx_action(u8 *frame, size_t len, u8 *sender, int8_t rssi, u8 channel); +#if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) #if defined(CONFIG_RRM) static void handle_rrm_frame(struct wpa_supplicant *wpa_s, u8 *sender, u8 *payload, size_t len, int8_t rssi) @@ -329,14 +327,16 @@ void supplicant_sta_conn_handler(uint8_t *bssid) /* Register for mgmt frames */ register_mgmt_frames(wpa_s); /* clear set bssid flag */ - clear_bssid_flag(wpa_s); + clear_bssid_flag_and_channel(wpa_s); #endif /* defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) */ } -void supplicant_sta_disconn_handler(void) +void supplicant_sta_disconn_handler(uint8_t reason_code) { -#if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) +#if defined(CONFIG_IEEE80211R) struct wpa_sm *sm = &gWpaSm; +#endif +#if defined(CONFIG_IEEE80211KV) || defined(CONFIG_IEEE80211R) struct wpa_supplicant *wpa_s = &g_wpa_supp; #if defined(CONFIG_RRM) @@ -353,8 +353,8 @@ void supplicant_sta_disconn_handler(void) wpa_s->current_bss = NULL; } #if defined(CONFIG_IEEE80211R) - if (reason_code == WIFI_REASON_INVALID_PMKID || reason_code == WIFI_REASON_INVALID_MDE || reason_code == WIFI_REASON_INVALID_FTE || (sm->cur_pmksa == NULL)) { - /* clear all ft auth related IEs so that next will be open auth */ + if (!sm->cur_pmksa) { + /* clear all ft auth related IEs so that next will be open auth */ wpa_sta_clear_ft_auth_ie(); } #endif diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_common_i.h b/components/wpa_supplicant/esp_supplicant/src/esp_common_i.h index 3539ddcace..20f05618ef 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_common_i.h +++ b/components/wpa_supplicant/esp_supplicant/src/esp_common_i.h @@ -32,5 +32,5 @@ void esp_supplicant_unset_all_appie(void); void esp_set_scan_ie(void); void esp_set_assoc_ie(uint8_t *bssid, const u8 *ies, size_t ies_len, bool add_mdie); void supplicant_sta_conn_handler(uint8_t* bssid); -void supplicant_sta_disconn_handler(void); +void supplicant_sta_disconn_handler(uint8_t reason_code); #endif diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_scan.c b/components/wpa_supplicant/esp_supplicant/src/esp_scan.c index 4ff1a4f7e7..2e1ae8eed7 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_scan.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_scan.c @@ -22,7 +22,6 @@ #include "common/wnm_sta.h" #include "esp_scan_i.h" #include "esp_common_i.h" -#include "eloop.h" extern struct wpa_supplicant g_wpa_supp; diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c b/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c index 6a965e2d83..b0e3b401f6 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c @@ -260,6 +260,8 @@ static void wpa_sta_disconnected_cb(uint8_t reason_code) case WIFI_REASON_ASSOC_FAIL: case WIFI_REASON_CONNECTION_FAIL: case WIFI_REASON_HANDSHAKE_TIMEOUT: + case WIFI_REASON_INVALID_MDE: + case WIFI_REASON_INVALID_FTE: wpa_sta_clear_curr_pmksa(); wpa_sm_notify_disassoc(&gWpaSm); break; @@ -280,7 +282,7 @@ static void wpa_sta_disconnected_cb(uint8_t reason_code) #endif /* CONFIG_OWE_STA */ esp_wpa3_free_sae_data(); - supplicant_sta_disconn_handler(); + supplicant_sta_disconn_handler(reason_code); } #ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT