OpenVPN
Functions | Variables
forward.c File Reference
#include "syshead.h"
#include "forward.h"
#include "init.h"
#include "push.h"
#include "gremlin.h"
#include "mss.h"
#include "event.h"
#include "occ.h"
#include "pf.h"
#include "ping.h"
#include "ps.h"
#include "dhcp.h"
#include "common.h"
#include "ssl_verify.h"
#include "memdbg.h"
#include "mstats.h"
Include dependency graph for forward.c:

Go to the source code of this file.

Functions

static void check_tls (struct context *c)
 
static void check_tls_errors (struct context *c)
 
static void check_incoming_control_channel (struct context *c)
 
static void check_connection_established (struct context *c)
 
static void check_add_routes (struct context *c)
 
static void check_inactivity_timeout (struct context *c)
 
static void check_server_poll_timeout (struct context *c)
 
static void check_scheduled_exit (struct context *c)
 
static void check_status_file (struct context *c)
 
static void check_fragment (struct context *c)
 
static void check_push_request (struct context *c)
 
static void check_packet_id_persist_flush (struct context *c)
 
static void context_immediate_reschedule (struct context *c)
 
static void context_reschedule_sec (struct context *c, int sec)
 
void check_tls_dowork (struct context *c)
 
void check_tls_errors_co (struct context *c)
 
void check_tls_errors_nco (struct context *c)
 
void check_incoming_control_channel_dowork (struct context *c)
 
void check_push_request_dowork (struct context *c)
 
void check_connection_established_dowork (struct context *c)
 
bool send_control_channel_string (struct context *c, const char *str, int msglevel)
 
static void check_add_routes_action (struct context *c, const bool errors)
 
void check_add_routes_dowork (struct context *c)
 
void check_inactivity_timeout_dowork (struct context *c)
 
int get_server_poll_remaining_time (struct event_timeout *server_poll_timeout)
 
void check_server_poll_timeout_dowork (struct context *c)
 
void schedule_exit (struct context *c, const int n_seconds, const int signal)
 
void check_scheduled_exit_dowork (struct context *c)
 
void check_status_file_dowork (struct context *c)
 
void check_fragment_dowork (struct context *c)
 
static void buffer_turnover (const uint8_t *orig_buf, struct buffer *dest_stub, struct buffer *src_stub, struct buffer *storage)
 
void encrypt_sign (struct context *c, bool comp_frag)
 Process a data channel packet that will be sent through a VPN tunnel. More...
 
static void process_coarse_timers (struct context *c)
 
static void check_coarse_timers_dowork (struct context *c)
 
static void check_coarse_timers (struct context *c)
 
static void check_timeout_random_component_dowork (struct context *c)
 
static void check_timeout_random_component (struct context *c)
 
static void socks_postprocess_incoming_link (struct context *c)
 
static void socks_preprocess_outgoing_link (struct context *c, struct link_socket_actual **to_addr, int *size_delta)
 
static void link_socket_write_post_size_adjust (int *size, int size_delta, struct buffer *buf)
 
void read_incoming_link (struct context *c)
 Read a packet from the external network interface. More...
 
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. More...
 
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. More...
 
static void process_incoming_link (struct context *c)
 
void read_incoming_tun (struct context *c)
 Read a packet from the virtual tun/tap network interface. More...
 
static void drop_if_recursive_routing (struct context *c, struct buffer *buf)
 Drops UDP packets which OS decided to route via tun. More...
 
void process_incoming_tun (struct context *c)
 Process a packet read from the virtual tun/tap network interface. More...
 
void process_ip_header (struct context *c, unsigned int flags, struct buffer *buf)
 
void process_outgoing_link (struct context *c)
 Write a packet to the external network interface. More...
 
void process_outgoing_tun (struct context *c)
 Write a packet to the virtual tun/tap network interface. More...
 
void pre_select (struct context *c)
 
void io_wait_dowork (struct context *c, const unsigned int flags)
 
void process_io (struct context *c)
 

Variables

counter_type link_read_bytes_global
 
counter_type link_write_bytes_global
 

Function Documentation

◆ buffer_turnover()

static void buffer_turnover ( const uint8_t orig_buf,
struct buffer dest_stub,
struct buffer src_stub,
struct buffer storage 
)
inlinestatic

Definition at line 657 of file forward.c.

References buf_assign(), and buffer::data.

Referenced by encrypt_sign(), and process_incoming_link_part2().

◆ check_add_routes()

static void check_add_routes ( struct context c)
inlinestatic

◆ check_add_routes_action()

static void check_add_routes_action ( struct context c,
const bool  errors 
)
static

◆ check_add_routes_dowork()

void check_add_routes_dowork ( struct context c)

◆ check_coarse_timers()

static void check_coarse_timers ( struct context c)
inlinestatic

◆ check_coarse_timers_dowork()

static void check_coarse_timers_dowork ( struct context c)
static

◆ check_connection_established()

static void check_connection_established ( struct context c)
inlinestatic

◆ check_connection_established_dowork()

void check_connection_established_dowork ( struct context c)

◆ check_fragment()

static void check_fragment ( struct context c)
inlinestatic

Definition at line 239 of file forward.c.

References context::c2, check_fragment_dowork(), and context_2::fragment.

Referenced by pre_select().

◆ check_fragment_dowork()

void check_fragment_dowork ( struct context c)

◆ check_inactivity_timeout()

static void check_inactivity_timeout ( struct context c)
inlinestatic

◆ check_inactivity_timeout_dowork()

void check_inactivity_timeout_dowork ( struct context c)

Definition at line 557 of file forward.c.

References M_INFO, msg, register_signal(), and SIGTERM.

Referenced by check_inactivity_timeout().

