Flush WPS registrar state on wpa_supplicant FLUSH command

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>
This commit is contained in:
Jouni Malinen 2014-12-21 17:32:35 +02:00
parent 01c87519a3
commit 422ba11e30
3 changed files with 19 additions and 4 deletions

View 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, int wps_registrar_add_nfc_password_token(struct wps_registrar *reg,
const u8 *oob_dev_pw, const u8 *oob_dev_pw,
size_t oob_dev_pw_len); size_t oob_dev_pw_len);
void wps_registrar_flush(struct wps_registrar *reg);
int wps_build_credential_wrap(struct wpabuf *msg, int wps_build_credential_wrap(struct wpabuf *msg,
const struct wps_credential *cred); const struct wps_credential *cred);

View 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 * wps_registrar_deinit - Deinitialize WPS Registrar data
* @reg: Registrar data from wps_registrar_init() * @reg: Registrar data from wps_registrar_init()
@ -686,11 +702,8 @@ void wps_registrar_deinit(struct wps_registrar *reg)
return; return;
eloop_cancel_timeout(wps_registrar_pbc_timeout, reg, NULL); eloop_cancel_timeout(wps_registrar_pbc_timeout, reg, NULL);
eloop_cancel_timeout(wps_registrar_set_selected_timeout, reg, NULL); eloop_cancel_timeout(wps_registrar_set_selected_timeout, reg, NULL);
wps_free_pins(&reg->pins); wps_registrar_flush(reg);
wps_free_nfc_pw_tokens(&reg->nfc_pw_tokens, 0);
wps_free_pbc_sessions(reg->pbc_sessions);
wpabuf_free(reg->extra_cred); wpabuf_free(reg->extra_cred);
wps_free_devices(reg->devices);
os_free(reg); os_free(reg);
} }

View file

@ -5993,6 +5993,7 @@ static void wpa_supplicant_ctrl_iface_flush(struct wpa_supplicant *wpa_s)
#ifdef CONFIG_WPS #ifdef CONFIG_WPS
wpa_s->wps_fragment_size = 0; wpa_s->wps_fragment_size = 0;
wpas_wps_cancel(wpa_s); wpas_wps_cancel(wpa_s);
wps_registrar_flush(wpa_s->wps->registrar);
#endif /* CONFIG_WPS */ #endif /* CONFIG_WPS */
wpa_s->after_wps = 0; wpa_s->after_wps = 0;
wpa_s->known_wps_freq = 0; wpa_s->known_wps_freq = 0;