2
* OpenVPN -- An application to securely tunnel IP networks
3
* over a single TCP/UDP port, with support for SSL/TLS-based
4
* session authentication and key exchange,
5
* packet encryption, packet authentication, and
8
* Copyright (C) 2002-2004 James Yonan <jim@yonan.net>
10
* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this program (see the file COPYING included with this
22
* distribution); if not, write to the Free Software Foundation, Inc.,
23
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
* Support routines for adding/deleting network routes.
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 */
88
struct route_special_addr
90
in_addr_t remote_endpoint;
91
bool remote_endpoint_defined;
92
in_addr_t net_gateway;
93
bool net_gateway_defined;
94
in_addr_t remote_host;
95
bool remote_host_defined;
105
struct route_option_list {
107
bool redirect_default_gateway;
108
struct route_option routes[MAX_ROUTES];
113
const struct route_option *option;
123
struct route_special_addr spec;
124
bool redirect_default_gateway;
125
bool did_redirect_default_gateway;
128
struct route routes[MAX_ROUTES];
131
void add_route_to_option_list (struct route_option_list *l,
137
void clear_route_list (struct route_list *rl);
139
bool init_route_list (struct route_list *rl,
140
const struct route_option_list *opt,
141
const char *remote_endpoint,
142
in_addr_t remote_host);
144
void add_routes (struct route_list *rl,
147
void delete_routes (struct route_list *rl);
148
void setenv_routes (const struct route_list *rl);
150
void print_route_options (const struct route_option_list *rol,
153
void print_routes (const struct route_list *rl, int level);