- 论坛徽章:
- 0
|
#define __KERNEL__ \r\n#define MODULE \r\n\r\n#include <linux/module.h>; \r\n#include <linux/kernel.h>; \r\n#include <linux/netfilter.h>; \r\n#include <linux/netfilter_ipv4.h>; \r\n\r\n/* 用于注册我们的函数的数据结构 */ \r\nstatic struct nf_hook_ops nfho; \r\n\r\n/* 注册的hook函数的实现 */ \r\nunsigned int hook_func(unsigned int hooknum, \r\nstruct sk_buff **skb, \r\nconst struct net_device *in, \r\nconst struct net_device *out, \r\nint (*okfn)(struct sk_buff *)) \r\n{ \r\nreturn NF_DROP; /* 丢弃所有的数据包 */ \r\n} \r\n\r\n/* 初始化程序 */ \r\nint init_module() \r\n{ \r\n/* 填充我们的hook数据结构 */ \r\nnfho.hook = hook_func; /* 处理函数 */ \r\nnfho.hooknum = NF_IP_PRE_ROUTING; /* 使用IPv4的第一个hook */ \r\nnfho.pf = PF_INET; \r\nnfho.priority = NF_IP_PRI_FIRST; /* 让我们的函数首先执行 */ \r\n\r\nnf_register_hook(&nfho); \r\n\r\nreturn 0; \r\n} \r\n\r\n/* 清除程序 */ \r\nvoid cleanup_module() \r\n{ \r\nnf_unregister_hook(&nfho); \r\n} \r\n\r\n在这段程序的编译过程中,编译器始终找不到nf_hook_ops结构,可是在内核中include/linux/netfilter.h 文件中却找的道,请问这是版本问题吗,怎么样才可以解决阿 |
|