blob: bf825d177b60d468a58ffb9aad7a752db4dec925 [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
paul718e3742002-12-13 20:15:29 +000075#define OSPF_AREA_BACKBONE 0x00000000 /* 0.0.0.0 */
76
77/* OSPF Authentication Type. */
78#define OSPF_AUTH_NULL 0
79#define OSPF_AUTH_SIMPLE 1
80#define OSPF_AUTH_CRYPTOGRAPHIC 2
81/* For Interface authentication setting default */
82#define OSPF_AUTH_NOTSET -1
83/* For the consumption and sanity of the command handler */
84/* DO NIOT REMOVE!!! Need to detect whether a value has
85 been given or not in VLink command handlers */
86#define OSPF_AUTH_CMD_NOTSEEN -2
87
88/* OSPF SPF timer values. */
pauld24f6e22005-10-21 09:23:12 +000089#define OSPF_SPF_DELAY_DEFAULT 200
90#define OSPF_SPF_HOLDTIME_DEFAULT 1000
91#define OSPF_SPF_MAX_HOLDTIME_DEFAULT 10000
paul718e3742002-12-13 20:15:29 +000092
93/* OSPF interface default values. */
94#define OSPF_OUTPUT_COST_DEFAULT 10
paul88d6cf32005-10-29 12:50:09 +000095#define OSPF_OUTPUT_COST_INFINITE UINT16_MAX
paul718e3742002-12-13 20:15:29 +000096#define OSPF_ROUTER_DEAD_INTERVAL_DEFAULT 40
paulf9ad9372005-10-21 00:45:17 +000097#define OSPF_ROUTER_DEAD_INTERVAL_MINIMAL 1
paul718e3742002-12-13 20:15:29 +000098#define OSPF_HELLO_INTERVAL_DEFAULT 10
99#define OSPF_ROUTER_PRIORITY_DEFAULT 1
100#define OSPF_RETRANSMIT_INTERVAL_DEFAULT 5
101#define OSPF_TRANSMIT_DELAY_DEFAULT 1
102#define OSPF_DEFAULT_BANDWIDTH 10000 /* Kbps */
103
104#define OSPF_DEFAULT_REF_BANDWIDTH 100000 /* Kbps */
105
106#define OSPF_POLL_INTERVAL_DEFAULT 60
107#define OSPF_NEIGHBOR_PRIORITY_DEFAULT 0
108
vincentba682532005-09-29 13:52:57 +0000109#define OSPF_MTU_IGNORE_DEFAULT 0
paulf9ad9372005-10-21 00:45:17 +0000110#define OSPF_FAST_HELLO_DEFAULT 0
vincentba682532005-09-29 13:52:57 +0000111
paul718e3742002-12-13 20:15:29 +0000112/* OSPF options. */
113#define OSPF_OPTION_T 0x01 /* TOS. */
114#define OSPF_OPTION_E 0x02
115#define OSPF_OPTION_MC 0x04
116#define OSPF_OPTION_NP 0x08
117#define OSPF_OPTION_EA 0x10
118#define OSPF_OPTION_DC 0x20
119#define OSPF_OPTION_O 0x40
120
121/* OSPF Database Description flags. */
122#define OSPF_DD_FLAG_MS 0x01
123#define OSPF_DD_FLAG_M 0x02
124#define OSPF_DD_FLAG_I 0x04
125#define OSPF_DD_FLAG_ALL 0x07
126
paul718e3742002-12-13 20:15:29 +0000127#define OSPF_LS_REFRESH_SHIFT (60 * 15)
128#define OSPF_LS_REFRESH_JITTER 60
129
paul020709f2003-04-04 02:44:16 +0000130/* OSPF master for system wide configuration and variables. */
131struct ospf_master
132{
133 /* OSPF instance. */
134 struct list *ospf;
135
136 /* OSPF thread master. */
137 struct thread_master *master;
138
139 /* Zebra interface list. */
140 struct list *iflist;
141
142 /* Redistributed external information. */
143 struct route_table *external_info[ZEBRA_ROUTE_MAX + 1];
144#define EXTERNAL_INFO(T) om->external_info[T]
145
146 /* OSPF start time. */
147 time_t start_time;
148
149 /* Various OSPF global configuration. */
150 u_char options;
paulc9c93d52005-11-26 13:31:11 +0000151#define OSPF_MASTER_SHUTDOWN (1 << 0) /* deferred-shutdown */
paul020709f2003-04-04 02:44:16 +0000152};
153
paul718e3742002-12-13 20:15:29 +0000154/* OSPF instance structure. */
155struct ospf
156{
157 /* OSPF Router ID. */
158 struct in_addr router_id; /* Configured automatically. */
159 struct in_addr router_id_static; /* Configured manually. */
160
161 /* ABR/ASBR internal flags. */
162 u_char flags;
163#define OSPF_FLAG_ABR 0x0001
164#define OSPF_FLAG_ASBR 0x0002
165
166 /* ABR type. */
167 u_char abr_type;
168#define OSPF_ABR_UNKNOWN 0
169#define OSPF_ABR_STAND 1
170#define OSPF_ABR_IBM 2
171#define OSPF_ABR_CISCO 3
172#define OSPF_ABR_SHORTCUT 4
pauld57834f2005-07-12 20:04:22 +0000173#define OSPF_ABR_DEFAULT OSPF_ABR_CISCO
paul718e3742002-12-13 20:15:29 +0000174
175 /* NSSA ABR */
176 u_char anyNSSA; /* Bump for every NSSA attached. */
177
178 /* Configured variables. */
179 u_char config;
180#define OSPF_RFC1583_COMPATIBLE (1 << 0)
181#define OSPF_OPAQUE_CAPABLE (1 << 2)
Andrew J. Schorrd7e60dd2006-06-29 20:20:52 +0000182#define OSPF_LOG_ADJACENCY_CHANGES (1 << 3)
183#define OSPF_LOG_ADJACENCY_DETAIL (1 << 4)
paul718e3742002-12-13 20:15:29 +0000184
185#ifdef HAVE_OPAQUE_LSA
186 /* Opaque-LSA administrative flags. */
187 u_char opaque;
188#define OPAQUE_OPERATION_READY_BIT (1 << 0)
189#define OPAQUE_BLOCK_TYPE_09_LSA_BIT (1 << 1)
190#define OPAQUE_BLOCK_TYPE_10_LSA_BIT (1 << 2)
191#define OPAQUE_BLOCK_TYPE_11_LSA_BIT (1 << 3)
192#endif /* HAVE_OPAQUE_LSA */
193
paul88d6cf32005-10-29 12:50:09 +0000194 /* RFC3137 stub router. Configured time to stay stub / max-metric */
195 unsigned int stub_router_startup_time; /* seconds */
196 unsigned int stub_router_shutdown_time; /* seconds */
197#define OSPF_STUB_ROUTER_UNCONFIGURED 0
paul88d6cf32005-10-29 12:50:09 +0000198
JR Riversb4154c12012-09-24 17:26:53 +0000199#define OSPF_STUB_MAX_METRIC_SUMMARY_COST 0x00ff0000
200
paul88d6cf32005-10-29 12:50:09 +0000201 /* SPF parameters */
202 unsigned int spf_delay; /* SPF delay time. */
203 unsigned int spf_holdtime; /* SPF hold time. */
204 unsigned int spf_max_holdtime; /* SPF maximum-holdtime */
205 unsigned int spf_hold_multiplier; /* Adaptive multiplier for hold time */
206
paul718e3742002-12-13 20:15:29 +0000207 int default_originate; /* Default information originate. */
208#define DEFAULT_ORIGINATE_NONE 0
209#define DEFAULT_ORIGINATE_ZEBRA 1
210#define DEFAULT_ORIGINATE_ALWAYS 2
211 u_int32_t ref_bandwidth; /* Reference Bandwidth (Kbps). */
212 struct route_table *networks; /* OSPF config networks. */
hasso52dc7ee2004-09-23 19:18:23 +0000213 struct list *vlinks; /* Configured Virtual-Links. */
214 struct list *areas; /* OSPF areas. */
paul718e3742002-12-13 20:15:29 +0000215 struct route_table *nbr_nbma;
216 struct ospf_area *backbone; /* Pointer to the Backbone Area. */
217
hasso52dc7ee2004-09-23 19:18:23 +0000218 struct list *oiflist; /* ospf interfaces */
Paul Jakma7ffa8fa2006-10-22 20:07:53 +0000219 u_char passive_interface_default; /* passive-interface default */
paul718e3742002-12-13 20:15:29 +0000220
221 /* LSDB of AS-external-LSAs. */
222 struct ospf_lsdb *lsdb;
223
paul718e3742002-12-13 20:15:29 +0000224 /* Flags. */
225 int external_origin; /* AS-external-LSA origin flag. */
226 int ase_calc; /* ASE calculation flag. */
227
228#ifdef HAVE_OPAQUE_LSA
hasso52dc7ee2004-09-23 19:18:23 +0000229 struct list *opaque_lsa_self; /* Type-11 Opaque-LSAs */
paul718e3742002-12-13 20:15:29 +0000230#endif /* HAVE_OPAQUE_LSA */
231
232 /* Routing tables. */
233 struct route_table *old_table; /* Old routing table. */
234 struct route_table *new_table; /* Current routing table. */
235
236 struct route_table *old_rtrs; /* Old ABR/ASBR RT. */
237 struct route_table *new_rtrs; /* New ABR/ASBR RT. */
238
239 struct route_table *new_external_route; /* New External Route. */
240 struct route_table *old_external_route; /* Old External Route. */
241
242 struct route_table *external_lsas; /* Database of external LSAs,
243 prefix is LSA's adv. network*/
244
245 /* Time stamps. */
pauld24f6e22005-10-21 09:23:12 +0000246 struct timeval ts_spf; /* SPF calculation time stamp. */
paul718e3742002-12-13 20:15:29 +0000247
hasso52dc7ee2004-09-23 19:18:23 +0000248 struct list *maxage_lsa; /* List of MaxAge LSA for deletion. */
paul718e3742002-12-13 20:15:29 +0000249 int redistribute; /* Num of redistributed protocols. */
250
251 /* Threads. */
paul718e3742002-12-13 20:15:29 +0000252 struct thread *t_abr_task; /* ABR task timer. */
253 struct thread *t_asbr_check; /* ASBR check timer. */
254 struct thread *t_distribute_update; /* Distirbute list update timer. */
255 struct thread *t_spf_calc; /* SPF calculation timer. */
256 struct thread *t_ase_calc; /* ASE calculation timer. */
257 struct thread *t_external_lsa; /* AS-external-LSA origin timer. */
258#ifdef HAVE_OPAQUE_LSA
259 struct thread *t_opaque_lsa_self; /* Type-11 Opaque-LSAs origin event. */
260#endif /* HAVE_OPAQUE_LSA */
Paul Jakma02d942c2010-01-24 23:36:20 +0000261
262#define OSFP_LSA_MAXAGE_REMOVE_DELAY_DEFAULT 60
263 unsigned int maxage_delay; /* Delay on Maxage remover timer, sec */
paul718e3742002-12-13 20:15:29 +0000264 struct thread *t_maxage; /* MaxAge LSA remover timer. */
Paul Jakma02d942c2010-01-24 23:36:20 +0000265#define OSPF_LSA_MAXAGE_CHECK_INTERVAL 30
paul718e3742002-12-13 20:15:29 +0000266 struct thread *t_maxage_walker; /* MaxAge LSA checking timer. */
Paul Jakma02d942c2010-01-24 23:36:20 +0000267
paulc9c93d52005-11-26 13:31:11 +0000268 struct thread *t_deferred_shutdown; /* deferred/stub-router shutdown timer*/
paul718e3742002-12-13 20:15:29 +0000269
270 struct thread *t_write;
271 struct thread *t_read;
272 int fd;
Denis Ovsienkob7fe4142007-08-21 16:32:56 +0000273 int maxsndbuflen;
ajs5c333492005-02-23 15:43:01 +0000274 struct stream *ibuf;
hasso52dc7ee2004-09-23 19:18:23 +0000275 struct list *oi_write_q;
paul718e3742002-12-13 20:15:29 +0000276
277 /* Distribute lists out of other route sources. */
278 struct
279 {
280 char *name;
281 struct access_list *list;
282 } dlist[ZEBRA_ROUTE_MAX];
paul020709f2003-04-04 02:44:16 +0000283#define DISTRIBUTE_NAME(O,T) (O)->dlist[T].name
284#define DISTRIBUTE_LIST(O,T) (O)->dlist[T].list
paul718e3742002-12-13 20:15:29 +0000285
286 /* Redistribute metric info. */
287 struct
288 {
289 int type; /* External metric type (E1 or E2). */
290 int value; /* Value for static metric (24-bit).
291 -1 means metric value is not set. */
292 } dmetric [ZEBRA_ROUTE_MAX + 1];
293
294 /* For redistribute route map. */
295 struct
296 {
297 char *name;
298 struct route_map *map;
299 } route_map [ZEBRA_ROUTE_MAX + 1]; /* +1 is for default-information */
paul020709f2003-04-04 02:44:16 +0000300#define ROUTEMAP_NAME(O,T) (O)->route_map[T].name
301#define ROUTEMAP(O,T) (O)->route_map[T].map
paul718e3742002-12-13 20:15:29 +0000302
303 int default_metric; /* Default metric for redistribute. */
304
305#define OSPF_LSA_REFRESHER_GRANULARITY 10
306#define OSPF_LSA_REFRESHER_SLOTS ((OSPF_LS_REFRESH_TIME + \
307 OSPF_LS_REFRESH_SHIFT)/10 + 1)
308 struct
309 {
310 u_int16_t index;
hasso52dc7ee2004-09-23 19:18:23 +0000311 struct list *qs[OSPF_LSA_REFRESHER_SLOTS];
paul718e3742002-12-13 20:15:29 +0000312 } lsa_refresh_queue;
313
314 struct thread *t_lsa_refresher;
315 time_t lsa_refresher_started;
316#define OSPF_LSA_REFRESH_INTERVAL_DEFAULT 10
317 u_int16_t lsa_refresh_interval;
318
319 /* Distance parameter. */
320 u_char distance_all;
321 u_char distance_intra;
322 u_char distance_inter;
323 u_char distance_external;
324
325 /* Statistics for LSA origination. */
326 u_int32_t lsa_originate_count;
327
328 /* Statistics for LSA used for new instantiation. */
329 u_int32_t rx_lsa_count;
330
331 struct route_table *distance_table;
332};
333
334/* OSPF area structure. */
335struct ospf_area
336{
337 /* OSPF instance. */
paul68980082003-03-25 05:07:42 +0000338 struct ospf *ospf;
paul718e3742002-12-13 20:15:29 +0000339
340 /* Zebra interface list belonging to the area. */
hasso52dc7ee2004-09-23 19:18:23 +0000341 struct list *oiflist;
paul718e3742002-12-13 20:15:29 +0000342
343 /* Area ID. */
344 struct in_addr area_id;
345
346 /* Area ID format. */
347 char format;
348#define OSPF_AREA_ID_FORMAT_ADDRESS 1
349#define OSPF_AREA_ID_FORMAT_DECIMAL 2
350
351 /* Address range. */
hasso52dc7ee2004-09-23 19:18:23 +0000352 struct list *address_range;
paul718e3742002-12-13 20:15:29 +0000353
354 /* Configured variables. */
355 int external_routing; /* ExternalRoutingCapability. */
356#define OSPF_AREA_DEFAULT 0
357#define OSPF_AREA_STUB 1
358#define OSPF_AREA_NSSA 2
359#define OSPF_AREA_TYPE_MAX 3
360 int no_summary; /* Don't inject summaries into stub.*/
361 int shortcut_configured; /* Area configured as shortcut. */
362#define OSPF_SHORTCUT_DEFAULT 0
363#define OSPF_SHORTCUT_ENABLE 1
364#define OSPF_SHORTCUT_DISABLE 2
365 int shortcut_capability; /* Other ABRs agree on S-bit */
366 u_int32_t default_cost; /* StubDefaultCost. */
367 int auth_type; /* Authentication type. */
paul88d6cf32005-10-29 12:50:09 +0000368
paul718e3742002-12-13 20:15:29 +0000369
paul464c8202003-06-22 08:32:35 +0000370 u_char NSSATranslatorRole; /* NSSA configured role */
paul718e3742002-12-13 20:15:29 +0000371#define OSPF_NSSA_ROLE_NEVER 0
pauld4a53d52003-07-12 21:30:57 +0000372#define OSPF_NSSA_ROLE_CANDIDATE 1
373#define OSPF_NSSA_ROLE_ALWAYS 2
paul464c8202003-06-22 08:32:35 +0000374 u_char NSSATranslatorState; /* NSSA operational role */
pauld4a53d52003-07-12 21:30:57 +0000375#define OSPF_NSSA_TRANSLATE_DISABLED 0
376#define OSPF_NSSA_TRANSLATE_ENABLED 1
paul464c8202003-06-22 08:32:35 +0000377 int NSSATranslatorStabilityInterval;
378
paul718e3742002-12-13 20:15:29 +0000379 u_char transit; /* TransitCapability. */
380#define OSPF_TRANSIT_FALSE 0
381#define OSPF_TRANSIT_TRUE 1
382 struct route_table *ranges; /* Configured Area Ranges. */
paul88d6cf32005-10-29 12:50:09 +0000383
384 /* RFC3137 stub router state flags for area */
385 u_char stub_router_state;
386#define OSPF_AREA_ADMIN_STUB_ROUTED (1 << 0) /* admin stub-router set */
387#define OSPF_AREA_IS_STUB_ROUTED (1 << 1) /* stub-router active */
388#define OSPF_AREA_WAS_START_STUB_ROUTED (1 << 2) /* startup SR was done */
389
paul718e3742002-12-13 20:15:29 +0000390 /* Area related LSDBs[Type1-4]. */
391 struct ospf_lsdb *lsdb;
392
393 /* Self-originated LSAs. */
394 struct ospf_lsa *router_lsa_self;
395#ifdef HAVE_OPAQUE_LSA
hasso52dc7ee2004-09-23 19:18:23 +0000396 struct list *opaque_lsa_self; /* Type-10 Opaque-LSAs */
paul718e3742002-12-13 20:15:29 +0000397#endif /* HAVE_OPAQUE_LSA */
398
399 /* Area announce list. */
400 struct
401 {
402 char *name;
403 struct access_list *list;
Paul Jakmadea04442008-02-26 09:16:09 +0000404 } _export;
405#define EXPORT_NAME(A) (A)->_export.name
406#define EXPORT_LIST(A) (A)->_export.list
paul718e3742002-12-13 20:15:29 +0000407
408 /* Area acceptance list. */
409 struct
410 {
411 char *name;
412 struct access_list *list;
413 } import;
414#define IMPORT_NAME(A) (A)->import.name
415#define IMPORT_LIST(A) (A)->import.list
416
417 /* Type 3 LSA Area prefix-list. */
418 struct
419 {
420 char *name;
421 struct prefix_list *list;
422 } plist_in;
423#define PREFIX_LIST_IN(A) (A)->plist_in.list
424#define PREFIX_NAME_IN(A) (A)->plist_in.name
425
426 struct
427 {
428 char *name;
429 struct prefix_list *list;
430 } plist_out;
431#define PREFIX_LIST_OUT(A) (A)->plist_out.list
432#define PREFIX_NAME_OUT(A) (A)->plist_out.name
433
434 /* Shortest Path Tree. */
435 struct vertex *spf;
436
437 /* Threads. */
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;
Stephen Hemminger7ba82f72009-05-15 10:47:45 -0700541extern const struct message ospf_ism_state_msg[];
542extern const struct message ospf_nsm_state_msg[];
543extern const struct message ospf_lsa_type_msg[];
544extern const struct message ospf_link_state_id_type_msg[];
545extern const struct message ospf_network_type_msg[];
546extern const int ospf_ism_state_msg_max;
547extern const int ospf_nsm_state_msg_max;
548extern const int ospf_lsa_type_msg_max;
549extern const int ospf_link_state_id_type_msg_max;
550extern const int ospf_redistributed_proto_max;
551extern const int ospf_network_type_msg_max;
paul718e3742002-12-13 20:15:29 +0000552extern 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);
paul4dadc292005-05-06 21:37:42 +0000562extern int ospf_network_set (struct ospf *, struct prefix_ipv4 *,
563 struct in_addr);
564extern int ospf_network_unset (struct ospf *, struct prefix_ipv4 *,
565 struct in_addr);
566extern int ospf_area_stub_set (struct ospf *, struct in_addr);
567extern int ospf_area_stub_unset (struct ospf *, struct in_addr);
568extern int ospf_area_no_summary_set (struct ospf *, struct in_addr);
569extern int ospf_area_no_summary_unset (struct ospf *, struct in_addr);
570extern int ospf_area_nssa_set (struct ospf *, struct in_addr);
571extern int ospf_area_nssa_unset (struct ospf *, struct in_addr);
572extern int ospf_area_nssa_translator_role_set (struct ospf *, struct in_addr,
573 int);
574extern int ospf_area_export_list_set (struct ospf *, struct ospf_area *,
575 const char *);
576extern int ospf_area_export_list_unset (struct ospf *, struct ospf_area *);
577extern int ospf_area_import_list_set (struct ospf *, struct ospf_area *,
578 const char *);
579extern int ospf_area_import_list_unset (struct ospf *, struct ospf_area *);
580extern int ospf_area_shortcut_set (struct ospf *, struct ospf_area *, int);
581extern int ospf_area_shortcut_unset (struct ospf *, struct ospf_area *);
paul4dadc292005-05-06 21:37:42 +0000582extern int ospf_timers_refresh_set (struct ospf *, int);
583extern int ospf_timers_refresh_unset (struct ospf *);
584extern int ospf_nbr_nbma_set (struct ospf *, struct in_addr);
585extern int ospf_nbr_nbma_unset (struct ospf *, struct in_addr);
586extern int ospf_nbr_nbma_priority_set (struct ospf *, struct in_addr, u_char);
587extern int ospf_nbr_nbma_priority_unset (struct ospf *, struct in_addr);
588extern int ospf_nbr_nbma_poll_interval_set (struct ospf *, struct in_addr,
589 unsigned int);
590extern int ospf_nbr_nbma_poll_interval_unset (struct ospf *, struct in_addr);
591extern void ospf_prefix_list_update (struct prefix_list *);
592extern void ospf_init (void);
Joakim Tjernlunda49eb302008-09-02 19:06:31 +0100593extern void ospf_if_update (struct ospf *, struct interface *);
paul4dadc292005-05-06 21:37:42 +0000594extern void ospf_ls_upd_queue_empty (struct ospf_interface *);
595extern void ospf_terminate (void);
596extern void ospf_nbr_nbma_if_update (struct ospf *, struct ospf_interface *);
597extern struct ospf_nbr_nbma *ospf_nbr_nbma_lookup (struct ospf *,
598 struct in_addr);
599extern struct ospf_nbr_nbma *ospf_nbr_nbma_lookup_next (struct ospf *,
600 struct in_addr *,
601 int);
602extern int ospf_oi_count (struct interface *);
paul718e3742002-12-13 20:15:29 +0000603
paul4dadc292005-05-06 21:37:42 +0000604extern struct ospf_area *ospf_area_get (struct ospf *, struct in_addr, int);
605extern void ospf_area_check_free (struct ospf *, struct in_addr);
606extern struct ospf_area *ospf_area_lookup_by_area_id (struct ospf *,
607 struct in_addr);
608extern void ospf_area_add_if (struct ospf_area *, struct ospf_interface *);
609extern void ospf_area_del_if (struct ospf_area *, struct ospf_interface *);
paul718e3742002-12-13 20:15:29 +0000610
paul4dadc292005-05-06 21:37:42 +0000611extern void ospf_route_map_init (void);
612extern void ospf_snmp_init (void);
paul718e3742002-12-13 20:15:29 +0000613
paul4dadc292005-05-06 21:37:42 +0000614extern void ospf_master_init (void);
paul020709f2003-04-04 02:44:16 +0000615
paul718e3742002-12-13 20:15:29 +0000616#endif /* _ZEBRA_OSPFD_H */