Fixed TKIP countermeasueres for drivers that do not use hostapd MLME
authorJouni Malinen <jouni.malinen@atheros.com>
Fri, 9 Jan 2009 15:00:29 +0000 (17:00 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 9 Jan 2009 15:00:29 +0000 (17:00 +0200)
The Michael MIC reporting functions have to be included even when using
driver MLME.

hostapd/hostapd.c
hostapd/ieee802_11.c
hostapd/ieee802_11.h

index ee7df2f..3431d2d 100644 (file)
@@ -46,6 +46,7 @@
 #include "version.h"
 #include "l2_packet/l2_packet.h"
 #include "wps_hostapd.h"
+#include "mlme.h"
 
 
 static int hostapd_radius_get_eap_user(void *ctx, const u8 *identity,
@@ -216,6 +217,76 @@ static void hostapd_prune_associations(struct hostapd_data *hapd,
 }
 
 
+static void ieee80211_tkip_countermeasures_stop(void *eloop_ctx,
+                                               void *timeout_ctx)
+{
+       struct hostapd_data *hapd = eloop_ctx;
+       hapd->tkip_countermeasures = 0;
+       hostapd_set_countermeasures(hapd, 0);
+       hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
+                      HOSTAPD_LEVEL_INFO, "TKIP countermeasures ended");
+}
+
+
+static void ieee80211_tkip_countermeasures_start(struct hostapd_data *hapd)
+{
+       struct sta_info *sta;
+
+       hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
+                      HOSTAPD_LEVEL_INFO, "TKIP countermeasures initiated");
+
+       wpa_auth_countermeasures_start(hapd->wpa_auth);
+       hapd->tkip_countermeasures = 1;
+       hostapd_set_countermeasures(hapd, 1);
+       wpa_gtk_rekey(hapd->wpa_auth);
+       eloop_cancel_timeout(ieee80211_tkip_countermeasures_stop, hapd, NULL);
+       eloop_register_timeout(60, 0, ieee80211_tkip_countermeasures_stop,
+                              hapd, NULL);
+       for (sta = hapd->sta_list; sta != NULL; sta = sta->next) {
+               hostapd_sta_deauth(hapd, sta->addr,
+                                  WLAN_REASON_MICHAEL_MIC_FAILURE);
+               sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC |
+                               WLAN_STA_AUTHORIZED);
+               hostapd_sta_remove(hapd, sta->addr);
+       }
+}
+
+
+static void ieee80211_michael_mic_failure(struct hostapd_data *hapd,
+                                         const u8 *addr, int local)
+{
+       time_t now;
+
+       if (addr && local) {
+               struct sta_info *sta = ap_get_sta(hapd, addr);
+               if (sta != NULL) {
+                       wpa_auth_sta_local_mic_failure_report(sta->wpa_sm);
+                       hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
+                                      HOSTAPD_LEVEL_INFO,
+                                      "Michael MIC failure detected in "
+                                      "received frame");
+                       mlme_michaelmicfailure_indication(hapd, addr);
+               } else {
+                       wpa_printf(MSG_DEBUG,
+                                  "MLME-MICHAELMICFAILURE.indication "
+                                  "for not associated STA (" MACSTR
+                                  ") ignored", MAC2STR(addr));
+                       return;
+               }
+       }
+
+       time(&now);
+       if (now > hapd->michael_mic_failure + 60) {
+               hapd->michael_mic_failures = 1;
+       } else {
+               hapd->michael_mic_failures++;
+               if (hapd->michael_mic_failures > 1)
+                       ieee80211_tkip_countermeasures_start(hapd);
+       }
+       hapd->michael_mic_failure = now;
+}
+
+
 /**
  * hostapd_new_assoc_sta - Notify that a new station associated with the AP
  * @hapd: Pointer to BSS data
index 34b823f..0faf6e1 100644 (file)
@@ -1680,76 +1680,6 @@ void ieee802_11_mgmt_cb(struct hostapd_data *hapd, u8 *buf, size_t len,
 }
 
 
-static void ieee80211_tkip_countermeasures_stop(void *eloop_ctx,
-                                               void *timeout_ctx)
-{
-       struct hostapd_data *hapd = eloop_ctx;
-       hapd->tkip_countermeasures = 0;
-       hostapd_set_countermeasures(hapd, 0);
-       hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
-                      HOSTAPD_LEVEL_INFO, "TKIP countermeasures ended");
-}
-
-
-static void ieee80211_tkip_countermeasures_start(struct hostapd_data *hapd)
-{
-       struct sta_info *sta;
-
-       hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
-                      HOSTAPD_LEVEL_INFO, "TKIP countermeasures initiated");
-
-       wpa_auth_countermeasures_start(hapd->wpa_auth);
-       hapd->tkip_countermeasures = 1;
-       hostapd_set_countermeasures(hapd, 1);
-       wpa_gtk_rekey(hapd->wpa_auth);
-       eloop_cancel_timeout(ieee80211_tkip_countermeasures_stop, hapd, NULL);
-       eloop_register_timeout(60, 0, ieee80211_tkip_countermeasures_stop,
-                              hapd, NULL);
-       for (sta = hapd->sta_list; sta != NULL; sta = sta->next) {
-               hostapd_sta_deauth(hapd, sta->addr,
-                                  WLAN_REASON_MICHAEL_MIC_FAILURE);
-               sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC |
-                               WLAN_STA_AUTHORIZED);
-               hostapd_sta_remove(hapd, sta->addr);
-       }
-}
-
-
-void ieee80211_michael_mic_failure(struct hostapd_data *hapd, const u8 *addr,
-                                  int local)
-{
-       time_t now;
-
-       if (addr && local) {
-               struct sta_info *sta = ap_get_sta(hapd, addr);
-               if (sta != NULL) {
-                       wpa_auth_sta_local_mic_failure_report(sta->wpa_sm);
-                       hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
-                                      HOSTAPD_LEVEL_INFO,
-                                      "Michael MIC failure detected in "
-                                      "received frame");
-                       mlme_michaelmicfailure_indication(hapd, addr);
-               } else {
-                       wpa_printf(MSG_DEBUG,
-                                  "MLME-MICHAELMICFAILURE.indication "
-                                  "for not associated STA (" MACSTR
-                                  ") ignored", MAC2STR(addr));
-                       return;
-               }
-       }
-
-       time(&now);
-       if (now > hapd->michael_mic_failure + 60) {
-               hapd->michael_mic_failures = 1;
-       } else {
-               hapd->michael_mic_failures++;
-               if (hapd->michael_mic_failures > 1)
-                       ieee80211_tkip_countermeasures_start(hapd);
-       }
-       hapd->michael_mic_failure = now;
-}
-
-
 int ieee802_11_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen)
 {
        /* TODO */
index ff67861..c6b7ccb 100644 (file)
@@ -31,17 +31,10 @@ void ieee802_11_mgmt_cb(struct hostapd_data *hapd, u8 *buf, size_t len,
                        u16 stype, int ok);
 void ieee802_11_print_ssid(char *buf, const u8 *ssid, u8 len);
 #ifdef NEED_MLME
-void ieee80211_michael_mic_failure(struct hostapd_data *hapd, const u8 *addr,
-                                  int local);
 int ieee802_11_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen);
 int ieee802_11_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
                           char *buf, size_t buflen);
 #else /* NEED_MLME */
-static inline void ieee80211_michael_mic_failure(struct hostapd_data *hapd,
-                                                const u8 *addr, int local)
-{
-}
-
 static inline int ieee802_11_get_mib(struct hostapd_data *hapd, char *buf,
                                     size_t buflen)
 {