]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_vty_isisd.c
isisd: retrofit the 'isis network' command
[mirror_frr.git] / isisd / isis_vty_isisd.c
1 /*
2 * IS-IS Rout(e)ing protocol - isis_vty_isisd.c
3 *
4 * This file contains the CLI that is specific to IS-IS
5 *
6 * Copyright (C) 2001,2002 Sampo Saaristo
7 * Tampere University of Technology
8 * Institute of Communications Engineering
9 * Copyright (C) 2016 David Lamparter, for NetDEF, Inc.
10 * Copyright (C) 2018 Christian Franke, for NetDEF, Inc.
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public Licenseas published by the Free
14 * Software Foundation; either version 2 of the License, or (at your option)
15 * any later version.
16 *
17 * This program is distributed in the hope that it will be useful,but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
20 * more details.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; see the file COPYING; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 */
26
27 #include <zebra.h>
28
29 #include "command.h"
30
31 #include "isis_circuit.h"
32 #include "isis_csm.h"
33 #include "isis_misc.h"
34 #include "isis_mt.h"
35 #include "isisd.h"
36 #include "isis_vty_common.h"
37
38 static int level_for_arg(const char *arg)
39 {
40 if (!strcmp(arg, "level-1"))
41 return IS_LEVEL_1;
42 else
43 return IS_LEVEL_2;
44 }
45
46 DEFUN (isis_priority,
47 isis_priority_cmd,
48 "isis priority (0-127)",
49 "IS-IS routing protocol\n"
50 "Set priority for Designated Router election\n"
51 "Priority value\n")
52 {
53 uint8_t prio = atoi(argv[2]->arg);
54 struct isis_circuit *circuit = isis_circuit_lookup(vty);
55 if (!circuit)
56 return CMD_ERR_NO_MATCH;
57
58 circuit->priority[0] = prio;
59 circuit->priority[1] = prio;
60
61 return CMD_SUCCESS;
62 }
63
64 DEFUN (no_isis_priority,
65 no_isis_priority_cmd,
66 "no isis priority [(0-127)]",
67 NO_STR
68 "IS-IS routing protocol\n"
69 "Set priority for Designated Router election\n"
70 "Priority value\n")
71 {
72 struct isis_circuit *circuit = isis_circuit_lookup(vty);
73 if (!circuit)
74 return CMD_ERR_NO_MATCH;
75
76 circuit->priority[0] = DEFAULT_PRIORITY;
77 circuit->priority[1] = DEFAULT_PRIORITY;
78
79 return CMD_SUCCESS;
80 }
81
82 DEFUN (isis_priority_level,
83 isis_priority_level_cmd,
84 "isis priority (0-127) <level-1|level-2>",
85 "IS-IS routing protocol\n"
86 "Set priority for Designated Router election\n"
87 "Priority value\n"
88 "Specify priority for level-1 routing\n"
89 "Specify priority for level-2 routing\n")
90 {
91 uint8_t prio = atoi(argv[2]->arg);
92 struct isis_circuit *circuit = isis_circuit_lookup(vty);
93 if (!circuit)
94 return CMD_ERR_NO_MATCH;
95
96 circuit->priority[level_for_arg(argv[3]->text)] = prio;
97
98 return CMD_SUCCESS;
99 }
100
101 DEFUN (no_isis_priority_level,
102 no_isis_priority_level_cmd,
103 "no isis priority [(0-127)] <level-1|level-2>",
104 NO_STR
105 "IS-IS routing protocol\n"
106 "Set priority for Designated Router election\n"
107 "Priority value\n"
108 "Specify priority for level-1 routing\n"
109 "Specify priority for level-2 routing\n")
110 {
111 struct isis_circuit *circuit = isis_circuit_lookup(vty);
112 int level = level_for_arg(argv[argc - 1]->text);
113 if (!circuit)
114 return CMD_ERR_NO_MATCH;
115
116 circuit->priority[level] = DEFAULT_PRIORITY;
117
118 return CMD_SUCCESS;
119 }
120
121 void isis_vty_daemon_init(void)
122 {
123 install_element(INTERFACE_NODE, &isis_priority_cmd);
124 install_element(INTERFACE_NODE, &no_isis_priority_cmd);
125 install_element(INTERFACE_NODE, &isis_priority_level_cmd);
126 install_element(INTERFACE_NODE, &no_isis_priority_level_cmd);
127 }