I'm facing some problems to compile a new module for Linux Ubuntu 8.04, kernel version 2.6. Above are two pieces of code related to the problem.
linux/netfilter.h
Expand|Select|Wrap|Line Numbers
- //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
Expand|Select|Wrap|Line Numbers
- // 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 *)); // It is a function that is further implemented
- ...
- 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
... 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.