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