From 090f8339751e850ac286e00ed7082872165daf08 Mon Sep 17 00:00:00 2001 From: Abhishek N R Date: Thu, 11 Aug 2022 04:47:12 -0700 Subject: [PATCH] pimd, pim6d: Using ttable for displaying "show ip/ipv6 pim upstream-join-desired" command output. Signed-off-by: Abhishek N R --- pimd/pim_cmd_common.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c index 258c5e1b53..fd9966fc40 100644 --- a/pimd/pim_cmd_common.c +++ b/pimd/pim_cmd_common.c @@ -1502,7 +1502,8 @@ void pim_show_upstream(struct pim_instance *pim, struct vty *vty, static void pim_show_join_desired_helper(struct pim_instance *pim, struct vty *vty, struct pim_upstream *up, - json_object *json, bool uj) + json_object *json, bool uj, + struct ttable *tt) { json_object *json_group = NULL; json_object *json_row = NULL; @@ -1533,31 +1534,46 @@ static void pim_show_join_desired_helper(struct pim_instance *pim, json_object_object_add(json_group, src_str, json_row); } else { - vty_out(vty, "%-15pPAs %-15pPAs %-6s\n", &up->sg.src, - &up->sg.grp, - pim_upstream_evaluate_join_desired(pim, up) ? "yes" - : "no"); + ttable_add_row(tt, "%pPAs|%pPAs|%s", &up->sg.src, &up->sg.grp, + pim_upstream_evaluate_join_desired(pim, up) + ? "yes" + : "no"); } } void pim_show_join_desired(struct pim_instance *pim, struct vty *vty, bool uj) { struct pim_upstream *up; + struct ttable *tt = NULL; + char *table = NULL; json_object *json = NULL; if (uj) json = json_object_new_object(); - else - vty_out(vty, "Source Group EvalJD\n"); + else { + /* Prepare table. */ + tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]); + ttable_add_row(tt, "Source|Group|EvalJD"); + tt->style.cell.rpad = 2; + tt->style.corner = '+'; + ttable_restyle(tt); + } frr_each (rb_pim_upstream, &pim->upstream_head, up) { /* scan all interfaces */ - pim_show_join_desired_helper(pim, vty, up, json, uj); + pim_show_join_desired_helper(pim, vty, up, json, uj, tt); } if (uj) vty_json(vty, json); + else { + /* 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_upstream_rpf(struct pim_instance *pim, struct vty *vty, bool uj) -- 2.39.5