63 for (
int i = 0;
i <
c->c1.link_sockets_num;
i++)
138 if (sec < c->c2.timeval.tv_sec)
289#if defined(__GNUC__) || defined(__clang__)
290#pragma GCC diagnostic push
291#pragma GCC diagnostic ignored "-Wsign-conversion"
309 while (
BLEN(&buf) > 1)
354 if (
c->c2.tls_multi &&
c->options.pull)
356#ifdef ENABLE_MANAGEMENT
366 if (
c->c2.push_request_timeout <
now)
368 c->c2.push_request_timeout =
now +
c->options.handshake_window;
398 msg(msglevel,
"SENT CONTROL [%s]: '%s' (status=%d)",
458 msg(
D_ROUTE,
"Route: Waiting for TUN/TAP interface to come up...");
515 msg(
M_INFO,
"Inactivity timeout (--inactive), exiting");
534 msg(
M_INFO,
"Server poll timeout, restarting");
599#ifdef ENABLE_FRAGMENT
637 if (orig_buf == src_stub->
data && src_stub->
data != storage->
data)
640 *dest_stub = *storage;
644 *dest_stub = *src_stub;
657 const uint8_t *orig_buf = c->
c2.
buf.
data;
662 msg(
M_WARN,
"Attempting to send data packet while data channel offload is in use. "
681 if (c->
c2.comp_context)
683 (*c->
c2.comp_context->alg.compress)(&c->
c2.
buf, b->compress_buf, c->
c2.comp_context,
687#ifdef ENABLE_FRAGMENT
850#ifdef ENABLE_MANAGEMENT
861 if (now < c->c2.coarse_timer_wakeup)
867 const struct timeval save = c->
c2.
timeval;
873 dmsg(
D_INTERVAL,
"TIMER: coarse timer wakeup %" PRIi64
" seconds",
886 const int update_interval = 10;
936 if (size_delta > 0 && *size > size_delta)
967 if (port_share && socket_foreign_protocol_detected(sock))
981 "Connection reset during exit notification period, ignoring [%zd]",
status);
1013 bool decrypt_status =
false;
1030 if (!ask_gremlin(c->
options.gremlin))
1042 fprintf(stderr,
"R");
1058 const uint8_t *ad_start = NULL;
1078 msg(
D_LINK_ERRORS,
"Data Channel Offload doesn't support DATA_V1 packets. "
1079 "Upgrade your server to 2.4.5 or newer.");
1129 "decryption-error");
1139 return decrypt_status;
1144 const uint8_t *orig_buf)
1148#ifdef ENABLE_FRAGMENT
1157 if (c->
c2.comp_context)
1159 (*c->
c2.comp_context->alg.decompress)(&c->
c2.
buf, c->
c2.
buffers->decompress_buf,
1223 const uint8_t *orig_buf = c->
c2.
buf.
data;
1231 const struct sockaddr *float_sa)
1233 if (float_sa->sa_family == AF_INET)
1235 const struct sockaddr_in *float4 = (
struct sockaddr_in *)float_sa;
1240 if (socket_family == AF_INET6)
1242 out_osaddr->
addr.
in6.sin6_family = AF_INET6;
1243 out_osaddr->
addr.
in6.sin6_port = float4->sin_port;
1245 memset(&out_osaddr->
addr.
in6.sin6_addr.s6_addr, 0, 10);
1246 out_osaddr->
addr.
in6.sin6_addr.s6_addr[10] = 0xff;
1247 out_osaddr->
addr.
in6.sin6_addr.s6_addr[11] = 0xff;
1248 memcpy(&out_osaddr->
addr.
in6.sin6_addr.s6_addr[12], &float4->sin_addr.s_addr,
1253 memcpy(&out_osaddr->
addr.
in4, float4,
sizeof(
struct sockaddr_in));
1258 const struct sockaddr_in6 *float6 = (
struct sockaddr_in6 *)float_sa;
1259 memcpy(&out_osaddr->
addr.
in6, float6,
sizeof(
struct sockaddr_in6));
1266#if defined(ENABLE_DCO) && (defined(TARGET_LINUX) || defined(TARGET_FREEBSD))
1275 "%s: received message for mismatching peer-id %d, "
1281 switch (dco->dco_message_type)
1289 "%s: received peer expired notification of for peer-id "
1291 __func__, dco->dco_message_peer_id);
1298 msg(
D_DCO_DEBUG,
"%s: received key rotation notification for peer-id %d", __func__,
1299 dco->dco_message_peer_id);
1304 msg(
D_DCO_DEBUG,
"%s: received message of type %d - ignoring", __func__,
1305 dco->dco_message_type);
1350 msg(
M_INFO,
"TUN/TAP interface has been stopped, exiting");
1359 msg(
M_INFO,
"TUN/TAP I/O operation aborted, restarting");
1386 int ip_hdr_offset = 0;
1389 if (tun_ip_ver == 4)
1392 const int min_ip_header = ip_hdr_offset +
sizeof(
struct openvpn_iphdr);
1393 if (
BLEN(buf) < min_ip_header)
1402 ||
BLENZ(buf) < ip_hdr_offset + ip_hlen +
sizeof(uint16_t) * 2)
1408 if (link_addr->
addr.
sa.sa_family != AF_INET)
1421 const uint8_t *l4_hdr = (uint8_t *)pip + ip_hlen;
1423 uint16_t link_port = ntohs(link_addr->
addr.
in4.sin_port);
1427 uint16_t src_port = ntohs(*(uint16_t *)l4_hdr);
1428 uint16_t dst_port = ntohs(*(uint16_t *)(l4_hdr +
sizeof(uint16_t)));
1429 if ((memcmp(&link_addr->
addr.
in4.sin_addr.s_addr, &pip->
daddr,
sizeof(pip->
daddr)) == 0) && (link_port == dst_port))
1434 msg(
D_LOW,
"Recursive routing detected, packet dropped %s:%" PRIu16
" -> %s",
1441 else if (tun_ip_ver == 6)
1444 const int min_ipv6 = ip_hdr_offset +
sizeof(
struct openvpn_ipv6hdr) + sizeof(uint16_t) * 2;
1445 if (
BLEN(buf) < min_ipv6)
1451 if (link_addr->
addr.
sa.sa_family != AF_INET6)
1465 uint16_t link_port = ntohs(link_addr->
addr.
in6.sin6_port);
1468 const uint8_t *l4_hdr = (uint8_t *)pip6 +
sizeof(
struct openvpn_ipv6hdr);
1469 uint16_t src_port = ntohs(*(uint16_t *)l4_hdr);
1470 uint16_t dst_port = ntohs(*(uint16_t *)(l4_hdr +
sizeof(uint16_t)));
1476 msg(
D_LOW,
"Recursive routing detected, packet dropped %s:%" PRIu16
" -> %s",
1501 fprintf(stderr,
"r");
1518 unsigned int flags =
1545#define MAX_ICMPV6LEN 1280
1581 inet_pton(AF_INET6,
"fe80::7", &pip6out.
saddr);
1595 int totalheader_len = icmpheader_len;
1609 max_payload_size =
max_int(max_payload_size, 64);
1610 const int payload_len =
min_int(max_payload_size,
BLEN(&inputipbuf));
1611 const uint16_t icmp_len = (uint16_t)(
sizeof(
struct openvpn_icmp6hdr) + payload_len);
1619 c->c2.to_tun =
c->c2.buffers->aux_buf;
1624 c->c2.to_link =
c->c2.buffers->aux_buf;
1675 flags &= ~PIP_MSSFIX;
1677#if PASSTOS_CAPABILITY
1680 flags &= ~PIPV4_PASSTOS;
1685 flags &= ~PIPV4_CLIENT_NAT;
1689 flags &= ~PIPV4_EXTRACT_DHCP_ROUTER;
1701#if PASSTOS_CAPABILITY
1791#if PASSTOS_CAPABILITY
1793 link_socket_set_tos(sock);
1800 fprintf(stderr,
"W");
1840 "TCP/UDP packet was truncated/expanded on write to %s (tried=%d,actual=%d)",
1853 bool unreachable = error_code ==
1859 if (size < 0 && unreachable && c->c2.tls_multi
1863 msg(
M_INFO,
"Network unreachable, restarting");
1871 msg(
D_LINK_ERRORS,
"TCP/UDP packet too large on write to %s (tried=%d,max=%d)",
1915 fprintf(stderr,
"w");
1946 "TUN/TAP packet was destructively fragmented on write to %s (tried=%d,actual=%zd)",
2021#ifdef ENABLE_FRAGMENT
2033#if defined(__GNUC__) || defined(__clang__)
2034#pragma GCC diagnostic pop
2040 unsigned int socket = 0;
2138#ifdef ENABLE_MANAGEMENT
2139 static uintptr_t management_shift =
2143#if defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
2154#if defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
2161#ifdef ENABLE_MANAGEMENT
2204 for (i = 0; i <
status; ++i)
2219 shift = socket_shift;
2223 shift = (uintptr_t)e->
arg;
2257#ifdef ENABLE_MANAGEMENT
void receive_acc_message(struct context *c, const struct buffer *buffer)
This method parses an app custom control message and delivers it to the management interface.
void check_send_auth_token(struct context *c)
Checks if the timer to resend the auth-token has expired and if a new auth-token should be send to th...
bool buf_printf(struct buffer *buf, const char *format,...)
printf-style append to a buffer with overflow check.
bool buf_assign(struct buffer *dest, const struct buffer *src)
Assign the content of one buffer to another.
struct buffer alloc_buf_gc(size_t size, struct gc_arena *gc)
Allocate a buffer of the given size under garbage collection.
bool buf_string_match_head_str(const struct buffer *src, const char *match)
Return true if the head of src matches the string match.
#define BSTR(buf)
Return the buffer content pointer cast to char *.
#define BPTR(buf)
Return a pointer to the start of the buffer content.
static bool buf_write_prepend(struct buffer *dest, const void *src, int size)
Prepend data to a buffer.
static bool buf_copy_n(struct buffer *dest, struct buffer *src, int n)
Read n bytes from src and append them to dest.
static void buf_reset(struct buffer *buf)
Reset a buffer to an undefined (unallocated) state.
static bool buf_safe(const struct buffer *buf, size_t len)
Check whether len bytes can be appended to a buffer.
#define CBPTR(buf)
Return a const pointer to the start of the buffer content.
static bool buf_advance(struct buffer *buf, ssize_t size)
Advance the content start of a buffer, consuming bytes from the front.
#define BLEN(buf)
Return the length of the buffer content in bytes.
#define BLENZ(buf)
Return the length of the buffer content as a size_t.
static void gc_free(struct gc_arena *a)
Free all allocations in a garbage collection arena.
#define CBSTR(buf)
Return the buffer content pointer cast to const char *.
#define buf_init(buf, offset)
static struct gc_arena gc_new(void)
Allocate and return a new, empty garbage collection arena.
void client_nat_transform(const struct client_nat_option_list *list, struct buffer *ipbuf, const int direction)
#define PUSH_REQUEST_INTERVAL
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...
static void dco_event_set(dco_context_t *dco, struct event_set *es, void *arg)
static void dco_delete_iroutes(openvpn_net_ctx_t *net_ctx, const struct context *c)
static int dco_read_and_process(dco_context_t *dco)
static bool dco_update_keys(dco_context_t *dco, struct tls_multi *multi)
static int dco_get_peer_stats(struct context *c, const bool raise_sigusr1_on_err)
in_addr_t dhcp_extract_router_msg(struct buffer *ipbuf)
static int event_wait(struct event_set *es, const struct timeval *tv, struct event_set_return *out, int outlen)
static void event_reset(struct event_set *es)
static void wait_signal(struct event_set *es, void *arg)
int get_server_poll_remaining_time(const struct event_timeout *server_poll_timeout)
void process_incoming_dco(dco_context_t *dco)
Process an incoming DCO message (from kernel space).
counter_type link_write_bytes_global
static void check_inactivity_timeout(struct context *c)
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)
static void context_reschedule_sec(struct context *c, time_t sec)
static void check_fragment(struct context *c)
static void check_tls_errors(struct context *c)
static void check_scheduled_exit(struct context *c)
static void check_session_timeout(struct context *c)
static void parse_incoming_control_channel_command(struct context *c, const struct buffer *buf)
void process_io(struct context *c, struct link_socket *sock)
static void socks_postprocess_incoming_link(struct context *c, const struct link_socket *sock)
static void show_wait_status(struct context *c)
static void check_timeout_random_component(struct context *c)
bool schedule_exit(struct context *c)
static void process_coarse_timers(struct context *c)
void ipv6_send_icmp_unreachable(struct context *c, const struct buffer *buf, bool client)
Forges a IPv6 ICMP packet with a no route to host error code from the IPv6 packet in buf and sends it...
static void check_connection_established(struct context *c)
static void check_timeout_random_component_dowork(struct context *c)
static const char * wait_status_string(struct context *c, struct gc_arena *gc)
static void buffer_turnover(const uint8_t *orig_buf, struct buffer *dest_stub, const struct buffer *src_stub, struct buffer *storage)
static void check_tls_errors_nco(struct context *c)
bool send_control_channel_string_dowork(struct tls_session *session, const char *str, msglvl_t msglevel)
void pre_select(struct context *c)
static void check_incoming_control_channel(struct context *c)
static void check_add_routes(struct context *c)
static void check_server_poll_timeout(struct context *c)
static void check_push_request(struct context *c)
static void process_incoming_link(struct context *c, struct link_socket *sock)
static void check_tls_errors_co(struct context *c)
static void socks_preprocess_outgoing_link(struct context *c, struct link_socket *sock, struct link_socket_actual **to_addr, int *size_delta)
void io_wait(struct context *c, const unsigned int flags)
static void link_socket_write_post_size_adjust(int *size, int size_delta, struct buffer *buf)
static void context_immediate_reschedule(struct context *c)
static void check_add_routes_action(struct context *c, const bool errors)
static void drop_if_recursive_routing(struct context *c, struct buffer *buf)
Drops UDP packets which OS decided to route via tun.
counter_type link_read_bytes_global
static void check_coarse_timers(struct context *c)
void multi_io_process_flags(struct context *c, struct event_set *es, struct link_socket *sock, const unsigned int flags)
Processes I/O flags to configure socket and TUN/TAP event monitors.
void check_dco_key_status(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...
static void check_tls(struct context *c)
static void check_status_file(struct context *c)
Interface functions to the internal and external multiplexers.
static void register_activity(struct context *c, const int64_t size)
#define PIPV4_EXTRACT_DHCP_ROUTER
#define PIPV6_ICMP_NOHOST_SERVER
#define PIPV6_ICMP_NOHOST_CLIENT
static struct link_socket_info * get_link_socket_info(struct context *c)
#define IOW_CHECK_RESIDUAL
static bool connection_established(struct context *c)
#define IOW_READ_TUN_FORCE
#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 tls_post_encrypt(struct tls_multi *multi, const struct buffer *buf)
Perform some accounting for the key state used.
void openvpn_encrypt(struct buffer *buf, struct buffer work, struct crypto_options *opt)
Encrypt and HMAC sign a packet so that it can be sent as a data channel VPN tunnel packet to a remote...
void tls_prepend_opcode_v1(const struct tls_multi *multi, struct buffer *buf)
Prepend a one-byte OpenVPN data channel P_DATA_V1 opcode to the packet.
void tls_pre_encrypt(struct tls_multi *multi, struct buffer *buf, struct crypto_options **opt)
Choose the appropriate security parameters with which to process an outgoing packet.
void tls_prepend_opcode_v2(const struct tls_multi *multi, struct buffer *buf)
Prepend an OpenVPN data channel P_DATA_V2 header to the packet.
bool openvpn_decrypt(struct buffer *buf, struct buffer work, struct crypto_options *opt, const struct frame *frame, const uint8_t *ad_start)
HMAC verify and decrypt a data channel packet received from a remote OpenVPN peer.
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.
void process_outgoing_link(struct context *c, struct link_socket *sock)
Write a packet to the external network interface.
void read_incoming_link(struct context *c, struct link_socket *sock)
Read a packet from the external network interface.
bool tls_pre_decrypt(struct tls_multi *multi, const struct link_socket_actual *from, struct buffer *buf, struct crypto_options **opt, bool floated, const uint8_t **ad_start)
Determine whether an incoming packet is a data channel or control channel packet, and process accordi...
bool process_incoming_link_part1(struct context *c, const struct link_socket_info *lsi, bool floated)
Starts processing a packet read from the external network interface.
static void fragment_housekeeping(struct fragment_master *f, struct frame *frame, struct timeval *tv)
Perform housekeeping of a fragment_master structure.
static bool fragment_outgoing_defined(struct fragment_master *f)
Check whether a fragment_master structure contains fragments ready to be sent.
void fragment_outgoing(struct fragment_master *f, struct buffer *buf, const struct frame *frame)
Process an outgoing packet, which may or may not need to be fragmented.
void fragment_incoming(struct fragment_master *f, struct buffer *buf, const struct frame *frame)
Process an incoming packet, which may or may not be fragmented.
bool fragment_ready_to_send(struct fragment_master *f, struct buffer *buf, const struct frame *frame)
Check whether outgoing fragments are ready to be send, and if so make one available.
void read_incoming_tun(struct context *c)
Read a packet from the virtual tun/tap network interface.
void process_incoming_tun(struct context *c, struct link_socket *out_sock)
Process a packet read from the virtual tun/tap network interface.
void process_outgoing_tun(struct context *c, struct link_socket *in_sock)
Write a packet to the virtual tun/tap network interface.
void initialization_sequence_completed(struct context *c, const unsigned int flags)
void reset_coarse_timers(struct context *c)
bool do_up(struct context *c, bool pulled_options, uint64_t option_types_found)
bool do_route(const struct options *options, struct route_list *route_list, struct route_ipv6_list *route_ipv6_list, const struct tuntap *tt, const struct plugin_list *plugins, struct env_set *es, openvpn_net_ctx_t *ctx)
static int min_int(int x, int y)
static int max_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 interval_future_trigger(struct interval *top, interval_t wakeup)
static void event_timeout_reset(struct event_timeout *et)
Resets a timer.
static void interval_action(struct interval *top)
static bool event_timeout_defined(const struct event_timeout *et)
static void event_timeout_init(struct event_timeout *et, interval_t n, const time_t last)
Initialises a timer struct.
static void interval_schedule_wakeup(const struct interval *top, interval_t *wakeup)
static void event_timeout_clear(struct event_timeout *et)
Clears the timeout and reset all values to 0.
static interval_t event_timeout_remaining(const struct event_timeout *et)
Returns the time until the timeout should triggered, from now.
static void event_timeout_modify_wakeup(struct event_timeout *et, interval_t n)
Sets the interval n of a timeout.
static bool interval_test(struct interval *top)
void management_socket_set(struct management *man, struct event_set *es, void *arg, unsigned int *persistent)
void management_set_state(struct management *man, const int state, const char *detail, const in_addr_t *tun_local_ip, const struct in6_addr *tun_local_ip6, const struct openvpn_sockaddr *local, const struct openvpn_sockaddr *remote)
void management_io(struct management *man)
void management_check_bytecount_client(struct context *c, struct management *man, struct timeval *timeval)
void management_sleep(const int n)
A sleep function that services the management layer for n seconds rather than doing nothing.
#define OPENVPN_STATE_GET_CONFIG
const char * sanitize_control_message(const char *src, struct gc_arena *gc)
void mss_fixup_ipv6(struct buffer *buf, uint16_t maxmss)
void mss_fixup_ipv4(struct buffer *buf, uint16_t maxmss)
void frame_adjust_path_mtu(struct context *c)
Checks and adjusts the fragment and mssfix value according to the discovered path mtu value.
void process_received_occ_msg(struct context *c)
static void check_send_occ_msg(struct context *c)
static bool is_occ_msg(const struct buffer *buf)
static void check_send_occ_req(struct context *c)
static void check_send_occ_load_test(struct context *c)
static bool check_debug_level(msglvl_t level)
static void check_status(ssize_t status, const char *description, struct link_socket *sock, const struct tuntap *tt)
#define PROTO_DUMP(buf, gc)
#define MODE_POINT_TO_POINT
static bool dco_enabled(const struct options *o)
Returns whether the current configuration has dco enabled.
const char * tv_string(const struct timeval *tv, struct gc_arena *gc)
static void update_time(void)
static void tv_add(struct timeval *dest, const struct timeval *src)
@ OVPN_DEL_PEER_REASON_EXPIRED
void trigger_ping_timeout_signal(struct context *c)
Trigger the correct signal on a –ping timeout depending if –ping-exit is set (SIGTERM) or not (SIGUSR...
static void check_ping_restart(struct context *c)
static bool is_ping_msg(const struct buffer *buf)
static void check_ping_send(struct context *c)
bool is_ipv4(int tunnel_type, struct buffer *buf)
bool is_ipv6(int tunnel_type, struct buffer *buf)
uint16_t ip_checksum(const sa_family_t af, const uint8_t *payload, const int len_payload, const uint8_t *src_addr, const uint8_t *dest_addr, const int proto)
Calculates an IP or IPv6 checksum with a pseudo header as required by TCP, UDP and ICMPv6.
#define OPENVPN_IPH_GET_LEN(v)
static int get_tun_ip_ver(int tunnel_type, const struct buffer *buf, int *ip_hdr_offset)
#define OPENVPN_ETH_P_IPV6
#define OPENVPN_IPPROTO_ICMPV6
#define OPENVPN_IN6_ARE_ADDR_EQUAL(a, b)
Version of IN6_ARE_ADDR_EQUAL that is guaranteed to work for unaligned access.
#define OPENVPN_IPPROTO_UDP
#define OPENVPN_ICMP6_DESTINATION_UNREACHABLE
#define OPENVPN_IPPROTO_TCP
#define OPENVPN_ICMP6_DU_NOROUTE
void receive_auth_pending(struct context *c, const struct buffer *buffer)
Parses an AUTH_PENDING message and if in pull mode extends the timeout.
void receive_auth_failed(struct context *c, const struct buffer *buffer)
void server_pushed_signal(struct context *c, const struct buffer *buffer, const bool restart, const int adv)
void receive_cr_response(struct context *c, const struct buffer *buffer)
void send_auth_failed(struct context *c, const char *client_reason)
void peer_pushed_info(struct context *c, const struct buffer *buffer, const int adv)
This message is called when an INFO or INFO_PRE message is received from a peer.
void receive_exit_message(struct context *c)
bool send_push_request(struct context *c)
void incoming_push_message(struct context *c, const struct buffer *buffer)
bool test_routes(const struct route_list *rl, const struct tuntap *tt)
void route_list_add_vpn_gateway(struct route_list *rl, struct env_set *es, const in_addr_t addr)
void show_routes(msglvl_t msglevel)
bool shaper_soonest_event(struct timeval *tv, int delay)
static void shaper_wrote_bytes(struct shaper *s, int nbytes)
static int shaper_delay(struct shaper *s)
void print_status(struct context *c, struct status_output *so)
void process_explicit_exit_notification_timer_wakeup(struct context *c)
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.
static void get_signal(volatile int *sig)
Copy the global signal_received (if non-zero) to the passed-in argument sig.
const char * socket_stat(const struct link_socket *s, unsigned int rwflags, struct gc_arena *gc)
int sockethandle_finalize(sockethandle_t sh, struct overlapped_io *io, struct buffer *buf, struct link_socket_actual *from)
unsigned int socket_set(struct link_socket *s, struct event_set *es, unsigned int rwflags, void *arg, unsigned int *persistent)
void link_socket_bad_incoming_addr(struct buffer *buf, const struct link_socket_info *info, const struct link_socket_actual *from_addr)
bool sockets_read_residual(const struct context *c)
static ssize_t link_socket_read(struct link_socket *sock, struct buffer *buf, struct link_socket_actual *from)
static bool socket_connection_reset(const struct link_socket *sock, ssize_t status)
static ssize_t link_socket_write(struct link_socket *sock, struct buffer *buf, struct link_socket_actual *to)
static bool link_socket_verify_incoming_addr(const struct buffer *buf, const struct link_socket_info *info, const struct link_socket_actual *from_addr)
static bool link_socket_connection_oriented(const struct link_socket *sock)
static void link_socket_set_outgoing_addr(struct link_socket_info *info, const struct link_socket_actual *act, const char *common_name, struct env_set *es)
static void link_socket_get_outgoing_addr(struct buffer *buf, const struct link_socket_info *info, struct link_socket_actual **act)
const char * proto2ascii(int proto, sa_family_t af, bool display_form)
const char * print_link_socket_actual(const struct link_socket_actual *act, struct gc_arena *gc)
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)
static bool link_socket_actual_defined(const struct link_socket_actual *act)
static int datagram_overhead(sa_family_t af, int proto)
Overhead added to packets by various protocols.
int socks_process_outgoing_udp(struct buffer *buf, const struct link_socket_actual *to)
void socks_process_incoming_udp(struct buffer *buf, struct link_socket_actual *from)
bool tls_send_payload(struct key_state *ks, const uint8_t *data, size_t size)
bool tls_rec_payload(struct tls_multi *multi, struct buffer *buf)
void tls_session_soft_reset(struct tls_multi *tls_multi)
int tls_multi_process(struct tls_multi *multi, struct buffer *to_link, struct link_socket_actual **to_link_addr, struct link_socket_info *to_link_socket_info, interval_t *wakeup)
static bool tls_initial_packet_received(const struct tls_multi *multi)
#define TLSMP_RESTART
the session cannot recover on its own and has to be restarted
static void tls_set_single_session(struct tls_multi *multi)
static int tls_test_payload_len(const struct tls_multi *multi)
struct buffer extract_command_buffer(struct buffer *buf, struct gc_arena *gc)
Extracts a control channel message from buf and adjusts the size of buf after the message has been ex...
Control Channel Verification Module.
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.
struct status_output * status_output
struct route_list * route_list
List of routing information.
struct route_ipv6_list * route_ipv6_list
struct tuntap * tuntap
Tun/tap virtual network interface.
counter_type link_read_bytes
counter_type link_write_bytes
struct event_timeout server_poll_interval
struct fragment_master * fragment
time_t update_timeout_random_component
unsigned int event_set_status
counter_type dco_read_bytes
struct event_timeout route_wakeup_expire
struct event_timeout ping_send_interval
struct timeval timeout_random_component
counter_type tun_read_bytes
counter_type dco_write_bytes
struct event_timeout scheduled_exit
struct event_timeout auth_token_renewal_interval
struct event_timeout wait_for_connect
struct event_timeout push_request_interval
struct tls_multi * tls_multi
TLS state structure for this VPN tunnel.
time_t coarse_timer_wakeup
int scheduled_exit_signal
struct link_socket_actual from
struct frame frame_fragment
struct crypto_options crypto_options
Security parameters and crypto state used by the Data Channel Crypto module to process data channel p...
counter_type tun_write_bytes
struct link_socket ** link_sockets
counter_type link_read_bytes_auth
struct link_socket_actual * to_link_addr
struct event_timeout session_interval
struct timeval timeval
Time to next event of timers and similar.
time_t explicit_exit_notification_time_wait
struct event_set * event_set
struct context_buffers * buffers
struct event_timeout route_wakeup
struct event_timeout inactivity_interval
struct event_timeout ping_rec_interval
struct buffer read_link_buf
struct buffer encrypt_buf
struct buffer read_tun_buf
struct buffer decrypt_buf
int restart_sleep_seconds
Contains all state information for one tunnel.
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 options options
Options loaded from command line or configuration file.
struct context_1 c1
Level 1 context.
struct context_persist persist
Persistent context.
Security parameter state for processing data channel packets.
struct link_socket * sock
interval_t n
periodic interval for periodic timeouts
int tun_mtu
the (user) configured tun-mtu.
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.
Security parameter state of one TLS and data channel key session.
struct openvpn_sockaddr dest
struct link_socket_addr * lsa
struct link_socket_actual socks_relay
struct link_socket_info info
struct socks_proxy_info * socks_proxy
struct event_arg ev_arg
this struct will store a pointer to either mi or link_socket, depending on the event type,...
uint8_t dest[OPENVPN_ETH_ALEN]
uint8_t source[OPENVPN_ETH_ALEN]
union openvpn_sockaddr::@27 addr
const char * ifconfig_ipv6_remote
int scheduled_exit_interval
bool allow_recursive_routing
int64_t inactivity_minimum_bytes
struct connection_entry ce
bool route_gateway_via_dhcp
struct client_nat_option_list * client_nat
volatile int signal_received
enum multi_status multi_state
struct tls_session session[TM_SIZE]
Array of tls_session objects representing control channel sessions with the remote peer.
char * client_reason
An error message to send to client on AUTH_FAILED.
int dco_peer_id
This is the handle that DCO uses to identify this session with the kernel.
Security parameter state of a single session within a VPN tunnel.
enum tun_driver_type backend_driver
The backend driver that used for this tun/tap device.
struct overlapped_io reads
unsigned short sa_family_t
int tun_write_win32(struct tuntap *tt, const struct buffer *buf)
const char * tun_stat(const struct tuntap *tt, unsigned int rwflags, struct gc_arena *gc)
bool tun_standby(struct tuntap *tt)
void show_adapters(msglvl_t msglevel)
void tun_show_debug(const struct tuntap *tt)
static bool tuntap_abort(int status)
ssize_t read_tun(const struct tuntap *tt, uint8_t *buf, int len)
static bool tuntap_is_dco_win_timeout(const struct tuntap *tt, ssize_t status)
static bool tuntap_defined(const struct tuntap *tt)
@ DRIVER_AFUNIX
using an AF_UNIX socket to pass packets from/to an external program.
static void tun_set(struct tuntap *tt, struct event_set *es, unsigned int rwflags, void *arg, unsigned int *persistent)
ssize_t write_tun(const struct tuntap *tt, const uint8_t *buf, int len)
static bool tuntap_stop(int status)
ssize_t write_tun_afunix(struct tuntap *tt, const uint8_t *buf, int len)
Writes a packet to a AF_UNIX based tun device.
ssize_t read_tun_afunix(struct tuntap *tt, uint8_t *buf, int len)
Reads a packet from a AF_UNIX based tun device.