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