]> git.proxmox.com Git - mirror_frr.git/blame - ripd/rip_nb_config.c
Merge pull request #5725 from ton31337/feature/doc_for_set_metric_increment_decrement
[mirror_frr.git] / ripd / rip_nb_config.c
CommitLineData
f80ec39e
RW
1/*
2 * Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro <kunihiro@zebra.org>
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 "ripd/ripd.h"
34#include "ripd/rip_nb.h"
35#include "ripd/rip_debug.h"
36#include "ripd/rip_interface.h"
37
38/*
39 * XPath: /frr-ripd:ripd/instance
40 */
41int ripd_instance_create(enum nb_event event, const struct lyd_node *dnode,
42 union nb_resource *resource)
43{
44 struct rip *rip;
45 struct vrf *vrf;
46 const char *vrf_name;
47 int socket;
48
49 vrf_name = yang_dnode_get_string(dnode, "./vrf");
50 vrf = vrf_lookup_by_name(vrf_name);
51
52 /*
53 * Try to create a RIP socket only if the VRF is enabled, otherwise
54 * create a disabled RIP instance and wait for the VRF to be enabled.
55 */
56 switch (event) {
57 case NB_EV_VALIDATE:
58 break;
59 case NB_EV_PREPARE:
60 if (!vrf || !vrf_is_enabled(vrf))
61 break;
62
63 socket = rip_create_socket(vrf);
64 if (socket < 0)
65 return NB_ERR_RESOURCE;
66 resource->fd = socket;
67 break;
68 case NB_EV_ABORT:
69 if (!vrf || !vrf_is_enabled(vrf))
70 break;
71
72 socket = resource->fd;
73 close(socket);
74 break;
75 case NB_EV_APPLY:
76 if (vrf && vrf_is_enabled(vrf))
77 socket = resource->fd;
78 else
79 socket = -1;
80
81 rip = rip_create(vrf_name, vrf, socket);
82 nb_running_set_entry(dnode, rip);
83 break;
84 }
85
86 return NB_OK;
87}
88
89int ripd_instance_destroy(enum nb_event event, const struct lyd_node *dnode)
90{
91 struct rip *rip;
92
93 if (event != NB_EV_APPLY)
94 return NB_OK;
95
96 rip = nb_running_unset_entry(dnode);
97 rip_clean(rip);
98
99 return NB_OK;
100}
101
102/*
103 * XPath: /frr-ripd:ripd/instance/allow-ecmp
104 */
105int ripd_instance_allow_ecmp_modify(enum nb_event event,
106 const struct lyd_node *dnode,
107 union nb_resource *resource)
108{
109 struct rip *rip;
110
111 if (event != NB_EV_APPLY)
112 return NB_OK;
113
114 rip = nb_running_get_entry(dnode, NULL, true);
115 rip->ecmp = yang_dnode_get_bool(dnode, NULL);
116 if (!rip->ecmp)
117 rip_ecmp_disable(rip);
118
119 return NB_OK;
120}
121
122/*
123 * XPath: /frr-ripd:ripd/instance/default-information-originate
124 */
125int ripd_instance_default_information_originate_modify(
126 enum nb_event event, const struct lyd_node *dnode,
127 union nb_resource *resource)
128{
129 struct rip *rip;
130 bool default_information;
131 struct prefix_ipv4 p;
132
133 if (event != NB_EV_APPLY)
134 return NB_OK;
135
136 rip = nb_running_get_entry(dnode, NULL, true);
137 default_information = yang_dnode_get_bool(dnode, NULL);
138
139 memset(&p, 0, sizeof(struct prefix_ipv4));
140 p.family = AF_INET;
141 if (default_information) {
142 struct nexthop nh;
143
144 memset(&nh, 0, sizeof(nh));
145 nh.type = NEXTHOP_TYPE_IPV4;
146 rip_redistribute_add(rip, ZEBRA_ROUTE_RIP, RIP_ROUTE_DEFAULT,
147 &p, &nh, 0, 0, 0);
148 } else {
149 rip_redistribute_delete(rip, ZEBRA_ROUTE_RIP, RIP_ROUTE_DEFAULT,
150 &p, 0);
151 }
152
153 return NB_OK;
154}
155
156/*
157 * XPath: /frr-ripd:ripd/instance/default-metric
158 */
159int ripd_instance_default_metric_modify(enum nb_event event,
160 const struct lyd_node *dnode,
161 union nb_resource *resource)
162{
163 struct rip *rip;
164
165 if (event != NB_EV_APPLY)
166 return NB_OK;
167
168 rip = nb_running_get_entry(dnode, NULL, true);
169 rip->default_metric = yang_dnode_get_uint8(dnode, NULL);
170 /* rip_update_default_metric (); */
171
172 return NB_OK;
173}
174
175/*
176 * XPath: /frr-ripd:ripd/instance/distance/default
177 */
178int ripd_instance_distance_default_modify(enum nb_event event,
179 const struct lyd_node *dnode,
180 union nb_resource *resource)
181{
182 struct rip *rip;
183
184 if (event != NB_EV_APPLY)
185 return NB_OK;
186
187 rip = nb_running_get_entry(dnode, NULL, true);
188 rip->distance = yang_dnode_get_uint8(dnode, NULL);
189
190 return NB_OK;
191}
192
193/*
194 * XPath: /frr-ripd:ripd/instance/distance/source
195 */
196int ripd_instance_distance_source_create(enum nb_event event,
197 const struct lyd_node *dnode,
198 union nb_resource *resource)
199{
200 struct rip *rip;
201 struct prefix_ipv4 prefix;
202 struct route_node *rn;
203
204 if (event != NB_EV_APPLY)
205 return NB_OK;
206
207 yang_dnode_get_ipv4p(&prefix, dnode, "./prefix");
208 apply_mask_ipv4(&prefix);
209
210 /* Get RIP distance node. */
211 rip = nb_running_get_entry(dnode, NULL, true);
212 rn = route_node_get(rip->distance_table, (struct prefix *)&prefix);
213 rn->info = rip_distance_new();
214 nb_running_set_entry(dnode, rn);
215
216 return NB_OK;
217}
218
219int ripd_instance_distance_source_destroy(enum nb_event event,
220 const struct lyd_node *dnode)
221{
222 struct route_node *rn;
223 struct rip_distance *rdistance;
224
225 if (event != NB_EV_APPLY)
226 return NB_OK;
227
228 rn = nb_running_unset_entry(dnode);
229 rdistance = rn->info;
230 rip_distance_free(rdistance);
231 rn->info = NULL;
232 route_unlock_node(rn);
233
234 return NB_OK;
235}
236
237/*
238 * XPath: /frr-ripd:ripd/instance/distance/source/distance
239 */
240int ripd_instance_distance_source_distance_modify(enum nb_event event,
241 const struct lyd_node *dnode,
242 union nb_resource *resource)
243{
244 struct route_node *rn;
245 uint8_t distance;
246 struct rip_distance *rdistance;
247
248 if (event != NB_EV_APPLY)
249 return NB_OK;
250
251 /* Set distance value. */
252 rn = nb_running_get_entry(dnode, NULL, true);
253 distance = yang_dnode_get_uint8(dnode, NULL);
254 rdistance = rn->info;
255 rdistance->distance = distance;
256
257 return NB_OK;
258}
259
260/*
261 * XPath: /frr-ripd:ripd/instance/distance/source/access-list
262 */
263int ripd_instance_distance_source_access_list_modify(
264 enum nb_event event, const struct lyd_node *dnode,
265 union nb_resource *resource)
266{
267 const char *acl_name;
268 struct route_node *rn;
269 struct rip_distance *rdistance;
270
271 if (event != NB_EV_APPLY)
272 return NB_OK;
273
274 acl_name = yang_dnode_get_string(dnode, NULL);
275
276 /* Set access-list */
277 rn = nb_running_get_entry(dnode, NULL, true);
278 rdistance = rn->info;
279 if (rdistance->access_list)
280 free(rdistance->access_list);
281 rdistance->access_list = strdup(acl_name);
282
283 return NB_OK;
284}
285
286int ripd_instance_distance_source_access_list_destroy(
287 enum nb_event event, const struct lyd_node *dnode)
288{
289 struct route_node *rn;
290 struct rip_distance *rdistance;
291
292 if (event != NB_EV_APPLY)
293 return NB_OK;
294
295 /* Reset access-list configuration. */
296 rn = nb_running_get_entry(dnode, NULL, true);
297 rdistance = rn->info;
298 free(rdistance->access_list);
299 rdistance->access_list = NULL;
300
301 return NB_OK;
302}
303
304/*
305 * XPath: /frr-ripd:ripd/instance/explicit-neighbor
306 */
307int ripd_instance_explicit_neighbor_create(enum nb_event event,
308 const struct lyd_node *dnode,
309 union nb_resource *resource)
310{
311 struct rip *rip;
312 struct prefix_ipv4 p;
313
314 if (event != NB_EV_APPLY)
315 return NB_OK;
316
317 rip = nb_running_get_entry(dnode, NULL, true);
318 p.family = AF_INET;
319 p.prefixlen = IPV4_MAX_BITLEN;
320 yang_dnode_get_ipv4(&p.prefix, dnode, NULL);
321
322 return rip_neighbor_add(rip, &p);
323}
324
325int ripd_instance_explicit_neighbor_destroy(enum nb_event event,
326 const struct lyd_node *dnode)
327{
328 struct rip *rip;
329 struct prefix_ipv4 p;
330
331 if (event != NB_EV_APPLY)
332 return NB_OK;
333
334 rip = nb_running_get_entry(dnode, NULL, true);
335 p.family = AF_INET;
336 p.prefixlen = IPV4_MAX_BITLEN;
337 yang_dnode_get_ipv4(&p.prefix, dnode, NULL);
338
339 return rip_neighbor_delete(rip, &p);
340}
341
342/*
343 * XPath: /frr-ripd:ripd/instance/network
344 */
345int ripd_instance_network_create(enum nb_event event,
346 const struct lyd_node *dnode,
347 union nb_resource *resource)
348{
349 struct rip *rip;
350 struct prefix p;
351
352 if (event != NB_EV_APPLY)
353 return NB_OK;
354
355 rip = nb_running_get_entry(dnode, NULL, true);
356 yang_dnode_get_ipv4p(&p, dnode, NULL);
357 apply_mask_ipv4((struct prefix_ipv4 *)&p);
358
359 return rip_enable_network_add(rip, &p);
360}
361
362int ripd_instance_network_destroy(enum nb_event event,
363 const struct lyd_node *dnode)
364{
365 struct rip *rip;
366 struct prefix p;
367
368 if (event != NB_EV_APPLY)
369 return NB_OK;
370
371 rip = nb_running_get_entry(dnode, NULL, true);
372 yang_dnode_get_ipv4p(&p, dnode, NULL);
373 apply_mask_ipv4((struct prefix_ipv4 *)&p);
374
375 return rip_enable_network_delete(rip, &p);
376}
377
378/*
379 * XPath: /frr-ripd:ripd/instance/interface
380 */
381int ripd_instance_interface_create(enum nb_event event,
382 const struct lyd_node *dnode,
383 union nb_resource *resource)
384{
385 struct rip *rip;
386 const char *ifname;
387
388 if (event != NB_EV_APPLY)
389 return NB_OK;
390
391 rip = nb_running_get_entry(dnode, NULL, true);
392 ifname = yang_dnode_get_string(dnode, NULL);
393
394 return rip_enable_if_add(rip, ifname);
395}
396
397int ripd_instance_interface_destroy(enum nb_event event,
398 const struct lyd_node *dnode)
399{
400 struct rip *rip;
401 const char *ifname;
402
403 if (event != NB_EV_APPLY)
404 return NB_OK;
405
406 rip = nb_running_get_entry(dnode, NULL, true);
407 ifname = yang_dnode_get_string(dnode, NULL);
408
409 return rip_enable_if_delete(rip, ifname);
410}
411
412/*
413 * XPath: /frr-ripd:ripd/instance/offset-list
414 */
415int ripd_instance_offset_list_create(enum nb_event event,
416 const struct lyd_node *dnode,
417 union nb_resource *resource)
418{
419 struct rip *rip;
420 const char *ifname;
421 struct rip_offset_list *offset;
422
423 if (event != NB_EV_APPLY)
424 return NB_OK;
425
426 rip = nb_running_get_entry(dnode, NULL, true);
427 ifname = yang_dnode_get_string(dnode, "./interface");
428
429 offset = rip_offset_list_new(rip, ifname);
430 nb_running_set_entry(dnode, offset);
431
432 return NB_OK;
433}
434
435int ripd_instance_offset_list_destroy(enum nb_event event,
436 const struct lyd_node *dnode)
437{
438 int direct;
439 struct rip_offset_list *offset;
440
441 if (event != NB_EV_APPLY)
442 return NB_OK;
443
444 direct = yang_dnode_get_enum(dnode, "./direction");
445
446 offset = nb_running_unset_entry(dnode);
447 if (offset->direct[direct].alist_name) {
448 free(offset->direct[direct].alist_name);
449 offset->direct[direct].alist_name = NULL;
450 }
451 if (offset->direct[RIP_OFFSET_LIST_IN].alist_name == NULL
452 && offset->direct[RIP_OFFSET_LIST_OUT].alist_name == NULL)
453 offset_list_del(offset);
454
455 return NB_OK;
456}
457
458/*
459 * XPath: /frr-ripd:ripd/instance/offset-list/access-list
460 */
461int ripd_instance_offset_list_access_list_modify(enum nb_event event,
462 const struct lyd_node *dnode,
463 union nb_resource *resource)
464{
465 int direct;
466 struct rip_offset_list *offset;
467 const char *alist_name;
468
469 if (event != NB_EV_APPLY)
470 return NB_OK;
471
472 direct = yang_dnode_get_enum(dnode, "../direction");
473 alist_name = yang_dnode_get_string(dnode, NULL);
474
475 offset = nb_running_get_entry(dnode, NULL, true);
476 if (offset->direct[direct].alist_name)
477 free(offset->direct[direct].alist_name);
478 offset->direct[direct].alist_name = strdup(alist_name);
479
480 return NB_OK;
481}
482
483/*
484 * XPath: /frr-ripd:ripd/instance/offset-list/metric
485 */
486int ripd_instance_offset_list_metric_modify(enum nb_event event,
487 const struct lyd_node *dnode,
488 union nb_resource *resource)
489{
490 int direct;
491 uint8_t metric;
492 struct rip_offset_list *offset;
493
494 if (event != NB_EV_APPLY)
495 return NB_OK;
496
497 direct = yang_dnode_get_enum(dnode, "../direction");
498 metric = yang_dnode_get_uint8(dnode, NULL);
499
500 offset = nb_running_get_entry(dnode, NULL, true);
501 offset->direct[direct].metric = metric;
502
503 return NB_OK;
504}
505
506/*
507 * XPath: /frr-ripd:ripd/instance/passive-default
508 */
509int ripd_instance_passive_default_modify(enum nb_event event,
510 const struct lyd_node *dnode,
511 union nb_resource *resource)
512{
513 struct rip *rip;
514
515 if (event != NB_EV_APPLY)
516 return NB_OK;
517
518 rip = nb_running_get_entry(dnode, NULL, true);
519 rip->passive_default = yang_dnode_get_bool(dnode, NULL);
520 rip_passive_nondefault_clean(rip);
521
522 return NB_OK;
523}
524
525/*
526 * XPath: /frr-ripd:ripd/instance/passive-interface
527 */
528int ripd_instance_passive_interface_create(enum nb_event event,
529 const struct lyd_node *dnode,
530 union nb_resource *resource)
531{
532 struct rip *rip;
533 const char *ifname;
534
535 if (event != NB_EV_APPLY)
536 return NB_OK;
537
538 rip = nb_running_get_entry(dnode, NULL, true);
539 ifname = yang_dnode_get_string(dnode, NULL);
540
541 return rip_passive_nondefault_set(rip, ifname);
542}
543
544int ripd_instance_passive_interface_destroy(enum nb_event event,
545 const struct lyd_node *dnode)
546{
547 struct rip *rip;
548 const char *ifname;
549
550 if (event != NB_EV_APPLY)
551 return NB_OK;
552
553 rip = nb_running_get_entry(dnode, NULL, true);
554 ifname = yang_dnode_get_string(dnode, NULL);
555
556 return rip_passive_nondefault_unset(rip, ifname);
557}
558
559/*
560 * XPath: /frr-ripd:ripd/instance/non-passive-interface
561 */
562int ripd_instance_non_passive_interface_create(enum nb_event event,
563 const struct lyd_node *dnode,
564 union nb_resource *resource)
565{
566 struct rip *rip;
567 const char *ifname;
568
569 if (event != NB_EV_APPLY)
570 return NB_OK;
571
572 rip = nb_running_get_entry(dnode, NULL, true);
573 ifname = yang_dnode_get_string(dnode, NULL);
574
575 return rip_passive_nondefault_unset(rip, ifname);
576}
577
578int ripd_instance_non_passive_interface_destroy(enum nb_event event,
579 const struct lyd_node *dnode)
580{
581 struct rip *rip;
582 const char *ifname;
583
584 if (event != NB_EV_APPLY)
585 return NB_OK;
586
587 rip = nb_running_get_entry(dnode, NULL, true);
588 ifname = yang_dnode_get_string(dnode, NULL);
589
590 return rip_passive_nondefault_set(rip, ifname);
591}
592
593/*
594 * XPath: /frr-ripd:ripd/instance/redistribute
595 */
596int ripd_instance_redistribute_create(enum nb_event event,
597 const struct lyd_node *dnode,
598 union nb_resource *resource)
599{
600 struct rip *rip;
601 int type;
602
603 if (event != NB_EV_APPLY)
604 return NB_OK;
605
606 rip = nb_running_get_entry(dnode, NULL, true);
607 type = yang_dnode_get_enum(dnode, "./protocol");
608
609 rip->redist[type].enabled = true;
610
611 return NB_OK;
612}
613
614int ripd_instance_redistribute_destroy(enum nb_event event,
615 const struct lyd_node *dnode)
616{
617 struct rip *rip;
618 int type;
619
620 if (event != NB_EV_APPLY)
621 return NB_OK;
622
623 rip = nb_running_get_entry(dnode, NULL, true);
624 type = yang_dnode_get_enum(dnode, "./protocol");
625
626 rip->redist[type].enabled = false;
627 if (rip->redist[type].route_map.name) {
628 free(rip->redist[type].route_map.name);
629 rip->redist[type].route_map.name = NULL;
630 rip->redist[type].route_map.map = NULL;
631 }
632 rip->redist[type].metric_config = false;
633 rip->redist[type].metric = 0;
634
635 if (rip->enabled)
636 rip_redistribute_conf_delete(rip, type);
637
638 return NB_OK;
639}
640
641void ripd_instance_redistribute_apply_finish(const struct lyd_node *dnode)
642{
643 struct rip *rip;
644 int type;
645
646 rip = nb_running_get_entry(dnode, NULL, true);
647 type = yang_dnode_get_enum(dnode, "./protocol");
648
649 if (rip->enabled)
650 rip_redistribute_conf_update(rip, type);
651}
652
653/*
654 * XPath: /frr-ripd:ripd/instance/redistribute/route-map
655 */
656int ripd_instance_redistribute_route_map_modify(enum nb_event event,
657 const struct lyd_node *dnode,
658 union nb_resource *resource)
659{
660 struct rip *rip;
661 int type;
662 const char *rmap_name;
663
664 if (event != NB_EV_APPLY)
665 return NB_OK;
666
667 rip = nb_running_get_entry(dnode, NULL, true);
668 type = yang_dnode_get_enum(dnode, "../protocol");
669 rmap_name = yang_dnode_get_string(dnode, NULL);
670
671 if (rip->redist[type].route_map.name)
672 free(rip->redist[type].route_map.name);
673 rip->redist[type].route_map.name = strdup(rmap_name);
674 rip->redist[type].route_map.map = route_map_lookup_by_name(rmap_name);
675
676 return NB_OK;
677}
678
679int ripd_instance_redistribute_route_map_destroy(enum nb_event event,
680 const struct lyd_node *dnode)
681{
682 struct rip *rip;
683 int type;
684
685 if (event != NB_EV_APPLY)
686 return NB_OK;
687
688 rip = nb_running_get_entry(dnode, NULL, true);
689 type = yang_dnode_get_enum(dnode, "../protocol");
690
691 free(rip->redist[type].route_map.name);
692 rip->redist[type].route_map.name = NULL;
693 rip->redist[type].route_map.map = NULL;
694
695 return NB_OK;
696}
697
698/*
699 * XPath: /frr-ripd:ripd/instance/redistribute/metric
700 */
701int ripd_instance_redistribute_metric_modify(enum nb_event event,
702 const struct lyd_node *dnode,
703 union nb_resource *resource)
704{
705 struct rip *rip;
706 int type;
707 uint8_t metric;
708
709 if (event != NB_EV_APPLY)
710 return NB_OK;
711
712 rip = nb_running_get_entry(dnode, NULL, true);
713 type = yang_dnode_get_enum(dnode, "../protocol");
714 metric = yang_dnode_get_uint8(dnode, NULL);
715
716 rip->redist[type].metric_config = true;
717 rip->redist[type].metric = metric;
718
719 return NB_OK;
720}
721
722int ripd_instance_redistribute_metric_destroy(enum nb_event event,
723 const struct lyd_node *dnode)
724{
725 struct rip *rip;
726 int type;
727
728 if (event != NB_EV_APPLY)
729 return NB_OK;
730
731 rip = nb_running_get_entry(dnode, NULL, true);
732 type = yang_dnode_get_enum(dnode, "../protocol");
733
734 rip->redist[type].metric_config = false;
735 rip->redist[type].metric = 0;
736
737 return NB_OK;
738}
739
740/*
741 * XPath: /frr-ripd:ripd/instance/static-route
742 */
743int ripd_instance_static_route_create(enum nb_event event,
744 const struct lyd_node *dnode,
745 union nb_resource *resource)
746{
747 struct rip *rip;
748 struct nexthop nh;
749 struct prefix_ipv4 p;
750
751 if (event != NB_EV_APPLY)
752 return NB_OK;
753
754 rip = nb_running_get_entry(dnode, NULL, true);
755 yang_dnode_get_ipv4p(&p, dnode, NULL);
756 apply_mask_ipv4(&p);
757
758 memset(&nh, 0, sizeof(nh));
759 nh.type = NEXTHOP_TYPE_IPV4;
760 rip_redistribute_add(rip, ZEBRA_ROUTE_RIP, RIP_ROUTE_STATIC, &p, &nh, 0,
761 0, 0);
762
763 return NB_OK;
764}
765
766int ripd_instance_static_route_destroy(enum nb_event event,
767 const struct lyd_node *dnode)
768{
769 struct rip *rip;
770 struct prefix_ipv4 p;
771
772 if (event != NB_EV_APPLY)
773 return NB_OK;
774
775 rip = nb_running_get_entry(dnode, NULL, true);
776 yang_dnode_get_ipv4p(&p, dnode, NULL);
777 apply_mask_ipv4(&p);
778
779 rip_redistribute_delete(rip, ZEBRA_ROUTE_RIP, RIP_ROUTE_STATIC, &p, 0);
780
781 return NB_OK;
782}
783
784/*
785 * XPath: /frr-ripd:ripd/instance/timers/
786 */
787void ripd_instance_timers_apply_finish(const struct lyd_node *dnode)
788{
789 struct rip *rip;
790
791 rip = nb_running_get_entry(dnode, NULL, true);
792
793 /* Reset update timer thread. */
794 rip_event(rip, RIP_UPDATE_EVENT, 0);
795}
796
797/*
798 * XPath: /frr-ripd:ripd/instance/timers/flush-interval
799 */
800int ripd_instance_timers_flush_interval_modify(enum nb_event event,
801 const struct lyd_node *dnode,
802 union nb_resource *resource)
803{
804 struct rip *rip;
805
806 if (event != NB_EV_APPLY)
807 return NB_OK;
808
809 rip = nb_running_get_entry(dnode, NULL, true);
810 rip->garbage_time = yang_dnode_get_uint32(dnode, NULL);
811
812 return NB_OK;
813}
814
815/*
816 * XPath: /frr-ripd:ripd/instance/timers/holddown-interval
817 */
818int ripd_instance_timers_holddown_interval_modify(enum nb_event event,
819 const struct lyd_node *dnode,
820 union nb_resource *resource)
821{
822 struct rip *rip;
823
824 if (event != NB_EV_APPLY)
825 return NB_OK;
826
827 rip = nb_running_get_entry(dnode, NULL, true);
828 rip->timeout_time = yang_dnode_get_uint32(dnode, NULL);
829
830 return NB_OK;
831}
832
833/*
834 * XPath: /frr-ripd:ripd/instance/timers/update-interval
835 */
836int ripd_instance_timers_update_interval_modify(enum nb_event event,
837 const struct lyd_node *dnode,
838 union nb_resource *resource)
839{
840 struct rip *rip;
841
842 if (event != NB_EV_APPLY)
843 return NB_OK;
844
845 rip = nb_running_get_entry(dnode, NULL, true);
846 rip->update_time = yang_dnode_get_uint32(dnode, NULL);
847
848 return NB_OK;
849}
850
851/*
852 * XPath: /frr-ripd:ripd/instance/version/receive
853 */
854int ripd_instance_version_receive_modify(enum nb_event event,
855 const struct lyd_node *dnode,
856 union nb_resource *resource)
857{
858 struct rip *rip;
859
860 if (event != NB_EV_APPLY)
861 return NB_OK;
862
863 rip = nb_running_get_entry(dnode, NULL, true);
864 rip->version_recv = yang_dnode_get_enum(dnode, NULL);
865
866 return NB_OK;
867}
868
869/*
870 * XPath: /frr-ripd:ripd/instance/version/send
871 */
872int ripd_instance_version_send_modify(enum nb_event event,
873 const struct lyd_node *dnode,
874 union nb_resource *resource)
875{
876 struct rip *rip;
877
878 if (event != NB_EV_APPLY)
879 return NB_OK;
880
881 rip = nb_running_get_entry(dnode, NULL, true);
882 rip->version_send = yang_dnode_get_enum(dnode, NULL);
883
884 return NB_OK;
885}
886
887/*
888 * XPath: /frr-interface:lib/interface/frr-ripd:rip/split-horizon
889 */
890int lib_interface_rip_split_horizon_modify(enum nb_event event,
891 const struct lyd_node *dnode,
892 union nb_resource *resource)
893{
894 struct interface *ifp;
895 struct rip_interface *ri;
896
897 if (event != NB_EV_APPLY)
898 return NB_OK;
899
900 ifp = nb_running_get_entry(dnode, NULL, true);
901 ri = ifp->info;
902 ri->split_horizon = yang_dnode_get_enum(dnode, NULL);
903
904 return NB_OK;
905}
906
907/*
908 * XPath: /frr-interface:lib/interface/frr-ripd:rip/v2-broadcast
909 */
910int lib_interface_rip_v2_broadcast_modify(enum nb_event event,
911 const struct lyd_node *dnode,
912 union nb_resource *resource)
913{
914 struct interface *ifp;
915 struct rip_interface *ri;
916
917 if (event != NB_EV_APPLY)
918 return NB_OK;
919
920 ifp = nb_running_get_entry(dnode, NULL, true);
921 ri = ifp->info;
922 ri->v2_broadcast = yang_dnode_get_bool(dnode, NULL);
923
924 return NB_OK;
925}
926
927/*
928 * XPath: /frr-interface:lib/interface/frr-ripd:rip/version-receive
929 */
930int lib_interface_rip_version_receive_modify(enum nb_event event,
931 const struct lyd_node *dnode,
932 union nb_resource *resource)
933{
934 struct interface *ifp;
935 struct rip_interface *ri;
936
937 if (event != NB_EV_APPLY)
938 return NB_OK;
939
940 ifp = nb_running_get_entry(dnode, NULL, true);
941 ri = ifp->info;
942 ri->ri_receive = yang_dnode_get_enum(dnode, NULL);
943
944 return NB_OK;
945}
946
947/*
948 * XPath: /frr-interface:lib/interface/frr-ripd:rip/version-send
949 */
950int lib_interface_rip_version_send_modify(enum nb_event event,
951 const struct lyd_node *dnode,
952 union nb_resource *resource)
953{
954 struct interface *ifp;
955 struct rip_interface *ri;
956
957 if (event != NB_EV_APPLY)
958 return NB_OK;
959
960 ifp = nb_running_get_entry(dnode, NULL, true);
961 ri = ifp->info;
962 ri->ri_send = yang_dnode_get_enum(dnode, NULL);
963
964 return NB_OK;
965}
966
967/*
968 * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-scheme/mode
969 */
970int lib_interface_rip_authentication_scheme_mode_modify(
971 enum nb_event event, const struct lyd_node *dnode,
972 union nb_resource *resource)
973{
974 struct interface *ifp;
975 struct rip_interface *ri;
976
977 if (event != NB_EV_APPLY)
978 return NB_OK;
979
980 ifp = nb_running_get_entry(dnode, NULL, true);
981 ri = ifp->info;
982 ri->auth_type = yang_dnode_get_enum(dnode, NULL);
983
984 return NB_OK;
985}
986
987/*
988 * XPath:
989 * /frr-interface:lib/interface/frr-ripd:rip/authentication-scheme/md5-auth-length
990 */
991int lib_interface_rip_authentication_scheme_md5_auth_length_modify(
992 enum nb_event event, const struct lyd_node *dnode,
993 union nb_resource *resource)
994{
995 struct interface *ifp;
996 struct rip_interface *ri;
997
998 if (event != NB_EV_APPLY)
999 return NB_OK;
1000
1001 ifp = nb_running_get_entry(dnode, NULL, true);
1002 ri = ifp->info;
1003 ri->md5_auth_len = yang_dnode_get_enum(dnode, NULL);
1004
1005 return NB_OK;
1006}
1007
1008int lib_interface_rip_authentication_scheme_md5_auth_length_destroy(
1009 enum nb_event event, const struct lyd_node *dnode)
1010{
1011 struct interface *ifp;
1012 struct rip_interface *ri;
1013
1014 if (event != NB_EV_APPLY)
1015 return NB_OK;
1016
1017 ifp = nb_running_get_entry(dnode, NULL, true);
1018 ri = ifp->info;
1019 ri->md5_auth_len = yang_get_default_enum(
1020 "%s/authentication-scheme/md5-auth-length", RIP_IFACE);
1021
1022 return NB_OK;
1023}
1024
1025/*
1026 * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-password
1027 */
1028int lib_interface_rip_authentication_password_modify(
1029 enum nb_event event, const struct lyd_node *dnode,
1030 union nb_resource *resource)
1031{
1032 struct interface *ifp;
1033 struct rip_interface *ri;
1034
1035 if (event != NB_EV_APPLY)
1036 return NB_OK;
1037
1038 ifp = nb_running_get_entry(dnode, NULL, true);
1039 ri = ifp->info;
1040 XFREE(MTYPE_RIP_INTERFACE_STRING, ri->auth_str);
1041 ri->auth_str = XSTRDUP(MTYPE_RIP_INTERFACE_STRING,
1042 yang_dnode_get_string(dnode, NULL));
1043
1044 return NB_OK;
1045}
1046
1047int lib_interface_rip_authentication_password_destroy(
1048 enum nb_event event, const struct lyd_node *dnode)
1049{
1050 struct interface *ifp;
1051 struct rip_interface *ri;
1052
1053 if (event != NB_EV_APPLY)
1054 return NB_OK;
1055
1056 ifp = nb_running_get_entry(dnode, NULL, true);
1057 ri = ifp->info;
1058 XFREE(MTYPE_RIP_INTERFACE_STRING, ri->auth_str);
1059
1060 return NB_OK;
1061}
1062
1063/*
1064 * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-key-chain
1065 */
1066int lib_interface_rip_authentication_key_chain_modify(
1067 enum nb_event event, const struct lyd_node *dnode,
1068 union nb_resource *resource)
1069{
1070 struct interface *ifp;
1071 struct rip_interface *ri;
1072
1073 if (event != NB_EV_APPLY)
1074 return NB_OK;
1075
1076 ifp = nb_running_get_entry(dnode, NULL, true);
1077 ri = ifp->info;
1078 XFREE(MTYPE_RIP_INTERFACE_STRING, ri->key_chain);
1079 ri->key_chain = XSTRDUP(MTYPE_RIP_INTERFACE_STRING,
1080 yang_dnode_get_string(dnode, NULL));
1081
1082 return NB_OK;
1083}
1084
1085int lib_interface_rip_authentication_key_chain_destroy(
1086 enum nb_event event, const struct lyd_node *dnode)
1087{
1088 struct interface *ifp;
1089 struct rip_interface *ri;
1090
1091 if (event != NB_EV_APPLY)
1092 return NB_OK;
1093
1094 ifp = nb_running_get_entry(dnode, NULL, true);
1095 ri = ifp->info;
1096 XFREE(MTYPE_RIP_INTERFACE_STRING, ri->key_chain);
1097
1098 return NB_OK;
1099}