2 * Copyright (C) 1998 Kunihiro Ishiguro
3 * Copyright (C) 2018 NetDEF, Inc.
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)
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
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
28 #include "northbound_cli.h"
31 #include "ripngd/ripngd.h"
32 #include "ripngd/ripng_cli.h"
33 #ifndef VTYSH_EXTRACT_PL
34 #include "ripngd/ripng_cli_clippy.c"
38 * XPath: /frr-ripngd:ripngd/instance
40 DEFPY_NOSH (router_ripng
,
43 "Enable a routing process\n"
44 "Make RIPng instance command\n")
48 nb_cli_enqueue_change(vty
, "/frr-ripngd:ripngd/instance", NB_OP_CREATE
,
51 ret
= nb_cli_apply_changes(vty
, NULL
);
52 if (ret
== CMD_SUCCESS
)
53 VTY_PUSH_XPATH(RIPNG_NODE
, "/frr-ripngd:ripngd/instance");
58 DEFPY (no_router_ripng
,
62 "Enable a routing process\n"
63 "Make RIPng instance command\n")
65 nb_cli_enqueue_change(vty
, "/frr-ripngd:ripngd/instance", NB_OP_DELETE
,
68 return nb_cli_apply_changes(vty
, NULL
);
71 void cli_show_router_ripng(struct vty
*vty
, struct lyd_node
*dnode
,
75 vty_out(vty
, "router ripng\n");
79 * XPath: /frr-ripngd:ripngd/instance/allow-ecmp
81 DEFPY (ripng_allow_ecmp
,
85 "Allow Equal Cost MultiPath\n")
87 nb_cli_enqueue_change(vty
, "./allow-ecmp", NB_OP_MODIFY
,
88 no
? "false" : "true");
90 return nb_cli_apply_changes(vty
, NULL
);
93 void cli_show_ripng_allow_ecmp(struct vty
*vty
, struct lyd_node
*dnode
,
96 if (!yang_dnode_get_bool(dnode
, NULL
))
99 vty_out(vty
, " allow-ecmp\n");
103 * XPath: /frr-ripngd:ripngd/instance/default-information-originate
105 DEFPY (ripng_default_information_originate
,
106 ripng_default_information_originate_cmd
,
107 "[no] default-information originate",
109 "Default route information\n"
110 "Distribute default route\n")
112 nb_cli_enqueue_change(vty
, "./default-information-originate",
113 NB_OP_MODIFY
, no
? "false" : "true");
115 return nb_cli_apply_changes(vty
, NULL
);
118 void cli_show_ripng_default_information_originate(struct vty
*vty
,
119 struct lyd_node
*dnode
,
122 if (!yang_dnode_get_bool(dnode
, NULL
))
125 vty_out(vty
, " default-information originate\n");
129 * XPath: /frr-ripngd:ripngd/instance/default-metric
131 DEFPY (ripng_default_metric
,
132 ripng_default_metric_cmd
,
133 "default-metric (1-16)",
134 "Set a metric of redistribute routes\n"
137 nb_cli_enqueue_change(vty
, "./default-metric", NB_OP_MODIFY
,
140 return nb_cli_apply_changes(vty
, NULL
);
143 DEFPY (no_ripng_default_metric
,
144 no_ripng_default_metric_cmd
,
145 "no default-metric [(1-16)]",
147 "Set a metric of redistribute routes\n"
150 nb_cli_enqueue_change(vty
, "./default-metric", NB_OP_MODIFY
, NULL
);
152 return nb_cli_apply_changes(vty
, NULL
);
155 void cli_show_ripng_default_metric(struct vty
*vty
, struct lyd_node
*dnode
,
158 vty_out(vty
, " default-metric %s\n",
159 yang_dnode_get_string(dnode
, NULL
));
163 * XPath: /frr-ripngd:ripngd/instance/network
165 DEFPY (ripng_network_prefix
,
166 ripng_network_prefix_cmd
,
167 "[no] network X:X::X:X/M",
169 "RIPng enable on specified interface or network.\n"
172 nb_cli_enqueue_change(vty
, "./network",
173 no
? NB_OP_DELETE
: NB_OP_CREATE
, network_str
);
175 return nb_cli_apply_changes(vty
, NULL
);
178 void cli_show_ripng_network_prefix(struct vty
*vty
, struct lyd_node
*dnode
,
181 vty_out(vty
, " network %s\n", yang_dnode_get_string(dnode
, NULL
));
185 * XPath: /frr-ripngd:ripngd/instance/interface
187 DEFPY (ripng_network_if
,
188 ripng_network_if_cmd
,
191 "RIPng enable on specified interface or network.\n"
194 nb_cli_enqueue_change(vty
, "./interface",
195 no
? NB_OP_DELETE
: NB_OP_CREATE
, network
);
197 return nb_cli_apply_changes(vty
, NULL
);
200 void cli_show_ripng_network_interface(struct vty
*vty
, struct lyd_node
*dnode
,
203 vty_out(vty
, " network %s\n", yang_dnode_get_string(dnode
, NULL
));
207 * XPath: /frr-ripngd:ripngd/instance/offset-list
209 DEFPY (ripng_offset_list
,
210 ripng_offset_list_cmd
,
211 "[no] offset-list WORD$acl <in|out>$direction (0-16)$metric [IFNAME]",
213 "Modify RIPng metric\n"
215 "For incoming updates\n"
216 "For outgoing updates\n"
218 "Interface to match\n")
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
,
226 nb_cli_enqueue_change(vty
, ".", NB_OP_DELETE
, NULL
);
228 return nb_cli_apply_changes(
229 vty
, "./offset-list[interface='%s'][direction='%s']",
230 ifname
? ifname
: "*", direction
);
233 void cli_show_ripng_offset_list(struct vty
*vty
, struct lyd_node
*dnode
,
236 const char *interface
;
238 interface
= yang_dnode_get_string(dnode
, "./interface");
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
);
250 * XPath: /frr-ripngd:ripngd/instance/passive-interface
252 DEFPY (ripng_passive_interface
,
253 ripng_passive_interface_cmd
,
254 "[no] passive-interface IFNAME",
256 "Suppress routing updates on an interface\n"
259 nb_cli_enqueue_change(vty
, "./passive-interface",
260 no
? NB_OP_DELETE
: NB_OP_CREATE
, ifname
);
262 return nb_cli_apply_changes(vty
, NULL
);
265 void cli_show_ripng_passive_interface(struct vty
*vty
, struct lyd_node
*dnode
,
268 vty_out(vty
, " passive-interface %s\n",
269 yang_dnode_get_string(dnode
, NULL
));
273 * XPath: /frr-ripngd:ripngd/instance/redistribute
275 DEFPY (ripng_redistribute
,
276 ripng_redistribute_cmd
,
277 "[no] redistribute " FRR_REDIST_STR_RIPNGD
"$protocol [{metric (0-16)|route-map WORD}]",
280 FRR_REDIST_HELP_STR_RIPNGD
283 "Route map reference\n"
284 "Pointer to route-map entries\n")
287 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
288 nb_cli_enqueue_change(vty
, "./route-map",
289 route_map
? NB_OP_MODIFY
: NB_OP_DELETE
,
291 nb_cli_enqueue_change(vty
, "./metric",
292 metric_str
? NB_OP_MODIFY
: NB_OP_DELETE
,
295 nb_cli_enqueue_change(vty
, ".", NB_OP_DELETE
, NULL
);
297 return nb_cli_apply_changes(vty
, "./redistribute[protocol='%s']",
301 void cli_show_ripng_redistribute(struct vty
*vty
, struct lyd_node
*dnode
,
304 vty_out(vty
, " redistribute %s",
305 yang_dnode_get_string(dnode
, "./protocol"));
306 if (yang_dnode_exists(dnode
, "./metric"))
307 vty_out(vty
, " metric %s",
308 yang_dnode_get_string(dnode
, "./metric"));
309 if (yang_dnode_exists(dnode
, "./route-map"))
310 vty_out(vty
, " route-map %s",
311 yang_dnode_get_string(dnode
, "./route-map"));
316 * XPath: /frr-ripngd:ripngd/instance/static-route
320 "[no] route X:X::X:X/M",
322 "Static route setup\n"
323 "Set static RIPng route announcement\n")
325 nb_cli_enqueue_change(vty
, "./static-route",
326 no
? NB_OP_DELETE
: NB_OP_CREATE
, route_str
);
328 return nb_cli_apply_changes(vty
, NULL
);
331 void cli_show_ripng_route(struct vty
*vty
, struct lyd_node
*dnode
,
334 vty_out(vty
, " route %s\n", yang_dnode_get_string(dnode
, NULL
));
337 void ripng_cli_init(void)
339 install_element(CONFIG_NODE
, &router_ripng_cmd
);
340 install_element(CONFIG_NODE
, &no_router_ripng_cmd
);
342 install_element(RIPNG_NODE
, &ripng_allow_ecmp_cmd
);
343 install_element(RIPNG_NODE
, &ripng_default_information_originate_cmd
);
344 install_element(RIPNG_NODE
, &ripng_default_metric_cmd
);
345 install_element(RIPNG_NODE
, &no_ripng_default_metric_cmd
);
346 install_element(RIPNG_NODE
, &ripng_network_prefix_cmd
);
347 install_element(RIPNG_NODE
, &ripng_network_if_cmd
);
348 install_element(RIPNG_NODE
, &ripng_offset_list_cmd
);
349 install_element(RIPNG_NODE
, &ripng_passive_interface_cmd
);
350 install_element(RIPNG_NODE
, &ripng_redistribute_cmd
);
351 install_element(RIPNG_NODE
, &ripng_route_cmd
);