From owner-freebsd-hackers Tue Jan 9 4: 5:24 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from citadel.cequrux.com (citadel.cequrux.com [192.96.22.18]) by hub.freebsd.org (Postfix) with ESMTP id BB29937B400 for ; Tue, 9 Jan 2001 04:05:01 -0800 (PST) Received: (from nobody@localhost) by citadel.cequrux.com (8.8.8/8.6.9) id OAA29575; Tue, 9 Jan 2001 14:04:52 +0200 (SAST) Received: by citadel.cequrux.com via recvmail id 29494; Tue Jan 9 14:04:42 2001 Message-ID: <3A5AE617.E8644889@cequrux.com> Date: Tue, 09 Jan 2001 12:21:11 +0200 From: Graham Wheeler Organization: Cequrux Technologies X-Mailer: Mozilla 4.75 [en] (X11; U; FreeBSD 3.4-RELEASE i386) X-Accept-Language: en MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Cc: markster@marko.net Subject: Size of struct ifreq/returned buffer of SIOCGIFCONF Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi all I am attempting to port the cheops network mapping/diagnostic program from Linux to FreeBSD (see www.marko.net/cheops). One of the first snags I have hit comes in using SIOCGIFCONF to queries the network interface names and addresses. The cheops code assumes that the buffer returned will have an array of struct ifreq elements. Stevens vol 2 p 121 on the other hand shows the returned buffer having an array of elements each 36 bytes in size. I figure that under Linux, sizeof(struct ifreq) must be 36 bytes so this works well, but under FreeBSD sizeof(struct ifreq) returns 32 bytes. I haven't been able to find any definitive documentation on SIOCGIFCONF, so I'm note sure whether this means that in 4.4BSD-Lite sizeof(struct ifreq) was indeed 36 bytes, and that the return buffer should contain an array of these structures, and that FreeBSD has broken this, or whether the only assumption that can be made about the return buffer is that it is an array of 36-byte elts, the first 16 bytes of each one being a name and the remainder being an address - in which case the cheops code is wrong, as it is assuming that these are struct ifreq's. Can anyone shed any light on this? Another interesting aspect is that the returned buffer under FreeBSD does have 36-byte elements, but the name of every second entry is empty. It would be interesting to know why this is the case too. regards Graham -- Dr Graham Wheeler E-mail: gram@cequrux.com Director, Research and Development WWW: http://www.cequrux.com CEQURUX Technologies Phone: +27(21)423-6065 Firewalls/VPN Specialists Fax: +27(21)424-3656 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message