Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (17.2 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 ospf_area *oa;
163
  struct object_lock *lock;
164
  sock *sk;                        /* IP socket (for DD ...) */
165
  list neigh_list;                /* List of neigbours */
166
  u32 cost;                        /* Cost of iface */
167
  u32 waitint;                        /* number of sec before changing state from wait */
168
  u32 rxmtint;                        /* number of seconds between LSA retransmissions */
169
  u32 pollint;                        /* Poll interval */
170
  u32 dead;                        /* after "deadint" missing hellos is router dead */
171
  u32 vid;                        /* Id of peer of virtual link */
172
  ip_addr vip;                        /* IP of peer of virtual link */
173
  struct ospf_area *voa;        /* Area wich the vlink goes through */
174
  u16 inftransdelay;                /* The estimated number of seconds it takes to
175
                                   transmit a Link State Update Packet over this
176
                                   interface.  LSAs contained in the update */
177
  u16 helloint;                        /* number of seconds between hello sending */
178

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

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

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

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

    
231
  struct top_hash_entry *net_lsa;        /* Originated network LSA */
232
  int orignet;                                /* Schedule network LSA origination */
233
#ifdef OSPFv3
234
  int origlink;                                /* Schedule link LSA origination */
235
  struct top_hash_entry *link_lsa;        /* Originated link LSA */
236
  struct top_hash_entry *pxn_lsa;        /* Originated prefix LSA */
237
#endif
238
  int fadj;                                /* Number of full adjacent neigh */
239
  list nbma_list;
240
  u8 priority;                                /* A router priority for DR election */
241
  u8 ioprob;
242
  u8 dr_up;                                /* Socket is a member of DRouters group */
243
  u32 rxbuf;
244
};
245

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

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

    
260

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

    
268
/* Area IDs */
269
#define BACKBONE 0
270

    
271

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

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

    
296

    
297
#ifdef OSPFv2
298

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

    
311

    
312
#else /* OSPFv3 packet descriptions */
313

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

    
326

    
327
#endif
328

    
329

    
330

    
331

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

    
339
#ifdef OSPFv2
340
  u8 options;
341
  u8 type;
342

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

    
349
#define LSA_SCOPE_AREA        0x2000
350
#define LSA_SCOPE_AS        0x4000
351

    
352
#define LSA_SCOPE(lsa)        (((lsa)->type == LSA_T_EXT) ? LSA_SCOPE_AS : LSA_SCOPE_AREA)
353

    
354
#else /* OSPFv3 */
355
  u16 type;
356

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

    
365
#define LSA_UBIT        0x8000
366

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

    
373
#define LSA_SCOPE(lsa)        ((lsa)->type & LSA_SCOPE_MASK)
374
#endif
375

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

    
385

    
386
#define LSART_PTP 1
387
#define LSART_NET 2
388
#define LSART_STUB 3
389
#define LSART_VLNK 4
390

    
391

    
392
#ifdef OSPFv2
393

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

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

    
420
struct ospf_lsa_net
421
{
422
  ip_addr netmask;
423
  u32 routers[];
424
};
425

    
426
struct ospf_lsa_sum
427
{
428
  ip_addr netmask;
429
  u32 metric;
430
};
431

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

    
440
#define LSA_SUM_TOS  0xFF000000
441
#define LSA_EXT_TOS  0x7F000000
442
#define LSA_EXT_EBIT 0x80000000
443

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

    
448

    
449
#else  /* OSPFv3 */
450

    
451
struct ospf_lsa_rt
452
{
453
  u32 options;
454
};
455

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

    
472
struct ospf_lsa_net
473
{
474
  u32 options;
475
  u32 routers[];
476
};
477

    
478
struct ospf_lsa_sum_net
479
{
480
  u32 metric;
481
  u32 prefix[];
482
};
483

    
484
struct ospf_lsa_sum_rt
485
{
486
  u32 options;
487
  u32 metric;
488
  u32 drid;
489
};
490

    
491
struct ospf_lsa_ext
492
{
493
  u32 metric;
494
  u32 rest[];
495
};
496

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

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

    
519
#define LSA_EXT_EBIT 0x4000000
520
#define LSA_EXT_FBIT 0x2000000
521
#define LSA_EXT_TBIT 0x1000000
522

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

    
527
#endif
528

    
529
#define METRIC_MASK  0x00FFFFFF
530
#define OPTIONS_MASK 0x00FFFFFF
531

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

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

    
546

    
547
#ifdef OSPFv3
548

    
549
#define IPV6_PREFIX_SPACE(x) ((((x) + 63) / 32) * 4)
550
#define IPV6_PREFIX_WORDS(x) (((x) + 63) / 32)
551

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

    
561
  *addr = IPA_NONE;
562

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

    
572
  return buf;
573
}
574

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

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

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

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

    
605
#endif
606

    
607

    
608

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

    
616
struct l_lsr_head
617
{
618
  node n;
619
  struct ospf_lsreq_header lsh;
620
};
621

    
622

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

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

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

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

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

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

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

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

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

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

    
764
#ifdef OSPFv2
765
  list *passwords;
766
#endif
767

    
768
#ifdef OSPFv3
769
  u8 instance_id;
770
#endif
771
};
772

    
773
int ospf_import_control(struct proto *p, rte **new, ea_list **attrs,
774
                        struct linpool *pool);
775
struct ea_list *ospf_make_tmp_attrs(struct rte *rt, struct linpool *pool);
776
void ospf_store_tmp_attrs(struct rte *rt, struct ea_list *attrs);
777
void schedule_rt_lsa(struct ospf_area *oa);
778
void schedule_rtcalc(struct proto_ospf *po);
779
void schedule_net_lsa(struct ospf_iface *ifa);
780

    
781
#ifdef OSPFv3
782
void schedule_link_lsa(struct ospf_iface *ifa);
783
#else
784
static inline void schedule_link_lsa(struct ospf_iface *ifa UNUSED) {}
785
#endif
786

    
787
void ospf_sh_neigh(struct proto *p, char *iff);
788
void ospf_sh(struct proto *p);
789
void ospf_sh_iface(struct proto *p, char *iff);
790
void ospf_sh_state(struct proto *p, int verbose);
791
void ospf_sh_lsadb(struct proto *p);
792

    
793

    
794
#define EA_OSPF_METRIC1        EA_CODE(EAP_OSPF, 0)
795
#define EA_OSPF_METRIC2        EA_CODE(EAP_OSPF, 1)
796
#define EA_OSPF_TAG        EA_CODE(EAP_OSPF, 2)
797
#define EA_OSPF_ROUTER_ID EA_CODE(EAP_OSPF, 3)
798

    
799
#include "proto/ospf/rt.h"
800
#include "proto/ospf/hello.h"
801
#include "proto/ospf/packet.h"
802
#include "proto/ospf/iface.h"
803
#include "proto/ospf/neighbor.h"
804
#include "proto/ospf/topology.h"
805
#include "proto/ospf/dbdes.h"
806
#include "proto/ospf/lsreq.h"
807
#include "proto/ospf/lsupd.h"
808
#include "proto/ospf/lsack.h"
809
#include "proto/ospf/lsalib.h"
810

    
811
#endif /* _BIRD_OSPF_H_ */