OpenVPN
Functions
Internal Multiplexer module

Functions

void read_incoming_tun (struct context *c)
 Read a packet from the virtual tun/tap network interface. More...
 
void process_incoming_tun (struct context *c)
 Process a packet read from the virtual tun/tap network interface. More...
 
void process_outgoing_tun (struct context *c)
 Write a packet to the virtual tun/tap network interface. More...
 
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 and then process it accordingly. More...
 
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. More...
 

Detailed Description

The Internal Multiplexer is the link between the virtual tun/tap network interface and the Data Channel Control module. It reads packets from the virtual network interface, determines for which remote OpenVPN peer they are destined, and then passes the packets on to the Data Channel Control module together with information about their destination VPN tunnel instance.

This module also handles packets traveling in the reverse direction, which have already been processed by the Data Channel Control module and are destined for a locally reachable host.

Function Documentation

◆ multi_process_incoming_tun()

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 and then process it accordingly.

This function determines which VPN tunnel instance the packet is destined for, and then calls process_outgoing_tun() to handle it.

Note
This function is only used by OpenVPN processes which are running in server mode, and can therefore sustain multiple active VPN tunnels.
Parameters
m- The single multi_context structure.
mpp_flags- Fast I/O optimization flags.

Definition at line 3547 of file multi.c.

References BLEN, context_2::buf, buf_reset_len(), context::c1, context::c2, clear_prefix(), multi_instance::context, D_MULTI_DROPPED, DEV_TYPE_TAP, DEV_TYPE_TUN, mroute_extract_addr_from_packet(), MROUTE_EXTRACT_BCAST, MROUTE_EXTRACT_MCAST, MROUTE_EXTRACT_SUCCEEDED, msg, multi_bcast(), multi_get_instance_by_virtual_addr(), multi_output_queue_ready(), multi_process_post(), multi_set_pending(), context::options, multi_context::pending, process_incoming_tun(), set_prefix(), multi_context::top, TUNNEL_TYPE, context_1::tuntap, mroute_addr::vid, vlan_decapsulate(), and options::vlan_tagging.

Referenced by multi_process_io_udp(), and multi_tcp_dispatch().

◆ multi_process_outgoing_tun()

static bool multi_process_outgoing_tun ( struct multi_context m,
const unsigned int  mpp_flags 
)
inlinestatic

Send a packet over the virtual tun/tap network interface to its locally reachable destination.

This function calls process_outgoing_tun() to perform the actual sending of the packet. Afterwards, it calls multi_process_post() to perform server-mode postprocessing.

Parameters
m- The single multi_context structure.
mpp_flags- Fast I/O optimization flags.
Returns
  • True, if the multi_instance associated with the packet sent was not closed due to a signal during processing.
  • Falls, if the multi_instance was closed.

Definition at line 652 of file multi.h.

References ASSERT, context::c2, clear_prefix(), multi_instance::context, buffer::len, multi_process_post(), multi_context::pending, process_outgoing_tun(), set_prefix(), context_2::to_tun, and vlan_process_outgoing_tun().

Referenced by multi_process_io_udp(), and multi_tcp_dispatch().

◆ process_incoming_tun()

void process_incoming_tun ( struct context c)

Process a packet read from the virtual tun/tap network interface.

This function calls encrypt_sign() of the Data Channel Control module to process the packet.

If an error occurs, it is logged and the packet is dropped.

Parameters
c- The context structure of the VPN tunnel associated with the packet.

Definition at line 1431 of file forward.c.

References options::allow_recursive_routing, BLEN, BPTR, context_2::buf, buf_reset(), context::c1, context::c2, D_TUN_RW, dmsg, drop_if_recursive_routing(), encrypt_sign(), gc_free(), gc_new(), buffer::len, context_2::log_rw, options::mode, MODE_POINT_TO_POINT, context::options, perf_pop(), PERF_PROC_IN_TUN, perf_push(), PIP_MSSFIX, PIPV4_CLIENT_NAT, PIPV4_PASSTOS, PIPV6_IMCP_NOHOST_CLIENT, process_ip_header(), context_2::to_link, context_2::tun_read_bytes, TUNNEL_TYPE, and context_1::tuntap.

Referenced by multi_process_incoming_tun(), and process_io().

◆ process_outgoing_tun()

void process_outgoing_tun ( struct context c)

Write a packet to the virtual tun/tap network interface.

This function writes the packet stored in c->c2.to_tun to the virtual tun/tap network device c->c1.tuntap.

If an error occurs, it is logged and the packet is dropped.

Parameters
c- The context structure of the VPN tunnel associated with the packet.

Definition at line 1878 of file forward.c.

References tuntap::actual_name, BLEN, BPTR, frame::buf, buf_reset(), context::c1, context::c2, check_status(), D_LINK_ERRORS, D_TUN_RW, dmsg, context_2::frame, buffer::len, context_2::log_rw, msg, frame::payload_size, perf_pop(), PERF_PROC_OUT_TUN, perf_push(), PIP_MSSFIX, PIP_OUTGOING, PIPV4_CLIENT_NAT, PIPV4_EXTRACT_DHCP_ROUTER, process_ip_header(), register_activity(), context_2::to_tun, context_2::tun_write_bytes, TUNNEL_TYPE, context_1::tuntap, write_tun(), and write_tun_buffered().

Referenced by multi_process_outgoing_tun(), and process_io().

◆ read_incoming_tun()

void read_incoming_tun ( struct context c)

Read a packet from the virtual tun/tap network interface.

This function reads a packet from the virtual tun/tap network device c->c1.tuntap and stores it in c->c2.buf.

If an error occurs, it is logged and the packet is dropped.

Parameters
c- The context structure in which to store the received packet.

Definition at line 1273 of file forward.c.

References ASSERT, BLEN, BPTR, frame::buf, context_2::buf, buf_init, buf_safe(), context_2::buffers, context::c1, context::c2, check_status(), context_2::frame, tuntap::hand, frame::headroom, sockethandle_t::is_handle, buffer::len, M_INFO, msg, frame::payload_size, perf_pop(), perf_push(), PERF_READ_IN_TUN, context::persist, read_tun(), context_buffers::read_tun_buf, read_wintun(), tuntap::reads, register_signal(), context_persist::restart_sleep_seconds, context::sig, sockethandle_finalize(), TUNNEL_TYPE, context_1::tuntap, tuntap_abort(), tuntap_stop(), tuntap::windows_driver, and WINDOWS_DRIVER_WINTUN.

Referenced by multi_process_io_udp(), multi_tcp_dispatch(), and process_io().