netfilter hook function error...
bikkit at gmail.com
Wed Sep 21 08:09:38 CEST 2005
thank you kindly for the "Introduction to C" session. Your pointers
were of most use. However, I must note that failing to know the
purpose of print_string() calls in my code, in both occasions that
they appear in the code I posted, you failed slightly to understand
the severity of the warnings that the compiler "screamed in terror"
about. In both points, they are merely there for logging to the
current tty, as an alternative to printk. As a concequence of that,
they are being commented in and out of the running code, as debugging
requires at that particular moment.
The last point, and of interest to me at that moment, was solved by
Wei and this code seems to work:
my_ipheader = (struct iphdr *)((*skb)->nh.iph);
as I was quick to post back in the thread, for the reference of others.
Please feel free to correct my code in the other thread, with subject
"How to change the source address of a tcp packet", with the same
enthusiasm. I would be, again, most thankful.
- Hide quoted text -
> > /home/jc/code/spider/spider.c:126: warning: ISO C90 forbids mixed
> > declarations and code
> > print_string("Packet reached IN_HOOK.");
> > struct iphdr *my_ipheader;
> In traditional C, a variable declaration (like your my_ipheader)
> MUST COME BEFORE ANY OTHER CODE IN A FUNCTION (like your print_string
> > /home/jc/code/spider/spider.c:134: warning: passing argument 1 of
> > 'print_string' discards qualifiers from pointer target type
> > print_string(out->name);
> Not that I really know, because you have not shown your print_string()
> function prototype, but I bet that you made its first argument be
> a 'const char *', and out->name is a 'char *' without the 'const'.
> > /home/jc/code/spider/spider.c:150: error: request for member 'nh' in
> > something not a structure or union
> > my_ipheader = skb->nh->iph;
> The compiler complains that the skb thing is not pointer to a structure.
> Which is correct. It is a pointer to a pointer to a structure. So you
> need to dereference it once, like '(*skb)->nh->iph'. However, I'm
> not sure that nh->iph is valid in all cases. Look at other hook
> functions which need the IP header.
> best regards
More information about the netfilter-devel