]> The Tcpdump Group git mirrors - libpcap/commitdiff
NPF: silently ignore all MS Surface cell modem errors when setting filter.
authorGuy Harris <[email protected]>
Tue, 4 May 2021 22:03:00 +0000 (15:03 -0700)
committerGuy Harris <[email protected]>
Wed, 12 May 2021 08:11:34 +0000 (01:11 -0700)
Ignore them if we *are* setting promiscuous mode as well.

(cherry picked from commit faf1c37e38c83f1cc9f1579008f8d0b6aec9c440)

pcap-npf.c

index 6e9e0f04630695549710f588667800dfc951975e..52aee78a98ae2973903e2f4c99414b46dd3b0c5d 100644 (file)
@@ -1223,10 +1223,40 @@ pcap_activate_npf(pcap_t *p)
 
                if (PacketSetHwFilter(pw->adapter,NDIS_PACKET_TYPE_PROMISCUOUS) == FALSE)
                {
-                       pcap_fmt_errmsg_for_win32_err(p->errbuf,
-                           PCAP_ERRBUF_SIZE, GetLastError(),
-                           "failed to set hardware filter to promiscuous mode");
-                       goto bad;
+                       DWORD errcode = GetLastError();
+
+                       /*
+                        * Suppress spurious error generated by non-compiant
+                        * MS Surface mobile adapters.
+                        *
+                        * If we knew that this meant "promiscuous mode
+                        * isn't supported", we could add a "promiscuous
+                        * mode isn't supported" error code and return
+                        * that, but:
+                        *
+                        *    1) we don't know that it means that
+                        *    rather than meaning "we reject attempts
+                        *    to set the filter, even though the NDIS
+                        *    specifications say you shouldn't do that"
+                        *
+                        * and
+                        *
+                        *    2) other interface types that don't
+                        *    support promiscuous mode, at least
+                        *    on UN*Xes, just silently ignore
+                        *    attempts to set promiscuous mode
+                        *
+                        * and rejecting it with an error could disrupt
+                        * attempts to capture, as many programs (tcpdump,
+                        * *shark) default to promiscuous mode.
+                        */
+                       if (errcode != NPF_SURFACE_MOBILE_NONPROMISC)
+                       {
+                               pcap_fmt_errmsg_for_win32_err(p->errbuf,
+                                   PCAP_ERRBUF_SIZE, errcode,
+                                   "failed to set hardware filter to promiscuous mode");
+                               goto bad;
+                       }
                }
        }
        else
@@ -1249,7 +1279,7 @@ pcap_activate_npf(pcap_t *p)
 
                        /*
                         * Suppress spurious error generated by non-compiant
-                        * MS Surface mobile adaptors
+                        * MS Surface mobile adapters.
                         */
                        if (errcode != NPF_SURFACE_MOBILE_NONPROMISC)
                        {