]> The Tcpdump Group git mirrors - libpcap/commitdiff
bpf: device_exists() is needed only on macOS.
authorGuy Harris <[email protected]>
Tue, 12 May 2020 22:54:21 +0000 (15:54 -0700)
committerGuy Harris <[email protected]>
Tue, 12 May 2020 22:54:21 +0000 (15:54 -0700)
It's part of the code to make monitor mode work on 10.4.

pcap-bpf.c

index 02ebd70538dee711ad7b3189a2ad65b097d7fb60..68771323e02393c4d4580cdf2aa637d195ccfa40 100644 (file)
@@ -735,20 +735,11 @@ bpf_open_and_bind(const char *name, char *errbuf)
        return (fd);
 }
 
+#ifdef __APPLE__
 static int
 device_exists(int fd, const char *name, char *errbuf)
 {
        int status;
-#ifdef LIFNAMSIZ
-       struct lifreq ifr;
-
-       if (strlen(name) >= sizeof(ifr.lifr_name)) {
-               /* The name is too long, so it can't possibly exist. */
-               return (PCAP_ERROR_NO_SUCH_DEVICE);
-       }
-       (void)pcap_strlcpy(ifr.lifr_name, name, sizeof(ifr.lifr_name));
-       status = ioctl(fd, SIOCGLIFFLAGS, (caddr_t)&ifr);
-#else
        struct ifreq ifr;
 
        if (strlen(name) >= sizeof(ifr.ifr_name)) {
@@ -757,7 +748,6 @@ device_exists(int fd, const char *name, char *errbuf)
        }
        (void)pcap_strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
        status = ioctl(fd, SIOCGIFFLAGS, (caddr_t)&ifr);
-#endif
 
        if (status < 0) {
                if (errno == ENXIO || errno == EINVAL) {
@@ -784,6 +774,7 @@ device_exists(int fd, const char *name, char *errbuf)
         */
        return (0);
 }
+#endif
 
 #ifdef BIOCGDLTLIST
 static int