List Info

Thread: Get my own IP




Get my own IP
country flaguser name
United Kingdom
2007-03-23 17:35:52
Hello,

Im sorry if this is not the correct place to ask but I've
been googleing
for 3 hours and I can't find a solution.


The thing is that I'm writing an application for Linux that
creates it's
own TCP/IP packets and sends them using a raw socket. To
create the
packet, I need to know which IP address is associated with
the interface
that the socket will be using to send data.

I though libpcap could be really helpful as it's very
portable but I
can't figure out the way to get the IP address of an
interface. I am
using pcap_lookupnet() but with that I just get the address
of the
network, not the specific IP address that the interface has
been asigned.

Is there any way, using libpcap or not, to get the IP of a
network
interface in a portable and easy way?


Could you please help me?



Thanks a lot, and I apologize if this is not the correct
place to ask
for this kind of stuff.


Salud.


Luis.
-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.

Re: Get my own IP
country flaguser name
United States
2007-03-23 18:06:09
On Mar 23, 2007, at 3:35 PM, Luis Martin Garcia wrote:

> Is there any way, using libpcap or not, to get the IP
of a network
> interface in a portable and easy way?

With newer versions of libpcap/WinPcap, you could try using 

pcap_findalldevs() and look for the interface in question on
the list  
of interfaces it returns.  If you find an entry for that
interface, it  
might include IP addresses for that interface.
-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )