OpenVPN
Macros | Functions
route.c File Reference
#include <stddef.h>
#include <stdbool.h>
#include "syshead.h"
#include "common.h"
#include "error.h"
#include "route.h"
#include "run_command.h"
#include "socket.h"
#include "manage.h"
#include "win32.h"
#include "options.h"
#include "networking.h"
#include "integer.h"
#include "memdbg.h"
#include "openvpn-msg.h"
Include dependency graph for route.c:

Go to the source code of this file.

Macros

#define METRIC_NOT_USED   ((DWORD)-1)
 
#define RTA_ERROR   0 /* route addition failed */
 
#define RTA_SUCCESS   1 /* route addition succeeded */
 
#define RTA_EEXIST   2 /* route not added as it already exists */
 
#define LR_NOMATCH   0 /* route is not local */
 
#define LR_MATCH   1 /* route is local */
 
#define LR_ERROR   2 /* caller should abort adding route */
 

Functions

static int add_route_service (const struct route_ipv4 *, const struct tuntap *)
 
static bool del_route_service (const struct route_ipv4 *, const struct tuntap *)
 
static int add_route_ipv6_service (const struct route_ipv6 *, const struct tuntap *)
 
static bool del_route_ipv6_service (const struct route_ipv6 *, const struct tuntap *)
 
static int route_ipv6_ipapi (bool add, const struct route_ipv6 *, const struct tuntap *)
 
static int add_route_ipapi (const struct route_ipv4 *r, const struct tuntap *tt, DWORD adapter_index)
 
static bool del_route_ipapi (const struct route_ipv4 *r, const struct tuntap *tt)
 
static void delete_route (struct route_ipv4 *r, const struct tuntap *tt, unsigned int flags, const struct route_gateway_info *rgi, const struct env_set *es, openvpn_net_ctx_t *ctx)
 
static void get_bypass_addresses (struct route_bypass *rb, const unsigned int flags)
 
static bool add_bypass_address (struct route_bypass *rb, const in_addr_t a)
 
struct route_option_listnew_route_option_list (struct gc_arena *a)
 
struct route_ipv6_option_listnew_route_ipv6_option_list (struct gc_arena *a)
 
struct route_option_listclone_route_option_list (const struct route_option_list *src, struct gc_arena *a)
 
struct route_ipv6_option_listclone_route_ipv6_option_list (const struct route_ipv6_option_list *src, struct gc_arena *a)
 
void copy_route_option_list (struct route_option_list *dest, const struct route_option_list *src, struct gc_arena *a)
 
void copy_route_ipv6_option_list (struct route_ipv6_option_list *dest, const struct route_ipv6_option_list *src, struct gc_arena *a)
 
static const char * route_string (const struct route_ipv4 *r, struct gc_arena *gc)
 
static bool is_route_parm_defined (const char *parm)
 
static void setenv_route_addr (struct env_set *es, const char *key, const in_addr_t addr, int i)
 
static bool get_special_addr (const struct route_list *rl, const char *string, in_addr_t *out, bool *status)
 
bool is_special_addr (const char *addr_str)
 
static bool init_route (struct route_ipv4 *r, struct addrinfo **network_list, const struct route_option *ro, const struct route_list *rl)
 
static bool init_route_ipv6 (struct route_ipv6 *r6, const struct route_ipv6_option *r6o, const struct route_ipv6_list *rl6)
 
void add_route_to_option_list (struct route_option_list *l, const char *network, const char *netmask, const char *gateway, const char *metric, int table_id)
 
void add_route_ipv6_to_option_list (struct route_ipv6_option_list *l, const char *prefix, const char *gateway, const char *metric, int table_id)
 
static void clear_route_list (struct route_list *rl)
 
static void clear_route_ipv6_list (struct route_ipv6_list *rl6)
 
void route_list_add_vpn_gateway (struct route_list *rl, struct env_set *es, const in_addr_t addr)
 
static void add_block_local_item (struct route_list *rl, const struct route_gateway_address *gateway, in_addr_t target)
 
