[PATCH 14/20] driver: nl80211: add .get_mac_addr() callback for P2P-Device
Arend van Spriel
arend
Thu May 16 06:28:29 PDT 2013
For P2P-Device the mac address is determined upon .init2(). The
wpa_s for this interface retrieves this address in
wpa_supplicant_update_mac_addr() using the .get_mac_addr() callback.
Signed-hostap: Arend van Spriel <arend at broadcom.com>
---
src/drivers/driver_nl80211.c | 42 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 48d1ba4..ef6ac59 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -550,6 +550,7 @@ static void * nl80211_cmd(struct wpa_driver_nl80211_data *drv,
struct wiphy_idx_data {
int wiphy_idx;
enum nl80211_iftype nlmode;
+ u8 *macaddr;
};
@@ -568,6 +569,9 @@ static int netdev_info_handler(struct nl_msg *msg, void *arg)
if (tb[NL80211_ATTR_IFTYPE])
info->nlmode = nla_get_u32(tb[NL80211_ATTR_IFTYPE]);
+ if (tb[NL80211_ATTR_MAC] && info->macaddr)
+ os_memcpy(info->macaddr, nla_data(tb[NL80211_ATTR_MAC]), ETH_ALEN);
+
return NL_SKIP;
}
@@ -577,6 +581,7 @@ static int nl80211_get_wiphy_index(struct i802_bss *bss)
struct nl_msg *msg;
struct wiphy_idx_data data = {
.wiphy_idx = -1,
+ .macaddr = NULL
};
msg = nlmsg_alloc();
@@ -600,7 +605,8 @@ static enum nl80211_iftype nl80211_get_ifmode(struct i802_bss *bss)
{
struct nl_msg *msg;
struct wiphy_idx_data data = {
- .wiphy_idx = -1,
+ .nlmode = NL80211_IFTYPE_UNSPECIFIED,
+ .macaddr = NULL
};
msg = nlmsg_alloc();
@@ -620,6 +626,27 @@ nla_put_failure:
}
+static int nl80211_get_macaddr(struct i802_bss *bss)
+{
+ struct nl_msg *msg;
+ struct wiphy_idx_data data = {
+ .macaddr = bss->addr,
+ };
+
+ msg = nlmsg_alloc();
+ if (!msg)
+ return NL80211_IFTYPE_UNSPECIFIED;
+
+ nl80211_cmd(bss->drv, msg, 0, NL80211_CMD_GET_INTERFACE);
+ NL80211_PUT_IFACE_ID(msg, bss);
+
+ return send_and_recv_msgs(bss->drv, msg, netdev_info_handler, &data);
+
+nla_put_failure:
+ nlmsg_free(msg);
+ return NL80211_IFTYPE_UNSPECIFIED;
+}
+
static int nl80211_register_beacons(struct wpa_driver_nl80211_data *drv,
struct nl80211_wiphy_data *w)
{
@@ -3842,6 +3869,7 @@ wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv)
int ret = nl80211_set_p2pdev(bss, 1);
if (ret < 0)
wpa_printf(MSG_ERROR, "nl80211: could not start P2P device");
+ nl80211_get_macaddr(bss);
return ret;
}
@@ -10076,6 +10104,17 @@ nla_put_failure:
}
+const u8 *wpa_driver_nl80211_get_macaddr(void *priv)
+{
+ struct i802_bss *bss = priv;
+ struct wpa_driver_nl80211_data *drv = bss->drv;
+
+ if (drv->nlmode != NL80211_IFTYPE_P2P_DEVICE)
+ return NULL;
+
+ return bss->addr;
+}
+
const struct wpa_driver_ops wpa_driver_nl80211_ops = {
.name = "nl80211",
.desc = "Linux nl80211/cfg80211",
@@ -10154,4 +10193,5 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
.tdls_oper = nl80211_tdls_oper,
#endif /* CONFIG_TDLS */
.update_ft_ies = wpa_driver_nl80211_update_ft_ies,
+ .get_mac_addr = wpa_driver_nl80211_get_macaddr,
};
--
1.7.10.4
More information about the Hostap
mailing list