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

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

View File

@ -974,9 +974,15 @@ void pim_show_rpf(struct pim_instance *pim, struct vty *vty, json_object *json)
void pim_show_neighbors_secondary(struct pim_instance *pim, struct vty *vty) void pim_show_neighbors_secondary(struct pim_instance *pim, struct vty *vty)
{ {
struct interface *ifp; struct interface *ifp;
struct ttable *tt = NULL;
char *table = NULL;
vty_out(vty, /* Prepare table. */
"Interface Address Neighbor Secondary \n"); tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
ttable_add_row(tt, "Interface|Address|Neighbor|Secondary");
tt->style.cell.rpad = 2;
tt->style.corner = '+';
ttable_restyle(tt);
FOR_ALL_INTERFACES (pim->vrf, ifp) { FOR_ALL_INTERFACES (pim->vrf, ifp) {
struct pim_interface *pim_ifp; struct pim_interface *pim_ifp;
@ -1004,12 +1010,16 @@ void pim_show_neighbors_secondary(struct pim_instance *pim, struct vty *vty)
for (ALL_LIST_ELEMENTS_RO(neigh->prefix_list, for (ALL_LIST_ELEMENTS_RO(neigh->prefix_list,
prefix_node, p)) prefix_node, p))
vty_out(vty, ttable_add_row(tt, "%s|%pPAs|%pPAs|%pFX",
"%-16s %-15pPAs %-15pPAs %-15pFX\n", ifp->name, &ifaddr,
ifp->name, &ifaddr, &neigh->source_addr, &neigh->source_addr, p);
p);
} }
} }
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
ttable_del(tt);
} }
void pim_show_state(struct pim_instance *pim, struct vty *vty, void pim_show_state(struct pim_instance *pim, struct vty *vty,