blob: b0a14ce29e9b13594ec602351ef6fb8841454f92 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
2 * OSPFd main header.
3 * Copyright (C) 1998, 99, 2000 Kunihiro Ishiguro, Toshiaki Takada
4 *
5 * This file is part of GNU Zebra.
6 *
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 */
22
23#ifndef _ZEBRA_OSPFD_H
24#define _ZEBRA_OSPFD_H
25
26#include "filter.h"
hasso343f5cc2005-03-25 19:48:40 +000027#include "log.h"
paul718e3742002-12-13 20:15:29 +000028
29#define OSPF_VERSION 2
30
31/* Default protocol, port number. */
32#ifndef IPPROTO_OSPFIGP
33#define IPPROTO_OSPFIGP 89
34#endif /* IPPROTO_OSPFIGP */
35
paul68980082003-03-25 05:07:42 +000036/* IP precedence. */
37#ifndef IPTOS_PREC_INTERNETCONTROL
38#define IPTOS_PREC_INTERNETCONTROL 0xC0
39#endif /* IPTOS_PREC_INTERNETCONTROL */
40
paul718e3742002-12-13 20:15:29 +000041/* VTY port number. */
42#define OSPF_VTY_PORT 2604
paul718e3742002-12-13 20:15:29 +000043
44/* IP TTL for OSPF protocol. */
45#define OSPF_IP_TTL 1
46#define OSPF_VL_IP_TTL 100
47
48/* Default configuration file name for ospfd. */
49#define OSPF_DEFAULT_CONFIG "ospfd.conf"
50
51/* Architectual Constants */
52#ifdef DEBUG
53#define OSPF_LS_REFRESH_TIME 60
54#else
55#define OSPF_LS_REFRESH_TIME 1800
56#endif
57#define OSPF_MIN_LS_INTERVAL 5
58#define OSPF_MIN_LS_ARRIVAL 1
59#define OSPF_LSA_MAXAGE 3600
60#define OSPF_CHECK_AGE 300
61#define OSPF_LSA_MAXAGE_DIFF 900
62#define OSPF_LS_INFINITY 0xffffff
63#define OSPF_DEFAULT_DESTINATION 0x00000000 /* 0.0.0.0 */
64#define OSPF_INITIAL_SEQUENCE_NUMBER 0x80000001
65#define OSPF_MAX_SEQUENCE_NUMBER 0x7fffffff
66
67#define OSPF_LSA_MAXAGE_CHECK_INTERVAL 30
paul464c8202003-06-22 08:32:35 +000068#define OSPF_NSSA_TRANS_STABLE_DEFAULT 40
paul718e3742002-12-13 20:15:29 +000069
70#define OSPF_ALLSPFROUTERS 0xe0000005 /* 224.0.0.5 */
71#define OSPF_ALLDROUTERS 0xe0000006 /* 224.0.0.6 */
72
hassobeebba72004-06-20 21:00:27 +000073/* XXX Where is this used? And why it was used only if compiled with
74 * NSSA support. */
paul718e3742002-12-13 20:15:29 +000075#define OSPF_LOOPer 0x7f000000 /* 127.0.0.0 */
paul718e3742002-12-13 20:15:29 +000076
77#define OSPF_AREA_BACKBONE 0x00000000 /* 0.0.0.0 */
78
79/* OSPF Authentication Type. */
80#define OSPF_AUTH_NULL 0
81#define OSPF_AUTH_SIMPLE 1
82#define OSPF_AUTH_CRYPTOGRAPHIC 2
83/* For Interface authentication setting default */
84#define OSPF_AUTH_NOTSET -1
85/* For the consumption and sanity of the command handler */
86/* DO NIOT REMOVE!!! Need to detect whether a value has
87 been given or not in VLink command handlers */
88#define OSPF_AUTH_CMD_NOTSEEN -2
89
90/* OSPF SPF timer values. */
pauld24f6e22005-10-21 09:23:12 +000091#define OSPF_SPF_DELAY_DEFAULT 200
92#define OSPF_SPF_HOLDTIME_DEFAULT 1000
93#define OSPF_SPF_MAX_HOLDTIME_DEFAULT 10000
paul718e3742002-12-13 20:15:29 +000094
95/* OSPF interface default values. */
96#define OSPF_OUTPUT_COST_DEFAULT 10
paul88d6cf32005-10-29 12:50:09 +000097#define OSPF_OUTPUT_COST_INFINITE UINT16_MAX
paul718e3742002-12-13 20:15:29 +000098#define OSPF_ROUTER_DEAD_INTERVAL_DEFAULT 40
paulf9ad9372005-10-21 00:45:17 +000099#define OSPF_ROUTER_DEAD_INTERVAL_MINIMAL 1
paul718e3742002-12-13 20:15:29 +0000100#define OSPF_HELLO_INTERVAL_DEFAULT 10
101#define OSPF_ROUTER_PRIORITY_DEFAULT 1
102#define OSPF_RETRANSMIT_INTERVAL_DEFAULT 5
103#define OSPF_TRANSMIT_DELAY_DEFAULT 1
104#define OSPF_DEFAULT_BANDWIDTH 10000 /* Kbps */
105
106#define OSPF_DEFAULT_REF_BANDWIDTH 100000 /* Kbps */
107
108#define OSPF_POLL_INTERVAL_DEFAULT 60
109#define OSPF_NEIGHBOR_PRIORITY_DEFAULT 0
110
vincentba682532005-09-29 13:52:57 +0000111#define OSPF_MTU_IGNORE_DEFAULT 0
paulf9ad9372005-10-21 00:45:17 +0000112#define OSPF_FAST_HELLO_DEFAULT 0
vincentba682532005-09-29 13:52:57 +0000113
paul718e3742002-12-13 20:15:29 +0000114/* OSPF options. */
115#define OSPF_OPTION_T 0x01 /* TOS. */
116#define OSPF_OPTION_E 0x02
117#define OSPF_OPTION_MC 0x04
118#define OSPF_OPTION_NP 0x08
119#define OSPF_OPTION_EA 0x10
120#define OSPF_OPTION_DC 0x20
121#define OSPF_OPTION_O 0x40
122
123/* OSPF Database Description flags. */
124#define OSPF_DD_FLAG_MS 0x01
125#define OSPF_DD_FLAG_M 0x02
126#define OSPF_DD_FLAG_I 0x04
127#define OSPF_DD_FLAG_ALL 0x07
128
paul718e3742002-12-13 20:15:29 +0000129#define OSPF_LS_REFRESH_SHIFT (60 * 15)
130#define OSPF_LS_REFRESH_JITTER 60
131
Denis Ovsienkob7fe4142007-08-21 16:32:56 +0000132/* Initial send buffer size for ospfd raw sending socket. */
133#define OSPF_SNDBUFLEN_DEFAULT 1024
134
paul020709f2003-04-04 02:44:16 +0000135/* OSPF master for system wide configuration and variables. */
136struct ospf_master
137{
138 /* OSPF instance. */
139 struct list *ospf;
140
141 /* OSPF thread master. */
142 struct thread_master *master;
143
144 /* Zebra interface list. */
145 struct list *iflist;
146
147 /* Redistributed external information. */
148 struct route_table *external_info[ZEBRA_ROUTE_MAX + 1];
149#define EXTERNAL_INFO(T) om->external_info[T]
150
151 /* OSPF start time. */
152 time_t start_time;
153
154 /* Various OSPF global configuration. */
155 u_char options;
paulc9c93d52005-11-26 13:31:11 +0000156#define OSPF_MASTER_SHUTDOWN (1 << 0) /* deferred-shutdown */
paul020709f2003-04-04 02:44:16 +0000157};
158
paul718e3742002-12-13 20:15:29 +0000159/* OSPF instance structure. */
160struct ospf
161{
162 /* OSPF Router ID. */
163 struct in_addr router_id; /* Configured automatically. */
164 struct in_addr router_id_static; /* Configured manually. */
165
166 /* ABR/ASBR internal flags. */
167 u_char flags;
168#define OSPF_FLAG_ABR 0x0001
169#define OSPF_FLAG_ASBR 0x0002
170
171 /* ABR type. */
172 u_char abr_type;
173#define OSPF_ABR_UNKNOWN 0
174#define OSPF_ABR_STAND 1
175#define OSPF_ABR_IBM 2
176#define OSPF_ABR_CISCO 3
177#define OSPF_ABR_SHORTCUT 4
pauld57834f2005-07-12 20:04:22 +0000178#define OSPF_ABR_DEFAULT OSPF_ABR_CISCO
paul718e3742002-12-13 20:15:29 +0000179
180 /* NSSA ABR */
181 u_char anyNSSA; /* Bump for every NSSA attached. */
182
183 /* Configured variables. */
184 u_char config;
185#define OSPF_RFC1583_COMPATIBLE (1 << 0)
186#define OSPF_OPAQUE_CAPABLE (1 << 2)
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +0000187#define OSPF_LOG_ADJACENCY_CHANGES (1 << 3)
188#define OSPF_LOG_ADJACENCY_DETAIL (1 << 4)
paul718e3742002-12-13 20:15:29 +0000189
190#ifdef HAVE_OPAQUE_LSA
191 /* Opaque-LSA administrative flags. */
192 u_char opaque;
193#define OPAQUE_OPERATION_READY_BIT (1 << 0)
194#define OPAQUE_BLOCK_TYPE_09_LSA_BIT (1 << 1)
195#define OPAQUE_BLOCK_TYPE_10_LSA_BIT (1 << 2)
196#define OPAQUE_BLOCK_TYPE_11_LSA_BIT (1 << 3)
197#endif /* HAVE_OPAQUE_LSA */
198
paul88d6cf32005-10-29 12:50:09 +0000199 /* RFC3137 stub router. Configured time to stay stub / max-metric */
200 unsigned int stub_router_startup_time; /* seconds */
201 unsigned int stub_router_shutdown_time; /* seconds */
202#define OSPF_STUB_ROUTER_UNCONFIGURED 0
paul88d6cf32005-10-29 12:50:09 +0000203
204 /* SPF parameters */
205 unsigned int spf_delay; /* SPF delay time. */
206 unsigned int spf_holdtime; /* SPF hold time. */
207 unsigned int spf_max_holdtime; /* SPF maximum-holdtime */
208 unsigned int spf_hold_multiplier; /* Adaptive multiplier for hold time */
209
paul718e3742002-12-13 20:15:29 +0000210 int default_originate; /* Default information originate. */
211#define DEFAULT_ORIGINATE_NONE 0
212#define DEFAULT_ORIGINATE_ZEBRA 1
213#define DEFAULT_ORIGINATE_ALWAYS 2
214 u_int32_t ref_bandwidth; /* Reference Bandwidth (Kbps). */
215 struct route_table *networks; /* OSPF config networks. */
hasso52dc7ee2004-09-23 19:18:23 +0000216 struct list *vlinks; /* Configured Virtual-Links. */
217 struct list *areas; /* OSPF areas. */
paul718e3742002-12-13 20:15:29 +0000218 struct route_table *nbr_nbma;
219 struct ospf_area *backbone; /* Pointer to the Backbone Area. */
220
hasso52dc7ee2004-09-23 19:18:23 +0000221 struct list *oiflist; /* ospf interfaces */
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000222 u_char passive_interface_default; /* passive-interface default */
paul718e3742002-12-13 20:15:29 +0000223
224 /* LSDB of AS-external-LSAs. */
225 struct ospf_lsdb *lsdb;
226
paul718e3742002-12-13 20:15:29 +0000227 /* Flags. */
228 int external_origin; /* AS-external-LSA origin flag. */
229 int ase_calc; /* ASE calculation flag. */
230
231#ifdef HAVE_OPAQUE_LSA
hasso52dc7ee2004-09-23 19:18:23 +0000232 struct list *opaque_lsa_self; /* Type-11 Opaque-LSAs */
paul718e3742002-12-13 20:15:29 +0000233#endif /* HAVE_OPAQUE_LSA */
234
235 /* Routing tables. */
236 struct route_table *old_table; /* Old routing table. */
237 struct route_table *new_table; /* Current routing table. */
238
239 struct route_table *old_rtrs; /* Old ABR/ASBR RT. */
240 struct route_table *new_rtrs; /* New ABR/ASBR RT. */
241
242 struct route_table *new_external_route; /* New External Route. */
243 struct route_table *old_external_route; /* Old External Route. */
244
245 struct route_table *external_lsas; /* Database of external LSAs,
246 prefix is LSA's adv. network*/
247
248 /* Time stamps. */
pauld24f6e22005-10-21 09:23:12 +0000249 struct timeval ts_spf; /* SPF calculation time stamp. */
paul718e3742002-12-13 20:15:29 +0000250
hasso52dc7ee2004-09-23 19:18:23 +0000251 struct list *maxage_lsa; /* List of MaxAge LSA for deletion. */
paul718e3742002-12-13 20:15:29 +0000252 int redistribute; /* Num of redistributed protocols. */
253
254 /* Threads. */
paul718e3742002-12-13 20:15:29 +0000255 struct thread *t_router_lsa_update; /* router-LSA update timer. */
256 struct thread *t_abr_task; /* ABR task timer. */
257 struct thread *t_asbr_check; /* ASBR check timer. */
258 struct thread *t_distribute_update; /* Distirbute list update timer. */
259 struct thread *t_spf_calc; /* SPF calculation timer. */
260 struct thread *t_ase_calc; /* ASE calculation timer. */
261 struct thread *t_external_lsa; /* AS-external-LSA origin timer. */
262#ifdef HAVE_OPAQUE_LSA
263 struct thread *t_opaque_lsa_self; /* Type-11 Opaque-LSAs origin event. */
264#endif /* HAVE_OPAQUE_LSA */
265 struct thread *t_maxage; /* MaxAge LSA remover timer. */
266 struct thread *t_maxage_walker; /* MaxAge LSA checking timer. */
paulc9c93d52005-11-26 13:31:11 +0000267 struct thread *t_deferred_shutdown; /* deferred/stub-router shutdown timer*/
paul718e3742002-12-13 20:15:29 +0000268
269 struct thread *t_write;
270 struct thread *t_read;
271 int fd;
Denis Ovsienkob7fe4142007-08-21 16:32:56 +0000272 int maxsndbuflen;
ajs5c333492005-02-23 15:43:01 +0000273 struct stream *ibuf;
hasso52dc7ee2004-09-23 19:18:23 +0000274 struct list *oi_write_q;
paul718e3742002-12-13 20:15:29 +0000275
276 /* Distribute lists out of other route sources. */
277 struct
278 {
279 char *name;
280 struct access_list *list;
281 } dlist[ZEBRA_ROUTE_MAX];
paul020709f2003-04-04 02:44:16 +0000282#define DISTRIBUTE_NAME(O,T) (O)->dlist[T].name
283#define DISTRIBUTE_LIST(O,T) (O)->dlist[T].list
paul718e3742002-12-13 20:15:29 +0000284
285 /* Redistribute metric info. */
286 struct
287 {
288 int type; /* External metric type (E1 or E2). */
289 int value; /* Value for static metric (24-bit).
290 -1 means metric value is not set. */
291 } dmetric [ZEBRA_ROUTE_MAX + 1];
292
293 /* For redistribute route map. */
294 struct
295 {
296 char *name;
297 struct route_map *map;
298 } route_map [ZEBRA_ROUTE_MAX + 1]; /* +1 is for default-information */
paul020709f2003-04-04 02:44:16 +0000299#define ROUTEMAP_NAME(O,T) (O)->route_map[T].name
300#define ROUTEMAP(O,T) (O)->route_map[T].map
paul718e3742002-12-13 20:15:29 +0000301
302 int default_metric; /* Default metric for redistribute. */
303
304#define OSPF_LSA_REFRESHER_GRANULARITY 10
305#define OSPF_LSA_REFRESHER_SLOTS ((OSPF_LS_REFRESH_TIME + \
306 OSPF_LS_REFRESH_SHIFT)/10 + 1)
307 struct
308 {
309 u_int16_t index;
hasso52dc7ee2004-09-23 19:18:23 +0000310 struct list *qs[OSPF_LSA_REFRESHER_SLOTS];
paul718e3742002-12-13 20:15:29 +0000311 } lsa_refresh_queue;
312
313 struct thread *t_lsa_refresher;
314 time_t lsa_refresher_started;
315#define OSPF_LSA_REFRESH_INTERVAL_DEFAULT 10
316 u_int16_t lsa_refresh_interval;
317
318 /* Distance parameter. */
319 u_char distance_all;
320 u_char distance_intra;
321 u_char distance_inter;
322 u_char distance_external;
323
324 /* Statistics for LSA origination. */
325 u_int32_t lsa_originate_count;
326
327 /* Statistics for LSA used for new instantiation. */
328 u_int32_t rx_lsa_count;
329
330 struct route_table *distance_table;
331};
332
333/* OSPF area structure. */
334struct ospf_area
335{
336 /* OSPF instance. */
paul68980082003-03-25 05:07:42 +0000337 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +0000338
339 /* Zebra interface list belonging to the area. */
hasso52dc7ee2004-09-23 19:18:23 +0000340 struct list *oiflist;
paul718e3742002-12-13 20:15:29 +0000341
342 /* Area ID. */
343 struct in_addr area_id;
344
345 /* Area ID format. */
346 char format;
347#define OSPF_AREA_ID_FORMAT_ADDRESS 1
348#define OSPF_AREA_ID_FORMAT_DECIMAL 2
349
350 /* Address range. */
hasso52dc7ee2004-09-23 19:18:23 +0000351 struct list *address_range;
paul718e3742002-12-13 20:15:29 +0000352
353 /* Configured variables. */
354 int external_routing; /* ExternalRoutingCapability. */
355#define OSPF_AREA_DEFAULT 0
356#define OSPF_AREA_STUB 1
357#define OSPF_AREA_NSSA 2
358#define OSPF_AREA_TYPE_MAX 3
359 int no_summary; /* Don't inject summaries into stub.*/
360 int shortcut_configured; /* Area configured as shortcut. */
361#define OSPF_SHORTCUT_DEFAULT 0
362#define OSPF_SHORTCUT_ENABLE 1
363#define OSPF_SHORTCUT_DISABLE 2
364 int shortcut_capability; /* Other ABRs agree on S-bit */
365 u_int32_t default_cost; /* StubDefaultCost. */
366 int auth_type; /* Authentication type. */
paul88d6cf32005-10-29 12:50:09 +0000367
paul718e3742002-12-13 20:15:29 +0000368
paul464c8202003-06-22 08:32:35 +0000369 u_char NSSATranslatorRole; /* NSSA configured role */
paul718e3742002-12-13 20:15:29 +0000370#define OSPF_NSSA_ROLE_NEVER 0
pauld4a53d52003-07-12 21:30:57 +0000371#define OSPF_NSSA_ROLE_CANDIDATE 1
372#define OSPF_NSSA_ROLE_ALWAYS 2
paul464c8202003-06-22 08:32:35 +0000373 u_char NSSATranslatorState; /* NSSA operational role */
pauld4a53d52003-07-12 21:30:57 +0000374#define OSPF_NSSA_TRANSLATE_DISABLED 0
375#define OSPF_NSSA_TRANSLATE_ENABLED 1
paul464c8202003-06-22 08:32:35 +0000376 int NSSATranslatorStabilityInterval;
377
paul718e3742002-12-13 20:15:29 +0000378 u_char transit; /* TransitCapability. */
379#define OSPF_TRANSIT_FALSE 0
380#define OSPF_TRANSIT_TRUE 1
381 struct route_table *ranges; /* Configured Area Ranges. */
paul88d6cf32005-10-29 12:50:09 +0000382
383 /* RFC3137 stub router state flags for area */
384 u_char stub_router_state;
385#define OSPF_AREA_ADMIN_STUB_ROUTED (1 << 0) /* admin stub-router set */
386#define OSPF_AREA_IS_STUB_ROUTED (1 << 1) /* stub-router active */
387#define OSPF_AREA_WAS_START_STUB_ROUTED (1 << 2) /* startup SR was done */
388
paul718e3742002-12-13 20:15:29 +0000389 /* Area related LSDBs[Type1-4]. */
390 struct ospf_lsdb *lsdb;
391
392 /* Self-originated LSAs. */
393 struct ospf_lsa *router_lsa_self;
394#ifdef HAVE_OPAQUE_LSA
hasso52dc7ee2004-09-23 19:18:23 +0000395 struct list *opaque_lsa_self; /* Type-10 Opaque-LSAs */
paul718e3742002-12-13 20:15:29 +0000396#endif /* HAVE_OPAQUE_LSA */
397
398 /* Area announce list. */
399 struct
400 {
401 char *name;
402 struct access_list *list;
403 } export;
404#define EXPORT_NAME(A) (A)->export.name
405#define EXPORT_LIST(A) (A)->export.list
406
407 /* Area acceptance list. */
408 struct
409 {
410 char *name;
411 struct access_list *list;
412 } import;
413#define IMPORT_NAME(A) (A)->import.name
414#define IMPORT_LIST(A) (A)->import.list
415
416 /* Type 3 LSA Area prefix-list. */
417 struct
418 {
419 char *name;
420 struct prefix_list *list;
421 } plist_in;
422#define PREFIX_LIST_IN(A) (A)->plist_in.list
423#define PREFIX_NAME_IN(A) (A)->plist_in.name
424
425 struct
426 {
427 char *name;
428 struct prefix_list *list;
429 } plist_out;
430#define PREFIX_LIST_OUT(A) (A)->plist_out.list
431#define PREFIX_NAME_OUT(A) (A)->plist_out.name
432
433 /* Shortest Path Tree. */
434 struct vertex *spf;
435
436 /* Threads. */
437 struct thread *t_router_lsa_self;/* Self-originated router-LSA timer. */
paul88d6cf32005-10-29 12:50:09 +0000438 struct thread *t_stub_router; /* Stub-router timer */
paul718e3742002-12-13 20:15:29 +0000439#ifdef HAVE_OPAQUE_LSA
440 struct thread *t_opaque_lsa_self; /* Type-10 Opaque-LSAs origin. */
441#endif /* HAVE_OPAQUE_LSA */
442
443 /* Statistics field. */
444 u_int32_t spf_calculation; /* SPF Calculation Count. */
445
446 /* Router count. */
447 u_int32_t abr_count; /* ABR router in this area. */
448 u_int32_t asbr_count; /* ASBR router in this area. */
449
450 /* Counters. */
451 u_int32_t act_ints; /* Active interfaces. */
452 u_int32_t full_nbrs; /* Fully adjacent neighbors. */
453 u_int32_t full_vls; /* Fully adjacent virtual neighbors. */
454};
455
456/* OSPF config network structure. */
457struct ospf_network
458{
459 /* Area ID. */
460 struct in_addr area_id;
461 int format;
462};
463
464/* OSPF NBMA neighbor structure. */
465struct ospf_nbr_nbma
466{
467 /* Neighbor IP address. */
468 struct in_addr addr;
469
470 /* OSPF interface. */
471 struct ospf_interface *oi;
472
473 /* OSPF neighbor structure. */
474 struct ospf_neighbor *nbr;
475
476 /* Neighbor priority. */
477 u_char priority;
478
479 /* Poll timer value. */
480 u_int32_t v_poll;
481
482 /* Poll timer thread. */
483 struct thread *t_poll;
484
485 /* State change. */
486 u_int32_t state_change;
487};
488
489/* Macro. */
490#define OSPF_AREA_SAME(X,Y) \
491 (memcmp ((X->area_id), (Y->area_id), IPV4_MAX_BYTELEN) == 0)
492
paul020709f2003-04-04 02:44:16 +0000493#define IS_OSPF_ABR(O) ((O)->flags & OSPF_FLAG_ABR)
494#define IS_OSPF_ASBR(O) ((O)->flags & OSPF_FLAG_ASBR)
paul718e3742002-12-13 20:15:29 +0000495
496#define OSPF_IS_AREA_ID_BACKBONE(I) ((I).s_addr == OSPF_AREA_BACKBONE)
497#define OSPF_IS_AREA_BACKBONE(A) OSPF_IS_AREA_ID_BACKBONE ((A)->area_id)
498
499#ifdef roundup
500# define ROUNDUP(val, gran) roundup(val, gran)
501#else /* roundup */
502# define ROUNDUP(val, gran) (((val) - 1 | (gran) - 1) + 1)
503#endif /* roundup */
504
505#define LSA_OPTIONS_GET(area) \
506 (((area)->external_routing == OSPF_AREA_DEFAULT) ? OSPF_OPTION_E : 0)
pauld4a53d52003-07-12 21:30:57 +0000507#define LSA_OPTIONS_NSSA_GET(area) \
508 (((area)->external_routing == OSPF_AREA_NSSA) ? OSPF_OPTION_NP : 0)
paul718e3742002-12-13 20:15:29 +0000509
510#define OSPF_TIMER_ON(T,F,V) \
511 do { \
512 if (!(T)) \
paul68980082003-03-25 05:07:42 +0000513 (T) = thread_add_timer (master, (F), ospf, (V)); \
paul718e3742002-12-13 20:15:29 +0000514 } while (0)
515
516#define OSPF_AREA_TIMER_ON(T,F,V) \
517 do { \
518 if (!(T)) \
519 (T) = thread_add_timer (master, (F), area, (V)); \
520 } while (0)
521
522#define OSPF_POLL_TIMER_ON(T,F,V) \
523 do { \
524 if (!(T)) \
525 (T) = thread_add_timer (master, (F), nbr_nbma, (V)); \
526 } while (0)
527
528#define OSPF_POLL_TIMER_OFF(X) OSPF_TIMER_OFF((X))
529
530#define OSPF_TIMER_OFF(X) \
531 do { \
532 if (X) \
533 { \
534 thread_cancel (X); \
535 (X) = NULL; \
536 } \
537 } while (0)
538
paul020709f2003-04-04 02:44:16 +0000539/* Extern variables. */
540extern struct ospf_master *om;
paul718e3742002-12-13 20:15:29 +0000541extern struct message ospf_ism_state_msg[];
542extern struct message ospf_nsm_state_msg[];
543extern struct message ospf_lsa_type_msg[];
544extern struct message ospf_link_state_id_type_msg[];
paul718e3742002-12-13 20:15:29 +0000545extern struct message ospf_network_type_msg[];
546extern int ospf_ism_state_msg_max;
547extern int ospf_nsm_state_msg_max;
548extern int ospf_lsa_type_msg_max;
549extern int ospf_link_state_id_type_msg_max;
550extern int ospf_redistributed_proto_max;
551extern int ospf_network_type_msg_max;
552extern struct zclient *zclient;
553extern struct thread_master *master;
paul718e3742002-12-13 20:15:29 +0000554extern int ospf_zlog;
555
556/* Prototypes. */
ajsf52d13c2005-10-01 17:38:06 +0000557extern const char *ospf_redist_string(u_int route_type);
paul4dadc292005-05-06 21:37:42 +0000558extern struct ospf *ospf_lookup (void);
559extern struct ospf *ospf_get (void);
560extern void ospf_finish (struct ospf *);
paul4dadc292005-05-06 21:37:42 +0000561extern void ospf_router_id_update (struct ospf *ospf);
562extern int ospf_network_match_iface (struct connected *, struct prefix *);
563extern int ospf_network_set (struct ospf *, struct prefix_ipv4 *,
564 struct in_addr);
565extern int ospf_network_unset (struct ospf *, struct prefix_ipv4 *,
566 struct in_addr);
567extern int ospf_area_stub_set (struct ospf *, struct in_addr);
568extern int ospf_area_stub_unset (struct ospf *, struct in_addr);
569extern int ospf_area_no_summary_set (struct ospf *, struct in_addr);
570extern int ospf_area_no_summary_unset (struct ospf *, struct in_addr);
571extern int ospf_area_nssa_set (struct ospf *, struct in_addr);
572extern int ospf_area_nssa_unset (struct ospf *, struct in_addr);
573extern int ospf_area_nssa_translator_role_set (struct ospf *, struct in_addr,
574 int);
575extern int ospf_area_export_list_set (struct ospf *, struct ospf_area *,
576 const char *);
577extern int ospf_area_export_list_unset (struct ospf *, struct ospf_area *);
578extern int ospf_area_import_list_set (struct ospf *, struct ospf_area *,
579 const char *);
580extern int ospf_area_import_list_unset (struct ospf *, struct ospf_area *);
581extern int ospf_area_shortcut_set (struct ospf *, struct ospf_area *, int);
582extern int ospf_area_shortcut_unset (struct ospf *, struct ospf_area *);
paul4dadc292005-05-06 21:37:42 +0000583extern int ospf_timers_refresh_set (struct ospf *, int);
584extern int ospf_timers_refresh_unset (struct ospf *);
585extern int ospf_nbr_nbma_set (struct ospf *, struct in_addr);
586extern int ospf_nbr_nbma_unset (struct ospf *, struct in_addr);
587extern int ospf_nbr_nbma_priority_set (struct ospf *, struct in_addr, u_char);
588extern int ospf_nbr_nbma_priority_unset (struct ospf *, struct in_addr);
589extern int ospf_nbr_nbma_poll_interval_set (struct ospf *, struct in_addr,
590 unsigned int);
591extern int ospf_nbr_nbma_poll_interval_unset (struct ospf *, struct in_addr);
592extern void ospf_prefix_list_update (struct prefix_list *);
593extern void ospf_init (void);
594extern void ospf_if_update (struct ospf *);
595extern void ospf_ls_upd_queue_empty (struct ospf_interface *);
596extern void ospf_terminate (void);
597extern void ospf_nbr_nbma_if_update (struct ospf *, struct ospf_interface *);
598extern struct ospf_nbr_nbma *ospf_nbr_nbma_lookup (struct ospf *,
599 struct in_addr);
600extern struct ospf_nbr_nbma *ospf_nbr_nbma_lookup_next (struct ospf *,
601 struct in_addr *,
602 int);
603extern int ospf_oi_count (struct interface *);
paul718e3742002-12-13 20:15:29 +0000604
paul4dadc292005-05-06 21:37:42 +0000605extern struct ospf_area *ospf_area_get (struct ospf *, struct in_addr, int);
606extern void ospf_area_check_free (struct ospf *, struct in_addr);
607extern struct ospf_area *ospf_area_lookup_by_area_id (struct ospf *,
608 struct in_addr);
609extern void ospf_area_add_if (struct ospf_area *, struct ospf_interface *);
610extern void ospf_area_del_if (struct ospf_area *, struct ospf_interface *);
paul718e3742002-12-13 20:15:29 +0000611
paul4dadc292005-05-06 21:37:42 +0000612extern void ospf_route_map_init (void);
613extern void ospf_snmp_init (void);
paul718e3742002-12-13 20:15:29 +0000614
paul4dadc292005-05-06 21:37:42 +0000615extern void ospf_master_init (void);
paul020709f2003-04-04 02:44:16 +0000616
paul718e3742002-12-13 20:15:29 +0000617#endif /* _ZEBRA_OSPFD_H */