From 0510e9aef8818eeaa445aea246b670871c671ddb Mon Sep 17 00:00:00 2001 From: Frederic Martinsons Date: Fri, 15 Oct 2021 08:38:50 +0200 Subject: api,bearer: new 'start-date' field in bearer statistics It stores the epoch timestamp of the current bearer session start. If there is no connected bearer, it is set to 0 and not displayed in mmcli output. Signed-off-by: Frederic Martinsons Includes updates by Aleksander Morgado to fix coding style issues. --- cli/mmcli-output.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'cli/mmcli-output.c') diff --git a/cli/mmcli-output.c b/cli/mmcli-output.c index c681d936..90bd753a 100644 --- a/cli/mmcli-output.c +++ b/cli/mmcli-output.c @@ -248,6 +248,7 @@ static FieldInfo field_infos[] = { [MMC_F_BEARER_IPV6_CONFIG_GATEWAY] = { "bearer.ipv6-config.gateway", "gateway", MMC_S_BEARER_IPV6_CONFIG, }, [MMC_F_BEARER_IPV6_CONFIG_DNS] = { "bearer.ipv6-config.dns", "dns", MMC_S_BEARER_IPV6_CONFIG, }, [MMC_F_BEARER_IPV6_CONFIG_MTU] = { "bearer.ipv6-config.mtu", "mtu", MMC_S_BEARER_IPV6_CONFIG, }, + [MMC_F_BEARER_STATS_START_DATE] = { "bearer.stats.start-date", "start date", MMC_S_BEARER_STATS, }, [MMC_F_BEARER_STATS_DURATION] = { "bearer.stats.duration", "duration", MMC_S_BEARER_STATS, }, [MMC_F_BEARER_STATS_BYTES_RX] = { "bearer.stats.bytes-rx", "bytes rx", MMC_S_BEARER_STATS, }, [MMC_F_BEARER_STATS_BYTES_TX] = { "bearer.stats.bytes-tx", "bytes tx", MMC_S_BEARER_STATS, }, @@ -594,6 +595,22 @@ mmcli_output_signal_quality (guint value, g_strdup_printf ("%s", recent ? "yes" : "no")); } +/******************************************************************************/ +/* (Custom) Bearer start date output */ + +void +mmcli_output_start_date (guint64 value) +{ + /* Merge value and recent flag in a single item in human output */ + if (selected_type == MMC_OUTPUT_TYPE_HUMAN) { + output_item_new_take_single (MMC_F_BEARER_STATS_START_DATE, mm_format_iso8601 (value)); + return; + } + + output_item_new_take_single (MMC_F_BEARER_STATS_START_DATE, + g_strdup_printf ("%" G_GUINT64_FORMAT, value)); +} + /******************************************************************************/ /* (Custom) State output */ -- cgit v1.2.3-70-g09d2