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