Re: Getting the port numbers and IP address from struct socket
From: Matthias Kaehlcke
Date: Mon Mar 16 2009 - 09:58:41 EST
El Mon, Mar 16, 2009 at 10:03:31PM +0800 Cliffe ha dit:
> This may be a simple question, but how do I determine the port numbers,
> and IP addresses from a (struct socket)socket?
i'm far from being a networking expert, so i might be plain
wrong. after having a look at the kernel sources i think it works in
the following way:
struct inet_sock *inet = inet_sk(socket->sk);
the data you are looking for are:
inet->saddr
inet->sport
inet->daddr
inet->dport
btw: for these kind of questions it is better to write to the
kernelnewbies list (kernelnewbies@xxxxxxxxxxxx)
best regards
--
Matthias Kaehlcke
Embedded Linux Engineer
Barcelona
Anyone who has never made a mistake has never tried anything new
(Albert Einstein)
.''`.
using free software / Debian GNU/Linux | http://debian.org : :' :
`. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4 `-
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/