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.
static void tunnel_server_udp_single_threaded (struct context *top)
 Main event loop for OpenVPN in UDP server mode.
void tunnel_server_udp (struct context *top)
 Main event loop wrapper function for OpenVPN in UDP server mode.
void tunnel_server (struct context *top)
 Main event loop for OpenVPN in server mode.
static void tunnel_point_to_point (struct context *c)
 Main event loop for OpenVPN in client mode, where only one VPN tunnel is active.
static int openvpn_main (int argc, char *argv[])
 OpenVPN's main init-run-cleanup loop.

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

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 133 of file openvpn.c.

References ASSERT, 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_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, open_management(), open_plugins(), openvpn_exit(), OPENVPN_EXIT_STATUS_GOOD, 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_library_versions(), show_settings(), show_windows_version(), context::sig, SIGHUP, siginfo_static, signal_info::signal_received, signal_restart_status(), SIGUSR1, title_string, tunnel_point_to_point(), tunnel_server(), uninit_options(), uninit_static(), write_pid(), and options::writepid.

Referenced by wmain().

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 61 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(), pre_select(), process_io(), and uninit_management_callback().

Referenced by openvpn_main().

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 3370 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().

void tunnel_server_tcp ( struct context top)
void tunnel_server_udp ( struct context top)

Main event loop wrapper function for OpenVPN in UDP server mode.

This function simply calls tunnel_server_udp_single_threaded().

Parameters
top- Top-level context structure.

Definition at line 377 of file mudp.c.

References tunnel_server_udp_single_threaded().

Referenced by tunnel_server().

static void tunnel_server_udp_single_threaded ( struct context top)
static