]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Flush WPS registrar state on wpa_supplicant FLUSH command
authorJouni Malinen <j@w1.fi>
Sun, 21 Dec 2014 15:32:35 +0000 (17:32 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 21 Dec 2014 15:47:42 +0000 (17:47 +0200)
This helps hwsim test cases by avoiding undesired state from previously
executed test cases affecting following tests.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/wps/wps.h
src/wps/wps_registrar.c
wpa_supplicant/ctrl_iface.c

index 192d283514a36084145a403f070f3cae3243f56a..0a7f65dfd6cb5220a3f41bbd56ff125a7cdc7fc4 100644 (file)
@@ -819,6 +819,7 @@ int wps_registrar_add_nfc_pw_token(struct wps_registrar *reg,
 int wps_registrar_add_nfc_password_token(struct wps_registrar *reg,
                                         const u8 *oob_dev_pw,
                                         size_t oob_dev_pw_len);
+void wps_registrar_flush(struct wps_registrar *reg);
 
 int wps_build_credential_wrap(struct wpabuf *msg,
                              const struct wps_credential *cred);
index ea6ea07dd5f29ecb03e02485ebbe76695b21d2c2..8ee1ea984115118038bad2fbc82a6312f20f3805 100644 (file)
@@ -676,6 +676,22 @@ wps_registrar_init(struct wps_context *wps,
 }
 
 
+void wps_registrar_flush(struct wps_registrar *reg)
+{
+       if (reg == NULL)
+               return;
+       wps_free_pins(&reg->pins);
+       wps_free_nfc_pw_tokens(&reg->nfc_pw_tokens, 0);
+       wps_free_pbc_sessions(reg->pbc_sessions);
+       reg->pbc_sessions = NULL;
+       wps_free_devices(reg->devices);
+       reg->devices = NULL;
+#ifdef WPS_WORKAROUNDS
+       reg->pbc_ignore_start.sec = 0;
+#endif /* WPS_WORKAROUNDS */
+}
+
+
 /**
  * wps_registrar_deinit - Deinitialize WPS Registrar data
  * @reg: Registrar data from wps_registrar_init()
@@ -686,11 +702,8 @@ void wps_registrar_deinit(struct wps_registrar *reg)
                return;
        eloop_cancel_timeout(wps_registrar_pbc_timeout, reg, NULL);
        eloop_cancel_timeout(wps_registrar_set_selected_timeout, reg, NULL);
-       wps_free_pins(&reg->pins);
-       wps_free_nfc_pw_tokens(&reg->nfc_pw_tokens, 0);
-       wps_free_pbc_sessions(reg->pbc_sessions);
+       wps_registrar_flush(reg);
        wpabuf_free(reg->extra_cred);
-       wps_free_devices(reg->devices);
        os_free(reg);
 }
 
index 9969716875903ca53c39348575a5db55d40932e1..e47a82c9c4cac731490e0e47c41c312b56667257 100644 (file)
@@ -5993,6 +5993,7 @@ static void wpa_supplicant_ctrl_iface_flush(struct wpa_supplicant *wpa_s)
 #ifdef CONFIG_WPS
        wpa_s->wps_fragment_size = 0;
        wpas_wps_cancel(wpa_s);
+       wps_registrar_flush(wpa_s->wps->registrar);
 #endif /* CONFIG_WPS */
        wpa_s->after_wps = 0;
        wpa_s->known_wps_freq = 0;