blob: c967ebf47da0ecd0e6f018d59062e239f7b28138 [file] [log] [blame]
developerc41fcd32022-09-20 22:09:06 +08001From 1538a92c53326c958133d5859c8dff0d56050c68 Mon Sep 17 00:00:00 2001
developere2cc0fa2022-03-29 17:31:03 +08002From: "howard.hsu" <howard-yh.hsu@mediatek.com>
3Date: Wed, 19 Jan 2022 21:15:07 +0800
developerc41fcd32022-09-20 22:09:06 +08004Subject: [PATCH 99905/99916] Add set_send_disassoc_frame_timer() to send
5 disassociate frame
developere2cc0fa2022-03-29 17:31:03 +08006
7Function set_disassoc_timer() may fail if key was deleted first. This new
8function will not ask to delete key as set_disassoc_timer() did.
9---
10 src/ap/wnm_ap.c | 30 +++++++++++++++++++++++++++++-
11 1 file changed, 29 insertions(+), 1 deletion(-)
12
13diff --git a/src/ap/wnm_ap.c b/src/ap/wnm_ap.c
developerc41fcd32022-09-20 22:09:06 +080014index f6761aba3..4349e1df2 100644
developere2cc0fa2022-03-29 17:31:03 +080015--- a/src/ap/wnm_ap.c
16+++ b/src/ap/wnm_ap.c
developerc41fcd32022-09-20 22:09:06 +080017@@ -780,6 +780,34 @@ static void set_disassoc_timer(struct hostapd_data *hapd, struct sta_info *sta,
developere2cc0fa2022-03-29 17:31:03 +080018 }
19
20
21+static void set_send_disassoc_frame_timer(struct hostapd_data *hapd, struct sta_info *sta,
22+ int disassoc_timer)
23+{
24+ int timeout, beacon_int;
25+
26+ /*
27+ * Prevent STA from reconnecting using cached PMKSA to force
28+ * full authentication with the authentication server (which may
29+ * decide to reject the connection),
30+ */
31+ wpa_auth_pmksa_remove(hapd->wpa_auth, sta->addr);
32+
33+ beacon_int = hapd->iconf->beacon_int;
34+ if (beacon_int < 1)
35+ beacon_int = 100; /* best guess */
36+ /* Calculate timeout in ms based on beacon_int in TU */
37+ timeout = disassoc_timer * beacon_int * 128 / 125;
38+ wpa_printf(MSG_DEBUG, "Disassociation timer for " MACSTR
39+ " set to %d ms", MAC2STR(sta->addr), timeout);
40+
41+ u16 reason = WLAN_REASON_PREV_AUTH_NOT_VALID;
42+
43+ hostapd_drv_sta_disassoc(hapd, sta->addr, reason);
44+ if (sta)
45+ ap_sta_disassociate(hapd, sta, reason);
46+}
47+
48+
49 void bss_termination_disable_iface(void *eloop_ctx, void *timeout_ctx)
50 {
51 struct hostapd_data *hapd = eloop_ctx;
developerc41fcd32022-09-20 22:09:06 +080052@@ -922,7 +950,7 @@ int wnm_send_bss_tm_req(struct hostapd_data *hapd, struct sta_info *sta,
developere2cc0fa2022-03-29 17:31:03 +080053 hapd->openwrt_stats.wnm.bss_transition_request_tx++;
54 if (disassoc_timer) {
55 /* send disassociation frame after time-out */
56- set_disassoc_timer(hapd, sta, disassoc_timer);
57+ set_send_disassoc_frame_timer(hapd, sta, disassoc_timer);
58 }
59
60 return 0;
61--
developerc41fcd32022-09-20 22:09:06 +0800622.25.1
developere2cc0fa2022-03-29 17:31:03 +080063