mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 13:13:08 +00:00
pimd: Added json to 'show ip igmp group'
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com> root@superm-redxp-05[quagga-pim]# vtysh -c 'show ip igmp group' Interface Address Group Mode Timer Srcs V Uptime br1 20.0.13.1 230.40.40.1 EXCL 00:03:24 1 3 00:01:28 root@superm-redxp-05[quagga-pim]# root@superm-redxp-05[quagga-pim]# root@superm-redxp-05[quagga-pim]# vtysh -c 'show ip igmp group json' | python -m json.tool { "br1": { "230.40.40.1": { "group": "230.40.40.1", "mode": "EXCLUDE", "source": "20.0.13.1", "sourcesCount": 1, "timer": "00:03:23", "uptime": "00:01:30", "version": 3 }, "address": "20.0.13.1", "flagBroadcast": true, "flagMulticast": true, "index": 96, "lanDelayEnabled": true, "name": "br1", "state": "up" } } root@superm-redxp-05[quagga-pim]#
This commit is contained in:
parent
c7b1183fc7
commit
9b91bb50f8
121
pimd/pim_cmd.c
121
pimd/pim_cmd.c
@ -577,6 +577,9 @@ static void igmp_show_interfaces_single(struct vty *vty, const char *ifname, u_c
|
|||||||
json_object *json = NULL;
|
json_object *json = NULL;
|
||||||
json_object *json_row = NULL;
|
json_object *json_row = NULL;
|
||||||
|
|
||||||
|
if (uj)
|
||||||
|
json = json_object_new_object();
|
||||||
|
|
||||||
now = pim_time_monotonic_sec();
|
now = pim_time_monotonic_sec();
|
||||||
|
|
||||||
for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
|
for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
|
||||||
@ -585,7 +588,7 @@ static void igmp_show_interfaces_single(struct vty *vty, const char *ifname, u_c
|
|||||||
if (!pim_ifp)
|
if (!pim_ifp)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (strcmp(ifname, ifp->name))
|
if (strcmp(ifname, "detail") && strcmp(ifname, ifp->name))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
|
for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
|
||||||
@ -615,7 +618,6 @@ static void igmp_show_interfaces_single(struct vty *vty, const char *ifname, u_c
|
|||||||
mloop = pim_socket_mcastloop_get(pim_ifp->pim_sock_fd);
|
mloop = pim_socket_mcastloop_get(pim_ifp->pim_sock_fd);
|
||||||
|
|
||||||
if (uj) {
|
if (uj) {
|
||||||
json = json_object_new_object();
|
|
||||||
json_row = json_object_new_object();
|
json_row = json_object_new_object();
|
||||||
json_object_pim_ifp_add(json_row, ifp);
|
json_object_pim_ifp_add(json_row, ifp);
|
||||||
|
|
||||||
@ -634,8 +636,6 @@ static void igmp_show_interfaces_single(struct vty *vty, const char *ifname, u_c
|
|||||||
json_object_int_add(json_row, "timerStartupQueryInterval", sqi);
|
json_object_int_add(json_row, "timerStartupQueryInterval", sqi);
|
||||||
|
|
||||||
json_object_object_add(json, ifp->name, json_row);
|
json_object_object_add(json, ifp->name, json_row);
|
||||||
vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
|
|
||||||
json_object_free(json);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
vty_out(vty, "Interface : %s%s", ifp->name, VTY_NEWLINE);
|
vty_out(vty, "Interface : %s%s", ifp->name, VTY_NEWLINE);
|
||||||
@ -672,13 +672,13 @@ static void igmp_show_interfaces_single(struct vty *vty, const char *ifname, u_c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found_ifname)
|
if (uj) {
|
||||||
{
|
vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
|
||||||
if (uj)
|
json_object_free(json);
|
||||||
vty_out (vty, "{}%s", VTY_NEWLINE);
|
} else {
|
||||||
else
|
if (!found_ifname)
|
||||||
vty_out (vty, "%% No such interface%s", VTY_NEWLINE);
|
vty_out (vty, "%% No such interface%s", VTY_NEWLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void igmp_show_interface_join(struct vty *vty)
|
static void igmp_show_interface_join(struct vty *vty)
|
||||||
@ -768,6 +768,9 @@ static void pim_show_interfaces_single(struct vty *vty, const char *ifname, u_ch
|
|||||||
|
|
||||||
now = pim_time_monotonic_sec();
|
now = pim_time_monotonic_sec();
|
||||||
|
|
||||||
|
if (uj)
|
||||||
|
json = json_object_new_object();
|
||||||
|
|
||||||
for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
|
for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp)) {
|
||||||
pim_ifp = ifp->info;
|
pim_ifp = ifp->info;
|
||||||
|
|
||||||
@ -777,7 +780,7 @@ static void pim_show_interfaces_single(struct vty *vty, const char *ifname, u_ch
|
|||||||
if (pim_ifp->pim_sock_fd < 0)
|
if (pim_ifp->pim_sock_fd < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (strcmp(ifname, ifp->name))
|
if (strcmp(ifname, "detail") && strcmp(ifname, ifp->name))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
found_ifname = 1;
|
found_ifname = 1;
|
||||||
@ -790,7 +793,6 @@ static void pim_show_interfaces_single(struct vty *vty, const char *ifname, u_ch
|
|||||||
mloop = pim_socket_mcastloop_get(pim_ifp->pim_sock_fd);
|
mloop = pim_socket_mcastloop_get(pim_ifp->pim_sock_fd);
|
||||||
|
|
||||||
if (uj) {
|
if (uj) {
|
||||||
json = json_object_new_object();
|
|
||||||
json_row = json_object_new_object();
|
json_row = json_object_new_object();
|
||||||
json_object_pim_ifp_add(json_row, ifp);
|
json_object_pim_ifp_add(json_row, ifp);
|
||||||
|
|
||||||
@ -871,10 +873,7 @@ static void pim_show_interfaces_single(struct vty *vty, const char *ifname, u_ch
|
|||||||
json_object_int_add(json_row, "propagationDelayHighest", pim_ifp->pim_neighbors_highest_propagation_delay_msec);
|
json_object_int_add(json_row, "propagationDelayHighest", pim_ifp->pim_neighbors_highest_propagation_delay_msec);
|
||||||
json_object_int_add(json_row, "overrideInterval", pim_ifp->pim_override_interval_msec);
|
json_object_int_add(json_row, "overrideInterval", pim_ifp->pim_override_interval_msec);
|
||||||
json_object_int_add(json_row, "overrideIntervalHighest", pim_ifp->pim_neighbors_highest_override_interval_msec);
|
json_object_int_add(json_row, "overrideIntervalHighest", pim_ifp->pim_neighbors_highest_override_interval_msec);
|
||||||
|
|
||||||
json_object_object_add(json, ifp->name, json_row);
|
json_object_object_add(json, ifp->name, json_row);
|
||||||
vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
|
|
||||||
json_object_free(json);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
vty_out(vty, "Interface : %s%s", ifp->name, VTY_NEWLINE);
|
vty_out(vty, "Interface : %s%s", ifp->name, VTY_NEWLINE);
|
||||||
@ -974,13 +973,13 @@ static void pim_show_interfaces_single(struct vty *vty, const char *ifname, u_ch
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found_ifname)
|
if (uj) {
|
||||||
{
|
vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
|
||||||
if (uj)
|
json_object_free(json);
|
||||||
vty_out (vty, "{}%s", VTY_NEWLINE);
|
} else {
|
||||||
else
|
if (!found_ifname)
|
||||||
vty_out (vty, "%% No such interface%s", VTY_NEWLINE);
|
vty_out (vty, "%% No such interface%s", VTY_NEWLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1185,7 +1184,9 @@ static void pim_show_neighbors_single(struct vty *vty, const char *neighbor, u_c
|
|||||||
* The user can specify either the interface name or the PIM neighbor IP.
|
* The user can specify either the interface name or the PIM neighbor IP.
|
||||||
* If this pim_ifp matches neither then skip.
|
* If this pim_ifp matches neither then skip.
|
||||||
*/
|
*/
|
||||||
if (strcmp(neighbor, ifp->name) && strcmp(neighbor, neigh_src_str))
|
if (strcmp(neighbor, "detail") &&
|
||||||
|
strcmp(neighbor, ifp->name) &&
|
||||||
|
strcmp(neighbor, neigh_src_str))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
found_neighbor = 1;
|
found_neighbor = 1;
|
||||||
@ -1777,15 +1778,21 @@ static void pim_show_rpf(struct vty *vty, u_char uj)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void igmp_show_groups(struct vty *vty)
|
static void igmp_show_groups(struct vty *vty, u_char uj)
|
||||||
{
|
{
|
||||||
struct listnode *ifnode;
|
struct listnode *ifnode;
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
time_t now;
|
time_t now;
|
||||||
|
json_object *json = NULL;
|
||||||
|
json_object *json_iface = NULL;
|
||||||
|
json_object *json_row = NULL;
|
||||||
|
|
||||||
now = pim_time_monotonic_sec();
|
now = pim_time_monotonic_sec();
|
||||||
|
|
||||||
vty_out(vty, "Interface Address Group Mode Timer Srcs V Uptime %s", VTY_NEWLINE);
|
if (uj)
|
||||||
|
json = json_object_new_object();
|
||||||
|
else
|
||||||
|
vty_out(vty, "Interface Address Group Mode Timer Srcs V Uptime %s", VTY_NEWLINE);
|
||||||
|
|
||||||
/* scan interfaces */
|
/* scan interfaces */
|
||||||
for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) {
|
for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), ifnode, ifp)) {
|
||||||
@ -1814,20 +1821,45 @@ static void igmp_show_groups(struct vty *vty)
|
|||||||
pim_time_timer_to_hhmmss(hhmmss, sizeof(hhmmss), grp->t_group_timer);
|
pim_time_timer_to_hhmmss(hhmmss, sizeof(hhmmss), grp->t_group_timer);
|
||||||
pim_time_uptime(uptime, sizeof(uptime), now - grp->group_creation);
|
pim_time_uptime(uptime, sizeof(uptime), now - grp->group_creation);
|
||||||
|
|
||||||
vty_out(vty, "%-9s %-15s %-15s %4s %8s %4d %d %8s%s",
|
if (uj) {
|
||||||
ifp->name,
|
json_object_object_get_ex(json, ifp->name, &json_iface);
|
||||||
ifaddr_str,
|
|
||||||
group_str,
|
|
||||||
grp->group_filtermode_isexcl ? "EXCL" : "INCL",
|
|
||||||
hhmmss,
|
|
||||||
grp->group_source_list ? listcount(grp->group_source_list) : 0,
|
|
||||||
igmp_group_compat_mode(igmp, grp),
|
|
||||||
uptime,
|
|
||||||
VTY_NEWLINE);
|
|
||||||
|
|
||||||
|
if (!json_iface) {
|
||||||
|
json_iface = json_object_new_object();
|
||||||
|
json_object_pim_ifp_add(json_iface, ifp);
|
||||||
|
json_object_object_add(json, ifp->name, json_iface);
|
||||||
|
}
|
||||||
|
|
||||||
|
json_row = json_object_new_object();
|
||||||
|
json_object_string_add(json_row, "source", ifaddr_str);
|
||||||
|
json_object_string_add(json_row, "group", group_str);
|
||||||
|
json_object_string_add(json_row, "mode", grp->group_filtermode_isexcl ? "EXCLUDE" : "INCLUDE");
|
||||||
|
json_object_string_add(json_row, "timer", hhmmss);
|
||||||
|
json_object_int_add(json_row, "sourcesCount", grp->group_source_list ? listcount(grp->group_source_list) : 0);
|
||||||
|
json_object_int_add(json_row, "version", igmp_group_compat_mode(igmp, grp));
|
||||||
|
json_object_string_add(json_row, "uptime", uptime);
|
||||||
|
json_object_object_add(json_iface, group_str, json_row);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
vty_out(vty, "%-9s %-15s %-15s %4s %8s %4d %d %8s%s",
|
||||||
|
ifp->name,
|
||||||
|
ifaddr_str,
|
||||||
|
group_str,
|
||||||
|
grp->group_filtermode_isexcl ? "EXCL" : "INCL",
|
||||||
|
hhmmss,
|
||||||
|
grp->group_source_list ? listcount(grp->group_source_list) : 0,
|
||||||
|
igmp_group_compat_mode(igmp, grp),
|
||||||
|
uptime,
|
||||||
|
VTY_NEWLINE);
|
||||||
|
}
|
||||||
} /* scan igmp groups */
|
} /* scan igmp groups */
|
||||||
} /* scan igmp sockets */
|
} /* scan igmp sockets */
|
||||||
} /* scan interfaces */
|
} /* scan interfaces */
|
||||||
|
|
||||||
|
if (uj) {
|
||||||
|
vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
|
||||||
|
json_object_free(json);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void igmp_show_group_retransmission(struct vty *vty)
|
static void igmp_show_group_retransmission(struct vty *vty)
|
||||||
@ -2178,11 +2210,12 @@ DEFUN (clear_ip_pim_oil,
|
|||||||
|
|
||||||
DEFUN (show_ip_igmp_interface,
|
DEFUN (show_ip_igmp_interface,
|
||||||
show_ip_igmp_interface_cmd,
|
show_ip_igmp_interface_cmd,
|
||||||
"show ip igmp interface [WORD] [json]",
|
"show ip igmp interface [detail|WORD] [json]",
|
||||||
SHOW_STR
|
SHOW_STR
|
||||||
IP_STR
|
IP_STR
|
||||||
IGMP_STR
|
IGMP_STR
|
||||||
"IGMP interface information\n"
|
"IGMP interface information\n"
|
||||||
|
"Detailed output\n"
|
||||||
"interface name\n"
|
"interface name\n"
|
||||||
"JavaScript Object Notation\n")
|
"JavaScript Object Notation\n")
|
||||||
{
|
{
|
||||||
@ -2210,13 +2243,15 @@ DEFUN (show_ip_igmp_join,
|
|||||||
|
|
||||||
DEFUN (show_ip_igmp_groups,
|
DEFUN (show_ip_igmp_groups,
|
||||||
show_ip_igmp_groups_cmd,
|
show_ip_igmp_groups_cmd,
|
||||||
"show ip igmp groups",
|
"show ip igmp groups [json]",
|
||||||
SHOW_STR
|
SHOW_STR
|
||||||
IP_STR
|
IP_STR
|
||||||
IGMP_STR
|
IGMP_STR
|
||||||
IGMP_GROUP_STR)
|
IGMP_GROUP_STR
|
||||||
|
"JavaScript Object Notation\n")
|
||||||
{
|
{
|
||||||
igmp_show_groups(vty);
|
u_char uj = use_json(argc, argv);
|
||||||
|
igmp_show_groups(vty, uj);
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -2344,11 +2379,12 @@ DEFUN (show_ip_pim_hello,
|
|||||||
|
|
||||||
DEFUN (show_ip_pim_interface,
|
DEFUN (show_ip_pim_interface,
|
||||||
show_ip_pim_interface_cmd,
|
show_ip_pim_interface_cmd,
|
||||||
"show ip pim interface [WORD] [json]",
|
"show ip pim interface [detail|WORD] [json]",
|
||||||
SHOW_STR
|
SHOW_STR
|
||||||
IP_STR
|
IP_STR
|
||||||
PIM_STR
|
PIM_STR
|
||||||
"PIM interface information\n"
|
"PIM interface information\n"
|
||||||
|
"Detailed output\n"
|
||||||
"interface name\n"
|
"interface name\n"
|
||||||
"JavaScript Object Notation\n")
|
"JavaScript Object Notation\n")
|
||||||
{
|
{
|
||||||
@ -2391,11 +2427,12 @@ DEFUN (show_ip_pim_local_membership,
|
|||||||
|
|
||||||
DEFUN (show_ip_pim_neighbor,
|
DEFUN (show_ip_pim_neighbor,
|
||||||
show_ip_pim_neighbor_cmd,
|
show_ip_pim_neighbor_cmd,
|
||||||
"show ip pim neighbor [WORD] [json]",
|
"show ip pim neighbor [detail|WORD] [json]",
|
||||||
SHOW_STR
|
SHOW_STR
|
||||||
IP_STR
|
IP_STR
|
||||||
PIM_STR
|
PIM_STR
|
||||||
"PIM neighbor information\n"
|
"PIM neighbor information\n"
|
||||||
|
"Detailed output\n"
|
||||||
"Name of interface or neighbor\n"
|
"Name of interface or neighbor\n"
|
||||||
"JavaScript Object Notation\n")
|
"JavaScript Object Notation\n")
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user