Note also that SIOCGIFCONF returns one entry per address per interface,
not one entry per interface; after fixing "pcap_findalldevs()" to skip
interfaces that aren't up, "iflist" now prints:
fxp0
Address Family: #18
Address Family Name: Unknown
Up: yes
Loopback: no
fxp0
Address Family: #2
Address Family Name: AF_INET
Address: XXX.XXX.XXX.XXX
Netmask: XXX.XXX.XXX.XXX
Up: yes
Loopback: no
fxp0
Address Family: #2
Address Family Name: AF_INET
Address: YYY.YYY.YYY.YYY
Netmask: YYY.YYY.YYY.YYY
Up: yes
Loopback: no
lo0
Address Family: #18
Address Family Name: Unknown
Up: yes
Loopback: yes
lo0
Address Family: #2
Address Family Name: AF_INET
Address: 127.0.0.1
Netmask: 255.0.0.0
Up: yes
Loopback: yes
(Address family 18 is AF_LINK; those addresses are link-layer addresses.
Yes, the loopback device apparently has one....)
An alternative might be to provide a "pcap_getifaddrs()" routine, which
is a wrapper for "getifaddrs()" if "getifaddrs()" is present on the
system, and a copy of the SIOCGIFCONF "getifaddrs()" code if
"getifaddrs()" isn't present.
However, for programs that really want a list of *interfaces*, not
*addresses* - and that might want only interfaces supported by
"pcap_open_live()" - a "getifaddrs()"-style routine requires that they
keep track of all addresses for a given interface, and weed out
interfaces that aren't up, and it might be better to have common code in
libpcap to do that.
-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:[EMAIL PROTECTED]?body=unsubscribe