diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2018-05-09 01:35:01 -0300 | 
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2018-10-27 16:16:12 -0200 | 
| commit | 90eff9dafe8f6985d77db9db8a1b48e159ed046c (patch) | |
| tree | 3843e159dca61d70b44441d6ae0eabe231ef3b46 /ripd/rip_cli.c | |
| parent | b745780b5f56e9770c5ba0785bafd17b2239c6cc (diff) | |
ripd: retrofit the 'version' command to the new northbound model
Trivial conversion.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ripd/rip_cli.c')
| -rw-r--r-- | ripd/rip_cli.c | 68 | 
1 files changed, 68 insertions, 0 deletions
diff --git a/ripd/rip_cli.c b/ripd/rip_cli.c index a89df5b2f1..6fa21df2cc 100644 --- a/ripd/rip_cli.c +++ b/ripd/rip_cli.c @@ -712,6 +712,72 @@ void cli_show_rip_timers(struct vty *vty, struct lyd_node *dnode,  		yang_dnode_get_string(dnode, "./flush-interval"));  } +/* + * XPath: /frr-ripd:ripd/instance/version + */ +DEFPY (rip_version, +       rip_version_cmd, +       "version (1-2)", +       "Set routing protocol version\n" +       "version\n") +{ +	struct cli_config_change changes[] = { +		{ +			.xpath = "./version/receive", +			.operation = NB_OP_MODIFY, +			.value = version_str, +		}, +		{ +			.xpath = "./version/send", +			.operation = NB_OP_MODIFY, +			.value = version_str, +		}, +	}; + +	return nb_cli_cfg_change(vty, NULL, changes, array_size(changes)); +} + +DEFPY (no_rip_version, +       no_rip_version_cmd, +       "no version [(1-2)]", +       NO_STR +       "Set routing protocol version\n" +       "version\n") +{ +	struct cli_config_change changes[] = { +		{ +			.xpath = "./version/receive", +			.operation = NB_OP_MODIFY, +		}, +		{ +			.xpath = "./version/send", +			.operation = NB_OP_MODIFY, +		}, +	}; + +	return nb_cli_cfg_change(vty, NULL, changes, array_size(changes)); +} + +void cli_show_rip_version(struct vty *vty, struct lyd_node *dnode, +			  bool show_defaults) +{ +	/* +	 * We have only one "version" command and three possible combinations of +	 * send/receive values. +	 */ +	switch (yang_dnode_get_enum(dnode, "./receive")) { +	case RI_RIP_VERSION_1: +		vty_out(vty, " version 1\n"); +		break; +	case RI_RIP_VERSION_2: +		vty_out(vty, " version 2\n"); +		break; +	case RI_RIP_VERSION_1_AND_2: +		vty_out(vty, " no version\n"); +		break; +	} +} +  void rip_cli_init(void)  {  	install_element(CONFIG_NODE, &router_rip_cmd); @@ -737,4 +803,6 @@ void rip_cli_init(void)  	install_element(RIP_NODE, &rip_route_cmd);  	install_element(RIP_NODE, &rip_timers_cmd);  	install_element(RIP_NODE, &no_rip_timers_cmd); +	install_element(RIP_NODE, &rip_version_cmd); +	install_element(RIP_NODE, &no_rip_version_cmd);  }  | 
