diff --git a/capture/capture-pcap-util-unix.c b/capture/capture-pcap-util-unix.c index b11d5f335d..ecb1d22db9 100644 --- a/capture/capture-pcap-util-unix.c +++ b/capture/capture-pcap-util-unix.c @@ -160,25 +160,6 @@ gather_caplibs_compile_info(feature_list l) #endif /* __linux__ */ } -/* - * Append the version of libpcap with which we're running to a GString. - * Used in dumpcap when reporting a pcap bug. - */ -void -get_runtime_caplibs_version(GString *str) -{ - const char *vstr = pcap_lib_version(); - - /* - * Remove the substring "version" from the output of pcap_lib_version() - * to be consistent with our format. - */ - if (g_str_has_prefix(vstr, "libpcap version ")) /* Sanity check */ - g_string_append_printf(str, "libpcap %s", vstr + strlen("libpcap version ")); - else - g_string_append(str, vstr); -} - void gather_caplibs_runtime_info(feature_list l) { @@ -207,14 +188,6 @@ gather_caplibs_compile_info(feature_list l) without_feature(l, "libpcap"); } -/* - * Don't append anything, as we weren't even compiled to use libpcap. - */ -void -get_runtime_caplibs_version(GString *str _U_) -{ -} - void gather_caplibs_runtime_info(feature_list l _U_) { diff --git a/capture/capture-pcap-util.h b/capture/capture-pcap-util.h index a3fb58bf6d..c6cbb87f17 100644 --- a/capture/capture-pcap-util.h +++ b/capture/capture-pcap-util.h @@ -88,9 +88,12 @@ extern void gather_caplibs_compile_info(feature_list l); * WinPcap/Npcap wasn't loaded, or nothing, if we weren't compiled with * libpcap/WinPcap/Npcap. */ -extern void get_runtime_caplibs_version(GString *str); extern void gather_caplibs_runtime_info(feature_list l); +#ifdef _WIN32 +extern gboolean caplibs_have_npcap(void); +#endif + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/capture/capture-wpcap.c b/capture/capture-wpcap.c index 9e030923b5..5c24c1f82e 100644 --- a/capture/capture-wpcap.c +++ b/capture/capture-wpcap.c @@ -221,6 +221,12 @@ load_wpcap(void) has_wpcap = TRUE; } +gboolean +caplibs_have_npcap(void) +{ + return has_wpcap && g_str_has_prefix(p_pcap_lib_version(), "Npcap"); +} + static char * local_code_page_str_to_utf8(char *str) { @@ -819,24 +825,6 @@ gather_caplibs_compile_info(feature_list l) with_feature(l, "libpcap"); } - -/* - * Append the version of Npcap with which we're running to a GString. - * Used in dumpcap when reporting a pcap bug. - */ -void -get_runtime_caplibs_version(GString *str) -{ - /* - * On Windows, we might have been compiled with WinPcap/Npcap but - * might not have it loaded; indicate whether we have it or - * not and, if we have it, what version we have. - */ - if (has_wpcap) { - g_string_append(str, p_pcap_lib_version()); - } -} - void gather_caplibs_runtime_info(feature_list l) { @@ -903,20 +891,17 @@ gather_caplibs_compile_info(feature_list l) without_feature(l, "libpcap"); } - -/* - * Don't append anything, as we weren't even compiled to use WinPcap/Npcap. - */ -void -get_runtime_caplibs_version(GString *str _U_) -{ -} - void gather_caplibs_runtime_info(feature_list l _U_) { } +gboolean +caplibs_have_npcap(void) +{ + return FALSE; +} + #endif /* HAVE_LIBPCAP */ /* diff --git a/dumpcap.c b/dumpcap.c index 5390f6db5e..75d3a56c9f 100644 --- a/dumpcap.c +++ b/dumpcap.c @@ -3863,33 +3863,26 @@ capture_loop_dequeue_packet(void) { static char * handle_npcap_bug(char *adapter_name _U_, char *cap_err_str _U_) { - GString *pcap_info_str; - GString *windows_info_str; - char *msg; + gboolean have_npcap = FALSE; - pcap_info_str = g_string_new(""); - // TODO: test directly for Npcap here, so we can remove - // get_runtime_caplibs_version() - get_runtime_caplibs_version(pcap_info_str); - if (!g_str_has_prefix(pcap_info_str->str, "Npcap")) { +#ifdef _WIN32 + have_npcap = caplibs_have_npcap(); +#endif + + if (!have_npcap) { /* * We're not using Npcap, so don't recomment a user * file a bug against Npcap. */ - g_string_free(pcap_info_str, TRUE); return g_strdup(""); } - windows_info_str = g_string_new(""); - get_os_version_info(windows_info_str); - msg = ws_strdup_printf("If you have not removed that adapter, this " + + return ws_strdup_printf("If you have not removed that adapter, this " "is probably a known issue in Npcap resulting from " "the behavior of the Windows networking stack. " "Work is being done in Npcap to improve the " "handling of this issue; it does not need to " "be reported as a Wireshark or Npcap bug."); - g_string_free(windows_info_str, TRUE); - g_string_free(pcap_info_str, TRUE); - return msg; } /* Do the low-level work of a capture.