tkip_countermeasures.c

Go to the documentation of this file.
00001 
00016 #include "includes.h"
00017 
00018 #include "hostapd.h"
00019 #include "eloop.h"
00020 #include "driver_i.h"
00021 #include "sta_info.h"
00022 #include "mlme.h"
00023 #include "wpa.h"
00024 #include "ieee802_11_defs.h"
00025 #include "tkip_countermeasures.h"
00026 
00027 
00028 static void ieee80211_tkip_countermeasures_stop(void *eloop_ctx,
00029                                                 void *timeout_ctx)
00030 {
00031         struct hostapd_data *hapd = eloop_ctx;
00032         hapd->tkip_countermeasures = 0;
00033         hostapd_set_countermeasures(hapd, 0);
00034         hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
00035                        HOSTAPD_LEVEL_INFO, "TKIP countermeasures ended");
00036 }
00037 
00038 
00039 static void ieee80211_tkip_countermeasures_start(struct hostapd_data *hapd)
00040 {
00041         struct sta_info *sta;
00042 
00043         hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
00044                        HOSTAPD_LEVEL_INFO, "TKIP countermeasures initiated");
00045 
00046         wpa_auth_countermeasures_start(hapd->wpa_auth);
00047         hapd->tkip_countermeasures = 1;
00048         hostapd_set_countermeasures(hapd, 1);
00049         wpa_gtk_rekey(hapd->wpa_auth);
00050         eloop_cancel_timeout(ieee80211_tkip_countermeasures_stop, hapd, NULL);
00051         eloop_register_timeout(60, 0, ieee80211_tkip_countermeasures_stop,
00052                                hapd, NULL);
00053         for (sta = hapd->sta_list; sta != NULL; sta = sta->next) {
00054                 hostapd_sta_deauth(hapd, sta->addr,
00055                                    WLAN_REASON_MICHAEL_MIC_FAILURE);
00056                 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC |
00057                                 WLAN_STA_AUTHORIZED);
00058                 hostapd_sta_remove(hapd, sta->addr);
00059         }
00060 }
00061 
00062 
00063 void michael_mic_failure(struct hostapd_data *hapd, const u8 *addr, int local)
00064 {
00065         time_t now;
00066 
00067         if (addr && local) {
00068                 struct sta_info *sta = ap_get_sta(hapd, addr);
00069                 if (sta != NULL) {
00070                         wpa_auth_sta_local_mic_failure_report(sta->wpa_sm);
00071                         hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
00072                                        HOSTAPD_LEVEL_INFO,
00073                                        "Michael MIC failure detected in "
00074                                        "received frame");
00075                         mlme_michaelmicfailure_indication(hapd, addr);
00076                 } else {
00077                         wpa_printf(MSG_DEBUG,
00078                                    "MLME-MICHAELMICFAILURE.indication "
00079                                    "for not associated STA (" MACSTR
00080                                    ") ignored", MAC2STR(addr));
00081                         return;
00082                 }
00083         }
00084 
00085         time(&now);
00086         if (now > hapd->michael_mic_failure + 60) {
00087                 hapd->michael_mic_failures = 1;
00088         } else {
00089                 hapd->michael_mic_failures++;
00090                 if (hapd->michael_mic_failures > 1)
00091                         ieee80211_tkip_countermeasures_start(hapd);
00092         }
00093         hapd->michael_mic_failure = now;
00094 }
00095 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on Sat Nov 21 23:16:48 2009 for hostapd by  doxygen 1.6.1