Date: Tue, 17 Sep 2002 12:05:19 +0800 From: Leslie Jackson <int@softhome.net> 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>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 16 Sep 2002 18:51:03 +0000 mm <meadele@nerim.net> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020917120519.37eb312d.int>