]> The Tcpdump Group git mirrors - libpcap/commitdiff
Avoid getting multiple devices per USB bus.
authorGuy Harris <[email protected]>
Sun, 18 Dec 2016 03:32:20 +0000 (19:32 -0800)
committerGuy Harris <[email protected]>
Sun, 18 Dec 2016 03:32:20 +0000 (19:32 -0800)
pcap-bpf.c

index 77ce278807d2baca6d3e01028146aa97ce7c871f..60086e42f17dcb2756f68b63595e76dc63bec83c 100644 (file)
@@ -2677,7 +2677,14 @@ finddevs_usb(pcap_if_t **alldevsp, char *errbuf)
                memcpy(name, usbus_prefix, USBUS_PREFIX_LEN);
                memcpy(name + USBUS_PREFIX_LEN, usbitem->d_name, busnumlen);
                *(name + USBUS_PREFIX_LEN + busnumlen) = '\0';
-               if (add_dev(alldevsp, name, PCAP_IF_UP, NULL, errbuf) == NULL) {
+               /*
+                * There's an entry in this directory for every USB device,
+                * not for every bus; if there's more than one device on
+                * the bus, there'll be more than one entry for that bus,
+                * so we need to avoid adding multiple capture devices
+                * for each bus.
+                */
+               if (find_or_add_dev(alldevsp, name, PCAP_IF_UP, NULL, errbuf) == NULL) {
                        free(name);
                        closedir(usbdir);
                        return (PCAP_ERROR);