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_nb.h"
33 #ifndef VTYSH_EXTRACT_PL
34 #include "ripngd/ripng_cli_clippy.c"
38 * XPath: /frr-ripngd:ripngd/instance
40 DEFPY_YANG_NOSH (router_ripng
,
42 "router ripng [vrf NAME]",
43 "Enable a routing process\n"
44 "Make RIPng instance command\n"
47 char xpath
[XPATH_MAXLEN
];
50 /* Build RIPng instance XPath. */
52 vrf
= VRF_DEFAULT_NAME
;
53 snprintf(xpath
, sizeof(xpath
), "/frr-ripngd:ripngd/instance[vrf='%s']",
56 nb_cli_enqueue_change(vty
, xpath
, NB_OP_CREATE
, NULL
);
58 ret
= nb_cli_apply_changes(vty
, NULL
);
59 if (ret
== CMD_SUCCESS
)
60 VTY_PUSH_XPATH(RIPNG_NODE
, xpath
);
65 DEFPY_YANG (no_router_ripng
,
67 "no router ripng [vrf NAME]",
69 "Enable a routing process\n"
70 "Make RIPng instance command\n"
73 char xpath
[XPATH_MAXLEN
];
75 /* Build RIPng instance XPath. */
77 vrf
= VRF_DEFAULT_NAME
;
78 snprintf(xpath
, sizeof(xpath
), "/frr-ripngd:ripngd/instance[vrf='%s']",
81 nb_cli_enqueue_change(vty
, xpath
, NB_OP_DESTROY
, NULL
);
83 return nb_cli_apply_changes(vty
, NULL
);
86 void cli_show_router_ripng(struct vty
*vty
, struct lyd_node
*dnode
,
91 vrf_name
= yang_dnode_get_string(dnode
, "./vrf");
94 vty_out(vty
, "router ripng");
95 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
))
96 vty_out(vty
, " vrf %s", vrf_name
);
101 * XPath: /frr-ripngd:ripngd/instance/allow-ecmp
103 DEFPY_YANG (ripng_allow_ecmp
,
104 ripng_allow_ecmp_cmd
,
107 "Allow Equal Cost MultiPath\n")
109 nb_cli_enqueue_change(vty
, "./allow-ecmp", NB_OP_MODIFY
,
110 no
? "false" : "true");
112 return nb_cli_apply_changes(vty
, NULL
);
115 void cli_show_ripng_allow_ecmp(struct vty
*vty
, struct lyd_node
*dnode
,
118 if (!yang_dnode_get_bool(dnode
, NULL
))
121 vty_out(vty
, " allow-ecmp\n");
125 * XPath: /frr-ripngd:ripngd/instance/default-information-originate
127 DEFPY_YANG (ripng_default_information_originate
,
128 ripng_default_information_originate_cmd
,
129 "[no] default-information originate",
131 "Default route information\n"
132 "Distribute default route\n")
134 nb_cli_enqueue_change(vty
, "./default-information-originate",
135 NB_OP_MODIFY
, no
? "false" : "true");
137 return nb_cli_apply_changes(vty
, NULL
);
140 void cli_show_ripng_default_information_originate(struct vty
*vty
,
141 struct lyd_node
*dnode
,
144 if (!yang_dnode_get_bool(dnode
, NULL
))
147 vty_out(vty
, " default-information originate\n");
151 * XPath: /frr-ripngd:ripngd/instance/default-metric
153 DEFPY_YANG (ripng_default_metric
,
154 ripng_default_metric_cmd
,
155 "default-metric (1-16)",
156 "Set a metric of redistribute routes\n"
159 nb_cli_enqueue_change(vty
, "./default-metric", NB_OP_MODIFY
,
162 return nb_cli_apply_changes(vty
, NULL
);
165 DEFPY_YANG (no_ripng_default_metric
,
166 no_ripng_default_metric_cmd
,
167 "no default-metric [(1-16)]",
169 "Set a metric of redistribute routes\n"
172 nb_cli_enqueue_change(vty
, "./default-metric", NB_OP_MODIFY
, NULL
);
174 return nb_cli_apply_changes(vty
, NULL
);
177 void cli_show_ripng_default_metric(struct vty
*vty
, struct lyd_node
*dnode
,
180 vty_out(vty
, " default-metric %s\n",
181 yang_dnode_get_string(dnode
, NULL
));
185 * XPath: /frr-ripngd:ripngd/instance/network
187 DEFPY_YANG (ripng_network_prefix
,
188 ripng_network_prefix_cmd
,
189 "[no] network X:X::X:X/M",
191 "RIPng enable on specified interface or network.\n"
194 nb_cli_enqueue_change(vty
, "./network",
195 no
? NB_OP_DESTROY
: NB_OP_CREATE
, network_str
);
197 return nb_cli_apply_changes(vty
, NULL
);
200 void cli_show_ripng_network_prefix(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/interface
209 DEFPY_YANG (ripng_network_if
,
210 ripng_network_if_cmd
,
213 "RIPng enable on specified interface or network.\n"
216 nb_cli_enqueue_change(vty
, "./interface",
217 no
? NB_OP_DESTROY
: NB_OP_CREATE
, network
);
219 return nb_cli_apply_changes(vty
, NULL
);
222 void cli_show_ripng_network_interface(struct vty
*vty
, struct lyd_node
*dnode
,
225 vty_out(vty
, " network %s\n", yang_dnode_get_string(dnode
, NULL
));
229 * XPath: /frr-ripngd:ripngd/instance/offset-list
231 DEFPY_YANG (ripng_offset_list
,
232 ripng_offset_list_cmd
,
233 "[no] offset-list WORD$acl <in|out>$direction (0-16)$metric [IFNAME]",
235 "Modify RIPng metric\n"
237 "For incoming updates\n"
238 "For outgoing updates\n"
240 "Interface to match\n")
243 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
244 nb_cli_enqueue_change(vty
, "./access-list", NB_OP_MODIFY
, acl
);
245 nb_cli_enqueue_change(vty
, "./metric", NB_OP_MODIFY
,
248 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
250 return nb_cli_apply_changes(
251 vty
, "./offset-list[interface='%s'][direction='%s']",
252 ifname
? ifname
: "*", direction
);
255 void cli_show_ripng_offset_list(struct vty
*vty
, struct lyd_node
*dnode
,
258 const char *interface
;
260 interface
= yang_dnode_get_string(dnode
, "./interface");
262 vty_out(vty
, " offset-list %s %s %s",
263 yang_dnode_get_string(dnode
, "./access-list"),
264 yang_dnode_get_string(dnode
, "./direction"),
265 yang_dnode_get_string(dnode
, "./metric"));
266 if (!strmatch(interface
, "*"))
267 vty_out(vty
, " %s", interface
);
272 * XPath: /frr-ripngd:ripngd/instance/passive-interface
274 DEFPY_YANG (ripng_passive_interface
,
275 ripng_passive_interface_cmd
,
276 "[no] passive-interface IFNAME",
278 "Suppress routing updates on an interface\n"
281 nb_cli_enqueue_change(vty
, "./passive-interface",
282 no
? NB_OP_DESTROY
: NB_OP_CREATE
, ifname
);
284 return nb_cli_apply_changes(vty
, NULL
);
287 void cli_show_ripng_passive_interface(struct vty
*vty
, struct lyd_node
*dnode
,
290 vty_out(vty
, " passive-interface %s\n",
291 yang_dnode_get_string(dnode
, NULL
));
295 * XPath: /frr-ripngd:ripngd/instance/redistribute
297 DEFPY_YANG (ripng_redistribute
,
298 ripng_redistribute_cmd
,
299 "[no] redistribute " FRR_REDIST_STR_RIPNGD
"$protocol [{metric (0-16)|route-map WORD}]",
302 FRR_REDIST_HELP_STR_RIPNGD
305 "Route map reference\n"
306 "Pointer to route-map entries\n")
309 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
310 nb_cli_enqueue_change(vty
, "./route-map",
311 route_map
? NB_OP_MODIFY
: NB_OP_DESTROY
,
313 nb_cli_enqueue_change(vty
, "./metric",
314 metric_str
? NB_OP_MODIFY
: NB_OP_DESTROY
,
317 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
319 return nb_cli_apply_changes(vty
, "./redistribute[protocol='%s']",
323 void cli_show_ripng_redistribute(struct vty
*vty
, struct lyd_node
*dnode
,
326 vty_out(vty
, " redistribute %s",
327 yang_dnode_get_string(dnode
, "./protocol"));
328 if (yang_dnode_exists(dnode
, "./metric"))
329 vty_out(vty
, " metric %s",
330 yang_dnode_get_string(dnode
, "./metric"));
331 if (yang_dnode_exists(dnode
, "./route-map"))
332 vty_out(vty
, " route-map %s",
333 yang_dnode_get_string(dnode
, "./route-map"));
338 * XPath: /frr-ripngd:ripngd/instance/static-route
340 DEFPY_YANG (ripng_route
,
342 "[no] route X:X::X:X/M",
344 "Static route setup\n"
345 "Set static RIPng route announcement\n")
347 nb_cli_enqueue_change(vty
, "./static-route",
348 no
? NB_OP_DESTROY
: NB_OP_CREATE
, route_str
);
350 return nb_cli_apply_changes(vty
, NULL
);
353 void cli_show_ripng_route(struct vty
*vty
, struct lyd_node
*dnode
,
356 vty_out(vty
, " route %s\n", yang_dnode_get_string(dnode
, NULL
));
360 * XPath: /frr-ripngd:ripngd/instance/aggregate-addres
362 DEFPY_YANG (ripng_aggregate_address
,
363 ripng_aggregate_address_cmd
,
364 "[no] aggregate-address X:X::X:X/M",
366 "Set aggregate RIPng route announcement\n"
367 "Aggregate network\n")
369 nb_cli_enqueue_change(vty
, "./aggregate-address",
370 no
? NB_OP_DESTROY
: NB_OP_CREATE
,
371 aggregate_address_str
);
373 return nb_cli_apply_changes(vty
, NULL
);
376 void cli_show_ripng_aggregate_address(struct vty
*vty
, struct lyd_node
*dnode
,
379 vty_out(vty
, " aggregate-address %s\n",
380 yang_dnode_get_string(dnode
, NULL
));
384 * XPath: /frr-ripngd:ripngd/instance/timers
386 DEFPY_YANG (ripng_timers
,
388 "timers basic (1-65535)$update (1-65535)$timeout (1-65535)$garbage",
389 "RIPng timers setup\n"
391 "Routing table update timer value in second. Default is 30.\n"
392 "Routing information timeout timer. Default is 180.\n"
393 "Garbage collection timer. Default is 120.\n")
395 nb_cli_enqueue_change(vty
, "./update-interval", NB_OP_MODIFY
,
397 nb_cli_enqueue_change(vty
, "./holddown-interval", NB_OP_MODIFY
,
399 nb_cli_enqueue_change(vty
, "./flush-interval", NB_OP_MODIFY
,
402 return nb_cli_apply_changes(vty
, "./timers");
405 DEFPY_YANG (no_ripng_timers
,
407 "no timers basic [(1-65535) (1-65535) (1-65535)]",
409 "RIPng timers setup\n"
411 "Routing table update timer value in second. Default is 30.\n"
412 "Routing information timeout timer. Default is 180.\n"
413 "Garbage collection timer. Default is 120.\n")
415 nb_cli_enqueue_change(vty
, "./update-interval", NB_OP_MODIFY
, NULL
);
416 nb_cli_enqueue_change(vty
, "./holddown-interval", NB_OP_MODIFY
, NULL
);
417 nb_cli_enqueue_change(vty
, "./flush-interval", NB_OP_MODIFY
, NULL
);
419 return nb_cli_apply_changes(vty
, "./timers");
422 void cli_show_ripng_timers(struct vty
*vty
, struct lyd_node
*dnode
,
425 vty_out(vty
, " timers basic %s %s %s\n",
426 yang_dnode_get_string(dnode
, "./update-interval"),
427 yang_dnode_get_string(dnode
, "./holddown-interval"),
428 yang_dnode_get_string(dnode
, "./flush-interval"));
432 * XPath: /frr-interface:lib/interface/frr-ripngd:ripng/split-horizon
434 DEFPY_YANG (ipv6_ripng_split_horizon
,
435 ipv6_ripng_split_horizon_cmd
,
436 "[no] ipv6 ripng split-horizon [poisoned-reverse$poisoned_reverse]",
439 "Routing Information Protocol\n"
440 "Perform split horizon\n"
441 "With poisoned-reverse\n")
447 else if (poisoned_reverse
)
448 value
= "poison-reverse";
452 nb_cli_enqueue_change(vty
, "./split-horizon", NB_OP_MODIFY
, value
);
454 return nb_cli_apply_changes(vty
, "./frr-ripngd:ripng");
457 void cli_show_ipv6_ripng_split_horizon(struct vty
*vty
, struct lyd_node
*dnode
,
462 value
= yang_dnode_get_enum(dnode
, NULL
);
464 case RIPNG_NO_SPLIT_HORIZON
:
465 vty_out(vty
, " no ipv6 ripng split-horizon\n");
467 case RIPNG_SPLIT_HORIZON
:
468 vty_out(vty
, " ipv6 ripng split-horizon\n");
470 case RIPNG_SPLIT_HORIZON_POISONED_REVERSE
:
471 vty_out(vty
, " ipv6 ripng split-horizon poisoned-reverse\n");
477 * XPath: /frr-ripngd:clear-ripng-route
479 DEFPY_YANG (clear_ipv6_rip
,
481 "clear ipv6 ripng [vrf WORD]",
484 "Clear IPv6 RIP database\n"
492 struct yang_data
*yang_vrf
;
494 yang_vrf
= yang_data_new(
495 "/frr-ripngd:clear-ripng-route/input/vrf", vrf
);
496 listnode_add(input
, yang_vrf
);
499 ret
= nb_cli_rpc(vty
, "/frr-ripngd:clear-ripng-route", input
, NULL
);
506 void ripng_cli_init(void)
508 install_element(CONFIG_NODE
, &router_ripng_cmd
);
509 install_element(CONFIG_NODE
, &no_router_ripng_cmd
);
511 install_element(RIPNG_NODE
, &ripng_allow_ecmp_cmd
);
512 install_element(RIPNG_NODE
, &ripng_default_information_originate_cmd
);
513 install_element(RIPNG_NODE
, &ripng_default_metric_cmd
);
514 install_element(RIPNG_NODE
, &no_ripng_default_metric_cmd
);
515 install_element(RIPNG_NODE
, &ripng_network_prefix_cmd
);
516 install_element(RIPNG_NODE
, &ripng_network_if_cmd
);
517 install_element(RIPNG_NODE
, &ripng_offset_list_cmd
);
518 install_element(RIPNG_NODE
, &ripng_passive_interface_cmd
);
519 install_element(RIPNG_NODE
, &ripng_redistribute_cmd
);
520 install_element(RIPNG_NODE
, &ripng_route_cmd
);
521 install_element(RIPNG_NODE
, &ripng_aggregate_address_cmd
);
522 install_element(RIPNG_NODE
, &ripng_timers_cmd
);
523 install_element(RIPNG_NODE
, &no_ripng_timers_cmd
);
525 install_element(INTERFACE_NODE
, &ipv6_ripng_split_horizon_cmd
);
527 install_element(ENABLE_NODE
, &clear_ipv6_rip_cmd
);