From: Sai Gomathi N Date: Thu, 9 Jun 2022 08:34:06 +0000 (-0700) Subject: pim6d: Moving the common lines of pim_show_neighbors cli X-Git-Tag: base_8.4~372^2~4 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=154aa4fcd42743f9f0bc370489ed28e78fb27262;p=mirror%2Ffrr.git pim6d: Moving the common lines of pim_show_neighbors cli 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 --- diff --git a/pimd/pim6_cmd.c b/pimd/pim6_cmd.c index 3fb36eae71..764e8059a9 100644 --- a/pimd/pim6_cmd.c +++ b/pimd/pim6_cmd.c @@ -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, diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 31162fdf1e..1afa707620 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -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, diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c index ca7ab5577f..42c6c2c98c 100644 --- a/pimd/pim_cmd_common.c +++ b/pimd/pim_cmd_common.c @@ -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) { diff --git a/pimd/pim_cmd_common.h b/pimd/pim_cmd_common.h index b16dd4b948..6bd3f48f11 100644 --- a/pimd/pim_cmd_common.h +++ b/pimd/pim_cmd_common.h @@ -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,