diff options
author | Guy Harris <guy@alum.mit.edu> | 2016-06-28 02:29:46 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-06-28 02:30:09 -0700 |
commit | 01dabcda25ed695976e5c844cdd7fc6875a17bf6 (patch) | |
tree | 1942c269617b36aa4dcb03ce42f4cf26da8e599c /pcap-linux.c | |
parent | 71d90a93c5cb7f15e10254d6ee711f1f690b0a9c (diff) |
Let the platform decide how to check capturable interfaces.
(Git's annoying policy of expecting a short one-line description of every
change means that the first line isn't very explanatory.)
Make pcap_findalldevs_interfaces() take as an argument a function that's
used to check whether an interface can be captured on or not, rather
than doing the check by trying to open the device for capturing.
This lets pcap_findalldevs() find interfaces even if you don't have
permission to capture on them; that way, instead of users saying "why
isn't {tcpdump -D, tshark -D, dumpcap -D, Wireshark, etc.} showing me
any interfaces?", they'll say "why am I getting a 'you don't have
permissions' error when I try to capture on this interface?", which is a
better description of the underlying problem.
On some platforms, it also avoids a bunch of extra work when getting a
list of interfaces.
Diffstat (limited to 'pcap-linux.c')
-rw-r--r-- | pcap-linux.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/pcap-linux.c b/pcap-linux.c index 104546e9..4aeb7ec3 100644 --- a/pcap-linux.c +++ b/pcap-linux.c @@ -2505,6 +2505,15 @@ scan_proc_net_dev(pcap_if_t **devlistp, char *errbuf) */ static const char any_descr[] = "Pseudo-device that captures on all interfaces"; +/* + * A SOCK_PACKET or PF_PACKET socket can be bound to any network interface. + */ +static int +can_be_bound(const char *name _U_) +{ + return (1); +} + int pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf) { @@ -2513,7 +2522,7 @@ pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf) /* * Get the list of regular interfaces first. */ - if (pcap_findalldevs_interfaces(alldevsp, errbuf) == -1) + if (pcap_findalldevs_interfaces(alldevsp, errbuf, can_be_bound) == -1) return (-1); /* failure */ /* |