OpenVPN
Macros | Functions | Variables
init.c File Reference
#include "syshead.h"
#include "win32.h"
#include "init.h"
#include "run_command.h"
#include "sig.h"
#include "occ.h"
#include "list.h"
#include "otime.h"
#include "pool.h"
#include "gremlin.h"
#include "pkcs11.h"
#include "ps.h"
#include "lladdr.h"
#include "ping.h"
#include "mstats.h"
#include "ssl_verify.h"
#include "ssl_ncp.h"
#include "tls_crypt.h"
#include "forward.h"
#include "auth_token.h"
#include "mss.h"
#include "mudp.h"
#include "dco.h"
#include "memdbg.h"
Include dependency graph for init.c:

Go to the source code of this file.

Macros

#define CF_LOAD_PERSISTED_PACKET_ID   (1<<0)
 
#define CF_INIT_TLS_MULTI   (1<<1)
 
#define CF_INIT_TLS_AUTH_STANDALONE   (1<<2)
 

Functions

static void do_init_first_time (struct context *c)
 
static bool do_deferred_p2p_ncp (struct context *c)
 
void context_clear (struct context *c)
 
void context_clear_1 (struct context *c)
 
void context_clear_2 (struct context *c)
 
void context_clear_all_except_first_time (struct context *c)
 
static void run_up_down (const char *command, const struct plugin_list *plugins, int plugin_type, const char *arg, DWORD adapter_index, const char *dev_type, int tun_mtu, const char *ifconfig_local, const char *ifconfig_remote, const char *context, const char *signal_text, const char *script_type, struct env_set *es)
 
static void update_options_ce_post (struct options *options)
 
static bool management_callback_proxy_cmd (void *arg, const char **p)
 
static bool ce_management_query_proxy (struct context *c)
 
static bool management_callback_send_cc_message (void *arg, const char *command, const char *parameters)
 This method sends a custom control channel message. More...
 
static unsigned int management_callback_remote_entry_count (void *arg)
 
static bool management_callback_remote_entry_get (void *arg, unsigned int index, char **remote)
 
static bool management_callback_remote_cmd (void *arg, const char **p)
 
static bool ce_management_query_remote (struct context *c)
 
static void init_connection_list (struct context *c)
 
static void clear_remote_addrlist (struct link_socket_addr *lsa, bool free)
 
static void next_connection_entry (struct context *c)
 
void init_query_passwords (const struct context *c)
 Query for private key and auth-user-pass username/passwords. More...
 
static void uninit_proxy_dowork (struct context *c)
 
static void init_proxy_dowork (struct context *c)
 
static void init_proxy (struct context *c)
 
static void uninit_proxy (struct context *c)
 
void context_init_1 (struct context *c)
 
void context_gc_free (struct context *c)
 
bool init_static (void)
 
void uninit_static (void)
 
void init_verb_mute (struct context *c, unsigned int flags)
 
void init_options_dev (struct options *options)
 
bool print_openssl_info (const struct options *options)
 
bool do_genkey (const struct options *options)
 
bool do_persist_tuntap (struct options *options, openvpn_net_ctx_t *ctx)
 
bool possibly_become_daemon (const struct options *options)
 
static void do_uid_gid_chroot (struct context *c, bool no_delay)
 
const char * format_common_name (struct context *c, struct gc_arena *gc)
 
void pre_setup (const struct options *options)
 
void reset_coarse_timers (struct context *c)
 
static void do_init_server_poll_timeout (struct context *c)
 
static void do_init_timers (struct context *c, bool deferred)
 
static void do_init_traffic_shaper (struct context *c)
 
static void do_alloc_route_list (struct context *c)
 
static void do_init_route_list (const struct options *options, struct route_list *route_list, const struct link_socket_info *link_socket_info, struct env_set *es, openvpn_net_ctx_t *ctx)
 
static void do_init_route_ipv6_list (const struct options *options, struct route_ipv6_list *route_ipv6_list, const struct link_socket_info *link_socket_info, struct env_set *es, openvpn_net_ctx_t *ctx)
 
void initialization_sequence_completed (struct context *c, const unsigned int flags)
 
bool do_route (const struct options *options, struct route_list *route_list, struct route_ipv6_list *route_ipv6_list, const struct tuntap *tt, const struct plugin_list *plugins, struct env_set *es, openvpn_net_ctx_t *ctx)
 
