Trivial conversion.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
yang_dnode_get_string(dnode, "./flush-interval"));
}
+/*
+ * XPath: /frr-ripd:ripd/instance/version
+ */
+DEFPY (rip_version,
+ rip_version_cmd,
+ "version (1-2)",
+ "Set routing protocol version\n"
+ "version\n")
+{
+ struct cli_config_change changes[] = {
+ {
+ .xpath = "./version/receive",
+ .operation = NB_OP_MODIFY,
+ .value = version_str,
+ },
+ {
+ .xpath = "./version/send",
+ .operation = NB_OP_MODIFY,
+ .value = version_str,
+ },
+ };
+
+ return nb_cli_cfg_change(vty, NULL, changes, array_size(changes));
+}
+
+DEFPY (no_rip_version,
+ no_rip_version_cmd,
+ "no version [(1-2)]",
+ NO_STR
+ "Set routing protocol version\n"
+ "version\n")
+{
+ struct cli_config_change changes[] = {
+ {
+ .xpath = "./version/receive",
+ .operation = NB_OP_MODIFY,
+ },
+ {
+ .xpath = "./version/send",
+ .operation = NB_OP_MODIFY,
+ },
+ };
+
+ return nb_cli_cfg_change(vty, NULL, changes, array_size(changes));
+}
+
+void cli_show_rip_version(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults)
+{
+ /*
+ * We have only one "version" command and three possible combinations of
+ * send/receive values.
+ */
+ switch (yang_dnode_get_enum(dnode, "./receive")) {
+ case RI_RIP_VERSION_1:
+ vty_out(vty, " version 1\n");
+ break;
+ case RI_RIP_VERSION_2:
+ vty_out(vty, " version 2\n");
+ break;
+ case RI_RIP_VERSION_1_AND_2:
+ vty_out(vty, " no version\n");
+ break;
+ }
+}
+
void rip_cli_init(void)
{
install_element(CONFIG_NODE, &router_rip_cmd);
install_element(RIP_NODE, &rip_route_cmd);
install_element(RIP_NODE, &rip_timers_cmd);
install_element(RIP_NODE, &no_rip_timers_cmd);
+ install_element(RIP_NODE, &rip_version_cmd);
+ install_element(RIP_NODE, &no_rip_version_cmd);
}
bool show_defaults);
extern void cli_show_rip_timers(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
+extern void cli_show_rip_version(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults);
#endif /* _FRR_RIP_CLI_H_ */
const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
+ if (event != NB_EV_APPLY)
+ return NB_OK;
+
+ rip->version_recv = yang_dnode_get_enum(dnode, NULL);
+
return NB_OK;
}
const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
+ if (event != NB_EV_APPLY)
+ return NB_OK;
+
+ rip->version_send = yang_dnode_get_enum(dnode, NULL);
+
return NB_OK;
}
.xpath = "/frr-ripd:ripd/instance/timers/update-interval",
.cbs.modify = ripd_instance_timers_update_interval_modify,
},
+ {
+ .xpath = "/frr-ripd:ripd/instance/version",
+ .cbs.cli_show = cli_show_rip_version,
+ },
{
.xpath = "/frr-ripd:ripd/instance/version/receive",
.cbs.modify = ripd_instance_version_receive_modify,
}
}
-DEFUN (rip_version,
- rip_version_cmd,
- "version (1-2)",
- "Set routing protocol version\n"
- "version\n")
-{
- int idx_number = 1;
- int version;
-
- version = atoi(argv[idx_number]->arg);
- if (version != RIPv1 && version != RIPv2) {
- vty_out(vty, "invalid rip version %d\n", version);
- return CMD_WARNING_CONFIG_FAILED;
- }
- rip->version_send = version;
- rip->version_recv = version;
-
- return CMD_SUCCESS;
-}
-
-DEFUN (no_rip_version,
- no_rip_version_cmd,
- "no version [(1-2)]",
- NO_STR
- "Set routing protocol version\n"
- "Version\n")
-{
- /* Set RIP version to the default. */
- rip->version_send = RI_RIP_VERSION_2;
- rip->version_recv = RI_RIP_VERSION_1_AND_2;
-
- return CMD_SUCCESS;
-}
-
#if 0
static void
rip_update_default_metric (void)
nb_cli_show_dnode_cmds(vty, dnode, false);
- /* RIP version statement. Default is RIP version 2. */
- if (rip->version_send != RI_RIP_VERSION_2
- || rip->version_recv != RI_RIP_VERSION_1_AND_2)
- vty_out(vty, " version %d\n", rip->version_send);
-
/* Distribute configuration. */
write += config_write_distribute(vty);
install_element(VIEW_NODE, &show_ip_rip_status_cmd);
install_default(RIP_NODE);
- install_element(RIP_NODE, &rip_version_cmd);
- install_element(RIP_NODE, &no_rip_version_cmd);
/* Debug related init. */
rip_debug_init();