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