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.c99
1 files changed, 83 insertions, 16 deletions
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c
index 2baaca1c9f..83ba74f69f 100644
--- a/pimd/pim_cmd.c
+++ b/pimd/pim_cmd.c
@@ -2427,9 +2427,9 @@ static void pim_show_upstream(struct pim_instance *pim, struct vty *vty,
if (!up->t_join_timer && up->rpf.source_nexthop.interface) {
struct pim_neighbor *nbr;
- nbr = pim_neighbor_find(
+ nbr = pim_neighbor_find_prefix(
up->rpf.source_nexthop.interface,
- up->rpf.rpf_addr.u.prefix4);
+ &up->rpf.rpf_addr);
if (nbr)
pim_time_timer_to_hhmmss(join_timer,
sizeof(join_timer),
@@ -3488,15 +3488,24 @@ static void igmp_show_group_retransmission(struct pim_instance *pim,
} /* scan interfaces */
}
-static void igmp_show_sources(struct pim_instance *pim, struct vty *vty)
+static void igmp_show_sources(struct pim_instance *pim, struct vty *vty,
+ bool uj)
{
struct interface *ifp;
time_t now;
+ json_object *json = NULL;
+ json_object *json_iface = NULL;
+ json_object *json_group = NULL;
+ json_object *json_source = NULL;
+ json_object *json_sources = NULL;
now = pim_time_monotonic_sec();
- vty_out(vty,
- "Interface Group Source Timer Fwd Uptime \n");
+ if (uj)
+ json = json_object_new_object();
+ else
+ vty_out(vty,
+ "Interface Address Group Source Timer Fwd Uptime \n");
/* scan interfaces */
FOR_ALL_INTERFACES (pim->vrf, ifp) {
@@ -3533,17 +3542,70 @@ static void igmp_show_sources(struct pim_instance *pim, struct vty *vty)
pim_time_uptime(uptime, sizeof(uptime),
now - src->source_creation);
- vty_out(vty, "%-16s %-15s %-15s %5s %3s %8s\n",
- ifp->name, group_str, source_str, mmss,
- IGMP_SOURCE_TEST_FORWARDING(
- src->source_flags)
- ? "Y"
- : "N",
- uptime);
+ if (uj) {
+ json_object_object_get_ex(
+ json, ifp->name, &json_iface);
+ if (!json_iface) {
+ json_iface =
+ json_object_new_object();
+ json_object_string_add(
+ json_iface, "name",
+ ifp->name);
+ json_object_object_add(
+ json, ifp->name,
+ json_iface);
+ }
+ json_object_object_get_ex(json_iface,
+ group_str,
+ &json_group);
+
+ if (!json_group) {
+ json_group =
+ json_object_new_object();
+ json_object_string_add(
+ json_group, "group",
+ group_str);
+ json_object_object_add(
+ json_iface, group_str,
+ json_group);
+ json_sources =
+ json_object_new_array();
+ json_object_object_add(
+ json_group, "sources",
+ json_sources);
+ }
+ json_source = json_object_new_object();
+ json_object_string_add(json_source,
+ "source",
+ source_str);
+ json_object_string_add(json_source,
+ "timer", mmss);
+ json_object_boolean_add(
+ json_source, "forwarded",
+ IGMP_SOURCE_TEST_FORWARDING(
+ src->source_flags));
+ json_object_string_add(
+ json_source, "uptime", uptime);
+ json_object_array_add(json_sources,
+ json_source);
+
+ } else {
+ vty_out(vty,
+ "%-16s %-15s %-15s %5s %3s %8s\n",
+ ifp->name, group_str,
+ source_str, mmss,
+ IGMP_SOURCE_TEST_FORWARDING(
+ src->source_flags)
+ ? "Y"
+ : "N",
+ uptime);
+ }
} /* scan group sources */
} /* scan igmp groups */
} /* scan interfaces */
+ if (uj)
+ vty_json(vty, json);
}
static void igmp_show_source_retransmission(struct pim_instance *pim,
@@ -4189,12 +4251,13 @@ DEFUN (show_ip_igmp_groups_retransmissions,
DEFUN (show_ip_igmp_sources,
show_ip_igmp_sources_cmd,
- "show ip igmp [vrf NAME] sources",
+ "show ip igmp [vrf NAME] sources [json]",
SHOW_STR
IP_STR
IGMP_STR
VRF_CMD_HELP_STR
- IGMP_SOURCE_STR)
+ IGMP_SOURCE_STR
+ JSON_STR)
{
int idx = 2;
struct vrf *vrf = pim_cmd_lookup_vrf(vty, argv, argc, &idx);
@@ -4202,7 +4265,7 @@ DEFUN (show_ip_igmp_sources,
if (!vrf)
return CMD_WARNING;
- igmp_show_sources(vrf->info, vty);
+ igmp_show_sources(vrf->info, vty, use_json(argc, argv));
return CMD_SUCCESS;
}
@@ -8174,7 +8237,8 @@ DEFPY_HIDDEN (interface_ip_igmp_query_generate,
"IGMP version number\n")
{
VTY_DECLVAR_CONTEXT(interface, ifp);
- int igmp_version = 2;
+ int igmp_version;
+ struct pim_interface *pim_ifp = ifp->info;
if (!ifp->info) {
vty_out(vty, "IGMP/PIM is not enabled on the interface %s\n",
@@ -8182,6 +8246,9 @@ DEFPY_HIDDEN (interface_ip_igmp_query_generate,
return CMD_WARNING_CONFIG_FAILED;
}
+ /* It takes the igmp version configured on the interface as default */
+ igmp_version = pim_ifp->igmp_version;
+
if (argc > 3)
igmp_version = atoi(argv[4]->arg);