aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel <82591719+joelg989@users.noreply.github.com>2021-04-29 14:41:13 +0100
committerJoel <82591719+joelg989@users.noreply.github.com>2021-04-29 14:41:13 +0100
commit919b51f7a0f7640143d15598a64afb2a0218f78a (patch)
tree892d2bf121a2b847b129acf705e975163eeaf6b4
parent6716a4fd84d8d579eabd3df24ce6ccc2ede0ee33 (diff)
Add check to suppress spurious error generated by noncompiant MS Surface mobile adaptors when attempting to set non-promiscuous mode
-rw-r--r--pcap-int.h11
-rw-r--r--pcap-npf.c12
2 files changed, 19 insertions, 4 deletions
diff --git a/pcap-int.h b/pcap-int.h
index dc18d50c..60e939f1 100644
--- a/pcap-int.h
+++ b/pcap-int.h
@@ -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.
diff --git a/pcap-npf.c b/pcap-npf.c
index 215efc9d..141ff88a 100644
--- a/pcap-npf.c
+++ b/pcap-npf.c
@@ -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;
+ }
}
}