static void do_init_tun (struct context *c)
 
static bool can_preserve_tun (struct tuntap *tt)
 
static bool do_open_tun (struct context *c, int *error_flags)
 
static void do_close_tun_simple (struct context *c)
 
static void do_close_tun (struct context *c, bool force)
 
void tun_abort (void)
 
static bool options_hash_changed_or_zero (const struct sha256_digest *a, const struct sha256_digest *b)
 Helper for do_up(). More...
 
static bool p2p_set_dco_keepalive (struct context *c)
 
static void add_delim_if_non_empty (struct buffer *buf, const char *header)
 Helper function for tls_print_deferred_options_results Adds the ", " delimitor if there already some data in the buffer. More...
 
static void tls_print_deferred_options_results (struct context *c)
 Prints the results of options imported for the data channel. More...
 
static bool do_deferred_options_part2 (struct context *c)
 This function is expected to be invoked after open_tun() was performed. More...
 
bool do_up (struct context *c, bool pulled_options, unsigned int option_types_found)
 
unsigned int pull_permission_mask (const struct context *c)
 
bool do_deferred_options (struct context *c, const unsigned int found)
 
static bool do_hold (int holdtime)
 
static void socket_restart_pause (struct context *c)
 
static void do_startup_pause (struct context *c)
 
static size_t get_frame_mtu (struct context *c, const struct options *o)
 
static void frame_finalize_options (struct context *c, const struct options *o)
 
static void key_schedule_free (struct key_schedule *ks, bool free_ssl_ctx)
 
static void init_crypto_pre (struct context *c, const unsigned int flags)
 
static void do_init_crypto_static (struct context *c, const unsigned int flags)
 
static void do_init_tls_wrap_key (struct context *c)
 
static void do_init_crypto_tls_c1 (struct context *c)
 
static void do_init_crypto_tls (struct context *c, const unsigned int flags)
 
static void do_init_frame_tls (struct context *c)
 
static void do_init_crypto_none (struct context *c)
 
static void do_init_crypto (struct context *c, const unsigned int flags)
 
static void do_init_frame (struct context *c)
 
static void do_option_warnings (struct context *c)
 
struct context_buffersinit_context_buffers (const struct frame *frame)
 
void free_context_buffers (struct context_buffers *b)
 
static void do_init_buffers (struct context *c)
 
static void do_init_fragment (struct context *c)
 
static void do_link_socket_new (struct context *c)
 
static void do_print_data_channel_mtu_parms (struct context *c)
 
static void do_compute_occ_strings (struct context *c)
 
static void do_close_free_buf (struct context *c)
 
static void do_close_tls (struct context *c)
 
static void do_close_free_key_schedule (struct context *c, bool free_ssl_ctx)
 
static void do_close_link_socket (struct context *c)
 
static void do_close_packet_id (struct context *c)
 
static void do_close_fragment (struct context *c)
 
static void do_event_set_init (struct context *c, bool need_us_timeout)
 
static void do_close_event_set (struct context *c)
 
static void do_open_status_output (struct context *c)
 
static void do_close_status_output (struct context *c)
 
static void do_open_ifconfig_pool_persist (struct context *c)
 
static void do_close_ifconfig_pool_persist (struct context *c)
 
static void do_inherit_env (struct context *c, const struct env_set *src)
 
static void do_env_set_destroy (struct context *c)
 
static void do_setup_fast_io (struct context *c)
 
static void do_signal_on_tls_errors (struct context *c)
 
void init_plugins (struct context *c)
 
void open_plugins (struct context *c, const bool import_options, int init_point)
 
static void do_close_plugins (struct context *c)
 
static void do_inherit_plugins (struct context *c, const struct context *src)
 
static void management_callback_status_p2p (void *arg, const int version, struct status_output *so)
 
void management_show_net_callback (void *arg, const int msglevel)
 
void init_management_callback_p2p (struct context *c)
 
void init_management (void)
 
bool open_management (struct context *c)
 
void close_management (void)
 
void uninit_management_callback (void)
 
void persist_client_stats (struct context *c)
 
void init_instance_handle_signals (struct context *c, const struct env_set *env, const unsigned int flags)
 
void init_instance (struct context *c, const struct env_set *env, const unsigned int flags)
 
