OpenVPN
Data Structures | Macros | Functions
mtu.h File Reference
#include "buffer.h"
Include dependency graph for mtu.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  frame
 Packet geometry parameters. More...
 

Macros

#define ETHERNET_MTU   1500
 
#define TUN_MTU_MIN   100
 
#define LINK_MTU_DEFAULT   1500
 
#define TUN_MTU_DEFAULT   1500
 
#define TAP_MTU_EXTRA_DEFAULT   32
 
#define MSSFIX_DEFAULT   1450
 
#define PAYLOAD_ALIGN   4
 
#define FRAME_HEADROOM_MARKER_DECRYPT   (1<<0)
 
#define FRAME_HEADROOM_MARKER_FRAGMENT   (1<<1)
 
#define FRAME_HEADROOM_MARKER_READ_LINK   (1<<2)
 
#define FRAME_HEADROOM_MARKER_READ_STREAM   (1<<3)
 
#define EXTRA_FRAME(f)   ((f)->extra_frame)
 
#define TUN_LINK_DELTA(f)   ((f)->extra_frame + (f)->extra_tun)
 
#define TUN_MTU_SIZE(f)   ((f)->link_mtu - TUN_LINK_DELTA(f))
 
#define TUN_MTU_SIZE_DYNAMIC(f)   ((f)->link_mtu_dynamic - TUN_LINK_DELTA(f))
 
#define PAYLOAD_SIZE(f)   ((f)->link_mtu - (f)->extra_frame)
 
#define PAYLOAD_SIZE_DYNAMIC(f)   ((f)->link_mtu_dynamic - (f)->extra_frame)
 
#define EXPANDED_SIZE(f)   ((f)->link_mtu)
 
#define EXPANDED_SIZE_DYNAMIC(f)   ((f)->link_mtu_dynamic)
 
#define EXPANDED_SIZE_MIN(f)   (TUN_MTU_MIN + TUN_LINK_DELTA(f))
 
#define MAX_RW_SIZE_TUN(f)   (PAYLOAD_SIZE(f))
 
#define MAX_RW_SIZE_LINK(f)   (EXPANDED_SIZE(f) + (f)->extra_link)
 
#define FRAME_HEADROOM_BASE(f)   (TUN_LINK_DELTA(f) + (f)->extra_buffer + (f)->extra_link)
 
#define FRAME_HEADROOM(f)   frame_headroom(f, 0)
 
#define FRAME_HEADROOM_ADJ(f, fm)   frame_headroom(f, fm)
 
#define BUF_SIZE(f)   (TUN_MTU_SIZE(f) + FRAME_HEADROOM_BASE(f) * 2)
 
#define SET_MTU_TUN   (1<<0) /* use tun/tap rather than link sizing */
 
#define SET_MTU_UPPER_BOUND   (1<<1) /* only decrease dynamic MTU */
 

Functions

void frame_finalize (struct frame *frame, bool link_mtu_defined, int link_mtu, bool tun_mtu_defined, int tun_mtu)
 
void frame_subtract_extra (struct frame *frame, const struct frame *src)
 
void frame_print (const struct frame *frame, int level, const char *prefix)
 
void set_mtu_discover_type (int sd, int mtu_type, sa_family_t proto_af)
 
int translate_mtu_discover_type_name (const char *name)
 
void frame_set_mtu_dynamic (struct frame *frame, int mtu, unsigned int flags)
 
void alloc_buf_sock_tun (struct buffer *buf, const struct frame *frame, const bool tuntap_buffer, const unsigned int align_mask)
 
void frame_init_mssfix (struct frame *frame, const struct options *options)
 Set the –mssfix option. More...
 
static int frame_headroom (const struct frame *f, const unsigned int flag_mask)
 
static void frame_add_to_link_mtu (struct frame *frame, const int increment)
 
static void frame_add_to_extra_frame (struct frame *frame, const int increment)
 
static void frame_add_to_extra_tun (struct frame *frame, const int increment)
 
static void frame_add_to_extra_link (struct frame *frame, const int increment)
 
static void frame_add_to_extra_buffer (struct frame *frame, const int increment)
 
static void frame_add_to_align_adjust (struct frame *frame, const int increment)
 
static void frame_align_to_extra_frame (struct frame *frame)
 
static void frame_or_align_flags (struct frame *frame, const unsigned int flag_mask)
 
static bool frame_defined (const struct frame *frame)
 

Macro Definition Documentation

◆ BUF_SIZE

#define BUF_SIZE (   f)    (TUN_MTU_SIZE(f) + FRAME_HEADROOM_BASE(f) * 2)

◆ ETHERNET_MTU

#define ETHERNET_MTU   1500

Definition at line 54 of file mtu.h.

Referenced by do_init_frame().

◆ EXPANDED_SIZE

#define EXPANDED_SIZE (   f)    ((f)->link_mtu)

