diff options
Diffstat (limited to 'pimd/pim_cmd_common.c')
| -rw-r--r-- | pimd/pim_cmd_common.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c index 2807762175..3bc7381e0d 100644 --- a/pimd/pim_cmd_common.c +++ b/pimd/pim_cmd_common.c @@ -3791,3 +3791,77 @@ int pim_show_rpf_vrf_all_helper(struct vty *vty, bool json) return CMD_SUCCESS; } + +int pim_show_rp_helper(const char *vrf, struct vty *vty, const char *group_str, + const struct prefix *group, bool json) +{ + struct pim_instance *pim; + struct vrf *v; + json_object *json_parent = NULL; + struct prefix *range = NULL; + + 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 (group_str) { + range = prefix_new(); + prefix_copy(range, group); + apply_mask(range); + } + + if (json) + json_parent = json_object_new_object(); + + pim_rp_show_information(pim, range, vty, json_parent); + + if (json) + vty_json(vty, json_parent); + + prefix_free(&range); + + return CMD_SUCCESS; +} + +int pim_show_rp_vrf_all_helper(struct vty *vty, const char *group_str, + const struct prefix *group, bool json) +{ + struct vrf *vrf; + json_object *json_parent = NULL; + json_object *json_vrf = NULL; + struct prefix *range = NULL; + + if (group_str) { + range = prefix_new(); + prefix_copy(range, group); + apply_mask(range); + } + + 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_rp_show_information(vrf->info, range, vty, json_vrf); + if (json) + json_object_object_add(json_parent, vrf->name, + json_vrf); + } + if (json) + vty_json(vty, json_parent); + + prefix_free(&range); + + return CMD_SUCCESS; +} |
