]> git.proxmox.com Git - mirror_frr.git/blame - ripngd/ripng_cli.c
ripngd: retrofit the 'passive-interface' command to the new northbound model
[mirror_frr.git] / ripngd / ripng_cli.c
CommitLineData
e9ce224b
RW
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
9a12e9e5
RW
37/*
38 * XPath: /frr-ripngd:ripngd/instance
39 */
40DEFPY_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
58DEFPY (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
71void 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
1e42a07c
RW
78/*
79 * XPath: /frr-ripngd:ripngd/instance/allow-ecmp
80 */
81DEFPY (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
93void 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
54b56562
RW
102/*
103 * XPath: /frr-ripngd:ripngd/instance/default-information-originate
104 */
105DEFPY (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
118void 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
ad8778c0
RW
128/*
129 * XPath: /frr-ripngd:ripngd/instance/default-metric
130 */
131DEFPY (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
143DEFPY (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
155void 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
cc48702b
RW
162/*
163 * XPath: /frr-ripngd:ripngd/instance/network
164 */
165DEFPY (ripng_network_prefix,
166 ripng_network_prefix_cmd,
167 "[no] network X:X::X:X/M",
168 NO_STR
169 "RIPng enable on specified interface or network.\n"
170 "IPv6 network\n")
171{
172 nb_cli_enqueue_change(vty, "./network",
173 no ? NB_OP_DELETE : NB_OP_CREATE, network_str);
174
175 return nb_cli_apply_changes(vty, NULL);
176}
177
178void cli_show_ripng_network_prefix(struct vty *vty, struct lyd_node *dnode,
179 bool show_defaults)
180{
181 vty_out(vty, " network %s\n", yang_dnode_get_string(dnode, NULL));
182}
183
184/*
185 * XPath: /frr-ripngd:ripngd/instance/interface
186 */
187DEFPY (ripng_network_if,
188 ripng_network_if_cmd,
189 "[no] network WORD",
190 NO_STR
191 "RIPng enable on specified interface or network.\n"
192 "Interface name\n")
193{
194 nb_cli_enqueue_change(vty, "./interface",
195 no ? NB_OP_DELETE : NB_OP_CREATE, network);
196
197 return nb_cli_apply_changes(vty, NULL);
198}
199
200void cli_show_ripng_network_interface(struct vty *vty, struct lyd_node *dnode,
201 bool show_defaults)
202{
203 vty_out(vty, " network %s\n", yang_dnode_get_string(dnode, NULL));
204}
205
b09956ca
RW
206/*
207 * XPath: /frr-ripngd:ripngd/instance/offset-list
208 */
209DEFPY (ripng_offset_list,
210 ripng_offset_list_cmd,
211 "[no] offset-list WORD$acl <in|out>$direction (0-16)$metric [IFNAME]",
212 NO_STR
213 "Modify RIPng metric\n"
214 "Access-list name\n"
215 "For incoming updates\n"
216 "For outgoing updates\n"
217 "Metric value\n"
218 "Interface to match\n")
219{
220 if (!no) {
221 nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
222 nb_cli_enqueue_change(vty, "./access-list", NB_OP_MODIFY, acl);
223 nb_cli_enqueue_change(vty, "./metric", NB_OP_MODIFY,
224 metric_str);
225 } else
226 nb_cli_enqueue_change(vty, ".", NB_OP_DELETE, NULL);
227
228 return nb_cli_apply_changes(
229 vty, "./offset-list[interface='%s'][direction='%s']",
230 ifname ? ifname : "*", direction);
231}
232
233void cli_show_ripng_offset_list(struct vty *vty, struct lyd_node *dnode,
234 bool show_defaults)
235{
236 const char *interface;
237
238 interface = yang_dnode_get_string(dnode, "./interface");
239
240 vty_out(vty, " offset-list %s %s %s",
241 yang_dnode_get_string(dnode, "./access-list"),
242 yang_dnode_get_string(dnode, "./direction"),
243 yang_dnode_get_string(dnode, "./metric"));
244 if (!strmatch(interface, "*"))
245 vty_out(vty, " %s", interface);
246 vty_out(vty, "\n");
247}
248
22e8c7ae
RW
249/*
250 * XPath: /frr-ripngd:ripngd/instance/passive-interface
251 */
252DEFPY (ripng_passive_interface,
253 ripng_passive_interface_cmd,
254 "[no] passive-interface IFNAME",
255 NO_STR
256 "Suppress routing updates on an interface\n"
257 "Interface name\n")
258{
259 nb_cli_enqueue_change(vty, "./passive-interface",
260 no ? NB_OP_DELETE : NB_OP_CREATE, ifname);
261
262 return nb_cli_apply_changes(vty, NULL);
263}
264
265void cli_show_ripng_passive_interface(struct vty *vty, struct lyd_node *dnode,
266 bool show_defaults)
267{
268 vty_out(vty, " passive-interface %s\n",
269 yang_dnode_get_string(dnode, NULL));
270}
271
e9ce224b
RW
272void ripng_cli_init(void)
273{
9a12e9e5
RW
274 install_element(CONFIG_NODE, &router_ripng_cmd);
275 install_element(CONFIG_NODE, &no_router_ripng_cmd);
1e42a07c
RW
276
277 install_element(RIPNG_NODE, &ripng_allow_ecmp_cmd);
54b56562 278 install_element(RIPNG_NODE, &ripng_default_information_originate_cmd);
ad8778c0
RW
279 install_element(RIPNG_NODE, &ripng_default_metric_cmd);
280 install_element(RIPNG_NODE, &no_ripng_default_metric_cmd);
cc48702b
RW
281 install_element(RIPNG_NODE, &ripng_network_prefix_cmd);
282 install_element(RIPNG_NODE, &ripng_network_if_cmd);
b09956ca 283 install_element(RIPNG_NODE, &ripng_offset_list_cmd);
22e8c7ae 284 install_element(RIPNG_NODE, &ripng_passive_interface_cmd);
e9ce224b 285}