]>
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 | |
eb5d44eb | 35 | #include "isisd/isis_constants.h" |
36 | #include "isisd/isis_common.h" | |
3f045a08 | 37 | #include "isisd/isis_flags.h" |
eb5d44eb | 38 | #include "isisd/isis_circuit.h" |
eb5d44eb | 39 | #include "isisd/isis_lsp.h" |
40 | #include "isisd/isis_pdu.h" | |
41 | #include "isisd/isis_network.h" | |
42 | #include "isisd/isis_misc.h" | |
43 | #include "isisd/isis_constants.h" | |
44 | #include "isisd/isis_adjacency.h" | |
45 | #include "isisd/isis_dr.h" | |
eb5d44eb | 46 | #include "isisd/isisd.h" |
47 | #include "isisd/isis_csm.h" | |
48 | #include "isisd/isis_events.h" | |
49 | #include "isisd/isis_spf.h" | |
54ece698 | 50 | #include "isisd/isis_errors.h" |
eb5d44eb | 51 | |
d62a17ae | 52 | void isis_event_circuit_state_change(struct isis_circuit *circuit, |
53 | struct isis_area *area, int up) | |
eb5d44eb | 54 | { |
d62a17ae | 55 | area->circuit_state_changes++; |
f390d2c7 | 56 | |
e740f9c1 | 57 | if (IS_DEBUG_EVENTS) |
d62a17ae | 58 | zlog_debug("ISIS-Evt (%s) circuit %s", area->area_tag, |
59 | up ? "up" : "down"); | |
f390d2c7 | 60 | |
d62a17ae | 61 | /* |
62 | * Regenerate LSPs this affects | |
63 | */ | |
64 | lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 0); | |
eb5d44eb | 65 | |
d62a17ae | 66 | return; |
eb5d44eb | 67 | } |
68 | ||
d62a17ae | 69 | static void circuit_commence_level(struct isis_circuit *circuit, int level) |
eb5d44eb | 70 | { |
2286851d EDP |
71 | if (IS_DEBUG_EVENTS) |
72 | zlog_debug( | |
73 | "ISIS-Evt (%s) circuit %u on iface %s commencing on L%d", | |
74 | circuit->area->area_tag, circuit->circuit_id, | |
75 | circuit->interface->name, level); | |
76 | ||
7c4f7aab CF |
77 | if (!circuit->is_passive) { |
78 | if (level == 1) { | |
d62a17ae | 79 | thread_add_timer(master, send_l1_psnp, circuit, |
80 | isis_jitter(circuit->psnp_interval[0], | |
81 | PSNP_JITTER), | |
82 | &circuit->t_send_psnp[0]); | |
7c4f7aab | 83 | } else { |
d62a17ae | 84 | thread_add_timer(master, send_l2_psnp, circuit, |
85 | isis_jitter(circuit->psnp_interval[1], | |
86 | PSNP_JITTER), | |
87 | &circuit->t_send_psnp[1]); | |
7c4f7aab CF |
88 | } |
89 | } | |
d62a17ae | 90 | |
7c4f7aab CF |
91 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { |
92 | thread_add_timer(master, isis_run_dr, | |
93 | &circuit->level_arg[level - 1], | |
94 | 2 * circuit->hello_interval[level - 1], | |
95 | &circuit->u.bc.t_run_dr[level - 1]); | |
d62a17ae | 96 | |
a0a707ee | 97 | send_hello_sched(circuit, level, TRIGGERED_IIH_DELAY); |
7c4f7aab | 98 | circuit->u.bc.lan_neighs[level - 1] = list_new(); |
f390d2c7 | 99 | } |
eb5d44eb | 100 | } |
101 | ||
d62a17ae | 102 | static void circuit_resign_level(struct isis_circuit *circuit, int level) |
eb5d44eb | 103 | { |
d62a17ae | 104 | int idx = level - 1; |
105 | ||
2286851d EDP |
106 | if (IS_DEBUG_EVENTS) |
107 | zlog_debug( | |
108 | "ISIS-Evt (%s) circuit %u on iface %s resigning on L%d", | |
109 | circuit->area->area_tag, circuit->circuit_id, | |
110 | circuit->interface->name, level); | |
111 | ||
fa935aa7 DS |
112 | THREAD_OFF(circuit->t_send_csnp[idx]); |
113 | THREAD_OFF(circuit->t_send_psnp[idx]); | |
d62a17ae | 114 | |
115 | if (circuit->circ_type == CIRCUIT_T_BROADCAST) { | |
fa935aa7 DS |
116 | THREAD_OFF(circuit->u.bc.t_send_lan_hello[idx]); |
117 | THREAD_OFF(circuit->u.bc.t_run_dr[idx]); | |
118 | THREAD_OFF(circuit->u.bc.t_refresh_pseudo_lsp[idx]); | |
d62a17ae | 119 | circuit->lsp_regenerate_pending[idx] = 0; |
120 | circuit->u.bc.run_dr_elect[idx] = 0; | |
2286851d | 121 | circuit->u.bc.is_dr[idx] = 0; |
affe9e99 | 122 | if (circuit->u.bc.lan_neighs[idx] != NULL) |
6a154c88 | 123 | list_delete(&circuit->u.bc.lan_neighs[idx]); |
d62a17ae | 124 | } |
125 | ||
126 | return; | |
eb5d44eb | 127 | } |
128 | ||
d62a17ae | 129 | void isis_circuit_is_type_set(struct isis_circuit *circuit, int newtype) |
eb5d44eb | 130 | { |
2f9a06f0 | 131 | if (!circuit->area) { |
d62a17ae | 132 | circuit->is_type = newtype; |
133 | return; | |
134 | } | |
135 | ||
e740f9c1 | 136 | if (IS_DEBUG_EVENTS) |
d62a17ae | 137 | zlog_debug("ISIS-Evt (%s) circuit type change %s -> %s", |
138 | circuit->area->area_tag, | |
139 | circuit_t2string(circuit->is_type), | |
140 | circuit_t2string(newtype)); | |
141 | ||
142 | if (circuit->is_type == newtype) | |
143 | return; /* No change */ | |
144 | ||
145 | if (!(newtype & circuit->area->is_type)) { | |
af4c2728 | 146 | flog_err( |
1a7ecb96 | 147 | EC_ISIS_CONFIG, |
54ece698 | 148 | "ISIS-Evt (%s) circuit type change - invalid level %s because area is %s", |
d62a17ae | 149 | circuit->area->area_tag, circuit_t2string(newtype), |
150 | circuit_t2string(circuit->area->is_type)); | |
151 | return; | |
152 | } | |
153 | ||
2f9a06f0 IR |
154 | if (circuit->state != C_STATE_UP) { |
155 | circuit->is_type = newtype; | |
156 | return; | |
157 | } | |
158 | ||
d62a17ae | 159 | if (!circuit->is_passive) { |
160 | switch (circuit->is_type) { | |
161 | case IS_LEVEL_1: | |
162 | if (newtype == IS_LEVEL_2) | |
163 | circuit_resign_level(circuit, 1); | |
164 | circuit_commence_level(circuit, 2); | |
165 | break; | |
166 | case IS_LEVEL_1_AND_2: | |
167 | if (newtype == IS_LEVEL_1) | |
168 | circuit_resign_level(circuit, 2); | |
169 | else | |
170 | circuit_resign_level(circuit, 1); | |
171 | break; | |
172 | case IS_LEVEL_2: | |
173 | if (newtype == IS_LEVEL_1) | |
174 | circuit_resign_level(circuit, 2); | |
175 | circuit_commence_level(circuit, 1); | |
176 | break; | |
177 | default: | |
178 | break; | |
179 | } | |
180 | } | |
181 | ||
182 | circuit->is_type = newtype; | |
183 | lsp_regenerate_schedule(circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0); | |
184 | ||
185 | return; | |
eb5d44eb | 186 | } |
187 | ||
d62a17ae | 188 | /* 04/18/2002 by Gwak. */ |
189 | /************************************************************************** | |
190 | * | |
191 | * EVENTS for LSP generation | |
192 | * | |
193 | * 1) an Adajacency or Circuit Up/Down event | |
194 | * 2) a chnage in Circuit metric | |
195 | * 3) a change in Reachable Address metric | |
196 | * 4) a change in manualAreaAddresses | |
197 | * 5) a change in systemID | |
198 | * 6) a change in DIS status | |
199 | * 7) a chnage in the waiting status | |
200 | * | |
201 | * *********************************************************************** | |
202 | * | |
203 | * current support event | |
204 | * | |
205 | * 1) Adjacency Up/Down event | |
206 | * 6) a change in DIS status | |
207 | * | |
208 | * ***********************************************************************/ | |
209 | ||
eb5d44eb | 210 | /* events supporting code */ |
211 | ||
cc9f21da | 212 | void isis_event_dis_status_change(struct thread *thread) |
eb5d44eb | 213 | { |
d62a17ae | 214 | struct isis_circuit *circuit; |
f390d2c7 | 215 | |
d62a17ae | 216 | circuit = THREAD_ARG(thread); |
f390d2c7 | 217 | |
d62a17ae | 218 | /* invalid arguments */ |
219 | if (!circuit || !circuit->area) | |
cc9f21da | 220 | return; |
e740f9c1 | 221 | if (IS_DEBUG_EVENTS) |
d62a17ae | 222 | zlog_debug("ISIS-Evt (%s) DIS status change", |
223 | circuit->area->area_tag); | |
eb5d44eb | 224 | |
d62a17ae | 225 | /* LSP generation again */ |
226 | lsp_regenerate_schedule(circuit->area, IS_LEVEL_1 | IS_LEVEL_2, 0); | |
eb5d44eb | 227 | } |
228 | ||
d62a17ae | 229 | void isis_event_auth_failure(char *area_tag, const char *error_string, |
d7c0a89a | 230 | uint8_t *sysid) |
eb5d44eb | 231 | { |
e740f9c1 | 232 | if (IS_DEBUG_EVENTS) |
d62a17ae | 233 | zlog_debug("ISIS-Evt (%s) Authentication failure %s from %s", |
234 | area_tag, error_string, sysid_print(sysid)); | |
f390d2c7 | 235 | |
d62a17ae | 236 | return; |
eb5d44eb | 237 | } |