From: JC <bikkit@gmail.com>
To: Patrick Schaaf <bof@bof.de>
Cc: netfilter-devel@lists.netfilter.org, netfilter@lists.netfilter.org
Subject: Re: netfilter hook function error...
Date: Wed, 21 Sep 2005 07:09:38 +0100 [thread overview]
Message-ID: <a60102c30509202309628deea@mail.gmail.com> (raw)
In-Reply-To: <20050921055121.GA25193@oknodo.bof.de>
Dear Patrick,
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.
kind regards,
JC
- 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
> call)
>
> > /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
> Patrick
>
next prev parent reply other threads:[~2005-09-21 6:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-21 0:13 netfilter hook function error JC
2005-09-21 1:14 ` JC
2005-09-21 5:51 ` Patrick Schaaf
2005-09-21 6:09 ` JC [this message]
[not found] <4330b900.50a87b17.7179.ffffad17SMTPIN_ADDED@mx.gmail.com>
2005-09-21 1:49 ` JC
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a60102c30509202309628deea@mail.gmail.com \
--to=bikkit@gmail.com \
--cc=bof@bof.de \
--cc=netfilter-devel@lists.netfilter.org \
--cc=netfilter@lists.netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.