Statistics
| Branch: | Revision:

iof-bird / bird-2.0.1 / proto / radv / radv.h @ 6b3f1a54

History | View | Annotate | Download (6.55 KB)

1
/*
2
 *        BIRD -- Router Advertisement
3
 *
4
 *
5
 *        Can be freely distributed and used under the terms of the GNU GPL.
6
 */
7

    
8
#ifndef _BIRD_RADV_H_
9
#define _BIRD_RADV_H_
10

    
11
#include "nest/bird.h"
12

    
13
#include "lib/ip.h"
14
#include "lib/lists.h"
15
#include "lib/socket.h"
16
#include "lib/timer.h"
17
#include "lib/resource.h"
18
#include "nest/protocol.h"
19
#include "nest/iface.h"
20
#include "nest/route.h"
21
#include "nest/cli.h"
22
#include "nest/locks.h"
23
#include "conf/conf.h"
24
#include "lib/string.h"
25

    
26

    
27
#define ICMPV6_PROTO 58
28

    
29
#define ICMPV6_RS 133
30
#define ICMPV6_RA 134
31

    
32
#define MAX_INITIAL_RTR_ADVERTISEMENTS 3
33
#define MAX_INITIAL_RTR_ADVERT_INTERVAL (16 S_)
34

    
35
#define DEFAULT_MAX_RA_INT 600
36
#define DEFAULT_MIN_DELAY 3
37
#define DEFAULT_CURRENT_HOP_LIMIT 64
38

    
39
#define DEFAULT_VALID_LIFETIME 86400
40
#define DEFAULT_PREFERRED_LIFETIME 14400
41

    
42
#define DEFAULT_DNS_LIFETIME_MULT 3
43

    
44

    
45
struct radv_config
46
{
47
  struct proto_config c;
48
  list patt_list;                /* List of iface configs (struct radv_iface_config) */
49
  list pref_list;                /* Global list of prefix configs (struct radv_prefix_config) */
50
  list rdnss_list;                /* Global list of RDNSS configs (struct radv_rdnss_config) */
51
  list dnssl_list;                /* Global list of DNSSL configs (struct radv_dnssl_config) */
52

    
53
  net_addr trigger;                /* Prefix of a trigger route, if defined */
54
  u8 propagate_routes;                /* Do we propagate more specific routes (RFC 4191)? */
55
  u32 max_linger_time;                /* Maximum of interface route_linger_time */
56
};
57

    
58
struct radv_iface_config
59
{
60
  struct iface_patt i;
61
  list pref_list;                /* Local list of prefix configs (struct radv_prefix_config) */
62
  list rdnss_list;                /* Local list of RDNSS configs (struct radv_rdnss_config) */
63
  list dnssl_list;                /* Local list of DNSSL configs (struct radv_dnssl_config) */
64

    
65
  u32 min_ra_int;                /* Standard options from RFC 4861 */
66
  u32 max_ra_int;
67
  u32 min_delay;
68

    
69
  u32 prefix_linger_time;        /* How long we advertise dead prefixes with lifetime 0 */
70
  u32 route_linger_time;        /* How long we advertise dead routes with lifetime 0 */
71

    
72
  u8 rdnss_local;                /* Global list is not used for RDNSS */
73
  u8 dnssl_local;                /* Global list is not used for DNSSL */
74

    
75
  u8 managed;                        /* Standard options from RFC 4861 */
76
  u8 other_config;
77
  u32 link_mtu;
78
  u32 reachable_time;
79
  u32 retrans_timer;
80
  u32 current_hop_limit;
81
  u32 default_lifetime;
82
  u32 route_lifetime;                /* Lifetime for the RFC 4191 routes */
83
  u8 default_lifetime_sensitive; /* Whether default_lifetime depends on trigger */
84
  u8 route_lifetime_sensitive;        /* Whether route_lifetime depends on trigger */
85
  u8 default_preference;        /* Default Router Preference (RFC 4191) */
86
  u8 route_preference;                /* Specific Route Preference (RFC 4191) */
87
};
88

    
89
struct radv_prefix_config
90
{
91
  node n;
92
  net_addr_ip6 prefix;
93

    
94
  u8 skip;                        /* Do not include this prefix to RA */
95
  u8 onlink;                        /* Standard options from RFC 4861 */
96
  u8 autonomous;
97
  u32 valid_lifetime;
98
  u32 preferred_lifetime;
99
  u8 valid_lifetime_sensitive;         /* Whether valid_lifetime depends on trigger */
100
  u8 preferred_lifetime_sensitive; /* Whether preferred_lifetime depends on trigger */
101
};
102

    
103
struct radv_rdnss_config
104
{
105
  node n;
106
  u32 lifetime;                        /* Valid if lifetime_mult is 0 */
107
  u16 lifetime_mult;                /* Lifetime specified as multiple of max_ra_int */
108
  ip6_addr server;                /* IP address of recursive DNS server */
109
};
110

    
111
struct radv_dnssl_config
112
{
113
  node n;
114
  u32 lifetime;                        /* Valid if lifetime_mult is 0 */
115
  u16 lifetime_mult;                /* Lifetime specified as multiple of max_ra_int */
116
  u8 dlen_first;                /* Length of first label in domain */
117
  u8 dlen_all;                        /* Both dlen_ filled in radv_process_domain() */
118
  char *domain;                        /* Domain for DNS search list, in processed form */
119
};
120

    
121
/*
122
 * One more specific route as per RFC 4191.
123
 *
124
 * Note that it does *not* contain the next hop field. The next hop is always
125
 * the router sending the advertisment and the more specific route only allows
126
 * overriding the preference of the route.
127
 */
