Browse Source

Add build option CONFIG_TERMINATE_ONLASTIF

This makes wpa_supplicant terminate automatically if the configured
interface(s) disappear.
Sam Leffler 16 years ago
parent
commit
a83d9c9652
1 changed files with 18 additions and 0 deletions
  1. 18 0
      wpa_supplicant/events.c

+ 18 - 0
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
 static void
 wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s,
 wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s,
 				      union wpa_event_data *data)
 				      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);
 		wpa_supplicant_mark_disassoc(wpa_s);
 		l2_packet_deinit(wpa_s->l2);
 		l2_packet_deinit(wpa_s->l2);
 		wpa_s->l2 = NULL;
 		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;
 		break;
 	}
 	}
 }
 }