From: David Spinadel Date: Tue, 25 Jun 2013 10:35:05 +0000 (+0300) Subject: nl80211: Add a handler to create_interface X-Git-Tag: aosp-kk-from-upstream~173 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=mech_eap.git;a=commitdiff_plain;h=d6dcfcdaac70d06a4d9027aaa6bd17de68b23d59 nl80211: Add a handler to create_interface Add an option to pass a handler to nl80211_create_iface() and nl80211_create_interface_once() that will be called after receiving the message from the kernel. This handler will add the option to process the message in different ways for different interfaces. Signed-off-by: David Spinadel --- diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 0f5224b..cc03c72 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -6569,7 +6569,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; int ifidx; @@ -6601,7 +6603,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: @@ -6633,11 +6635,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)) { @@ -6648,7 +6653,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_net_interface(iftype)) @@ -6998,7 +7003,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) { /* @@ -8509,7 +8514,7 @@ static int i802_set_wds_sta(void *priv, const u8 *addr, int aid, int val, if (!if_nametoindex(name)) { if (nl80211_create_iface(drv, name, NL80211_IFTYPE_AP_VLAN, - bss->addr, 1) < 0) + bss->addr, 1, NULL, NULL) < 0) return -1; if (bridge_ifname && linux_br_add_if(drv->global->ioctl_sock, @@ -8796,7 +8801,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);