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