From b6bf33775de493676cad5ae27c5545550d8a99c8 Mon Sep 17 00:00:00 2001 From: Sai Gomathi N Date: Wed, 1 Jun 2022 21:54:44 -0700 Subject: [PATCH] pim6d: Moving the common lines of pim_show_channel cli Moving the common lines of pim_show_channel cli in pim_cmd.c and pim6_cmd.c to pim_cmd_common.c file Signed-off-by: Sai Gomathi N --- pimd/pim6_cmd.c | 12 +----------- pimd/pim_cmd.c | 12 +----------- pimd/pim_cmd_common.c | 14 ++++++++++++++ pimd/pim_cmd_common.h | 1 + 4 files changed, 17 insertions(+), 22 deletions(-) diff --git a/pimd/pim6_cmd.c b/pimd/pim6_cmd.c index 77844988ea..bb9e2f7db6 100644 --- a/pimd/pim6_cmd.c +++ b/pimd/pim6_cmd.c @@ -1235,17 +1235,7 @@ DEFPY (show_ipv6_pim_channel, "PIM downstream channel info\n" JSON_STR) { - struct vrf *v; - bool uj = !!json; - - v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME); - - if (!v) - return CMD_WARNING; - - pim_show_channel(v->info, vty, uj); - - return CMD_SUCCESS; + return pim_show_channel_cmd_helper(vrf, vty, !!json); } DEFPY (show_ipv6_pim_interface, diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 2d6ce24381..3cdf53709d 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -3168,17 +3168,7 @@ DEFPY (show_ip_pim_channel, "PIM downstream channel info\n" JSON_STR) { - struct vrf *v; - bool uj = !!json; - - v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME); - - if (!v) - return CMD_WARNING; - - pim_show_channel(v->info, vty, uj); - - return CMD_SUCCESS; + return pim_show_channel_cmd_helper(vrf, vty, !!json); } DEFPY (show_ip_pim_upstream_join_desired, diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c index d5eb763df3..895ac0c81e 100644 --- a/pimd/pim_cmd_common.c +++ b/pimd/pim_cmd_common.c @@ -1945,6 +1945,20 @@ void pim_show_channel(struct pim_instance *pim, struct vty *vty, bool uj) vty_json(vty, json); } +int pim_show_channel_cmd_helper(const char *vrf, struct vty *vty, bool uj) +{ + struct vrf *v; + + v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME); + + if (!v) + return CMD_WARNING; + + pim_show_channel(v->info, vty, uj); + + return CMD_SUCCESS; +} + void pim_show_interfaces(struct pim_instance *pim, struct vty *vty, bool mlag, json_object *json) { diff --git a/pimd/pim_cmd_common.h b/pimd/pim_cmd_common.h index 9644f84e0c..21592385a4 100644 --- a/pimd/pim_cmd_common.h +++ b/pimd/pim_cmd_common.h @@ -88,6 +88,7 @@ void pim_show_join(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg, void pim_show_jp_agg_list(struct pim_instance *pim, struct vty *vty); void pim_show_membership(struct pim_instance *pim, struct vty *vty, bool uj); 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); 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, -- 2.39.5