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