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
));
338 * XPath: /frr-ripngd:ripngd/instance/aggregate-addres
340 DEFPY (ripng_aggregate_address
,
341 ripng_aggregate_address_cmd
,
342 "[no] aggregate-address X:X::X:X/M",
344 "Set aggregate RIPng route announcement\n"
345 "Aggregate network\n")
347 nb_cli_enqueue_change(vty
, "./aggregate-address",
348 no
? NB_OP_DELETE
: NB_OP_CREATE
,
349 aggregate_address_str
);
351 return nb_cli_apply_changes(vty
, NULL
);
354 void cli_show_ripng_aggregate_address(struct vty
*vty
, struct lyd_node
*dnode
,
357 vty_out(vty
, " aggregate-address %s\n",
358 yang_dnode_get_string(dnode
, NULL
));
362 * XPath: /frr-ripngd:ripngd/instance/timers
366 "timers basic (1-65535)$update (1-65535)$timeout (1-65535)$garbage",
367 "RIPng timers setup\n"
369 "Routing table update timer value in second. Default is 30.\n"
370 "Routing information timeout timer. Default is 180.\n"
371 "Garbage collection timer. Default is 120.\n")
373 nb_cli_enqueue_change(vty
, "./update-interval", NB_OP_MODIFY
,
375 nb_cli_enqueue_change(vty
, "./holddown-interval", NB_OP_MODIFY
,
377 nb_cli_enqueue_change(vty
, "./flush-interval", NB_OP_MODIFY
,
380 return nb_cli_apply_changes(vty
, "./timers");
383 DEFPY (no_ripng_timers
,
385 "no timers basic [(1-65535) (1-65535) (1-65535)]",
387 "RIPng timers setup\n"
389 "Routing table update timer value in second. Default is 30.\n"
390 "Routing information timeout timer. Default is 180.\n"
391 "Garbage collection timer. Default is 120.\n")
393 nb_cli_enqueue_change(vty
, "./update-interval", NB_OP_MODIFY
, NULL
);
394 nb_cli_enqueue_change(vty
, "./holddown-interval", NB_OP_MODIFY
, NULL
);
395 nb_cli_enqueue_change(vty
, "./flush-interval", NB_OP_MODIFY
, NULL
);
397 return nb_cli_apply_changes(vty
, "./timers");
400 void cli_show_ripng_timers(struct vty
*vty
, struct lyd_node
*dnode
,
403 vty_out(vty
, " timers basic %s %s %s\n",
404 yang_dnode_get_string(dnode
, "./update-interval"),
405 yang_dnode_get_string(dnode
, "./holddown-interval"),
406 yang_dnode_get_string(dnode
, "./flush-interval"));
410 * XPath: /frr-interface:lib/interface/frr-ripngd:ripng/split-horizon
412 DEFPY (ipv6_ripng_split_horizon
,
413 ipv6_ripng_split_horizon_cmd
,
414 "[no] ipv6 ripng split-horizon [poisoned-reverse$poisoned_reverse]",
417 "Routing Information Protocol\n"
418 "Perform split horizon\n"
419 "With poisoned-reverse\n")
425 else if (poisoned_reverse
)
426 value
= "poison-reverse";
430 nb_cli_enqueue_change(vty
, "./split-horizon", NB_OP_MODIFY
, value
);
432 return nb_cli_apply_changes(vty
, "./frr-ripngd:ripng");
435 void cli_show_ipv6_ripng_split_horizon(struct vty
*vty
, struct lyd_node
*dnode
,
440 value
= yang_dnode_get_enum(dnode
, NULL
);
442 case RIPNG_NO_SPLIT_HORIZON
:
443 vty_out(vty
, " no ipv6 ripng split-horizon\n");
445 case RIPNG_SPLIT_HORIZON
:
446 vty_out(vty
, " ipv6 ripng split-horizon\n");
448 case RIPNG_SPLIT_HORIZON_POISONED_REVERSE
:
449 vty_out(vty
, " ipv6 ripng split-horizon poisoned-reverse\n");
455 * XPath: /frr-ripngd:clear-ripng-route
457 DEFPY (clear_ipv6_rip
,
462 "Clear IPv6 RIP database\n")
464 return nb_cli_rpc("/frr-ripngd:clear-ripng-route", NULL
, NULL
);
467 void ripng_cli_init(void)
469 install_element(CONFIG_NODE
, &router_ripng_cmd
);
470 install_element(CONFIG_NODE
, &no_router_ripng_cmd
);
472 install_element(RIPNG_NODE
, &ripng_allow_ecmp_cmd
);
473 install_element(RIPNG_NODE
, &ripng_default_information_originate_cmd
);
474 install_element(RIPNG_NODE
, &ripng_default_metric_cmd
);
475 install_element(RIPNG_NODE
, &no_ripng_default_metric_cmd
);
476 install_element(RIPNG_NODE
, &ripng_network_prefix_cmd
);
477 install_element(RIPNG_NODE
, &ripng_network_if_cmd
);
478 install_element(RIPNG_NODE
, &ripng_offset_list_cmd
);
479 install_element(RIPNG_NODE
, &ripng_passive_interface_cmd
);
480 install_element(RIPNG_NODE
, &ripng_redistribute_cmd
);
481 install_element(RIPNG_NODE
, &ripng_route_cmd
);
482 install_element(RIPNG_NODE
, &ripng_aggregate_address_cmd
);
483 install_element(RIPNG_NODE
, &ripng_timers_cmd
);
484 install_element(RIPNG_NODE
, &no_ripng_timers_cmd
);
486 install_element(INTERFACE_NODE
, &ipv6_ripng_split_horizon_cmd
);
488 install_element(ENABLE_NODE
, &clear_ipv6_rip_cmd
);