OpenVPN
|
#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"
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_list * | new_route_option_list (struct gc_arena *a) |
struct route_ipv6_option_list * | new_route_ipv6_option_list (struct gc_arena *a) |
struct route_option_list * | clone_route_option_list (const struct route_option_list *src, struct gc_arena *a) |
struct route_ipv6_option_list * | clone_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) |
void | add_route_ipv6_to_option_list (struct route_ipv6_option_list *l, const char *prefix, const char *gateway, const char *metric) |
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. More... | |
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) |
static bool | route_ipv6_match_host (const struct route_ipv6 *r6, const struct in6_addr *host) |
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) |
static const char * | show_opt (const char *option) |
static void | print_route_option (const struct route_option *ro, int level) |
void | print_route_options (const struct route_option_list *rol, int level) |
void | print_default_gateway (const int msglevel, const struct route_gateway_info *rgi, const struct route_ipv6_gateway_info *rgi6) |
static void | print_route (const struct route_ipv4 *r, int level) |
void | print_routes (const struct route_list *rl, int level) |
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, unsigned int flags, 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) |
void | get_default_gateway (struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx) |
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 size_t 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 (int msglev) |
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) |
#define RTA_EEXIST 2 /* route not added as it already exists */ |
|
static |
Definition at line 568 of file route.c.
References ALLOC_OBJ_GC, route_ipv4::gateway, route_gateway_info::gateway, route_list::gc, route_gateway_address::netmask, route_ipv4::network, route_ipv4::next, http-client::r1, route_list::rgi, route_list::routes, and RT_DEFINED.
Referenced by add_block_local_routes().
|
static |
Definition at line 597 of file route.c.
References add_block_local_item(), add_bypass_address(), route_gateway_address::addr, route_gateway_info::addrs, route_special_addr::bypass, route_gateway_info::gateway, route_gateway_info::n_addrs, route_gateway_address::netmask, route_special_addr::remote_endpoint, route_list::rgi, and route_list::spec.
Referenced by init_route_list().
|
static |
Definition at line 108 of file route.c.
References route_bypass::bypass, route_bypass::n_bypass, and N_ROUTE_BYPASS.
Referenced by add_block_local_routes(), and add_host_route_if_nonlocal().
|
static |
Definition at line 961 of file route.c.
References add_route3(), route_bypass::bypass, es, route_ipv4::flags, route_ipv4::gateway, IPV4_NETMASK_HOST, route_bypass::n_bypass, and ROUTE_REF_GW.
Referenced by redirect_default_route_to_vpn().
|
static |
Definition at line 3994 of file route.c.
References add_host_route_if_nonlocal(), getaddr(), and GETADDR_HOST_ORDER.
Referenced by get_bypass_addresses().
|
static |
Definition at line 3985 of file route.c.
References add_bypass_address(), IPV4_NETMASK_HOST, test_local_addr(), and TLA_NONLOCAL.
Referenced by add_host_route_array().
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 | ||
) |
Definition at line 1565 of file route.c.
References route_gateway_info::adapter_index, add_route_ipapi(), add_route_service(), argv_free(), argv_msg(), argv_new(), argv_printf(), argv_printf_cat(), ASSERT, D_ROUTE, es, route_ipv4::flags, route_ipv4::gateway, gc_free(), gc_new(), get_win_sys_path(), iface, is_on_link(), local_route(), LR_ERROR, M_FATAL, M_WARN, route_ipv4::metric, msg, net_ctx_reset(), netcmd_semaphore_lock(), netcmd_semaphore_release(), route_ipv4::netmask, netmask_to_netbits2(), route_ipv4::network, openvpn_execve_check(), print_in_addr_t(), ROUTE_METHOD_ADAPTIVE, ROUTE_METHOD_EXE, ROUTE_METHOD_IPAPI, ROUTE_METHOD_MASK, ROUTE_METHOD_SERVICE, ROUTE_PATH, RT_ADDED, RT_DEFINED, RT_METRIC_DEFINED, RTA_EEXIST, RTA_ERROR, RTA_SUCCESS, status, TUN_ADAPTER_INDEX_INVALID, and WIN_ROUTE_PATH_SUFFIX.
Referenced by add_route3(), add_routes(), and do_ifconfig_ipv4().
|
static |
Definition at line 923 of file route.c.
References add_route(), CLEAR, es, route_ipv4::flags, route_ipv4::gateway, route_ipv4::netmask, route_ipv4::network, and RT_DEFINED.
Referenced by add_bypass_routes(), redirect_default_route_to_vpn(), and undo_redirect_default_route_to_vpn().
|
static |
Definition at line 2837 of file route.c.
References CLEAR, D_ROUTE, route_ipv4::flags, route_ipv4::gateway, gc_free(), gc_new(), M_WARN, route_ipv4::metric, METRIC_NOT_USED, msg, route_ipv4::netmask, route_ipv4::network, print_in_addr_t(), RT_METRIC_DEFINED, RTA_EEXIST, RTA_ERROR, RTA_SUCCESS, status, strerror_win32(), TUN_ADAPTER_INDEX_INVALID, and windows_route_find_if_index().
Referenced by add_route().
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 | ||
) |
Definition at line 1899 of file route.c.
References tuntap::actual_name, route_ipv6::adapter_index, tuntap::adapter_index, add_route_ipv6_service(), argv_free(), argv_msg(), argv_new(), argv_printf(), argv_printf_cat(), D_ROUTE, DEV_TYPE_TAP, DEV_TYPE_TUN, es, route_ipv6::flags, route_ipv6::gateway, gc_free(), gc_malloc(), gc_new(), M_FATAL, M_WARN, route_ipv6::metric, msg, tuntap_options::msg_channel, net_ctx_reset(), route_ipv6::netbits, route_ipv6::network, openvpn_execve_check(), tuntap::options, PACKAGE_NAME, print_in6_addr(), route_ipv6_clear_host_bits(), route_ipv6_ipapi(), ROUTE_PATH, RT_ADDED, RT_DEFINED, RT_METRIC_DEFINED, RTA_EEXIST, RTA_ERROR, RTA_SUCCESS, status, and tuntap::type.
Referenced by add_route_connected_v6_net(), and add_routes().
|
static |
Definition at line 3172 of file route.c.
References do_route_ipv6_service().
Referenced by add_route_ipv6().
void add_route_ipv6_to_option_list | ( | struct route_ipv6_option_list * | l, |
const char * | prefix, | ||
const char * | gateway, | ||
const char * | metric | ||
) |
Definition at line 528 of file route.c.
References ALLOC_OBJ_GC, route_ipv6_option::gateway, route_ipv6_option_list::gc, route_ipv6_option::metric, route_ipv6_option::next, route_ipv6_option::prefix, and route_ipv6_option_list::routes_ipv6.
Referenced by add_option(), and do_init_route_ipv6_list().
|
static |
Definition at line 3159 of file route.c.
References do_route_ipv4_service().
Referenced by add_route().
void add_route_to_option_list | ( | struct route_option_list * | l, |
const char * | network, | ||
const char * | netmask, | ||
const char * | gateway, | ||
const char * | metric | ||
) |
Definition at line 510 of file route.c.
References ALLOC_OBJ_GC, route_option::gateway, route_option_list::gc, route_option::metric, route_option::netmask, route_option::network, route_option::next, and route_option_list::routes.
Referenced by add_option(), and helper_add_route().
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 | ||
) |
Definition at line 1186 of file route.c.
References tuntap::actual_name, add_route(), add_route_ipv6(), check_subnet_conflict(), delete_route(), delete_route_ipv6(), tuntap::did_ifconfig_ipv6_setup, tuntap::did_ifconfig_setup, es, route_ipv4::flags, route_ipv6::flags, route_list::iflags, route_ipv6_list::iflags, M_INFO, management_set_state(), msg, route_ipv4::netmask, route_ipv4::network, route_ipv4::next, route_ipv6::next, OPENVPN_STATE_ADD_ROUTES, redirect_default_route_to_vpn(), route_list::rgi, RL_ROUTES_ADDED, ROUTE_DELETE_FIRST, route_list::routes, and route_ipv6_list::routes_ipv6.
Referenced by do_route().
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.
rl | const pointer to the struct route_list to base the decision on. |
Definition at line 621 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().
|
static |
Definition at line 550 of file route.c.
References CLEAR, route_ipv6_list::gc, and gc_free().
Referenced by delete_routes(), and init_route_ipv6_list().
|
static |
Definition at line 543 of file route.c.
References CLEAR, route_list::gc, and gc_free().
Referenced by delete_routes(), and init_route_list().
struct route_ipv6_option_list* clone_route_ipv6_option_list | ( | const struct route_ipv6_option_list * | src, |
struct gc_arena * | a | ||
) |
struct route_option_list* clone_route_option_list | ( | 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 | ||
) |
Definition at line 180 of file route.c.
References route_ipv6_option_list::gc.
Referenced by pre_connect_restore().
void copy_route_option_list | ( | struct route_option_list * | dest, |
const struct route_option_list * | src, | ||
struct gc_arena * | a | ||
) |
Definition at line 173 of file route.c.
References route_option_list::gc.
Referenced by pre_connect_restore().
|
static |
Definition at line 982 of file route.c.
References route_bypass::bypass, del_route3(), es, route_ipv4::flags, route_ipv4::gateway, IPV4_NETMASK_HOST, route_bypass::n_bypass, and ROUTE_REF_GW.
Referenced by undo_redirect_default_route_to_vpn().
|
static |
Definition at line 942 of file route.c.
References CLEAR, delete_route(), es, route_ipv4::flags, route_ipv4::gateway, route_ipv4::netmask, route_ipv4::network, RT_ADDED, and RT_DEFINED.
Referenced by del_bypass_routes(), redirect_default_route_to_vpn(), and undo_redirect_default_route_to_vpn().
|
static |
Definition at line 2929 of file route.c.
References CLEAR, route_ipv4::gateway, gc_free(), gc_new(), M_WARN, msg, route_ipv4::netmask, route_ipv4::network, status, strerror_win32(), TUN_ADAPTER_INDEX_INVALID, and windows_route_find_if_index().
Referenced by delete_route().
|
static |
Definition at line 3178 of file route.c.
References do_route_ipv6_service().
Referenced by delete_route_ipv6().
|
static |
Definition at line 3165 of file route.c.
References do_route_ipv4_service().
Referenced by delete_route().
|
static |
Definition at line 2148 of file route.c.
References argv_free(), argv_msg(), argv_new(), argv_printf(), ASSERT, D_ROUTE, D_ROUTE_DEBUG, del_route_ipapi(), del_route_service(), es, route_ipv4::flags, route_ipv4::gateway, argv::gc, gc_free(), gc_new(), get_win_sys_path(), is_on_link(), local_route(), LR_ERROR, M_FATAL, M_WARN, route_ipv4::metric, msg, net_ctx_reset(), netcmd_semaphore_lock(), netcmd_semaphore_release(), route_ipv4::netmask, netmask_to_netbits2(), route_ipv4::network, openvpn_execve_check(), print_in_addr_t(), ROUTE_METHOD_ADAPTIVE, ROUTE_METHOD_EXE, ROUTE_METHOD_IPAPI, ROUTE_METHOD_MASK, ROUTE_METHOD_SERVICE, ROUTE_PATH, RT_ADDED, RT_DEFINED, RT_METRIC_DEFINED, status, and WIN_ROUTE_PATH_SUFFIX.
Referenced by add_routes(), del_route3(), and delete_routes().
void delete_route_ipv6 | ( | const struct route_ipv6 * | r6, |
const struct tuntap * | tt, | ||
unsigned int | flags, | ||
const struct env_set * | es, | ||
openvpn_net_ctx_t * | ctx | ||
) |
Definition at line 2342 of file route.c.
References tuntap::actual_name, argv_free(), argv_msg(), argv_new(), argv_printf(), argv_printf_cat(), D_ROUTE, D_ROUTE_DEBUG, del_route_ipv6_service(), DEV_TYPE_TAP, es, route_ipv6::flags, route_ipv6::gateway, argv::gc, gc_free(), gc_malloc(), gc_new(), M_FATAL, M_WARN, route_ipv6::metric, msg, tuntap_options::msg_channel, net_ctx_reset(), route_ipv6::netbits, route_ipv6::network, openvpn_execve_check(), tuntap::options, print_in6_addr(), route_ipv6_ipapi(), ROUTE_PATH, RT_ADDED, RT_DEFINED, RT_METRIC_DEFINED, and tuntap::type.
Referenced by add_routes(), delete_route_connected_v6_net(), and 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 1254 of file route.c.
References clear_route_ipv6_list(), clear_route_list(), delete_route(), delete_route_ipv6(), es, route_ipv4::flags, route_ipv6::flags, route_list::iflags, route_ipv6_list::iflags, route_ipv4::next, route_ipv6::next, route_list::rgi, RL_ROUTES_ADDED, route_list::routes, route_ipv6_list::routes_ipv6, and undo_redirect_default_route_to_vpn().
Referenced by do_close_tun().
|
static |
Definition at line 2998 of file route.c.
References do_route_service(), route_ipv4::flags, route_ipv4::gateway, route_ipv4::metric, msg, msg_add_route, tuntap_options::msg_channel, msg_del_route, route_ipv4::netmask, netmask_to_netbits(), route_ipv4::network, tuntap::options, RT_METRIC_DEFINED, RTA_ERROR, and windows_route_find_if_index().
Referenced by add_route_service(), and del_route_service().
|
static |
Definition at line 3109 of file route.c.
References tuntap::actual_name, route_ipv6::adapter_index, tuntap::adapter_index, D_ROUTE, DEV_TYPE_TUN, do_route_service(), route_ipv6::flags, route_ipv6::gateway, route_ipv6::metric, msg, msg_add_route, tuntap_options::msg_channel, msg_del_route, route_ipv6::netbits, route_ipv6::network, tuntap::options, RT_METRIC_DEFINED, RTA_ERROR, RTA_SUCCESS, status, TUN_ADAPTER_INDEX_INVALID, and tuntap::type.
Referenced by add_route_ipv6_service(), and del_route_ipv6_service().
|
static |
Definition at line 2966 of file route.c.
References ack_message_t::error_number, gc_free(), gc_new(), route_message_t::iface, interface_t::index, M_WARN, msg, RTA_EEXIST, RTA_ERROR, RTA_SUCCESS, send_msg_iservice(), and strerror_win32().
Referenced by do_route_ipv4_service(), and do_route_ipv6_service().
|
static |
Definition at line 3184 of file route.c.
References alloc_buf_gc(), BSTR, buf_printf(), IA_NET_ORDER, and print_in_addr_t().
Referenced by show_routes().
|
static |
Definition at line 4009 of file route.c.
References add_host_route_array(), gc_free(), gc_new(), get_adapter_info(), get_default_gateway_row(), get_per_adapter_info(), get_windows_routing_table(), RG_BYPASS_DHCP, and RG_BYPASS_DNS.
Referenced by init_route_list().
void get_default_gateway | ( | struct route_gateway_info * | rgi, |
openvpn_net_ctx_t * | ctx | ||
) |
Definition at line 2680 of file route.c.
References route_gateway_info::adapter_index, adapter_index_of_ip(), route_gateway_address::addr, CLEAR, route_gateway_info::flags, route_gateway_info::gateway, gc_free(), gc_new(), get_adapter(), get_adapter_info_list(), get_default_gateway_row(), get_windows_routing_table(), route_gateway_info::hwaddr, route_gateway_address::netmask, RGI_ADDR_DEFINED, RGI_HWADDR_DEFINED, RGI_IFACE_DEFINED, RGI_NETMASK_DEFINED, and TUN_ADAPTER_INDEX_INVALID.
Referenced by add_option(), check_subnet_conflict(), init_route_list(), push_peer_info(), and warn_on_use_of_common_subnets().
void get_default_gateway_ipv6 | ( | struct route_ipv6_gateway_info * | rgi6, |
const struct in6_addr * | dest, | ||
openvpn_net_ctx_t * | ctx | ||
) |
Definition at line 2766 of file route.c.
References route_ipv6_gateway_info::adapter_index, route_ipv6_gateway_address::addr_ipv6, CLEAR, D_ROUTE, route_ipv6_gateway_info::flags, route_ipv6_gateway_info::gateway, gc_free(), gc_new(), InterfaceLuid(), msg, print_in6_addr(), RGI_ADDR_DEFINED, RGI_IFACE_DEFINED, RGI_ON_LINK, status, and strerror_win32().
Referenced by add_option(), and init_route_ipv6_list().
|
static |
Definition at line 2640 of file route.c.
References D_ROUTE_DEBUG, dmsg, gc_free(), gc_new(), and print_in_addr_t().
Referenced by get_bypass_addresses(), and get_default_gateway().
|
static |
Definition at line 236 of file route.c.
References route_gateway_address::addr, route_special_addr::flags, route_gateway_info::flags, route_gateway_info::gateway, M_INFO, msg, PACKAGE_NAME, route_special_addr::remote_endpoint, route_special_addr::remote_host, route_list::rgi, RGI_ADDR_DEFINED, RTSA_REMOTE_ENDPOINT, RTSA_REMOTE_HOST, route_list::spec, and status.
Referenced by init_route(), and is_special_addr().
|
static |
Definition at line 2526 of file route.c.
References D_ROUTE, argv::gc, gc_malloc(), msg, status, and strerror_win32().
Referenced by get_bypass_addresses(), get_default_gateway(), show_routes(), and test_local_addr().
|
static |
Definition at line 319 of file route.c.
References CLEAR, route_special_addr::default_metric, route_special_addr::flags, route_ipv4::flags, route_option::gateway, route_ipv4::gateway, get_special_addr(), getaddr(), GETADDR_HOST_ORDER, GETADDR_RESOLVE, GETADDR_WARN_ON_SIGNAL, IPV4_NETMASK_HOST, is_route_parm_defined(), M_WARN, route_option::metric, route_ipv4::metric, msg, route_option::netmask, route_ipv4::netmask, route_option::network, openvpn_getaddrinfo(), route_ipv4::option, PACKAGE_NAME, route_special_addr::remote_endpoint, RT_DEFINED, RT_METRIC_DEFINED, RTSA_DEFAULT_METRIC, RTSA_REMOTE_ENDPOINT, route_list::spec, and status.
Referenced by init_route_list().
|
static |
Definition at line 454 of file route.c.
References CLEAR, route_ipv6_list::default_metric, route_ipv6::flags, route_ipv6_option::gateway, route_ipv6::gateway, get_ipv6_addr(), is_route_parm_defined(), M_WARN, route_ipv6_option::metric, route_ipv6::metric, msg, route_ipv6::netbits, route_ipv6::network, PACKAGE_NAME, route_ipv6_option::prefix, route_ipv6_list::remote_endpoint_ipv6, RT_DEFINED, RT_METRIC_DEFINED, RTSA_DEFAULT_METRIC, RTSA_REMOTE_ENDPOINT, and route_ipv6_list::spec_flags.
Referenced by 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 | ||
) |
Definition at line 790 of file route.c.
References route_ipv6::adapter_index, route_ipv6_gateway_info::adapter_index, route_ipv6_gateway_address::addr_ipv6, ALLOC_OBJ_CLEAR_GC, ALLOC_OBJ_GC, clear_route_ipv6_list(), D_ROUTE, route_ipv6_list::default_metric, dmsg, es, route_ipv6_option_list::flags, route_ipv6::flags, route_ipv6_gateway_info::flags, route_ipv6_list::flags, route_ipv6::gateway, route_ipv6_gateway_info::gateway, route_ipv6_list::gc, gc_free(), gc_new(), get_default_gateway_ipv6(), init_route_ipv6(), is_route_parm_defined(), M_WARN, route_ipv6::metric, msg, route_ipv6::netbits, route_ipv6::network, route_ipv6_option::next, route_ipv6::next, PACKAGE_NAME, print_default_gateway(), print_in6_addr(), route_ipv6_list::remote_endpoint_ipv6, route_ipv6_list::remote_host_ipv6, route_ipv6_list::rgi6, RGI_ADDR_DEFINED, RGI_IFACE_DEFINED, RGI_ON_LINK, route_ipv6_match_host(), route_ipv6_option_list::routes_ipv6, route_ipv6_list::routes_ipv6, RT_DEFINED, RT_METRIC_DEFINED, RTSA_DEFAULT_METRIC, RTSA_REMOTE_ENDPOINT, RTSA_REMOTE_HOST, setenv_str(), and route_ipv6_list::spec_flags.
Referenced by do_init_route_ipv6_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 | ||
) |
Definition at line 631 of file route.c.
References add_block_local_routes(), route_gateway_address::addr, ALLOC_OBJ_GC, block_local_needed(), route_special_addr::bypass, clear_route_list(), D_ROUTE, route_special_addr::default_metric, dmsg, es, route_special_addr::flags, route_option_list::flags, route_gateway_info::flags, route_list::flags, route_gateway_info::gateway, route_list::gc, gc_addspecial(), gc_free(), gc_freeaddrinfo_callback(), gc_new(), get_bypass_addresses(), get_default_gateway(), getaddr(), GETADDR_HOST_ORDER, GETADDR_RESOLVE, GETADDR_WARN_ON_SIGNAL, init_route(), IPV4_INVALID_ADDR, is_route_parm_defined(), M_WARN, msg, route_ipv4::network, route_option::next, PACKAGE_NAME, print_default_gateway(), route_special_addr::remote_endpoint, route_special_addr::remote_host, route_special_addr::remote_host_local, RG_ENABLE, route_list::rgi, RGI_ADDR_DEFINED, route_option_list::routes, route_list::routes, RTSA_DEFAULT_METRIC, RTSA_REMOTE_ENDPOINT, RTSA_REMOTE_HOST, setenv_route_addr(), route_list::spec, and test_local_addr().
Referenced by do_init_route_list().
|
inlinestatic |
Definition at line 1558 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().
|
static |
Definition at line 205 of file route.c.
Referenced by init_route(), init_route_ipv6(), init_route_ipv6_list(), and init_route_list().
bool is_special_addr | ( | const char * | addr_str | ) |
|
static |
Definition at line 1521 of file route.c.
References route_gateway_address::addr, route_gateway_info::addrs, route_gateway_info::flags, route_ipv6::gateway, route_gateway_info::gateway, LR_MATCH, LR_NOMATCH, route_gateway_info::n_addrs, route_gateway_address::netmask, route_ipv6::network, RGI_ADDR_DEFINED, RGI_IFACE_DEFINED, and RGI_NETMASK_DEFINED.
Referenced by add_route(), and delete_route().
bool netmask_to_netbits | ( | const in_addr_t | network, |
const in_addr_t | netmask, | ||
int * | netbits | ||
) |
Definition at line 3928 of file route.c.
References netbits_to_netmask().
Referenced by do_route_ipv4_service(), and helper_client_server().
int netmask_to_netbits2 | ( | in_addr_t | netmask | ) |
Definition at line 3959 of file route.c.
References netbits_to_netmask().
Referenced by add_route(), delete_route(), do_address_service(), do_ifconfig_ipv4(), option_iroute(), and undo_ifconfig_ipv4().
struct route_ipv6_option_list* new_route_ipv6_option_list | ( | struct gc_arena * | a | ) |
Definition at line 139 of file route.c.
References ALLOC_OBJ_CLEAR_GC, and route_ipv6_option_list::gc.
Referenced by rol6_check_alloc().
struct route_option_list* new_route_option_list | ( | struct gc_arena * | a | ) |
Definition at line 130 of file route.c.
References ALLOC_OBJ_CLEAR_GC, and route_option_list::gc.
Referenced by rol_check_alloc().
void print_default_gateway | ( | const int | msglevel, |
const struct route_gateway_info * | rgi, | ||
const struct route_ipv6_gateway_info * | rgi6 | ||
) |
Definition at line 1333 of file route.c.
References route_gateway_info::adapter_index, route_ipv6_gateway_info::adapter_index, route_gateway_address::addr, route_ipv6_gateway_address::addr_ipv6, alloc_buf_gc(), BSTR, buf_printf(), route_gateway_info::flags, route_ipv6_gateway_info::flags, format_hex_ex(), route_gateway_info::gateway, route_ipv6_gateway_info::gateway, gc_free(), gc_new(), route_gateway_info::hwaddr, route_ipv6_gateway_info::hwaddr, msg, route_ipv6_gateway_address::netbits_ipv6, route_gateway_address::netmask, print_in6_addr(), print_in_addr_t(), RGI_ADDR_DEFINED, RGI_HWADDR_DEFINED, RGI_IFACE_DEFINED, RGI_NETMASK_DEFINED, and RGI_ON_LINK.
Referenced by add_option(), init_route_ipv6_list(), and init_route_list().
|
static |
Definition at line 1408 of file route.c.
References route_ipv4::flags, gc_free(), gc_new(), msg, route_string(), and RT_DEFINED.
Referenced by print_routes().
|
static |
Definition at line 1307 of file route.c.
References route_option::gateway, route_option::metric, msg, route_option::netmask, route_option::network, and show_opt().
Referenced by print_route_options().
void print_route_options | ( | const struct route_option_list * | rol, |
int | level | ||
) |
Definition at line 1317 of file route.c.
References route_option_list::flags, msg, route_option::next, print_route_option(), RG_ENABLE, RG_LOCAL, and route_option_list::routes.
Referenced by show_settings().
void print_routes | ( | const struct route_list * | rl, |
int | level | ||
) |
Definition at line 1419 of file route.c.
References route_ipv4::next, print_route(), and route_list::routes.
|
static |
Definition at line 1008 of file route.c.
References add_bypass_routes(), add_route3(), route_gateway_address::addr, route_special_addr::bypass, D_ROUTE, del_route3(), dmsg, es, route_special_addr::flags, route_ipv4::flags, route_gateway_info::flags, route_list::flags, route_gateway_info::gateway, route_list::iflags, IPV4_INVALID_ADDR, IPV4_NETMASK_HOST, M_WARN, msg, route_special_addr::remote_endpoint, route_special_addr::remote_host, route_special_addr::remote_host_local, RG_AUTO_LOCAL, RG_DEF1, RG_ENABLE, RG_LOCAL, RG_REROUTE_GW, route_list::rgi, RGI_ADDR_DEFINED, RL_DID_LOCAL, RL_DID_REDIRECT_DEFAULT_GATEWAY, ROUTE_REF_GW, RTSA_REMOTE_ENDPOINT, RTSA_REMOTE_HOST, route_list::spec, TLA_LOCAL, and TLA_NONLOCAL.
Referenced by add_routes().
void route_ipv6_clear_host_bits | ( | struct route_ipv6 * | r6 | ) |
Definition at line 1876 of file route.c.
References route_ipv6::netbits, and route_ipv6::network.
Referenced by add_route_ipv6(), and delete_route_connected_v6_net().
|
static |
Definition at line 3032 of file route.c.
References tuntap::actual_name, route_ipv6::adapter_index, tuntap::adapter_index, D_ROUTE, DEV_TYPE_TUN, route_ipv6::flags, route_ipv6::gateway, gc_free(), gc_malloc(), gc_new(), M_WARN, route_ipv6::metric, msg, route_ipv6::netbits, route_ipv6::network, RT_METRIC_DEFINED, RTA_EEXIST, RTA_ERROR, RTA_SUCCESS, strerror_win32(), TUN_ADAPTER_INDEX_INVALID, tuntap::type, and wide_string().
Referenced by add_route_ipv6(), and delete_route_ipv6().
|
static |
Definition at line 754 of file route.c.
References route_ipv6::netbits, and route_ipv6::network.
Referenced by init_route_ipv6_list().
void route_list_add_vpn_gateway | ( | struct route_list * | rl, |
struct env_set * | es, | ||
const in_addr_t | addr | ||
) |
Definition at line 557 of file route.c.
References ASSERT, es, route_special_addr::flags, route_special_addr::remote_endpoint, RTSA_REMOTE_ENDPOINT, setenv_route_addr(), and route_list::spec.
Referenced by process_ip_header().
|
static |
Definition at line 189 of file route.c.
References alloc_buf_gc(), BSTR, buf_printf(), route_ipv4::flags, route_ipv4::gateway, route_ipv4::metric, route_ipv4::netmask, route_ipv4::network, print_in_addr_t(), and RT_METRIC_DEFINED.
Referenced by print_route().
|
static |
Definition at line 1429 of file route.c.
References alloc_buf_gc(), BSTR, buf_printf(), es, route_ipv4::flags, route_ipv4::gateway, gc_free(), gc_new(), route_ipv4::metric, route_ipv4::netmask, route_ipv4::network, RT_DEFINED, RT_METRIC_DEFINED, setenv_int(), and setenv_route_addr().
Referenced by setenv_routes().
|
static |
Definition at line 219 of file route.c.
References alloc_buf_gc(), BSTR, buf_printf(), es, gc_free(), gc_new(), print_in_addr_t(), and setenv_str().
Referenced by init_route_list(), route_list_add_vpn_gateway(), and setenv_route().
|
static |
Definition at line 1460 of file route.c.
References alloc_buf_gc(), BSTR, buf_printf(), es, route_ipv6::flags, route_ipv6::gateway, gc_free(), gc_new(), route_ipv6::metric, route_ipv6::netbits, route_ipv6::network, print_in6_addr(), RT_DEFINED, RT_METRIC_DEFINED, setenv_int(), and setenv_str().
Referenced by setenv_routes_ipv6().
void setenv_routes | ( | struct env_set * | es, |
const struct route_list * | rl | ||
) |
Definition at line 1449 of file route.c.
References es, route_ipv4::next, route_list::routes, and setenv_route().
Referenced by do_init_route_list().
void setenv_routes_ipv6 | ( | struct env_set * | es, |
const struct route_ipv6_list * | rl6 | ||
) |
Definition at line 1487 of file route.c.
References es, route_ipv6::next, route_ipv6_list::routes_ipv6, and setenv_route_ipv6().
Referenced by do_init_route_ipv6_list().
|
static |
Definition at line 1294 of file route.c.
Referenced by print_route_option().
void show_routes | ( | int | msglev | ) |
Definition at line 3209 of file route.c.
References format_route_entry(), gc_free(), gc_new(), get_windows_routing_table(), and msg.
Referenced by add_option(), check_add_routes(), do_route(), initialization_sequence_completed(), and management_show_net_callback().
int test_local_addr | ( | const in_addr_t | addr, |
const struct route_gateway_info * | rgi | ||
) |
Definition at line 4065 of file route.c.
References gc_free(), gc_new(), get_windows_routing_table(), TLA_LOCAL, and TLA_NONLOCAL.
Referenced by add_host_route_if_nonlocal(), and init_route_list().
|
static |
Definition at line 2549 of file route.c.
References adapter_index_of_ip().
Referenced by test_route_helper(), and windows_route_find_if_index().
|
static |
bool test_routes | ( | const struct route_list * | rl, |
const struct tuntap * | tt | ||
) |
Definition at line 2592 of file route.c.
References D_ROUTE, tuntap::did_ifconfig_setup, route_special_addr::flags, route_list::flags, route_ipv4::gateway, gc_free(), gc_new(), get_adapter_info_list(), is_adapter_up(), msg, route_ipv4::next, route_special_addr::remote_endpoint, RG_ENABLE, route_list::routes, RTSA_REMOTE_ENDPOINT, route_list::spec, and test_route_helper().
Referenced by check_add_routes().
|
static |
Definition at line 1112 of file route.c.
References add_route3(), route_gateway_address::addr, route_special_addr::bypass, del_bypass_routes(), del_route3(), es, route_ipv4::flags, route_gateway_info::flags, route_list::flags, route_gateway_info::gateway, route_list::iflags, IPV4_NETMASK_HOST, route_special_addr::remote_endpoint, route_special_addr::remote_host, RG_DEF1, RG_REROUTE_GW, route_list::rgi, RGI_ADDR_DEFINED, RL_DID_LOCAL, RL_DID_REDIRECT_DEFAULT_GATEWAY, ROUTE_REF_GW, and route_list::spec.
Referenced by delete_routes().
|
static |
Definition at line 2717 of file route.c.
References D_ROUTE_DEBUG, dmsg, route_ipv4::gateway, gc_free(), gc_new(), get_adapter_info_list(), get_tun_adapter(), is_ip_in_adapter_subnet(), M_WARN, msg, print_in_addr_t(), test_route(), and TUN_ADAPTER_INDEX_INVALID.
Referenced by add_route_ipapi(), del_route_ipapi(), and do_route_ipv4_service().