void close_instance (struct context *c)
 
void inherit_context_child (struct context *dest, const struct context *src)
 
void inherit_context_top (struct context *dest, const struct context *src)
 
void close_context (struct context *c, int sig, unsigned int flags)
 
void write_pid_file (const char *filename, const char *chroot_dir)
 
void remove_pid_file (void)
 
static void * test_crypto_thread (void *arg)
 
bool do_test_crypto (const struct options *o)
 

Variables

static struct contextstatic_context
 
static const char * saved_pid_file_name
 

Macro Definition Documentation

◆ CF_INIT_TLS_AUTH_STANDALONE

#define CF_INIT_TLS_AUTH_STANDALONE   (1<<2)

Definition at line 69 of file init.c.

◆ CF_INIT_TLS_MULTI

#define CF_INIT_TLS_MULTI   (1<<1)

Definition at line 68 of file init.c.

◆ CF_LOAD_PERSISTED_PACKET_ID

#define CF_LOAD_PERSISTED_PACKET_ID   (1<<0)

Definition at line 67 of file init.c.

Function Documentation

◆ add_delim_if_non_empty()

static void add_delim_if_non_empty ( struct buffer buf,
const char *  header 
)
static

Helper function for tls_print_deferred_options_results Adds the ", " delimitor if there already some data in the buffer.

Definition at line 2203 of file init.c.

References buf_len(), and buf_printf().

Referenced by tls_print_deferred_options_results().

◆ can_preserve_tun()

static bool can_preserve_tun ( struct tuntap tt)
static

Definition at line 1787 of file init.c.

References is_tun_type_set().

Referenced by do_open_tun().

◆ ce_management_query_proxy()

static bool ce_management_query_proxy ( struct context c)
static

◆ ce_management_query_remote()

static bool ce_management_query_remote ( struct context c)
static

◆ clear_remote_addrlist()

static void clear_remote_addrlist ( struct link_socket_addr lsa,
bool  free 
)
static

◆ close_context()

void close_context ( struct context c,
int  sig,
unsigned int  flags 
)

◆ close_instance()

void close_instance ( struct context c)

◆ close_management()

void close_management ( void  )

Definition at line 4347 of file init.c.

References management_close().

Referenced by open_management(), and openvpn_main().

◆ context_clear()

void context_clear ( struct context c)

Definition at line 76 of file init.c.

References CLEAR.

Referenced by context_clear_all_except_first_time(), and do_test_crypto().

◆ context_clear_1()

void context_clear_1 ( struct context c)

Definition at line 82 of file init.c.

References context::c1, and CLEAR.

Referenced by context_init_1().

◆ context_clear_2()

void context_clear_2 ( struct context c)

Definition at line 88 of file init.c.

References context::c2, and CLEAR.

Referenced by tunnel_point_to_point(), tunnel_server_tcp(), and tunnel_server_udp().

◆ context_clear_all_except_first_time()

void context_clear_all_except_first_time ( struct context c)

Definition at line 94 of file init.c.

References context_clear(), context::first_time, and context::persist.

Referenced by openvpn_main().

◆ context_gc_free()

void context_gc_free ( struct context c)

◆ context_init_1()

void context_init_1 ( struct context c)

◆ do_alloc_route_list()

static void do_alloc_route_list ( struct context c)
static

◆ do_close_event_set()

static void do_close_event_set ( struct context c)
static

Definition at line 3986 of file init.c.

References context::c2, event_free(), context_2::event_set, and context_2::event_set_owned.

Referenced by close_instance().

◆ do_close_fragment()

static void do_close_fragment ( struct context c)
static

Definition at line 3952 of file init.c.

References context::c2, context_2::fragment, and fragment_free().

Referenced by close_instance().

◆ do_close_free_buf()

static void do_close_free_buf ( struct context c)
static

Definition at line 3821 of file init.c.

References context_2::buffers, context_2::buffers_owned, context::c2, and free_context_buffers().

Referenced by close_instance().

◆ do_close_free_key_schedule()

static void do_close_free_key_schedule ( struct context c,
bool  free_ssl_ctx 
)
static

◆ do_close_ifconfig_pool_persist()

static void do_close_ifconfig_pool_persist ( struct context c)
static

◆ do_close_link_socket()

static void do_close_link_socket ( struct context c)
static

◆ do_close_packet_id()

