Trivial conversion.
rip->default_metric was converted to an uint8_t to match the way it's
defined in the YANG module.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
vty_out(vty, " default-information originate\n");
}
+/*
+ * XPath: /frr-ripd:ripd/instance/default-metric
+ */
+DEFPY (rip_default_metric,
+ rip_default_metric_cmd,
+ "default-metric (1-16)",
+ "Set a metric of redistribute routes\n"
+ "Default metric\n")
+{
+ struct cli_config_change changes[] = {
+ {
+ .xpath = "./default-metric",
+ .operation = NB_OP_MODIFY,
+ .value = default_metric_str,
+ },
+ };
+
+ return nb_cli_cfg_change(vty, NULL, changes, array_size(changes));
+}
+
+DEFPY (no_rip_default_metric,
+ no_rip_default_metric_cmd,
+ "no default-metric [(1-16)]",
+ NO_STR
+ "Set a metric of redistribute routes\n"
+ "Default metric\n")
+{
+ struct cli_config_change changes[] = {
+ {
+ .xpath = "./default-metric",
+ .operation = NB_OP_MODIFY,
+ .value = NULL,
+ },
+ };
+
+ return nb_cli_cfg_change(vty, NULL, changes, array_size(changes));
+}
+
+void cli_show_rip_default_metric(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults)
+{
+ vty_out(vty, " default-metric %s\n",
+ yang_dnode_get_string(dnode, NULL));
+}
+
void rip_cli_init(void)
{
install_element(CONFIG_NODE, &router_rip_cmd);
install_element(RIP_NODE, &rip_allow_ecmp_cmd);
install_element(RIP_NODE, &rip_default_information_originate_cmd);
+ install_element(RIP_NODE, &rip_default_metric_cmd);
+ install_element(RIP_NODE, &no_rip_default_metric_cmd);
}
extern void cli_show_rip_default_information_originate(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
+extern void cli_show_rip_default_metric(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->default_metric = yang_dnode_get_uint8(dnode, NULL);
+ /* rip_update_default_metric (); */
+
return NB_OK;
}
{
.xpath = "/frr-ripd:ripd/instance/default-metric",
.cbs.modify = ripd_instance_default_metric_modify,
+ .cbs.cli_show = cli_show_rip_default_metric,
},
{
.xpath = "/frr-ripd:ripd/instance/distance/default",
}
#endif
-DEFUN (rip_default_metric,
- rip_default_metric_cmd,
- "default-metric (1-16)",
- "Set a metric of redistribute routes\n"
- "Default metric\n")
-{
- int idx_number = 1;
- if (rip) {
- rip->default_metric = atoi(argv[idx_number]->arg);
- /* rip_update_default_metric (); */
- }
- return CMD_SUCCESS;
-}
-
-DEFUN (no_rip_default_metric,
- no_rip_default_metric_cmd,
- "no default-metric [(1-16)]",
- NO_STR
- "Set a metric of redistribute routes\n"
- "Default metric\n")
-{
- if (rip) {
- rip->default_metric = RIP_DEFAULT_METRIC_DEFAULT;
- /* rip_update_default_metric (); */
- }
- return CMD_SUCCESS;
-}
-
-
DEFUN (rip_timers,
rip_timers_cmd,
"timers basic (5-2147483647) (5-2147483647) (5-2147483647)",
config_show_distribute(vty);
/* Default metric information. */
- vty_out(vty, " Default redistribution metric is %d\n",
+ vty_out(vty, " Default redistribution metric is %u\n",
rip->default_metric);
/* Redistribute information. */
/* RIP enabled network and interface configuration. */
config_write_rip_network(vty, 1);
- /* RIP default metric configuration */
- if (rip->default_metric != RIP_DEFAULT_METRIC_DEFAULT)
- vty_out(vty, " default-metric %d\n",
- rip->default_metric);
-
/* Distribute configuration. */
write += config_write_distribute(vty);
install_default(RIP_NODE);
install_element(RIP_NODE, &rip_version_cmd);
install_element(RIP_NODE, &no_rip_version_cmd);
- install_element(RIP_NODE, &rip_default_metric_cmd);
- install_element(RIP_NODE, &no_rip_default_metric_cmd);
install_element(RIP_NODE, &rip_timers_cmd);
install_element(RIP_NODE, &no_rip_timers_cmd);
install_element(RIP_NODE, &rip_route_cmd);
unsigned long garbage_time;
/* RIP default metric. */
- int default_metric;
+ uint8_t default_metric;
/* RIP default distance. */
uint8_t distance;
/* N.B. stuff will break if
(RIPv1 != RI_RIP_VERSION_1) || (RIPv2 != RI_RIP_VERSION_2) */
-/* Default value for "default-metric" command. */
-#define RIP_DEFAULT_METRIC_DEFAULT 1
-
/* RIP event. */
enum rip_event {
RIP_READ,