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