]>
Commit | Line | Data |
---|---|---|
707656ec 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" | |
908f0020 | 29 | #include "routemap.h" |
707656ec RW |
30 | #include "northbound.h" |
31 | #include "libfrr.h" | |
32 | ||
33 | #include "ripd/ripd.h" | |
14f17e63 | 34 | #include "ripd/rip_debug.h" |
707656ec | 35 | #include "ripd/rip_cli.h" |
814a2585 | 36 | #include "ripd/rip_interface.h" |
707656ec RW |
37 | |
38 | /* | |
39 | * XPath: /frr-ripd:ripd/instance | |
40 | */ | |
41 | static int ripd_instance_create(enum nb_event event, | |
42 | const struct lyd_node *dnode, | |
43 | union nb_resource *resource) | |
44 | { | |
045c5389 RW |
45 | struct rip *rip; |
46 | struct vrf *vrf; | |
ae7b826a | 47 | const char *vrf_name; |
8c9226c2 RW |
48 | int socket; |
49 | ||
ae7b826a RW |
50 | vrf_name = yang_dnode_get_string(dnode, "./vrf"); |
51 | vrf = vrf_lookup_by_name(vrf_name); | |
52 | ||
53 | /* | |
54 | * Try to create a RIP socket only if the VRF is enabled, otherwise | |
55 | * create a disabled RIP instance and wait for the VRF to be enabled. | |
56 | */ | |
8c9226c2 RW |
57 | switch (event) { |
58 | case NB_EV_VALIDATE: | |
59 | break; | |
60 | case NB_EV_PREPARE: | |
ae7b826a RW |
61 | if (!vrf || !vrf_is_enabled(vrf)) |
62 | break; | |
63 | ||
64 | socket = rip_create_socket(vrf); | |
8c9226c2 RW |
65 | if (socket < 0) |
66 | return NB_ERR_RESOURCE; | |
67 | resource->fd = socket; | |
68 | break; | |
69 | case NB_EV_ABORT: | |
ae7b826a RW |
70 | if (!vrf || !vrf_is_enabled(vrf)) |
71 | break; | |
72 | ||
8c9226c2 RW |
73 | socket = resource->fd; |
74 | close(socket); | |
75 | break; | |
76 | case NB_EV_APPLY: | |
ae7b826a RW |
77 | if (vrf && vrf_is_enabled(vrf)) |
78 | socket = resource->fd; | |
79 | else | |
80 | socket = -1; | |
81 | ||
82 | rip = rip_create(vrf_name, vrf, socket); | |
ccd43ada | 83 | nb_running_set_entry(dnode, rip); |
8c9226c2 RW |
84 | break; |
85 | } | |
86 | ||
707656ec RW |
87 | return NB_OK; |
88 | } | |
89 | ||
6a3fdeec RW |
90 | static int ripd_instance_destroy(enum nb_event event, |
91 | const struct lyd_node *dnode) | |
707656ec | 92 | { |
045c5389 RW |
93 | struct rip *rip; |
94 | ||
8c9226c2 RW |
95 | if (event != NB_EV_APPLY) |
96 | return NB_OK; | |
97 | ||
ccd43ada | 98 | rip = nb_running_unset_entry(dnode); |
045c5389 | 99 | rip_clean(rip); |
8c9226c2 | 100 | |
707656ec RW |
101 | return NB_OK; |
102 | } | |
103 | ||
32600a98 RW |
104 | static const void *ripd_instance_get_next(const void *parent_list_entry, |
105 | const void *list_entry) | |
106 | { | |
c7405ee2 | 107 | struct rip *rip = (struct rip *)list_entry; |
32600a98 RW |
108 | |
109 | if (list_entry == NULL) | |
110 | rip = RB_MIN(rip_instance_head, &rip_instances); | |
111 | else | |
c7405ee2 | 112 | rip = RB_NEXT(rip_instance_head, rip); |
32600a98 RW |
113 | |
114 | return rip; | |
115 | } | |
116 | ||
117 | static int ripd_instance_get_keys(const void *list_entry, | |
118 | struct yang_list_keys *keys) | |
119 | { | |
120 | const struct rip *rip = list_entry; | |
121 | ||
122 | keys->num = 1; | |
123 | strlcpy(keys->key[0], rip->vrf_name, sizeof(keys->key[0])); | |
124 | ||
125 | return NB_OK; | |
126 | } | |
127 | ||
128 | static const void *ripd_instance_lookup_entry(const void *parent_list_entry, | |
129 | const struct yang_list_keys *keys) | |
130 | { | |
131 | const char *vrf_name = keys->key[0]; | |
132 | ||
133 | return rip_lookup_by_vrf_name(vrf_name); | |
134 | } | |
135 | ||
707656ec RW |
136 | /* |
137 | * XPath: /frr-ripd:ripd/instance/allow-ecmp | |
138 | */ | |
139 | static int ripd_instance_allow_ecmp_modify(enum nb_event event, | |
140 | const struct lyd_node *dnode, | |
141 | union nb_resource *resource) | |
142 | { | |
045c5389 RW |
143 | struct rip *rip; |
144 | ||
edbf59d2 RW |
145 | if (event != NB_EV_APPLY) |
146 | return NB_OK; | |
147 | ||
ccd43ada | 148 | rip = nb_running_get_entry(dnode, NULL, true); |
edbf59d2 RW |
149 | rip->ecmp = yang_dnode_get_bool(dnode, NULL); |
150 | if (!rip->ecmp) | |
045c5389 | 151 | rip_ecmp_disable(rip); |
edbf59d2 | 152 | |
707656ec RW |
153 | return NB_OK; |
154 | } | |
155 | ||
156 | /* | |
157 | * XPath: /frr-ripd:ripd/instance/default-information-originate | |
158 | */ | |
159 | static int | |
160 | ripd_instance_default_information_originate_modify(enum nb_event event, | |
161 | const struct lyd_node *dnode, | |
162 | union nb_resource *resource) | |
163 | { | |
045c5389 | 164 | struct rip *rip; |
0b0609ba RW |
165 | bool default_information; |
166 | struct prefix_ipv4 p; | |
167 | ||
168 | if (event != NB_EV_APPLY) | |
169 | return NB_OK; | |
170 | ||
ccd43ada | 171 | rip = nb_running_get_entry(dnode, NULL, true); |
0b0609ba RW |
172 | default_information = yang_dnode_get_bool(dnode, NULL); |
173 | ||
174 | memset(&p, 0, sizeof(struct prefix_ipv4)); | |
175 | p.family = AF_INET; | |
176 | if (default_information) { | |
177 | struct nexthop nh; | |
178 | ||
179 | memset(&nh, 0, sizeof(nh)); | |
180 | nh.type = NEXTHOP_TYPE_IPV4; | |
045c5389 RW |
181 | rip_redistribute_add(rip, ZEBRA_ROUTE_RIP, RIP_ROUTE_DEFAULT, |
182 | &p, &nh, 0, 0, 0); | |
0b0609ba | 183 | } else { |
045c5389 RW |
184 | rip_redistribute_delete(rip, ZEBRA_ROUTE_RIP, RIP_ROUTE_DEFAULT, |
185 | &p, 0); | |
0b0609ba RW |
186 | } |
187 | ||
707656ec RW |
188 | return NB_OK; |
189 | } | |
190 | ||
191 | /* | |
192 | * XPath: /frr-ripd:ripd/instance/default-metric | |
193 | */ | |
194 | static int ripd_instance_default_metric_modify(enum nb_event event, | |
195 | const struct lyd_node *dnode, | |
196 | union nb_resource *resource) | |
197 | { | |
045c5389 RW |
198 | struct rip *rip; |
199 | ||
282ae30c RW |
200 | if (event != NB_EV_APPLY) |
201 | return NB_OK; | |
202 | ||
ccd43ada | 203 | rip = nb_running_get_entry(dnode, NULL, true); |
282ae30c RW |
204 | rip->default_metric = yang_dnode_get_uint8(dnode, NULL); |
205 | /* rip_update_default_metric (); */ | |
206 | ||
707656ec RW |
207 | return NB_OK; |
208 | } | |
209 | ||
210 | /* | |
211 | * XPath: /frr-ripd:ripd/instance/distance/default | |
212 | */ | |
213 | static int ripd_instance_distance_default_modify(enum nb_event event, | |
214 | const struct lyd_node *dnode, | |
215 | union nb_resource *resource) | |
216 | { | |
045c5389 RW |
217 | struct rip *rip; |
218 | ||
7f8a9cba RW |
219 | if (event != NB_EV_APPLY) |
220 | return NB_OK; | |
221 | ||
ccd43ada | 222 | rip = nb_running_get_entry(dnode, NULL, true); |
7f8a9cba RW |
223 | rip->distance = yang_dnode_get_uint8(dnode, NULL); |
224 | ||
707656ec RW |
225 | return NB_OK; |
226 | } | |
227 | ||
228 | /* | |
229 | * XPath: /frr-ripd:ripd/instance/distance/source | |
230 | */ | |
231 | static int ripd_instance_distance_source_create(enum nb_event event, | |
232 | const struct lyd_node *dnode, | |
233 | union nb_resource *resource) | |
234 | { | |
045c5389 | 235 | struct rip *rip; |
23b23d8c RW |
236 | struct prefix_ipv4 prefix; |
237 | struct route_node *rn; | |
238 | ||
239 | if (event != NB_EV_APPLY) | |
240 | return NB_OK; | |
241 | ||
242 | yang_dnode_get_ipv4p(&prefix, dnode, "./prefix"); | |
d682d365 | 243 | apply_mask_ipv4(&prefix); |
23b23d8c RW |
244 | |
245 | /* Get RIP distance node. */ | |
ccd43ada | 246 | rip = nb_running_get_entry(dnode, NULL, true); |
2826309c | 247 | rn = route_node_get(rip->distance_table, (struct prefix *)&prefix); |
23b23d8c | 248 | rn->info = rip_distance_new(); |
ccd43ada | 249 | nb_running_set_entry(dnode, rn); |
23b23d8c | 250 | |
707656ec RW |
251 | return NB_OK; |
252 | } | |
253 | ||
6a3fdeec RW |
254 | static int ripd_instance_distance_source_destroy(enum nb_event event, |
255 | const struct lyd_node *dnode) | |
707656ec | 256 | { |
23b23d8c RW |
257 | struct route_node *rn; |
258 | struct rip_distance *rdistance; | |
259 | ||
260 | if (event != NB_EV_APPLY) | |
261 | return NB_OK; | |
262 | ||
ccd43ada | 263 | rn = nb_running_unset_entry(dnode); |
23b23d8c | 264 | rdistance = rn->info; |
23b23d8c | 265 | rip_distance_free(rdistance); |
23b23d8c RW |
266 | rn->info = NULL; |
267 | route_unlock_node(rn); | |
268 | ||
707656ec RW |
269 | return NB_OK; |
270 | } | |
271 | ||
272 | /* | |
273 | * XPath: /frr-ripd:ripd/instance/distance/source/distance | |
274 | */ | |
275 | static int | |
276 | ripd_instance_distance_source_distance_modify(enum nb_event event, | |
277 | const struct lyd_node *dnode, | |
278 | union nb_resource *resource) | |
279 | { | |
23b23d8c RW |
280 | struct route_node *rn; |
281 | uint8_t distance; | |
282 | struct rip_distance *rdistance; | |
283 | ||
284 | if (event != NB_EV_APPLY) | |
285 | return NB_OK; | |
286 | ||
287 | /* Set distance value. */ | |
ccd43ada | 288 | rn = nb_running_get_entry(dnode, NULL, true); |
23b23d8c RW |
289 | distance = yang_dnode_get_uint8(dnode, NULL); |
290 | rdistance = rn->info; | |
291 | rdistance->distance = distance; | |
292 | ||
707656ec RW |
293 | return NB_OK; |
294 | } | |
295 | ||
296 | /* | |
297 | * XPath: /frr-ripd:ripd/instance/distance/source/access-list | |
298 | */ | |
299 | static int | |
300 | ripd_instance_distance_source_access_list_modify(enum nb_event event, | |
301 | const struct lyd_node *dnode, | |
302 | union nb_resource *resource) | |
303 | { | |
23b23d8c RW |
304 | const char *acl_name; |
305 | struct route_node *rn; | |
306 | struct rip_distance *rdistance; | |
307 | ||
308 | if (event != NB_EV_APPLY) | |
309 | return NB_OK; | |
310 | ||
311 | acl_name = yang_dnode_get_string(dnode, NULL); | |
312 | ||
313 | /* Set access-list */ | |
ccd43ada | 314 | rn = nb_running_get_entry(dnode, NULL, true); |
23b23d8c RW |
315 | rdistance = rn->info; |
316 | if (rdistance->access_list) | |
317 | free(rdistance->access_list); | |
318 | rdistance->access_list = strdup(acl_name); | |
319 | ||
707656ec RW |
320 | return NB_OK; |
321 | } | |
322 | ||
323 | static int | |
6a3fdeec RW |
324 | ripd_instance_distance_source_access_list_destroy(enum nb_event event, |
325 | const struct lyd_node *dnode) | |
707656ec | 326 | { |
23b23d8c RW |
327 | struct route_node *rn; |
328 | struct rip_distance *rdistance; | |
329 | ||
330 | if (event != NB_EV_APPLY) | |
331 | return NB_OK; | |
332 | ||
333 | /* Reset access-list configuration. */ | |
ccd43ada | 334 | rn = nb_running_get_entry(dnode, NULL, true); |
23b23d8c RW |
335 | rdistance = rn->info; |
336 | free(rdistance->access_list); | |
337 | rdistance->access_list = NULL; | |
338 | ||
707656ec RW |
339 | return NB_OK; |
340 | } | |
341 | ||
342 | /* | |
343 | * XPath: /frr-ripd:ripd/instance/explicit-neighbor | |
344 | */ | |
345 | static int ripd_instance_explicit_neighbor_create(enum nb_event event, | |
346 | const struct lyd_node *dnode, | |
347 | union nb_resource *resource) | |
348 | { | |
045c5389 | 349 | struct rip *rip; |
f0ab22fb RW |
350 | struct prefix_ipv4 p; |
351 | ||
352 | if (event != NB_EV_APPLY) | |
353 | return NB_OK; | |
354 | ||
ccd43ada | 355 | rip = nb_running_get_entry(dnode, NULL, true); |
f0ab22fb RW |
356 | p.family = AF_INET; |
357 | p.prefixlen = IPV4_MAX_BITLEN; | |
358 | yang_dnode_get_ipv4(&p.prefix, dnode, NULL); | |
359 | ||
045c5389 | 360 | return rip_neighbor_add(rip, &p); |
707656ec RW |
361 | } |
362 | ||
6a3fdeec RW |
363 | static int ripd_instance_explicit_neighbor_destroy(enum nb_event event, |
364 | const struct lyd_node *dnode) | |
707656ec | 365 | { |
045c5389 | 366 | struct rip *rip; |
f0ab22fb RW |
367 | struct prefix_ipv4 p; |
368 | ||
369 | if (event != NB_EV_APPLY) | |
370 | return NB_OK; | |
371 | ||
ccd43ada | 372 | rip = nb_running_get_entry(dnode, NULL, true); |
f0ab22fb RW |
373 | p.family = AF_INET; |
374 | p.prefixlen = IPV4_MAX_BITLEN; | |
375 | yang_dnode_get_ipv4(&p.prefix, dnode, NULL); | |
376 | ||
045c5389 | 377 | return rip_neighbor_delete(rip, &p); |
707656ec RW |
378 | } |
379 | ||
380 | /* | |
381 | * XPath: /frr-ripd:ripd/instance/network | |
382 | */ | |
383 | static int ripd_instance_network_create(enum nb_event event, | |
384 | const struct lyd_node *dnode, | |
385 | union nb_resource *resource) | |
386 | { | |
045c5389 | 387 | struct rip *rip; |
3d7a1be8 RW |
388 | struct prefix p; |
389 | ||
390 | if (event != NB_EV_APPLY) | |
391 | return NB_OK; | |
392 | ||
ccd43ada | 393 | rip = nb_running_get_entry(dnode, NULL, true); |
3d7a1be8 | 394 | yang_dnode_get_ipv4p(&p, dnode, NULL); |
d682d365 | 395 | apply_mask_ipv4((struct prefix_ipv4 *)&p); |
3d7a1be8 | 396 | |
045c5389 | 397 | return rip_enable_network_add(rip, &p); |
707656ec RW |
398 | } |
399 | ||
6a3fdeec RW |
400 | static int ripd_instance_network_destroy(enum nb_event event, |
401 | const struct lyd_node *dnode) | |
707656ec | 402 | { |
045c5389 | 403 | struct rip *rip; |
3d7a1be8 RW |
404 | struct prefix p; |
405 | ||
406 | if (event != NB_EV_APPLY) | |
407 | return NB_OK; | |
408 | ||
ccd43ada | 409 | rip = nb_running_get_entry(dnode, NULL, true); |
3d7a1be8 | 410 | yang_dnode_get_ipv4p(&p, dnode, NULL); |
d682d365 | 411 | apply_mask_ipv4((struct prefix_ipv4 *)&p); |
3d7a1be8 | 412 | |
045c5389 | 413 | return rip_enable_network_delete(rip, &p); |
707656ec RW |
414 | } |
415 | ||
416 | /* | |
417 | * XPath: /frr-ripd:ripd/instance/interface | |
418 | */ | |
419 | static int ripd_instance_interface_create(enum nb_event event, | |
420 | const struct lyd_node *dnode, | |
421 | union nb_resource *resource) | |
422 | { | |
045c5389 | 423 | struct rip *rip; |
3d7a1be8 RW |
424 | const char *ifname; |
425 | ||
426 | if (event != NB_EV_APPLY) | |
427 | return NB_OK; | |
428 | ||
ccd43ada | 429 | rip = nb_running_get_entry(dnode, NULL, true); |
3d7a1be8 RW |
430 | ifname = yang_dnode_get_string(dnode, NULL); |
431 | ||
045c5389 | 432 | return rip_enable_if_add(rip, ifname); |
707656ec RW |
433 | } |
434 | ||
6a3fdeec RW |
435 | static int ripd_instance_interface_destroy(enum nb_event event, |
436 | const struct lyd_node *dnode) | |
707656ec | 437 | { |
045c5389 | 438 | struct rip *rip; |
3d7a1be8 RW |
439 | const char *ifname; |
440 | ||
441 | if (event != NB_EV_APPLY) | |
442 | return NB_OK; | |
443 | ||
ccd43ada | 444 | rip = nb_running_get_entry(dnode, NULL, true); |
3d7a1be8 RW |
445 | ifname = yang_dnode_get_string(dnode, NULL); |
446 | ||
045c5389 | 447 | return rip_enable_if_delete(rip, ifname); |
707656ec RW |
448 | } |
449 | ||
450 | /* | |
451 | * XPath: /frr-ripd:ripd/instance/offset-list | |
452 | */ | |
453 | static int ripd_instance_offset_list_create(enum nb_event event, | |
454 | const struct lyd_node *dnode, | |
455 | union nb_resource *resource) | |
456 | { | |
045c5389 | 457 | struct rip *rip; |
8c942f65 RW |
458 | const char *ifname; |
459 | struct rip_offset_list *offset; | |
460 | ||
461 | if (event != NB_EV_APPLY) | |
462 | return NB_OK; | |
463 | ||
ccd43ada | 464 | rip = nb_running_get_entry(dnode, NULL, true); |
8c942f65 RW |
465 | ifname = yang_dnode_get_string(dnode, "./interface"); |
466 | ||
045c5389 | 467 | offset = rip_offset_list_new(rip, ifname); |
ccd43ada | 468 | nb_running_set_entry(dnode, offset); |
8c942f65 | 469 | |
707656ec RW |
470 | return NB_OK; |
471 | } | |
472 | ||
6a3fdeec RW |
473 | static int ripd_instance_offset_list_destroy(enum nb_event event, |
474 | const struct lyd_node *dnode) | |
707656ec | 475 | { |
8c942f65 RW |
476 | int direct; |
477 | struct rip_offset_list *offset; | |
478 | ||
479 | if (event != NB_EV_APPLY) | |
480 | return NB_OK; | |
481 | ||
482 | direct = yang_dnode_get_enum(dnode, "./direction"); | |
483 | ||
ccd43ada | 484 | offset = nb_running_unset_entry(dnode); |
8c942f65 RW |
485 | if (offset->direct[direct].alist_name) { |
486 | free(offset->direct[direct].alist_name); | |
487 | offset->direct[direct].alist_name = NULL; | |
488 | } | |
489 | if (offset->direct[RIP_OFFSET_LIST_IN].alist_name == NULL | |
490 | && offset->direct[RIP_OFFSET_LIST_OUT].alist_name == NULL) | |
491 | offset_list_del(offset); | |
492 | ||
707656ec RW |
493 | return NB_OK; |
494 | } | |
495 | ||
496 | /* | |
497 | * XPath: /frr-ripd:ripd/instance/offset-list/access-list | |
498 | */ | |
499 | static int | |
500 | ripd_instance_offset_list_access_list_modify(enum nb_event event, | |
501 | const struct lyd_node *dnode, | |
502 | union nb_resource *resource) | |
503 | { | |
8c942f65 RW |
504 | int direct; |
505 | struct rip_offset_list *offset; | |
506 | const char *alist_name; | |
507 | ||
508 | if (event != NB_EV_APPLY) | |
509 | return NB_OK; | |
510 | ||
511 | direct = yang_dnode_get_enum(dnode, "../direction"); | |
512 | alist_name = yang_dnode_get_string(dnode, NULL); | |
513 | ||
ccd43ada | 514 | offset = nb_running_get_entry(dnode, NULL, true); |
8c942f65 RW |
515 | if (offset->direct[direct].alist_name) |
516 | free(offset->direct[direct].alist_name); | |
517 | offset->direct[direct].alist_name = strdup(alist_name); | |
518 | ||
707656ec RW |
519 | return NB_OK; |
520 | } | |
521 | ||
522 | /* | |
523 | * XPath: /frr-ripd:ripd/instance/offset-list/metric | |
524 | */ | |
525 | static int ripd_instance_offset_list_metric_modify(enum nb_event event, | |
526 | const struct lyd_node *dnode, | |
527 | union nb_resource *resource) | |
528 | { | |
8c942f65 RW |
529 | int direct; |
530 | uint8_t metric; | |
531 | struct rip_offset_list *offset; | |
532 | ||
533 | if (event != NB_EV_APPLY) | |
534 | return NB_OK; | |
535 | ||
536 | direct = yang_dnode_get_enum(dnode, "../direction"); | |
537 | metric = yang_dnode_get_uint8(dnode, NULL); | |
538 | ||
ccd43ada | 539 | offset = nb_running_get_entry(dnode, NULL, true); |
8c942f65 RW |
540 | offset->direct[direct].metric = metric; |
541 | ||
707656ec RW |
542 | return NB_OK; |
543 | } | |
544 | ||
545 | /* | |
546 | * XPath: /frr-ripd:ripd/instance/passive-default | |
547 | */ | |
548 | static int ripd_instance_passive_default_modify(enum nb_event event, | |
549 | const struct lyd_node *dnode, | |
550 | union nb_resource *resource) | |
551 | { | |
045c5389 RW |
552 | struct rip *rip; |
553 | ||
44f2f852 RW |
554 | if (event != NB_EV_APPLY) |
555 | return NB_OK; | |
556 | ||
ccd43ada | 557 | rip = nb_running_get_entry(dnode, NULL, true); |
44f2f852 | 558 | rip->passive_default = yang_dnode_get_bool(dnode, NULL); |
045c5389 | 559 | rip_passive_nondefault_clean(rip); |
44f2f852 | 560 | |
707656ec RW |
561 | return NB_OK; |
562 | } | |
563 | ||
564 | /* | |
565 | * XPath: /frr-ripd:ripd/instance/passive-interface | |
566 | */ | |
567 | static int ripd_instance_passive_interface_create(enum nb_event event, | |
568 | const struct lyd_node *dnode, | |
569 | union nb_resource *resource) | |
570 | { | |
045c5389 | 571 | struct rip *rip; |
44f2f852 RW |
572 | const char *ifname; |
573 | ||
574 | if (event != NB_EV_APPLY) | |
575 | return NB_OK; | |
576 | ||
ccd43ada | 577 | rip = nb_running_get_entry(dnode, NULL, true); |
44f2f852 RW |
578 | ifname = yang_dnode_get_string(dnode, NULL); |
579 | ||
045c5389 | 580 | return rip_passive_nondefault_set(rip, ifname); |
707656ec RW |
581 | } |
582 | ||
6a3fdeec RW |
583 | static int ripd_instance_passive_interface_destroy(enum nb_event event, |
584 | const struct lyd_node *dnode) | |
707656ec | 585 | { |
045c5389 | 586 | struct rip *rip; |
44f2f852 RW |
587 | const char *ifname; |
588 | ||
589 | if (event != NB_EV_APPLY) | |
590 | return NB_OK; | |
591 | ||
ccd43ada | 592 | rip = nb_running_get_entry(dnode, NULL, true); |
44f2f852 RW |
593 | ifname = yang_dnode_get_string(dnode, NULL); |
594 | ||
045c5389 | 595 | return rip_passive_nondefault_unset(rip, ifname); |
707656ec RW |
596 | } |
597 | ||
598 | /* | |
599 | * XPath: /frr-ripd:ripd/instance/non-passive-interface | |
600 | */ | |
601 | static int | |
602 | ripd_instance_non_passive_interface_create(enum nb_event event, | |
603 | const struct lyd_node *dnode, | |
604 | union nb_resource *resource) | |
605 | { | |
045c5389 | 606 | struct rip *rip; |
44f2f852 RW |
607 | const char *ifname; |
608 | ||
609 | if (event != NB_EV_APPLY) | |
610 | return NB_OK; | |
611 | ||
ccd43ada | 612 | rip = nb_running_get_entry(dnode, NULL, true); |
44f2f852 RW |
613 | ifname = yang_dnode_get_string(dnode, NULL); |
614 | ||
045c5389 | 615 | return rip_passive_nondefault_unset(rip, ifname); |
707656ec RW |
616 | } |
617 | ||
618 | static int | |
6a3fdeec RW |
619 | ripd_instance_non_passive_interface_destroy(enum nb_event event, |
620 | const struct lyd_node *dnode) | |
707656ec | 621 | { |
045c5389 | 622 | struct rip *rip; |
44f2f852 RW |
623 | const char *ifname; |
624 | ||
625 | if (event != NB_EV_APPLY) | |
626 | return NB_OK; | |
627 | ||
ccd43ada | 628 | rip = nb_running_get_entry(dnode, NULL, true); |
44f2f852 RW |
629 | ifname = yang_dnode_get_string(dnode, NULL); |
630 | ||
045c5389 | 631 | return rip_passive_nondefault_set(rip, ifname); |
707656ec RW |
632 | } |
633 | ||
634 | /* | |
635 | * XPath: /frr-ripd:ripd/instance/redistribute | |
636 | */ | |
637 | static int ripd_instance_redistribute_create(enum nb_event event, | |
638 | const struct lyd_node *dnode, | |
639 | union nb_resource *resource) | |
640 | { | |
f9120f71 RW |
641 | struct rip *rip; |
642 | int type; | |
643 | ||
644 | if (event != NB_EV_APPLY) | |
645 | return NB_OK; | |
646 | ||
ccd43ada | 647 | rip = nb_running_get_entry(dnode, NULL, true); |
f9120f71 RW |
648 | type = yang_dnode_get_enum(dnode, "./protocol"); |
649 | ||
650 | rip->redist[type].enabled = true; | |
651 | ||
707656ec RW |
652 | return NB_OK; |
653 | } | |
654 | ||
6a3fdeec RW |
655 | static int ripd_instance_redistribute_destroy(enum nb_event event, |
656 | const struct lyd_node *dnode) | |
707656ec | 657 | { |
045c5389 | 658 | struct rip *rip; |
908f0020 RW |
659 | int type; |
660 | ||
661 | if (event != NB_EV_APPLY) | |
662 | return NB_OK; | |
663 | ||
ccd43ada | 664 | rip = nb_running_get_entry(dnode, NULL, true); |
908f0020 RW |
665 | type = yang_dnode_get_enum(dnode, "./protocol"); |
666 | ||
f9120f71 RW |
667 | rip->redist[type].enabled = false; |
668 | if (rip->redist[type].route_map.name) { | |
669 | free(rip->redist[type].route_map.name); | |
670 | rip->redist[type].route_map.name = NULL; | |
671 | rip->redist[type].route_map.map = NULL; | |
672 | } | |
673 | rip->redist[type].metric_config = false; | |
674 | rip->redist[type].metric = 0; | |
675 | ||
676 | if (rip->enabled) | |
677 | rip_redistribute_conf_delete(rip, type); | |
908f0020 | 678 | |
707656ec RW |
679 | return NB_OK; |
680 | } | |
681 | ||
908f0020 RW |
682 | static void |
683 | ripd_instance_redistribute_apply_finish(const struct lyd_node *dnode) | |
684 | { | |
045c5389 | 685 | struct rip *rip; |
908f0020 RW |
686 | int type; |
687 | ||
ccd43ada | 688 | rip = nb_running_get_entry(dnode, NULL, true); |
908f0020 | 689 | type = yang_dnode_get_enum(dnode, "./protocol"); |
045c5389 | 690 | |
f9120f71 RW |
691 | if (rip->enabled) |
692 | rip_redistribute_conf_update(rip, type); | |
908f0020 RW |
693 | } |
694 | ||
707656ec RW |
695 | /* |
696 | * XPath: /frr-ripd:ripd/instance/redistribute/route-map | |
697 | */ | |
698 | static int | |
699 | ripd_instance_redistribute_route_map_modify(enum nb_event event, | |
700 | const struct lyd_node *dnode, | |
701 | union nb_resource *resource) | |
702 | { | |
045c5389 | 703 | struct rip *rip; |
908f0020 RW |
704 | int type; |
705 | const char *rmap_name; | |
706 | ||
707 | if (event != NB_EV_APPLY) | |
708 | return NB_OK; | |
709 | ||
ccd43ada | 710 | rip = nb_running_get_entry(dnode, NULL, true); |
908f0020 RW |
711 | type = yang_dnode_get_enum(dnode, "../protocol"); |
712 | rmap_name = yang_dnode_get_string(dnode, NULL); | |
713 | ||
f9120f71 RW |
714 | if (rip->redist[type].route_map.name) |
715 | free(rip->redist[type].route_map.name); | |
716 | rip->redist[type].route_map.name = strdup(rmap_name); | |
717 | rip->redist[type].route_map.map = route_map_lookup_by_name(rmap_name); | |
908f0020 | 718 | |
707656ec RW |
719 | return NB_OK; |
720 | } | |
721 | ||
722 | static int | |
6a3fdeec RW |
723 | ripd_instance_redistribute_route_map_destroy(enum nb_event event, |
724 | const struct lyd_node *dnode) | |
707656ec | 725 | { |
045c5389 | 726 | struct rip *rip; |
908f0020 RW |
727 | int type; |
728 | ||
729 | if (event != NB_EV_APPLY) | |
730 | return NB_OK; | |
731 | ||
ccd43ada | 732 | rip = nb_running_get_entry(dnode, NULL, true); |
908f0020 RW |
733 | type = yang_dnode_get_enum(dnode, "../protocol"); |
734 | ||
f9120f71 RW |
735 | free(rip->redist[type].route_map.name); |
736 | rip->redist[type].route_map.name = NULL; | |
737 | rip->redist[type].route_map.map = NULL; | |
908f0020 | 738 | |
707656ec RW |
739 | return NB_OK; |
740 | } | |
741 | ||
742 | /* | |
743 | * XPath: /frr-ripd:ripd/instance/redistribute/metric | |
744 | */ | |
745 | static int | |
746 | ripd_instance_redistribute_metric_modify(enum nb_event event, | |
747 | const struct lyd_node *dnode, | |
748 | union nb_resource *resource) | |
749 | { | |
045c5389 | 750 | struct rip *rip; |
908f0020 RW |
751 | int type; |
752 | uint8_t metric; | |
753 | ||
754 | if (event != NB_EV_APPLY) | |
755 | return NB_OK; | |
756 | ||
ccd43ada | 757 | rip = nb_running_get_entry(dnode, NULL, true); |
908f0020 RW |
758 | type = yang_dnode_get_enum(dnode, "../protocol"); |
759 | metric = yang_dnode_get_uint8(dnode, NULL); | |
760 | ||
f9120f71 RW |
761 | rip->redist[type].metric_config = true; |
762 | rip->redist[type].metric = metric; | |
908f0020 | 763 | |
707656ec RW |
764 | return NB_OK; |
765 | } | |
766 | ||
767 | static int | |
6a3fdeec RW |
768 | ripd_instance_redistribute_metric_destroy(enum nb_event event, |
769 | const struct lyd_node *dnode) | |
707656ec | 770 | { |
045c5389 | 771 | struct rip *rip; |
908f0020 RW |
772 | int type; |
773 | ||
774 | if (event != NB_EV_APPLY) | |
775 | return NB_OK; | |
776 | ||
ccd43ada | 777 | rip = nb_running_get_entry(dnode, NULL, true); |
908f0020 RW |
778 | type = yang_dnode_get_enum(dnode, "../protocol"); |
779 | ||
f9120f71 RW |
780 | rip->redist[type].metric_config = false; |
781 | rip->redist[type].metric = 0; | |
908f0020 | 782 | |
707656ec RW |
783 | return NB_OK; |
784 | } | |
785 | ||
786 | /* | |
787 | * XPath: /frr-ripd:ripd/instance/static-route | |
788 | */ | |
789 | static int ripd_instance_static_route_create(enum nb_event event, | |
790 | const struct lyd_node *dnode, | |
791 | union nb_resource *resource) | |
792 | { | |
045c5389 | 793 | struct rip *rip; |
40687878 RW |
794 | struct nexthop nh; |
795 | struct prefix_ipv4 p; | |
796 | ||
797 | if (event != NB_EV_APPLY) | |
798 | return NB_OK; | |
799 | ||
ccd43ada | 800 | rip = nb_running_get_entry(dnode, NULL, true); |
40687878 | 801 | yang_dnode_get_ipv4p(&p, dnode, NULL); |
d682d365 | 802 | apply_mask_ipv4(&p); |
40687878 RW |
803 | |
804 | memset(&nh, 0, sizeof(nh)); | |
805 | nh.type = NEXTHOP_TYPE_IPV4; | |
045c5389 RW |
806 | rip_redistribute_add(rip, ZEBRA_ROUTE_RIP, RIP_ROUTE_STATIC, &p, &nh, 0, |
807 | 0, 0); | |
40687878 | 808 | |
707656ec RW |
809 | return NB_OK; |
810 | } | |
811 | ||
6a3fdeec RW |
812 | static int ripd_instance_static_route_destroy(enum nb_event event, |
813 | const struct lyd_node *dnode) | |
707656ec | 814 | { |
045c5389 | 815 | struct rip *rip; |
40687878 RW |
816 | struct prefix_ipv4 p; |
817 | ||
818 | if (event != NB_EV_APPLY) | |
819 | return NB_OK; | |
820 | ||
ccd43ada | 821 | rip = nb_running_get_entry(dnode, NULL, true); |
40687878 | 822 | yang_dnode_get_ipv4p(&p, dnode, NULL); |
d682d365 | 823 | apply_mask_ipv4(&p); |
40687878 | 824 | |
045c5389 | 825 | rip_redistribute_delete(rip, ZEBRA_ROUTE_RIP, RIP_ROUTE_STATIC, &p, 0); |
40687878 | 826 | |
707656ec RW |
827 | return NB_OK; |
828 | } | |
829 | ||
b745780b RW |
830 | /* |
831 | * XPath: /frr-ripd:ripd/instance/timers/ | |
832 | */ | |
833 | static void ripd_instance_timers_apply_finish(const struct lyd_node *dnode) | |
834 | { | |
045c5389 RW |
835 | struct rip *rip; |
836 | ||
ccd43ada | 837 | rip = nb_running_get_entry(dnode, NULL, true); |
045c5389 | 838 | |
b745780b | 839 | /* Reset update timer thread. */ |
045c5389 | 840 | rip_event(rip, RIP_UPDATE_EVENT, 0); |
b745780b RW |
841 | } |
842 | ||
707656ec RW |
843 | /* |
844 | * XPath: /frr-ripd:ripd/instance/timers/flush-interval | |
845 | */ | |
846 | static int | |
847 | ripd_instance_timers_flush_interval_modify(enum nb_event event, | |
848 | const struct lyd_node *dnode, | |
849 | union nb_resource *resource) | |
850 | { | |
045c5389 RW |
851 | struct rip *rip; |
852 | ||
b745780b RW |
853 | if (event != NB_EV_APPLY) |
854 | return NB_OK; | |
855 | ||
ccd43ada | 856 | rip = nb_running_get_entry(dnode, NULL, true); |
b745780b RW |
857 | rip->garbage_time = yang_dnode_get_uint32(dnode, NULL); |
858 | ||
707656ec RW |
859 | return NB_OK; |
860 | } | |
861 | ||
862 | /* | |
863 | * XPath: /frr-ripd:ripd/instance/timers/holddown-interval | |
864 | */ | |
865 | static int | |
866 | ripd_instance_timers_holddown_interval_modify(enum nb_event event, | |
867 | const struct lyd_node *dnode, | |
868 | union nb_resource *resource) | |
869 | { | |
045c5389 RW |
870 | struct rip *rip; |
871 | ||
b745780b RW |
872 | if (event != NB_EV_APPLY) |
873 | return NB_OK; | |
874 | ||
ccd43ada | 875 | rip = nb_running_get_entry(dnode, NULL, true); |
b745780b RW |
876 | rip->timeout_time = yang_dnode_get_uint32(dnode, NULL); |
877 | ||
707656ec RW |
878 | return NB_OK; |
879 | } | |
880 | ||
881 | /* | |
882 | * XPath: /frr-ripd:ripd/instance/timers/update-interval | |
883 | */ | |
884 | static int | |
885 | ripd_instance_timers_update_interval_modify(enum nb_event event, | |
886 | const struct lyd_node *dnode, | |
887 | union nb_resource *resource) | |
888 | { | |
045c5389 RW |
889 | struct rip *rip; |
890 | ||
b745780b RW |
891 | if (event != NB_EV_APPLY) |
892 | return NB_OK; | |
893 | ||
ccd43ada | 894 | rip = nb_running_get_entry(dnode, NULL, true); |
b745780b RW |
895 | rip->update_time = yang_dnode_get_uint32(dnode, NULL); |
896 | ||
707656ec RW |
897 | return NB_OK; |
898 | } | |
899 | ||
900 | /* | |
901 | * XPath: /frr-ripd:ripd/instance/version/receive | |
902 | */ | |
903 | static int ripd_instance_version_receive_modify(enum nb_event event, | |
904 | const struct lyd_node *dnode, | |
905 | union nb_resource *resource) | |
906 | { | |
045c5389 RW |
907 | struct rip *rip; |
908 | ||
90eff9da RW |
909 | if (event != NB_EV_APPLY) |
910 | return NB_OK; | |
911 | ||
ccd43ada | 912 | rip = nb_running_get_entry(dnode, NULL, true); |
90eff9da RW |
913 | rip->version_recv = yang_dnode_get_enum(dnode, NULL); |
914 | ||
707656ec RW |
915 | return NB_OK; |
916 | } | |
917 | ||
918 | /* | |
919 | * XPath: /frr-ripd:ripd/instance/version/send | |
920 | */ | |
921 | static int ripd_instance_version_send_modify(enum nb_event event, | |
922 | const struct lyd_node *dnode, | |
923 | union nb_resource *resource) | |
924 | { | |
045c5389 RW |
925 | struct rip *rip; |
926 | ||
90eff9da RW |
927 | if (event != NB_EV_APPLY) |
928 | return NB_OK; | |
929 | ||
ccd43ada | 930 | rip = nb_running_get_entry(dnode, NULL, true); |
90eff9da RW |
931 | rip->version_send = yang_dnode_get_enum(dnode, NULL); |
932 | ||
707656ec RW |
933 | return NB_OK; |
934 | } | |
935 | ||
936 | /* | |
937 | * XPath: /frr-interface:lib/interface/frr-ripd:rip/split-horizon | |
938 | */ | |
939 | static int lib_interface_rip_split_horizon_modify(enum nb_event event, | |
940 | const struct lyd_node *dnode, | |
941 | union nb_resource *resource) | |
942 | { | |
94b117b2 RW |
943 | struct interface *ifp; |
944 | struct rip_interface *ri; | |
945 | ||
946 | if (event != NB_EV_APPLY) | |
947 | return NB_OK; | |
948 | ||
ccd43ada | 949 | ifp = nb_running_get_entry(dnode, NULL, true); |
94b117b2 RW |
950 | ri = ifp->info; |
951 | ri->split_horizon = yang_dnode_get_enum(dnode, NULL); | |
952 | ||
707656ec RW |
953 | return NB_OK; |
954 | } | |
955 | ||
956 | /* | |
957 | * XPath: /frr-interface:lib/interface/frr-ripd:rip/v2-broadcast | |
958 | */ | |
959 | static int lib_interface_rip_v2_broadcast_modify(enum nb_event event, | |
960 | const struct lyd_node *dnode, | |
961 | union nb_resource *resource) | |
962 | { | |
94b117b2 RW |
963 | struct interface *ifp; |
964 | struct rip_interface *ri; | |
965 | ||
966 | if (event != NB_EV_APPLY) | |
967 | return NB_OK; | |
968 | ||
ccd43ada | 969 | ifp = nb_running_get_entry(dnode, NULL, true); |
94b117b2 RW |
970 | ri = ifp->info; |
971 | ri->v2_broadcast = yang_dnode_get_bool(dnode, NULL); | |
972 | ||
707656ec RW |
973 | return NB_OK; |
974 | } | |
975 | ||
976 | /* | |
977 | * XPath: /frr-interface:lib/interface/frr-ripd:rip/version-receive | |
978 | */ | |
979 | static int | |
980 | lib_interface_rip_version_receive_modify(enum nb_event event, | |
981 | const struct lyd_node *dnode, | |
982 | union nb_resource *resource) | |
983 | { | |
94b117b2 RW |
984 | struct interface *ifp; |
985 | struct rip_interface *ri; | |
986 | ||
987 | if (event != NB_EV_APPLY) | |
988 | return NB_OK; | |
989 | ||
ccd43ada | 990 | ifp = nb_running_get_entry(dnode, NULL, true); |
94b117b2 RW |
991 | ri = ifp->info; |
992 | ri->ri_receive = yang_dnode_get_enum(dnode, NULL); | |
993 | ||
707656ec RW |
994 | return NB_OK; |
995 | } | |
996 | ||
997 | /* | |
998 | * XPath: /frr-interface:lib/interface/frr-ripd:rip/version-send | |
999 | */ | |
1000 | static int lib_interface_rip_version_send_modify(enum nb_event event, | |
1001 | const struct lyd_node *dnode, | |
1002 | union nb_resource *resource) | |
1003 | { | |
94b117b2 RW |
1004 | struct interface *ifp; |
1005 | struct rip_interface *ri; | |
1006 | ||
1007 | if (event != NB_EV_APPLY) | |
1008 | return NB_OK; | |
1009 | ||
ccd43ada | 1010 | ifp = nb_running_get_entry(dnode, NULL, true); |
94b117b2 RW |
1011 | ri = ifp->info; |
1012 | ri->ri_send = yang_dnode_get_enum(dnode, NULL); | |
1013 | ||
707656ec RW |
1014 | return NB_OK; |
1015 | } | |
1016 | ||
1017 | /* | |
1018 | * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-scheme/mode | |
1019 | */ | |
1020 | static int lib_interface_rip_authentication_scheme_mode_modify( | |
1021 | enum nb_event event, const struct lyd_node *dnode, | |
1022 | union nb_resource *resource) | |
1023 | { | |
94b117b2 RW |
1024 | struct interface *ifp; |
1025 | struct rip_interface *ri; | |
1026 | ||
1027 | if (event != NB_EV_APPLY) | |
1028 | return NB_OK; | |
1029 | ||
ccd43ada | 1030 | ifp = nb_running_get_entry(dnode, NULL, true); |
94b117b2 RW |
1031 | ri = ifp->info; |
1032 | ri->auth_type = yang_dnode_get_enum(dnode, NULL); | |
1033 | ||
707656ec RW |
1034 | return NB_OK; |
1035 | } | |
1036 | ||
1037 | /* | |
1038 | * XPath: | |
1039 | * /frr-interface:lib/interface/frr-ripd:rip/authentication-scheme/md5-auth-length | |
1040 | */ | |
1041 | static int lib_interface_rip_authentication_scheme_md5_auth_length_modify( | |
1042 | enum nb_event event, const struct lyd_node *dnode, | |
1043 | union nb_resource *resource) | |
1044 | { | |
94b117b2 RW |
1045 | struct interface *ifp; |
1046 | struct rip_interface *ri; | |
1047 | ||
1048 | if (event != NB_EV_APPLY) | |
1049 | return NB_OK; | |
1050 | ||
ccd43ada | 1051 | ifp = nb_running_get_entry(dnode, NULL, true); |
94b117b2 RW |
1052 | ri = ifp->info; |
1053 | ri->md5_auth_len = yang_dnode_get_enum(dnode, NULL); | |
1054 | ||
707656ec RW |
1055 | return NB_OK; |
1056 | } | |
1057 | ||
6a3fdeec | 1058 | static int lib_interface_rip_authentication_scheme_md5_auth_length_destroy( |
707656ec RW |
1059 | enum nb_event event, const struct lyd_node *dnode) |
1060 | { | |
94b117b2 RW |
1061 | struct interface *ifp; |
1062 | struct rip_interface *ri; | |
1063 | ||
1064 | if (event != NB_EV_APPLY) | |
1065 | return NB_OK; | |
1066 | ||
ccd43ada | 1067 | ifp = nb_running_get_entry(dnode, NULL, true); |
94b117b2 RW |
1068 | ri = ifp->info; |
1069 | ri->md5_auth_len = yang_get_default_enum( | |
1070 | "%s/authentication-scheme/md5-auth-length", RIP_IFACE); | |
1071 | ||
707656ec RW |
1072 | return NB_OK; |
1073 | } | |
1074 | ||
1075 | /* | |
1076 | * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-password | |
1077 | */ | |
1078 | static int | |
1079 | lib_interface_rip_authentication_password_modify(enum nb_event event, | |
1080 | const struct lyd_node *dnode, | |
1081 | union nb_resource *resource) | |
1082 | { | |
94b117b2 RW |
1083 | struct interface *ifp; |
1084 | struct rip_interface *ri; | |
1085 | ||
1086 | if (event != NB_EV_APPLY) | |
1087 | return NB_OK; | |
1088 | ||
ccd43ada | 1089 | ifp = nb_running_get_entry(dnode, NULL, true); |
94b117b2 | 1090 | ri = ifp->info; |
0a22ddfb | 1091 | XFREE(MTYPE_RIP_INTERFACE_STRING, ri->auth_str); |
94b117b2 RW |
1092 | ri->auth_str = XSTRDUP(MTYPE_RIP_INTERFACE_STRING, |
1093 | yang_dnode_get_string(dnode, NULL)); | |
1094 | ||
707656ec RW |
1095 | return NB_OK; |
1096 | } | |
1097 | ||
1098 | static int | |
6a3fdeec RW |
1099 | lib_interface_rip_authentication_password_destroy(enum nb_event event, |
1100 | const struct lyd_node *dnode) | |
707656ec | 1101 | { |
94b117b2 RW |
1102 | struct interface *ifp; |
1103 | struct rip_interface *ri; | |
1104 | ||
1105 | if (event != NB_EV_APPLY) | |
1106 | return NB_OK; | |
1107 | ||
ccd43ada | 1108 | ifp = nb_running_get_entry(dnode, NULL, true); |
94b117b2 RW |
1109 | ri = ifp->info; |
1110 | XFREE(MTYPE_RIP_INTERFACE_STRING, ri->auth_str); | |
1111 | ||
707656ec RW |
1112 | return NB_OK; |
1113 | } | |
1114 | ||
1115 | /* | |
1116 | * XPath: /frr-interface:lib/interface/frr-ripd:rip/authentication-key-chain | |
1117 | */ | |
1118 | static int | |
1119 | lib_interface_rip_authentication_key_chain_modify(enum nb_event event, | |
1120 | const struct lyd_node *dnode, | |
1121 | union nb_resource *resource) | |
1122 | { | |
94b117b2 RW |
1123 | struct interface *ifp; |
1124 | struct rip_interface *ri; | |
1125 | ||
1126 | if (event != NB_EV_APPLY) | |
1127 | return NB_OK; | |
1128 | ||
ccd43ada | 1129 | ifp = nb_running_get_entry(dnode, NULL, true); |
94b117b2 | 1130 | ri = ifp->info; |
0a22ddfb | 1131 | XFREE(MTYPE_RIP_INTERFACE_STRING, ri->key_chain); |
94b117b2 RW |
1132 | ri->key_chain = XSTRDUP(MTYPE_RIP_INTERFACE_STRING, |
1133 | yang_dnode_get_string(dnode, NULL)); | |
1134 | ||
707656ec RW |
1135 | return NB_OK; |
1136 | } | |
1137 | ||
1138 | static int | |
6a3fdeec RW |
1139 | lib_interface_rip_authentication_key_chain_destroy(enum nb_event event, |
1140 | const struct lyd_node *dnode) | |
707656ec | 1141 | { |
94b117b2 RW |
1142 | struct interface *ifp; |
1143 | struct rip_interface *ri; | |
1144 | ||
1145 | if (event != NB_EV_APPLY) | |
1146 | return NB_OK; | |
1147 | ||
ccd43ada | 1148 | ifp = nb_running_get_entry(dnode, NULL, true); |
94b117b2 RW |
1149 | ri = ifp->info; |
1150 | XFREE(MTYPE_RIP_INTERFACE_STRING, ri->key_chain); | |
1151 | ||
707656ec RW |
1152 | return NB_OK; |
1153 | } | |
1154 | ||
1155 | /* | |
32600a98 | 1156 | * XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor |
707656ec RW |
1157 | */ |
1158 | static const void * | |
32600a98 RW |
1159 | ripd_instance_state_neighbors_neighbor_get_next(const void *parent_list_entry, |
1160 | const void *list_entry) | |
707656ec | 1161 | { |
32600a98 | 1162 | const struct rip *rip = parent_list_entry; |
5c1a8497 RW |
1163 | struct listnode *node; |
1164 | ||
1165 | if (list_entry == NULL) | |
29e897ad | 1166 | node = listhead(rip->peer_list); |
5c1a8497 RW |
1167 | else |
1168 | node = listnextnode((struct listnode *)list_entry); | |
1169 | ||
1170 | return node; | |
707656ec RW |
1171 | } |
1172 | ||
32600a98 RW |
1173 | static int |
1174 | ripd_instance_state_neighbors_neighbor_get_keys(const void *list_entry, | |
1175 | struct yang_list_keys *keys) | |
707656ec | 1176 | { |
5c1a8497 RW |
1177 | const struct listnode *node = list_entry; |
1178 | const struct rip_peer *peer = listgetdata(node); | |
1179 | ||
1180 | keys->num = 1; | |
80243aef RW |
1181 | (void)inet_ntop(AF_INET, &peer->addr, keys->key[0], |
1182 | sizeof(keys->key[0])); | |
5c1a8497 | 1183 | |
707656ec RW |
1184 | return NB_OK; |
1185 | } | |
1186 | ||
32600a98 RW |
1187 | static const void *ripd_instance_state_neighbors_neighbor_lookup_entry( |
1188 | const void *parent_list_entry, const struct yang_list_keys *keys) | |
707656ec | 1189 | { |
32600a98 | 1190 | const struct rip *rip = parent_list_entry; |
5c1a8497 | 1191 | struct in_addr address; |
9c472033 RW |
1192 | struct rip_peer *peer; |
1193 | struct listnode *node; | |
5c1a8497 | 1194 | |
80243aef | 1195 | yang_str2ipv4(keys->key[0], &address); |
5c1a8497 | 1196 | |
29e897ad | 1197 | for (ALL_LIST_ELEMENTS_RO(rip->peer_list, node, peer)) { |
9c472033 RW |
1198 | if (IPV4_ADDR_SAME(&peer->addr, &address)) |
1199 | return node; | |
1200 | } | |
5c1a8497 | 1201 | |
9c472033 | 1202 | return NULL; |
707656ec RW |
1203 | } |
1204 | ||
1205 | /* | |
32600a98 | 1206 | * XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor/address |
707656ec RW |
1207 | */ |
1208 | static struct yang_data * | |
32600a98 RW |
1209 | ripd_instance_state_neighbors_neighbor_address_get_elem(const char *xpath, |
1210 | const void *list_entry) | |
707656ec | 1211 | { |
9c472033 RW |
1212 | const struct listnode *node = list_entry; |
1213 | const struct rip_peer *peer = listgetdata(node); | |
5c1a8497 RW |
1214 | |
1215 | return yang_data_new_ipv4(xpath, &peer->addr); | |
707656ec RW |
1216 | } |
1217 | ||
1218 | /* | |
32600a98 | 1219 | * XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor/last-update |
707656ec RW |
1220 | */ |
1221 | static struct yang_data * | |
32600a98 RW |
1222 | ripd_instance_state_neighbors_neighbor_last_update_get_elem( |
1223 | const char *xpath, const void *list_entry) | |
707656ec | 1224 | { |
5c1a8497 | 1225 | /* TODO: yang:date-and-time is tricky */ |
707656ec RW |
1226 | return NULL; |
1227 | } | |
1228 | ||
1229 | /* | |
32600a98 | 1230 | * XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor/bad-packets-rcvd |
707656ec RW |
1231 | */ |
1232 | static struct yang_data * | |
32600a98 RW |
1233 | ripd_instance_state_neighbors_neighbor_bad_packets_rcvd_get_elem( |
1234 | const char *xpath, const void *list_entry) | |
707656ec | 1235 | { |
9c472033 RW |
1236 | const struct listnode *node = list_entry; |
1237 | const struct rip_peer *peer = listgetdata(node); | |
5c1a8497 RW |
1238 | |
1239 | return yang_data_new_uint32(xpath, peer->recv_badpackets); | |
707656ec RW |
1240 | } |
1241 | ||
1242 | /* | |
32600a98 | 1243 | * XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor/bad-routes-rcvd |
707656ec RW |
1244 | */ |
1245 | static struct yang_data * | |
32600a98 RW |
1246 | ripd_instance_state_neighbors_neighbor_bad_routes_rcvd_get_elem( |
1247 | const char *xpath, const void *list_entry) | |
707656ec | 1248 | { |
9c472033 RW |
1249 | const struct listnode *node = list_entry; |
1250 | const struct rip_peer *peer = listgetdata(node); | |
5c1a8497 RW |
1251 | |
1252 | return yang_data_new_uint32(xpath, peer->recv_badroutes); | |
707656ec RW |
1253 | } |
1254 | ||
1255 | /* | |
32600a98 | 1256 | * XPath: /frr-ripd:ripd/instance/state/routes/route |
707656ec | 1257 | */ |
1a4bc045 | 1258 | static const void * |
32600a98 RW |
1259 | ripd_instance_state_routes_route_get_next(const void *parent_list_entry, |
1260 | const void *list_entry) | |
707656ec | 1261 | { |
32600a98 | 1262 | const struct rip *rip = parent_list_entry; |
6270ce38 RW |
1263 | struct route_node *rn; |
1264 | ||
6270ce38 RW |
1265 | if (list_entry == NULL) |
1266 | rn = route_top(rip->table); | |
1267 | else | |
1268 | rn = route_next((struct route_node *)list_entry); | |
1269 | while (rn && rn->info == NULL) | |
1270 | rn = route_next(rn); | |
1271 | ||
1272 | return rn; | |
707656ec RW |
1273 | } |
1274 | ||
32600a98 RW |
1275 | static int |
1276 | ripd_instance_state_routes_route_get_keys(const void *list_entry, | |
1277 | struct yang_list_keys *keys) | |
707656ec | 1278 | { |
6270ce38 RW |
1279 | const struct route_node *rn = list_entry; |
1280 | ||
1281 | keys->num = 1; | |
80243aef | 1282 | (void)prefix2str(&rn->p, keys->key[0], sizeof(keys->key[0])); |
6270ce38 | 1283 | |
707656ec RW |
1284 | return NB_OK; |
1285 | } | |
1286 | ||
1287 | static const void * | |
32600a98 RW |
1288 | ripd_instance_state_routes_route_lookup_entry(const void *parent_list_entry, |
1289 | const struct yang_list_keys *keys) | |
707656ec | 1290 | { |
32600a98 | 1291 | const struct rip *rip = parent_list_entry; |
6270ce38 RW |
1292 | struct prefix prefix; |
1293 | struct route_node *rn; | |
1294 | ||
80243aef | 1295 | yang_str2ipv4p(keys->key[0], &prefix); |
6270ce38 RW |
1296 | |
1297 | rn = route_node_lookup(rip->table, &prefix); | |
1298 | if (!rn || !rn->info) | |
1299 | return NULL; | |
1300 | ||
1301 | route_unlock_node(rn); | |
1302 | ||
9c472033 | 1303 | return rn; |
707656ec RW |
1304 | } |
1305 | ||
1306 | /* | |
32600a98 | 1307 | * XPath: /frr-ripd:ripd/instance/state/routes/route/prefix |
707656ec RW |
1308 | */ |
1309 | static struct yang_data * | |
32600a98 RW |
1310 | ripd_instance_state_routes_route_prefix_get_elem(const char *xpath, |
1311 | const void *list_entry) | |
707656ec | 1312 | { |
9c472033 RW |
1313 | const struct route_node *rn = list_entry; |
1314 | const struct rip_info *rinfo = listnode_head(rn->info); | |
6270ce38 RW |
1315 | |
1316 | return yang_data_new_ipv4p(xpath, &rinfo->rp->p); | |
707656ec RW |
1317 | } |
1318 | ||
1319 | /* | |
32600a98 | 1320 | * XPath: /frr-ripd:ripd/instance/state/routes/route/next-hop |
707656ec RW |
1321 | */ |
1322 | static struct yang_data * | |
32600a98 RW |
1323 | ripd_instance_state_routes_route_next_hop_get_elem(const char *xpath, |
1324 | const void *list_entry) | |
707656ec | 1325 | { |
9c472033 RW |
1326 | const struct route_node *rn = list_entry; |
1327 | const struct rip_info *rinfo = listnode_head(rn->info); | |
6270ce38 RW |
1328 | |
1329 | switch (rinfo->nh.type) { | |
1330 | case NEXTHOP_TYPE_IPV4: | |
1331 | case NEXTHOP_TYPE_IPV4_IFINDEX: | |
1332 | return yang_data_new_ipv4(xpath, &rinfo->nh.gate.ipv4); | |
1333 | default: | |
1334 | return NULL; | |
1335 | } | |
707656ec RW |
1336 | } |
1337 | ||
1338 | /* | |
32600a98 | 1339 | * XPath: /frr-ripd:ripd/instance/state/routes/route/interface |
707656ec RW |
1340 | */ |
1341 | static struct yang_data * | |
32600a98 RW |
1342 | ripd_instance_state_routes_route_interface_get_elem(const char *xpath, |
1343 | const void *list_entry) | |
707656ec | 1344 | { |
9c472033 RW |
1345 | const struct route_node *rn = list_entry; |
1346 | const struct rip_info *rinfo = listnode_head(rn->info); | |
32600a98 | 1347 | const struct rip *rip = rip_info_get_instance(rinfo); |
6270ce38 RW |
1348 | |
1349 | switch (rinfo->nh.type) { | |
1350 | case NEXTHOP_TYPE_IFINDEX: | |
1351 | case NEXTHOP_TYPE_IPV4_IFINDEX: | |
1352 | return yang_data_new_string( | |
32600a98 RW |
1353 | xpath, |
1354 | ifindex2ifname(rinfo->nh.ifindex, rip->vrf->vrf_id)); | |
6270ce38 RW |
1355 | default: |
1356 | return NULL; | |
1357 | } | |
707656ec RW |
1358 | } |
1359 | ||
1360 | /* | |
32600a98 | 1361 | * XPath: /frr-ripd:ripd/instance/state/routes/route/metric |
707656ec RW |
1362 | */ |
1363 | static struct yang_data * | |
32600a98 RW |
1364 | ripd_instance_state_routes_route_metric_get_elem(const char *xpath, |
1365 | const void *list_entry) | |
707656ec | 1366 | { |
9c472033 RW |
1367 | const struct route_node *rn = list_entry; |
1368 | const struct rip_info *rinfo = listnode_head(rn->info); | |
6270ce38 RW |
1369 | |
1370 | return yang_data_new_uint8(xpath, rinfo->metric); | |
707656ec RW |
1371 | } |
1372 | ||
1373 | /* | |
1374 | * XPath: /frr-ripd:clear-rip-route | |
1375 | */ | |
14f17e63 | 1376 | static void clear_rip_route(struct rip *rip) |
707656ec | 1377 | { |
1137aef4 | 1378 | struct route_node *rp; |
1137aef4 | 1379 | |
14f17e63 RW |
1380 | if (IS_RIP_DEBUG_EVENT) |
1381 | zlog_debug("Clearing all RIP routes (VRF %s)", rip->vrf_name); | |
1137aef4 RW |
1382 | |
1383 | /* Clear received RIP routes */ | |
1384 | for (rp = route_top(rip->table); rp; rp = route_next(rp)) { | |
14f17e63 RW |
1385 | struct list *list; |
1386 | struct listnode *listnode; | |
1387 | struct rip_info *rinfo; | |
1388 | ||
1137aef4 RW |
1389 | list = rp->info; |
1390 | if (!list) | |
1391 | continue; | |
1392 | ||
1393 | for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) { | |
1394 | if (!rip_route_rte(rinfo)) | |
1395 | continue; | |
1396 | ||
1397 | if (CHECK_FLAG(rinfo->flags, RIP_RTF_FIB)) | |
045c5389 | 1398 | rip_zebra_ipv4_delete(rip, rp); |
1137aef4 RW |
1399 | break; |
1400 | } | |
1401 | ||
1402 | if (rinfo) { | |
1403 | RIP_TIMER_OFF(rinfo->t_timeout); | |
1404 | RIP_TIMER_OFF(rinfo->t_garbage_collect); | |
1405 | listnode_delete(list, rinfo); | |
1406 | rip_info_free(rinfo); | |
1407 | } | |
1408 | ||
1409 | if (list_isempty(list)) { | |
1410 | list_delete(&list); | |
1411 | rp->info = NULL; | |
1412 | route_unlock_node(rp); | |
1413 | } | |
1414 | } | |
14f17e63 RW |
1415 | } |
1416 | ||
1417 | static int clear_rip_route_rpc(const char *xpath, const struct list *input, | |
1418 | struct list *output) | |
1419 | { | |
1420 | struct rip *rip; | |
1421 | struct yang_data *yang_vrf; | |
1422 | ||
1423 | yang_vrf = yang_data_list_find(input, "%s/%s", xpath, "input/vrf"); | |
1424 | if (yang_vrf) { | |
1425 | rip = rip_lookup_by_vrf_name(yang_vrf->value); | |
1426 | if (rip) | |
1427 | clear_rip_route(rip); | |
1428 | } else { | |
1429 | struct vrf *vrf; | |
1430 | ||
1431 | RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { | |
1432 | rip = vrf->info; | |
1433 | if (!rip) | |
1434 | continue; | |
1435 | ||
1436 | clear_rip_route(rip); | |
1437 | } | |
1438 | } | |
1137aef4 | 1439 | |
707656ec RW |
1440 | return NB_OK; |
1441 | } | |
1442 | ||
fe339c95 RW |
1443 | /* |
1444 | * XPath: /frr-ripd:authentication-type-failure | |
1445 | */ | |
1446 | void ripd_notif_send_auth_type_failure(const char *ifname) | |
1447 | { | |
1448 | const char *xpath = "/frr-ripd:authentication-type-failure"; | |
1449 | struct list *arguments; | |
1450 | char xpath_arg[XPATH_MAXLEN]; | |
1451 | struct yang_data *data; | |
1452 | ||
1453 | arguments = yang_data_list_new(); | |
1454 | ||
1455 | snprintf(xpath_arg, sizeof(xpath_arg), "%s/interface-name", xpath); | |
1456 | data = yang_data_new_string(xpath_arg, ifname); | |
1457 | listnode_add(arguments, data); | |
1458 | ||
1459 | nb_notification_send(xpath, arguments); | |
1460 | } | |
1461 | ||
1462 | /* | |
1463 | * XPath: /frr-ripd:authentication-failure | |
1464 | */ | |
1465 | void ripd_notif_send_auth_failure(const char *ifname) | |
1466 | { | |
1467 | const char *xpath = "/frr-ripd:authentication-failure"; | |
1468 | struct list *arguments; | |
1469 | char xpath_arg[XPATH_MAXLEN]; | |
1470 | struct yang_data *data; | |
1471 | ||
1472 | arguments = yang_data_list_new(); | |
1473 | ||
1474 | snprintf(xpath_arg, sizeof(xpath_arg), "%s/interface-name", xpath); | |
1475 | data = yang_data_new_string(xpath_arg, ifname); | |
1476 | listnode_add(arguments, data); | |
1477 | ||
1478 | nb_notification_send(xpath, arguments); | |
1479 | } | |
1480 | ||
707656ec RW |
1481 | /* clang-format off */ |
1482 | const struct frr_yang_module_info frr_ripd_info = { | |
1483 | .name = "frr-ripd", | |
1484 | .nodes = { | |
1485 | { | |
1486 | .xpath = "/frr-ripd:ripd/instance", | |
53280f93 DL |
1487 | .cbs = { |
1488 | .cli_show = cli_show_router_rip, | |
1489 | .create = ripd_instance_create, | |
1490 | .destroy = ripd_instance_destroy, | |
1491 | .get_keys = ripd_instance_get_keys, | |
1492 | .get_next = ripd_instance_get_next, | |
1493 | .lookup_entry = ripd_instance_lookup_entry, | |
1494 | }, | |
707656ec RW |
1495 | }, |
1496 | { | |
1497 | .xpath = "/frr-ripd:ripd/instance/allow-ecmp", | |
53280f93 DL |
1498 | .cbs = { |
1499 | .cli_show = cli_show_rip_allow_ecmp, | |
1500 | .modify = ripd_instance_allow_ecmp_modify, | |
1501 | }, | |
707656ec RW |
1502 | }, |
1503 | { | |
1504 | .xpath = "/frr-ripd:ripd/instance/default-information-originate", | |
53280f93 DL |
1505 | .cbs = { |
1506 | .cli_show = cli_show_rip_default_information_originate, | |
1507 | .modify = ripd_instance_default_information_originate_modify, | |
1508 | }, | |
707656ec RW |
1509 | }, |
1510 | { | |
1511 | .xpath = "/frr-ripd:ripd/instance/default-metric", | |
53280f93 DL |
1512 | .cbs = { |
1513 | .cli_show = cli_show_rip_default_metric, | |
1514 | .modify = ripd_instance_default_metric_modify, | |
1515 | }, | |
707656ec RW |
1516 | }, |
1517 | { | |
1518 | .xpath = "/frr-ripd:ripd/instance/distance/default", | |
53280f93 DL |
1519 | .cbs = { |
1520 | .cli_show = cli_show_rip_distance, | |
1521 | .modify = ripd_instance_distance_default_modify, | |
1522 | }, | |
707656ec RW |
1523 | }, |
1524 | { | |
1525 | .xpath = "/frr-ripd:ripd/instance/distance/source", | |
53280f93 DL |
1526 | .cbs = { |
1527 | .cli_show = cli_show_rip_distance_source, | |
1528 | .create = ripd_instance_distance_source_create, | |
1529 | .destroy = ripd_instance_distance_source_destroy, | |
1530 | }, | |
707656ec RW |
1531 | }, |
1532 | { | |
1533 | .xpath = "/frr-ripd:ripd/instance/distance/source/distance", | |
53280f93 DL |
1534 | .cbs = { |
1535 | .modify = ripd_instance_distance_source_distance_modify, | |
1536 | }, | |
707656ec RW |
1537 | }, |
1538 | { | |
1539 | .xpath = "/frr-ripd:ripd/instance/distance/source/access-list", | |
53280f93 DL |
1540 | .cbs = { |
1541 | .destroy = ripd_instance_distance_source_access_list_destroy, | |
1542 | .modify = ripd_instance_distance_source_access_list_modify, | |
1543 | }, | |
707656ec RW |
1544 | }, |
1545 | { | |
1546 | .xpath = "/frr-ripd:ripd/instance/explicit-neighbor", | |
53280f93 DL |
1547 | .cbs = { |
1548 | .cli_show = cli_show_rip_neighbor, | |
1549 | .create = ripd_instance_explicit_neighbor_create, | |
1550 | .destroy = ripd_instance_explicit_neighbor_destroy, | |
1551 | }, | |
707656ec RW |
1552 | }, |
1553 | { | |
1554 | .xpath = "/frr-ripd:ripd/instance/network", | |
53280f93 DL |
1555 | .cbs = { |
1556 | .cli_show = cli_show_rip_network_prefix, | |
1557 | .create = ripd_instance_network_create, | |
1558 | .destroy = ripd_instance_network_destroy, | |
1559 | }, | |
707656ec RW |
1560 | }, |
1561 | { | |
1562 | .xpath = "/frr-ripd:ripd/instance/interface", | |
53280f93 DL |
1563 | .cbs = { |
1564 | .cli_show = cli_show_rip_network_interface, | |
1565 | .create = ripd_instance_interface_create, | |
1566 | .destroy = ripd_instance_interface_destroy, | |
1567 | }, | |
707656ec RW |
1568 | }, |
1569 | { | |
1570 | .xpath = "/frr-ripd:ripd/instance/offset-list", | |
53280f93 DL |
1571 | .cbs = { |
1572 | .cli_show = cli_show_rip_offset_list, | |
1573 | .create = ripd_instance_offset_list_create, | |
1574 | .destroy = ripd_instance_offset_list_destroy, | |
1575 | }, | |
707656ec RW |
1576 | }, |
1577 | { | |
1578 | .xpath = "/frr-ripd:ripd/instance/offset-list/access-list", | |
53280f93 DL |
1579 | .cbs = { |
1580 | .modify = ripd_instance_offset_list_access_list_modify, | |
1581 | }, | |
707656ec RW |
1582 | }, |
1583 | { | |
1584 | .xpath = "/frr-ripd:ripd/instance/offset-list/metric", | |
53280f93 DL |
1585 | .cbs = { |
1586 | .modify = ripd_instance_offset_list_metric_modify, | |
1587 | }, | |
707656ec RW |
1588 | }, |
1589 | { | |
1590 | .xpath = "/frr-ripd:ripd/instance/passive-default", | |
53280f93 DL |
1591 | .cbs = { |
1592 | .cli_show = cli_show_rip_passive_default, | |
1593 | .modify = ripd_instance_passive_default_modify, | |
1594 | }, | |
707656ec RW |
1595 | }, |
1596 | { | |
1597 | .xpath = "/frr-ripd:ripd/instance/passive-interface", | |
53280f93 DL |
1598 | .cbs = { |
1599 | .cli_show = cli_show_rip_passive_interface, | |
1600 | .create = ripd_instance_passive_interface_create, | |
1601 | .destroy = ripd_instance_passive_interface_destroy, | |
1602 | }, | |
707656ec RW |
1603 | }, |
1604 | { | |
1605 | .xpath = "/frr-ripd:ripd/instance/non-passive-interface", | |
53280f93 DL |
1606 | .cbs = { |
1607 | .cli_show = cli_show_rip_non_passive_interface, | |
1608 | .create = ripd_instance_non_passive_interface_create, | |
1609 | .destroy = ripd_instance_non_passive_interface_destroy, | |
1610 | }, | |
707656ec RW |
1611 | }, |
1612 | { | |
1613 | .xpath = "/frr-ripd:ripd/instance/redistribute", | |
53280f93 DL |
1614 | .cbs = { |
1615 | .apply_finish = ripd_instance_redistribute_apply_finish, | |
1616 | .cli_show = cli_show_rip_redistribute, | |
1617 | .create = ripd_instance_redistribute_create, | |
1618 | .destroy = ripd_instance_redistribute_destroy, | |
1619 | }, | |
707656ec RW |
1620 | }, |
1621 | { | |
1622 | .xpath = "/frr-ripd:ripd/instance/redistribute/route-map", | |
53280f93 DL |
1623 | .cbs = { |
1624 | .destroy = ripd_instance_redistribute_route_map_destroy, | |
1625 | .modify = ripd_instance_redistribute_route_map_modify, | |
1626 | }, | |
707656ec RW |
1627 | }, |
1628 | { | |
1629 | .xpath = "/frr-ripd:ripd/instance/redistribute/metric", | |
53280f93 DL |
1630 | .cbs = { |
1631 | .destroy = ripd_instance_redistribute_metric_destroy, | |
1632 | .modify = ripd_instance_redistribute_metric_modify, | |
1633 | }, | |
707656ec RW |
1634 | }, |
1635 | { | |
1636 | .xpath = "/frr-ripd:ripd/instance/static-route", | |
53280f93 DL |
1637 | .cbs = { |
1638 | .cli_show = cli_show_rip_route, | |
1639 | .create = ripd_instance_static_route_create, | |
1640 | .destroy = ripd_instance_static_route_destroy, | |
1641 | }, | |
707656ec | 1642 | }, |
b745780b RW |
1643 | { |
1644 | .xpath = "/frr-ripd:ripd/instance/timers", | |
53280f93 DL |
1645 | .cbs = { |
1646 | .apply_finish = ripd_instance_timers_apply_finish, | |
1647 | .cli_show = cli_show_rip_timers, | |
1648 | }, | |
b745780b | 1649 | }, |
707656ec RW |
1650 | { |
1651 | .xpath = "/frr-ripd:ripd/instance/timers/flush-interval", | |
53280f93 DL |
1652 | .cbs = { |
1653 | .modify = ripd_instance_timers_flush_interval_modify, | |
1654 | }, | |
707656ec RW |
1655 | }, |
1656 | { | |
1657 | .xpath = "/frr-ripd:ripd/instance/timers/holddown-interval", | |
53280f93 DL |
1658 | .cbs = { |
1659 | .modify = ripd_instance_timers_holddown_interval_modify, | |
1660 | }, | |
707656ec RW |
1661 | }, |
1662 | { | |
1663 | .xpath = "/frr-ripd:ripd/instance/timers/update-interval", | |
53280f93 DL |
1664 | .cbs = { |
1665 | .modify = ripd_instance_timers_update_interval_modify, | |
1666 | }, | |
707656ec | 1667 | }, |
90eff9da RW |
1668 | { |
1669 | .xpath = "/frr-ripd:ripd/instance/version", | |
53280f93 DL |
1670 | .cbs = { |
1671 | .cli_show = cli_show_rip_version, | |
1672 | }, | |
90eff9da | 1673 | }, |
707656ec RW |
1674 | { |
1675 | .xpath = "/frr-ripd:ripd/instance/version/receive", | |
53280f93 DL |
1676 | .cbs = { |
1677 | .modify = ripd_instance_version_receive_modify, | |
1678 | }, | |
707656ec RW |
1679 | }, |
1680 | { | |
1681 | .xpath = "/frr-ripd:ripd/instance/version/send", | |
53280f93 DL |
1682 | .cbs = { |
1683 | .modify = ripd_instance_version_send_modify, | |
1684 | }, | |
707656ec RW |
1685 | }, |
1686 | { | |
1687 | .xpath = "/frr-interface:lib/interface/frr-ripd:rip/split-horizon", | |
53280f93 DL |
1688 | .cbs = { |
1689 | .cli_show = cli_show_ip_rip_split_horizon, | |
1690 | .modify = lib_interface_rip_split_horizon_modify, | |
1691 | }, | |
707656ec RW |
1692 | }, |
1693 | { | |
1694 | .xpath = "/frr-interface:lib/interface/frr-ripd:rip/v2-broadcast", | |
53280f93 DL |
1695 | .cbs = { |
1696 | .cli_show = cli_show_ip_rip_v2_broadcast, | |
1697 | .modify = lib_interface_rip_v2_broadcast_modify, | |
1698 | }, | |
707656ec RW |
1699 | }, |
1700 | { | |
1701 | .xpath = "/frr-interface:lib/interface/frr-ripd:rip/version-receive", | |
53280f93 DL |
1702 | .cbs = { |
1703 | .cli_show = cli_show_ip_rip_receive_version, | |
1704 | .modify = lib_interface_rip_version_receive_modify, | |
1705 | }, | |
707656ec RW |
1706 | }, |
1707 | { | |
1708 | .xpath = "/frr-interface:lib/interface/frr-ripd:rip/version-send", | |
53280f93 DL |
1709 | .cbs = { |
1710 | .cli_show = cli_show_ip_rip_send_version, | |
1711 | .modify = lib_interface_rip_version_send_modify, | |
1712 | }, | |
94b117b2 RW |
1713 | }, |
1714 | { | |
1715 | .xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-scheme", | |
53280f93 DL |
1716 | .cbs = { |
1717 | .cli_show = cli_show_ip_rip_authentication_scheme, | |
1718 | }, | |
707656ec RW |
1719 | }, |
1720 | { | |
1721 | .xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-scheme/mode", | |
53280f93 DL |
1722 | .cbs = { |
1723 | .modify = lib_interface_rip_authentication_scheme_mode_modify, | |
1724 | }, | |
707656ec RW |
1725 | }, |
1726 | { | |
1727 | .xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-scheme/md5-auth-length", | |
53280f93 DL |
1728 | .cbs = { |
1729 | .destroy = lib_interface_rip_authentication_scheme_md5_auth_length_destroy, | |
1730 | .modify = lib_interface_rip_authentication_scheme_md5_auth_length_modify, | |
1731 | }, | |
707656ec RW |
1732 | }, |
1733 | { | |
1734 | .xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-password", | |
53280f93 DL |
1735 | .cbs = { |
1736 | .cli_show = cli_show_ip_rip_authentication_string, | |
1737 | .destroy = lib_interface_rip_authentication_password_destroy, | |
1738 | .modify = lib_interface_rip_authentication_password_modify, | |
1739 | }, | |
707656ec RW |
1740 | }, |
1741 | { | |
1742 | .xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-key-chain", | |
53280f93 DL |
1743 | .cbs = { |
1744 | .cli_show = cli_show_ip_rip_authentication_key_chain, | |
1745 | .destroy = lib_interface_rip_authentication_key_chain_destroy, | |
1746 | .modify = lib_interface_rip_authentication_key_chain_modify, | |
1747 | }, | |
707656ec RW |
1748 | }, |
1749 | { | |
32600a98 | 1750 | .xpath = "/frr-ripd:ripd/instance/state/neighbors/neighbor", |
53280f93 DL |
1751 | .cbs = { |
1752 | .get_keys = ripd_instance_state_neighbors_neighbor_get_keys, | |
1753 | .get_next = ripd_instance_state_neighbors_neighbor_get_next, | |
1754 | .lookup_entry = ripd_instance_state_neighbors_neighbor_lookup_entry, | |
1755 | }, | |
707656ec RW |
1756 | }, |
1757 | { | |
32600a98 | 1758 | .xpath = "/frr-ripd:ripd/instance/state/neighbors/neighbor/address", |
53280f93 DL |
1759 | .cbs = { |
1760 | .get_elem = ripd_instance_state_neighbors_neighbor_address_get_elem, | |
1761 | }, | |
707656ec RW |
1762 | }, |
1763 | { | |
32600a98 | 1764 | .xpath = "/frr-ripd:ripd/instance/state/neighbors/neighbor/last-update", |
53280f93 DL |
1765 | .cbs = { |
1766 | .get_elem = ripd_instance_state_neighbors_neighbor_last_update_get_elem, | |
1767 | }, | |
707656ec RW |
1768 | }, |
1769 | { | |
32600a98 | 1770 | .xpath = "/frr-ripd:ripd/instance/state/neighbors/neighbor/bad-packets-rcvd", |
53280f93 DL |
1771 | .cbs = { |
1772 | .get_elem = ripd_instance_state_neighbors_neighbor_bad_packets_rcvd_get_elem, | |
1773 | }, | |
707656ec RW |
1774 | }, |
1775 | { | |
32600a98 | 1776 | .xpath = "/frr-ripd:ripd/instance/state/neighbors/neighbor/bad-routes-rcvd", |
53280f93 DL |
1777 | .cbs = { |
1778 | .get_elem = ripd_instance_state_neighbors_neighbor_bad_routes_rcvd_get_elem, | |
1779 | }, | |
707656ec RW |
1780 | }, |
1781 | { | |
32600a98 | 1782 | .xpath = "/frr-ripd:ripd/instance/state/routes/route", |
53280f93 DL |
1783 | .cbs = { |
1784 | .get_keys = ripd_instance_state_routes_route_get_keys, | |
1785 | .get_next = ripd_instance_state_routes_route_get_next, | |
1786 | .lookup_entry = ripd_instance_state_routes_route_lookup_entry, | |
1787 | }, | |
707656ec RW |
1788 | }, |
1789 | { | |
32600a98 | 1790 | .xpath = "/frr-ripd:ripd/instance/state/routes/route/prefix", |
53280f93 DL |
1791 | .cbs = { |
1792 | .get_elem = ripd_instance_state_routes_route_prefix_get_elem, | |
1793 | }, | |
707656ec RW |
1794 | }, |
1795 | { | |
32600a98 | 1796 | .xpath = "/frr-ripd:ripd/instance/state/routes/route/next-hop", |
53280f93 DL |
1797 | .cbs = { |
1798 | .get_elem = ripd_instance_state_routes_route_next_hop_get_elem, | |
1799 | }, | |
707656ec RW |
1800 | }, |
1801 | { | |
32600a98 | 1802 | .xpath = "/frr-ripd:ripd/instance/state/routes/route/interface", |
53280f93 DL |
1803 | .cbs = { |
1804 | .get_elem = ripd_instance_state_routes_route_interface_get_elem, | |
1805 | }, | |
707656ec RW |
1806 | }, |
1807 | { | |
32600a98 | 1808 | .xpath = "/frr-ripd:ripd/instance/state/routes/route/metric", |
53280f93 DL |
1809 | .cbs = { |
1810 | .get_elem = ripd_instance_state_routes_route_metric_get_elem, | |
1811 | }, | |
707656ec RW |
1812 | }, |
1813 | { | |
1814 | .xpath = "/frr-ripd:clear-rip-route", | |
53280f93 DL |
1815 | .cbs = { |
1816 | .rpc = clear_rip_route_rpc, | |
1817 | }, | |
707656ec RW |
1818 | }, |
1819 | { | |
1820 | .xpath = NULL, | |
1821 | }, | |
1822 | } | |
1823 | }; |