ASR_BASE
Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/external/subpack/kernel/macremapper/Makefile b/external/subpack/kernel/macremapper/Makefile
new file mode 100644
index 0000000..0889805
--- /dev/null
+++ b/external/subpack/kernel/macremapper/Makefile
@@ -0,0 +1,41 @@
+#
+# Copyright (C) 2019 EWSI
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=macremapper
+PKG_VERSION:=1.1.0
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://codeload.github.com/ewsi/$(PKG_NAME)/tar.gz/v$(PKG_VERSION)?
+PKG_HASH:=f9580427803123d13d50f3422623a37212034a5d72a485f9c04904f19509e4bb
+
+PKG_MAINTAINER:=Carey Sonsino <careys@edgewaterwireless.com>
+PKG_LICENSE:=GPL-2.0-only
+PKG_LICENSE_FILES:=kernelmod/COPYING
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/macremapper
+ SUBMENU:=Network Support
+ URL:=https://www.edgewaterwireless.com
+ TITLE:=Dual Channel Wi-Fi macremapper Module
+ DEPENDS:= +kmod-cfg80211 +kmod-br-netfilter
+ FILES:=$(PKG_BUILD_DIR)/kernelmod/$(PKG_NAME).$(LINUX_KMOD_SUFFIX)
+ AUTOLOAD:=$(call AutoProbe,macremapper)
+endef
+
+define KernelPackage/macremapper/description
+ Linux kernel module for implementation the DCW filtering mechanism
+endef
+
+MAKE_FLAGS += KERNEL_SRC=$(LINUX_DIR) ARCH=$(LINUX_KARCH)
+MAKE_PATH:=kernelmod
+
+$(eval $(call KernelPackage,macremapper))
diff --git a/external/subpack/kernel/macremapper/patches/01_fix_nf_hooks.patch b/external/subpack/kernel/macremapper/patches/01_fix_nf_hooks.patch
new file mode 100644
index 0000000..29cb421
--- /dev/null
+++ b/external/subpack/kernel/macremapper/patches/01_fix_nf_hooks.patch
@@ -0,0 +1,27 @@
+--- a/kernelmod/main.c
++++ b/kernelmod/main.c
+@@ -98,8 +98,11 @@ modinit( void ) {
+
+ rv = mrm_rcdb_init();
+ if (rv != 0) return rv;
+-
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,13,0)
+ nf_register_hook(&_hops);
++#else
++ nf_register_net_hook(&init_net, &_hops);
++#endif
+ mrm_init_ctlfile(); /* XXX not checking for failure! */
+
+ printk(KERN_INFO "MRM The MAC Address Re-Mapper is now in the kernel\n");
+@@ -110,7 +113,11 @@ modinit( void ) {
+ static void __exit
+ modexit( void ) {
+ mrm_destroy_ctlfile();
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,13,0)
+ nf_unregister_hook(&_hops);
++#else
++ nf_unregister_net_hook(&init_net, &_hops);
++#endif
+ mrm_rcdb_destroy(); /* imperative that this happens last */
+ printk(KERN_INFO "MRM The MAC Address Re-Mapper gone bye-bye\n");
+ }
diff --git a/external/subpack/kernel/macremapper/patches/02-mrm_ctlfile.c-compatibility-with-linux-5.6.patch b/external/subpack/kernel/macremapper/patches/02-mrm_ctlfile.c-compatibility-with-linux-5.6.patch
new file mode 100644
index 0000000..d103b19
--- /dev/null
+++ b/external/subpack/kernel/macremapper/patches/02-mrm_ctlfile.c-compatibility-with-linux-5.6.patch
@@ -0,0 +1,59 @@
+From 6126f8efebf659708245ba99df6b85d7c1260668 Mon Sep 17 00:00:00 2001
+From: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
+Date: Sun, 31 Jan 2021 20:53:32 -0800
+Subject: [PATCH] mrm_ctlfile.c: compatibility with linux >= 5.6
+
+Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
+---
+ kernelmod/mrm_ctlfile.c | 13 ++++++++++++-
+ 1 file changed, 12 insertions(+), 1 deletion(-)
+
+--- a/kernelmod/mrm_ctlfile.c
++++ b/kernelmod/mrm_ctlfile.c
+@@ -13,6 +13,7 @@
+ #include "./macremapper_ioctl.h"
+ #include "./bufprintf.h"
+
++#include <linux/version.h>
+ #include <linux/proc_fs.h>
+ #include <linux/uaccess.h>
+ #include <linux/mutex.h>
+@@ -80,13 +81,14 @@ mrm_handle_read(struct file *f, char __u
+ }
+
+ static long
+-mrm_handle_ioctl(struct file *f, unsigned int type, void __user *param) {
++mrm_handle_ioctl(struct file *f, unsigned int type, unsigned long arg) {
+ union {
+ struct mrm_filter_config filt_conf;
+ struct mrm_remap_entry remap_entry;
+ unsigned count;
+ } u;
+ int rv;
++ void __user *param = (void __user *)arg;
+
+ mutex_lock(&_ctrl_mutex);
+
+@@ -159,6 +161,14 @@ fail_fault:
+ }
+
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
++static const struct proc_ops _fops = {
++ .proc_open = mrm_handle_open,
++ .proc_release = mrm_handle_release,
++ .proc_read = mrm_handle_read,
++ .proc_ioctl = mrm_handle_ioctl,
++};
++#else
+ static const struct file_operations _fops = {
+ owner: THIS_MODULE,
+ open: &mrm_handle_open,
+@@ -166,6 +176,7 @@ static const struct file_operations _fop
+ read: &mrm_handle_read,
+ unlocked_ioctl: (void*)&mrm_handle_ioctl,
+ };
++#endif
+
+ int mrm_init_ctlfile( void ) {
+ struct proc_dir_entry *pde;