static void add_block_local_routes (struct route_list *rl)
 
bool block_local_needed (const struct route_list *rl)
 Get the decision whether to block traffic to local networks while the VPN is connected.
 
bool init_route_list (struct route_list *rl, const struct route_option_list *opt, const char *remote_endpoint, int default_metric, in_addr_t remote_host, struct env_set *es, openvpn_net_ctx_t *ctx)
 
bool ipv6_net_contains_host (const struct in6_addr *network, unsigned int bits, const struct in6_addr *host)
 check whether an IPv6 host address is covered by a given network/bits
 
bool init_route_ipv6_list (struct route_ipv6_list *rl6, const struct route_ipv6_option_list *opt6, const char *remote_endpoint, int default_metric, const struct in6_addr *remote_host_ipv6, struct env_set *es, openvpn_net_ctx_t *ctx)
 
static bool add_route3 (in_addr_t network, in_addr_t netmask, in_addr_t gateway, const struct tuntap *tt, unsigned int flags, const struct route_gateway_info *rgi, const struct env_set *es, openvpn_net_ctx_t *ctx)
 
static void del_route3 (in_addr_t network, in_addr_t netmask, in_addr_t gateway, const struct tuntap *tt, unsigned int flags, const struct route_gateway_info *rgi, const struct env_set *es, openvpn_net_ctx_t *ctx)
 
static bool add_bypass_routes (struct route_bypass *rb, in_addr_t gateway, const struct tuntap *tt, unsigned int flags, const struct route_gateway_info *rgi, const struct env_set *es, openvpn_net_ctx_t *ctx)
 
static void del_bypass_routes (struct route_bypass *rb, in_addr_t gateway, const struct tuntap *tt, unsigned int flags, const struct route_gateway_info *rgi, const struct env_set *es, openvpn_net_ctx_t *ctx)
 
static bool redirect_default_route_to_vpn (struct route_list *rl, const struct tuntap *tt, unsigned int flags, const struct env_set *es, openvpn_net_ctx_t *ctx)
 
static void undo_redirect_default_route_to_vpn (struct route_list *rl, const struct tuntap *tt, unsigned int flags, const struct env_set *es, openvpn_net_ctx_t *ctx)
 
bool add_routes (struct route_list *rl, struct route_ipv6_list *rl6, const struct tuntap *tt, unsigned int flags, const struct env_set *es, openvpn_net_ctx_t *ctx)
 
void delete_routes (struct route_list *rl, struct route_ipv6_list *rl6, const struct tuntap *tt, unsigned int flags, const struct env_set *es, openvpn_net_ctx_t *ctx)
 
void delete_routes_v4 (struct route_list *rl, const struct tuntap *tt, unsigned int flags, const struct env_set *es, openvpn_net_ctx_t *ctx)
 
void delete_routes_v6 (struct route_ipv6_list *rl6, const struct tuntap *tt, unsigned int flags, const struct env_set *es, openvpn_net_ctx_t *ctx)
 
static const char * show_opt (const char *option)
 
static void print_route_option (const struct route_option *ro, msglvl_t msglevel)
 
void print_route_options (const struct route_option_list *rol, msglvl_t msglevel)
 
void print_default_gateway (const msglvl_t msglevel, const struct route_gateway_info *rgi, const struct route_ipv6_gateway_info *rgi6)
 
static void print_route (const struct route_ipv4 *r, msglvl_t msglevel)
 
void print_routes (const struct route_list *rl, msglvl_t msglevel)
 
static void setenv_route (struct env_set *es, const struct route_ipv4 *r, int i)
 
void setenv_routes (struct env_set *es, const struct route_list *rl)
 
static void setenv_route_ipv6 (struct env_set *es, const struct route_ipv6 *r6, int i)
 
void setenv_routes_ipv6 (struct env_set *es, const struct route_ipv6_list *rl6)
 
static int local_route (in_addr_t network, in_addr_t netmask, in_addr_t gateway, const struct route_gateway_info *rgi)
 
static bool is_on_link (const int is_local_route, const unsigned int flags, const struct route_gateway_info *rgi)
 
