From de6b1324cb80413e552806f75c70be72cc41e933 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Mon, 17 May 2021 21:33:32 +0200 Subject: api,bearer: new 'ConnectionError' property This new property will provide detailed information about the failed connection attempt, or about the network initiated disconnection. The property will be cleared only if a new connection attempt is triggered, and so it can be used to investigate why a given attempt failed without needing to be the one who triggered the attempt (e.g. so that failures in NetworkManager-triggered connection attempts can be investigated looking at the DBus API). The property is built as a (ss) tuple, but the libmm-glib interface provides methods to read this property as a GError. --- cli/mmcli-bearer.c | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'cli/mmcli-bearer.c') diff --git a/cli/mmcli-bearer.c b/cli/mmcli-bearer.c index 54d2d4c7..54da4ff9 100644 --- a/cli/mmcli-bearer.c +++ b/cli/mmcli-bearer.c @@ -133,30 +133,34 @@ mmcli_bearer_shutdown (void) static void print_bearer_info (MMBearer *bearer) { - MMBearerIpConfig *ipv4_config; - MMBearerIpConfig *ipv6_config; - MMBearerProperties *properties; - MMBearerStats *stats; - gint profile_id; - gchar *profile_id_str; - - ipv4_config = mm_bearer_get_ipv4_config (bearer); - ipv6_config = mm_bearer_get_ipv6_config (bearer); - properties = mm_bearer_get_properties (bearer); - stats = mm_bearer_get_stats (bearer); - profile_id = mm_bearer_get_profile_id (bearer); + g_autoptr(MMBearerIpConfig) ipv4_config = NULL; + g_autoptr(MMBearerIpConfig) ipv6_config = NULL; + g_autoptr(MMBearerProperties) properties = NULL; + g_autoptr(MMBearerStats) stats = NULL; + g_autoptr(GError) connection_error = NULL; + gint profile_id; + gchar *profile_id_str; + + ipv4_config = mm_bearer_get_ipv4_config (bearer); + ipv6_config = mm_bearer_get_ipv6_config (bearer); + properties = mm_bearer_get_properties (bearer); + stats = mm_bearer_get_stats (bearer); + profile_id = mm_bearer_get_profile_id (bearer); + connection_error = mm_bearer_get_connection_error (bearer); profile_id_str = (profile_id != MM_3GPP_PROFILE_ID_UNKNOWN) ? g_strdup_printf ("%d", profile_id) : NULL; mmcli_output_string (MMC_F_BEARER_GENERAL_DBUS_PATH, mm_bearer_get_path (bearer)); mmcli_output_string (MMC_F_BEARER_GENERAL_TYPE, mm_bearer_type_get_string (mm_bearer_get_bearer_type (bearer))); - mmcli_output_string (MMC_F_BEARER_STATUS_CONNECTED, mm_bearer_get_connected (bearer) ? "yes" : "no"); - mmcli_output_string (MMC_F_BEARER_STATUS_SUSPENDED, mm_bearer_get_suspended (bearer) ? "yes" : "no"); - mmcli_output_string (MMC_F_BEARER_STATUS_MULTIPLEXED, mm_bearer_get_multiplexed (bearer) ? "yes" : "no"); - mmcli_output_string (MMC_F_BEARER_STATUS_INTERFACE, mm_bearer_get_interface (bearer)); - mmcli_output_string_take (MMC_F_BEARER_STATUS_IP_TIMEOUT, g_strdup_printf ("%u", mm_bearer_get_ip_timeout (bearer))); - mmcli_output_string_take (MMC_F_BEARER_STATUS_PROFILE_ID, profile_id_str); + mmcli_output_string (MMC_F_BEARER_STATUS_CONNECTED, mm_bearer_get_connected (bearer) ? "yes" : "no"); + mmcli_output_string_take (MMC_F_BEARER_STATUS_CONNECTION_ERROR_NAME, connection_error ? g_dbus_error_encode_gerror (connection_error) : NULL); + mmcli_output_string (MMC_F_BEARER_STATUS_CONNECTION_ERROR_MESSAGE, connection_error ? connection_error->message : NULL); + mmcli_output_string (MMC_F_BEARER_STATUS_SUSPENDED, mm_bearer_get_suspended (bearer) ? "yes" : "no"); + mmcli_output_string (MMC_F_BEARER_STATUS_MULTIPLEXED, mm_bearer_get_multiplexed (bearer) ? "yes" : "no"); + mmcli_output_string (MMC_F_BEARER_STATUS_INTERFACE, mm_bearer_get_interface (bearer)); + mmcli_output_string_take (MMC_F_BEARER_STATUS_IP_TIMEOUT, g_strdup_printf ("%u", mm_bearer_get_ip_timeout (bearer))); + mmcli_output_string_take (MMC_F_BEARER_STATUS_PROFILE_ID, profile_id_str); /* Properties */ { @@ -315,11 +319,6 @@ print_bearer_info (MMBearer *bearer) } mmcli_output_dump (); - - g_clear_object (&stats); - g_clear_object (&properties); - g_clear_object (&ipv4_config); - g_clear_object (&ipv6_config); } static void -- cgit v1.2.3-70-g09d2