From 006334c73645bacf4d2ce940fe1e9a0bc5337b15 Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Thu, 7 Dec 2023 21:05:23 +0530 Subject: [PATCH] [nrf noup] zephyr: Fix sending unsolicited disconnect result fixup! [nrf noup] Monitor supplicant state and inform applications If STA is not connected but still disassociated for some reason e.g., wrong password, sending disconnect results is not intuitive as we have never sent connected status up, so, instead just send connect result with the reason code for failure. Fixes SHEL-2265. Signed-off-by: Chaitanya Tata --- wpa_supplicant/events.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 97a1a0386..615ef404d 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -3599,8 +3599,13 @@ static void wpa_supplicant_event_disassoc(struct wpa_supplicant *wpa_s, MAC2STR(bssid), reason_code, locally_generated ? " locally_generated=1" : ""); #ifdef CONFIG_ZEPHYR - int status = 0; - send_wifi_mgmt_event(wpa_s->ifname, NET_EVENT_WIFI_CMD_DISCONNECT_RESULT, (void *)&status, sizeof(int)); + int status = reason_code; + + if (wpa_s->wpa_state >= WPA_COMPLETED) { + send_wifi_mgmt_event(wpa_s->ifname, NET_EVENT_WIFI_CMD_DISCONNECT_RESULT, (void *)&status, sizeof(int)); + } else { + send_wifi_mgmt_event(wpa_s->ifname, NET_EVENT_WIFI_CMD_CONNECT_RESULT, (void *)&status, sizeof(int)); + } #endif /* CONFIG_ZEPHYR */ } }