- 论坛徽章:
- 0
|
我在《深入linux网络核心堆栈》中得到一个例子程序,如下:
#define _KERNEL_
#define MODULE
#include<linux/kernel.h>
#include<linux/module.h>
#include<linux/skbuff.h>
#include<linux/netdevice.h>
#include<linux/netfilter.h>
#include<linux/netfilter_ipv4.h>
static struct nf_hook_ops nfho;
static unsigned int
my_hook(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(void)
{
nfho.hook=my_hook;
nfho.hooknum=NF_IP_PRE_ROUTING;
nfho.pf= PF_INET;
nfho.priority=NF_IP_PRI_FIRST;
return nf_register_hook(&nfho);
return 0;
}
void cleanup_module(void)
{
nf_unregister_hook(&nfho);
}
对于以上程序我在redhat 9.0 (linux-2.4.20-8)下通过如下方式编译,但是产生了如下错误,困扰了我很多天,您能告诉我产生错误的原因以及解决的方法吗?
gcc -O -c -I/usr/src/linux-2.4/include test1.c
In file included from test1.c:10:
/usr/include/linux/netfilter_ipv4.h:53: `INT_MIN' undeclared here (not in a function)
/usr/include/linux/netfilter_ipv4.h:53: enumerator value for `NF_IP_PRI_FIRST' not integer constant
/usr/include/linux/netfilter_ipv4.h:59: `INT_MAX' undeclared here (not in a function)
/usr/include/linux/netfilter_ipv4.h:59: enumerator value for `NF_IP_PRI_LAST' not integer constant
test1.c:21: warning: `struct net_device' declared inside parameter list
test1.c:21: warning: its scope is only this definition or declaration, which is probably not what you want
test1.c:21: warning: `struct sk_buff' declared inside parameter list
test1.c: In function `init_module':
test1.c:37: invalid use of undefined type `struct nf_hook_ops'
test1.c:38: invalid use of undefined type `struct nf_hook_ops'
test1.c:39: invalid use of undefined type `struct nf_hook_ops'
test1.c:40: invalid use of undefined type `struct nf_hook_ops'
/usr/include/linux/byteorder/swab.h: At top level:
test1.c:14: storage size of `nfho' isn't known
nf_hook_ops数据结构不是在netfilter.h头文件里面吗,为什么还会这样报错呢?希望好心人帮帮忙。不胜感激。 |
|