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