aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt4
-rw-r--r--doc/plugins.example/CMakeLists.txt3
-rw-r--r--doc/plugins.example/hello.c4
-rw-r--r--plugins/epan/stats_tree/stats_tree_plugin.c3
-rwxr-xr-xtools/make-plugin-reg.py3
-rw-r--r--wireshark.pc.in1
-rw-r--r--ws_version.h.in10
-rw-r--r--wsutil/plugins.c39
8 files changed, 50 insertions, 17 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0250b9adef..5afb3a54b4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1418,12 +1418,13 @@ set_target_properties(version PROPERTIES FOLDER "Auxiliary")
set( configure_input "Built with CMake ${CMAKE_VERSION}" )
configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h)
+configure_file(${CMAKE_SOURCE_DIR}/ws_version.h.in ${CMAKE_BINARY_DIR}/ws_version.h)
+
set( prefix "${CMAKE_INSTALL_PREFIX}" )
set( exec_prefix "\${prefix}" )
set( libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}" )
set( includedir "\${prefix}/include" )
set( plugindir "\${libdir}/wireshark/${PLUGIN_VERSION_DIR}" )
-set( VERSION_RELEASE "${PROJECT_RELEASE_VERSION}" )
# Doxygen variables
file(GLOB TOP_LEVEL_SOURCE_LIST *.c *.cpp *.h)
@@ -2825,6 +2826,7 @@ set(SHARK_PUBLIC_HEADERS
ws_diag_control.h
ws_symbol_export.h
version_info.h
+ ${CMAKE_BINARY_DIR}/ws_version.h
)
if(NOT WIN32)
diff --git a/doc/plugins.example/CMakeLists.txt b/doc/plugins.example/CMakeLists.txt
index e7a20219e7..d754fc4cf3 100644
--- a/doc/plugins.example/CMakeLists.txt
+++ b/doc/plugins.example/CMakeLists.txt
@@ -20,7 +20,6 @@ pkg_check_modules(WIRESHARK REQUIRED wireshark>=2.5)
### CMake Bug: If you run into problems please use the "Unix Makefiles" generator.
### Ninja just wipes the pkg-config variables.
# https://gitlab.kitware.com/cmake/cmake/issues/17531 (and probably others)
-pkg_get_variable(WIRESHARK_VERSION_RELEASE wireshark VERSION_RELEASE)
pkg_get_variable(WIRESHARK_PLUGIN_DIR wireshark plugindir)
set(PLUGIN_INSTALL_LIBDIR "${WIRESHARK_PLUGIN_DIR}/epan")
@@ -41,7 +40,7 @@ if (CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_C_FLAGS "-Wall -Wextra ${CMAKE_C_FLAGS}")
endif()
-add_definitions(-DHAVE_PLUGINS -DVERSION=\"${PROJECT_VERSION}\" -DVERSION_RELEASE=\"${WIRESHARK_VERSION_RELEASE}\")
+add_definitions(-DHAVE_PLUGINS -DVERSION=\"${PROJECT_VERSION}\")
add_library(hello MODULE hello.c)
set_target_properties(hello PROPERTIES PREFIX "" DEFINE_SYMBOL "")
diff --git a/doc/plugins.example/hello.c b/doc/plugins.example/hello.c
index 52c4a50ec6..4e128afeda 100644
--- a/doc/plugins.example/hello.c
+++ b/doc/plugins.example/hello.c
@@ -14,6 +14,7 @@
#include <epan/packet.h>
#include <epan/proto.h>
#include <ws_attributes.h>
+#include <ws_version.h>
#ifndef VERSION
#define VERSION "0.0.0"
@@ -22,7 +23,8 @@
#define DLL_PUBLIC __attribute__((__visibility__("default")))
DLL_PUBLIC const gchar plugin_version[] = VERSION;
-DLL_PUBLIC const gchar plugin_release[] = VERSION_RELEASE;
+DLL_PUBLIC const int plugin_want_major = WIRESHARK_VERSION_MAJOR;
+DLL_PUBLIC const int plugin_want_minor = WIRESHARK_VERSION_MINOR;
DLL_PUBLIC void plugin_register(void);
diff --git a/plugins/epan/stats_tree/stats_tree_plugin.c b/plugins/epan/stats_tree/stats_tree_plugin.c
index 3074861a23..25a419185b 100644
--- a/plugins/epan/stats_tree/stats_tree_plugin.c
+++ b/plugins/epan/stats_tree/stats_tree_plugin.c
@@ -21,7 +21,8 @@
#include "pinfo_stats_tree.h"
WS_DLL_PUBLIC_DEF const gchar plugin_version[] = PLUGIN_VERSION;
-WS_DLL_PUBLIC_DEF const gchar plugin_release[] = VERSION_RELEASE;
+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 void plugin_register(void);
diff --git a/tools/make-plugin-reg.py b/tools/make-plugin-reg.py
index 1aed42ddef..66b465673a 100755
--- a/tools/make-plugin-reg.py
+++ b/tools/make-plugin-reg.py
@@ -130,7 +130,8 @@ for symbol in regs['codec_register']:
reg_code += """
WS_DLL_PUBLIC_DEF const gchar plugin_version[] = PLUGIN_VERSION;
-WS_DLL_PUBLIC_DEF const gchar plugin_release[] = VERSION_RELEASE;
+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 void plugin_register(void);
diff --git a/wireshark.pc.in b/wireshark.pc.in
index 82b520ee20..588917812b 100644
--- a/wireshark.pc.in
+++ b/wireshark.pc.in
@@ -4,7 +4,6 @@ libdir=@libdir@
includedir=@includedir@
sharedlibdir=${libdir}
plugindir=@plugindir@
-VERSION_RELEASE=@VERSION_RELEASE@
Name: Wireshark
Description: Network Packet Dissection Library
diff --git a/ws_version.h.in b/ws_version.h.in
new file mode 100644
index 0000000000..f89bfb80e2
--- /dev/null
+++ b/ws_version.h.in
@@ -0,0 +1,10 @@
+/* ws_version.h.in */
+
+#ifndef __WS_VERSION_H__
+#define __WS_VERSION_H__
+
+#define WIRESHARK_VERSION_MAJOR @PROJECT_MAJOR_VERSION@
+#define WIRESHARK_VERSION_MINOR @PROJECT_MINOR_VERSION@
+#define WIRESHARK_VERSION_MICRO @PROJECT_PATCH_VERSION@
+
+#endif /* __WS_VERSION_H__ */
diff --git a/wsutil/plugins.c b/wsutil/plugins.c
index a1d91a154e..9c5df36747 100644
--- a/wsutil/plugins.c
+++ b/wsutil/plugins.c
@@ -96,6 +96,33 @@ compare_plugins(gconstpointer a, gconstpointer b)
return g_strcmp0((*(plugin *const *)a)->name, (*(plugin *const *)b)->name);
}
+static gboolean
+pass_plugin_version_compatibility(GModule *handle, const char *name)
+{
+ gpointer symb;
+ int major, minor;
+
+ if(!g_module_symbol(handle, "plugin_want_major", &symb)) {
+ report_failure("The plugin '%s' has no \"plugin_want_major\" symbol", name);
+ return FALSE;
+ }
+ major = *(int *)symb;
+
+ if(!g_module_symbol(handle, "plugin_want_minor", &symb)) {
+ report_failure("The plugin '%s' has no \"plugin_want_minor\" symbol", name);
+ return FALSE;
+ }
+ minor = *(int *)symb;
+
+ if (major != VERSION_MAJOR || minor != VERSION_MINOR) {
+ report_failure("The plugin '%s' was compiled for Wireshark version %d.%d",
+ name, major, minor);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static void
scan_plugins_dir(GHashTable *plugins_module, const char *dirpath, plugin_type_e type, gboolean append_type)
{
@@ -105,7 +132,7 @@ scan_plugins_dir(GHashTable *plugins_module, const char *dirpath, plugin_type_e
gchar *plugin_file; /* current file full path */
GModule *handle; /* handle returned by g_module_open */
gpointer symbol;
- const char *plug_version, *plug_release;
+ const char *plug_version;
plugin *new_plug;
if (append_type)
@@ -152,15 +179,7 @@ scan_plugins_dir(GHashTable *plugins_module, const char *dirpath, plugin_type_e
}
plug_version = (const char *)symbol;
- if (!g_module_symbol(handle, "plugin_release", &symbol))
- {
- report_failure("The plugin '%s' has no \"plugin_release\" symbol", name);
- g_module_close(handle);
- continue;
- }
- plug_release = (const char *)symbol;
- if (strcmp(plug_release, VERSION_RELEASE) != 0) {
- report_failure("The plugin '%s' was compiled for Wireshark version %s", name, plug_release);
+ if (!pass_plugin_version_compatibility(handle, name)) {
g_module_close(handle);
continue;
}