6fbf66fa |
/*
* OpenVPN -- An application to securely tunnel IP networks
* over a single TCP/UDP port, with support for SSL/TLS-based
* session authentication and key exchange,
* packet encryption, packet authentication, and
* packet compression.
* |
49979459 |
* Copyright (C) 2002-2018 OpenVPN Inc <sales@openvpn.net> |
6fbf66fa |
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* |
caa54ac3 |
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
6fbf66fa |
*/
/*
* plug-in support, using dynamically loaded libraries
*/
#ifndef OPENVPN_PLUGIN_H
#define OPENVPN_PLUGIN_H
|
9b33b5a4 |
#ifdef ENABLE_CRYPTO_OPENSSL |
bcedab1f |
#include "ssl_verify_openssl.h"
#endif |
86d8cd68 |
#ifdef ENABLE_CRYPTO_MBEDTLS |
74586c65 |
#include "ssl_verify_mbedtls.h" |
bcedab1f |
#endif |
6fbf66fa |
#include "openvpn-plugin.h"
#ifdef ENABLE_PLUGIN
#include "misc.h"
|
3c7f2f55 |
#define MAX_PLUGINS 16 |
6fbf66fa |
struct plugin_option { |
81d882d5 |
const char *so_pathname;
const char **argv; |
6fbf66fa |
};
struct plugin_option_list { |
81d882d5 |
int n;
struct plugin_option plugins[MAX_PLUGINS]; |
6fbf66fa |
};
struct plugin { |
81d882d5 |
bool initialized;
const char *so_pathname;
unsigned int plugin_type_mask;
int requested_initialization_point; |
3c7f2f55 |
|
445b192a |
#ifndef _WIN32 |
81d882d5 |
void *handle; |
bdae4110 |
#else |
81d882d5 |
HMODULE module; |
6fbf66fa |
#endif |
3c7f2f55 |
|
81d882d5 |
openvpn_plugin_open_v1 open1;
openvpn_plugin_open_v2 open2;
openvpn_plugin_open_v3 open3;
openvpn_plugin_func_v1 func1;
openvpn_plugin_func_v2 func2;
openvpn_plugin_func_v3 func3;
openvpn_plugin_close_v1 close;
openvpn_plugin_abort_v1 abort;
openvpn_plugin_client_constructor_v1 client_constructor;
openvpn_plugin_client_destructor_v1 client_destructor;
openvpn_plugin_min_version_required_v1 min_version_required;
openvpn_plugin_select_initialization_point_v1 initialization_point;
openvpn_plugin_handle_t plugin_handle; |
6fbf66fa |
};
|
3c7f2f55 |
struct plugin_per_client
{ |
81d882d5 |
void *per_client_context[MAX_PLUGINS]; |
3c7f2f55 |
};
struct plugin_common
{ |
81d882d5 |
int n;
struct plugin plugins[MAX_PLUGINS]; |
6fbf66fa |
};
|
3c7f2f55 |
struct plugin_list
{ |
81d882d5 |
struct plugin_per_client per_client;
struct plugin_common *common;
bool common_owned; |
3c7f2f55 |
};
struct plugin_return
{ |
81d882d5 |
int n;
struct openvpn_plugin_string_list *list[MAX_PLUGINS]; |
3c7f2f55 |
};
|
81d882d5 |
struct plugin_option_list *plugin_option_list_new(struct gc_arena *gc);
bool plugin_option_list_add(struct plugin_option_list *list, char **p, struct gc_arena *gc); |
6fbf66fa |
|
6c61d0dd |
#ifndef ENABLE_SMALL |
81d882d5 |
void plugin_option_list_print(const struct plugin_option_list *list, int msglevel);
|
6fbf66fa |
#endif
|
81d882d5 |
struct plugin_list *plugin_list_init(const struct plugin_option_list *list); |
e1791bb1 |
|
81d882d5 |
void plugin_list_open(struct plugin_list *pl,
const struct plugin_option_list *list,
struct plugin_return *pr,
const struct env_set *es,
const int init_point); |
3c7f2f55 |
|
81d882d5 |
struct plugin_list *plugin_list_inherit(const struct plugin_list *src); |
3c7f2f55 |
|
81d882d5 |
int plugin_call_ssl(const struct plugin_list *pl,
const int type,
const struct argv *av,
struct plugin_return *pr, |
c7ca9133 |
struct env_set *es,
int current_cert_depth, |
81d882d5 |
openvpn_x509_cert_t *current_cert
); |
1876ccd0 |
|
81d882d5 |
void plugin_list_close(struct plugin_list *pl); |
6fbf66fa |
|
81d882d5 |
bool plugin_defined(const struct plugin_list *pl, const int type); |
3c7f2f55 |
|
81d882d5 |
void plugin_return_get_column(const struct plugin_return *src,
struct plugin_return *dest,
const char *colname);
void plugin_return_free(struct plugin_return *pr); |
3c7f2f55 |
#ifdef ENABLE_DEBUG |
81d882d5 |
void plugin_return_print(const int msglevel, const char *prefix, const struct plugin_return *pr);
|
3c7f2f55 |
#endif
static inline int |
81d882d5 |
plugin_n(const struct plugin_list *pl) |
3c7f2f55 |
{ |
81d882d5 |
if (pl && pl->common)
{
return pl->common->n;
}
else
{
return 0;
} |
3c7f2f55 |
}
static inline bool |
81d882d5 |
plugin_return_defined(const struct plugin_return *pr) |
3c7f2f55 |
{ |
81d882d5 |
return pr->n >= 0; |
3c7f2f55 |
}
static inline void |
81d882d5 |
plugin_return_init(struct plugin_return *pr) |
3c7f2f55 |
{ |
81d882d5 |
pr->n = 0; |
3c7f2f55 |
}
|
81d882d5 |
#else /* ifdef ENABLE_PLUGIN */ |
6fbf66fa |
struct plugin_list { int dummy; }; |
3c7f2f55 |
struct plugin_return { int dummy; }; |
6fbf66fa |
static inline bool |
81d882d5 |
plugin_defined(const struct plugin_list *pl, const int type) |
6fbf66fa |
{ |
81d882d5 |
return false; |
6fbf66fa |
}
static inline int |
81d882d5 |
plugin_call_ssl(const struct plugin_list *pl,
const int type,
const struct argv *av,
struct plugin_return *pr, |
c7ca9133 |
struct env_set *es,
int current_cert_depth, |
81d882d5 |
openvpn_x509_cert_t *current_cert
) |
6fbf66fa |
{ |
81d882d5 |
return 0; |
6fbf66fa |
}
#endif /* ENABLE_PLUGIN */
|
22277ec6 |
static inline int
plugin_call(const struct plugin_list *pl, |
81d882d5 |
const int type,
const struct argv *av,
struct plugin_return *pr,
struct env_set *es) |
22277ec6 |
{ |
c7ca9133 |
return plugin_call_ssl(pl, type, av, pr, es, -1, NULL); |
22277ec6 |
}
|
6fbf66fa |
#endif /* OPENVPN_PLUGIN_H */ |