27#ifdef HAVE_SYS_INOTIFY_H
28#include <sys/inotify.h>
29#define INOTIFY_EVENT_BUFFER_SIZE 16384
58#ifdef MULTI_DEBUG_EVENT_LOOP
73#ifdef ENABLE_MANAGEMENT
119 if (
plugin_call(plugins, OPENVPN_PLUGIN_LEARN_ADDRESS, &
argv, NULL, es)
120 != OPENVPN_PLUGIN_FUNC_SUCCESS)
122 msg(
M_WARN,
"WARNING: learn-address plugin call failed");
131 setenv_str(es,
"script_type",
"learn-address");
229#ifdef ENABLE_MANAGEMENT
234 const unsigned long *k = (
const unsigned long *)
key;
241 const unsigned long *k1 = (
const unsigned long *)key1;
242 const unsigned long *k2 = (
const unsigned long *)
key2;
248#ifdef ENABLE_ASYNC_PUSH
253int_hash_function(
const void *
key,
const uint8_t hash_key[
HASH_KEY_LEN])
255 return (uintptr_t)
key;
259int_compare_function(
const void *key1,
const void *
key2)
261 return (uintptr_t)key1 == (uintptr_t)
key2;
303#ifdef ENABLE_MANAGEMENT
307#ifdef ENABLE_ASYNC_PUSH
312 m->inotify_watchers =
409 "Initializing stale route check timer to run every %i seconds and to removing routes with activity timeout older than %i seconds",
532 != OPENVPN_PLUGIN_FUNC_SUCCESS)
534 msg(
M_WARN,
"WARNING: client-disconnect plugin call failed");
546#ifdef ENABLE_MANAGEMENT
583#ifdef ENABLE_MANAGEMENT
590#ifdef ENABLE_ASYNC_PUSH
591 if (mi->inotify_watch != -1)
593 hash_remove(m->inotify_watchers, (
void *)(uintptr_t)mi->inotify_watch);
594 mi->inotify_watch = -1;
617 mi->did_iroutes =
false;
628#ifdef ENABLE_MANAGEMENT
678#ifdef ENABLE_MANAGEMENT
685#ifdef ENABLE_ASYNC_PUSH
687 m->inotify_watchers = NULL;
738 "MULTI: new incoming connection would exceed maximum number of clients (%d)",
752#ifdef ENABLE_MANAGEMENT
761#ifdef ENABLE_ASYNC_PUSH
762 mi->inotify_watch = -1;
767 msg(
D_MULTI_ERRORS,
"MULTI: signal occurred during client instance initialization");
814 status_printf(so,
"Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since");
835 status_printf(so,
"Virtual Address,Common Name,Real Address,Last Ref");
846 char flags[2] = { 0, 0 };
869 else if (version == 2 || version == 3)
871 const char sep = (version == 3) ?
'\t' :
',';
881 "HEADER%cCLIENT_LIST%cCommon Name%cReal Address%cVirtual Address%cVirtual IPv6 Address%cBytes Received%cBytes Sent%cConnected Since%cConnected Since (time_t)%cUsername%cClient ID%cPeer ID%cData Channel Cipher",
882 sep, sep, sep, sep, sep, sep, sep, sep, sep, sep, sep, sep, sep);
895#ifdef ENABLE_MANAGEMENT
909#ifdef ENABLE_MANAGEMENT
923 "HEADER%cROUTING_TABLE%cVirtual Address%cCommon Name%cReal Address%cLast Ref%cLast Ref (time_t)",
924 sep, sep, sep, sep, sep, sep);
935 char flags[2] = { 0, 0 };
941 status_printf(so,
"ROUTING_TABLE%c%s%s%c%s%c%s%c%s%c%u", sep,
946 (
unsigned int)
route->last_reference);
954 status_printf(so,
"GLOBAL_STATS%cMax bcast/mcast queue length%c%d", sep, sep,
964 status_printf(so,
"ERROR: bad status format version number");
967#ifdef PACKET_TRUNCATION_CHECK
969 status_printf(so,
"HEADER,ERRORS,Common Name,TUN Read Trunc,TUN Write Trunc,Pre-encrypt Trunc,Post-decrypt Trunc");
996#ifdef ENABLE_ASYNC_PUSH
997 if (m->inotify_watchers)
1014 const unsigned int flags)
1039 bool learn_succeeded =
false;
1058 learn_succeeded =
true;
1068 he->
value = newroute;
1075 learn_succeeded =
true;
1085 msg(
D_MULTI_LOW,
"MULTI: Learn%s: %s -> %s", learn_succeeded ?
"" :
" FAILED",
1088 if (!learn_succeeded)
1123 else if (cidr_routing)
1185 remote_si.
addr.
in4.sin_family = AF_INET;
1186 remote_si.
addr.
in4.sin_addr.s_addr = htonl(a);
1197#ifdef ENABLE_MANAGEMENT
1242#ifdef ENABLE_MANAGEMENT
1331 for (uint32_t i = 0; i <= m->
max_peerid; i++)
1334 if (mi && mi != new_mi && !mi->
halt)
1337 if (cn && !strcmp(cn, new_cn))
1348 "MULTI: new connection by client '%s' will cause previous active sessions by this client to be dropped. Remember to use the --duplicate-cn option if you want multiple clients using the same certificate or username to concurrently connect.",
1438 "MULTI_sva: WARNING: if --ifconfig-push is used for IPv4, automatic IPv6 assignment from --ifconfig-ipv6-pool does not work. Use --ifconfig-ipv6-push for IPv6 then.");
1444 struct in6_addr remote_ipv6;
1445 const char *cn = NULL;
1460 msg(
M_INFO,
"MULTI_sva: pool returned IPv4=%s, IPv6=%s",
1465 :
"(Not enabled)"));
1484 if (tunnel_topology ==
TOP_P2P)
1501 "MULTI: no --ifconfig-pool netmask parameter is available to push to %s",
1535 msg(
M_INFO,
"MULTI_sva: push_ifconfig_ipv6 %s/%d",
1594 uint64_t *option_types_found)
1620 const struct plugin_return *pr, uint64_t *option_types_found)
1630 for (i = 0; i < config.
n; ++i)
1632 if (config.
list[i] && config.
list[i]->value)
1659 uint64_t *option_types_found)
1664#ifdef ENABLE_MANAGEMENT
1670 const char *opt =
BSTR(&be->
buf);
1736 msg(
M_INFO,
"Client does not support DATA_V2. Data channel offloading "
1737 "requires DATA_V2. Dropping client.");
1739 "failed (missing DATA_V2)");
1747 msg(
M_WARN,
"Note: peer reports running in P2P mode (no --pull/--client "
1748 "option). It will not negotiate ciphers with this server. "
1749 "Expect this connection to fail.");
1763 msg(
M_INFO,
"PUSH: client does not support TLS Keying Material "
1764 "Exporters but --force-tls-key-material-export is enabled.");
1766 "server. Keying Material Exporters (RFC 5705) "
1767 "support missing. Upgrade to a client that "
1768 "supports this feature (OpenVPN 2.6.0+).");
1790 "PUSH: client wants to negotiate cipher (NCP), but "
1791 "server has already generated data channel keys, "
1792 "re-sending previously negotiated cipher '%s'",
1801 const char *push_cipher =
1826 if (strlen(peer_ciphers) > 0)
1829 "PUSH: No common cipher between server and client. "
1830 "Server data-ciphers: '%s'%s, client supported ciphers '%s'",
1836 "PUSH: No common cipher between server and client. "
1837 "Server data-ciphers: '%s'%s, client supports cipher '%s'",
1842 msg(
M_INFO,
"PUSH: No NCP or OCC cipher data received from peer.");
1847 "Using data channel cipher '%s' since "
1848 "--data-ciphers-fallback is set.",
1854 msg(
M_INFO,
"Use --data-ciphers-fallback with the cipher the "
1855 "client is using if you want to allow the client to connect");
1861 "failed (no shared cipher)");
1940 const int c = fgetc(fp);
1965 msg(
M_WARN,
"WARNING: Unknown/unexpected value in deferred "
1966 "client-connect resultfile");
2030 bool deferred, uint64_t *option_types_found)
2036 ASSERT(option_types_found);
2047 call = OPENVPN_PLUGIN_CLIENT_CONNECT;
2056 call = OPENVPN_PLUGIN_CLIENT_CONNECT_DEFER;
2064 if (plug_ret == OPENVPN_PLUGIN_FUNC_SUCCESS)
2068 else if (plug_ret == OPENVPN_PLUGIN_FUNC_DEFERRED)
2079 msg(
M_WARN,
"WARNING: client-connect plugin call failed");
2120 bool deferred, uint64_t *option_types_found)
2126 ASSERT(option_types_found);
2128 int call = deferred ? OPENVPN_PLUGIN_CLIENT_CONNECT_DEFER_V2 : OPENVPN_PLUGIN_CLIENT_CONNECT_V2;
2137 if (plug_ret == OPENVPN_PLUGIN_FUNC_SUCCESS)
2142 else if (plug_ret == OPENVPN_PLUGIN_FUNC_DEFERRED)
2147 msg(
M_WARN,
"A plugin that defers from the "
2148 "OPENVPN_PLUGIN_CLIENT_CONNECT_V2 call must also "
2149 "declare support for "
2150 "OPENVPN_PLUGIN_CLIENT_CONNECT_DEFER_V2");
2156 msg(
M_WARN,
"WARNING: client-connect-v2 plugin call failed");
2169 uint64_t *option_types_found)
2172 ASSERT(option_types_found);
2198 msg(
M_INFO,
"MULTI: deferred --client-connect script returned CC_RET_FAILED");
2279 strerror(-ret), ret);
2292 struct frame *frame_fragment = NULL;
2293#ifdef ENABLE_FRAGMENT
2314 const uint64_t option_types_found)
2331 "MULTI: no dynamic or static remote "
2332 "--ifconfig address is available for %s",
2341 const char *ifconfig_constraint_network =
2343 const char *ifconfig_constraint_netmask =
2348 "MULTI ERROR: primary virtual IP for %s (%s) "
2349 "violates tunnel network/netmask constraint (%s/%s)",
2352 ifconfig_constraint_network, ifconfig_constraint_netmask);
2402 const char *ifconfig_local_ipv6 =
2422 "MULTI: --iroute options rejected for %s -- iroute "
2423 "only works with tun-style tunnels",
2472 bool deferred, uint64_t *option_types_found)
2480 if (peer_info && strstr(peer_info,
"IV_COMP_STUBv2=1"))
2504 uint64_t *option_types_found)
2513 const char *ccd_file = NULL;
2515 const char *ccd_client =
2519 const char *ccd_default =
2526 ccd_file = ccd_client;
2531 ccd_file = ccd_default;
2555 uint64_t *option_types_found);
2581 "user/password method is enabled. Enable "
2582 "--management-client-auth, --auth-user-pass-verify, or a "
2583 "plugin with user/password verify capability.");
2620 "MULTI: Note, override-username changes username "
2621 "from '%s' to '%s'",
2658 *cur_handler_index = 0;
2659 *option_types_found = 0;
2666 bool cc_succeeded =
true;
2673 from_deferred =
false;
2705 cc_succeeded =
false;
2716 if (mi->context.options.disable)
2719 "'disable' directive");
2720 cc_succeeded =
false;
2723 (*cur_handler_index)++;
2730 cc_succeeded =
false;
2738 msg(
D_MULTI_ERRORS,
"MULTI: client has been rejected due to incompatible DCO options");
2739 cc_succeeded =
false;
2744 msg(
D_MULTI_ERRORS,
"MULTI: client has been rejected due to invalid compression options");
2745 cc_succeeded =
false;
2768#ifdef ENABLE_MANAGEMENT
2777#ifdef ENABLE_ASYNC_PUSH
2785multi_process_file_closed(
struct multi_context *m,
const unsigned int mpp_flags)
2787 char buffer[INOTIFY_EVENT_BUFFER_SIZE];
2788 ssize_t buffer_i = 0;
2789 ssize_t r =
read(m->
top.
c2.inotify_fd,
buffer, INOTIFY_EVENT_BUFFER_SIZE);
2796 while (buffer_i < r)
2799 struct inotify_event *pevent = (
struct inotify_event *)&
buffer[buffer_i];
2800 size_t event_size =
sizeof(
struct inotify_event) + pevent->len;
2801 buffer_i += event_size;
2803 msg(
D_MULTI_DEBUG,
"MULTI: modified fd %d, mask %d", pevent->wd, pevent->mask);
2806 hash_lookup(m->inotify_watchers, (
void *)(uintptr_t)pevent->wd);
2808 if (pevent->mask & IN_CLOSE_WRITE)
2820 else if (pevent->mask & IN_IGNORED)
2825 hash_remove(m->inotify_watchers, (
void *)(uintptr_t)pevent->wd);
2826 mi->inotify_watch = -1;
2853 msg(
D_MULTI_DROPPED,
"MULTI: packet dropped due to output saturation (multi_add_mbuf)");
2885#ifdef MULTI_DEBUG_EVENT_LOOP
2886 printf(
"BCAST len=%d\n",
BLEN(
buf));
2890 for (uint32_t i = 0; i <= m->
max_peerid; i++)
2894 if (mi && mi != sender_instance && !mi->
halt)
2918static inline unsigned int
2921 ASSERT(delta->tv_sec >= 0);
2922 ASSERT(delta->tv_usec >= 0);
2923 if (delta->tv_sec < 1)
2926 return (
unsigned int)(delta->tv_usec >> 3);
2931 if (delta->tv_sec < 600)
2933 return (
unsigned int)(delta->tv_sec << 17);
2937 return 120 * 1000000;
2954#if defined(ENABLE_ASYNC_PUSH)
2960 int watch_descriptor = inotify_add_watch(inotify_fd, file, IN_CLOSE_WRITE | IN_ONESHOT);
2961 if (watch_descriptor >= 0)
2963 if (mi->inotify_watch != -1)
2965 hash_remove(m->inotify_watchers, (
void *)(uintptr_t)mi->inotify_watch);
2967 hash_add(m->inotify_watchers, (
void *)(uintptr_t)watch_descriptor, mi,
true);
2968 mi->inotify_watch = watch_descriptor;
2992#if defined(ENABLE_ASYNC_PUSH)
2993 bool was_unauthenticated =
true;
3006#if defined(ENABLE_ASYNC_PUSH)
3033#if defined(ENABLE_ASYNC_PUSH)
3037 add_inotify_file_watch(m, mi, m->
top.
c2.inotify_fd,
3059#ifdef MULTI_DEBUG_EVENT_LOOP
3060 printf(
"POST %s[%d] to=%d lo=%d/%d w=%" PRIi64
"/%ld\n",
id(mi), (
int)(mi == m->
pending),
3112 msg(
D_MULTI_LOW,
"Disallow float to an address taken by another client %s",
3125 msg(
D_MULTI_LOW,
"Disallow float to an address taken by another client %s",
3138 "disallowing peer %" PRIu32
" (%s) from floating to "
3139 "its own address (%s)",
3146 "closing instance %s due to float collision with %s "
3147 "using the same certificate and username",
3212#ifdef ENABLE_MANAGEMENT
3233#if (defined(ENABLE_DCO) && (defined(TARGET_LINUX) || defined(TARGET_FREEBSD))) \
3234 || defined(ENABLE_MANAGEMENT)
3243#if defined(ENABLE_DCO)
3247 const char *reason =
"ovpn-dco: unknown reason";
3248 switch (dco->dco_del_peer_reason)
3251 reason =
"ovpn-dco: ping expired";
3255 reason =
"ovpn-dco: transport error";
3259 reason =
"ovpn-dco: transport disconnected";
3292 int peer_id = dco->dco_message_peer_id;
3308 process_incoming_del_peer(m, mi, dco);
3315 (
struct sockaddr *)&dco->dco_float_peer_ss);
3317 CLEAR(dco->dco_float_peer_ss);
3341 "Received DCO message for unknown peer-id: %d, "
3342 "type %d, del_peer_reason %d",
3343 peer_id, dco->dco_message_type, dco->dco_del_peer_reason);
3358 const uint8_t *orig_buf;
3379 unsigned int mroute_flags =
3392 && IN6_IS_ADDR_LINKLOCAL(&src.
v6.
addr))
3400 "MULTI: bad source address from client [%s], packet dropped",
3452 unsigned int mroute_flags =
3484 "MULTI: bad source address from client [%s], packet dropped",
3503 const unsigned int mpp_flags,
struct link_socket *sock)
3507 bool floated =
false;
3516#ifdef MULTI_DEBUG_EVENT_LOOP
3571 unsigned int mroute_flags;
3576#ifdef MULTI_DEBUG_EVENT_LOOP
3632 "MULTI: packet dropped due to output saturation (multi_process_incoming_tun)");
3696#ifdef MULTI_DEBUG_EVENT_LOOP
3750 "MULTI ROUTE: route quota (%d) exceeded for %s (see --max-routes-per-client option)",
3762 const int level = GREMLIN_PACKET_FLOOD_LEVEL(m->
top.
options.gremlin);
3767 struct packet_flood_parms parm = get_packet_flood_parms(level);
3773 msg(
D_GREMLIN,
"GREMLIN_FLOOD_CLIENTS: flooding clients with %d packets of size %d",
3774 parm.n_packets, parm.packet_size);
3776 for (i = 0; i < parm.packet_size; ++i)
3781 for (i = 0; i < parm.n_packets; ++i)
3794 struct timeval null;
3821 gremlin_flood_clients(m);
3855 for (uint32_t i = 0; i <= m->
max_peerid; i++)
3868 struct timeval tv = { .tv_sec = 2, .tv_usec = 0 };
3907#ifdef ENABLE_MANAGEMENT
3937 for (uint32_t i = 0; i <= m->
max_peerid; i++)
3940 if (mi && !mi->
halt)
3943 if (cn && !strcmp(cn, del_cn))
3962 saddr.
addr.
in4.sin_family = AF_INET;
3968 for (uint32_t i = 0; i <= m->
max_peerid; i++)
3997 if (mi && !mi->
halt)
4024 const unsigned int mda_key_id)
4042 const char *extra,
unsigned int timeout)
4069 const bool auth,
const char *reason,
const char *client_reason,
4074 bool cc_config_owned =
true;
4087 cc_config_owned =
false;
4092 msg(
D_MULTI_LOW,
"MULTI: connection rejected: %s, CLI:%s", reason,
4125#ifdef ENABLE_MANAGEMENT
4191#ifdef ENABLE_MANAGEMENT
4270#ifdef ENABLE_ASYNC_PUSH
4271 multi.
top.
c2.inotify_fd = inotify_init();
4272 if (multi.
top.
c2.inotify_fd < 0)
4280#ifdef ENABLE_ASYNC_PUSH
4281 msg(
D_LOW,
"%s: close multi.top.c2.inotify_fd (%d)",
4282 __func__, multi.
top.
c2.inotify_fd);
4283 close(multi.
top.
c2.inotify_fd);
4381 struct in6_addr old_addr6;
4412 struct in_addr new_addr;
4414 if (inet_pton(AF_INET, new_ip, &new_addr) == 1
4433 struct in6_addr new_addr6;
4435 if (inet_pton(AF_INET6, new_ipv6, &new_addr6) == 1
4463 return (local_addr & local_netmask) != (dest & local_netmask);
4478 struct in6_addr ifconfig_local;
void argv_parse_cmd(struct argv *argres, const char *cmdstr)
Parses a command string, tokenizes it and puts each element into a separate struct argv argument slot...
void argv_free(struct argv *a)
Frees all memory allocations allocated by the struct argv related functions.
bool argv_printf(struct argv *argres, const char *format,...)
printf() variant which populates a struct argv.
bool argv_printf_cat(struct argv *argres, const char *format,...)
printf() inspired argv concatenation.
struct argv argv_new(void)
Allocates a new struct argv and ensures it is initialised.
void generate_auth_token(const struct user_pass *up, struct tls_multi *multi)
Generate an auth token based on username and timestamp.
bool buf_printf(struct buffer *buf, const char *format,...)
printf-style append to a buffer with overflow check.
void buffer_list_free(struct buffer_list *ol)
Frees a buffer list and all the buffers in it.
struct buffer alloc_buf_gc(size_t size, struct gc_arena *gc)
Allocate a buffer of the given size under garbage collection.
char * string_alloc(const char *str, struct gc_arena *gc)
Duplicate a string, allocating memory under garbage collection.
#define ALLOC_OBJ(dptr, type)
Allocate memory for a single object of the given type.
#define BSTR(buf)
Return the buffer content pointer cast to char *.
static void buf_reset(struct buffer *buf)
Reset a buffer to an undefined (unallocated) state.
static bool buf_write_u8(struct buffer *dest, uint8_t data)
Append a uint8_t to a buffer.
#define BLEN(buf)
Return the length of the buffer content in bytes.
static void buf_reset_len(struct buffer *buf)
Reset the length and offset of a buffer to zero.
static void strncpynt(char *dest, const char *src, size_t maxlen)
Like strncpy() but always null-terminates the destination.
static void gc_free(struct gc_arena *a)
Free all allocations in a garbage collection arena.
#define ALLOC_OBJ_CLEAR(dptr, type)
Allocate and zero-initialise memory for a single object of the given type.
#define buf_init(buf, offset)
static struct gc_arena gc_new(void)
Allocate and return a new, empty garbage collection arena.
bool check_compression_settings_valid(struct compress_options *info, msglvl_t msglevel)
Checks if the compression settings are valid.
#define COMP_ALG_STUB
support compression command byte and framing without actual compression
#define COMP_F_MIGRATE
push stub-v2 or comp-lzo no when we see a client with comp-lzo in occ
const char * translate_cipher_name_to_openvpn(const char *cipher_name)
Translate a crypto library cipher name to an OpenVPN cipher name.
int64_t get_random(void)
an analogue to the random() function, but use prng_bytes and also int64_t instead of long to avoid LL...
#define CO_USE_TLS_KEY_MATERIAL_EXPORT
Bit-flag indicating that data channel key derivation is done using TLS keying material export [RFC570...
#define CO_USE_DYNAMIC_TLS_CRYPT
Bit-flag indicating that renegotiations are using tls-crypt with a TLS-EKM derived key.
#define CO_EPOCH_DATA_KEY_FORMAT
Bit-flag indicating the epoch the data format.
#define CO_USE_CC_EXIT_NOTIFY
Bit-flag indicating that explicit exit notifies should be sent via the control channel instead of usi...
Data Channel Cryptography SSL library-specific backend interface.
bool cipher_kt_mode_aead(const char *ciphername)
Check if the supplied cipher is a supported AEAD mode cipher.
static int dco_get_peer_stats_multi(dco_context_t *dco, const bool raise_sigusr1_on_err)
static void dco_delete_iroutes(openvpn_net_ctx_t *net_ctx, const struct context *c)
static void dco_install_iroute(struct multi_context *m, struct multi_instance *mi, struct mroute_addr *addr)
static bool dco_check_option(msglvl_t msglevel, const struct options *o)
static int dco_multi_add_new_peer(struct multi_context *m, struct multi_instance *mi)
void setenv_counter(struct env_set *es, const char *name, counter_type value)
void setenv_int(struct env_set *es, const char *name, int value)
void setenv_str(struct env_set *es, const char *name, const char *value)
struct env_set * env_set_create(struct gc_arena *gc)
void setenv_long_long(struct env_set *es, const char *name, long long value)
void setenv_del(struct env_set *es, const char *name)
const struct rw_handle * event_t
@ EVENT_ARG_MULTI_INSTANCE
void reschedule_multi_process(struct context *c)
Reschedule tls_multi_process.
bool send_control_channel_string(struct context *c, const char *str, msglvl_t msglevel)
void pre_select(struct context *c)
void process_ip_header(struct context *c, unsigned int flags, struct buffer *buf, struct link_socket *sock)
void extract_dco_float_peer_addr(const sa_family_t socket_family, struct openvpn_sockaddr *out_osaddr, const struct sockaddr *float_sa)
Transfers float_sa data extracted from an incoming DCO PEER_FLOAT_NTF to out_osaddr for later process...
Interface functions to the internal and external multiplexers.
static void register_activity(struct context *c, const int64_t size)
#define PIPV6_ICMP_NOHOST_SERVER
static struct link_socket_info * get_link_socket_info(struct context *c)
#define TM_INITIAL
As yet un-trusted tls_session \ being negotiated.
#define KS_PRIMARY
Primary key state index.
#define TM_ACTIVE
Active tls_session.
void encrypt_sign(struct context *c, bool comp_frag)
Process a data channel packet that will be sent through a VPN tunnel.
void tunnel_server(struct context *top)
Main event loop for OpenVPN in server mode.
static void tunnel_server_loop(struct multi_context *multi)
Main event loop for OpenVPN in point-to-multipoint server mode.
bool process_incoming_link_part1(struct context *c, struct link_socket_info *lsi, bool floated)
Starts processing a packet read from the external network interface.
void process_incoming_link_part2(struct context *c, struct link_socket_info *lsi, const uint8_t *orig_buf)
Continues processing a packet read from the external network interface.
bool multi_process_incoming_link(struct multi_context *m, struct multi_instance *instance, const unsigned int mpp_flags, struct link_socket *sock)
Demultiplex and process a packet received over the external network interface.
struct multi_instance * multi_get_create_instance_udp(struct multi_context *m, bool *floated, struct link_socket *sock)
Get, and if necessary create, the multi_instance associated with a packet's source address.
void process_incoming_tun(struct context *c, struct link_socket *out_sock)
Process a packet read from the virtual tun/tap network interface.
bool multi_process_incoming_tun(struct multi_context *m, const unsigned int mpp_flags)
Determine the destination VPN tunnel of a packet received over the virtual tun/tap network interface ...
void uninit_management_callback(void)
void initialization_sequence_completed(struct context *c, const unsigned int flags)
void close_instance(struct context *c)
void inherit_context_top(struct context *dest, const struct context *src)
void free_context_buffers(struct context_buffers *b)
void init_instance_handle_signals(struct context *c, const struct env_set *env, const unsigned int flags)
void inherit_context_child(struct context *dest, const struct context *src, struct link_socket *sock)
void context_clear_2(struct context *c)
void close_context(struct context *c, int sig, unsigned int flags)
bool do_deferred_options(struct context *c, const uint64_t found, const bool is_update)
struct context_buffers * init_context_buffers(const struct frame *frame)
void management_show_net_callback(void *arg, const msglvl_t msglevel)
#define CC_HARD_USR1_TO_HUP
static unsigned int constrain_uint(unsigned int x, unsigned int min, unsigned int max)
static int min_int(int x, int y)
static SERVICE_STATUS status
bool event_timeout_trigger(struct event_timeout *et, struct timeval *tv, const int et_const_retry)
This is the principal function for testing and triggering recurring timers.
static void event_timeout_init(struct event_timeout *et, interval_t n, const time_t last)
Initialises a timer struct.
void hash_iterator_free(struct hash_iterator *hi)
struct hash_element * hash_iterator_next(struct hash_iterator *hi)
void hash_iterator_delete_element(struct hash_iterator *hi)
void hash_iterator_init(struct hash *hash, struct hash_iterator *hi)
struct hash * hash_init(const uint32_t n_buckets, uint64_t(*hash_function)(const void *key, const uint8_t hash_key[HASH_KEY_LEN]), bool(*compare_function)(const void *key1, const void *key2))
void hash_free(struct hash *hash)
struct hash_element * hash_lookup_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint64_t hv)
bool hash_add(struct hash *hash, const void *key, void *value, bool replace)
void hash_remove_by_value(struct hash *hash, void *value)
void hash_iterator_init_range(struct hash *hash, struct hash_iterator *hi, uint32_t start_bucket, uint32_t end_bucket)
static bool hash_remove(struct hash *hash, const void *key)
static void * hash_lookup(struct hash *hash, const void *key)
static uint32_t hash_n_elements(const struct hash *hash)
static uint32_t hash_n_buckets(const struct hash *hash)
static void hash_add_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint64_t hv, void *value)
static struct hash_bucket * hash_bucket(struct hash *hash, uint64_t hv)
static uint64_t hash_value(const struct hash *hash, const void *key)
void management_check_bytecount_server(struct multi_context *multi, struct timeval *timeval)
void management_connection_established(struct management *man, struct man_def_auth_context *mdac, const struct env_set *es)
void management_notify_client_close(const struct management *man, struct man_def_auth_context *mdac, const struct env_set *es)
void management_set_callback(struct management *man, const struct management_callback *cb)
void management_learn_addr(struct man_def_auth_context *mdac, const struct mroute_addr *addr, const bool primary)
void mbuf_add_item(struct mbuf_set *ms, const struct mbuf_item *item)
struct mbuf_buffer * mbuf_alloc_buf(const struct buffer *buf)
void mbuf_free_buf(struct mbuf_buffer *mb)
void mbuf_dereference_instance(struct mbuf_set *ms, struct multi_instance *mi)
bool mbuf_extract_item(struct mbuf_set *ms, struct mbuf_item *item)
void mbuf_free(struct mbuf_set *ms)
struct mbuf_set * mbuf_init(unsigned int size)
static int mbuf_maximum_queued(const struct mbuf_set *ms)
void mroute_addr_mask_host_bits(struct mroute_addr *ma)
void mroute_helper_add_iroute46(struct mroute_helper *mh, int netbits)
const char * mroute_addr_print_ex(const struct mroute_addr *ma, const unsigned int flags, struct gc_arena *gc)
bool mroute_extract_openvpn_sockaddr(struct mroute_addr *addr, const struct openvpn_sockaddr *osaddr, bool use_port)
const char * mroute_addr_print(const struct mroute_addr *ma, struct gc_arena *gc)
void mroute_helper_del_iroute46(struct mroute_helper *mh, int netbits)
bool mroute_learnable_address(const struct mroute_addr *addr, struct gc_arena *gc)
bool mroute_addr_compare_function(const void *key1, const void *key2)
struct mroute_helper * mroute_helper_init(int ageable_ttl_secs)
void mroute_addr_init(struct mroute_addr *addr)
uint64_t mroute_addr_hash_function(const void *key, const uint8_t hash_key[HASH_KEY_LEN])
void mroute_helper_free(struct mroute_helper *mh)
#define MROUTE_EXTRACT_SUCCEEDED
#define MROUTE_EXTRACT_MCAST
static unsigned int mroute_extract_addr_from_packet(struct mroute_addr *src, struct mroute_addr *dest, uint16_t vid, const struct buffer *buf, int tunnel_type)
static void mroute_extract_in_addr_t(struct mroute_addr *dest, const in_addr_t src)
#define MR_ONLINK_DCO_ADDR
static bool mroute_addr_equal(const struct mroute_addr *a1, const struct mroute_addr *a2)
#define MROUTE_EXTRACT_BCAST
void multi_tcp_instance_specific_free(struct multi_instance *mi)
void multi_tcp_delete_event(struct multi_io *multi_io, event_t event)
bool multi_tcp_instance_specific_init(struct multi_context *m, struct multi_instance *mi)
void multi_tcp_dereference_instance(struct multi_io *multi_io, struct multi_instance *mi)
static const char * np(const char *str)
static struct multi_instance * multi_learn_addr(struct multi_context *m, struct multi_instance *mi, const struct mroute_addr *addr, const unsigned int flags)
static void multi_schedule_context_wakeup(struct multi_context *m, struct multi_instance *mi)
bool multi_check_push_ifconfig_ipv6_extra_route(const struct options *o, const struct in6_addr *dest)
Determines if the ifconfig_ipv6_local address falls into the range of the local IP addresses of the V...
static void multi_unlearn_in_addr_t(struct multi_context *m, struct multi_instance *mi, in_addr_t a)
static void multi_client_connect_early_setup(struct multi_context *m, struct multi_instance *mi)
static void multi_reap_free(struct multi_reap *mr)
static bool ccs_gen_deferred_ret_file(struct multi_instance *mi)
Create a temporary file for the return value of client connect and puts it into the client_connect_de...
static void multi_process_float(struct multi_context *m, struct multi_instance *mi, struct link_socket *sock)
Handles peer floating.
static void multi_reap_range(const struct multi_context *m, uint32_t start_bucket, uint32_t end_bucket)
struct multi_instance * multi_create_instance(struct multi_context *m, const struct mroute_addr *real, struct link_socket *sock)
static void multi_add_iroutes(struct multi_context *m, struct multi_instance *mi)
void multi_ifconfig_pool_persist(struct multi_context *m, bool force)
static enum client_connect_return multi_client_connect_compress_migrate(struct multi_context *m, struct multi_instance *mi, bool deferred, uint64_t *option_types_found)
Do the necessary modification for doing the compress migrate.
static void multi_top_free(struct multi_context *m)
static void multi_signal_instance(struct multi_context *m, struct multi_instance *mi, const int sig)
void multi_reap_process_dowork(const struct multi_context *m)
static bool override_locked_username(struct multi_instance *mi)
Overrides the locked username with the username of –override-username.
static int management_callback_n_clients(void *arg)
bool multi_process_signal(struct multi_context *m)
static void multi_select_virtual_addr(struct multi_context *m, struct multi_instance *mi)
static bool multi_check_dest_addr_allowed(struct multi_context *m, struct multi_instance *mi, struct mroute_addr *real)
This methods checks if a client instance is allowed to use an address.
static void multi_get_timeout(struct multi_context *multi, struct timeval *timeval)
Determines the earliest wakeup interval based on periodic operations.
void multi_close_instance_on_signal(struct multi_context *m, struct multi_instance *mi)
bool multi_process_post(struct multi_context *m, struct multi_instance *mi, const unsigned int flags)
Perform postprocessing of a VPN tunnel instance.
static void multi_connection_established(struct multi_context *m, struct multi_instance *mi)
void multi_process_per_second_timers_dowork(struct multi_context *m)
static void multi_set_virtual_addr_env(struct multi_instance *mi)
static void multi_client_connect_setenv(struct multi_instance *mi)
struct multi_instance * multi_get_queue(struct mbuf_set *ms)
static void setenv_stats(struct context *c)
bool multi_process_timeout(struct multi_context *m, const unsigned int mpp_flags)
static void multi_unlearn_addr(struct multi_context *m, struct multi_instance *mi, const struct mroute_addr *addr)
static int management_callback_kill_by_cn(void *arg, const char *del_cn)
static void multi_client_disconnect_script(struct multi_instance *mi)
static bool stale_route_check_trigger(struct multi_context *m)
struct multi_instance * lookup_by_cid(struct multi_context *m, const unsigned long cid)
static bool management_kill_by_cid(void *arg, const unsigned long cid, const char *kill_msg)
static enum client_connect_return multi_client_connect_call_script(struct multi_context *m, struct multi_instance *mi, bool deferred, uint64_t *option_types_found)
Runs the –client-connect script if one is defined.
static void multi_init(struct context *t)
static void generate_prefix(struct multi_instance *mi)
static void multi_del_iroutes(struct multi_context *m, struct multi_instance *mi)
static enum client_connect_return multi_client_connect_call_plugin_v1(struct multi_context *m, struct multi_instance *mi, bool deferred, uint64_t *option_types_found)
enum client_connect_return(* multi_client_connect_handler)(struct multi_context *m, struct multi_instance *mi, bool from_deferred, uint64_t *option_types_found)
static void management_delete_event(void *arg, event_t event)
static uint64_t cid_hash_function(const void *key, const uint8_t hash_key[HASH_KEY_LEN])
static bool multi_client_setup_dco_initial(struct multi_context *m, struct multi_instance *mi, struct gc_arena *gc)
enum client_connect_return multi_client_connect_mda(struct multi_context *m, struct multi_instance *mi, bool deferred, uint64_t *option_types_found)
static void multi_uninit(struct multi_context *m)
const char * multi_instance_string(const struct multi_instance *mi, bool null, struct gc_arena *gc)
static unsigned int compute_wakeup_sigma(const struct timeval *delta)
static bool learn_address_script(const struct multi_context *m, const struct multi_instance *mi, const char *op, const struct mroute_addr *addr)
static void multi_unicast(struct multi_context *m, const struct buffer *buf, struct multi_instance *mi)
static void multi_client_connect_post(struct multi_context *m, struct multi_instance *mi, const char *dc_file, uint64_t *option_types_found)
void multi_close_instance(struct multi_context *m, struct multi_instance *mi, bool shutdown)
static bool management_client_pending_auth(void *arg, const unsigned long cid, const unsigned int mda_key_id, const char *extra, unsigned int timeout)
static void multi_push_restart_schedule_exit(struct multi_context *m, bool next_server)
static void multi_top_init(struct context *top)
static struct tls_session * lookup_session_by_mda_key_id(struct tls_multi *multi, const unsigned int mda_key_id)
static bool ccs_gen_config_file(struct multi_instance *mi)
Create a temporary file for the config directives of the client connect script and puts it into the c...
static enum client_connect_return multi_client_connect_call_plugin_v2(struct multi_context *m, struct multi_instance *mi, bool deferred, uint64_t *option_types_found)
static void check_stale_routes(struct multi_context *m)
bool multi_check_push_ifconfig_extra_route(const struct options *o, in_addr_t dest)
Determines if the ifconfig_push_local address falls into the range of the local IP addresses of the V...
static void multi_process_incoming_link_data(struct multi_context *m, bool floated, struct link_socket *sock)
Process incoming data packet from clients.
static bool management_client_auth(void *arg, const unsigned long cid, const unsigned int mda_key_id, const bool auth, const char *reason, const char *client_reason, struct buffer_list *cc_config)
static void multi_client_connect_late_setup(struct multi_context *m, struct multi_instance *mi, const uint64_t option_types_found)
static void multi_bcast(struct multi_context *m, const struct buffer *buf, const struct multi_instance *sender_instance, uint16_t vid)
static int management_callback_kill_by_addr(void *arg, const in_addr_t addr, const uint16_t port, const uint8_t proto)
static void multi_reap_all(const struct multi_context *m)
static void multi_print_status(struct multi_context *m, struct status_output *so, const int version)
void route_quota_exceeded(const struct multi_instance *mi)
void ungenerate_prefix(struct multi_instance *mi)
void multi_assign_peer_id(struct multi_context *m, struct multi_instance *mi)
Assigns a peer-id to a a client and adds the instance to the the instances array of the multi_context...
static struct multi_reap * multi_reap_new(uint32_t buckets_per_pass)
static void multi_delete_dup(struct multi_context *m, struct multi_instance *new_mi)
static struct multi_instance * multi_get_instance_by_virtual_addr(struct multi_context *m, const struct mroute_addr *addr, bool cidr_routing)
void init_management_callback_multi(struct multi_context *m)
static void multi_unlearn_in6_addr(struct multi_context *m, struct multi_instance *mi, struct in6_addr a6)
static void multi_add_mbuf(struct multi_context *m, struct multi_instance *mi, struct mbuf_buffer *mb)
static enum client_connect_return ccs_test_deferred_ret_file(struct multi_instance *mi)
Tests whether the deferred return value file exists and returns the contained return value.
static void multi_client_connect_post_plugin(struct multi_context *m, struct multi_instance *mi, const struct plugin_return *pr, uint64_t *option_types_found)
static uint32_t reap_buckets_per_pass(uint32_t n_buckets)
static char * management_get_peer_info(void *arg, const unsigned long cid)
static bool multi_client_set_protocol_options(struct context *c)
Calculates the options that depend on the client capabilities based on local options and available pe...
void unlearn_ifconfig_ipv6(struct multi_context *m, struct multi_instance *mi)
static struct multi_instance * multi_learn_in_addr_t(struct multi_context *m, struct multi_instance *mi, in_addr_t a, int netbits, bool primary)
static bool is_exit_restart(int sig)
static bool ifconfig_push_constraint_satisfied(const struct context *c)
static void set_cc_config(struct multi_instance *mi, struct buffer_list *cc_config)
void multi_process_drop_outgoing_tun(struct multi_context *m, const unsigned int mpp_flags)
static bool cid_compare_function(const void *key1, const void *key2)
static void multi_client_disconnect_setenv(struct multi_instance *mi)
void unlearn_ifconfig(struct multi_context *m, struct multi_instance *mi)
void update_vhash(struct multi_context *m, struct multi_instance *mi, const char *new_ip, const char *new_ipv6)
Update the vhash with new IP/IPv6 addresses in the multi_context when a push-update message containin...
static bool multi_client_generate_tls_keys(struct context *c)
Generates the data channel keys.
static enum client_connect_return multi_client_connect_source_ccd(struct multi_context *m, struct multi_instance *mi, bool deferred, uint64_t *option_types_found)
Try to source a dynamic config file from the –client-config-dir directory.
static struct multi_instance * multi_learn_in6_addr(struct multi_context *m, struct multi_instance *mi, struct in6_addr a6, int netbits, bool primary)
static void management_callback_status(void *arg, const int version, struct status_output *so)
static void ccs_delete_config_file(struct multi_instance *mi)
Deletes the temporary file for the config directives of the client connect script and removes it into...
static void ccs_delete_deferred_ret_file(struct multi_instance *mi)
Delete the temporary file for the return value of client connect It also removes it from client_conne...
static const multi_client_connect_handler client_connect_handlers[]
static enum client_connect_return multi_client_connect_script_deferred(struct multi_context *m, struct multi_instance *mi, uint64_t *option_types_found)
Header file for server-mode related structures and functions.
client_connect_return
Return values used by the client connect call-back functions.
static bool multi_output_queue_ready(const struct multi_context *m, const struct multi_instance *mi)
#define MULTI_PREFIX_MAX_LENGTH
#define MULTI_CHECK_SIG(m)
static void set_prefix(struct multi_instance *mi)
static void multi_route_del(struct multi_route *route)
static void multi_reap_process(const struct multi_context *m)
static void route_quota_inc(struct multi_instance *mi)
void multi_process_incoming_dco(dco_context_t *dco)
Process an incoming DCO message (from kernel space).
#define MULTI_ROUTE_CACHE
static void clear_prefix(void)
static bool multi_route_defined(const struct multi_context *m, const struct multi_route *r)
#define MULTI_CACHE_ROUTE_TTL
#define MPP_CLOSE_ON_SIGNAL
static void multi_instance_dec_refcount(struct multi_instance *mi)
static void multi_instance_inc_refcount(struct multi_instance *mi)
static void multi_get_timeout_instance(struct multi_context *m, struct timeval *dest)
#define CLIENT_CONNECT_OPT_MASK
static void multi_set_pending(struct multi_context *m, struct multi_instance *mi)
#define MULTI_ROUTE_AGEABLE
#define MULTI_ROUTE_PERMANENT
static void multi_process_per_second_timers(struct multi_context *m)
static bool route_quota_test(const struct multi_instance *mi)
struct multi_io * multi_io_init(const int maxclients)
void multi_io_process_io(struct multi_context *m)
void multi_io_free(struct multi_io *multi_io)
int multi_io_wait(struct multi_context *m)
void multi_io_action(struct multi_context *m, struct multi_instance *mi, int action, bool poll)
static bool check_debug_level(msglvl_t level)
static bool is_cas_pending(enum multi_status cas)
const char title_string[]
bool has_udp_in_local_list(const struct options *options)
static bool dco_enabled(const struct options *o)
Returns whether the current configuration has dco enabled.
void options_string_import(struct options *options, const char *config, const msglvl_t msglevel, const uint64_t permission_mask, uint64_t *option_types_found, struct env_set *es)
void options_server_import(struct options *o, const char *filename, msglvl_t msglevel, uint64_t permission_mask, uint64_t *option_types_found, struct env_set *es)
const char * time_string(time_t t, tv_usec_t usec, bool show_usec, struct gc_arena *gc)
struct frequency_limit * frequency_limit_init(int max, int per)
void frequency_limit_free(struct frequency_limit *f)
static int openvpn_gettimeofday(struct timeval *tv, void *tz)
static void tv_add(struct timeval *dest, const struct timeval *src)
@ OVPN_DEL_PEER_REASON_EXPIRED
@ OVPN_DEL_PEER_REASON_TRANSPORT_DISCONNECT
@ OVPN_DEL_PEER_REASON_TRANSPORT_ERROR
@ OVPN_DEL_PEER_REASON_USERSPACE
void plugin_return_free(struct plugin_return *pr)
void plugin_return_get_column(const struct plugin_return *src, struct plugin_return *dest, const char *colname)
bool plugin_defined(const struct plugin_list *pl, const int type)
static void plugin_return_init(struct plugin_return *pr)
static int plugin_call(const struct plugin_list *pl, const int type, const struct argv *av, struct plugin_return *pr, struct env_set *es)
static bool plugin_return_defined(const struct plugin_return *pr)
ifconfig_pool_handle ifconfig_pool_acquire(struct ifconfig_pool *pool, in_addr_t *local, in_addr_t *remote, struct in6_addr *remote_ipv6, const char *common_name)
bool ifconfig_pool_release(struct ifconfig_pool *pool, ifconfig_pool_handle hand, const bool hard)
void ifconfig_pool_write(struct ifconfig_pool_persist *persist, const struct ifconfig_pool *pool)
bool ifconfig_pool_write_trigger(struct ifconfig_pool_persist *persist)
void ifconfig_pool_free(struct ifconfig_pool *pool)
void ifconfig_pool_read(struct ifconfig_pool_persist *persist, struct ifconfig_pool *pool)
struct ifconfig_pool * ifconfig_pool_init(const bool ipv4_pool, enum pool_type type, in_addr_t start, in_addr_t end, const bool duplicate_cn, const bool ipv6_pool, const struct in6_addr ipv6_base, const int ipv6_netbits)
int process_incoming_push_request(struct context *c)
void push_option(struct options *o, const char *opt, msglvl_t msglevel)
void send_restart(struct context *c, const char *kill_msg)
bool send_auth_pending_messages(struct tls_multi *tls_multi, struct tls_session *session, const char *extra, unsigned int timeout)
Sends the auth pending control messages to a client.
void remove_iroutes_from_push_route_list(struct options *o)
bool management_callback_send_push_update_by_cid(void *arg, unsigned long cid, const char *options)
bool management_callback_send_push_update_broadcast(void *arg, const char *options)
void initial_rate_limit_free(struct initial_packet_rate_limit *irl)
free the initial-packet rate limiter structure
struct initial_packet_rate_limit * initial_rate_limit_init(int max_per_period, int period_length)
allocate and initialize the initial-packet rate limiter structure
bool ipv6_net_contains_host(const struct in6_addr *network, unsigned int bits, const struct in6_addr *host)
check whether an IPv6 host address is covered by a given network/bits
static int openvpn_run_script(const struct argv *a, const struct env_set *es, const unsigned int flags, const char *hook)
Will run a script and return the exit code of the script if between 0 and 255, -1 otherwise.
void schedule_remove_entry(struct schedule *s, struct schedule_entry *e)
struct schedule * schedule_init(void)
void schedule_free(struct schedule *s)
static void schedule_add_entry(struct schedule *s, struct schedule_entry *e, const struct timeval *tv, unsigned int sigma)
Add a struct schedule_entry to the scheduler btree or update an existing entry with a new wakeup time...
int signal_reset(struct signal_info *si, int signum)
Clear the signal if its current value equals signum.
void remap_signal(struct context *c)
void throw_signal(const int signum)
Throw a hard signal.
void print_signal(const struct signal_info *si, const char *title, msglvl_t msglevel)
void register_signal(struct signal_info *si, int signum, const char *signal_text)
Register a soft signal in the signal_info struct si respecting priority.
void setenv_trusted(struct env_set *es, const struct link_socket_info *info)
void setenv_in_addr_t(struct env_set *es, const char *name_prefix, in_addr_t addr, const unsigned int flags)
void setenv_in6_addr(struct env_set *es, const char *name_prefix, const struct in6_addr *addr, const unsigned int flags)
const char * print_in6_addr(struct in6_addr a6, unsigned int flags, struct gc_arena *gc)
const char * print_in_addr_t(in_addr_t addr, unsigned int flags, struct gc_arena *gc)
#define IA_EMPTY_IF_UNDEF
static bool proto_is_dgram(int proto)
Return if the protocol is datagram (UDP).
#define SA_SET_IF_NONZERO
void tls_update_remote_addr(struct tls_multi *multi, const struct link_socket_actual *addr)
Updates remote address in TLS sessions.
void tls_session_soft_reset(struct tls_multi *tls_multi)
bool tls_session_update_crypto_params(struct tls_multi *multi, struct tls_session *session, struct options *options, struct frame *frame, struct frame *frame_fragment, struct link_socket_info *lsi, dco_context_t *dco)
Update TLS session crypto parameters (cipher and auth) and derive data channel keys based on the supp...
#define IV_PROTO_CC_EXIT_NOTIFY
Support for explicit exit notify via control channel This also includes support for the protocol-flag...
#define IV_PROTO_DATA_EPOCH
Support the extended packet id and epoch format for data channel packets.
#define IV_PROTO_DATA_V2
Support P_DATA_V2.
#define IV_PROTO_TLS_KEY_EXPORT
Supports key derivation via TLS key material exporter [RFC5705].
#define IV_PROTO_DYN_TLS_CRYPT
Support to dynamic tls-crypt (renegotiation with TLS-EKM derived tls-crypt key).
#define IV_PROTO_REQUEST_PUSH
Assume client will send a push request and server does not need to wait for a push-request to send a ...
#define IV_PROTO_NCP_P2P
Support doing NCP in P2P mode.
@ CAS_PENDING_DEFERRED
Waiting on an async option import handler.
@ CAS_WAITING_AUTH
Initial TLS connection established but deferred auth is not yet finished.
@ CAS_PENDING_DEFERRED_PARTIAL
at least handler succeeded but another is still pending
@ CAS_PENDING
Options import (Connect script/plugin, ccd,...).
@ CAS_FAILED
Option import failed or explicitly denied the client.
@ KS_AUTH_FALSE
Key state is not authenticated.
@ KS_AUTH_DEFERRED
Key state authentication is being deferred, by async auth.
static const struct key_state * get_primary_key(const struct tls_multi *multi)
gets an item of key_state objects in the order they should be scanned by data channel modules.
#define SSLF_USERNAME_AS_COMMON_NAME
char * ncp_get_best_cipher(const char *server_list, const char *peer_info, const char *remote_cipher, struct gc_arena *gc)
Iterates through the ciphers in server_list and return the first cipher that is also supported by the...
const char * tls_peer_ncp_list(const char *peer_info, struct gc_arena *gc)
Returns the support cipher list from the peer according to the IV_NCP and IV_CIPHER values in peer_in...
const char * ncp_expanded_ciphers(struct options *o, struct gc_arena *gc)
returns the o->ncp_ciphers in brackets, e.g.
Control Channel SSL/Data dynamic negotiation Module This file is split from ssl.h to be able to unit ...
static unsigned int extract_iv_proto(const char *peer_info)
Extracts the IV_PROTO variable and returns its value or 0 if it cannot be extracted.
bool ssl_verify_username_length(struct tls_session *session, const char *username)
Checks if the username length is valid to use.
bool tls_authenticate_key(struct tls_multi *multi, const unsigned int mda_key_id, const bool auth, const char *client_reason)
bool cert_hash_compare(const struct cert_hash_set *chs1, const struct cert_hash_set *chs2)
Compares certificates hashes, returns true if hashes are equal.
void tls_lock_cert_hash_set(struct tls_multi *multi)
Locks the certificate hash set used in the given tunnel.
void tls_lock_common_name(struct tls_multi *multi)
Locks the common name field for the given tunnel.
const char * tls_username(const struct tls_multi *multi, const bool null)
Returns the username field for the given tunnel.
void set_common_name(struct tls_session *session, const char *common_name)
Sets the common name field for the given tunnel.
void auth_set_client_reason(struct tls_multi *multi, const char *client_reason)
Sets the reason why authentication of a client failed.
const char * tls_common_name(const struct tls_multi *multi, const bool null)
Returns the common name field for the given tunnel.
Control Channel Verification Module.
bool status_trigger(struct status_output *so)
void status_printf(struct status_output *so, const char *format,...)
struct status_output * status_open(const char *filename, const int refresh_freq, const int msglevel, const struct virtual_output *vout, const unsigned int flags)
void status_flush(struct status_output *so)
void status_reset(struct status_output *so)
bool status_close(struct status_output *so)
One node in a buffer_list linked list.
struct buffer_entry * next
Pointer to the next node, or NULL.
struct buffer buf
The buffer stored in this list node.
A singly-linked list of buffers, with head/tail pointers for O(1) push.
struct buffer_entry * head
Next item to pop/peek.
Wrapper structure for dynamically allocated memory.
uint8_t * data
Pointer to the allocated memory.
int len
Length in bytes of the actual content within the allocated memory.
Detached client connection state.
uint64_t option_types_found
char * config_file
The temporary file name that contains the config directives returned by the client-connect script.
char * deferred_ret_file
The temporary file name that contains the return status of the client-connect script if it exits with...
int explicit_exit_notification
struct ifconfig_pool_persist * ifconfig_pool_persist
struct status_output * status_output
struct tuntap * tuntap
Tun/tap virtual network interface.
bool push_request_received
counter_type link_read_bytes
counter_type link_write_bytes
bool push_ifconfig_ipv6_defined
struct fragment_master * fragment
bool push_ifconfig_defined
counter_type dco_read_bytes
struct man_def_auth_context mda_context
counter_type dco_write_bytes
struct tls_multi * tls_multi
TLS state structure for this VPN tunnel.
struct in6_addr push_ifconfig_ipv6_remote
struct link_socket_actual from
struct frame frame_fragment
int push_ifconfig_ipv6_netbits
struct in6_addr push_ifconfig_ipv6_local
struct link_socket ** link_sockets
in_addr_t push_ifconfig_local_alias
struct link_socket_info ** link_socket_infos
struct link_socket_actual * to_link_addr
in_addr_t push_ifconfig_remote_netmask
struct timeval timeval
Time to next event of timers and similar.
struct event_set * event_set
struct context_buffers * buffers
in_addr_t push_ifconfig_local
Contains all state information for one tunnel.
int mode
Role of this context within the OpenVPN process.
struct multi_context * multi
Pointer to the main P2MP context.
bool did_dco_iroutes
Whether DCO iroutes have been installed.
struct signal_info * sig
Internal error signaling object.
openvpn_net_ctx_t net_ctx
Networking API opaque context.
struct plugin_list * plugins
List of plug-ins.
struct context_2 c2
Level 2 context.
struct env_set * es
Set of environment variables.
struct options options
Options loaded from command line or configuration file.
struct context_1 c1
Level 1 context.
Security parameter state for processing data channel packets.
struct key_ctx_bi key_ctx_bi
OpenSSL cipher and HMAC contexts for both sending and receiving directions.
union event_arg::@352313260244035237115140212234220346176163201310 u
struct multi_instance * mi
struct buffer outgoing
Buffer containing the remaining parts of the fragmented packet being sent.
Packet geometry parameters.
struct frame::@074234134026241341315172337061247271261307273127 buf
int payload_size
the maximum size that a payload that our buffers can hold from either tun device or network link.
int headroom
the headroom in the buffer, this is choosen to allow all potential header to be added before the pack...
Garbage collection arena used to keep track of dynamically allocated memory.
struct iroute_ipv6 * next
Container for bidirectional cipher and HMAC key material.
Security parameter state of one TLS and data channel key session.
struct auth_deferred_status plugin_auth
struct auth_deferred_status script_auth
enum ks_auth_state authenticated
Container for unidirectional cipher and HMAC key material.
struct openvpn_sockaddr dest
struct link_socket_actual actual
struct link_socket_addr * lsa
struct link_socket_info info
char *(* get_peer_info)(void *arg, const unsigned long cid)
bool(* client_auth)(void *arg, const unsigned long cid, const unsigned int mda_key_id, const bool auth, const char *reason, const char *client_reason, struct buffer_list *cc_config)
int(* kill_by_addr)(void *arg, const in_addr_t addr, const uint16_t port, const uint8_t proto)
void(* delete_event)(void *arg, event_t event)
bool(* push_update_broadcast)(void *arg, const char *options)
bool(* push_update_by_cid)(void *arg, unsigned long cid, const char *options)
bool(* client_pending_auth)(void *arg, const unsigned long cid, const unsigned int kid, const char *extra, unsigned int timeout)
int(* n_clients)(void *arg)
void(* status)(void *arg, const int version, struct status_output *so)
void(* show_net)(void *arg, const msglvl_t msglevel)
int(* kill_by_cn)(void *arg, const char *common_name)
bool(* kill_by_cid)(void *arg, const unsigned long cid, const char *kill_msg)
struct mbuf_buffer * buffer
struct multi_instance * instance
uint8_t addr[OPENVPN_ETH_ALEN]
struct mroute_addr::@201361377123046052363312040316220023015150251140::@324142022017217332104337017226063207330251301017 v6
struct mroute_addr::@201361377123046052363312040316220023015150251140::@363302133323255313212060077174173034011260361234 v4
unsigned int cache_generation
uint8_t net_len[MR_HELPER_NET_LEN]
Main OpenVPN server state structure.
struct schedule * schedule
struct mbuf_set * mbuf
Set of buffers for passing data channel packets between VPN tunnel instances.
struct initial_packet_rate_limit * initial_rate_limiter
struct deferred_signal_schedule_entry deferred_shutdown_signal
uint32_t max_peerid
highest currently allocated peer-id and maximum allocated/valid index in instances
struct multi_reap * reaper
struct multi_io * multi_io
I/O state and events tracker.
struct hash * hash
VPN tunnel instances indexed by real address of the remote peer.
unsigned long cid_counter
struct event_timeout stale_routes_check_et
struct ifconfig_pool * ifconfig_pool
struct frequency_limit * new_connection_limiter
struct context top
Storage structure for process-wide configuration.
struct multi_instance * pending
struct hash * vhash
VPN tunnel instances indexed by virtual address of remote hosts.
struct multi_instance ** instances
Array of multi_instances with the size of max_clients.
struct multi_instance ** mpp_touched
struct multi_instance * earliest_wakeup
struct mroute_helper * route_helper
Server-mode state structure for one single VPN tunnel.
struct buffer_list * cc_config
struct client_connect_defer_state client_connect_defer_state
time_t created
Time at which a VPN tunnel instance was created.
char msg_prefix[MULTI_PREFIX_MAX_LENGTH]
struct mroute_addr real
External network address of the remote peer.
ifconfig_pool_handle vaddr_handle
struct in6_addr reporting_addr_ipv6
struct event_arg ev_arg
this struct will store a pointer to either mi or link_socket, depending on the event type,...
struct context context
The context structure storing state for this VPN tunnel.
uint32_t buckets_per_pass
unsigned int cache_generation
struct multi_instance * instance
union openvpn_sockaddr::@051240265251124304325377241125360350250341115171 addr
struct compress_options comp
int push_ifconfig_ipv6_netbits
int max_routes_per_client
const char * ncp_ciphers_conf
The original ncp_ciphers specified by the user in the configuration.
in_addr_t push_ifconfig_constraint_network
unsigned int imported_protocol_flags
int stale_routes_ageing_time
bool use_peer_id
Whether the data channel uses the DATA_V2 header (peer-id).
in_addr_t ifconfig_pool_netmask
const char * ifconfig_ipv6_local
bool push_ifconfig_defined
bool ifconfig_pool_defined
in_addr_t ifconfig_pool_end
bool ifconfig_ipv6_pool_defined
const char * client_disconnect_script
const char * ifconfig_local
struct connection_entry ce
struct iroute_ipv6 * iroutes_ipv6
in_addr_t push_ifconfig_local_alias
uint32_t virtual_hash_size
const char * learn_address_script
int stale_routes_check_interval
int ifconfig_ipv6_pool_netbits
in_addr_t push_ifconfig_constraint_netmask
bool enable_ncp_fallback
If defined fall back to ciphername if NCP fails.
in_addr_t push_ifconfig_local
bool push_ifconfig_constraint_defined
bool force_key_material_export
struct in6_addr push_ifconfig_ipv6_remote
const char * client_connect_script
bool push_ifconfig_ipv6_defined
const char * override_username
struct in6_addr push_ifconfig_ipv6_local
const char * ifconfig_remote_netmask
in_addr_t ifconfig_pool_start
in_addr_t push_ifconfig_remote_netmask
struct in6_addr ifconfig_ipv6_pool_base
const char * client_config_dir
int ifconfig_ipv6_netbits
struct openvpn_plugin_string_list * list[MAX_PLUGINS]
volatile int signal_received
Security parameter state for a single VPN tunnel.
char * auth_token_initial
The first auth-token we sent to a client.
bool remote_usescomp
remote announced comp-lzo in OCC string
char * peer_info
A multi-line string of general-purpose info received from peer over control channel.
char * remote_ciphername
cipher specified in peer's config file
char * locked_username
The locked username is the username we assume the client is using.
enum multi_status multi_state
struct tls_session session[TM_SIZE]
Array of tls_session objects representing control channel sessions with the remote peer.
struct cert_hash_set * locked_cert_hash_set
char * locked_cn
Our locked common name, username, and cert hashes (cannot change during the life of this tls_multi ob...
char * locked_original_username
The username that client initially used before being overridden by –override-user.
int dco_peer_id
This is the handle that DCO uses to identify this session with the kernel.
bool data_epoch_supported
whether our underlying data channel supports new data channel features (epoch keys with AEAD tag at t...
Security parameter state of a single session within a VPN tunnel.
struct key_state key[KS_SIZE]
struct in6_addr local_ipv6
char username[USER_PASS_LEN]
static int cleanup(void **state)
int dev_type_enum(const char *dev, const char *dev_type)
#define TUNNEL_TOPOLOGY(tt)
int16_t vlan_decapsulate(const struct context *c, struct buffer *buf)
bool vlan_is_tagged(const struct buffer *buf)