summaryrefslogtreecommitdiff
path: root/pimd/pim_cmd_common.c
diff options
context:
space:
mode:
authorAbhishek N R <abnr@vmware.com>2022-08-10 02:04:04 -0700
committerAbhishek N R <abnr@vmware.com>2022-08-10 02:09:00 -0700
commit7f0dc57f8ef8691f556bb9d43186d450bef2824f (patch)
treedfd9d3228b55e9755d00fc3aab2298b73c4cfd16 /pimd/pim_cmd_common.c
parentac2f410c379a8cef0abade46a2d2ef351b8f38a7 (diff)
pimd, pim6d: Using ttable for displaying "show ip/ipv6 multicast count" command.
Signed-off-by: Abhishek N R <abnr@vmware.com>
Diffstat (limited to 'pimd/pim_cmd_common.c')
-rw-r--r--pimd/pim_cmd_common.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c
index 45726b4e56..2eeecb5a28 100644
--- a/pimd/pim_cmd_common.c
+++ b/pimd/pim_cmd_common.c
@@ -3285,13 +3285,22 @@ void show_multicast_interfaces(struct pim_instance *pim, struct vty *vty,
json_object *json)
{
struct interface *ifp;
+ struct ttable *tt = NULL;
+ char *table = NULL;
json_object *json_row = NULL;
vty_out(vty, "\n");
- if (!json)
- vty_out(vty,
- "Interface Address ifi Vif PktsIn PktsOut BytesIn BytesOut\n");
+ if (!json) {
+ /* Prepare table. */
+ tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
+ ttable_add_row(
+ tt,
+ "Interface|Address|ifi|Vif|PktsIn|PktsOut|BytesIn|BytesOut");
+ tt->style.cell.rpad = 2;
+ tt->style.corner = '+';
+ ttable_restyle(tt);
+ }
FOR_ALL_INTERFACES (pim->vrf, ifp) {
struct pim_interface *pim_ifp;
@@ -3347,16 +3356,22 @@ void show_multicast_interfaces(struct pim_instance *pim, struct vty *vty,
(unsigned long)vreq.obytes);
json_object_object_add(json, ifp->name, json_row);
} else {
- vty_out(vty,
- "%-16s %-15pPAs %3d %3d %7lu %7lu %10lu %10lu\n",
- ifp->name, &pim_ifp->primary_address,
- ifp->ifindex, pim_ifp->mroute_vif_index,
- (unsigned long)vreq.icount,
- (unsigned long)vreq.ocount,
- (unsigned long)vreq.ibytes,
- (unsigned long)vreq.obytes);
+ ttable_add_row(tt, "%s|%pPAs|%d|%d|%lu|%lu|%lu|%lu",
+ ifp->name, &pim_ifp->primary_address,
+ ifp->ifindex, pim_ifp->mroute_vif_index,
+ (unsigned long)vreq.icount,
+ (unsigned long)vreq.ocount,
+ (unsigned long)vreq.ibytes,
+ (unsigned long)vreq.obytes);
}
}
+ /* 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 pim_cmd_show_ip_multicast_helper(struct pim_instance *pim, struct vty *vty)