Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Dec 1994 19:24:16 -0500 (EST)
From:      Wankle Rotary Engine <wpaul@skynet.ctr.columbia.edu>
To:        freebsd-hackers@freebsd.org
Subject:   Re: ifconfig -a
Message-ID:  <199412300024.TAA03220@skynet.ctr.columbia.edu>

next in thread | raw e-mail | index | archive | help

>>> A friend just pointed out Sun's useful -a flag to ifconfig.  Anyone
>>> game to add this to FreeBSD?  Any objections?
>>
>>No objections, i am missing it also a long time now :-). Only
>>interesting question, how close to which ifconfig version from
>>SUN should it be ? :-). Some give you back the ethernet adress
>>on the interface and some don't. I have not looked how easy it 
>>
>>	  ATS ( ats@first.gmd.de or ats@cs.tu-berlin.de )

>	Doesn't the SunOS version only show the ethernet address if run by
>root?

>					Terry Lee
>					terry@uivlsi.csl.uiuc.edu

You got it. Not sure why that's so, but it is. The same will be true
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:

[/usr/include/net]:marple{14}% ifconfig -a
ed1: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        inet 128.59.64.56 netmask 0xffffff00 broadcast 128.59.64.255
lp0: flags=810<POINTOPOINT,SIMPLEX> mtu 1500
lo0: flags=8009<UP,LOOPBACK,MULTICAST> mtu 65532
        inet 127.0.0.1 netmask 0xff000000 
ppp0: flags=10<POINTOPOINT> mtu 1500
ppp1: flags=10<POINTOPOINT> mtu 1500
sl0: flags=c010<POINTOPOINT,LINK2,MULTICAST> mtu 552
sl1: flags=c010<POINTOPOINT,LINK2,MULTICAST> mtu 552
[/usr/include/net]:marple{15}%

As soon as I get the ethernet address stuff done I'll be sending along a
complete set of patches to this list. Well, make that an almost complete
set: I don't do man pages. :)

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.

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?

-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!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



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