All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthias Kaehlcke <matthias@kaehlcke.net>
To: Cliffe <cliffe@ii.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Getting the port numbers and IP address from struct socket
Date: Mon, 16 Mar 2009 14:58:22 +0100	[thread overview]
Message-ID: <20090316135822.GF6891@traven> (raw)
In-Reply-To: <49BE5C33.7020101@ii.net>

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@nl.linux.org)

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                  `-

      reply	other threads:[~2009-03-16 13:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-16  8:52 Including STRTOK_R in a LSM Z. Cliffe Schreuders
2007-07-16 10:16 ` Jan Engelhardt
2007-07-16 12:19   ` Z. Cliffe Schreuders
2007-07-16 13:34     ` Casey Schaufler
2007-07-16 14:43       ` Z. Cliffe Schreuders
2009-03-16 14:03 ` Getting the port numbers and IP address from struct socket Cliffe
2009-03-16 13:58   ` Matthias Kaehlcke [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=20090316135822.GF6891@traven \
    --to=matthias@kaehlcke.net \
    --cc=cliffe@ii.net \
    --cc=linux-kernel@vger.kernel.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.