]> git.proxmox.com Git - mirror_frr.git/commitdiff
pim6d: Moving the common lines of pim_show_neighbors_vrf_all cli
authorSai Gomathi N <nsaigomathi@vmware.com>
Thu, 9 Jun 2022 09:36:08 +0000 (02:36 -0700)
committerSai Gomathi N <nsaigomathi@vmware.com>
Thu, 9 Jun 2022 09:36:08 +0000 (02:36 -0700)
Moving the common lines of pim_show_neighbors_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 764e8059a97c909d94b419fcceea335620024dd2..a46e7fa178d94481afdc0e0eabd920320661b36b 100644 (file)
@@ -1406,31 +1406,7 @@ DEFPY (show_ipv6_pim_neighbor_vrf_all,
        "Name of interface or neighbor\n"
        JSON_STR)
 {
-       struct vrf *v;
-       json_object *json_parent = NULL;
-       json_object *json_vrf = NULL;
-
-       if (json)
-               json_parent = json_object_new_object();
-       RB_FOREACH (v, vrf_name_head, &vrfs_by_name) {
-               if (!json)
-                       vty_out(vty, "VRF: %s\n", v->name);
-               else
-                       json_vrf = json_object_new_object();
-
-               if (interface)
-                       pim_show_neighbors_single(v->info, vty, interface,
-                                                 json_vrf);
-               else
-                       pim_show_neighbors(v->info, vty, json_vrf);
-
-               if (json)
-                       json_object_object_add(json_parent, v->name, json_vrf);
-       }
-       if (json)
-               vty_json(vty, json_parent);
-
-       return CMD_SUCCESS;
+       return pim_show_neighbors_vrf_all_cmd_helper(vty, json, interface);
 }
 
 DEFPY (show_ipv6_pim_nexthop,
index 1afa707620bd7a759a53238d330fd004f1c535d0..4e573d23721fa53e17a679194e9fd70b8dd5307d 100644 (file)
@@ -2850,31 +2850,7 @@ DEFPY (show_ip_pim_neighbor_vrf_all,
        "Name of interface or neighbor\n"
        JSON_STR)
 {
-       struct vrf *v;
-       json_object *json_parent = NULL;
-       json_object *json_vrf = NULL;
-
-       if (json)
-               json_parent = json_object_new_object();
-       RB_FOREACH (v, vrf_name_head, &vrfs_by_name) {
-               if (!json)
-                       vty_out(vty, "VRF: %s\n", v->name);
-               else
-                       json_vrf = json_object_new_object();
-
-               if (interface)
-                       pim_show_neighbors_single(v->info, vty, interface,
-                                                 json_vrf);
-               else
-                       pim_show_neighbors(v->info, vty, json_vrf);
-
-               if (json)
-                       json_object_object_add(json_parent, v->name, json_vrf);
-       }
-       if (json)
-               vty_json(vty, json_parent);
-
-       return CMD_SUCCESS;
+       return pim_show_neighbors_vrf_all_cmd_helper(vty, json, interface);
 }
 
 DEFPY (show_ip_pim_secondary,
index 42c6c2c98cfd523fecf53f013e3bdde5bc34eb27..e7299f221411508ac7756d954e3585ed911f090e 100644 (file)
@@ -2636,6 +2636,36 @@ int pim_show_neighbors_cmd_helper(const char *vrf, struct vty *vty,
        return CMD_SUCCESS;
 }
 
+int pim_show_neighbors_vrf_all_cmd_helper(struct vty *vty, const char *json,
+                                         const char *interface)
+{
+       struct vrf *v;
+       json_object *json_parent = NULL;
+       json_object *json_vrf = NULL;
+
+       if (json)
+               json_parent = json_object_new_object();
+       RB_FOREACH (v, vrf_name_head, &vrfs_by_name) {
+               if (!json)
+                       vty_out(vty, "VRF: %s\n", v->name);
+               else
+                       json_vrf = json_object_new_object();
+
+               if (interface)
+                       pim_show_neighbors_single(v->info, vty, interface,
+                                                 json_vrf);
+               else
+                       pim_show_neighbors(v->info, vty, json_vrf);
+
+               if (json)
+                       json_object_object_add(json_parent, v->name, json_vrf);
+       }
+       if (json)
+               vty_json(vty, json_parent);
+
+       return CMD_SUCCESS;
+}
+
 void pim_show_neighbors_single(struct pim_instance *pim, struct vty *vty,
                               const char *neighbor, json_object *json)
 {
index 6bd3f48f1186aa1eeff7803893ad69f2b13fbaa5..d6fd360ac8c7a52a60316dbacbf4bab8f611ce32 100644 (file)
@@ -105,6 +105,8 @@ void ip_pim_ssm_show_group_range(struct pim_instance *pim, struct vty *vty,
 void pim_show_nexthop(struct pim_instance *pim, struct vty *vty);
 int pim_show_neighbors_cmd_helper(const char *vrf, struct vty *vty,
                                  const char *json, const char *interface);
+int pim_show_neighbors_vrf_all_cmd_helper(struct vty *vty, const char *json,
+                                         const char *interface);
 void pim_show_neighbors_single(struct pim_instance *pim, struct vty *vty,
                               const char *neighbor, json_object *json);
 void pim_show_neighbors(struct pim_instance *pim, struct vty *vty,