From 1d92195de847a30e570ca690ab0a2034cb3a51d3 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Mon, 23 Jun 2014 14:55:56 -0700 Subject: [PATCH] Have individual programs get libpcap and libz version info. That way, the code that constructs the runtime version string doesn't itself have to call libpcap and libz, and could be usable in programs that don't call them. While we're at it, add "with" to the run-time version information for GnuTLS and libgcrypt, to match the compile-time version information, and add the version information from libwireshark to TShark. Change-Id: I3726a027d032270b032292da9314c1cec535dcd2 Reviewed-on: https://code.wireshark.org/review/2587 Reviewed-by: Guy Harris --- capture-pcap-util.h | 16 ++++++++-------- dumpcap.c | 19 ++++++++++++++++++- epan/epan.c | 4 ++-- tshark.c | 24 +++++++++++++++++++++++- ui/gtk/main.c | 20 ++++++++++++++++++-- ui/qt/main.cpp | 22 +++++++++++++++++----- version_info.c | 9 --------- 7 files changed, 86 insertions(+), 28 deletions(-) diff --git a/capture-pcap-util.h b/capture-pcap-util.h index 49ebe52c40..2dde7b89db 100644 --- a/capture-pcap-util.h +++ b/capture-pcap-util.h @@ -23,14 +23,14 @@ #ifndef __CAPTURE_PCAP_UTIL_H__ #define __CAPTURE_PCAP_UTIL_H__ -#ifdef HAVE_LIBPCAP - -#include - #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ +#ifdef HAVE_LIBPCAP + +#include + /* * A snapshot length of 0 is useless - and libpcap/WinPcap don't guarantee * that a snapshot length of 0 will work, and, on some platforms, it won't @@ -50,10 +50,6 @@ GList *get_remote_interface_list(const char *hostname, const char *port, const char *linktype_val_to_name(int dlt); int linktype_name_to_val(const char *linktype); -#ifdef __cplusplus -} -#endif /* __cplusplus */ - #endif /* HAVE_LIBPCAP */ /* @@ -71,4 +67,8 @@ extern void get_compiled_pcap_version(GString *str); */ extern void get_runtime_pcap_version(GString *str); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + #endif /* __CAPTURE_PCAP_UTIL_H__ */ diff --git a/dumpcap.c b/dumpcap.c index f25d6f060d..1e21f56454 100644 --- a/dumpcap.c +++ b/dumpcap.c @@ -67,6 +67,10 @@ #include #include +#ifdef HAVE_LIBZ +#include /* to get the libz version number */ +#endif + #include #include #include @@ -4172,6 +4176,19 @@ out: return ret; } +static void +get_dumpcap_runtime_info(GString *str) +{ + /* Libpcap */ + g_string_append(str, ", "); + get_runtime_pcap_version(str); + + /* zlib */ +#if defined(HAVE_LIBZ) && !defined(_WIN32) + g_string_append_printf(str, ", with libz %s", zlibVersion()); +#endif +} + /* And now our feature presentation... [ fade to music ] */ int main(int argc, char *argv[]) @@ -4221,7 +4238,7 @@ main(int argc, char *argv[]) /* Assemble the run-time version information string */ runtime_info_str = g_string_new("Running "); - get_runtime_version_info(runtime_info_str, NULL); + get_runtime_version_info(runtime_info_str, get_dumpcap_runtime_info); /* Add it to the information to be reported on a crash. */ ws_add_crash_info("Dumpcap %s\n" diff --git a/epan/epan.c b/epan/epan.c index eef9880f3e..2d5ebfe21d 100644 --- a/epan/epan.c +++ b/epan/epan.c @@ -549,12 +549,12 @@ _U_ { /* GnuTLS */ #ifdef HAVE_LIBGNUTLS - g_string_append_printf(str, ", GnuTLS %s", gnutls_check_version(NULL)); + g_string_append_printf(str, ", with GnuTLS %s", gnutls_check_version(NULL)); #endif /* HAVE_LIBGNUTLS */ /* Gcrypt */ #ifdef HAVE_LIBGCRYPT - g_string_append_printf(str, ", Gcrypt %s", gcry_check_version(NULL)); + g_string_append_printf(str, ", with Gcrypt %s", gcry_check_version(NULL)); #endif /* HAVE_LIBGCRYPT */ } diff --git a/tshark.c b/tshark.c index 70db566b68..e4c9a98a65 100644 --- a/tshark.c +++ b/tshark.c @@ -51,6 +51,10 @@ # include #endif +#ifdef HAVE_LIBZ +#include /* to get the libz version number */ +#endif + #ifndef HAVE_GETOPT #include "wsutil/wsgetopt.h" #endif @@ -918,6 +922,24 @@ show_version(GString *comp_info_str, GString *runtime_info_str) runtime_info_str->str); } +static void +get_tshark_runtime_info(GString *str) +{ +#ifdef HAVE_LIBPCAP + /* Libpcap */ + g_string_append(str, ", "); + get_runtime_pcap_version(str); +#endif + + /* zlib */ +#if defined(HAVE_LIBZ) && !defined(_WIN32) + g_string_append_printf(str, ", with libz %s", zlibVersion()); +#endif + + /* stuff used by libwireshark */ + epan_get_runtime_version_info(str); +} + int main(int argc, char *argv[]) { @@ -989,7 +1011,7 @@ main(int argc, char *argv[]) /* Assemble the run-time version information string */ runtime_info_str = g_string_new("Running "); - get_runtime_version_info(runtime_info_str, NULL); + get_runtime_version_info(runtime_info_str, get_tshark_runtime_info); /* Add it to the information to be reported on a crash. */ ws_add_crash_info("TShark %s\n" diff --git a/ui/gtk/main.c b/ui/gtk/main.c index a1caf1acfa..5848ea15ef 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -45,6 +45,10 @@ #include "wsutil/wsgetopt.h" #endif +#ifdef HAVE_LIBZ +#include /* to get the libz version number */ +#endif + #ifdef _WIN32 /* Needed for console I/O */ #include @@ -1949,8 +1953,20 @@ get_gui_compiled_info(GString *str) } static void -get_gui_runtime_info(GString *str) +get_wireshark_runtime_info(GString *str) { +#ifdef HAVE_LIBPCAP + /* Libpcap */ + g_string_append(str, ", "); + get_runtime_pcap_version(str); +#endif + + /* zlib */ +#if defined(HAVE_LIBZ) && !defined(_WIN32) + g_string_append_printf(str, ", with libz %s", zlibVersion()); +#endif + + /* stuff used by libwireshark */ epan_get_runtime_version_info(str); #ifdef HAVE_AIRPCAP @@ -2251,7 +2267,7 @@ main(int argc, char *argv[]) /* Assemble the run-time version information string */ runtime_info_str = g_string_new("Running "); - get_runtime_version_info(runtime_info_str, get_gui_runtime_info); + get_runtime_version_info(runtime_info_str, get_wireshark_runtime_info); #ifdef _WIN32 ws_add_crash_info(PACKAGE " %s\n" diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp index 19087c5789..52bbb7ffb9 100644 --- a/ui/qt/main.cpp +++ b/ui/qt/main.cpp @@ -31,6 +31,10 @@ #include +#ifdef HAVE_LIBZ +#include /* to get the libz version number */ +#endif + #ifndef HAVE_GETOPT # include "wsutil/wsgetopt.h" #else @@ -419,7 +423,7 @@ get_gui_compiled_info(GString *str) g_string_append(str, ", "); g_string_append(str, "without PortAudio"); - g_string_append(str, ", "); + g_string_append(str, ", "); #ifdef HAVE_AIRPCAP get_compiled_airpcap_version(str); #else @@ -429,8 +433,18 @@ get_gui_compiled_info(GString *str) // xxx copied from ../gtk/main.c static void -get_gui_runtime_info(GString *str) +get_wireshark_runtime_info(GString *str) { + /* Libpcap */ + g_string_append(str, ", "); + get_runtime_pcap_version(str); + + /* zlib */ +#if defined(HAVE_LIBZ) && !defined(_WIN32) + g_string_append_printf(str, ", with libz %s", zlibVersion()); +#endif + + /* stuff used by libwireshark */ epan_get_runtime_version_info(str); #ifdef HAVE_AIRPCAP @@ -438,12 +452,10 @@ get_gui_runtime_info(GString *str) get_runtime_airpcap_version(str); #endif - if(u3_active()) { g_string_append(str, ", "); u3_runtime_info(str); } - } /* And now our feature presentation... [ fade to music ] */ @@ -520,7 +532,7 @@ int main(int argc, char *argv[]) /* Assemble the run-time version information string */ runtime_info_str = g_string_new("Running "); // xxx qtshark - get_runtime_version_info(runtime_info_str, get_gui_runtime_info); + get_runtime_version_info(runtime_info_str, get_wireshark_runtime_info); ws_add_crash_info(PACKAGE " %s\n" "\n" diff --git a/version_info.c b/version_info.c index 63adc39991..888d7ea4c5 100644 --- a/version_info.c +++ b/version_info.c @@ -180,15 +180,6 @@ get_runtime_version_info(GString *str, void (*additional_info)(GString *)) g_string_append(str, ", without locale"); #endif - /* Libpcap */ - g_string_append(str, ", "); - get_runtime_pcap_version(str); - - /* zlib */ -#if defined(HAVE_LIBZ) && !defined(_WIN32) - g_string_append_printf(str, ", with libz %s", zlibVersion()); -#endif - /* Additional application-dependent information */ if (additional_info) (*additional_info)(str);