]> git.proxmox.com Git - mirror_frr.git/blob - ripngd/ripng_cli.c
ripngd: retrofit the 'default-metric' command to the new northbound model
[mirror_frr.git] / ripngd / ripng_cli.c
1 /*
2 * Copyright (C) 1998 Kunihiro Ishiguro
3 * Copyright (C) 2018 NetDEF, Inc.
4 * Renato Westphal
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
21 #include <zebra.h>
22
23 #include "if.h"
24 #include "vrf.h"
25 #include "log.h"
26 #include "prefix.h"
27 #include "command.h"
28 #include "northbound_cli.h"
29 #include "libfrr.h"
30
31 #include "ripngd/ripngd.h"
32 #include "ripngd/ripng_cli.h"
33 #ifndef VTYSH_EXTRACT_PL
34 #include "ripngd/ripng_cli_clippy.c"
35 #endif
36
37 /*
38 * XPath: /frr-ripngd:ripngd/instance
39 */
40 DEFPY_NOSH (router_ripng,
41 router_ripng_cmd,
42 "router ripng",
43 "Enable a routing process\n"
44 "Make RIPng instance command\n")
45 {
46 int ret;
47
48 nb_cli_enqueue_change(vty, "/frr-ripngd:ripngd/instance", NB_OP_CREATE,
49 NULL);
50
51 ret = nb_cli_apply_changes(vty, NULL);
52 if (ret == CMD_SUCCESS)
53 VTY_PUSH_XPATH(RIPNG_NODE, "/frr-ripngd:ripngd/instance");
54
55 return ret;
56 }
57
58 DEFPY (no_router_ripng,
59 no_router_ripng_cmd,
60 "no router ripng",
61 NO_STR
62 "Enable a routing process\n"
63 "Make RIPng instance command\n")
64 {
65 nb_cli_enqueue_change(vty, "/frr-ripngd:ripngd/instance", NB_OP_DELETE,
66 NULL);
67
68 return nb_cli_apply_changes(vty, NULL);
69 }
70
71 void cli_show_router_ripng(struct vty *vty, struct lyd_node *dnode,
72 bool show_defaults)
73 {
74 vty_out(vty, "!\n");
75 vty_out(vty, "router ripng\n");
76 }
77
78 /*
79 * XPath: /frr-ripngd:ripngd/instance/allow-ecmp
80 */
81 DEFPY (ripng_allow_ecmp,
82 ripng_allow_ecmp_cmd,
83 "[no] allow-ecmp",
84 NO_STR
85 "Allow Equal Cost MultiPath\n")
86 {
87 nb_cli_enqueue_change(vty, "./allow-ecmp", NB_OP_MODIFY,
88 no ? "false" : "true");
89
90 return nb_cli_apply_changes(vty, NULL);
91 }
92
93 void cli_show_ripng_allow_ecmp(struct vty *vty, struct lyd_node *dnode,
94 bool show_defaults)
95 {
96 if (!yang_dnode_get_bool(dnode, NULL))
97 vty_out(vty, " no");
98
99 vty_out(vty, " allow-ecmp\n");
100 }
101
102 /*
103 * XPath: /frr-ripngd:ripngd/instance/default-information-originate
104 */
105 DEFPY (ripng_default_information_originate,
106 ripng_default_information_originate_cmd,
107 "[no] default-information originate",
108 NO_STR
109 "Default route information\n"
110 "Distribute default route\n")
111 {
112 nb_cli_enqueue_change(vty, "./default-information-originate",
113 NB_OP_MODIFY, no ? "false" : "true");
114
115 return nb_cli_apply_changes(vty, NULL);
116 }
117
118 void cli_show_ripng_default_information_originate(struct vty *vty,
119 struct lyd_node *dnode,
120 bool show_defaults)
121 {
122 if (!yang_dnode_get_bool(dnode, NULL))
123 vty_out(vty, " no");
124
125 vty_out(vty, " default-information originate\n");
126 }
127
128 /*
129 * XPath: /frr-ripngd:ripngd/instance/default-metric
130 */
131 DEFPY (ripng_default_metric,
132 ripng_default_metric_cmd,
133 "default-metric (1-16)",
134 "Set a metric of redistribute routes\n"
135 "Default metric\n")
136 {
137 nb_cli_enqueue_change(vty, "./default-metric", NB_OP_MODIFY,
138 default_metric_str);
139
140 return nb_cli_apply_changes(vty, NULL);
141 }
142
143 DEFPY (no_ripng_default_metric,
144 no_ripng_default_metric_cmd,
145 "no default-metric [(1-16)]",
146 NO_STR
147 "Set a metric of redistribute routes\n"
148 "Default metric\n")
149 {
150 nb_cli_enqueue_change(vty, "./default-metric", NB_OP_MODIFY, NULL);
151
152 return nb_cli_apply_changes(vty, NULL);
153 }
154
155 void cli_show_ripng_default_metric(struct vty *vty, struct lyd_node *dnode,
156 bool show_defaults)
157 {
158 vty_out(vty, " default-metric %s\n",
159 yang_dnode_get_string(dnode, NULL));
160 }
161
162 void ripng_cli_init(void)
163 {
164 install_element(CONFIG_NODE, &router_ripng_cmd);
165 install_element(CONFIG_NODE, &no_router_ripng_cmd);
166
167 install_element(RIPNG_NODE, &ripng_allow_ecmp_cmd);
168 install_element(RIPNG_NODE, &ripng_default_information_originate_cmd);
169 install_element(RIPNG_NODE, &ripng_default_metric_cmd);
170 install_element(RIPNG_NODE, &no_ripng_default_metric_cmd);
171 }