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 if (event
!= NB_EV_APPLY
)
131 ripng
->default_metric
= yang_dnode_get_uint8(dnode
, NULL
);
137 * XPath: /frr-ripngd:ripngd/instance/network
139 static int ripngd_instance_network_create(enum nb_event event
,
140 const struct lyd_node
*dnode
,
141 union nb_resource
*resource
)
143 /* TODO: implement me. */
147 static int ripngd_instance_network_delete(enum nb_event event
,
148 const struct lyd_node
*dnode
)
150 /* TODO: implement me. */
155 * XPath: /frr-ripngd:ripngd/instance/interface
157 static int ripngd_instance_interface_create(enum nb_event event
,
158 const struct lyd_node
*dnode
,
159 union nb_resource
*resource
)
161 /* TODO: implement me. */
165 static int ripngd_instance_interface_delete(enum nb_event event
,
166 const struct lyd_node
*dnode
)
168 /* TODO: implement me. */
173 * XPath: /frr-ripngd:ripngd/instance/offset-list
175 static int ripngd_instance_offset_list_create(enum nb_event event
,
176 const struct lyd_node
*dnode
,
177 union nb_resource
*resource
)
179 /* TODO: implement me. */
183 static int ripngd_instance_offset_list_delete(enum nb_event event
,
184 const struct lyd_node
*dnode
)
186 /* TODO: implement me. */
191 * XPath: /frr-ripngd:ripngd/instance/offset-list/access-list
194 ripngd_instance_offset_list_access_list_modify(enum nb_event event
,
195 const struct lyd_node
*dnode
,
196 union nb_resource
*resource
)
198 /* TODO: implement me. */
203 * XPath: /frr-ripngd:ripngd/instance/offset-list/metric
206 ripngd_instance_offset_list_metric_modify(enum nb_event event
,
207 const struct lyd_node
*dnode
,
208 union nb_resource
*resource
)
210 /* TODO: implement me. */
215 * XPath: /frr-ripngd:ripngd/instance/passive-interface
218 ripngd_instance_passive_interface_create(enum nb_event event
,
219 const struct lyd_node
*dnode
,
220 union nb_resource
*resource
)
222 /* TODO: implement me. */
227 ripngd_instance_passive_interface_delete(enum nb_event event
,
228 const struct lyd_node
*dnode
)
230 /* TODO: implement me. */
235 * XPath: /frr-ripngd:ripngd/instance/redistribute
237 static int ripngd_instance_redistribute_create(enum nb_event event
,
238 const struct lyd_node
*dnode
,
239 union nb_resource
*resource
)
241 /* TODO: implement me. */
245 static int ripngd_instance_redistribute_delete(enum nb_event event
,
246 const struct lyd_node
*dnode
)
248 /* TODO: implement me. */
253 * XPath: /frr-ripngd:ripngd/instance/redistribute/route-map
256 ripngd_instance_redistribute_route_map_modify(enum nb_event event
,
257 const struct lyd_node
*dnode
,
258 union nb_resource
*resource
)
260 /* TODO: implement me. */
265 ripngd_instance_redistribute_route_map_delete(enum nb_event event
,
266 const struct lyd_node
*dnode
)
268 /* TODO: implement me. */
273 * XPath: /frr-ripngd:ripngd/instance/redistribute/metric
276 ripngd_instance_redistribute_metric_modify(enum nb_event event
,
277 const struct lyd_node
*dnode
,
278 union nb_resource
*resource
)
280 /* TODO: implement me. */
285 ripngd_instance_redistribute_metric_delete(enum nb_event event
,
286 const struct lyd_node
*dnode
)
288 /* TODO: implement me. */
293 * XPath: /frr-ripngd:ripngd/instance/static-route
295 static int ripngd_instance_static_route_create(enum nb_event event
,
296 const struct lyd_node
*dnode
,
297 union nb_resource
*resource
)
299 /* TODO: implement me. */
303 static int ripngd_instance_static_route_delete(enum nb_event event
,
304 const struct lyd_node
*dnode
)
306 /* TODO: implement me. */
311 * XPath: /frr-ripngd:ripngd/instance/aggregate-address
314 ripngd_instance_aggregate_address_create(enum nb_event event
,
315 const struct lyd_node
*dnode
,
316 union nb_resource
*resource
)
318 /* TODO: implement me. */
323 ripngd_instance_aggregate_address_delete(enum nb_event event
,
324 const struct lyd_node
*dnode
)
326 /* TODO: implement me. */
331 * XPath: /frr-ripngd:ripngd/instance/timers/flush-interval
334 ripngd_instance_timers_flush_interval_modify(enum nb_event event
,
335 const struct lyd_node
*dnode
,
336 union nb_resource
*resource
)
338 /* TODO: implement me. */
343 * XPath: /frr-ripngd:ripngd/instance/timers/holddown-interval
346 ripngd_instance_timers_holddown_interval_modify(enum nb_event event
,
347 const struct lyd_node
*dnode
,
348 union nb_resource
*resource
)
350 /* TODO: implement me. */
355 * XPath: /frr-ripngd:ripngd/instance/timers/update-interval
358 ripngd_instance_timers_update_interval_modify(enum nb_event event
,
359 const struct lyd_node
*dnode
,
360 union nb_resource
*resource
)
362 /* TODO: implement me. */
367 * XPath: /frr-ripngd:ripngd/state/neighbors/neighbor
370 ripngd_state_neighbors_neighbor_get_next(const void *parent_list_entry
,
371 const void *list_entry
)
373 /* TODO: implement me. */
377 static int ripngd_state_neighbors_neighbor_get_keys(const void *list_entry
,
378 struct yang_list_keys
*keys
)
380 /* TODO: implement me. */
385 ripngd_state_neighbors_neighbor_lookup_entry(const void *parent_list_entry
,
386 const struct yang_list_keys
*keys
)
388 /* TODO: implement me. */
393 * XPath: /frr-ripngd:ripngd/state/neighbors/neighbor/address
395 static struct yang_data
*
396 ripngd_state_neighbors_neighbor_address_get_elem(const char *xpath
,
397 const void *list_entry
)
399 /* TODO: implement me. */
404 * XPath: /frr-ripngd:ripngd/state/neighbors/neighbor/last-update
406 static struct yang_data
*
407 ripngd_state_neighbors_neighbor_last_update_get_elem(const char *xpath
,
408 const void *list_entry
)
410 /* TODO: implement me. */
415 * XPath: /frr-ripngd:ripngd/state/neighbors/neighbor/bad-packets-rcvd
417 static struct yang_data
*
418 ripngd_state_neighbors_neighbor_bad_packets_rcvd_get_elem(
419 const char *xpath
, const void *list_entry
)
421 /* TODO: implement me. */
426 * XPath: /frr-ripngd:ripngd/state/neighbors/neighbor/bad-routes-rcvd
428 static struct yang_data
*
429 ripngd_state_neighbors_neighbor_bad_routes_rcvd_get_elem(const char *xpath
,
430 const void *list_entry
)
432 /* TODO: implement me. */
437 * XPath: /frr-ripngd:ripngd/state/routes/route
440 ripngd_state_routes_route_get_next(const void *parent_list_entry
,
441 const void *list_entry
)
443 /* TODO: implement me. */
447 static int ripngd_state_routes_route_get_keys(const void *list_entry
,
448 struct yang_list_keys
*keys
)
450 /* TODO: implement me. */
455 ripngd_state_routes_route_lookup_entry(const void *parent_list_entry
,
456 const struct yang_list_keys
*keys
)
458 /* TODO: implement me. */
463 * XPath: /frr-ripngd:ripngd/state/routes/route/prefix
465 static struct yang_data
*
466 ripngd_state_routes_route_prefix_get_elem(const char *xpath
,
467 const void *list_entry
)
469 /* TODO: implement me. */
474 * XPath: /frr-ripngd:ripngd/state/routes/route/next-hop
476 static struct yang_data
*
477 ripngd_state_routes_route_next_hop_get_elem(const char *xpath
,
478 const void *list_entry
)
480 /* TODO: implement me. */
485 * XPath: /frr-ripngd:ripngd/state/routes/route/interface
487 static struct yang_data
*
488 ripngd_state_routes_route_interface_get_elem(const char *xpath
,
489 const void *list_entry
)
491 /* TODO: implement me. */
496 * XPath: /frr-ripngd:ripngd/state/routes/route/metric
498 static struct yang_data
*
499 ripngd_state_routes_route_metric_get_elem(const char *xpath
,
500 const void *list_entry
)
502 /* TODO: implement me. */
507 * XPath: /frr-ripngd:clear-ripng-route
509 static int clear_ripng_route_rpc(const char *xpath
, const struct list
*input
,
512 /* TODO: implement me. */
517 * XPath: /frr-interface:lib/interface/frr-ripngd:ripng/split-horizon
520 lib_interface_ripng_split_horizon_modify(enum nb_event event
,
521 const struct lyd_node
*dnode
,
522 union nb_resource
*resource
)
524 /* TODO: implement me. */
528 /* clang-format off */
529 const struct frr_yang_module_info frr_ripngd_info
= {
530 .name
= "frr-ripngd",
533 .xpath
= "/frr-ripngd:ripngd/instance",
534 .cbs
.create
= ripngd_instance_create
,
535 .cbs
.delete = ripngd_instance_delete
,
536 .cbs
.cli_show
= cli_show_router_ripng
,
539 .xpath
= "/frr-ripngd:ripngd/instance/allow-ecmp",
540 .cbs
.modify
= ripngd_instance_allow_ecmp_modify
,
541 .cbs
.cli_show
= cli_show_ripng_allow_ecmp
,
544 .xpath
= "/frr-ripngd:ripngd/instance/default-information-originate",
545 .cbs
.modify
= ripngd_instance_default_information_originate_modify
,
546 .cbs
.cli_show
= cli_show_ripng_default_information_originate
,
549 .xpath
= "/frr-ripngd:ripngd/instance/default-metric",
550 .cbs
.modify
= ripngd_instance_default_metric_modify
,
551 .cbs
.cli_show
= cli_show_ripng_default_metric
,
554 .xpath
= "/frr-ripngd:ripngd/instance/network",
555 .cbs
.create
= ripngd_instance_network_create
,
556 .cbs
.delete = ripngd_instance_network_delete
,
559 .xpath
= "/frr-ripngd:ripngd/instance/interface",
560 .cbs
.create
= ripngd_instance_interface_create
,
561 .cbs
.delete = ripngd_instance_interface_delete
,
564 .xpath
= "/frr-ripngd:ripngd/instance/offset-list",
565 .cbs
.create
= ripngd_instance_offset_list_create
,
566 .cbs
.delete = ripngd_instance_offset_list_delete
,
569 .xpath
= "/frr-ripngd:ripngd/instance/offset-list/access-list",
570 .cbs
.modify
= ripngd_instance_offset_list_access_list_modify
,
573 .xpath
= "/frr-ripngd:ripngd/instance/offset-list/metric",
574 .cbs
.modify
= ripngd_instance_offset_list_metric_modify
,
577 .xpath
= "/frr-ripngd:ripngd/instance/passive-interface",
578 .cbs
.create
= ripngd_instance_passive_interface_create
,
579 .cbs
.delete = ripngd_instance_passive_interface_delete
,
582 .xpath
= "/frr-ripngd:ripngd/instance/redistribute",
583 .cbs
.create
= ripngd_instance_redistribute_create
,
584 .cbs
.delete = ripngd_instance_redistribute_delete
,
587 .xpath
= "/frr-ripngd:ripngd/instance/redistribute/route-map",
588 .cbs
.modify
= ripngd_instance_redistribute_route_map_modify
,
589 .cbs
.delete = ripngd_instance_redistribute_route_map_delete
,
592 .xpath
= "/frr-ripngd:ripngd/instance/redistribute/metric",
593 .cbs
.modify
= ripngd_instance_redistribute_metric_modify
,
594 .cbs
.delete = ripngd_instance_redistribute_metric_delete
,
597 .xpath
= "/frr-ripngd:ripngd/instance/static-route",
598 .cbs
.create
= ripngd_instance_static_route_create
,
599 .cbs
.delete = ripngd_instance_static_route_delete
,
602 .xpath
= "/frr-ripngd:ripngd/instance/aggregate-address",
603 .cbs
.create
= ripngd_instance_aggregate_address_create
,
604 .cbs
.delete = ripngd_instance_aggregate_address_delete
,
607 .xpath
= "/frr-ripngd:ripngd/instance/timers/flush-interval",
608 .cbs
.modify
= ripngd_instance_timers_flush_interval_modify
,
611 .xpath
= "/frr-ripngd:ripngd/instance/timers/holddown-interval",
612 .cbs
.modify
= ripngd_instance_timers_holddown_interval_modify
,
615 .xpath
= "/frr-ripngd:ripngd/instance/timers/update-interval",
616 .cbs
.modify
= ripngd_instance_timers_update_interval_modify
,
619 .xpath
= "/frr-ripngd:ripngd/state/neighbors/neighbor",
620 .cbs
.get_next
= ripngd_state_neighbors_neighbor_get_next
,
621 .cbs
.get_keys
= ripngd_state_neighbors_neighbor_get_keys
,
622 .cbs
.lookup_entry
= ripngd_state_neighbors_neighbor_lookup_entry
,
625 .xpath
= "/frr-ripngd:ripngd/state/neighbors/neighbor/address",
626 .cbs
.get_elem
= ripngd_state_neighbors_neighbor_address_get_elem
,
629 .xpath
= "/frr-ripngd:ripngd/state/neighbors/neighbor/last-update",
630 .cbs
.get_elem
= ripngd_state_neighbors_neighbor_last_update_get_elem
,
633 .xpath
= "/frr-ripngd:ripngd/state/neighbors/neighbor/bad-packets-rcvd",
634 .cbs
.get_elem
= ripngd_state_neighbors_neighbor_bad_packets_rcvd_get_elem
,
637 .xpath
= "/frr-ripngd:ripngd/state/neighbors/neighbor/bad-routes-rcvd",
638 .cbs
.get_elem
= ripngd_state_neighbors_neighbor_bad_routes_rcvd_get_elem
,
641 .xpath
= "/frr-ripngd:ripngd/state/routes/route",
642 .cbs
.get_next
= ripngd_state_routes_route_get_next
,
643 .cbs
.get_keys
= ripngd_state_routes_route_get_keys
,
644 .cbs
.lookup_entry
= ripngd_state_routes_route_lookup_entry
,
647 .xpath
= "/frr-ripngd:ripngd/state/routes/route/prefix",
648 .cbs
.get_elem
= ripngd_state_routes_route_prefix_get_elem
,
651 .xpath
= "/frr-ripngd:ripngd/state/routes/route/next-hop",
652 .cbs
.get_elem
= ripngd_state_routes_route_next_hop_get_elem
,
655 .xpath
= "/frr-ripngd:ripngd/state/routes/route/interface",
656 .cbs
.get_elem
= ripngd_state_routes_route_interface_get_elem
,
659 .xpath
= "/frr-ripngd:ripngd/state/routes/route/metric",
660 .cbs
.get_elem
= ripngd_state_routes_route_metric_get_elem
,
663 .xpath
= "/frr-ripngd:clear-ripng-route",
664 .cbs
.rpc
= clear_ripng_route_rpc
,
667 .xpath
= "/frr-interface:lib/interface/frr-ripngd:ripng/split-horizon",
668 .cbs
.modify
= lib_interface_ripng_split_horizon_modify
,