From 5017c2ab1bd3ec70f556f325c138a9adedca1947 Mon Sep 17 00:00:00 2001
From: Frank Hunleth <fhunleth@troodon-software.com>
Date: Mon, 9 May 2016 13:21:56 -0400
Subject: [PATCH] kernel-wireless-regdb: install regdb in kernel

This kernel extension makes the CONFIG_CFG80211_INTERNAL_REGDB kernel
option work by installing a wireless regulatory database into
net/wireless/db.txt.
---
 linux/Config.ext.in                                      |  8 ++++++++
 linux/linux-ext-kernel-wireless-regdb.mk                 | 12 ++++++++++++
 package/Config.in                                        |  1 +
 package/kernel-wireless-regdb/Config.in                  |  9 +++++++++
 package/kernel-wireless-regdb/kernel-wireless-regdb.hash |  2 ++
 package/kernel-wireless-regdb/kernel-wireless-regdb.mk   | 13 +++++++++++++
 6 files changed, 45 insertions(+)
 create mode 100644 linux/linux-ext-kernel-wireless-regdb.mk
 create mode 100644 package/kernel-wireless-regdb/Config.in
 create mode 100644 package/kernel-wireless-regdb/kernel-wireless-regdb.hash
 create mode 100644 package/kernel-wireless-regdb/kernel-wireless-regdb.mk

diff --git a/linux/Config.ext.in b/linux/Config.ext.in
index 6705adb..7350a20 100644
--- a/linux/Config.ext.in
+++ b/linux/Config.ext.in
@@ -137,4 +137,12 @@ config BR2_LINUX_KERNEL_EXT_AUFS_VERSION
 
 endif # aufs
 
+# kernel-wireless-regdb
+config BR2_LINUX_KERNEL_EXT_KERNEL_WIRELESS_REGDB
+	bool "Wireless regulatory database"
+	select BR2_PACKAGE_KERNEL_WIRELESS_REGDB
+	help
+	  Install the wireless regulatory database into the kernel
+	  to support the CONFIG_CFG80211_INTERNAL_REGDB option.
+
 endmenu
diff --git a/linux/linux-ext-kernel-wireless-regdb.mk b/linux/linux-ext-kernel-wireless-regdb.mk
new file mode 100644
index 0000000..3cec0cd
--- /dev/null
+++ b/linux/linux-ext-kernel-wireless-regdb.mk
@@ -0,0 +1,12 @@
+################################################################################
+# Linux wireless-regdb extension
+#
+# Patch the linux kernel with the latest wireless-regdb database.
+# This enables the CONFIG_CFG80211_INTERNAL_REGDB kernel option.
+################################################################################
+
+LINUX_EXTENSIONS += kernel-wireless-regdb
+
+define KERNEL_WIRELESS_REGDB_PREPARE_KERNEL
+	cp -pf $(KERNEL_WIRELESS_REGDB_DIR)/db.txt $(LINUX_DIR)/net/wireless/db.txt
+endef
diff --git a/package/Config.in b/package/Config.in
index 0d2001c..3e1bc27 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1674,6 +1674,7 @@ menu "Networking applications"
 	source "package/iw/Config.in"
 	source "package/janus-gateway/Config.in"
 	source "package/keepalived/Config.in"
+	source "package/kernel-wireless-regdb/Config.in"
 	source "package/kismet/Config.in"
 	source "package/knock/Config.in"
 	source "package/leafnode2/Config.in"
diff --git a/package/kernel-wireless-regdb/Config.in b/package/kernel-wireless-regdb/Config.in
new file mode 100644
index 0000000..8a54a21
--- /dev/null
+++ b/package/kernel-wireless-regdb/Config.in
@@ -0,0 +1,9 @@
+config BR2_PACKAGE_KERNEL_WIRELESS_REGDB
+	bool "kernel-wireless-regdb"
+	help
+	  Wireless regulatory database.
+
+	  Wireless regulatory database for the kernel. The database
+	  lists allowed radio frequencies for each local jurisdiction.
+
+	  http://linuxwireless.org/en/developers/Regulatory
diff --git a/package/kernel-wireless-regdb/kernel-wireless-regdb.hash b/package/kernel-wireless-regdb/kernel-wireless-regdb.hash
new file mode 100644
index 0000000..4163609
--- /dev/null
+++ b/package/kernel-wireless-regdb/kernel-wireless-regdb.hash
@@ -0,0 +1,2 @@
+# From https://www.kernel.org/pub/software/network/wireless-regdb/sha256sums.asc
+sha256	371eafa3b26ece916ef83aca02c4bed2e54099eb5b8c6d22d3a4358dce6535b9	wireless-regdb-2017.03.07.tar.xz
diff --git a/package/kernel-wireless-regdb/kernel-wireless-regdb.mk b/package/kernel-wireless-regdb/kernel-wireless-regdb.mk
new file mode 100644
index 0000000..7da7f9e
--- /dev/null
+++ b/package/kernel-wireless-regdb/kernel-wireless-regdb.mk
@@ -0,0 +1,13 @@
+################################################################################
+#
+# kernel-wireless-regdb
+#
+################################################################################
+
+KERNEL_WIRELESS_REGDB_VERSION = 2017.03.07
+KERNEL_WIRELESS_REGDB_SOURCE = wireless-regdb-$(WIRELESS_REGDB_VERSION).tar.xz
+KERNEL_WIRELESS_REGDB_SITE = http://kernel.org/pub/software/network/wireless-regdb
+KERNEL_WIRELESS_REGDB_LICENSE = ISC
+KERNEL_WIRELESS_REGDB_LICENSE_FILES = LICENSE
+
+$(eval $(generic-package))
-- 
2.7.4