bool add_route (struct route_ipv4 *r, const struct tuntap *tt, unsigned int flags, const struct route_gateway_info *rgi, const struct env_set *es, openvpn_net_ctx_t *ctx)
 
void route_ipv6_clear_host_bits (struct route_ipv6 *r6)
 
bool add_route_ipv6 (struct route_ipv6 *r6, const struct tuntap *tt, unsigned int flags, const struct env_set *es, openvpn_net_ctx_t *ctx)
 
void delete_route_ipv6 (const struct route_ipv6 *r6, const struct tuntap *tt, const struct env_set *es, openvpn_net_ctx_t *ctx)
 
static const MIB_IPFORWARDTABLE * get_windows_routing_table (struct gc_arena *gc)
 
static int test_route (const IP_ADAPTER_INFO *adapters, const in_addr_t gateway, DWORD *index)
 
static void test_route_helper (bool *ret, int *count, int *good, int *ambig, const IP_ADAPTER_INFO *adapters, const in_addr_t gateway)
 
bool test_routes (const struct route_list *rl, const struct tuntap *tt)
 
static const MIB_IPFORWARDROW * get_default_gateway_row (const MIB_IPFORWARDTABLE *routes)
 
static DWORD get_best_route (struct gc_arena *gc, SOCKADDR_INET *dest, MIB_IPFORWARD_ROW2 *best_route)
 Determines the best route to a destination for both IPv4 and IPv6.
 
void get_default_gateway (struct route_gateway_info *rgi, in_addr_t dest, openvpn_net_ctx_t *ctx)
 Retrieves the best gateway for a given destination based on the routing table.
 
static DWORD windows_route_find_if_index (const struct route_ipv4 *r, const struct tuntap *tt)
 
void get_default_gateway_ipv6 (struct route_ipv6_gateway_info *rgi6, const struct in6_addr *dest, openvpn_net_ctx_t *ctx)
 
static int do_route_service (const bool add, const route_message_t *rt, const DWORD size, HANDLE pipe)
 
static int do_route_ipv4_service (const bool add, const struct route_ipv4 *r, const struct tuntap *tt)
 
static int do_route_ipv6_service (const bool add, const struct route_ipv6 *r, const struct tuntap *tt)
 
static const char * format_route_entry (const MIB_IPFORWARDROW *r, struct gc_arena *gc)
 
void show_routes (msglvl_t msglevel)
 
bool netmask_to_netbits (const in_addr_t network, const in_addr_t netmask, int *netbits)
 
int netmask_to_netbits2 (in_addr_t netmask)
 
static void add_host_route_if_nonlocal (struct route_bypass *rb, const in_addr_t addr)
 
static void add_host_route_array (struct route_bypass *rb, const IP_ADDR_STRING *iplist)
 
int test_local_addr (const in_addr_t addr, const struct route_gateway_info *rgi)
 

Macro Definition Documentation

◆ LR_ERROR

#define LR_ERROR   2 /* caller should abort adding route */

Definition at line 1431 of file route.c.

◆ LR_MATCH

#define LR_MATCH   1 /* route is local */

Definition at line 1430 of file route.c.

◆ LR_NOMATCH

#define LR_NOMATCH   0 /* route is not local */

Definition at line 1429 of file route.c.

◆ METRIC_NOT_USED

#define METRIC_NOT_USED   ((DWORD)-1)

Definition at line 59 of file route.c.

◆ RTA_EEXIST

#define RTA_EEXIST   2 /* route not added as it already exists */

Definition at line 103 of file route.c.

◆ RTA_ERROR

#define RTA_ERROR   0 /* route addition failed */

Definition at line 101 of file route.c.

◆ RTA_SUCCESS

#define RTA_SUCCESS   1 /* route addition succeeded */

Definition at line 102 of file route.c.

Function Documentation

◆ add_block_local_item()

static void add_block_local_item ( struct route_list rl,
const struct route_gateway_address gateway,
in_addr_t  target 
)
static

◆ add_block_local_routes()

