]> The Tcpdump Group git mirrors - libpcap/commitdiff
Add check to suppress spurious error generated by noncompiant MS Surface mobile adapt...
authorJoel <[email protected]>
Thu, 29 Apr 2021 13:41:13 +0000 (14:41 +0100)
committerGuy Harris <[email protected]>
Thu, 29 Apr 2021 18:22:42 +0000 (11:22 -0700)
(cherry picked from commit 919b51f7a0f7640143d15598a64afb2a0218f78a)

pcap-int.h
pcap-npf.c

index dc18d50cb633ebb277c3617a9cad464a06182d95..60e939f17dafa4702b749b695f8142e2739285e8 100644 (file)
@@ -350,6 +350,17 @@ struct pcap {
  * BPF code generation flags.
  */
 #define BPF_SPECIAL_VLAN_HANDLING      0x00000001      /* special VLAN handling for Linux */
+/*
+ * Interface Error Codes
+ * It is likely that there are other devices which throw spurious errors, at which point
+ * this will need refactoring to efficiently check against a list, but for now we can just
+ * check this one value.
+ */
+#define NPF_SURFACE_MOBILE_NONPROMISC  0xe00000bb
+/* Attempting to set non-promiscuous mode on a noncompliant Microsoft Surface Pro
+ * Mobile Broadband Adapter returns an error that can safely be ignored, as it's
+ * always in non-promiscuous mode.
+ */
 
 /*
  * This is a timeval as stored in a savefile.
index 215efc9df01f454e8903a5c81f561b43656f9b52..141ff88af379f23bb818fcd83cedbfdcf0791b7e 100644 (file)
@@ -1222,10 +1222,14 @@ pcap_activate_npf(pcap_t *p)
                        NDIS_PACKET_TYPE_BROADCAST |
                        NDIS_PACKET_TYPE_MULTICAST) == FALSE)
                {
-                       pcap_fmt_errmsg_for_win32_err(p->errbuf,
-                           PCAP_ERRBUF_SIZE, GetLastError(),
-                           "failed to set hardware filter to non-promiscuous mode");
-                       goto bad;
+                       /* suppress spurious error generated by noncompiant MS Surface mobile adaptors */
+                       if (GetLastError() != NPF_SURFACE_MOBILE_NONPROMISC)
+                       {
+                               pcap_fmt_errmsg_for_win32_err(p->errbuf,
+                                   PCAP_ERRBUF_SIZE, GetLastError(),
+                                   "failed to set hardware filter to non-promiscuous mode");
+                               goto bad;
+                       }
                }
        }