From: Guy Harris Date: Tue, 4 May 2021 22:03:00 +0000 (-0700) Subject: NPF: silently ignore all MS Surface cell modem errors when setting filter. X-Git-Tag: libpcap-1.10.1~17 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/8353bcac9d174ac2b008930519581c3f3fd813df NPF: silently ignore all MS Surface cell modem errors when setting filter. Ignore them if we *are* setting promiscuous mode as well. (cherry picked from commit faf1c37e38c83f1cc9f1579008f8d0b6aec9c440) --- diff --git a/pcap-npf.c b/pcap-npf.c index 6e9e0f04..52aee78a 100644 --- a/pcap-npf.c +++ b/pcap-npf.c @@ -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) {