From owner-freebsd-hackers Mon Sep 16 9: 7:53 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D940437B400 for ; Mon, 16 Sep 2002 09:07:51 -0700 (PDT) Received: from insomnia.spc.org (insomnia.spc.org [195.224.94.183]) by mx1.FreeBSD.org (Postfix) with SMTP id B7FDB43E42 for ; Mon, 16 Sep 2002 09:07:50 -0700 (PDT) (envelope-from bms@insomnia.spc.org) Received: (qmail 17699 invoked by uid 1031); 16 Sep 2002 16:05:05 -0000 Date: Mon, 16 Sep 2002 17:05:05 +0100 From: Bruce M Simpson To: Leslie Jackson Cc: freebsd-hackers@freebsd.org Subject: Re: ioctl & SIOCDIFADDR Message-ID: <20020916160505.GB11460@spc.org> Mail-Followup-To: Bruce M Simpson , Leslie Jackson , freebsd-hackers@freebsd.org References: <20020916114315.7feb4bac.int@softhome.net> <20020916085445.GA11460@spc.org> <20020916224146.52e31c8c.int@softhome.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020916224146.52e31c8c.int@softhome.net> User-Agent: Mutt/1.3.28i Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, Sep 16, 2002 at 10:41:46PM +0800, Leslie Jackson wrote: > > Try 0.0.0.0. (aka INADDR_ANY). > Failed using that way. (SIOCDIFADDR: can't assign requested addressed) My bad... a hasty answer to a hastily read question. Quick answer:- man 4 networking. Long answer:- Your best option is probably to issue an SIOCGIFCONF and walk the list. This should give you the default addresses assigned to each interface. If you need to look at aliases, use SIOCAIFCONF for the interface you're interested in. Look at netinet/in.c:in_control(). SIOCSIFADDR is now deprecated, so in a way you were right to watch what ifconfig was doing. If you need code examples, have a look in /usr/ports/mbone as some programs which need to determine multicast capabilities of each configured interface will have to walk the ifreq/ifconf list. You'll need to play an elastic buffer game where you specify the size of the chunk of memory you've allocated for the ifconf array, and if it's bigger, reallocate it and ask again. Also if portability is an issue note that Solaris and Linux do it slightly differently now. We haven't picked up that change yet (...scribbles in TODO list..) but what it boils down to is this:- instead of playing elastic buffer games to get the size of the list, you just ask how big the list is. BMS To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message