Trivial conversion.
'rip->default_information_route_map' was removed since it wasn't being
used anywhere.
'rip->default_information' was removed too because it was being used only
to display the running configuration and thus is not necessary anymore.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
vty_out(vty, " allow-ecmp\n");
}
+/*
+ * XPath: /frr-ripd:ripd/instance/default-information-originate
+ */
+DEFPY (rip_default_information_originate,
+ rip_default_information_originate_cmd,
+ "[no] default-information originate",
+ NO_STR
+ "Control distribution of default route\n"
+ "Distribute a default route\n")
+{
+ struct cli_config_change changes[] = {
+ {
+ .xpath = "./default-information-originate",
+ .operation = NB_OP_MODIFY,
+ .value = no ? "false" : "true",
+ },
+ };
+
+ return nb_cli_cfg_change(vty, NULL, changes, array_size(changes));
+}
+
+void cli_show_rip_default_information_originate(struct vty *vty,
+ struct lyd_node *dnode,
+ bool show_defaults)
+{
+ if (!yang_dnode_get_bool(dnode, NULL))
+ vty_out(vty, " no");
+
+ vty_out(vty, " default-information originate\n");
+}
+
void rip_cli_init(void)
{
install_element(CONFIG_NODE, &router_rip_cmd);
install_element(CONFIG_NODE, &no_router_rip_cmd);
install_element(RIP_NODE, &rip_allow_ecmp_cmd);
+ install_element(RIP_NODE, &rip_default_information_originate_cmd);
}
bool show_defaults);
extern void cli_show_rip_allow_ecmp(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
+extern void cli_show_rip_default_information_originate(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. */
+ bool default_information;
+ struct prefix_ipv4 p;
+
+ if (event != NB_EV_APPLY)
+ return NB_OK;
+
+ default_information = yang_dnode_get_bool(dnode, NULL);
+
+ memset(&p, 0, sizeof(struct prefix_ipv4));
+ p.family = AF_INET;
+ if (default_information) {
+ struct nexthop nh;
+
+ memset(&nh, 0, sizeof(nh));
+ nh.type = NEXTHOP_TYPE_IPV4;
+ rip_redistribute_add(ZEBRA_ROUTE_RIP, RIP_ROUTE_DEFAULT, &p,
+ &nh, 0, 0, 0);
+ } else {
+ rip_redistribute_delete(ZEBRA_ROUTE_RIP, RIP_ROUTE_DEFAULT, &p,
+ 0);
+ }
+
return NB_OK;
}
{
.xpath = "/frr-ripd:ripd/instance/default-information-originate",
.cbs.modify = ripd_instance_default_information_originate_modify,
+ .cbs.cli_show = cli_show_rip_default_information_originate,
},
{
.xpath = "/frr-ripd:ripd/instance/default-metric",
return CMD_WARNING_CONFIG_FAILED;
}
-/* Default information originate. */
-
-DEFUN (rip_default_information_originate,
- rip_default_information_originate_cmd,
- "default-information originate",
- "Control distribution of default route\n"
- "Distribute a default route\n")
-{
- struct prefix_ipv4 p;
- struct nexthop nh;
-
- if (!rip->default_information) {
- memset(&p, 0, sizeof(struct prefix_ipv4));
- memset(&nh, 0, sizeof(nh));
-
- p.family = AF_INET;
- nh.type = NEXTHOP_TYPE_IPV4;
-
- rip->default_information = 1;
-
- rip_redistribute_add(ZEBRA_ROUTE_RIP, RIP_ROUTE_DEFAULT, &p,
- &nh, 0, 0, 0);
- }
-
- return CMD_SUCCESS;
-}
-
-DEFUN (no_rip_default_information_originate,
- no_rip_default_information_originate_cmd,
- "no default-information originate",
- NO_STR
- "Control distribution of default route\n"
- "Distribute a default route\n")
-{
- struct prefix_ipv4 p;
-
- if (rip->default_information) {
- memset(&p, 0, sizeof(struct prefix_ipv4));
- p.family = AF_INET;
-
- rip->default_information = 0;
-
- rip_redistribute_delete(ZEBRA_ROUTE_RIP, RIP_ROUTE_DEFAULT, &p,
- 0);
- }
-
- return CMD_SUCCESS;
-}
-
int config_write_rip_redistribute(struct vty *vty, int config_mode)
{
int i;
install_element(RIP_NODE, &no_rip_redistribute_type_metric_cmd);
install_element(RIP_NODE,
&no_rip_redistribute_type_metric_routemap_cmd);
- install_element(RIP_NODE, &rip_default_information_originate_cmd);
- install_element(RIP_NODE, &no_rip_default_information_originate_cmd);
}
void rip_zclient_stop(void)
rip->update_time, rip->timeout_time,
rip->garbage_time);
- /* Default information configuration. */
- if (rip->default_information) {
- if (rip->default_information_route_map)
- vty_out(vty,
- " default-information originate route-map %s\n",
- rip->default_information_route_map);
- else
- vty_out(vty,
- " default-information originate\n");
- }
-
/* Redistribute configuration. */
config_write_rip_redistribute(vty, 1);
route_unlock_node(rp);
}
- /* Redistribute related clear. */
- if (rip->default_information_route_map)
- free(rip->default_information_route_map);
-
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
if (rip->route_map[i].name)
free(rip->route_map[i].name);
/* RIP default metric. */
int default_metric;
- /* RIP default-information originate. */
- uint8_t default_information;
- char *default_information_route_map;
-
/* RIP default distance. */
uint8_t distance;
struct route_table *distance_table;