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"; 32e28a4053SRui Paulo } 33e28a4053SRui Paulo 34e28a4053SRui Paulo return "unknown"; 35e28a4053SRui Paulo } 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)); 60e28a4053SRui Paulo if (sta->auth_alg != WLAN_AUTH_FT && !(sta->flags & WLAN_STA_MFP)) 61e28a4053SRui Paulo mlme_deletekeys_request(hapd, sta); 62*780fb4a2SCy Schubert ap_sta_clear_disconnect_timeouts(hapd, sta); 63e28a4053SRui Paulo } 64e28a4053SRui Paulo 65e28a4053SRui Paulo 66e28a4053SRui Paulo /** 67e28a4053SRui Paulo * mlme_deauthenticate_indication - Report the invalidation of an 68e28a4053SRui Paulo * authentication relationship with a specific peer MAC entity 69e28a4053SRui Paulo * @hapd: BSS data 70e28a4053SRui Paulo * @sta: Peer STA data 71e28a4053SRui Paulo * @reason_code: ReasonCode from Deauthentication frame 72e28a4053SRui Paulo * 73e28a4053SRui Paulo * MLME calls this function as a result of the invalidation of an 74e28a4053SRui Paulo * authentication relationship with a specific peer MAC entity. 75e28a4053SRui Paulo * 76e28a4053SRui Paulo * PeerSTAAddress = sta->addr 77e28a4053SRui Paulo */ 78e28a4053SRui Paulo void mlme_deauthenticate_indication(struct hostapd_data *hapd, 79e28a4053SRui Paulo struct sta_info *sta, u16 reason_code) 80e28a4053SRui Paulo { 81e28a4053SRui Paulo hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, 82e28a4053SRui Paulo HOSTAPD_LEVEL_DEBUG, 83e28a4053SRui Paulo "MLME-DEAUTHENTICATE.indication(" MACSTR ", %d)", 84e28a4053SRui Paulo MAC2STR(sta->addr), reason_code); 855b9c547cSRui Paulo if (!hapd->iface->driver_ap_teardown) 86e28a4053SRui Paulo mlme_deletekeys_request(hapd, sta); 87e28a4053SRui Paulo } 88e28a4053SRui Paulo 89e28a4053SRui Paulo 90e28a4053SRui Paulo /** 91e28a4053SRui Paulo * mlme_associate_indication - Report the establishment of an association with 92e28a4053SRui Paulo * a specific peer MAC entity 93e28a4053SRui Paulo * @hapd: BSS data 94e28a4053SRui Paulo * @sta: peer STA data 95e28a4053SRui Paulo * 96e28a4053SRui Paulo * MLME calls this function as a result of the establishment of an 97e28a4053SRui Paulo * association with a specific peer MAC entity that resulted from an 98e28a4053SRui Paulo * association procedure that was initiated by that specific peer MAC entity. 99e28a4053SRui Paulo * 100e28a4053SRui Paulo * PeerSTAAddress = sta->addr 101e28a4053SRui Paulo */ 102e28a4053SRui Paulo void mlme_associate_indication(struct hostapd_data *hapd, struct sta_info *sta) 103e28a4053SRui Paulo { 104e28a4053SRui Paulo hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, 105e28a4053SRui Paulo HOSTAPD_LEVEL_DEBUG, 106e28a4053SRui Paulo "MLME-ASSOCIATE.indication(" MACSTR ")", 107e28a4053SRui Paulo MAC2STR(sta->addr)); 108e28a4053SRui Paulo if (sta->auth_alg != WLAN_AUTH_FT) 109e28a4053SRui Paulo mlme_deletekeys_request(hapd, sta); 110*780fb4a2SCy Schubert ap_sta_clear_disconnect_timeouts(hapd, sta); 111e28a4053SRui Paulo } 112e28a4053SRui Paulo 113e28a4053SRui Paulo 114e28a4053SRui Paulo /** 115e28a4053SRui Paulo * mlme_reassociate_indication - Report the establishment of an reassociation 116e28a4053SRui Paulo * with a specific peer MAC entity 117e28a4053SRui Paulo * @hapd: BSS data 118e28a4053SRui Paulo * @sta: peer STA data 119e28a4053SRui Paulo * 120e28a4053SRui Paulo * MLME calls this function as a result of the establishment of an 121e28a4053SRui Paulo * reassociation with a specific peer MAC entity that resulted from a 122e28a4053SRui Paulo * reassociation procedure that was initiated by that specific peer MAC entity. 123e28a4053SRui Paulo * 124e28a4053SRui Paulo * PeerSTAAddress = sta->addr 125e28a4053SRui Paulo */ 126e28a4053SRui Paulo void mlme_reassociate_indication(struct hostapd_data *hapd, 127e28a4053SRui Paulo struct sta_info *sta) 128e28a4053SRui Paulo { 129e28a4053SRui Paulo hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, 130e28a4053SRui Paulo HOSTAPD_LEVEL_DEBUG, 131e28a4053SRui Paulo "MLME-REASSOCIATE.indication(" MACSTR ")", 132e28a4053SRui Paulo MAC2STR(sta->addr)); 133e28a4053SRui Paulo if (sta->auth_alg != WLAN_AUTH_FT) 134e28a4053SRui Paulo mlme_deletekeys_request(hapd, sta); 135*780fb4a2SCy Schubert ap_sta_clear_disconnect_timeouts(hapd, sta); 136e28a4053SRui Paulo } 137e28a4053SRui Paulo 138e28a4053SRui Paulo 139e28a4053SRui Paulo /** 140e28a4053SRui Paulo * mlme_disassociate_indication - Report disassociation with a specific peer 141e28a4053SRui Paulo * MAC entity 142e28a4053SRui Paulo * @hapd: BSS data 143e28a4053SRui Paulo * @sta: Peer STA data 144e28a4053SRui Paulo * @reason_code: ReasonCode from Disassociation frame 145e28a4053SRui Paulo * 146e28a4053SRui Paulo * MLME calls this function as a result of the invalidation of an association 147e28a4053SRui Paulo * relationship with a specific peer MAC entity. 148e28a4053SRui Paulo * 149e28a4053SRui Paulo * PeerSTAAddress = sta->addr 150e28a4053SRui Paulo */ 151e28a4053SRui Paulo void mlme_disassociate_indication(struct hostapd_data *hapd, 152e28a4053SRui Paulo struct sta_info *sta, u16 reason_code) 153e28a4053SRui Paulo { 154e28a4053SRui Paulo hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, 155e28a4053SRui Paulo HOSTAPD_LEVEL_DEBUG, 156e28a4053SRui Paulo "MLME-DISASSOCIATE.indication(" MACSTR ", %d)", 157e28a4053SRui Paulo MAC2STR(sta->addr), reason_code); 158e28a4053SRui Paulo mlme_deletekeys_request(hapd, sta); 159e28a4053SRui Paulo } 160e28a4053SRui Paulo 161e28a4053SRui Paulo 162e28a4053SRui Paulo void mlme_michaelmicfailure_indication(struct hostapd_data *hapd, 163e28a4053SRui Paulo const u8 *addr) 164e28a4053SRui Paulo { 165e28a4053SRui Paulo hostapd_logger(hapd, addr, HOSTAPD_MODULE_MLME, 166e28a4053SRui Paulo HOSTAPD_LEVEL_DEBUG, 167e28a4053SRui Paulo "MLME-MichaelMICFailure.indication(" MACSTR ")", 168e28a4053SRui Paulo MAC2STR(addr)); 169e28a4053SRui Paulo } 170e28a4053SRui Paulo 171e28a4053SRui Paulo 172e28a4053SRui Paulo void mlme_deletekeys_request(struct hostapd_data *hapd, struct sta_info *sta) 173e28a4053SRui Paulo { 174e28a4053SRui Paulo hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, 175e28a4053SRui Paulo HOSTAPD_LEVEL_DEBUG, 176e28a4053SRui Paulo "MLME-DELETEKEYS.request(" MACSTR ")", 177e28a4053SRui Paulo MAC2STR(sta->addr)); 178e28a4053SRui Paulo 179e28a4053SRui Paulo if (sta->wpa_sm) 180e28a4053SRui Paulo wpa_remove_ptk(sta->wpa_sm); 181e28a4053SRui Paulo } 182