]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pimd, pim6d: Using ttable for displaying "show ip/ipv6 multicast count" command.
authorAbhishek N R <abnr@vmware.com>
Wed, 10 Aug 2022 09:04:04 +0000 (02:04 -0700)
committerAbhishek N R <abnr@vmware.com>
Wed, 10 Aug 2022 09:09:00 +0000 (02:09 -0700)
Signed-off-by: Abhishek N R <abnr@vmware.com>
pimd/pim_cmd_common.c

index 45726b4e569feb5b9a1ef1a237e4da73488d505f..2eeecb5a28f975a068646cb8f7a3cca875a7b3c8 100644 (file)
@@ -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)