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