Skip to content

Commit

Permalink
pimd: Modified rp-info & igmp groups json o/p
Browse files Browse the repository at this point in the history
Fix 1: Added group as array in the o/p "show ip igmp groups json"
Before:
"225.1.1.1":{
      "source":"20.0.0.1",
      "group":"225.1.1.1",
      "timer":"00:04:11",
      "sourcesCount":1,
      "version":2,
      "uptime":"00:00:15"
    },
After:
"groups":[
      {
        "source":"20.0.0.1",
        "group":"225.1.1.2",
        "timer":"00:03:50",
        "sourcesCount":1,
        "version":2,
        "uptime":"00:00:29"
      },

Fix 2: Added a new field "rp_address" in "show ip igmp groups json"
Before:
"40.0.0.2":[
    {
      "outboundInterface":"ens224",
      "group":"224.0.0.0\/4",
      "source":"Static"
    }
After:
"40.0.0.2":[
    {
      "rp_address":"40.0.0.2",
      "outboundInterface":"ens224",
      "group":"224.0.0.0\/4",
      "source":"Static"
    }

Signed-off-by: Sarita Patra <saritap@vmware.com>
  • Loading branch information
patrasar committed Mar 18, 2020
1 parent 09c04bc commit 73338f1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
42 changes: 22 additions & 20 deletions pimd/pim_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3411,13 +3411,15 @@ static void igmp_show_groups(struct pim_instance *pim, struct vty *vty, bool uj)
time_t now;
json_object *json = NULL;
json_object *json_iface = NULL;
json_object *json_row = NULL;
json_object *json_group = NULL;
json_object *json_groups = NULL;

now = pim_time_monotonic_sec();

if (uj)
if (uj) {
json = json_object_new_object();
else
json_groups = json_object_new_array();
} else
vty_out(vty,
"Interface Address Group Mode Timer Srcs V Uptime \n");

Expand Down Expand Up @@ -3468,35 +3470,34 @@ static void igmp_show_groups(struct pim_instance *pim, struct vty *vty, bool uj)
json_iface);
}

json_row = json_object_new_object();
json_object_string_add(
json_row, "source", ifaddr_str);
json_group = json_object_new_object();
json_object_string_add(json_group,
"source",
ifaddr_str);
json_object_string_add(
json_row, "group", group_str);
json_group, "group", group_str);

if (grp->igmp_version == 3)
json_object_string_add(
json_row, "mode",
json_group, "mode",
grp->group_filtermode_isexcl
? "EXCLUDE"
: "INCLUDE");

json_object_string_add(json_row,
json_object_string_add(json_group,
"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",
json_group, "sourcesCount",
grp->group_source_list ? listcount(
grp->group_source_list)
: 0);
json_object_int_add(json_group,
"version",
grp->igmp_version);
json_object_string_add(
json_row, "uptime", uptime);
json_object_object_add(json_iface,
group_str,
json_row);

json_group, "uptime", uptime);
json_object_array_add(json_groups,
json_group);
} else {
vty_out(vty,
"%-16s %-15s %-15s %4s %8s %4d %d %8s\n",
Expand All @@ -3519,6 +3520,7 @@ static void igmp_show_groups(struct pim_instance *pim, struct vty *vty, bool uj)
} /* scan interfaces */

if (uj) {
json_object_object_add(json_iface, "groups", json_groups);
vty_out(vty, "%s\n", json_object_to_json_string_ext(
json, JSON_C_TO_STRING_PRETTY));
json_object_free(json);
Expand Down
5 changes: 5 additions & 0 deletions pimd/pim_rp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,11 @@ void pim_rp_show_information(struct pim_instance *pim, struct vty *vty, bool uj)
json_rp_rows = json_object_new_array();

json_row = json_object_new_object();
json_object_string_add(
json_object_string_add(
json_row, "rp_address",
inet_ntoa(rp_info->rp.rpf_addr.u
.prefix4));
if (rp_info->rp.source_nexthop.interface)
json_object_string_add(
json_row, "outboundInterface",
Expand Down

0 comments on commit 73338f1

Please sign in to comment.