From patchwork Tue Sep 4 17:52:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arik Nemtsov X-Patchwork-Id: 181647 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 F158E2C008A for ; Wed, 5 Sep 2012 03:53:30 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 5F58A9D208; Tue, 4 Sep 2012 13:53: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 0P6SCPxdgZ27; Tue, 4 Sep 2012 13:53:18 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 4FB509D1F2; Tue, 4 Sep 2012 13:53:05 -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 538149C1CB for ; Tue, 4 Sep 2012 13:53:04 -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 rfxCscI8jifl for ; Tue, 4 Sep 2012 13:53:00 -0400 (EDT) Received: from mail-wg0-f48.google.com (mail-wg0-f48.google.com [74.125.82.48]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client did not present a certificate) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 8B57D9C1D2 for ; Tue, 4 Sep 2012 13:53:00 -0400 (EDT) Received: by wgbdq11 with SMTP id dq11so3615880wgb.5 for ; Tue, 04 Sep 2012 10:52:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=OwN4X9373bIWWF6zmfWBvDUgPmDPWG46iC05qK34uFo=; b=E5NCjYc3C78lyan12j7qBKJ5A7viqxq3nnGgCVg+RA5Bu0NhmTpklu0a8VJuiuD5Ey dLW/0Z8mIOsmE4QwIHK6Ns9of/RydyBiFeS1kfi+HuC+fXRC5+R4Nzq26MmXZ7jvhsUL wN2dd0dU6OnauekMw3QuE0zXEBB2fWoSZLv/dLfBNo8YCJfHQTi2t2Wci3TQlT9yTZZ6 DN8uNVaBK+r3/NvvLaUMLZkCEMo72aV+6kYzm+7gbr4jJB4tk0wKq9uWRHC6R55oa1FV 9bY231LMKYSvY3FnHEsQKV9ZLARpk4KLq/2BIgRx1NoI3qWpgIAlMBaRFR1cxnIHvn6m wYIw== Received: by 10.180.96.3 with SMTP id do3mr32250774wib.5.1346781179395; Tue, 04 Sep 2012 10:52:59 -0700 (PDT) Received: from localhost.localdomain (109-186-69-34.bb.netvision.net.il. [109.186.69.34]) by mx.google.com with ESMTPS id t7sm38160242wix.6.2012.09.04.10.52.57 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 04 Sep 2012 10:52:58 -0700 (PDT) From: Arik Nemtsov To: hostap@lists.shmoo.com Subject: [PATCH 2/3] P2P: always re-select oper channel if not hard coded Date: Tue, 4 Sep 2012 20:52:50 +0300 Message-Id: <1346781171-16854-2-git-send-email-arik@wizery.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1346781171-16854-1-git-send-email-arik@wizery.com> References: <1346781171-16854-1-git-send-email-arik@wizery.com> X-Gm-Message-State: ALoCoQkhdFnjLPPR3qUc3pDdNd9x3JiONS23grjBhYAPvp5ARgxioIsmWqMhWYJDWnLL33iGcKNc Cc: Arik Nemtsov 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: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com Since the operating channel is randomly set to 1/6/11 on init, which is always in the channel intersection, we were effectively ignoring the set of p2p preferred channels. Fix this by trying to get the best channel we can, unless the user hard coded the operating channel in the configuration file. Fall back to the initial randomly selected channel if a better one cannot be chosen. Signed-hostap: Arik Nemtsov --- src/p2p/p2p_go_neg.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/p2p/p2p_go_neg.c b/src/p2p/p2p_go_neg.c index 031b3a1..e1ba466 100644 --- a/src/p2p/p2p_go_neg.c +++ b/src/p2p/p2p_go_neg.c @@ -391,6 +391,20 @@ static void p2p_reselect_channel(struct p2p_data *p2p, } /* + * Try to see if the original channel is in the intersection. If + * so, no need to change anything, as it already contains some + * randomness. + */ + if (p2p_channels_includes(intersection, p2p->op_reg_class, + p2p->op_channel)) { + wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, + "P2P: Using original operating class and channel " + "(reg_class %u channel %u) from intersection", + p2p->op_reg_class, p2p->op_channel); + return; + } + + /* * Fall back to whatever is included in the channel intersection since * no better options seems to be available. */ @@ -639,7 +653,8 @@ void p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa, wpa_hexdump(MSG_DEBUG, "P2P: channels", c->channel, c->channels); } - if (!p2p_channels_includes(&intersection, + if (!p2p->cfg->cfg_op_channel || + !p2p_channels_includes(&intersection, p2p->op_reg_class, p2p->op_channel)) p2p_reselect_channel(p2p, &intersection);