]> git.proxmox.com Git - mirror_frr.git/blob - vrrpd/vrrp_vty.c
vrrpd: initial commit
[mirror_frr.git] / vrrpd / vrrp_vty.c
1 /*
2 * VRRP commands
3 * Copyright (C) 2018 Cumulus Networks, Inc.
4 * Quentin Young
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 #include <zebra.h>
21
22 #include "command.h"
23 #include "vty.h"
24 #include "if.h"
25
26 #include "vrrp.h"
27 #include "vrrp_vty.h"
28 #include "vrrp_memory.h"
29 //#ifndef VTYSH_EXTRACT_PL
30 //#include "vrrp/vrrp_vty_clippy.c"
31 //#endif
32
33
34 #define VRRP_STR "Virtual Router Redundancy Protocol\n"
35 #define VRRP_VRID_STR "Virtual Router ID\n"
36
37 DEFUN_NOSH (show_debugging_vrrpd,
38 show_debugging_vrrpd_cmd,
39 "show debugging [vrrp]",
40 SHOW_STR
41 DEBUG_STR
42 "VRRP information\n")
43 {
44 vty_out(vty, "VRRP debugging status\n");
45
46 return CMD_SUCCESS;
47 }
48
49 DEFUN(vrrp_vrid,
50 vrrp_vrid_cmd,
51 "[no] vrrp (1-255)",
52 NO_STR
53 VRRP_STR
54 VRRP_VRID_STR)
55 {
56 VTY_DECLVAR_CONTEXT(interface, ifp);
57 int idx = 0;
58 uint8_t vrid;
59
60 argv_find(argv, argc, "(1-255)", &idx);
61 vrid = strtoul(argv[idx]->arg, NULL, 10);
62
63 struct vrrp_vrouter *vr = vrrp_vrouter_create(ifp, vrid);
64 vrrp_event(vr, VRRP_EVENT_STARTUP);
65
66 return CMD_SUCCESS;
67 }
68
69 static struct cmd_node interface_node = {
70 INTERFACE_NODE,
71 "%s(config-if)# ", 1
72 };
73
74 void vrrp_vty_init(void)
75 {
76 install_node(&interface_node, NULL);
77 if_cmd_init();
78 install_element(VIEW_NODE, &show_debugging_vrrpd_cmd);
79 install_element(INTERFACE_NODE, &vrrp_vrid_cmd);
80 }