From patchwork Sun Feb 5 09:54:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jouni Malinen X-Patchwork-Id: 139618 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 2FBF9B7259 for ; Sun, 5 Feb 2012 20:54:35 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id C6E939D21C; Sun, 5 Feb 2012 04:54:31 -0500 (EST) 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 63v0bXS075kB; Sun, 5 Feb 2012 04:54:31 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 7B4069D21E; Sun, 5 Feb 2012 04:54:27 -0500 (EST) 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 29EA69D21C for ; Sun, 5 Feb 2012 04:54:26 -0500 (EST) 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 wROoMJUGD9sT for ; Sun, 5 Feb 2012 04:54:21 -0500 (EST) Received: from jmaline2.user.openhosting.com (kvm.w1.fi [128.177.28.162]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 57AA99D21E for ; Sun, 5 Feb 2012 04:54:21 -0500 (EST) Received: from jm (a88-112-110-150.elisa-laajakaista.fi [88.112.110.150]) (authenticated bits=0) by jmaline2.user.openhosting.com (8.13.8/8.13.8) with ESMTP id q159qdOU016021 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 5 Feb 2012 04:52:40 -0500 Received: by jm (sSMTP sendmail emulation); Sun, 05 Feb 2012 11:54:14 +0200 Date: Sun, 5 Feb 2012 11:54:14 +0200 From: Jouni Malinen To: hostap@lists.shmoo.com Subject: Re: [PATCH] P2P: Inviting a p2p device from already running persistent p2p go Message-ID: <20120205095414.GB2180@w1.fi> Mail-Followup-To: hostap@lists.shmoo.com References: <2C2F1EBA8050E74EA81502D5740B4BD6BBDA4D2FC9@SJEXCHCCR02.corp.ad.broadcom.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2C2F1EBA8050E74EA81502D5740B4BD6BBDA4D2FC9@SJEXCHCCR02.corp.ad.broadcom.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.9 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 On Wed, Feb 01, 2012 at 04:37:36AM -0800, Neeraj Kumar Garg wrote: > 1. In the receive path of persistent invitation, supplicant code already checks for an already running group. So in that way, it makes more sense to check already running group in persistent= command for transmit case too. Those are quite different cases. In the case we receive an Invitation Request, wpa_supplicant has to answer it without external input to the decision and because of that, the check for running group is needed. This is not the case if we are sending an invitation. > 2. We have to use either group= or persistent= command to find out if we are already running a persistent group. Lets say we use p2p_invite peer=xx group=xxx persistent=x command. [Doing automatically without persistent= will be difficult as we might have multiple entries in conf file with same go_dev_addr but different ssid]. For this we have to add the complete code of persistent verification from persistent invite to group invite. I don't follow the logic here. > 3. Logic is since an application want to do a persistent invite, we can make persistent invite to find out if the group is already running or not. The alternative logic is since group is already running, should the application do a persistent invite or a normal invite. I think both weighs equal in this aspect. Use of wpas_p2p_invite() to send an invitation for an already running group is misuse of the designed interfaces and results in incorrect Invitation Request (incorrect operating channel information). If I've understood your use case correctly, the only difference that you want to see is in setting the Invitation Type in the Invitation Flags attribute to 1 if a GO is running a persistent group and is about to invite a peer that has previously connected to the persistent group. This can be done automatically. Though, please note that this may result in issues if the peer has already dropped all information of the persistent group and in such a case, would just reject the invitation with "Fail; unknown P2P Group". As such, it could be safer to just make the "peer case" work in the way that if it detects that an Invitation Request was received for an already running persistent group for which there are stored credentials, those credentials would be used automatically instead of WPS provisioning. Please take a look at the following patch that shows how the persistent group case can be checked automatically as part of "p2p_invite group= peer=". Would this address your use case? diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 88981d4..6a3223e 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -3053,7 +3053,7 @@ static int p2p_ctrl_peer(struct wpa_supplicant *wpa_s, char *cmd, return pos - buf; pos += res; - ssid = wpas_p2p_get_persistent(wpa_s, info->p2p_device_addr); + ssid = wpas_p2p_get_persistent(wpa_s, info->p2p_device_addr, NULL, 0); if (ssid) { res = os_snprintf(pos, end - pos, "persistent=%d\n", ssid->id); if (res < 0 || res >= end - pos) diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index a6298a7..1b66bdd 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -3707,6 +3707,7 @@ int wpas_p2p_invite_group(struct wpa_supplicant *wpa_s, const char *ifname, enum p2p_invite_role role; u8 *bssid = NULL; struct wpa_ssid *ssid; + int persistent; for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) { if (os_strcmp(wpa_s->ifname, ifname) == 0) @@ -3724,6 +3725,10 @@ int wpas_p2p_invite_group(struct wpa_supplicant *wpa_s, const char *ifname, return -1; } + persistent = ssid->p2p_persistent_group && + wpas_p2p_get_persistent(wpa_s->parent, peer_addr, + ssid->ssid, ssid->ssid_len); + if (ssid->mode == WPAS_MODE_P2P_GO) { role = P2P_INVITE_ROLE_ACTIVE_GO; bssid = wpa_s->own_addr; @@ -3746,14 +3751,14 @@ int wpas_p2p_invite_group(struct wpa_supplicant *wpa_s, const char *ifname, if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT) return wpa_drv_p2p_invite(wpa_s, peer_addr, role, bssid, ssid->ssid, ssid->ssid_len, - go_dev_addr, 0); + go_dev_addr, persistent); if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL) return -1; return p2p_invite(wpa_s->global->p2p, peer_addr, role, bssid, ssid->ssid, ssid->ssid_len, wpa_s->assoc_freq, - go_dev_addr, 0); + go_dev_addr, persistent); } @@ -4353,7 +4358,8 @@ void wpas_p2p_network_removed(struct wpa_supplicant *wpa_s, struct wpa_ssid * wpas_p2p_get_persistent(struct wpa_supplicant *wpa_s, - const u8 *addr) + const u8 *addr, const u8 *ssid, + size_t ssid_len) { struct wpa_ssid *s; size_t i; @@ -4361,6 +4367,10 @@ struct wpa_ssid * wpas_p2p_get_persistent(struct wpa_supplicant *wpa_s, for (s = wpa_s->conf->ssid; s; s = s->next) { if (s->disabled != 2) continue; + if (ssid && + (ssid_len != s->ssid_len || + os_memcmp(ssid, s->ssid, ssid_len) != 0)) + continue; if (os_memcmp(s->bssid, addr, ETH_ALEN) == 0) return s; /* peer is GO in the persistent group */ if (s->mode != WPAS_MODE_P2P_GO || s->p2p_client_list == NULL) diff --git a/wpa_supplicant/p2p_supplicant.h b/wpa_supplicant/p2p_supplicant.h index 605741d..599ff3f 100644 --- a/wpa_supplicant/p2p_supplicant.h +++ b/wpa_supplicant/p2p_supplicant.h @@ -133,7 +133,8 @@ int wpas_p2p_in_progress(struct wpa_supplicant *wpa_s); void wpas_p2p_network_removed(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid); struct wpa_ssid * wpas_p2p_get_persistent(struct wpa_supplicant *wpa_s, - const u8 *addr); + const u8 *addr, const u8 *ssid, + size_t ssid_len); void wpas_p2p_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s, const u8 *addr);