Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 09 Jan 2001 12:21:11 +0200
From:      Graham Wheeler <gram@cequrux.com>
To:        freebsd-hackers@freebsd.org
Cc:        markster@marko.net
Subject:   Size of struct ifreq/returned buffer of SIOCGIFCONF
Message-ID:  <3A5AE617.E8644889@cequrux.com>

next in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3A5AE617.E8644889>