ap_mlme.c revision 8d520ff1dc2da35cdca849e982051b86468016d8
1a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)/* 2a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) * hostapd / IEEE 802.11 MLME 3a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) * Copyright 2003-2006, Jouni Malinen <j@w1.fi> 4a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) * Copyright 2003-2004, Instant802 Networks, Inc. 5a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) * Copyright 2005-2006, Devicescape Software, Inc. 6a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) * 7a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) * This program is free software; you can redistribute it and/or modify 8a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) * it under the terms of the GNU General Public License version 2 as 9a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) * published by the Free Software Foundation. 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) * 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) * Alternatively, this software may be distributed under the terms of BSD 121320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci * license. 131320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci * 141320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci * See README and COPYING for more details. 151320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci */ 16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 171320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "utils/includes.h" 18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 19cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "utils/common.h" 20cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "common/ieee802_11_defs.h" 21cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "ieee802_11.h" 22a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "wpa_auth.h" 2346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#include "sta_info.h" 2446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#include "ap_mlme.h" 2546d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 2646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 2746d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#ifndef CONFIG_NO_HOSTAPD_LOGGER 2846d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)static const char * mlme_auth_alg_str(int alg) 2946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles){ 3046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) switch (alg) { 31a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) case WLAN_AUTH_OPEN: 32a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return "OPEN_SYSTEM"; 33cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) case WLAN_AUTH_SHARED_KEY: 34cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) return "SHARED_KEY"; 35cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) case WLAN_AUTH_FT: 36cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) return "FT"; 37cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) } 381320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 391320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci return "unknown"; 40cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)} 41cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#endif /* CONFIG_NO_HOSTAPD_LOGGER */ 42cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 43cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 44cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)/** 45cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * mlme_authenticate_indication - Report the establishment of an authentication 461320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci * relationship with a specific peer MAC entity 471320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci * @hapd: BSS data 481320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci * @sta: peer STA data 491320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci * 501320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci * MLME calls this function as a result of the establishment of an 511320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci * authentication relationship with a specific peer MAC entity that 52a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) * resulted from an authentication procedure that was initiated by 53cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * that specific peer MAC entity. 54a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) * 55a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) * PeerSTAAddress = sta->addr 565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) * AuthenticationType = sta->auth_alg (WLAN_AUTH_OPEN / WLAN_AUTH_SHARED_KEY) 571320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci */ 581320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid mlme_authenticate_indication(struct hostapd_data *hapd, 591320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci struct sta_info *sta) 601320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci{ 611320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, 621320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci HOSTAPD_LEVEL_DEBUG, 63a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) "MLME-AUTHENTICATE.indication(" MACSTR ", %s)", 6446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) MAC2STR(sta->addr), mlme_auth_alg_str(sta->auth_alg)); 651320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (sta->auth_alg != WLAN_AUTH_FT && !(sta->flags & WLAN_STA_MFP)) 661320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci mlme_deletekeys_request(hapd, sta); 671320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci} 681320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 691320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 701320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci/** 711320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci * mlme_deauthenticate_indication - Report the invalidation of an 7246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) * authentication relationship with a specific peer MAC entity 7346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) * @hapd: BSS data 74a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) * @sta: Peer STA data 75a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) * @reason_code: ReasonCode from Deauthentication frame 76a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) * 77a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) * MLME calls this function as a result of the invalidation of an 78a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) * authentication relationship with a specific peer MAC entity. 79a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) * 80a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) * PeerSTAAddress = sta->addr 81 */ 82void mlme_deauthenticate_indication(struct hostapd_data *hapd, 83 struct sta_info *sta, u16 reason_code) 84{ 85 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, 86 HOSTAPD_LEVEL_DEBUG, 87 "MLME-DEAUTHENTICATE.indication(" MACSTR ", %d)", 88 MAC2STR(sta->addr), reason_code); 89 mlme_deletekeys_request(hapd, sta); 90} 91 92 93/** 94 * mlme_associate_indication - Report the establishment of an association with 95 * a specific peer MAC entity 96 * @hapd: BSS data 97 * @sta: peer STA data 98 * 99 * MLME calls this function as a result of the establishment of an 100 * association with a specific peer MAC entity that resulted from an 101 * association procedure that was initiated by that specific peer MAC entity. 102 * 103 * PeerSTAAddress = sta->addr 104 */ 105void mlme_associate_indication(struct hostapd_data *hapd, struct sta_info *sta) 106{ 107 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, 108 HOSTAPD_LEVEL_DEBUG, 109 "MLME-ASSOCIATE.indication(" MACSTR ")", 110 MAC2STR(sta->addr)); 111 if (sta->auth_alg != WLAN_AUTH_FT) 112 mlme_deletekeys_request(hapd, sta); 113} 114 115 116/** 117 * mlme_reassociate_indication - Report the establishment of an reassociation 118 * with a specific peer MAC entity 119 * @hapd: BSS data 120 * @sta: peer STA data 121 * 122 * MLME calls this function as a result of the establishment of an 123 * reassociation with a specific peer MAC entity that resulted from a 124 * reassociation procedure that was initiated by that specific peer MAC entity. 125 * 126 * PeerSTAAddress = sta->addr 127 * 128 * sta->previous_ap contains the "Current AP" information from ReassocReq. 129 */ 130void mlme_reassociate_indication(struct hostapd_data *hapd, 131 struct sta_info *sta) 132{ 133 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, 134 HOSTAPD_LEVEL_DEBUG, 135 "MLME-REASSOCIATE.indication(" MACSTR ")", 136 MAC2STR(sta->addr)); 137 if (sta->auth_alg != WLAN_AUTH_FT) 138 mlme_deletekeys_request(hapd, sta); 139} 140 141 142/** 143 * mlme_disassociate_indication - Report disassociation with a specific peer 144 * MAC entity 145 * @hapd: BSS data 146 * @sta: Peer STA data 147 * @reason_code: ReasonCode from Disassociation frame 148 * 149 * MLME calls this function as a result of the invalidation of an association 150 * relationship with a specific peer MAC entity. 151 * 152 * PeerSTAAddress = sta->addr 153 */ 154void mlme_disassociate_indication(struct hostapd_data *hapd, 155 struct sta_info *sta, u16 reason_code) 156{ 157 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, 158 HOSTAPD_LEVEL_DEBUG, 159 "MLME-DISASSOCIATE.indication(" MACSTR ", %d)", 160 MAC2STR(sta->addr), reason_code); 161 mlme_deletekeys_request(hapd, sta); 162} 163 164 165void mlme_michaelmicfailure_indication(struct hostapd_data *hapd, 166 const u8 *addr) 167{ 168 hostapd_logger(hapd, addr, HOSTAPD_MODULE_MLME, 169 HOSTAPD_LEVEL_DEBUG, 170 "MLME-MichaelMICFailure.indication(" MACSTR ")", 171 MAC2STR(addr)); 172} 173 174 175void mlme_deletekeys_request(struct hostapd_data *hapd, struct sta_info *sta) 176{ 177 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, 178 HOSTAPD_LEVEL_DEBUG, 179 "MLME-DELETEKEYS.request(" MACSTR ")", 180 MAC2STR(sta->addr)); 181 182 if (sta->wpa_sm) 183 wpa_remove_ptk(sta->wpa_sm); 184} 185