summaryrefslogtreecommitdiff
path: root/pimd/pim_cmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'pimd/pim_cmd.c')
-rw-r--r--pimd/pim_cmd.c62
1 files changed, 39 insertions, 23 deletions
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c
index aa1ff5c925..866be77404 100644
--- a/pimd/pim_cmd.c
+++ b/pimd/pim_cmd.c
@@ -4631,9 +4631,9 @@ DEFPY (show_ip_pim_rp_vrf_all,
return CMD_SUCCESS;
}
-DEFUN (show_ip_pim_rpf,
+DEFPY (show_ip_pim_rpf,
show_ip_pim_rpf_cmd,
- "show ip pim [vrf NAME] rpf [json]",
+ "show ip pim [vrf NAME] rpf [json$json]",
SHOW_STR
IP_STR
PIM_STR
@@ -4641,21 +4641,36 @@ DEFUN (show_ip_pim_rpf,
"PIM cached source rpf information\n"
JSON_STR)
{
- int idx = 2;
- struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
- bool uj = use_json(argc, argv);
+ struct pim_instance *pim;
+ struct vrf *v;
+ json_object *json_parent = NULL;
- if (!vrf)
+ 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 (json)
+ json_parent = json_object_new_object();
+
+ pim_show_rpf(pim, vty, json_parent);
- pim_show_rpf(vrf->info, vty, uj);
+ if (json)
+ vty_json(vty, json_parent);
return CMD_SUCCESS;
}
-DEFUN (show_ip_pim_rpf_vrf_all,
+DEFPY (show_ip_pim_rpf_vrf_all,
show_ip_pim_rpf_vrf_all_cmd,
- "show ip pim vrf all rpf [json]",
+ "show ip pim vrf all rpf [json$json]",
SHOW_STR
IP_STR
PIM_STR
@@ -4663,24 +4678,25 @@ DEFUN (show_ip_pim_rpf_vrf_all,
"PIM cached source rpf information\n"
JSON_STR)
{
- bool uj = use_json(argc, argv);
struct vrf *vrf;
- bool first = true;
+ json_object *json_parent = NULL;
+ json_object *json_vrf = NULL;
+
+ if (json)
+ json_parent = json_object_new_object();
- if (uj)
- vty_out(vty, "{ ");
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
- if (uj) {
- if (!first)
- vty_out(vty, ", ");
- vty_out(vty, " \"%s\": ", vrf->name);
- first = false;
- } else
+ if (!json)
vty_out(vty, "VRF: %s\n", vrf->name);
- pim_show_rpf(vrf->info, vty, uj);
+ else
+ json_vrf = json_object_new_object();
+ pim_show_rpf(vrf->info, vty, json_vrf);
+ if (json)
+ json_object_object_add(json_parent, vrf->name,
+ json_vrf);
}
- if (uj)
- vty_out(vty, "}\n");
+ if (json)
+ vty_json(vty, json_parent);
return CMD_SUCCESS;
}
@@ -4998,7 +5014,7 @@ static void pim_cmd_show_ip_multicast_helper(struct pim_instance *pim,
vty_out(vty, "\n");
- show_rpf_refresh_stats(vty, pim, now, NULL);
+ pim_show_rpf_refresh_stats(vty, pim, now, NULL);
vty_out(vty, "\n");