diff options
author | Renato Westphal <renato@opensourcerouting.org> | 2018-05-09 06:34:59 +0200 |
---|---|---|
committer | Renato Westphal <renato@opensourcerouting.org> | 2018-10-27 20:16:12 +0200 |
commit | 7f8a9cbab7922be545a96af91d72fe38caf8e197 (patch) | |
tree | f53dbef5132a2b7012d4f465b76c5b3ac5907a70 /ripd | |
parent | ripd: retrofit the 'default-metric' command to the new northbound model (diff) | |
download | frr-7f8a9cbab7922be545a96af91d72fe38caf8e197.tar.xz frr-7f8a9cbab7922be545a96af91d72fe38caf8e197.zip |
ripd: retrofit the 'distance' command to the new northbound model
Trivial conversion.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ripd')
-rw-r--r-- | ripd/rip_cli.c | 46 | ||||
-rw-r--r-- | ripd/rip_cli.h | 2 | ||||
-rw-r--r-- | ripd/rip_northbound.c | 7 | ||||
-rw-r--r-- | ripd/ripd.c | 30 |
4 files changed, 55 insertions, 30 deletions
diff --git a/ripd/rip_cli.c b/ripd/rip_cli.c index d374ea64f..b9824d352 100644 --- a/ripd/rip_cli.c +++ b/ripd/rip_cli.c @@ -190,6 +190,50 @@ void cli_show_rip_default_metric(struct vty *vty, struct lyd_node *dnode, yang_dnode_get_string(dnode, NULL)); } +/* + * XPath: /frr-ripd:ripd/instance/distance/default + */ +DEFPY (rip_distance, + rip_distance_cmd, + "distance (1-255)", + "Administrative distance\n" + "Distance value\n") +{ + struct cli_config_change changes[] = { + { + .xpath = "./distance/default", + .operation = NB_OP_MODIFY, + .value = distance_str, + }, + }; + + return nb_cli_cfg_change(vty, NULL, changes, array_size(changes)); +} + +DEFPY (no_rip_distance, + no_rip_distance_cmd, + "no distance [(1-255)]", + NO_STR + "Administrative distance\n" + "Distance value\n") +{ + struct cli_config_change changes[] = { + { + .xpath = "./distance/default", + .operation = NB_OP_MODIFY, + .value = NULL, + }, + }; + + return nb_cli_cfg_change(vty, NULL, changes, array_size(changes)); +} + +void cli_show_rip_distance(struct vty *vty, struct lyd_node *dnode, + bool show_defaults) +{ + vty_out(vty, " distance %s\n", yang_dnode_get_string(dnode, NULL)); +} + void rip_cli_init(void) { install_element(CONFIG_NODE, &router_rip_cmd); @@ -199,4 +243,6 @@ void rip_cli_init(void) 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); + install_element(RIP_NODE, &rip_distance_cmd); + install_element(RIP_NODE, &no_rip_distance_cmd); } diff --git a/ripd/rip_cli.h b/ripd/rip_cli.h index 3e60ae8f9..1e2faac7f 100644 --- a/ripd/rip_cli.h +++ b/ripd/rip_cli.h @@ -30,5 +30,7 @@ extern void cli_show_rip_default_information_originate(struct vty *vty, bool show_defaults); extern void cli_show_rip_default_metric(struct vty *vty, struct lyd_node *dnode, bool show_defaults); +extern void cli_show_rip_distance(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); #endif /* _FRR_RIP_CLI_H_ */ diff --git a/ripd/rip_northbound.c b/ripd/rip_northbound.c index 67719cb25..79b3d252e 100644 --- a/ripd/rip_northbound.c +++ b/ripd/rip_northbound.c @@ -147,7 +147,11 @@ static int ripd_instance_distance_default_modify(enum nb_event event, const struct lyd_node *dnode, union nb_resource *resource) { - /* TODO: implement me. */ + if (event != NB_EV_APPLY) + return NB_OK; + + rip->distance = yang_dnode_get_uint8(dnode, NULL); + return NB_OK; } @@ -769,6 +773,7 @@ const struct frr_yang_module_info frr_ripd_info = { { .xpath = "/frr-ripd:ripd/instance/distance/default", .cbs.modify = ripd_instance_distance_default_modify, + .cbs.cli_show = cli_show_rip_distance, }, { .xpath = "/frr-ripd:ripd/instance/distance/source", diff --git a/ripd/ripd.c b/ripd/ripd.c index 1ae1d29eb..d85ebcc53 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -3157,7 +3157,7 @@ static void rip_distance_show(struct vty *vty) int header = 1; char buf[BUFSIZ]; - vty_out(vty, " Distance: (default is %d)\n", + vty_out(vty, " Distance: (default is %u)\n", rip->distance ? rip->distance : ZEBRA_RIP_DISTANCE_DEFAULT); for (rn = route_top(rip_distance_table); rn; rn = route_next(rn)) @@ -3176,28 +3176,6 @@ static void rip_distance_show(struct vty *vty) } } -DEFUN (rip_distance, - rip_distance_cmd, - "distance (1-255)", - "Administrative distance\n" - "Distance value\n") -{ - int idx_number = 1; - rip->distance = atoi(argv[idx_number]->arg); - return CMD_SUCCESS; -} - -DEFUN (no_rip_distance, - no_rip_distance_cmd, - "no distance (1-255)", - NO_STR - "Administrative distance\n" - "Distance value\n") -{ - rip->distance = 0; - return CMD_SUCCESS; -} - DEFUN (rip_distance_source, rip_distance_source_cmd, "distance (1-255) A.B.C.D/M", @@ -3591,10 +3569,6 @@ static int config_write_rip(struct vty *vty) /* Interface routemap configuration */ write += config_write_if_rmap(vty); - /* Distance configuration. */ - if (rip->distance) - vty_out(vty, " distance %d\n", rip->distance); - /* RIP source IP prefix distance configuration. */ for (rn = route_top(rip_distance_table); rn; rn = route_next(rn)) @@ -3889,8 +3863,6 @@ void rip_init(void) install_element(RIP_NODE, &no_rip_timers_cmd); install_element(RIP_NODE, &rip_route_cmd); install_element(RIP_NODE, &no_rip_route_cmd); - install_element(RIP_NODE, &rip_distance_cmd); - install_element(RIP_NODE, &no_rip_distance_cmd); install_element(RIP_NODE, &rip_distance_source_cmd); install_element(RIP_NODE, &no_rip_distance_source_cmd); install_element(RIP_NODE, &rip_distance_source_access_list_cmd); |