diff options
author | Abhishek N R <abnr@vmware.com> | 2022-06-09 11:40:21 +0200 |
---|---|---|
committer | Abhishek N R <abnr@vmware.com> | 2022-06-09 11:40:21 +0200 |
commit | 9aa0569d6e7d59e097e9739fd757c8f4fe817279 (patch) | |
tree | 76160437b98ac54f1a6db230be4353d6d50a6020 /pimd/pim_cmd_common.c | |
parent | pim6d: Moving reusable code to common api for "show pim statistics" command (diff) | |
download | frr-9aa0569d6e7d59e097e9739fd757c8f4fe817279.tar.xz frr-9aa0569d6e7d59e097e9739fd757c8f4fe817279.zip |
pim6d: Moving reusable code to common api for "show pim upstream" command
Signed-off-by: Abhishek N R <abnr@vmware.com>
Diffstat (limited to 'pimd/pim_cmd_common.c')
-rw-r--r-- | pimd/pim_cmd_common.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c index 46f48e91a..1159ebd3d 100644 --- a/pimd/pim_cmd_common.c +++ b/pimd/pim_cmd_common.c @@ -3913,3 +3913,70 @@ int pim_show_statistics_helper(const char *vrf, struct vty *vty, return CMD_SUCCESS; } + +int pim_show_upstream_helper(const char *vrf, struct vty *vty, pim_addr s_or_g, + pim_addr g, bool json) +{ + pim_sgaddr sg = {0}; + struct vrf *v; + struct pim_instance *pim; + json_object *json_parent = NULL; + + v = vrf_lookup_by_name(vrf ? vrf : VRF_DEFAULT_NAME); + + if (!v) { + vty_out(vty, "%% Vrf specified: %s does not exist\n", vrf); + 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 (json) + json_parent = json_object_new_object(); + + if (!pim_addr_is_any(s_or_g)) { + if (!pim_addr_is_any(g)) { + sg.src = s_or_g; + sg.grp = g; + } else + sg.grp = s_or_g; + } + + pim_show_upstream(pim, vty, &sg, json_parent); + + if (json) + vty_json(vty, json_parent); + + return CMD_SUCCESS; +} + +int pim_show_upstream_vrf_all_helper(struct vty *vty, bool json) +{ + pim_sgaddr sg = {0}; + struct vrf *vrf; + json_object *json_parent = NULL; + json_object *json_vrf = NULL; + + if (json) + json_parent = json_object_new_object(); + + RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { + if (!json) + vty_out(vty, "VRF: %s\n", vrf->name); + else + json_vrf = json_object_new_object(); + pim_show_upstream(vrf->info, vty, &sg, json_vrf); + if (json) + json_object_object_add(json_parent, vrf->name, + json_vrf); + } + + if (json) + vty_json(vty, json_parent); + + return CMD_SUCCESS; +} |