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