OpenVPN
Functions
Internal Multiplexer module

The Internal Multiplexer is the link between the virtual tun/tap network interface and the Data Channel Control module. More...

Functions

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

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

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 2719 of file multi.c.

References BLEN, context_2::buf, buf_reset_len(), context::c1, context::c2, clear_prefix(), multi_instance::context, D_MULTI_DROPPED, D_PF_DROPPED, DEV_TYPE_TUN, ENABLE_PF, gc_free(), gc_new(), MAPF_SHOW_ARP, mroute_addr_print_ex(), mroute_addr_reset(), 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(), multi_context::pending, process_incoming_tun(), set_prefix(), multi_context::top, TUNNEL_TYPE, and context_1::tuntap.

Referenced by multi_process_io_udp(), and multi_tcp_dispatch().

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 614 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(), and context_2::to_tun.

Referenced by multi_process_io_udp(), and multi_tcp_dispatch().

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 1170 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, 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().

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 1462 of file forward.c.

References tuntap::actual_name, BLEN, BPTR, buf_reset(), context::c1, context::c2, check_status(), D_LINK_ERRORS, D_TUN_RW, dmsg, context_2::frame, gc_free(), gc_new(), buffer::len, context_2::log_rw, MAX_RW_SIZE_TUN, msg, perf_pop(), PERF_PROC_OUT_TUN, perf_push(), PIP_MSSFIX, PIPV4_CLIENT_NAT, PIPV4_EXTRACT_DHCP_ROUTER, PIPV4_OUTGOING, 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().

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 1029 of file forward.c.

References ASSERT, BLEN, BPTR, context_2::buf, buf_init, buf_safe(), context_2::buffers, context::c1, context::c2, check_status(), context_2::frame, FRAME_HEADROOM, buffer::len, M_INFO, MAX_RW_SIZE_TUN, msg, perf_pop(), perf_push(), PERF_READ_IN_TUN, context::persist, read_tun(), context_buffers::read_tun_buf, read_tun_buffered(), register_signal(), context_persist::restart_sleep_seconds, SIGHUP, SIGTERM, TUNNEL_TYPE, context_1::tuntap, tuntap_abort(), and tuntap_stop().

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