From 6a40276c7500c2d0a2fe44b1a450ffe9cb2f37cd Mon Sep 17 00:00:00 2001 From: David Sommerseth Date: Fri, 10 Jul 2015 15:22:28 +0200 Subject: Provide OpenVPN runtime version information to plug-ins Also updated the log_v3 sample-plugin to demonstrate how this works. $ openvpn --plugin log_v3.so --dev tun Fri Jul 10 15:17:28 2015 OpenVPN 2.3_git [git:dev/plugin-version/f05d8623a29078bf+]..... ...more.openvpn.logging... log_v3: OpenVPN 2.3_git (Major: 2, Minor: 3, Patch: git:dev/plugin-version/f05d8623a29078bf+) ...more.openvpn.logging... $ Signed-off-by: David Sommerseth Acked-by: Gert Doering Message-Id: <1436534548-21507-3-git-send-email-openvpn.list@topphemmelig.net> URL: http://article.gmane.org/gmane.network.openvpn.devel/9904 Signed-off-by: Gert Doering --- src/openvpn/plugin.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/openvpn') diff --git a/src/openvpn/plugin.c b/src/openvpn/plugin.c index 60dd2ee..9be0b0c 100644 --- a/src/openvpn/plugin.c +++ b/src/openvpn/plugin.c @@ -27,6 +27,9 @@ #elif defined(_MSC_VER) #include "config-msvc.h" #endif +#ifdef HAVE_CONFIG_VERSION_H +#include "config-version.h" +#endif #include "syshead.h" @@ -347,6 +350,17 @@ static struct openvpn_plugin_callbacks callbacks = { plugin_vlog }; + +/* Provide a wrapper macro for a version patch level string to plug-ins. + * This is located here purely to not make the code too messy with #ifndef + * inside a struct declaration + */ +#ifndef CONFIGURE_GIT_REVISION +# define _OPENVPN_PATCH_LEVEL OPENVPN_VERSION_PATCH +#else +# define _OPENVPN_PATCH_LEVEL "git:" CONFIGURE_GIT_REVISION CONFIGURE_GIT_FLAGS +#endif + static void plugin_open_item (struct plugin *p, const struct plugin_option *o, @@ -375,7 +389,12 @@ plugin_open_item (struct plugin *p, (const char ** const) o->argv, (const char ** const) envp, &callbacks, - SSLAPI }; + SSLAPI, + PACKAGE_VERSION, + OPENVPN_VERSION_MAJOR, + OPENVPN_VERSION_MINOR, + _OPENVPN_PATCH_LEVEL + }; struct openvpn_plugin_args_open_return retargs; CLEAR(retargs); -- cgit