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

Go to the source code of this file.

Data Structures

struct  route_bypass
 
struct  route_special_addr
 
struct  route_option
 
struct  route_option_list
 
struct  route_ipv6_option
 
struct  route_ipv6_option_list
 
struct  route_ipv4
 
struct  route_ipv6
 
struct  route_gateway_address
 
struct  route_gateway_info
 
struct  route_ipv6_gateway_address
 
struct  route_ipv6_gateway_info
 
struct  route_list
 
struct  route_ipv6_list
 
struct  iroute
 
struct  iroute_ipv6
 

Macros

#define ROUTE_METHOD_ADAPTIVE   0 /* try IP helper first then route.exe */
 
#define ROUTE_METHOD_IPAPI   1 /* use IP helper API */
 
#define ROUTE_METHOD_EXE   2 /* use route.exe */
 
#define ROUTE_METHOD_SERVICE   3 /* use the privileged Windows service */
 
#define ROUTE_METHOD_MASK   3
 
#define ROUTE_DELETE_FIRST   (1<<2)
 
#define ROUTE_REF_GW   (1<<3)
 
#define N_ROUTE_BYPASS   8
 
#define RTSA_REMOTE_ENDPOINT   (1<<0)
 
#define RTSA_REMOTE_HOST   (1<<1)
 
#define RTSA_DEFAULT_METRIC   (1<<2)
 
#define RG_ENABLE   (1<<0)
 
#define RG_LOCAL   (1<<1)
 
#define RG_DEF1   (1<<2)
 
#define RG_BYPASS_DHCP   (1<<3)
 
#define RG_BYPASS_DNS   (1<<4)
 
#define RG_REROUTE_GW   (1<<5)
 
#define RG_AUTO_LOCAL   (1<<6)
 
#define RG_BLOCK_LOCAL   (1<<7)
 
#define RT_DEFINED   (1<<0)
 
#define RT_ADDED   (1<<1)
 
#define RT_METRIC_DEFINED   (1<<2)
 
#define RGI_ADDR_DEFINED   (1<<0) /* set if gateway.addr defined */
 
#define RGI_NETMASK_DEFINED   (1<<1) /* set if gateway.netmask defined */
 
#define RGI_HWADDR_DEFINED   (1<<2) /* set if hwaddr is defined */
 
#define RGI_IFACE_DEFINED   (1<<3) /* set if iface is defined */
 
#define RGI_OVERFLOW   (1<<4) /* set if more interface addresses than will fit in addrs */
 
#define RGI_ON_LINK   (1<<5)
 
#define RGI_N_ADDRESSES   8
 
#define RGI_N_ADDRESSES   8
 
#define RL_DID_REDIRECT_DEFAULT_GATEWAY   (1<<0)
 
#define RL_DID_LOCAL   (1<<1)
 
#define RL_ROUTES_ADDED   (1<<2)
 
#define TLA_NOT_IMPLEMENTED   0
 
#define TLA_NONLOCAL   1
 
#define TLA_LOCAL   2
 

Functions

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)
 
void route_ipv6_clear_host_bits (struct route_ipv6 *r6)
 
void add_route_ipv6 (struct route_ipv6 *r, const struct tuntap *tt, unsigned int flags, const struct env_set *es)
 
void delete_route_ipv6 (const struct route_ipv6 *r, const struct tuntap *tt, unsigned int flags, const struct env_set *es)
 
void add_route (struct route_ipv4 *r, const struct tuntap *tt, unsigned int flags, const struct route_gateway_info *rgi, const struct env_set *es)
 
void add_route_to_option_list (struct route_option_list *l, const char *network, const char *netmask, const char *gateway, const char *metric)
 
void add_route_ipv6_to_option_list (struct route_ipv6_option_list *l, const char *prefix, const char *gateway, const char *metric)
 
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)
 
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, struct env_set *es)
 
void route_list_add_vpn_gateway (struct route_list *rl, struct env_set *es, const in_addr_t addr)
 
void add_routes (struct route_list *rl, struct route_ipv6_list *rl6, const struct tuntap *tt, unsigned int flags, const struct env_set *es)
 
void delete_routes (struct route_list *rl, struct route_ipv6_list *rl6, const struct tuntap *tt, unsigned int flags, const struct env_set *es)
 
void setenv_routes (struct env_set *es, const struct route_list *rl)
 
void setenv_routes_ipv6 (struct env_set *es, const struct route_ipv6_list *rl6)
 
bool is_special_addr (const char *addr_str)
 
void get_default_gateway (struct route_gateway_info *rgi)
 
void get_default_gateway_ipv6 (struct route_ipv6_gateway_info *rgi, const struct in6_addr *dest)
 
void print_default_gateway (const int msglevel, const struct route_gateway_info *rgi, const struct route_ipv6_gateway_info *rgi6)
 
int test_local_addr (const in_addr_t addr, const struct route_gateway_info *rgi)
 
void print_route_options (const struct route_option_list *rol, int level)
 
void print_routes (const struct route_list *rl, int level)
 
