]> git.proxmox.com Git - mirror_frr.git/blame - isisd/isis_cli.c
Merge pull request #6249 from chiragshah6/yang_nb5
[mirror_frr.git] / isisd / isis_cli.c
CommitLineData
20bd27e2
EDP
1/*
2 * Copyright (C) 2001,2002 Sampo Saaristo
3 * Tampere University of Technology
4 * Institute of Communications Engineering
5 * Copyright (C) 2018 Volta Networks
6 * Emanuele Di Pascale
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; see the file COPYING; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include <zebra.h>
24
25#include "if.h"
26#include "vrf.h"
27#include "log.h"
28#include "prefix.h"
29#include "command.h"
30#include "northbound_cli.h"
31#include "libfrr.h"
32#include "yang.h"
33#include "lib/linklist.h"
34#include "isisd/isisd.h"
2a1c520e 35#include "isisd/isis_nb.h"
20bd27e2
EDP
36#include "isisd/isis_misc.h"
37#include "isisd/isis_circuit.h"
38#include "isisd/isis_csm.h"
39
40#ifndef VTYSH_EXTRACT_PL
41#include "isisd/isis_cli_clippy.c"
42#endif
43
44#ifndef FABRICD
45
aaf2fd21
EDP
46/*
47 * XPath: /frr-isisd:isis/instance
48 */
49DEFPY_NOSH(router_isis, router_isis_cmd, "router isis WORD$tag",
50 ROUTER_STR
51 "ISO IS-IS\n"
52 "ISO Routing area tag\n")
53{
54 int ret;
55 char base_xpath[XPATH_MAXLEN];
56
57 snprintf(base_xpath, XPATH_MAXLEN,
58 "/frr-isisd:isis/instance[area-tag='%s']", tag);
59 nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
60 /* default value in yang for is-type is level-1, but in FRR
61 * the first instance is assigned is-type level-1-2. We
62 * need to make sure to set it in the yang model so that it
63 * is consistent with what FRR sees.
64 */
65 if (listcount(isis->area_list) == 0)
66 nb_cli_enqueue_change(vty, "./is-type", NB_OP_MODIFY,
67 "level-1-2");
68 ret = nb_cli_apply_changes(vty, base_xpath);
69 if (ret == CMD_SUCCESS)
70 VTY_PUSH_XPATH(ISIS_NODE, base_xpath);
71
72 return ret;
73}
74
75DEFPY(no_router_isis, no_router_isis_cmd, "no router isis WORD$tag",
76 NO_STR ROUTER_STR
77 "ISO IS-IS\n"
78 "ISO Routing area tag\n")
79{
80 char temp_xpath[XPATH_MAXLEN];
81 struct listnode *node, *nnode;
82 struct isis_circuit *circuit = NULL;
83 struct isis_area *area = NULL;
84
4ecc4b46
EDP
85 if (!yang_dnode_exists(vty->candidate_config->dnode,
86 "/frr-isisd:isis/instance[area-tag='%s']",
87 tag)) {
aaf2fd21
EDP
88 vty_out(vty, "ISIS area %s not found.\n", tag);
89 return CMD_ERR_NOTHING_TODO;
90 }
91
95ce849b 92 nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL);
4ecc4b46
EDP
93 area = isis_area_lookup(tag);
94 if (area && area->circuit_list && listcount(area->circuit_list)) {
aaf2fd21
EDP
95 for (ALL_LIST_ELEMENTS(area->circuit_list, node, nnode,
96 circuit)) {
97 /* add callbacks to delete each of the circuits listed
98 */
99 const char *vrf_name =
a36898e7
DS
100 vrf_lookup_by_id(circuit->interface->vrf_id)
101 ->name;
aaf2fd21
EDP
102 snprintf(
103 temp_xpath, XPATH_MAXLEN,
104 "/frr-interface:lib/interface[name='%s'][vrf='%s']/frr-isisd:isis",
105 circuit->interface->name, vrf_name);
95ce849b 106 nb_cli_enqueue_change(vty, temp_xpath, NB_OP_DESTROY,
aaf2fd21
EDP
107 NULL);
108 }
109 }
110
111 return nb_cli_apply_changes(
112 vty, "/frr-isisd:isis/instance[area-tag='%s']", tag);
113}
114
115void cli_show_router_isis(struct vty *vty, struct lyd_node *dnode,
116 bool show_defaults)
117{
118 vty_out(vty, "!\n");
119 vty_out(vty, "router isis %s\n",
120 yang_dnode_get_string(dnode, "./area-tag"));
121}
122
123/*
124 * XPath: /frr-interface:lib/interface/frr-isisd:isis/
125 * XPath: /frr-interface:lib/interface/frr-isisd:isis/ipv4-routing
126 * XPath: /frr-interface:lib/interface/frr-isisd:isis/ipv6-routing
127 * XPath: /frr-isisd:isis/instance
128 */
129DEFPY(ip_router_isis, ip_router_isis_cmd, "ip router isis WORD$tag",
130 "Interface Internet Protocol config commands\n"
131 "IP router interface commands\n"
132 "IS-IS routing protocol\n"
133 "Routing process tag\n")
134{
135 char temp_xpath[XPATH_MAXLEN];
136 const char *circ_type;
137 struct isis_area *area;
5f1e5e3f 138 struct interface *ifp;
aaf2fd21
EDP
139
140 /* area will be created if it is not present. make sure the yang model
141 * is synced with FRR and call the appropriate NB cb.
142 */
143 area = isis_area_lookup(tag);
144 if (!area) {
145 snprintf(temp_xpath, XPATH_MAXLEN,
146 "/frr-isisd:isis/instance[area-tag='%s']", tag);
147 nb_cli_enqueue_change(vty, temp_xpath, NB_OP_CREATE, tag);
148 snprintf(temp_xpath, XPATH_MAXLEN,
149 "/frr-isisd:isis/instance[area-tag='%s']/is-type",
150 tag);
151 nb_cli_enqueue_change(
152 vty, temp_xpath, NB_OP_MODIFY,
153 listcount(isis->area_list) == 0 ? "level-1-2" : NULL);
154 nb_cli_enqueue_change(vty, "./frr-isisd:isis", NB_OP_CREATE,
155 NULL);
156 nb_cli_enqueue_change(vty, "./frr-isisd:isis/area-tag",
157 NB_OP_MODIFY, tag);
158 nb_cli_enqueue_change(vty, "./frr-isisd:isis/ipv4-routing",
5f1e5e3f 159 NB_OP_MODIFY, "true");
aaf2fd21
EDP
160 nb_cli_enqueue_change(
161 vty, "./frr-isisd:isis/circuit-type", NB_OP_MODIFY,
162 listcount(isis->area_list) == 0 ? "level-1-2"
163 : "level-1");
164 } else {
165 /* area exists, circuit type defaults to its area's is_type */
166 switch (area->is_type) {
167 case IS_LEVEL_1:
168 circ_type = "level-1";
169 break;
170 case IS_LEVEL_2:
171 circ_type = "level-2";
172 break;
173 case IS_LEVEL_1_AND_2:
174 circ_type = "level-1-2";
175 break;
8a5b2e10
EDP
176 default:
177 /* just to silence compiler warnings */
178 return CMD_WARNING_CONFIG_FAILED;
aaf2fd21
EDP
179 }
180 nb_cli_enqueue_change(vty, "./frr-isisd:isis", NB_OP_CREATE,
181 NULL);
182 nb_cli_enqueue_change(vty, "./frr-isisd:isis/area-tag",
183 NB_OP_MODIFY, tag);
184 nb_cli_enqueue_change(vty, "./frr-isisd:isis/ipv4-routing",
5f1e5e3f 185 NB_OP_MODIFY, "true");
aaf2fd21
EDP
186 nb_cli_enqueue_change(vty, "./frr-isisd:isis/circuit-type",
187 NB_OP_MODIFY, circ_type);
188 }
189
5f1e5e3f 190 /* check if the interface is a loopback and if so set it as passive */
8685be73
RW
191 ifp = nb_running_get_entry(NULL, VTY_CURR_XPATH, false);
192 if (ifp && if_is_loopback(ifp))
193 nb_cli_enqueue_change(vty, "./frr-isisd:isis/passive",
194 NB_OP_MODIFY, "true");
5f1e5e3f 195
aaf2fd21
EDP
196 return nb_cli_apply_changes(vty, NULL);
197}
198
199DEFPY(ip6_router_isis, ip6_router_isis_cmd, "ipv6 router isis WORD$tag",
200 "Interface Internet Protocol config commands\n"
201 "IP router interface commands\n"
202 "IS-IS routing protocol\n"
203 "Routing process tag\n")
204{
205 char temp_xpath[XPATH_MAXLEN];
206 const char *circ_type;
207 struct isis_area *area;
5f1e5e3f 208 struct interface *ifp;
aaf2fd21
EDP
209
210 /* area will be created if it is not present. make sure the yang model
211 * is synced with FRR and call the appropriate NB cb.
212 */
213 area = isis_area_lookup(tag);
214 if (!area) {
215 snprintf(temp_xpath, XPATH_MAXLEN,
216 "/frr-isisd:isis/instance[area-tag='%s']", tag);
217 nb_cli_enqueue_change(vty, temp_xpath, NB_OP_CREATE, tag);
218 snprintf(temp_xpath, XPATH_MAXLEN,
219 "/frr-isisd:isis/instance[area-tag='%s']/is-type",
220 tag);
221 nb_cli_enqueue_change(
222 vty, temp_xpath, NB_OP_MODIFY,
223 listcount(isis->area_list) == 0 ? "level-1-2" : NULL);
224 nb_cli_enqueue_change(vty, "./frr-isisd:isis", NB_OP_CREATE,
225 NULL);
226 nb_cli_enqueue_change(vty, "./frr-isisd:isis/area-tag",
227 NB_OP_MODIFY, tag);
228 nb_cli_enqueue_change(vty, "./frr-isisd:isis/ipv6-routing",
5f1e5e3f 229 NB_OP_MODIFY, "true");
aaf2fd21
EDP
230 nb_cli_enqueue_change(
231 vty, "./frr-isisd:isis/circuit-type", NB_OP_MODIFY,
232 listcount(isis->area_list) == 0 ? "level-1-2"
233 : "level-1");
234 } else {
235 /* area exists, circuit type defaults to its area's is_type */
236 switch (area->is_type) {
237 case IS_LEVEL_1:
238 circ_type = "level-1";
239 break;
240 case IS_LEVEL_2:
241 circ_type = "level-2";
242 break;
243 case IS_LEVEL_1_AND_2:
244 circ_type = "level-1-2";
245 break;
8a5b2e10
EDP
246 default:
247 /* just to silence compiler warnings */
248 return CMD_WARNING_CONFIG_FAILED;
aaf2fd21
EDP
249 }
250 nb_cli_enqueue_change(vty, "./frr-isisd:isis", NB_OP_CREATE,
251 NULL);
252 nb_cli_enqueue_change(vty, "./frr-isisd:isis/area-tag",
253 NB_OP_MODIFY, tag);
254 nb_cli_enqueue_change(vty, "./frr-isisd:isis/ipv6-routing",
5f1e5e3f 255 NB_OP_MODIFY, "true");
aaf2fd21
EDP
256 nb_cli_enqueue_change(vty, "./frr-isisd:isis/circuit-type",
257 NB_OP_MODIFY, circ_type);
258 }
259
5f1e5e3f 260 /* check if the interface is a loopback and if so set it as passive */
8685be73
RW
261 ifp = nb_running_get_entry(NULL, VTY_CURR_XPATH, false);
262 if (ifp && if_is_loopback(ifp))
263 nb_cli_enqueue_change(vty, "./frr-isisd:isis/passive",
264 NB_OP_MODIFY, "true");
5f1e5e3f 265
aaf2fd21
EDP
266 return nb_cli_apply_changes(vty, NULL);
267}
268
269DEFPY(no_ip_router_isis, no_ip_router_isis_cmd,
270 "no <ip|ipv6>$ip router isis [WORD]$tag",
271 NO_STR
272 "Interface Internet Protocol config commands\n"
273 "IP router interface commands\n"
274 "IP router interface commands\n"
275 "IS-IS routing protocol\n"
276 "Routing process tag\n")
277{
472c3dae 278 const struct lyd_node *dnode;
aaf2fd21 279
472c3dae
RW
280 dnode = yang_dnode_get(vty->candidate_config->dnode,
281 "%s/frr-isisd:isis", VTY_CURR_XPATH);
282 if (!dnode)
283 return CMD_SUCCESS;
284
285 /*
286 * If both ipv4 and ipv6 are off delete the interface isis container.
aaf2fd21 287 */
472c3dae
RW
288 if (strmatch(ip, "ipv6")) {
289 if (!yang_dnode_get_bool(dnode, "./ipv4-routing"))
aaf2fd21 290 nb_cli_enqueue_change(vty, "./frr-isisd:isis",
95ce849b 291 NB_OP_DESTROY, NULL);
aaf2fd21
EDP
292 else
293 nb_cli_enqueue_change(vty,
294 "./frr-isisd:isis/ipv6-routing",
5f1e5e3f 295 NB_OP_MODIFY, "false");
472c3dae
RW
296 } else {
297 if (!yang_dnode_get_bool(dnode, "./ipv6-routing"))
aaf2fd21 298 nb_cli_enqueue_change(vty, "./frr-isisd:isis",
95ce849b 299 NB_OP_DESTROY, NULL);
aaf2fd21
EDP
300 else
301 nb_cli_enqueue_change(vty,
302 "./frr-isisd:isis/ipv4-routing",
5f1e5e3f 303 NB_OP_MODIFY, "false");
aaf2fd21
EDP
304 }
305
306 return nb_cli_apply_changes(vty, NULL);
307}
308
309void cli_show_ip_isis_ipv4(struct vty *vty, struct lyd_node *dnode,
310 bool show_defaults)
311{
5f1e5e3f
EDP
312 if (!yang_dnode_get_bool(dnode, NULL))
313 vty_out(vty, " no");
aaf2fd21
EDP
314 vty_out(vty, " ip router isis %s\n",
315 yang_dnode_get_string(dnode, "../area-tag"));
316}
317
318void cli_show_ip_isis_ipv6(struct vty *vty, struct lyd_node *dnode,
319 bool show_defaults)
320{
5f1e5e3f
EDP
321 if (!yang_dnode_get_bool(dnode, NULL))
322 vty_out(vty, " no");
aaf2fd21
EDP
323 vty_out(vty, " ipv6 router isis %s\n",
324 yang_dnode_get_string(dnode, "../area-tag"));
325}
326
c3e6ac0b
RZ
327/*
328 * XPath: /frr-interface:lib/interface/frr-isisd:isis/bfd-monitoring
329 */
330DEFPY(isis_bfd,
331 isis_bfd_cmd,
332 "[no] isis bfd",
333 NO_STR
334 PROTO_HELP
335 "Enable BFD support\n")
336{
337 const struct lyd_node *dnode;
338
339 dnode = yang_dnode_get(vty->candidate_config->dnode,
340 "%s/frr-isisd:isis", VTY_CURR_XPATH);
8222b997
RZ
341 if (dnode == NULL) {
342 vty_out(vty, "ISIS is not enabled on this circuit\n");
c3e6ac0b 343 return CMD_SUCCESS;
8222b997 344 }
c3e6ac0b
RZ
345
346 nb_cli_enqueue_change(vty, "./frr-isisd:isis/bfd-monitoring",
347 NB_OP_MODIFY, no ? "false" : "true");
348
349 return nb_cli_apply_changes(vty, NULL);
350}
351
352void cli_show_ip_isis_bfd_monitoring(struct vty *vty, struct lyd_node *dnode,
353 bool show_defaults)
354{
8222b997
RZ
355 if (!yang_dnode_get_bool(dnode, NULL))
356 vty_out(vty, " no");
357
def117f7 358 vty_out(vty, " isis bfd\n");
c3e6ac0b
RZ
359}
360
f084ea55
EDP
361/*
362 * XPath: /frr-isisd:isis/instance/area-address
363 */
364DEFPY(net, net_cmd, "[no] net WORD",
365 "Remove an existing Network Entity Title for this process\n"
366 "A Network Entity Title for this process (OSI only)\n"
367 "XX.XXXX. ... .XXX.XX Network entity title (NET)\n")
368{
369 nb_cli_enqueue_change(vty, "./area-address",
95ce849b 370 no ? NB_OP_DESTROY : NB_OP_CREATE, net);
f084ea55
EDP
371
372 return nb_cli_apply_changes(vty, NULL);
373}
374
375void cli_show_isis_area_address(struct vty *vty, struct lyd_node *dnode,
376 bool show_defaults)
377{
378 vty_out(vty, " net %s\n", yang_dnode_get_string(dnode, NULL));
379}
380
e6bdae69
EDP
381/*
382 * XPath: /frr-isisd:isis/instance/is-type
383 */
384DEFPY(is_type, is_type_cmd, "is-type <level-1|level-1-2|level-2-only>$level",
385 "IS Level for this routing process (OSI only)\n"
386 "Act as a station router only\n"
387 "Act as both a station router and an area router\n"
388 "Act as an area router only\n")
389{
390 nb_cli_enqueue_change(vty, "./is-type", NB_OP_MODIFY,
391 strmatch(level, "level-2-only") ? "level-2"
392 : level);
393
394 return nb_cli_apply_changes(vty, NULL);
395}
396
397DEFPY(no_is_type, no_is_type_cmd,
398 "no is-type [<level-1|level-1-2|level-2-only>]",
399 NO_STR
400 "IS Level for this routing process (OSI only)\n"
401 "Act as a station router only\n"
402 "Act as both a station router and an area router\n"
403 "Act as an area router only\n")
404{
fd506bbb 405 nb_cli_enqueue_change(vty, "./is-type", NB_OP_MODIFY, NULL);
e6bdae69
EDP
406
407 return nb_cli_apply_changes(vty, NULL);
408}
409
410void cli_show_isis_is_type(struct vty *vty, struct lyd_node *dnode,
411 bool show_defaults)
412{
413 int is_type = yang_dnode_get_enum(dnode, NULL);
414
415 switch (is_type) {
416 case IS_LEVEL_1:
417 vty_out(vty, " is-type level-1\n");
418 break;
419 case IS_LEVEL_2:
420 vty_out(vty, " is-type level-2-only\n");
421 break;
422 case IS_LEVEL_1_AND_2:
423 vty_out(vty, " is-type level-1-2\n");
424 break;
425 }
426}
427
6bb043cd
EDP
428/*
429 * XPath: /frr-isisd:isis/instance/dynamic-hostname
430 */
431DEFPY(dynamic_hostname, dynamic_hostname_cmd, "[no] hostname dynamic",
432 NO_STR
433 "Dynamic hostname for IS-IS\n"
434 "Dynamic hostname\n")
435{
436 nb_cli_enqueue_change(vty, "./dynamic-hostname", NB_OP_MODIFY,
437 no ? "false" : "true");
438
439 return nb_cli_apply_changes(vty, NULL);
440}
441
442void cli_show_isis_dynamic_hostname(struct vty *vty, struct lyd_node *dnode,
443 bool show_defaults)
444{
445 if (!yang_dnode_get_bool(dnode, NULL))
446 vty_out(vty, " no");
447
448 vty_out(vty, " hostname dynamic\n");
449}
450
05a3f9f0
EDP
451/*
452 * XPath: /frr-isisd:isis/instance/overload
453 */
454DEFPY(set_overload_bit, set_overload_bit_cmd, "[no] set-overload-bit",
455 "Reset overload bit to accept transit traffic\n"
456 "Set overload bit to avoid any transit traffic\n")
457{
5f1e5e3f
EDP
458 nb_cli_enqueue_change(vty, "./overload", NB_OP_MODIFY,
459 no ? "false" : "true");
05a3f9f0
EDP
460
461 return nb_cli_apply_changes(vty, NULL);
462}
463
464void cli_show_isis_overload(struct vty *vty, struct lyd_node *dnode,
465 bool show_defaults)
466{
5f1e5e3f
EDP
467 if (!yang_dnode_get_bool(dnode, NULL))
468 vty_out(vty, " no");
05a3f9f0
EDP
469 vty_out(vty, " set-overload-bit\n");
470}
471
472/*
473 * XPath: /frr-isisd:isis/instance/attached
474 */
475DEFPY(set_attached_bit, set_attached_bit_cmd, "[no] set-attached-bit",
476 "Reset attached bit\n"
477 "Set attached bit to identify as L1/L2 router for inter-area traffic\n")
478{
5f1e5e3f
EDP
479 nb_cli_enqueue_change(vty, "./attached", NB_OP_MODIFY,
480 no ? "false" : "true");
05a3f9f0
EDP
481
482 return nb_cli_apply_changes(vty, NULL);
483}
484
485void cli_show_isis_attached(struct vty *vty, struct lyd_node *dnode,
486 bool show_defaults)
487{
5f1e5e3f
EDP
488 if (!yang_dnode_get_bool(dnode, NULL))
489 vty_out(vty, " no");
05a3f9f0
EDP
490 vty_out(vty, " set-attached-bit\n");
491}
492
e0df3206
EDP
493/*
494 * XPath: /frr-isisd:isis/instance/metric-style
495 */
496DEFPY(metric_style, metric_style_cmd,
f34ab52d 497 "metric-style <narrow|transition|wide>$style",
e0df3206
EDP
498 "Use old-style (ISO 10589) or new-style packet formats\n"
499 "Use old style of TLVs with narrow metric\n"
500 "Send and accept both styles of TLVs during transition\n"
501 "Use new style of TLVs to carry wider metric\n")
502{
503 nb_cli_enqueue_change(vty, "./metric-style", NB_OP_MODIFY, style);
504
505 return nb_cli_apply_changes(vty, NULL);
506}
507
508DEFPY(no_metric_style, no_metric_style_cmd,
f34ab52d
EDP
509 "no metric-style [narrow|transition|wide]",
510 NO_STR
511 "Use old-style (ISO 10589) or new-style packet formats\n"
e0df3206
EDP
512 "Use old style of TLVs with narrow metric\n"
513 "Send and accept both styles of TLVs during transition\n"
514 "Use new style of TLVs to carry wider metric\n")
515{
fd506bbb 516 nb_cli_enqueue_change(vty, "./metric-style", NB_OP_MODIFY, NULL);
e0df3206
EDP
517
518 return nb_cli_apply_changes(vty, NULL);
519}
520
521void cli_show_isis_metric_style(struct vty *vty, struct lyd_node *dnode,
522 bool show_defaults)
523{
524 int metric = yang_dnode_get_enum(dnode, NULL);
525
526 switch (metric) {
527 case ISIS_NARROW_METRIC:
528 vty_out(vty, " metric-style narrow\n");
529 break;
530 case ISIS_WIDE_METRIC:
531 vty_out(vty, " metric-style wide\n");
532 break;
533 case ISIS_TRANSITION_METRIC:
534 vty_out(vty, " metric-style transition\n");
535 break;
536 }
537}
538
933536e3
EDP
539/*
540 * XPath: /frr-isisd:isis/instance/area-password
541 */
542DEFPY(area_passwd, area_passwd_cmd,
543 "area-password <clear|md5>$pwd_type WORD$pwd [authenticate snp <send-only|validate>$snp]",
544 "Configure the authentication password for an area\n"
545 "Clear-text authentication type\n"
546 "MD5 authentication type\n"
547 "Level-wide password\n"
548 "Authentication\n"
549 "SNP PDUs\n"
550 "Send but do not check PDUs on receiving\n"
551 "Send and check PDUs on receiving\n")
552{
553 nb_cli_enqueue_change(vty, "./area-password", NB_OP_CREATE, NULL);
554 nb_cli_enqueue_change(vty, "./area-password/password", NB_OP_MODIFY,
555 pwd);
556 nb_cli_enqueue_change(vty, "./area-password/password-type",
557 NB_OP_MODIFY, pwd_type);
558 nb_cli_enqueue_change(vty, "./area-password/authenticate-snp",
559 NB_OP_MODIFY, snp ? snp : "none");
560
561 return nb_cli_apply_changes(vty, NULL);
562}
563
564void cli_show_isis_area_pwd(struct vty *vty, struct lyd_node *dnode,
565 bool show_defaults)
566{
567 const char *snp;
568
569 vty_out(vty, " area-password %s %s",
570 yang_dnode_get_string(dnode, "./password-type"),
571 yang_dnode_get_string(dnode, "./password"));
572 snp = yang_dnode_get_string(dnode, "./authenticate-snp");
573 if (!strmatch("none", snp))
574 vty_out(vty, " authenticate snp %s", snp);
575 vty_out(vty, "\n");
576}
577
578/*
579 * XPath: /frr-isisd:isis/instance/domain-password
580 */
581DEFPY(domain_passwd, domain_passwd_cmd,
582 "domain-password <clear|md5>$pwd_type WORD$pwd [authenticate snp <send-only|validate>$snp]",
583 "Set the authentication password for a routing domain\n"
584 "Clear-text authentication type\n"
585 "MD5 authentication type\n"
586 "Level-wide password\n"
587 "Authentication\n"
588 "SNP PDUs\n"
589 "Send but do not check PDUs on receiving\n"
590 "Send and check PDUs on receiving\n")
591{
592 nb_cli_enqueue_change(vty, "./domain-password", NB_OP_CREATE, NULL);
593 nb_cli_enqueue_change(vty, "./domain-password/password", NB_OP_MODIFY,
594 pwd);
595 nb_cli_enqueue_change(vty, "./domain-password/password-type",
596 NB_OP_MODIFY, pwd_type);
597 nb_cli_enqueue_change(vty, "./domain-password/authenticate-snp",
598 NB_OP_MODIFY, snp ? snp : "none");
599
600 return nb_cli_apply_changes(vty, NULL);
601}
602
603DEFPY(no_area_passwd, no_area_passwd_cmd,
604 "no <area-password|domain-password>$cmd",
605 NO_STR
606 "Configure the authentication password for an area\n"
607 "Set the authentication password for a routing domain\n")
608{
95ce849b 609 nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL);
933536e3
EDP
610
611 return nb_cli_apply_changes(vty, "./%s", cmd);
612}
613
614void cli_show_isis_domain_pwd(struct vty *vty, struct lyd_node *dnode,
615 bool show_defaults)
616{
617 const char *snp;
618
619 vty_out(vty, " domain-password %s %s",
620 yang_dnode_get_string(dnode, "./password-type"),
621 yang_dnode_get_string(dnode, "./password"));
622 snp = yang_dnode_get_string(dnode, "./authenticate-snp");
623 if (!strmatch("none", snp))
624 vty_out(vty, " authenticate snp %s", snp);
625 vty_out(vty, "\n");
626}
627
1d6fe72e 628/*
d2c970ff
EDP
629 * XPath: /frr-isisd:isis/instance/lsp/timers/level-1/generation-interval
630 * XPath: /frr-isisd:isis/instance/lsp/timers/level-2/generation-interval
1d6fe72e
EDP
631 */
632DEFPY(lsp_gen_interval, lsp_gen_interval_cmd,
633 "lsp-gen-interval [level-1|level-2]$level (1-120)$val",
634 "Minimum interval between regenerating same LSP\n"
635 "Set interval for level 1 only\n"
636 "Set interval for level 2 only\n"
637 "Minimum interval in seconds\n")
638{
639 if (!level || strmatch(level, "level-1"))
d2c970ff
EDP
640 nb_cli_enqueue_change(
641 vty, "./lsp/timers/level-1/generation-interval",
642 NB_OP_MODIFY, val_str);
1d6fe72e 643 if (!level || strmatch(level, "level-2"))
d2c970ff
EDP
644 nb_cli_enqueue_change(
645 vty, "./lsp/timers/level-2/generation-interval",
646 NB_OP_MODIFY, val_str);
1d6fe72e
EDP
647
648 return nb_cli_apply_changes(vty, NULL);
649}
650
651DEFPY(no_lsp_gen_interval, no_lsp_gen_interval_cmd,
652 "no lsp-gen-interval [level-1|level-2]$level [(1-120)]",
653 NO_STR
654 "Minimum interval between regenerating same LSP\n"
655 "Set interval for level 1 only\n"
656 "Set interval for level 2 only\n"
657 "Minimum interval in seconds\n")
658{
659 if (!level || strmatch(level, "level-1"))
d2c970ff
EDP
660 nb_cli_enqueue_change(
661 vty, "./lsp/timers/level-1/generation-interval",
662 NB_OP_MODIFY, NULL);
1d6fe72e 663 if (!level || strmatch(level, "level-2"))
d2c970ff
EDP
664 nb_cli_enqueue_change(
665 vty, "./lsp/timers/level-2/generation-interval",
666 NB_OP_MODIFY, NULL);
1d6fe72e
EDP
667
668 return nb_cli_apply_changes(vty, NULL);
669}
670
7e869004 671/*
d2c970ff
EDP
672 * XPath: /frr-isisd:isis/instance/lsp/timers/level-1/refresh-interval
673 * XPath: /frr-isisd:isis/instance/lsp/timers/level-2/refresh-interval
7e869004
EDP
674 */
675DEFPY(lsp_refresh_interval, lsp_refresh_interval_cmd,
676 "lsp-refresh-interval [level-1|level-2]$level (1-65235)$val",
677 "LSP refresh interval\n"
678 "LSP refresh interval for Level 1 only\n"
679 "LSP refresh interval for Level 2 only\n"
680 "LSP refresh interval in seconds\n")
681{
682 if (!level || strmatch(level, "level-1"))
d2c970ff
EDP
683 nb_cli_enqueue_change(vty,
684 "./lsp/timers/level-1/refresh-interval",
7e869004
EDP
685 NB_OP_MODIFY, val_str);
686 if (!level || strmatch(level, "level-2"))
d2c970ff
EDP
687 nb_cli_enqueue_change(vty,
688 "./lsp/timers/level-2/refresh-interval",
7e869004
EDP
689 NB_OP_MODIFY, val_str);
690
691 return nb_cli_apply_changes(vty, NULL);
692}
693
694DEFPY(no_lsp_refresh_interval, no_lsp_refresh_interval_cmd,
695 "no lsp-refresh-interval [level-1|level-2]$level [(1-65235)]",
696 NO_STR
697 "LSP refresh interval\n"
698 "LSP refresh interval for Level 1 only\n"
699 "LSP refresh interval for Level 2 only\n"
700 "LSP refresh interval in seconds\n")
701{
702 if (!level || strmatch(level, "level-1"))
d2c970ff
EDP
703 nb_cli_enqueue_change(vty,
704 "./lsp/timers/level-1/refresh-interval",
7e869004
EDP
705 NB_OP_MODIFY, NULL);
706 if (!level || strmatch(level, "level-2"))
d2c970ff
EDP
707 nb_cli_enqueue_change(vty,
708 "./lsp/timers/level-2/refresh-interval",
7e869004
EDP
709 NB_OP_MODIFY, NULL);
710
711 return nb_cli_apply_changes(vty, NULL);
712}
713
ea120aa0 714/*
d2c970ff
EDP
715 * XPath: /frr-isisd:isis/instance/lsp/timers/level-1/maximum-lifetime
716 * XPath: /frr-isisd:isis/instance/lsp/timers/level-1/maximum-lifetime
ea120aa0 717 */
d2c970ff 718
ea120aa0
EDP
719DEFPY(max_lsp_lifetime, max_lsp_lifetime_cmd,
720 "max-lsp-lifetime [level-1|level-2]$level (350-65535)$val",
721 "Maximum LSP lifetime\n"
722 "Maximum LSP lifetime for Level 1 only\n"
723 "Maximum LSP lifetime for Level 2 only\n"
724 "LSP lifetime in seconds\n")
725{
726 if (!level || strmatch(level, "level-1"))
d2c970ff
EDP
727 nb_cli_enqueue_change(vty,
728 "./lsp/timers/level-1/maximum-lifetime",
ea120aa0
EDP
729 NB_OP_MODIFY, val_str);
730 if (!level || strmatch(level, "level-2"))
d2c970ff
EDP
731 nb_cli_enqueue_change(vty,
732 "./lsp/timers/level-2/maximum-lifetime",
ea120aa0
EDP
733 NB_OP_MODIFY, val_str);
734
735 return nb_cli_apply_changes(vty, NULL);
736}
737
738DEFPY(no_max_lsp_lifetime, no_max_lsp_lifetime_cmd,
739 "no max-lsp-lifetime [level-1|level-2]$level [(350-65535)]",
740 NO_STR
741 "Maximum LSP lifetime\n"
742 "Maximum LSP lifetime for Level 1 only\n"
743 "Maximum LSP lifetime for Level 2 only\n"
744 "LSP lifetime in seconds\n")
745{
746 if (!level || strmatch(level, "level-1"))
d2c970ff
EDP
747 nb_cli_enqueue_change(vty,
748 "./lsp/timers/level-1/maximum-lifetime",
ea120aa0
EDP
749 NB_OP_MODIFY, NULL);
750 if (!level || strmatch(level, "level-2"))
d2c970ff
EDP
751 nb_cli_enqueue_change(vty,
752 "./lsp/timers/level-2/maximum-lifetime",
ea120aa0
EDP
753 NB_OP_MODIFY, NULL);
754
755 return nb_cli_apply_changes(vty, NULL);
756}
757
d2c970ff
EDP
758/* unified LSP timers command
759 * XPath: /frr-isisd:isis/instance/lsp/timers
760 */
761
762DEFPY(lsp_timers, lsp_timers_cmd,
763 "lsp-timers [level-1|level-2]$level gen-interval (1-120)$gen refresh-interval (1-65235)$refresh max-lifetime (350-65535)$lifetime",
764 "LSP-related timers\n"
765 "LSP-related timers for Level 1 only\n"
766 "LSP-related timers for Level 2 only\n"
767 "Minimum interval between regenerating same LSP\n"
768 "Generation interval in seconds\n"
769 "LSP refresh interval\n"
770 "LSP refresh interval in seconds\n"
771 "Maximum LSP lifetime\n"
772 "Maximum LSP lifetime in seconds\n")
ea120aa0 773{
d2c970ff
EDP
774 if (!level || strmatch(level, "level-1")) {
775 nb_cli_enqueue_change(
776 vty, "./lsp/timers/level-1/generation-interval",
777 NB_OP_MODIFY, gen_str);
778 nb_cli_enqueue_change(vty,
779 "./lsp/timers/level-1/refresh-interval",
780 NB_OP_MODIFY, refresh_str);
781 nb_cli_enqueue_change(vty,
782 "./lsp/timers/level-1/maximum-lifetime",
783 NB_OP_MODIFY, lifetime_str);
784 }
785 if (!level || strmatch(level, "level-2")) {
786 nb_cli_enqueue_change(
787 vty, "./lsp/timers/level-2/generation-interval",
788 NB_OP_MODIFY, gen_str);
789 nb_cli_enqueue_change(vty,
790 "./lsp/timers/level-2/refresh-interval",
791 NB_OP_MODIFY, refresh_str);
792 nb_cli_enqueue_change(vty,
793 "./lsp/timers/level-2/maximum-lifetime",
794 NB_OP_MODIFY, lifetime_str);
795 }
ea120aa0 796
d2c970ff
EDP
797 return nb_cli_apply_changes(vty, NULL);
798}
799
800DEFPY(no_lsp_timers, no_lsp_timers_cmd,
801 "no lsp-timers [level-1|level-2]$level [gen-interval (1-120) refresh-interval (1-65235) max-lifetime (350-65535)]",
802 NO_STR
803 "LSP-related timers\n"
804 "LSP-related timers for Level 1 only\n"
805 "LSP-related timers for Level 2 only\n"
806 "Minimum interval between regenerating same LSP\n"
807 "Generation interval in seconds\n"
808 "LSP refresh interval\n"
809 "LSP refresh interval in seconds\n"
810 "Maximum LSP lifetime\n"
811 "Maximum LSP lifetime in seconds\n")
812{
813 if (!level || strmatch(level, "level-1")) {
814 nb_cli_enqueue_change(
815 vty, "./lsp/timers/level-1/generation-interval",
816 NB_OP_MODIFY, NULL);
817 nb_cli_enqueue_change(vty,
818 "./lsp/timers/level-1/refresh-interval",
819 NB_OP_MODIFY, NULL);
820 nb_cli_enqueue_change(vty,
821 "./lsp/timers/level-1/maximum-lifetime",
822 NB_OP_MODIFY, NULL);
823 }
824 if (!level || strmatch(level, "level-2")) {
825 nb_cli_enqueue_change(
826 vty, "./lsp/timers/level-2/generation-interval",
827 NB_OP_MODIFY, NULL);
828 nb_cli_enqueue_change(vty,
829 "./lsp/timers/level-2/refresh-interval",
830 NB_OP_MODIFY, NULL);
831 nb_cli_enqueue_change(vty,
832 "./lsp/timers/level-2/maximum-lifetime",
833 NB_OP_MODIFY, NULL);
834 }
835
836 return nb_cli_apply_changes(vty, NULL);
837}
838
839void cli_show_isis_lsp_timers(struct vty *vty, struct lyd_node *dnode,
840 bool show_defaults)
841{
842 const char *l1_refresh =
843 yang_dnode_get_string(dnode, "./level-1/refresh-interval");
844 const char *l2_refresh =
845 yang_dnode_get_string(dnode, "./level-2/refresh-interval");
846 const char *l1_lifetime =
847 yang_dnode_get_string(dnode, "./level-1/maximum-lifetime");
848 const char *l2_lifetime =
849 yang_dnode_get_string(dnode, "./level-2/maximum-lifetime");
850 const char *l1_gen =
851 yang_dnode_get_string(dnode, "./level-1/generation-interval");
852 const char *l2_gen =
853 yang_dnode_get_string(dnode, "./level-2/generation-interval");
854 if (strmatch(l1_refresh, l2_refresh)
855 && strmatch(l1_lifetime, l2_lifetime) && strmatch(l1_gen, l2_gen))
856 vty_out(vty,
857 " lsp-timers gen-interval %s refresh-interval %s max-lifetime %s\n",
858 l1_gen, l1_refresh, l1_lifetime);
ea120aa0 859 else {
d2c970ff
EDP
860 vty_out(vty,
861 " lsp-timers level-1 gen-interval %s refresh-interval %s max-lifetime %s\n",
862 l1_gen, l1_refresh, l1_lifetime);
863 vty_out(vty,
864 " lsp-timers level-2 gen-interval %s refresh-interval %s max-lifetime %s\n",
865 l2_gen, l2_refresh, l2_lifetime);
ea120aa0
EDP
866 }
867}
868
27a45d16
EDP
869/*
870 * XPath: /frr-isisd:isis/instance/lsp/mtu
871 */
872DEFPY(area_lsp_mtu, area_lsp_mtu_cmd, "lsp-mtu (128-4352)$val",
873 "Configure the maximum size of generated LSPs\n"
874 "Maximum size of generated LSPs\n")
875{
876 nb_cli_enqueue_change(vty, "./lsp/mtu", NB_OP_MODIFY, val_str);
877
878 return nb_cli_apply_changes(vty, NULL);
879}
880
881DEFPY(no_area_lsp_mtu, no_area_lsp_mtu_cmd, "no lsp-mtu [(128-4352)]",
882 NO_STR
883 "Configure the maximum size of generated LSPs\n"
884 "Maximum size of generated LSPs\n")
885{
886 nb_cli_enqueue_change(vty, "./lsp/mtu", NB_OP_MODIFY, NULL);
887
888 return nb_cli_apply_changes(vty, NULL);
889}
890
891void cli_show_isis_lsp_mtu(struct vty *vty, struct lyd_node *dnode,
892 bool show_defaults)
893{
894 vty_out(vty, " lsp-mtu %s\n", yang_dnode_get_string(dnode, NULL));
895}
896
dcb1dcd6
EDP
897/*
898 * XPath: /frr-isisd:isis/instance/spf/minimum-interval
899 */
900DEFPY(spf_interval, spf_interval_cmd,
901 "spf-interval [level-1|level-2]$level (1-120)$val",
902 "Minimum interval between SPF calculations\n"
903 "Set interval for level 1 only\n"
904 "Set interval for level 2 only\n"
905 "Minimum interval between consecutive SPFs in seconds\n")
906{
907 if (!level || strmatch(level, "level-1"))
908 nb_cli_enqueue_change(vty, "./spf/minimum-interval/level-1",
909 NB_OP_MODIFY, val_str);
910 if (!level || strmatch(level, "level-2"))
911 nb_cli_enqueue_change(vty, "./spf/minimum-interval/level-2",
912 NB_OP_MODIFY, val_str);
913
914 return nb_cli_apply_changes(vty, NULL);
915}
916
917DEFPY(no_spf_interval, no_spf_interval_cmd,
918 "no spf-interval [level-1|level-2]$level [(1-120)]",
919 NO_STR
920 "Minimum interval between SPF calculations\n"
921 "Set interval for level 1 only\n"
922 "Set interval for level 2 only\n"
923 "Minimum interval between consecutive SPFs in seconds\n")
924{
925 if (!level || strmatch(level, "level-1"))
926 nb_cli_enqueue_change(vty, "./spf/minimum-interval/level-1",
927 NB_OP_MODIFY, NULL);
928 if (!level || strmatch(level, "level-2"))
929 nb_cli_enqueue_change(vty, "./spf/minimum-interval/level-2",
930 NB_OP_MODIFY, NULL);
931
932 return nb_cli_apply_changes(vty, NULL);
933}
934
935void cli_show_isis_spf_min_interval(struct vty *vty, struct lyd_node *dnode,
936 bool show_defaults)
937{
938 const char *l1 = yang_dnode_get_string(dnode, "./level-1");
939 const char *l2 = yang_dnode_get_string(dnode, "./level-2");
940
941 if (strmatch(l1, l2))
942 vty_out(vty, " spf-interval %s\n", l1);
943 else {
944 vty_out(vty, " spf-interval level-1 %s\n", l1);
945 vty_out(vty, " spf-interval level-2 %s\n", l2);
946 }
947}
948
5336ba30
EDP
949/*
950 * XPath: /frr-isisd:isis/instance/spf/ietf-backoff-delay
951 */
952DEFPY(spf_delay_ietf, spf_delay_ietf_cmd,
953 "spf-delay-ietf init-delay (0-60000) short-delay (0-60000) long-delay (0-60000) holddown (0-60000) time-to-learn (0-60000)",
954 "IETF SPF delay algorithm\n"
955 "Delay used while in QUIET state\n"
956 "Delay used while in QUIET state in milliseconds\n"
957 "Delay used while in SHORT_WAIT state\n"
958 "Delay used while in SHORT_WAIT state in milliseconds\n"
959 "Delay used while in LONG_WAIT\n"
960 "Delay used while in LONG_WAIT state in milliseconds\n"
961 "Time with no received IGP events before considering IGP stable\n"
962 "Time with no received IGP events before considering IGP stable (in milliseconds)\n"
963 "Maximum duration needed to learn all the events related to a single failure\n"
964 "Maximum duration needed to learn all the events related to a single failure (in milliseconds)\n")
965{
966 nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay", NB_OP_CREATE,
967 NULL);
968 nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay/init-delay",
969 NB_OP_MODIFY, init_delay_str);
970 nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay/short-delay",
971 NB_OP_MODIFY, short_delay_str);
972 nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay/long-delay",
973 NB_OP_MODIFY, long_delay_str);
974 nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay/hold-down",
975 NB_OP_MODIFY, holddown_str);
976 nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay/time-to-learn",
977 NB_OP_MODIFY, time_to_learn_str);
978
979 return nb_cli_apply_changes(vty, NULL);
980}
981
982DEFPY(no_spf_delay_ietf, no_spf_delay_ietf_cmd,
983 "no spf-delay-ietf [init-delay (0-60000) short-delay (0-60000) long-delay (0-60000) holddown (0-60000) time-to-learn (0-60000)]",
984 NO_STR
f34ab52d 985 "IETF SPF delay algorithm\n"
5336ba30
EDP
986 "Delay used while in QUIET state\n"
987 "Delay used while in QUIET state in milliseconds\n"
988 "Delay used while in SHORT_WAIT state\n"
989 "Delay used while in SHORT_WAIT state in milliseconds\n"
990 "Delay used while in LONG_WAIT\n"
991 "Delay used while in LONG_WAIT state in milliseconds\n"
992 "Time with no received IGP events before considering IGP stable\n"
993 "Time with no received IGP events before considering IGP stable (in milliseconds)\n"
994 "Maximum duration needed to learn all the events related to a single failure\n"
995 "Maximum duration needed to learn all the events related to a single failure (in milliseconds)\n")
996{
95ce849b 997 nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay", NB_OP_DESTROY,
5336ba30
EDP
998 NULL);
999
1000 return nb_cli_apply_changes(vty, NULL);
1001}
1002
1003void cli_show_isis_spf_ietf_backoff(struct vty *vty, struct lyd_node *dnode,
1004 bool show_defaults)
1005{
1006 vty_out(vty,
1007 " spf-delay-ietf init-delay %s short-delay %s long-delay %s holddown %s time-to-learn %s\n",
1008 yang_dnode_get_string(dnode, "./init-delay"),
1009 yang_dnode_get_string(dnode, "./short-delay"),
1010 yang_dnode_get_string(dnode, "./long-delay"),
1011 yang_dnode_get_string(dnode, "./hold-down"),
1012 yang_dnode_get_string(dnode, "./time-to-learn"));
1013}
1014
66e45e10
EDP
1015/*
1016 * XPath: /frr-isisd:isis/instance/purge-originator
1017 */
1018DEFPY(area_purge_originator, area_purge_originator_cmd, "[no] purge-originator",
1019 NO_STR "Use the RFC 6232 purge-originator\n")
1020{
5f1e5e3f
EDP
1021 nb_cli_enqueue_change(vty, "./purge-originator", NB_OP_MODIFY,
1022 no ? "false" : "true");
66e45e10
EDP
1023
1024 return nb_cli_apply_changes(vty, NULL);
1025}
1026
1027void cli_show_isis_purge_origin(struct vty *vty, struct lyd_node *dnode,
1028 bool show_defaults)
1029{
5f1e5e3f
EDP
1030 if (!yang_dnode_get_bool(dnode, NULL))
1031 vty_out(vty, " no");
66e45e10
EDP
1032 vty_out(vty, " purge-originator\n");
1033}
1034
d1a80ef6 1035/*
2e2a8b91 1036 * XPath: /frr-isisd:isis/instance/mpls-te
d1a80ef6
EDP
1037 */
1038DEFPY(isis_mpls_te_on, isis_mpls_te_on_cmd, "mpls-te on",
1039 MPLS_TE_STR "Enable the MPLS-TE functionality\n")
1040{
2e2a8b91 1041 nb_cli_enqueue_change(vty, "./mpls-te", NB_OP_CREATE,
d1a80ef6
EDP
1042 NULL);
1043
1044 return nb_cli_apply_changes(vty, NULL);
1045}
1046
1047DEFPY(no_isis_mpls_te_on, no_isis_mpls_te_on_cmd, "no mpls-te [on]",
1048 NO_STR
1049 "Disable the MPLS-TE functionality\n"
2e2a8b91 1050 "Disable the MPLS-TE functionality\n")
d1a80ef6 1051{
2e2a8b91 1052 nb_cli_enqueue_change(vty, "./mpls-te", NB_OP_DESTROY,
d1a80ef6
EDP
1053 NULL);
1054
1055 return nb_cli_apply_changes(vty, NULL);
1056}
1057
1058void cli_show_isis_mpls_te(struct vty *vty, struct lyd_node *dnode,
1059 bool show_defaults)
1060{
1061 vty_out(vty, " mpls-te on\n");
1062}
1063
1064/*
2e2a8b91 1065 * XPath: /frr-isisd:isis/instance/mpls-te/router-address
d1a80ef6
EDP
1066 */
1067DEFPY(isis_mpls_te_router_addr, isis_mpls_te_router_addr_cmd,
1068 "mpls-te router-address A.B.C.D",
1069 MPLS_TE_STR
1070 "Stable IP address of the advertising router\n"
1071 "MPLS-TE router address in IPv4 address format\n")
1072{
2e2a8b91 1073 nb_cli_enqueue_change(vty, "./mpls-te/router-address",
d1a80ef6
EDP
1074 NB_OP_MODIFY, router_address_str);
1075
1076 return nb_cli_apply_changes(vty, NULL);
1077}
1078
2e2a8b91
OD
1079DEFPY(no_isis_mpls_te_router_addr, no_isis_mpls_te_router_addr_cmd,
1080 "no mpls-te router-address [A.B.C.D]",
1081 NO_STR MPLS_TE_STR
1082 "Delete IP address of the advertising router\n"
1083 "MPLS-TE router address in IPv4 address format\n")
1084{
1085 nb_cli_enqueue_change(vty, "./mpls-te/router-address",
1086 NB_OP_DESTROY, NULL);
1087
1088 return nb_cli_apply_changes(vty, NULL);
1089}
1090
d1a80ef6
EDP
1091void cli_show_isis_mpls_te_router_addr(struct vty *vty, struct lyd_node *dnode,
1092 bool show_defaults)
1093{
1094 vty_out(vty, " mpls-te router-address %s\n",
1095 yang_dnode_get_string(dnode, NULL));
1096}
1097
1098DEFPY(isis_mpls_te_inter_as, isis_mpls_te_inter_as_cmd,
1099 "[no] mpls-te inter-as [level-1|level-1-2|level-2-only]",
1100 NO_STR MPLS_TE_STR
1101 "Configure MPLS-TE Inter-AS support\n"
1102 "AREA native mode self originate INTER-AS LSP with L1 only flooding scope\n"
1103 "AREA native mode self originate INTER-AS LSP with L1 and L2 flooding scope\n"
1104 "AS native mode self originate INTER-AS LSP with L2 only flooding scope\n")
1105{
2e2a8b91 1106 vty_out(vty, "MPLS-TE Inter-AS is not yet supported\n");
d1a80ef6
EDP
1107 return CMD_SUCCESS;
1108}
1109
8b104c10
EDP
1110/*
1111 * XPath: /frr-isisd:isis/instance/default-information-originate
1112 */
1113DEFPY(isis_default_originate, isis_default_originate_cmd,
1114 "[no] default-information originate <ipv4|ipv6>$ip"
1115 " <level-1|level-2>$level [always]$always"
82c25998 1116 " [{metric (0-16777215)$metric|route-map WORD$rmap}]",
8b104c10
EDP
1117 NO_STR
1118 "Control distribution of default information\n"
1119 "Distribute a default route\n"
1120 "Distribute default route for IPv4\n"
1121 "Distribute default route for IPv6\n"
1122 "Distribute default route into level-1\n"
1123 "Distribute default route into level-2\n"
1124 "Always advertise default route\n"
1125 "Metric for default route\n"
1126 "ISIS default metric\n"
1127 "Route map reference\n"
1128 "Pointer to route-map entries\n")
1129{
1130 if (no)
95ce849b 1131 nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL);
8b104c10
EDP
1132 else {
1133 nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
5f1e5e3f
EDP
1134 nb_cli_enqueue_change(vty, "./always", NB_OP_MODIFY,
1135 always ? "true" : "false");
8b104c10 1136 nb_cli_enqueue_change(vty, "./route-map",
95ce849b 1137 rmap ? NB_OP_MODIFY : NB_OP_DESTROY,
8b104c10 1138 rmap ? rmap : NULL);
82c25998
DT
1139 nb_cli_enqueue_change(vty, "./metric", NB_OP_MODIFY,
1140 metric_str ? metric_str : NULL);
8b104c10
EDP
1141 if (strmatch(ip, "ipv6") && !always) {
1142 vty_out(vty,
1143 "Zebra doesn't implement default-originate for IPv6 yet\n");
1144 vty_out(vty,
1145 "so use with care or use default-originate always.\n");
1146 }
1147 }
1148
1149 return nb_cli_apply_changes(
1150 vty, "./default-information-originate/%s[level='%s']", ip,
1151 level);
1152}
1153
1154static void vty_print_def_origin(struct vty *vty, struct lyd_node *dnode,
f34ab52d
EDP
1155 const char *family, const char *level,
1156 bool show_defaults)
8b104c10 1157{
8b104c10 1158 vty_out(vty, " default-information originate %s %s", family, level);
5f1e5e3f 1159 if (yang_dnode_get_bool(dnode, "./always"))
8b104c10
EDP
1160 vty_out(vty, " always");
1161
1162 if (yang_dnode_exists(dnode, "./route-map"))
1163 vty_out(vty, " route-map %s",
1164 yang_dnode_get_string(dnode, "./route-map"));
82c25998
DT
1165 if (show_defaults || !yang_dnode_is_default(dnode, "./metric"))
1166 vty_out(vty, " metric %s",
1167 yang_dnode_get_string(dnode, "./metric"));
1168
8b104c10
EDP
1169 vty_out(vty, "\n");
1170}
1171
1172void cli_show_isis_def_origin_ipv4(struct vty *vty, struct lyd_node *dnode,
1173 bool show_defaults)
1174{
1175 const char *level = yang_dnode_get_string(dnode, "./level");
1176
1177 vty_print_def_origin(vty, dnode, "ipv4", level, show_defaults);
1178}
1179
1180void cli_show_isis_def_origin_ipv6(struct vty *vty, struct lyd_node *dnode,
1181 bool show_defaults)
1182{
1183 const char *level = yang_dnode_get_string(dnode, "./level");
1184
1185 vty_print_def_origin(vty, dnode, "ipv6", level, show_defaults);
1186}
1187
a041ac8e
EDP
1188/*
1189 * XPath: /frr-isisd:isis/instance/redistribute
1190 */
1191DEFPY(isis_redistribute, isis_redistribute_cmd,
1192 "[no] redistribute <ipv4|ipv6>$ip " PROTO_REDIST_STR
1193 "$proto"
1194 " <level-1|level-2>$level"
82c25998 1195 " [{metric (0-16777215)|route-map WORD}]",
a041ac8e
EDP
1196 NO_STR REDIST_STR
1197 "Redistribute IPv4 routes\n"
1198 "Redistribute IPv6 routes\n" PROTO_REDIST_HELP
1199 "Redistribute into level-1\n"
1200 "Redistribute into level-2\n"
1201 "Metric for redistributed routes\n"
1202 "ISIS default metric\n"
1203 "Route map reference\n"
1204 "Pointer to route-map entries\n")
1205{
1206 if (no)
95ce849b 1207 nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL);
a041ac8e
EDP
1208 else {
1209 nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
1210 nb_cli_enqueue_change(vty, "./route-map",
95ce849b 1211 route_map ? NB_OP_MODIFY : NB_OP_DESTROY,
a041ac8e 1212 route_map ? route_map : NULL);
82c25998
DT
1213 nb_cli_enqueue_change(vty, "./metric", NB_OP_MODIFY,
1214 metric_str ? metric_str : NULL);
a041ac8e
EDP
1215 }
1216
1217 return nb_cli_apply_changes(
1218 vty, "./redistribute/%s[protocol='%s'][level='%s']", ip, proto,
1219 level);
1220}
1221
1222static void vty_print_redistribute(struct vty *vty, struct lyd_node *dnode,
82c25998 1223 bool show_defaults, const char *family)
a041ac8e
EDP
1224{
1225 const char *level = yang_dnode_get_string(dnode, "./level");
1226 const char *protocol = yang_dnode_get_string(dnode, "./protocol");
1227
1228 vty_out(vty, " redistribute %s %s %s", family, protocol, level);
82c25998 1229 if (show_defaults || !yang_dnode_is_default(dnode, "./metric"))
a041ac8e
EDP
1230 vty_out(vty, " metric %s",
1231 yang_dnode_get_string(dnode, "./metric"));
82c25998 1232 if (yang_dnode_exists(dnode, "./route-map"))
a041ac8e
EDP
1233 vty_out(vty, " route-map %s",
1234 yang_dnode_get_string(dnode, "./route-map"));
1235 vty_out(vty, "\n");
1236}
1237
1238void cli_show_isis_redistribute_ipv4(struct vty *vty, struct lyd_node *dnode,
1239 bool show_defaults)
1240{
82c25998 1241 vty_print_redistribute(vty, dnode, show_defaults, "ipv4");
a041ac8e
EDP
1242}
1243void cli_show_isis_redistribute_ipv6(struct vty *vty, struct lyd_node *dnode,
1244 bool show_defaults)
1245{
82c25998 1246 vty_print_redistribute(vty, dnode, show_defaults, "ipv6");
a041ac8e
EDP
1247}
1248
22af6a80
EDP
1249/*
1250 * XPath: /frr-isisd:isis/instance/multi-topology
1251 */
1252DEFPY(isis_topology, isis_topology_cmd,
1253 "[no] topology "
1254 "<ipv4-unicast"
1255 "|ipv4-mgmt"
1256 "|ipv6-unicast"
1257 "|ipv4-multicast"
1258 "|ipv6-multicast"
1259 "|ipv6-mgmt"
1260 "|ipv6-dstsrc>$topology "
1261 "[overload]$overload",
1262 NO_STR
1263 "Configure IS-IS topologies\n"
1264 "IPv4 unicast topology\n"
1265 "IPv4 management topology\n"
1266 "IPv6 unicast topology\n"
1267 "IPv4 multicast topology\n"
1268 "IPv6 multicast topology\n"
1269 "IPv6 management topology\n"
1270 "IPv6 dst-src topology\n"
1271 "Set overload bit for topology\n")
1272{
1273 char base_xpath[XPATH_MAXLEN];
1274
1275 /* Since IPv4-unicast is not configurable it is not present in the
1276 * YANG model, so we need to validate it here
1277 */
1278 if (strmatch(topology, "ipv4-unicast")) {
1279 vty_out(vty, "Cannot configure IPv4 unicast topology\n");
1280 return CMD_WARNING_CONFIG_FAILED;
1281 }
1282
1283 if (strmatch(topology, "ipv4-mgmt"))
1284 snprintf(base_xpath, XPATH_MAXLEN,
1285 "./multi-topology/ipv4-management");
1286 else if (strmatch(topology, "ipv6-mgmt"))
1287 snprintf(base_xpath, XPATH_MAXLEN,
1288 "./multi-topology/ipv6-management");
1289 else
1290 snprintf(base_xpath, XPATH_MAXLEN, "./multi-topology/%s",
1291 topology);
1292
1293 if (no)
95ce849b 1294 nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL);
22af6a80
EDP
1295 else {
1296 nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
5f1e5e3f
EDP
1297 nb_cli_enqueue_change(vty, "./overload", NB_OP_MODIFY,
1298 overload ? "true" : "false");
22af6a80
EDP
1299 }
1300
1301 return nb_cli_apply_changes(vty, base_xpath);
1302}
1303
1304void cli_show_isis_mt_ipv4_multicast(struct vty *vty, struct lyd_node *dnode,
1305 bool show_defaults)
1306{
1307 vty_out(vty, " topology ipv4-multicast");
5f1e5e3f 1308 if (yang_dnode_get_bool(dnode, "./overload"))
22af6a80
EDP
1309 vty_out(vty, " overload");
1310 vty_out(vty, "\n");
1311}
1312
1313void cli_show_isis_mt_ipv4_mgmt(struct vty *vty, struct lyd_node *dnode,
1314 bool show_defaults)
1315{
1316 vty_out(vty, " topology ipv4-mgmt");
5f1e5e3f 1317 if (yang_dnode_get_bool(dnode, "./overload"))
22af6a80
EDP
1318 vty_out(vty, " overload");
1319 vty_out(vty, "\n");
1320}
1321
1322void cli_show_isis_mt_ipv6_unicast(struct vty *vty, struct lyd_node *dnode,
1323 bool show_defaults)
1324{
1325 vty_out(vty, " topology ipv6-unicast");
5f1e5e3f 1326 if (yang_dnode_get_bool(dnode, "./overload"))
22af6a80
EDP
1327 vty_out(vty, " overload");
1328 vty_out(vty, "\n");
1329}
1330
1331void cli_show_isis_mt_ipv6_multicast(struct vty *vty, struct lyd_node *dnode,
1332 bool show_defaults)
1333{
1334 vty_out(vty, " topology ipv6-multicast");
5f1e5e3f 1335 if (yang_dnode_get_bool(dnode, "./overload"))
22af6a80
EDP
1336 vty_out(vty, " overload");
1337 vty_out(vty, "\n");
1338}
1339
1340void cli_show_isis_mt_ipv6_mgmt(struct vty *vty, struct lyd_node *dnode,
1341 bool show_defaults)
1342{
1343 vty_out(vty, " topology ipv6-mgmt");
5f1e5e3f 1344 if (yang_dnode_get_bool(dnode, "./overload"))
22af6a80
EDP
1345 vty_out(vty, " overload");
1346 vty_out(vty, "\n");
1347}
1348
1349void cli_show_isis_mt_ipv6_dstsrc(struct vty *vty, struct lyd_node *dnode,
1350 bool show_defaults)
1351{
1352 vty_out(vty, " topology ipv6-dstsrc");
5f1e5e3f 1353 if (yang_dnode_get_bool(dnode, "./overload"))
22af6a80
EDP
1354 vty_out(vty, " overload");
1355 vty_out(vty, "\n");
1356}
1357
a6a36c41
EDP
1358/*
1359 * XPath: /frr-interface:lib/interface/frr-isisd:isis/passive
1360 */
1361DEFPY(isis_passive, isis_passive_cmd, "[no] isis passive",
1362 NO_STR
1363 "IS-IS routing protocol\n"
1364 "Configure the passive mode for interface\n")
1365{
5f1e5e3f
EDP
1366 nb_cli_enqueue_change(vty, "./frr-isisd:isis/passive", NB_OP_MODIFY,
1367 no ? "false" : "true");
a6a36c41
EDP
1368
1369 return nb_cli_apply_changes(vty, NULL);
1370}
1371
1372void cli_show_ip_isis_passive(struct vty *vty, struct lyd_node *dnode,
1373 bool show_defaults)
1374{
5f1e5e3f
EDP
1375 if (!yang_dnode_get_bool(dnode, NULL))
1376 vty_out(vty, " no");
a6a36c41
EDP
1377 vty_out(vty, " isis passive\n");
1378}
1379
3e20c83a
EDP
1380/*
1381 * XPath: /frr-interface:lib/interface/frr-isisd:isis/password
1382 */
1383
1384DEFPY(isis_passwd, isis_passwd_cmd, "isis password <md5|clear>$type WORD$pwd",
1385 "IS-IS routing protocol\n"
1386 "Configure the authentication password for a circuit\n"
1387 "HMAC-MD5 authentication\n"
1388 "Cleartext password\n"
1389 "Circuit password\n")
1390{
1391 nb_cli_enqueue_change(vty, "./frr-isisd:isis/password", NB_OP_CREATE,
1392 NULL);
1393 nb_cli_enqueue_change(vty, "./frr-isisd:isis/password/password",
1394 NB_OP_MODIFY, pwd);
1395 nb_cli_enqueue_change(vty, "./frr-isisd:isis/password/password-type",
1396 NB_OP_MODIFY, type);
1397
1398 return nb_cli_apply_changes(vty, NULL);
1399}
1400
1401DEFPY(no_isis_passwd, no_isis_passwd_cmd, "no isis password [<md5|clear> WORD]",
1402 NO_STR
1403 "IS-IS routing protocol\n"
1404 "Configure the authentication password for a circuit\n"
1405 "HMAC-MD5 authentication\n"
1406 "Cleartext password\n"
1407 "Circuit password\n")
1408{
95ce849b 1409 nb_cli_enqueue_change(vty, "./frr-isisd:isis/password", NB_OP_DESTROY,
3e20c83a
EDP
1410 NULL);
1411
1412 return nb_cli_apply_changes(vty, NULL);
1413}
1414
1415void cli_show_ip_isis_password(struct vty *vty, struct lyd_node *dnode,
1416 bool show_defaults)
1417{
1418 vty_out(vty, " isis password %s %s\n",
1419 yang_dnode_get_string(dnode, "./password-type"),
1420 yang_dnode_get_string(dnode, "./password"));
1421}
1422
be49219c
EDP
1423/*
1424 * XPath: /frr-interface:lib/interface/frr-isisd:isis/metric
1425 */
1426DEFPY(isis_metric, isis_metric_cmd,
1427 "isis metric [level-1|level-2]$level (0-16777215)$met",
1428 "IS-IS routing protocol\n"
1429 "Set default metric for circuit\n"
1430 "Specify metric for level-1 routing\n"
1431 "Specify metric for level-2 routing\n"
1432 "Default metric value\n")
1433{
1434 if (!level || strmatch(level, "level-1"))
1435 nb_cli_enqueue_change(vty, "./frr-isisd:isis/metric/level-1",
1436 NB_OP_MODIFY, met_str);
1437 if (!level || strmatch(level, "level-2"))
1438 nb_cli_enqueue_change(vty, "./frr-isisd:isis/metric/level-2",
1439 NB_OP_MODIFY, met_str);
1440
1441 return nb_cli_apply_changes(vty, NULL);
1442}
1443
1444DEFPY(no_isis_metric, no_isis_metric_cmd,
1445 "no isis metric [level-1|level-2]$level [(0-16777215)]",
1446 NO_STR
1447 "IS-IS routing protocol\n"
1448 "Set default metric for circuit\n"
1449 "Specify metric for level-1 routing\n"
1450 "Specify metric for level-2 routing\n"
1451 "Default metric value\n")
1452{
1453 if (!level || strmatch(level, "level-1"))
1454 nb_cli_enqueue_change(vty, "./frr-isisd:isis/metric/level-1",
1455 NB_OP_MODIFY, NULL);
1456 if (!level || strmatch(level, "level-2"))
1457 nb_cli_enqueue_change(vty, "./frr-isisd:isis/metric/level-2",
1458 NB_OP_MODIFY, NULL);
1459
1460 return nb_cli_apply_changes(vty, NULL);
1461}
1462
1463void cli_show_ip_isis_metric(struct vty *vty, struct lyd_node *dnode,
1464 bool show_defaults)
1465{
1466 const char *l1 = yang_dnode_get_string(dnode, "./level-1");
1467 const char *l2 = yang_dnode_get_string(dnode, "./level-2");
1468
1469 if (strmatch(l1, l2))
1470 vty_out(vty, " isis metric %s\n", l1);
1471 else {
d32a4cac
EDP
1472 vty_out(vty, " isis metric level-1 %s\n", l1);
1473 vty_out(vty, " isis metric level-2 %s\n", l2);
be49219c
EDP
1474 }
1475}
1476
356a2e3c
EDP
1477/*
1478 * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/interval
1479 */
1480DEFPY(isis_hello_interval, isis_hello_interval_cmd,
1481 "isis hello-interval [level-1|level-2]$level (1-600)$intv",
1482 "IS-IS routing protocol\n"
1483 "Set Hello interval\n"
1484 "Specify hello-interval for level-1 IIHs\n"
1485 "Specify hello-interval for level-2 IIHs\n"
1486 "Holdtime 1 seconds, interval depends on multiplier\n")
1487{
1488 if (!level || strmatch(level, "level-1"))
1489 nb_cli_enqueue_change(vty,
1490 "./frr-isisd:isis/hello/interval/level-1",
1491 NB_OP_MODIFY, intv_str);
1492 if (!level || strmatch(level, "level-2"))
1493 nb_cli_enqueue_change(vty,
1494 "./frr-isisd:isis/hello/interval/level-2",
1495 NB_OP_MODIFY, intv_str);
1496
1497 return nb_cli_apply_changes(vty, NULL);
1498}
1499
1500DEFPY(no_isis_hello_interval, no_isis_hello_interval_cmd,
1501 "no isis hello-interval [level-1|level-2]$level [(1-600)]",
1502 NO_STR
1503 "IS-IS routing protocol\n"
1504 "Set Hello interval\n"
1505 "Specify hello-interval for level-1 IIHs\n"
1506 "Specify hello-interval for level-2 IIHs\n"
1507 "Holdtime 1 second, interval depends on multiplier\n")
1508{
1509 if (!level || strmatch(level, "level-1"))
1510 nb_cli_enqueue_change(vty,
1511 "./frr-isisd:isis/hello/interval/level-1",
1512 NB_OP_MODIFY, NULL);
1513 if (!level || strmatch(level, "level-2"))
1514 nb_cli_enqueue_change(vty,
1515 "./frr-isisd:isis/hello/interval/level-2",
1516 NB_OP_MODIFY, NULL);
1517
1518 return nb_cli_apply_changes(vty, NULL);
1519}
1520
1521void cli_show_ip_isis_hello_interval(struct vty *vty, struct lyd_node *dnode,
1522 bool show_defaults)
1523{
1524 const char *l1 = yang_dnode_get_string(dnode, "./level-1");
1525 const char *l2 = yang_dnode_get_string(dnode, "./level-2");
1526
1527 if (strmatch(l1, l2))
1528 vty_out(vty, " isis hello-interval %s\n", l1);
1529 else {
249312ab
EDP
1530 vty_out(vty, " isis hello-interval level-1 %s\n", l1);
1531 vty_out(vty, " isis hello-interval level-2 %s\n", l2);
356a2e3c
EDP
1532 }
1533}
1534
4e75a67d
EDP
1535/*
1536 * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/multiplier
1537 */
1538DEFPY(isis_hello_multiplier, isis_hello_multiplier_cmd,
1539 "isis hello-multiplier [level-1|level-2]$level (2-100)$mult",
1540 "IS-IS routing protocol\n"
1541 "Set multiplier for Hello holding time\n"
1542 "Specify hello multiplier for level-1 IIHs\n"
1543 "Specify hello multiplier for level-2 IIHs\n"
1544 "Hello multiplier value\n")
1545{
1546 if (!level || strmatch(level, "level-1"))
1547 nb_cli_enqueue_change(
1548 vty, "./frr-isisd:isis/hello/multiplier/level-1",
1549 NB_OP_MODIFY, mult_str);
1550 if (!level || strmatch(level, "level-2"))
1551 nb_cli_enqueue_change(
1552 vty, "./frr-isisd:isis/hello/multiplier/level-2",
1553 NB_OP_MODIFY, mult_str);
1554
1555 return nb_cli_apply_changes(vty, NULL);
1556}
1557
1558DEFPY(no_isis_hello_multiplier, no_isis_hello_multiplier_cmd,
1559 "no isis hello-multiplier [level-1|level-2]$level [(2-100)]",
1560 NO_STR
1561 "IS-IS routing protocol\n"
1562 "Set multiplier for Hello holding time\n"
1563 "Specify hello multiplier for level-1 IIHs\n"
1564 "Specify hello multiplier for level-2 IIHs\n"
1565 "Hello multiplier value\n")
1566{
1567 if (!level || strmatch(level, "level-1"))
1568 nb_cli_enqueue_change(
1569 vty, "./frr-isisd:isis/hello/multiplier/level-1",
1570 NB_OP_MODIFY, NULL);
1571 if (!level || strmatch(level, "level-2"))
1572 nb_cli_enqueue_change(
1573 vty, "./frr-isisd:isis/hello/multiplier/level-2",
1574 NB_OP_MODIFY, NULL);
1575
1576 return nb_cli_apply_changes(vty, NULL);
1577}
1578
1579void cli_show_ip_isis_hello_multi(struct vty *vty, struct lyd_node *dnode,
1580 bool show_defaults)
1581{
1582 const char *l1 = yang_dnode_get_string(dnode, "./level-1");
1583 const char *l2 = yang_dnode_get_string(dnode, "./level-2");
1584
1585 if (strmatch(l1, l2))
1586 vty_out(vty, " isis hello-multiplier %s\n", l1);
1587 else {
249312ab
EDP
1588 vty_out(vty, " isis hello-multiplier level-1 %s\n", l1);
1589 vty_out(vty, " isis hello-multiplier level-2 %s\n", l2);
4e75a67d
EDP
1590 }
1591}
1592
5f2ce446
EDP
1593/*
1594 * XPath:
1595 * /frr-interface:lib/interface/frr-isisd:isis/disable-three-way-handshake
1596 */
1597DEFPY(isis_threeway_adj, isis_threeway_adj_cmd, "[no] isis three-way-handshake",
1598 NO_STR
1599 "IS-IS commands\n"
1600 "Enable/Disable three-way handshake\n")
1601{
1602 nb_cli_enqueue_change(vty,
1603 "./frr-isisd:isis/disable-three-way-handshake",
5f1e5e3f 1604 NB_OP_MODIFY, no ? "true" : "false");
5f2ce446
EDP
1605
1606 return nb_cli_apply_changes(vty, NULL);
1607}
1608
1609void cli_show_ip_isis_threeway_shake(struct vty *vty, struct lyd_node *dnode,
1610 bool show_defaults)
1611{
5f1e5e3f
EDP
1612 if (yang_dnode_get_bool(dnode, NULL))
1613 vty_out(vty, " no");
1614 vty_out(vty, " isis three-way-handshake\n");
5f2ce446
EDP
1615}
1616
7b6b75e5
EDP
1617/*
1618 * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/padding
1619 */
1620DEFPY(isis_hello_padding, isis_hello_padding_cmd, "[no] isis hello padding",
1621 NO_STR
1622 "IS-IS routing protocol\n"
1623 "Add padding to IS-IS hello packets\n"
1624 "Pad hello packets\n")
1625{
1626 nb_cli_enqueue_change(vty, "./frr-isisd:isis/hello/padding",
1627 NB_OP_MODIFY, no ? "false" : "true");
1628
1629 return nb_cli_apply_changes(vty, NULL);
1630}
1631
1632void cli_show_ip_isis_hello_padding(struct vty *vty, struct lyd_node *dnode,
1633 bool show_defaults)
1634{
1635 if (!yang_dnode_get_bool(dnode, NULL))
1636 vty_out(vty, " no");
1637
1638 vty_out(vty, " isis hello padding\n");
1639}
1640
9ce808b9
EDP
1641/*
1642 * XPath: /frr-interface:lib/interface/frr-isisd:isis/csnp-interval
1643 */
1644DEFPY(csnp_interval, csnp_interval_cmd,
1645 "isis csnp-interval (1-600)$intv [level-1|level-2]$level",
1646 "IS-IS routing protocol\n"
1647 "Set CSNP interval in seconds\n"
1648 "CSNP interval value\n"
1649 "Specify interval for level-1 CSNPs\n"
1650 "Specify interval for level-2 CSNPs\n")
1651{
1652 if (!level || strmatch(level, "level-1"))
1653 nb_cli_enqueue_change(vty,
1654 "./frr-isisd:isis/csnp-interval/level-1",
1655 NB_OP_MODIFY, intv_str);
1656 if (!level || strmatch(level, "level-2"))
1657 nb_cli_enqueue_change(vty,
1658 "./frr-isisd:isis/csnp-interval/level-2",
1659 NB_OP_MODIFY, intv_str);
1660
1661 return nb_cli_apply_changes(vty, NULL);
1662}
1663
1664DEFPY(no_csnp_interval, no_csnp_interval_cmd,
1665 "no isis csnp-interval [(1-600)] [level-1|level-2]$level",
1666 NO_STR
1667 "IS-IS routing protocol\n"
1668 "Set CSNP interval in seconds\n"
1669 "CSNP interval value\n"
1670 "Specify interval for level-1 CSNPs\n"
1671 "Specify interval for level-2 CSNPs\n")
1672{
1673 if (!level || strmatch(level, "level-1"))
1674 nb_cli_enqueue_change(vty,
1675 "./frr-isisd:isis/csnp-interval/level-1",
1676 NB_OP_MODIFY, NULL);
1677 if (!level || strmatch(level, "level-2"))
1678 nb_cli_enqueue_change(vty,
1679 "./frr-isisd:isis/csnp-interval/level-2",
1680 NB_OP_MODIFY, NULL);
1681
1682 return nb_cli_apply_changes(vty, NULL);
1683}
1684
1685void cli_show_ip_isis_csnp_interval(struct vty *vty, struct lyd_node *dnode,
1686 bool show_defaults)
1687{
1688 const char *l1 = yang_dnode_get_string(dnode, "./level-1");
1689 const char *l2 = yang_dnode_get_string(dnode, "./level-2");
1690
1691 if (strmatch(l1, l2))
1692 vty_out(vty, " isis csnp-interval %s\n", l1);
1693 else {
1694 vty_out(vty, " isis csnp-interval %s level-1\n", l1);
1695 vty_out(vty, " isis csnp-interval %s level-2\n", l2);
1696 }
1697}
1698
1699/*
1700 * XPath: /frr-interface:lib/interface/frr-isisd:isis/psnp-interval
1701 */
1702DEFPY(psnp_interval, psnp_interval_cmd,
1703 "isis psnp-interval (1-120)$intv [level-1|level-2]$level",
1704 "IS-IS routing protocol\n"
1705 "Set PSNP interval in seconds\n"
1706 "PSNP interval value\n"
1707 "Specify interval for level-1 PSNPs\n"
1708 "Specify interval for level-2 PSNPs\n")
1709{
1710 if (!level || strmatch(level, "level-1"))
1711 nb_cli_enqueue_change(vty,
1712 "./frr-isisd:isis/psnp-interval/level-1",
1713 NB_OP_MODIFY, intv_str);
1714 if (!level || strmatch(level, "level-2"))
1715 nb_cli_enqueue_change(vty,
1716 "./frr-isisd:isis/psnp-interval/level-2",
1717 NB_OP_MODIFY, intv_str);
1718
1719 return nb_cli_apply_changes(vty, NULL);
1720}
1721
1722DEFPY(no_psnp_interval, no_psnp_interval_cmd,
1723 "no isis psnp-interval [(1-120)] [level-1|level-2]$level",
1724 NO_STR
1725 "IS-IS routing protocol\n"
1726 "Set PSNP interval in seconds\n"
1727 "PSNP interval value\n"
1728 "Specify interval for level-1 PSNPs\n"
1729 "Specify interval for level-2 PSNPs\n")
1730{
1731 if (!level || strmatch(level, "level-1"))
1732 nb_cli_enqueue_change(vty,
1733 "./frr-isisd:isis/psnp-interval/level-1",
1734 NB_OP_MODIFY, NULL);
1735 if (!level || strmatch(level, "level-2"))
1736 nb_cli_enqueue_change(vty,
1737 "./frr-isisd:isis/psnp-interval/level-2",
1738 NB_OP_MODIFY, NULL);
1739
1740 return nb_cli_apply_changes(vty, NULL);
1741}
1742
1743void cli_show_ip_isis_psnp_interval(struct vty *vty, struct lyd_node *dnode,
1744 bool show_defaults)
1745{
1746 const char *l1 = yang_dnode_get_string(dnode, "./level-1");
1747 const char *l2 = yang_dnode_get_string(dnode, "./level-2");
1748
1749 if (strmatch(l1, l2))
1750 vty_out(vty, " isis psnp-interval %s\n", l1);
1751 else {
1752 vty_out(vty, " isis psnp-interval %s level-1\n", l1);
1753 vty_out(vty, " isis psnp-interval %s level-2\n", l2);
1754 }
1755}
1756
83d043f6
EDP
1757/*
1758 * XPath: /frr-interface:lib/interface/frr-isisd:isis/multi-topology
1759 */
1760DEFPY(circuit_topology, circuit_topology_cmd,
1761 "[no] isis topology"
1762 "<ipv4-unicast"
1763 "|ipv4-mgmt"
1764 "|ipv6-unicast"
1765 "|ipv4-multicast"
1766 "|ipv6-multicast"
1767 "|ipv6-mgmt"
1768 "|ipv6-dstsrc"
1769 ">$topology",
1770 NO_STR
1771 "IS-IS routing protocol\n"
1772 "Configure interface IS-IS topologies\n"
1773 "IPv4 unicast topology\n"
1774 "IPv4 management topology\n"
1775 "IPv6 unicast topology\n"
1776 "IPv4 multicast topology\n"
1777 "IPv6 multicast topology\n"
1778 "IPv6 management topology\n"
1779 "IPv6 dst-src topology\n")
1780{
1781 nb_cli_enqueue_change(vty, ".", NB_OP_MODIFY, no ? "false" : "true");
1782
1783 if (strmatch(topology, "ipv4-mgmt"))
1784 return nb_cli_apply_changes(
1785 vty, "./frr-isisd:isis/multi-topology/ipv4-management");
1786 else if (strmatch(topology, "ipv6-mgmt"))
1787 return nb_cli_apply_changes(
1788 vty, "./frr-isisd:isis/multi-topology/ipv6-management");
1789 else
1790 return nb_cli_apply_changes(
1791 vty, "./frr-isisd:isis/multi-topology/%s", topology);
1792}
1793
1794void cli_show_ip_isis_mt_ipv4_unicast(struct vty *vty, struct lyd_node *dnode,
1795 bool show_defaults)
1796{
1797 if (!yang_dnode_get_bool(dnode, NULL))
1798 vty_out(vty, " no");
1799 vty_out(vty, " isis topology ipv4-unicast\n");
1800}
1801
1802void cli_show_ip_isis_mt_ipv4_multicast(struct vty *vty, struct lyd_node *dnode,
1803 bool show_defaults)
1804{
1805 if (!yang_dnode_get_bool(dnode, NULL))
1806 vty_out(vty, " no");
1807 vty_out(vty, " isis topology ipv4-multicast\n");
1808}
1809
1810void cli_show_ip_isis_mt_ipv4_mgmt(struct vty *vty, struct lyd_node *dnode,
1811 bool show_defaults)
1812{
1813 if (!yang_dnode_get_bool(dnode, NULL))
1814 vty_out(vty, " no");
1815 vty_out(vty, " isis topology ipv4-mgmt\n");
1816}
1817
1818void cli_show_ip_isis_mt_ipv6_unicast(struct vty *vty, struct lyd_node *dnode,
1819 bool show_defaults)
1820{
1821 if (!yang_dnode_get_bool(dnode, NULL))
1822 vty_out(vty, " no");
1823 vty_out(vty, " isis topology ipv6-unicast\n");
1824}
1825
1826void cli_show_ip_isis_mt_ipv6_multicast(struct vty *vty, struct lyd_node *dnode,
1827 bool show_defaults)
1828{
1829 if (!yang_dnode_get_bool(dnode, NULL))
1830 vty_out(vty, " no");
1831 vty_out(vty, " isis topology ipv6-multicast\n");
1832}
1833
1834void cli_show_ip_isis_mt_ipv6_mgmt(struct vty *vty, struct lyd_node *dnode,
1835 bool show_defaults)
1836{
1837 if (!yang_dnode_get_bool(dnode, NULL))
1838 vty_out(vty, " no");
1839 vty_out(vty, " isis topology ipv6-mgmt\n");
1840}
1841
1842void cli_show_ip_isis_mt_ipv6_dstsrc(struct vty *vty, struct lyd_node *dnode,
1843 bool show_defaults)
1844{
1845 if (!yang_dnode_get_bool(dnode, NULL))
1846 vty_out(vty, " no");
1847 vty_out(vty, " isis topology ipv6-dstsrc\n");
1848}
1849
9302fbb6
EDP
1850/*
1851 * XPath: /frr-interface:lib/interface/frr-isisd:isis/circuit-type
1852 */
1853DEFPY(isis_circuit_type, isis_circuit_type_cmd,
1854 "isis circuit-type <level-1|level-1-2|level-2-only>$type",
1855 "IS-IS routing protocol\n"
1856 "Configure circuit type for interface\n"
1857 "Level-1 only adjacencies are formed\n"
1858 "Level-1-2 adjacencies are formed\n"
1859 "Level-2 only adjacencies are formed\n")
1860{
1861 nb_cli_enqueue_change(
1862 vty, "./frr-isisd:isis/circuit-type", NB_OP_MODIFY,
1863 strmatch(type, "level-2-only") ? "level-2" : type);
1864
1865 return nb_cli_apply_changes(vty, NULL);
1866}
1867
1868DEFPY(no_isis_circuit_type, no_isis_circuit_type_cmd,
1869 "no isis circuit-type [level-1|level-1-2|level-2-only]",
1870 NO_STR
1871 "IS-IS routing protocol\n"
1872 "Configure circuit type for interface\n"
1873 "Level-1 only adjacencies are formed\n"
1874 "Level-1-2 adjacencies are formed\n"
1875 "Level-2 only adjacencies are formed\n")
1876{
8685be73
RW
1877 struct interface *ifp;
1878 struct isis_circuit *circuit;
1879 int is_type;
1880 const char *circ_type;
9302fbb6
EDP
1881
1882 /*
1883 * Default value depends on whether the circuit is part of an area,
1884 * and the is-type of the area if there is one. So we need to do this
1885 * here.
1886 */
8685be73
RW
1887 ifp = nb_running_get_entry(NULL, VTY_CURR_XPATH, false);
1888 if (!ifp)
1889 goto def_val;
9302fbb6 1890
8685be73
RW
1891 circuit = circuit_scan_by_ifp(ifp);
1892 if (!circuit)
1893 goto def_val;
9302fbb6 1894
8685be73
RW
1895 if (circuit->state == C_STATE_UP)
1896 is_type = circuit->area->is_type;
1897 else
1898 goto def_val;
9302fbb6 1899
8685be73
RW
1900 switch (is_type) {
1901 case IS_LEVEL_1:
1902 circ_type = "level-1";
1903 break;
1904 case IS_LEVEL_2:
1905 circ_type = "level-2";
1906 break;
1907 case IS_LEVEL_1_AND_2:
1908 circ_type = "level-1-2";
1909 break;
1910 default:
1911 return CMD_ERR_NO_MATCH;
9302fbb6 1912 }
9302fbb6 1913 nb_cli_enqueue_change(vty, "./frr-isisd:isis/circuit-type",
83981138 1914 NB_OP_MODIFY, circ_type);
9302fbb6
EDP
1915
1916 return nb_cli_apply_changes(vty, NULL);
8685be73
RW
1917
1918def_val:
1919 nb_cli_enqueue_change(vty, "./frr-isisd:isis/circuit-type",
1920 NB_OP_MODIFY, NULL);
1921
1922 return nb_cli_apply_changes(vty, NULL);
9302fbb6
EDP
1923}
1924
1925void cli_show_ip_isis_circ_type(struct vty *vty, struct lyd_node *dnode,
1926 bool show_defaults)
1927{
1928 int level = yang_dnode_get_enum(dnode, NULL);
1929
1930 switch (level) {
1931 case IS_LEVEL_1:
1932 vty_out(vty, " isis circuit-type level-1\n");
1933 break;
1934 case IS_LEVEL_2:
1935 vty_out(vty, " isis circuit-type level-2-only\n");
1936 break;
1937 case IS_LEVEL_1_AND_2:
1938 vty_out(vty, " isis circuit-type level-1-2\n");
1939 break;
1940 }
1941}
1942
d0820765
EDP
1943/*
1944 * XPath: /frr-interface:lib/interface/frr-isisd:isis/network-type
1945 */
1946DEFPY(isis_network, isis_network_cmd, "[no] isis network point-to-point",
1947 NO_STR
1948 "IS-IS routing protocol\n"
1949 "Set network type\n"
1950 "point-to-point network type\n")
1951{
1952 nb_cli_enqueue_change(vty, "./frr-isisd:isis/network-type",
1953 NB_OP_MODIFY,
1954 no ? "broadcast" : "point-to-point");
1955
1956 return nb_cli_apply_changes(vty, NULL);
1957}
1958
1959void cli_show_ip_isis_network_type(struct vty *vty, struct lyd_node *dnode,
1960 bool show_defaults)
1961{
1962 if (yang_dnode_get_enum(dnode, NULL) != CIRCUIT_T_P2P)
1963 vty_out(vty, " no");
1964
1965 vty_out(vty, " isis network point-to-point\n");
1966}
1967
d59c2d6b
EDP
1968/*
1969 * XPath: /frr-interface:lib/interface/frr-isisd:isis/priority
1970 */
1971DEFPY(isis_priority, isis_priority_cmd,
1972 "isis priority (0-127)$prio [level-1|level-2]$level",
1973 "IS-IS routing protocol\n"
1974 "Set priority for Designated Router election\n"
1975 "Priority value\n"
1976 "Specify priority for level-1 routing\n"
1977 "Specify priority for level-2 routing\n")
1978{
1979 if (!level || strmatch(level, "level-1"))
1980 nb_cli_enqueue_change(vty, "./frr-isisd:isis/priority/level-1",
1981 NB_OP_MODIFY, prio_str);
1982 if (!level || strmatch(level, "level-2"))
1983 nb_cli_enqueue_change(vty, "./frr-isisd:isis/priority/level-2",
1984 NB_OP_MODIFY, prio_str);
1985
1986 return nb_cli_apply_changes(vty, NULL);
1987}
1988
1989DEFPY(no_isis_priority, no_isis_priority_cmd,
1990 "no isis priority [(0-127)] [level-1|level-2]$level",
1991 NO_STR
1992 "IS-IS routing protocol\n"
1993 "Set priority for Designated Router election\n"
1994 "Priority value\n"
1995 "Specify priority for level-1 routing\n"
1996 "Specify priority for level-2 routing\n")
1997{
1998 if (!level || strmatch(level, "level-1"))
1999 nb_cli_enqueue_change(vty, "./frr-isisd:isis/priority/level-1",
2000 NB_OP_MODIFY, NULL);
2001 if (!level || strmatch(level, "level-2"))
2002 nb_cli_enqueue_change(vty, "./frr-isisd:isis/priority/level-2",
2003 NB_OP_MODIFY, NULL);
2004
2005 return nb_cli_apply_changes(vty, NULL);
2006}
2007
2008void cli_show_ip_isis_priority(struct vty *vty, struct lyd_node *dnode,
2009 bool show_defaults)
2010{
2011 const char *l1 = yang_dnode_get_string(dnode, "./level-1");
2012 const char *l2 = yang_dnode_get_string(dnode, "./level-2");
2013
2014 if (strmatch(l1, l2))
2015 vty_out(vty, " isis priority %s\n", l1);
2016 else {
2017 vty_out(vty, " isis priority %s level-1\n", l1);
2018 vty_out(vty, " isis priority %s level-2\n", l2);
2019 }
2020}
2021
2adf66ff
EDP
2022/*
2023 * XPath: /frr-isisd:isis/instance/log-adjacency-changes
2024 */
2025DEFPY(log_adj_changes, log_adj_changes_cmd, "[no] log-adjacency-changes",
2026 NO_STR "Log changes in adjacency state\n")
2027{
5f1e5e3f
EDP
2028 nb_cli_enqueue_change(vty, "./log-adjacency-changes", NB_OP_MODIFY,
2029 no ? "false" : "true");
2adf66ff
EDP
2030
2031 return nb_cli_apply_changes(vty, NULL);
2032}
2033
2034void cli_show_isis_log_adjacency(struct vty *vty, struct lyd_node *dnode,
2035 bool show_defaults)
2036{
5f1e5e3f
EDP
2037 if (!yang_dnode_get_bool(dnode, NULL))
2038 vty_out(vty, " no");
2adf66ff
EDP
2039 vty_out(vty, " log-adjacency-changes\n");
2040}
2041
20bd27e2
EDP
2042void isis_cli_init(void)
2043{
aaf2fd21
EDP
2044 install_element(CONFIG_NODE, &router_isis_cmd);
2045 install_element(CONFIG_NODE, &no_router_isis_cmd);
2046
2047 install_element(INTERFACE_NODE, &ip_router_isis_cmd);
2048 install_element(INTERFACE_NODE, &ip6_router_isis_cmd);
2049 install_element(INTERFACE_NODE, &no_ip_router_isis_cmd);
c3e6ac0b 2050 install_element(INTERFACE_NODE, &isis_bfd_cmd);
f084ea55
EDP
2051
2052 install_element(ISIS_NODE, &net_cmd);
e6bdae69
EDP
2053
2054 install_element(ISIS_NODE, &is_type_cmd);
2055 install_element(ISIS_NODE, &no_is_type_cmd);
6bb043cd
EDP
2056
2057 install_element(ISIS_NODE, &dynamic_hostname_cmd);
05a3f9f0
EDP
2058
2059 install_element(ISIS_NODE, &set_overload_bit_cmd);
2060 install_element(ISIS_NODE, &set_attached_bit_cmd);
e0df3206
EDP
2061
2062 install_element(ISIS_NODE, &metric_style_cmd);
2063 install_element(ISIS_NODE, &no_metric_style_cmd);
933536e3
EDP
2064
2065 install_element(ISIS_NODE, &area_passwd_cmd);
2066 install_element(ISIS_NODE, &domain_passwd_cmd);
2067 install_element(ISIS_NODE, &no_area_passwd_cmd);
1d6fe72e
EDP
2068
2069 install_element(ISIS_NODE, &lsp_gen_interval_cmd);
2070 install_element(ISIS_NODE, &no_lsp_gen_interval_cmd);
7e869004
EDP
2071 install_element(ISIS_NODE, &lsp_refresh_interval_cmd);
2072 install_element(ISIS_NODE, &no_lsp_refresh_interval_cmd);
ea120aa0
EDP
2073 install_element(ISIS_NODE, &max_lsp_lifetime_cmd);
2074 install_element(ISIS_NODE, &no_max_lsp_lifetime_cmd);
d2c970ff
EDP
2075 install_element(ISIS_NODE, &lsp_timers_cmd);
2076 install_element(ISIS_NODE, &no_lsp_timers_cmd);
27a45d16
EDP
2077 install_element(ISIS_NODE, &area_lsp_mtu_cmd);
2078 install_element(ISIS_NODE, &no_area_lsp_mtu_cmd);
dcb1dcd6
EDP
2079
2080 install_element(ISIS_NODE, &spf_interval_cmd);
2081 install_element(ISIS_NODE, &no_spf_interval_cmd);
5336ba30
EDP
2082 install_element(ISIS_NODE, &spf_delay_ietf_cmd);
2083 install_element(ISIS_NODE, &no_spf_delay_ietf_cmd);
66e45e10
EDP
2084
2085 install_element(ISIS_NODE, &area_purge_originator_cmd);
d1a80ef6
EDP
2086
2087 install_element(ISIS_NODE, &isis_mpls_te_on_cmd);
2088 install_element(ISIS_NODE, &no_isis_mpls_te_on_cmd);
2089 install_element(ISIS_NODE, &isis_mpls_te_router_addr_cmd);
2e2a8b91 2090 install_element(ISIS_NODE, &no_isis_mpls_te_router_addr_cmd);
d1a80ef6 2091 install_element(ISIS_NODE, &isis_mpls_te_inter_as_cmd);
8b104c10
EDP
2092
2093 install_element(ISIS_NODE, &isis_default_originate_cmd);
a041ac8e 2094 install_element(ISIS_NODE, &isis_redistribute_cmd);
22af6a80
EDP
2095
2096 install_element(ISIS_NODE, &isis_topology_cmd);
a6a36c41
EDP
2097
2098 install_element(INTERFACE_NODE, &isis_passive_cmd);
3e20c83a
EDP
2099
2100 install_element(INTERFACE_NODE, &isis_passwd_cmd);
2101 install_element(INTERFACE_NODE, &no_isis_passwd_cmd);
be49219c
EDP
2102
2103 install_element(INTERFACE_NODE, &isis_metric_cmd);
2104 install_element(INTERFACE_NODE, &no_isis_metric_cmd);
356a2e3c
EDP
2105
2106 install_element(INTERFACE_NODE, &isis_hello_interval_cmd);
2107 install_element(INTERFACE_NODE, &no_isis_hello_interval_cmd);
4e75a67d
EDP
2108
2109 install_element(INTERFACE_NODE, &isis_hello_multiplier_cmd);
2110 install_element(INTERFACE_NODE, &no_isis_hello_multiplier_cmd);
5f2ce446
EDP
2111
2112 install_element(INTERFACE_NODE, &isis_threeway_adj_cmd);
7b6b75e5
EDP
2113
2114 install_element(INTERFACE_NODE, &isis_hello_padding_cmd);
9ce808b9
EDP
2115
2116 install_element(INTERFACE_NODE, &csnp_interval_cmd);
2117 install_element(INTERFACE_NODE, &no_csnp_interval_cmd);
2118
2119 install_element(INTERFACE_NODE, &psnp_interval_cmd);
2120 install_element(INTERFACE_NODE, &no_psnp_interval_cmd);
83d043f6
EDP
2121
2122 install_element(INTERFACE_NODE, &circuit_topology_cmd);
9302fbb6
EDP
2123
2124 install_element(INTERFACE_NODE, &isis_circuit_type_cmd);
2125 install_element(INTERFACE_NODE, &no_isis_circuit_type_cmd);
d0820765
EDP
2126
2127 install_element(INTERFACE_NODE, &isis_network_cmd);
d59c2d6b
EDP
2128
2129 install_element(INTERFACE_NODE, &isis_priority_cmd);
2130 install_element(INTERFACE_NODE, &no_isis_priority_cmd);
2adf66ff
EDP
2131
2132 install_element(ISIS_NODE, &log_adj_changes_cmd);
20bd27e2
EDP
2133}
2134
2135#endif /* ifndef FABRICD */