2 * Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro <kunihiro@zebra.org>
3 * Copyright (C) 2018 NetDEF, Inc.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 #include "northbound_cli.h"
31 #include "ripd/ripd.h"
32 #include "ripd/rip_nb.h"
33 #include "ripd/rip_cli_clippy.c"
36 * XPath: /frr-ripd:ripd/instance
38 DEFPY_YANG_NOSH (router_rip
,
40 "router rip [vrf NAME]",
41 "Enable a routing process\n"
42 "Routing Information Protocol (RIP)\n"
45 char xpath
[XPATH_MAXLEN
];
48 /* Build RIP instance XPath. */
50 vrf
= VRF_DEFAULT_NAME
;
51 snprintf(xpath
, sizeof(xpath
), "/frr-ripd:ripd/instance[vrf='%s']",
54 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
56 ret
= nb_cli_apply_changes(vty
, NULL
);
57 if (ret
== CMD_SUCCESS
)
58 VTY_PUSH_XPATH(RIP_NODE
, xpath
);
63 DEFPY_YANG (no_router_rip
,
65 "no router rip [vrf NAME]",
67 "Enable a routing process\n"
68 "Routing Information Protocol (RIP)\n"
71 char xpath
[XPATH_MAXLEN
];
73 /* Build RIP instance XPath. */
75 vrf
= VRF_DEFAULT_NAME
;
76 snprintf(xpath
, sizeof(xpath
), "/frr-ripd:ripd/instance[vrf='%s']",
79 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
81 return nb_cli_apply_changes_clear_pending(vty
, NULL
);
84 void cli_show_router_rip(struct vty
*vty
, const struct lyd_node
*dnode
,
89 vrf_name
= yang_dnode_get_string(dnode
, "./vrf");
92 vty_out(vty
, "router rip");
93 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
))
94 vty_out(vty
, " vrf %s", vrf_name
);
99 * XPath: /frr-ripd:ripd/instance/allow-ecmp
101 DEFPY_YANG (rip_allow_ecmp
,
105 "Allow Equal Cost MultiPath\n")
107 nb_cli_enqueue_change(vty
, "./allow-ecmp", NB_OP_MODIFY
,
108 no
? "false" : "true");
110 return nb_cli_apply_changes(vty
, NULL
);
113 void cli_show_rip_allow_ecmp(struct vty
*vty
, const struct lyd_node
*dnode
,
116 if (!yang_dnode_get_bool(dnode
, NULL
))
119 vty_out(vty
, " allow-ecmp\n");
123 * XPath: /frr-ripd:ripd/instance/default-information-originate
125 DEFPY_YANG (rip_default_information_originate
,
126 rip_default_information_originate_cmd
,
127 "[no] default-information originate",
129 "Control distribution of default route\n"
130 "Distribute a default route\n")
132 nb_cli_enqueue_change(vty
, "./default-information-originate",
133 NB_OP_MODIFY
, no
? "false" : "true");
135 return nb_cli_apply_changes(vty
, NULL
);
138 void cli_show_rip_default_information_originate(struct vty
*vty
,
139 const struct lyd_node
*dnode
,
142 if (!yang_dnode_get_bool(dnode
, NULL
))
145 vty_out(vty
, " default-information originate\n");
149 * XPath: /frr-ripd:ripd/instance/default-metric
151 DEFPY_YANG (rip_default_metric
,
152 rip_default_metric_cmd
,
153 "default-metric (1-16)",
154 "Set a metric of redistribute routes\n"
157 nb_cli_enqueue_change(vty
, "./default-metric", NB_OP_MODIFY
,
160 return nb_cli_apply_changes(vty
, NULL
);
163 DEFPY_YANG (no_rip_default_metric
,
164 no_rip_default_metric_cmd
,
165 "no default-metric [(1-16)]",
167 "Set a metric of redistribute routes\n"
170 nb_cli_enqueue_change(vty
, "./default-metric", NB_OP_MODIFY
, NULL
);
172 return nb_cli_apply_changes(vty
, NULL
);
175 void cli_show_rip_default_metric(struct vty
*vty
, const struct lyd_node
*dnode
,
178 vty_out(vty
, " default-metric %s\n",
179 yang_dnode_get_string(dnode
, NULL
));
183 * XPath: /frr-ripd:ripd/instance/distance/default
185 DEFPY_YANG (rip_distance
,
188 "Administrative distance\n"
191 nb_cli_enqueue_change(vty
, "./distance/default", NB_OP_MODIFY
,
194 return nb_cli_apply_changes(vty
, NULL
);
197 DEFPY_YANG (no_rip_distance
,
199 "no distance [(1-255)]",
201 "Administrative distance\n"
204 nb_cli_enqueue_change(vty
, "./distance/default", NB_OP_MODIFY
, NULL
);
206 return nb_cli_apply_changes(vty
, NULL
);
209 void cli_show_rip_distance(struct vty
*vty
, const struct lyd_node
*dnode
,
212 if (yang_dnode_is_default(dnode
, NULL
))
213 vty_out(vty
, " no distance\n");
215 vty_out(vty
, " distance %s\n",
216 yang_dnode_get_string(dnode
, NULL
));
220 * XPath: /frr-ripd:ripd/instance/distance/source
222 DEFPY_YANG (rip_distance_source
,
223 rip_distance_source_cmd
,
224 "[no] distance (1-255) A.B.C.D/M$prefix [WORD$acl]",
226 "Administrative distance\n"
229 "Access list name\n")
232 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
233 nb_cli_enqueue_change(vty
, "./distance", NB_OP_MODIFY
,
235 nb_cli_enqueue_change(vty
, "./access-list",
236 acl
? NB_OP_MODIFY
: NB_OP_DESTROY
, acl
);
238 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
240 return nb_cli_apply_changes(vty
, "./distance/source[prefix='%s']",
244 void cli_show_rip_distance_source(struct vty
*vty
, const struct lyd_node
*dnode
,
247 vty_out(vty
, " distance %s %s",
248 yang_dnode_get_string(dnode
, "./distance"),
249 yang_dnode_get_string(dnode
, "./prefix"));
250 if (yang_dnode_exists(dnode
, "./access-list"))
252 yang_dnode_get_string(dnode
, "./access-list"));
257 * XPath: /frr-ripd:ripd/instance/explicit-neighbor
259 DEFPY_YANG (rip_neighbor
,
261 "[no] neighbor A.B.C.D",
263 "Specify a neighbor router\n"
264 "Neighbor address\n")
266 nb_cli_enqueue_change(vty
, "./explicit-neighbor",
267 no
? NB_OP_DESTROY
: NB_OP_CREATE
, neighbor_str
);
269 return nb_cli_apply_changes(vty
, NULL
);
272 void cli_show_rip_neighbor(struct vty
*vty
, const struct lyd_node
*dnode
,
275 vty_out(vty
, " neighbor %s\n", yang_dnode_get_string(dnode
, NULL
));
279 * XPath: /frr-ripd:ripd/instance/network
281 DEFPY_YANG (rip_network_prefix
,
282 rip_network_prefix_cmd
,
283 "[no] network A.B.C.D/M",
285 "Enable routing on an IP network\n"
286 "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
288 nb_cli_enqueue_change(vty
, "./network",
289 no
? NB_OP_DESTROY
: NB_OP_CREATE
, network_str
);
291 return nb_cli_apply_changes(vty
, NULL
);
294 void cli_show_rip_network_prefix(struct vty
*vty
, const struct lyd_node
*dnode
,
297 vty_out(vty
, " network %s\n", yang_dnode_get_string(dnode
, NULL
));
301 * XPath: /frr-ripd:ripd/instance/interface
303 DEFPY_YANG (rip_network_if
,
307 "Enable routing on an IP network\n"
310 nb_cli_enqueue_change(vty
, "./interface",
311 no
? NB_OP_DESTROY
: NB_OP_CREATE
, network
);
313 return nb_cli_apply_changes(vty
, NULL
);
316 void cli_show_rip_network_interface(struct vty
*vty
,
317 const struct lyd_node
*dnode
,
320 vty_out(vty
, " network %s\n", yang_dnode_get_string(dnode
, NULL
));
324 * XPath: /frr-ripd:ripd/instance/offset-list
326 DEFPY_YANG (rip_offset_list
,
328 "[no] offset-list ACCESSLIST4_NAME$acl <in|out>$direction (0-16)$metric [IFNAME]",
330 "Modify RIP metric\n"
332 "For incoming updates\n"
333 "For outgoing updates\n"
335 "Interface to match\n")
338 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
339 nb_cli_enqueue_change(vty
, "./access-list", NB_OP_MODIFY
, acl
);
340 nb_cli_enqueue_change(vty
, "./metric", NB_OP_MODIFY
,
343 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
345 return nb_cli_apply_changes(
346 vty
, "./offset-list[interface='%s'][direction='%s']",
347 ifname
? ifname
: "*", direction
);
350 void cli_show_rip_offset_list(struct vty
*vty
, const struct lyd_node
*dnode
,
353 const char *interface
;
355 interface
= yang_dnode_get_string(dnode
, "./interface");
357 vty_out(vty
, " offset-list %s %s %s",
358 yang_dnode_get_string(dnode
, "./access-list"),
359 yang_dnode_get_string(dnode
, "./direction"),
360 yang_dnode_get_string(dnode
, "./metric"));
361 if (!strmatch(interface
, "*"))
362 vty_out(vty
, " %s", interface
);
367 * XPath: /frr-ripd:ripd/instance/passive-default
369 DEFPY_YANG (rip_passive_default
,
370 rip_passive_default_cmd
,
371 "[no] passive-interface default",
373 "Suppress routing updates on an interface\n"
374 "default for all interfaces\n")
376 nb_cli_enqueue_change(vty
, "./passive-default", NB_OP_MODIFY
,
377 no
? "false" : "true");
379 return nb_cli_apply_changes(vty
, NULL
);
382 void cli_show_rip_passive_default(struct vty
*vty
, const struct lyd_node
*dnode
,
385 if (!yang_dnode_get_bool(dnode
, NULL
))
388 vty_out(vty
, " passive-interface default\n");
392 * XPath: /frr-ripd:ripd/instance/passive-interface
393 * /frr-ripd:ripd/instance/non-passive-interface
395 DEFPY_YANG (rip_passive_interface
,
396 rip_passive_interface_cmd
,
397 "[no] passive-interface IFNAME",
399 "Suppress routing updates on an interface\n"
402 bool passive_default
=
403 yang_dnode_get_bool(vty
->candidate_config
->dnode
, "%s%s",
404 VTY_CURR_XPATH
, "/passive-default");
406 if (passive_default
) {
407 nb_cli_enqueue_change(vty
, "./non-passive-interface",
408 no
? NB_OP_CREATE
: NB_OP_DESTROY
,
411 nb_cli_enqueue_change(vty
, "./passive-interface",
412 no
? NB_OP_DESTROY
: NB_OP_CREATE
,
416 return nb_cli_apply_changes(vty
, NULL
);
419 void cli_show_rip_passive_interface(struct vty
*vty
,
420 const struct lyd_node
*dnode
,
423 vty_out(vty
, " passive-interface %s\n",
424 yang_dnode_get_string(dnode
, NULL
));
427 void cli_show_rip_non_passive_interface(struct vty
*vty
,
428 const struct lyd_node
*dnode
,
431 vty_out(vty
, " no passive-interface %s\n",
432 yang_dnode_get_string(dnode
, NULL
));
436 * XPath: /frr-ripd:ripd/instance/redistribute
438 DEFPY_YANG (rip_redistribute
,
439 rip_redistribute_cmd
,
440 "[no] redistribute " FRR_REDIST_STR_RIPD
"$protocol [{metric (0-16)|route-map RMAP_NAME$route_map}]",
443 FRR_REDIST_HELP_STR_RIPD
446 "Route map reference\n"
447 "Pointer to route-map entries\n")
450 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
451 nb_cli_enqueue_change(vty
, "./route-map",
452 route_map
? NB_OP_MODIFY
: NB_OP_DESTROY
,
454 nb_cli_enqueue_change(vty
, "./metric",
455 metric_str
? NB_OP_MODIFY
: NB_OP_DESTROY
,
458 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
460 return nb_cli_apply_changes(vty
, "./redistribute[protocol='%s']",
464 void cli_show_rip_redistribute(struct vty
*vty
, const struct lyd_node
*dnode
,
467 vty_out(vty
, " redistribute %s",
468 yang_dnode_get_string(dnode
, "./protocol"));
469 if (yang_dnode_exists(dnode
, "./metric"))
470 vty_out(vty
, " metric %s",
471 yang_dnode_get_string(dnode
, "./metric"));
472 if (yang_dnode_exists(dnode
, "./route-map"))
473 vty_out(vty
, " route-map %s",
474 yang_dnode_get_string(dnode
, "./route-map"));
479 * XPath: /frr-ripd:ripd/instance/static-route
481 DEFPY_YANG (rip_route
,
483 "[no] route A.B.C.D/M",
485 "RIP static route configuration\n"
486 "IP prefix <network>/<length>\n")
488 nb_cli_enqueue_change(vty
, "./static-route",
489 no
? NB_OP_DESTROY
: NB_OP_CREATE
, route_str
);
491 return nb_cli_apply_changes(vty
, NULL
);
494 void cli_show_rip_route(struct vty
*vty
, const struct lyd_node
*dnode
,
497 vty_out(vty
, " route %s\n", yang_dnode_get_string(dnode
, NULL
));
501 * XPath: /frr-ripd:ripd/instance/timers
503 DEFPY_YANG (rip_timers
,
505 "timers basic (5-2147483647)$update (5-2147483647)$timeout (5-2147483647)$garbage",
506 "Adjust routing timers\n"
507 "Basic routing protocol update timers\n"
508 "Routing table update timer value in second. Default is 30.\n"
509 "Routing information timeout timer. Default is 180.\n"
510 "Garbage collection timer. Default is 120.\n")
512 nb_cli_enqueue_change(vty
, "./update-interval", NB_OP_MODIFY
,
514 nb_cli_enqueue_change(vty
, "./holddown-interval", NB_OP_MODIFY
,
516 nb_cli_enqueue_change(vty
, "./flush-interval", NB_OP_MODIFY
,
519 return nb_cli_apply_changes(vty
, "./timers");
522 DEFPY_YANG (no_rip_timers
,
524 "no timers basic [(5-2147483647) (5-2147483647) (5-2147483647)]",
526 "Adjust routing timers\n"
527 "Basic routing protocol update timers\n"
528 "Routing table update timer value in second. Default is 30.\n"
529 "Routing information timeout timer. Default is 180.\n"
530 "Garbage collection timer. Default is 120.\n")
532 nb_cli_enqueue_change(vty
, "./update-interval", NB_OP_MODIFY
, NULL
);
533 nb_cli_enqueue_change(vty
, "./holddown-interval", NB_OP_MODIFY
, NULL
);
534 nb_cli_enqueue_change(vty
, "./flush-interval", NB_OP_MODIFY
, NULL
);
536 return nb_cli_apply_changes(vty
, "./timers");
539 void cli_show_rip_timers(struct vty
*vty
, const struct lyd_node
*dnode
,
542 vty_out(vty
, " timers basic %s %s %s\n",
543 yang_dnode_get_string(dnode
, "./update-interval"),
544 yang_dnode_get_string(dnode
, "./holddown-interval"),
545 yang_dnode_get_string(dnode
, "./flush-interval"));
549 * XPath: /frr-ripd:ripd/instance/version
551 DEFPY_YANG (rip_version
,
554 "Set routing protocol version\n"
557 nb_cli_enqueue_change(vty
, "./version/receive", NB_OP_MODIFY
,
559 nb_cli_enqueue_change(vty
, "./version/send", NB_OP_MODIFY
, version_str
);
561 return nb_cli_apply_changes(vty
, NULL
);
564 DEFPY_YANG (no_rip_version
,
566 "no version [(1-2)]",
568 "Set routing protocol version\n"
571 nb_cli_enqueue_change(vty
, "./version/receive", NB_OP_MODIFY
, NULL
);
572 nb_cli_enqueue_change(vty
, "./version/send", NB_OP_MODIFY
, NULL
);
574 return nb_cli_apply_changes(vty
, NULL
);
577 void cli_show_rip_version(struct vty
*vty
, const struct lyd_node
*dnode
,
581 * We have only one "version" command and three possible combinations of
582 * send/receive values.
584 switch (yang_dnode_get_enum(dnode
, "./receive")) {
585 case RI_RIP_VERSION_1
:
586 vty_out(vty
, " version 1\n");
588 case RI_RIP_VERSION_2
:
589 vty_out(vty
, " version 2\n");
591 case RI_RIP_VERSION_1_AND_2
:
592 vty_out(vty
, " no version\n");
598 * XPath: /frr-interface:lib/interface/frr-ripd:rip/split-horizon
600 DEFPY_YANG (ip_rip_split_horizon
,
601 ip_rip_split_horizon_cmd
,
602 "[no] ip rip split-horizon [poisoned-reverse$poisoned_reverse]",
605 "Routing Information Protocol\n"
606 "Perform split horizon\n"
607 "With poisoned-reverse\n")
613 else if (poisoned_reverse
)
614 value
= "poison-reverse";
618 nb_cli_enqueue_change(vty
, "./split-horizon", NB_OP_MODIFY
, value
);
620 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
623 void cli_show_ip_rip_split_horizon(struct vty
*vty
,
624 const struct lyd_node
*dnode
,
629 value
= yang_dnode_get_enum(dnode
, NULL
);
631 case RIP_NO_SPLIT_HORIZON
:
632 vty_out(vty
, " no ip rip split-horizon\n");
634 case RIP_SPLIT_HORIZON
:
635 vty_out(vty
, " ip rip split-horizon\n");
637 case RIP_SPLIT_HORIZON_POISONED_REVERSE
:
638 vty_out(vty
, " ip rip split-horizon poisoned-reverse\n");
644 * XPath: /frr-interface:lib/interface/frr-ripd:rip/v2-broadcast
646 DEFPY_YANG (ip_rip_v2_broadcast
,
647 ip_rip_v2_broadcast_cmd
,
648 "[no] ip rip v2-broadcast",
651 "Routing Information Protocol\n"
652 "Send ip broadcast v2 update\n")
654 nb_cli_enqueue_change(vty
, "./v2-broadcast", NB_OP_MODIFY
,
655 no
? "false" : "true");
657 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
660 void cli_show_ip_rip_v2_broadcast(struct vty
*vty
, const struct lyd_node
*dnode
,
663 if (!yang_dnode_get_bool(dnode
, NULL
))
666 vty_out(vty
, " ip rip v2-broadcast\n");
670 * XPath: /frr-interface:lib/interface/frr-ripd:rip/version-receive
672 DEFPY_YANG (ip_rip_receive_version
,
673 ip_rip_receive_version_cmd
,
674 "ip rip receive version <{1$v1|2$v2}|none>",
676 "Routing Information Protocol\n"
677 "Advertisement reception\n"
694 nb_cli_enqueue_change(vty
, "./version-receive", NB_OP_MODIFY
, value
);
696 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
699 DEFPY_YANG (no_ip_rip_receive_version
,
700 no_ip_rip_receive_version_cmd
,
701 "no ip rip receive version [<{1|2}|none>]",
704 "Routing Information Protocol\n"
705 "Advertisement reception\n"
711 nb_cli_enqueue_change(vty
, "./version-receive", NB_OP_MODIFY
, NULL
);
713 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
716 void cli_show_ip_rip_receive_version(struct vty
*vty
,
717 const struct lyd_node
*dnode
,
720 switch (yang_dnode_get_enum(dnode
, NULL
)) {
722 vty_out(vty
, " no ip rip receive version\n");
724 case RI_RIP_VERSION_1
:
725 vty_out(vty
, " ip rip receive version 1\n");
727 case RI_RIP_VERSION_2
:
728 vty_out(vty
, " ip rip receive version 2\n");
730 case RI_RIP_VERSION_1_AND_2
:
731 vty_out(vty
, " ip rip receive version 1 2\n");
733 case RI_RIP_VERSION_NONE
:
734 vty_out(vty
, " ip rip receive version none\n");
740 * XPath: /frr-interface:lib/interface/frr-ripd:rip/version-send
742 DEFPY_YANG (ip_rip_send_version
,
743 ip_rip_send_version_cmd
,
744 "ip rip send version <{1$v1|2$v2}|none>",
746 "Routing Information Protocol\n"
747 "Advertisement transmission\n"
764 nb_cli_enqueue_change(vty
, "./version-send", NB_OP_MODIFY
, value
);
766 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
769 DEFPY_YANG (no_ip_rip_send_version
,
770 no_ip_rip_send_version_cmd
,
771 "no ip rip send version [<{1|2}|none>]",
774 "Routing Information Protocol\n"
775 "Advertisement transmission\n"
781 nb_cli_enqueue_change(vty
, "./version-send", NB_OP_MODIFY
, NULL
);
783 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
786 void cli_show_ip_rip_send_version(struct vty
*vty
, const struct lyd_node
*dnode
,
789 switch (yang_dnode_get_enum(dnode
, NULL
)) {
791 vty_out(vty
, " no ip rip send version\n");
793 case RI_RIP_VERSION_1
:
794 vty_out(vty
, " ip rip send version 1\n");
796 case RI_RIP_VERSION_2
:
797 vty_out(vty
, " ip rip send version 2\n");
799 case RI_RIP_VERSION_1_AND_2
:
800 vty_out(vty
, " ip rip send version 1 2\n");
802 case RI_RIP_VERSION_NONE
:
803 vty_out(vty
, " ip rip send version none\n");
809 * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-scheme
811 DEFPY_YANG (ip_rip_authentication_mode
,
812 ip_rip_authentication_mode_cmd
,
813 "ip rip authentication mode <md5$mode [auth-length <rfc|old-ripd>$auth_length]|text$mode>",
815 "Routing Information Protocol\n"
816 "Authentication control\n"
817 "Authentication mode\n"
818 "Keyed message digest\n"
819 "MD5 authentication data length\n"
821 "Old ripd compatible\n"
822 "Clear text authentication\n")
824 const char *value
= NULL
;
827 if (strmatch(auth_length
, "rfc"))
833 nb_cli_enqueue_change(vty
, "./authentication-scheme/mode", NB_OP_MODIFY
,
834 strmatch(mode
, "md5") ? "md5" : "plain-text");
835 if (strmatch(mode
, "md5"))
836 nb_cli_enqueue_change(vty
,
837 "./authentication-scheme/md5-auth-length",
838 NB_OP_MODIFY
, value
);
840 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
843 DEFPY_YANG (no_ip_rip_authentication_mode
,
844 no_ip_rip_authentication_mode_cmd
,
845 "no ip rip authentication mode [<md5 [auth-length <rfc|old-ripd>]|text>]",
848 "Routing Information Protocol\n"
849 "Authentication control\n"
850 "Authentication mode\n"
851 "Keyed message digest\n"
852 "MD5 authentication data length\n"
854 "Old ripd compatible\n"
855 "Clear text authentication\n")
857 nb_cli_enqueue_change(vty
, "./authentication-scheme/mode", NB_OP_MODIFY
,
859 nb_cli_enqueue_change(vty
, "./authentication-scheme/md5-auth-length",
860 NB_OP_DESTROY
, NULL
);
862 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
865 void cli_show_ip_rip_authentication_scheme(struct vty
*vty
,
866 const struct lyd_node
*dnode
,
869 switch (yang_dnode_get_enum(dnode
, "./mode")) {
871 vty_out(vty
, " no ip rip authentication mode\n");
873 case RIP_AUTH_SIMPLE_PASSWORD
:
874 vty_out(vty
, " ip rip authentication mode text\n");
877 vty_out(vty
, " ip rip authentication mode md5");
879 || !yang_dnode_is_default(dnode
, "./md5-auth-length")) {
880 if (yang_dnode_get_enum(dnode
, "./md5-auth-length")
881 == RIP_AUTH_MD5_SIZE
)
882 vty_out(vty
, " auth-length rfc");
884 vty_out(vty
, " auth-length old-ripd");
892 * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-password
894 DEFPY_YANG (ip_rip_authentication_string
,
895 ip_rip_authentication_string_cmd
,
896 "ip rip authentication string LINE$password",
898 "Routing Information Protocol\n"
899 "Authentication control\n"
900 "Authentication string\n"
901 "Authentication string\n")
903 if (strlen(password
) > 16) {
905 "%% RIPv2 authentication string must be shorter than 16\n");
906 return CMD_WARNING_CONFIG_FAILED
;
909 if (yang_dnode_existsf(vty
->candidate_config
->dnode
, "%s%s",
911 "/frr-ripd:rip/authentication-key-chain")) {
912 vty_out(vty
, "%% key-chain configuration exists\n");
913 return CMD_WARNING_CONFIG_FAILED
;
916 nb_cli_enqueue_change(vty
, "./authentication-password", NB_OP_MODIFY
,
919 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
922 DEFPY_YANG (no_ip_rip_authentication_string
,
923 no_ip_rip_authentication_string_cmd
,
924 "no ip rip authentication string [LINE]",
927 "Routing Information Protocol\n"
928 "Authentication control\n"
929 "Authentication string\n"
930 "Authentication string\n")
932 nb_cli_enqueue_change(vty
, "./authentication-password", NB_OP_DESTROY
,
935 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
938 void cli_show_ip_rip_authentication_string(struct vty
*vty
,
939 const struct lyd_node
*dnode
,
942 vty_out(vty
, " ip rip authentication string %s\n",
943 yang_dnode_get_string(dnode
, NULL
));
947 * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-key-chain
949 DEFPY_YANG (ip_rip_authentication_key_chain
,
950 ip_rip_authentication_key_chain_cmd
,
951 "ip rip authentication key-chain LINE$keychain",
953 "Routing Information Protocol\n"
954 "Authentication control\n"
955 "Authentication key-chain\n"
956 "name of key-chain\n")
958 if (yang_dnode_existsf(vty
->candidate_config
->dnode
, "%s%s",
960 "/frr-ripd:rip/authentication-password")) {
961 vty_out(vty
, "%% authentication string configuration exists\n");
962 return CMD_WARNING_CONFIG_FAILED
;
965 nb_cli_enqueue_change(vty
, "./authentication-key-chain", NB_OP_MODIFY
,
968 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
971 DEFPY_YANG (no_ip_rip_authentication_key_chain
,
972 no_ip_rip_authentication_key_chain_cmd
,
973 "no ip rip authentication key-chain [LINE]",
976 "Routing Information Protocol\n"
977 "Authentication control\n"
978 "Authentication key-chain\n"
979 "name of key-chain\n")
981 nb_cli_enqueue_change(vty
, "./authentication-key-chain", NB_OP_DESTROY
,
984 return nb_cli_apply_changes(vty
, "./frr-ripd:rip");
987 void cli_show_ip_rip_authentication_key_chain(struct vty
*vty
,
988 const struct lyd_node
*dnode
,
991 vty_out(vty
, " ip rip authentication key-chain %s\n",
992 yang_dnode_get_string(dnode
, NULL
));
996 * XPath: /frr-ripd:clear-rip-route
998 DEFPY_YANG (clear_ip_rip
,
1000 "clear ip rip [vrf WORD]",
1003 "Clear IP RIP database\n"
1011 struct yang_data
*yang_vrf
;
1013 yang_vrf
= yang_data_new("/frr-ripd:clear-rip-route/input/vrf",
1015 listnode_add(input
, yang_vrf
);
1018 ret
= nb_cli_rpc(vty
, "/frr-ripd:clear-rip-route", input
, NULL
);
1020 list_delete(&input
);
1025 DEFUN (rip_distribute_list
,
1026 rip_distribute_list_cmd
,
1027 "distribute-list [prefix] ACCESSLIST4_NAME <in|out> [WORD]",
1028 "Filter networks in routing updates\n"
1029 "Specify a prefix\n"
1030 "Access-list name\n"
1031 "Filter incoming routing updates\n"
1032 "Filter outgoing routing updates\n"
1035 const char *ifname
= NULL
;
1036 int prefix
= (argv
[1]->type
== WORD_TKN
) ? 1 : 0;
1038 if (argv
[argc
- 1]->type
== VARIABLE_TKN
)
1039 ifname
= argv
[argc
- 1]->arg
;
1041 return distribute_list_parser(prefix
, true, argv
[2 + prefix
]->text
,
1042 argv
[1 + prefix
]->arg
, ifname
);
1045 DEFUN (rip_no_distribute_list
,
1046 rip_no_distribute_list_cmd
,
1047 "no distribute-list [prefix] ACCESSLIST4_NAME <in|out> [WORD]",
1049 "Filter networks in routing updates\n"
1050 "Specify a prefix\n"
1051 "Access-list name\n"
1052 "Filter incoming routing updates\n"
1053 "Filter outgoing routing updates\n"
1056 const char *ifname
= NULL
;
1057 int prefix
= (argv
[2]->type
== WORD_TKN
) ? 1 : 0;
1059 if (argv
[argc
- 1]->type
== VARIABLE_TKN
)
1060 ifname
= argv
[argc
- 1]->arg
;
1062 return distribute_list_no_parser(vty
, prefix
, true,
1063 argv
[3 + prefix
]->text
,
1064 argv
[2 + prefix
]->arg
, ifname
);
1067 void rip_cli_init(void)
1069 install_element(CONFIG_NODE
, &router_rip_cmd
);
1070 install_element(CONFIG_NODE
, &no_router_rip_cmd
);
1072 install_element(RIP_NODE
, &rip_distribute_list_cmd
);
1073 install_element(RIP_NODE
, &rip_no_distribute_list_cmd
);
1075 install_element(RIP_NODE
, &rip_allow_ecmp_cmd
);
1076 install_element(RIP_NODE
, &rip_default_information_originate_cmd
);
1077 install_element(RIP_NODE
, &rip_default_metric_cmd
);
1078 install_element(RIP_NODE
, &no_rip_default_metric_cmd
);
1079 install_element(RIP_NODE
, &rip_distance_cmd
);
1080 install_element(RIP_NODE
, &no_rip_distance_cmd
);
1081 install_element(RIP_NODE
, &rip_distance_source_cmd
);
1082 install_element(RIP_NODE
, &rip_neighbor_cmd
);
1083 install_element(RIP_NODE
, &rip_network_prefix_cmd
);
1084 install_element(RIP_NODE
, &rip_network_if_cmd
);
1085 install_element(RIP_NODE
, &rip_offset_list_cmd
);
1086 install_element(RIP_NODE
, &rip_passive_default_cmd
);
1087 install_element(RIP_NODE
, &rip_passive_interface_cmd
);
1088 install_element(RIP_NODE
, &rip_redistribute_cmd
);
1089 install_element(RIP_NODE
, &rip_route_cmd
);
1090 install_element(RIP_NODE
, &rip_timers_cmd
);
1091 install_element(RIP_NODE
, &no_rip_timers_cmd
);
1092 install_element(RIP_NODE
, &rip_version_cmd
);
1093 install_element(RIP_NODE
, &no_rip_version_cmd
);
1095 install_element(INTERFACE_NODE
, &ip_rip_split_horizon_cmd
);
1096 install_element(INTERFACE_NODE
, &ip_rip_v2_broadcast_cmd
);
1097 install_element(INTERFACE_NODE
, &ip_rip_receive_version_cmd
);
1098 install_element(INTERFACE_NODE
, &no_ip_rip_receive_version_cmd
);
1099 install_element(INTERFACE_NODE
, &ip_rip_send_version_cmd
);
1100 install_element(INTERFACE_NODE
, &no_ip_rip_send_version_cmd
);
1101 install_element(INTERFACE_NODE
, &ip_rip_authentication_mode_cmd
);
1102 install_element(INTERFACE_NODE
, &no_ip_rip_authentication_mode_cmd
);
1103 install_element(INTERFACE_NODE
, &ip_rip_authentication_string_cmd
);
1104 install_element(INTERFACE_NODE
, &no_ip_rip_authentication_string_cmd
);
1105 install_element(INTERFACE_NODE
, &ip_rip_authentication_key_chain_cmd
);
1106 install_element(INTERFACE_NODE
,
1107 &no_ip_rip_authentication_key_chain_cmd
);
1109 install_element(ENABLE_NODE
, &clear_ip_rip_cmd
);