summaryrefslogtreecommitdiff
path: root/pimd/pim_cmd_common.c
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2022-11-30 21:40:30 +0200
committerGitHub <noreply@github.com>2022-11-30 21:40:30 +0200
commita677c44802499f2d8a4a5b34022025c963bf2a5e (patch)
treee809887da72c266f947beed20ed71e5576c60a9e /pimd/pim_cmd_common.c
parent14a67912569c288b619234440d55cec467deeb0a (diff)
parent86fb444df60ecef0f3b5671f5a013325b71c426f (diff)
Merge pull request #12325 from AbhishekNR/ttable_pim_nexthop
pimd, pim6d: Using ttable for displaying "show ip/ipv6 pim nexthop" command output
Diffstat (limited to 'pimd/pim_cmd_common.c')
-rw-r--r--pimd/pim_cmd_common.c79
1 files changed, 62 insertions, 17 deletions
diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c
index 0d60b17f04..28e4c488f3 100644
--- a/pimd/pim_cmd_common.c
+++ b/pimd/pim_cmd_common.c
@@ -2824,21 +2824,35 @@ static int pim_print_vty_pnc_cache_walkcb(struct hash_bucket *bucket, void *arg)
struct nexthop *nh_node = NULL;
ifindex_t first_ifindex;
struct interface *ifp = NULL;
+ struct ttable *tt = NULL;
+ char *table = NULL;
+
+ /* Prepare table. */
+ tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
+ ttable_add_row(tt, "Address|Interface|Nexthop");
+ tt->style.cell.rpad = 2;
+ tt->style.corner = '+';
+ ttable_restyle(tt);
for (nh_node = pnc->nexthop; nh_node; nh_node = nh_node->next) {
first_ifindex = nh_node->ifindex;
ifp = if_lookup_by_index(first_ifindex, pim->vrf->vrf_id);
- vty_out(vty, "%-15pPA ", &pnc->rpf.rpf_addr);
- vty_out(vty, "%-16s ", ifp ? ifp->name : "NULL");
#if PIM_IPV == 4
- vty_out(vty, "%pI4 ", &nh_node->gate.ipv4);
+ ttable_add_row(tt, "%pPA|%s|%pI4", &pnc->rpf.rpf_addr,
+ ifp ? ifp->name : "NULL", &nh_node->gate.ipv4);
#else
- vty_out(vty, "%pI6 ", &nh_node->gate.ipv6);
+ ttable_add_row(tt, "%pPA|%s|%pI6", &pnc->rpf.rpf_addr,
+ ifp ? ifp->name : "NULL", &nh_node->gate.ipv6);
#endif
- vty_out(vty, "\n");
}
+ /* Dump the generated table. */
+ table = ttable_dump(tt, "\n");
+ vty_out(vty, "%s\n", table);
+ XFREE(MTYPE_TMP, table);
+ ttable_del(tt);
+
return CMD_SUCCESS;
}
@@ -2966,8 +2980,6 @@ void pim_show_nexthop(struct pim_instance *pim, struct vty *vty, bool uj)
} else {
vty_out(vty, "Number of registered addresses: %lu\n",
pim->rpf_hash->count);
- vty_out(vty, "Address Interface Nexthop\n");
- vty_out(vty, "---------------------------------------------\n");
}
if (uj) {
@@ -5355,6 +5367,7 @@ static void pim_show_group_rp_mappings_info(struct pim_instance *pim,
json_object *json = NULL;
json_object *json_group = NULL;
json_object *json_row = NULL;
+ struct ttable *tt = NULL;
if (uj) {
json = json_object_new_object();
@@ -5385,10 +5398,15 @@ static void pim_show_group_rp_mappings_info(struct pim_instance *pim,
} else {
vty_out(vty, "Group Address %pFX\n", &bsgrp->group);
vty_out(vty, "--------------------------\n");
- vty_out(vty, "%-15s %-15s %-15s %-15s\n", "Rp Address",
- "priority", "Holdtime", "Hash");
-
- vty_out(vty, "(ACTIVE)\n");
+ /* Prepare table. */
+ tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
+ ttable_add_row(tt, "Rp Address|priority|Holdtime|Hash");
+ tt->style.cell.rpad = 2;
+ tt->style.corner = '+';
+ ttable_restyle(tt);
+
+ ttable_add_row(tt, "%s|%c|%c|%c", "(ACTIVE)", ' ', ' ',
+ ' ');
}
frr_each (bsm_rpinfos, bsgrp->bsrp_list, bsm_rp) {
@@ -5408,11 +5426,22 @@ static void pim_show_group_rp_mappings_info(struct pim_instance *pim,
&bsm_rp->rp_address);
} else {
- vty_out(vty, "%-15pPA %-15u %-15u %-15u\n",
+ ttable_add_row(
+ tt, "%pPA|%u|%u|%u",
&bsm_rp->rp_address, bsm_rp->rp_prio,
bsm_rp->rp_holdtime, bsm_rp->hash);
}
}
+ /* Dump the generated table. */
+ if (tt) {
+ char *table = NULL;
+
+ table = ttable_dump(tt, "\n");
+ vty_out(vty, "%s\n", table);
+ XFREE(MTYPE_TMP, table);
+ ttable_del(tt);
+ tt = NULL;
+ }
if (!bsm_rpinfos_count(bsgrp->bsrp_list) && !uj)
vty_out(vty, "Active List is empty.\n");
@@ -5423,10 +5452,16 @@ static void pim_show_group_rp_mappings_info(struct pim_instance *pim,
vty_out(vty, "(PENDING)\n");
vty_out(vty, "Pending RP count :%d\n",
bsgrp->pend_rp_cnt);
- if (bsgrp->pend_rp_cnt)
- vty_out(vty, "%-15s %-15s %-15s %-15s\n",
- "Rp Address", "priority", "Holdtime",
- "Hash");
+ if (bsgrp->pend_rp_cnt) {
+ /* Prepare table. */
+ tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
+ ttable_add_row(
+ tt,
+ "Rp Address|priority|Holdtime|Hash");
+ tt->style.cell.rpad = 2;
+ tt->style.corner = '+';
+ ttable_restyle(tt);
+ }
}
frr_each (bsm_rpinfos, bsgrp->partial_bsrp_list, bsm_rp) {
@@ -5445,11 +5480,21 @@ static void pim_show_group_rp_mappings_info(struct pim_instance *pim,
"%pPA",
&bsm_rp->rp_address);
} else {
- vty_out(vty, "%-15pPA %-15u %-15u %-15u\n",
+ ttable_add_row(
+ tt, "%pPA|%u|%u|%u",
&bsm_rp->rp_address, bsm_rp->rp_prio,
bsm_rp->rp_holdtime, bsm_rp->hash);
}
}
+ /* Dump the generated table. */
+ if (tt) {
+ char *table = NULL;
+
+ table = ttable_dump(tt, "\n");
+ vty_out(vty, "%s\n", table);
+ XFREE(MTYPE_TMP, table);
+ ttable_del(tt);
+ }
if (!bsm_rpinfos_count(bsgrp->partial_bsrp_list) && !uj)
vty_out(vty, "Partial List is empty\n");