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