void show_routes (int msglev)
 
bool test_routes (const struct route_list *rl, const struct tuntap *tt)
 
bool add_route_ipapi (const struct route_ipv4 *r, const struct tuntap *tt, DWORD adapter_index)
 
bool del_route_ipapi (const struct route_ipv4 *r, const struct tuntap *tt)
 
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 in_addr_t netbits_to_netmask (const int netbits)
 
static bool route_list_vpn_gateway_needed (const struct route_list *rl)
 
static int route_did_redirect_default_gateway (const struct route_list *rl)
 

Macro Definition Documentation

◆ N_ROUTE_BYPASS

#define N_ROUTE_BYPASS   8

Definition at line 54 of file route.h.

Referenced by add_bypass_address().

◆ RG_AUTO_LOCAL

#define RG_AUTO_LOCAL   (1<<6)

Definition at line 89 of file route.h.

Referenced by add_option(), and redirect_default_route_to_vpn().

◆ RG_BLOCK_LOCAL

#define RG_BLOCK_LOCAL   (1<<7)

Definition at line 90 of file route.h.

Referenced by add_block_local(), and add_option().

◆ RG_BYPASS_DHCP

#define RG_BYPASS_DHCP   (1<<3)

Definition at line 86 of file route.h.

Referenced by add_option(), and get_bypass_addresses().

◆ RG_BYPASS_DNS

#define RG_BYPASS_DNS   (1<<4)

Definition at line 87 of file route.h.

Referenced by add_option(), and get_bypass_addresses().

◆ RG_DEF1

#define RG_DEF1   (1<<2)

◆ RG_ENABLE

#define RG_ENABLE   (1<<0)

◆ RG_LOCAL

#define RG_LOCAL   (1<<1)

Definition at line 84 of file route.h.

Referenced by add_option(), print_route_options(), and redirect_default_route_to_vpn().

◆ RG_REROUTE_GW

#define RG_REROUTE_GW   (1<<5)

◆ RGI_ADDR_DEFINED

#define RGI_ADDR_DEFINED   (1<<0) /* set if gateway.addr defined */

◆ RGI_HWADDR_DEFINED

#define RGI_HWADDR_DEFINED   (1<<2) /* set if hwaddr is defined */

Definition at line 148 of file route.h.

Referenced by get_default_gateway(), print_default_gateway(), push_peer_info(), and show_routes().

◆ RGI_IFACE_DEFINED

#define RGI_IFACE_DEFINED   (1<<3) /* set if iface is defined */

◆ RGI_N_ADDRESSES [1/2]

#define RGI_N_ADDRESSES   8

Definition at line 196 of file route.h.

◆ RGI_N_ADDRESSES [2/2]

#define RGI_N_ADDRESSES   8

Definition at line 196 of file route.h.

◆ RGI_NETMASK_DEFINED

#define RGI_NETMASK_DEFINED   (1<<1) /* set if gateway.netmask defined */

◆ RGI_ON_LINK

#define RGI_ON_LINK   (1<<5)

◆ RGI_OVERFLOW

#define RGI_OVERFLOW   (1<<4) /* set if more interface addresses than will fit in addrs */

Definition at line 150 of file route.h.

◆ RL_DID_LOCAL

#define RL_DID_LOCAL   (1<<1)

Definition at line 203 of file route.h.

Referenced by redirect_default_route_to_vpn(), and undo_redirect_default_route_to_vpn().

◆ RL_DID_REDIRECT_DEFAULT_GATEWAY

#define RL_DID_REDIRECT_DEFAULT_GATEWAY   (1<<0)

◆ RL_ROUTES_ADDED

#define RL_ROUTES_ADDED   (1<<2)

Definition at line 204 of file route.h.

Referenced by add_routes(), and delete_routes().

◆ ROUTE_DELETE_FIRST

#define ROUTE_DELETE_FIRST   (1<<2)

Definition at line 49 of file route.h.

Referenced by add_routes().

◆ ROUTE_METHOD_ADAPTIVE

#define ROUTE_METHOD_ADAPTIVE   0 /* try IP helper first then route.exe */

Definition at line 39 of file route.h.

Referenced by add_option(), add_route(), delete_route(), and init_options().

◆ ROUTE_METHOD_EXE

#define ROUTE_METHOD_EXE   2 /* use route.exe */

Definition at line 41 of file route.h.

Referenced by add_option(), add_route(), and delete_route().

◆ ROUTE_METHOD_IPAPI

#define ROUTE_METHOD_IPAPI   1 /* use IP helper API */

Definition at line 40 of file route.h.

Referenced by add_option(), add_route(), and delete_route().

◆ ROUTE_METHOD_MASK

#define ROUTE_METHOD_MASK   3

Definition at line 43 of file route.h.

Referenced by add_route(), and delete_route().

◆ ROUTE_METHOD_SERVICE

#define ROUTE_METHOD_SERVICE   3 /* use the privileged Windows service */

Definition at line 42 of file route.h.

Referenced by add_option(), add_route(), delete_route(), and remap_redirect_gateway_flags().

