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