From patchwork Mon Feb 28 20:55:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Baligh Gasmi gasmibal@gmail.com" X-Patchwork-Id: 1599108 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=MDiu6aK4; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=oAoOHq9W; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K7D4C39ndz9tkx for ; Tue, 1 Mar 2022 21:28:43 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=N+oE9/sffvMiK80hX5cg0VwPg86sWzs0A9czrVgIThQ=; b=MDiu6aK419UTYh d6nnV1mNx8kqzQ4oe7mfKl1ruMPJ/QgvYnXTGeWRaXR1Q6aokkNgkHjdLU/YocQL3B/g/N9Krf80p JMk2Ys1KMUOG/7o+5aYoLkVLXGW/h9vjmlIuQvPBjoQbPTf1diaov+ZRwHISudMv1ZJWJKKFIX+Kn UUCE46wikNwe9YwO5DpMqOGgnowSgxLO1QGNzXQV2nTkb92sr3vOsMNPq2OUIh3QlouBPP0C+DCcp ie4siSPYiCIpJ5kpx29r+iN4V20RxSV47o0s/iLDJLnvDtZOPVmNB78F/g5eqgty4Putdxse8fUMC yM3uB8hPqmxSC6tgR6bQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOn3N-00E4wl-SE; Mon, 28 Feb 2022 20:55:33 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOn3J-00E4vl-Jc for hostap@lists.infradead.org; Mon, 28 Feb 2022 20:55:31 +0000 Received: by mail-wm1-x330.google.com with SMTP id c192so6419765wma.4 for ; Mon, 28 Feb 2022 12:55:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3tk4Nqa5d9YuwBRtxYx7jpVoFgmM/kKlxux+KBKBPwg=; b=oAoOHq9W8uEmT1UkxpB6sZhIu5PF3mTAm5N8KFQvwMnvrELiueM8PEFBVyDPPM+OSJ T658f+5DnKrASD10nSqFYtChkpLruXGfQ+9FntHi+jVG5UbAxP6CdZ56CE+65SyOH94v 68Sj87FTDwrzOYXCZubBOqI+f5TRTwsZKOC6WNJJtXkKTU9/ouxSotjFIO1mcUssGtjS w13V0T+UfPgoEqn3LGcCKw5HVPXIeivson9GI94KgL2JzILIGoYBFbLW61nC6xdDTR14 CJy/R7hivSssiBCUkWcSVJywN0wFwymKsUB5C/7+aDRBBB+NerjtsGx70lb5EN+/8Lp6 G3Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3tk4Nqa5d9YuwBRtxYx7jpVoFgmM/kKlxux+KBKBPwg=; b=wBYIz/byYwsLXDmNEdQbNk8P8EUWyI8AMdWJSreAtARSF1iX6SkvND8PLdtR7u9Bbl roj22ud7+s/bDrGPdfxugPF7Ko7pULMeseArUS5OtcF0mJ58vukQKi9yWMvFlp+Mtzoz tUHca3aRWzoEV06+pAVuIkLn5iA7xH+Hk6Ztm8pkk4w1xBniuWnTXQ8WiHF46Me5AR8A 7sEWdrQgb5Xjz2oCbzjqcsksBqQAwqPuoQg4IiEGyR7DG05oppv5AXRNGnNemnMYgC3V jQ1fCggCVu4mYH/hsLTLBFJwMXVnLj/8NRSxCIdK5zHbgnoIXrUQRROd6p2Sti/YuVG9 Rzzw== X-Gm-Message-State: AOAM533LVSljquGDT54RrGfrga/9m1d5vDIZgdCLJQLfT+1blr9o9haL klhOjy0Zw7+ybHlTz9o6MTW4kftAxu8= X-Google-Smtp-Source: ABdhPJyiVIDZyrBdAiGK8qU6VaQJYGvIS5v3UngOa5GCUiyB86E90fc1Ge3BiK/VFwK2lGdREZapIw== X-Received: by 2002:a1c:e90a:0:b0:381:504e:b57d with SMTP id q10-20020a1ce90a000000b00381504eb57dmr8351414wmc.177.1646081726625; Mon, 28 Feb 2022 12:55:26 -0800 (PST) Received: from baligh-ThinkCentre-M720q.iliad.local (freebox.vlq16.iliad.fr. [213.36.7.13]) by smtp.googlemail.com with ESMTPSA id a9-20020a05600c2d4900b0038100a95903sm448068wmg.41.2022.02.28.12.55.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 12:55:26 -0800 (PST) From: Baligh Gasmi To: hostap@lists.infradead.org Cc: Baligh Gasmi Subject: [PATCH 1/2] tests: Active beacon req for primary/center channel Date: Mon, 28 Feb 2022 21:55:23 +0100 Message-Id: <20220228205523.149995-1-gasmibal@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220228_125529_668090_EE3AF1A8 X-CRM114-Status: UNSURE ( 9.42 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Add tests for active beacon request to scan a specific VHT channel, either using primary channel or a center freq channel numbers. Signed-off-by: Baligh Gasmi --- tests/hwsim/test_rrm.py | 82 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:330 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [gasmibal[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Add tests for active beacon request to scan a specific VHT channel, either using primary channel or a center freq channel numbers. Signed-off-by: Baligh Gasmi --- tests/hwsim/test_rrm.py | 82 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/tests/hwsim/test_rrm.py b/tests/hwsim/test_rrm.py index 5a65a506e..e62565984 100644 --- a/tests/hwsim/test_rrm.py +++ b/tests/hwsim/test_rrm.py @@ -1795,6 +1795,88 @@ def test_rrm_beacon_req_passive_scan_vht160(dev, apdev): finally: clear_regdom(hapd, dev) +def test_rrm_beacon_req_active_scan_pri_channel(dev, apdev): + """Beacon request - primary channel active scan mode - VHT80""" + clear_scan_cache(apdev[0]) + try: + hapd = None + params = {"ssid": "rrm-vht", + "country_code": "FR", + 'ieee80211d': '0', + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "1", + "vht_oper_centr_freq_seg0_idx": "42", + "rrm_beacon_report": "1"} + + hapd = hostapd.add_ap(apdev[0], params) + + dev[0].scan_for_bss(apdev[0]['bssid'], freq=5180) + dev[0].connect("rrm-vht", key_mgmt="NONE", scan_freq="5180") + dev[0].request("LEVEL debug") + dev[0].request("LOG_LEVEL MSGDUMP") + + sig = dev[0].request("SIGNAL_POLL").splitlines() + addr = dev[0].own_addr() + token = run_req_beacon(hapd, addr, "80240000040001ffffffffffff") + ev = hapd.wait_event(["BEACON-RESP-RX"], timeout=10) + if ev is None: + raise Exception("Beacon report response not received") + fields = ev.split(' ') + if not fields[4]: + raise Exception("Beacon report is empty") + report = BeaconReport(binascii.unhexlify(fields[4])) + logger.info("Received beacon report: " + str(report)) + if report.opclass != 128: + raise Exception("Incorrect opclass for AP") + except Exception as e: + raise + finally: + clear_regdom(hapd, dev) + +def test_rrm_beacon_req_active_scan_center_freq_channel(dev, apdev): + """Beacon request - center channel active scan mode - VHT80""" + clear_scan_cache(apdev[0]) + try: + hapd = None + params = {"ssid": "rrm-vht", + "country_code": "FR", + 'ieee80211d': '0', + "hw_mode": "a", + "channel": "36", + "ht_capab": "[HT40+]", + "ieee80211n": "1", + "ieee80211ac": "1", + "vht_oper_chwidth": "1", + "vht_oper_centr_freq_seg0_idx": "42", + "rrm_beacon_report": "1"} + + hapd = hostapd.add_ap(apdev[0], params) + + dev[0].scan_for_bss(apdev[0]['bssid'], freq=5180) + dev[0].connect("rrm-vht", key_mgmt="NONE", scan_freq="5180") + sig = dev[0].request("SIGNAL_POLL").splitlines() + addr = dev[0].own_addr() + token = run_req_beacon(hapd, addr, "802a0000040001ffffffffffff") + ev = hapd.wait_event(["BEACON-RESP-RX"], timeout=10) + if ev is None: + raise Exception("Beacon report response not received") + fields = ev.split(' ') + if not fields[4]: + raise Exception("Empty beacon report") + report = BeaconReport(binascii.unhexlify(fields[4])) + logger.info("Received beacon report: " + str(report)) + if report.opclass != 128: + raise Exception("Incorrect opclass for AP") + except Exception as e: + raise + finally: + clear_regdom(hapd, dev) + + def test_rrm_beacon_req_ap_errors(dev, apdev): """Beacon request - AP error cases""" try: From patchwork Mon Feb 28 20:55:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Baligh Gasmi gasmibal@gmail.com" X-Patchwork-Id: 1599109 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=yCwsAlN1; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=WuUUEBqV; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K7D4C71XLz9tkp for ; Tue, 1 Mar 2022 21:28:43 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=h16A42KggNQuPy9mrm4IEH+KB03xU9GN0hX0QZz0rCo=; b=yCwsAlN1ZUfTPP R7WuWAVl+YUUgRsFpCUrhT8ZNO3fJM+PzWw9vhN71EVVohTgqmSfAcZ+1Y89C/uMX9Oaea2gk9LBd /kLjg+4YomsFCxM0e2dSS6VEmCgWOqdVNZUzuv9YxUC10QuwceIqMz0+3/FXpEWyue/MfsG2xK/eo B/ElulPiGtT/JfDmzQnQ8FizvqG4IQF2hyVFnoVL4upP7GH2MoZAnZSh34zZd/MFl/SWiGGWBC33l pyMDFHxkuHsw9SykHkvysaYva+S1IZzNkEC7XDhCRCowLQpzTAgg286hhXOmGph/RtiuXyoFIdnQM XhFwB/eUUnPT046xJi+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOn3c-00E4zr-7N; Mon, 28 Feb 2022 20:55:48 +0000 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOn3Z-00E4yX-8M for hostap@lists.infradead.org; Mon, 28 Feb 2022 20:55:46 +0000 Received: by mail-wr1-x433.google.com with SMTP id d3so17389323wrf.1 for ; Mon, 28 Feb 2022 12:55:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8l+STGtB9wsuwFRBbUATdOWYW3nhTLP3oO4Z7q/vDUw=; b=WuUUEBqVcZYkYUCZNoEhZw0rNbxntYQynFdsL7b3a0cVcSR7FHud2H4tLc+kbKINO6 l974NBq1xxJ1woyNGlj228b/2U89UXzrugYcuKi3pIM543vHEjTzFv68Cra/rWfvgJZW 52ymEBPdPtgxywhVc82ELzATRVwCFPPvbTQJZTFq035ntcyWhtv9AAsZO6nTCJLAdtR1 izu71USWApogPTr07gLhMzLCW/8Yq9Tj+75FkMaMcUAbJY31bwHH0TtIXPpN/vKTTtYp wNfSstjSV4BPOAZ0J9r+JJmYEjrK7X75djCwKGz5oGKh8+HvmBfPMNbpA0WPyQMtJ7up ONsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8l+STGtB9wsuwFRBbUATdOWYW3nhTLP3oO4Z7q/vDUw=; b=blyhYul7gdBU5W7W9N2w47dbxhSqLiSfI/0M17wLJZ1U5TyIq4w6IozSSV7f+CkL1G jKH2gygSLw7b0jdM+NBFVmRFMTDvVg2Cq840mmKdcozFdEvgQ85HsfWecY+AMTAoGVo4 mSjHJMAbfu/LymqMeaOaNYY/BEgDAiYEoxplM+0ki7K31rHYxT+TuMK73X9AE2KJvcib JjAQozajQA1h92QM812hbWI4yAUquJzwTydBPxScCXvjh0hx0BXimwbu/rC8DLJOpOVn RIcdewzYPkhRwo5aR94B9M+bfI9W6O1J2FCl50h/CyCjfuQBJguKsyt1GUu4rOWjn+zT +K9Q== X-Gm-Message-State: AOAM531H+tRHU42J7MsVCye5uKrL+V7ekSYeT7yNDhBYwnm8kpiNS9aM tfFOj3vk58stAdsCfwCItNEYAgoH9ro= X-Google-Smtp-Source: ABdhPJxYh57zOwiNEJM7Khoh/tbYDUJij1Q9PMwI/vGW00L2zyLY72qP+6tczBm5ZuA6AY3Gs/4QSA== X-Received: by 2002:adf:9d87:0:b0:1ea:99d9:256f with SMTP id p7-20020adf9d87000000b001ea99d9256fmr16854477wre.428.1646081743144; Mon, 28 Feb 2022 12:55:43 -0800 (PST) Received: from baligh-ThinkCentre-M720q.iliad.local (freebox.vlq16.iliad.fr. [213.36.7.13]) by smtp.googlemail.com with ESMTPSA id m62-20020a1c2641000000b00380d0cff5f3sm495447wmm.8.2022.02.28.12.55.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 12:55:42 -0800 (PST) From: Baligh Gasmi To: hostap@lists.infradead.org Cc: Baligh Gasmi Subject: [PATCH 2/2] Fix beacon request with a given channel number Date: Mon, 28 Feb 2022 21:55:40 +0100 Message-Id: <20220228205540.150442-1-gasmibal@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220228_125545_361340_AD100550 X-CRM114-Status: GOOD ( 16.16 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: When receiving a beacon request to scan one single channel, with 80MHz bandwidth, the freq for the 20MHz primary channels found are not correct. This commit is about fix that by looking for the center freq channel first, and then calculate the 20MHz channels freq. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:433 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [gasmibal[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When receiving a beacon request to scan one single channel, with 80MHz bandwidth, the freq for the 20MHz primary channels found are not correct. This commit is about fix that by looking for the center freq channel first, and then calculate the 20MHz channels freq. test [OK]: rrm_beacon_req_active_scan_pri_channel Signed-off-by: Baligh Gasmi --- wpa_supplicant/op_classes.c | 64 +++++++++++++++---------------- wpa_supplicant/rrm.c | 12 +++++- wpa_supplicant/wpa_supplicant_i.h | 3 +- 3 files changed, 44 insertions(+), 35 deletions(-) diff --git a/wpa_supplicant/op_classes.c b/wpa_supplicant/op_classes.c index bd53c5cec..8a51f087c 100644 --- a/wpa_supplicant/op_classes.c +++ b/wpa_supplicant/op_classes.c @@ -47,10 +47,23 @@ static enum chan_allowed allow_channel(struct hostapd_hw_modes *mode, } -static int get_center_80mhz(struct hostapd_hw_modes *mode, u8 channel, - const u8 *center_channels, size_t num_chan) +int get_center_80mhz(struct hostapd_hw_modes *mode, u8 channel, + u8 op_class) { size_t i; + size_t num_chan; + const u8 *center_channels; + const u8 center_channels_5ghz[] = { 42, 58, 106, 122, 138, 155, 171 }; + const u8 center_channels_6ghz[] = { 7, 23, 39, 55, 71, 87, 103, 119, + 135, 151, 167, 183, 199, 215 }; + + if (is_6ghz_op_class(op_class)) { + center_channels = center_channels_6ghz; + num_chan = ARRAY_SIZE(center_channels_6ghz); + } else { + center_channels = center_channels_5ghz; + num_chan = ARRAY_SIZE(center_channels_5ghz); + } if (mode->mode != HOSTAPD_MODE_IEEE80211A) return 0; @@ -75,22 +88,8 @@ static enum chan_allowed verify_80mhz(struct hostapd_hw_modes *mode, u8 center_chan; unsigned int i; unsigned int no_ir = 0; - const u8 *center_channels; - size_t num_chan; - const u8 center_channels_5ghz[] = { 42, 58, 106, 122, 138, 155, 171 }; - const u8 center_channels_6ghz[] = { 7, 23, 39, 55, 71, 87, 103, 119, - 135, 151, 167, 183, 199, 215 }; - - if (is_6ghz_op_class(op_class)) { - center_channels = center_channels_6ghz; - num_chan = ARRAY_SIZE(center_channels_6ghz); - } else { - center_channels = center_channels_5ghz; - num_chan = ARRAY_SIZE(center_channels_5ghz); - } - center_chan = get_center_80mhz(mode, channel, center_channels, - num_chan); + center_chan = get_center_80mhz(mode, channel, op_class); if (!center_chan) return NOT_ALLOWED; @@ -120,10 +119,22 @@ static enum chan_allowed verify_80mhz(struct hostapd_hw_modes *mode, } -static int get_center_160mhz(struct hostapd_hw_modes *mode, u8 channel, - const u8 *center_channels, size_t num_chan) +int get_center_160mhz(struct hostapd_hw_modes *mode, u8 channel, + u8 op_class) { unsigned int i; + size_t num_chan; + const u8 *center_channels; + const u8 center_channels_5ghz[] = { 50, 114, 163 }; + const u8 center_channels_6ghz[] = { 15, 47, 79, 111, 143, 175, 207 }; + + if (is_6ghz_op_class(op_class)) { + center_channels = center_channels_6ghz; + num_chan = ARRAY_SIZE(center_channels_6ghz); + } else { + center_channels = center_channels_5ghz; + num_chan = ARRAY_SIZE(center_channels_5ghz); + } if (mode->mode != HOSTAPD_MODE_IEEE80211A) return 0; @@ -148,21 +159,8 @@ static enum chan_allowed verify_160mhz(struct hostapd_hw_modes *mode, u8 center_chan; unsigned int i; unsigned int no_ir = 0; - const u8 *center_channels; - size_t num_chan; - const u8 center_channels_5ghz[] = { 50, 114, 163 }; - const u8 center_channels_6ghz[] = { 15, 47, 79, 111, 143, 175, 207 }; - - if (is_6ghz_op_class(op_class)) { - center_channels = center_channels_6ghz; - num_chan = ARRAY_SIZE(center_channels_6ghz); - } else { - center_channels = center_channels_5ghz; - num_chan = ARRAY_SIZE(center_channels_5ghz); - } - center_chan = get_center_160mhz(mode, channel, center_channels, - num_chan); + center_chan = get_center_160mhz(mode, channel, op_class); if (!center_chan) return NOT_ALLOWED; diff --git a/wpa_supplicant/rrm.c b/wpa_supplicant/rrm.c index cf107ebaf..3b68f0179 100644 --- a/wpa_supplicant/rrm.c +++ b/wpa_supplicant/rrm.c @@ -529,13 +529,23 @@ static int * wpas_add_channels(const struct oper_class_map *op, next_freq = freqs; for (i = 0; i < num_chans; i++) { u8 chan = channels ? channels[i] : op->min_chan + i * op->inc; + u8 center_freq_chan = chan; enum chan_allowed res = verify_channel(mode, op->op_class, chan, op->bw); if (res == NOT_ALLOWED || (res == NO_IR && active)) continue; - if (wpas_add_channel(op->op_class, chan, num_primary_channels, + /* in VHT/HT we need the center-freq-channel */ + if (op->bw == BW80 || op->bw == BW80P80) + center_freq_chan = get_center_80mhz(mode, chan, op->op_class); + else if (op->bw == BW160) + center_freq_chan = get_center_160mhz(mode, chan, op->op_class); + + /* if no valid result use given channel */ + center_freq_chan = center_freq_chan?:chan; + + if (wpas_add_channel(op->op_class, center_freq_chan, num_primary_channels, next_freq) < 0) { os_free(freqs); return NULL; diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 111aa0744..d8fa3dcd9 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1706,7 +1706,8 @@ void wpas_update_mbo_connect_params(struct wpa_supplicant *wpa_s); enum chan_allowed { NOT_ALLOWED, NO_IR, RADAR, ALLOWED }; - +int get_center_80mhz(struct hostapd_hw_modes *mode, u8 channel, u8 op_class); +int get_center_160mhz(struct hostapd_hw_modes *mode, u8 channel, u8 op_class); enum chan_allowed verify_channel(struct hostapd_hw_modes *mode, u8 op_class, u8 channel, u8 bw); size_t wpas_supp_op_class_ie(struct wpa_supplicant *wpa_s,