return NB_OK;
}
+static const void *ripd_instance_get_next(const void *parent_list_entry,
+ const void *list_entry)
+{
+ const struct rip *rip = list_entry;
+
+ if (list_entry == NULL)
+ rip = RB_MIN(rip_instance_head, &rip_instances);
+ else
+ rip = RB_NEXT(rip_instance_head, (struct rip *)rip);
+
+ return rip;
+}
+
+static int ripd_instance_get_keys(const void *list_entry,
+ struct yang_list_keys *keys)
+{
+ const struct rip *rip = list_entry;
+
+ keys->num = 1;
+ strlcpy(keys->key[0], rip->vrf_name, sizeof(keys->key[0]));
+
+ return NB_OK;
+}
+
+static const void *ripd_instance_lookup_entry(const void *parent_list_entry,
+ const struct yang_list_keys *keys)
+{
+ const char *vrf_name = keys->key[0];
+
+ return rip_lookup_by_vrf_name(vrf_name);
+}
+
/*
* XPath: /frr-ripd:ripd/instance/allow-ecmp
*/
}
/*
- * XPath: /frr-ripd:ripd/state/neighbors/neighbor
+ * XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor
*/
static const void *
-ripd_state_neighbors_neighbor_get_next(const void *parent_list_entry,
- const void *list_entry)
+ripd_instance_state_neighbors_neighbor_get_next(const void *parent_list_entry,
+ const void *list_entry)
{
- struct rip *rip;
+ const struct rip *rip = parent_list_entry;
struct listnode *node;
- rip = rip_lookup_by_vrf_id(VRF_DEFAULT);
- if (rip == NULL)
- return NULL;
-
if (list_entry == NULL)
node = listhead(rip->peer_list);
else
return node;
}
-static int ripd_state_neighbors_neighbor_get_keys(const void *list_entry,
- struct yang_list_keys *keys)
+static int
+ripd_instance_state_neighbors_neighbor_get_keys(const void *list_entry,
+ struct yang_list_keys *keys)
{
const struct listnode *node = list_entry;
const struct rip_peer *peer = listgetdata(node);
return NB_OK;
}
-static const void *
-ripd_state_neighbors_neighbor_lookup_entry(const void *parent_list_entry,
- const struct yang_list_keys *keys)
+static const void *ripd_instance_state_neighbors_neighbor_lookup_entry(
+ const void *parent_list_entry, const struct yang_list_keys *keys)
{
- struct rip *rip;
+ const struct rip *rip = parent_list_entry;
struct in_addr address;
struct rip_peer *peer;
struct listnode *node;
yang_str2ipv4(keys->key[0], &address);
- rip = rip_lookup_by_vrf_id(VRF_DEFAULT);
- if (rip == NULL)
- return NULL;
-
for (ALL_LIST_ELEMENTS_RO(rip->peer_list, node, peer)) {
if (IPV4_ADDR_SAME(&peer->addr, &address))
return node;
}
/*
- * XPath: /frr-ripd:ripd/state/neighbors/neighbor/address
+ * XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor/address
*/
static struct yang_data *
-ripd_state_neighbors_neighbor_address_get_elem(const char *xpath,
- const void *list_entry)
+ripd_instance_state_neighbors_neighbor_address_get_elem(const char *xpath,
+ const void *list_entry)
{
const struct listnode *node = list_entry;
const struct rip_peer *peer = listgetdata(node);
}
/*
- * XPath: /frr-ripd:ripd/state/neighbors/neighbor/last-update
+ * XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor/last-update
*/
static struct yang_data *
-ripd_state_neighbors_neighbor_last_update_get_elem(const char *xpath,
- const void *list_entry)
+ripd_instance_state_neighbors_neighbor_last_update_get_elem(
+ const char *xpath, const void *list_entry)
{
/* TODO: yang:date-and-time is tricky */
return NULL;
}
/*
- * XPath: /frr-ripd:ripd/state/neighbors/neighbor/bad-packets-rcvd
+ * XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor/bad-packets-rcvd
*/
static struct yang_data *
-ripd_state_neighbors_neighbor_bad_packets_rcvd_get_elem(const char *xpath,
- const void *list_entry)
+ripd_instance_state_neighbors_neighbor_bad_packets_rcvd_get_elem(
+ const char *xpath, const void *list_entry)
{
const struct listnode *node = list_entry;
const struct rip_peer *peer = listgetdata(node);
}
/*
- * XPath: /frr-ripd:ripd/state/neighbors/neighbor/bad-routes-rcvd
+ * XPath: /frr-ripd:ripd/instance/state/neighbors/neighbor/bad-routes-rcvd
*/
static struct yang_data *
-ripd_state_neighbors_neighbor_bad_routes_rcvd_get_elem(const char *xpath,
- const void *list_entry)
+ripd_instance_state_neighbors_neighbor_bad_routes_rcvd_get_elem(
+ const char *xpath, const void *list_entry)
{
const struct listnode *node = list_entry;
const struct rip_peer *peer = listgetdata(node);
}
/*
- * XPath: /frr-ripd:ripd/state/routes/route
+ * XPath: /frr-ripd:ripd/instance/state/routes/route
*/
static const void *
-ripd_state_routes_route_get_next(const void *parent_list_entry,
- const void *list_entry)
+ripd_instance_state_routes_route_get_next(const void *parent_list_entry,
+ const void *list_entry)
{
- struct rip *rip;
+ const struct rip *rip = parent_list_entry;
struct route_node *rn;
- rip = rip_lookup_by_vrf_id(VRF_DEFAULT);
- if (rip == NULL)
- return NULL;
-
if (list_entry == NULL)
rn = route_top(rip->table);
else
return rn;
}
-static int ripd_state_routes_route_get_keys(const void *list_entry,
- struct yang_list_keys *keys)
+static int
+ripd_instance_state_routes_route_get_keys(const void *list_entry,
+ struct yang_list_keys *keys)
{
const struct route_node *rn = list_entry;
}
static const void *
-ripd_state_routes_route_lookup_entry(const void *parent_list_entry,
- const struct yang_list_keys *keys)
+ripd_instance_state_routes_route_lookup_entry(const void *parent_list_entry,
+ const struct yang_list_keys *keys)
{
- struct rip *rip;
+ const struct rip *rip = parent_list_entry;
struct prefix prefix;
struct route_node *rn;
yang_str2ipv4p(keys->key[0], &prefix);
- rip = rip_lookup_by_vrf_id(VRF_DEFAULT);
- if (rip == NULL)
- return NULL;
-
rn = route_node_lookup(rip->table, &prefix);
if (!rn || !rn->info)
return NULL;
}
/*
- * XPath: /frr-ripd:ripd/state/routes/route/prefix
+ * XPath: /frr-ripd:ripd/instance/state/routes/route/prefix
*/
static struct yang_data *
-ripd_state_routes_route_prefix_get_elem(const char *xpath,
- const void *list_entry)
+ripd_instance_state_routes_route_prefix_get_elem(const char *xpath,
+ const void *list_entry)
{
const struct route_node *rn = list_entry;
const struct rip_info *rinfo = listnode_head(rn->info);
}
/*
- * XPath: /frr-ripd:ripd/state/routes/route/next-hop
+ * XPath: /frr-ripd:ripd/instance/state/routes/route/next-hop
*/
static struct yang_data *
-ripd_state_routes_route_next_hop_get_elem(const char *xpath,
- const void *list_entry)
+ripd_instance_state_routes_route_next_hop_get_elem(const char *xpath,
+ const void *list_entry)
{
const struct route_node *rn = list_entry;
const struct rip_info *rinfo = listnode_head(rn->info);
}
/*
- * XPath: /frr-ripd:ripd/state/routes/route/interface
+ * XPath: /frr-ripd:ripd/instance/state/routes/route/interface
*/
static struct yang_data *
-ripd_state_routes_route_interface_get_elem(const char *xpath,
- const void *list_entry)
+ripd_instance_state_routes_route_interface_get_elem(const char *xpath,
+ const void *list_entry)
{
const struct route_node *rn = list_entry;
const struct rip_info *rinfo = listnode_head(rn->info);
+ const struct rip *rip = rip_info_get_instance(rinfo);
switch (rinfo->nh.type) {
case NEXTHOP_TYPE_IFINDEX:
case NEXTHOP_TYPE_IPV4_IFINDEX:
return yang_data_new_string(
- xpath, ifindex2ifname(rinfo->nh.ifindex, VRF_DEFAULT));
+ xpath,
+ ifindex2ifname(rinfo->nh.ifindex, rip->vrf->vrf_id));
default:
return NULL;
}
}
/*
- * XPath: /frr-ripd:ripd/state/routes/route/metric
+ * XPath: /frr-ripd:ripd/instance/state/routes/route/metric
*/
static struct yang_data *
-ripd_state_routes_route_metric_get_elem(const char *xpath,
- const void *list_entry)
+ripd_instance_state_routes_route_metric_get_elem(const char *xpath,
+ const void *list_entry)
{
const struct route_node *rn = list_entry;
const struct rip_info *rinfo = listnode_head(rn->info);
.xpath = "/frr-ripd:ripd/instance",
.cbs.create = ripd_instance_create,
.cbs.delete = ripd_instance_delete,
+ .cbs.get_next = ripd_instance_get_next,
+ .cbs.get_keys = ripd_instance_get_keys,
+ .cbs.lookup_entry = ripd_instance_lookup_entry,
.cbs.cli_show = cli_show_router_rip,
},
{
.cbs.cli_show = cli_show_ip_rip_authentication_key_chain,
},
{
- .xpath = "/frr-ripd:ripd/state/neighbors/neighbor",
- .cbs.get_next = ripd_state_neighbors_neighbor_get_next,
- .cbs.get_keys = ripd_state_neighbors_neighbor_get_keys,
- .cbs.lookup_entry = ripd_state_neighbors_neighbor_lookup_entry,
+ .xpath = "/frr-ripd:ripd/instance/state/neighbors/neighbor",
+ .cbs.get_next = ripd_instance_state_neighbors_neighbor_get_next,
+ .cbs.get_keys = ripd_instance_state_neighbors_neighbor_get_keys,
+ .cbs.lookup_entry = ripd_instance_state_neighbors_neighbor_lookup_entry,
},
{
- .xpath = "/frr-ripd:ripd/state/neighbors/neighbor/address",
- .cbs.get_elem = ripd_state_neighbors_neighbor_address_get_elem,
+ .xpath = "/frr-ripd:ripd/instance/state/neighbors/neighbor/address",
+ .cbs.get_elem = ripd_instance_state_neighbors_neighbor_address_get_elem,
},
{
- .xpath = "/frr-ripd:ripd/state/neighbors/neighbor/last-update",
- .cbs.get_elem = ripd_state_neighbors_neighbor_last_update_get_elem,
+ .xpath = "/frr-ripd:ripd/instance/state/neighbors/neighbor/last-update",
+ .cbs.get_elem = ripd_instance_state_neighbors_neighbor_last_update_get_elem,
},
{
- .xpath = "/frr-ripd:ripd/state/neighbors/neighbor/bad-packets-rcvd",
- .cbs.get_elem = ripd_state_neighbors_neighbor_bad_packets_rcvd_get_elem,
+ .xpath = "/frr-ripd:ripd/instance/state/neighbors/neighbor/bad-packets-rcvd",
+ .cbs.get_elem = ripd_instance_state_neighbors_neighbor_bad_packets_rcvd_get_elem,
},
{
- .xpath = "/frr-ripd:ripd/state/neighbors/neighbor/bad-routes-rcvd",
- .cbs.get_elem = ripd_state_neighbors_neighbor_bad_routes_rcvd_get_elem,
+ .xpath = "/frr-ripd:ripd/instance/state/neighbors/neighbor/bad-routes-rcvd",
+ .cbs.get_elem = ripd_instance_state_neighbors_neighbor_bad_routes_rcvd_get_elem,
},
{
- .xpath = "/frr-ripd:ripd/state/routes/route",
- .cbs.get_next = ripd_state_routes_route_get_next,
- .cbs.get_keys = ripd_state_routes_route_get_keys,
- .cbs.lookup_entry = ripd_state_routes_route_lookup_entry,
+ .xpath = "/frr-ripd:ripd/instance/state/routes/route",
+ .cbs.get_next = ripd_instance_state_routes_route_get_next,
+ .cbs.get_keys = ripd_instance_state_routes_route_get_keys,
+ .cbs.lookup_entry = ripd_instance_state_routes_route_lookup_entry,
},
{
- .xpath = "/frr-ripd:ripd/state/routes/route/prefix",
- .cbs.get_elem = ripd_state_routes_route_prefix_get_elem,
+ .xpath = "/frr-ripd:ripd/instance/state/routes/route/prefix",
+ .cbs.get_elem = ripd_instance_state_routes_route_prefix_get_elem,
},
{
- .xpath = "/frr-ripd:ripd/state/routes/route/next-hop",
- .cbs.get_elem = ripd_state_routes_route_next_hop_get_elem,
+ .xpath = "/frr-ripd:ripd/instance/state/routes/route/next-hop",
+ .cbs.get_elem = ripd_instance_state_routes_route_next_hop_get_elem,
},
{
- .xpath = "/frr-ripd:ripd/state/routes/route/interface",
- .cbs.get_elem = ripd_state_routes_route_interface_get_elem,
+ .xpath = "/frr-ripd:ripd/instance/state/routes/route/interface",
+ .cbs.get_elem = ripd_instance_state_routes_route_interface_get_elem,
},
{
- .xpath = "/frr-ripd:ripd/state/routes/route/metric",
- .cbs.get_elem = ripd_state_routes_route_metric_get_elem,
+ .xpath = "/frr-ripd:ripd/instance/state/routes/route/metric",
+ .cbs.get_elem = ripd_instance_state_routes_route_metric_get_elem,
},
{
.xpath = "/frr-ripd:clear-rip-route",