From: KOVACS Krisztian <hidden@balabit.hu>
To: s.bogatyrev@kenjitsu.net
Cc: netfilter-devel@lists.netfilter.org
Subject: Re: ACC and port numers
Date: Wed, 26 Nov 2003 11:46:23 +0100 [thread overview]
Message-ID: <3FC4847F.9070809@balabit.hu> (raw)
In-Reply-To: <3FC46FA4.6060503@kenjitsu.net>
Hi,
Stanisalv V. Bogatyrev wrote:
> I added some code, but I get broken port nubers on incoming traffic.
> I'm new in netfilter/iptables programming and can't find a mistake. Help
> me please, what do I need to correct to make it work?
> case IPPROTO_TCP:
> tcp_hdr = (*pskb)->h.th;
> //We don't do ntohs() here. In userspace we trust. So Don't forget to modify ipacc.c
>
> sport=tcp_hdr->source;
> dport=tcp_hdr->dest;
The problem lies here: for incoming packets, skb->h.th is not yet set.
You should try it this way:
struct iphdr *iph = (*pskb)->nh.iph;
struct tcphdr *tcp_hdr = (struct tcphdr *)((u_int32_t *)iph + iph->ihl);
Of course the code for UDP, ICMP, etc. should also be upgraded (for TCP
and UDP the ports are at the same location). I didn't check, but you
should also take care of byte order problems.
--
Regards,
Krisztian KOVACS
prev parent reply other threads:[~2003-11-26 10:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-26 9:17 ACC and port numers Stanisalv V. Bogatyrev
2003-11-26 10:46 ` KOVACS Krisztian [this message]
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=3FC4847F.9070809@balabit.hu \
--to=hidden@balabit.hu \
--cc=netfilter-devel@lists.netfilter.org \
--cc=s.bogatyrev@kenjitsu.net \
/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.