Statistics
| Branch: | Revision:

iof-bird-daemon / proto / radv / radv.h @ fe9f1a6d

History | View | Annotate | Download (4.48 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
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 trigger_valid;                /* Whether a trigger route is defined */
55
};
56

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

    
64
  u32 min_ra_int;                /* Standard options from RFC 4261 */
65
  u32 max_ra_int;
66
  u32 min_delay;
67

    
68
  u8 rdnss_local;                /* Global list is not used for RDNSS */
69
  u8 dnssl_local;                /* Global list is not used for DNSSL */
70

    
71
  u8 managed;                        /* Standard options from RFC 4261 */
72
  u8 other_config;
73
  u32 link_mtu;
74
  u32 reachable_time;
75
  u32 retrans_timer;
76
  u32 current_hop_limit;
77
  u32 default_lifetime;
78
  u8 default_lifetime_sensitive; /* Whether default_lifetime depends on trigger */
79
  u8 default_preference;        /* Default Router Preference (RFC 4191) */
80
};
81

    
82
struct radv_prefix_config
83
{
84
  node n;
85
  ip_addr prefix;
86
  int pxlen;
87

    
88
  u8 skip;                        /* Do not include this prefix to RA */
89
  u8 onlink;                        /* Standard options from RFC 4261 */
90
  u8 autonomous;
91
  u32 valid_lifetime;
92
  u32 preferred_lifetime;
93
  u8 valid_lifetime_sensitive;         /* Whether valid_lifetime depends on trigger */
94
  u8 preferred_lifetime_sensitive; /* Whether preferred_lifetime depends on trigger */
95
};
96

    
97
struct radv_rdnss_config
98
{
99
  node n;
100
  u32 lifetime;                        /* Valid if lifetime_mult is 0 */
101
  u16 lifetime_mult;                /* Lifetime specified as multiple of max_ra_int */
102
  ip_addr server;                /* IP address of recursive DNS server */
103
};
104

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

    
115

    
116
struct proto_radv
117
{
118
  struct proto p;
119
  list iface_list;                /* List of active ifaces */
120
  u8 active;                        /* Whether radv is active w.r.t. triggers */
121
};
122

    
123
struct radv_iface
124
{
125
  node n;
126
  struct proto_radv *ra;
127
  struct radv_iface_config *cf;        /* Related config, must be updated in reconfigure */
128
  struct iface *iface;
129
  struct ifa *addr;                /* Link-local address of iface */
130

    
131
  timer *timer;
132
  struct object_lock *lock;
133
  sock *sk;
134

    
135
  bird_clock_t last;                /* Time of last sending of RA */
136
  u16 plen;                        /* Length of prepared RA in tbuf, or 0 if not valid */
137
  byte initial;                        /* List of active ifaces */
138
};
139

    
140
#define RA_EV_INIT 1                /* Switch to initial mode */
141
#define RA_EV_CHANGE 2                /* Change of options or prefixes */
142
#define RA_EV_RS 3                /* Received RS */
143

    
144
/* Default Router Preferences (RFC 4191) */
145
#define RA_PREF_LOW        0x18
146
#define RA_PREF_MEDIUM        0x00
147
#define RA_PREF_HIGH        0x08
148
#define RA_PREF_MASK        0x18
149

    
150

    
151
#ifdef LOCAL_DEBUG
152
#define RADV_FORCE_DEBUG 1
153
#else
154
#define RADV_FORCE_DEBUG 0
155
#endif
156
#define RADV_TRACE(flags, msg, args...) do { if ((ra->p.debug & flags) || RADV_FORCE_DEBUG) \
157
        log(L_TRACE "%s: " msg, ra->p.name , ## args ); } while(0)
158

    
159

    
160
/* radv.c */
161
void radv_iface_notify(struct radv_iface *ifa, int event);
162

    
163
/* packets.c */
164
int radv_process_domain(struct radv_dnssl_config *cf);
165
void radv_send_ra(struct radv_iface *ifa, int shutdown);
166
int radv_sk_open(struct radv_iface *ifa);
167

    
168

    
169

    
170
#endif /* _BIRD_RADV_H_ */