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,