AP: Unify code handling deauthentication/disassociation
This avoids unnecessary code duplication and adds the sta->wpa_sm deinit calls for deauthentication while it was previously done only in the disassociation case. Signed-off-by: Ilan Peer <ilan.peer@intel.com>
This commit is contained in:
parent
597e2be398
commit
e9f75a3520
1 changed files with 33 additions and 34 deletions
|
@ -846,32 +846,20 @@ static void ap_sta_disassoc_cb_timeout(void *eloop_ctx, void *timeout_ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ap_sta_disassociate(struct hostapd_data *hapd, struct sta_info *sta,
|
static void ap_sta_disconnect_common(struct hostapd_data *hapd,
|
||||||
u16 reason)
|
struct sta_info *sta, unsigned int timeout)
|
||||||
{
|
{
|
||||||
wpa_printf(MSG_DEBUG, "%s: disassociate STA " MACSTR,
|
|
||||||
hapd->conf->iface, MAC2STR(sta->addr));
|
|
||||||
sta->last_seq_ctrl = WLAN_INVALID_MGMT_SEQ;
|
sta->last_seq_ctrl = WLAN_INVALID_MGMT_SEQ;
|
||||||
if (hapd->iface->current_mode &&
|
|
||||||
hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211AD) {
|
|
||||||
/* Skip deauthentication in DMG/IEEE 802.11ad */
|
|
||||||
sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC |
|
|
||||||
WLAN_STA_ASSOC_REQ_OK);
|
|
||||||
sta->timeout_next = STA_REMOVE;
|
|
||||||
} else {
|
|
||||||
sta->flags &= ~(WLAN_STA_ASSOC | WLAN_STA_ASSOC_REQ_OK);
|
|
||||||
sta->timeout_next = STA_DEAUTH;
|
|
||||||
}
|
|
||||||
ap_sta_set_authorized(hapd, sta, 0);
|
ap_sta_set_authorized(hapd, sta, 0);
|
||||||
hostapd_set_sta_flags(hapd, sta);
|
hostapd_set_sta_flags(hapd, sta);
|
||||||
wpa_printf(MSG_DEBUG, "%s: reschedule ap_handle_timer timeout "
|
|
||||||
"for " MACSTR " (%d seconds - "
|
wpa_printf(MSG_DEBUG,
|
||||||
"AP_MAX_INACTIVITY_AFTER_DISASSOC)",
|
"reschedule ap_handle_timer timeout (%u sec) for " MACSTR,
|
||||||
__func__, MAC2STR(sta->addr),
|
MAC2STR(sta->addr), timeout);
|
||||||
AP_MAX_INACTIVITY_AFTER_DISASSOC);
|
|
||||||
eloop_cancel_timeout(ap_handle_timer, hapd, sta);
|
eloop_cancel_timeout(ap_handle_timer, hapd, sta);
|
||||||
eloop_register_timeout(AP_MAX_INACTIVITY_AFTER_DISASSOC, 0,
|
eloop_register_timeout(timeout, 0, ap_handle_timer, hapd, sta);
|
||||||
ap_handle_timer, hapd, sta);
|
|
||||||
accounting_sta_stop(hapd, sta);
|
accounting_sta_stop(hapd, sta);
|
||||||
ieee802_1x_free_station(hapd, sta);
|
ieee802_1x_free_station(hapd, sta);
|
||||||
#ifdef CONFIG_IEEE80211BE
|
#ifdef CONFIG_IEEE80211BE
|
||||||
|
@ -883,6 +871,27 @@ void ap_sta_disassociate(struct hostapd_data *hapd, struct sta_info *sta,
|
||||||
#endif /* CONFIG_IEEE80211BE */
|
#endif /* CONFIG_IEEE80211BE */
|
||||||
|
|
||||||
sta->wpa_sm = NULL;
|
sta->wpa_sm = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ap_sta_disassociate(struct hostapd_data *hapd, struct sta_info *sta,
|
||||||
|
u16 reason)
|
||||||
|
{
|
||||||
|
wpa_printf(MSG_DEBUG, "%s: disassociate STA " MACSTR,
|
||||||
|
hapd->conf->iface, MAC2STR(sta->addr));
|
||||||
|
|
||||||
|
if (hapd->iface->current_mode &&
|
||||||
|
hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211AD) {
|
||||||
|
/* Skip deauthentication in DMG/IEEE 802.11ad */
|
||||||
|
sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC |
|
||||||
|
WLAN_STA_ASSOC_REQ_OK);
|
||||||
|
sta->timeout_next = STA_REMOVE;
|
||||||
|
} else {
|
||||||
|
sta->flags &= ~(WLAN_STA_ASSOC | WLAN_STA_ASSOC_REQ_OK);
|
||||||
|
sta->timeout_next = STA_DEAUTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
ap_sta_disconnect_common(hapd, sta, AP_MAX_INACTIVITY_AFTER_DISASSOC);
|
||||||
|
|
||||||
sta->disassoc_reason = reason;
|
sta->disassoc_reason = reason;
|
||||||
sta->flags |= WLAN_STA_PENDING_DISASSOC_CB;
|
sta->flags |= WLAN_STA_PENDING_DISASSOC_CB;
|
||||||
|
@ -918,21 +927,11 @@ void ap_sta_deauthenticate(struct hostapd_data *hapd, struct sta_info *sta,
|
||||||
|
|
||||||
wpa_printf(MSG_DEBUG, "%s: deauthenticate STA " MACSTR,
|
wpa_printf(MSG_DEBUG, "%s: deauthenticate STA " MACSTR,
|
||||||
hapd->conf->iface, MAC2STR(sta->addr));
|
hapd->conf->iface, MAC2STR(sta->addr));
|
||||||
sta->last_seq_ctrl = WLAN_INVALID_MGMT_SEQ;
|
|
||||||
sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC | WLAN_STA_ASSOC_REQ_OK);
|
sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC | WLAN_STA_ASSOC_REQ_OK);
|
||||||
ap_sta_set_authorized(hapd, sta, 0);
|
|
||||||
hostapd_set_sta_flags(hapd, sta);
|
|
||||||
sta->timeout_next = STA_REMOVE;
|
sta->timeout_next = STA_REMOVE;
|
||||||
wpa_printf(MSG_DEBUG, "%s: reschedule ap_handle_timer timeout "
|
ap_sta_disconnect_common(hapd, sta, AP_MAX_INACTIVITY_AFTER_DEAUTH);
|
||||||
"for " MACSTR " (%d seconds - "
|
|
||||||
"AP_MAX_INACTIVITY_AFTER_DEAUTH)",
|
|
||||||
__func__, MAC2STR(sta->addr),
|
|
||||||
AP_MAX_INACTIVITY_AFTER_DEAUTH);
|
|
||||||
eloop_cancel_timeout(ap_handle_timer, hapd, sta);
|
|
||||||
eloop_register_timeout(AP_MAX_INACTIVITY_AFTER_DEAUTH, 0,
|
|
||||||
ap_handle_timer, hapd, sta);
|
|
||||||
accounting_sta_stop(hapd, sta);
|
|
||||||
ieee802_1x_free_station(hapd, sta);
|
|
||||||
|
|
||||||
sta->deauth_reason = reason;
|
sta->deauth_reason = reason;
|
||||||
sta->flags |= WLAN_STA_PENDING_DEAUTH_CB;
|
sta->flags |= WLAN_STA_PENDING_DEAUTH_CB;
|
||||||
|
|
Loading…
Reference in a new issue