ripd: implement new YANG operational state

Signed-off-by: Christian Hopps <chopps@labn.net>
This commit is contained in:
Christian Hopps 2023-04-06 18:23:31 -04:00
parent 0b7f0e3548
commit 7fd2ffb96c

View file

@ -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. */
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. */
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. */
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. */
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. */
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));
}
/*