Hello all, I'm facing a problem when compiling a new module to the Linux kernel 2.6 (Ubuntu 8.04), through the command 'make myfile.ko'.
I have the following structure inside the files:
linux/netfilter.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
//begin netfilter
...
typedef unsigned int nf_hookfn(unsigned int hooknum, struct sk_buff *skb, const struct net_devide *in, const struct net_device *out, int (*okfn)(struct sk_buff *));
...
struct nf_hook_ops {
struct list_head list;
nf_hookfn *hook;
struct module *owner;
int pf;
int hooknum;
int priority;
};
...
// end netfilter
| |
myfile.c
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
// begin myfile
...
#include <netfilter.h>
...
unsigned int my_nf_hook(unsigned int hook, struct sk_buff **skb, const struct net_device *indev, const struct net_device *outdev, int (*okfn)(struct sk_buff *));
...
static struct nf_hook_ops nfh_pre = {
{NULL, NULL},
my_nf_hook,
THIS_MODULE,
PF_INET,
NF_IP_PRE_ROUTING,
NF_IP_PRI_FILTER+1
}
...
// end myfile
| |
When I execute the 'make myfile.ko' to compile the module, it gives me the following warning:
... warning: initialization from incompatible pointer type
This warning is pointing the line '9. my_nf_hook' inside the struct nfh_pre initialization.
Well, after compiling, the ko file is generated. However, when I execute the command 'insmod myfile.ko' to load the module, it results in kernel panic. I believe that the warning is directed related to the problem.
Finally, my question: does anybody know where is the problem in the code above? What could be missing?
Thanks a lot in advance for repliers.