- 论坛徽章:
- 0
|
#define __KERNEL__
#define MODULE
#include <linux/module.h>;
#include <linux/kernel.h>;
#include <linux/netfilter.h>;
#include <linux/netfilter_ipv4.h>;
/* 用于注册我们的函数的数据结构 */
static struct nf_hook_ops nfho;
/* 注册的hook函数的实现 */
unsigned int hook_func(unsigned int hooknum,
struct sk_buff **skb,
const struct net_device *in,
const struct net_device *out,
int (*okfn)(struct sk_buff *))
{
return NF_DROP; /* 丢弃所有的数据包 */
}
/* 初始化程序 */
int init_module()
{
/* 填充我们的hook数据结构 */
nfho.hook = hook_func; /* 处理函数 */
nfho.hooknum = NF_IP_PRE_ROUTING; /* 使用IPv4的第一个hook */
nfho.pf = PF_INET;
nfho.priority = NF_IP_PRI_FIRST; /* 让我们的函数首先执行 */
nf_register_hook(&nfho);
return 0;
}
/* 清除程序 */
void cleanup_module()
{
nf_unregister_hook(&nfho);
}
在这段程序的编译过程中,编译器始终找不到nf_hook_ops结构,可是在内核中include/linux/netfilter.h 文件中却找的道,请问这是版本问题吗,怎么样才可以解决阿
希望给出正确的编译方法,谢谢,感激不尽 版本rh 2.4.20.8 |
|