]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_vty_isisd.c
isisd: retrofit the 'isis hello-multiplier' 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_circuit_type,
47 isis_circuit_type_cmd,
48 "isis circuit-type <level-1|level-1-2|level-2-only>",
49 "IS-IS routing protocol\n"
50 "Configure circuit type for interface\n"
51 "Level-1 only adjacencies are formed\n"
52 "Level-1-2 adjacencies are formed\n"
53 "Level-2 only adjacencies are formed\n")
54 {
55 int idx_level = 2;
56 int is_type;
57 struct isis_circuit *circuit = isis_circuit_lookup(vty);
58 if (!circuit)
59 return CMD_ERR_NO_MATCH;
60
61 is_type = string2circuit_t(argv[idx_level]->arg);
62 if (!is_type) {
63 vty_out(vty, "Unknown circuit-type \n");
64 return CMD_WARNING_CONFIG_FAILED;
65 }
66
67 if (circuit->state == C_STATE_UP
68 && circuit->area->is_type != IS_LEVEL_1_AND_2
69 && circuit->area->is_type != is_type) {
70 vty_out(vty, "Invalid circuit level for area %s.\n",
71 circuit->area->area_tag);
72 return CMD_WARNING_CONFIG_FAILED;
73 }
74 isis_circuit_is_type_set(circuit, is_type);
75
76 return CMD_SUCCESS;
77 }
78
79 DEFUN (no_isis_circuit_type,
80 no_isis_circuit_type_cmd,
81 "no isis circuit-type <level-1|level-1-2|level-2-only>",
82 NO_STR
83 "IS-IS routing protocol\n"
84 "Configure circuit type for interface\n"
85 "Level-1 only adjacencies are formed\n"
86 "Level-1-2 adjacencies are formed\n"
87 "Level-2 only adjacencies are formed\n")
88 {
89 int is_type;
90 struct isis_circuit *circuit = isis_circuit_lookup(vty);
91 if (!circuit)
92 return CMD_ERR_NO_MATCH;
93
94 /*
95 * Set the circuits level to its default value
96 */
97 if (circuit->state == C_STATE_UP)
98 is_type = circuit->area->is_type;
99 else
100 is_type = IS_LEVEL_1_AND_2;
101 isis_circuit_is_type_set(circuit, is_type);
102
103 return CMD_SUCCESS;
104 }
105
106 DEFUN (isis_network,
107 isis_network_cmd,
108 "isis network point-to-point",
109 "IS-IS routing protocol\n"
110 "Set network type\n"
111 "point-to-point network type\n")
112 {
113 struct isis_circuit *circuit = isis_circuit_lookup(vty);
114 if (!circuit)
115 return CMD_ERR_NO_MATCH;
116
117 if (isis_circuit_circ_type_set(circuit, CIRCUIT_T_P2P)) {
118 vty_out(vty,
119 "isis network point-to-point is valid only on broadcast interfaces\n");
120 return CMD_WARNING_CONFIG_FAILED;
121 }
122
123 return CMD_SUCCESS;
124 }
125
126 DEFUN (no_isis_network,
127 no_isis_network_cmd,
128 "no isis network point-to-point",
129 NO_STR
130 "IS-IS routing protocol\n"
131 "Set network type for circuit\n"
132 "point-to-point network type\n")
133 {
134 struct isis_circuit *circuit = isis_circuit_lookup(vty);
135 if (!circuit)
136 return CMD_ERR_NO_MATCH;
137
138 if (isis_circuit_circ_type_set(circuit, CIRCUIT_T_BROADCAST)) {
139 vty_out(vty,
140 "isis network point-to-point is valid only on broadcast interfaces\n");
141 return CMD_WARNING_CONFIG_FAILED;
142 }
143
144 return CMD_SUCCESS;
145 }
146
147 DEFUN (isis_priority,
148 isis_priority_cmd,
149 "isis priority (0-127)",
150 "IS-IS routing protocol\n"
151 "Set priority for Designated Router election\n"
152 "Priority value\n")
153 {
154 uint8_t prio = atoi(argv[2]->arg);
155 struct isis_circuit *circuit = isis_circuit_lookup(vty);
156 if (!circuit)
157 return CMD_ERR_NO_MATCH;
158
159 circuit->priority[0] = prio;
160 circuit->priority[1] = prio;
161
162 return CMD_SUCCESS;
163 }
164
165 DEFUN (no_isis_priority,
166 no_isis_priority_cmd,
167 "no isis priority [(0-127)]",
168 NO_STR
169 "IS-IS routing protocol\n"
170 "Set priority for Designated Router election\n"
171 "Priority value\n")
172 {
173 struct isis_circuit *circuit = isis_circuit_lookup(vty);
174 if (!circuit)
175 return CMD_ERR_NO_MATCH;
176
177 circuit->priority[0] = DEFAULT_PRIORITY;
178 circuit->priority[1] = DEFAULT_PRIORITY;
179
180 return CMD_SUCCESS;
181 }
182
183 DEFUN (isis_priority_level,
184 isis_priority_level_cmd,
185 "isis priority (0-127) <level-1|level-2>",
186 "IS-IS routing protocol\n"
187 "Set priority for Designated Router election\n"
188 "Priority value\n"
189 "Specify priority for level-1 routing\n"
190 "Specify priority for level-2 routing\n")
191 {
192 uint8_t prio = atoi(argv[2]->arg);
193 struct isis_circuit *circuit = isis_circuit_lookup(vty);
194 if (!circuit)
195 return CMD_ERR_NO_MATCH;
196
197 circuit->priority[level_for_arg(argv[3]->text)] = prio;
198
199 return CMD_SUCCESS;
200 }
201
202 DEFUN (no_isis_priority_level,
203 no_isis_priority_level_cmd,
204 "no isis priority [(0-127)] <level-1|level-2>",
205 NO_STR
206 "IS-IS routing protocol\n"
207 "Set priority for Designated Router election\n"
208 "Priority value\n"
209 "Specify priority for level-1 routing\n"
210 "Specify priority for level-2 routing\n")
211 {
212 struct isis_circuit *circuit = isis_circuit_lookup(vty);
213 int level = level_for_arg(argv[argc - 1]->text);
214 if (!circuit)
215 return CMD_ERR_NO_MATCH;
216
217 circuit->priority[level] = DEFAULT_PRIORITY;
218
219 return CMD_SUCCESS;
220 }
221
222 DEFUN (isis_threeway_adj,
223 isis_threeway_adj_cmd,
224 "[no] isis three-way-handshake",
225 NO_STR
226 "IS-IS commands\n"
227 "Enable/Disable three-way handshake\n")
228 {
229 struct isis_circuit *circuit = isis_circuit_lookup(vty);
230 if (!circuit)
231 return CMD_ERR_NO_MATCH;
232
233 circuit->disable_threeway_adj = !strcmp(argv[0]->text, "no");
234 return CMD_SUCCESS;
235 }
236
237 DEFUN (isis_hello_padding,
238 isis_hello_padding_cmd,
239 "isis hello padding",
240 "IS-IS routing protocol\n"
241 "Add padding to IS-IS hello packets\n"
242 "Pad hello packets\n")
243 {
244 struct isis_circuit *circuit = isis_circuit_lookup(vty);
245 if (!circuit)
246 return CMD_ERR_NO_MATCH;
247
248 circuit->pad_hellos = 1;
249
250 return CMD_SUCCESS;
251 }
252
253 DEFUN (no_isis_hello_padding,
254 no_isis_hello_padding_cmd,
255 "no isis hello padding",
256 NO_STR
257 "IS-IS routing protocol\n"
258 "Add padding to IS-IS hello packets\n"
259 "Pad hello packets\n")
260 {
261 struct isis_circuit *circuit = isis_circuit_lookup(vty);
262 if (!circuit)
263 return CMD_ERR_NO_MATCH;
264
265 circuit->pad_hellos = 0;
266
267 return CMD_SUCCESS;
268 }
269
270 DEFUN (csnp_interval_level,
271 csnp_interval_level_cmd,
272 "isis csnp-interval (1-600) <level-1|level-2>",
273 "IS-IS routing protocol\n"
274 "Set CSNP interval in seconds\n"
275 "CSNP interval value\n"
276 "Specify interval for level-1 CSNPs\n"
277 "Specify interval for level-2 CSNPs\n")
278 {
279 uint16_t interval = atoi(argv[2]->arg);
280 struct isis_circuit *circuit = isis_circuit_lookup(vty);
281 if (!circuit)
282 return CMD_ERR_NO_MATCH;
283
284 circuit->csnp_interval[level_for_arg(argv[3]->text)] = interval;
285
286 return CMD_SUCCESS;
287 }
288
289 DEFUN (no_csnp_interval_level,
290 no_csnp_interval_level_cmd,
291 "no isis csnp-interval [(1-600)] <level-1|level-2>",
292 NO_STR
293 "IS-IS routing protocol\n"
294 "Set CSNP interval in seconds\n"
295 "CSNP interval value\n"
296 "Specify interval for level-1 CSNPs\n"
297 "Specify interval for level-2 CSNPs\n")
298 {
299 struct isis_circuit *circuit = isis_circuit_lookup(vty);
300 int level = level_for_arg(argv[argc - 1]->text);
301 if (!circuit)
302 return CMD_ERR_NO_MATCH;
303
304 circuit->csnp_interval[level] = DEFAULT_CSNP_INTERVAL;
305
306 return CMD_SUCCESS;
307 }
308
309 DEFUN (psnp_interval_level,
310 psnp_interval_level_cmd,
311 "isis psnp-interval (1-120) <level-1|level-2>",
312 "IS-IS routing protocol\n"
313 "Set PSNP interval in seconds\n"
314 "PSNP interval value\n"
315 "Specify interval for level-1 PSNPs\n"
316 "Specify interval for level-2 PSNPs\n")
317 {
318 uint16_t interval = atoi(argv[2]->arg);
319 struct isis_circuit *circuit = isis_circuit_lookup(vty);
320 if (!circuit)
321 return CMD_ERR_NO_MATCH;
322
323 circuit->psnp_interval[level_for_arg(argv[3]->text)] = (uint16_t)interval;
324
325 return CMD_SUCCESS;
326 }
327
328 DEFUN (no_psnp_interval_level,
329 no_psnp_interval_level_cmd,
330 "no isis psnp-interval [(1-120)] <level-1|level-2>",
331 NO_STR
332 "IS-IS routing protocol\n"
333 "Set PSNP interval in seconds\n"
334 "PSNP interval value\n"
335 "Specify interval for level-1 PSNPs\n"
336 "Specify interval for level-2 PSNPs\n")
337 {
338 struct isis_circuit *circuit = isis_circuit_lookup(vty);
339 int level = level_for_arg(argv[argc - 1]->text);
340 if (!circuit)
341 return CMD_ERR_NO_MATCH;
342
343 circuit->psnp_interval[level] = DEFAULT_PSNP_INTERVAL;
344
345 return CMD_SUCCESS;
346 }
347
348 void isis_vty_daemon_init(void)
349 {
350 install_element(INTERFACE_NODE, &isis_circuit_type_cmd);
351 install_element(INTERFACE_NODE, &no_isis_circuit_type_cmd);
352
353 install_element(INTERFACE_NODE, &isis_network_cmd);
354 install_element(INTERFACE_NODE, &no_isis_network_cmd);
355
356 install_element(INTERFACE_NODE, &isis_priority_cmd);
357 install_element(INTERFACE_NODE, &no_isis_priority_cmd);
358 install_element(INTERFACE_NODE, &isis_priority_level_cmd);
359 install_element(INTERFACE_NODE, &no_isis_priority_level_cmd);
360
361 install_element(INTERFACE_NODE, &isis_threeway_adj_cmd);
362
363 install_element(INTERFACE_NODE, &isis_hello_padding_cmd);
364 install_element(INTERFACE_NODE, &no_isis_hello_padding_cmd);
365
366 install_element(INTERFACE_NODE, &csnp_interval_level_cmd);
367 install_element(INTERFACE_NODE, &no_csnp_interval_level_cmd);
368
369 install_element(INTERFACE_NODE, &psnp_interval_level_cmd);
370 install_element(INTERFACE_NODE, &no_psnp_interval_level_cmd);
371 }