]>
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" | |
51 | ||
d62a17ae | 52 | /* debug isis-spf spf-events |
eb5d44eb | 53 | 4w4d: ISIS-Spf (tlt): L2 SPF needed, new adjacency, from 0x609229F4 |
54 | 4w4d: ISIS-Spf (tlt): L2, 0000.0000.0042.01-00 TLV contents changed, code 0x2 | |
55 | 4w4d: ISIS-Spf (tlt): L2, new LSP 0 DEAD.BEEF.0043.00-00 | |
56 | 4w5d: ISIS-Spf (tlt): L1 SPF needed, periodic SPF, from 0x6091C844 | |
57 | 4w5d: ISIS-Spf (tlt): L2 SPF needed, periodic SPF, from 0x6091C844 | |
58 | */ | |
59 | ||
d62a17ae | 60 | void isis_event_circuit_state_change(struct isis_circuit *circuit, |
61 | struct isis_area *area, int up) | |
eb5d44eb | 62 | { |
d62a17ae | 63 | area->circuit_state_changes++; |
f390d2c7 | 64 | |
d62a17ae | 65 | if (isis->debugs & DEBUG_EVENTS) |
66 | zlog_debug("ISIS-Evt (%s) circuit %s", area->area_tag, | |
67 | up ? "up" : "down"); | |
f390d2c7 | 68 | |
d62a17ae | 69 | /* |
70 | * Regenerate LSPs this affects | |
71 | */ | |
72 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0); | |
eb5d44eb | 73 | |
d62a17ae | 74 | return; |
eb5d44eb | 75 | } |
76 | ||
d62a17ae | 77 | static void circuit_commence_level(struct isis_circuit *circuit, int level) |
eb5d44eb | 78 | { |
d62a17ae | 79 | if (level == 1) { |
80 | if (!circuit->is_passive) | |
81 | thread_add_timer(master, send_l1_psnp, circuit, | |
82 | isis_jitter(circuit->psnp_interval[0], | |
83 | PSNP_JITTER), | |
84 | &circuit->t_send_psnp[0]); | |
85 | ||
86 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { | |
87 | thread_add_timer(master, isis_run_dr_l1, circuit, | |
88 | 2 * circuit->hello_interval[0], | |
89 | &circuit->u.bc.t_run_dr[0]); | |
90 | ||
91 | thread_add_timer(master, send_lan_l1_hello, circuit, | |
92 | isis_jitter(circuit->hello_interval[0], | |
93 | IIH_JITTER), | |
94 | &circuit->u.bc.t_send_lan_hello[0]); | |
95 | ||
96 | circuit->u.bc.lan_neighs[0] = list_new(); | |
97 | } | |
98 | } else { | |
99 | if (!circuit->is_passive) | |
100 | thread_add_timer(master, send_l2_psnp, circuit, | |
101 | isis_jitter(circuit->psnp_interval[1], | |
102 | PSNP_JITTER), | |
103 | &circuit->t_send_psnp[1]); | |
104 | ||
105 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { | |
106 | thread_add_timer(master, isis_run_dr_l2, circuit, | |
107 | 2 * circuit->hello_interval[1], | |
108 | &circuit->u.bc.t_run_dr[1]); | |
109 | ||
110 | thread_add_timer(master, send_lan_l2_hello, circuit, | |
111 | isis_jitter(circuit->hello_interval[1], | |
112 | IIH_JITTER), | |
113 | &circuit->u.bc.t_send_lan_hello[1]); | |
114 | ||
115 | circuit->u.bc.lan_neighs[1] = list_new(); | |
116 | } | |
f390d2c7 | 117 | } |
f390d2c7 | 118 | |
d62a17ae | 119 | return; |
eb5d44eb | 120 | } |
121 | ||
d62a17ae | 122 | static void circuit_resign_level(struct isis_circuit *circuit, int level) |
eb5d44eb | 123 | { |
d62a17ae | 124 | int idx = level - 1; |
125 | ||
126 | THREAD_TIMER_OFF(circuit->t_send_csnp[idx]); | |
127 | THREAD_TIMER_OFF(circuit->t_send_psnp[idx]); | |
128 | ||
129 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { | |
130 | THREAD_TIMER_OFF(circuit->u.bc.t_send_lan_hello[idx]); | |
131 | THREAD_TIMER_OFF(circuit->u.bc.t_run_dr[idx]); | |
132 | THREAD_TIMER_OFF(circuit->u.bc.t_refresh_pseudo_lsp[idx]); | |
133 | circuit->lsp_regenerate_pending[idx] = 0; | |
134 | circuit->u.bc.run_dr_elect[idx] = 0; | |
135 | if (circuit->u.bc.lan_neighs[idx] != NULL) { | |
136 | list_delete(circuit->u.bc.lan_neighs[idx]); | |
137 | circuit->u.bc.lan_neighs[idx] = NULL; | |
138 | } | |
139 | } | |
140 | ||
141 | return; | |
eb5d44eb | 142 | } |
143 | ||
d62a17ae | 144 | void isis_circuit_is_type_set(struct isis_circuit *circuit, int newtype) |
eb5d44eb | 145 | { |
d62a17ae | 146 | if (circuit->state != C_STATE_UP) { |
147 | circuit->is_type = newtype; | |
148 | return; | |
149 | } | |
150 | ||
151 | if (isis->debugs & DEBUG_EVENTS) | |
152 | zlog_debug("ISIS-Evt (%s) circuit type change %s -> %s", | |
153 | circuit->area->area_tag, | |
154 | circuit_t2string(circuit->is_type), | |
155 | circuit_t2string(newtype)); | |
156 | ||
157 | if (circuit->is_type == newtype) | |
158 | return; /* No change */ | |
159 | ||
160 | if (!(newtype & circuit->area->is_type)) { | |
161 | zlog_err( | |
162 | "ISIS-Evt (%s) circuit type change - invalid level %s because" | |
163 | " area is %s", | |
164 | circuit->area->area_tag, circuit_t2string(newtype), | |
165 | circuit_t2string(circuit->area->is_type)); | |
166 | return; | |
167 | } | |
168 | ||
169 | if (!circuit->is_passive) { | |
170 | switch (circuit->is_type) { | |
171 | case IS_LEVEL_1: | |
172 | if (newtype == IS_LEVEL_2) | |
173 | circuit_resign_level(circuit, 1); | |
174 | circuit_commence_level(circuit, 2); | |
175 | break; | |
176 | case IS_LEVEL_1_AND_2: | |
177 | if (newtype == IS_LEVEL_1) | |
178 | circuit_resign_level(circuit, 2); | |
179 | else | |
180 | circuit_resign_level(circuit, 1); | |
181 | break; | |
182 | case IS_LEVEL_2: | |
183 | if (newtype == IS_LEVEL_1) | |
184 | circuit_resign_level(circuit, 2); | |
185 | circuit_commence_level(circuit, 1); | |
186 | break; | |
187 | default: | |
188 | break; | |
189 | } | |
190 | } | |
191 | ||
192 | circuit->is_type = newtype; | |
193 | lsp_regenerate_schedule(circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0); | |
194 | ||
195 | return; | |
eb5d44eb | 196 | } |
197 | ||
d62a17ae | 198 | /* 04/18/2002 by Gwak. */ |
199 | /************************************************************************** | |
200 | * | |
201 | * EVENTS for LSP generation | |
202 | * | |
203 | * 1) an Adajacency or Circuit Up/Down event | |
204 | * 2) a chnage in Circuit metric | |
205 | * 3) a change in Reachable Address metric | |
206 | * 4) a change in manualAreaAddresses | |
207 | * 5) a change in systemID | |
208 | * 6) a change in DIS status | |
209 | * 7) a chnage in the waiting status | |
210 | * | |
211 | * *********************************************************************** | |
212 | * | |
213 | * current support event | |
214 | * | |
215 | * 1) Adjacency Up/Down event | |
216 | * 6) a change in DIS status | |
217 | * | |
218 | * ***********************************************************************/ | |
219 | ||
220 | void isis_event_adjacency_state_change(struct isis_adjacency *adj, int newstate) | |
eb5d44eb | 221 | { |
d62a17ae | 222 | /* adjacency state change event. |
223 | * - the only proto-type was supported */ | |
f390d2c7 | 224 | |
d62a17ae | 225 | /* invalid arguments */ |
226 | if (!adj || !adj->circuit || !adj->circuit->area) | |
227 | return; | |
f390d2c7 | 228 | |
d62a17ae | 229 | if (isis->debugs & DEBUG_EVENTS) |
230 | zlog_debug("ISIS-Evt (%s) Adjacency State change", | |
231 | adj->circuit->area->area_tag); | |
f390d2c7 | 232 | |
d62a17ae | 233 | /* LSP generation again */ |
234 | lsp_regenerate_schedule(adj->circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0); | |
eb5d44eb | 235 | |
d62a17ae | 236 | return; |
eb5d44eb | 237 | } |
238 | ||
239 | /* events supporting code */ | |
240 | ||
d62a17ae | 241 | int isis_event_dis_status_change(struct thread *thread) |
eb5d44eb | 242 | { |
d62a17ae | 243 | struct isis_circuit *circuit; |
f390d2c7 | 244 | |
d62a17ae | 245 | circuit = THREAD_ARG(thread); |
f390d2c7 | 246 | |
d62a17ae | 247 | /* invalid arguments */ |
248 | if (!circuit || !circuit->area) | |
249 | return 0; | |
250 | if (isis->debugs & DEBUG_EVENTS) | |
251 | zlog_debug("ISIS-Evt (%s) DIS status change", | |
252 | circuit->area->area_tag); | |
eb5d44eb | 253 | |
d62a17ae | 254 | /* LSP generation again */ |
255 | lsp_regenerate_schedule(circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0); | |
f390d2c7 | 256 | |
d62a17ae | 257 | return 0; |
eb5d44eb | 258 | } |
259 | ||
d62a17ae | 260 | void isis_event_auth_failure(char *area_tag, const char *error_string, |
261 | u_char *sysid) | |
eb5d44eb | 262 | { |
d62a17ae | 263 | if (isis->debugs & DEBUG_EVENTS) |
264 | zlog_debug("ISIS-Evt (%s) Authentication failure %s from %s", | |
265 | area_tag, error_string, sysid_print(sysid)); | |
f390d2c7 | 266 | |
d62a17ae | 267 | return; |
eb5d44eb | 268 | } |