Statistics
| Branch: | Revision:

iof-bird-daemon / proto / ospf / ospf.h @ af157fa3

History | View | Annotate | Download (17.8 KB)

1
/*
2
 *        BIRD -- OSPF
3
 *
4
 *        (c) 1999--2005 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
#define MAXNETS 10
13
#define OSPF_VLINK_MTU 576        /* RFC2328 - A.1 */
14
#define OSPF_MAX_PKT_SIZE 65536
15
                        /*
16
                         * RFC 2328 says, maximum packet size is 65535
17
                         * This could be too much for small systems, so I
18
                         * normally allocate 2*mtu - (I found one cisco
19
                         * sending packets mtu+16)
20
                         */
21
#ifdef LOCAL_DEBUG
22
#define OSPF_FORCE_DEBUG 1
23
#else
24
#define OSPF_FORCE_DEBUG 0
25
#endif
26
#define OSPF_TRACE(flags, msg, args...) do { if ((p->debug & flags) || OSPF_FORCE_DEBUG) \
27
  log(L_TRACE "%s: " msg, p->name , ## args ); } while(0)
28

    
29
#define OSPF_PACKET(dumpfn, buffer, msg, args...) \
30
do { if ((p->debug & D_PACKETS) || OSPF_FORCE_DEBUG) \
31
{ log(L_TRACE "%s: " msg, p->name, ## args ); dumpfn(p, buffer); } } while(0)
32

    
33

    
34
#include "nest/bird.h"
35

    
36
#include "lib/checksum.h"
37
#include "lib/ip.h"
38
#include "lib/lists.h"
39
#include "lib/slists.h"
40
#include "lib/socket.h"
41
#include "lib/timer.h"
42
#include "lib/resource.h"
43
#include "nest/protocol.h"
44
#include "nest/iface.h"
45
#include "nest/route.h"
46
#include "nest/cli.h"
47
#include "nest/locks.h"
48
#include "conf/conf.h"
49
#include "lib/string.h"
50

    
51
#define OSPF_PROTO 89
52

    
53
#ifndef IPV6
54
#define OSPFv2 1
55
#define OSPF_VERSION 2
56
#define AllSPFRouters ipa_from_u32(0xe0000005)        /* 224.0.0.5 */
57
#define AllDRouters ipa_from_u32(0xe0000006)        /* 224.0.0.6 */
58
#else
59
#define OSPFv3 1
60
#define OSPF_VERSION 3
61
#define AllSPFRouters _MI(0xFF020000, 0, 0, 5)        /* FF02::5 */
62
#define AllDRouters   _MI(0xFF020000, 0, 0, 6)        /* FF02::6 */
63
#endif
64

    
65

    
66
#define LSREFRESHTIME 1800        /* 30 minutes */
67
#define MINLSINTERVAL 5
68
#define MINLSARRIVAL 1
69
#define LSINFINITY 0xffffff
70

    
71
#define DEFAULT_OSPFTICK 1
72
#define DEFAULT_RFC1583 0        /* compatibility with rfc1583 */
73
#define DEFAULT_STUB_COST 1000
74

    
75

    
76
struct ospf_config
77
{
78
  struct proto_config c;
79
  unsigned tick;
80
  int rfc1583;
81
  list area_list;
82
};
83

    
84
struct nbma_node
85
{
86
  node n;
87
  ip_addr ip;
88
  int eligible;
89
};
90

    
91
struct area_net_config
92
{
93
  node n;
94
  struct prefix px;
95
  int hidden;
96
};
97

    
98
struct area_net
99
{
100
  struct fib_node fn;
101
  int hidden;
102
  int active;
103
  u32 metric;
104
};
105

    
106
struct ospf_stubnet_config
107
{
108
  node n;
109
  struct prefix px;
110
  int hidden, summary;
111
  u32 cost;
112
};
113

    
114
struct ospf_area_config
115
{
116
  node n;
117
  u32 areaid;
118
  int stub;
119
  list patt_list;
120
  list vlink_list;
121
  list net_list;
122
  list stubnet_list;
123
};
124

    
125

    
126
/* Option flags */
127

    
128
#define OPT_E        0x02
129
#define OPT_N        0x08
130
#define OPT_DC        0x20
131

    
132
#ifdef OSPFv2
133
#define OPT_EA        0x10
134

    
135
/* VEB flags are are stored independently in 'u16 options' */
136
#define OPT_RT_B  (0x01 << 8)
137
#define OPT_RT_E  (0x02 << 8)
138
#define OPT_RT_V  (0x04 << 8)
139
#endif
140

    
141
#ifdef OSPFv3
142
#define OPT_V6        0x01
143
#define OPT_R        0x10
144

    
145
/* VEB flags are are stored together with options in 'u32 options' */
146
#define OPT_RT_B  (0x01 << 24)
147
#define OPT_RT_E  (0x02 << 24)
148
#define OPT_RT_V  (0x04 << 24)
149
#define OPT_RT_NT (0x10 << 24)
150

    
151
#define OPT_PX_NU 0x01
152
#define OPT_PX_LA 0x02
153
#define OPT_PX_P  0x08
154
#define OPT_PX_DN 0x10
155
#endif
156

    
157

    
158
struct ospf_iface
159
{
160
  node n;
161
  struct iface *iface;                /* Nest's iface */
162
  struct ifa *addr;
163
  struct ospf_area *oa;
164
  struct object_lock *lock;
165
  sock *sk;                        /* IP socket (for DD ...) */
166
  list neigh_list;                /* List of neigbours */
167
  u32 cost;                        /* Cost of iface */
168
  u32 waitint;                        /* number of sec before changing state from wait */
169
  u32 rxmtint;                        /* number of seconds between LSA retransmissions */
170
  u32 pollint;                        /* Poll interval */
171
  u32 dead;                        /* after "deadint" missing hellos is router dead */
172
  u32 vid;                        /* Id of peer of virtual link */
173
  ip_addr vip;                        /* IP of peer of virtual link */
174
  struct ospf_iface *vifa;        /* OSPF iface which the vlink goes through */
175
  struct ospf_area *voa;        /* OSPF area which the vlink goes through */
176
  u16 inftransdelay;                /* The estimated number of seconds it takes to
177
                                   transmit a Link State Update Packet over this
178
                                   interface.  LSAs contained in the update */
179
  u16 helloint;                        /* number of seconds between hello sending */
180

    
181
#ifdef OSPFv2
182
  list *passwords;
183
  u16 autype;
184
  u32 csn;                      /* Last used crypt seq number */
185
  bird_clock_t csn_use;         /* Last time when packet with that CSN was sent */
186
#endif
187

    
188
  ip_addr drip;                        /* Designated router */
189
  u32 drid;
190
  ip_addr bdrip;                /* Backup DR */
191
  u32 bdrid;
192

    
193
#ifdef OSPFv3
194
  u32 dr_iface_id;                /* if drid is valid, this is iface_id of DR (for connecting network) */
195
  u8 instance_id;                /* Used to differentiate between more OSPF
196
                                   instances on one interface */
197
#endif
198

    
199
  u8 type;                        /* OSPF view of type */
200
#define OSPF_IT_BCAST 0
201
#define OSPF_IT_NBMA 1
202
#define OSPF_IT_PTP 2
203
#define OSPF_IT_VLINK 3
204
#define OSPF_IT_UNDEF 4
205
  u8 strictnbma;                /* Can I talk with unknown neighbors? */
206
  u8 stub;                        /* Inactive interface */
207
  u8 state;                        /* Interface state machine */
208
#define OSPF_IS_DOWN 0                /* Not working */
209
#define OSPF_IS_LOOP 1                /* Should never happen */
210
#define OSPF_IS_WAITING 2        /* Waiting for Wait timer */
211
#define OSPF_IS_PTP 3                /* PTP operational */
212
#define OSPF_IS_DROTHER 4        /* I'm on BCAST or NBMA and I'm not DR */
213
#define OSPF_IS_BACKUP 5        /* I'm BDR */
214
#define OSPF_IS_DR 6                /* I'm DR */
215
  timer *wait_timer;                /* WAIT timer */
216
  timer *hello_timer;                /* HELLOINT timer */
217
  timer *poll_timer;                /* Poll Interval - for NBMA */
218
/* Default values for interface parameters */
219
#define COST_D 10
220
#define RXMTINT_D 5
221
#define INFTRANSDELAY_D 1
222
#define PRIORITY_D 1
223
#define HELLOINT_D 10
224
#define POLLINT_D 20
225
#define DEADC_D 4
226
#define WAIT_DMH 4                
227
  /* Value of Wait timer - not found it in RFC * - using 4*HELLO */
228

    
229
  struct top_hash_entry *net_lsa;        /* Originated network LSA */
230
  int orignet;                                /* Schedule network LSA origination */
231
#ifdef OSPFv3
232
  int origlink;                                /* Schedule link LSA origination */
233
  struct top_hash_entry *link_lsa;        /* Originated link LSA */
234
  struct top_hash_entry *pxn_lsa;        /* Originated prefix LSA */
235
#endif
236
  int fadj;                                /* Number of full adjacent neigh */
237
  list nbma_list;
238
  u8 priority;                        /* A router priority for DR election */
239
  u8 ioprob;
240
#define OSPF_I_OK 0                /* Everything OK */
241
#define OSPF_I_SK 1                /* Socket open failed */
242
#define OSPF_I_LL 2                /* Missing link-local address (OSPFv3) */
243
  u8 sk_spf;                        /* Socket is a member of SPFRouters group */
244
  u8 sk_dr;                         /* Socket is a member of DRouters group */
245
  u32 rxbuf;
246
};
247

    
248
struct ospf_md5
249
{
250
  u16 zero;
251
  u8 keyid;
252
  u8 len;
253
  u32 csn;
254
};
255

    
256
union ospf_auth
257
{
258
  u8 password[8];
259
  struct ospf_md5 md5;
260
};
261

    
262

    
263
/* Packet types */
264
#define HELLO_P 1                /* Hello */
265
#define DBDES_P 2                /* Database description */
266
#define LSREQ_P 3                /* Link state request */
267
#define LSUPD_P 4                /* Link state update */
268
#define LSACK_P 5                /* Link state acknowledgement */
269

    
270
/* Area IDs */
271
#define BACKBONE 0
272

    
273

    
274
struct immsb
275
{
276
#ifdef CPU_BIG_ENDIAN
277
  u8 padding:5;
278
  u8 i:1;
279
  u8 m:1;
280
  u8 ms:1;
281
#else
282
  u8 ms:1;
283
  u8 m:1;
284
  u8 i:1;
285
  u8 padding:5;
286
#endif
287
};
288

    
289
union imms
290
{
291
  u8 byte;
292
  struct immsb bit;
293
};
294
#define DBDES_MS 1
295
#define DBDES_M 2
296
#define DBDES_I 4
297

    
298

    
299
#ifdef OSPFv2
300

    
301
struct ospf_packet
302
{
303
  u8 version;
304
  u8 type;
305
  u16 length;
306
  u32 routerid;
307
  u32 areaid;
308
  u16 checksum;
309
  u16 autype;
310
  union ospf_auth u;
311
};
312

    
313

    
314
#else /* OSPFv3 packet descriptions */
315

    
316
struct ospf_packet
317
{
318
  u8 version;
319
  u8 type;
320
  u16 length;
321
  u32 routerid;
322
  u32 areaid;
323
  u16 checksum;
324
  u8 instance_id;
325
  u8 zero;
326
};
327

    
328

    
329
#endif
330

    
331

    
332

    
333

    
334
struct ospf_lsa_header
335
{
336
  u16 age;                        /* LS Age */
337
#define LSA_MAXAGE 3600                /* 1 hour */
338
#define LSA_CHECKAGE 300        /* 5 minutes */
339
#define LSA_MAXAGEDIFF 900        /* 15 minutes */
340

    
341
#ifdef OSPFv2
342
  u8 options;
343
  u8 type;
344

    
345
#define LSA_T_RT        1
346
#define LSA_T_NET        2
347
#define LSA_T_SUM_NET        3
348
#define LSA_T_SUM_RT        4
349
#define LSA_T_EXT        5
350

    
351
#define LSA_SCOPE_AREA        0x2000
352
#define LSA_SCOPE_AS        0x4000
353

    
354
#define LSA_SCOPE(lsa)        (((lsa)->type == LSA_T_EXT) ? LSA_SCOPE_AS : LSA_SCOPE_AREA)
355

    
356
#else /* OSPFv3 */
357
  u16 type;
358

    
359
#define LSA_T_RT        0x2001
360
#define LSA_T_NET        0x2002
361
#define LSA_T_SUM_NET        0x2003
362
#define LSA_T_SUM_RT        0x2004
363
#define LSA_T_EXT        0x4005
364
#define LSA_T_LINK        0x0008
365
#define LSA_T_PREFIX        0x2009
366

    
367
#define LSA_UBIT        0x8000
368

    
369
#define LSA_SCOPE_LINK        0x0000
370
#define LSA_SCOPE_AREA        0x2000
371
#define LSA_SCOPE_AS        0x4000
372
#define LSA_SCOPE_RES        0x6000
373
#define LSA_SCOPE_MASK        0x6000
374

    
375
#define LSA_SCOPE(lsa)        ((lsa)->type & LSA_SCOPE_MASK)
376
#endif
377

    
378
  u32 id;
379
  u32 rt;                        /* Advertising router */
380
  s32 sn;                        /* LS Sequence number */
381
#define LSA_INITSEQNO ((s32) 0x80000001)
382
#define LSA_MAXSEQNO ((s32) 0x7fffffff)
383
  u16 checksum;
384
  u16 length;
385
};
386

    
387

    
388
#define LSART_PTP 1
389
#define LSART_NET 2
390
#define LSART_STUB 3
391
#define LSART_VLNK 4
392

    
393

    
394
#ifdef OSPFv2
395

    
396
struct ospf_lsa_rt
397
{
398
#ifdef CPU_BIG_ENDIAN
399
  u16 options;        /* VEB flags only */
400
  u16 links;
401
#else
402
  u16 links;
403
  u16 options;        /* VEB flags only */
404
#endif
405
};
406

    
407
struct ospf_lsa_rt_link
408
{
409
  u32 id;
410
  u32 data;
411
#ifdef CPU_BIG_ENDIAN
412
  u8 type;
413
  u8 padding;
414
  u16 metric;
415
#else
416
  u16 metric;
417
  u8 padding;
418
  u8 type;
419
#endif
420
};
421

    
422
struct ospf_lsa_net
423
{
424
  ip_addr netmask;
425
  u32 routers[];
426
};
427

    
428
struct ospf_lsa_sum
429
{
430
  ip_addr netmask;
431
  u32 metric;
432
};
433

    
434
struct ospf_lsa_ext
435
{
436
  ip_addr netmask;
437
  u32 metric;
438
  ip_addr fwaddr;
439
  u32 tag;
440
};
441

    
442
#define LSA_SUM_TOS  0xFF000000
443
#define LSA_EXT_TOS  0x7F000000
444
#define LSA_EXT_EBIT 0x80000000
445

    
446
/* Endianity swap for lsa->type */
447
#define ntoht(x) x
448
#define htont(x) x
449

    
450

    
451
#else  /* OSPFv3 */
452

    
453
struct ospf_lsa_rt
454
{
455
  u32 options;
456
};
457

    
458
struct ospf_lsa_rt_link
459
{
460
#ifdef CPU_BIG_ENDIAN
461
  u8 type;
462
  u8 padding;
463
  u16 metric;
464
#else
465
  u16 metric;
466
  u8 padding;
467
  u8 type;
468
#endif
469
  u32 lif;        /* Local interface ID */
470
  u32 nif;        /* Neighbor interface ID */
471
  u32 id;        /* Neighbor router ID */
472
};
473

    
474
struct ospf_lsa_net
475
{
476
  u32 options;
477
  u32 routers[];
478
};
479

    
480
struct ospf_lsa_sum_net
481
{
482
  u32 metric;
483
  u32 prefix[];
484
};
485

    
486
struct ospf_lsa_sum_rt
487
{
488
  u32 options;
489
  u32 metric;
490
  u32 drid;
491
};
492

    
493
struct ospf_lsa_ext
494
{
495
  u32 metric;
496
  u32 rest[];
497
};
498

    
499
struct ospf_lsa_link
500
{
501
  u32 options;
502
  ip_addr lladdr;
503
  u32 pxcount;
504
  u32 rest[];
505
};
506

    
507
struct ospf_lsa_prefix
508
{
509
#ifdef CPU_BIG_ENDIAN
510
  u16 pxcount;
511
  u16 ref_type;
512
#else
513
  u16 ref_type;
514
  u16 pxcount;
515
#endif
516
  u32 ref_id;
517
  u32 ref_rt;
518
  u32 rest[];
519
};
520

    
521
#define LSA_EXT_EBIT 0x4000000
522
#define LSA_EXT_FBIT 0x2000000
523
#define LSA_EXT_TBIT 0x1000000
524

    
525
/* Endianity swap for lsa->type */
526
#define ntoht(x) ntohs(x)
527
#define htont(x) htons(x)
528

    
529
#endif
530

    
531
#define METRIC_MASK  0x00FFFFFF
532
#define OPTIONS_MASK 0x00FFFFFF
533

    
534
static inline unsigned
535
lsa_rt_count(struct ospf_lsa_header *lsa)
536
{
537
  return (lsa->length - sizeof(struct ospf_lsa_header) - sizeof(struct ospf_lsa_rt))
538
    / sizeof(struct ospf_lsa_rt_link);
539
}
540

    
541
static inline unsigned
542
lsa_net_count(struct ospf_lsa_header *lsa)
543
{
544
  return (lsa->length - sizeof(struct ospf_lsa_header) - sizeof(struct ospf_lsa_net))
545
    / sizeof(u32);
546
}
547

    
548

    
549
#ifdef OSPFv3
550

    
551
#define IPV6_PREFIX_SPACE(x) ((((x) + 63) / 32) * 4)
552
#define IPV6_PREFIX_WORDS(x) (((x) + 63) / 32)
553

    
554
static inline u32 *
555
lsa_get_ipv6_prefix(u32 *buf, ip_addr *addr, int *pxlen, u8 *pxopts, u16 *rest)
556
{
557
  u8 pxl = (*buf >> 24);
558
  *pxopts = (*buf >> 16);
559
  *rest = *buf;
560
  *pxlen = pxl;
561
  buf++;
562

    
563
  *addr = IPA_NONE;
564

    
565
  if (pxl > 0)
566
    _I0(*addr) = *buf++;
567
  if (pxl > 32)
568
    _I1(*addr) = *buf++;
569
  if (pxl > 64)
570
    _I2(*addr) = *buf++;
571
  if (pxl > 96)
572
    _I3(*addr) = *buf++;
573

    
574
  return buf;
575
}
576

    
577
static inline u32 *
578
lsa_get_ipv6_addr(u32 *buf, ip_addr *addr)
579
{
580
  *addr = *(ip_addr *) buf;
581
  return buf + 4;
582
}
583

    
584
static inline u32 *
585
put_ipv6_prefix(u32 *buf, ip_addr addr, u8 pxlen, u8 pxopts, u16 lh)
586
{
587
  *buf++ = ((pxlen << 24) | (pxopts << 16) | lh);
588

    
589
  if (pxlen > 0)
590
    *buf++ = _I0(addr);
591
  if (pxlen > 32)
592
    *buf++ = _I1(addr);
593
  if (pxlen > 64)
594
    *buf++ = _I2(addr);
595
  if (pxlen > 96)
596
    *buf++ = _I3(addr);
597
  return buf;
598
}
599

    
600
static inline u32 *
601
put_ipv6_addr(u32 *buf, ip_addr addr)
602
{
603
  *(ip_addr *) buf = addr;
604
  return buf + 4;
605
}
606

    
607
#endif
608

    
609

    
610

    
611
struct ospf_lsreq_header
612
{
613
  u32 type;
614
  u32 id;
615
  u32 rt;                        /* Advertising router */
616
};
617

    
618
struct l_lsr_head
619
{
620
  node n;
621
  struct ospf_lsreq_header lsh;
622
};
623

    
624

    
625
struct ospf_neighbor
626
{
627
  node n;
628
  pool *pool;
629
  struct ospf_iface *ifa;
630
  u8 state;
631
#define NEIGHBOR_DOWN 0
632
#define NEIGHBOR_ATTEMPT 1
633
#define NEIGHBOR_INIT 2
634
#define NEIGHBOR_2WAY 3
635
#define NEIGHBOR_EXSTART 4
636
#define NEIGHBOR_EXCHANGE 5
637
#define NEIGHBOR_LOADING 6
638
#define NEIGHBOR_FULL 7
639
  timer *inactim;                /* Inactivity timer */
640
  union imms imms;                /* I, M, Master/slave received */
641
  u32 dds;                        /* DD Sequence number being sent */
642
  u32 ddr;                        /* last Dat Des packet received */
643
  union imms myimms;                /* I, M Master/slave */
644
  u32 rid;                        /* Router ID */
645
  ip_addr ip;                        /* IP of it's interface */
646
  u8 priority;                        /* Priority */
647
  u8 adj;                        /* built adjacency? */
648
  u32 options;                        /* Options received */
649

    
650
  /* dr and bdr store IP address in OSPFv2 and router ID in OSPFv3,
651
     we use the same type to simplify handling */
652
  u32 dr;                        /* Neigbour's idea of DR */
653
  u32 bdr;                        /* Neigbour's idea of BDR */
654

    
655
#ifdef OSPFv3
656
  u32 iface_id;                        /* ID of Neighbour's iface connected to common network */
657
#endif
658

    
659
  siterator dbsi;                /* Database summary list iterator */
660
  slist lsrql;                        /* Link state request */
661
  struct top_graph *lsrqh;        /* LSA graph */
662
  siterator lsrqi;
663
  slist lsrtl;                        /* Link state retransmission list */
664
  siterator lsrti;
665
  struct top_graph *lsrth;
666
  void *ldbdes;                        /* Last database description packet */
667
  timer *rxmt_timer;                /* RXMT timer */
668
  list ackl[2];
669
#define ACKL_DIRECT 0
670
#define ACKL_DELAY 1
671
  timer *ackd_timer;                /* Delayed ack timer */
672
  u32 csn;                      /* Last received crypt seq number (for MD5) */
673
};
674

    
675
/* Definitions for interface state machine */
676
#define ISM_UP 0                /* Interface Up */
677
#define ISM_WAITF 1                /* Wait timer fired */
678
#define ISM_BACKS 2                /* Backup seen */
679
#define ISM_NEICH 3                /* Neighbor change */
680
// #define ISM_LOOP 4                /* Loop indicated */
681
// #define ISM_UNLOOP 5                /* Unloop indicated */
682
#define ISM_DOWN 6                /* Interface down */
683

    
684
/* Definitions for neighbor state machine */
685
#define INM_HELLOREC 0                /* Hello Received */
686
#define INM_START 1                /* Neighbor start - for NBMA */
687
#define INM_2WAYREC 2                /* 2-Way received */
688
#define INM_NEGDONE 3                /* Negotiation done */
689
#define INM_EXDONE 4                /* Exchange done */
690
#define INM_BADLSREQ 5                /* Bad LS Request */
691
#define INM_LOADDONE 6                /* Load done */
692
#define INM_ADJOK 7                /* AdjOK? */
693
#define INM_SEQMIS 8                /* Sequence number mismatch */
694
#define INM_1WAYREC 9                /* 1-Way */
695
#define INM_KILLNBR 10                /* Kill Neighbor */
696
#define INM_INACTTIM 11                /* Inactivity timer */
697
#define INM_LLDOWN 12                /* Line down */
698

    
699
struct ospf_area
700
{
701
  node n;
702
  u32 areaid;
703
  struct ospf_area_config *ac;        /* Related area config */
704
  int origrt;                        /* Rt lsa origination scheduled? */
705
  struct top_hash_entry *rt;        /* My own router LSA */
706
  struct top_hash_entry *pxr_lsa; /* Originated prefix LSA */
707
  list cand;                        /* List of candidates for RT calc. */
708
  struct fib net_fib;                /* Networks to advertise or not */
709
  unsigned stub;
710
  int trcap;                        /* Transit capability? */
711
  u32 options;                        /* Optional features */
712
  struct proto_ospf *po;
713
  struct fib rtr;                /* Routing tables for routers */
714
};
715

    
716
struct proto_ospf
717
{
718
  struct proto proto;
719
  timer *disp_timer;                /* OSPF proto dispatcher */
720
  unsigned tick;
721
  struct top_graph *gr;                /* LSA graph */
722
  slist lsal;                        /* List of all LSA's */
723
  int calcrt;                        /* Routing table calculation scheduled?
724
                                   0=no, 1=normal, 2=forced reload */
725
  int cleanup;                  /* Should I cleanup after RT calculation? */
726
  list iface_list;                /* Interfaces we really use */
727
  list area_list;
728
  int areano;                        /* Number of area I belong to */
729
  struct fib rtf;                /* Routing table */
730
  int rfc1583;                        /* RFC1583 compatibility */
731
  int ebit;                        /* Did I originate any ext lsa? */
732
  struct ospf_area *backbone;        /* If exists */
733
  void *lsab;                        /* LSA buffer used when originating router LSAs */
734
  int lsab_size, lsab_used;
735
  u32 router_id;
736
};
737

    
738
struct ospf_iface_patt
739
{
740
  struct iface_patt i;
741
  u32 cost;
742
  u32 helloint;
743
  u32 rxmtint;
744
  u32 pollint;
745
  u32 inftransdelay;
746
  u32 priority;
747
  u32 waitint;
748
  u32 deadc;
749
  u32 dead;
750
  u32 type;
751
  u32 strictnbma;
752
  u32 stub;
753
  u32 vid;
754
  u32 rxbuf;
755
#define OSPF_RXBUF_NORMAL 0
756
#define OSPF_RXBUF_LARGE 1
757
#define OSPF_RXBUF_MINSIZE 256        /* Minimal allowed size */
758
  list nbma_list;
759

    
760
  u32 autype;                          /* Not really used in OSPFv3 */
761
#define OSPF_AUTH_NONE 0
762
#define OSPF_AUTH_SIMPLE 1
763
#define OSPF_AUTH_CRYPT 2
764
#define OSPF_AUTH_CRYPT_SIZE 16
765

    
766
#ifdef OSPFv2
767
  list *passwords;
768
#endif
769

    
770
#ifdef OSPFv3
771
  u8 instance_id;
772
#endif
773
};
774

    
775
#if defined(OSPFv2) && !defined(CONFIG_MC_PROPER_SRC)
776
static inline int
777
ospf_iface_stubby(struct ospf_iface_patt *ip, struct ifa *addr)
778
{
779
  /*
780
   * We cannot properly support multiple OSPF ifaces on real iface
781
   * with multiple prefixes, therefore we force OSPF ifaces with
782
   * non-primary IP prefixes to be stub.
783
   */
784
  return ip->stub || !(addr->flags & IA_PRIMARY);
785
}
786
#else
787
static inline int
788
ospf_iface_stubby(struct ospf_iface_patt *ip, struct ifa *addr UNUSED)
789
{
790
  return ip->stub;
791
}
792
#endif
793

    
794
int ospf_import_control(struct proto *p, rte **new, ea_list **attrs,
795
                        struct linpool *pool);
796
struct ea_list *ospf_make_tmp_attrs(struct rte *rt, struct linpool *pool);
797
void ospf_store_tmp_attrs(struct rte *rt, struct ea_list *attrs);
798
void schedule_rt_lsa(struct ospf_area *oa);
799
void schedule_rtcalc(struct proto_ospf *po);
800
void schedule_net_lsa(struct ospf_iface *ifa);
801

    
802
#ifdef OSPFv3
803
void schedule_link_lsa(struct ospf_iface *ifa);
804
#else
805
static inline void schedule_link_lsa(struct ospf_iface *ifa UNUSED) {}
806
#endif
807

    
808
void ospf_sh_neigh(struct proto *p, char *iff);
809
void ospf_sh(struct proto *p);
810
void ospf_sh_iface(struct proto *p, char *iff);
811
void ospf_sh_state(struct proto *p, int verbose);
812
void ospf_sh_lsadb(struct proto *p);
813

    
814

    
815
#define EA_OSPF_METRIC1        EA_CODE(EAP_OSPF, 0)
816
#define EA_OSPF_METRIC2        EA_CODE(EAP_OSPF, 1)
817
#define EA_OSPF_TAG        EA_CODE(EAP_OSPF, 2)
818
#define EA_OSPF_ROUTER_ID EA_CODE(EAP_OSPF, 3)
819

    
820
#include "proto/ospf/rt.h"
821
#include "proto/ospf/hello.h"
822
#include "proto/ospf/packet.h"
823
#include "proto/ospf/iface.h"
824
#include "proto/ospf/neighbor.h"
825
#include "proto/ospf/topology.h"
826
#include "proto/ospf/dbdes.h"
827
#include "proto/ospf/lsreq.h"
828
#include "proto/ospf/lsupd.h"
829
#include "proto/ospf/lsack.h"
830
#include "proto/ospf/lsalib.h"
831

    
832
#endif /* _BIRD_OSPF_H_ */