pimd, pim6d: Using ttable for displaying "show ip/ipv6 pim upstream" command output.

Signed-off-by: Abhishek N R <abnr@vmware.com>
This commit is contained in:
Abhishek N R 2022-08-11 04:38:02 -07:00
parent 0148e53f3b
commit a8f7d5de6b

View File

@ -1343,15 +1343,24 @@ void pim_show_upstream(struct pim_instance *pim, struct vty *vty,
pim_sgaddr *sg, json_object *json)
{
struct pim_upstream *up;
struct ttable *tt = NULL;
char *table = NULL;
time_t now;
json_object *json_group = NULL;
json_object *json_row = NULL;
now = pim_time_monotonic_sec();
if (!json)
vty_out(vty,
"Iif Source Group State Uptime JoinTimer RSTimer KATimer RefCnt\n");
if (!json) {
/* Prepare table. */
tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
ttable_add_row(
tt,
"Iif|Source|Group|State|Uptime|JoinTimer|RSTimer|KATimer|RefCnt");
tt->style.cell.rpad = 2;
tt->style.corner = '+';
ttable_restyle(tt);
}
frr_each (rb_pim_upstream, &pim->upstream_head, up) {
char uptime[10];
@ -1472,8 +1481,8 @@ void pim_show_upstream(struct pim_instance *pim, struct vty *vty,
json_object_int_add(json_row, "sptBit", up->sptbit);
json_object_object_add(json_group, src_str, json_row);
} else {
vty_out(vty,
"%-16s%-15pPAs %-15pPAs %-11s %-8s %-9s %-9s %-9s %6d\n",
ttable_add_row(tt,
"%s|%pPAs|%pPAs|%s|%s|%s|%s|%s|%d",
up->rpf.source_nexthop.interface
? up->rpf.source_nexthop.interface->name
: "Unknown",
@ -1481,6 +1490,13 @@ void pim_show_upstream(struct pim_instance *pim, struct vty *vty,
join_timer, rs_timer, ka_timer, up->ref_count);
}
}
/* Dump the generated table. */
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
ttable_del(tt);
}
}
static void pim_show_join_desired_helper(struct pim_instance *pim,