static void add_block_local_routes ( struct route_list rl)
static

◆ add_bypass_address()

static bool add_bypass_address ( struct route_bypass rb,
const in_addr_t  a 
)
static

◆ add_bypass_routes()

static bool add_bypass_routes ( struct route_bypass rb,
in_addr_t  gateway,
const struct tuntap tt,
unsigned int  flags,
const struct route_gateway_info rgi,
const struct env_set es,
openvpn_net_ctx_t ctx 
)
static

◆ add_host_route_array()

static void add_host_route_array ( struct route_bypass rb,
const IP_ADDR_STRING *  iplist 
)
static

Definition at line 3940 of file route.c.

References add_host_route_if_nonlocal(), getaddr(), and GETADDR_HOST_ORDER.

Referenced by get_bypass_addresses().

◆ add_host_route_if_nonlocal()

static void add_host_route_if_nonlocal ( struct route_bypass rb,
const in_addr_t  addr 
)
static

Definition at line 3931 of file route.c.

References add_bypass_address(), IPV4_NETMASK_HOST, test_local_addr(), and TLA_NONLOCAL.

Referenced by add_host_route_array().

◆ add_route()

bool add_route ( struct route_ipv4 r,
const struct tuntap tt,
unsigned int  flags,
const struct route_gateway_info rgi,
const struct env_set es,
openvpn_net_ctx_t ctx 
)

◆ add_route3()

static bool add_route3 ( in_addr_t  network,
in_addr_t  netmask,
in_addr_t  gateway,
const struct tuntap tt,
unsigned int  flags,
const struct route_gateway_info rgi,
const struct env_set es,
openvpn_net_ctx_t ctx 
)
static

◆ add_route_ipapi()

static int add_route_ipapi ( const struct route_ipv4 r,
const struct tuntap tt,
DWORD  adapter_index 
)
static

◆ add_route_ipv6()

bool add_route_ipv6 ( struct route_ipv6 r6,
const struct tuntap tt,
unsigned int  flags,
const struct env_set es,
openvpn_net_ctx_t ctx 
)

◆ add_route_ipv6_service()

static int add_route_ipv6_service ( const struct route_ipv6 r,
const struct tuntap tt 
)
static

Definition at line 3037 of file route.c.

References do_route_ipv6_service().

Referenced by add_route_ipv6().

◆ add_route_ipv6_to_option_list()

void add_route_ipv6_to_option_list ( struct route_ipv6_option_list l,
const char *  prefix,
const char *  gateway,
const char *  metric,
int  table_id 
)

◆ add_route_service()

static int add_route_service ( const struct route_ipv4 r,
const struct tuntap tt 
)
static

Definition at line 3024 of file route.c.

References do_route_ipv4_service().

Referenced by add_route().

◆ add_route_to_option_list()

void add_route_to_option_list ( struct route_option_list l,
const char *  network,
const char *  netmask,
const char *  gateway,
const char *  metric,
int  table_id 
)

◆ add_routes()

bool add_routes ( struct route_list rl,
struct route_ipv6_list rl6,
const struct tuntap tt,
unsigned int  flags,
const struct env_set es,
openvpn_net_ctx_t ctx 
)

◆ block_local_needed()

bool block_local_needed ( const struct route_list rl)

Get the decision whether to block traffic to local networks while the VPN is connected.

This definitely returns false when not redirecting the gateway or when the 'block-local' flag is not set. Also checks for other prerequisites to redirect local networks into the tunnel.

Parameters
rlconst pointer to the struct route_list to base the decision on.
Returns
boolean indicating whether local traffic should be blocked.

Definition at line 596 of file route.c.

References route_special_addr::flags, route_gateway_info::flags, route_list::flags, route_special_addr::remote_host_local, RG_BLOCK_LOCAL, route_list::rgi, RGI_ADDR_DEFINED, RGI_NETMASK_DEFINED, RTSA_REMOTE_ENDPOINT, route_list::spec, and TLA_LOCAL.

Referenced by add_wfp_block(), del_wfp_block(), and init_route_list().

◆ clear_route_ipv6_list()

