From patchwork Thu Jul 16 12:50:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Eckert X-Patchwork-Id: 1330207 X-Patchwork-Delegate: nbd@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=dev.tdt.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=c3Dgr3z/; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (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 ozlabs.org (Postfix) with ESMTPS id 4B6vKy4J71z9sSt for ; Thu, 16 Jul 2020 22:52:38 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References:List-Owner; bh=gZGrZ37a1zluNup46t/2mGA3Nb5H8ODvjLNgPRudBU4=; b=c3Dgr3z/T80JOY/Vb9K4p7iqdf /c32SZGd3JU7SEdUzWp6nIucU7koEWLhSrr0ypD9+fbgo50W0AjFbovwMWjJbVfuBxw9/o7yMmUG+ g8p43tM1vy+5SG5MeKwRz8pLgMRd6aYD2ktnJqS915P4hkQvWHkfYqnUeTpKowYAT0ZRSDEeuaHzZ RHjZZ2AKEKxbo4Abi/XX1Ig/LObuoiCD1JUXpWfTGp1NYdi3DyYjJL3kQmByTDcgdqRKfGmnD2WwA lLXdl9za03PYCV4cjSEziYgBHDjnPsUbkY43W83pj1YT/UVFI8BK263j1bIT2GPF5vikJ6hiafnnn enZ32M6A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jw3LQ-00037K-NU; Thu, 16 Jul 2020 12:50:36 +0000 Received: from host-88-217-225-28.customer.m-online.net ([88.217.225.28] helo=mail.dev.tdt.de) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jw3LO-00036b-6l for openwrt-devel@lists.openwrt.org; Thu, 16 Jul 2020 12:50:35 +0000 Received: from feckert.dev.tdt.de (unknown [10.2.3.40]) by mail.dev.tdt.de (Postfix) with ESMTPSA id D92BD20072; Thu, 16 Jul 2020 12:50:27 +0000 (UTC) From: Florian Eckert To: ynezz@true.cz, nbd@nbd.name, Eckert.Florian@googlemail.com Subject: [PATCH v2 1/1] wireless-regdb: add country selection Date: Thu, 16 Jul 2020 14:50:17 +0200 Message-Id: <20200716125017.17669-1-fe@dev.tdt.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dev.tdt.de X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200716_085034_362535_E5B88505 X-CRM114-Status: GOOD ( 10.53 ) X-Spam-Score: 0.4 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS 0.1 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openwrt-devel@lists.openwrt.org, Florian Eckert Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Until now it has not been possible to remove countries from the regdb. The packages has been extended, so that it is now possible to add or omit individual countries in the regdb during package compile time. You can now add countries to a blacklist or whitelist to customize the regdb. In the blacklist or whitelist the countries must be entered in a comma separated list. So abbreviation for the countries are entered in IS03166 ALPHA-2 notation. If this option is not activated, then all countries in the regdb are taken over as before. Signed-off-by: Florian Eckert --- package/firmware/wireless-regdb/Config.in | 47 ++++++++++++++++++++ package/firmware/wireless-regdb/Makefile | 52 ++++++++++++++++++++++- 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 package/firmware/wireless-regdb/Config.in diff --git a/package/firmware/wireless-regdb/Config.in b/package/firmware/wireless-regdb/Config.in new file mode 100644 index 0000000000..1a37ff4d2b --- /dev/null +++ b/package/firmware/wireless-regdb/Config.in @@ -0,0 +1,47 @@ +if PACKAGE_wireless-regdb + +config WIRELESS_REGDB_CUSTOM + bool "Customize wirelss regdb country selection" + default n + help + Enabling this allows customization the wireless regdb + in blacklist and whitelist. + +if WIRELESS_REGDB_CUSTOM + +menu "Settings" + +choice + prompt "Choose regdb handling" + default WIRELESS_REGDB_WHITELIST + help + Choose which regdb handling you want to use during compile time. + +config WIRELESS_REGDB_WHITELIST + bool "whitelist" + help + Add a comma separated list, which countries should be included + in the regdb during package compile (ISO3166 ALPHA-2). + +config WIRELESS_REGDB_BLACKLIST + bool "blacklist" + help + Add a comma seperate list which countries should NOT be included + in the regdb during package compile (ISO3166 ALPHA-2). + +endchoice + +config WIRELESS_REGDB_COUNTRIES + string "Country list (ISO3166 ALPHA-2)" + help + Add a comma separated country list for whitelist/blacklist + handling in wireless regdb during compile time in + ISO3166 ALPHA-2 notation. + For example: DE,FR,US,ES + +endmenu + +endif + +endif + diff --git a/package/firmware/wireless-regdb/Makefile b/package/firmware/wireless-regdb/Makefile index fc18d159b1..3ba95ce320 100644 --- a/package/firmware/wireless-regdb/Makefile +++ b/package/firmware/wireless-regdb/Makefile @@ -20,8 +20,58 @@ define Package/wireless-regdb TITLE:=Wireless Regulatory Database endef +define Package/wireless-regdb/config + source "$(SOURCE)/Config.in +endef + +define Build/Configure + $(CP) $(PKG_BUILD_DIR)/db.txt $(PKG_BUILD_DIR)/db-gen.txt + ( \ + if [ "$(CONFIG_WIRELESS_REGDB_CUSTOM)" = "y" ]; then \ + echo "" > $(PKG_BUILD_DIR)/db-gen.txt; \ + IFS='\n'; \ + while read -r line; do \ + if echo "$$$$line" | grep "^country" 1>/dev/null 2>/dev/null; then \ + IFS_BAK=$$$$IFS; \ + IFS=','; \ + code=$$$${line:8:2}; \ + countries=$(CONFIG_WIRELESS_REGDB_COUNTRIES); \ + for country in $$$$countries; do \ + if [ "$(CONFIG_WIRELESS_REGDB_WHITELIST)" = "y" ]; then \ + if [ "$$$$code" = "$$$$country" ]; then \ + match="yes"; \ + break; \ + else \ + match="no"; \ + fi; \ + fi; \ + if [ "$(CONFIG_WIRELESS_REGDB_BLACKLIST)" = "y" ]; then \ + if [ "$$$$code" = "$$$$country" ]; then \ + match="no"; \ + break; \ + else \ + match="yes"; \ + fi; \ + fi; \ + done; \ + IFS=$$$$IFS_BAK; \ + fi; \ + if echo "$$$$line" | grep "^wmmrule ETSI:" 1>/dev/null 2>/dev/null; then \ + match="yes"; \ + fi; \ + if [ "$$$$match" = "yes" ]; then \ + printf "%s\n" "$$$$line" >> $(PKG_BUILD_DIR)/db-gen.txt; \ + fi; \ + if [ -z "$$$$line" ] && [ "$$$$match" = "yes" ]; then \ + match="no"; \ + fi; \ + done < $(PKG_BUILD_DIR)/db.txt; \ + fi; \ + ) +endef + define Build/Compile - $(STAGING_DIR_HOST)/bin/$(PYTHON) $(PKG_BUILD_DIR)/db2fw.py $(PKG_BUILD_DIR)/regulatory.db $(PKG_BUILD_DIR)/db.txt + $(STAGING_DIR_HOST)/bin/$(PYTHON) $(PKG_BUILD_DIR)/db2fw.py $(PKG_BUILD_DIR)/regulatory.db $(PKG_BUILD_DIR)/db-gen.txt endef define Package/wireless-regdb/install