AP: Move deauthentication/disassociation steps into helper functions
This is a step towards handling of deauthentication/disassociation from an MLD AP. Signed-off-by: Ilan Peer <ilan.peer@intel.com> Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
This commit is contained in:
parent
55038680a6
commit
62fcfe8d28
1 changed files with 49 additions and 32 deletions
|
@ -5507,28 +5507,38 @@ static void handle_assoc(struct hostapd_data *hapd,
|
|||
}
|
||||
|
||||
|
||||
static void handle_disassoc(struct hostapd_data *hapd,
|
||||
const struct ieee80211_mgmt *mgmt, size_t len)
|
||||
static void hostapd_deauth_sta(struct hostapd_data *hapd,
|
||||
struct sta_info *sta,
|
||||
const struct ieee80211_mgmt *mgmt)
|
||||
{
|
||||
struct sta_info *sta;
|
||||
wpa_msg(hapd->msg_ctx, MSG_DEBUG, "deauthentication: STA=" MACSTR
|
||||
" reason_code=%d",
|
||||
MAC2STR(mgmt->sa), le_to_host16(mgmt->u.deauth.reason_code));
|
||||
|
||||
if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.disassoc)) {
|
||||
wpa_printf(MSG_INFO, "handle_disassoc - too short payload (len=%lu)",
|
||||
(unsigned long) len);
|
||||
return;
|
||||
}
|
||||
ap_sta_set_authorized(hapd, sta, 0);
|
||||
sta->last_seq_ctrl = WLAN_INVALID_MGMT_SEQ;
|
||||
sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC |
|
||||
WLAN_STA_ASSOC_REQ_OK);
|
||||
hostapd_set_sta_flags(hapd, sta);
|
||||
wpa_auth_sm_event(sta->wpa_sm, WPA_DEAUTH);
|
||||
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
|
||||
HOSTAPD_LEVEL_DEBUG, "deauthenticated");
|
||||
mlme_deauthenticate_indication(
|
||||
hapd, sta, le_to_host16(mgmt->u.deauth.reason_code));
|
||||
sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
|
||||
ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
|
||||
ap_free_sta(hapd, sta);
|
||||
}
|
||||
|
||||
|
||||
static void hostapd_disassoc_sta(struct hostapd_data *hapd,
|
||||
struct sta_info *sta,
|
||||
const struct ieee80211_mgmt *mgmt)
|
||||
{
|
||||
wpa_printf(MSG_DEBUG, "disassocation: STA=" MACSTR " reason_code=%d",
|
||||
MAC2STR(mgmt->sa),
|
||||
le_to_host16(mgmt->u.disassoc.reason_code));
|
||||
|
||||
sta = ap_get_sta(hapd, mgmt->sa);
|
||||
if (sta == NULL) {
|
||||
wpa_printf(MSG_INFO, "Station " MACSTR " trying to disassociate, but it is not associated",
|
||||
MAC2STR(mgmt->sa));
|
||||
return;
|
||||
}
|
||||
|
||||
ap_sta_set_authorized(hapd, sta, 0);
|
||||
sta->last_seq_ctrl = WLAN_INVALID_MGMT_SEQ;
|
||||
sta->flags &= ~(WLAN_STA_ASSOC | WLAN_STA_ASSOC_REQ_OK);
|
||||
|
@ -5572,6 +5582,29 @@ static void handle_disassoc(struct hostapd_data *hapd,
|
|||
}
|
||||
|
||||
|
||||
static void handle_disassoc(struct hostapd_data *hapd,
|
||||
const struct ieee80211_mgmt *mgmt, size_t len)
|
||||
{
|
||||
struct sta_info *sta;
|
||||
|
||||
if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.disassoc)) {
|
||||
wpa_printf(MSG_INFO,
|
||||
"handle_disassoc - too short payload (len=%lu)",
|
||||
(unsigned long) len);
|
||||
return;
|
||||
}
|
||||
|
||||
sta = ap_get_sta(hapd, mgmt->sa);
|
||||
if (sta == NULL) {
|
||||
wpa_printf(MSG_INFO, "Station " MACSTR " trying to disassociate, but it is not associated",
|
||||
MAC2STR(mgmt->sa));
|
||||
return;
|
||||
}
|
||||
|
||||
hostapd_disassoc_sta(hapd, sta, mgmt);
|
||||
}
|
||||
|
||||
|
||||
static void handle_deauth(struct hostapd_data *hapd,
|
||||
const struct ieee80211_mgmt *mgmt, size_t len)
|
||||
{
|
||||
|
@ -5583,10 +5616,6 @@ static void handle_deauth(struct hostapd_data *hapd,
|
|||
return;
|
||||
}
|
||||
|
||||
wpa_msg(hapd->msg_ctx, MSG_DEBUG, "deauthentication: STA=" MACSTR
|
||||
" reason_code=%d",
|
||||
MAC2STR(mgmt->sa), le_to_host16(mgmt->u.deauth.reason_code));
|
||||
|
||||
/* Clear the PTKSA cache entries for PASN */
|
||||
ptksa_cache_flush(hapd->ptksa, mgmt->sa, WPA_CIPHER_NONE);
|
||||
|
||||
|
@ -5598,19 +5627,7 @@ static void handle_deauth(struct hostapd_data *hapd,
|
|||
return;
|
||||
}
|
||||
|
||||
ap_sta_set_authorized(hapd, sta, 0);
|
||||
sta->last_seq_ctrl = WLAN_INVALID_MGMT_SEQ;
|
||||
sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC |
|
||||
WLAN_STA_ASSOC_REQ_OK);
|
||||
hostapd_set_sta_flags(hapd, sta);
|
||||
wpa_auth_sm_event(sta->wpa_sm, WPA_DEAUTH);
|
||||
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
|
||||
HOSTAPD_LEVEL_DEBUG, "deauthenticated");
|
||||
mlme_deauthenticate_indication(
|
||||
hapd, sta, le_to_host16(mgmt->u.deauth.reason_code));
|
||||
sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
|
||||
ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
|
||||
ap_free_sta(hapd, sta);
|
||||
hostapd_deauth_sta(hapd, sta, mgmt);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue