2 * Copyright (C) 2020 Cumulus Networks, Inc.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "northbound.h"
24 #include "zebra/interface.h"
25 #include "zebra/zebra_router.h"
26 #include "zebra/debug.h"
30 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/state/up-count
33 lib_interface_zebra_state_up_count_get_elem(struct nb_cb_get_elem_args
*args
)
35 const struct interface
*ifp
= args
->list_entry
;
36 struct zebra_if
*zebra_if
;
40 return yang_data_new_uint16(args
->xpath
, zebra_if
->up_count
);
44 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/state/down-count
47 lib_interface_zebra_state_down_count_get_elem(struct nb_cb_get_elem_args
*args
)
49 const struct interface
*ifp
= args
->list_entry
;
50 struct zebra_if
*zebra_if
;
54 return yang_data_new_uint16(args
->xpath
, zebra_if
->down_count
);
58 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/state/zif-type
61 lib_interface_zebra_state_zif_type_get_elem(struct nb_cb_get_elem_args
*args
)
63 /* TODO: implement me. */
68 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/state/ptm-status
71 lib_interface_zebra_state_ptm_status_get_elem(struct nb_cb_get_elem_args
*args
)
73 /* TODO: implement me. */
78 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/state/vlan-id
81 lib_interface_zebra_state_vlan_id_get_elem(struct nb_cb_get_elem_args
*args
)
83 const struct interface
*ifp
= args
->list_entry
;
84 struct zebra_if
*zebra_if
;
85 struct zebra_l2info_vlan
*vlan_info
;
87 if (!IS_ZEBRA_IF_VLAN(ifp
))
91 vlan_info
= &zebra_if
->l2info
.vl
;
93 return yang_data_new_uint16(args
->xpath
, vlan_info
->vid
);
97 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/state/vni-id
100 lib_interface_zebra_state_vni_id_get_elem(struct nb_cb_get_elem_args
*args
)
102 const struct interface
*ifp
= args
->list_entry
;
103 struct zebra_if
*zebra_if
;
104 struct zebra_l2info_vxlan
*vxlan_info
;
106 if (!IS_ZEBRA_IF_VXLAN(ifp
))
109 zebra_if
= ifp
->info
;
110 vxlan_info
= &zebra_if
->l2info
.vxl
;
112 return yang_data_new_uint32(args
->xpath
, vxlan_info
->vni
);
116 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/state/remote-vtep
119 lib_interface_zebra_state_remote_vtep_get_elem(struct nb_cb_get_elem_args
*args
)
121 const struct interface
*ifp
= args
->list_entry
;
122 struct zebra_if
*zebra_if
;
123 struct zebra_l2info_vxlan
*vxlan_info
;
125 if (!IS_ZEBRA_IF_VXLAN(ifp
))
128 zebra_if
= ifp
->info
;
129 vxlan_info
= &zebra_if
->l2info
.vxl
;
131 return yang_data_new_ipv4(args
->xpath
, &vxlan_info
->vtep_ip
);
135 * XPath: /frr-interface:lib/interface/frr-zebra:zebra/state/mcast-group
138 lib_interface_zebra_state_mcast_group_get_elem(struct nb_cb_get_elem_args
*args
)
140 const struct interface
*ifp
= args
->list_entry
;
141 struct zebra_if
*zebra_if
;
142 struct zebra_l2info_vxlan
*vxlan_info
;
144 if (!IS_ZEBRA_IF_VXLAN(ifp
))
147 zebra_if
= ifp
->info
;
148 vxlan_info
= &zebra_if
->l2info
.vxl
;
150 return yang_data_new_ipv4(args
->xpath
, &vxlan_info
->mcast_grp
);
153 const void *lib_vrf_zebra_ribs_rib_get_next(struct nb_cb_get_next_args
*args
)
155 struct vrf
*vrf
= (struct vrf
*)args
->parent_list_entry
;
156 struct zebra_router_table
*zrt
=
157 (struct zebra_router_table
*)args
->list_entry
;
159 struct zebra_vrf
*zvrf
;
163 zvrf
= zebra_vrf_lookup_by_id(vrf
->vrf_id
);
165 if (args
->list_entry
== NULL
) {
169 zrt
= zebra_router_find_zrt(zvrf
, zvrf
->table_id
, afi
, safi
);
173 zrt
= RB_NEXT(zebra_router_table_head
, zrt
);
174 /* vrf_id/ns_id do not match, only walk for the given VRF */
175 while (zrt
&& zrt
->ns_id
!= zvrf
->zns
->ns_id
)
176 zrt
= RB_NEXT(zebra_router_table_head
, zrt
);
182 int lib_vrf_zebra_ribs_rib_get_keys(struct nb_cb_get_keys_args
*args
)
184 const struct zebra_router_table
*zrt
= args
->list_entry
;
188 snprintfrr(args
->keys
->key
[0], sizeof(args
->keys
->key
[0]), "%s",
189 yang_afi_safi_value2identity(zrt
->afi
, zrt
->safi
));
190 snprintfrr(args
->keys
->key
[1], sizeof(args
->keys
->key
[1]), "%u",
197 lib_vrf_zebra_ribs_rib_lookup_entry(struct nb_cb_lookup_entry_args
*args
)
199 struct vrf
*vrf
= (struct vrf
*)args
->parent_list_entry
;
200 struct zebra_vrf
*zvrf
;
203 uint32_t table_id
= 0;
205 zvrf
= zebra_vrf_lookup_by_id(vrf
->vrf_id
);
207 yang_afi_safi_identity2value(args
->keys
->key
[0], &afi
, &safi
);
208 table_id
= yang_str2uint32(args
->keys
->key
[1]);
209 /* table_id 0 assume vrf's table_id. */
211 table_id
= zvrf
->table_id
;
213 return zebra_router_find_zrt(zvrf
, table_id
, afi
, safi
);
217 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/afi-safi-name
220 lib_vrf_zebra_ribs_rib_afi_safi_name_get_elem(struct nb_cb_get_elem_args
*args
)
222 const struct zebra_router_table
*zrt
= args
->list_entry
;
224 return yang_data_new_string(args
->xpath
,
225 yang_afi_safi_value2identity(zrt
->afi
, zrt
->safi
));
229 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/table-id
232 lib_vrf_zebra_ribs_rib_table_id_get_elem(struct nb_cb_get_elem_args
*args
)
234 const struct zebra_router_table
*zrt
= args
->list_entry
;
236 return yang_data_new_uint32(args
->xpath
, zrt
->tableid
);
240 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route
243 lib_vrf_zebra_ribs_rib_route_get_next(struct nb_cb_get_next_args
*args
)
245 const struct zebra_router_table
*zrt
= args
->parent_list_entry
;
246 struct route_node
*rn
= (struct route_node
*)args
->list_entry
;
248 if (args
->list_entry
== NULL
)
249 rn
= route_top(zrt
->table
);
251 rn
= srcdest_route_next((struct route_node
*)rn
);
252 /* Optimization: skip empty route nodes. */
253 while (rn
&& rn
->info
== NULL
)
256 /* Skip link-local routes. */
257 if (rn
&& rn
->p
.family
== AF_INET6
258 && IN6_IS_ADDR_LINKLOCAL(&rn
->p
.u
.prefix6
))
264 int lib_vrf_zebra_ribs_rib_route_get_keys(struct nb_cb_get_keys_args
*args
)
266 const struct route_node
*rn
= args
->list_entry
;
269 prefix2str(&rn
->p
, args
->keys
->key
[0], sizeof(args
->keys
->key
[0]));
275 lib_vrf_zebra_ribs_rib_route_lookup_entry(struct nb_cb_lookup_entry_args
*args
)
277 const struct zebra_router_table
*zrt
= args
->parent_list_entry
;
279 struct route_node
*rn
;
281 yang_str2prefix(args
->keys
->key
[0], &p
);
283 rn
= route_node_lookup(zrt
->table
, &p
);
288 route_unlock_node(rn
);
294 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/prefix
297 lib_vrf_zebra_ribs_rib_route_prefix_get_elem(struct nb_cb_get_elem_args
*args
)
299 const struct route_node
*rn
= args
->list_entry
;
301 return yang_data_new_prefix(args
->xpath
, &rn
->p
);
305 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry
307 const void *lib_vrf_zebra_ribs_rib_route_route_entry_get_next(
308 struct nb_cb_get_next_args
*args
)
310 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
311 struct route_node
*rn
= (struct route_node
*)args
->parent_list_entry
;
313 if (args
->list_entry
== NULL
)
314 RNODE_FIRST_RE(rn
, re
);
316 RNODE_NEXT_RE(rn
, re
);
321 int lib_vrf_zebra_ribs_rib_route_route_entry_get_keys(
322 struct nb_cb_get_keys_args
*args
)
324 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
328 strlcpy(args
->keys
->key
[0], zebra_route_string(re
->type
),
329 sizeof(args
->keys
->key
[0]));
334 const void *lib_vrf_zebra_ribs_rib_route_route_entry_lookup_entry(
335 struct nb_cb_lookup_entry_args
*args
)
337 struct route_node
*rn
= (struct route_node
*)args
->parent_list_entry
;
338 struct route_entry
*re
= NULL
;
342 afi
= family2afi(rn
->p
.family
);
343 proto_type
= proto_redistnum(afi
, args
->keys
->key
[0]);
345 RNODE_FOREACH_RE (rn
, re
) {
346 if (proto_type
== re
->type
)
354 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/protocol
356 struct yang_data
*lib_vrf_zebra_ribs_rib_route_route_entry_protocol_get_elem(
357 struct nb_cb_get_elem_args
*args
)
359 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
361 return yang_data_new_enum(args
->xpath
, re
->type
);
365 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/instance
367 struct yang_data
*lib_vrf_zebra_ribs_rib_route_route_entry_instance_get_elem(
368 struct nb_cb_get_elem_args
*args
)
370 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
373 return yang_data_new_uint16(args
->xpath
, re
->instance
);
379 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/distance
381 struct yang_data
*lib_vrf_zebra_ribs_rib_route_route_entry_distance_get_elem(
382 struct nb_cb_get_elem_args
*args
)
384 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
386 return yang_data_new_uint8(args
->xpath
, re
->distance
);
390 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/metric
392 struct yang_data
*lib_vrf_zebra_ribs_rib_route_route_entry_metric_get_elem(
393 struct nb_cb_get_elem_args
*args
)
395 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
397 return yang_data_new_uint32(args
->xpath
, re
->metric
);
401 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/tag
403 struct yang_data
*lib_vrf_zebra_ribs_rib_route_route_entry_tag_get_elem(
404 struct nb_cb_get_elem_args
*args
)
406 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
409 return yang_data_new_uint32(args
->xpath
, re
->tag
);
415 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/selected
417 struct yang_data
*lib_vrf_zebra_ribs_rib_route_route_entry_selected_get_elem(
418 struct nb_cb_get_elem_args
*args
)
420 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
422 if (CHECK_FLAG(re
->flags
, ZEBRA_FLAG_SELECTED
))
423 return yang_data_new_empty(args
->xpath
);
429 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/installed
431 struct yang_data
*lib_vrf_zebra_ribs_rib_route_route_entry_installed_get_elem(
432 struct nb_cb_get_elem_args
*args
)
434 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
436 if (CHECK_FLAG(re
->status
, ROUTE_ENTRY_INSTALLED
))
437 return yang_data_new_empty(args
->xpath
);
443 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/failed
445 struct yang_data
*lib_vrf_zebra_ribs_rib_route_route_entry_failed_get_elem(
446 struct nb_cb_get_elem_args
*args
)
448 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
450 if (CHECK_FLAG(re
->status
, ROUTE_ENTRY_FAILED
))
451 return yang_data_new_empty(args
->xpath
);
457 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/queued
459 struct yang_data
*lib_vrf_zebra_ribs_rib_route_route_entry_queued_get_elem(
460 struct nb_cb_get_elem_args
*args
)
462 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
464 if (CHECK_FLAG(re
->status
, ROUTE_ENTRY_QUEUED
))
465 return yang_data_new_empty(args
->xpath
);
472 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/internal-flags
475 lib_vrf_zebra_ribs_rib_route_route_entry_internal_flags_get_elem(
476 struct nb_cb_get_elem_args
*args
)
478 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
481 return yang_data_new_int32(args
->xpath
, re
->flags
);
488 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/internal-status
491 lib_vrf_zebra_ribs_rib_route_route_entry_internal_status_get_elem(
492 struct nb_cb_get_elem_args
*args
)
494 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
497 return yang_data_new_int32(args
->xpath
, re
->status
);
503 * XPath: /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/uptime
505 struct yang_data
*lib_vrf_zebra_ribs_rib_route_route_entry_uptime_get_elem(
506 struct nb_cb_get_elem_args
*args
)
508 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
510 return yang_data_new_date_and_time(args
->xpath
, re
->uptime
);
515 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/id
518 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_id_get_elem(
519 struct nb_cb_get_elem_args
*args
)
521 struct route_entry
*re
= (struct route_entry
*)args
->list_entry
;
523 return yang_data_new_uint32(args
->xpath
, re
->nhe
->id
);
528 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop
531 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_get_next(
532 struct nb_cb_get_next_args
*args
)
534 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
535 struct route_entry
*re
= (struct route_entry
*)args
->parent_list_entry
;
536 struct nhg_hash_entry
*nhe
= re
->nhe
;
538 if (args
->list_entry
== NULL
) {
539 nexthop
= nhe
->nhg
.nexthop
;
541 nexthop
= nexthop_next(nexthop
);
546 int lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_get_keys(
547 struct nb_cb_get_keys_args
*args
)
549 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
553 strlcpy(args
->keys
->key
[0], yang_nexthop_type2str(nexthop
->type
),
554 sizeof(args
->keys
->key
[0]));
556 snprintfrr(args
->keys
->key
[1], sizeof(args
->keys
->key
[1]), "%" PRIu32
,
559 switch (nexthop
->type
) {
560 case NEXTHOP_TYPE_IPV4
:
561 case NEXTHOP_TYPE_IPV4_IFINDEX
:
562 snprintfrr(args
->keys
->key
[2], sizeof(args
->keys
->key
[2]),
563 "%pI4", &nexthop
->gate
.ipv4
);
564 if (nexthop
->ifindex
)
565 strlcpy(args
->keys
->key
[3],
566 ifindex2ifname(nexthop
->ifindex
,
568 sizeof(args
->keys
->key
[3]));
571 strlcpy(args
->keys
->key
[3], " ",
572 sizeof(args
->keys
->key
[3]));
575 case NEXTHOP_TYPE_IPV6
:
576 case NEXTHOP_TYPE_IPV6_IFINDEX
:
577 snprintfrr(args
->keys
->key
[2], sizeof(args
->keys
->key
[2]),
578 "%pI6", &nexthop
->gate
.ipv6
);
580 if (nexthop
->ifindex
)
581 strlcpy(args
->keys
->key
[3],
582 ifindex2ifname(nexthop
->ifindex
,
584 sizeof(args
->keys
->key
[3]));
587 strlcpy(args
->keys
->key
[3], " ",
588 sizeof(args
->keys
->key
[3]));
591 case NEXTHOP_TYPE_IFINDEX
:
592 strlcpy(args
->keys
->key
[2], "", sizeof(args
->keys
->key
[2]));
593 strlcpy(args
->keys
->key
[3],
594 ifindex2ifname(nexthop
->ifindex
, nexthop
->vrf_id
),
595 sizeof(args
->keys
->key
[3]));
598 case NEXTHOP_TYPE_BLACKHOLE
:
600 strlcpy(args
->keys
->key
[2], "", sizeof(args
->keys
->key
[2]));
601 strlcpy(args
->keys
->key
[3], " ", sizeof(args
->keys
->key
[3]));
611 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_lookup_entry(
612 struct nb_cb_lookup_entry_args
*args
)
614 struct nhg_hash_entry
*nhe
;
615 struct nexthop nexthop_lookup
= {};
616 struct nexthop
*nexthop
;
617 const char *nh_type_str
;
619 nhe
= (struct nhg_hash_entry
*)args
->parent_list_entry
;
620 nexthop_lookup
.vrf_id
= nhe
->vrf_id
;
624 * TODO: use yang_str2enum() instead.
626 nh_type_str
= args
->keys
->key
[0];
627 if (strmatch(nh_type_str
, "ifindex"))
628 nexthop_lookup
.type
= NEXTHOP_TYPE_IFINDEX
;
629 else if (strmatch(nh_type_str
, "ip4"))
630 nexthop_lookup
.type
= NEXTHOP_TYPE_IPV4
;
631 else if (strmatch(nh_type_str
, "ip4-ifindex"))
632 nexthop_lookup
.type
= NEXTHOP_TYPE_IPV4_IFINDEX
;
633 else if (strmatch(nh_type_str
, "ip6"))
634 nexthop_lookup
.type
= NEXTHOP_TYPE_IPV6
;
635 else if (strmatch(nh_type_str
, "ip6-ifindex"))
636 nexthop_lookup
.type
= NEXTHOP_TYPE_IPV6_IFINDEX
;
637 else if (strmatch(nh_type_str
, "blackhole"))
638 nexthop_lookup
.type
= NEXTHOP_TYPE_BLACKHOLE
;
643 /* Get nexthop address. */
644 switch (nexthop_lookup
.type
) {
645 case NEXTHOP_TYPE_IPV4
:
646 case NEXTHOP_TYPE_IPV4_IFINDEX
:
647 yang_str2ipv4(args
->keys
->key
[1], &nexthop_lookup
.gate
.ipv4
);
649 case NEXTHOP_TYPE_IPV6
:
650 case NEXTHOP_TYPE_IPV6_IFINDEX
:
651 yang_str2ipv6(args
->keys
->key
[1], &nexthop_lookup
.gate
.ipv6
);
653 case NEXTHOP_TYPE_IFINDEX
:
654 case NEXTHOP_TYPE_BLACKHOLE
:
658 /* Get nexthop interface. */
659 switch (nexthop_lookup
.type
) {
660 case NEXTHOP_TYPE_IPV4_IFINDEX
:
661 case NEXTHOP_TYPE_IPV6_IFINDEX
:
662 case NEXTHOP_TYPE_IFINDEX
:
663 nexthop_lookup
.ifindex
=
664 ifname2ifindex(args
->keys
->key
[2], nhe
->vrf_id
);
666 case NEXTHOP_TYPE_IPV4
:
667 case NEXTHOP_TYPE_IPV6
:
668 case NEXTHOP_TYPE_BLACKHOLE
:
672 /* Lookup requested nexthop (ignore weight and metric). */
673 for (ALL_NEXTHOPS(nhe
->nhg
, nexthop
)) {
674 nexthop_lookup
.weight
= nexthop
->weight
;
675 nexthop_lookup
.src
= nexthop
->src
;
676 if (nexthop_same_no_labels(&nexthop_lookup
, nexthop
))
685 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/nh-type
688 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_nh_type_get_elem(
689 struct nb_cb_get_elem_args
*args
)
691 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
693 switch (nexthop
->type
) {
694 case NEXTHOP_TYPE_IFINDEX
:
695 return yang_data_new_string(args
->xpath
, "ifindex");
697 case NEXTHOP_TYPE_IPV4
:
698 return yang_data_new_string(args
->xpath
, "ip4");
700 case NEXTHOP_TYPE_IPV4_IFINDEX
:
701 return yang_data_new_string(args
->xpath
, "ip4-ifindex");
703 case NEXTHOP_TYPE_IPV6
:
704 return yang_data_new_string(args
->xpath
, "ip6");
706 case NEXTHOP_TYPE_IPV6_IFINDEX
:
707 return yang_data_new_string(args
->xpath
, "ip6-ifindex");
718 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/vrf
721 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_vrf_get_elem(
722 struct nb_cb_get_elem_args
*args
)
724 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
726 return yang_data_new_string(args
->xpath
,
727 vrf_id_to_name(nexthop
->vrf_id
));
732 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/gateway
735 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_gateway_get_elem(
736 struct nb_cb_get_elem_args
*args
)
738 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
741 switch (nexthop
->type
) {
742 case NEXTHOP_TYPE_IPV4
:
743 case NEXTHOP_TYPE_IPV4_IFINDEX
:
744 addr
.ipa_type
= IPADDR_V4
;
745 memcpy(&addr
.ipaddr_v4
, &(nexthop
->gate
.ipv4
),
746 sizeof(struct in_addr
));
748 case NEXTHOP_TYPE_IPV6
:
749 case NEXTHOP_TYPE_IPV6_IFINDEX
:
750 addr
.ipa_type
= IPADDR_V6
;
751 memcpy(&addr
.ipaddr_v6
, &(nexthop
->gate
.ipv6
),
752 sizeof(struct in6_addr
));
754 case NEXTHOP_TYPE_BLACKHOLE
:
755 case NEXTHOP_TYPE_IFINDEX
:
757 return yang_data_new_string(args
->xpath
, "");
763 return yang_data_new_ip(args
->xpath
, &addr
);
768 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/interface
771 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_interface_get_elem(
772 struct nb_cb_get_elem_args
*args
)
774 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
776 if (nexthop
->ifindex
)
777 return yang_data_new_string(
779 ifindex2ifname(nexthop
->ifindex
, nexthop
->vrf_id
));
786 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/bh-type
789 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_bh_type_get_elem(
790 struct nb_cb_get_elem_args
*args
)
792 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
793 const char *type_str
= "";
795 if (nexthop
->type
!= NEXTHOP_TYPE_BLACKHOLE
)
798 switch (nexthop
->bh_type
) {
802 case BLACKHOLE_REJECT
:
805 case BLACKHOLE_ADMINPROHIB
:
806 type_str
= "prohibited";
808 case BLACKHOLE_UNSPEC
:
813 return yang_data_new_string(args
->xpath
, type_str
);
818 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/onlink
821 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_onlink_get_elem(
822 struct nb_cb_get_elem_args
*args
)
824 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
826 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_ONLINK
))
827 return yang_data_new_bool(args
->xpath
, true);
834 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/srte-color
837 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_color_get_elem(
838 struct nb_cb_get_elem_args
*args
)
840 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
842 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_SRTE
))
843 return yang_data_new_uint32(args
->xpath
, nexthop
->srte_color
);
850 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/mpls-label-stack/entry
853 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_mpls_label_stack_entry_get_next(
854 struct nb_cb_get_next_args
*args
)
856 /* TODO: implement me. */
860 int lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_mpls_label_stack_entry_get_keys(
861 struct nb_cb_get_keys_args
*args
)
863 /* TODO: implement me. */
868 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_mpls_label_stack_entry_lookup_entry(
869 struct nb_cb_lookup_entry_args
*args
)
871 /* TODO: implement me. */
877 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/mpls-label-stack/entry/id
880 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_mpls_label_stack_entry_id_get_elem(
881 struct nb_cb_get_elem_args
*args
)
883 /* TODO: implement me. */
889 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/mpls-label-stack/entry/label
892 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_mpls_label_stack_entry_label_get_elem(
893 struct nb_cb_get_elem_args
*args
)
895 /* TODO: implement me. */
901 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/mpls-label-stack/entry/ttl
904 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_mpls_label_stack_entry_ttl_get_elem(
905 struct nb_cb_get_elem_args
*args
)
907 /* TODO: implement me. */
913 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/mpls-label-stack/entry/traffic-class
916 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_mpls_label_stack_entry_traffic_class_get_elem(
917 struct nb_cb_get_elem_args
*args
)
919 /* TODO: implement me. */
925 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/duplicate
928 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_duplicate_get_elem(
929 struct nb_cb_get_elem_args
*args
)
931 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
933 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_DUPLICATE
))
934 return yang_data_new_empty(args
->xpath
);
941 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/recursive
944 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_recursive_get_elem(
945 struct nb_cb_get_elem_args
*args
)
947 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
949 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_RECURSIVE
))
950 return yang_data_new_empty(args
->xpath
);
957 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/active
960 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_active_get_elem(
961 struct nb_cb_get_elem_args
*args
)
963 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
965 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_ACTIVE
))
966 return yang_data_new_empty(args
->xpath
);
973 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/fib
976 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_fib_get_elem(
977 struct nb_cb_get_elem_args
*args
)
979 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
981 if (CHECK_FLAG(nexthop
->flags
, NEXTHOP_FLAG_FIB
))
982 return yang_data_new_empty(args
->xpath
);
989 * /frr-vrf:lib/vrf/frr-zebra:zebra/ribs/rib/route/route-entry/nexthop-group/nexthop/weight
992 lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_weight_get_elem(
993 struct nb_cb_get_elem_args
*args
)
995 struct nexthop
*nexthop
= (struct nexthop
*)args
->list_entry
;
998 return yang_data_new_uint8(args
->xpath
, nexthop
->weight
);