2 * IS-IS Rout(e)ing protocol - isis_vty_isisd.c
4 * This file contains the CLI that is specific to IS-IS
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.
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)
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
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
31 #include "isis_circuit.h"
33 #include "isis_misc.h"
36 #include "isis_vty_common.h"
38 static int level_for_arg(const char *arg
)
40 if (!strcmp(arg
, "level-1"))
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")
57 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
59 return CMD_ERR_NO_MATCH
;
61 is_type
= string2circuit_t(argv
[idx_level
]->arg
);
63 vty_out(vty
, "Unknown circuit-type \n");
64 return CMD_WARNING_CONFIG_FAILED
;
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
;
74 isis_circuit_is_type_set(circuit
, is_type
);
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>",
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")
90 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
92 return CMD_ERR_NO_MATCH
;
95 * Set the circuits level to its default value
97 if (circuit
->state
== C_STATE_UP
)
98 is_type
= circuit
->area
->is_type
;
100 is_type
= IS_LEVEL_1_AND_2
;
101 isis_circuit_is_type_set(circuit
, is_type
);
108 "isis network point-to-point",
109 "IS-IS routing protocol\n"
111 "point-to-point network type\n")
113 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
115 return CMD_ERR_NO_MATCH
;
117 if (isis_circuit_circ_type_set(circuit
, CIRCUIT_T_P2P
)) {
119 "isis network point-to-point is valid only on broadcast interfaces\n");
120 return CMD_WARNING_CONFIG_FAILED
;
126 DEFUN (no_isis_network
,
128 "no isis network point-to-point",
130 "IS-IS routing protocol\n"
131 "Set network type for circuit\n"
132 "point-to-point network type\n")
134 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
136 return CMD_ERR_NO_MATCH
;
138 if (isis_circuit_circ_type_set(circuit
, CIRCUIT_T_BROADCAST
)) {
140 "isis network point-to-point is valid only on broadcast interfaces\n");
141 return CMD_WARNING_CONFIG_FAILED
;
147 DEFUN (isis_priority
,
149 "isis priority (0-127)",
150 "IS-IS routing protocol\n"
151 "Set priority for Designated Router election\n"
154 uint8_t prio
= atoi(argv
[2]->arg
);
155 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
157 return CMD_ERR_NO_MATCH
;
159 circuit
->priority
[0] = prio
;
160 circuit
->priority
[1] = prio
;
165 DEFUN (no_isis_priority
,
166 no_isis_priority_cmd
,
167 "no isis priority [(0-127)]",
169 "IS-IS routing protocol\n"
170 "Set priority for Designated Router election\n"
173 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
175 return CMD_ERR_NO_MATCH
;
177 circuit
->priority
[0] = DEFAULT_PRIORITY
;
178 circuit
->priority
[1] = DEFAULT_PRIORITY
;
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"
189 "Specify priority for level-1 routing\n"
190 "Specify priority for level-2 routing\n")
192 uint8_t prio
= atoi(argv
[2]->arg
);
193 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
195 return CMD_ERR_NO_MATCH
;
197 circuit
->priority
[level_for_arg(argv
[3]->text
)] = prio
;
202 DEFUN (no_isis_priority_level
,
203 no_isis_priority_level_cmd
,
204 "no isis priority [(0-127)] <level-1|level-2>",
206 "IS-IS routing protocol\n"
207 "Set priority for Designated Router election\n"
209 "Specify priority for level-1 routing\n"
210 "Specify priority for level-2 routing\n")
212 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
213 int level
= level_for_arg(argv
[argc
- 1]->text
);
215 return CMD_ERR_NO_MATCH
;
217 circuit
->priority
[level
] = DEFAULT_PRIORITY
;
222 DEFUN (isis_hello_padding
,
223 isis_hello_padding_cmd
,
224 "isis hello padding",
225 "IS-IS routing protocol\n"
226 "Add padding to IS-IS hello packets\n"
227 "Pad hello packets\n")
229 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
231 return CMD_ERR_NO_MATCH
;
233 circuit
->pad_hellos
= 1;
238 DEFUN (no_isis_hello_padding
,
239 no_isis_hello_padding_cmd
,
240 "no isis hello padding",
242 "IS-IS routing protocol\n"
243 "Add padding to IS-IS hello packets\n"
244 "Pad hello packets\n")
246 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
248 return CMD_ERR_NO_MATCH
;
250 circuit
->pad_hellos
= 0;
255 DEFUN (csnp_interval_level
,
256 csnp_interval_level_cmd
,
257 "isis csnp-interval (1-600) <level-1|level-2>",
258 "IS-IS routing protocol\n"
259 "Set CSNP interval in seconds\n"
260 "CSNP interval value\n"
261 "Specify interval for level-1 CSNPs\n"
262 "Specify interval for level-2 CSNPs\n")
264 uint16_t interval
= atoi(argv
[2]->arg
);
265 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
267 return CMD_ERR_NO_MATCH
;
269 circuit
->csnp_interval
[level_for_arg(argv
[3]->text
)] = interval
;
274 DEFUN (no_csnp_interval_level
,
275 no_csnp_interval_level_cmd
,
276 "no isis csnp-interval [(1-600)] <level-1|level-2>",
278 "IS-IS routing protocol\n"
279 "Set CSNP interval in seconds\n"
280 "CSNP interval value\n"
281 "Specify interval for level-1 CSNPs\n"
282 "Specify interval for level-2 CSNPs\n")
284 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
285 int level
= level_for_arg(argv
[argc
- 1]->text
);
287 return CMD_ERR_NO_MATCH
;
289 circuit
->csnp_interval
[level
] = DEFAULT_CSNP_INTERVAL
;
294 DEFUN (psnp_interval_level
,
295 psnp_interval_level_cmd
,
296 "isis psnp-interval (1-120) <level-1|level-2>",
297 "IS-IS routing protocol\n"
298 "Set PSNP interval in seconds\n"
299 "PSNP interval value\n"
300 "Specify interval for level-1 PSNPs\n"
301 "Specify interval for level-2 PSNPs\n")
303 uint16_t interval
= atoi(argv
[2]->arg
);
304 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
306 return CMD_ERR_NO_MATCH
;
308 circuit
->psnp_interval
[level_for_arg(argv
[3]->text
)] = (uint16_t)interval
;
313 DEFUN (no_psnp_interval_level
,
314 no_psnp_interval_level_cmd
,
315 "no isis psnp-interval [(1-120)] <level-1|level-2>",
317 "IS-IS routing protocol\n"
318 "Set PSNP interval in seconds\n"
319 "PSNP interval value\n"
320 "Specify interval for level-1 PSNPs\n"
321 "Specify interval for level-2 PSNPs\n")
323 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
324 int level
= level_for_arg(argv
[argc
- 1]->text
);
326 return CMD_ERR_NO_MATCH
;
328 circuit
->psnp_interval
[level
] = DEFAULT_PSNP_INTERVAL
;
333 void isis_vty_daemon_init(void)
335 install_element(INTERFACE_NODE
, &isis_circuit_type_cmd
);
336 install_element(INTERFACE_NODE
, &no_isis_circuit_type_cmd
);
338 install_element(INTERFACE_NODE
, &isis_network_cmd
);
339 install_element(INTERFACE_NODE
, &no_isis_network_cmd
);
341 install_element(INTERFACE_NODE
, &isis_priority_cmd
);
342 install_element(INTERFACE_NODE
, &no_isis_priority_cmd
);
343 install_element(INTERFACE_NODE
, &isis_priority_level_cmd
);
344 install_element(INTERFACE_NODE
, &no_isis_priority_level_cmd
);
346 install_element(INTERFACE_NODE
, &isis_hello_padding_cmd
);
347 install_element(INTERFACE_NODE
, &no_isis_hello_padding_cmd
);
349 install_element(INTERFACE_NODE
, &csnp_interval_level_cmd
);
350 install_element(INTERFACE_NODE
, &no_csnp_interval_level_cmd
);
352 install_element(INTERFACE_NODE
, &psnp_interval_level_cmd
);
353 install_element(INTERFACE_NODE
, &no_psnp_interval_level_cmd
);