From owner-freebsd-net Wed Jul 3 10:11:48 2002 Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DD12B37B400 for ; Wed, 3 Jul 2002 10:11:45 -0700 (PDT) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id A4CE943E31 for ; Wed, 3 Jul 2002 10:11:45 -0700 (PDT) (envelope-from bright@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1192) id 71A38AE25A; Wed, 3 Jul 2002 10:11:45 -0700 (PDT) Date: Wed, 3 Jul 2002 10:11:45 -0700 From: Alfred Perlstein To: Andreas =?iso-8859-1?Q?M=F6ller?= Cc: freebsd-net@freebsd.org Subject: Re: How to determine the address of a network interface? Message-ID: <20020703171145.GD97638@elvis.mu.org> References: <3D231C18.8020408@gmx.net> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3D231C18.8020408@gmx.net> User-Agent: Mutt/1.3.27i Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org * Andreas Möller [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