]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_cli.c
Merge pull request #4232 from mjstapp/fix_topotests_py3
[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/instance/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, "./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 "Disable the MPLS-TE functionality\n")
946 {
947 nb_cli_enqueue_change(vty, "./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/instance/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, "./mpls-te/router-address",
969 NB_OP_MODIFY, router_address_str);
970
971 return nb_cli_apply_changes(vty, NULL);
972 }
973
974 DEFPY(no_isis_mpls_te_router_addr, no_isis_mpls_te_router_addr_cmd,
975 "no mpls-te router-address [A.B.C.D]",
976 NO_STR MPLS_TE_STR
977 "Delete IP address of the advertising router\n"
978 "MPLS-TE router address in IPv4 address format\n")
979 {
980 nb_cli_enqueue_change(vty, "./mpls-te/router-address",
981 NB_OP_DESTROY, NULL);
982
983 return nb_cli_apply_changes(vty, NULL);
984 }
985
986 void cli_show_isis_mpls_te_router_addr(struct vty *vty, struct lyd_node *dnode,
987 bool show_defaults)
988 {
989 vty_out(vty, " mpls-te router-address %s\n",
990 yang_dnode_get_string(dnode, NULL));
991 }
992
993 DEFPY(isis_mpls_te_inter_as, isis_mpls_te_inter_as_cmd,
994 "[no] mpls-te inter-as [level-1|level-1-2|level-2-only]",
995 NO_STR MPLS_TE_STR
996 "Configure MPLS-TE Inter-AS support\n"
997 "AREA native mode self originate INTER-AS LSP with L1 only flooding scope\n"
998 "AREA native mode self originate INTER-AS LSP with L1 and L2 flooding scope\n"
999 "AS native mode self originate INTER-AS LSP with L2 only flooding scope\n")
1000 {
1001 vty_out(vty, "MPLS-TE Inter-AS is not yet supported\n");
1002 return CMD_SUCCESS;
1003 }
1004
1005 /*
1006 * XPath: /frr-isisd:isis/instance/default-information-originate
1007 */
1008 DEFPY(isis_default_originate, isis_default_originate_cmd,
1009 "[no] default-information originate <ipv4|ipv6>$ip"
1010 " <level-1|level-2>$level [always]$always"
1011 " [{metric (0-16777215)$metric|route-map WORD$rmap}]",
1012 NO_STR
1013 "Control distribution of default information\n"
1014 "Distribute a default route\n"
1015 "Distribute default route for IPv4\n"
1016 "Distribute default route for IPv6\n"
1017 "Distribute default route into level-1\n"
1018 "Distribute default route into level-2\n"
1019 "Always advertise default route\n"
1020 "Metric for default route\n"
1021 "ISIS default metric\n"
1022 "Route map reference\n"
1023 "Pointer to route-map entries\n")
1024 {
1025 if (no)
1026 nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL);
1027 else {
1028 nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
1029 nb_cli_enqueue_change(vty, "./always", NB_OP_MODIFY,
1030 always ? "true" : "false");
1031 nb_cli_enqueue_change(vty, "./route-map",
1032 rmap ? NB_OP_MODIFY : NB_OP_DESTROY,
1033 rmap ? rmap : NULL);
1034 nb_cli_enqueue_change(vty, "./metric", NB_OP_MODIFY,
1035 metric_str ? metric_str : NULL);
1036 if (strmatch(ip, "ipv6") && !always) {
1037 vty_out(vty,
1038 "Zebra doesn't implement default-originate for IPv6 yet\n");
1039 vty_out(vty,
1040 "so use with care or use default-originate always.\n");
1041 }
1042 }
1043
1044 return nb_cli_apply_changes(
1045 vty, "./default-information-originate/%s[level='%s']", ip,
1046 level);
1047 }
1048
1049 static void vty_print_def_origin(struct vty *vty, struct lyd_node *dnode,
1050 const char *family, const char *level,
1051 bool show_defaults)
1052 {
1053 vty_out(vty, " default-information originate %s %s", family, level);
1054 if (yang_dnode_get_bool(dnode, "./always"))
1055 vty_out(vty, " always");
1056
1057 if (yang_dnode_exists(dnode, "./route-map"))
1058 vty_out(vty, " route-map %s",
1059 yang_dnode_get_string(dnode, "./route-map"));
1060 if (show_defaults || !yang_dnode_is_default(dnode, "./metric"))
1061 vty_out(vty, " metric %s",
1062 yang_dnode_get_string(dnode, "./metric"));
1063
1064 vty_out(vty, "\n");
1065 }
1066
1067 void cli_show_isis_def_origin_ipv4(struct vty *vty, struct lyd_node *dnode,
1068 bool show_defaults)
1069 {
1070 const char *level = yang_dnode_get_string(dnode, "./level");
1071
1072 vty_print_def_origin(vty, dnode, "ipv4", level, show_defaults);
1073 }
1074
1075 void cli_show_isis_def_origin_ipv6(struct vty *vty, struct lyd_node *dnode,
1076 bool show_defaults)
1077 {
1078 const char *level = yang_dnode_get_string(dnode, "./level");
1079
1080 vty_print_def_origin(vty, dnode, "ipv6", level, show_defaults);
1081 }
1082
1083 /*
1084 * XPath: /frr-isisd:isis/instance/redistribute
1085 */
1086 DEFPY(isis_redistribute, isis_redistribute_cmd,
1087 "[no] redistribute <ipv4|ipv6>$ip " PROTO_REDIST_STR
1088 "$proto"
1089 " <level-1|level-2>$level"
1090 " [{metric (0-16777215)|route-map WORD}]",
1091 NO_STR REDIST_STR
1092 "Redistribute IPv4 routes\n"
1093 "Redistribute IPv6 routes\n" PROTO_REDIST_HELP
1094 "Redistribute into level-1\n"
1095 "Redistribute into level-2\n"
1096 "Metric for redistributed routes\n"
1097 "ISIS default metric\n"
1098 "Route map reference\n"
1099 "Pointer to route-map entries\n")
1100 {
1101 if (no)
1102 nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL);
1103 else {
1104 nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
1105 nb_cli_enqueue_change(vty, "./route-map",
1106 route_map ? NB_OP_MODIFY : NB_OP_DESTROY,
1107 route_map ? route_map : NULL);
1108 nb_cli_enqueue_change(vty, "./metric", NB_OP_MODIFY,
1109 metric_str ? metric_str : NULL);
1110 }
1111
1112 return nb_cli_apply_changes(
1113 vty, "./redistribute/%s[protocol='%s'][level='%s']", ip, proto,
1114 level);
1115 }
1116
1117 static void vty_print_redistribute(struct vty *vty, struct lyd_node *dnode,
1118 bool show_defaults, const char *family)
1119 {
1120 const char *level = yang_dnode_get_string(dnode, "./level");
1121 const char *protocol = yang_dnode_get_string(dnode, "./protocol");
1122
1123 vty_out(vty, " redistribute %s %s %s", family, protocol, level);
1124 if (show_defaults || !yang_dnode_is_default(dnode, "./metric"))
1125 vty_out(vty, " metric %s",
1126 yang_dnode_get_string(dnode, "./metric"));
1127 if (yang_dnode_exists(dnode, "./route-map"))
1128 vty_out(vty, " route-map %s",
1129 yang_dnode_get_string(dnode, "./route-map"));
1130 vty_out(vty, "\n");
1131 }
1132
1133 void cli_show_isis_redistribute_ipv4(struct vty *vty, struct lyd_node *dnode,
1134 bool show_defaults)
1135 {
1136 vty_print_redistribute(vty, dnode, show_defaults, "ipv4");
1137 }
1138 void cli_show_isis_redistribute_ipv6(struct vty *vty, struct lyd_node *dnode,
1139 bool show_defaults)
1140 {
1141 vty_print_redistribute(vty, dnode, show_defaults, "ipv6");
1142 }
1143
1144 /*
1145 * XPath: /frr-isisd:isis/instance/multi-topology
1146 */
1147 DEFPY(isis_topology, isis_topology_cmd,
1148 "[no] topology "
1149 "<ipv4-unicast"
1150 "|ipv4-mgmt"
1151 "|ipv6-unicast"
1152 "|ipv4-multicast"
1153 "|ipv6-multicast"
1154 "|ipv6-mgmt"
1155 "|ipv6-dstsrc>$topology "
1156 "[overload]$overload",
1157 NO_STR
1158 "Configure IS-IS topologies\n"
1159 "IPv4 unicast topology\n"
1160 "IPv4 management topology\n"
1161 "IPv6 unicast topology\n"
1162 "IPv4 multicast topology\n"
1163 "IPv6 multicast topology\n"
1164 "IPv6 management topology\n"
1165 "IPv6 dst-src topology\n"
1166 "Set overload bit for topology\n")
1167 {
1168 char base_xpath[XPATH_MAXLEN];
1169
1170 /* Since IPv4-unicast is not configurable it is not present in the
1171 * YANG model, so we need to validate it here
1172 */
1173 if (strmatch(topology, "ipv4-unicast")) {
1174 vty_out(vty, "Cannot configure IPv4 unicast topology\n");
1175 return CMD_WARNING_CONFIG_FAILED;
1176 }
1177
1178 if (strmatch(topology, "ipv4-mgmt"))
1179 snprintf(base_xpath, XPATH_MAXLEN,
1180 "./multi-topology/ipv4-management");
1181 else if (strmatch(topology, "ipv6-mgmt"))
1182 snprintf(base_xpath, XPATH_MAXLEN,
1183 "./multi-topology/ipv6-management");
1184 else
1185 snprintf(base_xpath, XPATH_MAXLEN, "./multi-topology/%s",
1186 topology);
1187
1188 if (no)
1189 nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL);
1190 else {
1191 nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
1192 nb_cli_enqueue_change(vty, "./overload", NB_OP_MODIFY,
1193 overload ? "true" : "false");
1194 }
1195
1196 return nb_cli_apply_changes(vty, base_xpath);
1197 }
1198
1199 void cli_show_isis_mt_ipv4_multicast(struct vty *vty, struct lyd_node *dnode,
1200 bool show_defaults)
1201 {
1202 vty_out(vty, " topology ipv4-multicast");
1203 if (yang_dnode_get_bool(dnode, "./overload"))
1204 vty_out(vty, " overload");
1205 vty_out(vty, "\n");
1206 }
1207
1208 void cli_show_isis_mt_ipv4_mgmt(struct vty *vty, struct lyd_node *dnode,
1209 bool show_defaults)
1210 {
1211 vty_out(vty, " topology ipv4-mgmt");
1212 if (yang_dnode_get_bool(dnode, "./overload"))
1213 vty_out(vty, " overload");
1214 vty_out(vty, "\n");
1215 }
1216
1217 void cli_show_isis_mt_ipv6_unicast(struct vty *vty, struct lyd_node *dnode,
1218 bool show_defaults)
1219 {
1220 vty_out(vty, " topology ipv6-unicast");
1221 if (yang_dnode_get_bool(dnode, "./overload"))
1222 vty_out(vty, " overload");
1223 vty_out(vty, "\n");
1224 }
1225
1226 void cli_show_isis_mt_ipv6_multicast(struct vty *vty, struct lyd_node *dnode,
1227 bool show_defaults)
1228 {
1229 vty_out(vty, " topology ipv6-multicast");
1230 if (yang_dnode_get_bool(dnode, "./overload"))
1231 vty_out(vty, " overload");
1232 vty_out(vty, "\n");
1233 }
1234
1235 void cli_show_isis_mt_ipv6_mgmt(struct vty *vty, struct lyd_node *dnode,
1236 bool show_defaults)
1237 {
1238 vty_out(vty, " topology ipv6-mgmt");
1239 if (yang_dnode_get_bool(dnode, "./overload"))
1240 vty_out(vty, " overload");
1241 vty_out(vty, "\n");
1242 }
1243
1244 void cli_show_isis_mt_ipv6_dstsrc(struct vty *vty, struct lyd_node *dnode,
1245 bool show_defaults)
1246 {
1247 vty_out(vty, " topology ipv6-dstsrc");
1248 if (yang_dnode_get_bool(dnode, "./overload"))
1249 vty_out(vty, " overload");
1250 vty_out(vty, "\n");
1251 }
1252
1253 /*
1254 * XPath: /frr-interface:lib/interface/frr-isisd:isis/passive
1255 */
1256 DEFPY(isis_passive, isis_passive_cmd, "[no] isis passive",
1257 NO_STR
1258 "IS-IS routing protocol\n"
1259 "Configure the passive mode for interface\n")
1260 {
1261 nb_cli_enqueue_change(vty, "./frr-isisd:isis/passive", NB_OP_MODIFY,
1262 no ? "false" : "true");
1263
1264 return nb_cli_apply_changes(vty, NULL);
1265 }
1266
1267 void cli_show_ip_isis_passive(struct vty *vty, struct lyd_node *dnode,
1268 bool show_defaults)
1269 {
1270 if (!yang_dnode_get_bool(dnode, NULL))
1271 vty_out(vty, " no");
1272 vty_out(vty, " isis passive\n");
1273 }
1274
1275 /*
1276 * XPath: /frr-interface:lib/interface/frr-isisd:isis/password
1277 */
1278
1279 DEFPY(isis_passwd, isis_passwd_cmd, "isis password <md5|clear>$type WORD$pwd",
1280 "IS-IS routing protocol\n"
1281 "Configure the authentication password for a circuit\n"
1282 "HMAC-MD5 authentication\n"
1283 "Cleartext password\n"
1284 "Circuit password\n")
1285 {
1286 nb_cli_enqueue_change(vty, "./frr-isisd:isis/password", NB_OP_CREATE,
1287 NULL);
1288 nb_cli_enqueue_change(vty, "./frr-isisd:isis/password/password",
1289 NB_OP_MODIFY, pwd);
1290 nb_cli_enqueue_change(vty, "./frr-isisd:isis/password/password-type",
1291 NB_OP_MODIFY, type);
1292
1293 return nb_cli_apply_changes(vty, NULL);
1294 }
1295
1296 DEFPY(no_isis_passwd, no_isis_passwd_cmd, "no isis password [<md5|clear> WORD]",
1297 NO_STR
1298 "IS-IS routing protocol\n"
1299 "Configure the authentication password for a circuit\n"
1300 "HMAC-MD5 authentication\n"
1301 "Cleartext password\n"
1302 "Circuit password\n")
1303 {
1304 nb_cli_enqueue_change(vty, "./frr-isisd:isis/password", NB_OP_DESTROY,
1305 NULL);
1306
1307 return nb_cli_apply_changes(vty, NULL);
1308 }
1309
1310 void cli_show_ip_isis_password(struct vty *vty, struct lyd_node *dnode,
1311 bool show_defaults)
1312 {
1313 vty_out(vty, " isis password %s %s\n",
1314 yang_dnode_get_string(dnode, "./password-type"),
1315 yang_dnode_get_string(dnode, "./password"));
1316 }
1317
1318 /*
1319 * XPath: /frr-interface:lib/interface/frr-isisd:isis/metric
1320 */
1321 DEFPY(isis_metric, isis_metric_cmd,
1322 "isis metric [level-1|level-2]$level (0-16777215)$met",
1323 "IS-IS routing protocol\n"
1324 "Set default metric for circuit\n"
1325 "Specify metric for level-1 routing\n"
1326 "Specify metric for level-2 routing\n"
1327 "Default metric value\n")
1328 {
1329 if (!level || strmatch(level, "level-1"))
1330 nb_cli_enqueue_change(vty, "./frr-isisd:isis/metric/level-1",
1331 NB_OP_MODIFY, met_str);
1332 if (!level || strmatch(level, "level-2"))
1333 nb_cli_enqueue_change(vty, "./frr-isisd:isis/metric/level-2",
1334 NB_OP_MODIFY, met_str);
1335
1336 return nb_cli_apply_changes(vty, NULL);
1337 }
1338
1339 DEFPY(no_isis_metric, no_isis_metric_cmd,
1340 "no isis metric [level-1|level-2]$level [(0-16777215)]",
1341 NO_STR
1342 "IS-IS routing protocol\n"
1343 "Set default metric for circuit\n"
1344 "Specify metric for level-1 routing\n"
1345 "Specify metric for level-2 routing\n"
1346 "Default metric value\n")
1347 {
1348 if (!level || strmatch(level, "level-1"))
1349 nb_cli_enqueue_change(vty, "./frr-isisd:isis/metric/level-1",
1350 NB_OP_MODIFY, NULL);
1351 if (!level || strmatch(level, "level-2"))
1352 nb_cli_enqueue_change(vty, "./frr-isisd:isis/metric/level-2",
1353 NB_OP_MODIFY, NULL);
1354
1355 return nb_cli_apply_changes(vty, NULL);
1356 }
1357
1358 void cli_show_ip_isis_metric(struct vty *vty, struct lyd_node *dnode,
1359 bool show_defaults)
1360 {
1361 const char *l1 = yang_dnode_get_string(dnode, "./level-1");
1362 const char *l2 = yang_dnode_get_string(dnode, "./level-2");
1363
1364 if (strmatch(l1, l2))
1365 vty_out(vty, " isis metric %s\n", l1);
1366 else {
1367 vty_out(vty, " isis metric %s level-1\n", l1);
1368 vty_out(vty, " isis metric %s level-2\n", l2);
1369 }
1370 }
1371
1372 /*
1373 * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/interval
1374 */
1375 DEFPY(isis_hello_interval, isis_hello_interval_cmd,
1376 "isis hello-interval [level-1|level-2]$level (1-600)$intv",
1377 "IS-IS routing protocol\n"
1378 "Set Hello interval\n"
1379 "Specify hello-interval for level-1 IIHs\n"
1380 "Specify hello-interval for level-2 IIHs\n"
1381 "Holdtime 1 seconds, interval depends on multiplier\n")
1382 {
1383 if (!level || strmatch(level, "level-1"))
1384 nb_cli_enqueue_change(vty,
1385 "./frr-isisd:isis/hello/interval/level-1",
1386 NB_OP_MODIFY, intv_str);
1387 if (!level || strmatch(level, "level-2"))
1388 nb_cli_enqueue_change(vty,
1389 "./frr-isisd:isis/hello/interval/level-2",
1390 NB_OP_MODIFY, intv_str);
1391
1392 return nb_cli_apply_changes(vty, NULL);
1393 }
1394
1395 DEFPY(no_isis_hello_interval, no_isis_hello_interval_cmd,
1396 "no isis hello-interval [level-1|level-2]$level [(1-600)]",
1397 NO_STR
1398 "IS-IS routing protocol\n"
1399 "Set Hello interval\n"
1400 "Specify hello-interval for level-1 IIHs\n"
1401 "Specify hello-interval for level-2 IIHs\n"
1402 "Holdtime 1 second, interval depends on multiplier\n")
1403 {
1404 if (!level || strmatch(level, "level-1"))
1405 nb_cli_enqueue_change(vty,
1406 "./frr-isisd:isis/hello/interval/level-1",
1407 NB_OP_MODIFY, NULL);
1408 if (!level || strmatch(level, "level-2"))
1409 nb_cli_enqueue_change(vty,
1410 "./frr-isisd:isis/hello/interval/level-2",
1411 NB_OP_MODIFY, NULL);
1412
1413 return nb_cli_apply_changes(vty, NULL);
1414 }
1415
1416 void cli_show_ip_isis_hello_interval(struct vty *vty, struct lyd_node *dnode,
1417 bool show_defaults)
1418 {
1419 const char *l1 = yang_dnode_get_string(dnode, "./level-1");
1420 const char *l2 = yang_dnode_get_string(dnode, "./level-2");
1421
1422 if (strmatch(l1, l2))
1423 vty_out(vty, " isis hello-interval %s\n", l1);
1424 else {
1425 vty_out(vty, " isis hello-interval %s level-1\n", l1);
1426 vty_out(vty, " isis hello-interval %s level-2\n", l2);
1427 }
1428 }
1429
1430 /*
1431 * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/multiplier
1432 */
1433 DEFPY(isis_hello_multiplier, isis_hello_multiplier_cmd,
1434 "isis hello-multiplier [level-1|level-2]$level (2-100)$mult",
1435 "IS-IS routing protocol\n"
1436 "Set multiplier for Hello holding time\n"
1437 "Specify hello multiplier for level-1 IIHs\n"
1438 "Specify hello multiplier for level-2 IIHs\n"
1439 "Hello multiplier value\n")
1440 {
1441 if (!level || strmatch(level, "level-1"))
1442 nb_cli_enqueue_change(
1443 vty, "./frr-isisd:isis/hello/multiplier/level-1",
1444 NB_OP_MODIFY, mult_str);
1445 if (!level || strmatch(level, "level-2"))
1446 nb_cli_enqueue_change(
1447 vty, "./frr-isisd:isis/hello/multiplier/level-2",
1448 NB_OP_MODIFY, mult_str);
1449
1450 return nb_cli_apply_changes(vty, NULL);
1451 }
1452
1453 DEFPY(no_isis_hello_multiplier, no_isis_hello_multiplier_cmd,
1454 "no isis hello-multiplier [level-1|level-2]$level [(2-100)]",
1455 NO_STR
1456 "IS-IS routing protocol\n"
1457 "Set multiplier for Hello holding time\n"
1458 "Specify hello multiplier for level-1 IIHs\n"
1459 "Specify hello multiplier for level-2 IIHs\n"
1460 "Hello multiplier value\n")
1461 {
1462 if (!level || strmatch(level, "level-1"))
1463 nb_cli_enqueue_change(
1464 vty, "./frr-isisd:isis/hello/multiplier/level-1",
1465 NB_OP_MODIFY, NULL);
1466 if (!level || strmatch(level, "level-2"))
1467 nb_cli_enqueue_change(
1468 vty, "./frr-isisd:isis/hello/multiplier/level-2",
1469 NB_OP_MODIFY, NULL);
1470
1471 return nb_cli_apply_changes(vty, NULL);
1472 }
1473
1474 void cli_show_ip_isis_hello_multi(struct vty *vty, struct lyd_node *dnode,
1475 bool show_defaults)
1476 {
1477 const char *l1 = yang_dnode_get_string(dnode, "./level-1");
1478 const char *l2 = yang_dnode_get_string(dnode, "./level-2");
1479
1480 if (strmatch(l1, l2))
1481 vty_out(vty, " isis hello-multiplier %s\n", l1);
1482 else {
1483 vty_out(vty, " isis hello-multiplier %s level-1\n", l1);
1484 vty_out(vty, " isis hello-multiplier %s level-2\n", l2);
1485 }
1486 }
1487
1488 /*
1489 * XPath:
1490 * /frr-interface:lib/interface/frr-isisd:isis/disable-three-way-handshake
1491 */
1492 DEFPY(isis_threeway_adj, isis_threeway_adj_cmd, "[no] isis three-way-handshake",
1493 NO_STR
1494 "IS-IS commands\n"
1495 "Enable/Disable three-way handshake\n")
1496 {
1497 nb_cli_enqueue_change(vty,
1498 "./frr-isisd:isis/disable-three-way-handshake",
1499 NB_OP_MODIFY, no ? "true" : "false");
1500
1501 return nb_cli_apply_changes(vty, NULL);
1502 }
1503
1504 void cli_show_ip_isis_threeway_shake(struct vty *vty, struct lyd_node *dnode,
1505 bool show_defaults)
1506 {
1507 if (yang_dnode_get_bool(dnode, NULL))
1508 vty_out(vty, " no");
1509 vty_out(vty, " isis three-way-handshake\n");
1510 }
1511
1512 /*
1513 * XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/padding
1514 */
1515 DEFPY(isis_hello_padding, isis_hello_padding_cmd, "[no] isis hello padding",
1516 NO_STR
1517 "IS-IS routing protocol\n"
1518 "Add padding to IS-IS hello packets\n"
1519 "Pad hello packets\n")
1520 {
1521 nb_cli_enqueue_change(vty, "./frr-isisd:isis/hello/padding",
1522 NB_OP_MODIFY, no ? "false" : "true");
1523
1524 return nb_cli_apply_changes(vty, NULL);
1525 }
1526
1527 void cli_show_ip_isis_hello_padding(struct vty *vty, struct lyd_node *dnode,
1528 bool show_defaults)
1529 {
1530 if (!yang_dnode_get_bool(dnode, NULL))
1531 vty_out(vty, " no");
1532
1533 vty_out(vty, " isis hello padding\n");
1534 }
1535
1536 /*
1537 * XPath: /frr-interface:lib/interface/frr-isisd:isis/csnp-interval
1538 */
1539 DEFPY(csnp_interval, csnp_interval_cmd,
1540 "isis csnp-interval (1-600)$intv [level-1|level-2]$level",
1541 "IS-IS routing protocol\n"
1542 "Set CSNP interval in seconds\n"
1543 "CSNP interval value\n"
1544 "Specify interval for level-1 CSNPs\n"
1545 "Specify interval for level-2 CSNPs\n")
1546 {
1547 if (!level || strmatch(level, "level-1"))
1548 nb_cli_enqueue_change(vty,
1549 "./frr-isisd:isis/csnp-interval/level-1",
1550 NB_OP_MODIFY, intv_str);
1551 if (!level || strmatch(level, "level-2"))
1552 nb_cli_enqueue_change(vty,
1553 "./frr-isisd:isis/csnp-interval/level-2",
1554 NB_OP_MODIFY, intv_str);
1555
1556 return nb_cli_apply_changes(vty, NULL);
1557 }
1558
1559 DEFPY(no_csnp_interval, no_csnp_interval_cmd,
1560 "no isis csnp-interval [(1-600)] [level-1|level-2]$level",
1561 NO_STR
1562 "IS-IS routing protocol\n"
1563 "Set CSNP interval in seconds\n"
1564 "CSNP interval value\n"
1565 "Specify interval for level-1 CSNPs\n"
1566 "Specify interval for level-2 CSNPs\n")
1567 {
1568 if (!level || strmatch(level, "level-1"))
1569 nb_cli_enqueue_change(vty,
1570 "./frr-isisd:isis/csnp-interval/level-1",
1571 NB_OP_MODIFY, NULL);
1572 if (!level || strmatch(level, "level-2"))
1573 nb_cli_enqueue_change(vty,
1574 "./frr-isisd:isis/csnp-interval/level-2",
1575 NB_OP_MODIFY, NULL);
1576
1577 return nb_cli_apply_changes(vty, NULL);
1578 }
1579
1580 void cli_show_ip_isis_csnp_interval(struct vty *vty, struct lyd_node *dnode,
1581 bool show_defaults)
1582 {
1583 const char *l1 = yang_dnode_get_string(dnode, "./level-1");
1584 const char *l2 = yang_dnode_get_string(dnode, "./level-2");
1585
1586 if (strmatch(l1, l2))
1587 vty_out(vty, " isis csnp-interval %s\n", l1);
1588 else {
1589 vty_out(vty, " isis csnp-interval %s level-1\n", l1);
1590 vty_out(vty, " isis csnp-interval %s level-2\n", l2);
1591 }
1592 }
1593
1594 /*
1595 * XPath: /frr-interface:lib/interface/frr-isisd:isis/psnp-interval
1596 */
1597 DEFPY(psnp_interval, psnp_interval_cmd,
1598 "isis psnp-interval (1-120)$intv [level-1|level-2]$level",
1599 "IS-IS routing protocol\n"
1600 "Set PSNP interval in seconds\n"
1601 "PSNP interval value\n"
1602 "Specify interval for level-1 PSNPs\n"
1603 "Specify interval for level-2 PSNPs\n")
1604 {
1605 if (!level || strmatch(level, "level-1"))
1606 nb_cli_enqueue_change(vty,
1607 "./frr-isisd:isis/psnp-interval/level-1",
1608 NB_OP_MODIFY, intv_str);
1609 if (!level || strmatch(level, "level-2"))
1610 nb_cli_enqueue_change(vty,
1611 "./frr-isisd:isis/psnp-interval/level-2",
1612 NB_OP_MODIFY, intv_str);
1613
1614 return nb_cli_apply_changes(vty, NULL);
1615 }
1616
1617 DEFPY(no_psnp_interval, no_psnp_interval_cmd,
1618 "no isis psnp-interval [(1-120)] [level-1|level-2]$level",
1619 NO_STR
1620 "IS-IS routing protocol\n"
1621 "Set PSNP interval in seconds\n"
1622 "PSNP interval value\n"
1623 "Specify interval for level-1 PSNPs\n"
1624 "Specify interval for level-2 PSNPs\n")
1625 {
1626 if (!level || strmatch(level, "level-1"))
1627 nb_cli_enqueue_change(vty,
1628 "./frr-isisd:isis/psnp-interval/level-1",
1629 NB_OP_MODIFY, NULL);
1630 if (!level || strmatch(level, "level-2"))
1631 nb_cli_enqueue_change(vty,
1632 "./frr-isisd:isis/psnp-interval/level-2",
1633 NB_OP_MODIFY, NULL);
1634
1635 return nb_cli_apply_changes(vty, NULL);
1636 }
1637
1638 void cli_show_ip_isis_psnp_interval(struct vty *vty, struct lyd_node *dnode,
1639 bool show_defaults)
1640 {
1641 const char *l1 = yang_dnode_get_string(dnode, "./level-1");
1642 const char *l2 = yang_dnode_get_string(dnode, "./level-2");
1643
1644 if (strmatch(l1, l2))
1645 vty_out(vty, " isis psnp-interval %s\n", l1);
1646 else {
1647 vty_out(vty, " isis psnp-interval %s level-1\n", l1);
1648 vty_out(vty, " isis psnp-interval %s level-2\n", l2);
1649 }
1650 }
1651
1652 /*
1653 * XPath: /frr-interface:lib/interface/frr-isisd:isis/multi-topology
1654 */
1655 DEFPY(circuit_topology, circuit_topology_cmd,
1656 "[no] isis topology"
1657 "<ipv4-unicast"
1658 "|ipv4-mgmt"
1659 "|ipv6-unicast"
1660 "|ipv4-multicast"
1661 "|ipv6-multicast"
1662 "|ipv6-mgmt"
1663 "|ipv6-dstsrc"
1664 ">$topology",
1665 NO_STR
1666 "IS-IS routing protocol\n"
1667 "Configure interface IS-IS topologies\n"
1668 "IPv4 unicast topology\n"
1669 "IPv4 management topology\n"
1670 "IPv6 unicast topology\n"
1671 "IPv4 multicast topology\n"
1672 "IPv6 multicast topology\n"
1673 "IPv6 management topology\n"
1674 "IPv6 dst-src topology\n")
1675 {
1676 nb_cli_enqueue_change(vty, ".", NB_OP_MODIFY, no ? "false" : "true");
1677
1678 if (strmatch(topology, "ipv4-mgmt"))
1679 return nb_cli_apply_changes(
1680 vty, "./frr-isisd:isis/multi-topology/ipv4-management");
1681 else if (strmatch(topology, "ipv6-mgmt"))
1682 return nb_cli_apply_changes(
1683 vty, "./frr-isisd:isis/multi-topology/ipv6-management");
1684 else
1685 return nb_cli_apply_changes(
1686 vty, "./frr-isisd:isis/multi-topology/%s", topology);
1687 }
1688
1689 void cli_show_ip_isis_mt_ipv4_unicast(struct vty *vty, struct lyd_node *dnode,
1690 bool show_defaults)
1691 {
1692 if (!yang_dnode_get_bool(dnode, NULL))
1693 vty_out(vty, " no");
1694 vty_out(vty, " isis topology ipv4-unicast\n");
1695 }
1696
1697 void cli_show_ip_isis_mt_ipv4_multicast(struct vty *vty, struct lyd_node *dnode,
1698 bool show_defaults)
1699 {
1700 if (!yang_dnode_get_bool(dnode, NULL))
1701 vty_out(vty, " no");
1702 vty_out(vty, " isis topology ipv4-multicast\n");
1703 }
1704
1705 void cli_show_ip_isis_mt_ipv4_mgmt(struct vty *vty, struct lyd_node *dnode,
1706 bool show_defaults)
1707 {
1708 if (!yang_dnode_get_bool(dnode, NULL))
1709 vty_out(vty, " no");
1710 vty_out(vty, " isis topology ipv4-mgmt\n");
1711 }
1712
1713 void cli_show_ip_isis_mt_ipv6_unicast(struct vty *vty, struct lyd_node *dnode,
1714 bool show_defaults)
1715 {
1716 if (!yang_dnode_get_bool(dnode, NULL))
1717 vty_out(vty, " no");
1718 vty_out(vty, " isis topology ipv6-unicast\n");
1719 }
1720
1721 void cli_show_ip_isis_mt_ipv6_multicast(struct vty *vty, struct lyd_node *dnode,
1722 bool show_defaults)
1723 {
1724 if (!yang_dnode_get_bool(dnode, NULL))
1725 vty_out(vty, " no");
1726 vty_out(vty, " isis topology ipv6-multicast\n");
1727 }
1728
1729 void cli_show_ip_isis_mt_ipv6_mgmt(struct vty *vty, struct lyd_node *dnode,
1730 bool show_defaults)
1731 {
1732 if (!yang_dnode_get_bool(dnode, NULL))
1733 vty_out(vty, " no");
1734 vty_out(vty, " isis topology ipv6-mgmt\n");
1735 }
1736
1737 void cli_show_ip_isis_mt_ipv6_dstsrc(struct vty *vty, struct lyd_node *dnode,
1738 bool show_defaults)
1739 {
1740 if (!yang_dnode_get_bool(dnode, NULL))
1741 vty_out(vty, " no");
1742 vty_out(vty, " isis topology ipv6-dstsrc\n");
1743 }
1744
1745 /*
1746 * XPath: /frr-interface:lib/interface/frr-isisd:isis/circuit-type
1747 */
1748 DEFPY(isis_circuit_type, isis_circuit_type_cmd,
1749 "isis circuit-type <level-1|level-1-2|level-2-only>$type",
1750 "IS-IS routing protocol\n"
1751 "Configure circuit type for interface\n"
1752 "Level-1 only adjacencies are formed\n"
1753 "Level-1-2 adjacencies are formed\n"
1754 "Level-2 only adjacencies are formed\n")
1755 {
1756 nb_cli_enqueue_change(
1757 vty, "./frr-isisd:isis/circuit-type", NB_OP_MODIFY,
1758 strmatch(type, "level-2-only") ? "level-2" : type);
1759
1760 return nb_cli_apply_changes(vty, NULL);
1761 }
1762
1763 DEFPY(no_isis_circuit_type, no_isis_circuit_type_cmd,
1764 "no isis circuit-type [level-1|level-1-2|level-2-only]",
1765 NO_STR
1766 "IS-IS routing protocol\n"
1767 "Configure circuit type for interface\n"
1768 "Level-1 only adjacencies are formed\n"
1769 "Level-1-2 adjacencies are formed\n"
1770 "Level-2 only adjacencies are formed\n")
1771 {
1772 struct interface *ifp;
1773 struct isis_circuit *circuit;
1774 int is_type;
1775 const char *circ_type;
1776
1777 /*
1778 * Default value depends on whether the circuit is part of an area,
1779 * and the is-type of the area if there is one. So we need to do this
1780 * here.
1781 */
1782 ifp = nb_running_get_entry(NULL, VTY_CURR_XPATH, false);
1783 if (!ifp)
1784 goto def_val;
1785
1786 circuit = circuit_scan_by_ifp(ifp);
1787 if (!circuit)
1788 goto def_val;
1789
1790 if (circuit->state == C_STATE_UP)
1791 is_type = circuit->area->is_type;
1792 else
1793 goto def_val;
1794
1795 switch (is_type) {
1796 case IS_LEVEL_1:
1797 circ_type = "level-1";
1798 break;
1799 case IS_LEVEL_2:
1800 circ_type = "level-2";
1801 break;
1802 case IS_LEVEL_1_AND_2:
1803 circ_type = "level-1-2";
1804 break;
1805 default:
1806 return CMD_ERR_NO_MATCH;
1807 }
1808 nb_cli_enqueue_change(vty, "./frr-isisd:isis/circuit-type",
1809 NB_OP_MODIFY, circ_type);
1810
1811 return nb_cli_apply_changes(vty, NULL);
1812
1813 def_val:
1814 nb_cli_enqueue_change(vty, "./frr-isisd:isis/circuit-type",
1815 NB_OP_MODIFY, NULL);
1816
1817 return nb_cli_apply_changes(vty, NULL);
1818 }
1819
1820 void cli_show_ip_isis_circ_type(struct vty *vty, struct lyd_node *dnode,
1821 bool show_defaults)
1822 {
1823 int level = yang_dnode_get_enum(dnode, NULL);
1824
1825 switch (level) {
1826 case IS_LEVEL_1:
1827 vty_out(vty, " isis circuit-type level-1\n");
1828 break;
1829 case IS_LEVEL_2:
1830 vty_out(vty, " isis circuit-type level-2-only\n");
1831 break;
1832 case IS_LEVEL_1_AND_2:
1833 vty_out(vty, " isis circuit-type level-1-2\n");
1834 break;
1835 }
1836 }
1837
1838 /*
1839 * XPath: /frr-interface:lib/interface/frr-isisd:isis/network-type
1840 */
1841 DEFPY(isis_network, isis_network_cmd, "[no] isis network point-to-point",
1842 NO_STR
1843 "IS-IS routing protocol\n"
1844 "Set network type\n"
1845 "point-to-point network type\n")
1846 {
1847 nb_cli_enqueue_change(vty, "./frr-isisd:isis/network-type",
1848 NB_OP_MODIFY,
1849 no ? "broadcast" : "point-to-point");
1850
1851 return nb_cli_apply_changes(vty, NULL);
1852 }
1853
1854 void cli_show_ip_isis_network_type(struct vty *vty, struct lyd_node *dnode,
1855 bool show_defaults)
1856 {
1857 if (yang_dnode_get_enum(dnode, NULL) != CIRCUIT_T_P2P)
1858 vty_out(vty, " no");
1859
1860 vty_out(vty, " isis network point-to-point\n");
1861 }
1862
1863 /*
1864 * XPath: /frr-interface:lib/interface/frr-isisd:isis/priority
1865 */
1866 DEFPY(isis_priority, isis_priority_cmd,
1867 "isis priority (0-127)$prio [level-1|level-2]$level",
1868 "IS-IS routing protocol\n"
1869 "Set priority for Designated Router election\n"
1870 "Priority value\n"
1871 "Specify priority for level-1 routing\n"
1872 "Specify priority for level-2 routing\n")
1873 {
1874 if (!level || strmatch(level, "level-1"))
1875 nb_cli_enqueue_change(vty, "./frr-isisd:isis/priority/level-1",
1876 NB_OP_MODIFY, prio_str);
1877 if (!level || strmatch(level, "level-2"))
1878 nb_cli_enqueue_change(vty, "./frr-isisd:isis/priority/level-2",
1879 NB_OP_MODIFY, prio_str);
1880
1881 return nb_cli_apply_changes(vty, NULL);
1882 }
1883
1884 DEFPY(no_isis_priority, no_isis_priority_cmd,
1885 "no isis priority [(0-127)] [level-1|level-2]$level",
1886 NO_STR
1887 "IS-IS routing protocol\n"
1888 "Set priority for Designated Router election\n"
1889 "Priority value\n"
1890 "Specify priority for level-1 routing\n"
1891 "Specify priority for level-2 routing\n")
1892 {
1893 if (!level || strmatch(level, "level-1"))
1894 nb_cli_enqueue_change(vty, "./frr-isisd:isis/priority/level-1",
1895 NB_OP_MODIFY, NULL);
1896 if (!level || strmatch(level, "level-2"))
1897 nb_cli_enqueue_change(vty, "./frr-isisd:isis/priority/level-2",
1898 NB_OP_MODIFY, NULL);
1899
1900 return nb_cli_apply_changes(vty, NULL);
1901 }
1902
1903 void cli_show_ip_isis_priority(struct vty *vty, struct lyd_node *dnode,
1904 bool show_defaults)
1905 {
1906 const char *l1 = yang_dnode_get_string(dnode, "./level-1");
1907 const char *l2 = yang_dnode_get_string(dnode, "./level-2");
1908
1909 if (strmatch(l1, l2))
1910 vty_out(vty, " isis priority %s\n", l1);
1911 else {
1912 vty_out(vty, " isis priority %s level-1\n", l1);
1913 vty_out(vty, " isis priority %s level-2\n", l2);
1914 }
1915 }
1916
1917 /*
1918 * XPath: /frr-isisd:isis/instance/log-adjacency-changes
1919 */
1920 DEFPY(log_adj_changes, log_adj_changes_cmd, "[no] log-adjacency-changes",
1921 NO_STR "Log changes in adjacency state\n")
1922 {
1923 nb_cli_enqueue_change(vty, "./log-adjacency-changes", NB_OP_MODIFY,
1924 no ? "false" : "true");
1925
1926 return nb_cli_apply_changes(vty, NULL);
1927 }
1928
1929 void cli_show_isis_log_adjacency(struct vty *vty, struct lyd_node *dnode,
1930 bool show_defaults)
1931 {
1932 if (!yang_dnode_get_bool(dnode, NULL))
1933 vty_out(vty, " no");
1934 vty_out(vty, " log-adjacency-changes\n");
1935 }
1936
1937 void isis_cli_init(void)
1938 {
1939 install_element(CONFIG_NODE, &router_isis_cmd);
1940 install_element(CONFIG_NODE, &no_router_isis_cmd);
1941
1942 install_element(INTERFACE_NODE, &ip_router_isis_cmd);
1943 install_element(INTERFACE_NODE, &ip6_router_isis_cmd);
1944 install_element(INTERFACE_NODE, &no_ip_router_isis_cmd);
1945
1946 install_element(ISIS_NODE, &net_cmd);
1947
1948 install_element(ISIS_NODE, &is_type_cmd);
1949 install_element(ISIS_NODE, &no_is_type_cmd);
1950
1951 install_element(ISIS_NODE, &dynamic_hostname_cmd);
1952
1953 install_element(ISIS_NODE, &set_overload_bit_cmd);
1954 install_element(ISIS_NODE, &set_attached_bit_cmd);
1955
1956 install_element(ISIS_NODE, &metric_style_cmd);
1957 install_element(ISIS_NODE, &no_metric_style_cmd);
1958
1959 install_element(ISIS_NODE, &area_passwd_cmd);
1960 install_element(ISIS_NODE, &domain_passwd_cmd);
1961 install_element(ISIS_NODE, &no_area_passwd_cmd);
1962
1963 install_element(ISIS_NODE, &lsp_gen_interval_cmd);
1964 install_element(ISIS_NODE, &no_lsp_gen_interval_cmd);
1965 install_element(ISIS_NODE, &lsp_refresh_interval_cmd);
1966 install_element(ISIS_NODE, &no_lsp_refresh_interval_cmd);
1967 install_element(ISIS_NODE, &max_lsp_lifetime_cmd);
1968 install_element(ISIS_NODE, &no_max_lsp_lifetime_cmd);
1969 install_element(ISIS_NODE, &area_lsp_mtu_cmd);
1970 install_element(ISIS_NODE, &no_area_lsp_mtu_cmd);
1971
1972 install_element(ISIS_NODE, &spf_interval_cmd);
1973 install_element(ISIS_NODE, &no_spf_interval_cmd);
1974 install_element(ISIS_NODE, &spf_delay_ietf_cmd);
1975 install_element(ISIS_NODE, &no_spf_delay_ietf_cmd);
1976
1977 install_element(ISIS_NODE, &area_purge_originator_cmd);
1978
1979 install_element(ISIS_NODE, &isis_mpls_te_on_cmd);
1980 install_element(ISIS_NODE, &no_isis_mpls_te_on_cmd);
1981 install_element(ISIS_NODE, &isis_mpls_te_router_addr_cmd);
1982 install_element(ISIS_NODE, &no_isis_mpls_te_router_addr_cmd);
1983 install_element(ISIS_NODE, &isis_mpls_te_inter_as_cmd);
1984
1985 install_element(ISIS_NODE, &isis_default_originate_cmd);
1986 install_element(ISIS_NODE, &isis_redistribute_cmd);
1987
1988 install_element(ISIS_NODE, &isis_topology_cmd);
1989
1990 install_element(INTERFACE_NODE, &isis_passive_cmd);
1991
1992 install_element(INTERFACE_NODE, &isis_passwd_cmd);
1993 install_element(INTERFACE_NODE, &no_isis_passwd_cmd);
1994
1995 install_element(INTERFACE_NODE, &isis_metric_cmd);
1996 install_element(INTERFACE_NODE, &no_isis_metric_cmd);
1997
1998 install_element(INTERFACE_NODE, &isis_hello_interval_cmd);
1999 install_element(INTERFACE_NODE, &no_isis_hello_interval_cmd);
2000
2001 install_element(INTERFACE_NODE, &isis_hello_multiplier_cmd);
2002 install_element(INTERFACE_NODE, &no_isis_hello_multiplier_cmd);
2003
2004 install_element(INTERFACE_NODE, &isis_threeway_adj_cmd);
2005
2006 install_element(INTERFACE_NODE, &isis_hello_padding_cmd);
2007
2008 install_element(INTERFACE_NODE, &csnp_interval_cmd);
2009 install_element(INTERFACE_NODE, &no_csnp_interval_cmd);
2010
2011 install_element(INTERFACE_NODE, &psnp_interval_cmd);
2012 install_element(INTERFACE_NODE, &no_psnp_interval_cmd);
2013
2014 install_element(INTERFACE_NODE, &circuit_topology_cmd);
2015
2016 install_element(INTERFACE_NODE, &isis_circuit_type_cmd);
2017 install_element(INTERFACE_NODE, &no_isis_circuit_type_cmd);
2018
2019 install_element(INTERFACE_NODE, &isis_network_cmd);
2020
2021 install_element(INTERFACE_NODE, &isis_priority_cmd);
2022 install_element(INTERFACE_NODE, &no_isis_priority_cmd);
2023
2024 install_element(ISIS_NODE, &log_adj_changes_cmd);
2025 }
2026
2027 #endif /* ifndef FABRICD */