openvpn_plugin/ffi/
structs.rs

1// Copyright 2023 Mullvad VPN AB.
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9//! Constants for OpenVPN. Taken from include/openvpn-plugin.h in the OpenVPN repository:
10//! https://github.com/OpenVPN/openvpn/blob/master/include/openvpn-plugin.h.in
11
12use std::os::raw::{c_char, c_int, c_uint, c_void};
13
14/// Struct sent to `openvpn_plugin_open_v3` containing input values.
15#[repr(C)]
16pub struct openvpn_plugin_args_open_in {
17    type_mask: c_int,
18    pub argv: *const *const c_char,
19    pub envp: *const *const c_char,
20    callbacks: *const c_void,
21    ssl_api: ovpnSSLAPI,
22    ovpn_version: *const c_char,
23    ovpn_version_major: c_uint,
24    ovpn_version_minor: c_uint,
25    ovpn_version_patch: *const c_char,
26}
27
28#[allow(dead_code)]
29#[repr(C)]
30enum ovpnSSLAPI {
31    None,
32    OpenSsl,
33    MbedTls,
34}
35
36/// Struct used for returning values from `openvpn_plugin_open_v3` to OpenVPN.
37#[repr(C)]
38pub struct openvpn_plugin_args_open_return {
39    pub type_mask: c_int,
40    pub handle: *const c_void,
41    return_list: *const c_void,
42}
43
44/// Struct sent to `openvpn_plugin_func_v3` containing input values.
45#[repr(C)]
46pub struct openvpn_plugin_args_func_in {
47    pub event_type: c_int,
48    pub argv: *const *const c_char,
49    pub envp: *const *const c_char,
50    pub handle: *const c_void,
51    per_client_context: *const c_void,
52    current_cert_depth: c_int,
53    current_cert: *const c_void,
54}
55
56/// Struct used for returning values from `openvpn_plugin_func_v3` to OpenVPN.
57#[repr(C)]
58pub struct openvpn_plugin_args_func_return {
59    return_list: *const c_void,
60}