Trying to get a 'to' IP address from a socket

Fred Cohen (fc@all.net)
Tue, 20 Jul 1999 06:47:26 -0700 (PDT)


I'm not on the list, so please respond directly to me.

I am trying to figure out how to get a destination IP address from a
socket that has been passed to me by another program. According to what
I have been able to find out to date, the source IP address is easy to
get, but the destination isn't available except through some fairly
obscure set of system calls. No direct call seems to be available, but
lsof seems to be able to generate this information by looking through
the kernel structures. Does anybody out there have the code to do this
- preferably a few simple system calls - alternatively a very short C
program - last alternative a hairy complex beast...

FC

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/