iof-bird-daemon / proto / radv / radv.h @ 7152e5ef
History | View | Annotate | Download (4.42 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 "sysdep/unix/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 |
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 |
}; |
55 |
|
56 |
struct radv_iface_config
|
57 |
{ |
58 |
struct iface_patt i;
|
59 |
list pref_list; /* Local list of prefix configs (struct radv_prefix_config) */
|
60 |
list rdnss_list; /* Local list of RDNSS configs (struct radv_rdnss_config) */
|
61 |
list dnssl_list; /* Local list of DNSSL configs (struct radv_dnssl_config) */
|
62 |
|
63 |
u32 min_ra_int; /* Standard options from RFC 4261 */
|
64 |
u32 max_ra_int; |
65 |
u32 min_delay; |
66 |
|
67 |
u8 rdnss_local; /* Global list is not used for RDNSS */
|
68 |
u8 dnssl_local; /* Global list is not used for DNSSL */
|
69 |
|
70 |
u8 managed; /* Standard options from RFC 4261 */
|
71 |
u8 other_config; |
72 |
u32 link_mtu; |
73 |
u32 reachable_time; |
74 |
u32 retrans_timer; |
75 |
u32 current_hop_limit; |
76 |
u32 default_lifetime; |
77 |
u8 default_lifetime_sensitive; /* Whether default_lifetime depends on trigger */
|
78 |
u8 default_preference; /* Default Router Preference (RFC 4191) */
|
79 |
}; |
80 |
|
81 |
struct radv_prefix_config
|
82 |
{ |
83 |
node n; |
84 |
net_addr_ip6 prefix; |
85 |
|
86 |
u8 skip; /* Do not include this prefix to RA */
|
87 |
u8 onlink; /* Standard options from RFC 4261 */
|
88 |
u8 autonomous; |
89 |
u32 valid_lifetime; |
90 |
u32 preferred_lifetime; |
91 |
u8 valid_lifetime_sensitive; /* Whether valid_lifetime depends on trigger */
|
92 |
u8 preferred_lifetime_sensitive; /* Whether preferred_lifetime depends on trigger */
|
93 |
}; |
94 |
|
95 |
struct radv_rdnss_config
|
96 |
{ |
97 |
node n; |
98 |
u32 lifetime; /* Valid if lifetime_mult is 0 */
|
99 |
u16 lifetime_mult; /* Lifetime specified as multiple of max_ra_int */
|
100 |
ip6_addr server; /* IP address of recursive DNS server */
|
101 |
}; |
102 |
|
103 |
struct radv_dnssl_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 |
u8 dlen_first; /* Length of first label in domain */
|
109 |
u8 dlen_all; /* Both dlen_ filled in radv_process_domain() */
|
110 |
char *domain; /* Domain for DNS search list, in processed form */ |
111 |
}; |
112 |
|
113 |
|
114 |
struct proto_radv
|
115 |
{ |
116 |
struct proto p;
|
117 |
list iface_list; /* List of active ifaces */
|
118 |
u8 active; /* Whether radv is active w.r.t. triggers */
|
119 |
}; |
120 |
|
121 |
struct radv_iface
|
122 |
{ |
123 |
node n; |
124 |
struct proto_radv *ra;
|
125 |
struct radv_iface_config *cf; /* Related config, must be updated in reconfigure */ |
126 |
struct iface *iface;
|
127 |
struct ifa *addr; /* Link-local address of iface */ |
128 |
|
129 |
timer *timer; |
130 |
struct object_lock *lock;
|
131 |
sock *sk; |
132 |
|
133 |
bird_clock_t last; /* Time of last sending of RA */
|
134 |
u16 plen; /* Length of prepared RA in tbuf, or 0 if not valid */
|
135 |
byte initial; /* List of active ifaces */
|
136 |
}; |
137 |
|
138 |
#define RA_EV_INIT 1 /* Switch to initial mode */ |
139 |
#define RA_EV_CHANGE 2 /* Change of options or prefixes */ |
140 |
#define RA_EV_RS 3 /* Received RS */ |
141 |
|
142 |
/* Default Router Preferences (RFC 4191) */
|
143 |
#define RA_PREF_LOW 0x18 |
144 |
#define RA_PREF_MEDIUM 0x00 |
145 |
#define RA_PREF_HIGH 0x08 |
146 |
#define RA_PREF_MASK 0x18 |
147 |
|
148 |
|
149 |
#ifdef LOCAL_DEBUG
|
150 |
#define RADV_FORCE_DEBUG 1 |
151 |
#else
|
152 |
#define RADV_FORCE_DEBUG 0 |
153 |
#endif
|
154 |
#define RADV_TRACE(flags, msg, args...) do { if ((ra->p.debug & flags) || RADV_FORCE_DEBUG) \ |
155 |
log(L_TRACE "%s: " msg, ra->p.name , ## args ); } while(0) |
156 |
|
157 |
|
158 |
/* radv.c */
|
159 |
void radv_iface_notify(struct radv_iface *ifa, int event); |
160 |
|
161 |
/* packets.c */
|
162 |
int radv_process_domain(struct radv_dnssl_config *cf); |
163 |
void radv_send_ra(struct radv_iface *ifa, int shutdown); |
164 |
int radv_sk_open(struct radv_iface *ifa); |
165 |
|
166 |
|
167 |
|
168 |
#endif /* _BIRD_RADV_H_ */ |