static void do_close_packet_id ( struct context c)
static

◆ do_close_plugins()

static void do_close_plugins ( struct context c)
static

◆ do_close_status_output()

static void do_close_status_output ( struct context c)
static

◆ do_close_tls()

static void do_close_tls ( struct context c)
static

◆ do_close_tun()

static void do_close_tun ( struct context c,
bool  force 
)
static

◆ do_close_tun_simple()

static void do_close_tun_simple ( struct context c)
static

◆ do_compute_occ_strings()

static void do_compute_occ_strings ( struct context c)
static

◆ do_deferred_options()

bool do_deferred_options ( struct context c,
const unsigned int  found 
)

◆ do_deferred_options_part2()

static bool do_deferred_options_part2 ( struct context c)
static

This function is expected to be invoked after open_tun() was performed.

This kind of behaviour is required by DCO, because the following operations can be done only after the DCO device was created and the new peer was properly added.

Definition at line 2343 of file init.c.

References context::c2, options::ce, D_TLS_ERRORS, connection_entry::fragment, context_2::frame, context_2::frame_fragment, get_link_socket_info(), msg, context::options, tls_multi::session, context_2::tls_multi, tls_session_update_crypto_params(), and TM_ACTIVE.

Referenced by do_up().

◆ do_deferred_p2p_ncp()

static bool do_deferred_p2p_ncp ( struct context c)
static

◆ do_env_set_destroy()

static void do_env_set_destroy ( struct context c)
static

Definition at line 4069 of file init.c.

References context::c2, env_set_destroy(), context_2::es, and context_2::es_owned.

Referenced by close_instance().

◆ do_event_set_init()

static void do_event_set_init ( struct context c,
bool  need_us_timeout 
)
static

◆ do_genkey()

bool do_genkey ( const struct options options)

◆ do_hold()

static bool do_hold ( int  holdtime)
static

Definition at line 2725 of file init.c.

References management_hold().

Referenced by do_startup_pause(), open_management(), and socket_restart_pause().

◆ do_inherit_env()

static void do_inherit_env ( struct context c,
const struct env_set src 
)
static

Definition at line 4061 of file init.c.

References context::c2, env_set_create(), env_set_inherit(), context_2::es, and context_2::es_owned.

Referenced by init_instance().

◆ do_inherit_plugins()

static void do_inherit_plugins ( struct context c,
const struct context src 
)
static

Definition at line 4188 of file init.c.

References plugin_list_inherit(), context::plugins, and context::plugins_owned.

Referenced by inherit_context_child().

◆ do_init_buffers()

static void do_init_buffers ( struct context c)
static

◆ do_init_crypto()

static void do_init_crypto ( struct context c,
const unsigned int  flags 
)
static

◆ do_init_crypto_none()

static void do_init_crypto_none ( struct context c)
static

◆ do_init_crypto_static()

static void do_init_crypto_static ( struct context c,
const unsigned int  flags 
)
static

◆ do_init_crypto_tls()

static void do_init_crypto_tls ( struct context c,
const unsigned int  flags 
)
static

Definition at line 3211 of file init.c.

