summaryrefslogtreecommitdiffstats
path: root/ripd/rip_interface.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2018-05-09 06:35:00 +0200
committerRenato Westphal <renato@opensourcerouting.org>2018-10-27 20:16:12 +0200
commit3d7a1be850dbf7350fa217e7eb33967bf15351e9 (patch)
tree857da554ed85c1145a27ecaf5cade1c6ec3abdd4 /ripd/rip_interface.c
parentripd: retrofit the 'neighbor' command to the new northbound model (diff)
downloadfrr-3d7a1be850dbf7350fa217e7eb33967bf15351e9.tar.xz
frr-3d7a1be850dbf7350fa217e7eb33967bf15351e9.zip
ripd: retrofit the 'network' command to the new northbound model
The frr-ripd YANG module models the ripd "network" command using two separate leaf-lists for simplicity: one leaf-list for interfaces and another leaf-list for actual networks. In the 'cli_show' callbacks, display the "network" command for entries of both leaf-lists. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ripd/rip_interface.c')
-rw-r--r--ripd/rip_interface.c85
1 files changed, 13 insertions, 72 deletions
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index 4373484a2..1e79e6d27 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -762,7 +762,7 @@ int rip_enable_network_lookup2(struct connected *connected)
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;
@@ -770,18 +770,18 @@ static int rip_enable_network_add(struct prefix *p)
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;
@@ -798,9 +798,10 @@ static int rip_enable_network_delete(struct prefix *p)
/* 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. */
@@ -817,31 +818,31 @@ static int rip_enable_if_lookup(const char *ifname)
}
/* 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);
@@ -849,7 +850,7 @@ static int rip_enable_if_delete(const char *ifname)
rip_enable_apply_all(); /* TODOVJ */
- return 1;
+ return NB_OK;
}
/* Join to multicast group and send request to the interface. */
@@ -1152,63 +1153,6 @@ void rip_passive_nondefault_clean(void)
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>",
@@ -1848,9 +1792,6 @@ void rip_if_init(void)
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);