Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Jul 2002 10:11:45 -0700
From:      Alfred Perlstein <bright@mu.org>
To:        Andreas =?iso-8859-1?Q?M=F6ller?= <andreas-moeller@gmx.net>
Cc:        freebsd-net@freebsd.org
Subject:   Re: How to determine the address of a network interface?
Message-ID:  <20020703171145.GD97638@elvis.mu.org>
In-Reply-To: <3D231C18.8020408@gmx.net>
References:  <3D231C18.8020408@gmx.net>

next in thread | previous in thread | raw e-mail | index | archive | help
* Andreas Möller <andreas-moeller@gmx.net> [020703 08:59] wrote:
> Hello,
> 
> 	I am trying to write a small program in C that just outputs the IP
> address of an arbitrary network interface (like ifconfig, but only the
> address). The problem is, I don't know how I can determine the address
> and my programming experience is too limited in order to fully
> understand the ifconfig source code (I think ifconfig determines the
> address through the function in_status() in ifconfig.c, though I don't
> comprehend it).
> 
> 	It would be nice if anybody could point out how I should proceed or
> where I can find more information.
> 
> 
> Thanks a lot in advance,
> 
> 		Andreas
> 
> PS: I apologize if this is the wrong list for my questions. Please also
> excuse any language mistakes since English is not my native language.

Your english is fine and this is an ok list to ask technical network
related questions.

Ok, now that you're re-assured, check out the manpage for 'getifaddrs'
that sounds like what you might need.  The getifaddrs(3) function returns
a list of all the network devices in the system.


-- 
-Alfred Perlstein [alfred@freebsd.org]
'Instead of asking why a piece of software is using "1970s technology,"
 start asking why software is ignoring 30 years of accumulated wisdom.'
Tax deductible donations for FreeBSD: http://www.freebsdfoundation.org/

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020703171145.GD97638>