static void clear_route_ipv6_list ( struct route_ipv6_list rl6)
static

Definition at line 528 of file route.c.

References CLEAR, route_ipv6_list::gc, and gc_free().

Referenced by delete_routes_v6(), and init_route_ipv6_list().

◆ clear_route_list()

static void clear_route_list ( struct route_list rl)
static

Definition at line 521 of file route.c.

References CLEAR, route_list::gc, and gc_free().

Referenced by delete_routes_v4(), and init_route_list().

◆ clone_route_ipv6_option_list()

struct route_ipv6_option_list * clone_route_ipv6_option_list ( const struct route_ipv6_option_list src,
struct gc_arena a 
)

Definition at line 162 of file route.c.

References ALLOC_OBJ_GC.

Referenced by pre_connect_save().

◆ clone_route_option_list()

struct route_option_list * clone_route_option_list ( const struct route_option_list src,
struct gc_arena a 
)

Definition at line 153 of file route.c.

References ALLOC_OBJ_GC.

Referenced by pre_connect_save().

◆ copy_route_ipv6_option_list()

void copy_route_ipv6_option_list ( struct route_ipv6_option_list dest,
const struct route_ipv6_option_list src,
struct gc_arena a 
)

Definition at line 179 of file route.c.

References route_ipv6_option_list::gc.

Referenced by pre_connect_restore().

◆ copy_route_option_list()

void copy_route_option_list ( struct route_option_list dest,
const struct route_option_list src,
struct gc_arena a 
)

Definition at line 171 of file route.c.

References route_option_list::gc.

Referenced by pre_connect_restore().

◆ del_bypass_routes()

static void del_bypass_routes ( struct route_bypass rb,
in_addr_t  gateway,
const struct tuntap tt,
unsigned int  flags,
const struct route_gateway_info rgi,
const struct env_set es,
openvpn_net_ctx_t ctx 
)
static

◆ del_route3()

static void del_route3 ( in_addr_t  network,
in_addr_t  netmask,
in_addr_t  gateway,
const struct tuntap tt,
unsigned int  flags,
const struct route_gateway_info rgi,
const struct env_set es,
openvpn_net_ctx_t ctx 
)
static

◆ del_route_ipapi()

static bool del_route_ipapi ( const struct route_ipv4 r,
const struct tuntap tt 
)
static

◆ del_route_ipv6_service()

static bool del_route_ipv6_service ( const struct route_ipv6 r,
const struct tuntap tt 
)
static

Definition at line 3043 of file route.c.

References do_route_ipv6_service().

Referenced by delete_route_ipv6().

◆ del_route_service()

static bool del_route_service ( const struct route_ipv4 r,
const struct tuntap tt 
)
static

Definition at line 3030 of file route.c.

References do_route_ipv4_service().

Referenced by delete_route().

◆ delete_route()

static void delete_route ( struct route_ipv4 r,
const struct tuntap tt,
unsigned int  flags,
const struct route_gateway_info rgi,
const struct env_set es,
openvpn_net_ctx_t ctx 
)
static

◆ delete_route_ipv6()

void delete_route_ipv6 ( const struct route_ipv6 r6,
const struct tuntap tt,
const struct env_set es,
openvpn_net_ctx_t ctx 
)

◆ delete_routes()

void delete_routes ( struct route_list rl,
struct route_ipv6_list rl6,
const struct tuntap tt,
unsigned int  flags,
const struct env_set es,
openvpn_net_ctx_t ctx 
)

Definition at line 1162 of file route.c.

References delete_routes_v4(), delete_routes_v6(), es, and route_ipv6::flags.

Referenced by do_close_tun().

◆ delete_routes_v4()

void delete_routes_v4 ( struct route_list rl,
const struct tuntap tt,
unsigned int  flags,
const struct env_set es,
openvpn_net_ctx_t ctx 
)

◆ delete_routes_v6()

void delete_routes_v6 ( struct route_ipv6_list rl6,
const struct tuntap tt,
unsigned int  flags,
const struct env_set es,
openvpn_net_ctx_t ctx 
)

