From patchwork Thu May 16 13:28:23 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: 244309 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 ADECB2C015E for ; Thu, 16 May 2013 23:31:40 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 17F8B9D23D; Thu, 16 May 2013 09:31:01 -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 pSAVMGhd-y9g; Thu, 16 May 2013 09:31:00 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id D25039D23E; Thu, 16 May 2013 09:29:10 -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 AD4039D1DD for ; Thu, 16 May 2013 09:29:09 -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 qBPx+Nsm8rOv for ; Thu, 16 May 2013 09:29:04 -0400 (EDT) Received: from mms1.broadcom.com (mms1.broadcom.com [216.31.210.17]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 2A21A9D1FA for ; Thu, 16 May 2013 09:28:51 -0400 (EDT) Received: from [10.9.208.57] by mms1.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.5)); Thu, 16 May 2013 06:25:09 -0700 X-Server-Uuid: 06151B78-6688-425E-9DE2-57CB27892261 Received: from IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.1.438.0; Thu, 16 May 2013 06:28:42 -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:42 -0700 Received: from arend-ubuntu-1 (unknown [10.176.68.33]) by mail-sj1-12.sj.broadcom.com (Postfix) with ESMTP id 44FB6207D5; Thu, 16 May 2013 06:28:40 -0700 (PDT) Received: from arend by arend-ubuntu-1 with local (Exim 4.80) ( envelope-from ) id 1UcyEY-0008OT-Rp; Thu, 16 May 2013 15:28:38 +0200 From: "Arend van Spriel" To: "Jouni Malinen" Subject: [PATCH 08/20] driver: nl80211: handle creation of P2P device interface Date: Thu, 16 May 2013 15:28:23 +0200 Message-ID: <1368710915-32176-9-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: 7D8A01BF31W20416626-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 Add specific handler for creating the P2P device to store the wdev_id as this type of interface does not have an interface index. Signed-hostap: Arend van Spriel --- src/drivers/driver_nl80211.c | 57 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 7 deletions(-) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index f185f71..92b8882 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -4592,10 +4592,15 @@ static int wpa_driver_nl80211_set_key(const char *ifname, struct i802_bss *bss, const u8 *key, size_t key_len) { struct wpa_driver_nl80211_data *drv = bss->drv; - int ifindex = if_nametoindex(ifname); + int ifindex; struct nl_msg *msg; int ret; + /* ignore for P2P Device */ + if (drv->nlmode == NL80211_IFTYPE_P2P_DEVICE) + return 0; + + ifindex = if_nametoindex(ifname); wpa_printf(MSG_DEBUG, "%s: ifindex=%d alg=%d addr=%p key_idx=%d " "set_tx=%d seq_len=%lu key_len=%lu", __func__, ifindex, alg, addr, key_idx, set_tx, @@ -8584,6 +8589,24 @@ static int nl80211_p2p_interface_addr(struct wpa_driver_nl80211_data *drv, #endif /* CONFIG_P2P */ +static int nl80211_create_p2p_dev_handler(struct nl_msg *msg, void *arg) +{ + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); + struct nlattr *tb[NL80211_ATTR_MAX + 1]; + struct i802_bss *p2p_dev = arg; + + nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), + genlmsg_attrlen(gnlh, 0), NULL); + if (tb[NL80211_ATTR_WDEV]) + p2p_dev->wdev_id = + nla_get_u64(tb[NL80211_ATTR_WDEV]); + + if (tb[NL80211_ATTR_MAC]) + os_memcpy(p2p_dev->addr, + nla_data(tb[NL80211_ATTR_MAC]), ETH_ALEN); + + return NL_SKIP; +} static int wpa_driver_nl80211_if_add(void *priv, enum wpa_driver_if_type type, const char *ifname, const u8 *addr, @@ -8591,7 +8614,9 @@ static int wpa_driver_nl80211_if_add(void *priv, enum wpa_driver_if_type type, char *force_ifname, u8 *if_addr, const char *bridge) { + enum nl80211_iftype nlmode; struct i802_bss *bss = priv; + struct i802_bss *p2pdev; struct wpa_driver_nl80211_data *drv = bss->drv; int ifidx; #ifdef HOSTAPD @@ -8606,14 +8631,32 @@ static int wpa_driver_nl80211_if_add(void *priv, enum wpa_driver_if_type type, if (addr) os_memcpy(if_addr, addr, ETH_ALEN); - ifidx = nl80211_create_iface(drv, ifname, - wpa_driver_nl80211_if_type(type), addr, - 0, NULL, NULL); - if (ifidx < 0) { + nlmode = wpa_driver_nl80211_if_type(type); + if (nlmode == NL80211_IFTYPE_P2P_DEVICE) { + p2pdev = os_zalloc(sizeof(*p2pdev)); + if (!p2pdev) + return -1; + *p2pdev = *bss; + os_strncpy(p2pdev->ifname, ifname, IFNAMSIZ); + ifidx = nl80211_create_iface(drv, ifname, nlmode, addr, + 0, nl80211_create_p2p_dev_handler, + p2pdev); + if (p2pdev->wdev_id == -1 || ifidx != 0 || + is_zero_ether_addr((const u8 *)&p2pdev->addr)) { + wpa_printf(MSG_ERROR, "nl80211: Failed to create a p2p device" + " interface %s", ifname); + os_free(p2pdev); + return -1; + } + } else { + ifidx = nl80211_create_iface(drv, ifname, nlmode, addr, + 0, NULL, NULL); + if (ifidx < 0) { #ifdef HOSTAPD - os_free(new_bss); + os_free(new_bss); #endif /* HOSTAPD */ - return -1; + return -1; + } } if (!addr &&