Statistics
| Branch: | Revision:

iof-bird-daemon / proto / ospf / ospf.h @ 9669362f

History | View | Annotate | Download (8.84 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 OSPF_PROTO 89
31
#ifndef IPV6
32
#define OSPF_VERSION 2
33
#define AllSPFRouters ipa_from_u32(0xe0000005)        /* 224.0.0.5 */
34
#define AllDRouters ipa_from_u32(0xe0000006)        /* 224.0.0.6 */
35
#define DEFAULTDES ipa_from_u32(0)
36
#else
37
#error Multicast address not defined in IPv6
38
#endif
39

    
40

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

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

    
53
struct ospf_iface {
54
  node n;
55
  struct proto_ospf *proto;
56
  struct iface *iface;        /* Nest's iface */
57
  struct ospf_area *oa;
58
  u32 an;                /* Area number */
59
  sock *hello_sk;        /* Hello socket */
60
  sock *dr_sk;                /* For states DR or BACKUP */
61
  sock *ip_sk;                /* IP socket (for DD ...) */
62
  list neigh_list;        /* List of neigbours */
63
  u16 cost;                /* Cost of iface */
64
  u16 rxmtint;                /* number of seconds between LSA retransmissions */
65
  u16 inftransdelay;        /* The estimated number of seconds it takes to
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 */
70
  u16 waitint;                /* number of sec before changing state from wait */
71
  u32 deadc;                /* after "deadint" missing hellos is router dead */
72
  u16 autype;
73
  u8 aukey[8];
74
  u8 options;
75
  ip_addr drip;                /* Designated router */
76
  u32 drid;
77
  ip_addr bdrip;        /* Backup DR */
78
  u32 bdrid;
79
  u8 type;                /* OSPF view of type */
80
#define OSPF_IT_BCAST 0
81
#define OSPF_IT_NBMA 1
82
#define OSPF_IT_PTP 2
83
#define OSPF_IT_VLINK 3
84
  u8 state;                /* Interface state machine */
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 */
92
  timer *wait_timer;                /* WAIT timer */
93
  timer *hello_timer;                /* HELLOINT timer */
94
/* Default values for interface parameters */
95
#define COST_D 10
96
#define RXMTINT_D 5
97
#define INFTRANSDELAY_D 1
98
#define PRIORITY_D 1
99
#define HELLOINT_D 10
100
#define DEADC_D 4
101
#define WAIT_DMH 3        /* Value of Wait timer - not found it in RFC 
102
                         * - using 3*HELLO
103
                         */
104
  struct top_hash_entry *nlsa;        /* Originated net lsa */
105
  int fadj;                /* Number of full adjacent neigh */
106
};
107

    
108
struct 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;
119
#define BACKBONE 0
120
  u16 checksum;
121
  u16 autype;
122
  u8 authetication[8];
123
};
124

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

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

    
143
union imms {
144
  u8 byte;
145
  struct immsb bit;
146
};
147

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

    
159

    
160
struct 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 */
165
  u8 options;
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 */
174
  s32 sn;                /* LS Sequence number */
175
#define LSA_INITSEQNO 0x80000001
176
#define LSA_MAXSEQNO 0x7fffffff
177
  u16 checksum;
178
  u16 length;  
179
};
180

    
181
struct 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

    
190
struct 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

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

    
208
struct ospf_lsa_net {
209
  ip_addr netmask;
210
};
211

    
212
struct ospf_lsa_summ {
213
  ip_addr netmask;
214
};
215

    
216
struct ospf_lsa_summ_net {
217
  u8 tos;
218
  u8 padding;
219
  u16 metric;
220
};
221

    
222
struct ospf_lsa_ext {
223
  ip_addr netmask;
224
};
225

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

    
234
struct ospf_lsreq_packet {
235
  struct ospf_packet ospf_packet;
236
};
237

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

    
246
struct l_lsr_head {
247
  node n;
248
  struct ospf_lsreq_header lsh;
249
};
250

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

    
256
struct ospf_lsack_packet {
257
  struct ospf_packet ospf_packet;
258
};
259

    
260

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

    
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 */
320
#define INM_KILLNBR 10        /* Kill Neighbor */
321
#define INM_INACTTIM 11        /* Inactivity timer */
322
#define INM_LLDOWN 12        /* Line down */
323

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

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

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

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

    
364
#endif /* _BIRD_OSPF_H_ */