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.
21 #include "sta_flags.h"
25 #include "common/ieee802_11_defs.h"
26 #include "tkip_countermeasures.h"
29 static void ieee80211_tkip_countermeasures_stop(void *eloop_ctx,
32 struct hostapd_data *hapd = eloop_ctx;
33 hapd->tkip_countermeasures = 0;
34 hostapd_set_countermeasures(hapd, 0);
35 hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
36 HOSTAPD_LEVEL_INFO, "TKIP countermeasures ended");
40 static void ieee80211_tkip_countermeasures_start(struct hostapd_data *hapd)
44 hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
45 HOSTAPD_LEVEL_INFO, "TKIP countermeasures initiated");
47 wpa_auth_countermeasures_start(hapd->wpa_auth);
48 hapd->tkip_countermeasures = 1;
49 hostapd_set_countermeasures(hapd, 1);
50 wpa_gtk_rekey(hapd->wpa_auth);
51 eloop_cancel_timeout(ieee80211_tkip_countermeasures_stop, hapd, NULL);
52 eloop_register_timeout(60, 0, ieee80211_tkip_countermeasures_stop,
54 for (sta = hapd->sta_list; sta != NULL; sta = sta->next) {
55 hostapd_sta_deauth(hapd, sta->addr,
56 WLAN_REASON_MICHAEL_MIC_FAILURE);
57 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC |
59 hostapd_sta_remove(hapd, sta->addr);
64 void michael_mic_failure(struct hostapd_data *hapd, const u8 *addr, int local)
69 struct sta_info *sta = ap_get_sta(hapd, addr);
71 wpa_auth_sta_local_mic_failure_report(sta->wpa_sm);
72 hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
74 "Michael MIC failure detected in "
76 mlme_michaelmicfailure_indication(hapd, addr);
79 "MLME-MICHAELMICFAILURE.indication "
80 "for not associated STA (" MACSTR
81 ") ignored", MAC2STR(addr));
87 if (now > hapd->michael_mic_failure + 60) {
88 hapd->michael_mic_failures = 1;
90 hapd->michael_mic_failures++;
91 if (hapd->michael_mic_failures > 1)
92 ieee80211_tkip_countermeasures_start(hapd);
94 hapd->michael_mic_failure = now;