◆ do_route_ipv4_service()

static int do_route_ipv4_service ( const bool  add,
const struct route_ipv4 r,
const struct tuntap tt 
)
static

◆ do_route_ipv6_service()

static int do_route_ipv6_service ( const bool  add,
const struct route_ipv6 r,
const struct tuntap tt 
)
static

◆ do_route_service()

static int do_route_service ( const bool  add,
const route_message_t rt,
const DWORD  size,
HANDLE  pipe 
)
static

◆ format_route_entry()

static const char * format_route_entry ( const MIB_IPFORWARDROW *  r,
struct gc_arena gc 
)
static

Definition at line 3049 of file route.c.

References alloc_buf_gc(), BSTR, buf_printf(), gc, IA_NET_ORDER, buffer::len, and print_in_addr_t().

Referenced by show_routes().

◆ get_best_route()

static DWORD get_best_route ( struct gc_arena gc,
SOCKADDR_INET *  dest,
MIB_IPFORWARD_ROW2 *  best_route 
)
static

Determines the best route to a destination for both IPv4 and IPv6.

Uses GetBestInterfaceEx and GetBestRoute2 to find the optimal route and network interface for the specified destination address.

Parameters
gcPointer to struct gc_arena for internal string allocation.
destThe destination IP address (IPv4 or IPv6).
best_routePointer to a MIB_IPFORWARD_ROW2 structure to store the best route.
Returns
DWORD NO_ERROR on success, or an error code.

Definition at line 2530 of file route.c.

References CLEAR, D_ROUTE, D_ROUTE_DEBUG, gc, msg, status, and strerror_win32().

Referenced by get_default_gateway(), and get_default_gateway_ipv6().

◆ get_bypass_addresses()

static void get_bypass_addresses ( struct route_bypass rb,
const unsigned int  flags 
)
static

◆ get_default_gateway()

void get_default_gateway ( struct route_gateway_info rgi,
in_addr_t  dest,
openvpn_net_ctx_t ctx 
)

Retrieves the best gateway for a given destination based on the routing table.

Parameters
rgiPointer to a struct to store the gateway information.
destDestination IP address in host byte order.
ctxPointer to a platform-specific network context struct.

Definition at line 2566 of file route.c.

References route_gateway_info::adapter_index, route_gateway_address::addr, CLEAR, route_gateway_info::flags, route_gateway_info::gateway, gc, gc_free(), gc_new(), get_adapter(), get_adapter_info_list(), get_best_route(), route_gateway_info::hwaddr, route_gateway_address::netmask, RGI_ADDR_DEFINED, RGI_HWADDR_DEFINED, RGI_IFACE_DEFINED, RGI_NETMASK_DEFINED, RGI_ON_LINK, and status.

Referenced by add_option(), init_route_list(), push_peer_info(), and warn_on_use_of_common_subnets().

◆ get_default_gateway_ipv6()

void get_default_gateway_ipv6 ( struct route_ipv6_gateway_info rgi6,
const struct in6_addr *  dest,
openvpn_net_ctx_t ctx 
)

◆ get_default_gateway_row()

static const MIB_IPFORWARDROW * get_default_gateway_row ( const MIB_IPFORWARDTABLE *  routes)
static

Definition at line 2482 of file route.c.

References D_ROUTE_DEBUG, dmsg, gc, gc_free(), gc_new(), i, and print_in_addr_t().

Referenced by get_bypass_addresses().

◆ get_special_addr()

static bool get_special_addr ( const struct route_list rl,
const char *  string,
in_addr_t *  out,
bool *  status 
)
static

Definition at line 231 of file route.c.

References buffer::len, M_INFO, msg, RGI_ADDR_DEFINED, RTSA_REMOTE_ENDPOINT, RTSA_REMOTE_HOST, and status.

Referenced by init_route(), and is_special_addr().

◆ get_windows_routing_table()

static const MIB_IPFORWARDTABLE * get_windows_routing_table ( struct gc_arena gc)
static

Definition at line 2380 of file route.c.

