OpenVPN
forward.h File Reference

Interface functions to the internal and external multiplexers. More...

#include "openvpn.h"
#include "occ.h"
#include "ping.h"
#include "multi_io.h"
Include dependency graph for forward.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TUN_OUT(c)
#define LINK_OUT(c)
#define ANY_OUT(c)
#define TO_LINK_FRAG(c)
#define TO_LINK_DEF(c)
#define IOW_TO_TUN   (1 << 0)
#define IOW_TO_LINK   (1 << 1)
#define IOW_READ_TUN   (1 << 2)
#define IOW_READ_LINK   (1 << 3)
#define IOW_SHAPER   (1 << 4)
#define IOW_CHECK_RESIDUAL   (1 << 5)
#define IOW_FRAG   (1 << 6)
#define IOW_READ_TUN_FORCE   (1 << 8)
#define IOW_WAIT_SIGNAL   (1 << 9)
#define IOW_READ   (IOW_READ_TUN | IOW_READ_LINK)
#define PIPV4_PASSTOS   (1u << 0)
#define PIP_MSSFIX   (1u << 1) /* v4 and v6 */
#define PIP_OUTGOING   (1u << 2)
#define PIPV4_EXTRACT_DHCP_ROUTER   (1u << 3)
#define PIPV4_CLIENT_NAT   (1u << 4)
#define PIPV6_ICMP_NOHOST_CLIENT   (1u << 5)
#define PIPV6_ICMP_NOHOST_SERVER   (1u << 6)

Functions

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 io_wait (struct context *c, const unsigned int flags)
void pre_select (struct context *c)
void process_io (struct context *c, struct link_socket *sock)
void encrypt_sign (struct context *c, bool comp_frag)
 Process a data channel packet that will be sent through a VPN tunnel.
