From patchwork Thu May 16 13:28:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arend van Spriel X-Patchwork-Id: 244322 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) by ozlabs.org (Postfix) with ESMTP id DC9E12C015B for ; Thu, 16 May 2013 23:34:40 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id BFFBB17C071; Thu, 16 May 2013 09:33:14 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Y6MYDtcPGLnY; Thu, 16 May 2013 09:33:14 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 2A1E19D28B; Thu, 16 May 2013 09:29:41 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id EE4519D28B for ; Thu, 16 May 2013 09:29:39 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id U--YkJbLzmAA for ; Thu, 16 May 2013 09:29:34 -0400 (EDT) Received: from mms2.broadcom.com (mms2.broadcom.com [216.31.210.18]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id A221D9D211 for ; Thu, 16 May 2013 09:28:52 -0400 (EDT) Received: from [10.9.208.55] by mms2.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.5)); Thu, 16 May 2013 06:23:15 -0700 X-Server-Uuid: 4500596E-606A-40F9-852D-14843D8201B2 Received: from IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) by IRVEXCHCAS07.corp.ad.broadcom.com (10.9.208.55) with Microsoft SMTP Server (TLS) id 14.1.438.0; Thu, 16 May 2013 06:28:43 -0700 Received: from mail-sj1-12.sj.broadcom.com (10.10.10.20) by IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) with Microsoft SMTP Server id 14.1.438.0; Thu, 16 May 2013 06:28:43 -0700 Received: from arend-ubuntu-1 (unknown [10.176.68.33]) by mail-sj1-12.sj.broadcom.com (Postfix) with ESMTP id 19354207DF; Thu, 16 May 2013 06:28:41 -0700 (PDT) Received: from arend by arend-ubuntu-1 with local (Exim 4.80) ( envelope-from ) id 1UcyEZ-0008Oy-On; Thu, 16 May 2013 15:28:39 +0200 From: "Arend van Spriel" To: "Jouni Malinen" Subject: [PATCH 14/20] driver: nl80211: add .get_mac_addr() callback for P2P-Device Date: Thu, 16 May 2013 15:28:29 +0200 Message-ID: <1368710915-32176-15-git-send-email-arend@broadcom.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1368710915-32176-1-git-send-email-arend@broadcom.com> References: <1368710915-32176-1-git-send-email-arend@broadcom.com> MIME-Version: 1.0 X-WSS-ID: 7D8A02491R015488248-01-01 Cc: hostap@lists.shmoo.com X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com 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 --- 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, };