developer | e2cc0fa | 2022-03-29 17:31:03 +0800 | [diff] [blame] | 1 | From cb31775e39eaa2b8a0bd36f5e195ac8bff967535 Mon Sep 17 00:00:00 2001 |
| 2 | From: "howard.hsu" <howard-yh.hsu@mediatek.com> |
| 3 | Date: Wed, 19 Jan 2022 21:15:07 +0800 |
| 4 | Subject: [PATCH 6/9] Add set_send_disassoc_frame_timer() to send disassociate |
| 5 | frame |
| 6 | |
| 7 | Function set_disassoc_timer() may fail if key was deleted first. This new |
| 8 | function 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 | |
| 13 | diff --git a/src/ap/wnm_ap.c b/src/ap/wnm_ap.c |
| 14 | index 6eac3ac..fad132c 100644 |
| 15 | --- a/src/ap/wnm_ap.c |
| 16 | +++ b/src/ap/wnm_ap.c |
| 17 | @@ -767,6 +767,34 @@ static void set_disassoc_timer(struct hostapd_data *hapd, struct sta_info *sta, |
| 18 | } |
| 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; |
| 52 | @@ -909,7 +937,7 @@ int wnm_send_bss_tm_req(struct hostapd_data *hapd, struct sta_info *sta, |
| 53 | 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 | -- |
| 62 | 2.18.0 |
| 63 | |