]> git.ipfire.org Git - thirdparty/bird.git/blame - proto/ospf/ospf.h
Aging of lsa database added.
[thirdparty/bird.git] / proto / ospf / ospf.h
CommitLineData
c1f8dc91
OF
1/*
2 * BIRD -- OSPF
3 *
4 * (c) 1999 Ondrej Filip <feela@network.cz>
5 *
6 * Can be freely distributed and used under the terms of the GNU GPL.
7 */
8
9#ifndef _BIRD_OSPF_H_
10#define _BIRD_OSPF_H_
11
4364b47e
OF
12#define LOCAL_DEBUG
13
6d2b3211
OF
14#define SIPH 64 /* FIXME Size Of IP header */
15
4364b47e
OF
16#include "nest/bird.h"
17
18#include "lib/checksum.h"
6ba36f06
MM
19#include "lib/ip.h"
20#include "lib/lists.h"
30147b89 21#include "lib/slists.h"
6ba36f06
MM
22#include "lib/socket.h"
23#include "lib/timer.h"
24#include "lib/resource.h"
25#include "nest/protocol.h"
26#include "nest/iface.h"
4364b47e
OF
27#include "nest/route.h"
28#include "conf/conf.h"
85195f1a 29#include <string.h>
6ba36f06 30
5b1a92e6 31#define OSPF_PROTO 89
aec76c6e 32#ifndef IPV6
296ecb56 33#define OSPF_VERSION 2
5b1a92e6
OF
34#define AllSPFRouters ipa_from_u32(0xe0000005) /* 224.0.0.5 */
35#define AllDRouters ipa_from_u32(0xe0000006) /* 224.0.0.6 */
c6c56264 36#define DEFAULTDES ipa_from_u32(0)
aec76c6e 37#else
6376a961 38#error Multicast address not defined in IPv6
aec76c6e
OF
39#endif
40
15087574 41
921a93f2 42#define LSREFRESHTIME 1800 /* 30 minutes */
15087574
OF
43#define MINLSINTERVAL 5
44#define MINLSARRIVAL 1
c6c56264 45#define LSINFINITY 0xffff /* RFC says 0xffffff ??? */
c45f48fb 46#define AGINGDELTA 20 /* FIXME What's good value? */
15087574 47
c1f8dc91
OF
48struct ospf_config {
49 struct proto_config c;
b11d8a4f 50 u32 area; /* FIXME: Area ID !!! This is wrong !!!
aec76c6e 51 * Should respect interface */
c1f8dc91
OF
52};
53
5b1a92e6 54struct ospf_iface {
b11d8a4f 55 node n;
f7103dfc 56 struct proto_ospf *proto;
b11d8a4f 57 struct iface *iface; /* Nest's iface */
30147b89
OF
58 struct ospf_area *oa;
59 u32 an; /* Area number */
1af66415 60 sock *hello_sk; /* Hello socket */
2a092594 61 sock *dr_sk; /* For states DR or BACKUP */
1af66415 62 sock *ip_sk; /* IP socket (for DD ...) */
75b84c34 63 list neigh_list; /* List of neigbours */
5b1a92e6 64 u16 cost; /* Cost of iface */
2c1d1cc7
OF
65 u16 rxmtint; /* number of seconds between LSA retransmissions */
66 u16 iftransdelay; /* The estimated number of seconds it takes to
5b1a92e6
OF
67 transmit a Link State Update Packet over this
68 interface. LSAs contained in the update */
69 u8 priority; /* A router priority for DR election */
70 u16 helloint; /* number of seconds between hello sending */
96f1b8ba 71 u16 waitint; /* number of sec before changing state from wait */
35ff423d 72 u32 deadc; /* after "deadint" missing hellos is router dead */
5b1a92e6
OF
73 u16 autype;
74 u8 aukey[8];
75 u8 options;
aec76c6e
OF
76 ip_addr drip; /* Designated router */
77 u32 drid;
78 ip_addr bdrip; /* Backup DR */
79 u32 bdrid;
2c1d1cc7 80 u8 type; /* OSPF view of type */
96f1b8ba 81#define OSPF_IT_BCAST 0
4c630a6d
OF
82#define OSPF_IT_NBMA 1
83#define OSPF_IT_PTP 2
96f1b8ba 84#define OSPF_IT_VLINK 3
2c1d1cc7 85 u8 state; /* Interface state machine */
96f1b8ba
OF
86#define OSPF_IS_DOWN 0 /* Not working */
87#define OSPF_IS_LOOP 1 /* Should never happen */
88#define OSPF_IS_WAITING 2 /* Waiting for Wait timer */
89#define OSPF_IS_PTP 3 /* PTP operational */
90#define OSPF_IS_DROTHER 4 /* I'm on BCAST or NBMA and I'm not DR */
91#define OSPF_IS_BACKUP 5 /* I'm BDR */
92#define OSPF_IS_DR 6 /* I'm DR */
65112dd2
OF
93 timer *wait_timer; /* WAIT timer */
94 timer *hello_timer; /* HELLOINT timer */
5b1a92e6
OF
95/* Default values for interface parameters */
96#define COST_D 10
97#define RXMTINT_D 5
98#define IFTRANSDELAY_D 1
4c630a6d 99#define PRIORITY_D 1
5b1a92e6 100#define HELLOINT_D 10
35ff423d 101#define DEADC_D 4
96f1b8ba
OF
102#define WAIT_DMH 3 /* Value of Wait timer - not found it in RFC
103 * - using 3*HELLO
1af66415 104 */
5b1a92e6
OF
105};
106
296ecb56
OF
107struct ospf_packet {
108 u8 version;
109 u8 type;
110#define HELLO 1 /* Hello */
111#define DBDES 2 /* Database description */
112#define LSREQ 3 /* Link state request */
113#define LSUPD 4 /* Link state update */
114#define LSACK 5 /* Link state acknowledgement */
115 u16 length;
116 u32 routerid;
117 u32 areaid;
2c971094 118#define BACKBONE 0
296ecb56
OF
119 u16 checksum;
120 u16 autype;
121 u8 authetication[8];
122};
123
124struct ospf_hello_packet {
67ff9130
OF
125 struct ospf_packet ospf_packet;
126 ip_addr netmask;
35ff423d 127 u16 helloint;
296ecb56
OF
128 u8 options;
129 u8 priority;
130 u32 deadint;
131 u32 dr;
132 u32 bdr;
133};
134
04c6319a
OF
135struct immsb {
136 u8 ms:1;
137 u8 m:1;
138 u8 i:1;
139 u8 padding:5;
140};
141
142union imms {
143 u8 byte;
144 struct immsb bit;
145};
146
2c1d1cc7 147struct ospf_dbdes_packet {
1af66415
OF
148 struct ospf_packet ospf_packet;
149 u16 iface_mtu;
2c1d1cc7 150 u8 options;
04c6319a 151 union imms imms; /* I, M, MS bits */
2c1d1cc7
OF
152#define DBDES_MS 1
153#define DBDES_M 2
154#define DBDES_I 4
155 u32 ddseq;
1af66415
OF
156};
157
ce17d4c1
OF
158
159struct ospf_lsa_header {
160 u16 age; /* LS Age */
161#define LSA_MAXAGE 3600 /* 1 hour */
162#define LSA_CHECKAGE 300 /* 5 minutes */
163#define LSA_MAXAGEDIFF 900 /* 15 minutes */
2c1d1cc7 164 u8 options;
ce17d4c1
OF
165 u8 type;
166 u32 id;
167#define LSA_T_RT 1
168#define LSA_T_NET 2
169#define LSA_T_SUM_NET 3
170#define LSA_T_SUM_RT 4
171#define LSA_T_EXT 5
172 u32 rt; /* Advertising router */
910e557b 173 s32 sn; /* LS Sequence number */
ce17d4c1
OF
174#define LSA_INITSEQNO 0x80000001
175#define LSA_MAXSEQNO 0x7fffffff
2c1d1cc7 176 u16 checksum;
ce17d4c1
OF
177 u16 length;
178};
179
180struct ospf_lsa_rt {
181 u8 VEB;
182#define LSA_RT_V 5
183#define LSA_RT_E 6
184#define LSA_RT_B 7
185 u8 padding;
186 u16 links;
187};
188
189struct ospf_lsa_rt_link {
190 u32 id;
191 u32 data;
192 u8 type;
193#define LSART_PTP 1
194#define LSART_NET 2
195#define LSART_STUB 3
196#define LSART_VLNK 4
197 u8 notos;
198 u16 metric;
199};
200
201struct ospf_lsa_rt_link_tos { /* Actually we ignore TOS. This is useless */
202 u8 tos;
203 u8 padding;
204 u16 metric;
2c1d1cc7
OF
205};
206
dfa9a53a 207struct ospf_lsa_net {
c6c56264 208 ip_addr netmask;
dfa9a53a
OF
209};
210
ce17d4c1 211struct ospf_lsa_summ {
c6c56264 212 ip_addr netmask;
ce17d4c1
OF
213};
214
215struct ospf_lsa_summ_net {
216 u8 tos;
217 u8 padding;
218 u16 metric;
219};
220
221struct ospf_lsa_ext {
c6c56264 222 ip_addr netmask;
ce17d4c1
OF
223};
224
225struct ospf_lsa_ext_tos {
226 u8 etos;
227 u8 padding;
f45fd316 228 u16 metric;
ce17d4c1
OF
229 u32 fwaddr;
230 u32 tag;
231};
232
6d2b3211
OF
233struct ospf_lsreq_packet {
234 struct ospf_packet ospf_packet;
235};
236
237struct ospf_lsreq_header {
238 u16 padd1;
239 u8 padd2;
240 u8 type;
241 u32 id;
242 u32 rt; /* Advertising router */
243};
244
f45fd316
OF
245struct l_lsr_head {
246 node n;
247 struct ospf_lsreq_header lsh;
248};
249
de769e24
OF
250struct ospf_lsupd_packet {
251 struct ospf_packet ospf_packet;
252 u32 lsano; /* Number of LSA's */
253};
254
255struct ospf_lsack_packet {
256 struct ospf_packet ospf_packet;
257};
258
259
c76674f0
OF
260struct ospf_neighbor
261{
e83dc0d7 262 node n;
903a3f39 263 struct ospf_iface *ifa;
2c1d1cc7 264 u8 state;
c76674f0 265#define NEIGHBOR_DOWN 0
cd70d934
OF
266#define NEIGHBOR_ATTEMPT 1
267#define NEIGHBOR_INIT 2
268#define NEIGHBOR_2WAY 3
c76674f0 269#define NEIGHBOR_EXSTART 4
903a3f39
OF
270#define NEIGHBOR_EXCHANGE 5
271#define NEIGHBOR_LOADING 6
272#define NEIGHBOR_FULL 7
c76674f0 273 timer *inactim; /* Inactivity timer */
04c6319a 274 union imms imms; /* I, M, Master/slave received */
c2250f91
OF
275 u32 dds; /* DD Sequence number being sent */
276 u32 ddr; /* last Dat Des packet received */
04c6319a 277 union imms myimms; /* I, M Master/slave */
c76674f0 278 u32 rid; /* Router ID */
986e3413 279 ip_addr ip; /* IP of it's interface */
2c1d1cc7 280 u8 priority; /* Priority */
986e3413 281 u8 options; /* Options received */
c76674f0
OF
282 u32 dr; /* Neigbour's idea of DR */
283 u32 bdr; /* Neigbour's idea of BDR */
e3121112 284 u8 adj; /* built adjacency? */
30147b89 285 siterator dbsi; /* Database summary list iterator */
95eb1dba
OF
286 slist lsrql; /* Link state request */
287 struct top_graph *lsrqh; /* LSA graph */
30147b89
OF
288 siterator lsrqi;
289 slist lsrtl; /* Link state retransmission list */
290 siterator lsrti;
921a93f2 291 struct top_graph *lsrth;
30147b89 292 void *ldbdes; /* Last database description packet */
6d2b3211
OF
293 timer *rxmt_timer; /* RXMT timer */
294 timer *lsrr_timer; /* Link state requiest retransmition timer */
67315ef6
OF
295 list ackl;
296 timer *ackd_timer; /* Delayed ack timer */
c76674f0
OF
297};
298
96f1b8ba
OF
299/* Definitions for interface state machine */
300#define ISM_UP 0 /* Interface Up */
301#define ISM_WAITF 1 /* Wait timer fired */
302#define ISM_BACKS 2 /* Backup seen */
303#define ISM_NEICH 3 /* Neighbor change */
304#define ISM_LOOP 4 /* Loop indicated */
305#define ISM_UNLOOP 5 /* Unloop indicated */
306#define ISM_DOWN 6 /* Interface down */
307
308/* Definitions for neighbor state machine */
309#define INM_HELLOREC 0 /* Hello Received */
310#define INM_START 1 /* Neighbor start - for NBMA */
311#define INM_2WAYREC 2 /* 2-Way received */
312#define INM_NEGDONE 3 /* Negotiation done */
313#define INM_EXDONE 4 /* Exchange done */
314#define INM_BADLSREQ 5 /* Bad LS Request */
315#define INM_LOADDONE 6 /* Load done */
316#define INM_ADJOK 7 /* AdjOK? */
317#define INM_SEQMIS 8 /* Sequence number mismatch */
318#define INM_1WAYREC 9 /* 1-Way */
6ba36f06 319#define INM_KILLNBR 10 /* Kill Neighbor */
96f1b8ba
OF
320#define INM_INACTTIM 11 /* Inactivity timer */
321#define INM_LLDOWN 12 /* Line down */
322
15087574 323struct ospf_area {
8496b2e4 324 node n;
15087574 325 u32 areaid;
c45f48fb
OF
326 bird_clock_t lage; /* A time of last aging */
327 timer *age_timer; /* A timer for aging */
15087574 328 struct top_graph *gr; /* LSA graph */
30147b89 329 slist lsal; /* List of all LSA's */
de30342f 330 struct top_hash_entry *rt; /* My own router LSA */
dfa9a53a
OF
331 list cand; /* List of candidates for RT calc. */
332 u8 stub;
333 u8 trcap; /* Transit capability? */
c45f48fb 334 struct proto_ospf *po;
15087574
OF
335};
336
4364b47e
OF
337struct proto_ospf {
338 struct proto proto;
339 list iface_list; /* Interfaces we really use */
8496b2e4 340 list area_list;
15087574 341 int areano; /* Number of area I belong to */
6ba36f06
MM
342};
343
4364b47e
OF
344static int ospf_start(struct proto *p);
345static void ospf_dump(struct proto *p);
346static struct proto *ospf_init(struct proto_config *c);
347static void ospf_preconfig(struct protocol *p, struct config *c);
348static void ospf_postconfig(struct proto_config *c);
349
350#include "proto/ospf/hello.h"
351#include "proto/ospf/packet.h"
352#include "proto/ospf/iface.h"
353#include "proto/ospf/neighbor.h"
354#include "proto/ospf/topology.h"
355#include "proto/ospf/dbdes.h"
6d2b3211 356#include "proto/ospf/lsreq.h"
f45fd316
OF
357#include "proto/ospf/lsupd.h"
358#include "proto/ospf/lsack.h"
359#include "proto/ospf/lsalib.h"
dfa9a53a 360#include "proto/ospf/rt.h"
6ba36f06 361
c1f8dc91 362#endif /* _BIRD_OSPF_H_ */