aboutsummaryrefslogtreecommitdiffstats
path: root/epan/epan.c
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2016-12-08 15:16:00 -0800
committerMichael Mann <mmann78@netscape.net>2016-12-09 13:50:20 +0000
commit9f56bdbef3b2f20339b16308ec2faf663e7b4f3f (patch)
tree3ae93e2656d33643327b442ed47bbb4e9708abca /epan/epan.c
parentb7e7796e20d5b194a72658a0e3f88522e7f66ebc (diff)
Set a Libgcrypt log handler on Windows.
Libgcrypt prints all log messages to stderr by default. On Windows the slow_gatherer routine logs NOTE: you should run 'diskperf -y' to enable the disk statistics if DeviceIoControl(..., IOCTL_DISK_PERFORMANCE, ...) fails. We don't depend on cryptographically secure random numbers and the message is needlessly confusing. Add a log handler that ignores less-severe messages. Change-Id: If40a691ea380364457dfdf126b9bf33ac2672d3a Reviewed-on: https://code.wireshark.org/review/19155 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/epan.c')
-rw-r--r--epan/epan.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/epan/epan.c b/epan/epan.c
index 82e0d397e6..4b3e982d81 100644
--- a/epan/epan.c
+++ b/epan/epan.c
@@ -80,6 +80,37 @@ epan_get_version(void) {
return VERSION;
}
+#if defined(HAVE_LIBGCRYPT) && defined(_WIN32)
+// Libgcrypt prints all log messages to stderr by default. This is noisier
+// than we would like on Windows. In particular slow_gatherer tends to print
+// "NOTE: you should run 'diskperf -y' to enable the disk statistics"
+// which we don't care about.
+static void
+quiet_gcrypt_logger (void *dummy _U_, int level, const char *format, va_list args)
+{
+ GLogLevelFlags log_level = G_LOG_LEVEL_WARNING;
+
+ switch (level) {
+ case GCRY_LOG_CONT: // Continuation. Ignore for now.
+ case GCRY_LOG_DEBUG:
+ case GCRY_LOG_INFO:
+ default:
+ return;
+ case GCRY_LOG_WARN:
+ case GCRY_LOG_BUG:
+ log_level = G_LOG_LEVEL_WARNING;
+ break;
+ case GCRY_LOG_ERROR:
+ log_level = G_LOG_LEVEL_ERROR;
+ break;
+ case GCRY_LOG_FATAL:
+ log_level = G_LOG_LEVEL_CRITICAL;
+ break;
+ }
+ g_logv(NULL, log_level, format, args);
+}
+#endif // HAVE_LIBGCRYPT && _WIN32
+
/*
* Register all the plugin types that are part of libwireshark, namely
* dissector and tap plugins.
@@ -117,6 +148,9 @@ epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_da
#ifdef HAVE_LIBGCRYPT
/* initialize libgcrypt (beware, it won't be thread-safe) */
gcry_check_version(NULL);
+#if defined(HAVE_LIBGCRYPT) && defined(_WIN32)
+ gcry_set_log_handler (quiet_gcrypt_logger, NULL);
+#endif
gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
#endif