|
我的源代码是:
#define __KERNEL__
#define MODULE
#include <linux/module.h>
#include <linux/config.h>
#include <linux/ip.h>
#include <linux/netfilter.h>
static unsigned int linuxmag_hook(unsigned int hook, struct sk_buff **pskb,const struct net_device *indev, const struct net_device *outdev, int (*okfn)(struct sk_buff *))
{
return NF_DROP;
}
static struct nf_hook_ops linuxmag_ops={{NULL,NULL},linuxmag_hook,PF_INET,NF_IP_LOCAL_OUT,NF_IP_PRI_FILTER-1};
int init_module(void)
{
return nf_register_hook(&linuxmag_ops);
}
void cleanup_module(void)
{
nf_unregister_hook(&linuxmag_ops);
}
编译:gcc -c temp.c
结果却出现如下错误:
[yang@otest yang]$ gcc -c temp.c
temp.c:8: warning: `struct net_device' declared inside parameter list
temp.c:8: warning: its scope is only this definition or declaration, which is probably not what you want
temp.c:8: warning: `struct sk_buff' declared inside parameter list
temp.c:13: variable `linuxmag_ops' has initializer but incomplete type
temp.c:13: extra brace group at end of initializer
temp.c:13: (near initialization for `linuxmag_ops')
temp.c:13: `NULL' undeclared here (not in a function)
temp.c:13: `NULL' undeclared here (not in a function)
temp.c:13: warning: excess elements in struct initializer
temp.c:13: warning: (near initialization for `linuxmag_ops')
temp.c:13: warning: excess elements in struct initializer
temp.c:13: warning: (near initialization for `linuxmag_ops')
temp.c:13: `PF_INET' undeclared here (not in a function)
temp.c:13: warning: excess elements in struct initializer
temp.c:13: warning: (near initialization for `linuxmag_ops')
temp.c:13: `NF_IP_LOCAL_OUT' undeclared here (not in a function)
temp.c:13: warning: excess elements in struct initializer
temp.c:13: warning: (near initialization for `linuxmag_ops')
temp.c:13: `NF_IP_PRI_FILTER' undeclared here (not in a function)
temp.c:13: warning: excess elements in struct initializer
temp.c:13: warning: (near initialization for `linuxmag_ops')
temp.c:13: storage size of `linuxmag_ops' isn't known
不知该怎么解决!郁闷了很久了。希望那位高手指教一二。^_^
先谢了。 |
|