From: Guy Harris Date: Sun, 27 Dec 2020 21:10:16 +0000 (-0800) Subject: NPF: report the system error for PacketSetHwFilter() failures. X-Git-Tag: libpcap-1.10-bp~6 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/4f389694e580a62693aa19799ddfc44c2c729841 NPF: report the system error for PacketSetHwFilter() failures. It *does* fail to set promiscuous mode on some devices, such as bridge devices; knowing what error it is might help us distinguish "we don't support promiscuous mode" from some other, unexpected error. --- diff --git a/pcap-npf.c b/pcap-npf.c index 201597d8..1b18608d 100644 --- a/pcap-npf.c +++ b/pcap-npf.c @@ -1175,7 +1175,9 @@ pcap_activate_npf(pcap_t *p) if (PacketSetHwFilter(pw->adapter,NDIS_PACKET_TYPE_PROMISCUOUS) == FALSE) { - snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "failed to set hardware filter to promiscuous mode"); + pcap_fmt_errmsg_for_win32_err(p->errbuf, + PCAP_ERRBUF_SIZE, GetLastError(), + "failed to set hardware filter to promiscuous mode); goto bad; } } @@ -1193,7 +1195,9 @@ pcap_activate_npf(pcap_t *p) NDIS_PACKET_TYPE_BROADCAST | NDIS_PACKET_TYPE_MULTICAST) == FALSE) { - snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "failed to set hardware filter to non-promiscuous mode"); + pcap_fmt_errmsg_for_win32_err(p->errbuf, + PCAP_ERRBUF_SIZE, GetLastError(), + "failed to set hardware filter to non-promiscuous mode"); goto bad; } }