]>
git.proxmox.com Git - mirror_frr.git/blob - ripngd/ripng_nb_state.c
926573b407c34cf173121975e1fbc00c2162ee36
2 * Copyright (C) 2018 NetDEF, 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
29 #include "agg_table.h"
30 #include "northbound.h"
33 #include "ripngd/ripngd.h"
34 #include "ripngd/ripng_nb.h"
35 #include "ripngd/ripng_debug.h"
36 #include "ripngd/ripng_route.h"
39 * XPath: /frr-ripngd:ripngd/instance/state/neighbors/neighbor
41 const void *ripngd_instance_state_neighbors_neighbor_get_next(
42 struct nb_cb_get_next_args
*args
)
44 const struct ripng
*ripng
= args
->parent_list_entry
;
45 struct listnode
*node
;
47 if (args
->list_entry
== NULL
)
48 node
= listhead(ripng
->peer_list
);
50 node
= listnextnode((struct listnode
*)args
->list_entry
);
55 int ripngd_instance_state_neighbors_neighbor_get_keys(
56 struct nb_cb_get_keys_args
*args
)
58 const struct listnode
*node
= args
->list_entry
;
59 const struct ripng_peer
*peer
= listgetdata(node
);
62 (void)inet_ntop(AF_INET6
, &peer
->addr
, args
->keys
->key
[0],
63 sizeof(args
->keys
->key
[0]));
68 const void *ripngd_instance_state_neighbors_neighbor_lookup_entry(
69 struct nb_cb_lookup_entry_args
*args
)
71 const struct ripng
*ripng
= args
->parent_list_entry
;
72 struct in6_addr address
;
73 struct ripng_peer
*peer
;
74 struct listnode
*node
;
76 yang_str2ipv6(args
->keys
->key
[0], &address
);
78 for (ALL_LIST_ELEMENTS_RO(ripng
->peer_list
, node
, peer
)) {
79 if (IPV6_ADDR_SAME(&peer
->addr
, &address
))
87 * XPath: /frr-ripngd:ripngd/instance/state/neighbors/neighbor/address
89 struct yang_data
*ripngd_instance_state_neighbors_neighbor_address_get_elem(
90 struct nb_cb_get_elem_args
*args
)
92 const struct listnode
*node
= args
->list_entry
;
93 const struct ripng_peer
*peer
= listgetdata(node
);
95 return yang_data_new_ipv6(args
->xpath
, &peer
->addr
);
99 * XPath: /frr-ripngd:ripngd/instance/state/neighbors/neighbor/last-update
101 struct yang_data
*ripngd_instance_state_neighbors_neighbor_last_update_get_elem(
102 struct nb_cb_get_elem_args
*args
)
104 /* TODO: yang:date-and-time is tricky */
109 * XPath: /frr-ripngd:ripngd/instance/state/neighbors/neighbor/bad-packets-rcvd
112 ripngd_instance_state_neighbors_neighbor_bad_packets_rcvd_get_elem(
113 struct nb_cb_get_elem_args
*args
)
115 const struct listnode
*node
= args
->list_entry
;
116 const struct ripng_peer
*peer
= listgetdata(node
);
118 return yang_data_new_uint32(args
->xpath
, peer
->recv_badpackets
);
122 * XPath: /frr-ripngd:ripngd/instance/state/neighbors/neighbor/bad-routes-rcvd
125 ripngd_instance_state_neighbors_neighbor_bad_routes_rcvd_get_elem(
126 struct nb_cb_get_elem_args
*args
)
128 const struct listnode
*node
= args
->list_entry
;
129 const struct ripng_peer
*peer
= listgetdata(node
);
131 return yang_data_new_uint32(args
->xpath
, peer
->recv_badroutes
);
135 * XPath: /frr-ripngd:ripngd/instance/state/routes/route
138 ripngd_instance_state_routes_route_get_next(struct nb_cb_get_next_args
*args
)
140 const struct ripng
*ripng
= args
->parent_list_entry
;
143 if (args
->list_entry
== NULL
)
144 rn
= agg_route_top(ripng
->table
);
146 rn
= agg_route_next((struct agg_node
*)args
->list_entry
);
147 while (rn
&& rn
->info
== NULL
)
148 rn
= agg_route_next(rn
);
153 int ripngd_instance_state_routes_route_get_keys(
154 struct nb_cb_get_keys_args
*args
)
156 const struct agg_node
*rn
= args
->list_entry
;
159 (void)prefix2str(agg_node_get_prefix(rn
), args
->keys
->key
[0],
160 sizeof(args
->keys
->key
[0]));
165 const void *ripngd_instance_state_routes_route_lookup_entry(
166 struct nb_cb_lookup_entry_args
*args
)
168 const struct ripng
*ripng
= args
->parent_list_entry
;
169 struct prefix prefix
;
172 yang_str2ipv6p(args
->keys
->key
[0], &prefix
);
174 rn
= agg_node_lookup(ripng
->table
, &prefix
);
175 if (!rn
|| !rn
->info
)
184 * XPath: /frr-ripngd:ripngd/instance/state/routes/route/prefix
186 struct yang_data
*ripngd_instance_state_routes_route_prefix_get_elem(
187 struct nb_cb_get_elem_args
*args
)
189 const struct agg_node
*rn
= args
->list_entry
;
190 const struct ripng_info
*rinfo
= listnode_head(rn
->info
);
192 return yang_data_new_ipv6p(args
->xpath
, agg_node_get_prefix(rinfo
->rp
));
196 * XPath: /frr-ripngd:ripngd/instance/state/routes/route/next-hop
198 struct yang_data
*ripngd_instance_state_routes_route_next_hop_get_elem(
199 struct nb_cb_get_elem_args
*args
)
201 const struct agg_node
*rn
= args
->list_entry
;
202 const struct ripng_info
*rinfo
= listnode_head(rn
->info
);
204 return yang_data_new_ipv6(args
->xpath
, &rinfo
->nexthop
);
208 * XPath: /frr-ripngd:ripngd/instance/state/routes/route/interface
210 struct yang_data
*ripngd_instance_state_routes_route_interface_get_elem(
211 struct nb_cb_get_elem_args
*args
)
213 const struct agg_node
*rn
= args
->list_entry
;
214 const struct ripng_info
*rinfo
= listnode_head(rn
->info
);
215 const struct ripng
*ripng
= ripng_info_get_instance(rinfo
);
217 return yang_data_new_string(
219 ifindex2ifname(rinfo
->ifindex
, ripng
->vrf
->vrf_id
));
223 * XPath: /frr-ripngd:ripngd/instance/state/routes/route/metric
225 struct yang_data
*ripngd_instance_state_routes_route_metric_get_elem(
226 struct nb_cb_get_elem_args
*args
)
228 const struct agg_node
*rn
= args
->list_entry
;
229 const struct ripng_info
*rinfo
= listnode_head(rn
->info
);
231 return yang_data_new_uint8(args
->xpath
, rinfo
->metric
);