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_metric_level
,
223 isis_metric_level_cmd
,
224 "isis metric (0-16777215) <level-1|level-2>",
225 "IS-IS routing protocol\n"
226 "Set default metric for circuit\n"
227 "Default metric value\n"
228 "Specify metric for level-1 routing\n"
229 "Specify metric for level-2 routing\n")
231 uint32_t met
= atoi(argv
[2]->arg
);
232 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
234 return CMD_ERR_NO_MATCH
;
236 CMD_FERR_RETURN(isis_circuit_metric_set(circuit
,
237 level_for_arg(argv
[3]->text
),
239 "Failed to set metric: $ERR");
243 DEFUN (no_isis_metric_level
,
244 no_isis_metric_level_cmd
,
245 "no isis metric [(0-16777215)] <level-1|level-2>",
247 "IS-IS routing protocol\n"
248 "Set default metric for circuit\n"
249 "Default metric value\n"
250 "Specify metric for level-1 routing\n"
251 "Specify metric for level-2 routing\n")
253 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
254 int level
= level_for_arg(argv
[argc
- 1]->text
);
256 return CMD_ERR_NO_MATCH
;
258 CMD_FERR_RETURN(isis_circuit_metric_set(circuit
, level
,
259 DEFAULT_CIRCUIT_METRIC
),
260 "Failed to set L1 metric: $ERR");
264 DEFUN (isis_hello_interval_level
,
265 isis_hello_interval_level_cmd
,
266 "isis hello-interval (1-600) <level-1|level-2>",
267 "IS-IS routing protocol\n"
268 "Set Hello interval\n"
269 "Holdtime 1 second, interval depends on multiplier\n"
270 "Specify hello-interval for level-1 IIHs\n"
271 "Specify hello-interval for level-2 IIHs\n")
273 uint32_t interval
= atoi(argv
[2]->arg
);
274 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
276 return CMD_ERR_NO_MATCH
;
278 circuit
->hello_interval
[level_for_arg(argv
[3]->text
)] = interval
;
283 DEFUN (no_isis_hello_interval_level
,
284 no_isis_hello_interval_level_cmd
,
285 "no isis hello-interval [(1-600)] <level-1|level-2>",
287 "IS-IS routing protocol\n"
288 "Set Hello interval\n"
289 "Holdtime 1 second, interval depends on multiplier\n"
290 "Specify hello-interval for level-1 IIHs\n"
291 "Specify hello-interval for level-2 IIHs\n")
293 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
294 int level
= level_for_arg(argv
[argc
- 1]->text
);
296 return CMD_ERR_NO_MATCH
;
298 circuit
->hello_interval
[level
] = DEFAULT_HELLO_INTERVAL
;
303 DEFUN (isis_hello_multiplier_level
,
304 isis_hello_multiplier_level_cmd
,
305 "isis hello-multiplier (2-100) <level-1|level-2>",
306 "IS-IS routing protocol\n"
307 "Set multiplier for Hello holding time\n"
308 "Hello multiplier value\n"
309 "Specify hello multiplier for level-1 IIHs\n"
310 "Specify hello multiplier for level-2 IIHs\n")
312 uint16_t mult
= atoi(argv
[2]->arg
);
313 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
315 return CMD_ERR_NO_MATCH
;
317 circuit
->hello_multiplier
[level_for_arg(argv
[3]->text
)] = mult
;
322 DEFUN (no_isis_hello_multiplier_level
,
323 no_isis_hello_multiplier_level_cmd
,
324 "no isis hello-multiplier [(2-100)] <level-1|level-2>",
326 "IS-IS routing protocol\n"
327 "Set multiplier for Hello holding time\n"
328 "Hello multiplier value\n"
329 "Specify hello multiplier for level-1 IIHs\n"
330 "Specify hello multiplier for level-2 IIHs\n")
332 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
333 int level
= level_for_arg(argv
[argc
- 1]->text
);
335 return CMD_ERR_NO_MATCH
;
337 circuit
->hello_multiplier
[level
] = DEFAULT_HELLO_MULTIPLIER
;
342 DEFUN (isis_threeway_adj
,
343 isis_threeway_adj_cmd
,
344 "[no] isis three-way-handshake",
347 "Enable/Disable three-way handshake\n")
349 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
351 return CMD_ERR_NO_MATCH
;
353 circuit
->disable_threeway_adj
= !strcmp(argv
[0]->text
, "no");
357 DEFUN (isis_hello_padding
,
358 isis_hello_padding_cmd
,
359 "isis hello padding",
360 "IS-IS routing protocol\n"
361 "Add padding to IS-IS hello packets\n"
362 "Pad hello packets\n")
364 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
366 return CMD_ERR_NO_MATCH
;
368 circuit
->pad_hellos
= 1;
373 DEFUN (no_isis_hello_padding
,
374 no_isis_hello_padding_cmd
,
375 "no isis hello padding",
377 "IS-IS routing protocol\n"
378 "Add padding to IS-IS hello packets\n"
379 "Pad hello packets\n")
381 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
383 return CMD_ERR_NO_MATCH
;
385 circuit
->pad_hellos
= 0;
390 DEFUN (csnp_interval_level
,
391 csnp_interval_level_cmd
,
392 "isis csnp-interval (1-600) <level-1|level-2>",
393 "IS-IS routing protocol\n"
394 "Set CSNP interval in seconds\n"
395 "CSNP interval value\n"
396 "Specify interval for level-1 CSNPs\n"
397 "Specify interval for level-2 CSNPs\n")
399 uint16_t interval
= atoi(argv
[2]->arg
);
400 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
402 return CMD_ERR_NO_MATCH
;
404 circuit
->csnp_interval
[level_for_arg(argv
[3]->text
)] = interval
;
409 DEFUN (no_csnp_interval_level
,
410 no_csnp_interval_level_cmd
,
411 "no isis csnp-interval [(1-600)] <level-1|level-2>",
413 "IS-IS routing protocol\n"
414 "Set CSNP interval in seconds\n"
415 "CSNP interval value\n"
416 "Specify interval for level-1 CSNPs\n"
417 "Specify interval for level-2 CSNPs\n")
419 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
420 int level
= level_for_arg(argv
[argc
- 1]->text
);
422 return CMD_ERR_NO_MATCH
;
424 circuit
->csnp_interval
[level
] = DEFAULT_CSNP_INTERVAL
;
429 DEFUN (psnp_interval_level
,
430 psnp_interval_level_cmd
,
431 "isis psnp-interval (1-120) <level-1|level-2>",
432 "IS-IS routing protocol\n"
433 "Set PSNP interval in seconds\n"
434 "PSNP interval value\n"
435 "Specify interval for level-1 PSNPs\n"
436 "Specify interval for level-2 PSNPs\n")
438 uint16_t interval
= atoi(argv
[2]->arg
);
439 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
441 return CMD_ERR_NO_MATCH
;
443 circuit
->psnp_interval
[level_for_arg(argv
[3]->text
)] = (uint16_t)interval
;
448 DEFUN (no_psnp_interval_level
,
449 no_psnp_interval_level_cmd
,
450 "no isis psnp-interval [(1-120)] <level-1|level-2>",
452 "IS-IS routing protocol\n"
453 "Set PSNP interval in seconds\n"
454 "PSNP interval value\n"
455 "Specify interval for level-1 PSNPs\n"
456 "Specify interval for level-2 PSNPs\n")
458 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
459 int level
= level_for_arg(argv
[argc
- 1]->text
);
461 return CMD_ERR_NO_MATCH
;
463 circuit
->psnp_interval
[level
] = DEFAULT_PSNP_INTERVAL
;
468 DEFUN (max_lsp_lifetime_level
,
469 max_lsp_lifetime_level_cmd
,
470 "max-lsp-lifetime <level-1|level-2> (350-65535)",
471 "Maximum LSP lifetime\n"
472 "Maximum LSP lifetime for Level 1 only\n"
473 "Maximum LSP lifetime for Level 2 only\n"
474 "LSP lifetime in seconds\n")
476 uint16_t lifetime
= atoi(argv
[2]->arg
);
478 return isis_vty_max_lsp_lifetime_set(vty
, level_for_arg(argv
[1]->text
),
482 DEFUN (no_max_lsp_lifetime_level
,
483 no_max_lsp_lifetime_level_cmd
,
484 "no max-lsp-lifetime <level-1|level-2> [(350-65535)]",
486 "Maximum LSP lifetime\n"
487 "Maximum LSP lifetime for Level 1 only\n"
488 "Maximum LSP lifetime for Level 2 only\n"
489 "LSP lifetime in seconds\n")
491 return isis_vty_max_lsp_lifetime_set(vty
, level_for_arg(argv
[1]->text
),
492 DEFAULT_LSP_LIFETIME
);
495 DEFUN (spf_interval_level
,
496 spf_interval_level_cmd
,
497 "spf-interval <level-1|level-2> (1-120)",
498 "Minimum interval between SPF calculations\n"
499 "Set interval for level 1 only\n"
500 "Set interval for level 2 only\n"
501 "Minimum interval between consecutive SPFs in seconds\n")
503 VTY_DECLVAR_CONTEXT(isis_area
, area
);
504 uint16_t interval
= atoi(argv
[2]->arg
);
506 area
->min_spf_interval
[level_for_arg(argv
[1]->text
)] = interval
;
511 DEFUN (no_spf_interval_level
,
512 no_spf_interval_level_cmd
,
513 "no spf-interval <level-1|level-2> [(1-120)]",
515 "Minimum interval between SPF calculations\n"
516 "Set interval for level 1 only\n"
517 "Set interval for level 2 only\n"
518 "Minimum interval between consecutive SPFs in seconds\n")
520 VTY_DECLVAR_CONTEXT(isis_area
, area
);
521 int level
= level_for_arg(argv
[1]->text
);
523 area
->min_spf_interval
[level
] = MINIMUM_SPF_INTERVAL
;
528 void isis_vty_daemon_init(void)
530 install_element(INTERFACE_NODE
, &isis_circuit_type_cmd
);
531 install_element(INTERFACE_NODE
, &no_isis_circuit_type_cmd
);
533 install_element(INTERFACE_NODE
, &isis_network_cmd
);
534 install_element(INTERFACE_NODE
, &no_isis_network_cmd
);
536 install_element(INTERFACE_NODE
, &isis_priority_cmd
);
537 install_element(INTERFACE_NODE
, &no_isis_priority_cmd
);
538 install_element(INTERFACE_NODE
, &isis_priority_level_cmd
);
539 install_element(INTERFACE_NODE
, &no_isis_priority_level_cmd
);
541 install_element(INTERFACE_NODE
, &isis_metric_level_cmd
);
542 install_element(INTERFACE_NODE
, &no_isis_metric_level_cmd
);
544 install_element(INTERFACE_NODE
, &isis_hello_interval_level_cmd
);
545 install_element(INTERFACE_NODE
, &no_isis_hello_interval_level_cmd
);
547 install_element(INTERFACE_NODE
, &isis_hello_multiplier_level_cmd
);
548 install_element(INTERFACE_NODE
, &no_isis_hello_multiplier_level_cmd
);
550 install_element(INTERFACE_NODE
, &isis_threeway_adj_cmd
);
552 install_element(INTERFACE_NODE
, &isis_hello_padding_cmd
);
553 install_element(INTERFACE_NODE
, &no_isis_hello_padding_cmd
);
555 install_element(INTERFACE_NODE
, &csnp_interval_level_cmd
);
556 install_element(INTERFACE_NODE
, &no_csnp_interval_level_cmd
);
558 install_element(INTERFACE_NODE
, &psnp_interval_level_cmd
);
559 install_element(INTERFACE_NODE
, &no_psnp_interval_level_cmd
);
561 install_element(ROUTER_NODE
, &max_lsp_lifetime_level_cmd
);
562 install_element(ROUTER_NODE
, &no_max_lsp_lifetime_level_cmd
);
564 install_element(ROUTER_NODE
, &spf_interval_level_cmd
);
565 install_element(ROUTER_NODE
, &no_spf_interval_level_cmd
);