OpenVPN
options_string.c File Reference
#include "syshead.h"
#include "buffer.h"
#include "crypto.h"
#include "error.h"
#include "mtu.h"
#include "options.h"
#include "socket_util.h"
#include "ssl.h"
#include "ssl_ncp.h"
#include "tun.h"
#include <string.h>
Include dependency graph for options_string.c:

Go to the source code of this file.

Macros

#define TLS_CLIENT   (o->tls_client)
#define TLS_SERVER   (o->tls_server)

Functions

char * options_string (const struct options *o, const struct frame *frame, struct tuntap *tt, openvpn_net_ctx_t *ctx, bool remote, struct gc_arena *gc)
 Build an options string to represent data channel encryption options.
static const char * options_warning_extract_parm1 (const char *option_string, struct gc_arena *gc_ret)
 Compare option strings for equality.
static void options_warning_safe_scan2 (const msglvl_t msglevel, const int delim, const bool report_inconsistent, const char *p1, const struct buffer *b2_src, const char *b1_name, const char *b2_name)
static void options_warning_safe_scan1 (const msglvl_t msglevel, const int delim, const bool report_inconsistent, const struct buffer *b1_src, const struct buffer *b2_src, const char *b1_name, const char *b2_name)
static void options_warning_safe_ml (const msglvl_t msglevel, char *actual, const char *expected, size_t actual_n)
bool options_cmp_equal_safe (char *actual, const char *expected, size_t actual_n)
bool options_cmp_equal (char *actual, const char *expected)
void options_warning_safe (char *actual, const char *expected, size_t actual_n)
void options_warning (char *actual, const char *expected)
const char * options_string_version (const char *s, struct gc_arena *gc)
char * options_string_extract_option (const char *option_string, const char *opt_name, struct gc_arena *gc)
 Given an OpenVPN options string, extract the value of an option.

Macro Definition Documentation

◆ TLS_CLIENT

#define TLS_CLIENT   (o->tls_client)

Referenced by options_string().

◆ TLS_SERVER

#define TLS_SERVER   (o->tls_server)

Referenced by options_string().

Function Documentation

◆ options_cmp_equal()

bool options_cmp_equal ( char * actual,
const char * expected )

Definition at line 355 of file options_string.c.

References options_cmp_equal_safe().

Referenced by key_method_2_read().

◆ options_cmp_equal_safe()

bool options_cmp_equal_safe ( char * actual,
const char * expected,
size_t actual_n )

Definition at line 334 of file options_string.c.

References D_SHOW_OCC, msg, and options_warning_safe_ml().

Referenced by options_cmp_equal(), and process_received_occ_msg().

◆ options_string()

char * options_string ( const struct options * o,
const struct frame * frame,
struct tuntap * tt,
openvpn_net_ctx_t * ctx,
bool remote,
struct gc_arena * gc )

Build an options string to represent data channel encryption options.

This string must match exactly between peers. The keysize is checked separately by read_key().

The following options must match on both peers:

Tunnel options:

–dev tun|tap [unit number need not match] –dev-type tun|tap –link-mtu –udp-mtu –tun-mtu –proto udp –proto tcp-client [matched with –proto tcp-server on the other end of the connection] –proto tcp-server [matched with –proto tcp-client on the other end of the connection] –tun-ipv6 –ifconfig x y [matched with –ifconfig y x on the other end of the connection]

–comp-lzo –compress alg –fragment

Crypto Options:

–cipher –auth

SSL Options:

–tls-auth –tls-client [matched with –tls-server on the other end of the connection] –tls-server [matched with –tls-client on the other end of the connection]

Definition at line 42 of file options_string.c.

References compress_options::alg, alloc_buf(), ASSERT, options::authname, BSTR, buf_printf(), calc_options_string_link_mtu(), options::ce, key_type::cipher, cipher_defined(), cipher_kt_key_size(), cipher_kt_name(), options::ciphername, options::comp, COMP_ALG_UNDEF, options::dev, options::dev_type, dev_type_string(), key_type::digest, connection_entry::fragment, gc, options::ifconfig_ipv6_local, options::ifconfig_ipv6_netbits, options::ifconfig_ipv6_remote, options::ifconfig_local, options::ifconfig_nowarn, ifconfig_options_string(), options::ifconfig_remote_netmask, init_key_type(), init_tun(), options::key_direction, KEY_METHOD_2, keydirection2ascii(), md_kt_name(), options::mode, MODE_POINT_TO_POINT, options::ncp_ciphers, connection_entry::occ_mtu, OPTION_LINE_SIZE, connection_entry::proto, proto_remote(), PULL_DEFINED, connection_entry::tls_auth_file, TLS_CLIENT, tls_item_in_cipher_list(), TLS_SERVER, options::topology, and frame::tun_mtu.

Referenced by do_compute_occ_strings().

◆ options_string_extract_option()

char * options_string_extract_option ( const char * options_string,
const char * opt_name,
struct gc_arena * gc )

Given an OpenVPN options string, extract the value of an option.

Parameters
options_stringZero-terminated, comma-separated options string
opt_nameThe name of the option to extract
gcThe gc to allocate the return value
Returns
gc-allocated value of option with name opt_name if option was found, or NULL otherwise.

Definition at line 387 of file options_string.c.

References gc, and gc_malloc().

Referenced by key_method_2_read().

◆ options_string_version()

const char * options_string_version ( const char * s,
struct gc_arena * gc )

Definition at line 373 of file options_string.c.

References gc, gc_malloc(), and strlcpy().

Referenced by do_compute_occ_strings().

◆ options_warning()

void options_warning ( char * actual,
const char * expected )

Definition at line 367 of file options_string.c.

References options_warning_safe().

Referenced by key_method_2_read().

◆ options_warning_extract_parm1()

const char * options_warning_extract_parm1 ( const char * option_string,
struct gc_arena * gc_ret )
static

Compare option strings for equality.

If the first two chars of the strings differ, it means that we are looking at different versions of the options string, therefore don't compare them and return true.

Definition at line 226 of file options_string.c.

References buf_parse(), gc, gc_free(), gc_malloc(), gc_new(), OPTION_PARM_SIZE, string_alloc(), and string_alloc_buf().

Referenced by options_warning_safe_scan2().

◆ options_warning_safe()

void options_warning_safe ( char * actual,
const char * expected,
size_t actual_n )

Definition at line 361 of file options_string.c.

References D_SHOW_OCC, and options_warning_safe_ml().

Referenced by options_warning(), and process_received_occ_msg().

◆ options_warning_safe_ml()

void options_warning_safe_ml ( const msglvl_t msglevel,
char * actual,
const char * expected,
size_t actual_n )
static

◆ options_warning_safe_scan1()

void options_warning_safe_scan1 ( const msglvl_t msglevel,
const int delim,
const bool report_inconsistent,
const struct buffer * b1_src,
const struct buffer * b2_src,
const char * b1_name,
const char * b2_name )
static

◆ options_warning_safe_scan2()

void options_warning_safe_scan2 ( const msglvl_t msglevel,
const int delim,
const bool report_inconsistent,
const char * p1,
const struct buffer * b2_src,
const char * b1_name,
const char * b2_name )
static