]> git.ipfire.org Git - thirdparty/bird.git/blame - proto/radv/radv.h
RAdv: Allow solicited RAs to be sent as unicast
[thirdparty/bird.git] / proto / radv / radv.h
CommitLineData
93e868c7
OZ
1/*
2 * BIRD -- Router Advertisement
3 *
70a4320b
OZ
4 * (c) 2011--2019 Ondrej Zajicek <santiago@crfreenet.org>
5 * (c) 2011--2019 CZ.NIC z.s.p.o.
93e868c7
OZ
6 *
7 * Can be freely distributed and used under the terms of the GNU GPL.
8 */
9
10#ifndef _BIRD_RADV_H_
11#define _BIRD_RADV_H_
12
13#include "nest/bird.h"
14
15#include "lib/ip.h"
16#include "lib/lists.h"
17#include "lib/socket.h"
a6f79ca5 18#include "lib/timer.h"
93e868c7
OZ
19#include "lib/resource.h"
20#include "nest/protocol.h"
21#include "nest/iface.h"
22#include "nest/route.h"
23#include "nest/cli.h"
24#include "nest/locks.h"
25#include "conf/conf.h"
26#include "lib/string.h"
27
28
29#define ICMPV6_PROTO 58
30
93e868c7
OZ
31#define ICMPV6_RS 133
32#define ICMPV6_RA 134
33
34#define MAX_INITIAL_RTR_ADVERTISEMENTS 3
c521b3ac 35#define MAX_INITIAL_RTR_ADVERT_INTERVAL (16 S_)
93e868c7
OZ
36
37#define DEFAULT_MAX_RA_INT 600
38#define DEFAULT_MIN_DELAY 3
39#define DEFAULT_CURRENT_HOP_LIMIT 64
40
41#define DEFAULT_VALID_LIFETIME 86400
42#define DEFAULT_PREFERRED_LIFETIME 14400
43
fc06fb62
OZ
44#define DEFAULT_DNS_LIFETIME_MULT 3
45
93e868c7
OZ
46
47struct radv_config
48{
49 struct proto_config c;
a7f23f58
OZ
50 list patt_list; /* List of iface configs (struct radv_iface_config) */
51 list pref_list; /* Global list of prefix configs (struct radv_prefix_config) */
fc06fb62
OZ
52 list rdnss_list; /* Global list of RDNSS configs (struct radv_rdnss_config) */
53 list dnssl_list; /* Global list of DNSSL configs (struct radv_dnssl_config) */
36da2857 54
f4a60a9b 55 net_addr trigger; /* Prefix of a trigger route, if defined */
2a95e633 56 u8 propagate_routes; /* Do we propagate more specific routes (RFC 4191)? */
7c0bab3a 57 u32 max_linger_time; /* Maximum of interface route_linger_time */
93e868c7
OZ
58};
59
60struct radv_iface_config
61{
62 struct iface_patt i;
a7f23f58 63 list pref_list; /* Local list of prefix configs (struct radv_prefix_config) */
fc06fb62
OZ
64 list rdnss_list; /* Local list of RDNSS configs (struct radv_rdnss_config) */
65 list dnssl_list; /* Local list of DNSSL configs (struct radv_dnssl_config) */
93e868c7 66
afd9845e 67 u32 min_ra_int; /* Standard options from RFC 4861 */
93e868c7
OZ
68 u32 max_ra_int;
69 u32 min_delay;
70
70a4320b
OZ
71 u8 solicited_ra_unicast; /* Send solicited RAs as unicast */
72
7c0bab3a
OZ
73 u32 prefix_linger_time; /* How long we advertise dead prefixes with lifetime 0 */
74 u32 route_linger_time; /* How long we advertise dead routes with lifetime 0 */
ec7d6a50 75
fc06fb62
OZ
76 u8 rdnss_local; /* Global list is not used for RDNSS */
77 u8 dnssl_local; /* Global list is not used for DNSSL */
78
afd9845e 79 u8 managed; /* Standard options from RFC 4861 */
93e868c7
OZ
80 u8 other_config;
81 u32 link_mtu;
82 u32 reachable_time;
83 u32 retrans_timer;
a7f23f58 84 u32 current_hop_limit;
93e868c7 85 u32 default_lifetime;
7c0bab3a 86 u32 route_lifetime; /* Lifetime for the RFC 4191 routes */
36da2857 87 u8 default_lifetime_sensitive; /* Whether default_lifetime depends on trigger */
7c0bab3a
OZ
88 u8 route_lifetime_sensitive; /* Whether route_lifetime depends on trigger */
89 u8 default_preference; /* Default Router Preference (RFC 4191) */
90 u8 route_preference; /* Specific Route Preference (RFC 4191) */
93e868c7
OZ
91};
92
93struct radv_prefix_config
94{
95 node n;
d44e686e 96 net_addr_ip6 prefix;
93e868c7
OZ
97
98 u8 skip; /* Do not include this prefix to RA */
afd9845e 99 u8 onlink; /* Standard options from RFC 4861 */
93e868c7
OZ
100 u8 autonomous;
101 u32 valid_lifetime;
102 u32 preferred_lifetime;
36da2857
OZ
103 u8 valid_lifetime_sensitive; /* Whether valid_lifetime depends on trigger */
104 u8 preferred_lifetime_sensitive; /* Whether preferred_lifetime depends on trigger */
93e868c7
OZ
105};
106
fc06fb62
OZ
107struct radv_rdnss_config
108{
109 node n;
110 u32 lifetime; /* Valid if lifetime_mult is 0 */
111 u16 lifetime_mult; /* Lifetime specified as multiple of max_ra_int */
d44e686e 112 ip6_addr server; /* IP address of recursive DNS server */
fc06fb62
OZ
113};
114
115struct radv_dnssl_config
116{
117 node n;
118 u32 lifetime; /* Valid if lifetime_mult is 0 */
119 u16 lifetime_mult; /* Lifetime specified as multiple of max_ra_int */
120 u8 dlen_first; /* Length of first label in domain */
121 u8 dlen_all; /* Both dlen_ filled in radv_process_domain() */
122 char *domain; /* Domain for DNS search list, in processed form */
123};
124
2a95e633
MV
125/*
126 * One more specific route as per RFC 4191.
127 *
128 * Note that it does *not* contain the next hop field. The next hop is always
129 * the router sending the advertisment and the more specific route only allows
130 * overriding the preference of the route.
131 */
132struct radv_route
133{
2a95e633 134 u32 lifetime; /* Lifetime from an attribute */
7c0bab3a 135 u8 lifetime_set; /* Whether lifetime is defined */
2a95e633 136 u8 preference; /* Preference of the route, RA_PREF_* */
7c0bab3a
OZ
137 u8 preference_set; /* Whether preference is defined */
138 u8 valid; /* Whethe route is valid or withdrawn */
830ba75e
OZ
139 btime changed; /* Last time when the route changed */
140
141 struct fib_node n;
2a95e633 142};
fc06fb62 143
5a41eed2 144struct radv_proto
93e868c7
OZ
145{
146 struct proto p;
147 list iface_list; /* List of active ifaces */
2a95e633 148 u8 valid; /* Router is valid for forwarding, used for shutdown */
36da2857 149 u8 active; /* Whether radv is active w.r.t. triggers */
2a95e633
MV
150 u8 fib_up; /* FIB table (routes) is initialized */
151 struct fib routes; /* FIB table of specific routes (struct radv_route) */
830ba75e 152 btime prune_time; /* Next time of route table pruning */
93e868c7
OZ
153};
154
e2d2b3ef
MV
155struct radv_prefix /* One prefix we advertise */
156{
157 node n;
4ff15a75
OZ
158 net_addr_ip6 prefix;
159
7c0bab3a 160 u8 valid; /* Is the prefix valid? If not, we advertise it
08b6a617 161 with 0 lifetime, so clients stop using it */
e2d2b3ef 162 u8 mark; /* A temporary mark for processing */
830ba75e 163 btime changed; /* Last time when the prefix changed */
08b6a617 164 struct radv_prefix_config *cf; /* The config tied to this prefix */
e2d2b3ef
MV
165};
166
93e868c7
OZ
167struct radv_iface
168{
169 node n;
5a41eed2 170 struct radv_proto *ra;
93e868c7
OZ
171 struct radv_iface_config *cf; /* Related config, must be updated in reconfigure */
172 struct iface *iface;
173 struct ifa *addr; /* Link-local address of iface */
e2d2b3ef 174 struct pool *pool; /* A pool for interface-specific things */
08b6a617 175 list prefixes; /* The prefixes we advertise (struct radv_prefix) */
830ba75e
OZ
176 btime prune_time; /* Next time of prefix list pruning */
177 btime valid_time; /* Cached packet is valid until first linger timeout */
93e868c7
OZ
178
179 timer *timer;
180 struct object_lock *lock;
181 sock *sk;
182
c521b3ac 183 btime last; /* Time of last sending of RA */
93e868c7 184 u16 plen; /* Length of prepared RA in tbuf, or 0 if not valid */
e2d2b3ef 185 byte initial; /* How many RAs are still to be sent as initial */
93e868c7
OZ
186};
187
188#define RA_EV_INIT 1 /* Switch to initial mode */
189#define RA_EV_CHANGE 2 /* Change of options or prefixes */
190#define RA_EV_RS 3 /* Received RS */
191
75148289
OZ
192/* Default Router Preferences (RFC 4191) */
193#define RA_PREF_LOW 0x18
194#define RA_PREF_MEDIUM 0x00
195#define RA_PREF_HIGH 0x08
196#define RA_PREF_MASK 0x18
93e868c7 197
2a95e633 198/* Attributes */
ee7e2ffd
JMM
199#define EA_RA_PREFERENCE EA_CODE(PROTOCOL_RADV, 0)
200#define EA_RA_LIFETIME EA_CODE(PROTOCOL_RADV, 1)
93e868c7
OZ
201
202#ifdef LOCAL_DEBUG
203#define RADV_FORCE_DEBUG 1
204#else
205#define RADV_FORCE_DEBUG 0
206#endif
5a41eed2
MV
207#define RADV_TRACE(flags, msg, args...) do { if ((p->p.debug & flags) || RADV_FORCE_DEBUG) \
208 log(L_TRACE "%s: " msg, p->p.name , ## args ); } while(0)
93e868c7
OZ
209
210
70a4320b
OZ
211/* Invalidate cached RA packet */
212static inline void radv_invalidate(struct radv_iface *ifa)
213{ ifa->plen = 0; }
214
93e868c7
OZ
215/* radv.c */
216void radv_iface_notify(struct radv_iface *ifa, int event);
217
218/* packets.c */
fc06fb62 219int radv_process_domain(struct radv_dnssl_config *cf);
70a4320b 220void radv_send_ra(struct radv_iface *ifa, ip_addr to);
93e868c7
OZ
221int radv_sk_open(struct radv_iface *ifa);
222
223
224
225#endif /* _BIRD_RADV_H_ */