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