OpenVPN
|
#include "basic.h"
#include "common.h"
#include "mtu.h"
#include "route.h"
#include "tun.h"
#include "socket.h"
#include "plugin.h"
#include "manage.h"
#include "proxy.h"
#include "comp.h"
#include "pushlist.h"
#include "clinat.h"
#include "crypto_backend.h"
#include "dns.h"
Go to the source code of this file.
Data Structures | |
struct | options_pre_connect |
struct | connection_entry |
struct | remote_entry |
struct | connection_list |
struct | remote_list |
struct | provider_list |
struct | remote_host_store |
struct | verify_hash_list |
struct | options |
Macros | |
#define | MAX_PARMS 16 |
#define | OPTION_PARM_SIZE 256 |
#define | OPTION_LINE_SIZE 256 |
#define | CE_DISABLED (1<<0) |
#define | CE_MAN_QUERY_PROXY (1<<1) |
#define | CE_MAN_QUERY_REMOTE_UNDEF 0 |
#define | CE_MAN_QUERY_REMOTE_QUERY 1 |
#define | CE_MAN_QUERY_REMOTE_ACCEPT 2 |
#define | CE_MAN_QUERY_REMOTE_MOD 3 |
#define | CE_MAN_QUERY_REMOTE_SKIP 4 |
#define | CE_MAN_QUERY_REMOTE_MASK (0x07) |
#define | CE_MAN_QUERY_REMOTE_SHIFT (2) |
#define | CONNECTION_LIST_SIZE 64 |
#define | RH_HOST_LEN 80 |
#define | RH_PORT_LEN 20 |
#define | MODE_POINT_TO_POINT 0 |
#define | MODE_SERVER 1 |
#define | PING_UNDEF 0 |
#define | PING_EXIT 1 |
#define | PING_RESTART 2 |
#define | SF_NOPOOL (1<<0) |
#define | SF_TCP_NODELAY_HELPER (1<<1) |
#define | SF_NO_PUSH_ROUTE_GATEWAY (1<<2) |
#define | streq(x, y) (!strcmp((x), (y))) |
#define | OPT_P_GENERAL (1<<0) |
#define | OPT_P_UP (1<<1) |
#define | OPT_P_ROUTE (1<<2) |
#define | OPT_P_DHCPDNS (1<<3) /* includes ip windows options like */ |
#define | OPT_P_SCRIPT (1<<4) |
#define | OPT_P_SETENV (1<<5) |
#define | OPT_P_SHAPER (1<<6) |
#define | OPT_P_TIMER (1<<7) |
#define | OPT_P_PERSIST (1<<8) |
#define | OPT_P_PERSIST_IP (1<<9) |
#define | OPT_P_COMP (1<<10) /* TODO */ |
#define | OPT_P_MESSAGES (1<<11) |
#define | OPT_P_NCP (1<<12) |
Negotiable crypto parameters. More... | |
#define | OPT_P_TLS_PARMS (1<<13) /* TODO */ |
#define | OPT_P_MTU (1<<14) /* TODO */ |
#define | OPT_P_NICE (1<<15) |
#define | OPT_P_PUSH (1<<16) |
#define | OPT_P_INSTANCE (1<<17) |
allowed in ccd, client-connect etc More... | |
#define | OPT_P_CONFIG (1<<18) |
#define | OPT_P_EXPLICIT_NOTIFY (1<<19) |
#define | OPT_P_ECHO (1<<20) |
#define | OPT_P_INHERIT (1<<21) |
#define | OPT_P_ROUTE_EXTRAS (1<<22) |
#define | OPT_P_PULL_MODE (1<<23) |
#define | OPT_P_PLUGIN (1<<24) |
#define | OPT_P_SOCKBUF (1<<25) |
#define | OPT_P_SOCKFLAGS (1<<26) |
#define | OPT_P_CONNECTION (1<<27) |
#define | OPT_P_PEER_ID (1<<28) |
#define | OPT_P_INLINE (1<<29) |
#define | OPT_P_PUSH_MTU (1<<30) |
#define | OPT_P_DEFAULT (~(OPT_P_INSTANCE|OPT_P_PULL_MODE)) |
#define | PULL_DEFINED(opt) ((opt)->pull) |
#define | PUSH_DEFINED(opt) ((opt)->push_list) |
#define | ROUTE_OPTION_FLAGS(o) ((o)->route_method & ROUTE_METHOD_MASK) |
#define | SHAPER_DEFINED(opt) ((opt)->shaper) |
#define | PLUGIN_OPTION_LIST(opt) ((opt)->plugin_list) |
#define | MAN_CLIENT_AUTH_ENABLED(opt) ((opt)->management_flags & MF_CLIENT_AUTH) |
#define | AR_NONE 0 |
#define | AR_INTERACT 1 |
#define | AR_NOINTERACT 2 |
Enumerations | |
enum | vlan_acceptable_frames { VLAN_ONLY_TAGGED, VLAN_ONLY_UNTAGGED_OR_PRIORITY, VLAN_ALL } |
enum | genkey_type { GENKEY_SECRET, GENKEY_TLS_CRYPTV2_CLIENT, GENKEY_TLS_CRYPTV2_SERVER, GENKEY_AUTH_TOKEN } |
Functions | |
void | parse_argv (struct options *options, const int argc, char *argv[], const int msglevel, const unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es) |
void | notnull (const char *arg, const char *description) |
void | usage_small (void) |
void | show_library_versions (const unsigned int flags) |
void | show_windows_version (const unsigned int flags) |
void | show_dco_version (const unsigned int flags) |
void | init_options (struct options *o, const bool init_gc) |
void | uninit_options (struct options *o) |
void | setenv_settings (struct env_set *es, const struct options *o) |
void | show_settings (const struct options *o) |
bool | string_defined_equal (const char *s1, const char *s2) |
const char * | options_string_version (const char *s, struct gc_arena *gc) |
char * | options_string (const struct options *o, const struct frame *frame, struct tuntap *tt, openvpn_net_ctx_t *ctx, bool remote, struct gc_arena *gc) |
bool | options_cmp_equal_safe (char *actual, const char *expected, size_t actual_n) |
void | options_warning_safe (char *actual, const char *expected, size_t actual_n) |
bool | options_cmp_equal (char *actual, const char *expected) |
void | options_warning (char *actual, const char *expected) |
char * | options_string_extract_option (const char *options_string, const char *opt_name, struct gc_arena *gc) |
Given an OpenVPN options string, extract the value of an option. More... | |
void | options_postprocess (struct options *options, struct env_set *es) |
bool | options_postprocess_pull (struct options *o, struct env_set *es) |
void | pre_connect_restore (struct options *o, struct gc_arena *gc) |
bool | apply_push_options (struct options *options, struct buffer *buf, unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es) |
void | options_detach (struct options *o) |
void | options_server_import (struct options *o, const char *filename, int msglevel, unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es) |
void | pre_pull_default (struct options *o) |
void | rol_check_alloc (struct options *options) |
int | parse_line (const char *line, char *p[], const int n, const char *file, const int line_num, int msglevel, struct gc_arena *gc) |
int | parse_topology (const char *str, const int msglevel) |
const char * | print_topology (const int topology) |
int | auth_retry_get (void) |
bool | auth_retry_set (const int msglevel, const char *option) |
const char * | auth_retry_print (void) |
void | options_string_import (struct options *options, const char *config, const int msglevel, const unsigned int permission_mask, unsigned int *option_types_found, struct env_set *es) |
bool | key_is_external (const struct options *options) |
static bool | dco_enabled (const struct options *o) |
Returns whether the current configuration has dco enabled. More... | |
Variables | |
const char | title_string [] |
#define MAN_CLIENT_AUTH_ENABLED | ( | opt | ) | ((opt)->management_flags & MF_CLIENT_AUTH) |
#define OPT_P_DEFAULT (~(OPT_P_INSTANCE|OPT_P_PULL_MODE)) |
#define OPT_P_DHCPDNS (1<<3) /* includes ip windows options like */ |
#define OPT_P_INSTANCE (1<<17) |
#define PLUGIN_OPTION_LIST | ( | opt | ) | ((opt)->plugin_list) |
#define ROUTE_OPTION_FLAGS | ( | o | ) | ((o)->route_method & ROUTE_METHOD_MASK) |
enum genkey_type |
bool apply_push_options | ( | struct options * | options, |
struct buffer * | buf, | ||
unsigned int | permission_mask, | ||
unsigned int * | option_types_found, | ||
struct env_set * | es | ||
) |
Definition at line 5503 of file options.c.
References add_option(), apply_pull_filter(), buf_parse(), CLEAR, D_PUSH_ERRORS, es, options::gc, M_OPTERR, MAX_PARMS, OPTION_PARM_SIZE, parse_line(), and SIZE.
Referenced by process_incoming_push_reply().
int auth_retry_get | ( | void | ) |
Definition at line 4766 of file options.c.
References global_auth_retry.
Referenced by do_init_crypto_tls_c1(), init_instance(), receive_auth_failed(), and socket_restart_pause().
const char* auth_retry_print | ( | void | ) |
Definition at line 4795 of file options.c.
References AR_INTERACT, AR_NOINTERACT, AR_NONE, and global_auth_retry.
Referenced by man_dispatch_command().
bool auth_retry_set | ( | const int | msglevel, |
const char * | option | ||
) |
Definition at line 4772 of file options.c.
References AR_INTERACT, AR_NOINTERACT, AR_NONE, global_auth_retry, msg, and streq.
Referenced by add_option(), and man_dispatch_command().
|
inlinestatic |
Returns whether the current configuration has dco enabled.
Definition at line 907 of file options.h.
References tuntap_options::disable_dco, and options::tuntap_options.
Referenced by check_dco_key_status(), check_inactivity_timeout(), do_close_tun_simple(), do_deferred_options(), do_init_crypto_tls(), do_init_route_ipv6_list(), do_init_route_list(), do_init_timers(), do_open_tun(), do_persist_tuntap(), encrypt_sign(), init_key_contexts(), link_socket_init_phase2(), man_persist_client_stats(), management_check_bytecount(), multi_client_set_protocol_options(), multi_client_setup_dco_initial(), multi_connection_established(), multi_instance_string(), multi_print_status(), need_keep_caps(), options_postprocess_mutate(), options_postprocess_setdefault_ncpciphers(), options_postprocess_verify(), p2p_set_dco_keepalive(), print_status(), process_incoming_link_part1(), and setenv_stats().
void init_options | ( | struct options * | o, |
const bool | init_gc | ||
) |
Definition at line 789 of file options.c.
References connection_entry::af, options::allow_recursive_routing, options::auth_token_generate, options::authname, connection_entry::bind_ipv6_only, connection_entry::bind_local, options::block_outside_dns, options::ce, options::cf_initial_max, options::cf_initial_per, CLEAR, options::connect_retry_max, connection_entry::connect_retry_seconds, connection_entry::connect_retry_seconds_max, connection_entry::connect_timeout, DEFAULT_SEQ_BACKTRACK, DEFAULT_TIME_BACKTRACK, tuntap_options::dhcp_lease_time, tuntap_options::dhcp_masq_offset, tuntap_options::disable_dco, options::dns_options, options::ecdh_curve, dns_options::gc, options::gc, gc_init(), options::gc_owned, options::handshake_window, options::ifconfig_pool_persist_refresh_freq, tuntap_options::ip_win32_type, IPW32_SET_ADAPTIVE, IPW32_SET_DHCP_MASQ, options::key_direction, KEY_DIRECTION_BIDIRECTIONAL, connection_entry::link_mtu, LINK_MTU_DEFAULT, connection_entry::local_port, M_USAGE, options::management_echo_buffer_size, options::management_log_history_cache, options::management_state_buffer_size, options::max_clients, options::max_routes_per_client, options::mode, MODE_POINT_TO_POINT, msg, connection_entry::mssfix, connection_entry::mssfix_default, connection_entry::mssfix_encap, connection_entry::mtu_discover_type, options::n_bcast_buf, options::occ, connection_entry::occ_mtu, OPENVPN_PORT, options::persist_mode, connection_entry::proto, options::proto_force, PROTO_UDP, options::real_hash_size, connection_entry::remote_port, options::renegotiate_bytes, options::renegotiate_seconds, options::renegotiate_seconds_min, options::replay_time, options::replay_window, RESOLV_RETRY_INFINITE, options::resolve_in_advance, options::resolve_retry_seconds, options::route_delay_window, options::route_method, ROUTE_METHOD_ADAPTIVE, options::scheduled_exit_interval, options::stale_routes_check_interval, options::status_file_update_freq, options::status_file_version, options::tcp_queue_limit, options::tls_cert_profile, connection_entry::tls_mtu, TLS_MTU_DEFAULT, options::tls_timeout, options::tmp_dir, TOP_UNDEF, options::topology, options::transition_window, connection_entry::tun_mtu, TUN_MTU_DEFAULT, options::tuntap_options, options::verbosity, options::virtual_hash_size, options::vlan_accept, VLAN_ALL, options::vlan_pvid, win_get_tempdir(), options::windows_driver, WINDOWS_DRIVER_UNSPECIFIED, and X509_USERNAME_FIELD_DEFAULT.
Referenced by add_option(), openvpn_main(), options_postprocess_verify_ce(), and usage().
bool key_is_external | ( | const struct options * | options | ) |
Definition at line 5715 of file options.c.
References options::cryptoapi_cert, options::management_flags, and MF_EXTERNAL_KEY.
Referenced by init_ssl().
void notnull | ( | const char * | arg, |
const char * | description | ||
) |
Definition at line 4913 of file options.c.
Referenced by do_persist_tuntap(), options_postprocess_mutate(), and options_postprocess_verify_ce().
bool options_cmp_equal | ( | char * | actual, |
const char * | expected | ||
) |
Definition at line 4470 of file options.c.
References options_cmp_equal_safe().
Referenced by key_method_2_read().
bool options_cmp_equal_safe | ( | char * | actual, |
const char * | expected, | ||
size_t | actual_n | ||
) |
Definition at line 4612 of file options.c.
References D_SHOW_OCC, gc_free(), gc_new(), msg, and options_warning_safe_ml().
Referenced by options_cmp_equal(), and process_received_occ_msg().
void options_detach | ( | struct options * | o | ) |
Definition at line 1674 of file options.c.
References options::client_nat, clone_push_list(), options::gc, gc_detach(), and options::routes.
Referenced by do_test_crypto(), inherit_context_child(), and inherit_context_top().
Definition at line 4179 of file options.c.
References es, options_postprocess_filechecks(), options_postprocess_mutate(), and options_postprocess_verify().
Referenced by openvpn_main().
Definition at line 4193 of file options.c.
References D_PUSH_ERRORS, options::dns_options, dns_options_postprocess_pull(), dns_options_verify(), es, setenv_dns_options(), and tuntap_options_copy_dns().
Referenced by incoming_push_message().
void options_server_import | ( | struct options * | o, |
const char * | filename, | ||
int | msglevel, | ||
unsigned int | permission_mask, | ||
unsigned int * | option_types_found, | ||
struct env_set * | es | ||
) |
Definition at line 5533 of file options.c.
References D_PUSH, es, msg, and read_config_file().
Referenced by multi_client_connect_post(), and multi_client_connect_source_ccd().
char* options_string | ( | const struct options * | o, |
const struct frame * | frame, | ||
struct tuntap * | tt, | ||
openvpn_net_ctx_t * | ctx, | ||
bool | remote, | ||
struct gc_arena * | gc | ||
) |
Definition at line 4251 of file options.c.
References compress_options::alg, alloc_buf(), ASSERT, options::authname, BSTR, buf_printf(), calc_options_string_link_mtu(), options::ce, key_type::cipher, cipher_defined(), cipher_kt_key_size(), cipher_kt_name(), options::ciphername, options::comp, COMP_ALG_UNDEF, options::dev, options::dev_type, dev_type_string(), key_type::digest, connection_entry::fragment, options::ifconfig_ipv6_local, options::ifconfig_ipv6_netbits, options::ifconfig_ipv6_remote, options::ifconfig_local, options::ifconfig_nowarn, ifconfig_options_string(), options::ifconfig_remote_netmask, init_key_type(), init_tun(), options::key_direction, KEY_METHOD_2, keydirection2ascii(), md_kt_name(), options::mode, MODE_POINT_TO_POINT, options::ncp_ciphers, connection_entry::occ_mtu, OPTION_LINE_SIZE, connection_entry::proto, proto_remote(), PULL_DEFINED, options::shared_secret_file, connection_entry::tls_auth_file, TLS_CLIENT, tls_item_in_cipher_list(), TLS_SERVER, options::topology, and frame::tun_mtu.
Referenced by do_compute_occ_strings(), and options_string_extract_option().
char* options_string_extract_option | ( | const char * | options_string, |
const char * | opt_name, | ||
struct gc_arena * | gc | ||
) |
Given an OpenVPN options string, extract the value of an option.
options_string | Zero-terminated, comma-separated options string |
opt_name | The name of the option to extract |
gc | The gc to allocate the return value |
Definition at line 4649 of file options.c.
References gc_malloc(), and options_string().
Referenced by key_method_2_read().
void options_string_import | ( | struct options * | options, |
const char * | config, | ||
const int | msglevel, | ||
const unsigned int | permission_mask, | ||
unsigned int * | option_types_found, | ||
struct env_set * | es | ||
) |
Definition at line 5553 of file options.c.
References es, and read_config_string().
Referenced by multi_client_connect_mda(), multi_client_connect_post_plugin(), and open_plugins().
const char* options_string_version | ( | const char * | s, |
struct gc_arena * | gc | ||
) |
Definition at line 4641 of file options.c.
References alloc_buf_gc(), BPTR, BSTR, and strncpynt().
Referenced by do_compute_occ_strings().
void options_warning | ( | char * | actual, |
const char * | expected | ||
) |
Definition at line 4476 of file options.c.
References options_warning_safe().
Referenced by key_method_2_read().
void options_warning_safe | ( | char * | actual, |
const char * | expected, | ||
size_t | actual_n | ||
) |
Definition at line 4635 of file options.c.
References D_SHOW_OCC, and options_warning_safe_ml().
Referenced by options_warning(), and process_received_occ_msg().
void parse_argv | ( | struct options * | options, |
const int | argc, | ||
char * | argv[], | ||
const int | msglevel, | ||
const unsigned int | permission_mask, | ||
unsigned int * | option_types_found, | ||
struct env_set * | es | ||
) |
Definition at line 5390 of file options.c.
References add_option(), CLEAR, es, MAX_PARMS, msg, and usage().
Referenced by openvpn_main().
int parse_line | ( | const char * | line, |
char * | p[], | ||
const int | n, | ||
const char * | file, | ||
const int | line_num, | ||
int | msglevel, | ||
struct gc_arena * | gc | ||
) |
Definition at line 4966 of file options.c.
References gc_malloc(), M_INFO, M_MSG_VIRT_OUT, M_NOPREFIX, M_OPTERR, msg, OPTION_PARM_SIZE, PACKAGE, SIZE, and space().
Referenced by apply_push_options(), argv_parse_cmd(), make_arg_array(), man_process_command(), read_config_file(), read_config_string(), and remove_iroutes_from_push_route_list().
int parse_topology | ( | const char * | str, |
const int | msglevel | ||
) |
Definition at line 4716 of file options.c.
References msg, streq, TOP_NET30, TOP_P2P, TOP_SUBNET, and TOP_UNDEF.
Referenced by add_option().
Definition at line 3328 of file options.c.
References options_pre_connect::authname, options::authname, options_pre_connect::ciphername, options::ciphername, CLEAR, options_pre_connect::client_nat, options::client_nat, options_pre_connect::client_nat_defined, clone_dns_options(), cnol_check_alloc(), options_pre_connect::comp, options::comp, copy_client_nat_option_list(), copy_route_ipv6_option_list(), copy_route_option_list(), options_pre_connect::dns_options, options::dns_options, options_pre_connect::foreign_option_index, options::foreign_option_index, dns_options::gc, gc_free(), gc_new(), options::imported_protocol_flags, options_pre_connect::ping_rec_timeout, options::ping_rec_timeout, options_pre_connect::ping_rec_timeout_action, options::ping_rec_timeout_action, options_pre_connect::ping_send_timeout, options::ping_send_timeout, options::pre_connect, options::push_continuation, options::push_option_types_found, rol6_check_alloc(), rol_check_alloc(), options_pre_connect::route_default_gateway, options::route_default_gateway, options_pre_connect::route_ipv6_default_gateway, options::route_ipv6_default_gateway, options_pre_connect::routes, options::routes, options_pre_connect::routes_defined, options_pre_connect::routes_ipv6, options::routes_ipv6, options_pre_connect::routes_ipv6_defined, options_pre_connect::tuntap_options, options::tuntap_options, and options_pre_connect::tuntap_options_defined.
Referenced by init_instance().
void pre_pull_default | ( | struct options * | o | ) |
const char* print_topology | ( | const int | topology | ) |
Definition at line 4738 of file options.c.
References TOP_NET30, TOP_P2P, TOP_SUBNET, and TOP_UNDEF.
Referenced by print_opt_topology().
void rol_check_alloc | ( | struct options * | options | ) |
Definition at line 1683 of file options.c.
References options::gc, new_route_option_list(), and options::routes.
Referenced by add_option(), helper_add_route(), and pre_connect_restore().
Definition at line 1007 of file options.c.
References connection_list::array, options::ce, options::config, options::connection_list, options::daemon, options::dns_options, es, connection_list::len, options::log, platform_getpid(), options::pull, setenv_connection_entry(), setenv_dns_options(), setenv_int(), setenv_long_long(), setenv_str(), and options::verbosity.
Referenced by openvpn_main().
void show_dco_version | ( | const unsigned int | flags | ) |
Definition at line 4866 of file options.c.
References dco_version_string(), gc_free(), gc_new(), and msg.
Referenced by openvpn_main(), and usage_version().
void show_library_versions | ( | const unsigned int | flags | ) |
Definition at line 4876 of file options.c.
References get_ssl_library_version(), LZO_LIB_VER_STR, and msg.
Referenced by openvpn_main(), and usage_version().
void show_settings | ( | const struct options * | o | ) |
Definition at line 1798 of file options.c.
References options::client_nat, D_SHOW_PARMS, daemon(), tuntap_options::disable_dco, options::dns_options, format_hex_ex(), gc_free(), gc_new(), verify_hash_list::hash, options::key_direction, keydirection2ascii(), machine_readable_output, options::management_flags, MAX_PARMS, MD_SHA1, MF_EXTERNAL_CERT, MF_EXTERNAL_KEY, msg, verify_hash_list::next, pkcs11_id_management, options::plugin_list, plugin_option_list_print(), print_client_nat_list(), print_route_options(), options::pull_filter_list, push_peer_info(), options::routes, SHA256_DIGEST_LENGTH, SHA_DIGEST_LENGTH, SHOW_BOOL, show_connection_entries(), show_dns_options(), SHOW_INT, SHOW_INT64, show_p2mp_parms(), SHOW_PARM, show_pull_filter_list(), SHOW_STR, SHOW_STR_INLINE, show_tuntap_options(), suppress_timestamps, test_crypto(), tls_verify(), options::tuntap_options, options::verify_hash, and options::verify_hash_algo.
Referenced by openvpn_main().
void show_windows_version | ( | const unsigned int | flags | ) |
Definition at line 4857 of file options.c.
References gc_free(), gc_new(), msg, and win32_version_string().
Referenced by openvpn_main(), and usage_version().
bool string_defined_equal | ( | const char * | s1, |
const char * | s2 | ||
) |
Definition at line 4922 of file options.c.
Referenced by options_postprocess_verify_ce().
void uninit_options | ( | struct options * | o | ) |
Definition at line 911 of file options.c.
References CLEAR, options::connection_list, options::dns_options, dns_options::gc, options::gc, gc_free(), options::gc_owned, and options::remote_list.
Referenced by add_option(), openvpn_main(), and options_postprocess_verify_ce().
void usage_small | ( | void | ) |
Definition at line 4849 of file options.c.
References M_NOPREFIX, M_WARN, msg, openvpn_exit(), and OPENVPN_EXIT_STATUS_USAGE.
Referenced by x_msg_va().
const char title_string[] |
Definition at line 67 of file options.c.
Referenced by _tmain(), do_test_crypto(), man_dispatch_command(), man_help(), multi_print_status(), openvpn_main(), usage(), and usage_version().