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