int get_server_poll_remaining_time (const struct event_timeout *server_poll_timeout)
void read_incoming_link (struct context *c, struct link_socket *sock)
 Read a packet from the external network interface.
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.
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 extract_dco_float_peer_addr (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 processing.
void process_incoming_dco (dco_context_t *dco)
 Process an incoming DCO message (from kernel space).
void process_outgoing_link (struct context *c, struct link_socket *sock)
 Write a packet to the external network interface.
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.
bool send_control_channel_string (struct context *c, const char *str, msglvl_t msglevel)
bool send_control_channel_string_dowork (struct tls_session *session, const char *str, msglvl_t msglevel)
void reschedule_multi_process (struct context *c)
 Reschedule tls_multi_process.
void process_ip_header (struct context *c, unsigned int flags, struct buffer *buf, struct link_socket *sock)
bool schedule_exit (struct context *c)
static struct link_socket_info * get_link_socket_info (struct context *c)
static void register_activity (struct context *c, const int64_t size)
static unsigned int p2p_iow_flags (const struct context *c)
static bool connection_established (struct context *c)

Variables

counter_type link_read_bytes_global
counter_type link_write_bytes_global

Detailed Description

Interface functions to the internal and external multiplexers.

Definition in file forward.h.

Macro Definition Documentation

◆ ANY_OUT

#define ANY_OUT ( c)
Value:
(TUN_OUT(c) || LINK_OUT(c))
#define LINK_OUT(c)
Definition forward.h:38
#define TUN_OUT(c)
Definition forward.h:37

Definition at line 39 of file forward.h.

Referenced by multi_process_post().

◆ IOW_CHECK_RESIDUAL

#define IOW_CHECK_RESIDUAL   (1 << 5)

Definition at line 59 of file forward.h.

Referenced by io_wait(), and p2p_iow_flags().

◆ IOW_FRAG

#define IOW_FRAG   (1 << 6)

Definition at line 60 of file forward.h.

Referenced by multi_io_process_flags(), and p2p_iow_flags().

◆ IOW_READ

#define IOW_READ   (IOW_READ_TUN | IOW_READ_LINK)

Definition at line 64 of file forward.h.

Referenced by p2mp_iow_flags(), and p2p_iow_flags().

◆ IOW_READ_LINK

#define IOW_READ_LINK   (1 << 3)

Definition at line 57 of file forward.h.

Referenced by multi_io_process_flags().

◆ IOW_READ_TUN

#define IOW_READ_TUN   (1 << 2)

Definition at line 56 of file forward.h.

Referenced by multi_io_process_flags().

◆ IOW_READ_TUN_FORCE

#define IOW_READ_TUN_FORCE   (1 << 8)

Definition at line 61 of file forward.h.

Referenced by multi_io_process_flags(), and multi_io_wait_lite().

◆ IOW_SHAPER

#define IOW_SHAPER   (1 << 4)

Definition at line 58 of file forward.h.

Referenced by multi_io_process_flags(), and p2p_iow_flags().

◆ IOW_TO_LINK

#define IOW_TO_LINK   (1 << 1)

◆ IOW_TO_TUN

#define IOW_TO_TUN   (1 << 0)

◆ IOW_WAIT_SIGNAL

#define IOW_WAIT_SIGNAL   (1 << 9)

Definition at line 62 of file forward.h.

Referenced by multi_io_process_flags(), p2mp_iow_flags(), and p2p_iow_flags().

◆ LINK_OUT

#define LINK_OUT ( c)
Value:
(BLEN(&(c)->c2.to_link) > 0)
#define BLEN(buf)
Return the length of the buffer content in bytes.
Definition buffer.h:151

Definition at line 38 of file forward.h.

Referenced by multi_io_post(), and p2mp_iow_flags().

◆ PIP_MSSFIX

#define PIP_MSSFIX   (1u << 1) /* v4 and v6 */

◆ PIP_OUTGOING

#define PIP_OUTGOING   (1u << 2)

Definition at line 338 of file forward.h.

Referenced by process_ip_header(), and process_outgoing_tun().

◆ PIPV4_CLIENT_NAT

#define PIPV4_CLIENT_NAT   (1u << 4)

Definition at line 340 of file forward.h.

Referenced by process_incoming_tun(), process_ip_header(), and process_outgoing_tun().

◆ PIPV4_EXTRACT_DHCP_ROUTER

#define PIPV4_EXTRACT_DHCP_ROUTER   (1u << 3)

Definition at line 339 of file forward.h.

Referenced by process_ip_header(), and process_outgoing_tun().

◆ PIPV4_PASSTOS

#define PIPV4_PASSTOS   (1u << 0)

Definition at line 336 of file forward.h.

Referenced by multi_get_queue(), process_incoming_tun(), and process_ip_header().

◆ PIPV6_ICMP_NOHOST_CLIENT

#define PIPV6_ICMP_NOHOST_CLIENT   (1u << 5)

Definition at line 341 of file forward.h.

Referenced by process_incoming_tun(), and process_ip_header().

◆ PIPV6_ICMP_NOHOST_SERVER

#define PIPV6_ICMP_NOHOST_SERVER   (1u << 6)

Definition at line 342 of file forward.h.

Referenced by multi_get_queue(), and process_ip_header().

◆ TO_LINK_DEF

#define TO_LINK_DEF ( c)
Value:
#define TO_LINK_FRAG(c)
Definition forward.h:42

Definition at line 47 of file forward.h.

Referenced by check_ping_send(), check_send_occ_load_test(), check_send_occ_msg(), and check_send_occ_req().

◆ TO_LINK_FRAG

#define TO_LINK_FRAG ( c)
Value:
((c)->c2.fragment && fragment_outgoing_defined((c)->c2.fragment))
static bool fragment_outgoing_defined(struct fragment_master *f)
Check whether a fragment_master structure contains fragments ready to be sent.
Definition fragment.h:428

Definition at line 42 of file forward.h.

Referenced by multi_io_process_flags().

◆ TUN_OUT

#define TUN_OUT ( c)
Value:
(BLEN(&(c)->c2.to_tun) > 0)

Definition at line 37 of file forward.h.

Referenced by multi_io_post(), and p2mp_iow_flags().

Function Documentation

◆ connection_established()

◆ extract_dco_float_peer_addr()

void extract_dco_float_peer_addr ( 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 processing.

Parameters
socket_family- The address family of the socket
out_osaddr- openvpn_sockaddr struct that will be filled the new address data
float_sa- The sockaddr struct containing the data received from the DCO notification

Definition at line 1234 of file forward.c.

References openvpn_sockaddr::addr, openvpn_sockaddr::in4, and openvpn_sockaddr::in6.

◆ get_link_socket_info()

◆ get_server_poll_remaining_time()

int get_server_poll_remaining_time ( const struct event_timeout * server_poll_timeout)

◆ io_wait()

◆ multi_io_process_flags()

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.

Evaluates the current I/O state (flags) and context mode to determine which READ or WRITE events to register in the event loop.

Note
This function gets called from client instances from io_wait() and from p2mp (Point-to-multipoint) instances in multi_io_wait().
Parameters
cPointer to the core context.
esThe event set where descriptors are registered.
sockThe link socket to configure.
flagsBitmask of active I/O operation requests (e.g., IOW_TO_LINK, IOW_READ_TUN, IOW_TO_TUN, IOW_SHAPER).

Definition at line 2054 of file forward.c.

References context::c1, context::c2, ERR_SHIFT, link_socket::ev_arg, EVENT_READ, EVENT_WRITE, IOW_FRAG, IOW_READ_LINK, IOW_READ_TUN, IOW_READ_TUN_FORCE, IOW_SHAPER, IOW_TO_LINK, IOW_TO_TUN, IOW_WAIT_SIGNAL, max_int(), options::mode, MODE_SERVER, context::options, context_2::shaper, options::shaper, shaper_delay(), shaper_soonest_event(), socket_set(), context_2::timeval, TO_LINK_FRAG, tun_set(), TUN_SHIFT, context_1::tuntap, and wait_signal().

Referenced by io_wait(), and multi_io_wait().

◆ p2p_iow_flags()

unsigned int p2p_iow_flags ( const struct context * c)
inlinestatic

◆ pre_select()

◆ process_incoming_dco()

void process_incoming_dco ( dco_context_t * dco)

Process an incoming DCO message (from kernel space).

Parameters
dco- Pointer to the structure representing the DCO context.

Definition at line 1268 of file forward.c.

References context::c2, D_DCO_DEBUG, tls_multi::dco_peer_id, msg, OVPN_CMD_DEL_PEER, OVPN_CMD_SWAP_KEYS, OVPN_DEL_PEER_REASON_EXPIRED, context_2::tls_multi, tls_session_soft_reset(), and trigger_ping_timeout_signal().

Referenced by dco_read_and_process().

◆ process_io()

◆ process_ip_header()

◆ register_activity()

◆ reschedule_multi_process()

void reschedule_multi_process ( struct context * c)

Reschedule tls_multi_process.

NOTE: in multi-client mode, usually calling the function is insufficient to reschedule the client instance object unless multi_schedule_context_wakeup(m, mi) is also called.

Definition at line 397 of file forward.c.

References context::c2, context_immediate_reschedule(), interval_action(), and context_2::tmp_int.

Referenced by management_client_pending_auth(), send_auth_failed(), and send_control_channel_string().

◆ schedule_exit()

◆ send_control_channel_string()

◆ send_control_channel_string_dowork()

bool send_control_channel_string_dowork ( struct tls_session * session,
const char * str,
msglvl_t msglevel )

Variable Documentation

◆ link_read_bytes_global

counter_type link_read_bytes_global
extern

Definition at line 48 of file forward.c.

Referenced by man_load_stats(), and process_incoming_link_part1().

◆ link_write_bytes_global

counter_type link_write_bytes_global
extern

Definition at line 49 of file forward.c.

Referenced by man_load_stats(), and process_outgoing_link().