]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pim6d: Moving reusable code to common api for "show ip/ipv6 multicast" command
authorAbhishek N R <abnr@vmware.com>
Thu, 9 Jun 2022 10:51:41 +0000 (03:51 -0700)
committerAbhishek N R <abnr@vmware.com>
Thu, 9 Jun 2022 10:51:41 +0000 (03:51 -0700)
Signed-off-by: Abhishek N R <abnr@vmware.com>
pimd/pim6_cmd.c
pimd/pim_cmd.c
pimd/pim_cmd_common.c
pimd/pim_cmd_common.h

index 0cdbb73c19b6da38b578d2b6673414eefa3dd237..e9d90b104d5c6b38449fec12decb575983802a2a 100644 (file)
@@ -1329,24 +1329,7 @@ DEFPY (show_ipv6_multicast,
        "Multicast global information\n"
        VRF_CMD_HELP_STR)
 {
-       struct vrf *v;
-       struct pim_instance *pim;
-
-       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;
-       }
-
-       pim_cmd_show_ip_multicast_helper(pim, vty);
-
-       return CMD_SUCCESS;
+       return pim_show_multicast_helper(vrf, vty);
 }
 
 DEFPY (show_ipv6_multicast_vrf_all,
@@ -1357,14 +1340,7 @@ DEFPY (show_ipv6_multicast_vrf_all,
        "Multicast global information\n"
        VRF_CMD_HELP_STR)
 {
-       struct vrf *vrf;
-
-       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
-               vty_out(vty, "VRF: %s\n", vrf->name);
-               pim_cmd_show_ip_multicast_helper(vrf->info, vty);
-       }
-
-       return CMD_SUCCESS;
+       return pim_show_multicast_vrf_all_helper(vty);
 }
 
 DEFPY (show_ipv6_multicast_count,
index 6cd9e5fbd73a8842a7d8d848d3cc192620e31d11..1766bd1fae33b90979e69ca23fc678b21c228343 100644 (file)
@@ -3317,24 +3317,7 @@ DEFPY (show_ip_multicast,
        "Multicast global information\n"
        VRF_CMD_HELP_STR)
 {
-       struct vrf *v;
-       struct pim_instance *pim;
-
-       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;
-       }
-
-       pim_cmd_show_ip_multicast_helper(pim, vty);
-
-       return CMD_SUCCESS;
+       return pim_show_multicast_helper(vrf, vty);
 }
 
 DEFPY (show_ip_multicast_vrf_all,
@@ -3345,14 +3328,7 @@ DEFPY (show_ip_multicast_vrf_all,
        "Multicast global information\n"
        VRF_CMD_HELP_STR)
 {
-       struct vrf *vrf;
-
-       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
-               vty_out(vty, "VRF: %s\n", vrf->name);
-               pim_cmd_show_ip_multicast_helper(vrf->info, vty);
-       }
-
-       return CMD_SUCCESS;
+       return pim_show_multicast_vrf_all_helper(vty);
 }
 
 DEFPY (show_ip_multicast_count,
index a2a0891779e4c01c860ed3198f183258b42d06bd..7a051186777dc99bb69172bd8eafb17e21d0308b 100644 (file)
@@ -4081,3 +4081,37 @@ int pim_show_state_vrf_all_helper(struct vty *vty, const char *s_or_g_str,
 
        return CMD_SUCCESS;
 }
+
+int pim_show_multicast_helper(const char *vrf, struct vty *vty)
+{
+       struct vrf *v;
+       struct pim_instance *pim;
+
+       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;
+       }
+
+       pim_cmd_show_ip_multicast_helper(pim, vty);
+
+       return CMD_SUCCESS;
+}
+
+int pim_show_multicast_vrf_all_helper(struct vty *vty)
+{
+       struct vrf *vrf;
+
+       RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
+               vty_out(vty, "VRF: %s\n", vrf->name);
+               pim_cmd_show_ip_multicast_helper(vrf->info, vty);
+       }
+
+       return CMD_SUCCESS;
+}
index 981e6dc88f9b06a15546b09ad07275ac3e1fba22..ceba2f2b41fa5bb884871460fea3cb44989a80fb 100644 (file)
@@ -150,6 +150,8 @@ 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);
+int pim_show_multicast_helper(const char *vrf, struct vty *vty);
+int pim_show_multicast_vrf_all_helper(struct vty *vty);
 
 /*
  * Special Macro to allow us to get the correct pim_instance;