]> The Tcpdump Group git mirrors - libpcap/commitdiff
Cope with getting EPWROFF from SIOCGIFMEDIA.
authorGuy Harris <[email protected]>
Wed, 19 Feb 2020 03:14:52 +0000 (19:14 -0800)
committerGuy Harris <[email protected]>
Wed, 19 Feb 2020 03:14:52 +0000 (19:14 -0800)
At least some users report seeing that error on the llw0 device on macOS
Catalina if the Wi-Fi is off; don't let that cause pcap_findalldevs() to
fail.

See

    https://ask.wireshark.org/question/14711/need-debugging-suggestions-no-longer-see-ethernet-interfaces-after-upgrading-mac-from-10151-to-10153/

and

    https://ask.wireshark.org/question/13572/updated-catalina-no-interfaces-found/

pcap-bpf.c

index 3374de42f69a1221bc59e9ca3702b16acfcf370a..1c4e61101c75f99dbd5829a14bdcea6ddeca6b70 100644 (file)
@@ -2758,7 +2758,11 @@ get_if_flags(const char *name, bpf_u_int32 *flags, char *errbuf)
        strncpy(req.ifm_name, name, sizeof(req.ifm_name));
        if (ioctl(sock, SIOCGIFMEDIA, &req) < 0) {
                if (errno == EOPNOTSUPP || errno == EINVAL || errno == ENOTTY ||
-                   errno == ENODEV || errno == EPERM) {
+                   errno == ENODEV || errno == EPERM
+#ifdef EPWROFF
+                   || errno == EPWROFF
+#endif
+                   ) {
                        /*
                         * Not supported, so we can't provide any
                         * additional information.  Assume that
@@ -2773,6 +2777,18 @@ get_if_flags(const char *name, bpf_u_int32 *flags, char *errbuf)
                         * So, just as we do for some ethtool ioctls
                         * on Linux, which makes the same mistake, we
                         * also treat EPERM as meaning "not supported".
+                        *
+                        * And it appears that Apple's llw0 device, which
+                        * appears to be part of the Skywalk subsystem:
+                        *
+                        *    http://newosxbook.com/bonus/vol1ch16.html
+                        *
+                        * can sometimes return EPWROFF ("Device power
+                        * is off") for that ioctl, so we treat *that*
+                        * as another indication that we can't get a
+                        * connection status.  (If it *isn't* "powered
+                        * off", it's reported as a wireless device,
+                        * complete with an active/inactive state.)
                         */
                        *flags |= PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE;
                        close(sock);