aboutsummaryrefslogtreecommitdiff
path: root/pcap-npf.c
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2021-02-08 10:26:22 -0800
committerGuy Harris <gharris@sonic.net>2021-02-08 10:26:22 -0800
commitccf450fbd2708bfe900dbc66eb8983501effeee0 (patch)
treeae09510ff9afb30fd7d0c4a3fe823a26de73e335 /pcap-npf.c
parent8ce3839ab6ff30e3b914964d70f139138671ef9c (diff)
NPF: give the Windows and NT status code names for "removed" devices.
That makes a clearer indication of the error point in the Npcap driver available.
Diffstat (limited to 'pcap-npf.c')
-rw-r--r--pcap-npf.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/pcap-npf.c b/pcap-npf.c
index 1b4beaa5..b9b4642c 100644
--- a/pcap-npf.c
+++ b/pcap-npf.c
@@ -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,