Statistics
| Branch: | Revision:

iof-bird-daemon / proto / ospf / ospf.h @ 43e75f38

History | View | Annotate | Download (8.86 KB)

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

    
12

    
13
#define SIPH 64                /* FIXME Size Of IP header */
14

    
15
#include "nest/bird.h"
16

    
17
#include "lib/checksum.h"
18
#include "lib/ip.h"
19
#include "lib/lists.h"
20
#include "lib/slists.h"
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"
26
#include "nest/route.h"
27
#include "conf/conf.h"
28
#include "lib/string.h"
29

    
30
#define LOCAL_DEBUG
31

    
32
#define OSPF_PROTO 89
33
#ifndef IPV6
34
#define OSPF_VERSION 2
35
#define AllSPFRouters ipa_from_u32(0xe0000005)        /* 224.0.0.5 */
36
#define AllDRouters ipa_from_u32(0xe0000006)        /* 224.0.0.6 */
37
#define DEFAULTDES ipa_from_u32(0)
38
#else
39
#error Multicast address not defined in IPv6
40
#endif
41

    
42

    
43
#define LSREFRESHTIME 1800        /* 30 minutes */
44
#define MINLSINTERVAL 5
45
#define MINLSARRIVAL 1
46
#define LSINFINITY 0xffff        /* RFC says 0xffffff ??? */
47
#define AGINGDELTA 20                /* FIXME What's good value? */
48

    
49
struct ospf_config {
50
  struct proto_config c;
51
  u32 area;                /* FIXME: Area ID  !!! This is wrong !!!
52
                         * Should respect interface */
53
};
54

    
55
struct ospf_iface {
56
  node n;
57
  struct proto_ospf *proto;
58
  struct iface *iface;        /* Nest's iface */
59
  struct ospf_area *oa;
60
  u32 an;                /* Area number */
61
  sock *hello_sk;        /* Hello socket */
62
  sock *dr_sk;                /* For states DR or BACKUP */
63
  sock *ip_sk;                /* IP socket (for DD ...) */
64
  list neigh_list;        /* List of neigbours */
65
  u16 cost;                /* Cost of iface */
66
  u16 rxmtint;                /* number of seconds between LSA retransmissions */
67
  u16 inftransdelay;        /* The estimated number of seconds it takes to
68
                           transmit a Link State Update Packet over this
69
                           interface.  LSAs contained in the update */
70
  u8 priority;                /* A router priority for DR election */
71
  u16 helloint;                /* number of seconds between hello sending */
72
  u16 waitint;                /* number of sec before changing state from wait */
73
  u32 deadc;                /* after "deadint" missing hellos is router dead */
74
  u16 autype;
75
  u8 aukey[8];
76
  u8 options;
77
  ip_addr drip;                /* Designated router */
78
  u32 drid;
79
  ip_addr bdrip;        /* Backup DR */
80
  u32 bdrid;
81
  u8 type;                /* OSPF view of type */
82
#define OSPF_IT_BCAST 0
83
#define OSPF_IT_NBMA 1
84
#define OSPF_IT_PTP 2
85
#define OSPF_IT_VLINK 3
86
  u8 state;                /* Interface state machine */
87
#define OSPF_IS_DOWN 0                /* Not working */
88
#define OSPF_IS_LOOP 1                /* Should never happen */
89
#define OSPF_IS_WAITING 2        /* Waiting for Wait timer */
90
#define OSPF_IS_PTP 3                /* PTP operational */
91
#define OSPF_IS_DROTHER 4        /* I'm on BCAST or NBMA and I'm not DR */
92
#define OSPF_IS_BACKUP 5        /* I'm BDR */
93
#define OSPF_IS_DR 6                /* I'm DR */
94
  timer *wait_timer;                /* WAIT timer */
95
  timer *hello_timer;                /* HELLOINT timer */
96
/* Default values for interface parameters */
97
#define COST_D 10
98
#define RXMTINT_D 5
99
#define INFTRANSDELAY_D 1
100
#define PRIORITY_D 1
101
#define HELLOINT_D 10
102
#define DEADC_D 4
103
#define WAIT_DMH 3        /* Value of Wait timer - not found it in RFC 
104
                         * - using 3*HELLO
105
                         */
106
  struct top_hash_entry *nlsa;        /* Originated net lsa */
107
  int fadj;                /* Number of full adjacent neigh */
108
};
109

    
110
struct ospf_packet {
111
  u8 version;
112
  u8 type;
113
#define HELLO 1 /* Hello */
114
#define DBDES 2 /* Database description */
115
#define LSREQ 3 /* Link state request */
116
#define LSUPD 4 /* Link state update */
117
#define LSACK 5 /* Link state acknowledgement */
118
  u16 length;
119
  u32 routerid;
120
  u32 areaid;
121
#define BACKBONE 0
122
  u16 checksum;
123
  u16 autype;
124
  u8 authetication[8];
125
};
126

    
127
struct ospf_hello_packet {
128
  struct ospf_packet ospf_packet;
129
  ip_addr netmask;
130
  u16 helloint;
131
  u8 options;
132
  u8 priority;
133
  u32 deadint;
134
  u32 dr;
135
  u32 bdr;
136
};
137

    
138
struct immsb {
139
  u8 ms:1;
140
  u8 m:1;
141
  u8 i:1;
142
  u8 padding:5;
143
};
144

    
145
union imms {
146
  u8 byte;
147
  struct immsb bit;
148
};
149

    
150
struct ospf_dbdes_packet {
151
  struct ospf_packet ospf_packet;
152
  u16 iface_mtu;
153
  u8 options;
154
  union imms imms;                /* I, M, MS bits */
155
#define DBDES_MS 1
156
#define DBDES_M 2
157
#define DBDES_I 4
158
  u32 ddseq;
159
};
160

    
161

    
162
struct ospf_lsa_header {
163
  u16 age;        /* LS Age */
164
#define LSA_MAXAGE 3600                 /* 1 hour */
165
#define LSA_CHECKAGE 300                /* 5 minutes */
166
#define LSA_MAXAGEDIFF 900              /* 15 minutes */
167
  u8 options;
168
  u8 type;
169
  u32 id;
170
#define LSA_T_RT 1
171
#define LSA_T_NET 2
172
#define LSA_T_SUM_NET 3
173
#define LSA_T_SUM_RT 4
174
#define LSA_T_EXT 5
175
  u32 rt;                /* Advertising router */
176
  s32 sn;                /* LS Sequence number */
177
#define LSA_INITSEQNO 0x80000001
178
#define LSA_MAXSEQNO 0x7fffffff
179
  u16 checksum;
180
  u16 length;  
181
};
182

    
183
struct ospf_lsa_rt {
184
  u8 VEB;
185
#define LSA_RT_V 5
186
#define LSA_RT_E 6
187
#define LSA_RT_B 7
188
  u8 padding;
189
  u16 links;
190
};
191

    
192
struct ospf_lsa_rt_link {
193
  u32 id;
194
  u32 data;
195
  u8 type;
196
#define LSART_PTP 1
197
#define LSART_NET 2
198
#define LSART_STUB 3
199
#define LSART_VLNK 4
200
  u8 notos;
201
  u16 metric;
202
};
203

    
204
struct ospf_lsa_rt_link_tos {        /* Actually we ignore TOS. This is useless */
205
  u8 tos;
206
  u8 padding;
207
  u16 metric;
208
};
209

    
210
struct ospf_lsa_net {
211
  ip_addr netmask;
212
};
213

    
214
struct ospf_lsa_summ {
215
  ip_addr netmask;
216
};
217

    
218
struct ospf_lsa_summ_net {
219
  u8 tos;
220
  u8 padding;
221
  u16 metric;
222
};
223

    
224
struct ospf_lsa_ext {
225
  ip_addr netmask;
226
};
227

    
228
struct ospf_lsa_ext_tos {
229
  u8 etos;
230
  u8 padding;
231
  u16 metric;
232
  u32 fwaddr;
233
  u32 tag;
234
};
235

    
236
struct ospf_lsreq_packet {
237
  struct ospf_packet ospf_packet;
238
};
239

    
240
struct ospf_lsreq_header {
241
  u16 padd1;
242
  u8 padd2;
243
  u8 type;
244
  u32 id;
245
  u32 rt;                /* Advertising router */
246
};
247

    
248
struct l_lsr_head {
249
  node n;
250
  struct ospf_lsreq_header lsh;
251
};
252

    
253
struct ospf_lsupd_packet {
254
  struct ospf_packet ospf_packet;
255
  u32 lsano;                /* Number of LSA's */
256
};
257

    
258
struct ospf_lsack_packet {
259
  struct ospf_packet ospf_packet;
260
};
261

    
262

    
263
struct ospf_neighbor
264
{
265
  node n;
266
  struct ospf_iface *ifa;
267
  u8 state;
268
#define NEIGHBOR_DOWN 0
269
#define NEIGHBOR_ATTEMPT 1
270
#define NEIGHBOR_INIT 2
271
#define NEIGHBOR_2WAY 3
272
#define NEIGHBOR_EXSTART 4
273
#define NEIGHBOR_EXCHANGE 5
274
#define NEIGHBOR_LOADING 6
275
#define NEIGHBOR_FULL 7
276
  timer *inactim;        /* Inactivity timer */
277
  union imms imms;                /* I, M, Master/slave received */
278
  u32 dds;                /* DD Sequence number being sent */
279
  u32 ddr;                /* last Dat Des packet received */
280
  union imms myimms;                /* I, M Master/slave */
281
  u32 rid;                /* Router ID */
282
  ip_addr ip;                /* IP of it's interface */
283
  u8 priority;                /* Priority */
284
  u8 options;                /* Options received */
285
  u32 dr;                /* Neigbour's idea of DR */
286
  u32 bdr;                /* Neigbour's idea of BDR */
287
  u8 adj;                /* built adjacency? */
288
  siterator dbsi;        /* Database summary list iterator */
289
  slist lsrql;                /* Link state request */
290
  struct top_graph *lsrqh;                /* LSA graph */
291
  siterator lsrqi;
292
  slist lsrtl;                /* Link state retransmission list */
293
  siterator lsrti;
294
  struct top_graph *lsrth;
295
  void *ldbdes;                /* Last database description packet */
296
  timer *rxmt_timer;        /* RXMT timer */
297
  timer *lsrr_timer;        /* Link state request retransmition timer */
298
  list ackl;
299
  timer *ackd_timer;        /* Delayed ack timer */
300
};
301

    
302
/* Definitions for interface state machine */
303
#define ISM_UP 0        /* Interface Up */
304
#define ISM_WAITF 1        /* Wait timer fired */
305
#define ISM_BACKS 2        /* Backup seen */
306
#define ISM_NEICH 3        /* Neighbor change */
307
#define ISM_LOOP 4        /* Loop indicated */
308
#define ISM_UNLOOP 5        /* Unloop indicated */
309
#define ISM_DOWN 6        /* Interface down */
310

    
311
/* Definitions for neighbor state machine */
312
#define INM_HELLOREC 0        /* Hello Received */
313
#define INM_START 1        /* Neighbor start - for NBMA */
314
#define INM_2WAYREC 2        /* 2-Way received */
315
#define INM_NEGDONE 3        /* Negotiation done */
316
#define INM_EXDONE 4        /* Exchange done */
317
#define INM_BADLSREQ 5        /* Bad LS Request */
318
#define INM_LOADDONE 6        /* Load done */
319
#define INM_ADJOK 7        /* AdjOK? */
320
#define INM_SEQMIS 8        /* Sequence number mismatch */
321
#define INM_1WAYREC 9        /* 1-Way */
322
#define INM_KILLNBR 10        /* Kill Neighbor */
323
#define INM_INACTTIM 11        /* Inactivity timer */
324
#define INM_LLDOWN 12        /* Line down */
325

    
326
struct ospf_area {
327
  node n;
328
  u32 areaid;
329
  bird_clock_t lage;                /* A time of last aging */
330
  timer *age_timer;                        /* A timer for aging */
331
  struct top_graph *gr;                /* LSA graph */
332
  slist lsal;                        /* List of all LSA's */
333
  struct top_hash_entry *rt;        /* My own router LSA */
334
  list cand;                        /* List of candidates for RT calc. */
335
  u8 stub;
336
  u8 trcap;                        /* Transit capability? */
337
  struct proto_ospf *po;
338
  struct fib infib;                /* FIB for intra-area routes */
339
};
340

    
341
struct proto_ospf {
342
  struct proto proto;
343
  list iface_list;                /* Interfaces we really use */
344
  list area_list;
345
  int areano;                        /* Number of area I belong to */
346
};
347

    
348
static int ospf_start(struct proto *p);
349
static void ospf_dump(struct proto *p);
350
static struct proto *ospf_init(struct proto_config *c);
351
static void ospf_preconfig(struct protocol *p, struct config *c);
352
static void ospf_postconfig(struct proto_config *c);
353

    
354
#include "proto/ospf/hello.h"
355
#include "proto/ospf/packet.h"
356
#include "proto/ospf/iface.h"
357
#include "proto/ospf/neighbor.h"
358
#include "proto/ospf/topology.h"
359
#include "proto/ospf/dbdes.h"
360
#include "proto/ospf/lsreq.h"
361
#include "proto/ospf/lsupd.h"
362
#include "proto/ospf/lsack.h"
363
#include "proto/ospf/lsalib.h"
364
#include "proto/ospf/rt.h"
365

    
366
#endif /* _BIRD_OSPF_H_ */