aboutsummaryrefslogtreecommitdiff
path: root/src/mm-bearer-qmi.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2020-03-29 19:25:25 +0200
committerAleksander Morgado <aleksander@aleksander.es>2020-04-08 16:35:08 +0200
commitba89d59471a92ac0b5caabdd03d3b199b1cf8ab5 (patch)
tree1b39e950d7365e009e6668e0f1d32493b91bbfc7 /src/mm-bearer-qmi.c
parentb2d3ff0b3d77e2c859a37dcb0e3d67350c81c4c1 (diff)
bearer-qmi: port to use object logging
Diffstat (limited to 'src/mm-bearer-qmi.c')
-rw-r--r--src/mm-bearer-qmi.c139
1 files changed, 70 insertions, 69 deletions
diff --git a/src/mm-bearer-qmi.c b/src/mm-bearer-qmi.c
index ece92275..4ec93d7f 100644
--- a/src/mm-bearer-qmi.c
+++ b/src/mm-bearer-qmi.c
@@ -31,7 +31,7 @@
#include "mm-bearer-qmi.h"
#include "mm-modem-helpers-qmi.h"
#include "mm-port-enums-types.h"
-#include "mm-log.h"
+#include "mm-log-object.h"
#include "mm-modem-helpers.h"
G_DEFINE_TYPE (MMBearerQmi, mm_bearer_qmi, MM_TYPE_BASE_BEARER)
@@ -537,11 +537,14 @@ start_network_ready (QmiClientWds *client,
GAsyncResult *res,
GTask *task)
{
+ MMBearerQmi *self;
ConnectContext *ctx;
GError *error = NULL;
QmiMessageWdsStartNetworkOutput *output;
- ctx = g_task_get_task_data (task);
+ self = g_task_get_task_data (task);
+ ctx = g_task_get_task_data (task);
+
g_assert (ctx->running_ipv4 || ctx->running_ipv6);
g_assert (!(ctx->running_ipv4 && ctx->running_ipv6));
@@ -565,7 +568,7 @@ start_network_ready (QmiClientWds *client,
/* Fall down to a successful connection */
} else {
- mm_info ("error: couldn't start network: %s", error->message);
+ mm_obj_info (self, "couldn't start network: %s", error->message);
if (g_error_matches (error,
QMI_PROTOCOL_ERROR,
QMI_PROTOCOL_ERROR_CALL_FAILED)) {
@@ -577,20 +580,18 @@ start_network_ready (QmiClientWds *client,
output,
&cer,
NULL))
- mm_info ("call end reason (%u): '%s'",
- cer,
- qmi_wds_call_end_reason_get_string (cer));
+ mm_obj_info (self, "call end reason (%u): %s", cer, qmi_wds_call_end_reason_get_string (cer));
if (qmi_message_wds_start_network_output_get_verbose_call_end_reason (
output,
&verbose_cer_type,
&verbose_cer_reason,
NULL))
- mm_info ("verbose call end reason (%u,%d): [%s] %s",
- verbose_cer_type,
- verbose_cer_reason,
- qmi_wds_verbose_call_end_reason_type_get_string (verbose_cer_type),
- qmi_wds_verbose_call_end_reason_get_string (verbose_cer_type, verbose_cer_reason));
+ mm_obj_info (self, "verbose call end reason (%u,%d): [%s] %s",
+ verbose_cer_type,
+ verbose_cer_reason,
+ qmi_wds_verbose_call_end_reason_type_get_string (verbose_cer_type),
+ qmi_wds_verbose_call_end_reason_get_string (verbose_cer_type, verbose_cer_reason));
}
}
}
@@ -693,7 +694,7 @@ get_ipv4_config (MMBearerQmi *self,
/* IPv4 subnet mask */
if (!qmi_message_wds_get_current_settings_output_get_ipv4_gateway_subnet_mask (output, &addr, &error)) {
- mm_warn ("Failed to read IPv4 netmask (%s)", error->message);
+ mm_obj_warn (self, "failed to read IPv4 netmask: %s", error->message);
g_clear_error (&error);
return NULL;
}
@@ -702,12 +703,12 @@ get_ipv4_config (MMBearerQmi *self,
/* IPv4 address */
if (!qmi_message_wds_get_current_settings_output_get_ipv4_address (output, &addr, &error)) {
- mm_warn ("IPv4 family but no IPv4 address (%s)", error->message);
+ mm_obj_warn (self, "IPv4 family but no IPv4 address: %s", error->message);
g_clear_error (&error);
return NULL;
}
- mm_info ("QMI IPv4 Settings:");
+ mm_obj_info (self, "QMI IPv4 Settings:");
config = mm_bearer_ip_config_new ();
mm_bearer_ip_config_set_method (config, ip_method);
@@ -716,15 +717,15 @@ get_ipv4_config (MMBearerQmi *self,
qmi_inet4_ntop (addr, buf, sizeof (buf));
mm_bearer_ip_config_set_address (config, buf);
mm_bearer_ip_config_set_prefix (config, prefix);
- mm_info (" Address: %s/%d", buf, prefix);
+ mm_obj_info (self, " address: %s/%d", buf, prefix);
/* IPv4 gateway address */
if (qmi_message_wds_get_current_settings_output_get_ipv4_gateway_address (output, &addr, &error)) {
qmi_inet4_ntop (addr, buf, sizeof (buf));
mm_bearer_ip_config_set_gateway (config, buf);
- mm_info (" Gateway: %s", buf);
+ mm_obj_info (self, " gateway: %s", buf);
} else {
- mm_info (" Gateway: failed (%s)", error->message);
+ mm_obj_info (self, " gateway: failed (%s)", error->message);
g_clear_error (&error);
}
@@ -732,9 +733,9 @@ get_ipv4_config (MMBearerQmi *self,
if (qmi_message_wds_get_current_settings_output_get_primary_ipv4_dns_address (output, &addr, &error)) {
qmi_inet4_ntop (addr, buf, sizeof (buf));
dns[dns_idx++] = buf;
- mm_info (" DNS #1: %s", buf);
+ mm_obj_info (self, " DNS #1: %s", buf);
} else {
- mm_info (" DNS #1: failed (%s)", error->message);
+ mm_obj_info (self, " DNS #1: failed (%s)", error->message);
g_clear_error (&error);
}
@@ -742,9 +743,9 @@ get_ipv4_config (MMBearerQmi *self,
if (qmi_message_wds_get_current_settings_output_get_secondary_ipv4_dns_address (output, &addr, &error)) {
qmi_inet4_ntop (addr, buf2, sizeof (buf2));
dns[dns_idx++] = buf2;
- mm_info (" DNS #2: %s", buf2);
+ mm_obj_info (self, " DNS #2: %s", buf2);
} else {
- mm_info (" DNS #2: failed (%s)", error->message);
+ mm_obj_info (self, " DNS #2: failed (%s)", error->message);
g_clear_error (&error);
}
@@ -753,7 +754,7 @@ get_ipv4_config (MMBearerQmi *self,
if (mtu) {
mm_bearer_ip_config_set_mtu (config, mtu);
- mm_info (" MTU: %d", mtu);
+ mm_obj_info (self, " MTU: %d", mtu);
}
return config;
@@ -795,12 +796,12 @@ get_ipv6_config (MMBearerQmi *self,
/* If the message has an IPv6 address, create an IPv6 bearer config */
if (!qmi_message_wds_get_current_settings_output_get_ipv6_address (output, &array, &prefix, &error)) {
- mm_warn ("IPv6 family but no IPv6 address (%s)", error->message);
+ mm_obj_warn (self, "IPv6 family but no IPv6 address: %s", error->message);
g_clear_error (&error);
return NULL;
}
- mm_info ("QMI IPv6 Settings:");
+ mm_obj_info (self, "QMI IPv6 Settings:");
config = mm_bearer_ip_config_new ();
mm_bearer_ip_config_set_method (config, ip_method);
@@ -810,15 +811,15 @@ get_ipv6_config (MMBearerQmi *self,
mm_bearer_ip_config_set_address (config, buf);
mm_bearer_ip_config_set_prefix (config, prefix);
- mm_info (" Address: %s/%d", buf, prefix);
+ mm_obj_info (self, " address: %s/%d", buf, prefix);
/* IPv6 gateway address */
if (qmi_message_wds_get_current_settings_output_get_ipv6_gateway_address (output, &array, &prefix, &error)) {
qmi_inet6_ntop (array, buf, sizeof (buf));
mm_bearer_ip_config_set_gateway (config, buf);
- mm_info (" Gateway: %s/%d", buf, prefix);
+ mm_obj_info (self, " gateway: %s/%d", buf, prefix);
} else {
- mm_info (" Gateway: failed (%s)", error->message);
+ mm_obj_info (self, " gateway: failed (%s)", error->message);
g_clear_error (&error);
}
@@ -826,9 +827,9 @@ get_ipv6_config (MMBearerQmi *self,
if (qmi_message_wds_get_current_settings_output_get_ipv6_primary_dns_address (output, &array, &error)) {
qmi_inet6_ntop (array, buf, sizeof (buf));
dns[dns_idx++] = buf;
- mm_info (" DNS #1: %s", buf);
+ mm_obj_info (self, " DNS #1: %s", buf);
} else {
- mm_info (" DNS #1: failed (%s)", error->message);
+ mm_obj_info (self, " DNS #1: failed (%s)", error->message);
g_clear_error (&error);
}
@@ -836,9 +837,9 @@ get_ipv6_config (MMBearerQmi *self,
if (qmi_message_wds_get_current_settings_output_get_ipv6_secondary_dns_address (output, &array, &error)) {
qmi_inet6_ntop (array, buf2, sizeof (buf2));
dns[dns_idx++] = buf2;
- mm_info (" DNS #2: %s", buf2);
+ mm_obj_info (self, " DNS #2: %s", buf2);
} else {
- mm_info (" DNS #2: failed (%s)", error->message);
+ mm_obj_info (self, " DNS #2: failed (%s)", error->message);
g_clear_error (&error);
}
@@ -847,7 +848,7 @@ get_ipv6_config (MMBearerQmi *self,
if (mtu) {
mm_bearer_ip_config_set_mtu (config, mtu);
- mm_info (" MTU: %d", mtu);
+ mm_obj_info (self, " MTU: %d", mtu);
}
return config;
@@ -858,11 +859,13 @@ get_current_settings_ready (QmiClientWds *client,
GAsyncResult *res,
GTask *task)
{
+ MMBearerQmi *self;
ConnectContext *ctx;
GError *error = NULL;
QmiMessageWdsGetCurrentSettingsOutput *output;
- ctx = g_task_get_task_data (task);
+ self = g_task_get_source_object (task);
+ ctx = g_task_get_task_data (task);
g_assert (ctx->running_ipv4 || ctx->running_ipv6);
output = qmi_client_wds_get_current_settings_finish (client, res, &error);
@@ -871,7 +874,7 @@ get_current_settings_ready (QmiClientWds *client,
/* When we're using static IP address, the current settings are mandatory */
if (ctx->ip_method == MM_BEARER_IP_METHOD_STATIC) {
- mm_warn ("Failed to retrieve mandatory IP settings: %s", error->message);
+ mm_obj_warn (self, "failed to retrieve mandatory IP settings: %s", error->message);
if (output)
qmi_message_wds_get_current_settings_output_unref (output);
complete_connect (task, NULL, error);
@@ -879,7 +882,7 @@ get_current_settings_ready (QmiClientWds *client,
}
/* Otherwise, just go on as we're asking for DHCP */
- mm_dbg ("Couldn't get current settings: %s", error->message);
+ mm_obj_dbg (self, "couldn't get current settings: %s", error->message);
g_error_free (error);
config = mm_bearer_ip_config_new ();
@@ -897,16 +900,16 @@ get_current_settings_ready (QmiClientWds *client,
GArray *array;
if (!qmi_message_wds_get_current_settings_output_get_ip_family (output, &ip_family, &error)) {
- mm_dbg (" IP Family: failed (%s); assuming IPv4", error->message);
+ mm_obj_dbg (self, " IP Family: failed (%s); assuming IPv4", error->message);
g_clear_error (&error);
ip_family = QMI_WDS_IP_FAMILY_IPV4;
}
- mm_dbg (" IP Family: %s",
+ mm_obj_dbg (self, " IP Family: %s",
(ip_family == QMI_WDS_IP_FAMILY_IPV4) ? "IPv4" :
(ip_family == QMI_WDS_IP_FAMILY_IPV6) ? "IPv6" : "unknown");
if (!qmi_message_wds_get_current_settings_output_get_mtu (output, &mtu, &error)) {
- mm_dbg (" MTU: failed (%s)", error->message);
+ mm_obj_dbg (self, " MTU: failed (%s)", error->message);
g_clear_error (&error);
}
@@ -925,10 +928,10 @@ get_current_settings_ready (QmiClientWds *client,
g_string_append (s, ", ");
g_string_append (s, g_array_index (array, const char *, i));
}
- mm_dbg (" Domains: %s", s->str);
+ mm_obj_dbg (self, " domains: %s", s->str);
g_string_free (s, TRUE);
} else {
- mm_dbg (" Domains: failed (%s)", error ? error->message : "unknown");
+ mm_obj_dbg (self, " domains: failed (%s)", error ? error->message : "unknown");
g_clear_error (&error);
}
}
@@ -975,11 +978,14 @@ set_ip_family_ready (QmiClientWds *client,
GAsyncResult *res,
GTask *task)
{
+ MMBearerQmi *self;
ConnectContext *ctx;
GError *error = NULL;
QmiMessageWdsSetIpFamilyOutput *output;
+ self = g_task_get_source_object (task);
ctx = g_task_get_task_data (task);
+
g_assert (ctx->running_ipv4 || ctx->running_ipv6);
g_assert (!(ctx->running_ipv4 && ctx->running_ipv6));
@@ -991,7 +997,7 @@ set_ip_family_ready (QmiClientWds *client,
if (error) {
/* Ensure we add the IP family preference TLV */
- mm_dbg ("Couldn't set IP family preference: '%s'", error->message);
+ mm_obj_dbg (self, "couldn't set IP family preference: %s", error->message);
g_error_free (error);
ctx->default_ip_family_set = FALSE;
} else {
@@ -1029,20 +1035,18 @@ packet_service_status_indication_cb (QmiClientWds *client,
output,
&cer,
NULL))
- mm_info ("bearer call end reason (%u): '%s'",
- cer,
- qmi_wds_call_end_reason_get_string (cer));
+ mm_obj_info (self, "bearer call end reason (%u): '%s'", cer, qmi_wds_call_end_reason_get_string (cer));
if (qmi_indication_wds_packet_service_status_output_get_verbose_call_end_reason (
output,
&verbose_cer_type,
&verbose_cer_reason,
NULL))
- mm_info ("bearer verbose call end reason (%u,%d): [%s] %s",
- verbose_cer_type,
- verbose_cer_reason,
- qmi_wds_verbose_call_end_reason_type_get_string (verbose_cer_type),
- qmi_wds_verbose_call_end_reason_get_string (verbose_cer_type, verbose_cer_reason));
+ mm_obj_info (self, "bearer verbose call end reason (%u,%d): [%s] %s",
+ verbose_cer_type,
+ verbose_cer_reason,
+ qmi_wds_verbose_call_end_reason_type_get_string (verbose_cer_type),
+ qmi_wds_verbose_call_end_reason_get_string (verbose_cer_type, verbose_cer_reason));
mm_base_bearer_report_connection_status (MM_BASE_BEARER (self), MM_BEARER_CONNECTION_STATUS_DISCONNECTED);
}
@@ -1077,7 +1081,7 @@ event_report_indication_cb (QmiClientWds *client,
QmiIndicationWdsEventReportOutput *output,
MMBearerQmi *self)
{
- mm_dbg ("Got QMI WDS event report");
+ mm_obj_dbg (self, "got QMI WDS event report");
}
static guint
@@ -1326,7 +1330,7 @@ connect_context_step (GTask *task)
else
ctx->ip_method = MM_BEARER_IP_METHOD_DHCP;
- mm_dbg ("Defaulting to use %s IP method", mm_bearer_ip_method_get_string (ctx->ip_method));
+ mm_obj_dbg (self, "defaulting to use %s IP method", mm_bearer_ip_method_get_string (ctx->ip_method));
ctx->step++;
/* fall through */
@@ -1339,7 +1343,7 @@ connect_context_step (GTask *task)
}
/* Start IPv4 setup */
- mm_dbg ("Running IPv4 connection setup");
+ mm_obj_dbg (self, "running IPv4 connection setup");
ctx->running_ipv4 = TRUE;
ctx->running_ipv6 = FALSE;
ctx->step++;
@@ -1352,7 +1356,7 @@ connect_context_step (GTask *task)
QMI_SERVICE_WDS,
MM_PORT_QMI_FLAG_WDS_IPV4);
if (!client) {
- mm_dbg ("Allocating IPv4-specific WDS client");
+ mm_obj_dbg (self, "allocating IPv4-specific WDS client");
mm_port_qmi_allocate_client (ctx->qmi,
QMI_SERVICE_WDS,
MM_PORT_QMI_FLAG_WDS_IPV4,
@@ -1372,7 +1376,7 @@ connect_context_step (GTask *task)
qmi_client_check_version (QMI_CLIENT (ctx->client_ipv4), 1, 9)) {
QmiMessageWdsSetIpFamilyInput *input;
- mm_dbg ("Setting default IP family to: IPv4");
+ mm_obj_dbg (self, "setting default IP family to: IPv4");
input = qmi_message_wds_set_ip_family_input_new ();
qmi_message_wds_set_ip_family_input_set_preference (input, QMI_WDS_IP_FAMILY_IPV4, NULL);
qmi_client_wds_set_ip_family (ctx->client_ipv4,
@@ -1405,7 +1409,7 @@ connect_context_step (GTask *task)
case CONNECT_STEP_START_NETWORK_IPV4: {
QmiMessageWdsStartNetworkInput *input;
- mm_dbg ("Starting IPv4 connection...");
+ mm_obj_dbg (self, "starting IPv4 connection...");
input = build_start_network_input (ctx);
qmi_client_wds_start_network (ctx->client_ipv4,
input,
@@ -1420,7 +1424,7 @@ connect_context_step (GTask *task)
case CONNECT_STEP_GET_CURRENT_SETTINGS_IPV4:
/* Retrieve and print IP configuration */
if (ctx->packet_data_handle_ipv4) {
- mm_dbg ("Getting IPv4 configuration...");
+ mm_obj_dbg (self, "getting IPv4 configuration...");
get_current_settings (task, ctx->client_ipv4);
return;
}
@@ -1436,7 +1440,7 @@ connect_context_step (GTask *task)
}
/* Start IPv6 setup */
- mm_dbg ("Running IPv6 connection setup");
+ mm_obj_dbg (self, "running IPv6 connection setup");
ctx->running_ipv4 = FALSE;
ctx->running_ipv6 = TRUE;
ctx->step++;
@@ -1449,7 +1453,7 @@ connect_context_step (GTask *task)
QMI_SERVICE_WDS,
MM_PORT_QMI_FLAG_WDS_IPV6);
if (!client) {
- mm_dbg ("Allocating IPv6-specific WDS client");
+ mm_obj_dbg (self, "allocating IPv6-specific WDS client");
mm_port_qmi_allocate_client (ctx->qmi,
QMI_SERVICE_WDS,
MM_PORT_QMI_FLAG_WDS_IPV6,
@@ -1471,7 +1475,7 @@ connect_context_step (GTask *task)
if (qmi_client_check_version (QMI_CLIENT (ctx->client_ipv6), 1, 9)) {
QmiMessageWdsSetIpFamilyInput *input;
- mm_dbg ("Setting default IP family to: IPv6");
+ mm_obj_dbg (self, "setting default IP family to: IPv6");
input = qmi_message_wds_set_ip_family_input_new ();
qmi_message_wds_set_ip_family_input_set_preference (input, QMI_WDS_IP_FAMILY_IPV6, NULL);
qmi_client_wds_set_ip_family (ctx->client_ipv6,
@@ -1504,7 +1508,7 @@ connect_context_step (GTask *task)
case CONNECT_STEP_START_NETWORK_IPV6: {
QmiMessageWdsStartNetworkInput *input;
- mm_dbg ("Starting IPv6 connection...");
+ mm_obj_dbg (self, "starting IPv6 connection...");
input = build_start_network_input (ctx);
qmi_client_wds_start_network (ctx->client_ipv6,
input,
@@ -1519,7 +1523,7 @@ connect_context_step (GTask *task)
case CONNECT_STEP_GET_CURRENT_SETTINGS_IPV6:
/* Retrieve and print IP configuration */
if (ctx->packet_data_handle_ipv6) {
- mm_dbg ("Getting IPv6 configuration...");
+ mm_obj_dbg (self, "getting IPv6 configuration...");
get_current_settings (task, ctx->client_ipv6);
return;
}
@@ -1677,11 +1681,9 @@ _connect (MMBaseBearer *_self,
goto out;
}
- mm_dbg ("Launching connection with QMI port (%s/%s) and data port (%s/%s)",
- mm_port_subsys_get_string (mm_port_get_subsys (MM_PORT (qmi))),
- mm_port_get_device (MM_PORT (qmi)),
- mm_port_subsys_get_string (mm_port_get_subsys (data)),
- mm_port_get_device (data));
+ mm_obj_dbg (self, "launching connection with QMI port (%s) and data port (%s)",
+ mm_port_get_device (MM_PORT (qmi)),
+ mm_port_get_device (data));
ctx = g_slice_new0 (ConnectContext);
ctx->self = g_object_ref (self);
@@ -1714,8 +1716,7 @@ _connect (MMBaseBearer *_self,
ip_family = mm_base_bearer_get_default_ip_family (_self);
ip_family_str = mm_bearer_ip_family_build_string_from_mask (ip_family);
- mm_dbg ("No specific IP family requested, defaulting to %s",
- ip_family_str);
+ mm_obj_dbg (self, "no specific IP family requested, defaulting to %s", ip_family_str);
ctx->no_ip_family_preference = TRUE;
g_free (ip_family_str);
}
@@ -2061,7 +2062,7 @@ disconnect (MMBaseBearer *_self,
(!self->priv->client_ipv4 && !self->priv->client_ipv6) ||
!self->priv->data ||
!self->priv->qmi) {
- mm_dbg ("No need to disconnect: QMI bearer is already disconnected");
+ mm_obj_dbg (self, "no need to disconnect: QMI bearer is already disconnected");
g_task_return_boolean (task, TRUE);
g_object_unref (task);
return;