diff options
| author | Emanuele Di Pascale <emanuele@voltanet.io> | 2018-11-14 14:39:18 +0100 | 
|---|---|---|
| committer | Emanuele Di Pascale <emanuele@voltanet.io> | 2018-12-18 15:24:46 +0100 | 
| commit | d59c2d6be6452601c2fb0f8b1316c73aa17853c1 (patch) | |
| tree | a324062b72b846dff5503a1b42041895bed4e861 /isisd | |
| parent | d082076585baa46e58d7becaabb311ea7f40ec0c (diff) | |
isisd: retrofit the 'isis priority' command
remove isis_vty_isisd.c as it is no longer needed
Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
Diffstat (limited to 'isisd')
| -rw-r--r-- | isisd/isis_cli.c | 57 | ||||
| -rw-r--r-- | isisd/isis_cli.h | 2 | ||||
| -rw-r--r-- | isisd/isis_northbound.c | 22 | ||||
| -rw-r--r-- | isisd/isis_vty_common.c | 2 | ||||
| -rw-r--r-- | isisd/isis_vty_isisd.c | 127 | ||||
| -rw-r--r-- | isisd/subdir.am | 2 | 
6 files changed, 81 insertions, 131 deletions
diff --git a/isisd/isis_cli.c b/isisd/isis_cli.c index 4be87a791f..6934c33fc8 100644 --- a/isisd/isis_cli.c +++ b/isisd/isis_cli.c @@ -1824,6 +1824,60 @@ void cli_show_ip_isis_network_type(struct vty *vty, struct lyd_node *dnode,  	vty_out(vty, " isis network point-to-point\n");  } +/* + * XPath: /frr-interface:lib/interface/frr-isisd:isis/priority + */ +DEFPY(isis_priority, isis_priority_cmd, +      "isis priority (0-127)$prio [level-1|level-2]$level", +      "IS-IS routing protocol\n" +      "Set priority for Designated Router election\n" +      "Priority value\n" +      "Specify priority for level-1 routing\n" +      "Specify priority for level-2 routing\n") +{ +	if (!level || strmatch(level, "level-1")) +		nb_cli_enqueue_change(vty, "./frr-isisd:isis/priority/level-1", +				      NB_OP_MODIFY, prio_str); +	if (!level || strmatch(level, "level-2")) +		nb_cli_enqueue_change(vty, "./frr-isisd:isis/priority/level-2", +				      NB_OP_MODIFY, prio_str); + +	return nb_cli_apply_changes(vty, NULL); +} + +DEFPY(no_isis_priority, no_isis_priority_cmd, +      "no isis priority [(0-127)] [level-1|level-2]$level", +      NO_STR +      "IS-IS routing protocol\n" +      "Set priority for Designated Router election\n" +      "Priority value\n" +      "Specify priority for level-1 routing\n" +      "Specify priority for level-2 routing\n") +{ +	if (!level || strmatch(level, "level-1")) +		nb_cli_enqueue_change(vty, "./frr-isisd:isis/priority/level-1", +				      NB_OP_MODIFY, NULL); +	if (!level || strmatch(level, "level-2")) +		nb_cli_enqueue_change(vty, "./frr-isisd:isis/priority/level-2", +				      NB_OP_MODIFY, NULL); + +	return nb_cli_apply_changes(vty, NULL); +} + +void cli_show_ip_isis_priority(struct vty *vty, struct lyd_node *dnode, +			       bool show_defaults) +{ +	const char *l1 = yang_dnode_get_string(dnode, "./level-1"); +	const char *l2 = yang_dnode_get_string(dnode, "./level-2"); + +	if (strmatch(l1, l2)) +		vty_out(vty, " isis priority %s\n", l1); +	else { +		vty_out(vty, " isis priority %s level-1\n", l1); +		vty_out(vty, " isis priority %s level-2\n", l2); +	} +} +  void isis_cli_init(void)  {  	install_element(CONFIG_NODE, &router_isis_cmd); @@ -1906,6 +1960,9 @@ void isis_cli_init(void)  	install_element(INTERFACE_NODE, &no_isis_circuit_type_cmd);  	install_element(INTERFACE_NODE, &isis_network_cmd); + +	install_element(INTERFACE_NODE, &isis_priority_cmd); +	install_element(INTERFACE_NODE, &no_isis_priority_cmd);  }  #endif /* ifndef FABRICD */ diff --git a/isisd/isis_cli.h b/isisd/isis_cli.h index 0bc7e1c81c..90e31859fc 100644 --- a/isisd/isis_cli.h +++ b/isisd/isis_cli.h @@ -117,5 +117,7 @@ void cli_show_ip_isis_circ_type(struct vty *vty, struct lyd_node *dnode,  				bool show_defaults);  void cli_show_ip_isis_network_type(struct vty *vty, struct lyd_node *dnode,  				   bool show_defaults); +void cli_show_ip_isis_priority(struct vty *vty, struct lyd_node *dnode, +			       bool show_defaults);  #endif /* ISISD_ISIS_CLI_H_ */ diff --git a/isisd/isis_northbound.c b/isisd/isis_northbound.c index 125b80aab4..c11788a498 100644 --- a/isisd/isis_northbound.c +++ b/isisd/isis_northbound.c @@ -2069,7 +2069,14 @@ lib_interface_isis_priority_level_1_modify(enum nb_event event,  					   const struct lyd_node *dnode,  					   union nb_resource *resource)  { -	/* TODO: implement me. */ +	struct isis_circuit *circuit; + +	if (event != NB_EV_APPLY) +		return NB_OK; + +	circuit = yang_dnode_get_entry(dnode, true); +	circuit->priority[0] = yang_dnode_get_uint8(dnode, NULL); +  	return NB_OK;  } @@ -2081,7 +2088,14 @@ lib_interface_isis_priority_level_2_modify(enum nb_event event,  					   const struct lyd_node *dnode,  					   union nb_resource *resource)  { -	/* TODO: implement me. */ +	struct isis_circuit *circuit; + +	if (event != NB_EV_APPLY) +		return NB_OK; + +	circuit = yang_dnode_get_entry(dnode, true); +	circuit->priority[1] = yang_dnode_get_uint8(dnode, NULL); +  	return NB_OK;  } @@ -2836,6 +2850,10 @@ const struct frr_yang_module_info frr_isisd_info = {  			.cbs.modify = lib_interface_isis_metric_level_2_modify,  		},  		{ +			.xpath = "/frr-interface:lib/interface/frr-isisd:isis/priority", +			.cbs.cli_show = cli_show_ip_isis_priority, +		}, +		{  			.xpath = "/frr-interface:lib/interface/frr-isisd:isis/priority/level-1",  			.cbs.modify = lib_interface_isis_priority_level_1_modify,  		}, diff --git a/isisd/isis_vty_common.c b/isisd/isis_vty_common.c index 911713d657..06432db0b2 100644 --- a/isisd/isis_vty_common.c +++ b/isisd/isis_vty_common.c @@ -103,5 +103,7 @@ void isis_vty_init(void)  	install_element(INTERFACE_NODE, &isis_bfd_cmd);  	install_element(INTERFACE_NODE, &no_isis_bfd_cmd); +#ifdef FABRICD  	isis_vty_daemon_init(); +#endif /* ifdef FABRICD */  } diff --git a/isisd/isis_vty_isisd.c b/isisd/isis_vty_isisd.c deleted file mode 100644 index 1208420272..0000000000 --- a/isisd/isis_vty_isisd.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * IS-IS Rout(e)ing protocol - isis_vty_isisd.c - * - * This file contains the CLI that is specific to IS-IS - * - * Copyright (C) 2001,2002   Sampo Saaristo - *                           Tampere University of Technology - *                           Institute of Communications Engineering - * Copyright (C) 2016        David Lamparter, for NetDEF, Inc. - * Copyright (C) 2018        Christian Franke, for NetDEF, Inc. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public Licenseas published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful,but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; see the file COPYING; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <zebra.h> - -#include "command.h" - -#include "isis_circuit.h" -#include "isis_csm.h" -#include "isis_misc.h" -#include "isis_mt.h" -#include "isisd.h" -#include "isis_vty_common.h" - -static int level_for_arg(const char *arg) -{ -	if (!strcmp(arg, "level-1")) -		return IS_LEVEL_1; -	else -		return IS_LEVEL_2; -} - -DEFUN (isis_priority, -       isis_priority_cmd, -       "isis priority (0-127)", -       "IS-IS routing protocol\n" -       "Set priority for Designated Router election\n" -       "Priority value\n") -{ -	uint8_t prio = atoi(argv[2]->arg); -	struct isis_circuit *circuit = isis_circuit_lookup(vty); -	if (!circuit) -		return CMD_ERR_NO_MATCH; - -	circuit->priority[0] = prio; -	circuit->priority[1] = prio; - -	return CMD_SUCCESS; -} - -DEFUN (no_isis_priority, -       no_isis_priority_cmd, -       "no isis priority [(0-127)]", -       NO_STR -       "IS-IS routing protocol\n" -       "Set priority for Designated Router election\n" -       "Priority value\n") -{ -	struct isis_circuit *circuit = isis_circuit_lookup(vty); -	if (!circuit) -		return CMD_ERR_NO_MATCH; - -	circuit->priority[0] = DEFAULT_PRIORITY; -	circuit->priority[1] = DEFAULT_PRIORITY; - -	return CMD_SUCCESS; -} - -DEFUN (isis_priority_level, -       isis_priority_level_cmd, -       "isis priority (0-127) <level-1|level-2>", -       "IS-IS routing protocol\n" -       "Set priority for Designated Router election\n" -       "Priority value\n" -       "Specify priority for level-1 routing\n" -       "Specify priority for level-2 routing\n") -{ -	uint8_t prio = atoi(argv[2]->arg); -	struct isis_circuit *circuit = isis_circuit_lookup(vty); -	if (!circuit) -		return CMD_ERR_NO_MATCH; - -	circuit->priority[level_for_arg(argv[3]->text)] = prio; - -	return CMD_SUCCESS; -} - -DEFUN (no_isis_priority_level, -       no_isis_priority_level_cmd, -       "no isis priority [(0-127)] <level-1|level-2>", -       NO_STR -       "IS-IS routing protocol\n" -       "Set priority for Designated Router election\n" -       "Priority value\n" -       "Specify priority for level-1 routing\n" -       "Specify priority for level-2 routing\n") -{ -	struct isis_circuit *circuit = isis_circuit_lookup(vty); -	int level = level_for_arg(argv[argc - 1]->text); -	if (!circuit) -		return CMD_ERR_NO_MATCH; - -	circuit->priority[level] = DEFAULT_PRIORITY; - -	return CMD_SUCCESS; -} - -void isis_vty_daemon_init(void) -{ -	install_element(INTERFACE_NODE, &isis_priority_cmd); -	install_element(INTERFACE_NODE, &no_isis_priority_cmd); -	install_element(INTERFACE_NODE, &isis_priority_level_cmd); -	install_element(INTERFACE_NODE, &no_isis_priority_level_cmd); -} diff --git a/isisd/subdir.am b/isisd/subdir.am index 749caec6e5..11bedd9ed2 100644 --- a/isisd/subdir.am +++ b/isisd/subdir.am @@ -13,7 +13,6 @@ vtysh_scan += \  	$(top_srcdir)/isisd/isis_te.c \  	$(top_srcdir)/isisd/isis_vty_common.c \  	$(top_srcdir)/isisd/isis_vty_fabricd.c \ -	$(top_srcdir)/isisd/isis_vty_isisd.c \  	$(top_srcdir)/isisd/isisd.c \  	# end  man8 += $(MANBUILD)/isisd.8 @@ -105,7 +104,6 @@ ISIS_LDADD_COMMON = lib/libfrr.la @LIBCAP@  isisd_libisis_a_SOURCES = \  	$(LIBISIS_SOURCES) \ -	isisd/isis_vty_isisd.c \  	isisd/isis_northbound.c \  	isisd/isis_cli.c \  	#end  | 
