OpenVPN
Macros | Functions | Variables
base64.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "openvpn-plugin.h"
Include dependency graph for base64.c:

Go to the source code of this file.

Macros

#define PLUGIN_NAME   "base64.c"
 

Functions

static const char * get_env (const char *name, const char *envp[])
 Search the environment pointer for a specific env var name. More...
 
OPENVPN_EXPORT int openvpn_plugin_open_v3 (const int v3structver, struct openvpn_plugin_args_open_in const *args, struct openvpn_plugin_args_open_return *ret)
 This function is called when OpenVPN loads the plug-in. More...
 
OPENVPN_EXPORT int openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle, const int type, const char *argv[], const char *envp[])
 This function is called by OpenVPN each time the OpenVPN reaches a point where plug-in calls should happen. More...
 
OPENVPN_EXPORT void openvpn_plugin_close_v1 (openvpn_plugin_handle_t handle)
 This cleans up the last part of the plug-in, allows it to shut down cleanly and release the plug-in global context buffer. More...
 

Variables

plugin_log_t ovpn_log = NULL
 Pointer to the OpenVPN log function. More...
 
plugin_vlog_t ovpn_vlog = NULL
 Pointer to the OpenVPN vlog function. More...
 
plugin_base64_encode_t ovpn_base64_encode = NULL
 Pointer to the openvpn_base64_encode () function. More...
 
plugin_base64_decode_t ovpn_base64_decode = NULL
 Pointer to the openvpn_base64_decode () function. More...
 

Macro Definition Documentation

◆ PLUGIN_NAME

#define PLUGIN_NAME   "base64.c"

Definition at line 31 of file base64.c.

Referenced by openvpn_plugin_func_v1(), and openvpn_plugin_open_v3().

Function Documentation

◆ get_env()

static const char* get_env ( const char *  name,
const char *  envp[] 
)
static

Search the environment pointer for a specific env var name.

PLEASE NOTE! The result is not valid outside the local scope of the calling function. Once the calling function returns, any returned pointers are invalid.

Parameters
nameString containing the env.var name to search for
envpString array pointer to the environment variable
Returns
Returns a pointer to the value in the environment variable table on successful match. Otherwise NULL is returned

Definition at line 54 of file base64.c.

References OPENVPN_EXPORT.

Referenced by openvpn_plugin_func_v1().

◆ openvpn_plugin_close_v1()

OPENVPN_EXPORT void openvpn_plugin_close_v1 ( openvpn_plugin_handle_t  handle)

This cleans up the last part of the plug-in, allows it to shut down cleanly and release the plug-in global context buffer.

Parameters
handlePointer to the plug-in global context buffer, which need to be released by this function

Definition at line 199 of file base64.c.

References free.

◆ openvpn_plugin_func_v1()

OPENVPN_EXPORT int openvpn_plugin_func_v1 ( openvpn_plugin_handle_t  handle,
const int  type,
const char *  argv[],
const char *  envp[] 
)

This function is called by OpenVPN each time the OpenVPN reaches a point where plug-in calls should happen.

It only happens for those plug-in hooks enabled in openvpn_plugin_open_v3().

For the arguments, see the include/openvpn-plugin.h file for details on the function parameters

Parameters
argsPointer to a struct with details about the plug-in call from the main OpenVPN process.
returndataPointer to a struct where the plug-in can provide information back to OpenVPN to be processed
Returns
Must return OPENVPN_PLUGIN_FUNC_SUCCESS or OPENVPN_PLUGIN_FUNC_DEFERRED on success. Otherwise it should return OPENVPN_FUNC_ERROR, which will stop and reject the client session from progressing.

Definition at line 154 of file base64.c.

References free, get_env(), OPENVPN_EXPORT, OPENVPN_PLUGIN_CLIENT_CONNECT_V2, OPENVPN_PLUGIN_FUNC_ERROR, OPENVPN_PLUGIN_FUNC_SUCCESS, OPENVPN_PLUGIN_TLS_VERIFY, ovpn_base64_decode, ovpn_base64_encode, ovpn_log, PLOG_ERR, PLOG_NOTE, and PLUGIN_NAME.

◆ openvpn_plugin_open_v3()

OPENVPN_EXPORT int openvpn_plugin_open_v3 ( const int  v3structver,
struct openvpn_plugin_args_open_in const *  args,
struct openvpn_plugin_args_open_return ret 
)

This function is called when OpenVPN loads the plug-in.

The purpose is to initialize the plug-in and tell OpenVPN which plug-in hooks this plug-in wants to be involved in

For the arguments, see the include/openvpn-plugin.h file for details on the function parameters

Parameters
v3structverAn integer containing the API version of the plug-in structs OpenVPN uses
argsA pointer to the argument struct for information and features provided by OpenVPN to the plug-in
retA pointer to the struct OpenVPN uses to receive information back from the plug-in
Returns
Must return OPENVPN_PLUGIN_FUNC_SUCCESS when everything completed successfully. Otherwise it must be returned OPENVPN_PLUGIN_FUNC_ERROR, which will stop OpenVPN from running

Definition at line 99 of file base64.c.

References openvpn_plugin_args_open_in::callbacks, openvpn_plugin_args_open_return::handle, OPENVPN_EXPORT, OPENVPN_PLUGIN_CLIENT_CONNECT_V2, OPENVPN_PLUGIN_FUNC_ERROR, OPENVPN_PLUGIN_FUNC_SUCCESS, OPENVPN_PLUGIN_MASK, OPENVPN_PLUGIN_TLS_VERIFY, OPENVPN_PLUGINv3_STRUCTVER, ovpn_base64_decode, ovpn_base64_encode, ovpn_log, openvpn_plugin_args_open_in::ovpn_version, openvpn_plugin_args_open_in::ovpn_version_major, openvpn_plugin_args_open_in::ovpn_version_minor, openvpn_plugin_args_open_in::ovpn_version_patch, ovpn_vlog, PLOG_NOTE, openvpn_plugin_callbacks::plugin_log, PLUGIN_NAME, openvpn_plugin_callbacks::plugin_vlog, and openvpn_plugin_args_open_return::type_mask.

Variable Documentation

◆ ovpn_base64_decode

plugin_base64_decode_t ovpn_base64_decode = NULL

Pointer to the openvpn_base64_decode () function.

Definition at line 37 of file base64.c.

Referenced by openvpn_plugin_func_v1(), and openvpn_plugin_open_v3().

◆ ovpn_base64_encode

plugin_base64_encode_t ovpn_base64_encode = NULL

Pointer to the openvpn_base64_encode () function.

Definition at line 36 of file base64.c.

Referenced by openvpn_plugin_func_v1(), and openvpn_plugin_open_v3().

◆ ovpn_log

plugin_log_t ovpn_log = NULL

Pointer to the OpenVPN log function.

See plugin_log()

Definition at line 34 of file base64.c.

Referenced by openvpn_plugin_func_v1(), and openvpn_plugin_open_v3().

◆ ovpn_vlog

plugin_vlog_t ovpn_vlog = NULL

Pointer to the OpenVPN vlog function.

See plugin_vlog()

Definition at line 35 of file base64.c.

Referenced by openvpn_plugin_open_v3().