]> git.proxmox.com Git - mirror_frr.git/commitdiff
pim6d: Moving the common lines of pim_show_neighbors cli
authorSai Gomathi N <nsaigomathi@vmware.com>
Thu, 9 Jun 2022 08:34:06 +0000 (01:34 -0700)
committerSai Gomathi N <nsaigomathi@vmware.com>
Thu, 9 Jun 2022 08:34:06 +0000 (01:34 -0700)
Moving the common lines of pim_show_neighbors 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 3fb36eae71ef3c9cd3fd5437050466a2cafaafeb..764e8059a97c909d94b419fcceea335620024dd2 100644 (file)
@@ -1391,26 +1391,7 @@ DEFPY (show_ipv6_pim_neighbor,
        "Name of interface or neighbor\n"
        JSON_STR)
 {
-       struct vrf *v;
-       json_object *json_parent = NULL;
-
-       v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
-
-       if (!v)
-               return CMD_WARNING;
-
-       if (json)
-               json_parent = json_object_new_object();
-
-       if (interface)
-               pim_show_neighbors_single(v->info, vty, interface, json_parent);
-       else
-               pim_show_neighbors(v->info, vty, json_parent);
-
-       if (json)
-               vty_json(vty, json_parent);
-
-       return CMD_SUCCESS;
+       return pim_show_neighbors_cmd_helper(vrf, vty, json, interface);
 }
 
 DEFPY (show_ipv6_pim_neighbor_vrf_all,
index 31162fdf1e39f16c7bed4c577daf0d65575e51e1..1afa707620bd7a759a53238d330fd004f1c535d0 100644 (file)
@@ -2835,26 +2835,7 @@ DEFPY (show_ip_pim_neighbor,
        "Name of interface or neighbor\n"
        JSON_STR)
 {
-       struct vrf *v;
-       json_object *json_parent = NULL;
-
-       v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
-
-       if (!v)
-               return CMD_WARNING;
-
-       if (json)
-               json_parent = json_object_new_object();
-
-       if (interface)
-               pim_show_neighbors_single(v->info, vty, interface, json_parent);
-       else
-               pim_show_neighbors(v->info, vty, json_parent);
-
-       if (json)
-               vty_json(vty, json_parent);
-
-       return CMD_SUCCESS;
+       return pim_show_neighbors_cmd_helper(vrf, vty, json, interface);
 }
 
 DEFPY (show_ip_pim_neighbor_vrf_all,
index ca7ab5577f4608a5a0b88bb1d616b966433ad89d..42c6c2c98cfd523fecf53f013e3bdde5bc34eb27 100644 (file)
@@ -2611,6 +2611,31 @@ void pim_show_nexthop(struct pim_instance *pim, struct vty *vty)
        hash_walk(pim->rpf_hash, pim_print_pnc_cache_walkcb, &cwd);
 }
 
+int pim_show_neighbors_cmd_helper(const char *vrf, struct vty *vty,
+                                 const char *json, const char *interface)
+{
+       struct vrf *v;
+       json_object *json_parent = NULL;
+
+       v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME);
+
+       if (!v)
+               return CMD_WARNING;
+
+       if (json)
+               json_parent = json_object_new_object();
+
+       if (interface)
+               pim_show_neighbors_single(v->info, vty, interface, json_parent);
+       else
+               pim_show_neighbors(v->info, vty, json_parent);
+
+       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 b16dd4b9481f289964594ec2db081468cc4dce1f..6bd3f48f1186aa1eeff7803893ad69f2b13fbaa5 100644 (file)
@@ -103,6 +103,8 @@ void pim_show_interfaces_single(struct pim_instance *pim, struct vty *vty,
 void ip_pim_ssm_show_group_range(struct pim_instance *pim, struct vty *vty,
                                 bool uj);
 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);
 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,