From patchwork Wed May 29 09:07:53 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: 247203 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 2FFB22C032A for ; Wed, 29 May 2013 19:13:55 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 80B489C129; Wed, 29 May 2013 05:12:32 -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 uNPWb87u5nry; Wed, 29 May 2013 05:12:32 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 0D2829C12E; Wed, 29 May 2013 05:09:26 -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 4FF529C129 for ; Wed, 29 May 2013 05:09:24 -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 RVIuu+DJ1WQv for ; Wed, 29 May 2013 05:09:19 -0400 (EDT) Received: from mms1.broadcom.com (mms1.broadcom.com [216.31.210.17]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id E635E9C12F for ; Wed, 29 May 2013 05:08:29 -0400 (EDT) Received: from [10.9.208.57] by mms1.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.5)); Wed, 29 May 2013 02:04:41 -0700 X-Server-Uuid: 06151B78-6688-425E-9DE2-57CB27892261 Received: from IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.1.438.0; Wed, 29 May 2013 02:08:18 -0700 Received: from mail-sj1-12.sj.broadcom.com (10.10.10.20) by IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) with Microsoft SMTP Server id 14.1.438.0; Wed, 29 May 2013 02:08:17 -0700 Received: from arend-ubuntu-1 (unknown [10.176.68.31]) by mail-sj1-12.sj.broadcom.com (Postfix) with ESMTP id 9885A207D1; Wed, 29 May 2013 02:08:14 -0700 (PDT) Received: from arend by arend-ubuntu-1 with local (Exim 4.80) ( envelope-from ) id 1UhcMf-0001uk-N1; Wed, 29 May 2013 11:08:13 +0200 From: "Arend van Spriel" To: "Jouni Malinen" Subject: [PATCH V2 06/23] nl80211: Allow Android P2P functionality Date: Wed, 29 May 2013 11:07:53 +0200 Message-ID: <1369818491-7274-7-git-send-email-arend@broadcom.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1369818491-7274-1-git-send-email-arend@broadcom.com> References: <1369818491-7274-1-git-send-email-arend@broadcom.com> MIME-Version: 1.0 X-WSS-ID: 7DBB1B2331W28019807-01-01 Cc: hostap@lists.shmoo.com, Johannes Berg 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 From: Johannes Berg To support Android the kernel may have a "p2p0" netdev for a P2P Device even though this isn't very useful, but Android requires a netdev. To support this in the supplicant, if the interface mode is P2P_DEVICE, re-set it to the same instead of STATION mode. Note that this is only possible with a kernel that creates a netdev for the P2P Device wdev. Signed-hostap: Johannes Berg --- src/drivers/driver_nl80211.c | 51 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 708b83f..0c7021e 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -557,6 +557,7 @@ static void * nl80211_cmd(struct wpa_driver_nl80211_data *drv, struct wiphy_idx_data { int wiphy_idx; + enum nl80211_iftype nlmode; }; @@ -572,6 +573,9 @@ static int netdev_info_handler(struct nl_msg *msg, void *arg) if (tb[NL80211_ATTR_WIPHY]) info->wiphy_idx = nla_get_u32(tb[NL80211_ATTR_WIPHY]); + if (tb[NL80211_ATTR_IFTYPE]) + info->nlmode = nla_get_u32(tb[NL80211_ATTR_IFTYPE]); + return NL_SKIP; } @@ -600,6 +604,32 @@ nla_put_failure: } +#ifndef HOSTAPD +static enum nl80211_iftype nl80211_get_ifmode(struct i802_bss *bss) +{ + struct nl_msg *msg; + struct wiphy_idx_data data = { + .wiphy_idx = -1, + }; + + msg = nlmsg_alloc(); + if (!msg) + return -1; + + nl80211_cmd(bss->drv, msg, 0, NL80211_CMD_GET_INTERFACE); + + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, bss->ifindex); + + if (send_and_recv_msgs(bss->drv, msg, netdev_info_handler, &data) == 0) + return data.nlmode; + msg = NULL; +nla_put_failure: + nlmsg_free(msg); + return NL80211_IFTYPE_UNSPECIFIED; +} +#endif /* HOSTAPD */ + + static int nl80211_register_beacons(struct wpa_driver_nl80211_data *drv, struct nl80211_wiphy_data *w) { @@ -3760,11 +3790,22 @@ wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv) * dynamically added interface (e.g., P2P) that was already configured * with proper iftype. */ - if (drv->ifindex != drv->global->if_add_ifindex && - wpa_driver_nl80211_set_mode(bss, NL80211_IFTYPE_STATION) < 0) { - wpa_printf(MSG_ERROR, "nl80211: Could not configure driver to " - "use managed mode"); - return -1; + if (drv->ifindex != drv->global->if_add_ifindex) { + enum nl80211_iftype nlmode; + + nlmode = nl80211_get_ifmode(bss); + if (nlmode != NL80211_IFTYPE_P2P_DEVICE) + nlmode = NL80211_IFTYPE_STATION; + + if (wpa_driver_nl80211_set_mode(bss, nlmode) < 0) { + wpa_printf(MSG_ERROR, "nl80211: Could not configure driver to use %s mode", + nlmode == NL80211_IFTYPE_STATION ? + "managed" : "P2P-Device"); + return -1; + } + + /* Always use managed mode internally, even for P2P Device */ + drv->nlmode = NL80211_IFTYPE_STATION; } if (linux_set_iface_flags(drv->global->ioctl_sock, bss->ifname, 1)) {