128
struct radv_route
129
{
130
  u32 lifetime;                        /* Lifetime from an attribute */
131
  u8 lifetime_set;                /* Whether lifetime is defined */
132
  u8 preference;                /* Preference of the route, RA_PREF_* */
133
  u8 preference_set;                /* Whether preference is defined */
134
  u8 valid;                        /* Whethe route is valid or withdrawn */
135
  btime changed;                /* Last time when the route changed */
136

    
137
  struct fib_node n;
138
};
139

    
140
struct radv_proto
141
{
142
  struct proto p;
143
  list iface_list;                /* List of active ifaces */
144
  u8 valid;                        /* Router is valid for forwarding, used for shutdown */
145
  u8 active;                        /* Whether radv is active w.r.t. triggers */
146
  u8 fib_up;                        /* FIB table (routes) is initialized */
147
  struct fib routes;                /* FIB table of specific routes (struct radv_route) */
148
  btime prune_time;                /* Next time of route table pruning */
149
};
150

    
151
struct radv_prefix                /* One prefix we advertise */
152
{
153
  node n;
154
  net_addr_ip6 prefix;
155

    
156
  u8 valid;                        /* Is the prefix valid? If not, we advertise it
157
                                   with 0 lifetime, so clients stop using it */
158
  u8 mark;                        /* A temporary mark for processing */
159
  btime changed;                /* Last time when the prefix changed */
160
  struct radv_prefix_config *cf; /* The config tied to this prefix */
161
};
162

    
163
struct radv_iface
164
{
165
  node n;
166
  struct radv_proto *ra;
167
  struct radv_iface_config *cf;        /* Related config, must be updated in reconfigure */
168
  struct iface *iface;
169
  struct ifa *addr;                /* Link-local address of iface */
170
  struct pool *pool;                /* A pool for interface-specific things */
171
  list prefixes;                /* The prefixes we advertise (struct radv_prefix) */
172
  btime prune_time;                /* Next time of prefix list pruning */
173
  btime valid_time;                /* Cached packet is valid until first linger timeout */
174

    
175
  timer *timer;
176
  struct object_lock *lock;
177
  sock *sk;
178

    
179
  btime last;                        /* Time of last sending of RA */
180
  u16 plen;                        /* Length of prepared RA in tbuf, or 0 if not valid */
181
  byte initial;                        /* How many RAs are still to be sent as initial */
182
};
183

    
184
#define RA_EV_INIT 1                /* Switch to initial mode */
185
#define RA_EV_CHANGE 2                /* Change of options or prefixes */
186
#define RA_EV_RS 3                /* Received RS */
187

    
188
/* Default Router Preferences (RFC 4191) */
189
#define RA_PREF_LOW        0x18
190
#define RA_PREF_MEDIUM        0x00
191
#define RA_PREF_HIGH        0x08
192
#define RA_PREF_MASK        0x18
193

    
194
/* Attributes */
195
#define EA_RA_PREFERENCE        EA_CODE(EAP_RADV, 0)
196
#define EA_RA_LIFETIME                EA_CODE(EAP_RADV, 1)
197

    
198
#ifdef LOCAL_DEBUG
199
#define RADV_FORCE_DEBUG 1
200
#else
201
#define RADV_FORCE_DEBUG 0
202
#endif
203
#define RADV_TRACE(flags, msg, args...) do { if ((p->p.debug & flags) || RADV_FORCE_DEBUG) \
204
        log(L_TRACE "%s: " msg, p->p.name , ## args ); } while(0)
205

    
206

    
207
/* radv.c */
208
void radv_iface_notify(struct radv_iface *ifa, int event);
209

    
210
/* packets.c */
211
int radv_process_domain(struct radv_dnssl_config *cf);
212
void radv_send_ra(struct radv_iface *ifa);
213
int radv_sk_open(struct radv_iface *ifa);
214

    
215

    
216

    
217
#endif /* _BIRD_RADV_H_ */