diff options
| author | Abhishek N R <abnr@vmware.com> | 2022-04-14 00:07:41 -0700 |
|---|---|---|
| committer | Abhishek N R <abnr@vmware.com> | 2022-04-27 04:26:35 -0700 |
| commit | 3e55b3b5fdfd6676db0574ebf97f3dc904014c75 (patch) | |
| tree | 75c135eac231d84c827e23972862f91295309ad7 /pimd/pim6_cmd.c | |
| parent | ca3b5906fcca3d6a42d0e72516854dac0e1a34f0 (diff) | |
pim6d: Implementing "show ipv6 multicast count" CLI
Signed-off-by: Abhishek N R <abnr@vmware.com>
Diffstat (limited to 'pimd/pim6_cmd.c')
| -rw-r--r-- | pimd/pim6_cmd.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/pimd/pim6_cmd.c b/pimd/pim6_cmd.c index 7f7c3979c7..185ec33f9c 100644 --- a/pimd/pim6_cmd.c +++ b/pimd/pim6_cmd.c @@ -1615,6 +1615,77 @@ DEFPY (show_ipv6_multicast_vrf_all, 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) { 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_multicast_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); } |
