From a83d9c9652fd296bbd069bd1b259a77b7b536d2e Mon Sep 17 00:00:00 2001 From: Sam Leffler Date: Mon, 2 Mar 2009 21:57:00 +0200 Subject: [PATCH] Add build option CONFIG_TERMINATE_ONLASTIF This makes wpa_supplicant terminate automatically if the configured interface(s) disappear. --- wpa_supplicant/events.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index cd5928ebb..e6f3a4aed 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1017,6 +1017,19 @@ wpa_supplicant_event_michael_mic_failure(struct wpa_supplicant *wpa_s, } +#ifdef CONFIG_TERMINATE_ONLASTIF +static int any_interfaces(struct wpa_supplicant *head) +{ + struct wpa_supplicant *wpa_s; + + for (wpa_s = head; wpa_s != NULL; wpa_s = wpa_s->next) + if (!wpa_s->interface_removed) + return 1; + return 0; +} +#endif /* CONFIG_TERMINATE_ONLASTIF */ + + static void wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s, union wpa_event_data *data) @@ -1041,6 +1054,11 @@ wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s, wpa_supplicant_mark_disassoc(wpa_s); l2_packet_deinit(wpa_s->l2); wpa_s->l2 = NULL; +#ifdef CONFIG_TERMINATE_ONLASTIF + /* check if last interface */ + if (!any_interfaces(wpa_s->global->ifaces)) + eloop_terminate(); +#endif /* CONFIG_TERMINATE_ONLASTIF */ break; } }