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