References ASSERT, tls_options::auth_token_call_auth, options::auth_token_call_auth, tls_options::auth_token_generate, options::auth_token_generate, key_schedule::auth_token_key, tls_options::auth_token_key, tls_options::auth_token_lifetime, options::auth_token_lifetime, tls_options::auth_token_renewal, options::auth_token_renewal, tls_options::auth_user_pass_file, options::auth_user_pass_file, tls_options::auth_user_pass_file_inline, options::auth_user_pass_file_inline, tls_options::auth_user_pass_verify_script, options::auth_user_pass_verify_script, tls_options::auth_user_pass_verify_script_via_file, options::auth_user_pass_verify_script_via_file, context::c1, context::c2, options::ccd_exclusive, options::ce, CF_INIT_TLS_AUTH_STANDALONE, CF_INIT_TLS_MULTI, key_type::cipher, cipher_kt_mode_ofb_cfb(), options::ciphername, CLEAR, options::client_config_dir, tls_options::client_config_dir_exclusive, tls_options::client_crresponse_script, options::client_crresponse_script, CO_FORCE_TLSCRYPTV2_COOKIE, CO_MUTE_REPLAY_WARNINGS, CO_PACKET_ID_LONG_FORM, options::comp, tls_options::config_ciphername, tls_options::config_ncp_ciphers, tls_options::crl_file, options::crl_file, tls_options::crl_file_inline, options::crl_file_inline, tls_options::crypto_flags, tuntap::dco, tls_multi::dco, tls_options::dco_enabled, dco_enabled(), do_init_crypto_tls_c1(), tls_options::ekm_label, tls_options::ekm_label_size, tls_options::ekm_size, tls_options::es, context_2::es, tls_options::export_peer_cert_dir, crypto_options::flags, context_2::gc, get_random(), tls_options::gremlin, tls_options::handshake_window, options::handshake_window, init_crypto_pre(), IS_SIG, crypto_options::key_ctx_bi, key_schedule::key_type, tls_options::key_type, context_1::ks, link_socket_proto_connection_oriented(), max_int(), tls_options::mda_context, context_2::mda_context, options::mode, tls_wrap_ctx::mode, tls_options::mode, MODE_SERVER, options::mute_replay_warnings, options::ncp_ciphers, tls_options::net_ctx, context::net_ctx, tls_options::ns_cert_type, options::ns_cert_type, tls_wrap_ctx::opt, context::options, key_schedule::original_wrap_keydata, tls_wrap_ctx::original_wrap_keydata, tls_options::packet_timeout, context_1::pid_persist, crypto_options::pid_persist, tls_options::plugins, context::plugins, connection_entry::proto, PROTO_TCP_SERVER, tls_options::pull, options::pull, options::push_peer_info, tls_options::push_peer_info_detail, tls_options::remote_cert_eku, options::remote_cert_eku, tls_options::remote_cert_ku, options::remote_cert_ku, tls_options::renegotiate_bytes, options::renegotiate_bytes, tls_options::renegotiate_packets, options::renegotiate_packets, tls_options::renegotiate_seconds, options::renegotiate_seconds, options::renegotiate_seconds_min, tls_options::replay_time, options::replay_time, tls_options::replay_window, options::replay_window, options::sc_info, tls_options::sci, tls_options::server, context_2::session_id_hmac, session_id_hmac_init(), tls_options::single_session, options::single_session, key_schedule::ssl_ctx, tls_options::ssl_ctx, tls_options::ssl_flags, options::ssl_flags, tls_options::tcp_mode, options::test_crypto, connection_entry::tls_auth_file, context_2::tls_auth_standalone, tls_auth_standalone_init(), options::tls_client, connection_entry::tls_crypt_file, tls_options::tls_crypt_v2, connection_entry::tls_crypt_v2_file, connection_entry::tls_crypt_v2_force_cookie, key_schedule::tls_crypt_v2_server_key, tls_wrap_ctx::tls_crypt_v2_server_key, tls_options::tls_crypt_v2_verify_script, options::tls_crypt_v2_verify_script, key_schedule::tls_crypt_v2_wkc, tls_wrap_ctx::tls_crypt_v2_wkc, options::tls_export_peer_cert_dir, context_2::tls_multi, tls_multi_init(), options::tls_server, options::tls_timeout, options::tls_verify, tls_options::tls_wrap, key_schedule::tls_wrap_key, tls_options::tmp_dir, options::tmp_dir, tls_options::transition_window, options::transition_window, context_1::tuntap, tls_options::verify_command, tls_options::verify_hash, options::verify_hash, tls_options::verify_hash_algo, options::verify_hash_algo, tls_options::verify_hash_depth, options::verify_hash_depth, tls_options::verify_hash_no_ca, options::verify_hash_no_ca, tls_options::verify_x509_name, options::verify_x509_name, tls_options::verify_x509_type, options::verify_x509_type, tls_options::x509_track, options::x509_track, tls_options::x509_username_field, X509_USERNAME_FIELD_DEFAULT, and tls_options::xmit_hold.

Referenced by do_init_crypto().

◆ do_init_crypto_tls_c1()

static void do_init_crypto_tls_c1 ( struct context c)
static

◆ do_init_first_time()

static void do_init_first_time ( struct context c)
static

◆ do_init_fragment()

static void do_init_fragment ( struct context c)
static

◆ do_init_frame()

static void do_init_frame ( struct context c)
static

◆ do_init_frame_tls()

static void do_init_frame_tls ( struct context c)
static

