OpenVPN
Functions
Main Event Loop module

This main event loop module drives the packet processing of OpenVPN. More...

Functions

void tunnel_server_tcp (struct context *top)
 Main event loop for OpenVPN in TCP server mode. More...
 
void tunnel_server_udp (struct context *top)
 Main event loop for OpenVPN in UDP server mode. More...
 
void tunnel_server (struct context *top)
 Main event loop for OpenVPN in server mode. More...
 
static void tunnel_point_to_point (struct context *c)
 Main event loop for OpenVPN in client mode, where only one VPN tunnel is active. More...
 
static int openvpn_main (int argc, char *argv[])
 OpenVPN's main init-run-cleanup loop. More...
 

Detailed Description

This main event loop module drives the packet processing of OpenVPN.

OpenVPN is an event driven system. Its activities are driven by a main event loop, which repeatedly waits for one of several predefined events to occur, and then calls the appropriate module to handle the event. The major types of network events that OpenVPN processes are:

Beside these external events, OpenVPN also processes other types of internal events. These include scheduled events, such as resending of non-acknowledged control channel messages.

Main event loop implementations

Depending on the mode in which OpenVPN is running, a different main event loop function is called to drive the event processing. The following implementations are available:

Function Documentation

◆ openvpn_main()

static int openvpn_main ( int  argc,
char *  argv[] 
)
static

OpenVPN's main init-run-cleanup loop.

This function contains the two outer OpenVPN loops. Its structure is as follows:

  • Once-per-process initialization.
  • Outer loop, run at startup and then once per SIGHUP:
    • Level 1 initialization
    • Inner loop, run at startup and then once per SIGUSR1:
    • Level 1 cleanup
  • Once-per-process cleanup.
Parameters
argc- Commandline argument count.
argv- Commandline argument values.

Definition at line 160 of file openvpn.c.

References ASSERT, options::chroot_dir, CLEAR, close_management(), context_clear_all_except_first_time(), context_gc_free(), context_init_1(), context::did_we_daemonize, do_genkey(), do_persist_tuntap(), do_test_crypto(), env_set_create(), env_set_destroy(), context::es, context::first_time, context::gc, gc_init(), gc_reset(), init_early(), init_management(), init_options(), init_options_dev(), init_plugins(), init_query_passwords(), init_static(), init_verb_mute(), IS_SIG, IVM_LEVEL_1, M_INFO, M_USAGE, options::management_flags, MF_QUERY_PASSWORDS, options::mode, MODE_POINT_TO_POINT, MODE_SERVER, msg, context::net_ctx, open_management(), open_plugins(), openvpn_exit(), OPENVPN_EXIT_STATUS_GOOD, OPENVPN_PLUGIN_INIT_PRE_CONFIG_PARSE, OPT_P_DEFAULT, context::options, options_postprocess(), parse_argv(), possibly_become_daemon(), pre_init_signal_catch(), pre_setup(), print_openssl_info(), print_signal(), set_win_sys_path_via_env(), setenv_settings(), show_dco_version(), show_library_versions(), show_settings(), show_windows_version(), context::sig, siginfo_static, signal_reset(), signal_restart_status(), title_string, tunnel_point_to_point(), tunnel_server(), uninit_early(), uninit_options(), uninit_static(), write_pid_file(), and options::writepid.

Referenced by wmain().

◆ tunnel_point_to_point()

static void tunnel_point_to_point ( struct context c)
static

Main event loop for OpenVPN in client mode, where only one VPN tunnel is active.

Parameters
c- The context structure of the single active VPN tunnel.

Definition at line 57 of file openvpn.c.

References context::c2, CC_HARD_USR1_TO_HUP, close_instance(), CM_P2P, context_clear_2(), context::es, ES_TIMEOUT, context_2::event_set_status, init_instance_handle_signals(), io_wait(), IS_SIG, context::mode, P2P_CHECK_SIG, p2p_iow_flags(), PERF_EVENT_LOOP, perf_pop(), perf_push(), persist_client_stats(), pre_select(), process_io(), and uninit_management_callback().

Referenced by openvpn_main().

◆ tunnel_server()

void tunnel_server ( struct context top)

Main event loop for OpenVPN in server mode.

This function calls the appropriate main event loop function depending on the transport protocol used:

Parameters
top- Top-level context structure.

Definition at line 4169 of file multi.c.

References ASSERT, options::ce, options::mode, MODE_SERVER, context::options, connection_entry::proto, proto_is_dgram(), tunnel_server_tcp(), and tunnel_server_udp().

Referenced by openvpn_main().

◆ tunnel_server_tcp()

void tunnel_server_tcp ( struct context top)

◆ tunnel_server_udp()

void tunnel_server_udp ( struct context top)