diff options
| author | Abhishek N R <abnr@vmware.com> | 2022-08-11 04:10:00 -0700 | 
|---|---|---|
| committer | Abhishek N R <abnr@vmware.com> | 2022-08-14 08:29:11 -0700 | 
| commit | 1b6dbdcd1ea31ed5067e7c488df81e85fd6e4d39 (patch) | |
| tree | ac60405db302bb9d0df5bec34437ca49d76128b6 /pimd/pim_cmd_common.c | |
| parent | 0b368b50dd359fcc2972fc2be0cc62390b55211d (diff) | |
pimd, pim6d: Using ttable for displaying "show ip/ipv6 pim rpf" command output.
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 | 24 | 
1 files changed, 20 insertions, 4 deletions
diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c index 1d3f5f430a..f4c92e8f96 100644 --- a/pimd/pim_cmd_common.c +++ b/pimd/pim_cmd_common.c @@ -888,6 +888,8 @@ void pim_show_rpf(struct pim_instance *pim, struct vty *vty, json_object *json)  {  	struct pim_upstream *up;  	time_t now = pim_time_monotonic_sec(); +	struct ttable *tt = NULL; +	char *table = NULL;  	json_object *json_group = NULL;  	json_object *json_row = NULL; @@ -895,8 +897,15 @@ void pim_show_rpf(struct pim_instance *pim, struct vty *vty, json_object *json)  	if (!json) {  		vty_out(vty, "\n"); -		vty_out(vty, -			"Source          Group           RpfIface         RpfAddress      RibNextHop      Metric Pref\n"); + +		/* Prepare table. */ +		tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]); +		ttable_add_row( +			tt, +			"Source|Group|RpfIface|RpfAddress|RibNextHop|Metric|Pref"); +		tt->style.cell.rpad = 2; +		tt->style.corner = '+'; +		ttable_restyle(tt);  	}  	frr_each (rb_pim_upstream, &pim->upstream_head, up) { @@ -944,8 +953,8 @@ void pim_show_rpf(struct pim_instance *pim, struct vty *vty, json_object *json)  			json_object_object_add(json_group, src_str, json_row);  		} else { -			vty_out(vty, -				"%-15pPAs %-15pPAs %-16s %-15pPA %-15pPAs %6d %4d\n", +			ttable_add_row( +				tt, "%pPAs|%pPAs|%s|%pPA|%pPAs|%d|%d",  				&up->sg.src, &up->sg.grp, rpf_ifname,  				&rpf->rpf_addr,  				&rpf->source_nexthop.mrib_nexthop_addr, @@ -953,6 +962,13 @@ void pim_show_rpf(struct pim_instance *pim, struct vty *vty, json_object *json)  				rpf->source_nexthop.mrib_metric_preference);  		}  	} +	/* Dump the generated table. */ +	if (!json) { +		table = ttable_dump(tt, "\n"); +		vty_out(vty, "%s\n", table); +		XFREE(MTYPE_TMP, table); +		ttable_del(tt); +	}  }  void pim_show_neighbors_secondary(struct pim_instance *pim, struct vty *vty)  | 
