2 * hostapd / TKIP countermeasures
3 * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
24 #include "common/ieee802_11_defs.h"
25 #include "tkip_countermeasures.h"
28 static void ieee80211_tkip_countermeasures_stop(void *eloop_ctx,
31 struct hostapd_data *hapd = eloop_ctx;
32 hapd->tkip_countermeasures = 0;
33 hostapd_set_countermeasures(hapd, 0);
34 hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
35 HOSTAPD_LEVEL_INFO, "TKIP countermeasures ended");
39 static void ieee80211_tkip_countermeasures_start(struct hostapd_data *hapd)
43 hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
44 HOSTAPD_LEVEL_INFO, "TKIP countermeasures initiated");
46 wpa_auth_countermeasures_start(hapd->wpa_auth);
47 hapd->tkip_countermeasures = 1;
48 hostapd_set_countermeasures(hapd, 1);
49 wpa_gtk_rekey(hapd->wpa_auth);
50 eloop_cancel_timeout(ieee80211_tkip_countermeasures_stop, hapd, NULL);
51 eloop_register_timeout(60, 0, ieee80211_tkip_countermeasures_stop,
53 for (sta = hapd->sta_list; sta != NULL; sta = sta->next) {
54 hostapd_sta_deauth(hapd, sta->addr,
55 WLAN_REASON_MICHAEL_MIC_FAILURE);
56 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC |
58 hostapd_sta_remove(hapd, sta->addr);
63 void michael_mic_failure(struct hostapd_data *hapd, const u8 *addr, int local)
68 struct sta_info *sta = ap_get_sta(hapd, addr);
70 wpa_auth_sta_local_mic_failure_report(sta->wpa_sm);
71 hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
73 "Michael MIC failure detected in "
75 mlme_michaelmicfailure_indication(hapd, addr);
78 "MLME-MICHAELMICFAILURE.indication "
79 "for not associated STA (" MACSTR
80 ") ignored", MAC2STR(addr));
86 if (now > hapd->michael_mic_failure + 60) {
87 hapd->michael_mic_failures = 1;
89 hapd->michael_mic_failures++;
90 if (hapd->michael_mic_failures > 1)
91 ieee80211_tkip_countermeasures_start(hapd);
93 hapd->michael_mic_failure = now;