OpenVPN
Macros | Functions
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 *options_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)

◆ TLS_SERVER

#define TLS_SERVER   (o->tls_server)

Function Documentation

◆ options_cmp_equal()

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

Definition at line 368 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 
)

◆ 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 –secret

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 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, COMP_ALG_UNDEF, dev_type_string(), key_type::digest, gc, ifconfig_options_string(), init_key_type(), init_tun(), KEY_METHOD_2, keydirection2ascii(), buffer::len, md_kt_name(), MODE_POINT_TO_POINT, options::ncp_ciphers, OPTION_LINE_SIZE, proto_remote(), PULL_DEFINED, options::shared_secret_file, connection_entry::tls_auth_file, TLS_CLIENT, tls_item_in_cipher_list(), TLS_SERVER, and frame::tun_mtu.

Referenced by do_compute_occ_strings(), and options_string_extract_option().

◆ 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 399 of file options_string.c.

References gc, gc_malloc(), buffer::len, and options_string().

Referenced by key_method_2_read().

◆ options_string_version()

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

Definition at line 386 of file options_string.c.

References alloc_buf_gc(), BPTR, BSTR, gc, and strncpynt().

Referenced by do_compute_occ_strings().

◆ options_warning()

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

Definition at line 380 of file options_string.c.

References options_warning_safe().

Referenced by key_method_2_read().

◆ options_warning_extract_parm1()

static 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 237 of file options_string.c.

References buf_parse(), gc, gc_free(), gc_malloc(), gc_new(), buffer::len, 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 374 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()

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

◆ options_warning_safe_scan1()

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

◆ options_warning_safe_scan2()

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