]> The Tcpdump Group git mirrors - libpcap/commitdiff
NPF: give the Windows and NT status code names for "removed" devices.
authorGuy Harris <[email protected]>
Mon, 8 Feb 2021 18:26:22 +0000 (10:26 -0800)
committerGuy Harris <[email protected]>
Mon, 8 Feb 2021 21:17:06 +0000 (13:17 -0800)
That makes a clearer indication of the error point in the Npcap driver
available.

(cherry picked from commit ccf450fbd2708bfe900dbc66eb8983501effeee0)

pcap-npf.c

index 1b4beaa51625d8d79855e12370c9f4085f5d1607..b9b4642c382f16f045cfe84bc6f3609048f789ed 100644 (file)
@@ -565,14 +565,15 @@ pcap_read_npf(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
                                 * ERROR_DEVICE_REMOVED comes from
                                 * STATUS_DEVICE_REMOVED.
                                 *
-                                * We report the error code for the
-                                * benefit of attempts to debug cases
-                                * where this error is reported when
-                                * the device *wasn't* removed, either
-                                * because it's not removable, it's
-                                * removable but wasn't removed, or
-                                * it's a device that doesn't correspond
-                                * to a physical device.
+                                * We report the Windows status code
+                                * name and the corresponding NT status
+                                * code name, for the benefit of attempts
+                                * to debug cases where this error is
+                                * reported when the device *wasn't*
+                                * removed, either because it's not
+                                * removable, it's removable but wasn't
+                                * removed, or it's a device that doesn't
+                                * correspond to a physical device.
                                 *
                                 * XXX - we really should return an
                                 * appropriate error for that, but
@@ -580,9 +581,15 @@ pcap_read_npf(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
                                 * documented as having error returns
                                 * other than PCAP_ERROR or PCAP_ERROR_BREAK.
                                 */
+                               const char *errcode_msg;
+
+                               if (errcode == ERROR_GEN_FAILURE)
+                                       errcode_msg = "ERROR_GEN_FAILURE/STATUS_UNSUCCESSFUL";
+                               else
+                                       errcode_msg = "ERROR_DEVICE_REMOVED/STATUS_DEVICE_REMOVED";
                                snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
-                                   "The interface disappeared (error code %lu)",
-                                   errcode);
+                                   "The interface disappeared (error code %s)",
+                                   errcode_msg);
                        } else {
                                pcap_fmt_errmsg_for_win32_err(p->errbuf,
                                    PCAP_ERRBUF_SIZE, errcode,