mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-05 10:08:41 +00:00
pim6d: Moving reusable code to common api for "show pim state" command
Signed-off-by: Abhishek N R <abnr@vmware.com>
This commit is contained in:
parent
c630970866
commit
e7c01c6769
@ -928,31 +928,7 @@ DEFPY (show_ipv6_pim_state,
|
|||||||
"Multicast address\n"
|
"Multicast address\n"
|
||||||
JSON_STR)
|
JSON_STR)
|
||||||
{
|
{
|
||||||
struct pim_instance *pim;
|
return pim_show_state_helper(vrf, vty, s_or_g_str, g_str, !!json);
|
||||||
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();
|
|
||||||
|
|
||||||
pim_show_state(pim, vty, s_or_g_str, g_str, json_parent);
|
|
||||||
|
|
||||||
if (json)
|
|
||||||
vty_json(vty, json_parent);
|
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFPY (show_ipv6_pim_state_vrf_all,
|
DEFPY (show_ipv6_pim_state_vrf_all,
|
||||||
@ -967,27 +943,7 @@ DEFPY (show_ipv6_pim_state_vrf_all,
|
|||||||
"Multicast address\n"
|
"Multicast address\n"
|
||||||
JSON_STR)
|
JSON_STR)
|
||||||
{
|
{
|
||||||
struct vrf *vrf;
|
return pim_show_state_vrf_all_helper(vty, s_or_g_str, g_str, !!json);
|
||||||
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();
|
|
||||||
pim_show_state(vrf->info, vty, s_or_g_str, g_str, json_vrf);
|
|
||||||
if (json)
|
|
||||||
json_object_object_add(json_parent, vrf->name,
|
|
||||||
json_vrf);
|
|
||||||
}
|
|
||||||
if (json)
|
|
||||||
vty_json(vty, json_parent);
|
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFPY (show_ipv6_pim_channel,
|
DEFPY (show_ipv6_pim_channel,
|
||||||
|
@ -2995,31 +2995,7 @@ DEFPY (show_ip_pim_state,
|
|||||||
"Multicast address\n"
|
"Multicast address\n"
|
||||||
JSON_STR)
|
JSON_STR)
|
||||||
{
|
{
|
||||||
struct pim_instance *pim;
|
return pim_show_state_helper(vrf, vty, s_or_g_str, g_str, !!json);
|
||||||
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();
|
|
||||||
|
|
||||||
pim_show_state(pim, vty, s_or_g_str, g_str, json_parent);
|
|
||||||
|
|
||||||
if (json)
|
|
||||||
vty_json(vty, json_parent);
|
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFPY (show_ip_pim_state_vrf_all,
|
DEFPY (show_ip_pim_state_vrf_all,
|
||||||
@ -3034,27 +3010,7 @@ DEFPY (show_ip_pim_state_vrf_all,
|
|||||||
"Multicast address\n"
|
"Multicast address\n"
|
||||||
JSON_STR)
|
JSON_STR)
|
||||||
{
|
{
|
||||||
struct vrf *vrf;
|
return pim_show_state_vrf_all_helper(vty, s_or_g_str, g_str, !!json);
|
||||||
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();
|
|
||||||
pim_show_state(vrf->info, vty, s_or_g_str, g_str, json_vrf);
|
|
||||||
if (json)
|
|
||||||
json_object_object_add(json_parent, vrf->name,
|
|
||||||
json_vrf);
|
|
||||||
}
|
|
||||||
if (json)
|
|
||||||
vty_json(vty, json_parent);
|
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFPY (show_ip_pim_upstream,
|
DEFPY (show_ip_pim_upstream,
|
||||||
|
@ -4025,3 +4025,59 @@ int pim_show_upstream_rpf_helper(const char *vrf, struct vty *vty, bool uj)
|
|||||||
|
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pim_show_state_helper(const char *vrf, struct vty *vty,
|
||||||
|
const char *s_or_g_str, const char *g_str, 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();
|
||||||
|
|
||||||
|
pim_show_state(pim, vty, s_or_g_str, g_str, json_parent);
|
||||||
|
|
||||||
|
if (json)
|
||||||
|
vty_json(vty, json_parent);
|
||||||
|
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int pim_show_state_vrf_all_helper(struct vty *vty, const char *s_or_g_str,
|
||||||
|
const char *g_str, 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();
|
||||||
|
pim_show_state(vrf->info, vty, s_or_g_str, g_str, json_vrf);
|
||||||
|
if (json)
|
||||||
|
json_object_object_add(json_parent, vrf->name,
|
||||||
|
json_vrf);
|
||||||
|
}
|
||||||
|
if (json)
|
||||||
|
vty_json(vty, json_parent);
|
||||||
|
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
@ -146,6 +146,10 @@ int pim_show_upstream_vrf_all_helper(struct vty *vty, bool json);
|
|||||||
int pim_show_upstream_join_desired_helper(const char *vrf, struct vty *vty,
|
int pim_show_upstream_join_desired_helper(const char *vrf, struct vty *vty,
|
||||||
bool uj);
|
bool uj);
|
||||||
int pim_show_upstream_rpf_helper(const char *vrf, struct vty *vty, bool uj);
|
int pim_show_upstream_rpf_helper(const char *vrf, struct vty *vty, bool uj);
|
||||||
|
int pim_show_state_helper(const char *vrf, struct vty *vty,
|
||||||
|
const char *s_or_g_str, const char *g_str, bool json);
|
||||||
|
int pim_show_state_vrf_all_helper(struct vty *vty, const char *s_or_g_str,
|
||||||
|
const char *g_str, bool json);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Special Macro to allow us to get the correct pim_instance;
|
* Special Macro to allow us to get the correct pim_instance;
|
||||||
|
Loading…
Reference in New Issue
Block a user