paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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. |
| 11 | * |
| 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 | |
| 26 | #include "filter.h" |
| 27 | |
| 28 | #define OSPF_VERSION 2 |
| 29 | |
| 30 | /* Default protocol, port number. */ |
| 31 | #ifndef IPPROTO_OSPFIGP |
| 32 | #define IPPROTO_OSPFIGP 89 |
| 33 | #endif /* IPPROTO_OSPFIGP */ |
| 34 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 35 | /* IP precedence. */ |
| 36 | #ifndef IPTOS_PREC_INTERNETCONTROL |
| 37 | #define IPTOS_PREC_INTERNETCONTROL 0xC0 |
| 38 | #endif /* IPTOS_PREC_INTERNETCONTROL */ |
| 39 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 40 | /* VTY port number. */ |
| 41 | #define OSPF_VTY_PORT 2604 |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 | |
| 50 | /* Architectual Constants */ |
| 51 | #ifdef DEBUG |
| 52 | #define OSPF_LS_REFRESH_TIME 60 |
| 53 | #else |
| 54 | #define OSPF_LS_REFRESH_TIME 1800 |
| 55 | #endif |
| 56 | #define OSPF_MIN_LS_INTERVAL 5 |
| 57 | #define OSPF_MIN_LS_ARRIVAL 1 |
| 58 | #define OSPF_LSA_MAXAGE 3600 |
| 59 | #define OSPF_CHECK_AGE 300 |
| 60 | #define OSPF_LSA_MAXAGE_DIFF 900 |
| 61 | #define OSPF_LS_INFINITY 0xffffff |
| 62 | #define OSPF_DEFAULT_DESTINATION 0x00000000 /* 0.0.0.0 */ |
| 63 | #define OSPF_INITIAL_SEQUENCE_NUMBER 0x80000001 |
| 64 | #define OSPF_MAX_SEQUENCE_NUMBER 0x7fffffff |
| 65 | |
| 66 | #define OSPF_LSA_MAXAGE_CHECK_INTERVAL 30 |
| 67 | |
| 68 | #define OSPF_ALLSPFROUTERS 0xe0000005 /* 224.0.0.5 */ |
| 69 | #define OSPF_ALLDROUTERS 0xe0000006 /* 224.0.0.6 */ |
| 70 | |
| 71 | #ifdef HAVE_NSSA |
| 72 | #define OSPF_LOOPer 0x7f000000 /* 127.0.0.0 */ |
| 73 | #endif /* HAVE_NSSA */ |
| 74 | |
| 75 | #define OSPF_AREA_BACKBONE 0x00000000 /* 0.0.0.0 */ |
| 76 | |
| 77 | /* OSPF Authentication Type. */ |
| 78 | #define OSPF_AUTH_NULL 0 |
| 79 | #define OSPF_AUTH_SIMPLE 1 |
| 80 | #define OSPF_AUTH_CRYPTOGRAPHIC 2 |
| 81 | /* For Interface authentication setting default */ |
| 82 | #define OSPF_AUTH_NOTSET -1 |
| 83 | /* For the consumption and sanity of the command handler */ |
| 84 | /* DO NIOT REMOVE!!! Need to detect whether a value has |
| 85 | been given or not in VLink command handlers */ |
| 86 | #define OSPF_AUTH_CMD_NOTSEEN -2 |
| 87 | |
| 88 | /* OSPF SPF timer values. */ |
paul | 800d615 | 2003-05-29 17:26:24 +0000 | [diff] [blame] | 89 | #define OSPF_SPF_DELAY_DEFAULT 1 |
| 90 | #define OSPF_SPF_HOLDTIME_DEFAULT 1 |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 91 | |
| 92 | /* OSPF interface default values. */ |
| 93 | #define OSPF_OUTPUT_COST_DEFAULT 10 |
| 94 | #define OSPF_ROUTER_DEAD_INTERVAL_DEFAULT 40 |
| 95 | #define OSPF_HELLO_INTERVAL_DEFAULT 10 |
| 96 | #define OSPF_ROUTER_PRIORITY_DEFAULT 1 |
| 97 | #define OSPF_RETRANSMIT_INTERVAL_DEFAULT 5 |
| 98 | #define OSPF_TRANSMIT_DELAY_DEFAULT 1 |
| 99 | #define OSPF_DEFAULT_BANDWIDTH 10000 /* Kbps */ |
| 100 | |
| 101 | #define OSPF_DEFAULT_REF_BANDWIDTH 100000 /* Kbps */ |
| 102 | |
| 103 | #define OSPF_POLL_INTERVAL_DEFAULT 60 |
| 104 | #define OSPF_NEIGHBOR_PRIORITY_DEFAULT 0 |
| 105 | |
| 106 | /* OSPF options. */ |
| 107 | #define OSPF_OPTION_T 0x01 /* TOS. */ |
| 108 | #define OSPF_OPTION_E 0x02 |
| 109 | #define OSPF_OPTION_MC 0x04 |
| 110 | #define OSPF_OPTION_NP 0x08 |
| 111 | #define OSPF_OPTION_EA 0x10 |
| 112 | #define OSPF_OPTION_DC 0x20 |
| 113 | #define OSPF_OPTION_O 0x40 |
| 114 | |
| 115 | /* OSPF Database Description flags. */ |
| 116 | #define OSPF_DD_FLAG_MS 0x01 |
| 117 | #define OSPF_DD_FLAG_M 0x02 |
| 118 | #define OSPF_DD_FLAG_I 0x04 |
| 119 | #define OSPF_DD_FLAG_ALL 0x07 |
| 120 | |
| 121 | /* Timer value. */ |
| 122 | #define OSPF_ROUTER_ID_UPDATE_DELAY 1 |
| 123 | |
| 124 | #define OSPF_LS_REFRESH_SHIFT (60 * 15) |
| 125 | #define OSPF_LS_REFRESH_JITTER 60 |
| 126 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 127 | /* OSPF master for system wide configuration and variables. */ |
| 128 | struct ospf_master |
| 129 | { |
| 130 | /* OSPF instance. */ |
| 131 | struct list *ospf; |
| 132 | |
| 133 | /* OSPF thread master. */ |
| 134 | struct thread_master *master; |
| 135 | |
| 136 | /* Zebra interface list. */ |
| 137 | struct list *iflist; |
| 138 | |
| 139 | /* Redistributed external information. */ |
| 140 | struct route_table *external_info[ZEBRA_ROUTE_MAX + 1]; |
| 141 | #define EXTERNAL_INFO(T) om->external_info[T] |
| 142 | |
| 143 | /* OSPF start time. */ |
| 144 | time_t start_time; |
| 145 | |
| 146 | /* Various OSPF global configuration. */ |
| 147 | u_char options; |
| 148 | }; |
| 149 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 150 | /* OSPF instance structure. */ |
| 151 | struct ospf |
| 152 | { |
| 153 | /* OSPF Router ID. */ |
| 154 | struct in_addr router_id; /* Configured automatically. */ |
| 155 | struct in_addr router_id_static; /* Configured manually. */ |
| 156 | |
| 157 | /* ABR/ASBR internal flags. */ |
| 158 | u_char flags; |
| 159 | #define OSPF_FLAG_ABR 0x0001 |
| 160 | #define OSPF_FLAG_ASBR 0x0002 |
| 161 | |
| 162 | /* ABR type. */ |
| 163 | u_char abr_type; |
| 164 | #define OSPF_ABR_UNKNOWN 0 |
| 165 | #define OSPF_ABR_STAND 1 |
| 166 | #define OSPF_ABR_IBM 2 |
| 167 | #define OSPF_ABR_CISCO 3 |
| 168 | #define OSPF_ABR_SHORTCUT 4 |
| 169 | |
| 170 | /* NSSA ABR */ |
| 171 | u_char anyNSSA; /* Bump for every NSSA attached. */ |
| 172 | |
| 173 | /* Configured variables. */ |
| 174 | u_char config; |
| 175 | #define OSPF_RFC1583_COMPATIBLE (1 << 0) |
| 176 | #define OSPF_OPAQUE_CAPABLE (1 << 2) |
| 177 | |
| 178 | #ifdef HAVE_OPAQUE_LSA |
| 179 | /* Opaque-LSA administrative flags. */ |
| 180 | u_char opaque; |
| 181 | #define OPAQUE_OPERATION_READY_BIT (1 << 0) |
| 182 | #define OPAQUE_BLOCK_TYPE_09_LSA_BIT (1 << 1) |
| 183 | #define OPAQUE_BLOCK_TYPE_10_LSA_BIT (1 << 2) |
| 184 | #define OPAQUE_BLOCK_TYPE_11_LSA_BIT (1 << 3) |
| 185 | #endif /* HAVE_OPAQUE_LSA */ |
| 186 | |
| 187 | int spf_delay; /* SPF delay time. */ |
| 188 | int spf_holdtime; /* SPF hold time. */ |
| 189 | int default_originate; /* Default information originate. */ |
| 190 | #define DEFAULT_ORIGINATE_NONE 0 |
| 191 | #define DEFAULT_ORIGINATE_ZEBRA 1 |
| 192 | #define DEFAULT_ORIGINATE_ALWAYS 2 |
| 193 | u_int32_t ref_bandwidth; /* Reference Bandwidth (Kbps). */ |
| 194 | struct route_table *networks; /* OSPF config networks. */ |
| 195 | list vlinks; /* Configured Virtual-Links. */ |
| 196 | list areas; /* OSPF areas. */ |
| 197 | struct route_table *nbr_nbma; |
| 198 | struct ospf_area *backbone; /* Pointer to the Backbone Area. */ |
| 199 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 200 | list oiflist; /* ospf interfaces */ |
| 201 | |
| 202 | /* LSDB of AS-external-LSAs. */ |
| 203 | struct ospf_lsdb *lsdb; |
| 204 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 205 | /* Flags. */ |
| 206 | int external_origin; /* AS-external-LSA origin flag. */ |
| 207 | int ase_calc; /* ASE calculation flag. */ |
| 208 | |
| 209 | #ifdef HAVE_OPAQUE_LSA |
| 210 | list opaque_lsa_self; /* Type-11 Opaque-LSAs */ |
| 211 | #endif /* HAVE_OPAQUE_LSA */ |
| 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 | time_t ts_spf; /* SPF calculation time stamp. */ |
| 228 | |
| 229 | list maxage_lsa; /* List of MaxAge LSA for deletion. */ |
| 230 | int redistribute; /* Num of redistributed protocols. */ |
| 231 | |
| 232 | /* Threads. */ |
| 233 | struct thread *t_router_id_update; /* Router ID update timer. */ |
| 234 | struct thread *t_router_lsa_update; /* router-LSA update timer. */ |
| 235 | struct thread *t_abr_task; /* ABR task timer. */ |
| 236 | struct thread *t_asbr_check; /* ASBR check timer. */ |
| 237 | struct thread *t_distribute_update; /* Distirbute list update timer. */ |
| 238 | struct thread *t_spf_calc; /* SPF calculation timer. */ |
| 239 | struct thread *t_ase_calc; /* ASE calculation timer. */ |
| 240 | struct thread *t_external_lsa; /* AS-external-LSA origin timer. */ |
| 241 | #ifdef HAVE_OPAQUE_LSA |
| 242 | struct thread *t_opaque_lsa_self; /* Type-11 Opaque-LSAs origin event. */ |
| 243 | #endif /* HAVE_OPAQUE_LSA */ |
| 244 | struct thread *t_maxage; /* MaxAge LSA remover timer. */ |
| 245 | struct thread *t_maxage_walker; /* MaxAge LSA checking timer. */ |
| 246 | |
| 247 | struct thread *t_write; |
| 248 | struct thread *t_read; |
| 249 | int fd; |
| 250 | list oi_write_q; |
| 251 | |
| 252 | /* Distribute lists out of other route sources. */ |
| 253 | struct |
| 254 | { |
| 255 | char *name; |
| 256 | struct access_list *list; |
| 257 | } dlist[ZEBRA_ROUTE_MAX]; |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 258 | #define DISTRIBUTE_NAME(O,T) (O)->dlist[T].name |
| 259 | #define DISTRIBUTE_LIST(O,T) (O)->dlist[T].list |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 260 | |
| 261 | /* Redistribute metric info. */ |
| 262 | struct |
| 263 | { |
| 264 | int type; /* External metric type (E1 or E2). */ |
| 265 | int value; /* Value for static metric (24-bit). |
| 266 | -1 means metric value is not set. */ |
| 267 | } dmetric [ZEBRA_ROUTE_MAX + 1]; |
| 268 | |
| 269 | /* For redistribute route map. */ |
| 270 | struct |
| 271 | { |
| 272 | char *name; |
| 273 | struct route_map *map; |
| 274 | } route_map [ZEBRA_ROUTE_MAX + 1]; /* +1 is for default-information */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 275 | #define ROUTEMAP_NAME(O,T) (O)->route_map[T].name |
| 276 | #define ROUTEMAP(O,T) (O)->route_map[T].map |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 277 | |
| 278 | int default_metric; /* Default metric for redistribute. */ |
| 279 | |
| 280 | #define OSPF_LSA_REFRESHER_GRANULARITY 10 |
| 281 | #define OSPF_LSA_REFRESHER_SLOTS ((OSPF_LS_REFRESH_TIME + \ |
| 282 | OSPF_LS_REFRESH_SHIFT)/10 + 1) |
| 283 | struct |
| 284 | { |
| 285 | u_int16_t index; |
| 286 | list qs[OSPF_LSA_REFRESHER_SLOTS]; |
| 287 | } lsa_refresh_queue; |
| 288 | |
| 289 | struct thread *t_lsa_refresher; |
| 290 | time_t lsa_refresher_started; |
| 291 | #define OSPF_LSA_REFRESH_INTERVAL_DEFAULT 10 |
| 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 | struct route_table *distance_table; |
| 307 | }; |
| 308 | |
| 309 | /* OSPF area structure. */ |
| 310 | struct ospf_area |
| 311 | { |
| 312 | /* OSPF instance. */ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 313 | struct ospf *ospf; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 314 | |
| 315 | /* Zebra interface list belonging to the area. */ |
| 316 | list oiflist; |
| 317 | |
| 318 | /* Area ID. */ |
| 319 | struct in_addr area_id; |
| 320 | |
| 321 | /* Area ID format. */ |
| 322 | char format; |
| 323 | #define OSPF_AREA_ID_FORMAT_ADDRESS 1 |
| 324 | #define OSPF_AREA_ID_FORMAT_DECIMAL 2 |
| 325 | |
| 326 | /* Address range. */ |
| 327 | list address_range; |
| 328 | |
| 329 | /* Configured variables. */ |
| 330 | int external_routing; /* ExternalRoutingCapability. */ |
| 331 | #define OSPF_AREA_DEFAULT 0 |
| 332 | #define OSPF_AREA_STUB 1 |
| 333 | #define OSPF_AREA_NSSA 2 |
| 334 | #define OSPF_AREA_TYPE_MAX 3 |
| 335 | int no_summary; /* Don't inject summaries into stub.*/ |
| 336 | int shortcut_configured; /* Area configured as shortcut. */ |
| 337 | #define OSPF_SHORTCUT_DEFAULT 0 |
| 338 | #define OSPF_SHORTCUT_ENABLE 1 |
| 339 | #define OSPF_SHORTCUT_DISABLE 2 |
| 340 | int shortcut_capability; /* Other ABRs agree on S-bit */ |
| 341 | u_int32_t default_cost; /* StubDefaultCost. */ |
| 342 | int auth_type; /* Authentication type. */ |
| 343 | |
| 344 | u_char NSSATranslatorRole; /* NSSA Role during configuration */ |
| 345 | #define OSPF_NSSA_ROLE_NEVER 0 |
| 346 | #define OSPF_NSSA_ROLE_ALWAYS 1 |
| 347 | #define OSPF_NSSA_ROLE_CANDIDATE 2 |
| 348 | u_char NSSATranslator; /* NSSA Role after election process */ |
| 349 | |
| 350 | u_char transit; /* TransitCapability. */ |
| 351 | #define OSPF_TRANSIT_FALSE 0 |
| 352 | #define OSPF_TRANSIT_TRUE 1 |
| 353 | struct route_table *ranges; /* Configured Area Ranges. */ |
| 354 | |
| 355 | /* Area related LSDBs[Type1-4]. */ |
| 356 | struct ospf_lsdb *lsdb; |
| 357 | |
| 358 | /* Self-originated LSAs. */ |
| 359 | struct ospf_lsa *router_lsa_self; |
| 360 | #ifdef HAVE_OPAQUE_LSA |
| 361 | list opaque_lsa_self; /* Type-10 Opaque-LSAs */ |
| 362 | #endif /* HAVE_OPAQUE_LSA */ |
| 363 | |
| 364 | /* Area announce list. */ |
| 365 | struct |
| 366 | { |
| 367 | char *name; |
| 368 | struct access_list *list; |
| 369 | } export; |
| 370 | #define EXPORT_NAME(A) (A)->export.name |
| 371 | #define EXPORT_LIST(A) (A)->export.list |
| 372 | |
| 373 | /* Area acceptance list. */ |
| 374 | struct |
| 375 | { |
| 376 | char *name; |
| 377 | struct access_list *list; |
| 378 | } import; |
| 379 | #define IMPORT_NAME(A) (A)->import.name |
| 380 | #define IMPORT_LIST(A) (A)->import.list |
| 381 | |
| 382 | /* Type 3 LSA Area prefix-list. */ |
| 383 | struct |
| 384 | { |
| 385 | char *name; |
| 386 | struct prefix_list *list; |
| 387 | } plist_in; |
| 388 | #define PREFIX_LIST_IN(A) (A)->plist_in.list |
| 389 | #define PREFIX_NAME_IN(A) (A)->plist_in.name |
| 390 | |
| 391 | struct |
| 392 | { |
| 393 | char *name; |
| 394 | struct prefix_list *list; |
| 395 | } plist_out; |
| 396 | #define PREFIX_LIST_OUT(A) (A)->plist_out.list |
| 397 | #define PREFIX_NAME_OUT(A) (A)->plist_out.name |
| 398 | |
| 399 | /* Shortest Path Tree. */ |
| 400 | struct vertex *spf; |
| 401 | |
| 402 | /* Threads. */ |
| 403 | struct thread *t_router_lsa_self;/* Self-originated router-LSA timer. */ |
| 404 | #ifdef HAVE_OPAQUE_LSA |
| 405 | struct thread *t_opaque_lsa_self; /* Type-10 Opaque-LSAs origin. */ |
| 406 | #endif /* HAVE_OPAQUE_LSA */ |
| 407 | |
| 408 | /* Statistics field. */ |
| 409 | u_int32_t spf_calculation; /* SPF Calculation Count. */ |
| 410 | |
| 411 | /* Router count. */ |
| 412 | u_int32_t abr_count; /* ABR router in this area. */ |
| 413 | u_int32_t asbr_count; /* ASBR router in this area. */ |
| 414 | |
| 415 | /* Counters. */ |
| 416 | u_int32_t act_ints; /* Active interfaces. */ |
| 417 | u_int32_t full_nbrs; /* Fully adjacent neighbors. */ |
| 418 | u_int32_t full_vls; /* Fully adjacent virtual neighbors. */ |
| 419 | }; |
| 420 | |
| 421 | /* OSPF config network structure. */ |
| 422 | struct ospf_network |
| 423 | { |
| 424 | /* Area ID. */ |
| 425 | struct in_addr area_id; |
| 426 | int format; |
| 427 | }; |
| 428 | |
| 429 | /* OSPF NBMA neighbor structure. */ |
| 430 | struct ospf_nbr_nbma |
| 431 | { |
| 432 | /* Neighbor IP address. */ |
| 433 | struct in_addr addr; |
| 434 | |
| 435 | /* OSPF interface. */ |
| 436 | struct ospf_interface *oi; |
| 437 | |
| 438 | /* OSPF neighbor structure. */ |
| 439 | struct ospf_neighbor *nbr; |
| 440 | |
| 441 | /* Neighbor priority. */ |
| 442 | u_char priority; |
| 443 | |
| 444 | /* Poll timer value. */ |
| 445 | u_int32_t v_poll; |
| 446 | |
| 447 | /* Poll timer thread. */ |
| 448 | struct thread *t_poll; |
| 449 | |
| 450 | /* State change. */ |
| 451 | u_int32_t state_change; |
| 452 | }; |
| 453 | |
| 454 | /* Macro. */ |
| 455 | #define OSPF_AREA_SAME(X,Y) \ |
| 456 | (memcmp ((X->area_id), (Y->area_id), IPV4_MAX_BYTELEN) == 0) |
| 457 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 458 | #define IS_OSPF_ABR(O) ((O)->flags & OSPF_FLAG_ABR) |
| 459 | #define IS_OSPF_ASBR(O) ((O)->flags & OSPF_FLAG_ASBR) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 460 | |
| 461 | #define OSPF_IS_AREA_ID_BACKBONE(I) ((I).s_addr == OSPF_AREA_BACKBONE) |
| 462 | #define OSPF_IS_AREA_BACKBONE(A) OSPF_IS_AREA_ID_BACKBONE ((A)->area_id) |
| 463 | |
| 464 | #ifdef roundup |
| 465 | # define ROUNDUP(val, gran) roundup(val, gran) |
| 466 | #else /* roundup */ |
| 467 | # define ROUNDUP(val, gran) (((val) - 1 | (gran) - 1) + 1) |
| 468 | #endif /* roundup */ |
| 469 | |
| 470 | #define LSA_OPTIONS_GET(area) \ |
| 471 | (((area)->external_routing == OSPF_AREA_DEFAULT) ? OSPF_OPTION_E : 0) |
| 472 | #ifdef HAVE_NSSA |
| 473 | #define LSA_NSSA_GET(area) \ |
| 474 | (((area)->external_routing == OSPF_AREA_NSSA) ? \ |
| 475 | (area)->NSSATranslator : 0) |
| 476 | #endif /* HAVE_NSSA */ |
| 477 | |
| 478 | #define OSPF_TIMER_ON(T,F,V) \ |
| 479 | do { \ |
| 480 | if (!(T)) \ |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 481 | (T) = thread_add_timer (master, (F), ospf, (V)); \ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 482 | } while (0) |
| 483 | |
| 484 | #define OSPF_AREA_TIMER_ON(T,F,V) \ |
| 485 | do { \ |
| 486 | if (!(T)) \ |
| 487 | (T) = thread_add_timer (master, (F), area, (V)); \ |
| 488 | } while (0) |
| 489 | |
| 490 | #define OSPF_POLL_TIMER_ON(T,F,V) \ |
| 491 | do { \ |
| 492 | if (!(T)) \ |
| 493 | (T) = thread_add_timer (master, (F), nbr_nbma, (V)); \ |
| 494 | } while (0) |
| 495 | |
| 496 | #define OSPF_POLL_TIMER_OFF(X) OSPF_TIMER_OFF((X)) |
| 497 | |
| 498 | #define OSPF_TIMER_OFF(X) \ |
| 499 | do { \ |
| 500 | if (X) \ |
| 501 | { \ |
| 502 | thread_cancel (X); \ |
| 503 | (X) = NULL; \ |
| 504 | } \ |
| 505 | } while (0) |
| 506 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 507 | /* Extern variables. */ |
| 508 | extern struct ospf_master *om; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 509 | extern struct message ospf_ism_state_msg[]; |
| 510 | extern struct message ospf_nsm_state_msg[]; |
| 511 | extern struct message ospf_lsa_type_msg[]; |
| 512 | extern struct message ospf_link_state_id_type_msg[]; |
| 513 | extern struct message ospf_redistributed_proto[]; |
| 514 | extern struct message ospf_network_type_msg[]; |
| 515 | extern int ospf_ism_state_msg_max; |
| 516 | extern int ospf_nsm_state_msg_max; |
| 517 | extern int ospf_lsa_type_msg_max; |
| 518 | extern int ospf_link_state_id_type_msg_max; |
| 519 | extern int ospf_redistributed_proto_max; |
| 520 | extern int ospf_network_type_msg_max; |
| 521 | extern struct zclient *zclient; |
| 522 | extern struct thread_master *master; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 523 | extern int ospf_zlog; |
| 524 | |
| 525 | /* Prototypes. */ |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 526 | struct ospf *ospf_lookup (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 527 | struct ospf *ospf_get (); |
| 528 | void ospf_finish (struct ospf *); |
| 529 | int ospf_router_id_update_timer (struct thread *); |
| 530 | void ospf_router_id_update (); |
paul | 570f759 | 2003-01-25 06:47:41 +0000 | [diff] [blame] | 531 | int ospf_network_match_iface (struct connected *, struct prefix *); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 532 | int ospf_network_set (struct ospf *, struct prefix_ipv4 *, struct in_addr); |
| 533 | int ospf_network_unset (struct ospf *, struct prefix_ipv4 *, struct in_addr); |
| 534 | int ospf_area_stub_set (struct ospf *, struct in_addr); |
| 535 | int ospf_area_stub_unset (struct ospf *, struct in_addr); |
| 536 | int ospf_area_no_summary_set (struct ospf *, struct in_addr); |
| 537 | int ospf_area_no_summary_unset (struct ospf *, struct in_addr); |
| 538 | int ospf_area_nssa_set (struct ospf *, struct in_addr); |
| 539 | int ospf_area_nssa_unset (struct ospf *, struct in_addr); |
| 540 | int ospf_area_nssa_translator_role_set (struct ospf *, struct in_addr, int); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 541 | int ospf_area_export_list_set (struct ospf *, struct ospf_area *, char *); |
| 542 | int ospf_area_export_list_unset (struct ospf *, struct ospf_area *); |
| 543 | int ospf_area_import_list_set (struct ospf *, struct ospf_area *, char *); |
| 544 | int ospf_area_import_list_unset (struct ospf *, struct ospf_area *); |
| 545 | int ospf_area_shortcut_set (struct ospf *, struct ospf_area *, int); |
| 546 | int ospf_area_shortcut_unset (struct ospf *, struct ospf_area *); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 547 | int ospf_timers_spf_set (struct ospf *, u_int32_t, u_int32_t); |
| 548 | int ospf_timers_spf_unset (struct ospf *); |
| 549 | int ospf_timers_refresh_set (struct ospf *, int); |
| 550 | int ospf_timers_refresh_unset (struct ospf *); |
| 551 | int ospf_nbr_nbma_set (struct ospf *, struct in_addr); |
| 552 | int ospf_nbr_nbma_unset (struct ospf *, struct in_addr); |
| 553 | int ospf_nbr_nbma_priority_set (struct ospf *, struct in_addr, u_char); |
| 554 | int ospf_nbr_nbma_priority_unset (struct ospf *, struct in_addr); |
| 555 | int ospf_nbr_nbma_poll_interval_set (struct ospf *, struct in_addr, int); |
| 556 | int ospf_nbr_nbma_poll_interval_unset (struct ospf *, struct in_addr); |
| 557 | void ospf_prefix_list_update (struct prefix_list *); |
| 558 | void ospf_init (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 559 | void ospf_if_update (struct ospf *); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 560 | void ospf_ls_upd_queue_empty (struct ospf_interface *); |
| 561 | void ospf_terminate (); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 562 | void ospf_nbr_nbma_if_update (struct ospf *, struct ospf_interface *); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 563 | struct ospf_nbr_nbma *ospf_nbr_nbma_lookup (struct ospf *, struct in_addr); |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 564 | struct ospf_nbr_nbma *ospf_nbr_nbma_lookup_next (struct ospf *, |
| 565 | struct in_addr *, int); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 566 | int ospf_oi_count (struct interface *); |
| 567 | |
paul | 6898008 | 2003-03-25 05:07:42 +0000 | [diff] [blame] | 568 | struct ospf_area *ospf_area_get (struct ospf *, struct in_addr, int); |
| 569 | void ospf_area_check_free (struct ospf *, struct in_addr); |
| 570 | struct ospf_area *ospf_area_lookup_by_area_id (struct ospf *, struct in_addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 571 | void ospf_area_add_if (struct ospf_area *, struct ospf_interface *); |
| 572 | void ospf_area_del_if (struct ospf_area *, struct ospf_interface *); |
| 573 | |
| 574 | void ospf_route_map_init (); |
| 575 | void ospf_snmp_init (); |
| 576 | |
paul | 020709f | 2003-04-04 02:44:16 +0000 | [diff] [blame] | 577 | void ospf_master_init (); |
| 578 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 579 | #endif /* _ZEBRA_OSPFD_H */ |