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