summaryrefslogtreecommitdiff
path: root/pimd/pim_cmd_common.c
diff options
context:
space:
mode:
authorAbhishek N R <abnr@vmware.com>2022-09-16 10:11:09 -0700
committerAbhishek N R <abnr@vmware.com>2022-09-19 02:11:13 -0700
commitc3cd01eb06b50986448c6ae4322c7f09cb5d82e4 (patch)
tree08b0897cf348d87b289b4912b9719178ccce0c1f /pimd/pim_cmd_common.c
parentbae90f95d1f21ad3b8cfdf01ccda5ff772444e0d (diff)
pimd, pim6d: Using ttable for displaying "show ip/ipv6 pim neighbor" command output.
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>
Diffstat (limited to 'pimd/pim_cmd_common.c')
-rw-r--r--pimd/pim_cmd_common.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c
index 0ddce42004..4798f3b3ef 100644
--- a/pimd/pim_cmd_common.c
+++ b/pimd/pim_cmd_common.c
@@ -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,