1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro <kunihiro@zebra.org>
4 * Copyright (C) 2018 NetDEF, Inc.
15 #include "northbound_cli.h"
18 #include "ripd/ripd.h"
19 #include "ripd/rip_nb.h"
20 #include "ripd/rip_cli_clippy.c"
23 * XPath: /frr-ripd:ripd/instance
25 DEFPY_YANG_NOSH (router_rip
,
27 "router rip [vrf NAME]",
28 "Enable a routing process\n"
29 "Routing Information Protocol (RIP)\n"
32 char xpath
[XPATH_MAXLEN
];
35 /* Build RIP instance XPath. */
37 vrf
= VRF_DEFAULT_NAME
;
38 snprintf(xpath
, sizeof(xpath
), "/frr-ripd:ripd/instance[vrf='%s']",
41 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
43 ret
= nb_cli_apply_changes(vty
, NULL
);
44 if (ret
== CMD_SUCCESS
)
45 VTY_PUSH_XPATH(RIP_NODE
, xpath
);
50 DEFPY_YANG (no_router_rip
,
52 "no router rip [vrf NAME]",
54 "Enable a routing process\n"
55 "Routing Information Protocol (RIP)\n"
58 char xpath
[XPATH_MAXLEN
];
60 /* Build RIP instance XPath. */
62 vrf
= VRF_DEFAULT_NAME
;
63 snprintf(xpath
, sizeof(xpath
), "/frr-ripd:ripd/instance[vrf='%s']",
66 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
68 return nb_cli_apply_changes_clear_pending(vty
, NULL
);
71 void cli_show_router_rip(struct vty
*vty
, const struct lyd_node
*dnode
,
76 vrf_name
= yang_dnode_get_string(dnode
, "./vrf");
79 vty_out(vty
, "router rip");
80 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
))
81 vty_out(vty
, " vrf %s", vrf_name
);
86 * XPath: /frr-ripd:ripd/instance/allow-ecmp
88 DEFUN_YANG (rip_allow_ecmp
,
90 "allow-ecmp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
91 "Allow Equal Cost MultiPath\n"
96 uint32_t paths
= MULTIPATH_NUM
;
99 paths
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
100 snprintf(mpaths
, sizeof(mpaths
), "%u", paths
);
102 nb_cli_enqueue_change(vty
, "./allow-ecmp", NB_OP_MODIFY
, mpaths
);
104 return nb_cli_apply_changes(vty
, NULL
);
107 DEFUN_YANG (no_rip_allow_ecmp
,
108 no_rip_allow_ecmp_cmd
,
109 "no allow-ecmp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
111 "Allow Equal Cost MultiPath\n"
114 nb_cli_enqueue_change(vty
, "./allow-ecmp", NB_OP_MODIFY
, 0);
116 return nb_cli_apply_changes(vty
, NULL
);
119 void cli_show_rip_allow_ecmp(struct vty
*vty
, const struct lyd_node
*dnode
,
124 paths
= yang_dnode_get_uint8(dnode
, NULL
);
127 vty_out(vty
, " no allow-ecmp\n");
129 vty_out(vty
, " allow-ecmp %d\n", paths
);
133 * XPath: /frr-ripd:ripd/instance/default-information-originate
135 DEFPY_YANG (rip_default_information_originate
,
136 rip_default_information_originate_cmd
,
137 "[no] default-information originate",
139 "Control distribution of default route\n"
140 "Distribute a default route\n")
142 nb_cli_enqueue_change(vty
, "./default-information-originate",
143 NB_OP_MODIFY
, no
? "false" : "true");
145 return nb_cli_apply_changes(vty
, NULL
);
148 void cli_show_rip_default_information_originate(struct vty
*vty
,
149 const struct lyd_node
*dnode
,
152 if (!yang_dnode_get_bool(dnode
, NULL
))
155 vty_out(vty
, " default-information originate\n");
159 * XPath: /frr-ripd:ripd/instance/default-metric
161 DEFPY_YANG (rip_default_metric
,
162 rip_default_metric_cmd
,
163 "default-metric (1-16)",
164 "Set a metric of redistribute routes\n"
167 nb_cli_enqueue_change(vty
, "./default-metric", NB_OP_MODIFY
,
170 return nb_cli_apply_changes(vty
, NULL
);
173 DEFPY_YANG (no_rip_default_metric
,
174 no_rip_default_metric_cmd
,
175 "no default-metric [(1-16)]",
177 "Set a metric of redistribute routes\n"
180 nb_cli_enqueue_change(vty
, "./default-metric", NB_OP_MODIFY
, NULL
);
182 return nb_cli_apply_changes(vty
, NULL
);
185 void cli_show_rip_default_metric(struct vty
*vty
, const struct lyd_node
*dnode
,
188 vty_out(vty
, " default-metric %s\n",
189 yang_dnode_get_string(dnode
, NULL
));
193 * XPath: /frr-ripd:ripd/instance/distance/default
195 DEFPY_YANG (rip_distance
,
198 "Administrative distance\n"
201 nb_cli_enqueue_change(vty
, "./distance/default", NB_OP_MODIFY
,
204 return nb_cli_apply_changes(vty
, NULL
);
207 DEFPY_YANG (no_rip_distance
,
209 "no distance [(1-255)]",
211 "Administrative distance\n"
214 nb_cli_enqueue_change(vty
, "./distance/default", NB_OP_MODIFY
, NULL
);
216 return nb_cli_apply_changes(vty
, NULL
);
219 void cli_show_rip_distance(struct vty
*vty
, const struct lyd_node
*dnode
,
222 if (yang_dnode_is_default(dnode
, NULL
))
223 vty_out(vty
, " no distance\n");
225 vty_out(vty
, " distance %s\n",
226 yang_dnode_get_string(dnode
, NULL
));
230 * XPath: /frr-ripd:ripd/instance/distance/source
232 DEFPY_YANG (rip_distance_source
,
233 rip_distance_source_cmd
,
234 "[no] distance (1-255) A.B.C.D/M$prefix [WORD$acl]",
236 "Administrative distance\n"
239 "Access list name\n")
242 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
243 nb_cli_enqueue_change(vty
, "./distance", NB_OP_MODIFY
,
245 nb_cli_enqueue_change(vty
, "./access-list",
246 acl
? NB_OP_MODIFY
: NB_OP_DESTROY
, acl
);
248 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
250 return nb_cli_apply_changes(vty
, "./distance/source[prefix='%s']",
254 void cli_show_rip_distance_source(struct vty
*vty
, const struct lyd_node
*dnode
,
257 vty_out(vty
, " distance %s %s",
258 yang_dnode_get_string(dnode
, "./distance"),
259 yang_dnode_get_string(dnode
, "./prefix"));
260 if (yang_dnode_exists(dnode
, "./access-list"))
262 yang_dnode_get_string(dnode
, "./access-list"));
267 * XPath: /frr-ripd:ripd/instance/explicit-neighbor
269 DEFPY_YANG (rip_neighbor
,
271 "[no] neighbor A.B.C.D",
273 "Specify a neighbor router\n"
274 "Neighbor address\n")
276 nb_cli_enqueue_change(vty
, "./explicit-neighbor",
277 no
? NB_OP_DESTROY
: NB_OP_CREATE
, neighbor_str
);
279 return nb_cli_apply_changes(vty
, NULL
);
282 void cli_show_rip_neighbor(struct vty
*vty
, const struct lyd_node
*dnode
,
285 vty_out(vty
, " neighbor %s\n", yang_dnode_get_string(dnode
, NULL
));
289 * XPath: /frr-ripd:ripd/instance/network
291 DEFPY_YANG (rip_network_prefix
,
292 rip_network_prefix_cmd
,
293 "[no] network A.B.C.D/M",
295 "Enable routing on an IP network\n"
296 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
298 nb_cli_enqueue_change(vty
, "./network",
299 no
? NB_OP_DESTROY
: NB_OP_CREATE
, network_str
);
301 return nb_cli_apply_changes(vty
, NULL
);
304 void cli_show_rip_network_prefix(struct vty
*vty
, const struct lyd_node
*dnode
,
307 vty_out(vty
, " network %s\n", yang_dnode_get_string(dnode
, NULL
));
311 * XPath: /frr-ripd:ripd/instance/interface
313 DEFPY_YANG (rip_network_if
,
317 "Enable routing on an IP network\n"
320 nb_cli_enqueue_change(vty
, "./interface",
321 no
? NB_OP_DESTROY
: NB_OP_CREATE
, network
);
323 return nb_cli_apply_changes(vty
, NULL
);
326 void cli_show_rip_network_interface(struct vty
*vty
,
327 const struct lyd_node
*dnode
,
330 vty_out(vty
, " network %s\n", yang_dnode_get_string(dnode
, NULL
));
334 * XPath: /frr-ripd:ripd/instance/offset-list
336 DEFPY_YANG (rip_offset_list
,
338 "[no] offset-list ACCESSLIST4_NAME$acl <in|out>$direction (0-16)$metric [IFNAME]",
340 "Modify RIP metric\n"
342 "For incoming updates\n"
343 "For outgoing updates\n"
345 "Interface to match\n")
348 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
349 nb_cli_enqueue_change(vty
, "./access-list", NB_OP_MODIFY
, acl
);
350 nb_cli_enqueue_change(vty
, "./metric", NB_OP_MODIFY
,
353 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
355 return nb_cli_apply_changes(
356 vty
, "./offset-list[interface='%s'][direction='%s']",
357 ifname
? ifname
: "*", direction
);
360 void cli_show_rip_offset_list(struct vty
*vty
, const struct lyd_node
*dnode
,
363 const char *interface
;
365 interface
= yang_dnode_get_string(dnode
, "./interface");
367 vty_out(vty
, " offset-list %s %s %s",
368 yang_dnode_get_string(dnode
, "./access-list"),
369 yang_dnode_get_string(dnode
, "./direction"),
370 yang_dnode_get_string(dnode
, "./metric"));
371 if (!strmatch(interface
, "*"))
372 vty_out(vty
, " %s", interface
);
377 * XPath: /frr-ripd:ripd/instance/passive-default
379 DEFPY_YANG (rip_passive_default
,
380 rip_passive_default_cmd
,
381 "[no] passive-interface default",
383 "Suppress routing updates on an interface\n"
384 "default for all interfaces\n")
386 nb_cli_enqueue_change(vty
, "./passive-default", NB_OP_MODIFY
,
387 no
? "false" : "true");
389 return nb_cli_apply_changes(vty
, NULL
);
392 void cli_show_rip_passive_default(struct vty
*vty
, const struct lyd_node
*dnode
,
395 if (!yang_dnode_get_bool(dnode
, NULL
))
398 vty_out(vty
, " passive-interface default\n");
402 * XPath: /frr-ripd:ripd/instance/passive-interface
403 * /frr-ripd:ripd/instance/non-passive-interface
405 DEFPY_YANG (rip_passive_interface
,
406 rip_passive_interface_cmd
,
407 "[no] passive-interface IFNAME",
409 "Suppress routing updates on an interface\n"
412 bool passive_default
=
413 yang_dnode_get_bool(vty
->candidate_config
->dnode
, "%s%s",
414 VTY_CURR_XPATH
, "/passive-default");
416 if (passive_default
) {
417 nb_cli_enqueue_change(vty
, "./non-passive-interface",
418 no
? NB_OP_CREATE
: NB_OP_DESTROY
,
421 nb_cli_enqueue_change(vty
, "./passive-interface",
422 no
? NB_OP_DESTROY
: NB_OP_CREATE
,
426 return nb_cli_apply_changes(vty
, NULL
);
429 void cli_show_rip_passive_interface(struct vty
*vty
,
430 const struct lyd_node
*dnode
,
433 vty_out(vty
, " passive-interface %s\n",
434 yang_dnode_get_string(dnode
, NULL
));
437 void cli_show_rip_non_passive_interface(struct vty
*vty
,
438 const struct lyd_node
*dnode
,
441 vty_out(vty
, " no passive-interface %s\n",
442 yang_dnode_get_string(dnode
, NULL
));
446 * XPath: /frr-ripd:ripd/instance/redistribute
448 DEFPY_YANG (rip_redistribute
,
449 rip_redistribute_cmd
,
450 "[no] redistribute " FRR_REDIST_STR_RIPD
"$protocol [{metric (0-16)|route-map RMAP_NAME$route_map}]",
453 FRR_REDIST_HELP_STR_RIPD
456 "Route map reference\n"
457 "Pointer to route-map entries\n")
460 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
461 nb_cli_enqueue_change(vty
, "./route-map",
462 route_map
? NB_OP_MODIFY
: NB_OP_DESTROY
,
464 nb_cli_enqueue_change(vty
, "./metric",
465 metric_str
? NB_OP_MODIFY
: NB_OP_DESTROY
,
468 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
470 return nb_cli_apply_changes(vty
, "./redistribute[protocol='%s']",
474 void cli_show_rip_redistribute(struct vty
*vty
, const struct lyd_node
*dnode
,
477 vty_out(vty
, " redistribute %s",
478 yang_dnode_get_string(dnode
, "./protocol"));
479 if (yang_dnode_exists(dnode
, "./metric"))
480 vty_out(vty
, " metric %s",
481 yang_dnode_get_string(dnode
, "./metric"));
482 if (yang_dnode_exists(dnode
, "./route-map"))
483 vty_out(vty
, " route-map %s",
484 yang_dnode_get_string(dnode
, "./route-map"));
489 * XPath: /frr-ripd:ripd/instance/static-route
491 DEFPY_YANG (rip_route
,
493 "[no] route A.B.C.D/M",
495 "RIP static route configuration\n"
496 "IP prefix <network>/<length>\n")
498 nb_cli_enqueue_change(vty
, "./static-route",
499 no
? NB_OP_DESTROY
: NB_OP_CREATE
, route_str
);
501 return nb_cli_apply_changes(vty
, NULL
);
504 void cli_show_rip_route(struct vty
*vty
, const struct lyd_node
*dnode
,
507 vty_out(vty
, " route %s\n", yang_dnode_get_string(dnode
, NULL
));
511 * XPath: /frr-ripd:ripd/instance/timers
513 DEFPY_YANG (rip_timers
,
515 "timers basic (5-2147483647)$update (5-2147483647)$timeout (5-2147483647)$garbage",
516 "Adjust routing timers\n"
517 "Basic routing protocol update timers\n"
518 "Routing table update timer value in second. Default is 30.\n"
519 "Routing information timeout timer. Default is 180.\n"
520 "Garbage collection timer. Default is 120.\n")
522 nb_cli_enqueue_change(vty
, "./update-interval", NB_OP_MODIFY
,
524 nb_cli_enqueue_change(vty
, "./holddown-interval", NB_OP_MODIFY
,
526 nb_cli_enqueue_change(vty
, "./flush-interval", NB_OP_MODIFY
,
529 return nb_cli_apply_changes(vty
, "./timers");
532 DEFPY_YANG (no_rip_timers
,
534 "no timers basic [(5-2147483647) (5-2147483647) (5-2147483647)]",
536 "Adjust routing timers\n"
537 "Basic routing protocol update timers\n"
538 "Routing table update timer value in second. Default is 30.\n"
539 "Routing information timeout timer. Default is 180.\n"
540 "Garbage collection timer. Default is 120.\n")
542 nb_cli_enqueue_change(vty
, "./update-interval", NB_OP_MODIFY
, NULL
);
543 nb_cli_enqueue_change(vty
, "./holddown-interval", NB_OP_MODIFY
, NULL
);
544 nb_cli_enqueue_change(vty
, "./flush-interval", NB_OP_MODIFY
, NULL
);
546 return nb_cli_apply_changes(vty
, "./timers");
549 void cli_show_rip_timers(struct vty
*vty
, const struct lyd_node
*dnode
,
552 vty_out(vty
, " timers basic %s %s %s\n",
553 yang_dnode_get_string(dnode
, "./update-interval"),
554 yang_dnode_get_string(dnode
, "./holddown-interval"),
555 yang_dnode_get_string(dnode
, "./flush-interval"));
559 * XPath: /frr-ripd:ripd/instance/version
561 DEFPY_YANG (rip_version
,
564 "Set routing protocol version\n"
567 nb_cli_enqueue_change(vty
, "./version/receive", NB_OP_MODIFY
,
569 nb_cli_enqueue_change(vty
, "./version/send", NB_OP_MODIFY
, version_str
);
571 return nb_cli_apply_changes(vty
, NULL
);
574 DEFPY_YANG (no_rip_version
,
576 "no version [(1-2)]",
578 "Set routing protocol version\n"
581 nb_cli_enqueue_change(vty
, "./version/receive", NB_OP_MODIFY
, NULL
);
582 nb_cli_enqueue_change(vty
, "./version/send", NB_OP_MODIFY
, NULL
);
584 return nb_cli_apply_changes(vty
, NULL
);
587 void cli_show_rip_version(struct vty
*vty
, const struct lyd_node
*dnode
,
591 * We have only one "version" command and three possible combinations of
592 * send/receive values.
594 switch (yang_dnode_get_enum(dnode
, "./receive")) {
595 case RI_RIP_VERSION_1
:
596 vty_out(vty
, " version 1\n");
598 case RI_RIP_VERSION_2
:
599 vty_out(vty
, " version 2\n");
601 case RI_RIP_VERSION_1_AND_2
:
602 vty_out(vty
, " no version\n");
608 * XPath: /frr-ripd:ripd/instance/default-bfd-profile
610 DEFPY_YANG(rip_bfd_default_profile
, rip_bfd_default_profile_cmd
,
611 "bfd default-profile BFDPROF$profile",
612 "Bidirectional Forwarding Detection\n"
613 "BFD default profile\n"
616 nb_cli_enqueue_change(vty
, "./default-bfd-profile", NB_OP_MODIFY
,
619 return nb_cli_apply_changes(vty
, NULL
);
622 DEFPY_YANG(no_rip_bfd_default_profile
, no_rip_bfd_default_profile_cmd
,
623 "no bfd default-profile [BFDPROF]",
625 "Bidirectional Forwarding Detection\n"
626 "BFD default profile\n"
629 nb_cli_enqueue_change(vty
, "./default-bfd-profile", NB_OP_DESTROY
,
632 return nb_cli_apply_changes(vty
, NULL
);
635 void cli_show_ripd_instance_default_bfd_profile(struct vty
*vty
,
636 const struct lyd_node
*dnode
,
639 vty_out(vty
, " bfd default-profile %s\n",
640 yang_dnode_get_string(dnode
, NULL
));
644 * XPath: /frr-interface:lib/interface/frr-ripd:rip/split-horizon
646 DEFPY_YANG (ip_rip_split_horizon
,
647 ip_rip_split_horizon_cmd
,
648 "[no] ip rip split-horizon [poisoned-reverse$poisoned_reverse]",
651 "Routing Information Protocol\n"
652 "Perform split horizon\n"
653 "With poisoned-reverse\n")
659 else if (poisoned_reverse
)
660 value
= "poison-reverse";
664 nb_cli_enqueue_change(vty
, "./split-horizon", NB_OP_MODIFY
, value
);
666 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
669 void cli_show_ip_rip_split_horizon(struct vty
*vty
,
670 const struct lyd_node
*dnode
,
675 value
= yang_dnode_get_enum(dnode
, NULL
);
677 case RIP_NO_SPLIT_HORIZON
:
678 vty_out(vty
, " no ip rip split-horizon\n");
680 case RIP_SPLIT_HORIZON
:
681 vty_out(vty
, " ip rip split-horizon\n");
683 case RIP_SPLIT_HORIZON_POISONED_REVERSE
:
684 vty_out(vty
, " ip rip split-horizon poisoned-reverse\n");
690 * XPath: /frr-interface:lib/interface/frr-ripd:rip/v2-broadcast
692 DEFPY_YANG (ip_rip_v2_broadcast
,
693 ip_rip_v2_broadcast_cmd
,
694 "[no] ip rip v2-broadcast",
697 "Routing Information Protocol\n"
698 "Send ip broadcast v2 update\n")
700 nb_cli_enqueue_change(vty
, "./v2-broadcast", NB_OP_MODIFY
,
701 no
? "false" : "true");
703 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
706 void cli_show_ip_rip_v2_broadcast(struct vty
*vty
, const struct lyd_node
*dnode
,
709 if (!yang_dnode_get_bool(dnode
, NULL
))
712 vty_out(vty
, " ip rip v2-broadcast\n");
716 * XPath: /frr-interface:lib/interface/frr-ripd:rip/version-receive
718 DEFPY_YANG (ip_rip_receive_version
,
719 ip_rip_receive_version_cmd
,
720 "ip rip receive version <{1$v1|2$v2}|none>",
722 "Routing Information Protocol\n"
723 "Advertisement reception\n"
740 nb_cli_enqueue_change(vty
, "./version-receive", NB_OP_MODIFY
, value
);
742 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
745 DEFPY_YANG (no_ip_rip_receive_version
,
746 no_ip_rip_receive_version_cmd
,
747 "no ip rip receive version [<{1|2}|none>]",
750 "Routing Information Protocol\n"
751 "Advertisement reception\n"
757 nb_cli_enqueue_change(vty
, "./version-receive", NB_OP_MODIFY
, NULL
);
759 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
762 void cli_show_ip_rip_receive_version(struct vty
*vty
,
763 const struct lyd_node
*dnode
,
766 switch (yang_dnode_get_enum(dnode
, NULL
)) {
768 vty_out(vty
, " no ip rip receive version\n");
770 case RI_RIP_VERSION_1
:
771 vty_out(vty
, " ip rip receive version 1\n");
773 case RI_RIP_VERSION_2
:
774 vty_out(vty
, " ip rip receive version 2\n");
776 case RI_RIP_VERSION_1_AND_2
:
777 vty_out(vty
, " ip rip receive version 1 2\n");
779 case RI_RIP_VERSION_NONE
:
780 vty_out(vty
, " ip rip receive version none\n");
786 * XPath: /frr-interface:lib/interface/frr-ripd:rip/version-send
788 DEFPY_YANG (ip_rip_send_version
,
789 ip_rip_send_version_cmd
,
790 "ip rip send version <{1$v1|2$v2}|none>",
792 "Routing Information Protocol\n"
793 "Advertisement transmission\n"
810 nb_cli_enqueue_change(vty
, "./version-send", NB_OP_MODIFY
, value
);
812 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
815 DEFPY_YANG (no_ip_rip_send_version
,
816 no_ip_rip_send_version_cmd
,
817 "no ip rip send version [<{1|2}|none>]",
820 "Routing Information Protocol\n"
821 "Advertisement transmission\n"
827 nb_cli_enqueue_change(vty
, "./version-send", NB_OP_MODIFY
, NULL
);
829 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
832 void cli_show_ip_rip_send_version(struct vty
*vty
, const struct lyd_node
*dnode
,
835 switch (yang_dnode_get_enum(dnode
, NULL
)) {
837 vty_out(vty
, " no ip rip send version\n");
839 case RI_RIP_VERSION_1
:
840 vty_out(vty
, " ip rip send version 1\n");
842 case RI_RIP_VERSION_2
:
843 vty_out(vty
, " ip rip send version 2\n");
845 case RI_RIP_VERSION_1_AND_2
:
846 vty_out(vty
, " ip rip send version 1 2\n");
848 case RI_RIP_VERSION_NONE
:
849 vty_out(vty
, " ip rip send version none\n");
855 * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-scheme
857 DEFPY_YANG (ip_rip_authentication_mode
,
858 ip_rip_authentication_mode_cmd
,
859 "ip rip authentication mode <md5$mode [auth-length <rfc|old-ripd>$auth_length]|text$mode>",
861 "Routing Information Protocol\n"
862 "Authentication control\n"
863 "Authentication mode\n"
864 "Keyed message digest\n"
865 "MD5 authentication data length\n"
867 "Old ripd compatible\n"
868 "Clear text authentication\n")
870 const char *value
= NULL
;
873 if (strmatch(auth_length
, "rfc"))
879 nb_cli_enqueue_change(vty
, "./authentication-scheme/mode", NB_OP_MODIFY
,
880 strmatch(mode
, "md5") ? "md5" : "plain-text");
881 if (strmatch(mode
, "md5"))
882 nb_cli_enqueue_change(vty
,
883 "./authentication-scheme/md5-auth-length",
884 NB_OP_MODIFY
, value
);
886 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
889 DEFPY_YANG (no_ip_rip_authentication_mode
,
890 no_ip_rip_authentication_mode_cmd
,
891 "no ip rip authentication mode [<md5 [auth-length <rfc|old-ripd>]|text>]",
894 "Routing Information Protocol\n"
895 "Authentication control\n"
896 "Authentication mode\n"
897 "Keyed message digest\n"
898 "MD5 authentication data length\n"
900 "Old ripd compatible\n"
901 "Clear text authentication\n")
903 nb_cli_enqueue_change(vty
, "./authentication-scheme/mode", NB_OP_MODIFY
,
905 nb_cli_enqueue_change(vty
, "./authentication-scheme/md5-auth-length",
906 NB_OP_DESTROY
, NULL
);
908 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
911 void cli_show_ip_rip_authentication_scheme(struct vty
*vty
,
912 const struct lyd_node
*dnode
,
915 switch (yang_dnode_get_enum(dnode
, "./mode")) {
917 vty_out(vty
, " no ip rip authentication mode\n");
919 case RIP_AUTH_SIMPLE_PASSWORD
:
920 vty_out(vty
, " ip rip authentication mode text\n");
923 vty_out(vty
, " ip rip authentication mode md5");
925 || !yang_dnode_is_default(dnode
, "./md5-auth-length")) {
926 if (yang_dnode_get_enum(dnode
, "./md5-auth-length")
927 == RIP_AUTH_MD5_SIZE
)
928 vty_out(vty
, " auth-length rfc");
930 vty_out(vty
, " auth-length old-ripd");
938 * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-password
940 DEFPY_YANG (ip_rip_authentication_string
,
941 ip_rip_authentication_string_cmd
,
942 "ip rip authentication string LINE$password",
944 "Routing Information Protocol\n"
945 "Authentication control\n"
946 "Authentication string\n"
947 "Authentication string\n")
949 if (strlen(password
) > 16) {
951 "%% RIPv2 authentication string must be shorter than 16\n");
952 return CMD_WARNING_CONFIG_FAILED
;
955 if (yang_dnode_existsf(vty
->candidate_config
->dnode
, "%s%s",
957 "/frr-ripd:rip/authentication-key-chain")) {
958 vty_out(vty
, "%% key-chain configuration exists\n");
959 return CMD_WARNING_CONFIG_FAILED
;
962 nb_cli_enqueue_change(vty
, "./authentication-password", NB_OP_MODIFY
,
965 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
968 DEFPY_YANG (no_ip_rip_authentication_string
,
969 no_ip_rip_authentication_string_cmd
,
970 "no ip rip authentication string [LINE]",
973 "Routing Information Protocol\n"
974 "Authentication control\n"
975 "Authentication string\n"
976 "Authentication string\n")
978 nb_cli_enqueue_change(vty
, "./authentication-password", NB_OP_DESTROY
,
981 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
984 void cli_show_ip_rip_authentication_string(struct vty
*vty
,
985 const struct lyd_node
*dnode
,
988 vty_out(vty
, " ip rip authentication string %s\n",
989 yang_dnode_get_string(dnode
, NULL
));
993 * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-key-chain
995 DEFPY_YANG (ip_rip_authentication_key_chain
,
996 ip_rip_authentication_key_chain_cmd
,
997 "ip rip authentication key-chain LINE$keychain",
999 "Routing Information Protocol\n"
1000 "Authentication control\n"
1001 "Authentication key-chain\n"
1002 "name of key-chain\n")
1004 if (yang_dnode_existsf(vty
->candidate_config
->dnode
, "%s%s",
1006 "/frr-ripd:rip/authentication-password")) {
1007 vty_out(vty
, "%% authentication string configuration exists\n");
1008 return CMD_WARNING_CONFIG_FAILED
;
1011 nb_cli_enqueue_change(vty
, "./authentication-key-chain", NB_OP_MODIFY
,
1014 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
1017 DEFPY_YANG (no_ip_rip_authentication_key_chain
,
1018 no_ip_rip_authentication_key_chain_cmd
,
1019 "no ip rip authentication key-chain [LINE]",
1022 "Routing Information Protocol\n"
1023 "Authentication control\n"
1024 "Authentication key-chain\n"
1025 "name of key-chain\n")
1027 nb_cli_enqueue_change(vty
, "./authentication-key-chain", NB_OP_DESTROY
,
1030 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
1033 void cli_show_ip_rip_authentication_key_chain(struct vty
*vty
,
1034 const struct lyd_node
*dnode
,
1037 vty_out(vty
, " ip rip authentication key-chain %s\n",
1038 yang_dnode_get_string(dnode
, NULL
));
1042 * XPath: /frr-interface:lib/interface/frr-ripd:rip/bfd-monitoring/enable
1044 DEFPY_YANG(ip_rip_bfd
, ip_rip_bfd_cmd
, "[no] ip rip bfd",
1046 "Routing Information Protocol\n"
1047 "Enable BFD support\n")
1049 nb_cli_enqueue_change(vty
, "./bfd-monitoring/enable", NB_OP_MODIFY
,
1050 no
? "false" : "true");
1052 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
1055 void cli_show_ip_rip_bfd_enable(struct vty
*vty
, const struct lyd_node
*dnode
,
1058 vty_out(vty
, " ip rip bfd\n");
1062 * XPath: /frr-interface:lib/interface/frr-ripd:rip/bfd/profile
1064 DEFPY_YANG(ip_rip_bfd_profile
, ip_rip_bfd_profile_cmd
,
1065 "[no] ip rip bfd profile BFDPROF$profile",
1067 "Routing Information Protocol\n"
1068 "Enable BFD support\n"
1069 "Use a pre-configured profile\n"
1073 nb_cli_enqueue_change(vty
, "./bfd-monitoring/profile",
1074 NB_OP_DESTROY
, NULL
);
1076 nb_cli_enqueue_change(vty
, "./bfd-monitoring/profile",
1077 NB_OP_MODIFY
, profile
);
1079 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
1082 DEFPY_YANG(no_ip_rip_bfd_profile
, no_ip_rip_bfd_profile_cmd
,
1083 "no ip rip bfd profile",
1085 "Routing Information Protocol\n"
1086 "Enable BFD support\n"
1087 "Use a pre-configured profile\n")
1089 nb_cli_enqueue_change(vty
, "./bfd-monitoring/profile", NB_OP_DESTROY
,
1091 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
1094 void cli_show_ip_rip_bfd_profile(struct vty
*vty
, const struct lyd_node
*dnode
,
1097 vty_out(vty
, " ip rip bfd profile %s\n",
1098 yang_dnode_get_string(dnode
, NULL
));
1102 * XPath: /frr-ripd:clear-rip-route
1104 DEFPY_YANG (clear_ip_rip
,
1106 "clear ip rip [vrf WORD]",
1109 "Clear IP RIP database\n"
1117 struct yang_data
*yang_vrf
;
1119 yang_vrf
= yang_data_new("/frr-ripd:clear-rip-route/input/vrf",
1121 listnode_add(input
, yang_vrf
);
1124 ret
= nb_cli_rpc(vty
, "/frr-ripd:clear-rip-route", input
, NULL
);
1126 list_delete(&input
);
1131 DEFUN (rip_distribute_list
,
1132 rip_distribute_list_cmd
,
1133 "distribute-list [prefix] ACCESSLIST4_NAME <in|out> [WORD]",
1134 "Filter networks in routing updates\n"
1135 "Specify a prefix\n"
1136 "Access-list name\n"
1137 "Filter incoming routing updates\n"
1138 "Filter outgoing routing updates\n"
1141 const char *ifname
= NULL
;
1142 int prefix
= (argv
[1]->type
== WORD_TKN
) ? 1 : 0;
1144 if (argv
[argc
- 1]->type
== VARIABLE_TKN
)
1145 ifname
= argv
[argc
- 1]->arg
;
1147 return distribute_list_parser(prefix
, true, argv
[2 + prefix
]->text
,
1148 argv
[1 + prefix
]->arg
, ifname
);
1151 DEFUN (rip_no_distribute_list
,
1152 rip_no_distribute_list_cmd
,
1153 "no distribute-list [prefix] ACCESSLIST4_NAME <in|out> [WORD]",
1155 "Filter networks in routing updates\n"
1156 "Specify a prefix\n"
1157 "Access-list name\n"
1158 "Filter incoming routing updates\n"
1159 "Filter outgoing routing updates\n"
1162 const char *ifname
= NULL
;
1163 int prefix
= (argv
[2]->type
== WORD_TKN
) ? 1 : 0;
1165 if (argv
[argc
- 1]->type
== VARIABLE_TKN
)
1166 ifname
= argv
[argc
- 1]->arg
;
1168 return distribute_list_no_parser(vty
, prefix
, true,
1169 argv
[3 + prefix
]->text
,
1170 argv
[2 + prefix
]->arg
, ifname
);
1173 void rip_cli_init(void)
1175 install_element(CONFIG_NODE
, &router_rip_cmd
);
1176 install_element(CONFIG_NODE
, &no_router_rip_cmd
);
1178 install_element(RIP_NODE
, &rip_distribute_list_cmd
);
1179 install_element(RIP_NODE
, &rip_no_distribute_list_cmd
);
1181 install_element(RIP_NODE
, &rip_allow_ecmp_cmd
);
1182 install_element(RIP_NODE
, &no_rip_allow_ecmp_cmd
);
1183 install_element(RIP_NODE
, &rip_default_information_originate_cmd
);
1184 install_element(RIP_NODE
, &rip_default_metric_cmd
);
1185 install_element(RIP_NODE
, &no_rip_default_metric_cmd
);
1186 install_element(RIP_NODE
, &rip_distance_cmd
);
1187 install_element(RIP_NODE
, &no_rip_distance_cmd
);
1188 install_element(RIP_NODE
, &rip_distance_source_cmd
);
1189 install_element(RIP_NODE
, &rip_neighbor_cmd
);
1190 install_element(RIP_NODE
, &rip_network_prefix_cmd
);
1191 install_element(RIP_NODE
, &rip_network_if_cmd
);
1192 install_element(RIP_NODE
, &rip_offset_list_cmd
);
1193 install_element(RIP_NODE
, &rip_passive_default_cmd
);
1194 install_element(RIP_NODE
, &rip_passive_interface_cmd
);
1195 install_element(RIP_NODE
, &rip_redistribute_cmd
);
1196 install_element(RIP_NODE
, &rip_route_cmd
);
1197 install_element(RIP_NODE
, &rip_timers_cmd
);
1198 install_element(RIP_NODE
, &no_rip_timers_cmd
);
1199 install_element(RIP_NODE
, &rip_version_cmd
);
1200 install_element(RIP_NODE
, &no_rip_version_cmd
);
1201 install_element(RIP_NODE
, &rip_bfd_default_profile_cmd
);
1202 install_element(RIP_NODE
, &no_rip_bfd_default_profile_cmd
);
1204 install_element(INTERFACE_NODE
, &ip_rip_split_horizon_cmd
);
1205 install_element(INTERFACE_NODE
, &ip_rip_v2_broadcast_cmd
);
1206 install_element(INTERFACE_NODE
, &ip_rip_receive_version_cmd
);
1207 install_element(INTERFACE_NODE
, &no_ip_rip_receive_version_cmd
);
1208 install_element(INTERFACE_NODE
, &ip_rip_send_version_cmd
);
1209 install_element(INTERFACE_NODE
, &no_ip_rip_send_version_cmd
);
1210 install_element(INTERFACE_NODE
, &ip_rip_authentication_mode_cmd
);
1211 install_element(INTERFACE_NODE
, &no_ip_rip_authentication_mode_cmd
);
1212 install_element(INTERFACE_NODE
, &ip_rip_authentication_string_cmd
);
1213 install_element(INTERFACE_NODE
, &no_ip_rip_authentication_string_cmd
);
1214 install_element(INTERFACE_NODE
, &ip_rip_authentication_key_chain_cmd
);
1215 install_element(INTERFACE_NODE
,
1216 &no_ip_rip_authentication_key_chain_cmd
);
1217 install_element(INTERFACE_NODE
, &ip_rip_bfd_cmd
);
1218 install_element(INTERFACE_NODE
, &ip_rip_bfd_profile_cmd
);
1219 install_element(INTERFACE_NODE
, &no_ip_rip_bfd_profile_cmd
);
1221 install_element(ENABLE_NODE
, &clear_ip_rip_cmd
);