]> git.proxmox.com Git - mirror_frr.git/blobdiff - ripngd/ripng_northbound.c
zebra: Allow ns delete to happen after under/over flow checks
[mirror_frr.git] / ripngd / ripng_northbound.c
index 6ec80982be26d41d555b9afb3cec0a226aafe6e3..7993714e8d3540a5c93cfe380320651032239049 100644 (file)
@@ -579,14 +579,26 @@ static const void *
 ripngd_state_neighbors_neighbor_get_next(const void *parent_list_entry,
                                         const void *list_entry)
 {
-       /* TODO: implement me. */
-       return NULL;
+       struct listnode *node;
+
+       if (list_entry == NULL)
+               node = listhead(peer_list);
+       else
+               node = listnextnode((struct listnode *)list_entry);
+
+       return node;
 }
 
 static int ripngd_state_neighbors_neighbor_get_keys(const void *list_entry,
                                                    struct yang_list_keys *keys)
 {
-       /* TODO: implement me. */
+       const struct listnode *node = list_entry;
+       const struct ripng_peer *peer = listgetdata(node);
+
+       keys->num = 1;
+       (void)inet_ntop(AF_INET6, &peer->addr, keys->key[0],
+                       sizeof(keys->key[0]));
+
        return NB_OK;
 }
 
@@ -594,7 +606,17 @@ static const void *
 ripngd_state_neighbors_neighbor_lookup_entry(const void *parent_list_entry,
                                             const struct yang_list_keys *keys)
 {
-       /* TODO: implement me. */
+       struct in6_addr address;
+       struct ripng_peer *peer;
+       struct listnode *node;
+
+       yang_str2ipv6(keys->key[0], &address);
+
+       for (ALL_LIST_ELEMENTS_RO(peer_list, node, peer)) {
+               if (IPV6_ADDR_SAME(&peer->addr, &address))
+                       return node;
+       }
+
        return NULL;
 }
 
@@ -605,8 +627,10 @@ static struct yang_data *
 ripngd_state_neighbors_neighbor_address_get_elem(const char *xpath,
                                                 const void *list_entry)
 {
-       /* TODO: implement me. */
-       return NULL;
+       const struct listnode *node = list_entry;
+       const struct ripng_peer *peer = listgetdata(node);
+
+       return yang_data_new_ipv6(xpath, &peer->addr);
 }
 
 /*
@@ -616,7 +640,7 @@ static struct yang_data *
 ripngd_state_neighbors_neighbor_last_update_get_elem(const char *xpath,
                                                     const void *list_entry)
 {
-       /* TODO: implement me. */
+       /* TODO: yang:date-and-time is tricky */
        return NULL;
 }
 
@@ -627,8 +651,10 @@ static struct yang_data *
 ripngd_state_neighbors_neighbor_bad_packets_rcvd_get_elem(
        const char *xpath, const void *list_entry)
 {
-       /* TODO: implement me. */
-       return NULL;
+       const struct listnode *node = list_entry;
+       const struct ripng_peer *peer = listgetdata(node);
+
+       return yang_data_new_uint32(xpath, peer->recv_badpackets);
 }
 
 /*
@@ -638,8 +664,10 @@ static struct yang_data *
 ripngd_state_neighbors_neighbor_bad_routes_rcvd_get_elem(const char *xpath,
                                                         const void *list_entry)
 {
-       /* TODO: implement me. */
-       return NULL;
+       const struct listnode *node = list_entry;
+       const struct ripng_peer *peer = listgetdata(node);
+
+       return yang_data_new_uint32(xpath, peer->recv_badroutes);
 }
 
 /*
@@ -649,14 +677,29 @@ static const void *
 ripngd_state_routes_route_get_next(const void *parent_list_entry,
                                   const void *list_entry)
 {
-       /* TODO: implement me. */
-       return NULL;
+       struct agg_node *rn;
+
+       if (ripng == NULL)
+               return NULL;
+
+       if (list_entry == NULL)
+               rn = agg_route_top(ripng->table);
+       else
+               rn = agg_route_next((struct agg_node *)list_entry);
+       while (rn && rn->info == NULL)
+               rn = agg_route_next(rn);
+
+       return rn;
 }
 
 static int ripngd_state_routes_route_get_keys(const void *list_entry,
                                              struct yang_list_keys *keys)
 {
-       /* TODO: implement me. */
+       const struct agg_node *rn = list_entry;
+
+       keys->num = 1;
+       (void)prefix2str(&rn->p, keys->key[0], sizeof(keys->key[0]));
+
        return NB_OK;
 }
 
@@ -664,8 +707,18 @@ static const void *
 ripngd_state_routes_route_lookup_entry(const void *parent_list_entry,
                                       const struct yang_list_keys *keys)
 {
-       /* TODO: implement me. */
-       return NULL;
+       struct prefix prefix;
+       struct agg_node *rn;
+
+       yang_str2ipv6p(keys->key[0], &prefix);
+
+       rn = agg_node_lookup(ripng->table, &prefix);
+       if (!rn || !rn->info)
+               return NULL;
+
+       agg_unlock_node(rn);
+
+       return rn;
 }
 
 /*
@@ -675,8 +728,10 @@ static struct yang_data *
 ripngd_state_routes_route_prefix_get_elem(const char *xpath,
                                          const void *list_entry)
 {
-       /* TODO: implement me. */
-       return NULL;
+       const struct agg_node *rn = list_entry;
+       const struct ripng_info *rinfo = listnode_head(rn->info);
+
+       return yang_data_new_ipv6p(xpath, &rinfo->rp->p);
 }
 
 /*
@@ -686,8 +741,10 @@ static struct yang_data *
 ripngd_state_routes_route_next_hop_get_elem(const char *xpath,
                                            const void *list_entry)
 {
-       /* TODO: implement me. */
-       return NULL;
+       const struct agg_node *rn = list_entry;
+       const struct ripng_info *rinfo = listnode_head(rn->info);
+
+       return yang_data_new_ipv6(xpath, &rinfo->nexthop);
 }
 
 /*
@@ -697,8 +754,11 @@ static struct yang_data *
 ripngd_state_routes_route_interface_get_elem(const char *xpath,
                                             const void *list_entry)
 {
-       /* TODO: implement me. */
-       return NULL;
+       const struct agg_node *rn = list_entry;
+       const struct ripng_info *rinfo = listnode_head(rn->info);
+
+       return yang_data_new_string(
+               xpath, ifindex2ifname(rinfo->ifindex, VRF_DEFAULT));
 }
 
 /*
@@ -708,8 +768,10 @@ static struct yang_data *
 ripngd_state_routes_route_metric_get_elem(const char *xpath,
                                          const void *list_entry)
 {
-       /* TODO: implement me. */
-       return NULL;
+       const struct agg_node *rn = list_entry;
+       const struct ripng_info *rinfo = listnode_head(rn->info);
+
+       return yang_data_new_uint8(xpath, rinfo->metric);
 }
 
 /*