◆ ROUTE_REF_GW

#define ROUTE_REF_GW   (1<<3)

◆ RT_ADDED

#define RT_ADDED   (1<<1)

◆ RT_DEFINED

#define RT_DEFINED   (1<<0)

◆ RT_METRIC_DEFINED

#define RT_METRIC_DEFINED   (1<<2)

◆ RTSA_DEFAULT_METRIC

#define RTSA_DEFAULT_METRIC   (1<<2)

Definition at line 64 of file route.h.

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

◆ RTSA_REMOTE_ENDPOINT

#define RTSA_REMOTE_ENDPOINT   (1<<0)

◆ RTSA_REMOTE_HOST

#define RTSA_REMOTE_HOST   (1<<1)

◆ TLA_LOCAL

#define TLA_LOCAL   2

Definition at line 335 of file route.h.

Referenced by add_block_local(), redirect_default_route_to_vpn(), and test_local_addr().

◆ TLA_NONLOCAL

#define TLA_NONLOCAL   1

◆ TLA_NOT_IMPLEMENTED

#define TLA_NOT_IMPLEMENTED   0

Definition at line 333 of file route.h.

Referenced by test_local_addr().

Function Documentation

◆ add_route()

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

◆ add_route_ipapi()

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

◆ add_route_ipv6()

void add_route_ipv6 ( struct route_ipv6 r,
const struct tuntap tt,
unsigned int  flags,
const struct env_set es 
)

◆ 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 
)

◆ 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 
)

◆ add_routes()

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

◆ 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 144 of file route.c.

References ALLOC_OBJ_GC.

Referenced by pre_pull_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 135 of file route.c.

References ALLOC_OBJ_GC.

Referenced by pre_pull_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 160 of file route.c.

References route_ipv6_option_list::gc.

Referenced by pre_pull_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 153 of file route.c.

References route_option_list::gc.

Referenced by pre_pull_restore().

◆ del_route_ipapi()

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

◆ delete_route_ipv6()

void delete_route_ipv6 ( const struct route_ipv6 r,
const struct tuntap tt,
unsigned int  flags,
const struct env_set es 
)

◆ 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 
)

◆ get_default_gateway()

void get_default_gateway ( struct route_gateway_info rgi)

◆ get_default_gateway_ipv6()

void get_default_gateway_ipv6 ( struct route_ipv6_gateway_info rgi,
const struct in6_addr *  dest 
)

◆ 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,
struct env_set es 
)

◆ 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 
)

◆ is_special_addr()

bool is_special_addr ( const char *  addr_str)

Definition at line 286 of file route.c.

References get_special_addr().

Referenced by add_option().

◆ netbits_to_netmask()

static in_addr_t netbits_to_netmask ( const int  netbits)
inlinestatic

◆ netmask_to_netbits()

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

Definition at line 4008 of file route.c.

References in_addr_t, and netbits_to_netmask().

Referenced by do_route_ipv4_service(), helper_client_server(), and option_iroute().

◆ netmask_to_netbits2()

int netmask_to_netbits2 ( in_addr_t  netmask)

Definition at line 4039 of file route.c.

References in_addr_t, and netbits_to_netmask().

Referenced by add_route(), delete_route(), do_ifconfig_ipv4(), and open_null().

◆ new_route_ipv6_option_list()

struct route_ipv6_option_list* new_route_ipv6_option_list ( struct gc_arena a)

Definition at line 119 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 110 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 int  msglevel,
const struct route_gateway_info rgi,
const struct route_ipv6_gateway_info rgi6 
)

◆ print_route_options()

void print_route_options ( const struct route_option_list rol,
int  level 
)

◆ print_routes()

void print_routes ( const struct route_list rl,
int  level 
)

Definition at line 1387 of file route.c.

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

◆ route_did_redirect_default_gateway()

static int route_did_redirect_default_gateway ( const struct route_list rl)
inlinestatic

Definition at line 394 of file route.h.

References BOOL_CAST, route_list::iflags, and RL_DID_REDIRECT_DEFAULT_GATEWAY.

Referenced by do_route().

◆ route_ipv6_clear_host_bits()

void route_ipv6_clear_host_bits ( struct route_ipv6 r6)

Definition at line 1824 of file route.c.

References route_ipv6::netbits, and route_ipv6::network.

Referenced by add_route_ipv6(), and delete_route_connected_v6_net().

◆ 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_list_vpn_gateway_needed()

static bool route_list_vpn_gateway_needed ( const struct route_list rl)
inlinestatic

Definition at line 381 of file route.h.

References route_special_addr::flags, RTSA_REMOTE_ENDPOINT, and route_list::spec.

◆ setenv_routes()

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

Definition at line 1417 of file route.c.

References 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 1448 of file route.c.

References route_ipv6::next, route_ipv6_list::routes_ipv6, and setenv_route_ipv6().

Referenced by do_init_route_ipv6_list().

◆ show_routes()

void show_routes ( int  msglev)

◆ test_local_addr()

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

◆ test_routes()

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