~ubuntu-branches/ubuntu/hardy/openvpn/hardy-security

« back to all changes in this revision

Viewing changes to route.h

  • Committer: Bazaar Package Importer
  • Author(s): Alberto Gonzalez Iniesta
  • Date: 2005-01-05 19:03:11 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050105190311-mvqzpuhmlvobg9nh
Tags: 1.99+2.rc6-1
* The 'Three Wise Men' release.
* New upstream release.
* Update README.Debian with comments on changed string remapping.
  Thanks ron@debian.org for noting this first. (Closes: #288669)

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#ifndef ROUTE_H
31
31
#define ROUTE_H
32
32
 
33
 
#define MAX_ROUTES 50
34
 
 
35
 
#if defined(TARGET_FREEBSD)
36
 
 
37
 
/* all of this is taken from <net/route.h> in FreeBSD */
38
 
#define RTA_DST     0x1
39
 
#define RTA_GATEWAY 0x2
40
 
#define RTA_NETMASK 0x4
41
 
 
42
 
#define RTM_GET     0x4
43
 
#define RTM_VERSION 5
44
 
 
45
 
#define RTF_UP      0x1
46
 
#define RTF_GATEWAY 0x2
47
 
 
48
 
/*
49
 
 * These numbers are used by reliable protocols for determining
50
 
 * retransmission behavior and are included in the routing structure.
51
 
 */
52
 
struct rt_metrics {
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 */
64
 
};
65
 
 
66
 
 
67
 
/*
68
 
 * Structures for routing messages.
69
 
 */
70
 
struct rt_msghdr {
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 */
83
 
};
84
 
 
 
33
#include "tun.h"
 
34
#include "misc.h"
 
35
 
 
36
#define MAX_ROUTES 100
 
37
 
 
38
#ifdef WIN32
 
39
/*
 
40
 * Windows route methods
 
41
 */
 
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
85
45
#endif
86
46
 
 
47
/*
 
48
 * Route add flags (must stay clear of ROUTE_METHOD bits)
 
49
 */
 
50
#define ROUTE_DELETE_FIRST  2
87
51
 
88
52
struct route_special_addr
89
53
{
105
69
struct route_option_list {
106
70
  int n;
107
71
  bool redirect_default_gateway;
 
72
  bool redirect_local;
 
73
  bool redirect_def1;
108
74
  struct route_option routes[MAX_ROUTES];
109
75
};
110
76
 
122
88
  bool routes_added;
123
89
  struct route_special_addr spec;
124
90
  bool redirect_default_gateway;
 
91
  bool redirect_local;
 
92
  bool redirect_def1;
125
93
  bool did_redirect_default_gateway;
126
94
 
127
95
  int n;
128
96
  struct route routes[MAX_ROUTES];
129
97
};
130
98
 
 
99
#if P2MP
 
100
/* internal OpenVPN route */
 
101
struct iroute {
 
102
  in_addr_t network;
 
103
  int netbits;
 
104
  struct iroute *next;
 
105
};
 
106
#endif
 
107
 
 
108
struct route_option_list *new_route_option_list (struct gc_arena *a);
 
109
 
 
110
struct route_list *new_route_list (struct gc_arena *a);
 
111
 
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,
 
124
                      struct env_set *es);
143
125
 
144
126
void add_routes (struct route_list *rl,
145
 
                 bool delete_first);
146
 
 
147
 
void delete_routes (struct route_list *rl);
148
 
void setenv_routes (const struct route_list *rl);
149
 
 
 
127
                 const struct tuntap *tt,
 
128
                 unsigned int flags,
 
129
                 const struct env_set *es);
 
130
 
 
131
void delete_routes (struct route_list *rl,
 
132
                    const struct tuntap *tt,
 
133
                    unsigned int flags,
 
134
                    const struct env_set *es);
 
135
 
 
136
void setenv_routes (struct env_set *es, const struct route_list *rl);
 
137
 
 
138
#ifdef ENABLE_DEBUG
150
139
void print_route_options (const struct route_option_list *rol,
151
140
                          int level);
 
141
#endif
152
142
 
153
143
void print_routes (const struct route_list *rl, int level);
154
144
 
 
145
#ifdef WIN32
 
146
 
 
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);
 
151
 
 
152
#else
 
153
static inline bool test_routes (const struct route_list *rl, const struct tuntap *tt) { return true; }
 
154
#endif
 
155
 
 
156
bool netmask_to_netbits (const in_addr_t network, const in_addr_t netmask, int *netbits);
 
157
 
 
158
static inline in_addr_t
 
159
netbits_to_netmask (const int netbits)
 
160
{
 
161
  const int addrlen = sizeof (in_addr_t) * 8;
 
162
  in_addr_t mask = 0;
 
163
  if (netbits > 0 && netbits <= addrlen)
 
164
    mask = ~0 << (addrlen-netbits);
 
165
  return mask;
 
166
}
155
167
 
156
168
#endif