]> git.proxmox.com Git - mirror_frr.git/commitdiff
pimd, pim6d: Using ttable for displaying "show ip/ipv6 pim neighbor" command output.
authorAbhishek N R <abnr@vmware.com>
Fri, 16 Sep 2022 17:11:09 +0000 (10:11 -0700)
committerAbhishek N R <abnr@vmware.com>
Mon, 19 Sep 2022 09:11:13 +0000 (02:11 -0700)
Before:

frr# show ipv6 pim neighbor
Interface                Neighbor    Uptime  Holdtime  DR Pri
ens192            fe80::250:56ff:feb7:38de  00:10:47  00:01:28       1
ens224            fe80::250:56ff:feb7:4bad  00:10:47  00:01:28       1

After:

frr# sh ipv6 pim neighbor
 Interface  Neighbor                  Uptime    Holdtime  DR Pri
 ens192     fe80::250:56ff:feb7:38de  00:00:12  00:01:32  1
 ens224     fe80::250:56ff:feb7:4bad  00:00:12  00:01:32  1

Signed-off-by: Abhishek N R <abnr@vmware.com>
pimd/pim_cmd_common.c

index 0ddce4200481648de42109f65e4a830565343cde..4798f3b3ef76540ac6581fafea98d4d03c5c7ad3 100644 (file)
@@ -3195,6 +3195,8 @@ void pim_show_neighbors(struct pim_instance *pim, struct vty *vty,
        struct interface *ifp;
        struct pim_interface *pim_ifp;
        struct pim_neighbor *neigh;
+       struct ttable *tt = NULL;
+       char *table = NULL;
        time_t now;
        char uptime[10];
        char expire[10];
@@ -3205,8 +3207,12 @@ void pim_show_neighbors(struct pim_instance *pim, struct vty *vty,
        now = pim_time_monotonic_sec();
 
        if (!json) {
-               vty_out(vty,
-                       "Interface                Neighbor    Uptime  Holdtime  DR Pri\n");
+               /* Prepare table. */
+               tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
+               ttable_add_row(tt, "Interface|Neighbor|Uptime|Holdtime|DR Pri");
+               tt->style.cell.rpad = 2;
+               tt->style.corner = '+';
+               ttable_restyle(tt);
        }
 
        FOR_ALL_INTERFACES (pim->vrf, ifp) {
@@ -3248,9 +3254,10 @@ void pim_show_neighbors(struct pim_instance *pim, struct vty *vty,
                                                       neigh_src_str, json_row);
 
                        } else {
-                               vty_out(vty, "%-16s  %15s  %8s  %8s  %6d\n",
-                                       ifp->name, neigh_src_str, uptime,
-                                       expire, neigh->dr_priority);
+                               ttable_add_row(tt, "%s|%pPAs|%s|%s|%d",
+                                              ifp->name, &neigh->source_addr,
+                                              uptime, expire,
+                                              neigh->dr_priority);
                        }
                }
 
@@ -3259,6 +3266,13 @@ void pim_show_neighbors(struct pim_instance *pim, struct vty *vty,
                        json_ifp_rows = NULL;
                }
        }
+       /* Dump the generated table. */
+       if (!json) {
+               table = ttable_dump(tt, "\n");
+               vty_out(vty, "%s\n", table);
+               XFREE(MTYPE_TMP, table);
+               ttable_del(tt);
+       }
 }
 
 int gm_process_query_max_response_time_cmd(struct vty *vty,