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