From owner-freebsd-hackers Fri Dec 30 10:21:37 1994 Return-Path: hackers-owner Received: (from root@localhost) by freefall.cdrom.com (8.6.9/8.6.6) id KAA22662 for hackers-outgoing; Fri, 30 Dec 1994 10:21:37 -0800 Received: from skynet.ctr.columbia.edu (skynet.ctr.columbia.edu [128.59.64.70]) by freefall.cdrom.com (8.6.9/8.6.6) with ESMTP id KAA22656 for ; Fri, 30 Dec 1994 10:21:33 -0800 Received: (from wpaul@localhost) by skynet.ctr.columbia.edu (8.6.8/8.6.6) id NAA00645; Fri, 30 Dec 1994 13:19:27 -0500 From: Wankle Rotary Engine Message-Id: <199412301819.NAA00645@skynet.ctr.columbia.edu> Subject: Re: ifconfig -a To: wollman@halloran-eldar.lcs.mit.edu (Garrett Wollman) Date: Fri, 30 Dec 1994 13:19:24 -0500 (EST) Cc: freebsd-hackers@freebsd.org In-Reply-To: <9412301553.AA05515@halloran-eldar.lcs.mit.edu> from "Garrett Wollman" at Dec 30, 94 10:53:43 am X-Mailer: ELM [version 2.4 PL23] Content-Type: text Content-Length: 2143 Sender: hackers-owner@freebsd.org Precedence: bulk They say this Garrett Wollman person was kidding when he wrote: > > < 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. Er, I don't understand what you're telling me here. Looking at the sources to netstat, the if.c module, which is what is used when you invoke netstat -i, quite clearly calls kvm_read(). (It's wrapped inside a function called kread(), but it's the same thing.) And main.c calles kvm_open() and kvm_nlist(). The kvm_nlist() is used to look up several symbols, including "_ifnet", which is used by if.c to track down the per-interface data. That's how I did it for ifconfig. Are you saying somebody rewrote netstat to not use KVM when I wasn't looking? I only supped my kernel source tree two days ago. I think I'm confused. > > That's right. There's one for each address, INCLUDING THE LINK-LAYER > ADDRESS. So I've discovered. :) > > 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. Ah... that sounds sensible. Then if no one objects I'll make a new patch that works this way. > > -GAWollman -Bill -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Bill Paul System Manager wpaul@ctr.columbia.edu Center for Telecommunications Research (212) 854-6020 Columbia University, New York City ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Møøse Illuminati: ignore it and be confused, or join it and be confusing! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~