From patchwork Thu Sep 24 17:38:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilan Peer X-Patchwork-Id: 522470 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 8723714017E for ; Fri, 25 Sep 2015 03:43:10 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 0F53417C54E; Thu, 24 Sep 2015 13:42:18 -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 3tZz11iYENdv; Thu, 24 Sep 2015 13:42:17 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 7564817C5AE; Thu, 24 Sep 2015 13:39:53 -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 8DC5917C56F for ; Thu, 24 Sep 2015 13:39:43 -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 iGKMMhV8FhG2 for ; Thu, 24 Sep 2015 13:39:41 -0400 (EDT) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 2543217C573 for ; Thu, 24 Sep 2015 13:38:47 -0400 (EDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 24 Sep 2015 10:38:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,582,1437462000"; d="scan'208";a="812503162" Received: from unknown (HELO JEL00311.ger.corp.intel.com) ([10.12.217.137]) by orsmga002.jf.intel.com with ESMTP; 24 Sep 2015 10:38:45 -0700 From: Ilan Peer To: hostap@lists.shmoo.com Subject: [PATCH 21/23] P2PS: Use the freq of a running P2P GO Date: Thu, 24 Sep 2015 20:38:11 +0300 Message-Id: <1443116293-9323-22-git-send-email-ilan.peer@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1443116293-9323-1-git-send-email-ilan.peer@intel.com> References: <1443116293-9323-1-git-send-email-ilan.peer@intel.com> X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com In case that there is an active P2P GO that is going to be used for the P2PS PD, force its current operating frequency in the PD attributes. Signed-off-by: Ilan Peer --- src/p2p/p2p.h | 6 ++++-- src/p2p/p2p_pd.c | 17 +++++++++++++---- wpa_supplicant/p2p_supplicant.c | 36 +++++++++++++++--------------------- 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index 18763b0..d697a7c 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -1034,14 +1034,16 @@ struct p2p_config { * @ssid_len: Buffer for returning length of @ssid * @group_iface: Buffer for returning whether a separate group interface * would be used + * @freq: if a currently running P2P GO is to be used, its current freq + * would be used * Returns: 1 if GO info found, 0 otherwise * * This is used to compose New Group settings (SSID, and intended * address) during P2PS provisioning if results of provisioning *might* * result in our being an autonomous GO. */ - int (*get_go_info)(void *ctx, u8 *intended_addr, - u8 *ssid, size_t *ssid_len, int *group_iface); + int (*get_go_info)(void *ctx, u8 *intended_addr, u8 *ssid, + size_t *ssid_len, int *group_iface, int *freq); /** * remove_stale_groups - Remove stale P2PS groups diff --git a/src/p2p/p2p_pd.c b/src/p2p/p2p_pd.c index 6372d35..024edb7 100644 --- a/src/p2p/p2p_pd.c +++ b/src/p2p/p2p_pd.c @@ -40,21 +40,30 @@ static void p2p_build_wps_ie_config_methods(struct wpabuf *buf, } -static void p2ps_add_new_group_info(struct p2p_data *p2p, struct wpabuf *buf) +static void p2ps_add_new_group_info(struct p2p_data *p2p, + struct p2p_device *dev, + struct wpabuf *buf) { int found; u8 intended_addr[ETH_ALEN]; u8 ssid[SSID_MAX_LEN]; size_t ssid_len; int group_iface; + int force_freq; if (!p2p->cfg->get_go_info) return; found = p2p->cfg->get_go_info( p2p->cfg->cb_ctx, intended_addr, ssid, - &ssid_len, &group_iface); + &ssid_len, &group_iface, &force_freq); if (found) { + if (force_freq > 0) { + p2p->p2ps_prov->force_freq = force_freq; + p2p->p2ps_prov->pref_freq = 0; + + p2p_prepare_channel(p2p, dev, force_freq, 0, 0); + } p2p_buf_add_group_id(buf, p2p->cfg->dev_addr, ssid, ssid_len); @@ -99,7 +108,7 @@ static void p2ps_add_pd_req_attrs(struct p2p_data *p2p, struct p2p_device *dev, if (!follow_on_req_fail && (prov->conncap & (P2PS_SETUP_GROUP_OWNER | P2PS_SETUP_NEW))) - p2ps_add_new_group_info(p2p, buf); + p2ps_add_new_group_info(p2p, dev, buf); if (prov->status >= 0) p2p_buf_add_status(buf, (u8) prov->status); @@ -331,7 +340,7 @@ static struct wpabuf * p2p_build_prov_disc_resp(struct p2p_data *p2p, } if (!persist && (conncap & P2PS_SETUP_GROUP_OWNER)) - p2ps_add_new_group_info(p2p, buf); + p2ps_add_new_group_info(p2p, dev, buf); /* Add Operating Channel if conncap indicates GO */ if (persist || (conncap & P2PS_SETUP_GROUP_OWNER)) { diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index c85767e..a7af034 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -608,20 +608,6 @@ wpas_p2p_get_cli_group(struct wpa_supplicant *wpa_s) } -/* Find an active P2P group where we are the GO */ -static struct wpa_ssid * wpas_p2p_group_go_ssid(struct wpa_supplicant *wpa_s, - u8 *bssid) -{ - struct wpa_supplicant *go = wpas_p2p_get_go_group(wpa_s); - - if (!go) - return NULL; - - os_memcpy(bssid, go->own_addr, ETH_ALEN); - return go->current_ssid; -} - - /* Find a persistent group where we are the GO */ static struct wpa_ssid * wpas_p2p_get_persistent_go(struct wpa_supplicant *wpa_s) @@ -3675,12 +3661,12 @@ static int wpas_get_persistent_group(void *ctx, const u8 *addr, const u8 *ssid, } -static int wpas_get_go_info(void *ctx, u8 *intended_addr, - u8 *ssid, size_t *ssid_len, int *group_iface) +static int wpas_get_go_info(void *ctx, u8 *intended_addr, u8 *ssid, + size_t *ssid_len, int *group_iface, int *freq) { struct wpa_supplicant *wpa_s = ctx; + struct wpa_supplicant *go; struct wpa_ssid *s; - u8 bssid[ETH_ALEN]; /* * group_iface will be set to 1 only if a dedicated interface for P2P @@ -3690,17 +3676,25 @@ static int wpas_get_go_info(void *ctx, u8 *intended_addr, * that the pending interface should be used. */ *group_iface = 0; - s = wpas_p2p_group_go_ssid(wpa_s, bssid); - if (!s) { + + if (freq) + *freq = 0; + + go = wpas_p2p_get_go_group(wpa_s); + if (!go) { s = wpas_p2p_get_persistent_go(wpa_s); *group_iface = wpas_p2p_create_iface(wpa_s); if (s) - os_memcpy(bssid, s->bssid, ETH_ALEN); + os_memcpy(intended_addr, s->bssid, ETH_ALEN); else return 0; + } else { + s = go->current_ssid; + os_memcpy(intended_addr, go->own_addr, ETH_ALEN); + if (freq) + *freq = go->assoc_freq; } - os_memcpy(intended_addr, bssid, ETH_ALEN); os_memcpy(ssid, s->ssid, s->ssid_len); *ssid_len = s->ssid_len;