From owner-freebsd-hackers Thu Dec 29 20:28:30 1994 Return-Path: hackers-owner Received: (from root@localhost) by freefall.cdrom.com (8.6.9/8.6.6) id UAA11439 for hackers-outgoing; Thu, 29 Dec 1994 20:28:30 -0800 Received: from physics.su.OZ.AU (dawes@physics.su.OZ.AU [129.78.129.1]) by freefall.cdrom.com (8.6.9/8.6.6) with SMTP id UAA11433 for ; Thu, 29 Dec 1994 20:28:27 -0800 Received: by physics.su.OZ.AU id AA26566 (5.67b/IDA-1.4.4 for freebsd-hackers@freebsd.org); Fri, 30 Dec 1994 15:27:54 +1100 From: David Dawes Message-Id: <199412300427.AA26566@physics.su.OZ.AU> Subject: Re: ifconfig -a To: wpaul@skynet.ctr.columbia.edu (Wankle Rotary Engine) Date: Fri, 30 Dec 1994 15:27:53 +1100 (EST) Cc: freebsd-hackers@freebsd.org In-Reply-To: <199412300024.TAA03220@skynet.ctr.columbia.edu> from "Wankle Rotary Engine" at Dec 29, 94 07:24:16 pm X-Mailer: ELM [version 2.4 PL23] Content-Type: text Content-Length: 1535 Sender: hackers-owner@freebsd.org Precedence: bulk >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. >If, for example, I assign a dummy address to sl0, then sl0 pops up twice >as well. I found a quick though inelegant test to jump over the extra >entries, but I'm confused as to why SIOCGIFCONF behaves this way. You get an entry for each configured address type an interface has. All have an AF_LINK entry. Those with an IP address also have an AF_INET entry (the sa.family field). >Oh, I have a question for those who might know: the data returned by >ioctl(sock,SIOCGIFCONF,&ifconf) needs to be placed in a buffer, and you >have to allocate enough space to hold the data for all interfaces. I >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... anybody know what the official maximum number of >interfaces is? Is there a MAXINTERFACES defined somewhere? Also keep in mind that the length of the returned data can be longer than sizeof(struct ifreq) because of the variable size of the sockaddr entry. The size of the sockaddr is given in its sa_len field. David