]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Separate the general plug-in version constant and v3 plug-in structs version
authorDavid Sommerseth <dazo@users.sourceforge.net>
Thu, 6 Jan 2011 22:24:52 +0000 (23:24 +0100)
committerDavid Sommerseth <davids@redhat.com>
Fri, 25 Mar 2011 08:38:48 +0000 (09:38 +0100)
After a review of the second round of the the v3 plug-in implementation, it
was decided to use a separate constant defining the version of the structs
used for argument and return value passing, instead of OPENVPN_PLUGIN_VERSION.

To not make it too complex, this patch uses a shared version constant for all
the v3 structures.  It is not expected that these strucutures will change too
much and too often.

Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
Acked-by: James Yonan <james@openvpn.net>
openvpn-plugin.h
plugin.c
plugin/examples/log_v3.c

index 13913a8e39878da13d18913ab4bc31b14257397f..5c82dafc547a794f4803e2d21ab1393c6baad5f8 100644 (file)
@@ -168,6 +168,20 @@ struct openvpn_plugin_string_list
 
 /* openvpn_plugin_{open,func}_v3() related structs */
 
+/* Defines version of the v3 plugin argument structs
+ *
+ * Whenever one or more of these structs are modified, this constant
+ * must be updated.  A changelog should be appended in this comment
+ * as well, to make it easier to see what information is available
+ * in the different versions.
+ *
+ * Version   Comment
+ *    1      Initial plugin v3 structures providing the same API as
+ *           the v2 plugin interface + X509 certificate information.
+ *
+ */
+#define OPENVPN_PLUGINv3_STRUCTVER 1
+
 /**
  * Arguments used to transport variables to the plug-in.
  * The struct openvpn_plugin_args_open_in is only used
index 03e7df306a4e99c2f18df7ae1864fdf3596ea66a..56bd37ff6618e1aca36da14dbd7b249085a15f77 100644 (file)
--- a/plugin.c
+++ b/plugin.c
@@ -305,7 +305,7 @@ plugin_open_item (struct plugin *p,
         struct openvpn_plugin_args_open_return retargs;
 
         CLEAR(retargs);
-        if ((*p->open3)(OPENVPN_PLUGIN_VERSION, &args, &retargs) == OPENVPN_PLUGIN_FUNC_SUCCESS) {
+        if ((*p->open3)(OPENVPN_PLUGINv3_STRUCTVER, &args, &retargs) == OPENVPN_PLUGIN_FUNC_SUCCESS) {
           p->plugin_type_mask = retargs.type_mask;
           p->plugin_handle = retargs.handle;
           retlist = retargs.return_list;
@@ -377,7 +377,7 @@ plugin_call_item (const struct plugin *p,
         struct openvpn_plugin_args_func_return retargs;
 
         CLEAR(retargs);
-        status = (*p->func3)(OPENVPN_PLUGIN_VERSION, &args, &retargs);
+        status = (*p->func3)(OPENVPN_PLUGINv3_STRUCTVER, &args, &retargs);
         retlist = retargs.return_list;
       } else if (p->func2)
        status = (*p->func2)(p->plugin_handle, type, (const char **)a.argv, envp, per_client_context, retlist);
index 4974ef26245fa5c557ed8a92e0d225e3a8c46a4e..bf2f1dcec486617d24bf6072f48a8e1d3d27a0b6 100644 (file)
@@ -72,14 +72,14 @@ get_env (const char *name, const char *envp[])
 }
 
 OPENVPN_EXPORT int
-openvpn_plugin_open_v3 (const int apiver,
+openvpn_plugin_open_v3 (const int v3structver,
                         struct openvpn_plugin_args_open_in const *args,
                         struct openvpn_plugin_args_open_return *ret)
 {
   struct plugin_context *context = NULL;
 
   /* Check that we are API compatible */
-  if( apiver != OPENVPN_PLUGIN_VERSION ) {
+  if( v3structver != OPENVPN_PLUGINv3_STRUCTVER ) {
     return OPENVPN_PLUGIN_FUNC_ERROR;
   }