back to topotato report
topotato coverage report
Current view: top level - ripngd - ripng_nb_state.c (source / functions) Hit Total Coverage
Test: aggregated run ( view descriptions ) Lines: 0 77 0.0 %
Date: 2023-02-24 14:41:08 Functions: 0 14 0.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (C) 2018 NetDEF, Inc.
       3             :  *                    Renato Westphal
       4             :  *
       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)
       8             :  * any later version.
       9             :  *
      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
      13             :  * more details.
      14             :  *
      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
      18             :  */
      19             : 
      20             : #include <zebra.h>
      21             : 
      22             : #include "if.h"
      23             : #include "vrf.h"
      24             : #include "log.h"
      25             : #include "prefix.h"
      26             : #include "table.h"
      27             : #include "command.h"
      28             : #include "routemap.h"
      29             : #include "agg_table.h"
      30             : #include "northbound.h"
      31             : #include "libfrr.h"
      32             : 
      33             : #include "ripngd/ripngd.h"
      34             : #include "ripngd/ripng_nb.h"
      35             : #include "ripngd/ripng_debug.h"
      36             : #include "ripngd/ripng_route.h"
      37             : 
      38             : /*
      39             :  * XPath: /frr-ripngd:ripngd/instance/state/neighbors/neighbor
      40             :  */
      41           0 : const void *ripngd_instance_state_neighbors_neighbor_get_next(
      42             :         struct nb_cb_get_next_args *args)
      43             : {
      44           0 :         const struct ripng *ripng = args->parent_list_entry;
      45           0 :         struct listnode *node;
      46             : 
      47           0 :         if (args->list_entry == NULL)
      48           0 :                 node = listhead(ripng->peer_list);
      49             :         else
      50           0 :                 node = listnextnode((struct listnode *)args->list_entry);
      51             : 
      52           0 :         return node;
      53             : }
      54             : 
      55           0 : int ripngd_instance_state_neighbors_neighbor_get_keys(
      56             :         struct nb_cb_get_keys_args *args)
      57             : {
      58           0 :         const struct listnode *node = args->list_entry;
      59           0 :         const struct ripng_peer *peer = listgetdata(node);
      60             : 
      61           0 :         args->keys->num = 1;
      62           0 :         (void)inet_ntop(AF_INET6, &peer->addr, args->keys->key[0],
      63             :                         sizeof(args->keys->key[0]));
      64             : 
      65           0 :         return NB_OK;
      66             : }
      67             : 
      68           0 : const void *ripngd_instance_state_neighbors_neighbor_lookup_entry(
      69             :         struct nb_cb_lookup_entry_args *args)
      70             : {
      71           0 :         const struct ripng *ripng = args->parent_list_entry;
      72           0 :         struct in6_addr address;
      73           0 :         struct ripng_peer *peer;
      74           0 :         struct listnode *node;
      75             : 
      76           0 :         yang_str2ipv6(args->keys->key[0], &address);
      77             : 
      78           0 :         for (ALL_LIST_ELEMENTS_RO(ripng->peer_list, node, peer)) {
      79           0 :                 if (IPV6_ADDR_SAME(&peer->addr, &address))
      80           0 :                         return node;
      81             :         }
      82             : 
      83             :         return NULL;
      84             : }
      85             : 
      86             : /*
      87             :  * XPath: /frr-ripngd:ripngd/instance/state/neighbors/neighbor/address
      88             :  */
      89           0 : struct yang_data *ripngd_instance_state_neighbors_neighbor_address_get_elem(
      90             :         struct nb_cb_get_elem_args *args)
      91             : {
      92           0 :         const struct listnode *node = args->list_entry;
      93           0 :         const struct ripng_peer *peer = listgetdata(node);
      94             : 
      95           0 :         return yang_data_new_ipv6(args->xpath, &peer->addr);
      96             : }
      97             : 
      98             : /*
      99             :  * XPath: /frr-ripngd:ripngd/instance/state/neighbors/neighbor/last-update
     100             :  */
     101           0 : struct yang_data *ripngd_instance_state_neighbors_neighbor_last_update_get_elem(
     102             :         struct nb_cb_get_elem_args *args)
     103             : {
     104             :         /* TODO: yang:date-and-time is tricky */
     105           0 :         return NULL;
     106             : }
     107             : 
     108             : /*
     109             :  * XPath: /frr-ripngd:ripngd/instance/state/neighbors/neighbor/bad-packets-rcvd
     110             :  */
     111             : struct yang_data *
     112           0 : ripngd_instance_state_neighbors_neighbor_bad_packets_rcvd_get_elem(
     113             :         struct nb_cb_get_elem_args *args)
     114             : {
     115           0 :         const struct listnode *node = args->list_entry;
     116           0 :         const struct ripng_peer *peer = listgetdata(node);
     117             : 
     118           0 :         return yang_data_new_uint32(args->xpath, peer->recv_badpackets);
     119             : }
     120             : 
     121             : /*
     122             :  * XPath: /frr-ripngd:ripngd/instance/state/neighbors/neighbor/bad-routes-rcvd
     123             :  */
     124             : struct yang_data *
     125           0 : ripngd_instance_state_neighbors_neighbor_bad_routes_rcvd_get_elem(
     126             :         struct nb_cb_get_elem_args *args)
     127             : {
     128           0 :         const struct listnode *node = args->list_entry;
     129           0 :         const struct ripng_peer *peer = listgetdata(node);
     130             : 
     131           0 :         return yang_data_new_uint32(args->xpath, peer->recv_badroutes);
     132             : }
     133             : 
     134             : /*
     135             :  * XPath: /frr-ripngd:ripngd/instance/state/routes/route
     136             :  */
     137             : const void *
     138           0 : ripngd_instance_state_routes_route_get_next(struct nb_cb_get_next_args *args)
     139             : {
     140           0 :         const struct ripng *ripng = args->parent_list_entry;
     141           0 :         struct agg_node *rn;
     142             : 
     143           0 :         if (args->list_entry == NULL)
     144           0 :                 rn = agg_route_top(ripng->table);
     145             :         else
     146           0 :                 rn = agg_route_next((struct agg_node *)args->list_entry);
     147             :         /* Optimization: skip empty route nodes. */
     148           0 :         while (rn && rn->info == NULL)
     149           0 :                 rn = agg_route_next(rn);
     150             : 
     151           0 :         return rn;
     152             : }
     153             : 
     154           0 : int ripngd_instance_state_routes_route_get_keys(
     155             :         struct nb_cb_get_keys_args *args)
     156             : {
     157           0 :         const struct agg_node *rn = args->list_entry;
     158             : 
     159           0 :         args->keys->num = 1;
     160           0 :         (void)prefix2str(agg_node_get_prefix(rn), args->keys->key[0],
     161             :                          sizeof(args->keys->key[0]));
     162             : 
     163           0 :         return NB_OK;
     164             : }
     165             : 
     166           0 : const void *ripngd_instance_state_routes_route_lookup_entry(
     167             :         struct nb_cb_lookup_entry_args *args)
     168             : {
     169           0 :         const struct ripng *ripng = args->parent_list_entry;
     170           0 :         struct prefix prefix;
     171           0 :         struct agg_node *rn;
     172             : 
     173           0 :         yang_str2ipv6p(args->keys->key[0], &prefix);
     174             : 
     175           0 :         rn = agg_node_lookup(ripng->table, &prefix);
     176           0 :         if (!rn || !rn->info)
     177             :                 return NULL;
     178             : 
     179           0 :         agg_unlock_node(rn);
     180             : 
     181           0 :         return rn;
     182             : }
     183             : 
     184             : /*
     185             :  * XPath: /frr-ripngd:ripngd/instance/state/routes/route/prefix
     186             :  */
     187           0 : struct yang_data *ripngd_instance_state_routes_route_prefix_get_elem(
     188             :         struct nb_cb_get_elem_args *args)
     189             : {
     190           0 :         const struct agg_node *rn = args->list_entry;
     191           0 :         const struct ripng_info *rinfo = listnode_head(rn->info);
     192             : 
     193           0 :         return yang_data_new_ipv6p(args->xpath, agg_node_get_prefix(rinfo->rp));
     194             : }
     195             : 
     196             : /*
     197             :  * XPath: /frr-ripngd:ripngd/instance/state/routes/route/next-hop
     198             :  */
     199           0 : struct yang_data *ripngd_instance_state_routes_route_next_hop_get_elem(
     200             :         struct nb_cb_get_elem_args *args)
     201             : {
     202           0 :         const struct agg_node *rn = args->list_entry;
     203           0 :         const struct ripng_info *rinfo = listnode_head(rn->info);
     204             : 
     205           0 :         return yang_data_new_ipv6(args->xpath, &rinfo->nexthop);
     206             : }
     207             : 
     208             : /*
     209             :  * XPath: /frr-ripngd:ripngd/instance/state/routes/route/interface
     210             :  */
     211           0 : struct yang_data *ripngd_instance_state_routes_route_interface_get_elem(
     212             :         struct nb_cb_get_elem_args *args)
     213             : {
     214           0 :         const struct agg_node *rn = args->list_entry;
     215           0 :         const struct ripng_info *rinfo = listnode_head(rn->info);
     216           0 :         const struct ripng *ripng = ripng_info_get_instance(rinfo);
     217             : 
     218           0 :         return yang_data_new_string(
     219             :                 args->xpath,
     220           0 :                 ifindex2ifname(rinfo->ifindex, ripng->vrf->vrf_id));
     221             : }
     222             : 
     223             : /*
     224             :  * XPath: /frr-ripngd:ripngd/instance/state/routes/route/metric
     225             :  */
     226           0 : struct yang_data *ripngd_instance_state_routes_route_metric_get_elem(
     227             :         struct nb_cb_get_elem_args *args)
     228             : {
     229           0 :         const struct agg_node *rn = args->list_entry;
     230           0 :         const struct ripng_info *rinfo = listnode_head(rn->info);
     231             : 
     232           0 :         return yang_data_new_uint8(args->xpath, rinfo->metric);
     233             : }

Generated by: LCOV version v1.16-topotato