From 9f17b7137523be4cdbcfde59b8d0f6c57803aec2 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Sun, 29 Mar 2015 20:58:40 -0500 Subject: [PATCH] eapol: Add eapol_cancel --- src/eapol.c | 19 +++++++++++++++++++ src/eapol.h | 1 + 2 files changed, 20 insertions(+) diff --git a/src/eapol.c b/src/eapol.c index 6a11961f..b19c5dd3 100644 --- a/src/eapol.c +++ b/src/eapol.c @@ -514,6 +514,25 @@ void eapol_start(uint32_t ifindex, struct eapol_sm *sm) l_queue_push_head(state_machines, sm); } +static bool eapol_sm_ifindex_match(void *data, void *user_data) +{ + struct eapol_sm *sm = data; + uint32_t ifindex = L_PTR_TO_UINT(user_data); + + if (sm->ifindex != ifindex) + return false; + + eapol_sm_free(sm); + + return false; +} + +void eapol_cancel(uint32_t ifindex) +{ + l_queue_foreach_remove(state_machines, eapol_sm_ifindex_match, + L_UINT_TO_PTR(ifindex)); +} + static void eapol_handle_ptk_1_of_4(uint32_t ifindex, struct eapol_sm *sm, const struct eapol_key *ek, void *user_data) diff --git a/src/eapol.h b/src/eapol.h index 00400b0f..05e2cf63 100644 --- a/src/eapol.h +++ b/src/eapol.h @@ -164,6 +164,7 @@ void eapol_sm_set_user_data(struct eapol_sm *sm, void *user_data); struct l_io *eapol_open_pae(uint32_t index); void eapol_start(uint32_t ifindex, struct eapol_sm *sm); +void eapol_cancel(uint32_t ifindex); bool eapol_init(); bool eapol_exit();