- 论坛徽章:
- 0
|
大家好 还是同样的问题 我随便找个和netfilter相关的例程编译都会出现这个错误,像这里面的例程http://bbs.chinaunix.net/thread-2177913-1-1.html
就算是例程中有错误 还是报的这个错误。也注意到了hook接口的问题。
我的内核版本是 2.6.35-29-generic netfilter相关的模块也已经按模块编译了
在lib/modules/2.6.35-29-generic/kernel/net/ipv4/netfilter 也能找到很多.ko文件
同时 我原先有个aodv的程序 也要用到netfilter 也能够顺利编译并运行 。
但是现在是只要单独写的关于netfilter的小内核程序 就会有问题。不知道为什么。请大家帮忙 不胜感激!
我用的一个例程- /* Sample code to install a Netfilter hook function that will
- * drop all incoming packets. */
- #define __KERNEL__
- #define MODULE
- #include <linux/module.h>
- #include <linux/kernel.h>
- #include <linux/netfilter.h>
- #include <linux/netfilter_ipv4.h>
- /* This is the structure we shall use to register our function */
- static struct nf_hook_ops nfho;
- /* This is the hook function itself */
- 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; /* Drop ALL packets */
- }
- /* Initialisation routine */
- int init_module()
- {
- /* Fill in our hook structure */
- nfho.hook = hook_func; /* Handler function */
- nfho.hooknum = NF_IP_PRE_ROUTING; /* First hook for IPv4 */
- nfho.pf = PF_INET;
- nfho.priority = NF_IP_PRI_FIRST; /* Make our function first */
- nf_register_hook(&nfho);
- return 0;
- }
- /* Cleanup routine */
- void cleanup_module()
- {
- nf_unregister_hook(&nfho);
- }
复制代码 Makefite- obj-m:=test.o
- KERNELDIR:=/lib/modules/`uname -r`/build
- PWD:=$(shell pwd)
- modules:
- $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
- module_install:
- $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
- clean:
- make -C $(KERNELDIR) M=$(PWD) clean
- remove:
- /sbin/rmmod dropAll
复制代码 求解答 忙乎很多了。。。。 |
|