References D_ROUTE, gc, gc_malloc(), msg, status, and strerror_win32().

Referenced by get_bypass_addresses(), show_routes(), and test_local_addr().

◆ init_route()

static bool init_route ( struct route_ipv4 r,
struct addrinfo **  network_list,
const struct route_option ro,
const struct route_list rl 
)
static

◆ init_route_ipv6()

static bool init_route_ipv6 ( struct route_ipv6 r6,
const struct route_ipv6_option r6o,
const struct route_ipv6_list rl6 
)
static

◆ init_route_ipv6_list()

bool init_route_ipv6_list ( struct route_ipv6_list rl6,
const struct route_ipv6_option_list opt6,
const char *  remote_endpoint,
int  default_metric,
const struct in6_addr *  remote_host_ipv6,
struct env_set es,
openvpn_net_ctx_t ctx 
)

◆ init_route_list()

bool init_route_list ( struct route_list rl,
const struct route_option_list opt,
const char *  remote_endpoint,
int  default_metric,
in_addr_t  remote_host,
struct env_set es,
openvpn_net_ctx_t ctx 
)

◆ ipv6_net_contains_host()

bool ipv6_net_contains_host ( const struct in6_addr *  network,
unsigned int  bits,
const struct in6_addr *  host 
)

check whether an IPv6 host address is covered by a given network/bits

Parameters
networkthe network address
bitsthe network mask
hostthe host address to be checked if it is contained by the network
Returns
true if the host address is covered by the network with the given network mask by bits

Definition at line 714 of file route.c.

References i, and route_ipv4::network.

Referenced by init_route_ipv6_list().

◆ is_on_link()

static bool is_on_link ( const int  is_local_route,
const unsigned int  flags,
const struct route_gateway_info rgi 
)
inlinestatic

Definition at line 1467 of file route.c.

References route_gateway_info::flags, LR_MATCH, RGI_ON_LINK, and ROUTE_REF_GW.

Referenced by add_route(), and delete_route().

◆ is_route_parm_defined()

static bool is_route_parm_defined ( const char *  parm)
static

Definition at line 200 of file route.c.

References buffer::len.

Referenced by init_route(), init_route_ipv6(), init_route_ipv6_list(), and init_route_list().

◆ is_special_addr()

bool is_special_addr ( const char *  addr_str)

Definition at line 299 of file route.c.

References get_special_addr(), and buffer::len.

Referenced by add_option(), and check_route_option().

◆ local_route()

static int local_route ( in_addr_t  network,
in_addr_t  netmask,
in_addr_t  gateway,
const struct route_gateway_info rgi 
)
static

◆ netmask_to_netbits()

bool netmask_to_netbits ( const in_addr_t  network,
const in_addr_t  netmask,
int *  netbits 
)

Definition at line 3874 of file route.c.

References i, and netbits_to_netmask().

Referenced by do_route_ipv4_service(), and helper_client_server().

◆ netmask_to_netbits2()

int netmask_to_netbits2 ( in_addr_t  netmask)

◆ new_route_ipv6_option_list()

struct route_ipv6_option_list * new_route_ipv6_option_list ( struct gc_arena a)

Definition at line 137 of file route.c.

References ALLOC_OBJ_CLEAR_GC, and route_ipv6_option_list::gc.

Referenced by rol6_check_alloc().

◆ new_route_option_list()

struct route_option_list * new_route_option_list ( struct gc_arena a)

Definition at line 128 of file route.c.

References ALLOC_OBJ_CLEAR_GC, and route_option_list::gc.

Referenced by rol_check_alloc().

◆ print_default_gateway()

void print_default_gateway ( const msglvl_t  msglevel,
const struct route_gateway_info rgi,
const struct route_ipv6_gateway_info rgi6 
)

◆ print_route()

static void print_route ( const struct route_ipv4 r,
msglvl_t  msglevel 
)
static

Definition at line 1322 of file route.c.

References route_ipv4::flags, gc, gc_free(), gc_new(), msg, route_string(), and RT_DEFINED.

Referenced by print_routes().

