* 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.
SetEvent(PacketGetReadEvent(pw->adapter));
}
+/*
+ * Vendor-specific error codes.
+ *
+ * These are NTSTATUS values:
+ *
+ * https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/87fba13e-bf06-450e-83b1-9241dc81e781
+ *
+ * with the "Customer" bit set. If a driver returns them, they are not
+ * mapped to Windows error values in userland; they're returned by
+ * GetLastError().
+ *
+ * Attempting to set non-promiscuous mode on a Microsoft Surface Pro's
+ * Mobile Broadband Adapter returns an error; that error can safely be
+ * ignored, as it's always in non-promiscuous mode.
+ *
+ * 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
+
static int
pcap_activate_npf(pcap_t *p)
{
}
else
{
- /* NDIS_PACKET_TYPE_ALL_LOCAL selects "All packets sent by installed
- * protocols and all packets indicated by the NIC" but if no protocol
- * drivers (like TCP/IP) are installed, NDIS_PACKET_TYPE_DIRECTED,
- * NDIS_PACKET_TYPE_BROADCAST, and NDIS_PACKET_TYPE_MULTICAST are needed to
- * capture incoming frames.
+ /*
+ * NDIS_PACKET_TYPE_ALL_LOCAL selects "All packets sent by
+ * installed protocols and all packets indicated by the NIC",
+ * but if no protocol drivers (like TCP/IP) are installed,
+ * NDIS_PACKET_TYPE_DIRECTED, NDIS_PACKET_TYPE_BROADCAST,
+ * and NDIS_PACKET_TYPE_MULTICAST are needed to capture
+ * incoming frames.
*/
if (PacketSetHwFilter(pw->adapter,
NDIS_PACKET_TYPE_ALL_LOCAL |
NDIS_PACKET_TYPE_BROADCAST |
NDIS_PACKET_TYPE_MULTICAST) == FALSE)
{
- /* suppress spurious error generated by noncompiant MS Surface mobile adaptors */
- if (GetLastError() != NPF_SURFACE_MOBILE_NONPROMISC)
+ DWORD errcode = GetLastError();
+
+ /*
+ * Suppress spurious error generated by non-compiant
+ * MS Surface mobile adaptors
+ */
+ if (errcode != NPF_SURFACE_MOBILE_NONPROMISC)
{
pcap_fmt_errmsg_for_win32_err(p->errbuf,
- PCAP_ERRBUF_SIZE, GetLastError(),
+ PCAP_ERRBUF_SIZE, errcode,
"failed to set hardware filter to non-promiscuous mode");
goto bad;
}