aboutsummaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
authorGreg Cox2021-01-27 20:21:49 +0000
committerGert Doering2021-01-30 10:44:58 +0100
commita385a3e8a28f2ce96c7ee0be8940b257765add5a (patch)
tree5f125bd9cc26ae8e04165448e2090f5bc7764f32 /sample
parent7d1361c18f38d6301b4d558578c73e74f6597927 (diff)
downloadopenvpn-a385a3e8a28f2ce96c7ee0be8940b257765add5a.zip
openvpn-a385a3e8a28f2ce96c7ee0be8940b257765add5a.tar.gz
More explicit versioning compatibility in sample-plugins/defer/simple.c
While not required, adding openvpn_plugin_min_version_required_v1 helps by making an example for others to copy, and helps to explicitly call attention to the difference between the API version number and the struct version number in v3 calls. Acked-by: David Sommerseth <davids@openvpn.net> Message-Id: <1611778909-20630-2-git-send-email-gcox@mozilla.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21508.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
Diffstat (limited to 'sample')
-rw-r--r--sample/sample-plugins/defer/simple.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/sample/sample-plugins/defer/simple.c b/sample/sample-plugins/defer/simple.c
index a2e47cf..05bfc4e 100644
--- a/sample/sample-plugins/defer/simple.c
+++ b/sample/sample-plugins/defer/simple.c
@@ -66,7 +66,15 @@
static plugin_log_t plugin_log = NULL;
/*
- * Our context, where we keep our state.
+ * Constants indicating minimum API and struct versions by the functions
+ * in this plugin. Consult openvpn-plugin.h, look for:
+ * OPENVPN_PLUGIN_VERSION and OPENVPN_PLUGINv3_STRUCTVER
+ */
+#define OPENVPN_PLUGIN_VERSION_MIN 3
+#define OPENVPN_PLUGIN_STRUCTVER_MIN 5
+
+/*
+* Our context, where we keep our state.
*/
struct plugin_context {
@@ -136,6 +144,13 @@ atoi_null0(const char *str)
}
}
+/* Require a minimum OpenVPN Plugin API */
+OPENVPN_EXPORT int
+openvpn_plugin_min_version_required_v1()
+{
+ return OPENVPN_PLUGIN_VERSION_MIN;
+}
+
/* use v3 functions so we can use openvpn's logging and base64 etc. */
OPENVPN_EXPORT int
openvpn_plugin_open_v3(const int v3structver,
@@ -146,7 +161,7 @@ openvpn_plugin_open_v3(const int v3structver,
struct plugin_context *context;
/* Check API compatibility -- struct version 5 or higher needed */
- if (v3structver < 5)
+ if (v3structver < OPENVPN_PLUGIN_STRUCTVER_MIN)
{
fprintf(stderr, "%s: this plugin is incompatible with the running version of OpenVPN\n", MODULE);
return OPENVPN_PLUGIN_FUNC_ERROR;
@@ -428,7 +443,7 @@ openvpn_plugin_func_v3(const int v3structver,
struct openvpn_plugin_args_func_return *ret)
{
/* Check API compatibility -- struct version 5 or higher needed */
- if (v3structver < 5)
+ if (v3structver < OPENVPN_PLUGIN_STRUCTVER_MIN)
{
fprintf(stderr, "%s: this plugin is incompatible with the running version of OpenVPN\n", MODULE);
return OPENVPN_PLUGIN_FUNC_ERROR;