aboutsummaryrefslogtreecommitdiffstats
path: root/doc/plugins.example
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2017-09-29 19:49:51 +0100
committerJoão Valverde <j@v6e.pt>2017-10-03 10:09:24 +0000
commit2777003e121a5d764b54c62590e7ceb46ae2c157 (patch)
tree1ca9471c447c0fcf94640328fd1a3207224615ad /doc/plugins.example
parentd477ea35a946c2935974edb3fea45cf23513a03c (diff)
Add version check for plugin compatibility
Only plugins built for the same feature release (X.Y) are assured binary compatibility. Make sure we don't try to run unsuitable code and, if so, warn the user. This might happen for example if the user manually copies a binary plugin to the wrong folder, intentionally or by accident. I'm using "release version" to loosely mean not a patch release (i.e: a feature release). Change-Id: I896e9cbbd2d3843623fff6af8ef51002ec06f1f8 Reviewed-on: https://code.wireshark.org/review/23807 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: João Valverde <j@v6e.pt>
Diffstat (limited to 'doc/plugins.example')
-rw-r--r--doc/plugins.example/Makefile.am6
-rw-r--r--doc/plugins.example/hello.c5
2 files changed, 8 insertions, 3 deletions
diff --git a/doc/plugins.example/Makefile.am b/doc/plugins.example/Makefile.am
index 1b9b5b0d27..b477e13933 100644
--- a/doc/plugins.example/Makefile.am
+++ b/doc/plugins.example/Makefile.am
@@ -23,17 +23,21 @@ WARNFLAGS = -Wall -Wextra
plugindir := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --define-variable=libdir=$(libdir) --variable plugindir wireshark)
+release_version := $(notdir $(plugindir))
+
plugin_LTLIBRARIES = hello.la
hello_la_SOURCES = hello.c
+hello_la_CPPFLAGS = -DVERSION_RELEASE=\"$(release_version)\"
+
hello_la_CFLAGS = $(WIRESHARK_CFLAGS) -fvisibility=hidden $(WARNFLAGS)
hello_la_LDFLAGS = -module -avoid-version -shared
hello_la_LIBADD = $(WIRESHARK_LIBS)
-homedir = $${HOME}/.local/lib/wireshark/plugins/$(notdir $(plugindir))
+homedir = $${HOME}/.local/lib/wireshark/plugins/$(release_version)
install-home:
$(MKDIR_P) $(homedir) || exit 1; \
diff --git a/doc/plugins.example/hello.c b/doc/plugins.example/hello.c
index af78239e3a..8493d12ad0 100644
--- a/doc/plugins.example/hello.c
+++ b/doc/plugins.example/hello.c
@@ -32,7 +32,8 @@
#define DLL_PUBLIC __attribute__((__visibility__("default")))
-DLL_PUBLIC const gchar version[] = VERSION;
+DLL_PUBLIC const gchar plugin_version[] = VERSION;
+DLL_PUBLIC const gchar plugin_release[] = VERSION_RELEASE;
DLL_PUBLIC void plugin_register(void);
@@ -45,7 +46,7 @@ static dissector_handle_t handle_hello;
static int
dissect_hello(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
{
- proto_tree_add_protocol_format(tree, proto_hello, tvb, 0, -1, "This is Hello version %s, a Wireshark postdissector plugin prototype", version);
+ proto_tree_add_protocol_format(tree, proto_hello, tvb, 0, -1, "This is Hello version %s, a Wireshark postdissector plugin prototype", plugin_version);
return tvb_captured_length(tvb);
}