summaryrefslogtreecommitdiff
path: root/proto/radv/radv.h
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2011-03-13 11:33:50 +0100
committerOndrej Zajicek <santiago@crfreenet.org>2011-03-13 11:33:50 +0100
commit93e868c730dc0b1825b2a685e0b066c051b1cb07 (patch)
tree732a24861785cbefac966c365a762628bac9c0ac /proto/radv/radv.h
parent9d67ffb0b4cdfbbf88779ce2b44ba810d1ba85d3 (diff)
Implements Router Advertisement protocol.
Diffstat (limited to 'proto/radv/radv.h')
-rw-r--r--proto/radv/radv.h131
1 files changed, 131 insertions, 0 deletions
diff --git a/proto/radv/radv.h b/proto/radv/radv.h
new file mode 100644
index 00000000..fe121f26
--- /dev/null
+++ b/proto/radv/radv.h
@@ -0,0 +1,131 @@
+/*
+ * BIRD -- Router Advertisement
+ *
+ *
+ * Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+#ifndef _BIRD_RADV_H_
+#define _BIRD_RADV_H_
+
+#include "nest/bird.h"
+
+#include "lib/ip.h"
+#include "lib/lists.h"
+#include "lib/socket.h"
+#include "lib/timer.h"
+#include "lib/resource.h"
+#include "nest/protocol.h"
+#include "nest/iface.h"
+#include "nest/route.h"
+#include "nest/cli.h"
+#include "nest/locks.h"
+#include "conf/conf.h"
+#include "lib/string.h"
+
+
+#define ICMPV6_PROTO 58
+
+#define AllNodes _MI(0xFF020000, 0, 0, 1) /* FF02::1 */
+#define AllRouters _MI(0xFF020000, 0, 0, 2) /* FF02::2 */
+
+#define ICMPV6_RS 133
+#define ICMPV6_RA 134
+
+#define MAX_INITIAL_RTR_ADVERTISEMENTS 3
+#define MAX_INITIAL_RTR_ADVERT_INTERVAL 16
+
+#define DEFAULT_MAX_RA_INT 600
+#define DEFAULT_MIN_DELAY 3
+#define DEFAULT_CURRENT_HOP_LIMIT 64
+
+#define DEFAULT_VALID_LIFETIME 86400
+#define DEFAULT_PREFERRED_LIFETIME 14400
+
+
+struct radv_config
+{
+ struct proto_config c;
+ list patt_list; /* List of iface configs */
+ list pref_list; /* Global list of prefix configs */
+};
+
+struct radv_iface_config
+{
+ struct iface_patt i;
+ list pref_list; /* Local list of prefix configs */
+
+ u32 min_ra_int; /* Standard options from RFC 4261 */
+ u32 max_ra_int;
+ u32 min_delay;
+
+ u8 managed;
+ u8 other_config;
+ u32 link_mtu;
+ u32 reachable_time;
+ u32 retrans_timer;
+ u32 current_hop_limit;
+ u32 default_lifetime;
+};
+
+struct radv_prefix_config
+{
+ node n;
+ ip_addr prefix;
+ int pxlen;
+
+ u8 skip; /* Do not include this prefix to RA */
+ u8 onlink; /* Standard options from RFC 4261 */
+ u8 autonomous;
+ u32 valid_lifetime;
+ u32 preferred_lifetime;
+};
+
+struct proto_radv
+{
+ struct proto p;
+ list iface_list; /* List of active ifaces */
+};
+
+struct radv_iface
+{
+ node n;
+ struct proto_radv *ra;
+ struct radv_iface_config *cf; /* Related config, must be updated in reconfigure */
+ struct iface *iface;
+ struct ifa *addr; /* Link-local address of iface */
+
+ timer *timer;
+ struct object_lock *lock;
+ sock *sk;
+
+ bird_clock_t last; /* Time of last sending of RA */
+ u16 plen; /* Length of prepared RA in tbuf, or 0 if not valid */
+ byte initial; /* List of active ifaces */
+};
+
+#define RA_EV_INIT 1 /* Switch to initial mode */
+#define RA_EV_CHANGE 2 /* Change of options or prefixes */
+#define RA_EV_RS 3 /* Received RS */
+
+
+
+#ifdef LOCAL_DEBUG
+#define RADV_FORCE_DEBUG 1
+#else
+#define RADV_FORCE_DEBUG 0
+#endif
+#define RADV_TRACE(flags, msg, args...) do { if ((ra->p.debug & flags) || RADV_FORCE_DEBUG) \
+ log(L_TRACE "%s: " msg, ra->p.name , ## args ); } while(0)
+
+
+/* radv.c */
+void radv_iface_notify(struct radv_iface *ifa, int event);
+
+/* packets.c */
+void radv_send_ra(struct radv_iface *ifa, int shutdown);
+int radv_sk_open(struct radv_iface *ifa);
+
+
+
+#endif /* _BIRD_RADV_H_ */