]> git.proxmox.com Git - mirror_frr.git/commitdiff
pimd, pim6d: Using ttable for displaying "show ip/ipv6 pim rpf" command output.
authorAbhishek N R <abnr@vmware.com>
Thu, 11 Aug 2022 11:10:00 +0000 (04:10 -0700)
committerAbhishek N R <abnr@vmware.com>
Sun, 14 Aug 2022 15:29:11 +0000 (08:29 -0700)
Signed-off-by: Abhishek N R <abnr@vmware.com>
pimd/pim_cmd_common.c

index 1d3f5f430a7a1fd45a5ee4651e63b25886e7672e..f4c92e8f965845df1a68c878379a3b677886cba5 100644 (file)
@@ -888,6 +888,8 @@ void pim_show_rpf(struct pim_instance *pim, struct vty *vty, json_object *json)
 {
        struct pim_upstream *up;
        time_t now = pim_time_monotonic_sec();
+       struct ttable *tt = NULL;
+       char *table = NULL;
        json_object *json_group = NULL;
        json_object *json_row = NULL;
 
@@ -895,8 +897,15 @@ void pim_show_rpf(struct pim_instance *pim, struct vty *vty, json_object *json)
 
        if (!json) {
                vty_out(vty, "\n");
-               vty_out(vty,
-                       "Source          Group           RpfIface         RpfAddress      RibNextHop      Metric Pref\n");
+
+               /* Prepare table. */
+               tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
+               ttable_add_row(
+                       tt,
+                       "Source|Group|RpfIface|RpfAddress|RibNextHop|Metric|Pref");
+               tt->style.cell.rpad = 2;
+               tt->style.corner = '+';
+               ttable_restyle(tt);
        }
 
        frr_each (rb_pim_upstream, &pim->upstream_head, up) {
@@ -944,8 +953,8 @@ void pim_show_rpf(struct pim_instance *pim, struct vty *vty, json_object *json)
                        json_object_object_add(json_group, src_str, json_row);
 
                } else {
-                       vty_out(vty,
-                               "%-15pPAs %-15pPAs %-16s %-15pPA %-15pPAs %6d %4d\n",
+                       ttable_add_row(
+                               tt, "%pPAs|%pPAs|%s|%pPA|%pPAs|%d|%d",
                                &up->sg.src, &up->sg.grp, rpf_ifname,
                                &rpf->rpf_addr,
                                &rpf->source_nexthop.mrib_nexthop_addr,
@@ -953,6 +962,13 @@ void pim_show_rpf(struct pim_instance *pim, struct vty *vty, json_object *json)
                                rpf->source_nexthop.mrib_metric_preference);
                }
        }
+       /* 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_show_neighbors_secondary(struct pim_instance *pim, struct vty *vty)