summaryrefslogtreecommitdiffstats
path: root/ripd
diff options
context:
space:
mode:
authorChristian Hopps <chopps@labn.net>2023-04-07 00:23:31 +0200
committerChristian Hopps <chopps@labn.net>2023-04-07 10:21:17 +0200
commit7fd2ffb96cabc158be10ec942bf650fdfbbb2654 (patch)
treea898a9a9903eb4cd83c416c2d69a6c931df53bc0 /ripd
parentripd: yang: extend nexthops functionality in YANG model - skeleton (diff)
downloadfrr-7fd2ffb96cabc158be10ec942bf650fdfbbb2654.tar.xz
frr-7fd2ffb96cabc158be10ec942bf650fdfbbb2654.zip
ripd: implement new YANG operational state
Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'ripd')
-rw-r--r--ripd/rip_nb_state.c90
1 files changed, 70 insertions, 20 deletions
diff --git a/ripd/rip_nb_state.c b/ripd/rip_nb_state.c
index 6cb1174cc..fa0d382a0 100644
--- a/ripd/rip_nb_state.c
+++ b/ripd/rip_nb_state.c
@@ -207,6 +207,7 @@ struct yang_data *ripd_instance_state_routes_route_prefix_get_elem(
const struct route_node *rn = args->list_entry;
const struct rip_info *rinfo = listnode_head(rn->info);
+ assert(rinfo);
return yang_data_new_ipv4p(args->xpath, &rinfo->rp->p);
}
@@ -216,8 +217,20 @@ struct yang_data *ripd_instance_state_routes_route_prefix_get_elem(
const void *ripd_instance_state_routes_route_nexthops_nexthop_get_next(
struct nb_cb_get_next_args *args)
{
- /* TODO: implement me. */
- return NULL;
+ const struct route_node *rn = args->parent_list_entry;
+ const struct listnode *node = args->list_entry;
+
+ assert(rn);
+ if (node)
+ return listnextnode(node);
+ assert(rn->info);
+ return listhead((struct list *)rn->info);
+}
+
+static inline const struct rip_info *get_rip_info(const void *info)
+{
+ return (const struct rip_info *)listgetdata(
+ (const struct listnode *)info);
}
/*
@@ -227,8 +240,10 @@ struct yang_data *
ripd_instance_state_routes_route_nexthops_nexthop_nh_type_get_elem(
struct nb_cb_get_elem_args *args)
{
- /* TODO: implement me. */
- return NULL;
+ const struct rip_info *rinfo = get_rip_info(args->list_entry);
+
+ assert(rinfo);
+ return yang_data_new_enum(args->xpath, rinfo->nh.type);
}
/*
@@ -238,8 +253,10 @@ struct yang_data *
ripd_instance_state_routes_route_nexthops_nexthop_protocol_get_elem(
struct nb_cb_get_elem_args *args)
{
- /* TODO: implement me. */
- return NULL;
+ const struct rip_info *rinfo = get_rip_info(args->list_entry);
+
+ assert(rinfo);
+ return yang_data_new_enum(args->xpath, rinfo->type);
}
/*
@@ -249,8 +266,10 @@ struct yang_data *
ripd_instance_state_routes_route_nexthops_nexthop_rip_type_get_elem(
struct nb_cb_get_elem_args *args)
{
- /* TODO: implement me. */
- return NULL;
+ const struct rip_info *rinfo = get_rip_info(args->list_entry);
+
+ assert(rinfo);
+ return yang_data_new_enum(args->xpath, rinfo->sub_type);
}
/*
@@ -260,8 +279,13 @@ struct yang_data *
ripd_instance_state_routes_route_nexthops_nexthop_gateway_get_elem(
struct nb_cb_get_elem_args *args)
{
- /* TODO: implement me. */
- return NULL;
+ const struct rip_info *rinfo = get_rip_info(args->list_entry);
+
+ if (rinfo->nh.type != NEXTHOP_TYPE_IPV4 &&
+ rinfo->nh.type != NEXTHOP_TYPE_IPV4_IFINDEX)
+ return NULL;
+
+ return yang_data_new_ipv4(args->xpath, &rinfo->nh.gate.ipv4);
}
/*
@@ -271,8 +295,16 @@ struct yang_data *
ripd_instance_state_routes_route_nexthops_nexthop_interface_get_elem(
struct nb_cb_get_elem_args *args)
{
- /* TODO: implement me. */
- return NULL;
+ const struct rip_info *rinfo = get_rip_info(args->list_entry);
+ const struct rip *rip = rip_info_get_instance(rinfo);
+
+ if (rinfo->nh.type != NEXTHOP_TYPE_IFINDEX &&
+ rinfo->nh.type != NEXTHOP_TYPE_IPV4_IFINDEX)
+ return NULL;
+
+ return yang_data_new_string(
+ args->xpath,
+ ifindex2ifname(rinfo->nh.ifindex, rip->vrf->vrf_id));
}
/*
@@ -282,8 +314,12 @@ struct yang_data *
ripd_instance_state_routes_route_nexthops_nexthop_from_get_elem(
struct nb_cb_get_elem_args *args)
{
- /* TODO: implement me. */
- return NULL;
+ const struct rip_info *rinfo = get_rip_info(args->list_entry);
+
+ if (rinfo->type != ZEBRA_ROUTE_RIP || rinfo->sub_type != RIP_ROUTE_RTE)
+ return NULL;
+
+ return yang_data_new_ipv4(args->xpath, &rinfo->from);
}
/*
@@ -293,8 +329,9 @@ struct yang_data *
ripd_instance_state_routes_route_nexthops_nexthop_tag_get_elem(
struct nb_cb_get_elem_args *args)
{
- /* TODO: implement me. */
- return NULL;
+ const struct rip_info *rinfo = get_rip_info(args->list_entry);
+
+ return yang_data_new_uint32(args->xpath, rinfo->tag);
}
/*
@@ -305,8 +342,13 @@ struct yang_data *
ripd_instance_state_routes_route_nexthops_nexthop_external_metric_get_elem(
struct nb_cb_get_elem_args *args)
{
- /* TODO: implement me. */
- return NULL;
+ const struct rip_info *rinfo = get_rip_info(args->list_entry);
+
+ if ((rinfo->type == ZEBRA_ROUTE_RIP &&
+ rinfo->sub_type == RIP_ROUTE_RTE) ||
+ rinfo->metric == RIP_METRIC_INFINITY || rinfo->external_metric == 0)
+ return NULL;
+ return yang_data_new_uint32(args->xpath, rinfo->external_metric);
}
/*
@@ -317,8 +359,16 @@ struct yang_data *
ripd_instance_state_routes_route_nexthops_nexthop_expire_time_get_elem(
struct nb_cb_get_elem_args *args)
{
- /* TODO: implement me. */
- return NULL;
+ const struct rip_info *rinfo = get_rip_info(args->list_entry);
+ struct event *event;
+
+ if ((event = rinfo->t_timeout) == NULL)
+ event = rinfo->t_garbage_collect;
+ if (!event)
+ return NULL;
+
+ return yang_data_new_uint32(args->xpath,
+ event_timer_remain_second(event));
}
/*