diff options
| author | Abhishek N R <abnr@vmware.com> | 2022-09-16 09:49:22 -0700 | 
|---|---|---|
| committer | Abhishek N R <abnr@vmware.com> | 2022-09-19 02:03:24 -0700 | 
| commit | bae90f95d1f21ad3b8cfdf01ccda5ff772444e0d (patch) | |
| tree | 0577c428ec721d027bf46a226d101c5504766f64 /pimd/pim_cmd_common.c | |
| parent | d1bf3d9aeae41a567fbbbecb285e4dddab538715 (diff) | |
pimd, pim6d: Using ttable for displaying "show ip/ipv6 pim join" command output
Before:
frr# sh ipv6 pim join
Interface        Address         Source          Group           State      Uptime   Expire Prune
ens224           fe80::250:56ff:feb7:9091 *               ff08::1         JOIN       00:16:31 03:28  --:--
After:
frr# show ipv6 pim join
 Interface  Address                   Source  Group    State  Uptime    Expire  Prune
 ens224     fe80::250:56ff:feb7:9091  *       ff08::1  JOIN   00:00:51  03:27   --:--
Signed-off-by: Abhishek N R <abnr@vmware.com>
Diffstat (limited to 'pimd/pim_cmd_common.c')
| -rw-r--r-- | pimd/pim_cmd_common.c | 32 | 
1 files changed, 24 insertions, 8 deletions
diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c index 70c1544717..0ddce42004 100644 --- a/pimd/pim_cmd_common.c +++ b/pimd/pim_cmd_common.c @@ -1655,9 +1655,9 @@ void pim_show_upstream_rpf(struct pim_instance *pim, struct vty *vty, bool uj)  	}  } -static void pim_show_join_helper(struct vty *vty, struct pim_interface *pim_ifp, +static void pim_show_join_helper(struct pim_interface *pim_ifp,  				 struct pim_ifchannel *ch, json_object *json, -				 time_t now) +				 time_t now, struct ttable *tt)  {  	json_object *json_iface = NULL;  	json_object *json_row = NULL; @@ -1724,8 +1724,8 @@ static void pim_show_join_helper(struct vty *vty, struct pim_interface *pim_ifp,  			json_object_object_addf(json_grp, json_row, "%pPAs",  						&ch->sg.src);  	} else { -		vty_out(vty, -			"%-16s %-15pPAs %-15pPAs %-15pPAs %-10s %8s %-6s %5s\n", +		ttable_add_row( +			tt, "%s|%pPAs|%pPAs|%pPAs|%s|%s|%s|%s",  			ch->interface->name, &ifaddr, &ch->sg.src, &ch->sg.grp,  			pim_ifchannel_ifjoin_name(ch->ifjoin_state, ch->flags),  			uptime, expire, prune); @@ -1806,12 +1806,21 @@ void pim_show_join(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,  	struct pim_ifchannel *ch;  	struct interface *ifp;  	time_t now; +	struct ttable *tt = NULL; +	char *table = NULL;  	now = pim_time_monotonic_sec(); -	if (!json) -		vty_out(vty, -			"Interface        Address         Source          Group           State      Uptime   Expire Prune\n"); +	if (!json) { +		/* Prepare table. */ +		tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]); +		ttable_add_row( +			tt, +			"Interface|Address|Source|Group|State|Uptime|Expire|Prune"); +		tt->style.cell.rpad = 2; +		tt->style.corner = '+'; +		ttable_restyle(tt); +	}  	FOR_ALL_INTERFACES (pim->vrf, ifp) {  		pim_ifp = ifp->info; @@ -1822,9 +1831,16 @@ void pim_show_join(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,  			if (!pim_sgaddr_match(ch->sg, *sg))  				continue; -			pim_show_join_helper(vty, pim_ifp, ch, json, now); +			pim_show_join_helper(pim_ifp, ch, json, now, tt);  		} /* scan interface channels */  	} +	/* 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_jp_agg_helper(struct interface *ifp,  | 
