Fix couple of forgotten wpa_hw_modes -> hostapd_hw_modes
[wpasupplicant] / hostapd / eapol_sm.c
index 4bf0ff4..8e9d56c 100644 (file)
@@ -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);
@@ -356,15 +370,15 @@ SM_STEP(AUTH_PAE)
 {
        if ((sm->portControl == Auto && sm->portMode != sm->portControl) ||
            sm->initialize || !sm->eap_if->portEnabled)
-               SM_ENTER(AUTH_PAE, INITIALIZE);
+               SM_ENTER_GLOBAL(AUTH_PAE, INITIALIZE);
        else if (sm->portControl == ForceAuthorized &&
                 sm->portMode != sm->portControl &&
                 !(sm->initialize || !sm->eap_if->portEnabled))
-               SM_ENTER(AUTH_PAE, FORCE_AUTH);
+               SM_ENTER_GLOBAL(AUTH_PAE, FORCE_AUTH);
        else if (sm->portControl == ForceUnauthorized &&
                 sm->portMode != sm->portControl &&
                 !(sm->initialize || !sm->eap_if->portEnabled))
-               SM_ENTER(AUTH_PAE, FORCE_UNAUTH);
+               SM_ENTER_GLOBAL(AUTH_PAE, FORCE_UNAUTH);
        else {
                switch (sm->auth_pae_state) {
                case AUTH_PAE_INITIALIZE:
@@ -520,7 +534,7 @@ SM_STATE(BE_AUTH, IGNORE)
 SM_STEP(BE_AUTH)
 {
        if (sm->portControl != Auto || sm->initialize || sm->authAbort) {
-               SM_ENTER(BE_AUTH, INITIALIZE);
+               SM_ENTER_GLOBAL(BE_AUTH, INITIALIZE);
                return;
        }
 
@@ -605,7 +619,7 @@ SM_STEP(REAUTH_TIMER)
 {
        if (sm->portControl != Auto || sm->initialize ||
            sm->authPortStatus == Unauthorized || !sm->reAuthEnabled) {
-               SM_ENTER(REAUTH_TIMER, INITIALIZE);
+               SM_ENTER_GLOBAL(REAUTH_TIMER, INITIALIZE);
                return;
        }
 
@@ -643,7 +657,7 @@ SM_STATE(AUTH_KEY_TX, KEY_TRANSMIT)
 SM_STEP(AUTH_KEY_TX)
 {
        if (sm->initialize || sm->portControl != Auto) {
-               SM_ENTER(AUTH_KEY_TX, NO_KEY_TRANSMIT);
+               SM_ENTER_GLOBAL(AUTH_KEY_TX, NO_KEY_TRANSMIT);
                return;
        }
 
@@ -684,7 +698,7 @@ SM_STATE(KEY_RX, KEY_RECEIVE)
 SM_STEP(KEY_RX)
 {
        if (sm->initialize || !sm->eap_if->portEnabled) {
-               SM_ENTER(KEY_RX, NO_KEY_RECEIVE);
+               SM_ENTER_GLOBAL(KEY_RX, NO_KEY_RECEIVE);
                return;
        }
 
@@ -721,7 +735,7 @@ SM_STATE(CTRL_DIR, IN_OR_BOTH)
 SM_STEP(CTRL_DIR)
 {
        if (sm->initialize) {
-               SM_ENTER(CTRL_DIR, IN_OR_BOTH);
+               SM_ENTER_GLOBAL(CTRL_DIR, IN_OR_BOTH);
                return;
        }
 
@@ -805,7 +819,15 @@ eapol_auth_alloc(struct eapol_authenticator *eapol, const u8 *addr,
        eap_conf.eap_sim_db_priv = eapol->conf.eap_sim_db_priv;
        eap_conf.pac_opaque_encr_key = eapol->conf.pac_opaque_encr_key;
        eap_conf.eap_fast_a_id = eapol->conf.eap_fast_a_id;
+       eap_conf.eap_fast_a_id_len = eapol->conf.eap_fast_a_id_len;
+       eap_conf.eap_fast_a_id_info = eapol->conf.eap_fast_a_id_info;
+       eap_conf.eap_fast_prov = eapol->conf.eap_fast_prov;
+       eap_conf.pac_key_lifetime = eapol->conf.pac_key_lifetime;
+       eap_conf.pac_key_refresh_time = eapol->conf.pac_key_refresh_time;
        eap_conf.eap_sim_aka_result_ind = eapol->conf.eap_sim_aka_result_ind;
+       eap_conf.tnc = eapol->conf.tnc;
+       eap_conf.wps = eapol->conf.wps;
+       eap_conf.assoc_wps_ie = sta->wps_ie;
        sm->eap = eap_server_sm_init(sm, &eapol_cb, &eap_conf);
        if (sm->eap == NULL) {
                eapol_auth_free(sm);
@@ -924,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)
 {
        /*
@@ -1232,11 +1261,32 @@ static int eapol_auth_conf_clone(struct eapol_auth_config *dst,
                          16);
        } else
                dst->pac_opaque_encr_key = NULL;
-       if (src->eap_fast_a_id)
-               dst->eap_fast_a_id = os_strdup(src->eap_fast_a_id);
-       else
+       if (src->eap_fast_a_id) {
+               dst->eap_fast_a_id = os_malloc(src->eap_fast_a_id_len);
+               if (dst->eap_fast_a_id == NULL) {
+                       os_free(dst->eap_req_id_text);
+                       return -1;
+               }
+               os_memcpy(dst->eap_fast_a_id, src->eap_fast_a_id,
+                         src->eap_fast_a_id_len);
+               dst->eap_fast_a_id_len = src->eap_fast_a_id_len;
+       } else
                dst->eap_fast_a_id = NULL;
+       if (src->eap_fast_a_id_info) {
+               dst->eap_fast_a_id_info = os_strdup(src->eap_fast_a_id_info);
+               if (dst->eap_fast_a_id_info == NULL) {
+                       os_free(dst->eap_req_id_text);
+                       os_free(dst->eap_fast_a_id);
+                       return -1;
+               }
+       } else
+               dst->eap_fast_a_id_info = NULL;
+       dst->eap_fast_prov = src->eap_fast_prov;
+       dst->pac_key_lifetime = src->pac_key_lifetime;
+       dst->pac_key_refresh_time = src->pac_key_refresh_time;
        dst->eap_sim_aka_result_ind = src->eap_sim_aka_result_ind;
+       dst->tnc = src->tnc;
+       dst->wps = src->wps;
        return 0;
 }
 
@@ -1249,6 +1299,8 @@ static void eapol_auth_conf_free(struct eapol_auth_config *conf)
        conf->pac_opaque_encr_key = NULL;
        os_free(conf->eap_fast_a_id);
        conf->eap_fast_a_id = NULL;
+       os_free(conf->eap_fast_a_id_info);
+       conf->eap_fast_a_id_info = NULL;
 }