Date: Fri, 30 Dec 1994 10:53:43 -0500 From: Garrett Wollman <wollman@halloran-eldar.lcs.mit.edu> To: Wankle Rotary Engine <wpaul@skynet.ctr.columbia.edu> Cc: freebsd-hackers@freebsd.org Subject: Re: ifconfig -a Message-ID: <9412301553.AA05515@halloran-eldar.lcs.mit.edu> In-Reply-To: <199412300024.TAA03220@skynet.ctr.columbia.edu> References: <199412300024.TAA03220@skynet.ctr.columbia.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
<<On Thu, 29 Dec 1994 19:24:16 -0500 (EST), Wankle Rotary Engine <wpaul@skynet.ctr.columbia.edu> said: > of FreeBSD's ifconfig once I get done smacking it around too, since the > only way I've found to read the hardware address for an interface involves > kvm_read() and friends (at this very moment I'm furiously cribbing away > from netstat ;). I already have the -a option working though: Do it the same way netstat does; no KVM stuff involved. > There's one strange thing I discovered while implimenting the -a option: > I used SIOCGIFCONF to figure out what interfaces are present in the system, > but for some reason the active interfaces turn up twice. That is, without > a little bit of extra fiddling, ed0 and lo0 (from the output above) would > occur twice. With SIOCGIFCONF you get back an array with a member for each > configured interface, but there seem to be two members for ed0 and > lo0. That's right. There's one for each address, INCLUDING THE LINK-LAYER ADDRESS. > arbitrarily assumed that there wouldn't be more than 20 interfaces, thus > the buffer space allocated is (20 * struct ifreq). That's a silly thing > to assume though... The ifc_len field should be filled in with the total amount of space required. I believe that you can do an initial SIOCGIFCONF with ifc_len set to zero, and then allocate ifc_len space for the buffer and do it again. -GAWollman -- Garrett A. Wollman | Shashish is simple, it's discreet, it's brief. ... wollman@lcs.mit.edu | Shashish is the bonding of hearts in spite of distance. Opinions not those of| It is a bond more powerful than absence. We like people MIT, LCS, ANA, or NSA| who like Shashish. - Claude McKenzie + Florent Vollant
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9412301553.AA05515>