]>
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> |
ae19c240 | 26 | #include "qobj.h" |
8551e6da | 27 | #include "libospf.h" |
c514adc6 | 28 | |
718e3744 | 29 | #include "filter.h" |
343f5cc7 | 30 | #include "log.h" |
b5a8894d | 31 | #include "vrf.h" |
718e3744 | 32 | |
4a1ab8e4 | 33 | #include "ospf_memory.h" |
0a3fc2a5 | 34 | #include "ospf_dump_api.h" |
4a1ab8e4 | 35 | |
718e3744 | 36 | #define OSPF_VERSION 2 |
37 | ||
718e3744 | 38 | /* VTY port number. */ |
39 | #define OSPF_VTY_PORT 2604 | |
718e3744 | 40 | |
41 | /* IP TTL for OSPF protocol. */ | |
42 | #define OSPF_IP_TTL 1 | |
43 | #define OSPF_VL_IP_TTL 100 | |
44 | ||
45 | /* Default configuration file name for ospfd. */ | |
46 | #define OSPF_DEFAULT_CONFIG "ospfd.conf" | |
47 | ||
464c8204 | 48 | #define OSPF_NSSA_TRANS_STABLE_DEFAULT 40 |
718e3744 | 49 | |
50 | #define OSPF_ALLSPFROUTERS 0xe0000005 /* 224.0.0.5 */ | |
51 | #define OSPF_ALLDROUTERS 0xe0000006 /* 224.0.0.6 */ | |
52 | ||
718e3744 | 53 | /* OSPF Authentication Type. */ |
54 | #define OSPF_AUTH_NULL 0 | |
55 | #define OSPF_AUTH_SIMPLE 1 | |
56 | #define OSPF_AUTH_CRYPTOGRAPHIC 2 | |
57 | /* For Interface authentication setting default */ | |
58 | #define OSPF_AUTH_NOTSET -1 | |
d62a17ae | 59 | /* For the consumption and sanity of the command handler */ |
718e3744 | 60 | /* DO NIOT REMOVE!!! Need to detect whether a value has |
61 | been given or not in VLink command handlers */ | |
62 | #define OSPF_AUTH_CMD_NOTSEEN -2 | |
63 | ||
718e3744 | 64 | /* OSPF options. */ |
16f1b9ee | 65 | #define OSPF_OPTION_MT 0x01 /* M/T */ |
718e3744 | 66 | #define OSPF_OPTION_E 0x02 |
67 | #define OSPF_OPTION_MC 0x04 | |
68 | #define OSPF_OPTION_NP 0x08 | |
69 | #define OSPF_OPTION_EA 0x10 | |
70 | #define OSPF_OPTION_DC 0x20 | |
71 | #define OSPF_OPTION_O 0x40 | |
16f1b9ee | 72 | #define OSPF_OPTION_DN 0x80 |
718e3744 | 73 | |
74 | /* OSPF Database Description flags. */ | |
75 | #define OSPF_DD_FLAG_MS 0x01 | |
76 | #define OSPF_DD_FLAG_M 0x02 | |
77 | #define OSPF_DD_FLAG_I 0x04 | |
78 | #define OSPF_DD_FLAG_ALL 0x07 | |
79 | ||
718e3744 | 80 | #define OSPF_LS_REFRESH_SHIFT (60 * 15) |
81 | #define OSPF_LS_REFRESH_JITTER 60 | |
82 | ||
d62a17ae | 83 | struct ospf_external { |
d7c0a89a | 84 | unsigned short instance; |
d62a17ae | 85 | struct route_table *external_info; |
7c8ff89e DS |
86 | }; |
87 | ||
020709f9 | 88 | /* OSPF master for system wide configuration and variables. */ |
d62a17ae | 89 | struct ospf_master { |
90 | /* OSPF instance. */ | |
91 | struct list *ospf; | |
020709f9 | 92 | |
d62a17ae | 93 | /* OSPF thread master. */ |
94 | struct thread_master *master; | |
020709f9 | 95 | |
d62a17ae | 96 | /* Various OSPF global configuration. */ |
d7c0a89a | 97 | uint8_t options; |
32ab5cf4 | 98 | #define OSPF_MASTER_SHUTDOWN (1 << 0) /* deferred-shutdown */ |
020709f9 | 99 | }; |
100 | ||
d62a17ae | 101 | struct ospf_redist { |
d7c0a89a | 102 | unsigned short instance; |
d62a17ae | 103 | |
104 | /* Redistribute metric info. */ | |
105 | struct { | |
106 | int type; /* External metric type (E1 or E2). */ | |
107 | int value; /* Value for static metric (24-bit). | |
108 | -1 means metric value is not set. */ | |
109 | } dmetric; | |
110 | ||
111 | /* For redistribute route map. */ | |
112 | struct { | |
113 | char *name; | |
114 | struct route_map *map; | |
115 | } route_map; /* +1 is for default-information */ | |
7c8ff89e DS |
116 | #define ROUTEMAP_NAME(R) (R->route_map.name) |
117 | #define ROUTEMAP(R) (R->route_map.map) | |
118 | }; | |
119 | ||
c572fbfe DL |
120 | /* ospf->config */ |
121 | enum { | |
122 | OSPF_RFC1583_COMPATIBLE = (1 << 0), | |
123 | OSPF_OPAQUE_CAPABLE = (1 << 2), | |
124 | OSPF_LOG_ADJACENCY_CHANGES = (1 << 3), | |
125 | OSPF_LOG_ADJACENCY_DETAIL = (1 << 4), | |
126 | }; | |
127 | ||
718e3744 | 128 | /* OSPF instance structure. */ |
d62a17ae | 129 | struct ospf { |
130 | /* OSPF's running state based on the '[no] router ospf [<instance>]' | |
131 | * config. */ | |
d7c0a89a | 132 | uint8_t oi_running; |
0bad4851 | 133 | |
d62a17ae | 134 | /* OSPF instance ID */ |
d7c0a89a | 135 | unsigned short instance; |
7c8ff89e | 136 | |
d62a17ae | 137 | /* OSPF Router ID. */ |
138 | struct in_addr router_id; /* Configured automatically. */ | |
139 | struct in_addr router_id_static; /* Configured manually. */ | |
6021c6c0 | 140 | struct in_addr router_id_zebra; |
718e3744 | 141 | |
996c9314 LB |
142 | vrf_id_t vrf_id; /* VRF Id */ |
143 | char *name; /* VRF name */ | |
b5a8894d | 144 | |
d62a17ae | 145 | /* ABR/ASBR internal flags. */ |
d7c0a89a | 146 | uint8_t flags; |
718e3744 | 147 | #define OSPF_FLAG_ABR 0x0001 |
148 | #define OSPF_FLAG_ASBR 0x0002 | |
149 | ||
d62a17ae | 150 | /* ABR type. */ |
d7c0a89a | 151 | uint8_t abr_type; |
718e3744 | 152 | #define OSPF_ABR_UNKNOWN 0 |
153 | #define OSPF_ABR_STAND 1 | |
154 | #define OSPF_ABR_IBM 2 | |
155 | #define OSPF_ABR_CISCO 3 | |
156 | #define OSPF_ABR_SHORTCUT 4 | |
d57834f6 | 157 | #define OSPF_ABR_DEFAULT OSPF_ABR_CISCO |
718e3744 | 158 | |
d62a17ae | 159 | /* NSSA ABR */ |
d7c0a89a | 160 | uint8_t anyNSSA; /* Bump for every NSSA attached. */ |
718e3744 | 161 | |
c572fbfe | 162 | /* Configuration bitmask, refer to enum above */ |
d7c0a89a | 163 | uint8_t config; |
718e3744 | 164 | |
d62a17ae | 165 | /* Opaque-LSA administrative flags. */ |
d7c0a89a | 166 | uint8_t opaque; |
718e3744 | 167 | #define OPAQUE_OPERATION_READY_BIT (1 << 0) |
718e3744 | 168 | |
d62a17ae | 169 | /* RFC3137 stub router. Configured time to stay stub / max-metric */ |
170 | unsigned int stub_router_startup_time; /* seconds */ | |
171 | unsigned int stub_router_shutdown_time; /* seconds */ | |
88d6cf37 | 172 | #define OSPF_STUB_ROUTER_UNCONFIGURED 0 |
d7c0a89a | 173 | uint8_t stub_router_admin_set; |
4ba4fc85 AB |
174 | #define OSPF_STUB_ROUTER_ADMINISTRATIVE_SET 1 |
175 | #define OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET 0 | |
88d6cf37 | 176 | |
b4154c14 JR |
177 | #define OSPF_STUB_MAX_METRIC_SUMMARY_COST 0x00ff0000 |
178 | ||
d62a17ae | 179 | /* LSA timers */ |
180 | unsigned int min_ls_interval; /* minimum delay between LSAs (in msec) */ | |
181 | unsigned int min_ls_arrival; /* minimum interarrival time between LSAs | |
182 | (in msec) */ | |
183 | ||
184 | /* SPF parameters */ | |
185 | unsigned int spf_delay; /* SPF delay time. */ | |
186 | unsigned int spf_holdtime; /* SPF hold time. */ | |
187 | unsigned int spf_max_holdtime; /* SPF maximum-holdtime */ | |
188 | unsigned int | |
189 | spf_hold_multiplier; /* Adaptive multiplier for hold time */ | |
190 | ||
191 | int default_originate; /* Default information originate. */ | |
718e3744 | 192 | #define DEFAULT_ORIGINATE_NONE 0 |
193 | #define DEFAULT_ORIGINATE_ZEBRA 1 | |
194 | #define DEFAULT_ORIGINATE_ALWAYS 2 | |
d7c0a89a | 195 | uint32_t ref_bandwidth; /* Reference Bandwidth (Kbps). */ |
d62a17ae | 196 | struct route_table *networks; /* OSPF config networks. */ |
197 | struct list *vlinks; /* Configured Virtual-Links. */ | |
198 | struct list *areas; /* OSPF areas. */ | |
199 | struct route_table *nbr_nbma; | |
200 | struct ospf_area *backbone; /* Pointer to the Backbone Area. */ | |
201 | ||
202 | struct list *oiflist; /* ospf interfaces */ | |
d7c0a89a | 203 | uint8_t passive_interface_default; /* passive-interface default */ |
d62a17ae | 204 | |
205 | /* LSDB of AS-external-LSAs. */ | |
206 | struct ospf_lsdb *lsdb; | |
207 | ||
208 | /* Flags. */ | |
d62a17ae | 209 | int ase_calc; /* ASE calculation flag. */ |
210 | ||
211 | struct list *opaque_lsa_self; /* Type-11 Opaque-LSAs */ | |
212 | ||
213 | /* Routing tables. */ | |
214 | struct route_table *old_table; /* Old routing table. */ | |
215 | struct route_table *new_table; /* Current routing table. */ | |
216 | ||
217 | struct route_table *old_rtrs; /* Old ABR/ASBR RT. */ | |
218 | struct route_table *new_rtrs; /* New ABR/ASBR RT. */ | |
219 | ||
220 | struct route_table *new_external_route; /* New External Route. */ | |
221 | struct route_table *old_external_route; /* Old External Route. */ | |
222 | ||
223 | struct route_table *external_lsas; /* Database of external LSAs, | |
224 | prefix is LSA's adv. network*/ | |
225 | ||
226 | /* Time stamps */ | |
227 | struct timeval ts_spf; /* SPF calculation time stamp. */ | |
228 | struct timeval ts_spf_duration; /* Execution time of last SPF */ | |
229 | ||
230 | struct route_table *maxage_lsa; /* List of MaxAge LSA for deletion. */ | |
231 | int redistribute; /* Num of redistributed protocols. */ | |
232 | ||
233 | /* Threads. */ | |
234 | struct thread *t_abr_task; /* ABR task timer. */ | |
235 | struct thread *t_asbr_check; /* ASBR check timer. */ | |
236 | struct thread *t_distribute_update; /* Distirbute list update timer. */ | |
237 | struct thread *t_spf_calc; /* SPF calculation timer. */ | |
238 | struct thread *t_ase_calc; /* ASE calculation timer. */ | |
d62a17ae | 239 | struct thread |
240 | *t_opaque_lsa_self; /* Type-11 Opaque-LSAs origin event. */ | |
cf9b9f77 | 241 | struct thread *t_sr_update; /* Segment Routing update timer */ |
d62a17ae | 242 | |
243 | unsigned int maxage_delay; /* Delay on Maxage remover timer, sec */ | |
244 | struct thread *t_maxage; /* MaxAge LSA remover timer. */ | |
245 | struct thread *t_maxage_walker; /* MaxAge LSA checking timer. */ | |
246 | ||
247 | struct thread | |
248 | *t_deferred_shutdown; /* deferred/stub-router shutdown timer*/ | |
249 | ||
250 | struct thread *t_write; | |
e8f45e82 | 251 | #define OSPF_WRITE_INTERFACE_COUNT_DEFAULT 20 |
d62a17ae | 252 | int write_oi_count; /* Num of packets sent per thread invocation */ |
253 | struct thread *t_read; | |
254 | int fd; | |
255 | struct stream *ibuf; | |
256 | struct list *oi_write_q; | |
257 | ||
258 | /* Distribute lists out of other route sources. */ | |
259 | struct { | |
260 | char *name; | |
261 | struct access_list *list; | |
262 | } dlist[ZEBRA_ROUTE_MAX]; | |
020709f9 | 263 | #define DISTRIBUTE_NAME(O,T) (O)->dlist[T].name |
264 | #define DISTRIBUTE_LIST(O,T) (O)->dlist[T].list | |
718e3744 | 265 | |
d62a17ae | 266 | /* OSPF redistribute configuration */ |
267 | struct list *redist[ZEBRA_ROUTE_MAX + 1]; | |
718e3744 | 268 | |
d62a17ae | 269 | /* Redistribute tag info. */ |
270 | route_tag_t | |
271 | dtag[ZEBRA_ROUTE_MAX + 1]; // Pending: cant configure as of now | |
0d9551dc | 272 | |
d62a17ae | 273 | int default_metric; /* Default metric for redistribute. */ |
718e3744 | 274 | |
275 | #define OSPF_LSA_REFRESHER_GRANULARITY 10 | |
d62a17ae | 276 | #define OSPF_LSA_REFRESHER_SLOTS \ |
277 | ((OSPF_LS_REFRESH_TIME + OSPF_LS_REFRESH_SHIFT) \ | |
278 | / OSPF_LSA_REFRESHER_GRANULARITY \ | |
279 | + 1) | |
280 | struct { | |
d7c0a89a | 281 | uint16_t index; |
d62a17ae | 282 | struct list *qs[OSPF_LSA_REFRESHER_SLOTS]; |
283 | } lsa_refresh_queue; | |
284 | ||
285 | struct thread *t_lsa_refresher; | |
286 | time_t lsa_refresher_started; | |
718e3744 | 287 | #define OSPF_LSA_REFRESH_INTERVAL_DEFAULT 10 |
d7c0a89a | 288 | uint16_t lsa_refresh_interval; |
d62a17ae | 289 | |
290 | /* Distance parameter. */ | |
d7c0a89a QY |
291 | uint8_t distance_all; |
292 | uint8_t distance_intra; | |
293 | uint8_t distance_inter; | |
294 | uint8_t distance_external; | |
d62a17ae | 295 | |
296 | /* Statistics for LSA origination. */ | |
d7c0a89a | 297 | uint32_t lsa_originate_count; |
d62a17ae | 298 | |
299 | /* Statistics for LSA used for new instantiation. */ | |
d7c0a89a | 300 | uint32_t rx_lsa_count; |
d62a17ae | 301 | |
aed7cc62 CS |
302 | /* Counter of "ip ospf area x.x.x.x" used |
303 | * for multual exclusion of network command under | |
304 | * router ospf or ip ospf area x under interface. */ | |
d7c0a89a | 305 | uint32_t if_ospf_cli_count; |
d62a17ae | 306 | |
307 | struct route_table *distance_table; | |
308 | ||
046460a1 CS |
309 | /* Used during ospf instance going down send LSDB |
310 | * update to neighbors immediatly */ | |
311 | uint8_t inst_shutdown; | |
312 | ||
de1ac5fd CS |
313 | /* Redistributed external information. */ |
314 | struct list *external[ZEBRA_ROUTE_MAX + 1]; | |
315 | #define EXTERNAL_INFO(E) (E->external_info) | |
316 | ||
d62a17ae | 317 | QOBJ_FIELDS |
718e3744 | 318 | }; |
ae19c240 | 319 | DECLARE_QOBJ_TYPE(ospf) |
718e3744 | 320 | |
321 | /* OSPF area structure. */ | |
d62a17ae | 322 | struct ospf_area { |
323 | /* OSPF instance. */ | |
324 | struct ospf *ospf; | |
718e3744 | 325 | |
d62a17ae | 326 | /* Zebra interface list belonging to the area. */ |
327 | struct list *oiflist; | |
718e3744 | 328 | |
d62a17ae | 329 | /* Area ID. */ |
330 | struct in_addr area_id; | |
718e3744 | 331 | |
d62a17ae | 332 | /* Area ID format. */ |
333 | int area_id_fmt; | |
86573dcb QY |
334 | #define OSPF_AREA_ID_FMT_DOTTEDQUAD 1 |
335 | #define OSPF_AREA_ID_FMT_DECIMAL 2 | |
718e3744 | 336 | |
d62a17ae | 337 | /* Address range. */ |
338 | struct list *address_range; | |
718e3744 | 339 | |
d62a17ae | 340 | /* Configured variables. */ |
341 | int external_routing; /* ExternalRoutingCapability. */ | |
342 | int no_summary; /* Don't inject summaries into stub.*/ | |
343 | int shortcut_configured; /* Area configured as shortcut. */ | |
718e3744 | 344 | #define OSPF_SHORTCUT_DEFAULT 0 |
345 | #define OSPF_SHORTCUT_ENABLE 1 | |
346 | #define OSPF_SHORTCUT_DISABLE 2 | |
d62a17ae | 347 | int shortcut_capability; /* Other ABRs agree on S-bit */ |
d7c0a89a | 348 | uint32_t default_cost; /* StubDefaultCost. */ |
d62a17ae | 349 | int auth_type; /* Authentication type. */ |
718e3744 | 350 | |
d62a17ae | 351 | |
d7c0a89a | 352 | uint8_t NSSATranslatorRole; /* NSSA configured role */ |
718e3744 | 353 | #define OSPF_NSSA_ROLE_NEVER 0 |
d4a53d58 | 354 | #define OSPF_NSSA_ROLE_CANDIDATE 1 |
355 | #define OSPF_NSSA_ROLE_ALWAYS 2 | |
d7c0a89a | 356 | uint8_t NSSATranslatorState; /* NSSA operational role */ |
d4a53d58 | 357 | #define OSPF_NSSA_TRANSLATE_DISABLED 0 |
358 | #define OSPF_NSSA_TRANSLATE_ENABLED 1 | |
d62a17ae | 359 | int NSSATranslatorStabilityInterval; |
360 | ||
d7c0a89a | 361 | uint8_t transit; /* TransitCapability. */ |
718e3744 | 362 | #define OSPF_TRANSIT_FALSE 0 |
363 | #define OSPF_TRANSIT_TRUE 1 | |
d62a17ae | 364 | struct route_table *ranges; /* Configured Area Ranges. */ |
365 | ||
366 | /* RFC3137 stub router state flags for area */ | |
d7c0a89a | 367 | uint8_t stub_router_state; |
88d6cf37 | 368 | #define OSPF_AREA_ADMIN_STUB_ROUTED (1 << 0) /* admin stub-router set */ |
369 | #define OSPF_AREA_IS_STUB_ROUTED (1 << 1) /* stub-router active */ | |
370 | #define OSPF_AREA_WAS_START_STUB_ROUTED (1 << 2) /* startup SR was done */ | |
d62a17ae | 371 | /* Area related LSDBs[Type1-4]. */ |
372 | struct ospf_lsdb *lsdb; | |
373 | ||
374 | /* Self-originated LSAs. */ | |
375 | struct ospf_lsa *router_lsa_self; | |
376 | struct list *opaque_lsa_self; /* Type-10 Opaque-LSAs */ | |
377 | ||
378 | /* Area announce list. */ | |
379 | struct { | |
380 | char *name; | |
381 | struct access_list *list; | |
382 | } _export; | |
dea04441 PJ |
383 | #define EXPORT_NAME(A) (A)->_export.name |
384 | #define EXPORT_LIST(A) (A)->_export.list | |
718e3744 | 385 | |
d62a17ae | 386 | /* Area acceptance list. */ |
387 | struct { | |
388 | char *name; | |
389 | struct access_list *list; | |
390 | } import; | |
718e3744 | 391 | #define IMPORT_NAME(A) (A)->import.name |
392 | #define IMPORT_LIST(A) (A)->import.list | |
393 | ||
d62a17ae | 394 | /* Type 3 LSA Area prefix-list. */ |
395 | struct { | |
396 | char *name; | |
397 | struct prefix_list *list; | |
398 | } plist_in; | |
718e3744 | 399 | #define PREFIX_LIST_IN(A) (A)->plist_in.list |
400 | #define PREFIX_NAME_IN(A) (A)->plist_in.name | |
401 | ||
d62a17ae | 402 | struct { |
403 | char *name; | |
404 | struct prefix_list *list; | |
405 | } plist_out; | |
718e3744 | 406 | #define PREFIX_LIST_OUT(A) (A)->plist_out.list |
407 | #define PREFIX_NAME_OUT(A) (A)->plist_out.name | |
408 | ||
d62a17ae | 409 | /* Shortest Path Tree. */ |
410 | struct vertex *spf; | |
718e3744 | 411 | |
d62a17ae | 412 | /* Threads. */ |
413 | struct thread *t_stub_router; /* Stub-router timer */ | |
414 | struct thread *t_opaque_lsa_self; /* Type-10 Opaque-LSAs origin. */ | |
718e3744 | 415 | |
d62a17ae | 416 | /* Statistics field. */ |
d7c0a89a | 417 | uint32_t spf_calculation; /* SPF Calculation Count. */ |
718e3744 | 418 | |
d62a17ae | 419 | /* Time stamps. */ |
420 | struct timeval ts_spf; /* SPF calculation time stamp. */ | |
cf744958 | 421 | |
d62a17ae | 422 | /* Router count. */ |
d7c0a89a QY |
423 | uint32_t abr_count; /* ABR router in this area. */ |
424 | uint32_t asbr_count; /* ASBR router in this area. */ | |
718e3744 | 425 | |
d62a17ae | 426 | /* Counters. */ |
d7c0a89a QY |
427 | uint32_t act_ints; /* Active interfaces. */ |
428 | uint32_t full_nbrs; /* Fully adjacent neighbors. */ | |
429 | uint32_t full_vls; /* Fully adjacent virtual neighbors. */ | |
718e3744 | 430 | }; |
431 | ||
432 | /* OSPF config network structure. */ | |
d62a17ae | 433 | struct ospf_network { |
434 | /* Area ID. */ | |
435 | struct in_addr area_id; | |
436 | int area_id_fmt; | |
718e3744 | 437 | }; |
438 | ||
439 | /* OSPF NBMA neighbor structure. */ | |
d62a17ae | 440 | struct ospf_nbr_nbma { |
441 | /* Neighbor IP address. */ | |
442 | struct in_addr addr; | |
718e3744 | 443 | |
d62a17ae | 444 | /* OSPF interface. */ |
445 | struct ospf_interface *oi; | |
718e3744 | 446 | |
d62a17ae | 447 | /* OSPF neighbor structure. */ |
448 | struct ospf_neighbor *nbr; | |
718e3744 | 449 | |
d62a17ae | 450 | /* Neighbor priority. */ |
d7c0a89a | 451 | uint8_t priority; |
718e3744 | 452 | |
d62a17ae | 453 | /* Poll timer value. */ |
d7c0a89a | 454 | uint32_t v_poll; |
718e3744 | 455 | |
d62a17ae | 456 | /* Poll timer thread. */ |
457 | struct thread *t_poll; | |
718e3744 | 458 | |
d62a17ae | 459 | /* State change. */ |
d7c0a89a | 460 | uint32_t state_change; |
718e3744 | 461 | }; |
462 | ||
463 | /* Macro. */ | |
d62a17ae | 464 | #define OSPF_AREA_SAME(X, Y) \ |
465 | (memcmp((X->area_id), (Y->area_id), IPV4_MAX_BYTELEN) == 0) | |
718e3744 | 466 | |
020709f9 | 467 | #define IS_OSPF_ABR(O) ((O)->flags & OSPF_FLAG_ABR) |
468 | #define IS_OSPF_ASBR(O) ((O)->flags & OSPF_FLAG_ASBR) | |
718e3744 | 469 | |
470 | #define OSPF_IS_AREA_ID_BACKBONE(I) ((I).s_addr == OSPF_AREA_BACKBONE) | |
471 | #define OSPF_IS_AREA_BACKBONE(A) OSPF_IS_AREA_ID_BACKBONE ((A)->area_id) | |
472 | ||
473 | #ifdef roundup | |
474 | # define ROUNDUP(val, gran) roundup(val, gran) | |
d62a17ae | 475 | #else /* roundup */ |
718e3744 | 476 | # define ROUNDUP(val, gran) (((val) - 1 | (gran) - 1) + 1) |
477 | #endif /* roundup */ | |
478 | ||
d62a17ae | 479 | #define LSA_OPTIONS_GET(area) \ |
480 | (((area)->external_routing == OSPF_AREA_DEFAULT) ? OSPF_OPTION_E : 0) | |
481 | #define LSA_OPTIONS_NSSA_GET(area) \ | |
482 | (((area)->external_routing == OSPF_AREA_NSSA) ? OSPF_OPTION_NP : 0) | |
718e3744 | 483 | |
ffa2c898 QY |
484 | #define OSPF_TIMER_ON(T,F,V) thread_add_timer (master,(F),ospf,(V),&(T)) |
485 | #define OSPF_AREA_TIMER_ON(T,F,V) thread_add_timer (master, (F), area, (V), &(T)) | |
486 | #define OSPF_POLL_TIMER_ON(T,F,V) thread_add_timer (master, (F), nbr_nbma, (V), &(T)) | |
487 | #define OSPF_POLL_TIMER_OFF(X) OSPF_TIMER_OFF((X)) | |
d62a17ae | 488 | #define OSPF_TIMER_OFF(X) \ |
489 | do { \ | |
490 | if (X) { \ | |
491 | thread_cancel(X); \ | |
492 | (X) = NULL; \ | |
493 | } \ | |
494 | } while (0) | |
718e3744 | 495 | |
020709f9 | 496 | /* Extern variables. */ |
497 | extern struct ospf_master *om; | |
7ba82f70 | 498 | extern const int ospf_redistributed_proto_max; |
718e3744 | 499 | extern struct zclient *zclient; |
500 | extern struct thread_master *master; | |
718e3744 | 501 | extern int ospf_zlog; |
e5c25022 | 502 | extern struct zebra_privs_t ospfd_privs; |
718e3744 | 503 | |
504 | /* Prototypes. */ | |
d7c0a89a QY |
505 | extern const char *ospf_redist_string(unsigned int route_type); |
506 | extern struct ospf *ospf_lookup_instance(unsigned short); | |
c572fbfe DL |
507 | extern struct ospf *ospf_get(unsigned short instance, const char *name, |
508 | bool *created); | |
509 | extern struct ospf *ospf_get_instance(unsigned short, bool *created); | |
d7c0a89a | 510 | extern struct ospf *ospf_lookup_by_inst_name(unsigned short instance, |
b5a8894d CS |
511 | const char *name); |
512 | extern struct ospf *ospf_lookup_by_vrf_id(vrf_id_t vrf_id); | |
d62a17ae | 513 | extern void ospf_finish(struct ospf *); |
514 | extern void ospf_router_id_update(struct ospf *ospf); | |
515 | extern int ospf_network_set(struct ospf *, struct prefix_ipv4 *, struct in_addr, | |
516 | int); | |
517 | extern int ospf_network_unset(struct ospf *, struct prefix_ipv4 *, | |
518 | struct in_addr); | |
519 | extern int ospf_area_display_format_set(struct ospf *, struct ospf_area *area, | |
520 | int df); | |
521 | extern int ospf_area_stub_set(struct ospf *, struct in_addr); | |
522 | extern int ospf_area_stub_unset(struct ospf *, struct in_addr); | |
523 | extern int ospf_area_no_summary_set(struct ospf *, struct in_addr); | |
524 | extern int ospf_area_no_summary_unset(struct ospf *, struct in_addr); | |
525 | extern int ospf_area_nssa_set(struct ospf *, struct in_addr); | |
7ef56a73 | 526 | extern int ospf_area_nssa_unset(struct ospf *, struct in_addr, int); |
d62a17ae | 527 | extern int ospf_area_nssa_translator_role_set(struct ospf *, struct in_addr, |
528 | int); | |
529 | extern int ospf_area_export_list_set(struct ospf *, struct ospf_area *, | |
530 | const char *); | |
531 | extern int ospf_area_export_list_unset(struct ospf *, struct ospf_area *); | |
532 | extern int ospf_area_import_list_set(struct ospf *, struct ospf_area *, | |
533 | const char *); | |
534 | extern int ospf_area_import_list_unset(struct ospf *, struct ospf_area *); | |
535 | extern int ospf_area_shortcut_set(struct ospf *, struct ospf_area *, int); | |
536 | extern int ospf_area_shortcut_unset(struct ospf *, struct ospf_area *); | |
537 | extern int ospf_timers_refresh_set(struct ospf *, int); | |
538 | extern int ospf_timers_refresh_unset(struct ospf *); | |
539 | extern int ospf_nbr_nbma_set(struct ospf *, struct in_addr); | |
540 | extern int ospf_nbr_nbma_unset(struct ospf *, struct in_addr); | |
d7c0a89a | 541 | extern int ospf_nbr_nbma_priority_set(struct ospf *, struct in_addr, uint8_t); |
d62a17ae | 542 | extern int ospf_nbr_nbma_priority_unset(struct ospf *, struct in_addr); |
543 | extern int ospf_nbr_nbma_poll_interval_set(struct ospf *, struct in_addr, | |
544 | unsigned int); | |
545 | extern int ospf_nbr_nbma_poll_interval_unset(struct ospf *, struct in_addr); | |
546 | extern void ospf_prefix_list_update(struct prefix_list *); | |
547 | extern void ospf_init(void); | |
548 | extern void ospf_if_update(struct ospf *, struct interface *); | |
549 | extern void ospf_ls_upd_queue_empty(struct ospf_interface *); | |
550 | extern void ospf_terminate(void); | |
551 | extern void ospf_nbr_nbma_if_update(struct ospf *, struct ospf_interface *); | |
552 | extern struct ospf_nbr_nbma *ospf_nbr_nbma_lookup(struct ospf *, | |
553 | struct in_addr); | |
554 | extern struct ospf_nbr_nbma *ospf_nbr_nbma_lookup_next(struct ospf *, | |
555 | struct in_addr *, int); | |
556 | extern int ospf_oi_count(struct interface *); | |
557 | ||
558 | extern struct ospf_area *ospf_area_get(struct ospf *, struct in_addr); | |
559 | extern void ospf_area_check_free(struct ospf *, struct in_addr); | |
560 | extern struct ospf_area *ospf_area_lookup_by_area_id(struct ospf *, | |
561 | struct in_addr); | |
562 | extern void ospf_area_add_if(struct ospf_area *, struct ospf_interface *); | |
563 | extern void ospf_area_del_if(struct ospf_area *, struct ospf_interface *); | |
564 | ||
b5a8894d CS |
565 | extern void ospf_interface_area_set(struct ospf *, struct interface *); |
566 | extern void ospf_interface_area_unset(struct ospf *, struct interface *); | |
e9f07a30 PG |
567 | extern bool ospf_interface_area_is_already_set(struct ospf *ospf, |
568 | struct interface *ifp); | |
d62a17ae | 569 | |
570 | extern void ospf_route_map_init(void); | |
571 | ||
572 | extern void ospf_master_init(struct thread_master *master); | |
b5a8894d CS |
573 | extern void ospf_vrf_init(void); |
574 | extern void ospf_vrf_terminate(void); | |
575 | extern void ospf_vrf_link(struct ospf *ospf, struct vrf *vrf); | |
576 | extern void ospf_vrf_unlink(struct ospf *ospf, struct vrf *vrf); | |
577 | const char *ospf_vrf_id_to_name(vrf_id_t vrf_id); | |
7ef56a73 CS |
578 | int ospf_area_nssa_no_summary_set(struct ospf *, struct in_addr); |
579 | ||
88b6b28e | 580 | const char *ospf_get_name(const struct ospf *ospf); |
718e3744 | 581 | #endif /* _ZEBRA_OSPFD_H */ |