From owner-freebsd-net Thu Jul 18 12:15:17 2002 Delivered-To: freebsd-net@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 931) id 30F6E37B400; Thu, 18 Jul 2002 12:15:15 -0700 (PDT) Date: Thu, 18 Jul 2002 12:15:15 -0700 From: Juli Mallett To: Alex Rousskov Cc: "Chuck T." , net@FreeBSD.ORG Subject: Re: programatically list all local IP addresses ? Message-ID: <20020718121515.A95081@FreeBSD.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: ; from rousskov@measurement-factory.com on Thu, Jul 18, 2002 at 12:59:58PM -0600 Organisation: The FreeBSD Project X-Alternate-Addresses: , , , X-Towel: Yes X-LiveJournal: flata, jmallett X-Negacore: Yes 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 * De: Alex Rousskov [ Data: 2002-07-18 ] [ Subjecte: Re: programatically list all local IP addresses ? ] > On Thu, 18 Jul 2002, Chuck T. wrote: > > > Yes portablity is a concern, unfortunately my program will > > probably be used on Linux more than FreeBSD, sigh. I starting to > > read about ioctl() and SIOCGIFADDR which appears to be portable > > (and a pain). > > We had to write portable local address detection for Web Polygraph. In > my experience, ioctl/SIOCGIFADDR is not portable at all and is a lot > of pain. Linux uses them differently from FreeBSD, and the exact > interface/behavior is often OS-version specific (e.g., for Solaris > IIRC). > > Looking at existing code helps. I would suggest using getifaddrs(3) > where available (./configure can detect that, of course) and delve > into ioctl() and other OS-specific methods where getifaddrs(3) is not > supported. Stockpile some pain relieve medication first. Using a library which has these sorts of things abstracted helps. I believe this particular case is one covered by libnet or libdnet or whatever it's called. -- Juli Mallett | FreeBSD: The Power To Serve Will break world for fulltime employment. | finger jmallett@FreeBSD.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message