Move default_wep_key variable into EAPOL authenticator data
[wpasupplicant] / hostapd / eapol_sm.c
index 826d71d..5491fc4 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "includes.h"
 
-#include "hostapd.h"
+#include "common.h"
 #include "ieee802_1x.h"
 #include "eapol_sm.h"
 #include "eloop.h"
@@ -140,9 +140,14 @@ static void eapol_auth_tx_req(struct eapol_state_machine *sm)
 }
 
 
-/* Port Timers state machine - implemented as a function that will be called
- * once a second as a registered event loop timeout */
-
+/**
+ * eapol_port_timers_tick - Port Timers state machine
+ * @eloop_ctx: struct eapol_state_machine *
+ * @timeout_ctx: Not used
+ *
+ * This statemachine is implemented as a function that will be called
+ * once a second as a registered event loop timeout.
+ */
 static void eapol_port_timers_tick(void *eloop_ctx, void *timeout_ctx)
 {
        struct eapol_state_machine *state = timeout_ctx;
@@ -174,6 +179,15 @@ static void eapol_port_timers_tick(void *eloop_ctx, void *timeout_ctx)
                }
        }
 
+       if (state->eap_if->retransWhile > 0) {
+               state->eap_if->retransWhile--;
+               if (state->eap_if->retransWhile == 0) {
+                       wpa_printf(MSG_DEBUG, "IEEE 802.1X: " MACSTR
+                                  " - (EAP) retransWhile --> 0",
+                                  MAC2STR(state->addr));
+               }
+       }
+
        eapol_sm_step_run(state);
 
        eloop_register_timeout(1, 0, eapol_port_timers_tick, eloop_ctx, state);
@@ -790,7 +804,7 @@ eapol_auth_alloc(struct eapol_authenticator *eapol, const u8 *addr,
        sm->portControl = Auto;
 
        if (!eapol->conf.wpa &&
-           (hapd->default_wep_key || eapol->conf.individual_wep_key_len > 0))
+           (eapol->default_wep_key || eapol->conf.individual_wep_key_len > 0))
                sm->keyTxEnabled = TRUE;
        else
                sm->keyTxEnabled = FALSE;
@@ -932,6 +946,13 @@ static void eapol_sm_step_cb(void *eloop_ctx, void *timeout_ctx)
 }
 
 
+/**
+ * eapol_auth_step - Advance EAPOL state machines
+ * @sm: EAPOL state machine
+ *
+ * This function is called to advance EAPOL state machines after any change
+ * that could affect their state.
+ */
 void eapol_auth_step(struct eapol_state_machine *sm)
 {
        /*
@@ -1297,6 +1318,11 @@ struct eapol_authenticator * eapol_auth_init(struct eapol_auth_config *conf,
                return NULL;
        }
 
+       if (conf->individual_wep_key_len > 0) {
+               /* use key0 in individual key and key1 in broadcast key */
+               eapol->default_wep_key_idx = 1;
+       }
+
        eapol->cb.eapol_send = cb->eapol_send;
        eapol->cb.aaa_send = cb->aaa_send;
        eapol->cb.finished = cb->finished;
@@ -1317,5 +1343,6 @@ void eapol_auth_deinit(struct eapol_authenticator *eapol)
                return;
 
        eapol_auth_conf_free(&eapol->conf);
+       os_free(eapol->default_wep_key);
        os_free(eapol);
 }