dumpcap: provide more information to put into an Npcap bug.

Turn the sequence of details to supply in an Npcap bug into a list, with
one element per line, and provide the interface name, Windows version
string, and Npcap version string.  Put that into a common routine.


(cherry picked from commit b09514f3b3)
This commit is contained in:
Guy Harris 2021-02-09 06:33:18 +00:00
parent 089889acf2
commit 098fe77ec6
1 changed files with 38 additions and 42 deletions

View File

@ -3704,6 +3704,40 @@ capture_loop_dequeue_packet(void) {
return FALSE;
}
/*
* Note: this code will never be run on any OS other than Windows.
*/
static char *
please_report_npcap_bug(char *adapter_name, char *cap_err_str)
{
GString *windows_info_str = g_string_new("");
GString *pcap_info_str = g_string_new("");
char *msg;
get_os_version_info(windows_info_str);
get_runtime_caplibs_version(pcap_info_str);
msg = g_strdup_printf("If you have not removed that adapter, this "
"may be a bug in Npcap: please report it "
"as an issue at https://github.com/nmap/npcap/issues\n\n"
"Give all details, such as:\n\n"
"The name of the adapter on which the error occurred (\"%s\");\n"
"The error message \"%s\";\n"
"The full version of Windows on which this occurred (\"%s\");\n"
"The version of Npcap with which this occurred (\"%s\");\n"
"Any indication of whether the machine went to sleep "
"during the capture;\n"
"Any indication of whether any other interfaces "
"were added to or removed from the machine while "
"the capture was taking place.",
adapter_name,
cap_err_str,
windows_info_str->str,
pcap_info_str->str);
g_string_free(windows_info_str, TRUE);
g_string_free(pcap_info_str, TRUE);
return msg;
}
/* Do the low-level work of a capture.
Returns TRUE if it succeeds, FALSE otherwise. */
static gboolean
@ -4068,27 +4102,8 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
"is no longer attached; the "
"capture has stopped.",
interface_opts->display_name);
secondary_msg = g_strdup_printf("If you have not removed that "
"adapter, this may be a bug "
"in Npcap: please report it "
"as an issue at https://github.com/nmap/npcap/issues\n\n"
"Give all details, such as "
"the name of the adapter on "
"which the error occurred, "
"the error message \"%s\", "
"the full version of Windows "
"on which this occurred, "
"the version of Npcap with "
"which this occurred, any "
"indication of whether the "
"machine went to sleep "
"during the capture, "
"and any indication of "
"whether any other interfaces "
"were added to or removed "
"from the machine while the "
"capture was taking place.",
cap_err_str);
secondary_msg = please_report_npcap_bug(interface_opts->display_name,
cap_err_str);
} else if (g_str_has_prefix(cap_err_str, "PacketReceivePacket error:") &&
g_str_has_suffix(cap_err_str, "(1617)")) {
/*
@ -4112,27 +4127,8 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
"is no longer attached; the "
"capture has stopped.",
interface_opts->display_name);
secondary_msg = g_strdup_printf("If you have not removed that "
"adapter, this may be a bug "
"in Npcap: please report it "
"as an issue at https://github.com/nmap/npcap/issues\n\n"
"Give all details, such as "
"the name of the adapter on "
"which the error occurred, "
"the error message \"%s\", "
"the full version of Windows "
"on which this occurred, "
"the version of Npcap with "
"which this occurred, any "
"indication of whether the "
"machine went to sleep "
"during the capture, "
"and any indication of "
"whether any other interfaces "
"were added to or removed "
"from the machine while the "
"capture was taking place.",
"(ERROR_DEVICE_REMOVED/STATUS_DEVICE_REMOVED)");
secondary_msg = please_report_npcap_bug(interface_opts->display_name,
"The interface disappeared (error code ERROR_DEVICE_REMOVED/STATUS_DEVICE_REMOVED)");
} else if (strcmp(cap_err_str, "The other host terminated the connection") == 0) {
primary_msg = g_strdup(cap_err_str);
secondary_msg = g_strdup("This may be a problem with the "