Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions hello-packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <linux/init.h> // included for __init and __exit macros
#include <linux/netfilter.h>
#include <linux/vmalloc.h>
#include <linux/version.h>

//#undef __KERNEL__
#include <linux/netfilter_ipv4.h>
Expand Down Expand Up @@ -31,7 +32,11 @@ static int init_filter_if(void)
nfho.pf = PF_INET;
nfho.priority = NF_IP_PRI_FIRST;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,13,0)
nf_register_net_hook(&init_net, &nfho);
#else
nf_register_hook(&nfho);
#endif

return 0;
}
Expand All @@ -45,7 +50,12 @@ static int __init hello_init(void)

static void __exit hello_cleanup(void)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,13,0)
nf_unregister_net_hook(&init_net, &nfho);
#else
nf_unregister_hook(&nfho);
#endif

printk(KERN_INFO "Cleaning up module.\n");
}

Expand Down