From owner-freebsd-hackers Mon Sep 16 21: 5:28 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 82BF237B400 for ; Mon, 16 Sep 2002 21:05:27 -0700 (PDT) Received: from jive.SoftHome.net (jive.SoftHome.net [66.54.152.27]) by mx1.FreeBSD.org (Postfix) with SMTP id E857143E3B for ; Mon, 16 Sep 2002 21:05:26 -0700 (PDT) (envelope-from int@softhome.net) Received: (qmail 32452 invoked by uid 417); 17 Sep 2002 04:05:26 -0000 Received: from shunt-smtp-out-0 (HELO softhome.net) (172.16.3.12) by shunt-smtp-out-0 with SMTP; 17 Sep 2002 04:05:26 -0000 Received: from int.homeunix.org ([218.58.83.59]) (AUTH: LOGIN int@softhome.net) by softhome.net with esmtp; Mon, 16 Sep 2002 22:05:25 -0600 Date: Tue, 17 Sep 2002 12:05:19 +0800 From: Leslie Jackson To: freebsd-hackers@freebsd.org Subject: Re: ioctl & SIOCDIFADDR Message-Id: <20020917120519.37eb312d.int@softhome.net> In-Reply-To: <3D862817.8070007@nerim.net> References: <20020916114315.7feb4bac.int@softhome.net> <3D862817.8070007@nerim.net> X-Mailer: Sylpheed version 0.7.6 (GTK+ 1.2.10; i386-portbld-freebsd4.6) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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, 16 Sep 2002 18:51:03 +0000 mm wrote: > You can try to request the first address of the specified interface via > ioctl call. > > [snip] > /* > * let get_ifaddr() find the address of the interface > */ > in->sin_addr.s_addr = get_ifaddr(ifaliasreq.ifra_name); > [snip] Thanks for your sample code. I've thought of this method. But from 'ktrace'ing ifconfig, i found it never issued the SIOCGIFADDR request using ioctl(). And actually, there's _really_ somthing i've missed. I just ktrace'd again, finding that ifconfig just first uses sysctl() with NET_RT_IFLIST to abtain the whole interface list. This is what ifconfig does when changing an IP: 1. call sysctl() to obtain the whole interface list. 2. do some needed work. (ie. get the FIRST IP of the interface from the interface list) 3. issue SIOCDIFADDR request by calling ioctl() to delete the FIRST IP. 4. issue SIOCAIFADDR request by calling ioctl() to assign the new IP. Now my mind's clear. :-) Thanks any way, for your help. -- Leslie Jackson To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message