* Source ports at the IP layer
@ 2003-10-14 21:13 Javier Govea
2003-10-14 21:42 ` Willy Tarreau
0 siblings, 1 reply; 3+ messages in thread
From: Javier Govea @ 2003-10-14 21:13 UTC (permalink / raw)
To: linux-kernel
Hi guys,
I want to get the source ports of every incomming IP packet at the IP layer, but I'm
having problems.
A print out, in the ip_rcv() function (in ip_input.c), of skb->h.uh->source (for the UDP
source port) and of skb->h.th->source (for the TCP source port) is always displaying 17664
(and i'm sure that is not the real source port). What am i doing wrong?? Is it possilble
at all to get the source ports directly from skb->h.th->source at this early stage, i mean
at the IP layer?? Do i need to do some casting or calling another function before i can
get the ports???
I also tried
struct tcphdr *th = (struct tcphdf *)skb->h.th;
and then printing out th->source...but i'm still getting 17664...any suggestion on how I
can get the ports??? All ideas are very very welcome...
Thanx in advance...
Xavier
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Source ports at the IP layer
2003-10-14 21:13 Source ports at the IP layer Javier Govea
@ 2003-10-14 21:42 ` Willy Tarreau
2003-10-15 6:57 ` Raj
0 siblings, 1 reply; 3+ messages in thread
From: Willy Tarreau @ 2003-10-14 21:42 UTC (permalink / raw)
To: Javier Govea; +Cc: linux-kernel
> I also tried
> struct tcphdr *th = (struct tcphdf *)skb->h.th;
> and then printing out th->source...but i'm still getting 17664...any suggestion on how I
> can get the ports??? All ideas are very very welcome...
I think you forgot to add the IP header length somewhere, because 17664 is
0x4500 = the start of your IP header, and not the TCP header.
Cheers,
Willy
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Source ports at the IP layer
2003-10-14 21:42 ` Willy Tarreau
@ 2003-10-15 6:57 ` Raj
0 siblings, 0 replies; 3+ messages in thread
From: Raj @ 2003-10-15 6:57 UTC (permalink / raw)
To: Willy Tarreau; +Cc: Javier Govea, linux-kernel
> > I also tried
> > struct tcphdr *th = (struct tcphdf *)skb->h.th;
> > and then printing out th->source...but i'm still getting 17664...any suggestion on how I
> > can get the ports??? All ideas are very very welcome...
A weird wild guess :-) . Possibly the source port is still in
network-byte-order. Try converting it to host-byte-order ( if your
machine arch is little-endian ) before printing.
Network-byte-order 17664 = 69 in little-endian which is tftp.
/Raj
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-10-15 6:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-14 21:13 Source ports at the IP layer Javier Govea
2003-10-14 21:42 ` Willy Tarreau
2003-10-15 6:57 ` Raj
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.