mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 13:27:53 +00:00
pim6d: Moving reusable code to common api for "show ip/ipv6 mroute count" command
Signed-off-by: Abhishek N R <abnr@vmware.com>
This commit is contained in:
parent
4f1f8ff9aa
commit
1c1077c200
@ -1407,31 +1407,7 @@ DEFPY (show_ipv6_mroute_count,
|
||||
"Route and packet count data\n"
|
||||
JSON_STR)
|
||||
{
|
||||
struct pim_instance *pim;
|
||||
struct vrf *v;
|
||||
json_object *json_parent = NULL;
|
||||
|
||||
v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
|
||||
|
||||
if (!v)
|
||||
return CMD_WARNING;
|
||||
|
||||
pim = pim_get_pim_instance(v->vrf_id);
|
||||
|
||||
if (!pim) {
|
||||
vty_out(vty, "%% Unable to find pim instance\n");
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
if (json)
|
||||
json_parent = json_object_new_object();
|
||||
|
||||
show_mroute_count(pim, vty, json_parent);
|
||||
|
||||
if (json)
|
||||
vty_json(vty, json_parent);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
return pim_show_mroute_count_helper(vrf, vty, !!json);
|
||||
}
|
||||
|
||||
DEFPY (show_ipv6_mroute_count_vrf_all,
|
||||
@ -1444,29 +1420,7 @@ DEFPY (show_ipv6_mroute_count_vrf_all,
|
||||
"Route and packet count data\n"
|
||||
JSON_STR)
|
||||
{
|
||||
struct vrf *vrf;
|
||||
json_object *json_parent = NULL;
|
||||
json_object *json_vrf = NULL;
|
||||
|
||||
if (json)
|
||||
json_parent = json_object_new_object();
|
||||
|
||||
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
|
||||
if (!json)
|
||||
vty_out(vty, "VRF: %s\n", vrf->name);
|
||||
else
|
||||
json_vrf = json_object_new_object();
|
||||
show_mroute_count(vrf->info, vty, json_vrf);
|
||||
|
||||
if (json)
|
||||
json_object_object_add(json_parent, vrf->name,
|
||||
json_vrf);
|
||||
}
|
||||
|
||||
if (json)
|
||||
vty_json(vty, json_parent);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
return pim_show_mroute_count_vrf_all_helper(vty, !!json);
|
||||
}
|
||||
|
||||
DEFPY (show_ipv6_mroute_summary,
|
||||
|
@ -3407,31 +3407,7 @@ DEFPY (show_ip_mroute_count,
|
||||
"Route and packet count data\n"
|
||||
JSON_STR)
|
||||
{
|
||||
struct pim_instance *pim;
|
||||
struct vrf *v;
|
||||
json_object *json_parent = NULL;
|
||||
|
||||
v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
|
||||
|
||||
if (!v)
|
||||
return CMD_WARNING;
|
||||
|
||||
pim = pim_get_pim_instance(v->vrf_id);
|
||||
|
||||
if (!pim) {
|
||||
vty_out(vty, "%% Unable to find pim instance\n");
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
if (json)
|
||||
json_parent = json_object_new_object();
|
||||
|
||||
show_mroute_count(pim, vty, json_parent);
|
||||
|
||||
if (json)
|
||||
vty_json(vty, json_parent);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
return pim_show_mroute_count_helper(vrf, vty, !!json);
|
||||
}
|
||||
|
||||
DEFPY (show_ip_mroute_count_vrf_all,
|
||||
@ -3444,29 +3420,7 @@ DEFPY (show_ip_mroute_count_vrf_all,
|
||||
"Route and packet count data\n"
|
||||
JSON_STR)
|
||||
{
|
||||
struct vrf *vrf;
|
||||
json_object *json_parent = NULL;
|
||||
json_object *json_vrf = NULL;
|
||||
|
||||
if (json)
|
||||
json_parent = json_object_new_object();
|
||||
|
||||
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
|
||||
if (!json)
|
||||
vty_out(vty, "VRF: %s\n", vrf->name);
|
||||
else
|
||||
json_vrf = json_object_new_object();
|
||||
|
||||
show_mroute_count(vrf->info, vty, json_vrf);
|
||||
|
||||
if (json)
|
||||
json_object_object_add(json_parent, vrf->name,
|
||||
json_vrf);
|
||||
}
|
||||
if (json)
|
||||
vty_json(vty, json_parent);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
return pim_show_mroute_count_vrf_all_helper(vty, !!json);
|
||||
}
|
||||
|
||||
DEFPY (show_ip_mroute_summary,
|
||||
|
@ -4235,3 +4235,59 @@ int pim_show_mroute_vrf_all_helper(struct vty *vty, bool fill, bool json)
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
int pim_show_mroute_count_helper(const char *vrf, struct vty *vty, bool json)
|
||||
{
|
||||
struct pim_instance *pim;
|
||||
struct vrf *v;
|
||||
json_object *json_parent = NULL;
|
||||
|
||||
v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
|
||||
|
||||
if (!v)
|
||||
return CMD_WARNING;
|
||||
|
||||
pim = pim_get_pim_instance(v->vrf_id);
|
||||
|
||||
if (!pim) {
|
||||
vty_out(vty, "%% Unable to find pim instance\n");
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
if (json)
|
||||
json_parent = json_object_new_object();
|
||||
|
||||
show_mroute_count(pim, vty, json_parent);
|
||||
|
||||
if (json)
|
||||
vty_json(vty, json_parent);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
int pim_show_mroute_count_vrf_all_helper(struct vty *vty, bool json)
|
||||
{
|
||||
struct vrf *vrf;
|
||||
json_object *json_parent = NULL;
|
||||
json_object *json_vrf = NULL;
|
||||
|
||||
if (json)
|
||||
json_parent = json_object_new_object();
|
||||
|
||||
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
|
||||
if (!json)
|
||||
vty_out(vty, "VRF: %s\n", vrf->name);
|
||||
else
|
||||
json_vrf = json_object_new_object();
|
||||
|
||||
show_mroute_count(vrf->info, vty, json_vrf);
|
||||
|
||||
if (json)
|
||||
json_object_object_add(json_parent, vrf->name,
|
||||
json_vrf);
|
||||
}
|
||||
if (json)
|
||||
vty_json(vty, json_parent);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
@ -158,6 +158,8 @@ int pim_show_multicast_count_vrf_all_helper(struct vty *vty, bool json);
|
||||
int pim_show_mroute_helper(const char *vrf, struct vty *vty, pim_addr s_or_g,
|
||||
pim_addr g, bool fill, bool json);
|
||||
int pim_show_mroute_vrf_all_helper(struct vty *vty, bool fill, bool json);
|
||||
int pim_show_mroute_count_helper(const char *vrf, struct vty *vty, bool json);
|
||||
int pim_show_mroute_count_vrf_all_helper(struct vty *vty, bool json);
|
||||
|
||||
/*
|
||||
* Special Macro to allow us to get the correct pim_instance;
|
||||
|
Loading…
Reference in New Issue
Block a user