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