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