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