]> The Tcpdump Group git mirrors - libpcap/commit
Clean up findalldevs code.
authorGuy Harris <[email protected]>
Sun, 18 Dec 2016 02:23:23 +0000 (18:23 -0800)
committerGuy Harris <[email protected]>
Sun, 18 Dec 2016 02:23:23 +0000 (18:23 -0800)
commit961ab5ebd1b1b91002dda27cbc79b715b178b6b4
tree6ef8d113868753ab716310f20e103261dd26fa8e
parent3c877b90e2c6de0537d50c2aaad9610ac462b0c1
Clean up findalldevs code.

Have a routine that unconditionally adds a device to the list of
devices, without bothering to check whether there's already a device
with that name, and a separate routine that does the check and, if it
doesn't find the device, calls the routine to add ti.  That avoids
scanning the entire list in cases where we know the search will fail.
The only reasons for doing the check are that we're on a platform where
we find the list of interfaces by a call that returns a list of
*addresses*, with an interface name attached to each address, and

1) for each address, we need to make sure we don't already have
   the interface, create it if we don't, and add the address to
   the now-guaranteed-to-exist entry for the interface;

2) we might have to make a *separate* call to enumerate
   interfaces, to find interfaces with *no* addresses, and that
   call also enumerates the ones that *do* have addresses, and
   we don't want to create a duplicate entry for them.

Change some findalldevs helper routines to have "dev" rather than "if"
in the name, as not all devices are regular network interfaces.

For the DAG findalldevs routine, make sure it always provides an error
message if it fails.

We don't need add_addr_to_iflist() or get_if_description() on Windows,
so don't define them on Windows.

Update comments to reflect reality.
15 files changed:
fad-helpers.c
pcap-bpf.c
pcap-bt-linux.c
pcap-bt-monitor-linux.c
pcap-dag.c
pcap-dbus.c
pcap-dlpi.c
pcap-dos.c
pcap-int.h
pcap-libdlpi.c
pcap-linux.c
pcap-netfilter-linux.c
pcap-septel.c
pcap-usb-linux.c
pcap-win32.c