2 * IS-IS Rout(e)ing protocol - isis_vty_common.c
4 * This file contains the CLI that is shared between OpenFabric and 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
32 #include "isis_circuit.h"
34 #include "isis_misc.h"
38 #include "isis_vty_common.h"
40 struct isis_circuit
*isis_circuit_lookup(struct vty
*vty
)
42 struct interface
*ifp
= VTY_GET_CONTEXT(interface
);
43 struct isis_circuit
*circuit
;
46 vty_out(vty
, "Invalid interface \n");
50 circuit
= circuit_scan_by_ifp(ifp
);
52 vty_out(vty
, "ISIS is not enabled on circuit %s\n", ifp
->name
);
59 DEFUN (circuit_topology
,
61 PROTO_NAME
" topology " ISIS_MT_NAMES
,
63 "Configure interface IS-IS topologies\n"
66 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
68 return CMD_ERR_NO_MATCH
;
69 const char *arg
= argv
[2]->arg
;
70 uint16_t mtid
= isis_str2mtid(arg
);
72 if (circuit
->area
&& circuit
->area
->oldmetric
) {
74 "Multi topology IS-IS can only be used with wide metrics\n");
75 return CMD_WARNING_CONFIG_FAILED
;
78 if (mtid
== (uint16_t)-1) {
79 vty_out(vty
, "Don't know topology '%s'\n", arg
);
80 return CMD_WARNING_CONFIG_FAILED
;
83 return isis_circuit_mt_enabled_set(circuit
, mtid
, true);
86 DEFUN (no_circuit_topology
,
87 no_circuit_topology_cmd
,
88 "no " PROTO_NAME
" topology " ISIS_MT_NAMES
,
91 "Configure interface IS-IS topologies\n"
94 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
96 return CMD_ERR_NO_MATCH
;
97 const char *arg
= argv
[3]->arg
;
98 uint16_t mtid
= isis_str2mtid(arg
);
100 if (circuit
->area
&& circuit
->area
->oldmetric
) {
102 "Multi topology IS-IS can only be used with wide metrics\n");
103 return CMD_WARNING_CONFIG_FAILED
;
106 if (mtid
== (uint16_t)-1) {
107 vty_out(vty
, "Don't know topology '%s'\n", arg
);
108 return CMD_WARNING_CONFIG_FAILED
;
111 return isis_circuit_mt_enabled_set(circuit
, mtid
, false);
118 "Enable BFD support\n")
120 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
123 return CMD_ERR_NO_MATCH
;
125 if (circuit
->bfd_info
126 && CHECK_FLAG(circuit
->bfd_info
->flags
, BFD_FLAG_PARAM_CFG
)) {
130 isis_bfd_circuit_param_set(circuit
, BFD_DEF_MIN_RX
,
131 BFD_DEF_MIN_TX
, BFD_DEF_DETECT_MULT
, true);
138 "no " PROTO_NAME
" bfd",
141 "Disables BFD support\n"
144 struct isis_circuit
*circuit
= isis_circuit_lookup(vty
);
147 return CMD_ERR_NO_MATCH
;
149 if (!circuit
->bfd_info
)
152 isis_bfd_circuit_cmd(circuit
, ZEBRA_BFD_DEST_DEREGISTER
);
153 bfd_info_free(&circuit
->bfd_info
);
157 void isis_vty_init(void)
159 install_element(INTERFACE_NODE
, &circuit_topology_cmd
);
160 install_element(INTERFACE_NODE
, &no_circuit_topology_cmd
);
162 install_element(INTERFACE_NODE
, &isis_bfd_cmd
);
163 install_element(INTERFACE_NODE
, &no_isis_bfd_cmd
);
165 isis_vty_daemon_init();