◆ EXPANDED_SIZE_DYNAMIC

#define EXPANDED_SIZE_DYNAMIC (   f)    ((f)->link_mtu_dynamic)

Definition at line 173 of file mtu.h.

Referenced by tls_pre_decrypt_lite().

◆ EXPANDED_SIZE_MIN

#define EXPANDED_SIZE_MIN (   f)    (TUN_MTU_MIN + TUN_LINK_DELTA(f))

Definition at line 174 of file mtu.h.

Referenced by frame_set_mtu_dynamic().

◆ EXTRA_FRAME

#define EXTRA_FRAME (   f)    ((f)->extra_frame)

Definition at line 145 of file mtu.h.

Referenced by check_send_occ_msg_dowork().

◆ FRAME_HEADROOM

#define FRAME_HEADROOM (   f)    frame_headroom(f, 0)

◆ FRAME_HEADROOM_ADJ

#define FRAME_HEADROOM_ADJ (   f,
  fm 
)    frame_headroom(f, fm)

◆ FRAME_HEADROOM_BASE

#define FRAME_HEADROOM_BASE (   f)    (TUN_LINK_DELTA(f) + (f)->extra_buffer + (f)->extra_link)

Definition at line 186 of file mtu.h.

Referenced by frame_headroom().

◆ FRAME_HEADROOM_MARKER_DECRYPT

#define FRAME_HEADROOM_MARKER_DECRYPT   (1<<0)

Definition at line 129 of file mtu.h.

Referenced by do_init_frame(), openvpn_decrypt_aead(), and openvpn_decrypt_v1().

◆ FRAME_HEADROOM_MARKER_FRAGMENT

#define FRAME_HEADROOM_MARKER_FRAGMENT   (1<<1)

Definition at line 130 of file mtu.h.

Referenced by do_init_frame(), fragment_incoming(), and frame_finalize_options().

◆ FRAME_HEADROOM_MARKER_READ_LINK

#define FRAME_HEADROOM_MARKER_READ_LINK   (1<<2)

Definition at line 131 of file mtu.h.

Referenced by frame_finalize_options(), and read_incoming_link().

◆ FRAME_HEADROOM_MARKER_READ_STREAM

#define FRAME_HEADROOM_MARKER_READ_STREAM   (1<<3)

Definition at line 132 of file mtu.h.

Referenced by frame_finalize_options(), and socket_frame_init().

◆ LINK_MTU_DEFAULT

#define LINK_MTU_DEFAULT   1500

Definition at line 65 of file mtu.h.

Referenced by init_options(), and options_postprocess_verify_ce().

◆ MAX_RW_SIZE_LINK

#define MAX_RW_SIZE_LINK (   f)    (EXPANDED_SIZE(f) + (f)->extra_link)

Definition at line 181 of file mtu.h.

Referenced by alloc_buf_sock_tun(), and context_gc_free().

◆ MAX_RW_SIZE_TUN

#define MAX_RW_SIZE_TUN (   f)    (PAYLOAD_SIZE(f))

◆ MSSFIX_DEFAULT

#define MSSFIX_DEFAULT   1450

Definition at line 80 of file mtu.h.

Referenced by init_options().

◆ PAYLOAD_ALIGN

#define PAYLOAD_ALIGN   4

Definition at line 86 of file mtu.h.

Referenced by frame_finalize_options(), frame_headroom(), and string_replace_leading().

◆ PAYLOAD_SIZE

#define PAYLOAD_SIZE (   f)    ((f)->link_mtu - (f)->extra_frame)

Definition at line 165 of file mtu.h.

Referenced by options_string().

◆ PAYLOAD_SIZE_DYNAMIC

#define PAYLOAD_SIZE_DYNAMIC (   f)    ((f)->link_mtu_dynamic - (f)->extra_frame)

Definition at line 166 of file mtu.h.

Referenced by fragment_outgoing(), and tls_process().

◆ SET_MTU_TUN

#define SET_MTU_TUN   (1<<0) /* use tun/tap rather than link sizing */

Definition at line 220 of file mtu.h.

Referenced by do_open_tun(), and frame_set_mtu_dynamic().

◆ SET_MTU_UPPER_BOUND

#define SET_MTU_UPPER_BOUND   (1<<1) /* only decrease dynamic MTU */

◆ TAP_MTU_EXTRA_DEFAULT

#define TAP_MTU_EXTRA_DEFAULT   32

Definition at line 75 of file mtu.h.

Referenced by options_postprocess_mutate_ce(), and usage().

◆ TUN_LINK_DELTA

#define TUN_LINK_DELTA (   f)    ((f)->extra_frame + (f)->extra_tun)

◆ TUN_MTU_DEFAULT

#define TUN_MTU_DEFAULT   1500

Definition at line 70 of file mtu.h.

