Unix Programming - Enumerate ip addresses

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > March 2007 > Enumerate ip addresses





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Enumerate ip addresses
Henrik Goldman

2007-03-19, 1:29 pm

Hello,

I would like to enumerate all ip adresses on my current machine in a
platform independent way. The code should work across several unix
platforms.

Is there an easy way to acomplish this?

Thanks.

-- Henrik


Pascal Bourguignon

2007-03-20, 7:27 am

"Henrik Goldman" <henrik_goldman@mail.tele.dk> writes:

> Hello,
>
> I would like to enumerate all ip adresses on my current machine in a
> platform independent way. The code should work across several unix
> platforms.
>
> Is there an easy way to acomplish this?


No.


For example, POSIX doesn't specify this kind of things.
AFAIK, there is not standard API to do it independently of the platform.


You could implement a de-facto standard library that would gather all
the ways it can be done on all the platforms and export the
functionality under a common API. That won't be easy.



Another way to do it, perhaps easier, but it won't work always nor
everywhere, is to use ifconfig and try to parse its output. I say
try, because of course, the output of these commands vary from system
to system and from time to time, and on some systems it's even not
named ifconfig, but IPCONFIG.EXE...


--
__Pascal Bourguignon__
http://www.informatimago.com
http://pjb.ogamita.org
Bin Chen

2007-03-20, 7:27 am

On Mar 20, 1:59 am, "Henrik Goldman" <henrik_gold...@mail.tele.dk>
wrote:
> Hello,
>
> I would like to enumerate all ip adresses on my current machine in a
> platform independent way. The code should work across several unix
> platforms.
>
> Is there an easy way to acomplish this?
>

I think the easiest and most portable is parse the output of ifconfig.


David Schwartz

2007-03-20, 7:19 pm

On Mar 19, 10:59 am, "Henrik Goldman" <henrik_gold...@mail.tele.dk>
wrote:
> Hello,
>
> I would like to enumerate all ip adresses on my current machine in a
> platform independent way. The code should work across several unix
> platforms.
>
> Is there an easy way to acomplish this?
>
> Thanks.
>
> -- Henrik


Google 'SIOCGIFCONF' for an approach that works on many UNIXes.

DS

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com