35
#if defined(TARGET_FREEBSD)
37
/* all of this is taken from <net/route.h> in FreeBSD */
39
#define RTA_GATEWAY 0x2
40
#define RTA_NETMASK 0x4
46
#define RTF_GATEWAY 0x2
49
* These numbers are used by reliable protocols for determining
50
* retransmission behavior and are included in the routing structure.
53
u_long rmx_locks; /* Kernel must leave these values alone */
54
u_long rmx_mtu; /* MTU for this path */
55
u_long rmx_hopcount; /* max hops expected */
56
u_long rmx_expire; /* lifetime for route, e.g. redirect */
57
u_long rmx_recvpipe; /* inbound delay-bandwidth product */
58
u_long rmx_sendpipe; /* outbound delay-bandwidth product */
59
u_long rmx_ssthresh; /* outbound gateway buffer limit */
60
u_long rmx_rtt; /* estimated round trip time */
61
u_long rmx_rttvar; /* estimated rtt variance */
62
u_long rmx_pksent; /* packets sent using this route */
63
u_long rmx_filler[4]; /* will be used for T/TCP later */
68
* Structures for routing messages.
71
u_short rtm_msglen; /* to skip over non-understood messages */
72
u_char rtm_version; /* future binary compatibility */
73
u_char rtm_type; /* message type */
74
u_short rtm_index; /* index for associated ifp */
75
int rtm_flags; /* flags, incl. kern & message, e.g. DONE */
76
int rtm_addrs; /* bitmask identifying sockaddrs in msg */
77
pid_t rtm_pid; /* identify sender */
78
int rtm_seq; /* for sender to identify action */
79
int rtm_errno; /* why failed */
80
int rtm_use; /* from rtentry */
81
u_long rtm_inits; /* which metrics we are initializing */
82
struct rt_metrics rtm_rmx; /* metrics themselves */
36
#define MAX_ROUTES 100
40
* Windows route methods
42
#define ROUTE_METHOD_IPAPI 0 /* use IP helper API */
43
#define ROUTE_METHOD_EXE 1 /* use route.exe */
44
#define ROUTE_METHOD_MASK 1
48
* Route add flags (must stay clear of ROUTE_METHOD bits)
50
#define ROUTE_DELETE_FIRST 2
88
52
struct route_special_addr
122
88
bool routes_added;
123
89
struct route_special_addr spec;
124
90
bool redirect_default_gateway;
125
93
bool did_redirect_default_gateway;
128
96
struct route routes[MAX_ROUTES];
100
/* internal OpenVPN route */
108
struct route_option_list *new_route_option_list (struct gc_arena *a);
110
struct route_list *new_route_list (struct gc_arena *a);
131
112
void add_route_to_option_list (struct route_option_list *l,
132
113
const char *network,
133
114
const char *netmask,
139
120
bool init_route_list (struct route_list *rl,
140
121
const struct route_option_list *opt,
141
122
const char *remote_endpoint,
142
in_addr_t remote_host);
123
in_addr_t remote_host,
144
126
void add_routes (struct route_list *rl,
147
void delete_routes (struct route_list *rl);
148
void setenv_routes (const struct route_list *rl);
127
const struct tuntap *tt,
129
const struct env_set *es);
131
void delete_routes (struct route_list *rl,
132
const struct tuntap *tt,
134
const struct env_set *es);
136
void setenv_routes (struct env_set *es, const struct route_list *rl);
150
139
void print_route_options (const struct route_option_list *rol,
153
143
void print_routes (const struct route_list *rl, int level);
147
void show_routes (int msglev);
148
bool test_routes (const struct route_list *rl, const struct tuntap *tt);
149
bool add_route_ipapi (const struct route *r, const struct tuntap *tt);
150
bool del_route_ipapi (const struct route *r, const struct tuntap *tt);
153
static inline bool test_routes (const struct route_list *rl, const struct tuntap *tt) { return true; }
156
bool netmask_to_netbits (const in_addr_t network, const in_addr_t netmask, int *netbits);
158
static inline in_addr_t
159
netbits_to_netmask (const int netbits)
161
const int addrlen = sizeof (in_addr_t) * 8;
163
if (netbits > 0 && netbits <= addrlen)
164
mask = ~0 << (addrlen-netbits);