Patchwork [RFC,05/10] nl80211_driver: add a handler to create_interface

login
register
mail settings
Submitter Arend van Spriel
Date Feb. 11, 2013, 11:15 a.m.
Message ID <1360581347-26766-6-git-send-email-arend@broadcom.com>
Download mbox | patch
Permalink /patch/219577/
State Superseded
Headers show

Comments

Arend van Spriel - Feb. 11, 2013, 11:15 a.m.
From: David Spinadel <david.spinadel@intel.com>

Add an option to pass handler to nl80211_create_iface and
nl80211_create_interface_once that will be called after recieving
the message from the kernel.
this handler will add the option to process the message in different ways
for different interfaces.

Signed-hostap: David Spinadel <david.spinadel@intel.com>
---
 src/drivers/driver_nl80211.c |   19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

Patch

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 4d6e0a8..f0306f1 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -6002,7 +6002,9 @@  static const char * nl80211_iftype_str(enum nl80211_iftype mode)
 static int nl80211_create_iface_once(struct wpa_driver_nl80211_data *drv,
 				     const char *ifname,
 				     enum nl80211_iftype iftype,
-				     const u8 *addr, int wds)
+				     const u8 *addr, int wds,
+				     int (*handler)(struct nl_msg *, void *),
+				     void *arg)
 {
 	struct nl_msg *msg, *flags = NULL;
 	int ifidx;
@@ -6039,7 +6041,7 @@  static int nl80211_create_iface_once(struct wpa_driver_nl80211_data *drv,
 		NLA_PUT_U8(msg, NL80211_ATTR_4ADDR, wds);
 	}
 
-	ret = send_and_recv_msgs(drv, msg, NULL, NULL);
+	ret = send_and_recv_msgs(drv, msg, handler, arg);
 	msg = NULL;
 	if (ret) {
  nla_put_failure:
@@ -6071,11 +6073,14 @@  static int nl80211_create_iface_once(struct wpa_driver_nl80211_data *drv,
 
 static int nl80211_create_iface(struct wpa_driver_nl80211_data *drv,
 				const char *ifname, enum nl80211_iftype iftype,
-				const u8 *addr, int wds)
+				const u8 *addr, int wds,
+				int (*handler)(struct nl_msg *, void *),
+				void *arg)
 {
 	int ret;
 
-	ret = nl80211_create_iface_once(drv, ifname, iftype, addr, wds);
+	ret = nl80211_create_iface_once(drv, ifname, iftype, addr, wds, handler,
+					arg);
 
 	/* if error occurred and interface exists already */
 	if (ret == -ENFILE && if_nametoindex(ifname)) {
@@ -6086,7 +6091,7 @@  static int nl80211_create_iface(struct wpa_driver_nl80211_data *drv,
 
 		/* Try to create the interface again */
 		ret = nl80211_create_iface_once(drv, ifname, iftype, addr,
-						wds);
+						wds, handler, arg);
 	}
 
 	if (ret >= 0 && is_p2p_interface(iftype))
@@ -6436,7 +6441,7 @@  nl80211_create_monitor_interface(struct wpa_driver_nl80211_data *drv)
 
 	drv->monitor_ifidx =
 		nl80211_create_iface(drv, buf, NL80211_IFTYPE_MONITOR, NULL,
-				     0);
+				     0, NULL, NULL);
 
 	if (drv->monitor_ifidx == -EOPNOTSUPP) {
 		/*
@@ -8196,7 +8201,7 @@  static int wpa_driver_nl80211_if_add(void *priv, enum wpa_driver_if_type type,
 		os_memcpy(if_addr, addr, ETH_ALEN);
 	ifidx = nl80211_create_iface(drv, ifname,
 				     wpa_driver_nl80211_if_type(type), addr,
-				     0);
+				     0, NULL, NULL);
 	if (ifidx < 0) {
 #ifdef HOSTAPD
 		os_free(new_bss);