]> The Tcpdump Group git mirrors - libpcap/commitdiff
NPF: handle ERROR_INVALID_FUNCTION from PacketGetTimestampModes().
authorGuy Harris <[email protected]>
Sat, 6 Nov 2021 22:15:08 +0000 (15:15 -0700)
committerGuy Harris <[email protected]>
Sun, 7 Nov 2021 00:06:06 +0000 (17:06 -0700)
This is probably due to the driver that Packet.dll is using being a
driver for an older version of Npcap, or for WinPcap, so that the
BIOCGTIMESTAMPMODES DeviceIoControl is rejected as being unsupported.

Tell the user to try unindtalling Npcap - and WinPcap if it's installed
- and re-installing from npcap.org.

(cherry picked from commit 4ba0bf4f6f2f43107f62dd742b0d5e06422276a9)

pcap-npf.c

index 8efebce5bab11097e042ef50e23d19710f26c2fe..6f419a47d29eaf19dfd7119394d1f0c5af1ee4e1 100644 (file)
@@ -1576,6 +1576,29 @@ pcap_create_interface(const char *device _U_, char *ebuf)
                         */
                        error = GetLastError();
                        if (error != ERROR_MORE_DATA) {
+                               /*
+                                * No, did it fail with ERROR_INVALID_FUNCTION?
+                                */
+                               if (error == ERROR_INVALID_FUNCTION) {
+                                       /*
+                                        * This is probably due to
+                                        * the driver with which Packet.dll
+                                        * communicates being older, or
+                                        * being a WinPcap driver, so
+                                        * that it doesn't support
+                                        * BIOCGTIMESTAMPMODES.
+                                        *
+                                        * Tell the user to try uninstalling
+                                        * Npcap - and WinPcap if installed -
+                                        * and re-installing it, to flush
+                                        * out all older drivers.
+                                        */
+                                       snprintf(errbuf, PCAP_ERRBUF_SIZE,
+                                           "PacketGetTimestampModes() failed with ERROR_INVALID_FUNCTION; try uninstalling Npcap, and WinPcap if installed, and re-installing it from npcap.org");
+                                       pcap_close(p);
+                                       return (NULL);
+                               }
+
                                /*
                                 * No, some other error.  Fail.
                                 */