summaryrefslogtreecommitdiff
path: root/pimd/pim_cmd_common.c
diff options
context:
space:
mode:
authorAbhishek N R <abnr@vmware.com>2022-08-11 01:01:51 -0700
committerAbhishek N R <abnr@vmware.com>2022-08-11 04:03:11 -0700
commit88e9f3a00909b9dcf90c5543d88006c51a426938 (patch)
tree9ad2ad526055ba69e3735670763c01922f4d93bd /pimd/pim_cmd_common.c
parent68575e1605c40292caf2c46ba7d864d534014898 (diff)
pimd, pim6d: Using ttable for displaying "show ip/ipv6 mroute count" command output.
Signed-off-by: Abhishek N R <abnr@vmware.com>
Diffstat (limited to 'pimd/pim_cmd_common.c')
-rw-r--r--pimd/pim_cmd_common.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c
index 2eeecb5a28..63751ac9d4 100644
--- a/pimd/pim_cmd_common.c
+++ b/pimd/pim_cmd_common.c
@@ -3805,7 +3805,8 @@ void show_mroute(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
static void show_mroute_count_per_channel_oil(struct channel_oil *c_oil,
json_object *json,
- struct vty *vty)
+ struct vty *vty,
+ struct ttable *tt)
{
json_object *json_group = NULL;
json_object *json_source = NULL;
@@ -3840,12 +3841,12 @@ static void show_mroute_count_per_channel_oil(struct channel_oil *c_oil,
json_object_int_add(json_source, "wrongIf", c_oil->cc.wrong_if);
} else {
- vty_out(vty, "%-15pPAs %-15pPAs %-8llu %-7ld %-10ld %-7ld\n",
- oil_origin(c_oil), oil_mcastgrp(c_oil),
- c_oil->cc.lastused / 100,
- c_oil->cc.pktcnt - c_oil->cc.origpktcnt,
- c_oil->cc.bytecnt - c_oil->cc.origbytecnt,
- c_oil->cc.wrong_if - c_oil->cc.origwrong_if);
+ ttable_add_row(tt, "%pPAs|%pPAs|%llu|%ld|%ld|%ld",
+ oil_origin(c_oil), oil_mcastgrp(c_oil),
+ c_oil->cc.lastused / 100,
+ c_oil->cc.pktcnt - c_oil->cc.origpktcnt,
+ c_oil->cc.bytecnt - c_oil->cc.origbytecnt,
+ c_oil->cc.wrong_if - c_oil->cc.origwrong_if);
}
}
@@ -3855,20 +3856,35 @@ void show_mroute_count(struct pim_instance *pim, struct vty *vty,
struct listnode *node;
struct channel_oil *c_oil;
struct static_route *sr;
+ struct ttable *tt = NULL;
+ char *table = NULL;
if (!json) {
vty_out(vty, "\n");
- vty_out(vty,
- "Source Group LastUsed Packets Bytes WrongIf \n");
+ /* Prepare table. */
+ tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
+ ttable_add_row(tt,
+ "Source|Group|LastUsed|Packets|Bytes|WrongIf");
+ tt->style.cell.rpad = 2;
+ tt->style.corner = '+';
+ ttable_restyle(tt);
}
/* Print PIM and IGMP route counts */
frr_each (rb_pim_oil, &pim->channel_oil_head, c_oil)
- show_mroute_count_per_channel_oil(c_oil, json, vty);
+ show_mroute_count_per_channel_oil(c_oil, json, vty, tt);
for (ALL_LIST_ELEMENTS_RO(pim->static_routes, node, sr))
- show_mroute_count_per_channel_oil(&sr->c_oil, json, vty);
+ show_mroute_count_per_channel_oil(&sr->c_oil, json, vty, tt);
+
+ /* Dump the generated table. */
+ if (!json) {
+ table = ttable_dump(tt, "\n");
+ vty_out(vty, "%s\n", table);
+ XFREE(MTYPE_TMP, table);
+ ttable_del(tt);
+ }
}
void show_mroute_summary(struct pim_instance *pim, struct vty *vty,