◆ check_incoming_control_channel()

static void check_incoming_control_channel ( struct context c)
inlinestatic

◆ check_incoming_control_channel_dowork()

void check_incoming_control_channel_dowork ( struct context c)

◆ check_packet_id_persist_flush()

static void check_packet_id_persist_flush ( struct context c)
inlinestatic

◆ check_push_request()

static void check_push_request ( struct context c)
inlinestatic

◆ check_push_request_dowork()

void check_push_request_dowork ( struct context c)

◆ check_scheduled_exit()

static void check_scheduled_exit ( struct context c)
inlinestatic

◆ check_scheduled_exit_dowork()

void check_scheduled_exit_dowork ( struct context c)

Definition at line 603 of file forward.c.

References context::c2, register_signal(), and context_2::scheduled_exit_signal.

Referenced by check_scheduled_exit().

◆ check_server_poll_timeout()

static void check_server_poll_timeout ( struct context c)
inlinestatic

◆ check_server_poll_timeout_dowork()

void check_server_poll_timeout_dowork ( struct context c)

◆ check_status_file()

static void check_status_file ( struct context c)
inlinestatic

◆ check_status_file_dowork()

void check_status_file_dowork ( struct context c)

Definition at line 614 of file forward.c.

References context::c1, print_status(), and context_1::status_output.

Referenced by check_status_file().

◆ check_timeout_random_component()

static void check_timeout_random_component ( struct context c)
inlinestatic

◆ check_timeout_random_component_dowork()

static void check_timeout_random_component_dowork ( struct context c)
static

◆ check_tls()

static void check_tls ( struct context c)
inlinestatic

Definition at line 84 of file forward.c.

References context::c2, check_tls_dowork(), and context_2::tls_multi.

Referenced by pre_select().

◆ check_tls_dowork()

void check_tls_dowork ( struct context c)

◆ check_tls_errors()

static void check_tls_errors ( struct context c)
inlinestatic

◆ check_tls_errors_co()

void check_tls_errors_co ( struct context c)

Definition at line 348 of file forward.c.

References context::c2, D_STREAM_ERRORS, msg, register_signal(), and context_2::tls_exit_signal.

Referenced by check_tls_errors().

◆ check_tls_errors_nco()

void check_tls_errors_nco ( struct context c)

Definition at line 355 of file forward.c.

References context::c2, register_signal(), and context_2::tls_exit_signal.

Referenced by check_tls_errors().

◆ context_immediate_reschedule()

static void context_immediate_reschedule ( struct context c)
inlinestatic

Definition at line 286 of file forward.c.

References context::c2, and context_2::timeval.

Referenced by send_control_channel_string().

◆ context_reschedule_sec()

static void context_reschedule_sec ( struct context c,
int  sec 
)
inlinestatic

Definition at line 293 of file forward.c.

References context::c2, and context_2::timeval.

Referenced by check_coarse_timers(), and check_tls_dowork().

◆ drop_if_recursive_routing()

static void drop_if_recursive_routing ( struct context c,
struct buffer buf 
)
static

Drops UDP packets which OS decided to route via tun.

On Windows and OS X when netwotk adapter is disabled or disconnected, platform starts to use tun as external interface. When packet is sent to tun, it comes to openvpn, encapsulated and sent to routing table, which sends it again to tun.

Definition at line 1303 of file forward.c.

References openvpn_sockaddr::addr, BLEN, BPTR, context_2::buf, context::c1, context::c2, D_LOW, openvpn_iphdr::daddr, openvpn_ipv6hdr::daddr, link_socket_actual::dest, gc_free(), gc_new(), get_tun_ip_ver(), openvpn_sockaddr::in4, openvpn_sockaddr::in6, IN6_ARE_ADDR_EQUAL, buffer::len, msg, print_link_socket_actual(), openvpn_sockaddr::sa, context_2::to_link_addr, TUNNEL_TYPE, and context_1::tuntap.

Referenced by process_incoming_tun().

◆ get_server_poll_remaining_time()

int get_server_poll_remaining_time ( struct event_timeout server_poll_timeout)

◆ io_wait_dowork()

void io_wait_dowork ( struct context c,
const unsigned int  flags 
)

◆ link_socket_write_post_size_adjust()

static void link_socket_write_post_size_adjust ( int *  size,
int  size_delta,
struct buffer buf 
)
inlinestatic

Definition at line 914 of file forward.c.

References buf_advance().

Referenced by process_outgoing_link().

◆ pre_select()

void pre_select ( struct context c)

◆ process_coarse_timers()

static void process_coarse_timers ( struct context c)
static

◆ process_incoming_link()

static void process_incoming_link ( struct context c)
static

◆ process_io()

void process_io ( struct context c)

◆ process_ip_header()

void process_ip_header ( struct context c,
unsigned int  flags,
struct buffer buf 
)

◆ schedule_exit()

void schedule_exit ( struct context c,
const int  n_seconds,
const int  signal 
)

◆ send_control_channel_string()

bool send_control_channel_string ( struct context c,
const char *  str,
int  msglevel 
)

◆ socks_postprocess_incoming_link()

static void socks_postprocess_incoming_link ( struct context c)
inlinestatic

◆ socks_preprocess_outgoing_link()

static void socks_preprocess_outgoing_link ( struct context c,
struct link_socket_actual **  to_addr,
int *  size_delta 
)
inlinestatic

Variable Documentation

◆ link_read_bytes_global

counter_type link_read_bytes_global

Definition at line 50 of file forward.c.

Referenced by man_load_stats(), and process_incoming_link_part1().

◆ link_write_bytes_global

counter_type link_write_bytes_global

Definition at line 51 of file forward.c.

Referenced by man_load_stats(), and process_outgoing_link().