]>
Commit | Line | Data |
---|---|---|
eb5d44eb | 1 | /* |
d62a17ae | 2 | * IS-IS Rout(e)ing protocol - isis_events.h |
eb5d44eb | 3 | * |
4 | * Copyright (C) 2001,2002 Sampo Saaristo | |
d62a17ae | 5 | * Tampere University of Technology |
eb5d44eb | 6 | * Institute of Communications Engineering |
7 | * | |
d62a17ae | 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) | |
eb5d44eb | 11 | * any later version. |
12 | * | |
d62a17ae | 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 | |
eb5d44eb | 16 | * more details. |
896014f4 DL |
17 | * |
18 | * You should have received a copy of the GNU General Public License along | |
19 | * with this program; see the file COPYING; if not, write to the Free Software | |
20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
eb5d44eb | 21 | */ |
eb5d44eb | 22 | #include <zebra.h> |
eb5d44eb | 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" | |
3f045a08 | 33 | #include "table.h" |
eb5d44eb | 34 | |
35 | #include "isisd/dict.h" | |
eb5d44eb | 36 | #include "isisd/isis_constants.h" |
37 | #include "isisd/isis_common.h" | |
3f045a08 | 38 | #include "isisd/isis_flags.h" |
eb5d44eb | 39 | #include "isisd/isis_circuit.h" |
eb5d44eb | 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" | |
eb5d44eb | 47 | #include "isisd/isisd.h" |
48 | #include "isisd/isis_csm.h" | |
49 | #include "isisd/isis_events.h" | |
50 | #include "isisd/isis_spf.h" | |
54ece698 | 51 | #include "isisd/isis_errors.h" |
eb5d44eb | 52 | |
d62a17ae | 53 | /* debug isis-spf spf-events |
eb5d44eb | 54 | 4w4d: ISIS-Spf (tlt): L2 SPF needed, new adjacency, from 0x609229F4 |
55 | 4w4d: ISIS-Spf (tlt): L2, 0000.0000.0042.01-00 TLV contents changed, code 0x2 | |
56 | 4w4d: ISIS-Spf (tlt): L2, new LSP 0 DEAD.BEEF.0043.00-00 | |
57 | 4w5d: ISIS-Spf (tlt): L1 SPF needed, periodic SPF, from 0x6091C844 | |
58 | 4w5d: ISIS-Spf (tlt): L2 SPF needed, periodic SPF, from 0x6091C844 | |
59 | */ | |
60 | ||
d62a17ae | 61 | void isis_event_circuit_state_change(struct isis_circuit *circuit, |
62 | struct isis_area *area, int up) | |
eb5d44eb | 63 | { |
d62a17ae | 64 | area->circuit_state_changes++; |
f390d2c7 | 65 | |
d62a17ae | 66 | if (isis->debugs & DEBUG_EVENTS) |
67 | zlog_debug("ISIS-Evt (%s) circuit %s", area->area_tag, | |
68 | up ? "up" : "down"); | |
f390d2c7 | 69 | |
d62a17ae | 70 | /* |
71 | * Regenerate LSPs this affects | |
72 | */ | |
73 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0); | |
eb5d44eb | 74 | |
d62a17ae | 75 | return; |
eb5d44eb | 76 | } |
77 | ||
d62a17ae | 78 | static void circuit_commence_level(struct isis_circuit *circuit, int level) |
eb5d44eb | 79 | { |
7c4f7aab CF |
80 | if (!circuit->is_passive) { |
81 | if (level == 1) { | |
d62a17ae | 82 | thread_add_timer(master, send_l1_psnp, circuit, |
83 | isis_jitter(circuit->psnp_interval[0], | |
84 | PSNP_JITTER), | |
85 | &circuit->t_send_psnp[0]); | |
7c4f7aab | 86 | } else { |
d62a17ae | 87 | thread_add_timer(master, send_l2_psnp, circuit, |
88 | isis_jitter(circuit->psnp_interval[1], | |
89 | PSNP_JITTER), | |
90 | &circuit->t_send_psnp[1]); | |
7c4f7aab CF |
91 | } |
92 | } | |
d62a17ae | 93 | |
7c4f7aab CF |
94 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { |
95 | thread_add_timer(master, isis_run_dr, | |
96 | &circuit->level_arg[level - 1], | |
97 | 2 * circuit->hello_interval[level - 1], | |
98 | &circuit->u.bc.t_run_dr[level - 1]); | |
d62a17ae | 99 | |
a0a707ee | 100 | send_hello_sched(circuit, level, TRIGGERED_IIH_DELAY); |
7c4f7aab | 101 | circuit->u.bc.lan_neighs[level - 1] = list_new(); |
f390d2c7 | 102 | } |
eb5d44eb | 103 | } |
104 | ||
d62a17ae | 105 | static void circuit_resign_level(struct isis_circuit *circuit, int level) |
eb5d44eb | 106 | { |
d62a17ae | 107 | int idx = level - 1; |
108 | ||
109 | THREAD_TIMER_OFF(circuit->t_send_csnp[idx]); | |
110 | THREAD_TIMER_OFF(circuit->t_send_psnp[idx]); | |
111 | ||
112 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { | |
113 | THREAD_TIMER_OFF(circuit->u.bc.t_send_lan_hello[idx]); | |
114 | THREAD_TIMER_OFF(circuit->u.bc.t_run_dr[idx]); | |
115 | THREAD_TIMER_OFF(circuit->u.bc.t_refresh_pseudo_lsp[idx]); | |
116 | circuit->lsp_regenerate_pending[idx] = 0; | |
117 | circuit->u.bc.run_dr_elect[idx] = 0; | |
affe9e99 | 118 | if (circuit->u.bc.lan_neighs[idx] != NULL) |
6a154c88 | 119 | list_delete(&circuit->u.bc.lan_neighs[idx]); |
d62a17ae | 120 | } |
121 | ||
122 | return; | |
eb5d44eb | 123 | } |
124 | ||
d62a17ae | 125 | void isis_circuit_is_type_set(struct isis_circuit *circuit, int newtype) |
eb5d44eb | 126 | { |
d62a17ae | 127 | if (circuit->state != C_STATE_UP) { |
128 | circuit->is_type = newtype; | |
129 | return; | |
130 | } | |
131 | ||
132 | if (isis->debugs & DEBUG_EVENTS) | |
133 | zlog_debug("ISIS-Evt (%s) circuit type change %s -> %s", | |
134 | circuit->area->area_tag, | |
135 | circuit_t2string(circuit->is_type), | |
136 | circuit_t2string(newtype)); | |
137 | ||
138 | if (circuit->is_type == newtype) | |
139 | return; /* No change */ | |
140 | ||
141 | if (!(newtype & circuit->area->is_type)) { | |
af4c2728 | 142 | flog_err( |
1a7ecb96 | 143 | EC_ISIS_CONFIG, |
54ece698 | 144 | "ISIS-Evt (%s) circuit type change - invalid level %s because area is %s", |
d62a17ae | 145 | circuit->area->area_tag, circuit_t2string(newtype), |
146 | circuit_t2string(circuit->area->is_type)); | |
147 | return; | |
148 | } | |
149 | ||
150 | if (!circuit->is_passive) { | |
151 | switch (circuit->is_type) { | |
152 | case IS_LEVEL_1: | |
153 | if (newtype == IS_LEVEL_2) | |
154 | circuit_resign_level(circuit, 1); | |
155 | circuit_commence_level(circuit, 2); | |
156 | break; | |
157 | case IS_LEVEL_1_AND_2: | |
158 | if (newtype == IS_LEVEL_1) | |
159 | circuit_resign_level(circuit, 2); | |
160 | else | |
161 | circuit_resign_level(circuit, 1); | |
162 | break; | |
163 | case IS_LEVEL_2: | |
164 | if (newtype == IS_LEVEL_1) | |
165 | circuit_resign_level(circuit, 2); | |
166 | circuit_commence_level(circuit, 1); | |
167 | break; | |
168 | default: | |
169 | break; | |
170 | } | |
171 | } | |
172 | ||
173 | circuit->is_type = newtype; | |
174 | lsp_regenerate_schedule(circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0); | |
175 | ||
176 | return; | |
eb5d44eb | 177 | } |
178 | ||
d62a17ae | 179 | /* 04/18/2002 by Gwak. */ |
180 | /************************************************************************** | |
181 | * | |
182 | * EVENTS for LSP generation | |
183 | * | |
184 | * 1) an Adajacency or Circuit Up/Down event | |
185 | * 2) a chnage in Circuit metric | |
186 | * 3) a change in Reachable Address metric | |
187 | * 4) a change in manualAreaAddresses | |
188 | * 5) a change in systemID | |
189 | * 6) a change in DIS status | |
190 | * 7) a chnage in the waiting status | |
191 | * | |
192 | * *********************************************************************** | |
193 | * | |
194 | * current support event | |
195 | * | |
196 | * 1) Adjacency Up/Down event | |
197 | * 6) a change in DIS status | |
198 | * | |
199 | * ***********************************************************************/ | |
200 | ||
eb5d44eb | 201 | /* events supporting code */ |
202 | ||
d62a17ae | 203 | int isis_event_dis_status_change(struct thread *thread) |
eb5d44eb | 204 | { |
d62a17ae | 205 | struct isis_circuit *circuit; |
f390d2c7 | 206 | |
d62a17ae | 207 | circuit = THREAD_ARG(thread); |
f390d2c7 | 208 | |
d62a17ae | 209 | /* invalid arguments */ |
210 | if (!circuit || !circuit->area) | |
211 | return 0; | |
212 | if (isis->debugs & DEBUG_EVENTS) | |
213 | zlog_debug("ISIS-Evt (%s) DIS status change", | |
214 | circuit->area->area_tag); | |
eb5d44eb | 215 | |
d62a17ae | 216 | /* LSP generation again */ |
217 | lsp_regenerate_schedule(circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0); | |
f390d2c7 | 218 | |
d62a17ae | 219 | return 0; |
eb5d44eb | 220 | } |
221 | ||
d62a17ae | 222 | void isis_event_auth_failure(char *area_tag, const char *error_string, |
d7c0a89a | 223 | uint8_t *sysid) |
eb5d44eb | 224 | { |
d62a17ae | 225 | if (isis->debugs & DEBUG_EVENTS) |
226 | zlog_debug("ISIS-Evt (%s) Authentication failure %s from %s", | |
227 | area_tag, error_string, sysid_print(sysid)); | |
f390d2c7 | 228 | |
d62a17ae | 229 | return; |
eb5d44eb | 230 | } |