◆ print_route_option()

static void print_route_option ( const struct route_option ro,
msglvl_t  msglevel 
)
static

◆ print_route_options()

void print_route_options ( const struct route_option_list rol,
msglvl_t  msglevel 
)

◆ print_routes()

void print_routes ( const struct route_list rl,
msglvl_t  msglevel 
)

Definition at line 1333 of file route.c.

References route_ipv4::next, print_route(), and route_list::routes.

◆ redirect_default_route_to_vpn()

static bool redirect_default_route_to_vpn ( struct route_list rl,
const struct tuntap tt,
unsigned int  flags,
const struct env_set es,
openvpn_net_ctx_t ctx 
)
static

◆ route_ipv6_clear_host_bits()

void route_ipv6_clear_host_bits ( struct route_ipv6 r6)

Definition at line 1765 of file route.c.

References r6.

Referenced by add_route_ipv6(), and delete_route_connected_v6_net().

◆ route_ipv6_ipapi()

static int route_ipv6_ipapi ( bool  add,
const struct route_ipv6 r,
const struct tuntap tt 
)
static

◆ route_list_add_vpn_gateway()

void route_list_add_vpn_gateway ( struct route_list rl,
struct env_set es,
const in_addr_t  addr 
)

◆ route_string()

static const char * route_string ( const struct route_ipv4 r,
struct gc_arena gc 
)
static

Definition at line 187 of file route.c.

References alloc_buf_gc(), BSTR, buf_printf(), gc, buffer::len, print_in_addr_t(), and RT_METRIC_DEFINED.

Referenced by print_route().

◆ setenv_route()

static void setenv_route ( struct env_set es,
const struct route_ipv4 r,
int  i 
)
static

◆ setenv_route_addr()

static void setenv_route_addr ( struct env_set es,
const char *  key,
const in_addr_t  addr,
int  i 
)
static

◆ setenv_route_ipv6()

static void setenv_route_ipv6 ( struct env_set es,
const struct route_ipv6 r6,
int  i 
)
static

◆ setenv_routes()

void setenv_routes ( struct env_set es,
const struct route_list rl 
)

Definition at line 1363 of file route.c.

References es, i, route_ipv4::next, route_list::routes, and setenv_route().

Referenced by do_init_route_list().

◆ setenv_routes_ipv6()

void setenv_routes_ipv6 ( struct env_set es,
const struct route_ipv6_list rl6 
)

Definition at line 1400 of file route.c.

References es, i, r6, route_ipv6_list::routes_ipv6, and setenv_route_ipv6().

Referenced by do_init_route_ipv6_list().

◆ show_opt()

static const char * show_opt ( const char *  option)
static

Definition at line 1214 of file route.c.

Referenced by print_route_option().

◆ show_routes()

void show_routes ( msglvl_t  msglevel)

◆ test_local_addr()

int test_local_addr ( const in_addr_t  addr,
const struct route_gateway_info rgi 
)

◆ test_route()

static int test_route ( const IP_ADAPTER_INFO *  adapters,
const in_addr_t  gateway,
DWORD *  index 
)
static

Definition at line 2402 of file route.c.

References adapter_index_of_ip(), and i.

Referenced by test_route_helper(), and windows_route_find_if_index().

◆ test_route_helper()

static void test_route_helper ( bool *  ret,
int *  count,
int *  good,
int *  ambig,
const IP_ADAPTER_INFO *  adapters,
const in_addr_t  gateway 
)
static

Definition at line 2414 of file route.c.

References test_route().

Referenced by test_routes().

◆ test_routes()

bool test_routes ( const struct route_list rl,
const struct tuntap tt 
)

◆ undo_redirect_default_route_to_vpn()

static void undo_redirect_default_route_to_vpn ( struct route_list rl,
const struct tuntap tt,
unsigned int  flags,
const struct env_set es,
openvpn_net_ctx_t ctx 
)
static

◆ windows_route_find_if_index()

static DWORD windows_route_find_if_index ( const struct route_ipv4 r,
const struct tuntap tt 
)
static