]>
Commit | Line | Data |
---|---|---|
65f9a9a8 DL |
1 | /* |
2 | * IS-IS Rout(e)ing protocol - isis_circuit.h | |
3 | * | |
4 | * Copyright (C) 2001,2002 Sampo Saaristo | |
d62a17ae | 5 | * Tampere University of Technology |
65f9a9a8 DL |
6 | * Institute of Communications Engineering |
7 | * Copyright (C) 2016 David Lamparter, for NetDEF, Inc. | |
8 | * | |
d62a17ae | 9 | * This program is free software; you can redistribute it and/or modify it |
10 | * under the terms of the GNU General Public Licenseas published by the Free | |
11 | * Software Foundation; either version 2 of the License, or (at your option) | |
65f9a9a8 DL |
12 | * any later version. |
13 | * | |
d62a17ae | 14 | * This program is distributed in the hope that it will be useful,but WITHOUT |
15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
65f9a9a8 | 17 | * more details. |
896014f4 DL |
18 | * |
19 | * You should have received a copy of the GNU General Public License along | |
20 | * with this program; see the file COPYING; if not, write to the Free Software | |
21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
65f9a9a8 DL |
22 | */ |
23 | ||
24 | #include <zebra.h> | |
5475ecf7 SL |
25 | |
26 | #include "command.h" | |
03f7e182 | 27 | #include "spf_backoff.h" |
65f9a9a8 DL |
28 | |
29 | #include "isis_circuit.h" | |
30 | #include "isis_csm.h" | |
31 | #include "isis_misc.h" | |
064f4896 | 32 | #include "isis_mt.h" |
65f9a9a8 DL |
33 | #include "isisd.h" |
34 | ||
d62a17ae | 35 | static struct isis_circuit *isis_circuit_lookup(struct vty *vty) |
65f9a9a8 | 36 | { |
d62a17ae | 37 | struct interface *ifp = VTY_GET_CONTEXT(interface); |
38 | struct isis_circuit *circuit; | |
65f9a9a8 | 39 | |
d62a17ae | 40 | if (!ifp) { |
41 | vty_out(vty, "Invalid interface \n"); | |
42 | return NULL; | |
43 | } | |
65f9a9a8 | 44 | |
d62a17ae | 45 | circuit = circuit_scan_by_ifp(ifp); |
46 | if (!circuit) { | |
47 | vty_out(vty, "ISIS is not enabled on circuit %s\n", ifp->name); | |
48 | return NULL; | |
49 | } | |
65f9a9a8 | 50 | |
d62a17ae | 51 | return circuit; |
65f9a9a8 DL |
52 | } |
53 | ||
54 | DEFUN (ip_router_isis, | |
55 | ip_router_isis_cmd, | |
12dcf78e | 56 | "ip router isis WORD", |
65f9a9a8 DL |
57 | "Interface Internet Protocol config commands\n" |
58 | "IP router interface commands\n" | |
59 | "IS-IS Routing for IP\n" | |
60 | "Routing process tag\n") | |
61 | { | |
d62a17ae | 62 | int idx_afi = 0; |
63 | int idx_word = 3; | |
64 | VTY_DECLVAR_CONTEXT(interface, ifp); | |
65 | struct isis_circuit *circuit; | |
66 | struct isis_area *area; | |
67 | const char *af = argv[idx_afi]->arg; | |
68 | const char *area_tag = argv[idx_word]->arg; | |
69 | ||
70 | /* Prevent more than one area per circuit */ | |
71 | circuit = circuit_scan_by_ifp(ifp); | |
72 | if (circuit && circuit->area) { | |
73 | if (strcmp(circuit->area->area_tag, area_tag)) { | |
74 | vty_out(vty, "ISIS circuit is already defined on %s\n", | |
75 | circuit->area->area_tag); | |
76 | return CMD_ERR_NOTHING_TODO; | |
77 | } | |
78 | } | |
79 | ||
80 | area = isis_area_lookup(area_tag); | |
81 | if (!area) | |
82 | area = isis_area_create(area_tag); | |
83 | ||
84 | if (!circuit || !circuit->area) { | |
85 | circuit = isis_circuit_create(area, ifp); | |
86 | ||
87 | if (circuit->state != C_STATE_CONF | |
88 | && circuit->state != C_STATE_UP) { | |
89 | vty_out(vty, | |
90 | "Couldn't bring up interface, please check log.\n"); | |
91 | return CMD_WARNING_CONFIG_FAILED; | |
92 | } | |
93 | } | |
94 | ||
95 | bool ip = circuit->ip_router, ipv6 = circuit->ipv6_router; | |
96 | if (af[2] != '\0') | |
97 | ipv6 = true; | |
98 | else | |
99 | ip = true; | |
100 | ||
101 | isis_circuit_af_set(circuit, ip, ipv6); | |
102 | return CMD_SUCCESS; | |
65f9a9a8 DL |
103 | } |
104 | ||
12dcf78e QY |
105 | DEFUN (ip6_router_isis, |
106 | ip6_router_isis_cmd, | |
107 | "ipv6 router isis WORD", | |
108 | "Interface Internet Protocol config commands\n" | |
109 | "IP router interface commands\n" | |
110 | "IS-IS Routing for IP\n" | |
111 | "Routing process tag\n") | |
112 | { | |
d62a17ae | 113 | return ip_router_isis(self, vty, argc, argv); |
12dcf78e QY |
114 | } |
115 | ||
65f9a9a8 DL |
116 | DEFUN (no_ip_router_isis, |
117 | no_ip_router_isis_cmd, | |
6147e2c6 | 118 | "no <ip|ipv6> router isis WORD", |
65f9a9a8 DL |
119 | NO_STR |
120 | "Interface Internet Protocol config commands\n" | |
121 | "IP router interface commands\n" | |
3a2d747c | 122 | "IP router interface commands\n" |
65f9a9a8 DL |
123 | "IS-IS Routing for IP\n" |
124 | "Routing process tag\n") | |
125 | { | |
d62a17ae | 126 | int idx_afi = 1; |
127 | int idx_word = 4; | |
128 | VTY_DECLVAR_CONTEXT(interface, ifp); | |
129 | struct isis_area *area; | |
130 | struct isis_circuit *circuit; | |
131 | const char *af = argv[idx_afi]->arg; | |
132 | const char *area_tag = argv[idx_word]->arg; | |
133 | ||
134 | area = isis_area_lookup(area_tag); | |
135 | if (!area) { | |
136 | vty_out(vty, "Can't find ISIS instance %s\n", | |
137 | argv[idx_afi]->arg); | |
138 | return CMD_ERR_NO_MATCH; | |
139 | } | |
140 | ||
141 | circuit = circuit_lookup_by_ifp(ifp, area->circuit_list); | |
142 | if (!circuit) { | |
143 | vty_out(vty, "ISIS is not enabled on circuit %s\n", ifp->name); | |
144 | return CMD_ERR_NO_MATCH; | |
145 | } | |
146 | ||
147 | bool ip = circuit->ip_router, ipv6 = circuit->ipv6_router; | |
148 | if (af[2] != '\0') | |
149 | ipv6 = false; | |
150 | else | |
151 | ip = false; | |
152 | ||
153 | isis_circuit_af_set(circuit, ip, ipv6); | |
154 | return CMD_SUCCESS; | |
65f9a9a8 DL |
155 | } |
156 | ||
157 | DEFUN (isis_passive, | |
158 | isis_passive_cmd, | |
159 | "isis passive", | |
160 | "IS-IS commands\n" | |
161 | "Configure the passive mode for interface\n") | |
162 | { | |
d62a17ae | 163 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
164 | if (!circuit) | |
165 | return CMD_ERR_NO_MATCH; | |
65f9a9a8 | 166 | |
64dd3ffe DL |
167 | CMD_FERR_RETURN(isis_circuit_passive_set(circuit, 1), |
168 | "Cannot set passive: $ERR"); | |
d62a17ae | 169 | return CMD_SUCCESS; |
65f9a9a8 DL |
170 | } |
171 | ||
172 | DEFUN (no_isis_passive, | |
173 | no_isis_passive_cmd, | |
174 | "no isis passive", | |
175 | NO_STR | |
176 | "IS-IS commands\n" | |
177 | "Configure the passive mode for interface\n") | |
178 | { | |
d62a17ae | 179 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
180 | if (!circuit) | |
181 | return CMD_ERR_NO_MATCH; | |
65f9a9a8 | 182 | |
64dd3ffe DL |
183 | CMD_FERR_RETURN(isis_circuit_passive_set(circuit, 0), |
184 | "Cannot set no passive: $ERR"); | |
d62a17ae | 185 | return CMD_SUCCESS; |
65f9a9a8 DL |
186 | } |
187 | ||
188 | DEFUN (isis_circuit_type, | |
189 | isis_circuit_type_cmd, | |
6147e2c6 | 190 | "isis circuit-type <level-1|level-1-2|level-2-only>", |
65f9a9a8 DL |
191 | "IS-IS commands\n" |
192 | "Configure circuit type for interface\n" | |
193 | "Level-1 only adjacencies are formed\n" | |
194 | "Level-1-2 adjacencies are formed\n" | |
195 | "Level-2 only adjacencies are formed\n") | |
196 | { | |
d62a17ae | 197 | int idx_level = 2; |
198 | int is_type; | |
199 | struct isis_circuit *circuit = isis_circuit_lookup(vty); | |
200 | if (!circuit) | |
201 | return CMD_ERR_NO_MATCH; | |
65f9a9a8 | 202 | |
d62a17ae | 203 | is_type = string2circuit_t(argv[idx_level]->arg); |
204 | if (!is_type) { | |
205 | vty_out(vty, "Unknown circuit-type \n"); | |
a5fdb4c5 | 206 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 207 | } |
65f9a9a8 | 208 | |
d62a17ae | 209 | if (circuit->state == C_STATE_UP |
210 | && circuit->area->is_type != IS_LEVEL_1_AND_2 | |
211 | && circuit->area->is_type != is_type) { | |
212 | vty_out(vty, "Invalid circuit level for area %s.\n", | |
213 | circuit->area->area_tag); | |
a5fdb4c5 | 214 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 215 | } |
216 | isis_circuit_is_type_set(circuit, is_type); | |
65f9a9a8 | 217 | |
d62a17ae | 218 | return CMD_SUCCESS; |
65f9a9a8 DL |
219 | } |
220 | ||
221 | DEFUN (no_isis_circuit_type, | |
222 | no_isis_circuit_type_cmd, | |
6147e2c6 | 223 | "no isis circuit-type <level-1|level-1-2|level-2-only>", |
65f9a9a8 DL |
224 | NO_STR |
225 | "IS-IS commands\n" | |
226 | "Configure circuit type for interface\n" | |
227 | "Level-1 only adjacencies are formed\n" | |
228 | "Level-1-2 adjacencies are formed\n" | |
229 | "Level-2 only adjacencies are formed\n") | |
230 | { | |
d62a17ae | 231 | int is_type; |
232 | struct isis_circuit *circuit = isis_circuit_lookup(vty); | |
233 | if (!circuit) | |
234 | return CMD_ERR_NO_MATCH; | |
65f9a9a8 | 235 | |
d62a17ae | 236 | /* |
237 | * Set the circuits level to its default value | |
238 | */ | |
239 | if (circuit->state == C_STATE_UP) | |
240 | is_type = circuit->area->is_type; | |
241 | else | |
242 | is_type = IS_LEVEL_1_AND_2; | |
243 | isis_circuit_is_type_set(circuit, is_type); | |
65f9a9a8 | 244 | |
d62a17ae | 245 | return CMD_SUCCESS; |
65f9a9a8 DL |
246 | } |
247 | ||
248 | DEFUN (isis_network, | |
249 | isis_network_cmd, | |
250 | "isis network point-to-point", | |
251 | "IS-IS commands\n" | |
252 | "Set network type\n" | |
253 | "point-to-point network type\n") | |
254 | { | |
d62a17ae | 255 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
256 | if (!circuit) | |
257 | return CMD_ERR_NO_MATCH; | |
65f9a9a8 | 258 | |
d62a17ae | 259 | if (isis_circuit_circ_type_set(circuit, CIRCUIT_T_P2P)) { |
260 | vty_out(vty, | |
261 | "isis network point-to-point is valid only on broadcast interfaces\n"); | |
a5fdb4c5 | 262 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 263 | } |
65f9a9a8 | 264 | |
d62a17ae | 265 | return CMD_SUCCESS; |
65f9a9a8 DL |
266 | } |
267 | ||
268 | DEFUN (no_isis_network, | |
269 | no_isis_network_cmd, | |
270 | "no isis network point-to-point", | |
271 | NO_STR | |
272 | "IS-IS commands\n" | |
273 | "Set network type for circuit\n" | |
274 | "point-to-point network type\n") | |
275 | { | |
d62a17ae | 276 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
277 | if (!circuit) | |
278 | return CMD_ERR_NO_MATCH; | |
65f9a9a8 | 279 | |
d62a17ae | 280 | if (isis_circuit_circ_type_set(circuit, CIRCUIT_T_BROADCAST)) { |
281 | vty_out(vty, | |
282 | "isis network point-to-point is valid only on broadcast interfaces\n"); | |
a5fdb4c5 | 283 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 284 | } |
65f9a9a8 | 285 | |
d62a17ae | 286 | return CMD_SUCCESS; |
65f9a9a8 DL |
287 | } |
288 | ||
50c7d14a CF |
289 | DEFUN (isis_passwd, |
290 | isis_passwd_cmd, | |
6147e2c6 | 291 | "isis password <md5|clear> WORD", |
50c7d14a CF |
292 | "IS-IS commands\n" |
293 | "Configure the authentication password for a circuit\n" | |
294 | "HMAC-MD5 authentication\n" | |
295 | "Cleartext password\n" | |
296 | "Circuit password\n") | |
297 | { | |
d62a17ae | 298 | int idx_encryption = 2; |
299 | int idx_word = 3; | |
300 | struct isis_circuit *circuit = isis_circuit_lookup(vty); | |
64dd3ffe DL |
301 | ferr_r rv; |
302 | ||
d62a17ae | 303 | if (!circuit) |
304 | return CMD_ERR_NO_MATCH; | |
50c7d14a | 305 | |
d62a17ae | 306 | if (argv[idx_encryption]->arg[0] == 'm') |
307 | rv = isis_circuit_passwd_hmac_md5_set(circuit, | |
308 | argv[idx_word]->arg); | |
309 | else | |
310 | rv = isis_circuit_passwd_cleartext_set(circuit, | |
311 | argv[idx_word]->arg); | |
50c7d14a | 312 | |
64dd3ffe | 313 | CMD_FERR_RETURN(rv, "Failed to set circuit password: $ERR"); |
d62a17ae | 314 | return CMD_SUCCESS; |
50c7d14a CF |
315 | } |
316 | ||
317 | DEFUN (no_isis_passwd, | |
318 | no_isis_passwd_cmd, | |
b44c509a | 319 | "no isis password [<md5|clear> WORD]", |
50c7d14a CF |
320 | NO_STR |
321 | "IS-IS commands\n" | |
b44c509a DW |
322 | "Configure the authentication password for a circuit\n" |
323 | "HMAC-MD5 authentication\n" | |
324 | "Cleartext password\n" | |
325 | "Circuit password\n") | |
50c7d14a | 326 | { |
d62a17ae | 327 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
328 | if (!circuit) | |
329 | return CMD_ERR_NO_MATCH; | |
50c7d14a | 330 | |
64dd3ffe DL |
331 | CMD_FERR_RETURN(isis_circuit_passwd_unset(circuit), |
332 | "Failed to unset circuit password: $ERR"); | |
d62a17ae | 333 | return CMD_SUCCESS; |
50c7d14a CF |
334 | } |
335 | ||
50c7d14a | 336 | |
65f9a9a8 DL |
337 | DEFUN (isis_priority, |
338 | isis_priority_cmd, | |
6147e2c6 | 339 | "isis priority (0-127)", |
65f9a9a8 DL |
340 | "IS-IS commands\n" |
341 | "Set priority for Designated Router election\n" | |
342 | "Priority value\n") | |
343 | { | |
d62a17ae | 344 | int idx_number = 2; |
345 | int prio; | |
346 | struct isis_circuit *circuit = isis_circuit_lookup(vty); | |
347 | if (!circuit) | |
348 | return CMD_ERR_NO_MATCH; | |
65f9a9a8 | 349 | |
d62a17ae | 350 | prio = atoi(argv[idx_number]->arg); |
351 | if (prio < MIN_PRIORITY || prio > MAX_PRIORITY) { | |
352 | vty_out(vty, "Invalid priority %d - should be <0-127>\n", prio); | |
a5fdb4c5 | 353 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 354 | } |
65f9a9a8 | 355 | |
d62a17ae | 356 | circuit->priority[0] = prio; |
357 | circuit->priority[1] = prio; | |
65f9a9a8 | 358 | |
d62a17ae | 359 | return CMD_SUCCESS; |
65f9a9a8 DL |
360 | } |
361 | ||
362 | DEFUN (no_isis_priority, | |
363 | no_isis_priority_cmd, | |
b44c509a | 364 | "no isis priority [(0-127)]", |
65f9a9a8 DL |
365 | NO_STR |
366 | "IS-IS commands\n" | |
b44c509a DW |
367 | "Set priority for Designated Router election\n" |
368 | "Priority value\n") | |
65f9a9a8 | 369 | { |
d62a17ae | 370 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
371 | if (!circuit) | |
372 | return CMD_ERR_NO_MATCH; | |
65f9a9a8 | 373 | |
d62a17ae | 374 | circuit->priority[0] = DEFAULT_PRIORITY; |
375 | circuit->priority[1] = DEFAULT_PRIORITY; | |
65f9a9a8 | 376 | |
d62a17ae | 377 | return CMD_SUCCESS; |
65f9a9a8 DL |
378 | } |
379 | ||
65f9a9a8 DL |
380 | |
381 | DEFUN (isis_priority_l1, | |
382 | isis_priority_l1_cmd, | |
6147e2c6 | 383 | "isis priority (0-127) level-1", |
65f9a9a8 DL |
384 | "IS-IS commands\n" |
385 | "Set priority for Designated Router election\n" | |
386 | "Priority value\n" | |
387 | "Specify priority for level-1 routing\n") | |
388 | { | |
d62a17ae | 389 | int idx_number = 2; |
390 | int prio; | |
391 | struct isis_circuit *circuit = isis_circuit_lookup(vty); | |
392 | if (!circuit) | |
393 | return CMD_ERR_NO_MATCH; | |
65f9a9a8 | 394 | |
d62a17ae | 395 | prio = atoi(argv[idx_number]->arg); |
396 | if (prio < MIN_PRIORITY || prio > MAX_PRIORITY) { | |
397 | vty_out(vty, "Invalid priority %d - should be <0-127>\n", prio); | |
a5fdb4c5 | 398 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 399 | } |
65f9a9a8 | 400 | |
d62a17ae | 401 | circuit->priority[0] = prio; |
65f9a9a8 | 402 | |
d62a17ae | 403 | return CMD_SUCCESS; |
65f9a9a8 DL |
404 | } |
405 | ||
406 | DEFUN (no_isis_priority_l1, | |
407 | no_isis_priority_l1_cmd, | |
b44c509a | 408 | "no isis priority [(0-127)] level-1", |
65f9a9a8 DL |
409 | NO_STR |
410 | "IS-IS commands\n" | |
411 | "Set priority for Designated Router election\n" | |
b44c509a | 412 | "Priority value\n" |
65f9a9a8 DL |
413 | "Specify priority for level-1 routing\n") |
414 | { | |
d62a17ae | 415 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
416 | if (!circuit) | |
417 | return CMD_ERR_NO_MATCH; | |
65f9a9a8 | 418 | |
d62a17ae | 419 | circuit->priority[0] = DEFAULT_PRIORITY; |
65f9a9a8 | 420 | |
d62a17ae | 421 | return CMD_SUCCESS; |
65f9a9a8 DL |
422 | } |
423 | ||
65f9a9a8 DL |
424 | |
425 | DEFUN (isis_priority_l2, | |
426 | isis_priority_l2_cmd, | |
6147e2c6 | 427 | "isis priority (0-127) level-2", |
65f9a9a8 DL |
428 | "IS-IS commands\n" |
429 | "Set priority for Designated Router election\n" | |
430 | "Priority value\n" | |
431 | "Specify priority for level-2 routing\n") | |
432 | { | |
d62a17ae | 433 | int idx_number = 2; |
434 | int prio; | |
435 | struct isis_circuit *circuit = isis_circuit_lookup(vty); | |
436 | if (!circuit) | |
437 | return CMD_ERR_NO_MATCH; | |
65f9a9a8 | 438 | |
d62a17ae | 439 | prio = atoi(argv[idx_number]->arg); |
440 | if (prio < MIN_PRIORITY || prio > MAX_PRIORITY) { | |
441 | vty_out(vty, "Invalid priority %d - should be <0-127>\n", prio); | |
a5fdb4c5 | 442 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 443 | } |
65f9a9a8 | 444 | |
d62a17ae | 445 | circuit->priority[1] = prio; |
65f9a9a8 | 446 | |
d62a17ae | 447 | return CMD_SUCCESS; |
65f9a9a8 DL |
448 | } |
449 | ||
450 | DEFUN (no_isis_priority_l2, | |
451 | no_isis_priority_l2_cmd, | |
b44c509a | 452 | "no isis priority [(0-127)] level-2", |
65f9a9a8 DL |
453 | NO_STR |
454 | "IS-IS commands\n" | |
455 | "Set priority for Designated Router election\n" | |
b44c509a | 456 | "Priority value\n" |
65f9a9a8 DL |
457 | "Specify priority for level-2 routing\n") |
458 | { | |
d62a17ae | 459 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
460 | if (!circuit) | |
461 | return CMD_ERR_NO_MATCH; | |
65f9a9a8 | 462 | |
d62a17ae | 463 | circuit->priority[1] = DEFAULT_PRIORITY; |
65f9a9a8 | 464 | |
d62a17ae | 465 | return CMD_SUCCESS; |
65f9a9a8 DL |
466 | } |
467 | ||
65f9a9a8 DL |
468 | |
469 | /* Metric command */ | |
470 | DEFUN (isis_metric, | |
471 | isis_metric_cmd, | |
6147e2c6 | 472 | "isis metric (0-16777215)", |
65f9a9a8 DL |
473 | "IS-IS commands\n" |
474 | "Set default metric for circuit\n" | |
475 | "Default metric value\n") | |
476 | { | |
d62a17ae | 477 | int idx_number = 2; |
478 | int met; | |
479 | struct isis_circuit *circuit = isis_circuit_lookup(vty); | |
480 | if (!circuit) | |
481 | return CMD_ERR_NO_MATCH; | |
65f9a9a8 | 482 | |
d62a17ae | 483 | met = atoi(argv[idx_number]->arg); |
65f9a9a8 | 484 | |
d62a17ae | 485 | /* RFC3787 section 5.1 */ |
486 | if (circuit->area && circuit->area->oldmetric == 1 | |
487 | && met > MAX_NARROW_LINK_METRIC) { | |
488 | vty_out(vty, | |
489 | "Invalid metric %d - should be <0-63> " | |
490 | "when narrow metric type enabled\n", | |
491 | met); | |
a5fdb4c5 | 492 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 493 | } |
65f9a9a8 | 494 | |
d62a17ae | 495 | /* RFC4444 */ |
496 | if (circuit->area && circuit->area->newmetric == 1 | |
497 | && met > MAX_WIDE_LINK_METRIC) { | |
498 | vty_out(vty, | |
499 | "Invalid metric %d - should be <0-16777215> " | |
500 | "when wide metric type enabled\n", | |
501 | met); | |
a5fdb4c5 | 502 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 503 | } |
65f9a9a8 | 504 | |
64dd3ffe DL |
505 | CMD_FERR_RETURN(isis_circuit_metric_set(circuit, IS_LEVEL_1, met), |
506 | "Failed to set L1 metric: $ERR"); | |
507 | CMD_FERR_RETURN(isis_circuit_metric_set(circuit, IS_LEVEL_2, met), | |
508 | "Failed to set L2 metric: $ERR"); | |
d62a17ae | 509 | return CMD_SUCCESS; |
65f9a9a8 DL |
510 | } |
511 | ||
b44c509a | 512 | |
65f9a9a8 DL |
513 | DEFUN (no_isis_metric, |
514 | no_isis_metric_cmd, | |
b44c509a | 515 | "no isis metric [(0-16777215)]", |
65f9a9a8 DL |
516 | NO_STR |
517 | "IS-IS commands\n" | |
b44c509a DW |
518 | "Set default metric for circuit\n" |
519 | "Default metric value\n") | |
65f9a9a8 | 520 | { |
d62a17ae | 521 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
522 | if (!circuit) | |
523 | return CMD_ERR_NO_MATCH; | |
65f9a9a8 | 524 | |
64dd3ffe DL |
525 | CMD_FERR_RETURN(isis_circuit_metric_set(circuit, IS_LEVEL_1, |
526 | DEFAULT_CIRCUIT_METRIC), | |
527 | "Failed to set L1 metric: $ERR"); | |
528 | CMD_FERR_RETURN(isis_circuit_metric_set(circuit, IS_LEVEL_2, | |
529 | DEFAULT_CIRCUIT_METRIC), | |
530 | "Failed to set L2 metric: $ERR"); | |
d62a17ae | 531 | return CMD_SUCCESS; |
65f9a9a8 DL |
532 | } |
533 | ||
65f9a9a8 DL |
534 | |
535 | DEFUN (isis_metric_l1, | |
536 | isis_metric_l1_cmd, | |
6147e2c6 | 537 | "isis metric (0-16777215) level-1", |
65f9a9a8 DL |
538 | "IS-IS commands\n" |
539 | "Set default metric for circuit\n" | |
540 | "Default metric value\n" | |
541 | "Specify metric for level-1 routing\n") | |
542 | { | |
d62a17ae | 543 | int idx_number = 2; |
544 | int met; | |
545 | struct isis_circuit *circuit = isis_circuit_lookup(vty); | |
546 | if (!circuit) | |
547 | return CMD_ERR_NO_MATCH; | |
65f9a9a8 | 548 | |
d62a17ae | 549 | met = atoi(argv[idx_number]->arg); |
64dd3ffe DL |
550 | CMD_FERR_RETURN(isis_circuit_metric_set(circuit, IS_LEVEL_1, met), |
551 | "Failed to set L1 metric: $ERR"); | |
d62a17ae | 552 | return CMD_SUCCESS; |
65f9a9a8 DL |
553 | } |
554 | ||
b44c509a | 555 | |
65f9a9a8 DL |
556 | DEFUN (no_isis_metric_l1, |
557 | no_isis_metric_l1_cmd, | |
b44c509a | 558 | "no isis metric [(0-16777215)] level-1", |
65f9a9a8 DL |
559 | NO_STR |
560 | "IS-IS commands\n" | |
561 | "Set default metric for circuit\n" | |
b44c509a | 562 | "Default metric value\n" |
65f9a9a8 DL |
563 | "Specify metric for level-1 routing\n") |
564 | { | |
d62a17ae | 565 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
566 | if (!circuit) | |
567 | return CMD_ERR_NO_MATCH; | |
65f9a9a8 | 568 | |
64dd3ffe DL |
569 | CMD_FERR_RETURN(isis_circuit_metric_set(circuit, IS_LEVEL_1, |
570 | DEFAULT_CIRCUIT_METRIC), | |
571 | "Failed to set L1 metric: $ERR"); | |
d62a17ae | 572 | return CMD_SUCCESS; |
65f9a9a8 DL |
573 | } |
574 | ||
65f9a9a8 DL |
575 | |
576 | DEFUN (isis_metric_l2, | |
577 | isis_metric_l2_cmd, | |
6147e2c6 | 578 | "isis metric (0-16777215) level-2", |
65f9a9a8 DL |
579 | "IS-IS commands\n" |
580 | "Set default metric for circuit\n" | |
581 | "Default metric value\n" | |
582 | "Specify metric for level-2 routing\n") | |
583 | { | |
d62a17ae | 584 | int idx_number = 2; |
585 | int met; | |
586 | struct isis_circuit *circuit = isis_circuit_lookup(vty); | |
587 | if (!circuit) | |
588 | return CMD_ERR_NO_MATCH; | |
65f9a9a8 | 589 | |
d62a17ae | 590 | met = atoi(argv[idx_number]->arg); |
64dd3ffe DL |
591 | CMD_FERR_RETURN(isis_circuit_metric_set(circuit, IS_LEVEL_2, met), |
592 | "Failed to set L2 metric: $ERR"); | |
d62a17ae | 593 | return CMD_SUCCESS; |
65f9a9a8 DL |
594 | } |
595 | ||
b44c509a | 596 | |
65f9a9a8 DL |
597 | DEFUN (no_isis_metric_l2, |
598 | no_isis_metric_l2_cmd, | |
b44c509a | 599 | "no isis metric [(0-16777215)] level-2", |
65f9a9a8 DL |
600 | NO_STR |
601 | "IS-IS commands\n" | |
602 | "Set default metric for circuit\n" | |
b44c509a | 603 | "Default metric value\n" |
65f9a9a8 DL |
604 | "Specify metric for level-2 routing\n") |
605 | { | |
d62a17ae | 606 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
607 | if (!circuit) | |
608 | return CMD_ERR_NO_MATCH; | |
65f9a9a8 | 609 | |
64dd3ffe DL |
610 | CMD_FERR_RETURN(isis_circuit_metric_set(circuit, IS_LEVEL_2, |
611 | DEFAULT_CIRCUIT_METRIC), | |
612 | "Failed to set L2 metric: $ERR"); | |
d62a17ae | 613 | return CMD_SUCCESS; |
65f9a9a8 DL |
614 | } |
615 | ||
65f9a9a8 DL |
616 | /* end of metrics */ |
617 | ||
01bb08b6 DL |
618 | DEFUN (isis_hello_interval, |
619 | isis_hello_interval_cmd, | |
6147e2c6 | 620 | "isis hello-interval (1-600)", |
01bb08b6 DL |
621 | "IS-IS commands\n" |
622 | "Set Hello interval\n" | |
01bb08b6 DL |
623 | "Holdtime 1 seconds, interval depends on multiplier\n") |
624 | { | |
d62a17ae | 625 | int idx_number = 2; |
626 | int interval; | |
627 | struct isis_circuit *circuit = isis_circuit_lookup(vty); | |
628 | if (!circuit) | |
629 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 630 | |
d62a17ae | 631 | interval = atoi(argv[idx_number]->arg); |
632 | if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL) { | |
633 | vty_out(vty, "Invalid hello-interval %d - should be <1-600>\n", | |
634 | interval); | |
a5fdb4c5 | 635 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 636 | } |
01bb08b6 | 637 | |
d7c0a89a QY |
638 | circuit->hello_interval[0] = (uint16_t)interval; |
639 | circuit->hello_interval[1] = (uint16_t)interval; | |
01bb08b6 | 640 | |
d62a17ae | 641 | return CMD_SUCCESS; |
01bb08b6 DL |
642 | } |
643 | ||
b44c509a | 644 | |
01bb08b6 DL |
645 | DEFUN (no_isis_hello_interval, |
646 | no_isis_hello_interval_cmd, | |
b44c509a | 647 | "no isis hello-interval [(1-600)]", |
01bb08b6 DL |
648 | NO_STR |
649 | "IS-IS commands\n" | |
b44c509a DW |
650 | "Set Hello interval\n" |
651 | "Holdtime 1 second, interval depends on multiplier\n") | |
01bb08b6 | 652 | { |
d62a17ae | 653 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
654 | if (!circuit) | |
655 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 656 | |
d62a17ae | 657 | circuit->hello_interval[0] = DEFAULT_HELLO_INTERVAL; |
658 | circuit->hello_interval[1] = DEFAULT_HELLO_INTERVAL; | |
01bb08b6 | 659 | |
d62a17ae | 660 | return CMD_SUCCESS; |
01bb08b6 DL |
661 | } |
662 | ||
01bb08b6 DL |
663 | |
664 | DEFUN (isis_hello_interval_l1, | |
665 | isis_hello_interval_l1_cmd, | |
6147e2c6 | 666 | "isis hello-interval (1-600) level-1", |
01bb08b6 DL |
667 | "IS-IS commands\n" |
668 | "Set Hello interval\n" | |
01bb08b6 DL |
669 | "Holdtime 1 second, interval depends on multiplier\n" |
670 | "Specify hello-interval for level-1 IIHs\n") | |
671 | { | |
d62a17ae | 672 | int idx_number = 2; |
673 | long interval; | |
674 | struct isis_circuit *circuit = isis_circuit_lookup(vty); | |
675 | if (!circuit) | |
676 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 677 | |
d62a17ae | 678 | interval = atoi(argv[idx_number]->arg); |
679 | if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL) { | |
680 | vty_out(vty, "Invalid hello-interval %ld - should be <1-600>\n", | |
681 | interval); | |
a5fdb4c5 | 682 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 683 | } |
01bb08b6 | 684 | |
d7c0a89a | 685 | circuit->hello_interval[0] = (uint16_t)interval; |
01bb08b6 | 686 | |
d62a17ae | 687 | return CMD_SUCCESS; |
01bb08b6 DL |
688 | } |
689 | ||
b44c509a | 690 | |
01bb08b6 DL |
691 | DEFUN (no_isis_hello_interval_l1, |
692 | no_isis_hello_interval_l1_cmd, | |
b44c509a | 693 | "no isis hello-interval [(1-600)] level-1", |
01bb08b6 DL |
694 | NO_STR |
695 | "IS-IS commands\n" | |
696 | "Set Hello interval\n" | |
b44c509a | 697 | "Holdtime 1 second, interval depends on multiplier\n" |
01bb08b6 DL |
698 | "Specify hello-interval for level-1 IIHs\n") |
699 | { | |
d62a17ae | 700 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
701 | if (!circuit) | |
702 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 703 | |
d62a17ae | 704 | circuit->hello_interval[0] = DEFAULT_HELLO_INTERVAL; |
01bb08b6 | 705 | |
d62a17ae | 706 | return CMD_SUCCESS; |
01bb08b6 DL |
707 | } |
708 | ||
01bb08b6 DL |
709 | |
710 | DEFUN (isis_hello_interval_l2, | |
711 | isis_hello_interval_l2_cmd, | |
6147e2c6 | 712 | "isis hello-interval (1-600) level-2", |
01bb08b6 DL |
713 | "IS-IS commands\n" |
714 | "Set Hello interval\n" | |
01bb08b6 DL |
715 | "Holdtime 1 second, interval depends on multiplier\n" |
716 | "Specify hello-interval for level-2 IIHs\n") | |
717 | { | |
d62a17ae | 718 | int idx_number = 2; |
719 | long interval; | |
720 | struct isis_circuit *circuit = isis_circuit_lookup(vty); | |
721 | if (!circuit) | |
722 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 723 | |
d62a17ae | 724 | interval = atoi(argv[idx_number]->arg); |
725 | if (interval < MIN_HELLO_INTERVAL || interval > MAX_HELLO_INTERVAL) { | |
726 | vty_out(vty, "Invalid hello-interval %ld - should be <1-600>\n", | |
727 | interval); | |
a5fdb4c5 | 728 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 729 | } |
01bb08b6 | 730 | |
d7c0a89a | 731 | circuit->hello_interval[1] = (uint16_t)interval; |
01bb08b6 | 732 | |
d62a17ae | 733 | return CMD_SUCCESS; |
01bb08b6 DL |
734 | } |
735 | ||
b44c509a | 736 | |
01bb08b6 DL |
737 | DEFUN (no_isis_hello_interval_l2, |
738 | no_isis_hello_interval_l2_cmd, | |
b44c509a | 739 | "no isis hello-interval [(1-600)] level-2", |
01bb08b6 DL |
740 | NO_STR |
741 | "IS-IS commands\n" | |
742 | "Set Hello interval\n" | |
b44c509a | 743 | "Holdtime 1 second, interval depends on multiplier\n" |
01bb08b6 DL |
744 | "Specify hello-interval for level-2 IIHs\n") |
745 | { | |
d62a17ae | 746 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
747 | if (!circuit) | |
748 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 749 | |
d62a17ae | 750 | circuit->hello_interval[1] = DEFAULT_HELLO_INTERVAL; |
01bb08b6 | 751 | |
d62a17ae | 752 | return CMD_SUCCESS; |
01bb08b6 DL |
753 | } |
754 | ||
01bb08b6 DL |
755 | |
756 | DEFUN (isis_hello_multiplier, | |
757 | isis_hello_multiplier_cmd, | |
6147e2c6 | 758 | "isis hello-multiplier (2-100)", |
01bb08b6 DL |
759 | "IS-IS commands\n" |
760 | "Set multiplier for Hello holding time\n" | |
761 | "Hello multiplier value\n") | |
762 | { | |
d62a17ae | 763 | int idx_number = 2; |
764 | int mult; | |
765 | struct isis_circuit *circuit = isis_circuit_lookup(vty); | |
766 | if (!circuit) | |
767 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 768 | |
d62a17ae | 769 | mult = atoi(argv[idx_number]->arg); |
770 | if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER) { | |
771 | vty_out(vty, | |
772 | "Invalid hello-multiplier %d - should be <2-100>\n", | |
773 | mult); | |
a5fdb4c5 | 774 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 775 | } |
01bb08b6 | 776 | |
d7c0a89a QY |
777 | circuit->hello_multiplier[0] = (uint16_t)mult; |
778 | circuit->hello_multiplier[1] = (uint16_t)mult; | |
01bb08b6 | 779 | |
d62a17ae | 780 | return CMD_SUCCESS; |
01bb08b6 DL |
781 | } |
782 | ||
b44c509a | 783 | |
01bb08b6 DL |
784 | DEFUN (no_isis_hello_multiplier, |
785 | no_isis_hello_multiplier_cmd, | |
b44c509a | 786 | "no isis hello-multiplier [(2-100)]", |
01bb08b6 DL |
787 | NO_STR |
788 | "IS-IS commands\n" | |
b44c509a DW |
789 | "Set multiplier for Hello holding time\n" |
790 | "Hello multiplier value\n") | |
01bb08b6 | 791 | { |
d62a17ae | 792 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
793 | if (!circuit) | |
794 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 795 | |
d62a17ae | 796 | circuit->hello_multiplier[0] = DEFAULT_HELLO_MULTIPLIER; |
797 | circuit->hello_multiplier[1] = DEFAULT_HELLO_MULTIPLIER; | |
01bb08b6 | 798 | |
d62a17ae | 799 | return CMD_SUCCESS; |
01bb08b6 DL |
800 | } |
801 | ||
01bb08b6 DL |
802 | |
803 | DEFUN (isis_hello_multiplier_l1, | |
804 | isis_hello_multiplier_l1_cmd, | |
6147e2c6 | 805 | "isis hello-multiplier (2-100) level-1", |
01bb08b6 DL |
806 | "IS-IS commands\n" |
807 | "Set multiplier for Hello holding time\n" | |
808 | "Hello multiplier value\n" | |
809 | "Specify hello multiplier for level-1 IIHs\n") | |
810 | { | |
d62a17ae | 811 | int idx_number = 2; |
812 | int mult; | |
813 | struct isis_circuit *circuit = isis_circuit_lookup(vty); | |
814 | if (!circuit) | |
815 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 816 | |
d62a17ae | 817 | mult = atoi(argv[idx_number]->arg); |
818 | if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER) { | |
819 | vty_out(vty, | |
820 | "Invalid hello-multiplier %d - should be <2-100>\n", | |
821 | mult); | |
a5fdb4c5 | 822 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 823 | } |
01bb08b6 | 824 | |
d7c0a89a | 825 | circuit->hello_multiplier[0] = (uint16_t)mult; |
01bb08b6 | 826 | |
d62a17ae | 827 | return CMD_SUCCESS; |
01bb08b6 DL |
828 | } |
829 | ||
b44c509a | 830 | |
01bb08b6 DL |
831 | DEFUN (no_isis_hello_multiplier_l1, |
832 | no_isis_hello_multiplier_l1_cmd, | |
b44c509a | 833 | "no isis hello-multiplier [(2-100)] level-1", |
01bb08b6 DL |
834 | NO_STR |
835 | "IS-IS commands\n" | |
836 | "Set multiplier for Hello holding time\n" | |
b44c509a | 837 | "Hello multiplier value\n" |
01bb08b6 DL |
838 | "Specify hello multiplier for level-1 IIHs\n") |
839 | { | |
d62a17ae | 840 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
841 | if (!circuit) | |
842 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 843 | |
d62a17ae | 844 | circuit->hello_multiplier[0] = DEFAULT_HELLO_MULTIPLIER; |
01bb08b6 | 845 | |
d62a17ae | 846 | return CMD_SUCCESS; |
01bb08b6 DL |
847 | } |
848 | ||
01bb08b6 DL |
849 | |
850 | DEFUN (isis_hello_multiplier_l2, | |
851 | isis_hello_multiplier_l2_cmd, | |
6147e2c6 | 852 | "isis hello-multiplier (2-100) level-2", |
01bb08b6 DL |
853 | "IS-IS commands\n" |
854 | "Set multiplier for Hello holding time\n" | |
855 | "Hello multiplier value\n" | |
856 | "Specify hello multiplier for level-2 IIHs\n") | |
857 | { | |
d62a17ae | 858 | int idx_number = 2; |
859 | int mult; | |
860 | struct isis_circuit *circuit = isis_circuit_lookup(vty); | |
861 | if (!circuit) | |
862 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 863 | |
d62a17ae | 864 | mult = atoi(argv[idx_number]->arg); |
865 | if (mult < MIN_HELLO_MULTIPLIER || mult > MAX_HELLO_MULTIPLIER) { | |
866 | vty_out(vty, | |
867 | "Invalid hello-multiplier %d - should be <2-100>\n", | |
868 | mult); | |
a5fdb4c5 | 869 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 870 | } |
01bb08b6 | 871 | |
d7c0a89a | 872 | circuit->hello_multiplier[1] = (uint16_t)mult; |
01bb08b6 | 873 | |
d62a17ae | 874 | return CMD_SUCCESS; |
01bb08b6 DL |
875 | } |
876 | ||
b44c509a | 877 | |
01bb08b6 DL |
878 | DEFUN (no_isis_hello_multiplier_l2, |
879 | no_isis_hello_multiplier_l2_cmd, | |
b44c509a | 880 | "no isis hello-multiplier [(2-100)] level-2", |
01bb08b6 DL |
881 | NO_STR |
882 | "IS-IS commands\n" | |
883 | "Set multiplier for Hello holding time\n" | |
b44c509a | 884 | "Hello multiplier value\n" |
01bb08b6 DL |
885 | "Specify hello multiplier for level-2 IIHs\n") |
886 | { | |
d62a17ae | 887 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
888 | if (!circuit) | |
889 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 890 | |
d62a17ae | 891 | circuit->hello_multiplier[1] = DEFAULT_HELLO_MULTIPLIER; |
01bb08b6 | 892 | |
d62a17ae | 893 | return CMD_SUCCESS; |
01bb08b6 DL |
894 | } |
895 | ||
01bb08b6 DL |
896 | |
897 | DEFUN (isis_hello_padding, | |
898 | isis_hello_padding_cmd, | |
899 | "isis hello padding", | |
900 | "IS-IS commands\n" | |
901 | "Add padding to IS-IS hello packets\n" | |
7111c1a0 | 902 | "Pad hello packets\n") |
01bb08b6 | 903 | { |
d62a17ae | 904 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
905 | if (!circuit) | |
906 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 907 | |
d62a17ae | 908 | circuit->pad_hellos = 1; |
01bb08b6 | 909 | |
d62a17ae | 910 | return CMD_SUCCESS; |
01bb08b6 DL |
911 | } |
912 | ||
913 | DEFUN (no_isis_hello_padding, | |
914 | no_isis_hello_padding_cmd, | |
915 | "no isis hello padding", | |
916 | NO_STR | |
917 | "IS-IS commands\n" | |
918 | "Add padding to IS-IS hello packets\n" | |
7111c1a0 | 919 | "Pad hello packets\n") |
01bb08b6 | 920 | { |
d62a17ae | 921 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
922 | if (!circuit) | |
923 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 924 | |
d62a17ae | 925 | circuit->pad_hellos = 0; |
01bb08b6 | 926 | |
d62a17ae | 927 | return CMD_SUCCESS; |
01bb08b6 DL |
928 | } |
929 | ||
58e5d748 CF |
930 | DEFUN (isis_threeway_adj, |
931 | isis_threeway_adj_cmd, | |
932 | "[no] isis three-way-handshake", | |
933 | NO_STR | |
934 | "IS-IS commands\n" | |
935 | "Enable/Disable three-way handshake\n") | |
936 | { | |
937 | struct isis_circuit *circuit = isis_circuit_lookup(vty); | |
938 | if (!circuit) | |
939 | return CMD_ERR_NO_MATCH; | |
940 | ||
941 | circuit->disable_threeway_adj = !strcmp(argv[0]->text, "no"); | |
942 | return CMD_SUCCESS; | |
943 | } | |
944 | ||
01bb08b6 DL |
945 | DEFUN (csnp_interval, |
946 | csnp_interval_cmd, | |
6147e2c6 | 947 | "isis csnp-interval (1-600)", |
01bb08b6 DL |
948 | "IS-IS commands\n" |
949 | "Set CSNP interval in seconds\n" | |
950 | "CSNP interval value\n") | |
951 | { | |
d62a17ae | 952 | int idx_number = 2; |
953 | unsigned long interval; | |
954 | struct isis_circuit *circuit = isis_circuit_lookup(vty); | |
955 | if (!circuit) | |
956 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 957 | |
d62a17ae | 958 | interval = atol(argv[idx_number]->arg); |
959 | if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL) { | |
960 | vty_out(vty, "Invalid csnp-interval %lu - should be <1-600>\n", | |
961 | interval); | |
a5fdb4c5 | 962 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 963 | } |
01bb08b6 | 964 | |
d7c0a89a QY |
965 | circuit->csnp_interval[0] = (uint16_t)interval; |
966 | circuit->csnp_interval[1] = (uint16_t)interval; | |
01bb08b6 | 967 | |
d62a17ae | 968 | return CMD_SUCCESS; |
01bb08b6 DL |
969 | } |
970 | ||
b44c509a | 971 | |
01bb08b6 DL |
972 | DEFUN (no_csnp_interval, |
973 | no_csnp_interval_cmd, | |
b44c509a | 974 | "no isis csnp-interval [(1-600)]", |
01bb08b6 DL |
975 | NO_STR |
976 | "IS-IS commands\n" | |
b44c509a DW |
977 | "Set CSNP interval in seconds\n" |
978 | "CSNP interval value\n") | |
01bb08b6 | 979 | { |
d62a17ae | 980 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
981 | if (!circuit) | |
982 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 983 | |
d62a17ae | 984 | circuit->csnp_interval[0] = DEFAULT_CSNP_INTERVAL; |
985 | circuit->csnp_interval[1] = DEFAULT_CSNP_INTERVAL; | |
01bb08b6 | 986 | |
d62a17ae | 987 | return CMD_SUCCESS; |
01bb08b6 DL |
988 | } |
989 | ||
01bb08b6 DL |
990 | |
991 | DEFUN (csnp_interval_l1, | |
992 | csnp_interval_l1_cmd, | |
6147e2c6 | 993 | "isis csnp-interval (1-600) level-1", |
01bb08b6 DL |
994 | "IS-IS commands\n" |
995 | "Set CSNP interval in seconds\n" | |
996 | "CSNP interval value\n" | |
997 | "Specify interval for level-1 CSNPs\n") | |
998 | { | |
d62a17ae | 999 | int idx_number = 2; |
1000 | unsigned long interval; | |
1001 | struct isis_circuit *circuit = isis_circuit_lookup(vty); | |
1002 | if (!circuit) | |
1003 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 1004 | |
d62a17ae | 1005 | interval = atol(argv[idx_number]->arg); |
1006 | if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL) { | |
1007 | vty_out(vty, "Invalid csnp-interval %lu - should be <1-600>\n", | |
1008 | interval); | |
a5fdb4c5 | 1009 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1010 | } |
01bb08b6 | 1011 | |
d7c0a89a | 1012 | circuit->csnp_interval[0] = (uint16_t)interval; |
01bb08b6 | 1013 | |
d62a17ae | 1014 | return CMD_SUCCESS; |
01bb08b6 DL |
1015 | } |
1016 | ||
b44c509a | 1017 | |
01bb08b6 DL |
1018 | DEFUN (no_csnp_interval_l1, |
1019 | no_csnp_interval_l1_cmd, | |
b44c509a | 1020 | "no isis csnp-interval [(1-600)] level-1", |
01bb08b6 DL |
1021 | NO_STR |
1022 | "IS-IS commands\n" | |
1023 | "Set CSNP interval in seconds\n" | |
b44c509a | 1024 | "CSNP interval value\n" |
01bb08b6 DL |
1025 | "Specify interval for level-1 CSNPs\n") |
1026 | { | |
d62a17ae | 1027 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
1028 | if (!circuit) | |
1029 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 1030 | |
d62a17ae | 1031 | circuit->csnp_interval[0] = DEFAULT_CSNP_INTERVAL; |
01bb08b6 | 1032 | |
d62a17ae | 1033 | return CMD_SUCCESS; |
01bb08b6 DL |
1034 | } |
1035 | ||
01bb08b6 DL |
1036 | |
1037 | DEFUN (csnp_interval_l2, | |
1038 | csnp_interval_l2_cmd, | |
6147e2c6 | 1039 | "isis csnp-interval (1-600) level-2", |
01bb08b6 DL |
1040 | "IS-IS commands\n" |
1041 | "Set CSNP interval in seconds\n" | |
1042 | "CSNP interval value\n" | |
1043 | "Specify interval for level-2 CSNPs\n") | |
1044 | { | |
d62a17ae | 1045 | int idx_number = 2; |
1046 | unsigned long interval; | |
1047 | struct isis_circuit *circuit = isis_circuit_lookup(vty); | |
1048 | if (!circuit) | |
1049 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 1050 | |
d62a17ae | 1051 | interval = atol(argv[idx_number]->arg); |
1052 | if (interval < MIN_CSNP_INTERVAL || interval > MAX_CSNP_INTERVAL) { | |
1053 | vty_out(vty, "Invalid csnp-interval %lu - should be <1-600>\n", | |
1054 | interval); | |
a5fdb4c5 | 1055 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1056 | } |
01bb08b6 | 1057 | |
d7c0a89a | 1058 | circuit->csnp_interval[1] = (uint16_t)interval; |
01bb08b6 | 1059 | |
d62a17ae | 1060 | return CMD_SUCCESS; |
01bb08b6 DL |
1061 | } |
1062 | ||
b44c509a | 1063 | |
01bb08b6 DL |
1064 | DEFUN (no_csnp_interval_l2, |
1065 | no_csnp_interval_l2_cmd, | |
b44c509a | 1066 | "no isis csnp-interval [(1-600)] level-2", |
01bb08b6 DL |
1067 | NO_STR |
1068 | "IS-IS commands\n" | |
1069 | "Set CSNP interval in seconds\n" | |
b44c509a | 1070 | "CSNP interval value\n" |
01bb08b6 DL |
1071 | "Specify interval for level-2 CSNPs\n") |
1072 | { | |
d62a17ae | 1073 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
1074 | if (!circuit) | |
1075 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 1076 | |
d62a17ae | 1077 | circuit->csnp_interval[1] = DEFAULT_CSNP_INTERVAL; |
01bb08b6 | 1078 | |
d62a17ae | 1079 | return CMD_SUCCESS; |
01bb08b6 DL |
1080 | } |
1081 | ||
01bb08b6 DL |
1082 | |
1083 | DEFUN (psnp_interval, | |
1084 | psnp_interval_cmd, | |
6147e2c6 | 1085 | "isis psnp-interval (1-120)", |
01bb08b6 DL |
1086 | "IS-IS commands\n" |
1087 | "Set PSNP interval in seconds\n" | |
1088 | "PSNP interval value\n") | |
1089 | { | |
d62a17ae | 1090 | int idx_number = 2; |
1091 | unsigned long interval; | |
1092 | struct isis_circuit *circuit = isis_circuit_lookup(vty); | |
1093 | if (!circuit) | |
1094 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 1095 | |
d62a17ae | 1096 | interval = atol(argv[idx_number]->arg); |
1097 | if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL) { | |
1098 | vty_out(vty, "Invalid psnp-interval %lu - should be <1-120>\n", | |
1099 | interval); | |
a5fdb4c5 | 1100 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1101 | } |
01bb08b6 | 1102 | |
d7c0a89a QY |
1103 | circuit->psnp_interval[0] = (uint16_t)interval; |
1104 | circuit->psnp_interval[1] = (uint16_t)interval; | |
01bb08b6 | 1105 | |
d62a17ae | 1106 | return CMD_SUCCESS; |
01bb08b6 DL |
1107 | } |
1108 | ||
b44c509a | 1109 | |
01bb08b6 DL |
1110 | DEFUN (no_psnp_interval, |
1111 | no_psnp_interval_cmd, | |
b44c509a | 1112 | "no isis psnp-interval [(1-120)]", |
01bb08b6 DL |
1113 | NO_STR |
1114 | "IS-IS commands\n" | |
b44c509a DW |
1115 | "Set PSNP interval in seconds\n" |
1116 | "PSNP interval value\n") | |
01bb08b6 | 1117 | { |
d62a17ae | 1118 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
1119 | if (!circuit) | |
1120 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 1121 | |
d62a17ae | 1122 | circuit->psnp_interval[0] = DEFAULT_PSNP_INTERVAL; |
1123 | circuit->psnp_interval[1] = DEFAULT_PSNP_INTERVAL; | |
01bb08b6 | 1124 | |
d62a17ae | 1125 | return CMD_SUCCESS; |
01bb08b6 DL |
1126 | } |
1127 | ||
01bb08b6 DL |
1128 | |
1129 | DEFUN (psnp_interval_l1, | |
1130 | psnp_interval_l1_cmd, | |
6147e2c6 | 1131 | "isis psnp-interval (1-120) level-1", |
01bb08b6 DL |
1132 | "IS-IS commands\n" |
1133 | "Set PSNP interval in seconds\n" | |
1134 | "PSNP interval value\n" | |
1135 | "Specify interval for level-1 PSNPs\n") | |
1136 | { | |
d62a17ae | 1137 | int idx_number = 2; |
1138 | unsigned long interval; | |
1139 | struct isis_circuit *circuit = isis_circuit_lookup(vty); | |
1140 | if (!circuit) | |
1141 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 1142 | |
d62a17ae | 1143 | interval = atol(argv[idx_number]->arg); |
1144 | if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL) { | |
1145 | vty_out(vty, "Invalid psnp-interval %lu - should be <1-120>\n", | |
1146 | interval); | |
a5fdb4c5 | 1147 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1148 | } |
01bb08b6 | 1149 | |
d7c0a89a | 1150 | circuit->psnp_interval[0] = (uint16_t)interval; |
01bb08b6 | 1151 | |
d62a17ae | 1152 | return CMD_SUCCESS; |
01bb08b6 DL |
1153 | } |
1154 | ||
b44c509a | 1155 | |
01bb08b6 DL |
1156 | DEFUN (no_psnp_interval_l1, |
1157 | no_psnp_interval_l1_cmd, | |
b44c509a | 1158 | "no isis psnp-interval [(1-120)] level-1", |
01bb08b6 DL |
1159 | NO_STR |
1160 | "IS-IS commands\n" | |
1161 | "Set PSNP interval in seconds\n" | |
b44c509a | 1162 | "PSNP interval value\n" |
01bb08b6 DL |
1163 | "Specify interval for level-1 PSNPs\n") |
1164 | { | |
d62a17ae | 1165 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
1166 | if (!circuit) | |
1167 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 1168 | |
d62a17ae | 1169 | circuit->psnp_interval[0] = DEFAULT_PSNP_INTERVAL; |
01bb08b6 | 1170 | |
d62a17ae | 1171 | return CMD_SUCCESS; |
01bb08b6 DL |
1172 | } |
1173 | ||
01bb08b6 DL |
1174 | |
1175 | DEFUN (psnp_interval_l2, | |
1176 | psnp_interval_l2_cmd, | |
6147e2c6 | 1177 | "isis psnp-interval (1-120) level-2", |
01bb08b6 DL |
1178 | "IS-IS commands\n" |
1179 | "Set PSNP interval in seconds\n" | |
1180 | "PSNP interval value\n" | |
1181 | "Specify interval for level-2 PSNPs\n") | |
1182 | { | |
d62a17ae | 1183 | int idx_number = 2; |
1184 | unsigned long interval; | |
1185 | struct isis_circuit *circuit = isis_circuit_lookup(vty); | |
1186 | if (!circuit) | |
1187 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 1188 | |
d62a17ae | 1189 | interval = atol(argv[idx_number]->arg); |
1190 | if (interval < MIN_PSNP_INTERVAL || interval > MAX_PSNP_INTERVAL) { | |
1191 | vty_out(vty, "Invalid psnp-interval %lu - should be <1-120>\n", | |
1192 | interval); | |
a5fdb4c5 | 1193 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1194 | } |
01bb08b6 | 1195 | |
d7c0a89a | 1196 | circuit->psnp_interval[1] = (uint16_t)interval; |
01bb08b6 | 1197 | |
d62a17ae | 1198 | return CMD_SUCCESS; |
01bb08b6 DL |
1199 | } |
1200 | ||
b44c509a | 1201 | |
01bb08b6 DL |
1202 | DEFUN (no_psnp_interval_l2, |
1203 | no_psnp_interval_l2_cmd, | |
b44c509a | 1204 | "no isis psnp-interval [(1-120)] level-2", |
01bb08b6 DL |
1205 | NO_STR |
1206 | "IS-IS commands\n" | |
1207 | "Set PSNP interval in seconds\n" | |
b44c509a | 1208 | "PSNP interval value\n" |
01bb08b6 DL |
1209 | "Specify interval for level-2 PSNPs\n") |
1210 | { | |
d62a17ae | 1211 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
1212 | if (!circuit) | |
1213 | return CMD_ERR_NO_MATCH; | |
01bb08b6 | 1214 | |
d62a17ae | 1215 | circuit->psnp_interval[1] = DEFAULT_PSNP_INTERVAL; |
01bb08b6 | 1216 | |
d62a17ae | 1217 | return CMD_SUCCESS; |
01bb08b6 DL |
1218 | } |
1219 | ||
064f4896 CF |
1220 | DEFUN (circuit_topology, |
1221 | circuit_topology_cmd, | |
1222 | "isis topology " ISIS_MT_NAMES, | |
1223 | "IS-IS commands\n" | |
1224 | "Configure interface IS-IS topologies\n" | |
1225 | ISIS_MT_DESCRIPTIONS) | |
1226 | { | |
d62a17ae | 1227 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
1228 | if (!circuit) | |
1229 | return CMD_ERR_NO_MATCH; | |
1230 | const char *arg = argv[2]->arg; | |
1231 | uint16_t mtid = isis_str2mtid(arg); | |
c3ea3906 | 1232 | |
d62a17ae | 1233 | if (circuit->area && circuit->area->oldmetric) { |
1234 | vty_out(vty, | |
1235 | "Multi topology IS-IS can only be used with wide metrics\n"); | |
a5fdb4c5 | 1236 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1237 | } |
c3ea3906 | 1238 | |
d62a17ae | 1239 | if (mtid == (uint16_t)-1) { |
1240 | vty_out(vty, "Don't know topology '%s'\n", arg); | |
a5fdb4c5 | 1241 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1242 | } |
064f4896 | 1243 | |
d62a17ae | 1244 | return isis_circuit_mt_enabled_set(circuit, mtid, true); |
064f4896 CF |
1245 | } |
1246 | ||
1247 | DEFUN (no_circuit_topology, | |
1248 | no_circuit_topology_cmd, | |
1249 | "no isis topology " ISIS_MT_NAMES, | |
1250 | NO_STR | |
1251 | "IS-IS commands\n" | |
1252 | "Configure interface IS-IS topologies\n" | |
1253 | ISIS_MT_DESCRIPTIONS) | |
1254 | { | |
d62a17ae | 1255 | struct isis_circuit *circuit = isis_circuit_lookup(vty); |
1256 | if (!circuit) | |
1257 | return CMD_ERR_NO_MATCH; | |
1258 | const char *arg = argv[3]->arg; | |
1259 | uint16_t mtid = isis_str2mtid(arg); | |
1260 | ||
1261 | if (circuit->area && circuit->area->oldmetric) { | |
1262 | vty_out(vty, | |
1263 | "Multi topology IS-IS can only be used with wide metrics\n"); | |
a5fdb4c5 | 1264 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1265 | } |
1266 | ||
1267 | if (mtid == (uint16_t)-1) { | |
1268 | vty_out(vty, "Don't know topology '%s'\n", arg); | |
a5fdb4c5 | 1269 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1270 | } |
1271 | ||
1272 | return isis_circuit_mt_enabled_set(circuit, mtid, false); | |
1273 | } | |
1274 | ||
1275 | static int validate_metric_style_narrow(struct vty *vty, struct isis_area *area) | |
1276 | { | |
1277 | struct isis_circuit *circuit; | |
1278 | struct listnode *node; | |
1279 | ||
1280 | if (!vty) | |
a5fdb4c5 | 1281 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1282 | |
1283 | if (!area) { | |
1284 | vty_out(vty, "ISIS area is invalid\n"); | |
a5fdb4c5 | 1285 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1286 | } |
1287 | ||
1288 | for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { | |
1289 | if ((area->is_type & IS_LEVEL_1) | |
1290 | && (circuit->is_type & IS_LEVEL_1) | |
1291 | && (circuit->te_metric[0] > MAX_NARROW_LINK_METRIC)) { | |
1292 | vty_out(vty, "ISIS circuit %s metric is invalid\n", | |
1293 | circuit->interface->name); | |
a5fdb4c5 | 1294 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1295 | } |
1296 | if ((area->is_type & IS_LEVEL_2) | |
1297 | && (circuit->is_type & IS_LEVEL_2) | |
1298 | && (circuit->te_metric[1] > MAX_NARROW_LINK_METRIC)) { | |
1299 | vty_out(vty, "ISIS circuit %s metric is invalid\n", | |
1300 | circuit->interface->name); | |
a5fdb4c5 | 1301 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1302 | } |
1303 | } | |
1304 | ||
1305 | return CMD_SUCCESS; | |
a38a72db CF |
1306 | } |
1307 | ||
1308 | DEFUN (metric_style, | |
1309 | metric_style_cmd, | |
6147e2c6 | 1310 | "metric-style <narrow|transition|wide>", |
a38a72db CF |
1311 | "Use old-style (ISO 10589) or new-style packet formats\n" |
1312 | "Use old style of TLVs with narrow metric\n" | |
1313 | "Send and accept both styles of TLVs during transition\n" | |
1314 | "Use new style of TLVs to carry wider metric\n") | |
1315 | { | |
d62a17ae | 1316 | int idx_metric_style = 1; |
1317 | VTY_DECLVAR_CONTEXT(isis_area, area); | |
1318 | int ret; | |
a38a72db | 1319 | |
d62a17ae | 1320 | if (strncmp(argv[idx_metric_style]->arg, "w", 1) == 0) { |
1321 | isis_area_metricstyle_set(area, false, true); | |
1322 | return CMD_SUCCESS; | |
1323 | } | |
a38a72db | 1324 | |
d62a17ae | 1325 | if (area_is_mt(area)) { |
1326 | vty_out(vty, | |
1327 | "Narrow metrics cannot be used while multi topology IS-IS is active\n"); | |
a5fdb4c5 | 1328 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1329 | } |
c3ea3906 | 1330 | |
d62a17ae | 1331 | ret = validate_metric_style_narrow(vty, area); |
1332 | if (ret != CMD_SUCCESS) | |
1333 | return ret; | |
a38a72db | 1334 | |
d62a17ae | 1335 | if (strncmp(argv[idx_metric_style]->arg, "t", 1) == 0) |
1336 | isis_area_metricstyle_set(area, true, true); | |
1337 | else if (strncmp(argv[idx_metric_style]->arg, "n", 1) == 0) | |
1338 | isis_area_metricstyle_set(area, true, false); | |
1339 | return CMD_SUCCESS; | |
a38a72db | 1340 | |
d62a17ae | 1341 | return CMD_SUCCESS; |
a38a72db CF |
1342 | } |
1343 | ||
1344 | DEFUN (no_metric_style, | |
1345 | no_metric_style_cmd, | |
1346 | "no metric-style", | |
1347 | NO_STR | |
1348 | "Use old-style (ISO 10589) or new-style packet formats\n") | |
1349 | { | |
d62a17ae | 1350 | VTY_DECLVAR_CONTEXT(isis_area, area); |
1351 | int ret; | |
a38a72db | 1352 | |
d62a17ae | 1353 | if (area_is_mt(area)) { |
1354 | vty_out(vty, | |
1355 | "Narrow metrics cannot be used while multi topology IS-IS is active\n"); | |
a5fdb4c5 | 1356 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1357 | } |
c3ea3906 | 1358 | |
d62a17ae | 1359 | ret = validate_metric_style_narrow(vty, area); |
1360 | if (ret != CMD_SUCCESS) | |
1361 | return ret; | |
a38a72db | 1362 | |
d62a17ae | 1363 | isis_area_metricstyle_set(area, true, false); |
1364 | return CMD_SUCCESS; | |
a38a72db CF |
1365 | } |
1366 | ||
1367 | DEFUN (set_overload_bit, | |
1368 | set_overload_bit_cmd, | |
1369 | "set-overload-bit", | |
7111c1a0 | 1370 | "Set overload bit to avoid any transit traffic\n") |
a38a72db | 1371 | { |
d62a17ae | 1372 | VTY_DECLVAR_CONTEXT(isis_area, area); |
a38a72db | 1373 | |
d62a17ae | 1374 | isis_area_overload_bit_set(area, true); |
1375 | return CMD_SUCCESS; | |
a38a72db CF |
1376 | } |
1377 | ||
1378 | DEFUN (no_set_overload_bit, | |
1379 | no_set_overload_bit_cmd, | |
1380 | "no set-overload-bit", | |
1381 | "Reset overload bit to accept transit traffic\n" | |
1382 | "Reset overload bit\n") | |
1383 | { | |
d62a17ae | 1384 | VTY_DECLVAR_CONTEXT(isis_area, area); |
a38a72db | 1385 | |
d62a17ae | 1386 | isis_area_overload_bit_set(area, false); |
1387 | return CMD_SUCCESS; | |
a38a72db CF |
1388 | } |
1389 | ||
1390 | DEFUN (set_attached_bit, | |
1391 | set_attached_bit_cmd, | |
1392 | "set-attached-bit", | |
7111c1a0 | 1393 | "Set attached bit to identify as L1/L2 router for inter-area traffic\n") |
a38a72db | 1394 | { |
d62a17ae | 1395 | VTY_DECLVAR_CONTEXT(isis_area, area); |
a38a72db | 1396 | |
d62a17ae | 1397 | isis_area_attached_bit_set(area, true); |
1398 | return CMD_SUCCESS; | |
a38a72db CF |
1399 | } |
1400 | ||
1401 | DEFUN (no_set_attached_bit, | |
1402 | no_set_attached_bit_cmd, | |
1403 | "no set-attached-bit", | |
16cedbb0 | 1404 | NO_STR |
a38a72db CF |
1405 | "Reset attached bit\n") |
1406 | { | |
d62a17ae | 1407 | VTY_DECLVAR_CONTEXT(isis_area, area); |
a38a72db | 1408 | |
d62a17ae | 1409 | isis_area_attached_bit_set(area, false); |
1410 | return CMD_SUCCESS; | |
a38a72db CF |
1411 | } |
1412 | ||
1413 | DEFUN (dynamic_hostname, | |
1414 | dynamic_hostname_cmd, | |
1415 | "hostname dynamic", | |
1416 | "Dynamic hostname for IS-IS\n" | |
1417 | "Dynamic hostname\n") | |
1418 | { | |
d62a17ae | 1419 | VTY_DECLVAR_CONTEXT(isis_area, area); |
a38a72db | 1420 | |
d62a17ae | 1421 | isis_area_dynhostname_set(area, true); |
1422 | return CMD_SUCCESS; | |
a38a72db CF |
1423 | } |
1424 | ||
1425 | DEFUN (no_dynamic_hostname, | |
1426 | no_dynamic_hostname_cmd, | |
1427 | "no hostname dynamic", | |
1428 | NO_STR | |
1429 | "Dynamic hostname for IS-IS\n" | |
1430 | "Dynamic hostname\n") | |
1431 | { | |
d62a17ae | 1432 | VTY_DECLVAR_CONTEXT(isis_area, area); |
a38a72db | 1433 | |
d62a17ae | 1434 | isis_area_dynhostname_set(area, false); |
1435 | return CMD_SUCCESS; | |
a38a72db CF |
1436 | } |
1437 | ||
6754fc66 CF |
1438 | static int area_lsp_mtu_set(struct vty *vty, unsigned int lsp_mtu) |
1439 | { | |
d62a17ae | 1440 | VTY_DECLVAR_CONTEXT(isis_area, area); |
1441 | struct listnode *node; | |
1442 | struct isis_circuit *circuit; | |
6754fc66 | 1443 | |
d62a17ae | 1444 | for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { |
1445 | if (circuit->state != C_STATE_INIT | |
1446 | && circuit->state != C_STATE_UP) | |
1447 | continue; | |
1448 | if (lsp_mtu > isis_circuit_pdu_size(circuit)) { | |
1449 | vty_out(vty, | |
1450 | "ISIS area contains circuit %s, which has a maximum PDU size of %zu.\n", | |
1451 | circuit->interface->name, | |
1452 | isis_circuit_pdu_size(circuit)); | |
a5fdb4c5 | 1453 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1454 | } |
1455 | } | |
6754fc66 | 1456 | |
d62a17ae | 1457 | isis_area_lsp_mtu_set(area, lsp_mtu); |
1458 | return CMD_SUCCESS; | |
6754fc66 CF |
1459 | } |
1460 | ||
1461 | DEFUN (area_lsp_mtu, | |
1462 | area_lsp_mtu_cmd, | |
6147e2c6 | 1463 | "lsp-mtu (128-4352)", |
6754fc66 CF |
1464 | "Configure the maximum size of generated LSPs\n" |
1465 | "Maximum size of generated LSPs\n") | |
1466 | { | |
d62a17ae | 1467 | int idx_number = 1; |
1468 | unsigned int lsp_mtu; | |
6754fc66 | 1469 | |
d62a17ae | 1470 | lsp_mtu = strtoul(argv[idx_number]->arg, NULL, 10); |
6754fc66 | 1471 | |
d62a17ae | 1472 | return area_lsp_mtu_set(vty, lsp_mtu); |
6754fc66 CF |
1473 | } |
1474 | ||
b44c509a | 1475 | |
49d41a26 DS |
1476 | DEFUN (no_area_lsp_mtu, |
1477 | no_area_lsp_mtu_cmd, | |
b44c509a | 1478 | "no lsp-mtu [(128-4352)]", |
49d41a26 | 1479 | NO_STR |
b44c509a DW |
1480 | "Configure the maximum size of generated LSPs\n" |
1481 | "Maximum size of generated LSPs\n") | |
6754fc66 | 1482 | { |
d62a17ae | 1483 | return area_lsp_mtu_set(vty, DEFAULT_LSP_MTU); |
6754fc66 CF |
1484 | } |
1485 | ||
6754fc66 CF |
1486 | |
1487 | DEFUN (is_type, | |
1488 | is_type_cmd, | |
6147e2c6 | 1489 | "is-type <level-1|level-1-2|level-2-only>", |
6754fc66 CF |
1490 | "IS Level for this routing process (OSI only)\n" |
1491 | "Act as a station router only\n" | |
1492 | "Act as both a station router and an area router\n" | |
1493 | "Act as an area router only\n") | |
1494 | { | |
d62a17ae | 1495 | int idx_level = 1; |
1496 | VTY_DECLVAR_CONTEXT(isis_area, area); | |
1497 | int type; | |
6754fc66 | 1498 | |
d62a17ae | 1499 | type = string2circuit_t(argv[idx_level]->arg); |
1500 | if (!type) { | |
1501 | vty_out(vty, "Unknown IS level \n"); | |
1502 | return CMD_SUCCESS; | |
1503 | } | |
6754fc66 | 1504 | |
d62a17ae | 1505 | isis_area_is_type_set(area, type); |
6754fc66 | 1506 | |
d62a17ae | 1507 | return CMD_SUCCESS; |
6754fc66 CF |
1508 | } |
1509 | ||
1510 | DEFUN (no_is_type, | |
1511 | no_is_type_cmd, | |
6147e2c6 | 1512 | "no is-type <level-1|level-1-2|level-2-only>", |
6754fc66 CF |
1513 | NO_STR |
1514 | "IS Level for this routing process (OSI only)\n" | |
1515 | "Act as a station router only\n" | |
1516 | "Act as both a station router and an area router\n" | |
1517 | "Act as an area router only\n") | |
1518 | { | |
d62a17ae | 1519 | VTY_DECLVAR_CONTEXT(isis_area, area); |
1520 | int type; | |
6754fc66 | 1521 | |
d62a17ae | 1522 | /* |
1523 | * Put the is-type back to defaults: | |
1524 | * - level-1-2 on first area | |
1525 | * - level-1 for the rest | |
1526 | */ | |
1527 | if (listgetdata(listhead(isis->area_list)) == area) | |
1528 | type = IS_LEVEL_1_AND_2; | |
1529 | else | |
1530 | type = IS_LEVEL_1; | |
6754fc66 | 1531 | |
d62a17ae | 1532 | isis_area_is_type_set(area, type); |
6754fc66 | 1533 | |
d62a17ae | 1534 | return CMD_SUCCESS; |
6754fc66 CF |
1535 | } |
1536 | ||
d62a17ae | 1537 | static int set_lsp_gen_interval(struct vty *vty, struct isis_area *area, |
1538 | uint16_t interval, int level) | |
466ed406 | 1539 | { |
d62a17ae | 1540 | int lvl; |
466ed406 | 1541 | |
d62a17ae | 1542 | for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl) { |
1543 | if (!(lvl & level)) | |
1544 | continue; | |
466ed406 | 1545 | |
d62a17ae | 1546 | if (interval >= area->lsp_refresh[lvl - 1]) { |
1547 | vty_out(vty, | |
1548 | "LSP gen interval %us must be less than " | |
1549 | "the LSP refresh interval %us\n", | |
1550 | interval, area->lsp_refresh[lvl - 1]); | |
a5fdb4c5 | 1551 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1552 | } |
1553 | } | |
466ed406 | 1554 | |
d62a17ae | 1555 | for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl) { |
1556 | if (!(lvl & level)) | |
1557 | continue; | |
1558 | area->lsp_gen_interval[lvl - 1] = interval; | |
1559 | } | |
466ed406 | 1560 | |
d62a17ae | 1561 | return CMD_SUCCESS; |
466ed406 CF |
1562 | } |
1563 | ||
1564 | DEFUN (lsp_gen_interval, | |
1565 | lsp_gen_interval_cmd, | |
3a2d747c | 1566 | "lsp-gen-interval [<level-1|level-2>] (1-120)", |
466ed406 | 1567 | "Minimum interval between regenerating same LSP\n" |
3a2d747c QY |
1568 | "Set interval for level 1 only\n" |
1569 | "Set interval for level 2 only\n" | |
466ed406 CF |
1570 | "Minimum interval in seconds\n") |
1571 | { | |
d62a17ae | 1572 | int idx = 0; |
1573 | VTY_DECLVAR_CONTEXT(isis_area, area); | |
1574 | uint16_t interval; | |
1575 | int level; | |
466ed406 | 1576 | |
d62a17ae | 1577 | level = 0; |
1578 | level |= argv_find(argv, argc, "level-1", &idx) ? IS_LEVEL_1 : 0; | |
1579 | level |= argv_find(argv, argc, "level-2", &idx) ? IS_LEVEL_2 : 0; | |
1580 | if (!level) | |
1581 | level = IS_LEVEL_1 | IS_LEVEL_2; | |
3a2d747c | 1582 | |
d62a17ae | 1583 | argv_find(argv, argc, "(1-120)", &idx); |
3a2d747c | 1584 | |
d62a17ae | 1585 | interval = atoi(argv[idx]->arg); |
1586 | return set_lsp_gen_interval(vty, area, interval, level); | |
466ed406 CF |
1587 | } |
1588 | ||
1589 | DEFUN (no_lsp_gen_interval, | |
1590 | no_lsp_gen_interval_cmd, | |
3a2d747c | 1591 | "no lsp-gen-interval [<level-1|level-2>] [(1-120)]", |
466ed406 | 1592 | NO_STR |
b44c509a | 1593 | "Minimum interval between regenerating same LSP\n" |
466ed406 | 1594 | "Set interval for level 1 only\n" |
466ed406 CF |
1595 | "Set interval for level 2 only\n" |
1596 | "Minimum interval in seconds\n") | |
1597 | { | |
d62a17ae | 1598 | int idx = 0; |
1599 | VTY_DECLVAR_CONTEXT(isis_area, area); | |
1600 | uint16_t interval; | |
1601 | int level; | |
466ed406 | 1602 | |
d62a17ae | 1603 | level = 0; |
1604 | level |= argv_find(argv, argc, "level-1", &idx) ? IS_LEVEL_1 : 0; | |
1605 | level |= argv_find(argv, argc, "level-2", &idx) ? IS_LEVEL_2 : 0; | |
1606 | if (!level) | |
1607 | level = IS_LEVEL_1 | IS_LEVEL_2; | |
466ed406 | 1608 | |
d62a17ae | 1609 | interval = DEFAULT_MIN_LSP_GEN_INTERVAL; |
1610 | return set_lsp_gen_interval(vty, area, interval, level); | |
466ed406 CF |
1611 | } |
1612 | ||
466ed406 CF |
1613 | DEFUN (spf_interval, |
1614 | spf_interval_cmd, | |
6147e2c6 | 1615 | "spf-interval (1-120)", |
466ed406 CF |
1616 | "Minimum interval between SPF calculations\n" |
1617 | "Minimum interval between consecutive SPFs in seconds\n") | |
1618 | { | |
d62a17ae | 1619 | int idx_number = 1; |
1620 | VTY_DECLVAR_CONTEXT(isis_area, area); | |
d7c0a89a | 1621 | uint16_t interval; |
466ed406 | 1622 | |
d62a17ae | 1623 | interval = atoi(argv[idx_number]->arg); |
1624 | area->min_spf_interval[0] = interval; | |
1625 | area->min_spf_interval[1] = interval; | |
466ed406 | 1626 | |
d62a17ae | 1627 | return CMD_SUCCESS; |
466ed406 CF |
1628 | } |
1629 | ||
b44c509a | 1630 | |
466ed406 CF |
1631 | DEFUN (no_spf_interval, |
1632 | no_spf_interval_cmd, | |
b44c509a | 1633 | "no spf-interval [[<level-1|level-2>] (1-120)]", |
466ed406 | 1634 | NO_STR |
b44c509a DW |
1635 | "Minimum interval between SPF calculations\n" |
1636 | "Set interval for level 1 only\n" | |
1637 | "Set interval for level 2 only\n" | |
1638 | "Minimum interval between consecutive SPFs in seconds\n") | |
466ed406 | 1639 | { |
d62a17ae | 1640 | VTY_DECLVAR_CONTEXT(isis_area, area); |
466ed406 | 1641 | |
d62a17ae | 1642 | area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL; |
1643 | area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL; | |
466ed406 | 1644 | |
d62a17ae | 1645 | return CMD_SUCCESS; |
466ed406 CF |
1646 | } |
1647 | ||
466ed406 CF |
1648 | |
1649 | DEFUN (spf_interval_l1, | |
1650 | spf_interval_l1_cmd, | |
6147e2c6 | 1651 | "spf-interval level-1 (1-120)", |
466ed406 CF |
1652 | "Minimum interval between SPF calculations\n" |
1653 | "Set interval for level 1 only\n" | |
1654 | "Minimum interval between consecutive SPFs in seconds\n") | |
1655 | { | |
d62a17ae | 1656 | int idx_number = 2; |
1657 | VTY_DECLVAR_CONTEXT(isis_area, area); | |
d7c0a89a | 1658 | uint16_t interval; |
466ed406 | 1659 | |
d62a17ae | 1660 | interval = atoi(argv[idx_number]->arg); |
1661 | area->min_spf_interval[0] = interval; | |
466ed406 | 1662 | |
d62a17ae | 1663 | return CMD_SUCCESS; |
466ed406 CF |
1664 | } |
1665 | ||
1666 | DEFUN (no_spf_interval_l1, | |
1667 | no_spf_interval_l1_cmd, | |
1668 | "no spf-interval level-1", | |
1669 | NO_STR | |
1670 | "Minimum interval between SPF calculations\n" | |
1671 | "Set interval for level 1 only\n") | |
1672 | { | |
d62a17ae | 1673 | VTY_DECLVAR_CONTEXT(isis_area, area); |
466ed406 | 1674 | |
d62a17ae | 1675 | area->min_spf_interval[0] = MINIMUM_SPF_INTERVAL; |
466ed406 | 1676 | |
d62a17ae | 1677 | return CMD_SUCCESS; |
466ed406 CF |
1678 | } |
1679 | ||
466ed406 CF |
1680 | |
1681 | DEFUN (spf_interval_l2, | |
1682 | spf_interval_l2_cmd, | |
6147e2c6 | 1683 | "spf-interval level-2 (1-120)", |
466ed406 CF |
1684 | "Minimum interval between SPF calculations\n" |
1685 | "Set interval for level 2 only\n" | |
1686 | "Minimum interval between consecutive SPFs in seconds\n") | |
1687 | { | |
d62a17ae | 1688 | int idx_number = 2; |
1689 | VTY_DECLVAR_CONTEXT(isis_area, area); | |
d7c0a89a | 1690 | uint16_t interval; |
466ed406 | 1691 | |
d62a17ae | 1692 | interval = atoi(argv[idx_number]->arg); |
1693 | area->min_spf_interval[1] = interval; | |
466ed406 | 1694 | |
d62a17ae | 1695 | return CMD_SUCCESS; |
466ed406 CF |
1696 | } |
1697 | ||
1698 | DEFUN (no_spf_interval_l2, | |
1699 | no_spf_interval_l2_cmd, | |
1700 | "no spf-interval level-2", | |
1701 | NO_STR | |
1702 | "Minimum interval between SPF calculations\n" | |
1703 | "Set interval for level 2 only\n") | |
1704 | { | |
d62a17ae | 1705 | VTY_DECLVAR_CONTEXT(isis_area, area); |
466ed406 | 1706 | |
d62a17ae | 1707 | area->min_spf_interval[1] = MINIMUM_SPF_INTERVAL; |
466ed406 | 1708 | |
d62a17ae | 1709 | return CMD_SUCCESS; |
466ed406 CF |
1710 | } |
1711 | ||
03f7e182 SL |
1712 | DEFUN (no_spf_delay_ietf, |
1713 | no_spf_delay_ietf_cmd, | |
1714 | "no spf-delay-ietf", | |
1715 | NO_STR | |
1716 | "IETF SPF delay algorithm\n") | |
1717 | { | |
d62a17ae | 1718 | VTY_DECLVAR_CONTEXT(isis_area, area); |
03f7e182 | 1719 | |
d62a17ae | 1720 | spf_backoff_free(area->spf_delay_ietf[0]); |
1721 | spf_backoff_free(area->spf_delay_ietf[1]); | |
1722 | area->spf_delay_ietf[0] = NULL; | |
1723 | area->spf_delay_ietf[1] = NULL; | |
03f7e182 | 1724 | |
d62a17ae | 1725 | return CMD_SUCCESS; |
03f7e182 SL |
1726 | } |
1727 | ||
1728 | DEFUN (spf_delay_ietf, | |
1729 | spf_delay_ietf_cmd, | |
1730 | "spf-delay-ietf init-delay (0-60000) short-delay (0-60000) long-delay (0-60000) holddown (0-60000) time-to-learn (0-60000)", | |
1731 | "IETF SPF delay algorithm\n" | |
1732 | "Delay used while in QUIET state\n" | |
1733 | "Delay used while in QUIET state in milliseconds\n" | |
1734 | "Delay used while in SHORT_WAIT state\n" | |
1735 | "Delay used while in SHORT_WAIT state in milliseconds\n" | |
1736 | "Delay used while in LONG_WAIT\n" | |
1737 | "Delay used while in LONG_WAIT state in milliseconds\n" | |
1738 | "Time with no received IGP events before considering IGP stable\n" | |
1739 | "Time with no received IGP events before considering IGP stable (in milliseconds)\n" | |
1740 | "Maximum duration needed to learn all the events related to a single failure\n" | |
1741 | "Maximum duration needed to learn all the events related to a single failure (in milliseconds)\n") | |
1742 | { | |
d62a17ae | 1743 | VTY_DECLVAR_CONTEXT(isis_area, area); |
1744 | ||
1745 | long init_delay = atol(argv[2]->arg); | |
1746 | long short_delay = atol(argv[4]->arg); | |
1747 | long long_delay = atol(argv[6]->arg); | |
1748 | long holddown = atol(argv[8]->arg); | |
1749 | long timetolearn = atol(argv[10]->arg); | |
1750 | ||
1751 | size_t bufsiz = strlen(area->area_tag) + sizeof("IS-IS Lx"); | |
1752 | char *buf = XCALLOC(MTYPE_TMP, bufsiz); | |
1753 | ||
1754 | snprintf(buf, bufsiz, "IS-IS %s L1", area->area_tag); | |
1755 | spf_backoff_free(area->spf_delay_ietf[0]); | |
1756 | area->spf_delay_ietf[0] = | |
1757 | spf_backoff_new(master, buf, init_delay, short_delay, | |
1758 | long_delay, holddown, timetolearn); | |
1759 | ||
1760 | snprintf(buf, bufsiz, "IS-IS %s L2", area->area_tag); | |
1761 | spf_backoff_free(area->spf_delay_ietf[1]); | |
1762 | area->spf_delay_ietf[1] = | |
1763 | spf_backoff_new(master, buf, init_delay, short_delay, | |
1764 | long_delay, holddown, timetolearn); | |
1765 | ||
1766 | XFREE(MTYPE_TMP, buf); | |
1767 | return CMD_SUCCESS; | |
1768 | } | |
1769 | ||
1770 | static int area_max_lsp_lifetime_set(struct vty *vty, int level, | |
1771 | uint16_t interval) | |
1772 | { | |
1773 | VTY_DECLVAR_CONTEXT(isis_area, area); | |
1774 | int lvl; | |
1775 | uint16_t refresh_interval = interval - 300; | |
1776 | int set_refresh_interval[ISIS_LEVELS] = {0, 0}; | |
1777 | ||
1778 | for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++) { | |
1779 | if (!(lvl & level)) | |
1780 | continue; | |
1781 | ||
1782 | if (refresh_interval < area->lsp_refresh[lvl - 1]) { | |
1783 | vty_out(vty, | |
1784 | "Level %d Max LSP lifetime %us must be 300s greater than " | |
1785 | "the configured LSP refresh interval %us\n", | |
1786 | lvl, interval, area->lsp_refresh[lvl - 1]); | |
1787 | vty_out(vty, | |
1788 | "Automatically reducing level %d LSP refresh interval " | |
1789 | "to %us\n", | |
1790 | lvl, refresh_interval); | |
1791 | set_refresh_interval[lvl - 1] = 1; | |
1792 | ||
1793 | if (refresh_interval | |
1794 | <= area->lsp_gen_interval[lvl - 1]) { | |
1795 | vty_out(vty, | |
1796 | "LSP refresh interval %us must be greater than " | |
1797 | "the configured LSP gen interval %us\n", | |
1798 | refresh_interval, | |
1799 | area->lsp_gen_interval[lvl - 1]); | |
a5fdb4c5 | 1800 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1801 | } |
1802 | } | |
1803 | } | |
1804 | ||
1805 | for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; lvl++) { | |
1806 | if (!(lvl & level)) | |
1807 | continue; | |
1808 | isis_area_max_lsp_lifetime_set(area, lvl, interval); | |
1809 | if (set_refresh_interval[lvl - 1]) | |
1810 | isis_area_lsp_refresh_set(area, lvl, refresh_interval); | |
1811 | } | |
1812 | ||
1813 | return CMD_SUCCESS; | |
466ed406 CF |
1814 | } |
1815 | ||
1816 | DEFUN (max_lsp_lifetime, | |
1817 | max_lsp_lifetime_cmd, | |
16cedbb0 | 1818 | "max-lsp-lifetime [<level-1|level-2>] (350-65535)", |
3a2d747c | 1819 | "Maximum LSP lifetime\n" |
16cedbb0 QY |
1820 | "Maximum LSP lifetime for Level 1 only\n" |
1821 | "Maximum LSP lifetime for Level 2 only\n" | |
466ed406 CF |
1822 | "LSP lifetime in seconds\n") |
1823 | { | |
d62a17ae | 1824 | int idx = 0; |
1825 | unsigned int level = IS_LEVEL_1_AND_2; | |
466ed406 | 1826 | |
d62a17ae | 1827 | if (argv_find(argv, argc, "level-1", &idx)) |
1828 | level = IS_LEVEL_1; | |
1829 | else if (argv_find(argv, argc, "level-2", &idx)) | |
1830 | level = IS_LEVEL_2; | |
b44c509a | 1831 | |
d62a17ae | 1832 | argv_find(argv, argc, "(350-65535)", &idx); |
1833 | int lifetime = atoi(argv[idx]->arg); | |
466ed406 | 1834 | |
d62a17ae | 1835 | return area_max_lsp_lifetime_set(vty, level, lifetime); |
466ed406 CF |
1836 | } |
1837 | ||
b44c509a | 1838 | |
16cedbb0 QY |
1839 | DEFUN (no_max_lsp_lifetime, |
1840 | no_max_lsp_lifetime_cmd, | |
1841 | "no max-lsp-lifetime [<level-1|level-2>] [(350-65535)]", | |
466ed406 | 1842 | NO_STR |
3a2d747c | 1843 | "Maximum LSP lifetime\n" |
16cedbb0 | 1844 | "Maximum LSP lifetime for Level 1 only\n" |
466ed406 | 1845 | "Maximum LSP lifetime for Level 2 only\n" |
16cedbb0 | 1846 | "LSP lifetime in seconds\n") |
466ed406 | 1847 | { |
d62a17ae | 1848 | int idx = 0; |
1849 | unsigned int level = IS_LEVEL_1_AND_2; | |
1850 | ||
1851 | if (argv_find(argv, argc, "level-1", &idx)) | |
1852 | level = IS_LEVEL_1; | |
1853 | else if (argv_find(argv, argc, "level-2", &idx)) | |
1854 | level = IS_LEVEL_2; | |
1855 | ||
1856 | return area_max_lsp_lifetime_set(vty, level, DEFAULT_LSP_LIFETIME); | |
1857 | } | |
1858 | ||
1859 | static int area_lsp_refresh_interval_set(struct vty *vty, int level, | |
1860 | uint16_t interval) | |
1861 | { | |
1862 | VTY_DECLVAR_CONTEXT(isis_area, area); | |
1863 | int lvl; | |
1864 | ||
1865 | for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl) { | |
1866 | if (!(lvl & level)) | |
1867 | continue; | |
1868 | if (interval <= area->lsp_gen_interval[lvl - 1]) { | |
1869 | vty_out(vty, | |
1870 | "LSP refresh interval %us must be greater than " | |
1871 | "the configured LSP gen interval %us\n", | |
1872 | interval, area->lsp_gen_interval[lvl - 1]); | |
a5fdb4c5 | 1873 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1874 | } |
1875 | if (interval > (area->max_lsp_lifetime[lvl - 1] - 300)) { | |
1876 | vty_out(vty, | |
1877 | "LSP refresh interval %us must be less than " | |
1878 | "the configured LSP lifetime %us less 300\n", | |
1879 | interval, area->max_lsp_lifetime[lvl - 1]); | |
a5fdb4c5 | 1880 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1881 | } |
1882 | } | |
1883 | ||
1884 | for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl) { | |
1885 | if (!(lvl & level)) | |
1886 | continue; | |
1887 | isis_area_lsp_refresh_set(area, lvl, interval); | |
1888 | } | |
1889 | ||
1890 | return CMD_SUCCESS; | |
466ed406 CF |
1891 | } |
1892 | ||
1893 | DEFUN (lsp_refresh_interval, | |
1894 | lsp_refresh_interval_cmd, | |
16cedbb0 | 1895 | "lsp-refresh-interval [<level-1|level-2>] (1-65235)", |
466ed406 | 1896 | "LSP refresh interval\n" |
16cedbb0 QY |
1897 | "LSP refresh interval for Level 1 only\n" |
1898 | "LSP refresh interval for Level 2 only\n" | |
466ed406 CF |
1899 | "LSP refresh interval in seconds\n") |
1900 | { | |
d62a17ae | 1901 | int idx = 0; |
1902 | unsigned int level = IS_LEVEL_1_AND_2; | |
1903 | unsigned int interval = 0; | |
466ed406 | 1904 | |
d62a17ae | 1905 | if (argv_find(argv, argc, "level-1", &idx)) |
1906 | level = IS_LEVEL_1; | |
1907 | else if (argv_find(argv, argc, "level-2", &idx)) | |
1908 | level = IS_LEVEL_2; | |
16cedbb0 | 1909 | |
d62a17ae | 1910 | interval = atoi(argv[argc - 1]->arg); |
1911 | return area_lsp_refresh_interval_set(vty, level, interval); | |
16cedbb0 | 1912 | } |
b44c509a | 1913 | |
466ed406 CF |
1914 | DEFUN (no_lsp_refresh_interval, |
1915 | no_lsp_refresh_interval_cmd, | |
16cedbb0 | 1916 | "no lsp-refresh-interval [<level-1|level-2>] [(1-65235)]", |
466ed406 | 1917 | NO_STR |
b44c509a | 1918 | "LSP refresh interval\n" |
b44c509a | 1919 | "LSP refresh interval for Level 1 only\n" |
466ed406 | 1920 | "LSP refresh interval for Level 2 only\n" |
16cedbb0 | 1921 | "LSP refresh interval in seconds\n") |
466ed406 | 1922 | { |
d62a17ae | 1923 | int idx = 0; |
1924 | unsigned int level = IS_LEVEL_1_AND_2; | |
466ed406 | 1925 | |
d62a17ae | 1926 | if (argv_find(argv, argc, "level-1", &idx)) |
1927 | level = IS_LEVEL_1; | |
1928 | else if (argv_find(argv, argc, "level-2", &idx)) | |
1929 | level = IS_LEVEL_2; | |
b44c509a | 1930 | |
d62a17ae | 1931 | return area_lsp_refresh_interval_set(vty, level, |
1932 | DEFAULT_MAX_LSP_GEN_INTERVAL); | |
466ed406 CF |
1933 | } |
1934 | ||
d62a17ae | 1935 | static int area_passwd_set(struct vty *vty, int level, |
1936 | int (*type_set)(struct isis_area *area, int level, | |
d7c0a89a QY |
1937 | const char *passwd, |
1938 | uint8_t snp_auth), | |
1939 | const char *passwd, uint8_t snp_auth) | |
9093b230 | 1940 | { |
d62a17ae | 1941 | VTY_DECLVAR_CONTEXT(isis_area, area); |
9093b230 | 1942 | |
d62a17ae | 1943 | if (passwd && strlen(passwd) > 254) { |
1944 | vty_out(vty, "Too long area password (>254)\n"); | |
a5fdb4c5 | 1945 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 1946 | } |
9093b230 | 1947 | |
d62a17ae | 1948 | type_set(area, level, passwd, snp_auth); |
1949 | return CMD_SUCCESS; | |
9093b230 CF |
1950 | } |
1951 | ||
b44c509a | 1952 | |
9093b230 CF |
1953 | DEFUN (area_passwd_md5, |
1954 | area_passwd_md5_cmd, | |
d8bd2aff | 1955 | "area-password md5 WORD [authenticate snp <send-only|validate>]", |
9093b230 | 1956 | "Configure the authentication password for an area\n" |
9093b230 | 1957 | "Authentication type\n" |
b44c509a DW |
1958 | "Level-wide password\n" |
1959 | "Authentication\n" | |
1960 | "SNP PDUs\n" | |
1961 | "Send but do not check PDUs on receiving\n" | |
1962 | "Send and check PDUs on receiving\n") | |
9093b230 | 1963 | { |
d62a17ae | 1964 | int idx_password = 0; |
1965 | int idx_word = 2; | |
1966 | int idx_type = 5; | |
d7c0a89a | 1967 | uint8_t snp_auth = 0; |
d62a17ae | 1968 | int level = strmatch(argv[idx_password]->text, "domain-password") |
1969 | ? IS_LEVEL_2 | |
1970 | : IS_LEVEL_1; | |
9093b230 | 1971 | |
d62a17ae | 1972 | if (argc > 3) { |
1973 | snp_auth = SNP_AUTH_SEND; | |
1974 | if (strmatch(argv[idx_type]->text, "validate")) | |
1975 | snp_auth |= SNP_AUTH_RECV; | |
1976 | } | |
9093b230 | 1977 | |
d62a17ae | 1978 | return area_passwd_set(vty, level, isis_area_passwd_hmac_md5_set, |
1979 | argv[idx_word]->arg, snp_auth); | |
9093b230 CF |
1980 | } |
1981 | ||
d8bd2aff QY |
1982 | DEFUN (domain_passwd_md5, |
1983 | domain_passwd_md5_cmd, | |
1984 | "domain-password md5 WORD [authenticate snp <send-only|validate>]", | |
1985 | "Set the authentication password for a routing domain\n" | |
1986 | "Authentication type\n" | |
1987 | "Level-wide password\n" | |
1988 | "Authentication\n" | |
1989 | "SNP PDUs\n" | |
1990 | "Send but do not check PDUs on receiving\n" | |
1991 | "Send and check PDUs on receiving\n") | |
1992 | { | |
d62a17ae | 1993 | return area_passwd_md5(self, vty, argc, argv); |
d8bd2aff | 1994 | } |
9093b230 CF |
1995 | |
1996 | DEFUN (area_passwd_clear, | |
1997 | area_passwd_clear_cmd, | |
d8bd2aff | 1998 | "area-password clear WORD [authenticate snp <send-only|validate>]", |
9093b230 | 1999 | "Configure the authentication password for an area\n" |
9093b230 | 2000 | "Authentication type\n" |
b44c509a DW |
2001 | "Area password\n" |
2002 | "Authentication\n" | |
2003 | "SNP PDUs\n" | |
2004 | "Send but do not check PDUs on receiving\n" | |
2005 | "Send and check PDUs on receiving\n") | |
9093b230 | 2006 | { |
d62a17ae | 2007 | int idx_password = 0; |
2008 | int idx_word = 2; | |
2009 | int idx_type = 5; | |
d7c0a89a | 2010 | uint8_t snp_auth = 0; |
d62a17ae | 2011 | int level = strmatch(argv[idx_password]->text, "domain-password") |
2012 | ? IS_LEVEL_2 | |
2013 | : IS_LEVEL_1; | |
9093b230 | 2014 | |
d62a17ae | 2015 | if (argc > 3) { |
2016 | snp_auth = SNP_AUTH_SEND; | |
2017 | if (strmatch(argv[idx_type]->text, "validate")) | |
2018 | snp_auth |= SNP_AUTH_RECV; | |
2019 | } | |
9093b230 | 2020 | |
d62a17ae | 2021 | return area_passwd_set(vty, level, isis_area_passwd_cleartext_set, |
2022 | argv[idx_word]->arg, snp_auth); | |
9093b230 CF |
2023 | } |
2024 | ||
d8bd2aff QY |
2025 | DEFUN (domain_passwd_clear, |
2026 | domain_passwd_clear_cmd, | |
2027 | "domain-password clear WORD [authenticate snp <send-only|validate>]", | |
2028 | "Set the authentication password for a routing domain\n" | |
2029 | "Authentication type\n" | |
2030 | "Area password\n" | |
2031 | "Authentication\n" | |
2032 | "SNP PDUs\n" | |
2033 | "Send but do not check PDUs on receiving\n" | |
2034 | "Send and check PDUs on receiving\n") | |
2035 | { | |
d62a17ae | 2036 | return area_passwd_clear(self, vty, argc, argv); |
d8bd2aff | 2037 | } |
9093b230 CF |
2038 | |
2039 | DEFUN (no_area_passwd, | |
2040 | no_area_passwd_cmd, | |
6147e2c6 | 2041 | "no <area-password|domain-password>", |
9093b230 CF |
2042 | NO_STR |
2043 | "Configure the authentication password for an area\n" | |
2044 | "Set the authentication password for a routing domain\n") | |
2045 | { | |
d62a17ae | 2046 | int idx_password = 1; |
2047 | int level = strmatch(argv[idx_password]->text, "domain-password") | |
2048 | ? IS_LEVEL_2 | |
2049 | : IS_LEVEL_1; | |
2050 | VTY_DECLVAR_CONTEXT(isis_area, area); | |
9093b230 | 2051 | |
d62a17ae | 2052 | return isis_area_passwd_unset(area, level); |
9093b230 CF |
2053 | } |
2054 | ||
d62a17ae | 2055 | void isis_vty_init(void) |
65f9a9a8 | 2056 | { |
d62a17ae | 2057 | install_element(INTERFACE_NODE, &ip_router_isis_cmd); |
2058 | install_element(INTERFACE_NODE, &ip6_router_isis_cmd); | |
2059 | install_element(INTERFACE_NODE, &no_ip_router_isis_cmd); | |
65f9a9a8 | 2060 | |
d62a17ae | 2061 | install_element(INTERFACE_NODE, &isis_passive_cmd); |
2062 | install_element(INTERFACE_NODE, &no_isis_passive_cmd); | |
65f9a9a8 | 2063 | |
d62a17ae | 2064 | install_element(INTERFACE_NODE, &isis_circuit_type_cmd); |
2065 | install_element(INTERFACE_NODE, &no_isis_circuit_type_cmd); | |
65f9a9a8 | 2066 | |
d62a17ae | 2067 | install_element(INTERFACE_NODE, &isis_network_cmd); |
2068 | install_element(INTERFACE_NODE, &no_isis_network_cmd); | |
50c7d14a | 2069 | |
d62a17ae | 2070 | install_element(INTERFACE_NODE, &isis_passwd_cmd); |
2071 | install_element(INTERFACE_NODE, &no_isis_passwd_cmd); | |
65f9a9a8 | 2072 | |
d62a17ae | 2073 | install_element(INTERFACE_NODE, &isis_priority_cmd); |
2074 | install_element(INTERFACE_NODE, &no_isis_priority_cmd); | |
2075 | install_element(INTERFACE_NODE, &isis_priority_l1_cmd); | |
2076 | install_element(INTERFACE_NODE, &no_isis_priority_l1_cmd); | |
2077 | install_element(INTERFACE_NODE, &isis_priority_l2_cmd); | |
2078 | install_element(INTERFACE_NODE, &no_isis_priority_l2_cmd); | |
a38a72db | 2079 | |
d62a17ae | 2080 | install_element(INTERFACE_NODE, &isis_metric_cmd); |
2081 | install_element(INTERFACE_NODE, &no_isis_metric_cmd); | |
2082 | install_element(INTERFACE_NODE, &isis_metric_l1_cmd); | |
2083 | install_element(INTERFACE_NODE, &no_isis_metric_l1_cmd); | |
2084 | install_element(INTERFACE_NODE, &isis_metric_l2_cmd); | |
2085 | install_element(INTERFACE_NODE, &no_isis_metric_l2_cmd); | |
01bb08b6 | 2086 | |
d62a17ae | 2087 | install_element(INTERFACE_NODE, &isis_hello_interval_cmd); |
2088 | install_element(INTERFACE_NODE, &no_isis_hello_interval_cmd); | |
2089 | install_element(INTERFACE_NODE, &isis_hello_interval_l1_cmd); | |
2090 | install_element(INTERFACE_NODE, &no_isis_hello_interval_l1_cmd); | |
2091 | install_element(INTERFACE_NODE, &isis_hello_interval_l2_cmd); | |
2092 | install_element(INTERFACE_NODE, &no_isis_hello_interval_l2_cmd); | |
01bb08b6 | 2093 | |
d62a17ae | 2094 | install_element(INTERFACE_NODE, &isis_hello_multiplier_cmd); |
2095 | install_element(INTERFACE_NODE, &no_isis_hello_multiplier_cmd); | |
2096 | install_element(INTERFACE_NODE, &isis_hello_multiplier_l1_cmd); | |
2097 | install_element(INTERFACE_NODE, &no_isis_hello_multiplier_l1_cmd); | |
2098 | install_element(INTERFACE_NODE, &isis_hello_multiplier_l2_cmd); | |
2099 | install_element(INTERFACE_NODE, &no_isis_hello_multiplier_l2_cmd); | |
01bb08b6 | 2100 | |
d62a17ae | 2101 | install_element(INTERFACE_NODE, &isis_hello_padding_cmd); |
2102 | install_element(INTERFACE_NODE, &no_isis_hello_padding_cmd); | |
01bb08b6 | 2103 | |
58e5d748 CF |
2104 | install_element(INTERFACE_NODE, &isis_threeway_adj_cmd); |
2105 | ||
d62a17ae | 2106 | install_element(INTERFACE_NODE, &csnp_interval_cmd); |
2107 | install_element(INTERFACE_NODE, &no_csnp_interval_cmd); | |
2108 | install_element(INTERFACE_NODE, &csnp_interval_l1_cmd); | |
2109 | install_element(INTERFACE_NODE, &no_csnp_interval_l1_cmd); | |
2110 | install_element(INTERFACE_NODE, &csnp_interval_l2_cmd); | |
2111 | install_element(INTERFACE_NODE, &no_csnp_interval_l2_cmd); | |
01bb08b6 | 2112 | |
d62a17ae | 2113 | install_element(INTERFACE_NODE, &psnp_interval_cmd); |
2114 | install_element(INTERFACE_NODE, &no_psnp_interval_cmd); | |
2115 | install_element(INTERFACE_NODE, &psnp_interval_l1_cmd); | |
2116 | install_element(INTERFACE_NODE, &no_psnp_interval_l1_cmd); | |
2117 | install_element(INTERFACE_NODE, &psnp_interval_l2_cmd); | |
2118 | install_element(INTERFACE_NODE, &no_psnp_interval_l2_cmd); | |
064f4896 | 2119 | |
d62a17ae | 2120 | install_element(INTERFACE_NODE, &circuit_topology_cmd); |
2121 | install_element(INTERFACE_NODE, &no_circuit_topology_cmd); | |
a38a72db | 2122 | |
d62a17ae | 2123 | install_element(ISIS_NODE, &metric_style_cmd); |
2124 | install_element(ISIS_NODE, &no_metric_style_cmd); | |
a38a72db | 2125 | |
d62a17ae | 2126 | install_element(ISIS_NODE, &set_overload_bit_cmd); |
2127 | install_element(ISIS_NODE, &no_set_overload_bit_cmd); | |
a38a72db | 2128 | |
d62a17ae | 2129 | install_element(ISIS_NODE, &set_attached_bit_cmd); |
2130 | install_element(ISIS_NODE, &no_set_attached_bit_cmd); | |
6754fc66 | 2131 | |
d62a17ae | 2132 | install_element(ISIS_NODE, &dynamic_hostname_cmd); |
2133 | install_element(ISIS_NODE, &no_dynamic_hostname_cmd); | |
6754fc66 | 2134 | |
d62a17ae | 2135 | install_element(ISIS_NODE, &area_lsp_mtu_cmd); |
2136 | install_element(ISIS_NODE, &no_area_lsp_mtu_cmd); | |
466ed406 | 2137 | |
d62a17ae | 2138 | install_element(ISIS_NODE, &is_type_cmd); |
2139 | install_element(ISIS_NODE, &no_is_type_cmd); | |
466ed406 | 2140 | |
d62a17ae | 2141 | install_element(ISIS_NODE, &lsp_gen_interval_cmd); |
2142 | install_element(ISIS_NODE, &no_lsp_gen_interval_cmd); | |
466ed406 | 2143 | |
d62a17ae | 2144 | install_element(ISIS_NODE, &spf_interval_cmd); |
2145 | install_element(ISIS_NODE, &no_spf_interval_cmd); | |
2146 | install_element(ISIS_NODE, &spf_interval_l1_cmd); | |
2147 | install_element(ISIS_NODE, &no_spf_interval_l1_cmd); | |
2148 | install_element(ISIS_NODE, &spf_interval_l2_cmd); | |
2149 | install_element(ISIS_NODE, &no_spf_interval_l2_cmd); | |
466ed406 | 2150 | |
d62a17ae | 2151 | install_element(ISIS_NODE, &max_lsp_lifetime_cmd); |
2152 | install_element(ISIS_NODE, &no_max_lsp_lifetime_cmd); | |
03f7e182 | 2153 | |
d62a17ae | 2154 | install_element(ISIS_NODE, &lsp_refresh_interval_cmd); |
2155 | install_element(ISIS_NODE, &no_lsp_refresh_interval_cmd); | |
2156 | ||
2157 | install_element(ISIS_NODE, &area_passwd_md5_cmd); | |
2158 | install_element(ISIS_NODE, &area_passwd_clear_cmd); | |
2159 | install_element(ISIS_NODE, &domain_passwd_md5_cmd); | |
2160 | install_element(ISIS_NODE, &domain_passwd_clear_cmd); | |
2161 | install_element(ISIS_NODE, &no_area_passwd_cmd); | |
2162 | ||
2163 | install_element(ISIS_NODE, &spf_delay_ietf_cmd); | |
2164 | install_element(ISIS_NODE, &no_spf_delay_ietf_cmd); | |
65f9a9a8 | 2165 | } |