lkml.org 
[lkml]   [2009]   [Mar]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Getting the port numbers and IP address from struct socket
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 `-


\
 
 \ /
  Last update: 2009-03-16 15:01    [W:0.055 / U:0.248 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site