----- Original Message ----- From: cranium2003 <cranium2003@xxxxxxxxx> To: kernel newbies <kernelnewbies@xxxxxxxxxxxx> Sent: Monday, May 02, 2005 10:58 AM Subject: Problem with kernel modules > Hello, > I have written a kernel module that accesses skbuff > and depending on whether packet is icmp or not it > prints IP checksum and ICMP checksum. But I am getting > > sum.c: In function `hook_func1': > sum.c:24: dereferencing pointer to incomplete type > sum.c: In function `hook_func2': > sum.c:40: dereferencing pointer to incomplete type Hey just check out whether u r typecasting it properly when dereferencing in case ur using Void Pointers. sandeep > Whats wrong? > regards, > cranium. > > ************************************************* > > #define __KERNEL__ > #define MODULE > > #include <linux/module.h> > #include <linux/kernel.h> > #include <linux/skbuff.h> > #include <linux/ip.h> > #include <linux/netfilter.h> > #include <linux/netfilter_ipv4.h> > > static struct nf_hook_ops nfho1,nfho2; > > unsigned int hook_func1(unsigned int hooknum,struct > sk_buff **skb, > const struct net_device *in, > const struct net_device *out, > int (*okfn)(struct sk_buff *)) > { > struct sk_buff *sb = *skb; > > if(sb->nh.iph->protocol==1) > { > printk(KERN_DEBUG"ICMP packet\n"); > printk(KERN_DEBUG "ICMP cksum=%d,& IP > cksum=%d\n",sb->h.icmph->checksum,sb->nh.iph->check); > } > > return NF_ACCEPT; > } > > > unsigned int hook_func2(unsigned int hooknum,struct > sk_buff **skb, > const struct net_device *in, > const struct net_device *out, > int (*okfn)(struct sk_buff *)) > { > struct sk_buff *sb = *skb; > if(sb->nh.iph->protocol==1) > { > printk(KERN_DEBUG"ICMP packet\n"); > printk(KERN_DEBUG "ICMP cksum=%d,& IP > cksum=%d\n",sb->h.icmph->checksum,sb->nh.iph->check); > } > return NF_ACCEPT; > } > > static int __init init(void) > { > nfho1.hook = hook_func1; > nfho1.hooknum = NF_IP_POST_ROUTING; > nfho1.pf = PF_INET; > nfho1.priority = NF_IP_PRI_FIRST; > nf_register_hook(&nfho1); > > nfho2.hook = hook_func2; > nfho2.hooknum = NF_IP_PRE_ROUTING; > nfho2.pf = PF_INET; > nfho2.priority = NF_IP_PRI_FIRST; > nf_register_hook(&nfho2); > return 0; > } > > static void __exit fini(void) > { > nf_unregister_hook(&nfho1); > nf_unregister_hook(&nfho2); > } > module_init(init); > module_exit(fini); > MODULE_LICENSE("GPL"); > > ************************************************************* > > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > > -- > Kernelnewbies: Help each other learn about the Linux kernel. > Archive: http://mail.nl.linux.org/kernelnewbies/ > FAQ: http://kernelnewbies.org/faq/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/