]> git.puffer.fish Git - mirror/frr.git/commitdiff
pim6d: Moving the common lines of pim_show_interface_vrf_all cli
authorSai Gomathi N <nsaigomathi@vmware.com>
Thu, 9 Jun 2022 06:56:17 +0000 (23:56 -0700)
committerSai Gomathi N <nsaigomathi@vmware.com>
Thu, 9 Jun 2022 06:56:17 +0000 (23:56 -0700)
Moving the common lines of pim_show_interface_vrf_all cli
in pim_cmd.c and pim6_cmd.c to pim_cmd_common.c file

Signed-off-by: Sai Gomathi N <nsaigomathi@vmware.com>
pimd/pim6_cmd.c
pimd/pim_cmd.c
pimd/pim_cmd_common.c
pimd/pim_cmd_common.h

index d69740260870b763ce566cb4a26a868ea4fdffbd..8af576321235b5a2020f320e608f3bfc373d41b0 100644 (file)
@@ -1266,33 +1266,8 @@ DEFPY (show_ipv6_pim_interface_vrf_all,
        "interface name\n"
        JSON_STR)
 {
-       bool uj = !!json;
-       struct vrf *v;
-       json_object *json_parent = NULL;
-       json_object *json_vrf = NULL;
-
-       if (uj)
-               json_parent = json_object_new_object();
-
-       RB_FOREACH (v, vrf_name_head, &vrfs_by_name) {
-               if (!uj)
-                       vty_out(vty, "VRF: %s\n", v->name);
-               else
-                       json_vrf = json_object_new_object();
-
-               if (interface)
-                       pim_show_interfaces_single(v->info, vty, interface,
-                                                  false, json_vrf);
-               else
-                       pim_show_interfaces(v->info, vty, false, json_vrf);
-
-               if (uj)
-                       json_object_object_add(json_parent, v->name, json_vrf);
-       }
-       if (uj)
-               vty_json(vty, json_parent);
-
-       return CMD_SUCCESS;
+       return pim_show_interface_vrf_all_cmd_helper(vty, !!json, false,
+                                                    interface);
 }
 
 DEFPY (show_ipv6_pim_join,
index 0d66b9e79bbe73d8718a797297bb10aee3fd7137..6c8d2e357555dde61fb61e930669f58d446f7fe8 100644 (file)
@@ -2444,34 +2444,8 @@ DEFPY (show_ip_pim_interface_vrf_all,
        "interface name\n"
        JSON_STR)
 {
-       bool uj = !!json;
-       bool is_mlag = !!mlag;
-       struct vrf *v;
-       json_object *json_parent = NULL;
-       json_object *json_vrf = NULL;
-
-       if (uj)
-               json_parent = json_object_new_object();
-
-       RB_FOREACH (v, vrf_name_head, &vrfs_by_name) {
-               if (!uj)
-                       vty_out(vty, "VRF: %s\n", v->name);
-               else
-                       json_vrf = json_object_new_object();
-
-               if (interface)
-                       pim_show_interfaces_single(v->info, vty, interface,
-                                                  is_mlag, json_vrf);
-               else
-                       pim_show_interfaces(v->info, vty, is_mlag, json_vrf);
-
-               if (uj)
-                       json_object_object_add(json_parent, v->name, json_vrf);
-       }
-       if (uj)
-               vty_json(vty, json_parent);
-
-       return CMD_SUCCESS;
+       return pim_show_interface_vrf_all_cmd_helper(vty, !!json, !!mlag,
+                                                    interface);
 }
 
 DEFPY (show_ip_pim_join,
index bf594727ec35281e1b284e757822d34f6ec2dbf4..95526e899ad1be8ec692466bb1a7c1b979cf2702 100644 (file)
@@ -1985,6 +1985,37 @@ int pim_show_interface_cmd_helper(const char *vrf, struct vty *vty, bool uj,
        return CMD_SUCCESS;
 }
 
+int pim_show_interface_vrf_all_cmd_helper(struct vty *vty, bool uj, bool mlag,
+                                         const char *interface)
+{
+       struct vrf *v;
+       json_object *json_parent = NULL;
+       json_object *json_vrf = NULL;
+
+       if (uj)
+               json_parent = json_object_new_object();
+
+       RB_FOREACH (v, vrf_name_head, &vrfs_by_name) {
+               if (!uj)
+                       vty_out(vty, "VRF: %s\n", v->name);
+               else
+                       json_vrf = json_object_new_object();
+
+               if (interface)
+                       pim_show_interfaces_single(v->info, vty, interface,
+                                                  mlag, json_vrf);
+               else
+                       pim_show_interfaces(v->info, vty, mlag, json_vrf);
+
+               if (uj)
+                       json_object_object_add(json_parent, v->name, json_vrf);
+       }
+       if (uj)
+               vty_json(vty, json_parent);
+
+       return CMD_SUCCESS;
+}
+
 void pim_show_interfaces(struct pim_instance *pim, struct vty *vty, bool mlag,
                         json_object *json)
 {
index c16bf0bea470ef2aa473935a473afff9fca9630e..f7c4e54e0eb1596bc244f61773176e6b7974eccf 100644 (file)
@@ -91,6 +91,8 @@ void pim_show_channel(struct pim_instance *pim, struct vty *vty, bool uj);
 int pim_show_channel_cmd_helper(const char *vrf, struct vty *vty, bool uj);
 int pim_show_interface_cmd_helper(const char *vrf, struct vty *vty, bool uj,
                                  bool mlag, const char *interface);
+int pim_show_interface_vrf_all_cmd_helper(struct vty *vty, bool uj, bool mlag,
+                                         const char *interface);
 void pim_show_interfaces(struct pim_instance *pim, struct vty *vty, bool mlag,
                         json_object *json);
 void pim_show_interfaces_single(struct pim_instance *pim, struct vty *vty,