[PATCH 4/5] events.c: add wpa_supplicant_event2 for global driver events

Roy Marples roy at marples.name
Tue May 26 17:25:17 EDT 2009


If the event is notification of a new interface then we attempt to
add the interface using the default driver and configuration if
wpa_supplicant is not already using it and the name matches our list.
Otherwise we pass the event to wpa_supplicant_event if we can find
an interface that wpa_supplicant is using.

Signed-off-by: Roy Marples <roy at marples.name>
---
 src/drivers/driver.h    |   13 +++++++++++++
 wpa_supplicant/events.c |   30 ++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index 30bc72e..f46526c 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -1706,6 +1706,19 @@ void wpa_supplicant_event(void *ctx, wpa_event_type event,
 			  union wpa_event_data *data);
 
 /**
+ * wpa_supplicant_event2 - Report a global driver event for wpa_supplicant
+ * @ctx: Context pointer to wpa_global
+ * @event: event type (defined above)
+ * @data: possible extra data for the event
+ *
+ * Same as wpa_suppicant_event, but we search for the interface in wpa_global.
+ * If the event is notification of a new interface and we match
+ * the interfacename and wpa_supplicant is not currently monitoring it
+ * then we try and start the interface using the default driver.
+ */
+void wpa_supplicant_event2(void *ctx, wpa_event_type event,
+			  union wpa_event_data *data);
+/**
  * wpa_supplicant_rx_eapol - Deliver a received EAPOL frame to wpa_supplicant
  * @ctx: Context pointer (wpa_s); this is the ctx variable registered
  *	with struct wpa_driver_ops::init()
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 56c57fb..7b6e6ee 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -1125,6 +1125,7 @@ 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;
+		wpa_supplicant_remove_iface(wpa_s->global, wpa_s);
 #ifdef CONFIG_TERMINATE_ONLASTIF
 		/* check if last interface */
 		if (!any_interfaces(wpa_s->global->ifaces))
@@ -1240,3 +1241,32 @@ void wpa_supplicant_event(void *ctx, wpa_event_type event,
 		break;
 	}
 }
+
+void wpa_supplicant_event2(void *ctx, wpa_event_type event,
+			  union wpa_event_data *data)
+{
+	struct wpa_global *wpa_g;
+	struct wpa_supplicant *wpa_s;
+	struct wpa_interface wpa_i;
+
+	wpa_s = wpa_supplicant_get_iface(ctx, data->interface_status.ifname);
+
+	if (event == EVENT_INTERFACE_STATUS &&
+		data->interface_status.ievent == EVENT_INTERFACE_ADDED)
+	{
+		if (wpa_s != NULL)
+			return;
+		wpa_g = ctx;
+		if (!wpa_supplicant_match_iface(wpa_g,
+						data->interface_status.ifname))
+			return;
+		os_memset(&wpa_i, 0, sizeof(wpa_i));
+		wpa_i.ifname = data->interface_status.ifname;
+		wpa_i.confname = wpa_g->params.confname;
+		wpa_supplicant_add_iface(ctx, &wpa_i);
+		return;
+	}
+
+	if (wpa_s != NULL)
+		wpa_supplicant_event(wpa_s, event, data);
+}
-- 
1.6.2.5



More information about the HostAP mailing list