◆ do_init_route_ipv6_list()

static void do_init_route_ipv6_list ( const struct options options,
struct route_ipv6_list route_ipv6_list,
const struct link_socket_info link_socket_info,
struct env_set es,
openvpn_net_ctx_t ctx 
)
static

◆ do_init_route_list()

static void do_init_route_list ( const struct options options,
struct route_list route_list,
const struct link_socket_info link_socket_info,
struct env_set es,
openvpn_net_ctx_t ctx 
)
static

◆ do_init_server_poll_timeout()

static void do_init_server_poll_timeout ( struct context c)
static

◆ do_init_timers()

static void do_init_timers ( struct context c,
bool  deferred 
)
static

◆ do_init_tls_wrap_key()

static void do_init_tls_wrap_key ( struct context c)
static

◆ do_init_traffic_shaper()

static void do_init_traffic_shaper ( struct context c)
static

◆ do_init_tun()

static void do_init_tun ( struct context c)
static

◆ do_link_socket_new()

static void do_link_socket_new ( struct context c)
static

◆ do_open_ifconfig_pool_persist()

static void do_open_ifconfig_pool_persist ( struct context c)
static

◆ do_open_status_output()

static void do_open_status_output ( struct context c)
static

◆ do_open_tun()

static bool do_open_tun ( struct context c,
int *  error_flags 
)
static

◆ do_option_warnings()

static void do_option_warnings ( struct context c)
static

◆ do_persist_tuntap()

bool do_persist_tuntap ( struct options options,
openvpn_net_ctx_t ctx 
)

◆ do_print_data_channel_mtu_parms()

static void do_print_data_channel_mtu_parms ( struct context c)
static

◆ do_route()

bool do_route ( const struct options options,
struct route_list route_list,
struct route_ipv6_list route_ipv6_list,
const struct tuntap tt,
const struct plugin_list plugins,
struct env_set es,
openvpn_net_ctx_t ctx 
)

◆ do_setup_fast_io()

static void do_setup_fast_io ( struct context c)
static

◆ do_signal_on_tls_errors()

static void do_signal_on_tls_errors ( struct context c)
static

Definition at line 4115 of file init.c.

References context::c2, context::options, options::tls_exit, and context_2::tls_exit_signal.

Referenced by init_instance().

◆ do_startup_pause()

static void do_startup_pause ( struct context c)
static

Definition at line 2822 of file init.c.

References do_hold(), context::first_time, and socket_restart_pause().

Referenced by init_instance().

◆ do_test_crypto()

bool do_test_crypto ( const struct options o)

◆ do_uid_gid_chroot()

static void do_uid_gid_chroot ( struct context c,
bool  no_delay 
)
static

◆ do_up()

bool do_up ( struct context c,
bool  pulled_options,
unsigned int  option_types_found 
)

◆ format_common_name()

const char* format_common_name ( struct context c,
struct gc_arena gc 
)

◆ frame_finalize_options()

static void frame_finalize_options ( struct context c,
const struct options o 
)
static

◆ free_context_buffers()

void free_context_buffers ( struct context_buffers b)

◆ get_frame_mtu()

static size_t get_frame_mtu ( struct context c,
const struct options o 
)
static

◆ inherit_context_child()

void inherit_context_child ( struct context dest,
const struct context src 
)

◆ inherit_context_top()

void inherit_context_top ( struct context dest,
const struct context src 
)

◆ init_connection_list()

static void init_connection_list ( struct context c)
static

◆ init_context_buffers()

struct context_buffers* init_context_buffers ( const struct frame frame)

◆ init_crypto_pre()

static void init_crypto_pre ( struct context c,
const unsigned int  flags 
)
static

◆ init_instance()

void init_instance ( struct context c,
const struct env_set env,
const unsigned int  flags 
)

Definition at line 4408 of file init.c.

