]> git.ipfire.org Git - thirdparty/bird.git/blob - proto/rip/rip.h
Triggered updates should now actually work. Fixed metric=16 -> time it
[thirdparty/bird.git] / proto / rip / rip.h
1 /*
2 * Structures for RIP protocol
3 *
4 FIXME: in V6, they insert additional entry whenever next hop differs. Such entry is identified by 0xff in metric.
5 */
6
7 #include "nest/route.h"
8 #include "nest/password.h"
9
10 #define EA_RIP_TAG EA_CODE(EAP_RIP, 0)
11 #define EA_RIP_METRIC EA_CODE(EAP_RIP, 1)
12
13 #define PACKET_MAX 25
14 #define PACKET_MD5_MAX 18 /* FIXME */
15
16 struct rip_connection {
17 node n;
18
19 int num;
20 struct proto *proto;
21 ip_addr addr;
22 sock *send;
23 struct rip_interface *rif;
24 struct fib_iterator iter;
25
26 ip_addr daddr;
27 int dport;
28 int done;
29 };
30
31 struct rip_packet_heading {
32 u8 command;
33 #define RIPCMD_REQUEST 1 /* want info */
34 #define RIPCMD_RESPONSE 2 /* responding to request */
35 #define RIPCMD_TRACEON 3 /* turn tracing on */
36 #define RIPCMD_TRACEOFF 4 /* turn it off */
37 #define RIPCMD_MAX 5
38 u8 version;
39 #define RIP_V1 1
40 #define RIP_V2 2
41 u16 unused;
42 };
43
44 #ifndef IPV6
45 struct rip_block {
46 u16 family; /* 0xffff on first message means this is authentication */
47 u16 tag;
48 ip_addr network;
49 ip_addr netmask;
50 ip_addr nexthop;
51 u32 metric;
52 };
53 #else
54 struct rip_block {
55 ip_addr network;
56 u16 tag;
57 u8 pxlen;
58 u8 metric
59 };
60 #endif
61
62 struct rip_block_auth {
63 u16 mustbeFFFF;
64 u16 authtype;
65 u16 packetlen;
66 u8 keyid;
67 u8 authlen;
68 u32 seq;
69 u32 zero0;
70 u32 zero1;
71 };
72
73 struct rip_md5_tail {
74 u16 mustbeFFFF;
75 u16 mustbe0001;
76 char md5[16];
77 };
78
79 struct rip_entry {
80 struct fib_node n;
81
82 ip_addr whotoldme;
83 ip_addr nexthop;
84 int metric;
85 u16 tag;
86
87 bird_clock_t updated, changed;
88 int flags;
89 #define RIP_F_EXTERNAL 1
90 };
91
92 struct rip_packet {
93 struct rip_packet_heading heading;
94 struct rip_block block[25];
95 };
96
97 struct rip_interface {
98 node n;
99 struct proto *proto;
100 struct iface *iface;
101 sock *sock;
102 struct rip_connection *busy;
103 struct rip_patt *patt;
104 int triggered;
105 };
106
107 struct rip_patt {
108 struct iface_patt i;
109
110 int metric;
111 int mode;
112 #define IM_MULTICAST 1
113 #define IM_BROADCAST 2
114 #define IM_QUIET 4
115 #define IM_NOLISTEN 8
116 #define IM_VERSION1 16
117 };
118
119 struct rip_proto_config {
120 struct proto_config c;
121 list iface_list; /* Patterns configured */
122
123 int infinity; /* User configurable data */
124 int port;
125 int period;
126 int garbage_time;
127 int timeout_time;
128
129 struct password_item *passwords;
130 int authtype;
131 #define AT_NONE 0
132 #define AT_PLAINTEXT 2
133 #define AT_MD5 3
134 int honour;
135 #define HO_NEVER 0
136 #define HO_NEIGHBOUR 1
137 #define HO_ALWAYS 2
138 };
139
140 struct rip_proto {
141 struct proto inherited;
142 timer *timer;
143 list connections;
144 struct fib rtable;
145 list garbage;
146 list interfaces; /* Interfaces we really know about */
147 int magic;
148 int tx_count; /* Do one regular update once in a while */
149 };
150
151
152 #define RIP_MAGIC 81861253
153 #define CHK_MAGIC do { if (P->magic != RIP_MAGIC) bug( "Not enough magic\n" ); } while (0)
154
155 void rip_init_instance(struct proto *p);
156 void rip_init_config(struct rip_proto_config *c);
157
158 /* Authentication functions */
159
160 int rip_incoming_authentication( struct proto *p, struct rip_block_auth *block, struct rip_packet *packet, int num );
161 void rip_outgoing_authentication( struct proto *p, struct rip_block_auth *block, struct rip_packet *packet, int num );