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