References AR_INTERACT, auth_retry_get(), context::c1, context::c2, options::ce, CF_INIT_TLS_AUTH_STANDALONE, CF_INIT_TLS_MULTI, CF_LOAD_PERSISTED_PACKET_ID, close_context(), CM_CHILD_TCP, CM_CHILD_UDP, CM_P2P, CM_TOP, options::comp, context_2::did_open_tun, do_compute_occ_strings(), do_event_set_init(), do_inherit_env(), do_init_buffers(), do_init_crypto(), do_init_first_time(), do_init_fragment(), do_init_frame(), do_init_frame_tls(), do_init_server_poll_timeout(), do_init_timers(), do_init_traffic_shaper(), do_link_socket_new(), do_open_ifconfig_pool_persist(), do_open_status_output(), do_open_tun(), do_option_warnings(), do_preresolve(), do_print_data_channel_mtu_parms(), do_setup_fast_io(), do_signal_on_tls_errors(), do_startup_pause(), do_uid_gid_chroot(), context::first_time, connection_entry::fragment, context_2::fragment, fragment_init(), context_2::frame, frame_calculate_dynamic(), context_2::gc, gc_init(), get_link_socket_info(), init_management_callback_p2p(), init_proxy(), init_query_passwords(), init_verb_mute(), IS_SIG, IVM_LEVEL_2, key_schedule::key_type, context_1::ks, link_socket_init_phase1(), link_socket_init_phase2(), LS_MODE_DEFAULT, LS_MODE_TCP_ACCEPT_FROM, LS_MODE_TCP_LISTEN, options::mlock, context::mode, next_connection_entry(), context_2::occ_op, occ_reset_op(), open_plugins(), OPENVPN_PLUGIN_INIT_POST_DAEMON, OPENVPN_PLUGIN_INIT_POST_UID_CHANGE, OPENVPN_PLUGIN_INIT_PRE_DAEMON, context::options, P2P_ERROR_DELAY_MS, platform_mlockall(), pre_connect_restore(), connection_entry::proto, PROTO_TCP_SERVER, PULL_DEFINED, options::resolve_in_advance, set_check_status_error_delay(), SHAPER_DEFINED, context::sig, signal_info::signal_text, and options::up_delay.

Referenced by inherit_context_child(), and init_instance_handle_signals().

◆ init_instance_handle_signals()

void init_instance_handle_signals ( struct context c,
const struct env_set env,
const unsigned int  flags 
)

◆ init_management()

void init_management ( void  )

Definition at line 4288 of file init.c.

References management_init().

Referenced by openvpn_main().

◆ init_management_callback_p2p()

void init_management_callback_p2p ( struct context c)

◆ init_options_dev()

void init_options_dev ( struct options options)

Definition at line 972 of file init.c.

References basename(), options::dev, options::dev_node, and string_alloc().

Referenced by openvpn_main().

◆ init_plugins()

void init_plugins ( struct context c)

◆ init_proxy()

static void init_proxy ( struct context c)
static

Definition at line 722 of file init.c.

References init_proxy_dowork().

Referenced by init_instance().

◆ init_proxy_dowork()

static void init_proxy_dowork ( struct context c)
static

◆ init_query_passwords()

void init_query_passwords ( const struct context c)

◆ init_static()

bool init_static ( void  )

◆ init_verb_mute()

void init_verb_mute ( struct context c,
unsigned int  flags 
)

◆ initialization_sequence_completed()

void initialization_sequence_completed ( struct context c,
const unsigned int  flags 
)

◆ key_schedule_free()

static void key_schedule_free ( struct key_schedule ks,
bool  free_ssl_ctx 
)
static

◆ management_callback_proxy_cmd()

static bool management_callback_proxy_cmd ( void *  arg,
const char **  p 
)
static

◆ management_callback_remote_cmd()

static bool management_callback_remote_cmd ( void *  arg,
const char **  p 
)
static

◆ management_callback_remote_entry_count()

static unsigned int management_callback_remote_entry_count ( void *  arg)
static

Definition at line 337 of file init.c.

References options::connection_list, connection_list::len, and context::options.

Referenced by init_management_callback_p2p().

◆ management_callback_remote_entry_get()

static bool management_callback_remote_entry_get ( void *  arg,
unsigned int  index,
char **  remote 
)
static

◆ management_callback_send_cc_message()

static bool management_callback_send_cc_message ( void *  arg,
const char *  command,
const char *  parameters 
)
static

This method sends a custom control channel message.

This will write the control message

command parm1,parm2,..to the control channel.

Parameters
argThe context struct
commandThe command being sent
parametersthe parameters to the command
Returns
if sending was successful

Definition at line 312 of file init.c.

References alloc_buf_gc(), ASSERT, BSTR, buf_printf(), D_PUSH, gc_free(), gc_new(), buffer::len, PUSH_BUNDLE_SIZE, send_control_channel_string(), and status.

