diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2020-11-29 22:08:04 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2020-12-21 12:05:57 +0000 |
commit | 527b4e3232a611bde1cab6e6302924fb65f453a7 (patch) | |
tree | f437e5f2db5c9869e32b605236bdb7fbdd499ce5 | |
parent | 295400688acc4d670a1f7c58d45359bb891bf44d (diff) |
broadband-modem-qmi: implement initial EPS bearer info loading
-rw-r--r-- | src/mm-broadband-modem-qmi.c | 75 | ||||
-rw-r--r-- | src/mm-modem-helpers-qmi.c | 15 | ||||
-rw-r--r-- | src/mm-modem-helpers-qmi.h | 1 |
3 files changed, 91 insertions, 0 deletions
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c index f544bc48..1dff318c 100644 --- a/src/mm-broadband-modem-qmi.c +++ b/src/mm-broadband-modem-qmi.c @@ -7646,6 +7646,79 @@ modem_3gpp_ussd_cancel (MMIfaceModem3gppUssd *_self, } /*****************************************************************************/ +/* Initial EPS bearer info loading */ + +static MMBearerProperties * +modem_3gpp_load_initial_eps_bearer_finish (MMIfaceModem3gpp *self, + GAsyncResult *res, + GError **error) +{ + return MM_BEARER_PROPERTIES (g_task_propagate_pointer (G_TASK (res), error)); +} + +static void +get_lte_attach_parameters_ready (QmiClientWds *client, + GAsyncResult *res, + GTask *task) +{ + g_autoptr(QmiMessageWdsGetLteAttachParametersOutput) output = NULL; + GError *error = NULL; + MMBearerProperties *properties; + const gchar *apn; + QmiWdsIpSupportType ip_support_type; + + output = qmi_client_wds_get_lte_attach_parameters_finish (client, res, &error); + if (!output) { + g_prefix_error (&error, "QMI operation failed: "); + g_task_return_error (task, error); + g_object_unref (task); + return; + } + + if (!qmi_message_wds_get_lte_attach_parameters_output_get_result (output, &error)) { + g_prefix_error (&error, "Couldn't get LTE attach parameters: "); + g_task_return_error (task, error); + g_object_unref (task); + return; + } + + properties = mm_bearer_properties_new (); + if (qmi_message_wds_get_lte_attach_parameters_output_get_apn (output, &apn, NULL)) + mm_bearer_properties_set_apn (properties, apn); + if (qmi_message_wds_get_lte_attach_parameters_output_get_ip_support_type (output, &ip_support_type, NULL)) { + MMBearerIpFamily ip_family; + + ip_family = mm_bearer_ip_family_from_qmi_ip_support_type (ip_support_type); + if (ip_family != MM_BEARER_IP_FAMILY_NONE) + mm_bearer_properties_set_ip_type (properties, ip_family); + } + g_task_return_pointer (task, properties, g_object_unref); + g_object_unref (task); +} + +static void +modem_3gpp_load_initial_eps_bearer (MMIfaceModem3gpp *self, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GTask *task; + QmiClient *client; + + if (!mm_shared_qmi_ensure_client (MM_SHARED_QMI (self), + QMI_SERVICE_WDS, &client, + callback, user_data)) + return; + + task = g_task_new (self, NULL, callback, user_data); + qmi_client_wds_get_lte_attach_parameters (QMI_CLIENT_WDS (client), + NULL, + 10, + NULL, + (GAsyncReadyCallback) get_lte_attach_parameters_ready, + task); +} + +/*****************************************************************************/ /* Check firmware support (Firmware interface) */ typedef struct { @@ -9537,6 +9610,8 @@ iface_modem_3gpp_init (MMIfaceModem3gpp *iface) iface->load_operator_code_finish = modem_3gpp_load_operator_code_finish; iface->load_operator_name = modem_3gpp_load_operator_name; iface->load_operator_name_finish = modem_3gpp_load_operator_name_finish; + iface->load_initial_eps_bearer = modem_3gpp_load_initial_eps_bearer; + iface->load_initial_eps_bearer_finish = modem_3gpp_load_initial_eps_bearer_finish; } static void diff --git a/src/mm-modem-helpers-qmi.c b/src/mm-modem-helpers-qmi.c index 584d0618..e7f93914 100644 --- a/src/mm-modem-helpers-qmi.c +++ b/src/mm-modem-helpers-qmi.c @@ -1472,6 +1472,21 @@ mm_bearer_allowed_auth_to_qmi_authentication (MMBearerAllowedAuth auth) return out; } +MMBearerIpFamily +mm_bearer_ip_family_from_qmi_ip_support_type (QmiWdsIpSupportType ip_support_type) +{ + switch (ip_support_type) { + case QMI_WDS_IP_SUPPORT_TYPE_IPV4: + return MM_BEARER_IP_FAMILY_IPV4; + case QMI_WDS_IP_SUPPORT_TYPE_IPV6: + return MM_BEARER_IP_FAMILY_IPV6; + case QMI_WDS_IP_SUPPORT_TYPE_IPV4V6: + return MM_BEARER_IP_FAMILY_IPV4V6; + default: + return MM_BEARER_IP_FAMILY_NONE; + } +} + /*****************************************************************************/ /** diff --git a/src/mm-modem-helpers-qmi.h b/src/mm-modem-helpers-qmi.h index 9d69e99a..a7d835b6 100644 --- a/src/mm-modem-helpers-qmi.h +++ b/src/mm-modem-helpers-qmi.h @@ -114,6 +114,7 @@ MMSmsState mm_sms_state_from_qmi_message_tag (QmiWmsMessageTagType tag); /* QMI/WDS to MM translations */ QmiWdsAuthentication mm_bearer_allowed_auth_to_qmi_authentication (MMBearerAllowedAuth auth); +MMBearerIpFamily mm_bearer_ip_family_from_qmi_ip_support_type (QmiWdsIpSupportType ip_support_type); /*****************************************************************************/ /* QMI/OMA to MM translations */ |