]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_vty_common.c
isisd: retrofit the 'isis [c|p]snp-interval' commands
[mirror_frr.git] / isisd / isis_vty_common.c
1 /*
2 * IS-IS Rout(e)ing protocol - isis_vty_common.c
3 *
4 * This file contains the CLI that is shared between OpenFabric and 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 #include "bfd.h"
31
32 #include "isis_circuit.h"
33 #include "isis_csm.h"
34 #include "isis_misc.h"
35 #include "isis_mt.h"
36 #include "isisd.h"
37 #include "isis_bfd.h"
38 #include "isis_vty_common.h"
39
40 struct isis_circuit *isis_circuit_lookup(struct vty *vty)
41 {
42 struct interface *ifp = VTY_GET_CONTEXT(interface);
43 struct isis_circuit *circuit;
44
45 if (!ifp) {
46 vty_out(vty, "Invalid interface \n");
47 return NULL;
48 }
49
50 circuit = circuit_scan_by_ifp(ifp);
51 if (!circuit) {
52 vty_out(vty, "ISIS is not enabled on circuit %s\n", ifp->name);
53 return NULL;
54 }
55
56 return circuit;
57 }
58
59 DEFUN (circuit_topology,
60 circuit_topology_cmd,
61 PROTO_NAME " topology " ISIS_MT_NAMES,
62 PROTO_HELP
63 "Configure interface IS-IS topologies\n"
64 ISIS_MT_DESCRIPTIONS)
65 {
66 struct isis_circuit *circuit = isis_circuit_lookup(vty);
67 if (!circuit)
68 return CMD_ERR_NO_MATCH;
69 const char *arg = argv[2]->arg;
70 uint16_t mtid = isis_str2mtid(arg);
71
72 if (circuit->area && circuit->area->oldmetric) {
73 vty_out(vty,
74 "Multi topology IS-IS can only be used with wide metrics\n");
75 return CMD_WARNING_CONFIG_FAILED;
76 }
77
78 if (mtid == (uint16_t)-1) {
79 vty_out(vty, "Don't know topology '%s'\n", arg);
80 return CMD_WARNING_CONFIG_FAILED;
81 }
82
83 return isis_circuit_mt_enabled_set(circuit, mtid, true);
84 }
85
86 DEFUN (no_circuit_topology,
87 no_circuit_topology_cmd,
88 "no " PROTO_NAME " topology " ISIS_MT_NAMES,
89 NO_STR
90 PROTO_HELP
91 "Configure interface IS-IS topologies\n"
92 ISIS_MT_DESCRIPTIONS)
93 {
94 struct isis_circuit *circuit = isis_circuit_lookup(vty);
95 if (!circuit)
96 return CMD_ERR_NO_MATCH;
97 const char *arg = argv[3]->arg;
98 uint16_t mtid = isis_str2mtid(arg);
99
100 if (circuit->area && circuit->area->oldmetric) {
101 vty_out(vty,
102 "Multi topology IS-IS can only be used with wide metrics\n");
103 return CMD_WARNING_CONFIG_FAILED;
104 }
105
106 if (mtid == (uint16_t)-1) {
107 vty_out(vty, "Don't know topology '%s'\n", arg);
108 return CMD_WARNING_CONFIG_FAILED;
109 }
110
111 return isis_circuit_mt_enabled_set(circuit, mtid, false);
112 }
113
114 DEFUN (isis_bfd,
115 isis_bfd_cmd,
116 PROTO_NAME " bfd",
117 PROTO_HELP
118 "Enable BFD support\n")
119 {
120 struct isis_circuit *circuit = isis_circuit_lookup(vty);
121
122 if (!circuit)
123 return CMD_ERR_NO_MATCH;
124
125 if (circuit->bfd_info
126 && CHECK_FLAG(circuit->bfd_info->flags, BFD_FLAG_PARAM_CFG)) {
127 return CMD_SUCCESS;
128 }
129
130 isis_bfd_circuit_param_set(circuit, BFD_DEF_MIN_RX,
131 BFD_DEF_MIN_TX, BFD_DEF_DETECT_MULT, true);
132
133 return CMD_SUCCESS;
134 }
135
136 DEFUN (no_isis_bfd,
137 no_isis_bfd_cmd,
138 "no " PROTO_NAME " bfd",
139 NO_STR
140 PROTO_HELP
141 "Disables BFD support\n"
142 )
143 {
144 struct isis_circuit *circuit = isis_circuit_lookup(vty);
145
146 if (!circuit)
147 return CMD_ERR_NO_MATCH;
148
149 if (!circuit->bfd_info)
150 return CMD_SUCCESS;
151
152 isis_bfd_circuit_cmd(circuit, ZEBRA_BFD_DEST_DEREGISTER);
153 bfd_info_free(&circuit->bfd_info);
154 return CMD_SUCCESS;
155 }
156
157 void isis_vty_init(void)
158 {
159 install_element(INTERFACE_NODE, &circuit_topology_cmd);
160 install_element(INTERFACE_NODE, &no_circuit_topology_cmd);
161
162 install_element(INTERFACE_NODE, &isis_bfd_cmd);
163 install_element(INTERFACE_NODE, &no_isis_bfd_cmd);
164
165 isis_vty_daemon_init();
166 }