vty_out(vty, " neighbor %s\n", yang_dnode_get_string(dnode, NULL));
}
+/*
+ * XPath: /frr-ripd:ripd/instance/network
+ */
+DEFPY (rip_network_prefix,
+ rip_network_prefix_cmd,
+ "[no] network A.B.C.D/M",
+ NO_STR
+ "Enable routing on an IP network\n"
+ "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
+{
+ struct cli_config_change changes[] = {
+ {
+ .xpath = "./network",
+ .operation = no ? NB_OP_DELETE : NB_OP_CREATE,
+ .value = network_str,
+ },
+ };
+
+ return nb_cli_cfg_change(vty, NULL, changes, array_size(changes));
+}
+
+void cli_show_rip_network_prefix(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults)
+{
+ vty_out(vty, " network %s\n", yang_dnode_get_string(dnode, NULL));
+}
+
+/*
+ * XPath: /frr-ripd:ripd/instance/interface
+ */
+DEFPY (rip_network_if,
+ rip_network_if_cmd,
+ "[no] network WORD",
+ NO_STR
+ "Enable routing on an IP network\n"
+ "Interface name\n")
+{
+ struct cli_config_change changes[] = {
+ {
+ .xpath = "./interface",
+ .operation = no ? NB_OP_DELETE : NB_OP_CREATE,
+ .value = network,
+ },
+ };
+
+ return nb_cli_cfg_change(vty, NULL, changes, array_size(changes));
+}
+
+void cli_show_rip_network_interface(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults)
+{
+ vty_out(vty, " network %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_distance_source_cmd);
install_element(RIP_NODE, &no_rip_distance_source_cmd);
install_element(RIP_NODE, &rip_neighbor_cmd);
+ install_element(RIP_NODE, &rip_network_prefix_cmd);
+ install_element(RIP_NODE, &rip_network_if_cmd);
}
bool show_defaults);
extern void cli_show_rip_neighbor(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
+extern void cli_show_rip_network_prefix(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults);
+extern void cli_show_rip_network_interface(struct vty *vty,
+ struct lyd_node *dnode,
+ bool show_defaults);
#endif /* _FRR_RIP_CLI_H_ */
return -1;
}
/* Add RIP enable network. */
-static int rip_enable_network_add(struct prefix *p)
+int rip_enable_network_add(struct prefix *p)
{
struct route_node *node;
if (node->info) {
route_unlock_node(node);
- return -1;
+ return NB_ERR_INCONSISTENCY;
} else
node->info = (void *)1;
/* XXX: One should find a better solution than a generic one */
rip_enable_apply_all();
- return 1;
+ return NB_OK;
}
/* Delete RIP enable network. */
-static int rip_enable_network_delete(struct prefix *p)
+int rip_enable_network_delete(struct prefix *p)
{
struct route_node *node;
/* XXX: One should find a better solution than a generic one */
rip_enable_apply_all();
- return 1;
+ return NB_OK;
}
- return -1;
+
+ return NB_ERR_INCONSISTENCY;
}
/* Check interface is enabled by ifname statement. */
}
/* Add interface to rip_enable_if. */
-static int rip_enable_if_add(const char *ifname)
+int rip_enable_if_add(const char *ifname)
{
int ret;
ret = rip_enable_if_lookup(ifname);
if (ret >= 0)
- return -1;
+ return NB_ERR_INCONSISTENCY;
vector_set(rip_enable_interface,
XSTRDUP(MTYPE_RIP_INTERFACE_STRING, ifname));
rip_enable_apply_all(); /* TODOVJ */
- return 1;
+ return NB_OK;
}
/* Delete interface from rip_enable_if. */
-static int rip_enable_if_delete(const char *ifname)
+int rip_enable_if_delete(const char *ifname)
{
int index;
char *str;
index = rip_enable_if_lookup(ifname);
if (index < 0)
- return -1;
+ return NB_ERR_INCONSISTENCY;
str = vector_slot(rip_enable_interface, index);
XFREE(MTYPE_RIP_INTERFACE_STRING, str);
rip_enable_apply_all(); /* TODOVJ */
- return 1;
+ return NB_OK;
}
/* Join to multicast group and send request to the interface. */
rip_passive_interface_apply_all();
}
-/* RIP enable network or interface configuration. */
-DEFUN (rip_network,
- rip_network_cmd,
- "network <A.B.C.D/M|WORD>",
- "Enable routing on an IP network\n"
- "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
- "Interface name\n")
-{
- int idx_ipv4_word = 1;
- int ret;
- struct prefix_ipv4 p;
-
- ret = str2prefix_ipv4(argv[idx_ipv4_word]->arg, &p);
-
- if (ret)
- ret = rip_enable_network_add((struct prefix *)&p);
- else
- ret = rip_enable_if_add(argv[idx_ipv4_word]->arg);
-
- if (ret < 0) {
- vty_out(vty, "There is a same network configuration %s\n",
- argv[idx_ipv4_word]->arg);
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- return CMD_SUCCESS;
-}
-
-/* RIP enable network or interface configuration. */
-DEFUN (no_rip_network,
- no_rip_network_cmd,
- "no network <A.B.C.D/M|WORD>",
- NO_STR
- "Enable routing on an IP network\n"
- "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
- "Interface name\n")
-{
- int idx_ipv4_word = 2;
- int ret;
- struct prefix_ipv4 p;
-
- ret = str2prefix_ipv4(argv[idx_ipv4_word]->arg, &p);
-
- if (ret)
- ret = rip_enable_network_delete((struct prefix *)&p);
- else
- ret = rip_enable_if_delete(argv[idx_ipv4_word]->arg);
-
- if (ret < 0) {
- vty_out(vty, "Can't find network configuration %s\n",
- argv[idx_ipv4_word]->arg);
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- return CMD_SUCCESS;
-}
-
DEFUN (ip_rip_receive_version,
ip_rip_receive_version_cmd,
"ip rip receive version <(1-2)|none>",
if_cmd_init();
/* Install commands. */
- install_element(RIP_NODE, &rip_network_cmd);
- install_element(RIP_NODE, &no_rip_network_cmd);
-
install_element(RIP_NODE, &rip_passive_interface_cmd);
install_element(RIP_NODE, &no_rip_passive_interface_cmd);
const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
- return NB_OK;
+ struct prefix p;
+
+ if (event != NB_EV_APPLY)
+ return NB_OK;
+
+ yang_dnode_get_ipv4p(&p, dnode, NULL);
+
+ return rip_enable_network_add(&p);
}
static int ripd_instance_network_delete(enum nb_event event,
const struct lyd_node *dnode)
{
- /* TODO: implement me. */
- return NB_OK;
+ struct prefix p;
+
+ if (event != NB_EV_APPLY)
+ return NB_OK;
+
+ yang_dnode_get_ipv4p(&p, dnode, NULL);
+
+ return rip_enable_network_delete(&p);
}
/*
const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
- return NB_OK;
+ const char *ifname;
+
+ if (event != NB_EV_APPLY)
+ return NB_OK;
+
+ ifname = yang_dnode_get_string(dnode, NULL);
+
+ return rip_enable_if_add(ifname);
}
static int ripd_instance_interface_delete(enum nb_event event,
const struct lyd_node *dnode)
{
- /* TODO: implement me. */
- return NB_OK;
+ const char *ifname;
+
+ if (event != NB_EV_APPLY)
+ return NB_OK;
+
+ ifname = yang_dnode_get_string(dnode, NULL);
+
+ return rip_enable_if_delete(ifname);
}
/*
.xpath = "/frr-ripd:ripd/instance/network",
.cbs.create = ripd_instance_network_create,
.cbs.delete = ripd_instance_network_delete,
+ .cbs.cli_show = cli_show_rip_network_prefix,
},
{
.xpath = "/frr-ripd:ripd/instance/interface",
.cbs.create = ripd_instance_interface_create,
.cbs.delete = ripd_instance_interface_delete,
+ .cbs.cli_show = cli_show_rip_network_interface,
},
{
.xpath = "/frr-ripd:ripd/instance/offset-list",
/* RIP offset-list configuration. */
config_write_rip_offset_list(vty);
- /* RIP enabled network and interface configuration. */
- config_write_rip_network(vty, 1);
-
/* Distribute configuration. */
write += config_write_distribute(vty);
extern int rip_neighbor_add(struct prefix_ipv4 *p);
extern int rip_neighbor_delete(struct prefix_ipv4 *p);
+extern int rip_enable_network_add(struct prefix *p);
+extern int rip_enable_network_delete(struct prefix *p);
+extern int rip_enable_if_add(const char *ifname);
+extern int rip_enable_if_delete(const char *ifname);
+
extern void rip_ecmp_disable(void);
extern int rip_create_socket(void);