46#define MULTI_PREFIX_MAX_LENGTH 256
137#ifdef ENABLE_MANAGEMENT
147#ifdef ENABLE_ASYNC_PUSH
191#ifdef ENABLE_MANAGEMENT
214#ifdef ENABLE_ASYNC_PUSH
216 struct hash *inotify_watchers;
241#define MULTI_ROUTE_CACHE (1<<0)
242#define MULTI_ROUTE_AGEABLE (1<<1)
292#define MPP_PRE_SELECT (1<<0)
293#define MPP_CONDITIONAL_PRE_SELECT (1<<1)
294#define MPP_CLOSE_ON_SIGNAL (1<<2)
295#define MPP_RECORD_TOUCH (1<<3)
397#ifdef ENABLE_ASYNC_PUSH
405void multi_process_file_closed(
struct multi_context *m,
const unsigned int mpp_flags);
546#ifdef MULTI_DEBUG_EVENT_LOOP
558#ifdef MULTI_DEBUG_EVENT_LOOP
573#define REAP_MAX_WAKEUP 10
574#define REAP_DIVISOR 256
582#define MULTI_CACHE_ROUTE_TTL 60
618 struct timeval tv, current;
665#ifdef MULTI_DEBUG_EVENT_LOOP
666 printf(
"%s -> TUN len=%d\n",
678#define CLIENT_CONNECT_OPT_MASK (OPT_P_INSTANCE | OPT_P_INHERIT \
679 |OPT_P_PUSH | OPT_P_TIMER | OPT_P_CONFIG \
680 |OPT_P_ECHO | OPT_P_COMP | OPT_P_SOCKFLAGS)
696#define MULTI_CHECK_SIG(m) EVENT_LOOP_CHECK_SIGNAL(&(m)->top, multi_process_signal, (m))
static void gc_free(struct gc_arena *a)
Interface functions to the internal and external multiplexers.
void tunnel_server(struct context *top)
Main event loop for OpenVPN in server mode.
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.
void process_outgoing_link(struct context *c, struct link_socket *sock)
Write a packet to the external network interface.
void process_outgoing_tun(struct context *c, struct link_socket *in_sock)
Write a packet to the virtual tun/tap network interface.
static bool multi_process_outgoing_tun(struct multi_context *m, const unsigned int mpp_flags)
Send a packet over the virtual tun/tap network interface to its locally reachable destination.
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 ...
static bool mbuf_defined(const struct mbuf_set *ms)
static unsigned int mbuf_len(const struct mbuf_set *ms)
bool multi_process_incoming_dco(struct multi_context *m)
Process an incoming DCO message (from kernel space).
client_connect_return
Return values used by the client connect call-back functions.
struct multi_instance * multi_create_instance(struct multi_context *m, const struct mroute_addr *real, struct link_socket *sock)
static bool multi_output_queue_ready(const struct multi_context *m, const struct multi_instance *mi)
void multi_ifconfig_pool_persist(struct multi_context *m, bool force)
#define MULTI_PREFIX_MAX_LENGTH
void multi_reap_process_dowork(const struct multi_context *m)
static void route_quota_dec(struct multi_instance *mi)
bool multi_process_signal(struct multi_context *m)
void multi_init(struct multi_context *m, struct context *t)
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.
void multi_process_per_second_timers_dowork(struct multi_context *m)
struct multi_instance * multi_get_queue(struct mbuf_set *ms)
bool multi_process_timeout(struct multi_context *m, const unsigned int mpp_flags)
static void set_prefix(struct multi_instance *mi)
void multi_process_float(struct multi_context *m, struct multi_instance *mi, struct link_socket *sock)
Handles peer floating.
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)
#define MULTI_ROUTE_CACHE
const char * multi_instance_string(const struct multi_instance *mi, bool null, struct gc_arena *gc)
static void clear_prefix(void)
void multi_close_instance(struct multi_context *m, struct multi_instance *mi, bool shutdown)
static bool multi_route_defined(const struct multi_context *m, const struct multi_route *r)
static struct multi_instance * multi_process_outgoing_link_pre(struct multi_context *m)
static void multi_instance_dec_refcount(struct multi_instance *mi)
void multi_add_mbuf(struct multi_context *m, struct multi_instance *mi, struct mbuf_buffer *mb)
static void multi_instance_inc_refcount(struct multi_instance *mi)
void route_quota_exceeded(const struct multi_instance *mi)
void ungenerate_prefix(struct multi_instance *mi)
void multi_top_free(struct multi_context *m)
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 void multi_get_timeout(struct multi_context *m, struct timeval *dest)
static void multi_set_pending(struct multi_context *m, struct multi_instance *mi)
void multi_top_init(struct multi_context *m, struct context *top)
void init_management_callback_multi(struct multi_context *m)
#define MULTI_ROUTE_AGEABLE
void multi_process_drop_outgoing_tun(struct multi_context *m, const unsigned int mpp_flags)
static bool multi_process_outgoing_link_dowork(struct multi_context *m, struct multi_instance *mi, const unsigned int mpp_flags)
static void multi_process_per_second_timers(struct multi_context *m)
void multi_print_status(struct multi_context *m, struct status_output *so, const int version)
static bool route_quota_test(const struct multi_instance *mi)
void multi_uninit(struct multi_context *m)
static void msg_set_prefix(const char *prefix)
static void tv_delta(struct timeval *dest, const struct timeval *t1, const struct timeval *t2)
static int openvpn_gettimeofday(struct timeval *tv, void *tz)
static struct schedule_entry * schedule_get_earliest_wakeup(struct schedule *s, struct timeval *wakeup)
Wrapper structure for dynamically allocated memory.
int len
Length in bytes of the actual content within the allocated memory.
Detached client connection state.
char * config_file
The temporary file name that contains the config directives returned by the client-connect script.
unsigned int option_types_found
char * deferred_ret_file
The temporary file name that contains the return status of the client-connect script if it exits with...
struct link_socket ** link_sockets
Contains all state information for one tunnel.
struct context_2 c2
Level 2 context.
struct options options
Options loaded from command line or configuration file.
Garbage collection arena used to keep track of dynamically allocated memory.
struct that handles all the rate limiting logic for initial responses
unsigned int cache_generation
Main OpenVPN server state structure.
struct schedule * schedule
time_t per_second_trigger
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
struct link_socket_actual * hmac_reply_dest
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.
struct context_buffers * context_buffers
unsigned long cid_counter
struct event_timeout stale_routes_check_et
struct link_socket * hmac_reply_ls
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 hash * iter
VPN tunnel instances indexed by real address of the remote peer, optimized for iteration.
struct multi_instance ** instances
Array of multi_instances.
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 mbuf_set * tcp_link_out_deferred
struct buffer_list * cc_config
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.
unsigned int cache_generation
struct multi_instance * instance
int max_routes_per_client
void vlan_process_outgoing_tun(struct multi_context *m, struct multi_instance *mi)