From patchwork Mon Aug 6 19:46:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathy Vanhoef X-Patchwork-Id: 954208 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) 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=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cs.kuleuven.be Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="sk2s1HFs"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="cYT4WLaf"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41kpGX6Nh6z9ryt for ; Tue, 7 Aug 2018 05:52:52 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=1150eIAykXeJkFyTjImC2J9ucODEYdbYrzCnzctvgpA=; b=sk2s1HFsG7gM2rbf7icepvhFiU KQKeekjpFDxrKj+qhtCJeRHoI8MrAJ7L/PvNA7n6x9zKbxoYnFXDUfE2hVHanArDwcHlw5//tbvoN vgaLdrlNFieAd8gcQPGa1HcKD+LGT11dcRkrgrN/l6jsDe3aDMBHv0AtoD7Hwn/P2LqcLqQGDOyTR qko7UhZaS679sMlMK+RVLR5p5IPYuoE2gEJbKjUW1H9vjeLphvDsiYU8RAhy+pRAQNg9mI1F8/Yn6 y5LJDPPzffiaeHTdyH7bXY5EP+7z9S2fWADG31v/Ofu/ZnDCsQZh8j5BKTpDytmstjI5VahQlCVG5 OsZ22SXA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmlYd-0004BZ-Pn; Mon, 06 Aug 2018 19:52:47 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmlY1-00037e-Ig for hostap@bombadil.infradead.org; Mon, 06 Aug 2018 19:52:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=P3jHMa8/ES1R50TRY0j21HSpBIvtswx9g4p6Nbtxfro=; b=cYT4WLafXONXb2cXSiaJVgemM WhPxSaOSLjClmRNqE7G7CKRKva9iYc8v4EUtAi8E/Mfz4JhO06yT6CnhootYe/N8iCC3mwvCW9kIN sO/P5c5z1e5YlK3XiTeg/pECwFaLmv27j37v+/lftvux7lYQ8h6IwE6ZC/8ZdQXxdQovBPk4OXQf1 s3eXccUoZkwAiHJpFamPCzxPy/UqGsXqVs2Ib152saY9mhQSkh4xJSdVeyYDb149Ww4ZcBJco7+ky Gn/9fESkjHp2Tsx9e/xVo8d/rxInDzNJ9NYwjiTOGnizWA69B0wPevmKnHuL1f2aSLU/3UkbFrhjz gHewWbvJg==; Received: from vmailrelay1.cs.kuleuven.be ([2a02:2c40:0:a000::118] helo=hermes4.cs.kuleuven.be) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmlXy-0003YK-WF for hostap@lists.infradead.org; Mon, 06 Aug 2018 19:52:07 +0000 Received: from dr-zook.cs.kuleuven.be. (vdr-zook1.cs.kuleuven.be [IPv6:2a02:2c40:500:a005::12c]) by hermes4.cs.kuleuven.be. with ESMTP id w76JiQfU018406 for ; Mon, 6 Aug 2018 21:44:26 +0200 Received: from localhost (localhost [127.0.0.1]) by dr-zook.cs.kuleuven.be. (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id w76JhX2c020697 for ; Mon, 6 Aug 2018 21:44:26 +0200 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dr-zook.cs.kuleuven.be. X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Virus-Scanned: Debian amavisd-new at dr-zook.cs.kuleuven.be Received: from dr-zook.cs.kuleuven.be. ([127.0.0.1]) by localhost (dr-zook.cs.kuleuven.be [127.0.0.1]) (amavisd-new, port 10023) with LMTP id rfEuMJTmpkRa for ; Mon, 6 Aug 2018 21:44:18 +0200 (CEST) Received: from oryx.cs.kuleuven.be. (mail4.cs.kuleuven.be [IPv6:2a02:2c40:0:a000::122]) by dr-zook.cs.kuleuven.be. (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id w76JiBKB020724 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 6 Aug 2018 21:44:11 +0200 Received: from localhost.localdomain (ip-83-134-207-58.dsl.scarlet.be [83.134.207.58]) (authenticated bits=0) by oryx.cs.kuleuven.be. (A_Good_MTA/8.14.4/Debian-4.1ubuntu1) with ESMTP id w76Jhl8m019837 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 6 Aug 2018 21:44:11 +0200 From: Maty Vanhoef To: hostap@lists.infradead.org Subject: [PATCH 05/25] Add functions to convert channel bandwidth to an integer Date: Mon, 6 Aug 2018 15:46:23 -0400 Message-Id: <20180806194643.1328-6-Mathy.Vanhoef@cs.kuleuven.be> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180806194643.1328-1-Mathy.Vanhoef@cs.kuleuven.be> References: <20180806194643.1328-1-Mathy.Vanhoef@cs.kuleuven.be> X-Scanned-By: MIMEDefang 2.73 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180806_155207_253133_D054583D X-CRM114-Status: GOOD ( 14.06 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maty Vanhoef MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This adds two utility functions to convert both operating classes and and the chan_width enum to an integer representing the channel bandwidth. This can then be used to compare bandwidth parameters in an uniform manner. Signed-off-by: Mathy Vanhoef --- src/common/ieee802_11_common.c | 21 +++++++++++++++++++++ src/common/ieee802_11_common.h | 1 + src/drivers/driver.h | 2 ++ src/drivers/driver_common.c | 19 +++++++++++++++++++ 4 files changed, 43 insertions(+) diff --git a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c index 1c64f9b00..c730ebce0 100644 --- a/src/common/ieee802_11_common.c +++ b/src/common/ieee802_11_common.c @@ -1698,6 +1698,27 @@ const struct oper_class_map * get_oper_class(const char *country, u8 op_class) } +int oper_class_bw_to_int(const struct oper_class_map *map) +{ + switch (map->bw) { + case BW20: + return 20; + case BW40PLUS: + case BW40MINUS: + return 40; + case BW80: + return 80; + case BW80P80: + case BW160: + return 160; + case BW2160: + return 2160; + default: + return 0; + } +} + + int ieee802_11_parse_candidate_list(const char *pos, u8 *nei_rep, size_t nei_rep_len) { diff --git a/src/common/ieee802_11_common.h b/src/common/ieee802_11_common.h index 36cb71a5b..26ed66ee3 100644 --- a/src/common/ieee802_11_common.h +++ b/src/common/ieee802_11_common.h @@ -201,6 +201,7 @@ struct country_op_class { u8 country_to_global_op_class(const char *country, u8 op_class); const struct oper_class_map * get_oper_class(const char *country, u8 op_class); +int oper_class_bw_to_int(const struct oper_class_map *map); int ieee802_11_parse_candidate_list(const char *pos, u8 *nei_rep, size_t nei_rep_len); diff --git a/src/drivers/driver.h b/src/drivers/driver.h index b111fbecb..d679fbc57 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -5534,6 +5534,8 @@ const char * event_to_string(enum wpa_event_type event); /* Convert chan_width to a string for logging and control interfaces */ const char * channel_width_to_string(enum chan_width width); +int channel_width_to_int(enum chan_width width); + int ht_supported(const struct hostapd_hw_modes *mode); int vht_supported(const struct hostapd_hw_modes *mode); diff --git a/src/drivers/driver_common.c b/src/drivers/driver_common.c index ac0916e40..1b92e8605 100644 --- a/src/drivers/driver_common.c +++ b/src/drivers/driver_common.c @@ -115,6 +115,25 @@ const char * channel_width_to_string(enum chan_width width) } +int channel_width_to_int(enum chan_width width) +{ + switch (width) { + case CHAN_WIDTH_20_NOHT: + case CHAN_WIDTH_20: + return 20; + case CHAN_WIDTH_40: + return 40; + case CHAN_WIDTH_80: + return 80; + case CHAN_WIDTH_80P80: + case CHAN_WIDTH_160: + return 160; + default: + return 0; + } +} + + int ht_supported(const struct hostapd_hw_modes *mode) { if (!(mode->flags & HOSTAPD_MODE_FLAG_HT_INFO_KNOWN)) {