Message ID | 1611778909-20630-1-git-send-email-gcox@mozilla.com |
---|---|
State | Accepted |
Headers | show |
Series | [Openvpn-devel,1/2] Update openvpn_plugin_func_v2 to _v3 in sample-plugins/defer/simple.c | expand |
On 27/01/2021 21:21, Greg Cox wrote: > This isn't strictly required, but it modernizes the functions used. > This change makes _open the same parameter form as _func (for better > parallelism in function writing) and includes a check for the correct > struct version, as recommended by openvpn-plugin.h > --- > sample/sample-plugins/defer/simple.c | 23 ++++++++++++++--------- > 1 file changed, 14 insertions(+), 9 deletions(-) > Thanks a lot! This makes a lot of sense and works as expected. Acked-By: David Sommerseth <davids@openvpn.net>
Your patch has been applied to the master, release/2.5 and release/2.4 branch. I have not tested anything beyond "it still compiles", but this looks reasonable and has David's ACK. commit 7d1361c18f38d6301b4d558578c73e74f6597927 (master) commit 11aa1288ffc95877cd5686e19137b9abd6c374bb (release/2.5) commit 5e7e41dc56d71cb7e414d53059149d9490f14a67 (release/2.4) Author: Greg Cox Date: Wed Jan 27 20:21:48 2021 +0000 Update openvpn_plugin_func_v2 to _v3 in sample-plugins/defer/simple.c Acked-by: David Sommerseth <davids@openvpn.net> Message-Id: <1611778909-20630-1-git-send-email-gcox@mozilla.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21507.html Signed-off-by: Gert Doering <gert@greenie.muc.de> -- kind regards, Gert Doering
diff --git a/sample/sample-plugins/defer/simple.c b/sample/sample-plugins/defer/simple.c index 22bc22765d6773d3ea2344a328faf5008b0c5d89..a2e47cfc3953ae188a5a2588a3d21e12404c75f1 100644 --- a/sample/sample-plugins/defer/simple.c +++ b/sample/sample-plugins/defer/simple.c @@ -423,16 +423,21 @@ tls_final(struct plugin_context *context, struct plugin_per_client_context *pcc, } OPENVPN_EXPORT int -openvpn_plugin_func_v2(openvpn_plugin_handle_t handle, - const int type, - const char *argv[], - const char *envp[], - void *per_client_context, - struct openvpn_plugin_string_list **return_list) +openvpn_plugin_func_v3(const int v3structver, + struct openvpn_plugin_args_func_in const *args, + struct openvpn_plugin_args_func_return *ret) { - struct plugin_context *context = (struct plugin_context *) handle; - struct plugin_per_client_context *pcc = (struct plugin_per_client_context *) per_client_context; - switch (type) + /* Check API compatibility -- struct version 5 or higher needed */ + if (v3structver < 5) + { + fprintf(stderr, "%s: this plugin is incompatible with the running version of OpenVPN\n", MODULE); + return OPENVPN_PLUGIN_FUNC_ERROR; + } + const char **argv = args->argv; + const char **envp = args->envp; + struct plugin_context *context = (struct plugin_context *) args->handle; + struct plugin_per_client_context *pcc = (struct plugin_per_client_context *) args->per_client_context; + switch (args->type) { case OPENVPN_PLUGIN_UP: plugin_log(PLOG_NOTE, MODULE, "OPENVPN_PLUGIN_UP");