From e253e62750b5d5ec74b8368ea1e1e2dd933fb336 Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Fri, 28 Dec 2018 10:56:44 -0500 Subject: Use human-readable numbers for conversation stats Bug: 15360 Change-Id: Iceaa5c2336cfb58966ef12f4267fcd09ae48bfe7 Reviewed-on: https://code.wireshark.org/review/31234 Reviewed-by: Michael Mann Petri-Dish: Michael Mann Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- ui/cli/tap-iousers.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'ui') diff --git a/ui/cli/tap-iousers.c b/ui/cli/tap-iousers.c index 6c52d829e5..3295b386d8 100644 --- a/ui/cli/tap-iousers.c +++ b/ui/cli/tap-iousers.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -45,7 +46,7 @@ iousers_draw(void *arg) case TS_UTC: printf("%s | <- | | -> | | Total | Absolute Time | Duration |\n", display_ports ? " " : ""); - printf("%s | Frames Bytes | | Frames Bytes | | Frames Bytes | Start | |\n", + printf("%s | Frames Size | | Frames Size | | Frames Size | Start | |\n", display_ports ? " " : ""); break; case TS_ABSOLUTE_WITH_YMD: @@ -54,7 +55,7 @@ iousers_draw(void *arg) case TS_UTC_WITH_YDOY: printf("%s | <- | | -> | | Total | Absolute Date | Duration |\n", display_ports ? " " : ""); - printf("%s | Frames Bytes | | Frames Bytes | | Frames Bytes | Start | |\n", + printf("%s | Frames Size | | Frames Size | | Frames Size | Start | |\n", display_ports ? " " : ""); break; case TS_RELATIVE: @@ -89,6 +90,12 @@ iousers_draw(void *arg) tot_frames = iui->rx_frames + iui->tx_frames; if (tot_frames == last_frames) { + char *rx_bytes, *tx_bytes, *total_bytes; + + rx_bytes = format_size_wmem(NULL, iui->rx_bytes, (format_size_flags_e)(format_size_unit_bytes|format_size_suffix_no_space)); + tx_bytes = format_size_wmem(NULL, iui->tx_bytes, (format_size_flags_e)(format_size_unit_bytes|format_size_suffix_no_space)); + total_bytes = format_size_wmem(NULL, iui->tx_bytes + iui->rx_bytes, (format_size_flags_e)(format_size_unit_bytes|format_size_suffix_no_space)); + /* XXX - TODO: make name / port resolution configurable (through gbl_resolv_flags?) */ src_addr = get_conversation_address(NULL, &iui->src_address, TRUE); dst_addr = get_conversation_address(NULL, &iui->dst_address, TRUE); @@ -98,33 +105,36 @@ iousers_draw(void *arg) dst_port = get_conversation_port(NULL, iui->dst_port, iui->etype, TRUE); src = wmem_strconcat(NULL, src_addr, ":", src_port, NULL); dst = wmem_strconcat(NULL, dst_addr, ":", dst_port, NULL); - printf("%-26s <-> %-26s %6" G_GINT64_MODIFIER "u %9" G_GINT64_MODIFIER - "u %6" G_GINT64_MODIFIER "u %9" G_GINT64_MODIFIER "u %6" - G_GINT64_MODIFIER "u %9" G_GINT64_MODIFIER "u ", + printf("%-26s <-> %-26s %6" G_GINT64_MODIFIER "u %-9s" + " %6" G_GINT64_MODIFIER "u %-9s" + " %6" G_GINT64_MODIFIER "u %-9s ", src, dst, - iui->rx_frames, iui->rx_bytes, - iui->tx_frames, iui->tx_bytes, + iui->rx_frames, rx_bytes, + iui->tx_frames, tx_bytes, iui->tx_frames+iui->rx_frames, - iui->tx_bytes+iui->rx_bytes + total_bytes ); wmem_free(NULL, src_port); wmem_free(NULL, dst_port); wmem_free(NULL, src); wmem_free(NULL, dst); } else { - printf("%-20s <-> %-20s %6" G_GINT64_MODIFIER "u %9" G_GINT64_MODIFIER - "u %6" G_GINT64_MODIFIER "u %9" G_GINT64_MODIFIER "u %6" - G_GINT64_MODIFIER "u %9" G_GINT64_MODIFIER "u ", + printf("%-20s <-> %-20s %6" G_GINT64_MODIFIER "u %-9s" + " %6" G_GINT64_MODIFIER "u %-9s" + " %6" G_GINT64_MODIFIER "u %-9s ", src_addr, dst_addr, - iui->rx_frames, iui->rx_bytes, - iui->tx_frames, iui->tx_bytes, + iui->rx_frames, rx_bytes, + iui->tx_frames, tx_bytes, iui->tx_frames+iui->rx_frames, - iui->tx_bytes+iui->rx_bytes + total_bytes ); } wmem_free(NULL, src_addr); wmem_free(NULL, dst_addr); + wmem_free(NULL, rx_bytes); + wmem_free(NULL, tx_bytes); + wmem_free(NULL, total_bytes); switch (timestamp_get_type()) { case TS_ABSOLUTE: -- cgit v1.2.3