From 5894051d6c122f6573d9992eb555d6e78718b8c0 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Wed, 30 May 2018 14:52:22 -0500 Subject: [PATCH] eap: Introduce state reset This is meant to reset the EAP state back to its original state without affecting any state variables obtained through load_settings. This can be useful for EAP Reauthentication triggered by the AP. --- src/eap.c | 14 ++++++++++++++ src/eap.h | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/src/eap.c b/src/eap.c index c84c047c..93ccfc20 100644 --- a/src/eap.c +++ b/src/eap.c @@ -93,6 +93,20 @@ void eap_set_event_func(struct eap_state *eap, eap_event_func_t func) eap->event_func = func; } +bool eap_reset(struct eap_state *eap) +{ + if (eap->method_state && eap->method->reset_state) { + if (!eap->method->reset_state(eap)) + return false; + } + + eap->method_success = false; + l_timeout_remove(eap->complete_timeout); + eap->complete_timeout = NULL; + + return true; +} + void eap_free(struct eap_state *eap) { if (eap->method_state && eap->method->free) diff --git a/src/eap.h b/src/eap.h index fedfdb0d..03b6f9ed 100644 --- a/src/eap.h +++ b/src/eap.h @@ -70,6 +70,7 @@ int eap_check_settings(struct l_settings *settings, struct l_queue *secrets, struct l_queue **out_missing); bool eap_load_settings(struct eap_state *eap, struct l_settings *settings, const char *prefix); +bool eap_reset(struct eap_state *eap); void eap_set_key_material_func(struct eap_state *eap, eap_key_material_func_t func); @@ -130,6 +131,9 @@ struct eap_method { bool (*load_settings)(struct eap_state *eap, struct l_settings *settings, const char *prefix); + + /* Reset the internal state back to initial conditions */ + bool (*reset_state)(struct eap_state *eap); void (*free)(struct eap_state *eap); void (*handle_request)(struct eap_state *eap,