wifidog-ng: Update to 2.0.2
Compatible with Linux kernel 5.3 and above Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
This commit is contained in:
parent
803dd9c739
commit
447e65c539
5 changed files with 34 additions and 10 deletions
|
@ -8,7 +8,7 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=wifidog-ng
|
PKG_NAME:=wifidog-ng
|
||||||
PKG_VERSION:=2.0.1
|
PKG_VERSION:=2.0.2
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
PKG_BUILD_DIR=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)
|
PKG_BUILD_DIR=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)
|
||||||
|
@ -16,7 +16,7 @@ PKG_BUILD_DIR=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)
|
||||||
PKG_LICENSE:=LGPL-2.1
|
PKG_LICENSE:=LGPL-2.1
|
||||||
PKG_LICENSE_FILES:=LICENSE
|
PKG_LICENSE_FILES:=LICENSE
|
||||||
|
|
||||||
PKG_MAINTAINER:=Jianhui Zhao <jianhuizhao329@gmail.com>
|
PKG_MAINTAINER:=Jianhui Zhao <zhaojh329@gmail.com>
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2017 jianhui zhao <jianhuizhao329@gmail.com>
|
* Copyright (C) 2017 jianhui zhao <zhaojh329@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2 as
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
#include <linux/inetdevice.h>
|
#include <linux/inetdevice.h>
|
||||||
#include <linux/seq_file.h>
|
#include <linux/seq_file.h>
|
||||||
|
#include <linux/version.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
@ -20,6 +21,9 @@ static int update_gw_interface(const char *interface)
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
struct in_device *in_dev;
|
struct in_device *in_dev;
|
||||||
|
#if LINUX_VERSION_CODE > KERNEL_VERSION(5, 2, 21)
|
||||||
|
const struct in_ifaddr *ifa;
|
||||||
|
#endif
|
||||||
|
|
||||||
dev = dev_get_by_name(&init_net, interface);
|
dev = dev_get_by_name(&init_net, interface);
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
|
@ -36,14 +40,24 @@ static int update_gw_interface(const char *interface)
|
||||||
goto QUIT;
|
goto QUIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LINUX_VERSION_CODE > KERNEL_VERSION(5, 2, 21)
|
||||||
|
in_dev_for_each_ifa_rcu(ifa, in_dev) {
|
||||||
|
if (ifa->ifa_flags & IFA_F_SECONDARY)
|
||||||
|
continue;
|
||||||
|
#else
|
||||||
for_primary_ifa(in_dev) {
|
for_primary_ifa(in_dev) {
|
||||||
|
#endif
|
||||||
conf.interface_ipaddr = ifa->ifa_local;
|
conf.interface_ipaddr = ifa->ifa_local;
|
||||||
conf.interface_mask = ifa->ifa_mask;
|
conf.interface_mask = ifa->ifa_mask;
|
||||||
conf.interface_broadcast = ifa->ifa_broadcast;
|
conf.interface_broadcast = ifa->ifa_broadcast;
|
||||||
|
|
||||||
pr_info("Found ip from %s: %pI4\n", interface, &conf.interface_ipaddr);
|
pr_info("Found ip from %s: %pI4\n", interface, &conf.interface_ipaddr);
|
||||||
break;
|
break;
|
||||||
|
#if LINUX_VERSION_CODE > KERNEL_VERSION(5, 2, 21)
|
||||||
|
}
|
||||||
|
#else
|
||||||
} endfor_ifa(in_dev)
|
} endfor_ifa(in_dev)
|
||||||
|
#endif
|
||||||
|
|
||||||
QUIT:
|
QUIT:
|
||||||
dev_put(dev);
|
dev_put(dev);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2017 jianhui zhao <jianhuizhao329@gmail.com>
|
* Copyright (C) 2017 jianhui zhao <zhaojh329@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2 as
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2017 jianhui zhao <jianhuizhao329@gmail.com>
|
* Copyright (C) 2017 jianhui zhao <zhaojh329@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2 as
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
@ -14,7 +14,9 @@
|
||||||
#include <linux/tcp.h>
|
#include <linux/tcp.h>
|
||||||
#include <linux/udp.h>
|
#include <linux/udp.h>
|
||||||
#include <net/netfilter/nf_nat.h>
|
#include <net/netfilter/nf_nat.h>
|
||||||
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)
|
||||||
#include <net/netfilter/nf_nat_l3proto.h>
|
#include <net/netfilter/nf_nat_l3proto.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -85,7 +87,11 @@ static u32 wifidog_hook(void *priv, struct sk_buff *skb, const struct nf_hook_st
|
||||||
if (ct->status & IPS_HIJACKED) {
|
if (ct->status & IPS_HIJACKED) {
|
||||||
if (is_allowed_mac(skb, state)) {
|
if (is_allowed_mac(skb, state)) {
|
||||||
/* Avoid duplication of authentication */
|
/* Avoid duplication of authentication */
|
||||||
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)
|
||||||
nf_reset(skb);
|
nf_reset(skb);
|
||||||
|
#else
|
||||||
|
nf_reset_ct(skb);
|
||||||
|
#endif
|
||||||
nf_ct_kill(ct);
|
nf_ct_kill(ct);
|
||||||
}
|
}
|
||||||
return NF_ACCEPT;
|
return NF_ACCEPT;
|
||||||
|
@ -149,7 +155,9 @@ static int __init wifidog_init(void)
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE > KERNEL_VERSION(4, 17, 19)
|
#if LINUX_VERSION_CODE > KERNEL_VERSION(5, 0, 21)
|
||||||
|
ret = nf_nat_ipv4_register_fn(&init_net, &wifidog_ops);
|
||||||
|
#elif LINUX_VERSION_CODE > KERNEL_VERSION(4, 17, 19)
|
||||||
ret = nf_nat_l3proto_ipv4_register_fn(&init_net, &wifidog_ops);
|
ret = nf_nat_l3proto_ipv4_register_fn(&init_net, &wifidog_ops);
|
||||||
#elif LINUX_VERSION_CODE > KERNEL_VERSION(4, 12, 14)
|
#elif LINUX_VERSION_CODE > KERNEL_VERSION(4, 12, 14)
|
||||||
ret = nf_register_net_hook(&init_net, &wifidog_ops);
|
ret = nf_register_net_hook(&init_net, &wifidog_ops);
|
||||||
|
@ -174,7 +182,9 @@ static void __exit wifidog_exit(void)
|
||||||
{
|
{
|
||||||
deinit_config();
|
deinit_config();
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE > KERNEL_VERSION(4, 17, 19)
|
#if LINUX_VERSION_CODE > KERNEL_VERSION(5, 0, 21)
|
||||||
|
nf_nat_ipv4_unregister_fn(&init_net, &wifidog_ops);
|
||||||
|
#elif LINUX_VERSION_CODE > KERNEL_VERSION(4, 17, 19)
|
||||||
nf_nat_l3proto_ipv4_unregister_fn(&init_net, &wifidog_ops);
|
nf_nat_l3proto_ipv4_unregister_fn(&init_net, &wifidog_ops);
|
||||||
#elif LINUX_VERSION_CODE > KERNEL_VERSION(4, 12, 14)
|
#elif LINUX_VERSION_CODE > KERNEL_VERSION(4, 12, 14)
|
||||||
nf_unregister_net_hook(&init_net, &wifidog_ops);
|
nf_unregister_net_hook(&init_net, &wifidog_ops);
|
||||||
|
@ -188,5 +198,5 @@ static void __exit wifidog_exit(void)
|
||||||
module_init(wifidog_init);
|
module_init(wifidog_init);
|
||||||
module_exit(wifidog_exit);
|
module_exit(wifidog_exit);
|
||||||
|
|
||||||
MODULE_AUTHOR("jianhui zhao <jianhuizhao329@gmail.com>");
|
MODULE_AUTHOR("jianhui zhao <zhaojh329@gmail.com>");
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2017 jianhui zhao <jianhuizhao329@gmail.com>
|
* Copyright (C) 2017 jianhui zhao <zhaojh329@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2 as
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
|
Loading…
Reference in a new issue