Referenced by init_options(), and usage().

◆ TUN_MTU_MIN

#define TUN_MTU_MIN   100

Definition at line 60 of file mtu.h.

Referenced by frame_finalize(), and process_received_occ_msg().

◆ TUN_MTU_SIZE

#define TUN_MTU_SIZE (   f)    ((f)->link_mtu - TUN_LINK_DELTA(f))

◆ TUN_MTU_SIZE_DYNAMIC

#define TUN_MTU_SIZE_DYNAMIC (   f)    ((f)->link_mtu_dynamic - TUN_LINK_DELTA(f))

Definition at line 157 of file mtu.h.

Referenced by process_ip_header().

Function Documentation

◆ alloc_buf_sock_tun()

void alloc_buf_sock_tun ( struct buffer buf,
const struct frame frame,
const bool  tuntap_buffer,
const unsigned int  align_mask 
)

◆ frame_add_to_align_adjust()

static void frame_add_to_align_adjust ( struct frame frame,
const int  increment 
)
inlinestatic

Definition at line 298 of file mtu.h.

References frame::align_adjust.

Referenced by do_init_frame().

◆ frame_add_to_extra_buffer()

static void frame_add_to_extra_buffer ( struct frame frame,
const int  increment 
)
inlinestatic

Definition at line 292 of file mtu.h.

References frame::extra_buffer.

Referenced by frame_finalize_options().

◆ frame_add_to_extra_frame()

static void frame_add_to_extra_frame ( struct frame frame,
const int  increment 
)
inlinestatic

◆ frame_add_to_extra_link()

static void frame_add_to_extra_link ( struct frame frame,
const int  increment 
)
inlinestatic

Definition at line 286 of file mtu.h.

References frame::extra_link.

Referenced by do_init_frame(), and socks_adjust_frame_parameters().

◆ frame_add_to_extra_tun()

static void frame_add_to_extra_tun ( struct frame frame,
const int  increment 
)
inlinestatic

Definition at line 280 of file mtu.h.

References frame::extra_tun.

Referenced by tun_adjust_frame_parameters().

◆ frame_add_to_link_mtu()

static void frame_add_to_link_mtu ( struct frame frame,
const int  increment 
)
inlinestatic

Definition at line 268 of file mtu.h.

References frame::link_mtu.

Referenced by do_deferred_options().

◆ frame_align_to_extra_frame()

static void frame_align_to_extra_frame ( struct frame frame)
inlinestatic

Definition at line 304 of file mtu.h.

References frame::align_adjust, frame::extra_frame, and frame::extra_link.

Referenced by frame_finalize_options().

◆ frame_defined()

static bool frame_defined ( const struct frame frame)
inlinestatic

Definition at line 316 of file mtu.h.

References frame::link_mtu.

◆ frame_finalize()

void frame_finalize ( struct frame frame,
bool  link_mtu_defined,
int  link_mtu,
bool  tun_mtu_defined,
int  tun_mtu 
)

◆ frame_headroom()

static int frame_headroom ( const struct frame f,
const unsigned int  flag_mask 
)
inlinestatic

Definition at line 255 of file mtu.h.

References frame::align_adjust, frame::align_flags, FRAME_HEADROOM_BASE, and PAYLOAD_ALIGN.

◆ frame_init_mssfix()

void frame_init_mssfix ( struct frame frame,
const struct options options 
)

Set the –mssfix option.

Definition at line 130 of file mtu.c.

References options::ce, frame_set_mtu_dynamic(), connection_entry::mssfix, and SET_MTU_UPPER_BOUND.

Referenced by init_instance(), and tls_session_update_crypto_params().

◆ frame_or_align_flags()

static void frame_or_align_flags ( struct frame frame,
const unsigned int  flag_mask 
)
inlinestatic

Definition at line 310 of file mtu.h.

References frame::align_flags.

Referenced by do_init_frame(), and frame_finalize_options().

◆ frame_print()

void frame_print ( const struct frame frame,
int  level,
const char *  prefix 
)

◆ frame_set_mtu_dynamic()

void frame_set_mtu_dynamic ( struct frame frame,
int  mtu,
unsigned int  flags 
)

◆ frame_subtract_extra()

void frame_subtract_extra ( struct frame frame,
const struct frame src 
)

Definition at line 123 of file mtu.c.

References frame::extra_frame, and frame::extra_tun.

Referenced by do_init_frame().

◆ set_mtu_discover_type()

void set_mtu_discover_type ( int  sd,
int  mtu_type,
sa_family_t  proto_af 
)

Definition at line 169 of file mtu.c.

References M_ERR, M_FATAL, msg, and MTUDISC_NOT_SUPPORTED_MSG.

Referenced by phase2_set_socket_flags().

◆ translate_mtu_discover_type_name()

int translate_mtu_discover_type_name ( const char *  name)