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
30 #include "northbound.h"
33 #include "ripngd/ripngd.h"
34 #include "ripngd/ripng_cli.h"
37 * XPath: /frr-ripngd:ripngd/instance
39 static int ripngd_instance_create(enum nb_event event
,
40 const struct lyd_node
*dnode
,
41 union nb_resource
*resource
)
49 socket
= ripng_make_socket();
51 return NB_ERR_RESOURCE
;
52 resource
->fd
= socket
;
55 socket
= resource
->fd
;
59 socket
= resource
->fd
;
67 static int ripngd_instance_delete(enum nb_event event
,
68 const struct lyd_node
*dnode
)
70 if (event
!= NB_EV_APPLY
)
79 * XPath: /frr-ripngd:ripngd/instance/allow-ecmp
81 static int ripngd_instance_allow_ecmp_modify(enum nb_event event
,
82 const struct lyd_node
*dnode
,
83 union nb_resource
*resource
)
85 if (event
!= NB_EV_APPLY
)
88 ripng
->ecmp
= yang_dnode_get_bool(dnode
, NULL
);
96 * XPath: /frr-ripngd:ripngd/instance/default-information-originate
98 static int ripngd_instance_default_information_originate_modify(
99 enum nb_event event
, const struct lyd_node
*dnode
,
100 union nb_resource
*resource
)
102 bool default_information
;
103 struct prefix_ipv6 p
;
105 if (event
!= NB_EV_APPLY
)
108 default_information
= yang_dnode_get_bool(dnode
, NULL
);
109 str2prefix_ipv6("::/0", &p
);
110 if (default_information
) {
111 ripng_redistribute_add(ZEBRA_ROUTE_RIPNG
, RIPNG_ROUTE_DEFAULT
,
114 ripng_redistribute_delete(ZEBRA_ROUTE_RIPNG
,
115 RIPNG_ROUTE_DEFAULT
, &p
, 0);
122 * XPath: /frr-ripngd:ripngd/instance/default-metric
124 static int ripngd_instance_default_metric_modify(enum nb_event event
,
125 const struct lyd_node
*dnode
,
126 union nb_resource
*resource
)
128 /* TODO: implement me. */
133 * XPath: /frr-ripngd:ripngd/instance/network
135 static int ripngd_instance_network_create(enum nb_event event
,
136 const struct lyd_node
*dnode
,
137 union nb_resource
*resource
)
139 /* TODO: implement me. */
143 static int ripngd_instance_network_delete(enum nb_event event
,
144 const struct lyd_node
*dnode
)
146 /* TODO: implement me. */
151 * XPath: /frr-ripngd:ripngd/instance/interface
153 static int ripngd_instance_interface_create(enum nb_event event
,
154 const struct lyd_node
*dnode
,
155 union nb_resource
*resource
)
157 /* TODO: implement me. */
161 static int ripngd_instance_interface_delete(enum nb_event event
,
162 const struct lyd_node
*dnode
)
164 /* TODO: implement me. */
169 * XPath: /frr-ripngd:ripngd/instance/offset-list
171 static int ripngd_instance_offset_list_create(enum nb_event event
,
172 const struct lyd_node
*dnode
,
173 union nb_resource
*resource
)
175 /* TODO: implement me. */
179 static int ripngd_instance_offset_list_delete(enum nb_event event
,
180 const struct lyd_node
*dnode
)
182 /* TODO: implement me. */
187 * XPath: /frr-ripngd:ripngd/instance/offset-list/access-list
190 ripngd_instance_offset_list_access_list_modify(enum nb_event event
,
191 const struct lyd_node
*dnode
,
192 union nb_resource
*resource
)
194 /* TODO: implement me. */
199 * XPath: /frr-ripngd:ripngd/instance/offset-list/metric
202 ripngd_instance_offset_list_metric_modify(enum nb_event event
,
203 const struct lyd_node
*dnode
,
204 union nb_resource
*resource
)
206 /* TODO: implement me. */
211 * XPath: /frr-ripngd:ripngd/instance/passive-interface
214 ripngd_instance_passive_interface_create(enum nb_event event
,
215 const struct lyd_node
*dnode
,
216 union nb_resource
*resource
)
218 /* TODO: implement me. */
223 ripngd_instance_passive_interface_delete(enum nb_event event
,
224 const struct lyd_node
*dnode
)
226 /* TODO: implement me. */
231 * XPath: /frr-ripngd:ripngd/instance/redistribute
233 static int ripngd_instance_redistribute_create(enum nb_event event
,
234 const struct lyd_node
*dnode
,
235 union nb_resource
*resource
)
237 /* TODO: implement me. */
241 static int ripngd_instance_redistribute_delete(enum nb_event event
,
242 const struct lyd_node
*dnode
)
244 /* TODO: implement me. */
249 * XPath: /frr-ripngd:ripngd/instance/redistribute/route-map
252 ripngd_instance_redistribute_route_map_modify(enum nb_event event
,
253 const struct lyd_node
*dnode
,
254 union nb_resource
*resource
)
256 /* TODO: implement me. */
261 ripngd_instance_redistribute_route_map_delete(enum nb_event event
,
262 const struct lyd_node
*dnode
)
264 /* TODO: implement me. */
269 * XPath: /frr-ripngd:ripngd/instance/redistribute/metric
272 ripngd_instance_redistribute_metric_modify(enum nb_event event
,
273 const struct lyd_node
*dnode
,
274 union nb_resource
*resource
)
276 /* TODO: implement me. */
281 ripngd_instance_redistribute_metric_delete(enum nb_event event
,
282 const struct lyd_node
*dnode
)
284 /* TODO: implement me. */
289 * XPath: /frr-ripngd:ripngd/instance/static-route
291 static int ripngd_instance_static_route_create(enum nb_event event
,
292 const struct lyd_node
*dnode
,
293 union nb_resource
*resource
)
295 /* TODO: implement me. */
299 static int ripngd_instance_static_route_delete(enum nb_event event
,
300 const struct lyd_node
*dnode
)
302 /* TODO: implement me. */
307 * XPath: /frr-ripngd:ripngd/instance/aggregate-address
310 ripngd_instance_aggregate_address_create(enum nb_event event
,
311 const struct lyd_node
*dnode
,
312 union nb_resource
*resource
)
314 /* TODO: implement me. */
319 ripngd_instance_aggregate_address_delete(enum nb_event event
,
320 const struct lyd_node
*dnode
)
322 /* TODO: implement me. */
327 * XPath: /frr-ripngd:ripngd/instance/timers/flush-interval
330 ripngd_instance_timers_flush_interval_modify(enum nb_event event
,
331 const struct lyd_node
*dnode
,
332 union nb_resource
*resource
)
334 /* TODO: implement me. */
339 * XPath: /frr-ripngd:ripngd/instance/timers/holddown-interval
342 ripngd_instance_timers_holddown_interval_modify(enum nb_event event
,
343 const struct lyd_node
*dnode
,
344 union nb_resource
*resource
)
346 /* TODO: implement me. */
351 * XPath: /frr-ripngd:ripngd/instance/timers/update-interval
354 ripngd_instance_timers_update_interval_modify(enum nb_event event
,
355 const struct lyd_node
*dnode
,
356 union nb_resource
*resource
)
358 /* TODO: implement me. */
363 * XPath: /frr-ripngd:ripngd/state/neighbors/neighbor
366 ripngd_state_neighbors_neighbor_get_next(const void *parent_list_entry
,
367 const void *list_entry
)
369 /* TODO: implement me. */
373 static int ripngd_state_neighbors_neighbor_get_keys(const void *list_entry
,
374 struct yang_list_keys
*keys
)
376 /* TODO: implement me. */
381 ripngd_state_neighbors_neighbor_lookup_entry(const void *parent_list_entry
,
382 const struct yang_list_keys
*keys
)
384 /* TODO: implement me. */
389 * XPath: /frr-ripngd:ripngd/state/neighbors/neighbor/address
391 static struct yang_data
*
392 ripngd_state_neighbors_neighbor_address_get_elem(const char *xpath
,
393 const void *list_entry
)
395 /* TODO: implement me. */
400 * XPath: /frr-ripngd:ripngd/state/neighbors/neighbor/last-update
402 static struct yang_data
*
403 ripngd_state_neighbors_neighbor_last_update_get_elem(const char *xpath
,
404 const void *list_entry
)
406 /* TODO: implement me. */
411 * XPath: /frr-ripngd:ripngd/state/neighbors/neighbor/bad-packets-rcvd
413 static struct yang_data
*
414 ripngd_state_neighbors_neighbor_bad_packets_rcvd_get_elem(
415 const char *xpath
, const void *list_entry
)
417 /* TODO: implement me. */
422 * XPath: /frr-ripngd:ripngd/state/neighbors/neighbor/bad-routes-rcvd
424 static struct yang_data
*
425 ripngd_state_neighbors_neighbor_bad_routes_rcvd_get_elem(const char *xpath
,
426 const void *list_entry
)
428 /* TODO: implement me. */
433 * XPath: /frr-ripngd:ripngd/state/routes/route
436 ripngd_state_routes_route_get_next(const void *parent_list_entry
,
437 const void *list_entry
)
439 /* TODO: implement me. */
443 static int ripngd_state_routes_route_get_keys(const void *list_entry
,
444 struct yang_list_keys
*keys
)
446 /* TODO: implement me. */
451 ripngd_state_routes_route_lookup_entry(const void *parent_list_entry
,
452 const struct yang_list_keys
*keys
)
454 /* TODO: implement me. */
459 * XPath: /frr-ripngd:ripngd/state/routes/route/prefix
461 static struct yang_data
*
462 ripngd_state_routes_route_prefix_get_elem(const char *xpath
,
463 const void *list_entry
)
465 /* TODO: implement me. */
470 * XPath: /frr-ripngd:ripngd/state/routes/route/next-hop
472 static struct yang_data
*
473 ripngd_state_routes_route_next_hop_get_elem(const char *xpath
,
474 const void *list_entry
)
476 /* TODO: implement me. */
481 * XPath: /frr-ripngd:ripngd/state/routes/route/interface
483 static struct yang_data
*
484 ripngd_state_routes_route_interface_get_elem(const char *xpath
,
485 const void *list_entry
)
487 /* TODO: implement me. */
492 * XPath: /frr-ripngd:ripngd/state/routes/route/metric
494 static struct yang_data
*
495 ripngd_state_routes_route_metric_get_elem(const char *xpath
,
496 const void *list_entry
)
498 /* TODO: implement me. */
503 * XPath: /frr-ripngd:clear-ripng-route
505 static int clear_ripng_route_rpc(const char *xpath
, const struct list
*input
,
508 /* TODO: implement me. */
513 * XPath: /frr-interface:lib/interface/frr-ripngd:ripng/split-horizon
516 lib_interface_ripng_split_horizon_modify(enum nb_event event
,
517 const struct lyd_node
*dnode
,
518 union nb_resource
*resource
)
520 /* TODO: implement me. */
524 /* clang-format off */
525 const struct frr_yang_module_info frr_ripngd_info
= {
526 .name
= "frr-ripngd",
529 .xpath
= "/frr-ripngd:ripngd/instance",
530 .cbs
.create
= ripngd_instance_create
,
531 .cbs
.delete = ripngd_instance_delete
,
532 .cbs
.cli_show
= cli_show_router_ripng
,
535 .xpath
= "/frr-ripngd:ripngd/instance/allow-ecmp",
536 .cbs
.modify
= ripngd_instance_allow_ecmp_modify
,
537 .cbs
.cli_show
= cli_show_ripng_allow_ecmp
,
540 .xpath
= "/frr-ripngd:ripngd/instance/default-information-originate",
541 .cbs
.modify
= ripngd_instance_default_information_originate_modify
,
542 .cbs
.cli_show
= cli_show_ripng_default_information_originate
,
545 .xpath
= "/frr-ripngd:ripngd/instance/default-metric",
546 .cbs
.modify
= ripngd_instance_default_metric_modify
,
549 .xpath
= "/frr-ripngd:ripngd/instance/network",
550 .cbs
.create
= ripngd_instance_network_create
,
551 .cbs
.delete = ripngd_instance_network_delete
,
554 .xpath
= "/frr-ripngd:ripngd/instance/interface",
555 .cbs
.create
= ripngd_instance_interface_create
,
556 .cbs
.delete = ripngd_instance_interface_delete
,
559 .xpath
= "/frr-ripngd:ripngd/instance/offset-list",
560 .cbs
.create
= ripngd_instance_offset_list_create
,
561 .cbs
.delete = ripngd_instance_offset_list_delete
,
564 .xpath
= "/frr-ripngd:ripngd/instance/offset-list/access-list",
565 .cbs
.modify
= ripngd_instance_offset_list_access_list_modify
,
568 .xpath
= "/frr-ripngd:ripngd/instance/offset-list/metric",
569 .cbs
.modify
= ripngd_instance_offset_list_metric_modify
,
572 .xpath
= "/frr-ripngd:ripngd/instance/passive-interface",
573 .cbs
.create
= ripngd_instance_passive_interface_create
,
574 .cbs
.delete = ripngd_instance_passive_interface_delete
,
577 .xpath
= "/frr-ripngd:ripngd/instance/redistribute",
578 .cbs
.create
= ripngd_instance_redistribute_create
,
579 .cbs
.delete = ripngd_instance_redistribute_delete
,
582 .xpath
= "/frr-ripngd:ripngd/instance/redistribute/route-map",
583 .cbs
.modify
= ripngd_instance_redistribute_route_map_modify
,
584 .cbs
.delete = ripngd_instance_redistribute_route_map_delete
,
587 .xpath
= "/frr-ripngd:ripngd/instance/redistribute/metric",
588 .cbs
.modify
= ripngd_instance_redistribute_metric_modify
,
589 .cbs
.delete = ripngd_instance_redistribute_metric_delete
,
592 .xpath
= "/frr-ripngd:ripngd/instance/static-route",
593 .cbs
.create
= ripngd_instance_static_route_create
,
594 .cbs
.delete = ripngd_instance_static_route_delete
,
597 .xpath
= "/frr-ripngd:ripngd/instance/aggregate-address",
598 .cbs
.create
= ripngd_instance_aggregate_address_create
,
599 .cbs
.delete = ripngd_instance_aggregate_address_delete
,
602 .xpath
= "/frr-ripngd:ripngd/instance/timers/flush-interval",
603 .cbs
.modify
= ripngd_instance_timers_flush_interval_modify
,
606 .xpath
= "/frr-ripngd:ripngd/instance/timers/holddown-interval",
607 .cbs
.modify
= ripngd_instance_timers_holddown_interval_modify
,
610 .xpath
= "/frr-ripngd:ripngd/instance/timers/update-interval",
611 .cbs
.modify
= ripngd_instance_timers_update_interval_modify
,
614 .xpath
= "/frr-ripngd:ripngd/state/neighbors/neighbor",
615 .cbs
.get_next
= ripngd_state_neighbors_neighbor_get_next
,
616 .cbs
.get_keys
= ripngd_state_neighbors_neighbor_get_keys
,
617 .cbs
.lookup_entry
= ripngd_state_neighbors_neighbor_lookup_entry
,
620 .xpath
= "/frr-ripngd:ripngd/state/neighbors/neighbor/address",
621 .cbs
.get_elem
= ripngd_state_neighbors_neighbor_address_get_elem
,
624 .xpath
= "/frr-ripngd:ripngd/state/neighbors/neighbor/last-update",
625 .cbs
.get_elem
= ripngd_state_neighbors_neighbor_last_update_get_elem
,
628 .xpath
= "/frr-ripngd:ripngd/state/neighbors/neighbor/bad-packets-rcvd",
629 .cbs
.get_elem
= ripngd_state_neighbors_neighbor_bad_packets_rcvd_get_elem
,
632 .xpath
= "/frr-ripngd:ripngd/state/neighbors/neighbor/bad-routes-rcvd",
633 .cbs
.get_elem
= ripngd_state_neighbors_neighbor_bad_routes_rcvd_get_elem
,
636 .xpath
= "/frr-ripngd:ripngd/state/routes/route",
637 .cbs
.get_next
= ripngd_state_routes_route_get_next
,
638 .cbs
.get_keys
= ripngd_state_routes_route_get_keys
,
639 .cbs
.lookup_entry
= ripngd_state_routes_route_lookup_entry
,
642 .xpath
= "/frr-ripngd:ripngd/state/routes/route/prefix",
643 .cbs
.get_elem
= ripngd_state_routes_route_prefix_get_elem
,
646 .xpath
= "/frr-ripngd:ripngd/state/routes/route/next-hop",
647 .cbs
.get_elem
= ripngd_state_routes_route_next_hop_get_elem
,
650 .xpath
= "/frr-ripngd:ripngd/state/routes/route/interface",
651 .cbs
.get_elem
= ripngd_state_routes_route_interface_get_elem
,
654 .xpath
= "/frr-ripngd:ripngd/state/routes/route/metric",
655 .cbs
.get_elem
= ripngd_state_routes_route_metric_get_elem
,
658 .xpath
= "/frr-ripngd:clear-ripng-route",
659 .cbs
.rpc
= clear_ripng_route_rpc
,
662 .xpath
= "/frr-interface:lib/interface/frr-ripngd:ripng/split-horizon",
663 .cbs
.modify
= lib_interface_ripng_split_horizon_modify
,