123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879 |
- #ifndef OPENVPN_PLUGIN_H_
- #define OPENVPN_PLUGIN_H_
- #define OPENVPN_PLUGIN_VERSION 3
- #ifdef ENABLE_CRYPTO
- #ifdef ENABLE_CRYPTO_MBEDTLS
- #include <mbedtls/x509_crt.h>
- #ifndef __OPENVPN_X509_CERT_T_DECLARED
- #define __OPENVPN_X509_CERT_T_DECLARED
- typedef mbedtls_x509_crt openvpn_x509_cert_t;
- #endif
- #else
- #include <openssl/x509.h>
- #ifndef __OPENVPN_X509_CERT_T_DECLARED
- #define __OPENVPN_X509_CERT_T_DECLARED
- typedef X509 openvpn_x509_cert_t;
- #endif
- #endif
- #endif
- #include <stdarg.h>
- #include <stddef.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define OPENVPN_VERSION_MAJOR 2
- #define OPENVPN_VERSION_MINOR 4
- #define OPENVPN_VERSION_PATCH ".9"
- #define OPENVPN_PLUGIN_UP 0
- #define OPENVPN_PLUGIN_DOWN 1
- #define OPENVPN_PLUGIN_ROUTE_UP 2
- #define OPENVPN_PLUGIN_IPCHANGE 3
- #define OPENVPN_PLUGIN_TLS_VERIFY 4
- #define OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY 5
- #define OPENVPN_PLUGIN_CLIENT_CONNECT 6
- #define OPENVPN_PLUGIN_CLIENT_DISCONNECT 7
- #define OPENVPN_PLUGIN_LEARN_ADDRESS 8
- #define OPENVPN_PLUGIN_CLIENT_CONNECT_V2 9
- #define OPENVPN_PLUGIN_TLS_FINAL 10
- #define OPENVPN_PLUGIN_ENABLE_PF 11
- #define OPENVPN_PLUGIN_ROUTE_PREDOWN 12
- #define OPENVPN_PLUGIN_N 13
- #define OPENVPN_PLUGIN_MASK(x) (1<<(x))
- typedef void *openvpn_plugin_handle_t;
- #define OPENVPN_PLUGIN_FUNC_SUCCESS 0
- #define OPENVPN_PLUGIN_FUNC_ERROR 1
- #define OPENVPN_PLUGIN_FUNC_DEFERRED 2
- #if defined(_WIN32) && !defined(OPENVPN_PLUGIN_H)
- #define OPENVPN_EXPORT __declspec(dllexport)
- #else
- #define OPENVPN_EXPORT
- #endif
- #ifdef OPENVPN_PLUGIN_H
- #define OPENVPN_PLUGIN_DEF typedef
- #define OPENVPN_PLUGIN_FUNC(name) (*name)
- #else
- #define OPENVPN_PLUGIN_DEF OPENVPN_EXPORT
- #define OPENVPN_PLUGIN_FUNC(name) name
- #endif
- struct openvpn_plugin_string_list
- {
- struct openvpn_plugin_string_list *next;
- char *name;
- char *value;
- };
- #define OPENVPN_PLUGINv3_STRUCTVER 5
- typedef enum
- {
- PLOG_ERR = (1 << 0),
- PLOG_WARN = (1 << 1),
- PLOG_NOTE = (1 << 2),
- PLOG_DEBUG = (1 << 3),
- PLOG_ERRNO = (1 << 8),
- PLOG_NOMUTE = (1 << 9),
- } openvpn_plugin_log_flags_t;
- #ifdef __GNUC__
- #if __USE_MINGW_ANSI_STDIO
- #define _ovpn_chk_fmt(a, b) __attribute__ ((format(gnu_printf, (a), (b))))
- #else
- #define _ovpn_chk_fmt(a, b) __attribute__ ((format(__printf__, (a), (b))))
- #endif
- #else
- #define _ovpn_chk_fmt(a, b)
- #endif
- typedef void (*plugin_log_t)(openvpn_plugin_log_flags_t flags,
- const char *plugin_name,
- const char *format, ...) _ovpn_chk_fmt (3, 4);
- typedef void (*plugin_vlog_t)(openvpn_plugin_log_flags_t flags,
- const char *plugin_name,
- const char *format,
- va_list arglist) _ovpn_chk_fmt (3, 0);
- typedef void (*plugin_secure_memzero_t)(void *data, size_t len);
- typedef int (*plugin_base64_encode_t)(const void *data, int size, char **str);
- typedef int (*plugin_base64_decode_t)(const char *str, void *data, int size);
- struct openvpn_plugin_callbacks
- {
- plugin_log_t plugin_log;
- plugin_vlog_t plugin_vlog;
- plugin_secure_memzero_t plugin_secure_memzero;
- plugin_base64_encode_t plugin_base64_encode;
- plugin_base64_decode_t plugin_base64_decode;
- };
- typedef enum {
- SSLAPI_NONE,
- SSLAPI_OPENSSL,
- SSLAPI_MBEDTLS
- } ovpnSSLAPI;
- struct openvpn_plugin_args_open_in
- {
- const int type_mask;
- const char **const argv;
- const char **const envp;
- struct openvpn_plugin_callbacks *callbacks;
- const ovpnSSLAPI ssl_api;
- const char *ovpn_version;
- const unsigned int ovpn_version_major;
- const unsigned int ovpn_version_minor;
- const char *const ovpn_version_patch;
- };
- struct openvpn_plugin_args_open_return
- {
- int type_mask;
- openvpn_plugin_handle_t handle;
- struct openvpn_plugin_string_list **return_list;
- };
- struct openvpn_plugin_args_func_in
- {
- const int type;
- const char **const argv;
- const char **const envp;
- openvpn_plugin_handle_t handle;
- void *per_client_context;
- #ifdef ENABLE_CRYPTO
- int current_cert_depth;
- openvpn_x509_cert_t *current_cert;
- #else
- int __current_cert_depth_disabled;
- void *__current_cert_disabled;
- #endif
- };
- struct openvpn_plugin_args_func_return
- {
- struct openvpn_plugin_string_list **return_list;
- };
- OPENVPN_PLUGIN_DEF openvpn_plugin_handle_t OPENVPN_PLUGIN_FUNC(openvpn_plugin_open_v2)
- (unsigned int *type_mask,
- const char *argv[],
- const char *envp[],
- struct openvpn_plugin_string_list **return_list);
- OPENVPN_PLUGIN_DEF int OPENVPN_PLUGIN_FUNC(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_DEF int OPENVPN_PLUGIN_FUNC(openvpn_plugin_open_v3)
- (const int version,
- struct openvpn_plugin_args_open_in const *arguments,
- struct openvpn_plugin_args_open_return *retptr);
- OPENVPN_PLUGIN_DEF int OPENVPN_PLUGIN_FUNC(openvpn_plugin_func_v3)
- (const int version,
- struct openvpn_plugin_args_func_in const *arguments,
- struct openvpn_plugin_args_func_return *retptr);
- OPENVPN_PLUGIN_DEF void OPENVPN_PLUGIN_FUNC(openvpn_plugin_close_v1)
- (openvpn_plugin_handle_t handle);
- OPENVPN_PLUGIN_DEF void OPENVPN_PLUGIN_FUNC(openvpn_plugin_abort_v1)
- (openvpn_plugin_handle_t handle);
- OPENVPN_PLUGIN_DEF void *OPENVPN_PLUGIN_FUNC(openvpn_plugin_client_constructor_v1)
- (openvpn_plugin_handle_t handle);
- OPENVPN_PLUGIN_DEF void OPENVPN_PLUGIN_FUNC(openvpn_plugin_client_destructor_v1)
- (openvpn_plugin_handle_t handle, void *per_client_context);
- #define OPENVPN_PLUGIN_INIT_PRE_CONFIG_PARSE 1
- #define OPENVPN_PLUGIN_INIT_PRE_DAEMON 2
- #define OPENVPN_PLUGIN_INIT_POST_DAEMON 3
- #define OPENVPN_PLUGIN_INIT_POST_UID_CHANGE 4
- OPENVPN_PLUGIN_DEF int OPENVPN_PLUGIN_FUNC(openvpn_plugin_select_initialization_point_v1)
- (void);
- OPENVPN_PLUGIN_DEF int OPENVPN_PLUGIN_FUNC(openvpn_plugin_min_version_required_v1)
- (void);
- OPENVPN_PLUGIN_DEF openvpn_plugin_handle_t OPENVPN_PLUGIN_FUNC(openvpn_plugin_open_v1)
- (unsigned int *type_mask,
- const char *argv[],
- const char *envp[]);
- OPENVPN_PLUGIN_DEF int OPENVPN_PLUGIN_FUNC(openvpn_plugin_func_v1)
- (openvpn_plugin_handle_t handle, const int type, const char *argv[], const char *envp[]);
- #ifdef __cplusplus
- }
- #endif
- #endif
|