Referenced by init_management_callback_p2p().

◆ management_callback_status_p2p()

static void management_callback_status_p2p ( void *  arg,
const int  version,
struct status_output so 
)
static

Definition at line 4202 of file init.c.

References print_status().

Referenced by init_management_callback_p2p().

◆ management_show_net_callback()

void management_show_net_callback ( void *  arg,
const int  msglevel 
)

Definition at line 4209 of file init.c.

References msg, show_adapters(), and show_routes().

Referenced by init_management_callback_multi(), and init_management_callback_p2p().

◆ next_connection_entry()

static void next_connection_entry ( struct context c)
static

◆ open_management()

bool open_management ( struct context c)

◆ open_plugins()

void open_plugins ( struct context c,
const bool  import_options,
int  init_point 
)

◆ options_hash_changed_or_zero()

static bool options_hash_changed_or_zero ( const struct sha256_digest a,
const struct sha256_digest b 
)
static

Helper for do_up().

Take two option hashes and return true if they are not equal, or either one is all-zeroes.

Definition at line 2168 of file init.c.

Referenced by do_up().

◆ p2p_set_dco_keepalive()

static bool p2p_set_dco_keepalive ( struct context c)
static

◆ persist_client_stats()

void persist_client_stats ( struct context c)

Definition at line 4371 of file init.c.

References man_persist_client_stats().

Referenced by tunnel_point_to_point().

◆ possibly_become_daemon()

bool possibly_become_daemon ( const struct options options)

Definition at line 1167 of file init.c.

References daemon(), options::daemon, options::log, M_ERR, msg, restore_signal_state(), and set_std_files_to_null().

Referenced by openvpn_main().

◆ pre_setup()

void pre_setup ( const struct options options)

◆ print_openssl_info()

bool print_openssl_info ( const struct options options)

◆ pull_permission_mask()

unsigned int pull_permission_mask ( const struct context c)

◆ remove_pid_file()

void remove_pid_file ( void  )

Definition at line 4978 of file init.c.

References platform_unlink(), and saved_pid_file_name.

Referenced by openvpn_exit().

◆ reset_coarse_timers()

void reset_coarse_timers ( struct context c)

◆ run_up_down()

static void run_up_down ( const char *  command,
const struct plugin_list plugins,
int  plugin_type,
const char *  arg,
DWORD  adapter_index,
const char *  dev_type,
int  tun_mtu,
const char *  ifconfig_local,
const char *  ifconfig_remote,
const char *  context,
const char *  signal_text,
const char *  script_type,
struct env_set es 
)
static

◆ socket_restart_pause()

static void socket_restart_pause ( struct context c)
static

◆ test_crypto_thread()

static void* test_crypto_thread ( void *  arg)
static

◆ tls_print_deferred_options_results()

static void tls_print_deferred_options_results ( struct context c)
static

◆ tun_abort()

void tun_abort ( void  )

Definition at line 2149 of file init.c.

References do_close_tun(), and static_context.

Referenced by openvpn_exit().

◆ uninit_management_callback()

void uninit_management_callback ( void  )

◆ uninit_proxy()

static void uninit_proxy ( struct context c)
static

Definition at line 728 of file init.c.

References uninit_proxy_dowork().

Referenced by close_instance().

◆ uninit_proxy_dowork()

static void uninit_proxy_dowork ( struct context c)
static

◆ uninit_static()

void uninit_static ( void  )

Definition at line 931 of file init.c.

References free_ssl_lib().

Referenced by openvpn_main().

◆ update_options_ce_post()

static void update_options_ce_post ( struct options options)
static

◆ write_pid_file()

void write_pid_file ( const char *  filename,
const char *  chroot_dir 
)

Definition at line 4948 of file init.c.

References options::chroot_dir, M_ERR, msg, platform_fopen(), platform_getpid(), and saved_pid_file_name.

Referenced by openvpn_main().

Variable Documentation

◆ saved_pid_file_name

const char* saved_pid_file_name
static

Definition at line 62 of file init.c.

Referenced by remove_pid_file(), and write_pid_file().

◆ static_context

struct context* static_context
static

Definition at line 61 of file init.c.

Referenced by do_close_tun(), do_open_tun(), and tun_abort().