]> git.proxmox.com Git - mirror_frr.git/blame - isisd/isis_vty_common.c
isisd: retrofit the 'isis topology' command
[mirror_frr.git] / isisd / isis_vty_common.c
CommitLineData
ef020087
CF
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"
215eccb0 30#include "bfd.h"
ef020087
CF
31
32#include "isis_circuit.h"
33#include "isis_csm.h"
34#include "isis_misc.h"
ef020087 35#include "isisd.h"
215eccb0 36#include "isis_bfd.h"
ef020087
CF
37#include "isis_vty_common.h"
38
39struct isis_circuit *isis_circuit_lookup(struct vty *vty)
40{
41 struct interface *ifp = VTY_GET_CONTEXT(interface);
42 struct isis_circuit *circuit;
43
44 if (!ifp) {
45 vty_out(vty, "Invalid interface \n");
46 return NULL;
47 }
48
49 circuit = circuit_scan_by_ifp(ifp);
50 if (!circuit) {
51 vty_out(vty, "ISIS is not enabled on circuit %s\n", ifp->name);
52 return NULL;
53 }
54
55 return circuit;
56}
57
215eccb0
CF
58DEFUN (isis_bfd,
59 isis_bfd_cmd,
60 PROTO_NAME " bfd",
61 PROTO_HELP
62 "Enable BFD support\n")
63{
64 struct isis_circuit *circuit = isis_circuit_lookup(vty);
5489eb45 65
215eccb0
CF
66 if (!circuit)
67 return CMD_ERR_NO_MATCH;
68
69 if (circuit->bfd_info
70 && CHECK_FLAG(circuit->bfd_info->flags, BFD_FLAG_PARAM_CFG)) {
71 return CMD_SUCCESS;
72 }
73
74 isis_bfd_circuit_param_set(circuit, BFD_DEF_MIN_RX,
75 BFD_DEF_MIN_TX, BFD_DEF_DETECT_MULT, true);
76
77 return CMD_SUCCESS;
78}
79
215eccb0
CF
80DEFUN (no_isis_bfd,
81 no_isis_bfd_cmd,
215eccb0 82 "no " PROTO_NAME " bfd",
215eccb0
CF
83 NO_STR
84 PROTO_HELP
85 "Disables BFD support\n"
215eccb0
CF
86)
87{
88 struct isis_circuit *circuit = isis_circuit_lookup(vty);
5489eb45 89
215eccb0
CF
90 if (!circuit)
91 return CMD_ERR_NO_MATCH;
92
93 if (!circuit->bfd_info)
94 return CMD_SUCCESS;
95
96 isis_bfd_circuit_cmd(circuit, ZEBRA_BFD_DEST_DEREGISTER);
97 bfd_info_free(&circuit->bfd_info);
98 return CMD_SUCCESS;
99}
100
ef020087
CF
101void isis_vty_init(void)
102{
215eccb0 103 install_element(INTERFACE_NODE, &isis_bfd_cmd);
215eccb0
CF
104 install_element(INTERFACE_NODE, &no_isis_bfd_cmd);
105
ef020087
CF
106 isis_vty_daemon_init();
107}