1e28a4053SRui Paulo /* 2e28a4053SRui Paulo * hostapd / IEEE 802.11 MLME 3e28a4053SRui Paulo * Copyright 2003-2006, Jouni Malinen <j@w1.fi> 4e28a4053SRui Paulo * Copyright 2003-2004, Instant802 Networks, Inc. 5e28a4053SRui Paulo * Copyright 2005-2006, Devicescape Software, Inc. 6e28a4053SRui Paulo * 7f05cddf9SRui Paulo * This software may be distributed under the terms of the BSD license. 8f05cddf9SRui Paulo * See README for more details. 9e28a4053SRui Paulo */ 10e28a4053SRui Paulo 11e28a4053SRui Paulo #include "utils/includes.h" 12e28a4053SRui Paulo 13e28a4053SRui Paulo #include "utils/common.h" 14e28a4053SRui Paulo #include "common/ieee802_11_defs.h" 15e28a4053SRui Paulo #include "ieee802_11.h" 16e28a4053SRui Paulo #include "wpa_auth.h" 17e28a4053SRui Paulo #include "sta_info.h" 18e28a4053SRui Paulo #include "ap_mlme.h" 195b9c547cSRui Paulo #include "hostapd.h" 20e28a4053SRui Paulo 21e28a4053SRui Paulo 22e28a4053SRui Paulo #ifndef CONFIG_NO_HOSTAPD_LOGGER 23e28a4053SRui Paulo static const char * mlme_auth_alg_str(int alg) 24e28a4053SRui Paulo { 25e28a4053SRui Paulo switch (alg) { 26e28a4053SRui Paulo case WLAN_AUTH_OPEN: 27e28a4053SRui Paulo return "OPEN_SYSTEM"; 28e28a4053SRui Paulo case WLAN_AUTH_SHARED_KEY: 29e28a4053SRui Paulo return "SHARED_KEY"; 30e28a4053SRui Paulo case WLAN_AUTH_FT: 31e28a4053SRui Paulo return "FT"; 32*a90b9d01SCy Schubert default: 33e28a4053SRui Paulo return "unknown"; 34e28a4053SRui Paulo } 35*a90b9d01SCy Schubert } 36e28a4053SRui Paulo #endif /* CONFIG_NO_HOSTAPD_LOGGER */ 37e28a4053SRui Paulo 38e28a4053SRui Paulo 39e28a4053SRui Paulo /** 40e28a4053SRui Paulo * mlme_authenticate_indication - Report the establishment of an authentication 41e28a4053SRui Paulo * relationship with a specific peer MAC entity 42e28a4053SRui Paulo * @hapd: BSS data 43e28a4053SRui Paulo * @sta: peer STA data 44e28a4053SRui Paulo * 45e28a4053SRui Paulo * MLME calls this function as a result of the establishment of an 46e28a4053SRui Paulo * authentication relationship with a specific peer MAC entity that 47e28a4053SRui Paulo * resulted from an authentication procedure that was initiated by 48e28a4053SRui Paulo * that specific peer MAC entity. 49e28a4053SRui Paulo * 50e28a4053SRui Paulo * PeerSTAAddress = sta->addr 51e28a4053SRui Paulo * AuthenticationType = sta->auth_alg (WLAN_AUTH_OPEN / WLAN_AUTH_SHARED_KEY) 52e28a4053SRui Paulo */ 53e28a4053SRui Paulo void mlme_authenticate_indication(struct hostapd_data *hapd, 54e28a4053SRui Paulo struct sta_info *sta) 55e28a4053SRui Paulo { 56e28a4053SRui Paulo hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, 57e28a4053SRui Paulo HOSTAPD_LEVEL_DEBUG, 58e28a4053SRui Paulo "MLME-AUTHENTICATE.indication(" MACSTR ", %s)", 59e28a4053SRui Paulo MAC2STR(sta->addr), mlme_auth_alg_str(sta->auth_alg)); 6085732ac8SCy Schubert if (sta->auth_alg != WLAN_AUTH_FT && 6185732ac8SCy Schubert sta->auth_alg != WLAN_AUTH_FILS_SK && 6285732ac8SCy Schubert sta->auth_alg != WLAN_AUTH_FILS_SK_PFS && 6385732ac8SCy Schubert sta->auth_alg != WLAN_AUTH_FILS_PK && 6485732ac8SCy Schubert !(sta->flags & WLAN_STA_MFP)) 65e28a4053SRui Paulo mlme_deletekeys_request(hapd, sta); 66780fb4a2SCy Schubert ap_sta_clear_disconnect_timeouts(hapd, sta); 67e28a4053SRui Paulo } 68e28a4053SRui Paulo 69e28a4053SRui Paulo 70e28a4053SRui Paulo /** 71e28a4053SRui Paulo * mlme_deauthenticate_indication - Report the invalidation of an 72e28a4053SRui Paulo * authentication relationship with a specific peer MAC entity 73e28a4053SRui Paulo * @hapd: BSS data 74e28a4053SRui Paulo * @sta: Peer STA data 75e28a4053SRui Paulo * @reason_code: ReasonCode from Deauthentication frame 76e28a4053SRui Paulo * 77e28a4053SRui Paulo * MLME calls this function as a result of the invalidation of an 78e28a4053SRui Paulo * authentication relationship with a specific peer MAC entity. 79e28a4053SRui Paulo * 80e28a4053SRui Paulo * PeerSTAAddress = sta->addr 81e28a4053SRui Paulo */ 82e28a4053SRui Paulo void mlme_deauthenticate_indication(struct hostapd_data *hapd, 83e28a4053SRui Paulo struct sta_info *sta, u16 reason_code) 84e28a4053SRui Paulo { 85e28a4053SRui Paulo hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, 86e28a4053SRui Paulo HOSTAPD_LEVEL_DEBUG, 87e28a4053SRui Paulo "MLME-DEAUTHENTICATE.indication(" MACSTR ", %d)", 88e28a4053SRui Paulo MAC2STR(sta->addr), reason_code); 895b9c547cSRui Paulo if (!hapd->iface->driver_ap_teardown) 90e28a4053SRui Paulo mlme_deletekeys_request(hapd, sta); 91e28a4053SRui Paulo } 92e28a4053SRui Paulo 93e28a4053SRui Paulo 94e28a4053SRui Paulo /** 95e28a4053SRui Paulo * mlme_associate_indication - Report the establishment of an association with 96e28a4053SRui Paulo * a specific peer MAC entity 97e28a4053SRui Paulo * @hapd: BSS data 98e28a4053SRui Paulo * @sta: peer STA data 99e28a4053SRui Paulo * 100e28a4053SRui Paulo * MLME calls this function as a result of the establishment of an 101e28a4053SRui Paulo * association with a specific peer MAC entity that resulted from an 102e28a4053SRui Paulo * association procedure that was initiated by that specific peer MAC entity. 103e28a4053SRui Paulo * 104e28a4053SRui Paulo * PeerSTAAddress = sta->addr 105e28a4053SRui Paulo */ 106e28a4053SRui Paulo void mlme_associate_indication(struct hostapd_data *hapd, struct sta_info *sta) 107e28a4053SRui Paulo { 108e28a4053SRui Paulo hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, 109e28a4053SRui Paulo HOSTAPD_LEVEL_DEBUG, 110e28a4053SRui Paulo "MLME-ASSOCIATE.indication(" MACSTR ")", 111e28a4053SRui Paulo MAC2STR(sta->addr)); 11285732ac8SCy Schubert if (sta->auth_alg != WLAN_AUTH_FT && 11385732ac8SCy Schubert sta->auth_alg != WLAN_AUTH_FILS_SK && 11485732ac8SCy Schubert sta->auth_alg != WLAN_AUTH_FILS_SK_PFS && 11585732ac8SCy Schubert sta->auth_alg != WLAN_AUTH_FILS_PK) 116e28a4053SRui Paulo mlme_deletekeys_request(hapd, sta); 117780fb4a2SCy Schubert ap_sta_clear_disconnect_timeouts(hapd, sta); 118e28a4053SRui Paulo } 119e28a4053SRui Paulo 120e28a4053SRui Paulo 121e28a4053SRui Paulo /** 122e28a4053SRui Paulo * mlme_reassociate_indication - Report the establishment of an reassociation 123e28a4053SRui Paulo * with a specific peer MAC entity 124e28a4053SRui Paulo * @hapd: BSS data 125e28a4053SRui Paulo * @sta: peer STA data 126e28a4053SRui Paulo * 127e28a4053SRui Paulo * MLME calls this function as a result of the establishment of an 128e28a4053SRui Paulo * reassociation with a specific peer MAC entity that resulted from a 129e28a4053SRui Paulo * reassociation procedure that was initiated by that specific peer MAC entity. 130e28a4053SRui Paulo * 131e28a4053SRui Paulo * PeerSTAAddress = sta->addr 132e28a4053SRui Paulo */ 133e28a4053SRui Paulo void mlme_reassociate_indication(struct hostapd_data *hapd, 134e28a4053SRui Paulo struct sta_info *sta) 135e28a4053SRui Paulo { 136e28a4053SRui Paulo hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, 137e28a4053SRui Paulo HOSTAPD_LEVEL_DEBUG, 138e28a4053SRui Paulo "MLME-REASSOCIATE.indication(" MACSTR ")", 139e28a4053SRui Paulo MAC2STR(sta->addr)); 14085732ac8SCy Schubert if (sta->auth_alg != WLAN_AUTH_FT && 14185732ac8SCy Schubert sta->auth_alg != WLAN_AUTH_FILS_SK && 14285732ac8SCy Schubert sta->auth_alg != WLAN_AUTH_FILS_SK_PFS && 14385732ac8SCy Schubert sta->auth_alg != WLAN_AUTH_FILS_PK) 144e28a4053SRui Paulo mlme_deletekeys_request(hapd, sta); 145780fb4a2SCy Schubert ap_sta_clear_disconnect_timeouts(hapd, sta); 146e28a4053SRui Paulo } 147e28a4053SRui Paulo 148e28a4053SRui Paulo 149e28a4053SRui Paulo /** 150e28a4053SRui Paulo * mlme_disassociate_indication - Report disassociation with a specific peer 151e28a4053SRui Paulo * MAC entity 152e28a4053SRui Paulo * @hapd: BSS data 153e28a4053SRui Paulo * @sta: Peer STA data 154e28a4053SRui Paulo * @reason_code: ReasonCode from Disassociation frame 155e28a4053SRui Paulo * 156e28a4053SRui Paulo * MLME calls this function as a result of the invalidation of an association 157e28a4053SRui Paulo * relationship with a specific peer MAC entity. 158e28a4053SRui Paulo * 159e28a4053SRui Paulo * PeerSTAAddress = sta->addr 160e28a4053SRui Paulo */ 161e28a4053SRui Paulo void mlme_disassociate_indication(struct hostapd_data *hapd, 162e28a4053SRui Paulo struct sta_info *sta, u16 reason_code) 163e28a4053SRui Paulo { 164e28a4053SRui Paulo hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, 165e28a4053SRui Paulo HOSTAPD_LEVEL_DEBUG, 166e28a4053SRui Paulo "MLME-DISASSOCIATE.indication(" MACSTR ", %d)", 167e28a4053SRui Paulo MAC2STR(sta->addr), reason_code); 168e28a4053SRui Paulo mlme_deletekeys_request(hapd, sta); 169e28a4053SRui Paulo } 170e28a4053SRui Paulo 171e28a4053SRui Paulo 172e28a4053SRui Paulo void mlme_michaelmicfailure_indication(struct hostapd_data *hapd, 173e28a4053SRui Paulo const u8 *addr) 174e28a4053SRui Paulo { 175e28a4053SRui Paulo hostapd_logger(hapd, addr, HOSTAPD_MODULE_MLME, 176e28a4053SRui Paulo HOSTAPD_LEVEL_DEBUG, 177e28a4053SRui Paulo "MLME-MichaelMICFailure.indication(" MACSTR ")", 178e28a4053SRui Paulo MAC2STR(addr)); 179e28a4053SRui Paulo } 180e28a4053SRui Paulo 181e28a4053SRui Paulo 182e28a4053SRui Paulo void mlme_deletekeys_request(struct hostapd_data *hapd, struct sta_info *sta) 183e28a4053SRui Paulo { 184e28a4053SRui Paulo hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, 185e28a4053SRui Paulo HOSTAPD_LEVEL_DEBUG, 186e28a4053SRui Paulo "MLME-DELETEKEYS.request(" MACSTR ")", 187e28a4053SRui Paulo MAC2STR(sta->addr)); 188e28a4053SRui Paulo 189e28a4053SRui Paulo if (sta->wpa_sm) 190e28a4053SRui Paulo wpa_remove_ptk(sta->wpa_sm); 191e28a4053SRui Paulo } 192