diff options
-rw-r--r-- | pimd/pim_cmd.c | 19 | ||||
-rw-r--r-- | pimd/pim_cmd_common.c | 26 | ||||
-rw-r--r-- | pimd/pim_cmd_common.h | 2 |
3 files changed, 31 insertions, 16 deletions
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 2e4c98f75..817ebcc25 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -2806,9 +2806,9 @@ DEFPY (show_ip_pim_nexthop_lookup, return pim_show_nexthop_lookup_cmd_helper(vrf, vty, source, group); } -DEFUN (show_ip_pim_interface_traffic, +DEFPY (show_ip_pim_interface_traffic, show_ip_pim_interface_traffic_cmd, - "show ip pim [vrf NAME] interface traffic [WORD] [json]", + "show ip pim [vrf NAME] interface traffic [WORD$if_name] [json$json]", SHOW_STR IP_STR PIM_STR @@ -2818,20 +2818,7 @@ DEFUN (show_ip_pim_interface_traffic, "Interface name\n" JSON_STR) { - int idx = 2; - struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx); - bool uj = use_json(argc, argv); - - if (!vrf) - return CMD_WARNING; - - if (argv_find(argv, argc, "WORD", &idx)) - pim_show_interface_traffic_single(vrf->info, vty, - argv[idx]->arg, uj); - else - pim_show_interface_traffic(vrf->info, vty, uj); - - return CMD_SUCCESS; + return pim_show_interface_traffic_helper(vrf, if_name, vty, !!json); } DEFUN (show_ip_pim_bsm_db, diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c index bfa0ddec6..2e03bac94 100644 --- a/pimd/pim_cmd_common.c +++ b/pimd/pim_cmd_common.c @@ -4825,3 +4825,29 @@ void pim_show_interface_traffic_single(struct pim_instance *pim, else if (!found_ifname) vty_out(vty, "%% No such interface\n"); } + +int pim_show_interface_traffic_helper(const char *vrf, const char *if_name, + struct vty *vty, bool uj) +{ + struct pim_instance *pim; + struct vrf *v; + + v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME); + + if (!v) + return CMD_WARNING; + + pim = pim_get_pim_instance(v->vrf_id); + + if (!pim) { + vty_out(vty, "%% Unable to find pim instance\n"); + return CMD_WARNING; + } + + if (if_name) + pim_show_interface_traffic_single(v->info, vty, if_name, uj); + else + pim_show_interface_traffic(v->info, vty, uj); + + return CMD_SUCCESS; +} diff --git a/pimd/pim_cmd_common.h b/pimd/pim_cmd_common.h index ead6c9b48..67e092e07 100644 --- a/pimd/pim_cmd_common.h +++ b/pimd/pim_cmd_common.h @@ -185,6 +185,8 @@ void pim_show_interface_traffic_single(struct pim_instance *pim, bool uj); void pim_show_interface_traffic(struct pim_instance *pim, struct vty *vty, bool uj); +int pim_show_interface_traffic_helper(const char *vrf, const char *if_name, + struct vty *vty, bool uj); /* * Special Macro to allow us to get the correct pim_instance; */ |