aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil/plugins.c
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2018-08-21 15:18:56 +0100
committerJoão Valverde <j@v6e.pt>2018-08-21 19:56:12 +0000
commit65d9c473f035290b1b076268332c399125f048ca (patch)
treee6d4236dd6436e38ad7f6a586fecc7d563200426 /wsutil/plugins.c
parent0410a522d5b5e0b7c534146628770f9801e314e2 (diff)
plugins: Minor interface improvement
Change the plugin compatibility check to make it more convenient to define and check the major.minor Wireshark version. Change-Id: I2a6d2a746682c29504311cce5c457e0a852c3daf Reviewed-on: https://code.wireshark.org/review/29224 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde <j@v6e.pt>
Diffstat (limited to 'wsutil/plugins.c')
-rw-r--r--wsutil/plugins.c39
1 files changed, 29 insertions, 10 deletions
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;
}