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