From owner-freebsd-net Thu Jul 18 12: 0: 4 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 CDAC337B400 for ; Thu, 18 Jul 2002 11:59:59 -0700 (PDT) Received: from measurement-factory.com (measurement-factory.com [206.168.0.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6383643E42 for ; Thu, 18 Jul 2002 11:59:59 -0700 (PDT) (envelope-from rousskov@measurement-factory.com) Received: from measurement-factory.com (localhost [127.0.0.1]) by measurement-factory.com (8.12.5/8.12.5) with ESMTP id g6IIxw4S045971; Thu, 18 Jul 2002 12:59:58 -0600 (MDT) (envelope-from rousskov@measurement-factory.com) Received: (from rousskov@localhost) by measurement-factory.com (8.12.5/8.12.5/Submit) id g6IIxwxv045970; Thu, 18 Jul 2002 12:59:58 -0600 (MDT) (envelope-from rousskov) Date: Thu, 18 Jul 2002 12:59:58 -0600 (MDT) From: Alex Rousskov To: "Chuck T." Cc: net@FreeBSD.ORG Subject: Re: programatically list all local IP addresses ? In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 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. $0.02, Alex. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message