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 DEFPY_YANG (rip_allow_ecmp
,
92 "Allow Equal Cost MultiPath\n")
94 nb_cli_enqueue_change(vty
, "./allow-ecmp", NB_OP_MODIFY
,
95 no
? "false" : "true");
97 return nb_cli_apply_changes(vty
, NULL
);
100 void cli_show_rip_allow_ecmp(struct vty
*vty
, const struct lyd_node
*dnode
,
103 if (!yang_dnode_get_bool(dnode
, NULL
))
106 vty_out(vty
, " allow-ecmp\n");
110 * XPath: /frr-ripd:ripd/instance/default-information-originate
112 DEFPY_YANG (rip_default_information_originate
,
113 rip_default_information_originate_cmd
,
114 "[no] default-information originate",
116 "Control distribution of default route\n"
117 "Distribute a default route\n")
119 nb_cli_enqueue_change(vty
, "./default-information-originate",
120 NB_OP_MODIFY
, no
? "false" : "true");
122 return nb_cli_apply_changes(vty
, NULL
);
125 void cli_show_rip_default_information_originate(struct vty
*vty
,
126 const struct lyd_node
*dnode
,
129 if (!yang_dnode_get_bool(dnode
, NULL
))
132 vty_out(vty
, " default-information originate\n");
136 * XPath: /frr-ripd:ripd/instance/default-metric
138 DEFPY_YANG (rip_default_metric
,
139 rip_default_metric_cmd
,
140 "default-metric (1-16)",
141 "Set a metric of redistribute routes\n"
144 nb_cli_enqueue_change(vty
, "./default-metric", NB_OP_MODIFY
,
147 return nb_cli_apply_changes(vty
, NULL
);
150 DEFPY_YANG (no_rip_default_metric
,
151 no_rip_default_metric_cmd
,
152 "no default-metric [(1-16)]",
154 "Set a metric of redistribute routes\n"
157 nb_cli_enqueue_change(vty
, "./default-metric", NB_OP_MODIFY
, NULL
);
159 return nb_cli_apply_changes(vty
, NULL
);
162 void cli_show_rip_default_metric(struct vty
*vty
, const struct lyd_node
*dnode
,
165 vty_out(vty
, " default-metric %s\n",
166 yang_dnode_get_string(dnode
, NULL
));
170 * XPath: /frr-ripd:ripd/instance/distance/default
172 DEFPY_YANG (rip_distance
,
175 "Administrative distance\n"
178 nb_cli_enqueue_change(vty
, "./distance/default", NB_OP_MODIFY
,
181 return nb_cli_apply_changes(vty
, NULL
);
184 DEFPY_YANG (no_rip_distance
,
186 "no distance [(1-255)]",
188 "Administrative distance\n"
191 nb_cli_enqueue_change(vty
, "./distance/default", NB_OP_MODIFY
, NULL
);
193 return nb_cli_apply_changes(vty
, NULL
);
196 void cli_show_rip_distance(struct vty
*vty
, const struct lyd_node
*dnode
,
199 if (yang_dnode_is_default(dnode
, NULL
))
200 vty_out(vty
, " no distance\n");
202 vty_out(vty
, " distance %s\n",
203 yang_dnode_get_string(dnode
, NULL
));
207 * XPath: /frr-ripd:ripd/instance/distance/source
209 DEFPY_YANG (rip_distance_source
,
210 rip_distance_source_cmd
,
211 "[no] distance (1-255) A.B.C.D/M$prefix [WORD$acl]",
213 "Administrative distance\n"
216 "Access list name\n")
219 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
220 nb_cli_enqueue_change(vty
, "./distance", NB_OP_MODIFY
,
222 nb_cli_enqueue_change(vty
, "./access-list",
223 acl
? NB_OP_MODIFY
: NB_OP_DESTROY
, acl
);
225 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
227 return nb_cli_apply_changes(vty
, "./distance/source[prefix='%s']",
231 void cli_show_rip_distance_source(struct vty
*vty
, const struct lyd_node
*dnode
,
234 vty_out(vty
, " distance %s %s",
235 yang_dnode_get_string(dnode
, "./distance"),
236 yang_dnode_get_string(dnode
, "./prefix"));
237 if (yang_dnode_exists(dnode
, "./access-list"))
239 yang_dnode_get_string(dnode
, "./access-list"));
244 * XPath: /frr-ripd:ripd/instance/explicit-neighbor
246 DEFPY_YANG (rip_neighbor
,
248 "[no] neighbor A.B.C.D",
250 "Specify a neighbor router\n"
251 "Neighbor address\n")
253 nb_cli_enqueue_change(vty
, "./explicit-neighbor",
254 no
? NB_OP_DESTROY
: NB_OP_CREATE
, neighbor_str
);
256 return nb_cli_apply_changes(vty
, NULL
);
259 void cli_show_rip_neighbor(struct vty
*vty
, const struct lyd_node
*dnode
,
262 vty_out(vty
, " neighbor %s\n", yang_dnode_get_string(dnode
, NULL
));
266 * XPath: /frr-ripd:ripd/instance/network
268 DEFPY_YANG (rip_network_prefix
,
269 rip_network_prefix_cmd
,
270 "[no] network A.B.C.D/M",
272 "Enable routing on an IP network\n"
273 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
275 nb_cli_enqueue_change(vty
, "./network",
276 no
? NB_OP_DESTROY
: NB_OP_CREATE
, network_str
);
278 return nb_cli_apply_changes(vty
, NULL
);
281 void cli_show_rip_network_prefix(struct vty
*vty
, const struct lyd_node
*dnode
,
284 vty_out(vty
, " network %s\n", yang_dnode_get_string(dnode
, NULL
));
288 * XPath: /frr-ripd:ripd/instance/interface
290 DEFPY_YANG (rip_network_if
,
294 "Enable routing on an IP network\n"
297 nb_cli_enqueue_change(vty
, "./interface",
298 no
? NB_OP_DESTROY
: NB_OP_CREATE
, network
);
300 return nb_cli_apply_changes(vty
, NULL
);
303 void cli_show_rip_network_interface(struct vty
*vty
,
304 const struct lyd_node
*dnode
,
307 vty_out(vty
, " network %s\n", yang_dnode_get_string(dnode
, NULL
));
311 * XPath: /frr-ripd:ripd/instance/offset-list
313 DEFPY_YANG (rip_offset_list
,
315 "[no] offset-list ACCESSLIST4_NAME$acl <in|out>$direction (0-16)$metric [IFNAME]",
317 "Modify RIP metric\n"
319 "For incoming updates\n"
320 "For outgoing updates\n"
322 "Interface to match\n")
325 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
326 nb_cli_enqueue_change(vty
, "./access-list", NB_OP_MODIFY
, acl
);
327 nb_cli_enqueue_change(vty
, "./metric", NB_OP_MODIFY
,
330 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
332 return nb_cli_apply_changes(
333 vty
, "./offset-list[interface='%s'][direction='%s']",
334 ifname
? ifname
: "*", direction
);
337 void cli_show_rip_offset_list(struct vty
*vty
, const struct lyd_node
*dnode
,
340 const char *interface
;
342 interface
= yang_dnode_get_string(dnode
, "./interface");
344 vty_out(vty
, " offset-list %s %s %s",
345 yang_dnode_get_string(dnode
, "./access-list"),
346 yang_dnode_get_string(dnode
, "./direction"),
347 yang_dnode_get_string(dnode
, "./metric"));
348 if (!strmatch(interface
, "*"))
349 vty_out(vty
, " %s", interface
);
354 * XPath: /frr-ripd:ripd/instance/passive-default
356 DEFPY_YANG (rip_passive_default
,
357 rip_passive_default_cmd
,
358 "[no] passive-interface default",
360 "Suppress routing updates on an interface\n"
361 "default for all interfaces\n")
363 nb_cli_enqueue_change(vty
, "./passive-default", NB_OP_MODIFY
,
364 no
? "false" : "true");
366 return nb_cli_apply_changes(vty
, NULL
);
369 void cli_show_rip_passive_default(struct vty
*vty
, const struct lyd_node
*dnode
,
372 if (!yang_dnode_get_bool(dnode
, NULL
))
375 vty_out(vty
, " passive-interface default\n");
379 * XPath: /frr-ripd:ripd/instance/passive-interface
380 * /frr-ripd:ripd/instance/non-passive-interface
382 DEFPY_YANG (rip_passive_interface
,
383 rip_passive_interface_cmd
,
384 "[no] passive-interface IFNAME",
386 "Suppress routing updates on an interface\n"
389 bool passive_default
=
390 yang_dnode_get_bool(vty
->candidate_config
->dnode
, "%s%s",
391 VTY_CURR_XPATH
, "/passive-default");
393 if (passive_default
) {
394 nb_cli_enqueue_change(vty
, "./non-passive-interface",
395 no
? NB_OP_CREATE
: NB_OP_DESTROY
,
398 nb_cli_enqueue_change(vty
, "./passive-interface",
399 no
? NB_OP_DESTROY
: NB_OP_CREATE
,
403 return nb_cli_apply_changes(vty
, NULL
);
406 void cli_show_rip_passive_interface(struct vty
*vty
,
407 const struct lyd_node
*dnode
,
410 vty_out(vty
, " passive-interface %s\n",
411 yang_dnode_get_string(dnode
, NULL
));
414 void cli_show_rip_non_passive_interface(struct vty
*vty
,
415 const struct lyd_node
*dnode
,
418 vty_out(vty
, " no passive-interface %s\n",
419 yang_dnode_get_string(dnode
, NULL
));
423 * XPath: /frr-ripd:ripd/instance/redistribute
425 DEFPY_YANG (rip_redistribute
,
426 rip_redistribute_cmd
,
427 "[no] redistribute " FRR_REDIST_STR_RIPD
"$protocol [{metric (0-16)|route-map RMAP_NAME$route_map}]",
430 FRR_REDIST_HELP_STR_RIPD
433 "Route map reference\n"
434 "Pointer to route-map entries\n")
437 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
438 nb_cli_enqueue_change(vty
, "./route-map",
439 route_map
? NB_OP_MODIFY
: NB_OP_DESTROY
,
441 nb_cli_enqueue_change(vty
, "./metric",
442 metric_str
? NB_OP_MODIFY
: NB_OP_DESTROY
,
445 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
447 return nb_cli_apply_changes(vty
, "./redistribute[protocol='%s']",
451 void cli_show_rip_redistribute(struct vty
*vty
, const struct lyd_node
*dnode
,
454 vty_out(vty
, " redistribute %s",
455 yang_dnode_get_string(dnode
, "./protocol"));
456 if (yang_dnode_exists(dnode
, "./metric"))
457 vty_out(vty
, " metric %s",
458 yang_dnode_get_string(dnode
, "./metric"));
459 if (yang_dnode_exists(dnode
, "./route-map"))
460 vty_out(vty
, " route-map %s",
461 yang_dnode_get_string(dnode
, "./route-map"));
466 * XPath: /frr-ripd:ripd/instance/static-route
468 DEFPY_YANG (rip_route
,
470 "[no] route A.B.C.D/M",
472 "RIP static route configuration\n"
473 "IP prefix <network>/<length>\n")
475 nb_cli_enqueue_change(vty
, "./static-route",
476 no
? NB_OP_DESTROY
: NB_OP_CREATE
, route_str
);
478 return nb_cli_apply_changes(vty
, NULL
);
481 void cli_show_rip_route(struct vty
*vty
, const struct lyd_node
*dnode
,
484 vty_out(vty
, " route %s\n", yang_dnode_get_string(dnode
, NULL
));
488 * XPath: /frr-ripd:ripd/instance/timers
490 DEFPY_YANG (rip_timers
,
492 "timers basic (5-2147483647)$update (5-2147483647)$timeout (5-2147483647)$garbage",
493 "Adjust routing timers\n"
494 "Basic routing protocol update timers\n"
495 "Routing table update timer value in second. Default is 30.\n"
496 "Routing information timeout timer. Default is 180.\n"
497 "Garbage collection timer. Default is 120.\n")
499 nb_cli_enqueue_change(vty
, "./update-interval", NB_OP_MODIFY
,
501 nb_cli_enqueue_change(vty
, "./holddown-interval", NB_OP_MODIFY
,
503 nb_cli_enqueue_change(vty
, "./flush-interval", NB_OP_MODIFY
,
506 return nb_cli_apply_changes(vty
, "./timers");
509 DEFPY_YANG (no_rip_timers
,
511 "no timers basic [(5-2147483647) (5-2147483647) (5-2147483647)]",
513 "Adjust routing timers\n"
514 "Basic routing protocol update timers\n"
515 "Routing table update timer value in second. Default is 30.\n"
516 "Routing information timeout timer. Default is 180.\n"
517 "Garbage collection timer. Default is 120.\n")
519 nb_cli_enqueue_change(vty
, "./update-interval", NB_OP_MODIFY
, NULL
);
520 nb_cli_enqueue_change(vty
, "./holddown-interval", NB_OP_MODIFY
, NULL
);
521 nb_cli_enqueue_change(vty
, "./flush-interval", NB_OP_MODIFY
, NULL
);
523 return nb_cli_apply_changes(vty
, "./timers");
526 void cli_show_rip_timers(struct vty
*vty
, const struct lyd_node
*dnode
,
529 vty_out(vty
, " timers basic %s %s %s\n",
530 yang_dnode_get_string(dnode
, "./update-interval"),
531 yang_dnode_get_string(dnode
, "./holddown-interval"),
532 yang_dnode_get_string(dnode
, "./flush-interval"));
536 * XPath: /frr-ripd:ripd/instance/version
538 DEFPY_YANG (rip_version
,
541 "Set routing protocol version\n"
544 nb_cli_enqueue_change(vty
, "./version/receive", NB_OP_MODIFY
,
546 nb_cli_enqueue_change(vty
, "./version/send", NB_OP_MODIFY
, version_str
);
548 return nb_cli_apply_changes(vty
, NULL
);
551 DEFPY_YANG (no_rip_version
,
553 "no version [(1-2)]",
555 "Set routing protocol version\n"
558 nb_cli_enqueue_change(vty
, "./version/receive", NB_OP_MODIFY
, NULL
);
559 nb_cli_enqueue_change(vty
, "./version/send", NB_OP_MODIFY
, NULL
);
561 return nb_cli_apply_changes(vty
, NULL
);
564 void cli_show_rip_version(struct vty
*vty
, const struct lyd_node
*dnode
,
568 * We have only one "version" command and three possible combinations of
569 * send/receive values.
571 switch (yang_dnode_get_enum(dnode
, "./receive")) {
572 case RI_RIP_VERSION_1
:
573 vty_out(vty
, " version 1\n");
575 case RI_RIP_VERSION_2
:
576 vty_out(vty
, " version 2\n");
578 case RI_RIP_VERSION_1_AND_2
:
579 vty_out(vty
, " no version\n");
585 * XPath: /frr-interface:lib/interface/frr-ripd:rip/split-horizon
587 DEFPY_YANG (ip_rip_split_horizon
,
588 ip_rip_split_horizon_cmd
,
589 "[no] ip rip split-horizon [poisoned-reverse$poisoned_reverse]",
592 "Routing Information Protocol\n"
593 "Perform split horizon\n"
594 "With poisoned-reverse\n")
600 else if (poisoned_reverse
)
601 value
= "poison-reverse";
605 nb_cli_enqueue_change(vty
, "./split-horizon", NB_OP_MODIFY
, value
);
607 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
610 void cli_show_ip_rip_split_horizon(struct vty
*vty
,
611 const struct lyd_node
*dnode
,
616 value
= yang_dnode_get_enum(dnode
, NULL
);
618 case RIP_NO_SPLIT_HORIZON
:
619 vty_out(vty
, " no ip rip split-horizon\n");
621 case RIP_SPLIT_HORIZON
:
622 vty_out(vty
, " ip rip split-horizon\n");
624 case RIP_SPLIT_HORIZON_POISONED_REVERSE
:
625 vty_out(vty
, " ip rip split-horizon poisoned-reverse\n");
631 * XPath: /frr-interface:lib/interface/frr-ripd:rip/v2-broadcast
633 DEFPY_YANG (ip_rip_v2_broadcast
,
634 ip_rip_v2_broadcast_cmd
,
635 "[no] ip rip v2-broadcast",
638 "Routing Information Protocol\n"
639 "Send ip broadcast v2 update\n")
641 nb_cli_enqueue_change(vty
, "./v2-broadcast", NB_OP_MODIFY
,
642 no
? "false" : "true");
644 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
647 void cli_show_ip_rip_v2_broadcast(struct vty
*vty
, const struct lyd_node
*dnode
,
650 if (!yang_dnode_get_bool(dnode
, NULL
))
653 vty_out(vty
, " ip rip v2-broadcast\n");
657 * XPath: /frr-interface:lib/interface/frr-ripd:rip/version-receive
659 DEFPY_YANG (ip_rip_receive_version
,
660 ip_rip_receive_version_cmd
,
661 "ip rip receive version <{1$v1|2$v2}|none>",
663 "Routing Information Protocol\n"
664 "Advertisement reception\n"
681 nb_cli_enqueue_change(vty
, "./version-receive", NB_OP_MODIFY
, value
);
683 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
686 DEFPY_YANG (no_ip_rip_receive_version
,
687 no_ip_rip_receive_version_cmd
,
688 "no ip rip receive version [<{1|2}|none>]",
691 "Routing Information Protocol\n"
692 "Advertisement reception\n"
698 nb_cli_enqueue_change(vty
, "./version-receive", NB_OP_MODIFY
, NULL
);
700 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
703 void cli_show_ip_rip_receive_version(struct vty
*vty
,
704 const struct lyd_node
*dnode
,
707 switch (yang_dnode_get_enum(dnode
, NULL
)) {
709 vty_out(vty
, " no ip rip receive version\n");
711 case RI_RIP_VERSION_1
:
712 vty_out(vty
, " ip rip receive version 1\n");
714 case RI_RIP_VERSION_2
:
715 vty_out(vty
, " ip rip receive version 2\n");
717 case RI_RIP_VERSION_1_AND_2
:
718 vty_out(vty
, " ip rip receive version 1 2\n");
720 case RI_RIP_VERSION_NONE
:
721 vty_out(vty
, " ip rip receive version none\n");
727 * XPath: /frr-interface:lib/interface/frr-ripd:rip/version-send
729 DEFPY_YANG (ip_rip_send_version
,
730 ip_rip_send_version_cmd
,
731 "ip rip send version <{1$v1|2$v2}|none>",
733 "Routing Information Protocol\n"
734 "Advertisement transmission\n"
751 nb_cli_enqueue_change(vty
, "./version-send", NB_OP_MODIFY
, value
);
753 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
756 DEFPY_YANG (no_ip_rip_send_version
,
757 no_ip_rip_send_version_cmd
,
758 "no ip rip send version [<{1|2}|none>]",
761 "Routing Information Protocol\n"
762 "Advertisement transmission\n"
768 nb_cli_enqueue_change(vty
, "./version-send", NB_OP_MODIFY
, NULL
);
770 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
773 void cli_show_ip_rip_send_version(struct vty
*vty
, const struct lyd_node
*dnode
,
776 switch (yang_dnode_get_enum(dnode
, NULL
)) {
778 vty_out(vty
, " no ip rip send version\n");
780 case RI_RIP_VERSION_1
:
781 vty_out(vty
, " ip rip send version 1\n");
783 case RI_RIP_VERSION_2
:
784 vty_out(vty
, " ip rip send version 2\n");
786 case RI_RIP_VERSION_1_AND_2
:
787 vty_out(vty
, " ip rip send version 1 2\n");
789 case RI_RIP_VERSION_NONE
:
790 vty_out(vty
, " ip rip send version none\n");
796 * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-scheme
798 DEFPY_YANG (ip_rip_authentication_mode
,
799 ip_rip_authentication_mode_cmd
,
800 "ip rip authentication mode <md5$mode [auth-length <rfc|old-ripd>$auth_length]|text$mode>",
802 "Routing Information Protocol\n"
803 "Authentication control\n"
804 "Authentication mode\n"
805 "Keyed message digest\n"
806 "MD5 authentication data length\n"
808 "Old ripd compatible\n"
809 "Clear text authentication\n")
811 const char *value
= NULL
;
814 if (strmatch(auth_length
, "rfc"))
820 nb_cli_enqueue_change(vty
, "./authentication-scheme/mode", NB_OP_MODIFY
,
821 strmatch(mode
, "md5") ? "md5" : "plain-text");
822 if (strmatch(mode
, "md5"))
823 nb_cli_enqueue_change(vty
,
824 "./authentication-scheme/md5-auth-length",
825 NB_OP_MODIFY
, value
);
827 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
830 DEFPY_YANG (no_ip_rip_authentication_mode
,
831 no_ip_rip_authentication_mode_cmd
,
832 "no ip rip authentication mode [<md5 [auth-length <rfc|old-ripd>]|text>]",
835 "Routing Information Protocol\n"
836 "Authentication control\n"
837 "Authentication mode\n"
838 "Keyed message digest\n"
839 "MD5 authentication data length\n"
841 "Old ripd compatible\n"
842 "Clear text authentication\n")
844 nb_cli_enqueue_change(vty
, "./authentication-scheme/mode", NB_OP_MODIFY
,
846 nb_cli_enqueue_change(vty
, "./authentication-scheme/md5-auth-length",
847 NB_OP_DESTROY
, NULL
);
849 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
852 void cli_show_ip_rip_authentication_scheme(struct vty
*vty
,
853 const struct lyd_node
*dnode
,
856 switch (yang_dnode_get_enum(dnode
, "./mode")) {
858 vty_out(vty
, " no ip rip authentication mode\n");
860 case RIP_AUTH_SIMPLE_PASSWORD
:
861 vty_out(vty
, " ip rip authentication mode text\n");
864 vty_out(vty
, " ip rip authentication mode md5");
866 || !yang_dnode_is_default(dnode
, "./md5-auth-length")) {
867 if (yang_dnode_get_enum(dnode
, "./md5-auth-length")
868 == RIP_AUTH_MD5_SIZE
)
869 vty_out(vty
, " auth-length rfc");
871 vty_out(vty
, " auth-length old-ripd");
879 * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-password
881 DEFPY_YANG (ip_rip_authentication_string
,
882 ip_rip_authentication_string_cmd
,
883 "ip rip authentication string LINE$password",
885 "Routing Information Protocol\n"
886 "Authentication control\n"
887 "Authentication string\n"
888 "Authentication string\n")
890 if (strlen(password
) > 16) {
892 "%% RIPv2 authentication string must be shorter than 16\n");
893 return CMD_WARNING_CONFIG_FAILED
;
896 if (yang_dnode_existsf(vty
->candidate_config
->dnode
, "%s%s",
898 "/frr-ripd:rip/authentication-key-chain")) {
899 vty_out(vty
, "%% key-chain configuration exists\n");
900 return CMD_WARNING_CONFIG_FAILED
;
903 nb_cli_enqueue_change(vty
, "./authentication-password", NB_OP_MODIFY
,
906 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
909 DEFPY_YANG (no_ip_rip_authentication_string
,
910 no_ip_rip_authentication_string_cmd
,
911 "no ip rip authentication string [LINE]",
914 "Routing Information Protocol\n"
915 "Authentication control\n"
916 "Authentication string\n"
917 "Authentication string\n")
919 nb_cli_enqueue_change(vty
, "./authentication-password", NB_OP_DESTROY
,
922 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
925 void cli_show_ip_rip_authentication_string(struct vty
*vty
,
926 const struct lyd_node
*dnode
,
929 vty_out(vty
, " ip rip authentication string %s\n",
930 yang_dnode_get_string(dnode
, NULL
));
934 * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-key-chain
936 DEFPY_YANG (ip_rip_authentication_key_chain
,
937 ip_rip_authentication_key_chain_cmd
,
938 "ip rip authentication key-chain LINE$keychain",
940 "Routing Information Protocol\n"
941 "Authentication control\n"
942 "Authentication key-chain\n"
943 "name of key-chain\n")
945 if (yang_dnode_existsf(vty
->candidate_config
->dnode
, "%s%s",
947 "/frr-ripd:rip/authentication-password")) {
948 vty_out(vty
, "%% authentication string configuration exists\n");
949 return CMD_WARNING_CONFIG_FAILED
;
952 nb_cli_enqueue_change(vty
, "./authentication-key-chain", NB_OP_MODIFY
,
955 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
958 DEFPY_YANG (no_ip_rip_authentication_key_chain
,
959 no_ip_rip_authentication_key_chain_cmd
,
960 "no ip rip authentication key-chain [LINE]",
963 "Routing Information Protocol\n"
964 "Authentication control\n"
965 "Authentication key-chain\n"
966 "name of key-chain\n")
968 nb_cli_enqueue_change(vty
, "./authentication-key-chain", NB_OP_DESTROY
,
971 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
974 void cli_show_ip_rip_authentication_key_chain(struct vty
*vty
,
975 const struct lyd_node
*dnode
,
978 vty_out(vty
, " ip rip authentication key-chain %s\n",
979 yang_dnode_get_string(dnode
, NULL
));
983 * XPath: /frr-ripd:clear-rip-route
985 DEFPY_YANG (clear_ip_rip
,
987 "clear ip rip [vrf WORD]",
990 "Clear IP RIP database\n"
998 struct yang_data
*yang_vrf
;
1000 yang_vrf
= yang_data_new("/frr-ripd:clear-rip-route/input/vrf",
1002 listnode_add(input
, yang_vrf
);
1005 ret
= nb_cli_rpc(vty
, "/frr-ripd:clear-rip-route", input
, NULL
);
1007 list_delete(&input
);
1012 DEFUN (rip_distribute_list
,
1013 rip_distribute_list_cmd
,
1014 "distribute-list [prefix] ACCESSLIST4_NAME <in|out> [WORD]",
1015 "Filter networks in routing updates\n"
1016 "Specify a prefix\n"
1017 "Access-list name\n"
1018 "Filter incoming routing updates\n"
1019 "Filter outgoing routing updates\n"
1022 const char *ifname
= NULL
;
1023 int prefix
= (argv
[1]->type
== WORD_TKN
) ? 1 : 0;
1025 if (argv
[argc
- 1]->type
== VARIABLE_TKN
)
1026 ifname
= argv
[argc
- 1]->arg
;
1028 return distribute_list_parser(prefix
, true, argv
[2 + prefix
]->text
,
1029 argv
[1 + prefix
]->arg
, ifname
);
1032 DEFUN (rip_no_distribute_list
,
1033 rip_no_distribute_list_cmd
,
1034 "no distribute-list [prefix] ACCESSLIST4_NAME <in|out> [WORD]",
1036 "Filter networks in routing updates\n"
1037 "Specify a prefix\n"
1038 "Access-list name\n"
1039 "Filter incoming routing updates\n"
1040 "Filter outgoing routing updates\n"
1043 const char *ifname
= NULL
;
1044 int prefix
= (argv
[2]->type
== WORD_TKN
) ? 1 : 0;
1046 if (argv
[argc
- 1]->type
== VARIABLE_TKN
)
1047 ifname
= argv
[argc
- 1]->arg
;
1049 return distribute_list_no_parser(vty
, prefix
, true,
1050 argv
[3 + prefix
]->text
,
1051 argv
[2 + prefix
]->arg
, ifname
);
1054 void rip_cli_init(void)
1056 install_element(CONFIG_NODE
, &router_rip_cmd
);
1057 install_element(CONFIG_NODE
, &no_router_rip_cmd
);
1059 install_element(RIP_NODE
, &rip_distribute_list_cmd
);
1060 install_element(RIP_NODE
, &rip_no_distribute_list_cmd
);
1062 install_element(RIP_NODE
, &rip_allow_ecmp_cmd
);
1063 install_element(RIP_NODE
, &rip_default_information_originate_cmd
);
1064 install_element(RIP_NODE
, &rip_default_metric_cmd
);
1065 install_element(RIP_NODE
, &no_rip_default_metric_cmd
);
1066 install_element(RIP_NODE
, &rip_distance_cmd
);
1067 install_element(RIP_NODE
, &no_rip_distance_cmd
);
1068 install_element(RIP_NODE
, &rip_distance_source_cmd
);
1069 install_element(RIP_NODE
, &rip_neighbor_cmd
);
1070 install_element(RIP_NODE
, &rip_network_prefix_cmd
);
1071 install_element(RIP_NODE
, &rip_network_if_cmd
);
1072 install_element(RIP_NODE
, &rip_offset_list_cmd
);
1073 install_element(RIP_NODE
, &rip_passive_default_cmd
);
1074 install_element(RIP_NODE
, &rip_passive_interface_cmd
);
1075 install_element(RIP_NODE
, &rip_redistribute_cmd
);
1076 install_element(RIP_NODE
, &rip_route_cmd
);
1077 install_element(RIP_NODE
, &rip_timers_cmd
);
1078 install_element(RIP_NODE
, &no_rip_timers_cmd
);
1079 install_element(RIP_NODE
, &rip_version_cmd
);
1080 install_element(RIP_NODE
, &no_rip_version_cmd
);
1082 install_element(INTERFACE_NODE
, &ip_rip_split_horizon_cmd
);
1083 install_element(INTERFACE_NODE
, &ip_rip_v2_broadcast_cmd
);
1084 install_element(INTERFACE_NODE
, &ip_rip_receive_version_cmd
);
1085 install_element(INTERFACE_NODE
, &no_ip_rip_receive_version_cmd
);
1086 install_element(INTERFACE_NODE
, &ip_rip_send_version_cmd
);
1087 install_element(INTERFACE_NODE
, &no_ip_rip_send_version_cmd
);
1088 install_element(INTERFACE_NODE
, &ip_rip_authentication_mode_cmd
);
1089 install_element(INTERFACE_NODE
, &no_ip_rip_authentication_mode_cmd
);
1090 install_element(INTERFACE_NODE
, &ip_rip_authentication_string_cmd
);
1091 install_element(INTERFACE_NODE
, &no_ip_rip_authentication_string_cmd
);
1092 install_element(INTERFACE_NODE
, &ip_rip_authentication_key_chain_cmd
);
1093 install_element(INTERFACE_NODE
,
1094 &no_ip_rip_authentication_key_chain_cmd
);
1096 install_element(ENABLE_NODE
, &clear_ip_rip_cmd
);