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