]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospfd.h
Merge pull request #12366 from manojvn/ospfv2-flood-reduction
[mirror_frr.git] / ospfd / ospfd.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * OSPFd main header.
4 * Copyright (C) 1998, 99, 2000 Kunihiro Ishiguro, Toshiaki Takada
5 */
6
7 #ifndef _ZEBRA_OSPFD_H
8 #define _ZEBRA_OSPFD_H
9
10 #include <zebra.h>
11 #include "typesafe.h"
12 #include "qobj.h"
13 #include "libospf.h"
14 #include "ldp_sync.h"
15
16 #include "filter.h"
17 #include "log.h"
18 #include "vrf.h"
19
20 #include "ospf_memory.h"
21 #include "ospf_dump_api.h"
22
23 #define OSPF_VERSION 2
24
25 /* VTY port number. */
26 #define OSPF_VTY_PORT 2604
27
28 /* IP TTL for OSPF protocol. */
29 #define OSPF_IP_TTL 1
30 #define OSPF_VL_IP_TTL 100
31
32 /* Default configuration file name for ospfd. */
33 #define OSPF_DEFAULT_CONFIG "ospfd.conf"
34
35 #define OSPF_NSSA_TRANS_STABLE_DEFAULT 40
36
37 #define OSPF_ALLSPFROUTERS 0xe0000005 /* 224.0.0.5 */
38 #define OSPF_ALLDROUTERS 0xe0000006 /* 224.0.0.6 */
39
40 /* OSPF Authentication Type. */
41 #define OSPF_AUTH_NULL 0
42 #define OSPF_AUTH_SIMPLE 1
43 #define OSPF_AUTH_CRYPTOGRAPHIC 2
44 /* For Interface authentication setting default */
45 #define OSPF_AUTH_NOTSET -1
46 /* For the consumption and sanity of the command handler */
47 /* DO NIOT REMOVE!!! Need to detect whether a value has
48 been given or not in VLink command handlers */
49 #define OSPF_AUTH_CMD_NOTSEEN -2
50
51 /* OSPF options. */
52 #define OSPF_OPTION_MT 0x01 /* M/T */
53 #define OSPF_OPTION_E 0x02
54 #define OSPF_OPTION_MC 0x04
55 #define OSPF_OPTION_NP 0x08
56 #define OSPF_OPTION_EA 0x10
57 #define OSPF_OPTION_DC 0x20
58 #define OSPF_OPTION_O 0x40
59 #define OSPF_OPTION_DN 0x80
60
61 /* OSPF Database Description flags. */
62 #define OSPF_DD_FLAG_MS 0x01
63 #define OSPF_DD_FLAG_M 0x02
64 #define OSPF_DD_FLAG_I 0x04
65 #define OSPF_DD_FLAG_ALL 0x07
66
67 #define OSPF_LS_REFRESH_SHIFT (60 * 15)
68 #define OSPF_LS_REFRESH_JITTER 60
69
70 struct ospf_external {
71 unsigned short instance;
72 struct route_table *external_info;
73 };
74
75 /* OSPF master for system wide configuration and variables. */
76 struct ospf_master {
77 /* OSPF instance. */
78 struct list *ospf;
79
80 /* OSPF thread master. */
81 struct thread_master *master;
82
83 /* Various OSPF global configuration. */
84 uint8_t options;
85 #define OSPF_MASTER_SHUTDOWN (1 << 0) /* deferred-shutdown */
86 };
87
88 struct ospf_redist {
89 unsigned short instance;
90
91 /* Redistribute metric info. */
92 struct {
93 int type; /* External metric type (E1 or E2). */
94 int value; /* Value for static metric (24-bit).
95 -1 means metric value is not set. */
96 } dmetric;
97
98 /* For redistribute route map. */
99 struct {
100 char *name;
101 struct route_map *map;
102 } route_map; /* +1 is for default-information */
103 #define ROUTEMAP_NAME(R) (R->route_map.name)
104 #define ROUTEMAP(R) (R->route_map.map)
105 };
106
107 /* OSPF area flood reduction info */
108 struct ospf_area_fr_info {
109 bool enabled; /* Area support for Flood Reduction */
110 bool configured; /* Flood Reduction configured per area knob */
111 bool state_changed; /* flood reduction state change info */
112 int router_lsas_recv_dc_bit; /* Number of unique router lsas
113 * received with DC bit set.
114 * (excluding self)
115 */
116 bool area_ind_lsa_recvd; /* Indication lsa received in this area */
117 bool area_dc_clear; /* Area has atleast one lsa with dc bit 0(
118 * excluding indication lsa)
119 */
120 struct ospf_lsa *indication_lsa_self; /* Indication LSA generated
121 * in the area.
122 */
123 };
124
125 /* ospf->config */
126 enum {
127 OSPF_RFC1583_COMPATIBLE = (1 << 0),
128 OSPF_OPAQUE_CAPABLE = (1 << 2),
129 OSPF_LOG_ADJACENCY_CHANGES = (1 << 3),
130 OSPF_LOG_ADJACENCY_DETAIL = (1 << 4),
131 OSPF_SEND_EXTRA_DATA_TO_ZEBRA = (1 << 5),
132 };
133
134 /* TI-LFA */
135 enum protection_type {
136 OSPF_TI_LFA_UNDEFINED_PROTECTION,
137 OSPF_TI_LFA_LINK_PROTECTION,
138 OSPF_TI_LFA_NODE_PROTECTION,
139 };
140
141 /* OSPF nonstop forwarding aka Graceful Restart */
142 struct ospf_gr_info {
143 bool restart_support;
144 bool restart_in_progress;
145 bool prepare_in_progress;
146 bool finishing_restart;
147 uint32_t grace_period;
148 struct thread *t_grace_period;
149 };
150
151 /* OSPF instance structure. */
152 struct ospf {
153 /* OSPF's running state based on the '[no] router ospf [<instance>]'
154 * config. */
155 uint8_t oi_running;
156
157 /* OSPF instance ID */
158 unsigned short instance;
159
160 /* OSPF Router ID. */
161 struct in_addr router_id; /* Configured automatically. */
162 struct in_addr router_id_static; /* Configured manually. */
163 struct in_addr router_id_zebra;
164
165 vrf_id_t vrf_id; /* VRF Id */
166 char *name; /* VRF name */
167
168 /* ABR/ASBR internal flags. */
169 uint8_t flags;
170 #define OSPF_FLAG_ABR 0x0001
171 #define OSPF_FLAG_ASBR 0x0002
172
173 /* ABR type. */
174 uint8_t abr_type;
175 #define OSPF_ABR_UNKNOWN 0
176 #define OSPF_ABR_STAND 1
177 #define OSPF_ABR_IBM 2
178 #define OSPF_ABR_CISCO 3
179 #define OSPF_ABR_SHORTCUT 4
180 #define OSPF_ABR_DEFAULT OSPF_ABR_CISCO
181
182 /* NSSA ABR */
183 uint8_t anyNSSA; /* Bump for every NSSA attached. */
184
185 /* Configuration bitmask, refer to enum above */
186 uint8_t config;
187
188 /* Opaque-LSA administrative flags. */
189 uint8_t opaque;
190 #define OPAQUE_OPERATION_READY_BIT (1 << 0)
191
192 /* RFC3137 stub router. Configured time to stay stub / max-metric */
193 unsigned int stub_router_startup_time; /* seconds */
194 unsigned int stub_router_shutdown_time; /* seconds */
195 #define OSPF_STUB_ROUTER_UNCONFIGURED 0
196 uint8_t stub_router_admin_set;
197 #define OSPF_STUB_ROUTER_ADMINISTRATIVE_SET 1
198 #define OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET 0
199
200 #define OSPF_STUB_MAX_METRIC_SUMMARY_COST 0x00ff0000
201
202 /* LSA timers */
203 unsigned int min_ls_interval; /* minimum delay between LSAs (in msec) */
204 unsigned int min_ls_arrival; /* minimum interarrival time between LSAs
205 (in msec) */
206
207 /* SPF parameters */
208 unsigned int spf_delay; /* SPF delay time. */
209 unsigned int spf_holdtime; /* SPF hold time. */
210 unsigned int spf_max_holdtime; /* SPF maximum-holdtime */
211 unsigned int
212 spf_hold_multiplier; /* Adaptive multiplier for hold time */
213
214 int default_originate; /* Default information originate. */
215 #define DEFAULT_ORIGINATE_NONE 0
216 #define DEFAULT_ORIGINATE_ZEBRA 1
217 #define DEFAULT_ORIGINATE_ALWAYS 2
218 uint32_t ref_bandwidth; /* Reference Bandwidth (Kbps). */
219 struct route_table *networks; /* OSPF config networks. */
220 struct list *vlinks; /* Configured Virtual-Links. */
221 struct list *areas; /* OSPF areas. */
222 struct route_table *nbr_nbma;
223 struct ospf_area *backbone; /* Pointer to the Backbone Area. */
224
225 struct list *oiflist; /* ospf interfaces */
226 uint8_t passive_interface_default; /* passive-interface default */
227
228 /* LSDB of AS-external-LSAs. */
229 struct ospf_lsdb *lsdb;
230
231 /* Flags. */
232 int ase_calc; /* ASE calculation flag. */
233
234 struct list *opaque_lsa_self; /* Type-11 Opaque-LSAs */
235
236 /* Routing tables. */
237 struct route_table *old_table; /* Old routing table. */
238 struct route_table *new_table; /* Current routing table. */
239
240 struct route_table *oall_rtrs; /* Old router RT. */
241 struct route_table *all_rtrs; /* New routers RT. */
242
243 struct route_table *old_rtrs; /* Old ABR/ASBR RT. */
244 struct route_table *new_rtrs; /* New ABR/ASBR RT. */
245
246 struct route_table *new_external_route; /* New External Route. */
247 struct route_table *old_external_route; /* Old External Route. */
248
249 struct route_table *external_lsas; /* Database of external LSAs,
250 prefix is LSA's adv. network*/
251
252 /* Time stamps */
253 struct timeval ts_spf; /* SPF calculation time stamp. */
254 struct timeval ts_spf_duration; /* Execution time of last SPF */
255
256 struct route_table *maxage_lsa; /* List of MaxAge LSA for deletion. */
257 int redistribute; /* Num of redistributed protocols. */
258
259 /* Threads. */
260 struct thread *t_abr_task; /* ABR task timer. */
261 struct thread *t_abr_fr; /* ABR FR timer. */
262 struct thread *t_asbr_check; /* ASBR check timer. */
263 struct thread *t_asbr_nssa_redist_update; /* ASBR NSSA redistribution
264 update timer. */
265 struct thread *t_distribute_update; /* Distirbute list update timer. */
266 struct thread *t_spf_calc; /* SPF calculation timer. */
267 struct thread *t_ase_calc; /* ASE calculation timer. */
268 struct thread
269 *t_opaque_lsa_self; /* Type-11 Opaque-LSAs origin event. */
270 struct thread *t_sr_update; /* Segment Routing update timer */
271
272 unsigned int maxage_delay; /* Delay on Maxage remover timer, sec */
273 struct thread *t_maxage; /* MaxAge LSA remover timer. */
274 struct thread *t_maxage_walker; /* MaxAge LSA checking timer. */
275
276 struct thread
277 *t_deferred_shutdown; /* deferred/stub-router shutdown timer*/
278
279 struct thread *t_write;
280 #define OSPF_WRITE_INTERFACE_COUNT_DEFAULT 20
281 struct thread *t_default_routemap_timer;
282
283 int write_oi_count; /* Num of packets sent per thread invocation */
284 struct thread *t_read;
285 int fd;
286 struct stream *ibuf;
287 struct list *oi_write_q;
288
289 /* Distribute lists out of other route sources. */
290 struct {
291 char *name;
292 struct access_list *list;
293 } dlist[ZEBRA_ROUTE_MAX];
294 #define DISTRIBUTE_NAME(O,T) (O)->dlist[T].name
295 #define DISTRIBUTE_LIST(O,T) (O)->dlist[T].list
296
297 /* OSPF redistribute configuration */
298 struct list *redist[ZEBRA_ROUTE_MAX + 1];
299
300 /* Redistribute tag info. */
301 route_tag_t
302 dtag[ZEBRA_ROUTE_MAX + 1]; // Pending: cant configure as of now
303
304 int default_metric; /* Default metric for redistribute. */
305
306 #define OSPF_LSA_REFRESHER_GRANULARITY 10
307 #define OSPF_LSA_REFRESHER_SLOTS \
308 ((OSPF_LS_REFRESH_TIME + OSPF_LS_REFRESH_SHIFT) \
309 / OSPF_LSA_REFRESHER_GRANULARITY \
310 + 1)
311 struct {
312 uint16_t index;
313 struct list *qs[OSPF_LSA_REFRESHER_SLOTS];
314 } 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 uint16_t lsa_refresh_interval;
320 uint16_t lsa_refresh_timer;
321
322 /* Distance parameter. */
323 uint8_t distance_all;
324 uint8_t distance_intra;
325 uint8_t distance_inter;
326 uint8_t distance_external;
327
328 /* Statistics for LSA origination. */
329 uint32_t lsa_originate_count;
330
331 /* Statistics for LSA used for new instantiation. */
332 uint32_t rx_lsa_count;
333
334 struct route_table *distance_table;
335
336 /* Used during ospf instance going down send LSDB
337 * update to neighbors immediatly */
338 uint8_t inst_shutdown;
339
340 /* Enable or disable sending proactive ARP requests. */
341 bool proactive_arp;
342 #define OSPF_PROACTIVE_ARP_DEFAULT true
343
344 /* Redistributed external information. */
345 struct list *external[ZEBRA_ROUTE_MAX + 1];
346 #define EXTERNAL_INFO(E) (E->external_info)
347
348 /* Graceful restart Helper supported configs*/
349 /* Supported grace interval*/
350 uint32_t supported_grace_time;
351
352 /* Helper support
353 * Supported : True
354 * Not Supported : False.
355 */
356 bool is_helper_supported;
357
358 /* Support for strict LSA check.
359 * if it is set,Helper aborted
360 * upon a TOPO change.
361 */
362 bool strict_lsa_check;
363
364 /* Support as HELPER only for
365 * planned restarts.
366 */
367 bool only_planned_restart;
368
369 /* This list contains the advertisement
370 * routerids which are not support for HELPERs.
371 */
372 struct hash *enable_rtr_list;
373
374 /* HELPER for number of active
375 * RESTARTERs.
376 */
377 uint16_t active_restarter_cnt;
378
379 /* last HELPER exit reason */
380 uint32_t last_exit_reason;
381
382 /* delay timer to process external routes
383 * with summary address.
384 */
385 struct thread *t_external_aggr;
386
387 /* delay interval in seconds */
388 uint16_t aggr_delay_interval;
389
390 /* Table of configured Aggregate addresses */
391 struct route_table *rt_aggr_tbl;
392
393 /* used as argument for aggr delay
394 * timer thread.
395 */
396 int aggr_action;
397
398 /* Max number of multiple paths
399 * to support ECMP.
400 */
401 uint16_t max_multipath;
402
403 /* MPLS LDP-IGP Sync */
404 struct ldp_sync_info_cmd ldp_sync_cmd;
405
406 /* OSPF Graceful Restart info */
407 struct ospf_gr_info gr_info;
408
409 /* TI-LFA support for all interfaces. */
410 bool ti_lfa_enabled;
411 enum protection_type ti_lfa_protection_type;
412
413 /* Flood Reduction configuration state */
414 bool fr_configured;
415
416 QOBJ_FIELDS;
417 };
418 DECLARE_QOBJ_TYPE(ospf);
419
420 enum ospf_ti_lfa_p_q_space_adjacency {
421 OSPF_TI_LFA_P_Q_SPACE_ADJACENT,
422 OSPF_TI_LFA_P_Q_SPACE_NON_ADJACENT,
423 };
424
425 enum ospf_ti_lfa_node_type {
426 OSPF_TI_LFA_UNDEFINED_NODE,
427 OSPF_TI_LFA_PQ_NODE,
428 OSPF_TI_LFA_P_NODE,
429 OSPF_TI_LFA_Q_NODE,
430 };
431
432 struct ospf_ti_lfa_node_info {
433 struct vertex *node;
434 enum ospf_ti_lfa_node_type type;
435 struct in_addr nexthop;
436 };
437
438 struct ospf_ti_lfa_inner_backup_path_info {
439 struct ospf_ti_lfa_node_info p_node_info;
440 struct ospf_ti_lfa_node_info q_node_info;
441 struct mpls_label_stack *label_stack;
442 };
443
444 struct protected_resource {
445 enum protection_type type;
446
447 /* Link Protection */
448 struct router_lsa_link *link;
449
450 /* Node Protection */
451 struct in_addr router_id;
452 };
453
454 PREDECL_RBTREE_UNIQ(q_spaces);
455 struct q_space {
456 struct vertex *root;
457 struct list *vertex_list;
458 struct mpls_label_stack *label_stack;
459 struct in_addr nexthop;
460 struct list *pc_path;
461 struct ospf_ti_lfa_node_info *p_node_info;
462 struct ospf_ti_lfa_node_info *q_node_info;
463 struct q_spaces_item q_spaces_item;
464 };
465
466 PREDECL_RBTREE_UNIQ(p_spaces);
467 struct p_space {
468 struct vertex *root;
469 struct protected_resource *protected_resource;
470 struct q_spaces_head *q_spaces;
471 struct list *vertex_list;
472 struct vertex *pc_spf;
473 struct list *pc_vertex_list;
474 struct p_spaces_item p_spaces_item;
475 };
476
477 /* OSPF area structure. */
478 struct ospf_area {
479 /* OSPF instance. */
480 struct ospf *ospf;
481
482 /* Zebra interface list belonging to the area. */
483 struct list *oiflist;
484
485 /* Area ID. */
486 struct in_addr area_id;
487
488 /* Area ID format. */
489 int area_id_fmt;
490 #define OSPF_AREA_ID_FMT_DOTTEDQUAD 1
491 #define OSPF_AREA_ID_FMT_DECIMAL 2
492
493 /* Address range. */
494 struct list *address_range;
495
496 /* Configured variables. */
497 int external_routing; /* ExternalRoutingCapability. */
498 int no_summary; /* Don't inject summaries into stub.*/
499 int shortcut_configured; /* Area configured as shortcut. */
500 #define OSPF_SHORTCUT_DEFAULT 0
501 #define OSPF_SHORTCUT_ENABLE 1
502 #define OSPF_SHORTCUT_DISABLE 2
503 int shortcut_capability; /* Other ABRs agree on S-bit */
504 uint32_t default_cost; /* StubDefaultCost. */
505 int auth_type; /* Authentication type. */
506 int suppress_fa; /* Suppress forwarding address in NSSA ABR */
507
508 uint8_t NSSATranslatorRole; /* NSSA configured role */
509 #define OSPF_NSSA_ROLE_NEVER 0
510 #define OSPF_NSSA_ROLE_CANDIDATE 1
511 #define OSPF_NSSA_ROLE_ALWAYS 2
512 uint8_t NSSATranslatorState; /* NSSA operational role */
513 #define OSPF_NSSA_TRANSLATE_DISABLED 0
514 #define OSPF_NSSA_TRANSLATE_ENABLED 1
515 int NSSATranslatorStabilityInterval;
516
517 uint8_t transit; /* TransitCapability. */
518 #define OSPF_TRANSIT_FALSE 0
519 #define OSPF_TRANSIT_TRUE 1
520 struct route_table *ranges; /* Configured Area Ranges. */
521
522 /* RFC3137 stub router state flags for area */
523 uint8_t stub_router_state;
524 #define OSPF_AREA_ADMIN_STUB_ROUTED (1 << 0) /* admin stub-router set */
525 #define OSPF_AREA_IS_STUB_ROUTED (1 << 1) /* stub-router active */
526 #define OSPF_AREA_WAS_START_STUB_ROUTED (1 << 2) /* startup SR was done */
527 /* Area related LSDBs[Type1-4]. */
528 struct ospf_lsdb *lsdb;
529
530 /* Self-originated LSAs. */
531 struct ospf_lsa *router_lsa_self;
532 struct list *opaque_lsa_self; /* Type-10 Opaque-LSAs */
533
534 /* Area announce list. */
535 struct {
536 char *name;
537 struct access_list *list;
538 } _export;
539 #define EXPORT_NAME(A) (A)->_export.name
540 #define EXPORT_LIST(A) (A)->_export.list
541
542 /* Area acceptance list. */
543 struct {
544 char *name;
545 struct access_list *list;
546 } import;
547 #define IMPORT_NAME(A) (A)->import.name
548 #define IMPORT_LIST(A) (A)->import.list
549
550 /* Type 3 LSA Area prefix-list. */
551 struct {
552 char *name;
553 struct prefix_list *list;
554 } plist_in;
555 #define PREFIX_LIST_IN(A) (A)->plist_in.list
556 #define PREFIX_NAME_IN(A) (A)->plist_in.name
557
558 struct {
559 char *name;
560 struct prefix_list *list;
561 } plist_out;
562 #define PREFIX_LIST_OUT(A) (A)->plist_out.list
563 #define PREFIX_NAME_OUT(A) (A)->plist_out.name
564
565 /* Shortest Path Tree. */
566 struct vertex *spf;
567 struct list *spf_vertex_list;
568
569 bool spf_dry_run; /* flag for checking if the SPF calculation is
570 intended for the local RIB */
571 bool spf_root_node; /* flag for checking if the calculating node is the
572 root node of the SPF tree */
573
574 /* TI-LFA protected link for SPF calculations */
575 struct protected_resource *spf_protected_resource;
576
577 /* P/Q spaces for TI-LFA */
578 struct p_spaces_head *p_spaces;
579
580 /* Threads. */
581 struct thread *t_stub_router; /* Stub-router timer */
582 struct thread *t_opaque_lsa_self; /* Type-10 Opaque-LSAs origin. */
583
584 /* Statistics field. */
585 uint32_t spf_calculation; /* SPF Calculation Count. */
586
587 /* reverse SPF (used for TI-LFA Q spaces) */
588 bool spf_reversed;
589
590 /* Time stamps. */
591 struct timeval ts_spf; /* SPF calculation time stamp. */
592
593 /* Router count. */
594 uint32_t abr_count; /* ABR router in this area. */
595 uint32_t asbr_count; /* ASBR router in this area. */
596
597 /* Counters. */
598 uint32_t act_ints; /* Active interfaces. */
599 uint32_t full_nbrs; /* Fully adjacent neighbors. */
600 uint32_t full_vls; /* Fully adjacent virtual neighbors. */
601
602 struct ospf_area_fr_info fr_info; /* Flood reduction info. */
603 };
604
605 /* OSPF config network structure. */
606 struct ospf_network {
607 /* Area ID. */
608 struct in_addr area_id;
609 int area_id_fmt;
610 };
611
612 /* OSPF NBMA neighbor structure. */
613 struct ospf_nbr_nbma {
614 /* Neighbor IP address. */
615 struct in_addr addr;
616
617 /* OSPF interface. */
618 struct ospf_interface *oi;
619
620 /* OSPF neighbor structure. */
621 struct ospf_neighbor *nbr;
622
623 /* Neighbor priority. */
624 uint8_t priority;
625
626 /* Poll timer value. */
627 uint32_t v_poll;
628
629 /* Poll timer thread. */
630 struct thread *t_poll;
631
632 /* State change. */
633 uint32_t state_change;
634 };
635
636 /* Macro. */
637 #define OSPF_AREA_SAME(X, Y) \
638 (memcmp((X->area_id), (Y->area_id), IPV4_MAX_BYTELEN) == 0)
639
640 #define IS_OSPF_ABR(O) ((O)->flags & OSPF_FLAG_ABR)
641 #define IS_OSPF_ASBR(O) ((O)->flags & OSPF_FLAG_ASBR)
642
643 #define OSPF_IS_AREA_ID_BACKBONE(I) ((I).s_addr == OSPF_AREA_BACKBONE)
644 #define OSPF_IS_AREA_BACKBONE(A) OSPF_IS_AREA_ID_BACKBONE ((A)->area_id)
645
646 #ifdef roundup
647 # define ROUNDUP(val, gran) roundup(val, gran)
648 #else /* roundup */
649 # define ROUNDUP(val, gran) (((val) - 1 | (gran) - 1) + 1)
650 #endif /* roundup */
651
652 #define LSA_OPTIONS_GET(area) \
653 (((area)->external_routing == OSPF_AREA_DEFAULT) ? OSPF_OPTION_E : 0)
654 #define LSA_OPTIONS_NSSA_GET(area) \
655 (((area)->external_routing == OSPF_AREA_NSSA) ? OSPF_OPTION_NP : 0)
656
657 #define OSPF_TIMER_ON(T,F,V) thread_add_timer (master,(F),ospf,(V),&(T))
658 #define OSPF_AREA_TIMER_ON(T,F,V) thread_add_timer (master, (F), area, (V), &(T))
659 #define OSPF_POLL_TIMER_ON(T,F,V) thread_add_timer (master, (F), nbr_nbma, (V), &(T))
660
661 /* Extern variables. */
662 extern struct ospf_master *om;
663 extern unsigned short ospf_instance;
664 extern const int ospf_redistributed_proto_max;
665 extern struct zclient *zclient;
666 extern struct thread_master *master;
667 extern int ospf_zlog;
668 extern struct zebra_privs_t ospfd_privs;
669
670 /* Prototypes. */
671 extern const char *ospf_redist_string(unsigned int route_type);
672 extern struct ospf *ospf_lookup_instance(unsigned short instance);
673 extern struct ospf *ospf_lookup(unsigned short instance, const char *name);
674 extern struct ospf *ospf_get(unsigned short instance, const char *name,
675 bool *created);
676 extern struct ospf *ospf_new_alloc(unsigned short instance, const char *name);
677 extern struct ospf *ospf_lookup_by_inst_name(unsigned short instance,
678 const char *name);
679 extern struct ospf *ospf_lookup_by_vrf_id(vrf_id_t vrf_id);
680 extern uint32_t ospf_count_area_params(struct ospf *ospf);
681 extern void ospf_finish(struct ospf *ospf);
682 extern void ospf_process_refresh_data(struct ospf *ospf, bool reset);
683 extern void ospf_router_id_update(struct ospf *ospf);
684 extern void ospf_process_reset(struct ospf *ospf);
685 extern void ospf_neighbor_reset(struct ospf *ospf, struct in_addr nbr_id,
686 const char *nbr_str);
687 extern int ospf_network_set(struct ospf *ospf, struct prefix_ipv4 *p,
688 struct in_addr area_id, int df);
689 extern int ospf_network_unset(struct ospf *ospf, struct prefix_ipv4 *p,
690 struct in_addr aread_id);
691 extern int ospf_area_display_format_set(struct ospf *ospf,
692 struct ospf_area *area, int df);
693 extern int ospf_area_stub_set(struct ospf *ospf, struct in_addr area_id);
694 extern int ospf_area_stub_unset(struct ospf *ospf, struct in_addr area_id);
695 extern int ospf_area_no_summary_set(struct ospf *ospf, struct in_addr area_id);
696 extern int ospf_area_no_summary_unset(struct ospf *ospf,
697 struct in_addr area_id);
698 extern int ospf_area_nssa_set(struct ospf *ospf, struct in_addr area_id);
699 extern int ospf_area_nssa_unset(struct ospf *ospf, struct in_addr area_id,
700 int argc);
701 extern int ospf_area_nssa_suppress_fa_set(struct ospf *ospf,
702 struct in_addr area_id);
703 extern int ospf_area_nssa_suppress_fa_unset(struct ospf *ospf,
704 struct in_addr area_id);
705 extern int ospf_area_nssa_translator_role_set(struct ospf *ospf,
706 struct in_addr area_id, int role);
707 extern int ospf_area_export_list_set(struct ospf *ospf,
708 struct ospf_area *area_id,
709 const char *list_name);
710 extern int ospf_area_export_list_unset(struct ospf *ospf,
711 struct ospf_area *area_id);
712 extern int ospf_area_import_list_set(struct ospf *ospf,
713 struct ospf_area *area_id,
714 const char *name);
715 extern int ospf_area_import_list_unset(struct ospf *ospf,
716 struct ospf_area *area_id);
717 extern int ospf_area_shortcut_set(struct ospf *ospf, struct ospf_area *area_id,
718 int mode);
719 extern int ospf_area_shortcut_unset(struct ospf *ospf,
720 struct ospf_area *area_id);
721 extern int ospf_timers_refresh_set(struct ospf *ospf, int interval);
722 extern int ospf_timers_refresh_unset(struct ospf *ospf);
723 void ospf_area_lsdb_discard_delete(struct ospf_area *area);
724 extern int ospf_nbr_nbma_set(struct ospf *ospf, struct in_addr nbr_addr);
725 extern int ospf_nbr_nbma_unset(struct ospf *ospf, struct in_addr nbr_addr);
726 extern int ospf_nbr_nbma_priority_set(struct ospf *ospf,
727 struct in_addr nbr_addr,
728 uint8_t priority);
729 extern int ospf_nbr_nbma_priority_unset(struct ospf *ospf,
730 struct in_addr nbr_addr);
731 extern int ospf_nbr_nbma_poll_interval_set(struct ospf *ospf,
732 struct in_addr nbr_addr,
733 unsigned int interval);
734 extern int ospf_nbr_nbma_poll_interval_unset(struct ospf *ospf,
735 struct in_addr addr);
736 extern void ospf_if_update(struct ospf *ospf, struct interface *ifp);
737 extern void ospf_ls_upd_queue_empty(struct ospf_interface *oi);
738 extern void ospf_terminate(void);
739 extern void ospf_nbr_nbma_if_update(struct ospf *ospf,
740 struct ospf_interface *oi);
741 extern struct ospf_nbr_nbma *ospf_nbr_nbma_lookup(struct ospf *ospf,
742 struct in_addr nbr_addr);
743 extern int ospf_oi_count(struct interface *ifp);
744
745 extern struct ospf_area *ospf_area_new(struct ospf *ospf,
746 struct in_addr area_id);
747 extern struct ospf_area *ospf_area_get(struct ospf *ospf,
748 struct in_addr area_id);
749 extern void ospf_area_check_free(struct ospf *ospf, struct in_addr area_id);
750 extern struct ospf_area *ospf_area_lookup_by_area_id(struct ospf *ospf,
751 struct in_addr area_id);
752 extern void ospf_area_add_if(struct ospf_area *oa, struct ospf_interface *oi);
753 extern void ospf_area_del_if(struct ospf_area *oa, struct ospf_interface *oi);
754
755 extern void ospf_interface_area_set(struct ospf *ospf, struct interface *ifp);
756 extern void ospf_interface_area_unset(struct ospf *ospf, struct interface *ifp);
757
758 extern void ospf_route_map_init(void);
759
760 extern void ospf_master_init(struct thread_master *master);
761 extern void ospf_vrf_init(void);
762 extern void ospf_vrf_terminate(void);
763 extern void ospf_vrf_link(struct ospf *ospf, struct vrf *vrf);
764 extern void ospf_vrf_unlink(struct ospf *ospf, struct vrf *vrf);
765 const char *ospf_vrf_id_to_name(vrf_id_t vrf_id);
766 int ospf_area_nssa_no_summary_set(struct ospf *ospf, struct in_addr area_id);
767
768 const char *ospf_get_name(const struct ospf *ospf);
769 extern struct ospf_interface *add_ospf_interface(struct connected *co,
770 struct ospf_area *area);
771
772 extern int p_spaces_compare_func(const struct p_space *a,
773 const struct p_space *b);
774 extern int q_spaces_compare_func(const struct q_space *a,
775 const struct q_space *b);
776
777 #endif /* _ZEBRA_OSPFD_H */