forked from Mirror/frr
pim6d: Implementing "show ipv6 multicast count" CLI
Signed-off-by: Abhishek N R <abnr@vmware.com>
This commit is contained in:
parent
ca3b5906fc
commit
3e55b3b5fd
|
@ -1615,6 +1615,77 @@ DEFPY (show_ipv6_multicast_vrf_all,
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFPY (show_ipv6_multicast_count,
|
||||||
|
show_ipv6_multicast_count_cmd,
|
||||||
|
"show ipv6 multicast count [vrf NAME] [json$json]",
|
||||||
|
SHOW_STR
|
||||||
|
IPV6_STR
|
||||||
|
"Multicast global information\n"
|
||||||
|
"Data packet count\n"
|
||||||
|
VRF_CMD_HELP_STR
|
||||||
|
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_multicast_interfaces(pim, vty, json_parent);
|
||||||
|
|
||||||
|
if (json)
|
||||||
|
vty_json(vty, json_parent);
|
||||||
|
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFPY (show_ipv6_multicast_count_vrf_all,
|
||||||
|
show_ipv6_multicast_count_vrf_all_cmd,
|
||||||
|
"show ipv6 multicast count vrf all [json$json]",
|
||||||
|
SHOW_STR
|
||||||
|
IPV6_STR
|
||||||
|
"Multicast global information\n"
|
||||||
|
"Data packet count\n"
|
||||||
|
VRF_CMD_HELP_STR
|
||||||
|
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_multicast_interfaces(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;
|
||||||
|
}
|
||||||
|
|
||||||
void pim_cmd_init(void)
|
void pim_cmd_init(void)
|
||||||
{
|
{
|
||||||
if_cmd_init(pim_interface_config_write);
|
if_cmd_init(pim_interface_config_write);
|
||||||
|
@ -1713,4 +1784,6 @@ void pim_cmd_init(void)
|
||||||
install_element(VIEW_NODE, &show_ipv6_pim_nexthop_lookup_cmd);
|
install_element(VIEW_NODE, &show_ipv6_pim_nexthop_lookup_cmd);
|
||||||
install_element(VIEW_NODE, &show_ipv6_multicast_cmd);
|
install_element(VIEW_NODE, &show_ipv6_multicast_cmd);
|
||||||
install_element(VIEW_NODE, &show_ipv6_multicast_vrf_all_cmd);
|
install_element(VIEW_NODE, &show_ipv6_multicast_vrf_all_cmd);
|
||||||
|
install_element(VIEW_NODE, &show_ipv6_multicast_count_cmd);
|
||||||
|
install_element(VIEW_NODE, &show_ipv6_multicast_count_vrf_all_cmd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3695,56 +3695,73 @@ DEFPY (show_ip_multicast_vrf_all,
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFUN(show_ip_multicast_count,
|
DEFPY (show_ip_multicast_count,
|
||||||
show_ip_multicast_count_cmd,
|
show_ip_multicast_count_cmd,
|
||||||
"show ip multicast count [vrf NAME] [json]",
|
"show ip multicast count [vrf NAME] [json$json]",
|
||||||
SHOW_STR IP_STR
|
SHOW_STR
|
||||||
"Multicast global information\n"
|
IP_STR
|
||||||
"Data packet count\n"
|
"Multicast global information\n"
|
||||||
VRF_CMD_HELP_STR JSON_STR)
|
"Data packet count\n"
|
||||||
|
VRF_CMD_HELP_STR
|
||||||
|
JSON_STR)
|
||||||
{
|
{
|
||||||
int idx = 3;
|
struct pim_instance *pim;
|
||||||
struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
|
struct vrf *v;
|
||||||
bool uj = use_json(argc, argv);
|
json_object *json_parent = NULL;
|
||||||
|
|
||||||
if (!vrf)
|
v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
|
||||||
|
|
||||||
|
if (!v)
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
|
|
||||||
show_multicast_interfaces(vrf->info, vty, uj);
|
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_multicast_interfaces(pim, vty, json_parent);
|
||||||
|
|
||||||
|
if (json)
|
||||||
|
vty_json(vty, json_parent);
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFUN(show_ip_multicast_count_vrf_all,
|
DEFPY (show_ip_multicast_count_vrf_all,
|
||||||
show_ip_multicast_count_vrf_all_cmd,
|
show_ip_multicast_count_vrf_all_cmd,
|
||||||
"show ip multicast count vrf all [json]",
|
"show ip multicast count vrf all [json$json]",
|
||||||
SHOW_STR IP_STR
|
SHOW_STR
|
||||||
"Multicast global information\n"
|
IP_STR
|
||||||
"Data packet count\n"
|
"Multicast global information\n"
|
||||||
VRF_CMD_HELP_STR JSON_STR)
|
"Data packet count\n"
|
||||||
|
VRF_CMD_HELP_STR
|
||||||
|
JSON_STR)
|
||||||
{
|
{
|
||||||
bool uj = use_json(argc, argv);
|
|
||||||
struct vrf *vrf;
|
struct vrf *vrf;
|
||||||
bool first = true;
|
json_object *json_parent = NULL;
|
||||||
|
json_object *json_vrf = NULL;
|
||||||
|
|
||||||
if (uj)
|
if (json)
|
||||||
vty_out(vty, "{ ");
|
json_parent = json_object_new_object();
|
||||||
|
|
||||||
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
|
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
|
||||||
if (uj) {
|
if (!json)
|
||||||
if (!first)
|
|
||||||
vty_out(vty, ", ");
|
|
||||||
|
|
||||||
vty_out(vty, " \"%s\": ", vrf->name);
|
|
||||||
first = false;
|
|
||||||
} else
|
|
||||||
vty_out(vty, "VRF: %s\n", vrf->name);
|
vty_out(vty, "VRF: %s\n", vrf->name);
|
||||||
|
else
|
||||||
|
json_vrf = json_object_new_object();
|
||||||
|
|
||||||
show_multicast_interfaces(vrf->info, vty, uj);
|
show_multicast_interfaces(vrf->info, vty, json_vrf);
|
||||||
|
if (json)
|
||||||
|
json_object_object_add(json_parent, vrf->name,
|
||||||
|
json_vrf);
|
||||||
}
|
}
|
||||||
|
if (json)
|
||||||
if (uj)
|
vty_json(vty, json_parent);
|
||||||
vty_out(vty, "}\n");
|
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2882,17 +2882,14 @@ static void show_scan_oil_stats(struct pim_instance *pim, struct vty *vty,
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_multicast_interfaces(struct pim_instance *pim, struct vty *vty,
|
void show_multicast_interfaces(struct pim_instance *pim, struct vty *vty,
|
||||||
bool uj)
|
json_object *json)
|
||||||
{
|
{
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
json_object *json = NULL;
|
|
||||||
json_object *json_row = NULL;
|
json_object *json_row = NULL;
|
||||||
|
|
||||||
vty_out(vty, "\n");
|
vty_out(vty, "\n");
|
||||||
|
|
||||||
if (uj)
|
if (!json)
|
||||||
json = json_object_new_object();
|
|
||||||
else
|
|
||||||
vty_out(vty,
|
vty_out(vty,
|
||||||
"Interface Address ifi Vif PktsIn PktsOut BytesIn BytesOut\n");
|
"Interface Address ifi Vif PktsIn PktsOut BytesIn BytesOut\n");
|
||||||
|
|
||||||
|
@ -2930,7 +2927,7 @@ void show_multicast_interfaces(struct pim_instance *pim, struct vty *vty,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (uj) {
|
if (json) {
|
||||||
json_row = json_object_new_object();
|
json_row = json_object_new_object();
|
||||||
json_object_string_add(json_row, "name", ifp->name);
|
json_object_string_add(json_row, "name", ifp->name);
|
||||||
json_object_string_add(json_row, "state",
|
json_object_string_add(json_row, "state",
|
||||||
|
@ -2960,9 +2957,6 @@ void show_multicast_interfaces(struct pim_instance *pim, struct vty *vty,
|
||||||
(unsigned long)vreq.obytes);
|
(unsigned long)vreq.obytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uj)
|
|
||||||
vty_json(vty, json);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void pim_cmd_show_ip_multicast_helper(struct pim_instance *pim, struct vty *vty)
|
void pim_cmd_show_ip_multicast_helper(struct pim_instance *pim, struct vty *vty)
|
||||||
|
@ -3011,5 +3005,5 @@ void pim_cmd_show_ip_multicast_helper(struct pim_instance *pim, struct vty *vty)
|
||||||
|
|
||||||
show_scan_oil_stats(pim, vty, now);
|
show_scan_oil_stats(pim, vty, now);
|
||||||
|
|
||||||
show_multicast_interfaces(pim, vty, false);
|
show_multicast_interfaces(pim, vty, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ int pim_process_ssmpingd_cmd(struct vty *vty, enum nb_operation operation,
|
||||||
void pim_cmd_show_ip_multicast_helper(struct pim_instance *pim,
|
void pim_cmd_show_ip_multicast_helper(struct pim_instance *pim,
|
||||||
struct vty *vty);
|
struct vty *vty);
|
||||||
void show_multicast_interfaces(struct pim_instance *pim, struct vty *vty,
|
void show_multicast_interfaces(struct pim_instance *pim, struct vty *vty,
|
||||||
bool uj);
|
json_object *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 a new issue