]> git.proxmox.com Git - mirror_frr.git/blob - ripngd/ripng_northbound.c
7a7c14cebca4570035a77ca018d3d1b591bd1802
[mirror_frr.git] / ripngd / ripng_northbound.c
1 /*
2 * Copyright (C) 1998 Kunihiro Ishiguro
3 * Copyright (C) 2018 NetDEF, Inc.
4 * Renato Westphal
5 *
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)
9 * any later version.
10 *
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
14 * more details.
15 *
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
19 */
20
21 #include <zebra.h>
22
23 #include "if.h"
24 #include "vrf.h"
25 #include "log.h"
26 #include "prefix.h"
27 #include "table.h"
28 #include "command.h"
29 #include "routemap.h"
30 #include "northbound.h"
31 #include "libfrr.h"
32
33 #include "ripngd/ripngd.h"
34 #include "ripngd/ripng_cli.h"
35
36 /*
37 * XPath: /frr-ripngd:ripngd/instance
38 */
39 static int ripngd_instance_create(enum nb_event event,
40 const struct lyd_node *dnode,
41 union nb_resource *resource)
42 {
43 int socket;
44
45 switch (event) {
46 case NB_EV_VALIDATE:
47 break;
48 case NB_EV_PREPARE:
49 socket = ripng_make_socket();
50 if (socket < 0)
51 return NB_ERR_RESOURCE;
52 resource->fd = socket;
53 break;
54 case NB_EV_ABORT:
55 socket = resource->fd;
56 close(socket);
57 break;
58 case NB_EV_APPLY:
59 socket = resource->fd;
60 ripng_create(socket);
61 break;
62 }
63
64 return NB_OK;
65 }
66
67 static int ripngd_instance_delete(enum nb_event event,
68 const struct lyd_node *dnode)
69 {
70 if (event != NB_EV_APPLY)
71 return NB_OK;
72
73 ripng_clean();
74
75 return NB_OK;
76 }
77
78 /*
79 * XPath: /frr-ripngd:ripngd/instance/allow-ecmp
80 */
81 static int ripngd_instance_allow_ecmp_modify(enum nb_event event,
82 const struct lyd_node *dnode,
83 union nb_resource *resource)
84 {
85 if (event != NB_EV_APPLY)
86 return NB_OK;
87
88 ripng->ecmp = yang_dnode_get_bool(dnode, NULL);
89 if (!ripng->ecmp)
90 ripng_ecmp_disable();
91
92 return NB_OK;
93 }
94
95 /*
96 * XPath: /frr-ripngd:ripngd/instance/default-information-originate
97 */
98 static int ripngd_instance_default_information_originate_modify(
99 enum nb_event event, const struct lyd_node *dnode,
100 union nb_resource *resource)
101 {
102 bool default_information;
103 struct prefix_ipv6 p;
104
105 if (event != NB_EV_APPLY)
106 return NB_OK;
107
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,
112 &p, 0, NULL, 0);
113 } else {
114 ripng_redistribute_delete(ZEBRA_ROUTE_RIPNG,
115 RIPNG_ROUTE_DEFAULT, &p, 0);
116 }
117
118 return NB_OK;
119 }
120
121 /*
122 * XPath: /frr-ripngd:ripngd/instance/default-metric
123 */
124 static int ripngd_instance_default_metric_modify(enum nb_event event,
125 const struct lyd_node *dnode,
126 union nb_resource *resource)
127 {
128 if (event != NB_EV_APPLY)
129 return NB_OK;
130
131 ripng->default_metric = yang_dnode_get_uint8(dnode, NULL);
132
133 return NB_OK;
134 }
135
136 /*
137 * XPath: /frr-ripngd:ripngd/instance/network
138 */
139 static int ripngd_instance_network_create(enum nb_event event,
140 const struct lyd_node *dnode,
141 union nb_resource *resource)
142 {
143 /* TODO: implement me. */
144 return NB_OK;
145 }
146
147 static int ripngd_instance_network_delete(enum nb_event event,
148 const struct lyd_node *dnode)
149 {
150 /* TODO: implement me. */
151 return NB_OK;
152 }
153
154 /*
155 * XPath: /frr-ripngd:ripngd/instance/interface
156 */
157 static int ripngd_instance_interface_create(enum nb_event event,
158 const struct lyd_node *dnode,
159 union nb_resource *resource)
160 {
161 /* TODO: implement me. */
162 return NB_OK;
163 }
164
165 static int ripngd_instance_interface_delete(enum nb_event event,
166 const struct lyd_node *dnode)
167 {
168 /* TODO: implement me. */
169 return NB_OK;
170 }
171
172 /*
173 * XPath: /frr-ripngd:ripngd/instance/offset-list
174 */
175 static int ripngd_instance_offset_list_create(enum nb_event event,
176 const struct lyd_node *dnode,
177 union nb_resource *resource)
178 {
179 /* TODO: implement me. */
180 return NB_OK;
181 }
182
183 static int ripngd_instance_offset_list_delete(enum nb_event event,
184 const struct lyd_node *dnode)
185 {
186 /* TODO: implement me. */
187 return NB_OK;
188 }
189
190 /*
191 * XPath: /frr-ripngd:ripngd/instance/offset-list/access-list
192 */
193 static int
194 ripngd_instance_offset_list_access_list_modify(enum nb_event event,
195 const struct lyd_node *dnode,
196 union nb_resource *resource)
197 {
198 /* TODO: implement me. */
199 return NB_OK;
200 }
201
202 /*
203 * XPath: /frr-ripngd:ripngd/instance/offset-list/metric
204 */
205 static int
206 ripngd_instance_offset_list_metric_modify(enum nb_event event,
207 const struct lyd_node *dnode,
208 union nb_resource *resource)
209 {
210 /* TODO: implement me. */
211 return NB_OK;
212 }
213
214 /*
215 * XPath: /frr-ripngd:ripngd/instance/passive-interface
216 */
217 static int
218 ripngd_instance_passive_interface_create(enum nb_event event,
219 const struct lyd_node *dnode,
220 union nb_resource *resource)
221 {
222 /* TODO: implement me. */
223 return NB_OK;
224 }
225
226 static int
227 ripngd_instance_passive_interface_delete(enum nb_event event,
228 const struct lyd_node *dnode)
229 {
230 /* TODO: implement me. */
231 return NB_OK;
232 }
233
234 /*
235 * XPath: /frr-ripngd:ripngd/instance/redistribute
236 */
237 static int ripngd_instance_redistribute_create(enum nb_event event,
238 const struct lyd_node *dnode,
239 union nb_resource *resource)
240 {
241 /* TODO: implement me. */
242 return NB_OK;
243 }
244
245 static int ripngd_instance_redistribute_delete(enum nb_event event,
246 const struct lyd_node *dnode)
247 {
248 /* TODO: implement me. */
249 return NB_OK;
250 }
251
252 /*
253 * XPath: /frr-ripngd:ripngd/instance/redistribute/route-map
254 */
255 static int
256 ripngd_instance_redistribute_route_map_modify(enum nb_event event,
257 const struct lyd_node *dnode,
258 union nb_resource *resource)
259 {
260 /* TODO: implement me. */
261 return NB_OK;
262 }
263
264 static int
265 ripngd_instance_redistribute_route_map_delete(enum nb_event event,
266 const struct lyd_node *dnode)
267 {
268 /* TODO: implement me. */
269 return NB_OK;
270 }
271
272 /*
273 * XPath: /frr-ripngd:ripngd/instance/redistribute/metric
274 */
275 static int
276 ripngd_instance_redistribute_metric_modify(enum nb_event event,
277 const struct lyd_node *dnode,
278 union nb_resource *resource)
279 {
280 /* TODO: implement me. */
281 return NB_OK;
282 }
283
284 static int
285 ripngd_instance_redistribute_metric_delete(enum nb_event event,
286 const struct lyd_node *dnode)
287 {
288 /* TODO: implement me. */
289 return NB_OK;
290 }
291
292 /*
293 * XPath: /frr-ripngd:ripngd/instance/static-route
294 */
295 static int ripngd_instance_static_route_create(enum nb_event event,
296 const struct lyd_node *dnode,
297 union nb_resource *resource)
298 {
299 /* TODO: implement me. */
300 return NB_OK;
301 }
302
303 static int ripngd_instance_static_route_delete(enum nb_event event,
304 const struct lyd_node *dnode)
305 {
306 /* TODO: implement me. */
307 return NB_OK;
308 }
309
310 /*
311 * XPath: /frr-ripngd:ripngd/instance/aggregate-address
312 */
313 static int
314 ripngd_instance_aggregate_address_create(enum nb_event event,
315 const struct lyd_node *dnode,
316 union nb_resource *resource)
317 {
318 /* TODO: implement me. */
319 return NB_OK;
320 }
321
322 static int
323 ripngd_instance_aggregate_address_delete(enum nb_event event,
324 const struct lyd_node *dnode)
325 {
326 /* TODO: implement me. */
327 return NB_OK;
328 }
329
330 /*
331 * XPath: /frr-ripngd:ripngd/instance/timers/flush-interval
332 */
333 static int
334 ripngd_instance_timers_flush_interval_modify(enum nb_event event,
335 const struct lyd_node *dnode,
336 union nb_resource *resource)
337 {
338 /* TODO: implement me. */
339 return NB_OK;
340 }
341
342 /*
343 * XPath: /frr-ripngd:ripngd/instance/timers/holddown-interval
344 */
345 static int
346 ripngd_instance_timers_holddown_interval_modify(enum nb_event event,
347 const struct lyd_node *dnode,
348 union nb_resource *resource)
349 {
350 /* TODO: implement me. */
351 return NB_OK;
352 }
353
354 /*
355 * XPath: /frr-ripngd:ripngd/instance/timers/update-interval
356 */
357 static int
358 ripngd_instance_timers_update_interval_modify(enum nb_event event,
359 const struct lyd_node *dnode,
360 union nb_resource *resource)
361 {
362 /* TODO: implement me. */
363 return NB_OK;
364 }
365
366 /*
367 * XPath: /frr-ripngd:ripngd/state/neighbors/neighbor
368 */
369 static const void *
370 ripngd_state_neighbors_neighbor_get_next(const void *parent_list_entry,
371 const void *list_entry)
372 {
373 /* TODO: implement me. */
374 return NULL;
375 }
376
377 static int ripngd_state_neighbors_neighbor_get_keys(const void *list_entry,
378 struct yang_list_keys *keys)
379 {
380 /* TODO: implement me. */
381 return NB_OK;
382 }
383
384 static const void *
385 ripngd_state_neighbors_neighbor_lookup_entry(const void *parent_list_entry,
386 const struct yang_list_keys *keys)
387 {
388 /* TODO: implement me. */
389 return NULL;
390 }
391
392 /*
393 * XPath: /frr-ripngd:ripngd/state/neighbors/neighbor/address
394 */
395 static struct yang_data *
396 ripngd_state_neighbors_neighbor_address_get_elem(const char *xpath,
397 const void *list_entry)
398 {
399 /* TODO: implement me. */
400 return NULL;
401 }
402
403 /*
404 * XPath: /frr-ripngd:ripngd/state/neighbors/neighbor/last-update
405 */
406 static struct yang_data *
407 ripngd_state_neighbors_neighbor_last_update_get_elem(const char *xpath,
408 const void *list_entry)
409 {
410 /* TODO: implement me. */
411 return NULL;
412 }
413
414 /*
415 * XPath: /frr-ripngd:ripngd/state/neighbors/neighbor/bad-packets-rcvd
416 */
417 static struct yang_data *
418 ripngd_state_neighbors_neighbor_bad_packets_rcvd_get_elem(
419 const char *xpath, const void *list_entry)
420 {
421 /* TODO: implement me. */
422 return NULL;
423 }
424
425 /*
426 * XPath: /frr-ripngd:ripngd/state/neighbors/neighbor/bad-routes-rcvd
427 */
428 static struct yang_data *
429 ripngd_state_neighbors_neighbor_bad_routes_rcvd_get_elem(const char *xpath,
430 const void *list_entry)
431 {
432 /* TODO: implement me. */
433 return NULL;
434 }
435
436 /*
437 * XPath: /frr-ripngd:ripngd/state/routes/route
438 */
439 static const void *
440 ripngd_state_routes_route_get_next(const void *parent_list_entry,
441 const void *list_entry)
442 {
443 /* TODO: implement me. */
444 return NULL;
445 }
446
447 static int ripngd_state_routes_route_get_keys(const void *list_entry,
448 struct yang_list_keys *keys)
449 {
450 /* TODO: implement me. */
451 return NB_OK;
452 }
453
454 static const void *
455 ripngd_state_routes_route_lookup_entry(const void *parent_list_entry,
456 const struct yang_list_keys *keys)
457 {
458 /* TODO: implement me. */
459 return NULL;
460 }
461
462 /*
463 * XPath: /frr-ripngd:ripngd/state/routes/route/prefix
464 */
465 static struct yang_data *
466 ripngd_state_routes_route_prefix_get_elem(const char *xpath,
467 const void *list_entry)
468 {
469 /* TODO: implement me. */
470 return NULL;
471 }
472
473 /*
474 * XPath: /frr-ripngd:ripngd/state/routes/route/next-hop
475 */
476 static struct yang_data *
477 ripngd_state_routes_route_next_hop_get_elem(const char *xpath,
478 const void *list_entry)
479 {
480 /* TODO: implement me. */
481 return NULL;
482 }
483
484 /*
485 * XPath: /frr-ripngd:ripngd/state/routes/route/interface
486 */
487 static struct yang_data *
488 ripngd_state_routes_route_interface_get_elem(const char *xpath,
489 const void *list_entry)
490 {
491 /* TODO: implement me. */
492 return NULL;
493 }
494
495 /*
496 * XPath: /frr-ripngd:ripngd/state/routes/route/metric
497 */
498 static struct yang_data *
499 ripngd_state_routes_route_metric_get_elem(const char *xpath,
500 const void *list_entry)
501 {
502 /* TODO: implement me. */
503 return NULL;
504 }
505
506 /*
507 * XPath: /frr-ripngd:clear-ripng-route
508 */
509 static int clear_ripng_route_rpc(const char *xpath, const struct list *input,
510 struct list *output)
511 {
512 /* TODO: implement me. */
513 return NB_OK;
514 }
515
516 /*
517 * XPath: /frr-interface:lib/interface/frr-ripngd:ripng/split-horizon
518 */
519 static int
520 lib_interface_ripng_split_horizon_modify(enum nb_event event,
521 const struct lyd_node *dnode,
522 union nb_resource *resource)
523 {
524 /* TODO: implement me. */
525 return NB_OK;
526 }
527
528 /* clang-format off */
529 const struct frr_yang_module_info frr_ripngd_info = {
530 .name = "frr-ripngd",
531 .nodes = {
532 {
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,
537 },
538 {
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,
542 },
543 {
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,
547 },
548 {
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,
552 },
553 {
554 .xpath = "/frr-ripngd:ripngd/instance/network",
555 .cbs.create = ripngd_instance_network_create,
556 .cbs.delete = ripngd_instance_network_delete,
557 },
558 {
559 .xpath = "/frr-ripngd:ripngd/instance/interface",
560 .cbs.create = ripngd_instance_interface_create,
561 .cbs.delete = ripngd_instance_interface_delete,
562 },
563 {
564 .xpath = "/frr-ripngd:ripngd/instance/offset-list",
565 .cbs.create = ripngd_instance_offset_list_create,
566 .cbs.delete = ripngd_instance_offset_list_delete,
567 },
568 {
569 .xpath = "/frr-ripngd:ripngd/instance/offset-list/access-list",
570 .cbs.modify = ripngd_instance_offset_list_access_list_modify,
571 },
572 {
573 .xpath = "/frr-ripngd:ripngd/instance/offset-list/metric",
574 .cbs.modify = ripngd_instance_offset_list_metric_modify,
575 },
576 {
577 .xpath = "/frr-ripngd:ripngd/instance/passive-interface",
578 .cbs.create = ripngd_instance_passive_interface_create,
579 .cbs.delete = ripngd_instance_passive_interface_delete,
580 },
581 {
582 .xpath = "/frr-ripngd:ripngd/instance/redistribute",
583 .cbs.create = ripngd_instance_redistribute_create,
584 .cbs.delete = ripngd_instance_redistribute_delete,
585 },
586 {
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,
590 },
591 {
592 .xpath = "/frr-ripngd:ripngd/instance/redistribute/metric",
593 .cbs.modify = ripngd_instance_redistribute_metric_modify,
594 .cbs.delete = ripngd_instance_redistribute_metric_delete,
595 },
596 {
597 .xpath = "/frr-ripngd:ripngd/instance/static-route",
598 .cbs.create = ripngd_instance_static_route_create,
599 .cbs.delete = ripngd_instance_static_route_delete,
600 },
601 {
602 .xpath = "/frr-ripngd:ripngd/instance/aggregate-address",
603 .cbs.create = ripngd_instance_aggregate_address_create,
604 .cbs.delete = ripngd_instance_aggregate_address_delete,
605 },
606 {
607 .xpath = "/frr-ripngd:ripngd/instance/timers/flush-interval",
608 .cbs.modify = ripngd_instance_timers_flush_interval_modify,
609 },
610 {
611 .xpath = "/frr-ripngd:ripngd/instance/timers/holddown-interval",
612 .cbs.modify = ripngd_instance_timers_holddown_interval_modify,
613 },
614 {
615 .xpath = "/frr-ripngd:ripngd/instance/timers/update-interval",
616 .cbs.modify = ripngd_instance_timers_update_interval_modify,
617 },
618 {
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,
623 },
624 {
625 .xpath = "/frr-ripngd:ripngd/state/neighbors/neighbor/address",
626 .cbs.get_elem = ripngd_state_neighbors_neighbor_address_get_elem,
627 },
628 {
629 .xpath = "/frr-ripngd:ripngd/state/neighbors/neighbor/last-update",
630 .cbs.get_elem = ripngd_state_neighbors_neighbor_last_update_get_elem,
631 },
632 {
633 .xpath = "/frr-ripngd:ripngd/state/neighbors/neighbor/bad-packets-rcvd",
634 .cbs.get_elem = ripngd_state_neighbors_neighbor_bad_packets_rcvd_get_elem,
635 },
636 {
637 .xpath = "/frr-ripngd:ripngd/state/neighbors/neighbor/bad-routes-rcvd",
638 .cbs.get_elem = ripngd_state_neighbors_neighbor_bad_routes_rcvd_get_elem,
639 },
640 {
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,
645 },
646 {
647 .xpath = "/frr-ripngd:ripngd/state/routes/route/prefix",
648 .cbs.get_elem = ripngd_state_routes_route_prefix_get_elem,
649 },
650 {
651 .xpath = "/frr-ripngd:ripngd/state/routes/route/next-hop",
652 .cbs.get_elem = ripngd_state_routes_route_next_hop_get_elem,
653 },
654 {
655 .xpath = "/frr-ripngd:ripngd/state/routes/route/interface",
656 .cbs.get_elem = ripngd_state_routes_route_interface_get_elem,
657 },
658 {
659 .xpath = "/frr-ripngd:ripngd/state/routes/route/metric",
660 .cbs.get_elem = ripngd_state_routes_route_metric_get_elem,
661 },
662 {
663 .xpath = "/frr-ripngd:clear-ripng-route",
664 .cbs.rpc = clear_ripng_route_rpc,
665 },
666 {
667 .xpath = "/frr-interface:lib/interface/frr-ripngd:ripng/split-horizon",
668 .cbs.modify = lib_interface_ripng_split_horizon_modify,
669 },
670 {
671 .xpath = NULL,
672 },
673 }
674 };