Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <linux/netfilter.h>
- #include <linux/netfilter_ipv4.h>
- static unsigned int my_nf_hookfn(unsigned int hooknum,
- struct sk_buff *skb,
- const struct net_device *in,
- const struct net_device *out,
- int (*okfn)(struct sk_buff *))
- {
- /* process packet */
- //...
- return NF_ACCEPT;
- }
- static struct nf_hook_ops my_nfho = {
- .owner = THIS_MODULE,
- .hook = my_nf_hookfn,
- .hooknum = NF_IP_LOCAL_IN,
- .pf = PF_INET,
- .priority = NF_IP_PRI_FIRST
- };
- int __init my_hook_init(void)
- {
- return nf_register_hook(&my_nfho);
- }
- void __exit my_hook_exit(void)
- {
- nf_unregister_hook(&my_nfho);
- }
- module_init(my_hook_init);
- module_exit(my_hook_exit);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement