blob: 0e57c4524e0a72c604e9733728d0c42bcf48ff23 [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
Jeremy Jacksonc514adc2009-01-23 15:48:10 -050026#include <zebra.h>
27
paul718e3742002-12-13 20:15:29 +000028#include "filter.h"
hasso343f5cc2005-03-25 19:48:40 +000029#include "log.h"
paul718e3742002-12-13 20:15:29 +000030
31#define OSPF_VERSION 2
32
33/* Default protocol, port number. */
34#ifndef IPPROTO_OSPFIGP
35#define IPPROTO_OSPFIGP 89
36#endif /* IPPROTO_OSPFIGP */
37
paul68980082003-03-25 05:07:42 +000038/* IP precedence. */
39#ifndef IPTOS_PREC_INTERNETCONTROL
40#define IPTOS_PREC_INTERNETCONTROL 0xC0
41#endif /* IPTOS_PREC_INTERNETCONTROL */
42
paul718e3742002-12-13 20:15:29 +000043/* VTY port number. */
44#define OSPF_VTY_PORT 2604
paul718e3742002-12-13 20:15:29 +000045
46/* IP TTL for OSPF protocol. */
47#define OSPF_IP_TTL 1
48#define OSPF_VL_IP_TTL 100
49
50/* Default configuration file name for ospfd. */
51#define OSPF_DEFAULT_CONFIG "ospfd.conf"
52
53/* Architectual Constants */
54#ifdef DEBUG
55#define OSPF_LS_REFRESH_TIME 60
56#else
57#define OSPF_LS_REFRESH_TIME 1800
58#endif
59#define OSPF_MIN_LS_INTERVAL 5
60#define OSPF_MIN_LS_ARRIVAL 1
Paul Jakma02d942c2010-01-24 23:36:20 +000061#define OSPF_LSA_INITIAL_AGE 0 /* useful for debug */
paul718e3742002-12-13 20:15:29 +000062#define OSPF_LSA_MAXAGE 3600
63#define OSPF_CHECK_AGE 300
64#define OSPF_LSA_MAXAGE_DIFF 900
65#define OSPF_LS_INFINITY 0xffffff
66#define OSPF_DEFAULT_DESTINATION 0x00000000 /* 0.0.0.0 */
67#define OSPF_INITIAL_SEQUENCE_NUMBER 0x80000001
68#define OSPF_MAX_SEQUENCE_NUMBER 0x7fffffff
69
paul464c8202003-06-22 08:32:35 +000070#define OSPF_NSSA_TRANS_STABLE_DEFAULT 40
paul718e3742002-12-13 20:15:29 +000071
72#define OSPF_ALLSPFROUTERS 0xe0000005 /* 224.0.0.5 */
73#define OSPF_ALLDROUTERS 0xe0000006 /* 224.0.0.6 */
74
hassobeebba72004-06-20 21:00:27 +000075/* XXX Where is this used? And why it was used only if compiled with
76 * NSSA support. */
paul718e3742002-12-13 20:15:29 +000077#define OSPF_LOOPer 0x7f000000 /* 127.0.0.0 */
paul718e3742002-12-13 20:15:29 +000078
79#define OSPF_AREA_BACKBONE 0x00000000 /* 0.0.0.0 */
80
81/* OSPF Authentication Type. */
82#define OSPF_AUTH_NULL 0
83#define OSPF_AUTH_SIMPLE 1
84#define OSPF_AUTH_CRYPTOGRAPHIC 2
85/* For Interface authentication setting default */
86#define OSPF_AUTH_NOTSET -1
87/* For the consumption and sanity of the command handler */
88/* DO NIOT REMOVE!!! Need to detect whether a value has
89 been given or not in VLink command handlers */
90#define OSPF_AUTH_CMD_NOTSEEN -2
91
92/* OSPF SPF timer values. */
pauld24f6e22005-10-21 09:23:12 +000093#define OSPF_SPF_DELAY_DEFAULT 200
94#define OSPF_SPF_HOLDTIME_DEFAULT 1000
95#define OSPF_SPF_MAX_HOLDTIME_DEFAULT 10000
paul718e3742002-12-13 20:15:29 +000096
97/* OSPF interface default values. */
98#define OSPF_OUTPUT_COST_DEFAULT 10
paul88d6cf32005-10-29 12:50:09 +000099#define OSPF_OUTPUT_COST_INFINITE UINT16_MAX
paul718e3742002-12-13 20:15:29 +0000100#define OSPF_ROUTER_DEAD_INTERVAL_DEFAULT 40
paulf9ad9372005-10-21 00:45:17 +0000101#define OSPF_ROUTER_DEAD_INTERVAL_MINIMAL 1
paul718e3742002-12-13 20:15:29 +0000102#define OSPF_HELLO_INTERVAL_DEFAULT 10
103#define OSPF_ROUTER_PRIORITY_DEFAULT 1
104#define OSPF_RETRANSMIT_INTERVAL_DEFAULT 5
105#define OSPF_TRANSMIT_DELAY_DEFAULT 1
106#define OSPF_DEFAULT_BANDWIDTH 10000 /* Kbps */
107
108#define OSPF_DEFAULT_REF_BANDWIDTH 100000 /* Kbps */
109
110#define OSPF_POLL_INTERVAL_DEFAULT 60
111#define OSPF_NEIGHBOR_PRIORITY_DEFAULT 0
112
vincentba682532005-09-29 13:52:57 +0000113#define OSPF_MTU_IGNORE_DEFAULT 0
paulf9ad9372005-10-21 00:45:17 +0000114#define OSPF_FAST_HELLO_DEFAULT 0
vincentba682532005-09-29 13:52:57 +0000115
paul718e3742002-12-13 20:15:29 +0000116/* OSPF options. */
117#define OSPF_OPTION_T 0x01 /* TOS. */
118#define OSPF_OPTION_E 0x02
119#define OSPF_OPTION_MC 0x04
120#define OSPF_OPTION_NP 0x08
121#define OSPF_OPTION_EA 0x10
122#define OSPF_OPTION_DC 0x20
123#define OSPF_OPTION_O 0x40
124
125/* OSPF Database Description flags. */
126#define OSPF_DD_FLAG_MS 0x01
127#define OSPF_DD_FLAG_M 0x02
128#define OSPF_DD_FLAG_I 0x04
129#define OSPF_DD_FLAG_ALL 0x07
130
paul718e3742002-12-13 20:15:29 +0000131#define OSPF_LS_REFRESH_SHIFT (60 * 15)
132#define OSPF_LS_REFRESH_JITTER 60
133
paul020709f2003-04-04 02:44:16 +0000134/* OSPF master for system wide configuration and variables. */
135struct ospf_master
136{
137 /* OSPF instance. */
138 struct list *ospf;
139
140 /* OSPF thread master. */
141 struct thread_master *master;
142
143 /* Zebra interface list. */
144 struct list *iflist;
145
146 /* Redistributed external information. */
147 struct route_table *external_info[ZEBRA_ROUTE_MAX + 1];
148#define EXTERNAL_INFO(T) om->external_info[T]
149
150 /* OSPF start time. */
151 time_t start_time;
152
153 /* Various OSPF global configuration. */
154 u_char options;
paulc9c93d52005-11-26 13:31:11 +0000155#define OSPF_MASTER_SHUTDOWN (1 << 0) /* deferred-shutdown */
paul020709f2003-04-04 02:44:16 +0000156};
157
paul718e3742002-12-13 20:15:29 +0000158/* OSPF instance structure. */
159struct ospf
160{
161 /* OSPF Router ID. */
162 struct in_addr router_id; /* Configured automatically. */
163 struct in_addr router_id_static; /* Configured manually. */
164
165 /* ABR/ASBR internal flags. */
166 u_char flags;
167#define OSPF_FLAG_ABR 0x0001
168#define OSPF_FLAG_ASBR 0x0002
169
170 /* ABR type. */
171 u_char abr_type;
172#define OSPF_ABR_UNKNOWN 0
173#define OSPF_ABR_STAND 1
174#define OSPF_ABR_IBM 2
175#define OSPF_ABR_CISCO 3
176#define OSPF_ABR_SHORTCUT 4
pauld57834f2005-07-12 20:04:22 +0000177#define OSPF_ABR_DEFAULT OSPF_ABR_CISCO
paul718e3742002-12-13 20:15:29 +0000178
179 /* NSSA ABR */
180 u_char anyNSSA; /* Bump for every NSSA attached. */
181
182 /* Configured variables. */
183 u_char config;
184#define OSPF_RFC1583_COMPATIBLE (1 << 0)
185#define OSPF_OPAQUE_CAPABLE (1 << 2)
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +0000186#define OSPF_LOG_ADJACENCY_CHANGES (1 << 3)
187#define OSPF_LOG_ADJACENCY_DETAIL (1 << 4)
paul718e3742002-12-13 20:15:29 +0000188
189#ifdef HAVE_OPAQUE_LSA
190 /* Opaque-LSA administrative flags. */
191 u_char opaque;
192#define OPAQUE_OPERATION_READY_BIT (1 << 0)
193#define OPAQUE_BLOCK_TYPE_09_LSA_BIT (1 << 1)
194#define OPAQUE_BLOCK_TYPE_10_LSA_BIT (1 << 2)
195#define OPAQUE_BLOCK_TYPE_11_LSA_BIT (1 << 3)
196#endif /* HAVE_OPAQUE_LSA */
197
paul88d6cf32005-10-29 12:50:09 +0000198 /* RFC3137 stub router. Configured time to stay stub / max-metric */
199 unsigned int stub_router_startup_time; /* seconds */
200 unsigned int stub_router_shutdown_time; /* seconds */
201#define OSPF_STUB_ROUTER_UNCONFIGURED 0
paul88d6cf32005-10-29 12:50:09 +0000202
203 /* SPF parameters */
204 unsigned int spf_delay; /* SPF delay time. */
205 unsigned int spf_holdtime; /* SPF hold time. */
206 unsigned int spf_max_holdtime; /* SPF maximum-holdtime */
207 unsigned int spf_hold_multiplier; /* Adaptive multiplier for hold time */
208
paul718e3742002-12-13 20:15:29 +0000209 int default_originate; /* Default information originate. */
210#define DEFAULT_ORIGINATE_NONE 0
211#define DEFAULT_ORIGINATE_ZEBRA 1
212#define DEFAULT_ORIGINATE_ALWAYS 2
213 u_int32_t ref_bandwidth; /* Reference Bandwidth (Kbps). */
214 struct route_table *networks; /* OSPF config networks. */
hasso52dc7ee2004-09-23 19:18:23 +0000215 struct list *vlinks; /* Configured Virtual-Links. */
216 struct list *areas; /* OSPF areas. */
paul718e3742002-12-13 20:15:29 +0000217 struct route_table *nbr_nbma;
218 struct ospf_area *backbone; /* Pointer to the Backbone Area. */
219
hasso52dc7ee2004-09-23 19:18:23 +0000220 struct list *oiflist; /* ospf interfaces */
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000221 u_char passive_interface_default; /* passive-interface default */
paul718e3742002-12-13 20:15:29 +0000222
223 /* LSDB of AS-external-LSAs. */
224 struct ospf_lsdb *lsdb;
225
paul718e3742002-12-13 20:15:29 +0000226 /* Flags. */
227 int external_origin; /* AS-external-LSA origin flag. */
228 int ase_calc; /* ASE calculation flag. */
229
230#ifdef HAVE_OPAQUE_LSA
hasso52dc7ee2004-09-23 19:18:23 +0000231 struct list *opaque_lsa_self; /* Type-11 Opaque-LSAs */
paul718e3742002-12-13 20:15:29 +0000232#endif /* HAVE_OPAQUE_LSA */
233
234 /* Routing tables. */
235 struct route_table *old_table; /* Old routing table. */
236 struct route_table *new_table; /* Current routing table. */
237
238 struct route_table *old_rtrs; /* Old ABR/ASBR RT. */
239 struct route_table *new_rtrs; /* New ABR/ASBR RT. */
240
241 struct route_table *new_external_route; /* New External Route. */
242 struct route_table *old_external_route; /* Old External Route. */
243
244 struct route_table *external_lsas; /* Database of external LSAs,
245 prefix is LSA's adv. network*/
246
247 /* Time stamps. */
pauld24f6e22005-10-21 09:23:12 +0000248 struct timeval ts_spf; /* SPF calculation time stamp. */
paul718e3742002-12-13 20:15:29 +0000249
hasso52dc7ee2004-09-23 19:18:23 +0000250 struct list *maxage_lsa; /* List of MaxAge LSA for deletion. */
paul718e3742002-12-13 20:15:29 +0000251 int redistribute; /* Num of redistributed protocols. */
252
253 /* Threads. */
paul718e3742002-12-13 20:15:29 +0000254 struct thread *t_abr_task; /* ABR task timer. */
255 struct thread *t_asbr_check; /* ASBR check timer. */
256 struct thread *t_distribute_update; /* Distirbute list update timer. */
257 struct thread *t_spf_calc; /* SPF calculation timer. */
258 struct thread *t_ase_calc; /* ASE calculation timer. */
259 struct thread *t_external_lsa; /* AS-external-LSA origin timer. */
260#ifdef HAVE_OPAQUE_LSA
261 struct thread *t_opaque_lsa_self; /* Type-11 Opaque-LSAs origin event. */
262#endif /* HAVE_OPAQUE_LSA */
Paul Jakma02d942c2010-01-24 23:36:20 +0000263
264#define OSFP_LSA_MAXAGE_REMOVE_DELAY_DEFAULT 60
265 unsigned int maxage_delay; /* Delay on Maxage remover timer, sec */
paul718e3742002-12-13 20:15:29 +0000266 struct thread *t_maxage; /* MaxAge LSA remover timer. */
Paul Jakma02d942c2010-01-24 23:36:20 +0000267#define OSPF_LSA_MAXAGE_CHECK_INTERVAL 30
paul718e3742002-12-13 20:15:29 +0000268 struct thread *t_maxage_walker; /* MaxAge LSA checking timer. */
Paul Jakma02d942c2010-01-24 23:36:20 +0000269
paulc9c93d52005-11-26 13:31:11 +0000270 struct thread *t_deferred_shutdown; /* deferred/stub-router shutdown timer*/
paul718e3742002-12-13 20:15:29 +0000271
272 struct thread *t_write;
273 struct thread *t_read;
274 int fd;
Denis Ovsienkob7fe4142007-08-21 16:32:56 +0000275 int maxsndbuflen;
ajs5c333492005-02-23 15:43:01 +0000276 struct stream *ibuf;
hasso52dc7ee2004-09-23 19:18:23 +0000277 struct list *oi_write_q;
paul718e3742002-12-13 20:15:29 +0000278
279 /* Distribute lists out of other route sources. */
280 struct
281 {
282 char *name;
283 struct access_list *list;
284 } dlist[ZEBRA_ROUTE_MAX];
paul020709f2003-04-04 02:44:16 +0000285#define DISTRIBUTE_NAME(O,T) (O)->dlist[T].name
286#define DISTRIBUTE_LIST(O,T) (O)->dlist[T].list
paul718e3742002-12-13 20:15:29 +0000287
288 /* Redistribute metric info. */
289 struct
290 {
291 int type; /* External metric type (E1 or E2). */
292 int value; /* Value for static metric (24-bit).
293 -1 means metric value is not set. */
294 } dmetric [ZEBRA_ROUTE_MAX + 1];
295
296 /* For redistribute route map. */
297 struct
298 {
299 char *name;
300 struct route_map *map;
301 } route_map [ZEBRA_ROUTE_MAX + 1]; /* +1 is for default-information */
paul020709f2003-04-04 02:44:16 +0000302#define ROUTEMAP_NAME(O,T) (O)->route_map[T].name
303#define ROUTEMAP(O,T) (O)->route_map[T].map
paul718e3742002-12-13 20:15:29 +0000304
305 int default_metric; /* Default metric for redistribute. */
306
307#define OSPF_LSA_REFRESHER_GRANULARITY 10
308#define OSPF_LSA_REFRESHER_SLOTS ((OSPF_LS_REFRESH_TIME + \
309 OSPF_LS_REFRESH_SHIFT)/10 + 1)
310 struct
311 {
312 u_int16_t index;
hasso52dc7ee2004-09-23 19:18:23 +0000313 struct list *qs[OSPF_LSA_REFRESHER_SLOTS];
paul718e3742002-12-13 20:15:29 +0000314 } lsa_refresh_queue;
315
316 struct thread *t_lsa_refresher;
317 time_t lsa_refresher_started;
318#define OSPF_LSA_REFRESH_INTERVAL_DEFAULT 10
319 u_int16_t lsa_refresh_interval;
320
321 /* Distance parameter. */
322 u_char distance_all;
323 u_char distance_intra;
324 u_char distance_inter;
325 u_char distance_external;
326
327 /* Statistics for LSA origination. */
328 u_int32_t lsa_originate_count;
329
330 /* Statistics for LSA used for new instantiation. */
331 u_int32_t rx_lsa_count;
332
333 struct route_table *distance_table;
334};
335
336/* OSPF area structure. */
337struct ospf_area
338{
339 /* OSPF instance. */
paul68980082003-03-25 05:07:42 +0000340 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +0000341
342 /* Zebra interface list belonging to the area. */
hasso52dc7ee2004-09-23 19:18:23 +0000343 struct list *oiflist;
paul718e3742002-12-13 20:15:29 +0000344
345 /* Area ID. */
346 struct in_addr area_id;
347
348 /* Area ID format. */
349 char format;
350#define OSPF_AREA_ID_FORMAT_ADDRESS 1
351#define OSPF_AREA_ID_FORMAT_DECIMAL 2
352
353 /* Address range. */
hasso52dc7ee2004-09-23 19:18:23 +0000354 struct list *address_range;
paul718e3742002-12-13 20:15:29 +0000355
356 /* Configured variables. */
357 int external_routing; /* ExternalRoutingCapability. */
358#define OSPF_AREA_DEFAULT 0
359#define OSPF_AREA_STUB 1
360#define OSPF_AREA_NSSA 2
361#define OSPF_AREA_TYPE_MAX 3
362 int no_summary; /* Don't inject summaries into stub.*/
363 int shortcut_configured; /* Area configured as shortcut. */
364#define OSPF_SHORTCUT_DEFAULT 0
365#define OSPF_SHORTCUT_ENABLE 1
366#define OSPF_SHORTCUT_DISABLE 2
367 int shortcut_capability; /* Other ABRs agree on S-bit */
368 u_int32_t default_cost; /* StubDefaultCost. */
369 int auth_type; /* Authentication type. */
paul88d6cf32005-10-29 12:50:09 +0000370
paul718e3742002-12-13 20:15:29 +0000371
paul464c8202003-06-22 08:32:35 +0000372 u_char NSSATranslatorRole; /* NSSA configured role */
paul718e3742002-12-13 20:15:29 +0000373#define OSPF_NSSA_ROLE_NEVER 0
pauld4a53d52003-07-12 21:30:57 +0000374#define OSPF_NSSA_ROLE_CANDIDATE 1
375#define OSPF_NSSA_ROLE_ALWAYS 2
paul464c8202003-06-22 08:32:35 +0000376 u_char NSSATranslatorState; /* NSSA operational role */
pauld4a53d52003-07-12 21:30:57 +0000377#define OSPF_NSSA_TRANSLATE_DISABLED 0
378#define OSPF_NSSA_TRANSLATE_ENABLED 1
paul464c8202003-06-22 08:32:35 +0000379 int NSSATranslatorStabilityInterval;
380
paul718e3742002-12-13 20:15:29 +0000381 u_char transit; /* TransitCapability. */
382#define OSPF_TRANSIT_FALSE 0
383#define OSPF_TRANSIT_TRUE 1
384 struct route_table *ranges; /* Configured Area Ranges. */
paul88d6cf32005-10-29 12:50:09 +0000385
386 /* RFC3137 stub router state flags for area */
387 u_char stub_router_state;
388#define OSPF_AREA_ADMIN_STUB_ROUTED (1 << 0) /* admin stub-router set */
389#define OSPF_AREA_IS_STUB_ROUTED (1 << 1) /* stub-router active */
390#define OSPF_AREA_WAS_START_STUB_ROUTED (1 << 2) /* startup SR was done */
391
paul718e3742002-12-13 20:15:29 +0000392 /* Area related LSDBs[Type1-4]. */
393 struct ospf_lsdb *lsdb;
394
395 /* Self-originated LSAs. */
396 struct ospf_lsa *router_lsa_self;
397#ifdef HAVE_OPAQUE_LSA
hasso52dc7ee2004-09-23 19:18:23 +0000398 struct list *opaque_lsa_self; /* Type-10 Opaque-LSAs */
paul718e3742002-12-13 20:15:29 +0000399#endif /* HAVE_OPAQUE_LSA */
400
401 /* Area announce list. */
402 struct
403 {
404 char *name;
405 struct access_list *list;
Paul Jakmadea04442008-02-26 09:16:09 +0000406 } _export;
407#define EXPORT_NAME(A) (A)->_export.name
408#define EXPORT_LIST(A) (A)->_export.list
paul718e3742002-12-13 20:15:29 +0000409
410 /* Area acceptance list. */
411 struct
412 {
413 char *name;
414 struct access_list *list;
415 } import;
416#define IMPORT_NAME(A) (A)->import.name
417#define IMPORT_LIST(A) (A)->import.list
418
419 /* Type 3 LSA Area prefix-list. */
420 struct
421 {
422 char *name;
423 struct prefix_list *list;
424 } plist_in;
425#define PREFIX_LIST_IN(A) (A)->plist_in.list
426#define PREFIX_NAME_IN(A) (A)->plist_in.name
427
428 struct
429 {
430 char *name;
431 struct prefix_list *list;
432 } plist_out;
433#define PREFIX_LIST_OUT(A) (A)->plist_out.list
434#define PREFIX_NAME_OUT(A) (A)->plist_out.name
435
436 /* Shortest Path Tree. */
437 struct vertex *spf;
438
439 /* Threads. */
paul88d6cf32005-10-29 12:50:09 +0000440 struct thread *t_stub_router; /* Stub-router timer */
paul718e3742002-12-13 20:15:29 +0000441#ifdef HAVE_OPAQUE_LSA
442 struct thread *t_opaque_lsa_self; /* Type-10 Opaque-LSAs origin. */
443#endif /* HAVE_OPAQUE_LSA */
444
445 /* Statistics field. */
446 u_int32_t spf_calculation; /* SPF Calculation Count. */
447
448 /* Router count. */
449 u_int32_t abr_count; /* ABR router in this area. */
450 u_int32_t asbr_count; /* ASBR router in this area. */
451
452 /* Counters. */
453 u_int32_t act_ints; /* Active interfaces. */
454 u_int32_t full_nbrs; /* Fully adjacent neighbors. */
455 u_int32_t full_vls; /* Fully adjacent virtual neighbors. */
456};
457
458/* OSPF config network structure. */
459struct ospf_network
460{
461 /* Area ID. */
462 struct in_addr area_id;
463 int format;
464};
465
466/* OSPF NBMA neighbor structure. */
467struct ospf_nbr_nbma
468{
469 /* Neighbor IP address. */
470 struct in_addr addr;
471
472 /* OSPF interface. */
473 struct ospf_interface *oi;
474
475 /* OSPF neighbor structure. */
476 struct ospf_neighbor *nbr;
477
478 /* Neighbor priority. */
479 u_char priority;
480
481 /* Poll timer value. */
482 u_int32_t v_poll;
483
484 /* Poll timer thread. */
485 struct thread *t_poll;
486
487 /* State change. */
488 u_int32_t state_change;
489};
490
491/* Macro. */
492#define OSPF_AREA_SAME(X,Y) \
493 (memcmp ((X->area_id), (Y->area_id), IPV4_MAX_BYTELEN) == 0)
494
paul020709f2003-04-04 02:44:16 +0000495#define IS_OSPF_ABR(O) ((O)->flags & OSPF_FLAG_ABR)
496#define IS_OSPF_ASBR(O) ((O)->flags & OSPF_FLAG_ASBR)
paul718e3742002-12-13 20:15:29 +0000497
498#define OSPF_IS_AREA_ID_BACKBONE(I) ((I).s_addr == OSPF_AREA_BACKBONE)
499#define OSPF_IS_AREA_BACKBONE(A) OSPF_IS_AREA_ID_BACKBONE ((A)->area_id)
500
501#ifdef roundup
502# define ROUNDUP(val, gran) roundup(val, gran)
503#else /* roundup */
504# define ROUNDUP(val, gran) (((val) - 1 | (gran) - 1) + 1)
505#endif /* roundup */
506
507#define LSA_OPTIONS_GET(area) \
508 (((area)->external_routing == OSPF_AREA_DEFAULT) ? OSPF_OPTION_E : 0)
pauld4a53d52003-07-12 21:30:57 +0000509#define LSA_OPTIONS_NSSA_GET(area) \
510 (((area)->external_routing == OSPF_AREA_NSSA) ? OSPF_OPTION_NP : 0)
paul718e3742002-12-13 20:15:29 +0000511
512#define OSPF_TIMER_ON(T,F,V) \
513 do { \
514 if (!(T)) \
paul68980082003-03-25 05:07:42 +0000515 (T) = thread_add_timer (master, (F), ospf, (V)); \
paul718e3742002-12-13 20:15:29 +0000516 } while (0)
517
518#define OSPF_AREA_TIMER_ON(T,F,V) \
519 do { \
520 if (!(T)) \
521 (T) = thread_add_timer (master, (F), area, (V)); \
522 } while (0)
523
524#define OSPF_POLL_TIMER_ON(T,F,V) \
525 do { \
526 if (!(T)) \
527 (T) = thread_add_timer (master, (F), nbr_nbma, (V)); \
528 } while (0)
529
530#define OSPF_POLL_TIMER_OFF(X) OSPF_TIMER_OFF((X))
531
532#define OSPF_TIMER_OFF(X) \
533 do { \
534 if (X) \
535 { \
536 thread_cancel (X); \
537 (X) = NULL; \
538 } \
539 } while (0)
540
paul020709f2003-04-04 02:44:16 +0000541/* Extern variables. */
542extern struct ospf_master *om;
Stephen Hemminger7ba82f72009-05-15 10:47:45 -0700543extern const struct message ospf_ism_state_msg[];
544extern const struct message ospf_nsm_state_msg[];
545extern const struct message ospf_lsa_type_msg[];
546extern const struct message ospf_link_state_id_type_msg[];
547extern const struct message ospf_network_type_msg[];
548extern const int ospf_ism_state_msg_max;
549extern const int ospf_nsm_state_msg_max;
550extern const int ospf_lsa_type_msg_max;
551extern const int ospf_link_state_id_type_msg_max;
552extern const int ospf_redistributed_proto_max;
553extern const int ospf_network_type_msg_max;
paul718e3742002-12-13 20:15:29 +0000554extern struct zclient *zclient;
555extern struct thread_master *master;
paul718e3742002-12-13 20:15:29 +0000556extern int ospf_zlog;
557
558/* Prototypes. */
ajsf52d13c2005-10-01 17:38:06 +0000559extern const char *ospf_redist_string(u_int route_type);
paul4dadc292005-05-06 21:37:42 +0000560extern struct ospf *ospf_lookup (void);
561extern struct ospf *ospf_get (void);
562extern void ospf_finish (struct ospf *);
paul4dadc292005-05-06 21:37:42 +0000563extern void ospf_router_id_update (struct ospf *ospf);
paul4dadc292005-05-06 21:37:42 +0000564extern int ospf_network_set (struct ospf *, struct prefix_ipv4 *,
565 struct in_addr);
566extern int ospf_network_unset (struct ospf *, struct prefix_ipv4 *,
567 struct in_addr);
568extern int ospf_area_stub_set (struct ospf *, struct in_addr);
569extern int ospf_area_stub_unset (struct ospf *, struct in_addr);
570extern int ospf_area_no_summary_set (struct ospf *, struct in_addr);
571extern int ospf_area_no_summary_unset (struct ospf *, struct in_addr);
572extern int ospf_area_nssa_set (struct ospf *, struct in_addr);
573extern int ospf_area_nssa_unset (struct ospf *, struct in_addr);
574extern int ospf_area_nssa_translator_role_set (struct ospf *, struct in_addr,
575 int);
576extern int ospf_area_export_list_set (struct ospf *, struct ospf_area *,
577 const char *);
578extern int ospf_area_export_list_unset (struct ospf *, struct ospf_area *);
579extern int ospf_area_import_list_set (struct ospf *, struct ospf_area *,
580 const char *);
581extern int ospf_area_import_list_unset (struct ospf *, struct ospf_area *);
582extern int ospf_area_shortcut_set (struct ospf *, struct ospf_area *, int);
583extern int ospf_area_shortcut_unset (struct ospf *, struct ospf_area *);
paul4dadc292005-05-06 21:37:42 +0000584extern int ospf_timers_refresh_set (struct ospf *, int);
585extern int ospf_timers_refresh_unset (struct ospf *);
586extern int ospf_nbr_nbma_set (struct ospf *, struct in_addr);
587extern int ospf_nbr_nbma_unset (struct ospf *, struct in_addr);
588extern int ospf_nbr_nbma_priority_set (struct ospf *, struct in_addr, u_char);
589extern int ospf_nbr_nbma_priority_unset (struct ospf *, struct in_addr);
590extern int ospf_nbr_nbma_poll_interval_set (struct ospf *, struct in_addr,
591 unsigned int);
592extern int ospf_nbr_nbma_poll_interval_unset (struct ospf *, struct in_addr);
593extern void ospf_prefix_list_update (struct prefix_list *);
594extern void ospf_init (void);
Joakim Tjernlunda49eb302008-09-02 19:06:31 +0100595extern void ospf_if_update (struct ospf *, struct interface *);
paul4dadc292005-05-06 21:37:42 +0000596extern void ospf_ls_upd_queue_empty (struct ospf_interface *);
597extern void ospf_terminate (void);
598extern void ospf_nbr_nbma_if_update (struct ospf *, struct ospf_interface *);
599extern struct ospf_nbr_nbma *ospf_nbr_nbma_lookup (struct ospf *,
600 struct in_addr);
601extern struct ospf_nbr_nbma *ospf_nbr_nbma_lookup_next (struct ospf *,
602 struct in_addr *,
603 int);
604extern int ospf_oi_count (struct interface *);
paul718e3742002-12-13 20:15:29 +0000605
paul4dadc292005-05-06 21:37:42 +0000606extern struct ospf_area *ospf_area_get (struct ospf *, struct in_addr, int);
607extern void ospf_area_check_free (struct ospf *, struct in_addr);
608extern struct ospf_area *ospf_area_lookup_by_area_id (struct ospf *,
609 struct in_addr);
610extern void ospf_area_add_if (struct ospf_area *, struct ospf_interface *);
611extern void ospf_area_del_if (struct ospf_area *, struct ospf_interface *);
paul718e3742002-12-13 20:15:29 +0000612
paul4dadc292005-05-06 21:37:42 +0000613extern void ospf_route_map_init (void);
614extern void ospf_snmp_init (void);
paul718e3742002-12-13 20:15:29 +0000615
paul4dadc292005-05-06 21:37:42 +0000616extern void ospf_master_init (void);
paul020709f2003-04-04 02:44:16 +0000617
paul718e3742002-12-13 20:15:29 +0000618#endif /* _ZEBRA_OSPFD_H */