I'm trying to build Netfilter. First stage is to accept only vlan packets, and then check if it is the correct vlan ID. the problem i dont get any vlan packets. simple example for code:
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
#include <linux/if_ether.h>
static struct nf_hook_ops nfho;
static void __exit_filter(void) {
printk("__exit_filter\n");
nf_unregister_hook(&nfho); //unregister our hook
}
static u32
recv_packet_handler(const struct nf_hook_ops *ops,
struct sk_buff *skb,
const struct net_device *in,
const struct net_device *out,
int (*okfn)(struct sk_buff *)){
//NEED TO GET HERE VLAN PACKETS
return NF_ACCEPT;
}
static int __init_filter(void) {
nfho.hook = recv_packet_handler;
nfho.hooknum = NF_INET_PRE_ROUTING;
nfho.pf = PF_INET;
nfho.priority = NF_IP_PRI_FIRST;
nf_register_hook(&nfho);
printk("insert filter\n");
return 0;
}
module_init(__init_filter);
module_exit(__exit_filter);
I guess the problem is with nfho.pf
but I'm not sure what to do. Thanks for helpers