jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * IS-IS Rout(e)ing protocol - isis_events.h |
| 3 | * |
| 4 | * Copyright (C) 2001,2002 Sampo Saaristo |
| 5 | * Tampere University of Technology |
| 6 | * Institute of Communications Engineering |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public Licenseas published by the Free |
| 10 | * Software Foundation; either version 2 of the License, or (at your option) |
| 11 | * any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful,but WITHOUT |
| 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 16 | * more details. |
| 17 | |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 21 | */ |
| 22 | #include <stdlib.h> |
| 23 | #include <stdio.h> |
| 24 | #include <ctype.h> |
| 25 | #include <zebra.h> |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 26 | |
| 27 | #include "log.h" |
| 28 | #include "memory.h" |
| 29 | #include "if.h" |
| 30 | #include "linklist.h" |
| 31 | #include "command.h" |
| 32 | #include "thread.h" |
| 33 | #include "hash.h" |
| 34 | #include "prefix.h" |
| 35 | #include "stream.h" |
| 36 | |
| 37 | #include "isisd/dict.h" |
| 38 | #include "isisd/include-netbsd/iso.h" |
| 39 | #include "isisd/isis_constants.h" |
| 40 | #include "isisd/isis_common.h" |
| 41 | #include "isisd/isis_circuit.h" |
| 42 | #include "isisd/isis_tlv.h" |
| 43 | #include "isisd/isis_lsp.h" |
| 44 | #include "isisd/isis_pdu.h" |
| 45 | #include "isisd/isis_network.h" |
| 46 | #include "isisd/isis_misc.h" |
| 47 | #include "isisd/isis_constants.h" |
| 48 | #include "isisd/isis_adjacency.h" |
| 49 | #include "isisd/isis_dr.h" |
| 50 | #include "isisd/isis_flags.h" |
| 51 | #include "isisd/isisd.h" |
| 52 | #include "isisd/isis_csm.h" |
| 53 | #include "isisd/isis_events.h" |
| 54 | #include "isisd/isis_spf.h" |
| 55 | |
| 56 | extern struct thread_master *master; |
| 57 | extern struct isis *isis; |
| 58 | |
| 59 | /* debug isis-spf spf-events |
| 60 | 4w4d: ISIS-Spf (tlt): L2 SPF needed, new adjacency, from 0x609229F4 |
| 61 | 4w4d: ISIS-Spf (tlt): L2, 0000.0000.0042.01-00 TLV contents changed, code 0x2 |
| 62 | 4w4d: ISIS-Spf (tlt): L2, new LSP 0 DEAD.BEEF.0043.00-00 |
| 63 | 4w5d: ISIS-Spf (tlt): L1 SPF needed, periodic SPF, from 0x6091C844 |
| 64 | 4w5d: ISIS-Spf (tlt): L2 SPF needed, periodic SPF, from 0x6091C844 |
| 65 | */ |
| 66 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 67 | void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 68 | isis_event_circuit_state_change (struct isis_circuit *circuit, int up) |
| 69 | { |
| 70 | struct isis_area *area; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 71 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 72 | area = circuit->area; |
| 73 | assert (area); |
| 74 | area->circuit_state_changes++; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 75 | |
| 76 | if (isis->debugs & DEBUG_EVENTS) |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 77 | zlog_debug ("ISIS-Evt (%s) circuit %s", circuit->area->area_tag, |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 78 | up ? "up" : "down"); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 79 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 80 | /* |
| 81 | * Regenerate LSPs this affects |
| 82 | */ |
| 83 | lsp_regenerate_schedule (area); |
| 84 | |
| 85 | return; |
| 86 | } |
| 87 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 88 | void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 89 | isis_event_system_type_change (struct isis_area *area, int newtype) |
| 90 | { |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 91 | struct listnode *node; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 92 | struct isis_circuit *circuit; |
| 93 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 94 | if (isis->debugs & DEBUG_EVENTS) |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 95 | zlog_debug ("ISIS-Evt (%s) system type change %s -> %s", area->area_tag, |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 96 | circuit_t2string (area->is_type), circuit_t2string (newtype)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 97 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 98 | if (area->is_type == newtype) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 99 | return; /* No change */ |
| 100 | |
| 101 | switch (area->is_type) |
| 102 | { |
| 103 | case IS_LEVEL_1: |
| 104 | if (area->lspdb[1] == NULL) |
| 105 | area->lspdb[1] = lsp_db_init (); |
| 106 | lsp_l2_generate (area); |
| 107 | break; |
| 108 | case IS_LEVEL_1_AND_2: |
| 109 | if (newtype == IS_LEVEL_1) |
| 110 | { |
| 111 | lsp_db_destroy (area->lspdb[1]); |
| 112 | } |
| 113 | else |
| 114 | { |
| 115 | lsp_db_destroy (area->lspdb[0]); |
| 116 | } |
| 117 | break; |
| 118 | case IS_LEVEL_2: |
| 119 | if (area->lspdb[0] == NULL) |
| 120 | area->lspdb[0] = lsp_db_init (); |
| 121 | lsp_l1_generate (area); |
| 122 | break; |
| 123 | default: |
| 124 | break; |
| 125 | } |
| 126 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 127 | area->is_type = newtype; |
hasso | 3fdb2dd | 2005-09-28 18:45:54 +0000 | [diff] [blame] | 128 | for (ALL_LIST_ELEMENTS_RO (area->circuit_list, node, circuit)) |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 129 | isis_event_circuit_type_change (circuit, newtype); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 130 | |
| 131 | spftree_area_init (area); |
| 132 | lsp_regenerate_schedule (area); |
| 133 | |
| 134 | return; |
| 135 | } |
| 136 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 137 | void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 138 | isis_event_area_addr_change (struct isis_area *area) |
| 139 | { |
| 140 | |
| 141 | } |
| 142 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 143 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 144 | circuit_commence_level (struct isis_circuit *circuit, int level) |
| 145 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 146 | if (level == 1) |
| 147 | { |
| 148 | THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit, |
| 149 | isis_jitter (circuit->psnp_interval[0], PSNP_JITTER)); |
hasso | d70f99e | 2004-02-11 20:26:31 +0000 | [diff] [blame] | 150 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 151 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) |
| 152 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 153 | THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1, |
hasso | a211d65 | 2004-09-20 14:55:29 +0000 | [diff] [blame] | 154 | circuit, 2 * circuit->hello_interval[1]); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 155 | |
| 156 | THREAD_TIMER_ON (master, circuit->u.bc.t_send_lan_hello[0], |
| 157 | send_lan_l1_hello, circuit, |
| 158 | isis_jitter (circuit->hello_interval[0], |
| 159 | IIH_JITTER)); |
| 160 | |
| 161 | circuit->u.bc.lan_neighs[0] = list_new (); |
| 162 | } |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 163 | } |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 164 | else |
| 165 | { |
| 166 | THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit, |
| 167 | isis_jitter (circuit->psnp_interval[1], PSNP_JITTER)); |
| 168 | |
| 169 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) |
| 170 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 171 | THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2, |
hasso | a211d65 | 2004-09-20 14:55:29 +0000 | [diff] [blame] | 172 | circuit, 2 * circuit->hello_interval[1]); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 173 | |
| 174 | THREAD_TIMER_ON (master, circuit->u.bc.t_send_lan_hello[1], |
| 175 | send_lan_l2_hello, circuit, |
| 176 | isis_jitter (circuit->hello_interval[1], |
| 177 | IIH_JITTER)); |
| 178 | |
| 179 | circuit->u.bc.lan_neighs[1] = list_new (); |
| 180 | } |
| 181 | } |
| 182 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 183 | return; |
| 184 | } |
| 185 | |
hasso | 9236588 | 2005-01-18 13:53:33 +0000 | [diff] [blame] | 186 | static void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 187 | circuit_resign_level (struct isis_circuit *circuit, int level) |
| 188 | { |
| 189 | int idx = level - 1; |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 190 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 191 | THREAD_TIMER_OFF (circuit->t_send_csnp[idx]); |
| 192 | THREAD_TIMER_OFF (circuit->t_send_psnp[idx]); |
| 193 | |
| 194 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) |
| 195 | { |
| 196 | THREAD_TIMER_OFF (circuit->u.bc.t_send_lan_hello[idx]); |
| 197 | THREAD_TIMER_OFF (circuit->u.bc.t_run_dr[idx]); |
hasso | 13fb40a | 2005-10-01 06:03:04 +0000 | [diff] [blame] | 198 | THREAD_TIMER_OFF (circuit->u.bc.t_refresh_pseudo_lsp[idx]); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 199 | circuit->u.bc.run_dr_elect[idx] = 0; |
| 200 | } |
| 201 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 202 | return; |
| 203 | } |
| 204 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 205 | void |
| 206 | isis_event_circuit_type_change (struct isis_circuit *circuit, int newtype) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 207 | { |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 208 | |
| 209 | if (isis->debugs & DEBUG_EVENTS) |
hasso | 529d65b | 2004-12-24 00:14:50 +0000 | [diff] [blame] | 210 | zlog_debug ("ISIS-Evt (%s) circuit type change %s -> %s", |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 211 | circuit->area->area_tag, |
| 212 | circuit_t2string (circuit->circuit_is_type), |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 213 | circuit_t2string (newtype)); |
| 214 | |
| 215 | if (circuit->circuit_is_type == newtype) |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 216 | return; /* No change */ |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 217 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 218 | if (!(newtype & circuit->area->is_type)) |
| 219 | { |
| 220 | zlog_err ("ISIS-Evt (%s) circuit type change - invalid level %s because" |
| 221 | " area is %s", circuit->area->area_tag, |
| 222 | circuit_t2string (newtype), |
| 223 | circuit_t2string (circuit->area->is_type)); |
| 224 | return; |
| 225 | } |
| 226 | |
| 227 | switch (circuit->circuit_is_type) |
| 228 | { |
| 229 | case IS_LEVEL_1: |
| 230 | if (newtype == IS_LEVEL_2) |
| 231 | circuit_resign_level (circuit, 1); |
| 232 | circuit_commence_level (circuit, 2); |
| 233 | break; |
| 234 | case IS_LEVEL_1_AND_2: |
| 235 | if (newtype == IS_LEVEL_1) |
| 236 | circuit_resign_level (circuit, 2); |
| 237 | else |
| 238 | circuit_resign_level (circuit, 1); |
| 239 | break; |
| 240 | case IS_LEVEL_2: |
| 241 | if (newtype == IS_LEVEL_1) |
| 242 | circuit_resign_level (circuit, 2); |
| 243 | circuit_commence_level (circuit, 1); |
| 244 | break; |
| 245 | default: |
| 246 | break; |
| 247 | } |
| 248 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 249 | circuit->circuit_is_type = newtype; |
| 250 | lsp_regenerate_schedule (circuit->area); |
| 251 | |
| 252 | return; |
| 253 | } |
| 254 | |
| 255 | /* 04/18/2002 by Gwak. */ |
| 256 | /************************************************************************** |
| 257 | * |
| 258 | * EVENTS for LSP generation |
| 259 | * |
| 260 | * 1) an Adajacency or Circuit Up/Down event |
| 261 | * 2) a chnage in Circuit metric |
| 262 | * 3) a change in Reachable Address metric |
| 263 | * 4) a change in manualAreaAddresses |
| 264 | * 5) a change in systemID |
| 265 | * 6) a change in DIS status |
| 266 | * 7) a chnage in the waiting status |
| 267 | * |
| 268 | * *********************************************************************** |
| 269 | * |
| 270 | * current support event |
| 271 | * |
| 272 | * 1) Adjacency Up/Down event |
| 273 | * 6) a change in DIS status |
| 274 | * |
| 275 | * ***********************************************************************/ |
| 276 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 277 | void |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 278 | isis_event_adjacency_state_change (struct isis_adjacency *adj, int newstate) |
| 279 | { |
| 280 | /* adjacency state change event. |
| 281 | * - the only proto-type was supported */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 282 | |
| 283 | /* invalid arguments */ |
| 284 | if (!adj || !adj->circuit || !adj->circuit->area) |
| 285 | return; |
| 286 | |
hasso | c89c05d | 2005-09-04 21:36:36 +0000 | [diff] [blame] | 287 | if (isis->debugs & DEBUG_EVENTS) |
| 288 | zlog_debug ("ISIS-Evt (%s) Adjacency State change", |
| 289 | adj->circuit->area->area_tag); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 290 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 291 | /* LSP generation again */ |
| 292 | lsp_regenerate_schedule (adj->circuit->area); |
| 293 | |
| 294 | return; |
| 295 | } |
| 296 | |
| 297 | /* events supporting code */ |
| 298 | |
| 299 | int |
| 300 | isis_event_dis_status_change (struct thread *thread) |
| 301 | { |
| 302 | struct isis_circuit *circuit; |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 303 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 304 | circuit = THREAD_ARG (thread); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 305 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 306 | /* invalid arguments */ |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 307 | if (!circuit || !circuit->area) |
| 308 | return 0; |
hasso | c89c05d | 2005-09-04 21:36:36 +0000 | [diff] [blame] | 309 | if (isis->debugs & DEBUG_EVENTS) |
| 310 | zlog_debug ("ISIS-Evt (%s) DIS status change", circuit->area->area_tag); |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 311 | |
| 312 | /* LSP generation again */ |
| 313 | lsp_regenerate_schedule (circuit->area); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 314 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 315 | return 0; |
| 316 | } |
| 317 | |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 318 | void |
hasso | 1cd8084 | 2004-10-07 20:07:40 +0000 | [diff] [blame] | 319 | isis_event_auth_failure (char *area_tag, const char *error_string, u_char *sysid) |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 320 | { |
hasso | c89c05d | 2005-09-04 21:36:36 +0000 | [diff] [blame] | 321 | if (isis->debugs & DEBUG_EVENTS) |
| 322 | zlog_debug ("ISIS-Evt (%s) Authentication failure %s from %s", |
| 323 | area_tag, error_string, sysid_print (sysid)); |
hasso | f390d2c | 2004-09-10 20:48:21 +0000 | [diff] [blame] | 324 | |
jardin | eb5d44e | 2003-12-23 08:09:43 +0000 | [diff] [blame] | 325 | return; |
| 326 | } |