]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
wireshark: Prefer ws_version.h over config.h
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 7 Sep 2020 15:50:24 +0000 (17:50 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 8 Sep 2020 08:58:24 +0000 (10:58 +0200)
A wireshark plugin must declare what major and minor version it
was built with as these are checked when wireshark loads plugins.
On the top of that, we use major + minor + micro to adapt to
changed API between releases. So far, we were getting these
version numbers from wireshark/config.h.

And while most distributions install wireshark/config.h file some
don't. On distros shipping it it's hack^Wsaved during built by
packaging system and installed later. But some distros are not
doing that. At least not for new enough wireshark because as of
wireshark's commit v2.9.0~1273 the ws_version.h is installed
which contains the version macros we need and is installed by
wireshark itself.

But of course, some distros which have new enough wireshark
packaged do not ship ws_version.h and stick to the hack. That is
why we can't simply bump the minimal version and switch to the
new header file. We need a configure check and adopt our code to
deal with both ways. At least for the time being.

Based on Andrea's original patch:

https://www.redhat.com/archives/libvir-list/2020-September/msg00156.html

Closes: https://gitlab.com/libvirt/libvirt/-/issues/74
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
meson.build
tools/wireshark/src/packet-libvirt.c
tools/wireshark/src/plugin.c

index 1eadea33bf8758d0ae4c05b331f89663369f8264..33eaa9ff56d98751c6947d25196c0ac428cfb399 100644 (file)
@@ -1472,6 +1472,12 @@ if wireshark_dep.found()
   # Since wireshark 2.5.0 plugins can't live in top level plugindir but have
   # to be under one of ["epan", "wiretap", "codecs"] subdir. The first one looks okay.
   wireshark_plugindir = wireshark_plugindir / 'epan'
+
+  # Wireshark is installing ws_version.h since v2.9.0, but some distributions
+  # are not shipping it.
+  if cc.has_header('wireshark/ws_version.h')
+    conf.set('WITH_WS_VERSION', 1)
+  endif
 endif
 
 # On MinGW portablexdr provides XDR functions, on linux they are
index 9f3c7f650d76879e7c4492b155c1da5d2f964099..965f1f5482958220e50b35662820a54ea59d692d 100644 (file)
@@ -18,7 +18,6 @@
  */
 #include <config.h>
 
-#include <wireshark/config.h>
 #include <wireshark/epan/proto.h>
 #include <wireshark/epan/packet.h>
 #include <wireshark/epan/dissectors/packet-tcp.h>
index 504e4383a7b7c2686601bb8e246d233d1577fc9f..13af1b6a73b46e622badf627911475d4341e1bf7 100644 (file)
 
 #include <gmodule.h>
 
-#include <wireshark/config.h>
+#ifdef WITH_WS_VERSION
+# include <wireshark/ws_version.h>
+#else
+# include <wireshark/config.h>
+# define WIRESHARK_VERSION_MAJOR VERSION_MAJOR
+# define WIRESHARK_VERSION_MINOR VERSION_MINOR
+# define WIRESHARK_VERSION_MICRO VERSION_MICRO
+#endif
+
+#define HAVE_PLUGINS 1
 #include <wireshark/epan/proto.h>
 /* plugins are DLLs */
 #define WS_BUILD_DLL
@@ -26,9 +35,9 @@
 #define PLUGIN_VERSION VERSION
 
 #define WIRESHARK_VERSION \
-    ((VERSION_MAJOR * 1000 * 1000) + \
-     (VERSION_MINOR * 1000) + \
-     (VERSION_MICRO))
+    ((WIRESHARK_VERSION_MAJOR * 1000 * 1000) + \
+     (WIRESHARK_VERSION_MINOR * 1000) + \
+     (WIRESHARK_VERSION_MICRO))
 
 #if WIRESHARK_VERSION < 2005000
 
@@ -69,8 +78,8 @@ void proto_register_libvirt(void);
 void proto_reg_handoff_libvirt(void);
 
 WS_DLL_PUBLIC_DEF const gchar plugin_version[] = PLUGIN_VERSION;
-WS_DLL_PUBLIC_DEF const int plugin_want_major = VERSION_MAJOR;
-WS_DLL_PUBLIC_DEF const int plugin_want_minor = VERSION_MINOR;
+WS_DLL_PUBLIC_DEF const int plugin_want_major = WIRESHARK_VERSION_MAJOR;
+WS_DLL_PUBLIC_DEF const int plugin_want_minor = WIRESHARK_VERSION_MINOR;
 
 WS_DLL_PUBLIC void plugin_register(void);