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) pim_sgaddr *sg, json_object *json)
{ {
struct pim_upstream *up; struct pim_upstream *up;
struct ttable *tt = NULL;
char *table = NULL;
time_t now; time_t now;
json_object *json_group = NULL; json_object *json_group = NULL;
json_object *json_row = NULL; json_object *json_row = NULL;
now = pim_time_monotonic_sec(); now = pim_time_monotonic_sec();
if (!json) if (!json) {
vty_out(vty, /* Prepare table. */
"Iif Source Group State Uptime JoinTimer RSTimer KATimer RefCnt\n"); 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) { frr_each (rb_pim_upstream, &pim->upstream_head, up) {
char uptime[10]; 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_int_add(json_row, "sptBit", up->sptbit);
json_object_object_add(json_group, src_str, json_row); json_object_object_add(json_group, src_str, json_row);
} else { } else {
vty_out(vty, ttable_add_row(tt,
"%-16s%-15pPAs %-15pPAs %-11s %-8s %-9s %-9s %-9s %6d\n", "%s|%pPAs|%pPAs|%s|%s|%s|%s|%s|%d",
up->rpf.source_nexthop.interface up->rpf.source_nexthop.interface
? up->rpf.source_nexthop.interface->name ? up->rpf.source_nexthop.interface->name
: "Unknown", : "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); 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, static void pim_show_join_desired_helper(struct pim_instance *pim,