39#define ROUTE_METHOD_ADAPTIVE 0
40#define ROUTE_METHOD_IPAPI 1
41#define ROUTE_METHOD_EXE 2
42#define ROUTE_METHOD_SERVICE 3
43#define ROUTE_METHOD_MASK 3
49#define ROUTE_DELETE_FIRST (1 << 2)
50#define ROUTE_REF_GW (1 << 3)
54#define N_ROUTE_BYPASS 8
62#define RTSA_REMOTE_ENDPOINT (1 << 0)
63#define RTSA_REMOTE_HOST (1 << 1)
64#define RTSA_DEFAULT_METRIC (1 << 2)
86#define RG_ENABLE (1u << 0)
87#define RG_LOCAL (1u << 1)
88#define RG_DEF1 (1u << 2)
89#define RG_BYPASS_DHCP (1u << 3)
90#define RG_BYPASS_DNS (1u << 4)
91#define RG_REROUTE_GW (1u << 5)
92#define RG_AUTO_LOCAL (1u << 6)
93#define RG_BLOCK_LOCAL (1u << 7)
120#define RT_DEFINED (1u << 0)
121#define RT_ADDED (1u << 1)
122#define RT_METRIC_DEFINED (1u << 2)
159#define RGI_ADDR_DEFINED (1 << 0)
160#define RGI_NETMASK_DEFINED (1 << 1)
161#define RGI_HWADDR_DEFINED (1 << 2)
162#define RGI_IFACE_DEFINED (1 << 3)
163#define RGI_OVERFLOW (1 << 4)
164#define RGI_ON_LINK (1 << 5)
170#elif defined(TARGET_HAIKU)
171 char iface[PATH_MAX];
183#define RGI_N_ADDRESSES 8
205#if defined(TARGET_HAIKU)
207#define IFNAMSIZ PATH_MAX
212 char iface[IFNAMSIZ];
222#define RGI_N_ADDRESSES 8
230#define RL_DID_REDIRECT_DEFAULT_GATEWAY (1u << 0)
231#define RL_DID_LOCAL (1u << 1)
232#define RL_ROUTES_ADDED (1u << 2)
313 const char *gateway,
const char *metric,
int table_id);
316 const char *gateway,
const char *metric,
int table_id);
319 const char *remote_endpoint,
int default_metric, in_addr_t remote_host,
323 const char *remote_endpoint,
int default_metric,
324 const struct in6_addr *remote_host,
struct env_set *
es,
368#define TLA_NOT_IMPLEMENTED 0
369#define TLA_NONLOCAL 1
394bool netmask_to_netbits(
const in_addr_t network,
const in_addr_t netmask,
int *netbits);
398static inline in_addr_t
401 const int addrlen =
sizeof(in_addr_t) * 8;
403 if (netbits > 0 && netbits <= addrlen)
#define IPV4_NETMASK_HOST
static bool route_list_vpn_gateway_needed(const struct route_list *rl)
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)
bool is_special_addr(const char *addr_str)
struct route_option_list * clone_route_option_list(const struct route_option_list *src, struct gc_arena *a)
void setenv_routes_ipv6(struct env_set *es, const struct route_ipv6_list *rl6)
int netmask_to_netbits2(in_addr_t netmask)
struct route_ipv6_option_list * new_route_ipv6_option_list(struct gc_arena *a)
#define RL_DID_REDIRECT_DEFAULT_GATEWAY
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)
#define RTSA_REMOTE_ENDPOINT
bool test_routes(const struct route_list *rl, const struct tuntap *tt)
static int route_did_redirect_default_gateway(const 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.
static in_addr_t netbits_to_netmask(const int netbits)
void show_routes(int msglev)
void print_route_options(const struct route_option_list *rol, int level)
void route_list_add_vpn_gateway(struct route_list *rl, struct env_set *es, const in_addr_t addr)
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)
void print_default_gateway(const int msglevel, const struct route_gateway_info *rgi, const struct route_ipv6_gateway_info *rgi6)
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)
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)
bool add_route_ipv6(struct route_ipv6 *r, const struct tuntap *tt, unsigned int flags, const struct env_set *es, openvpn_net_ctx_t *ctx)
void get_default_gateway_ipv6(struct route_ipv6_gateway_info *rgi, const struct in6_addr *dest, openvpn_net_ctx_t *ctx)
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.
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 * new_route_option_list(struct gc_arena *a)
int test_local_addr(const in_addr_t addr, const struct route_gateway_info *rgi)
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 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, openvpn_net_ctx_t *ctx)
void route_ipv6_clear_host_bits(struct route_ipv6 *r6)
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 print_routes(const struct route_list *rl, int level)
bool netmask_to_netbits(const in_addr_t network, const in_addr_t netmask, int *netbits)
void setenv_routes(struct env_set *es, const struct route_list *rl)
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 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 delete_route_ipv6(const struct route_ipv6 *r, const struct tuntap *tt, const struct env_set *es, openvpn_net_ctx_t *ctx)
Garbage collection arena used to keep track of dynamically allocated memory.
struct iroute_ipv6 * next
in_addr_t bypass[N_ROUTE_BYPASS]
struct route_gateway_address addrs[RGI_N_ADDRESSES]
struct route_gateway_address gateway
const struct route_option * option
struct in6_addr addr_ipv6
struct route_ipv6_gateway_address gateway
struct route_ipv6_gateway_address addrs[RGI_N_ADDRESSES]
struct route_ipv6_gateway_info rgi6
struct route_ipv6 * routes_ipv6
struct in6_addr remote_host_ipv6
struct in6_addr remote_endpoint_ipv6
struct route_ipv6_option * routes_ipv6
struct route_ipv6_option * next
struct route_gateway_info rgi
struct route_ipv4 * routes
struct route_special_addr spec
struct route_option * routes
struct route_option * next
struct route_bypass bypass
in_addr_t remote_endpoint