From owner-freebsd-hackers Fri Sep 15 8:52:44 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by hub.freebsd.org (Postfix) with ESMTP id A850237B422 for ; Fri, 15 Sep 2000 08:52:42 -0700 (PDT) Received: from fledge.watson.org (robert@fledge.pr.watson.org [192.0.2.3]) by fledge.watson.org (8.9.3/8.9.3) with SMTP id LAA45467; Fri, 15 Sep 2000 11:52:32 -0400 (EDT) (envelope-from robert@fledge.watson.org) Date: Fri, 15 Sep 2000 11:52:31 -0400 (EDT) From: Robert Watson X-Sender: robert@fledge.watson.org To: David Malone Cc: Chris Ptacek , freebsd-hackers@FreeBSD.ORG Subject: Re: Getting all the IP address for a machine from code... In-Reply-To: <20000914095622.A25929@gosset.maths.tcd.ie> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, 14 Sep 2000, David Malone wrote: > On Wed, Sep 13, 2000 at 08:12:47PM -0700, Chris Ptacek wrote: > > I am looking for a way to get all the IP addresses that are configured a > > machine. I need to do this in c source code, and without using DNS services > > (ie: gethostname/gethostbyname won't work). I am hoping there are some > > system calls I can use to get this information. Thanks in advance for any > > help. > > You could use getifaddrs in FreeBSD 4 and later - otherwise you'll > need to use sysctl to get the list of interfaces and addresses. It is possible to get interface lists on earlier versions (and I hope still current versions) using the ioctl interfaces described in Stevens. See also ifconfig.c source from various versions of FreeBSD :-). Robert N M Watson robert@fledge.watson.org http://www.watson.org/~robert/ PGP key fingerprint: AF B5 5F FF A6 4A 79 37 ED 5F 55 E9 58 04 6A B1 TIS Labs at Network Associates, Safeport Network Services To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message