api,modem-3gpp: new 'SetInitialEpsBearerSettings' method

This method allows users to modify the settings used during the
initial LTE attach procedure.
This commit is contained in:
Aleksander Morgado
2018-12-06 08:04:13 +01:00
committed by Dan Williams
parent 8281b5048b
commit 4cb6751daf
7 changed files with 380 additions and 0 deletions

View File

@@ -51,6 +51,7 @@ static gboolean scan_flag;
static gboolean register_home_flag; static gboolean register_home_flag;
static gchar *register_in_operator_str; static gchar *register_in_operator_str;
static gchar *set_eps_ue_mode_operation_str; static gchar *set_eps_ue_mode_operation_str;
static gchar *set_initial_eps_bearer_settings_str;
static gboolean ussd_status_flag; static gboolean ussd_status_flag;
static gchar *ussd_initiate_str; static gchar *ussd_initiate_str;
static gchar *ussd_respond_str; static gchar *ussd_respond_str;
@@ -73,6 +74,10 @@ static GOptionEntry entries[] = {
"Set the UE mode of operation for EPS", "Set the UE mode of operation for EPS",
"[ps-1|ps-2|csps-1|csps-2]" "[ps-1|ps-2|csps-1|csps-2]"
}, },
{ "3gpp-set-initial-eps-bearer-settings", 0, 0, G_OPTION_ARG_STRING, &set_initial_eps_bearer_settings_str,
"Set the initial EPS bearer settings",
"[\"key=value,...\"]"
},
{ "3gpp-ussd-status", 0, 0, G_OPTION_ARG_NONE, &ussd_status_flag, { "3gpp-ussd-status", 0, 0, G_OPTION_ARG_NONE, &ussd_status_flag,
"Show status of any ongoing USSD session", "Show status of any ongoing USSD session",
NULL NULL
@@ -120,6 +125,7 @@ mmcli_modem_3gpp_options_enabled (void)
register_home_flag + register_home_flag +
!!register_in_operator_str + !!register_in_operator_str +
!!set_eps_ue_mode_operation_str + !!set_eps_ue_mode_operation_str +
!!set_initial_eps_bearer_settings_str +
ussd_status_flag + ussd_status_flag +
!!ussd_initiate_str + !!ussd_initiate_str +
!!ussd_respond_str + !!ussd_respond_str +
@@ -261,6 +267,32 @@ register_ready (MMModem3gpp *modem_3gpp,
mmcli_async_operation_done (); mmcli_async_operation_done ();
} }
static void
set_initial_eps_bearer_settings_process_reply (gboolean result,
const GError *error)
{
if (!result) {
g_printerr ("error: couldn't set initial EPS bearer properties: '%s'\n",
error ? error->message : "unknown error");
exit (EXIT_FAILURE);
}
g_print ("Successfully set initial EPS bearer properties\n");
}
static void
set_initial_eps_bearer_settings_ready (MMModem3gpp *modem,
GAsyncResult *res)
{
gboolean result;
GError *error = NULL;
result = mm_modem_3gpp_set_initial_eps_bearer_settings_finish (modem, res, &error);
set_initial_eps_bearer_settings_process_reply (result, error);
mmcli_async_operation_done ();
}
static void static void
set_eps_ue_mode_operation_process_reply (gboolean result, set_eps_ue_mode_operation_process_reply (gboolean result,
const GError *error) const GError *error)
@@ -452,6 +484,28 @@ get_modem_ready (GObject *source,
return; return;
} }
/* Request to set initial EPS bearer properties? */
if (set_initial_eps_bearer_settings_str) {
GError *error = NULL;
MMBearerProperties *config;
config = mm_bearer_properties_new_from_string (set_initial_eps_bearer_settings_str, &error);
if (!config) {
g_printerr ("Error parsing properties string: '%s'\n", error->message);
exit (EXIT_FAILURE);
}
g_debug ("Asynchronously setting initial EPS bearer properties...");
mm_modem_3gpp_set_initial_eps_bearer_settings (ctx->modem_3gpp,
config,
ctx->cancellable,
(GAsyncReadyCallback)set_initial_eps_bearer_settings_ready,
NULL);
g_object_unref (config);
return;
}
/* Request to initiate USSD session? */ /* Request to initiate USSD session? */
if (ussd_initiate_str) { if (ussd_initiate_str) {
ensure_modem_3gpp_ussd (); ensure_modem_3gpp_ussd ();
@@ -568,6 +622,28 @@ mmcli_modem_3gpp_run_synchronous (GDBusConnection *connection)
return; return;
} }
/* Request to set initial EPS bearer properties? */
if (set_initial_eps_bearer_settings_str) {
GError *error = NULL;
gboolean result;
MMBearerProperties *config;
config = mm_bearer_properties_new_from_string (set_initial_eps_bearer_settings_str, &error);
if (!config) {
g_printerr ("Error parsing properties string: '%s'\n", error->message);
exit (EXIT_FAILURE);
}
g_debug ("Synchronously setting initial EPS bearer properties...");
result = mm_modem_3gpp_set_initial_eps_bearer_settings_sync (ctx->modem_3gpp,
config,
NULL,
&error);
set_initial_eps_bearer_settings_process_reply (result, error);
g_object_unref (config);
return;
}
/* Request to show USSD status? */ /* Request to show USSD status? */
if (ussd_status_flag) { if (ussd_status_flag) {
ensure_modem_3gpp_ussd (); ensure_modem_3gpp_ussd ();

View File

@@ -296,6 +296,9 @@ mm_modem_3gpp_scan_sync
mm_modem_3gpp_set_eps_ue_mode_operation mm_modem_3gpp_set_eps_ue_mode_operation
mm_modem_3gpp_set_eps_ue_mode_operation_finish mm_modem_3gpp_set_eps_ue_mode_operation_finish
mm_modem_3gpp_set_eps_ue_mode_operation_sync mm_modem_3gpp_set_eps_ue_mode_operation_sync
mm_modem_3gpp_set_initial_eps_bearer_settings
mm_modem_3gpp_set_initial_eps_bearer_settings_finish
mm_modem_3gpp_set_initial_eps_bearer_settings_sync
<SUBSECTION Standard> <SUBSECTION Standard>
MMModem3gppClass MMModem3gppClass
MMModem3gppPrivate MMModem3gppPrivate
@@ -1784,10 +1787,14 @@ mm_gdbus_modem3gpp_call_scan_sync
mm_gdbus_modem3gpp_call_set_eps_ue_mode_operation mm_gdbus_modem3gpp_call_set_eps_ue_mode_operation
mm_gdbus_modem3gpp_call_set_eps_ue_mode_operation_finish mm_gdbus_modem3gpp_call_set_eps_ue_mode_operation_finish
mm_gdbus_modem3gpp_call_set_eps_ue_mode_operation_sync mm_gdbus_modem3gpp_call_set_eps_ue_mode_operation_sync
mm_gdbus_modem3gpp_call_set_initial_eps_bearer_settings
mm_gdbus_modem3gpp_call_set_initial_eps_bearer_settings_finish
mm_gdbus_modem3gpp_call_set_initial_eps_bearer_settings_sync
<SUBSECTION Private> <SUBSECTION Private>
mm_gdbus_modem3gpp_complete_register mm_gdbus_modem3gpp_complete_register
mm_gdbus_modem3gpp_complete_scan mm_gdbus_modem3gpp_complete_scan
mm_gdbus_modem3gpp_complete_set_eps_ue_mode_operation mm_gdbus_modem3gpp_complete_set_eps_ue_mode_operation
mm_gdbus_modem3gpp_complete_set_initial_eps_bearer_settings
mm_gdbus_modem3gpp_interface_info mm_gdbus_modem3gpp_interface_info
mm_gdbus_modem3gpp_override_properties mm_gdbus_modem3gpp_override_properties
mm_gdbus_modem3gpp_set_enabled_facility_locks mm_gdbus_modem3gpp_set_enabled_facility_locks

View File

@@ -95,6 +95,30 @@
<arg name="mode" type="u" direction="in" /> <arg name="mode" type="u" direction="in" />
</method> </method>
<!--
SetInitialEpsBearerSettings:
@settings: List of properties to use when requesting the LTE attach procedure.
Updates the default settings to be used in the initial default EPS bearer when registering to the LTE network.
Allowed properties are:
<variablelist>
<varlistentry><term><literal>"apn"</literal></term>
<listitem><para>Access Point Name, given as a string value (signature <literal>"s"</literal>).</para></listitem></varlistentry>
<varlistentry><term><literal>"ip-type"</literal></term>
<listitem><para>Addressing type, given as a <link linkend="MMBearerIpFamily">MMBearerIpFamily</link> value (signature <literal>"u"</literal>).</para></listitem></varlistentry>
<varlistentry><term><literal>"allowed-auth"</literal></term>
<listitem><para>The authentication method to use, given as a <link linkend="MMBearerAllowedAuth">MMBearerAllowedAuth</link> value (signature <literal>"u"</literal>).</para></listitem></varlistentry>
<varlistentry><term><literal>"user"</literal></term>
<listitem><para>User name (if any) required by the network, given as a string value (signature <literal>"s"</literal>).</para></listitem></varlistentry>
<varlistentry><term><literal>"password"</literal></term>
<listitem><para>Password (if any) required by the network, given as a string value (signature <literal>"s"</literal>).</para></listitem></varlistentry>
</variablelist>
-->
<method name="SetInitialEpsBearerSettings">
<arg name="settings" type="a{sv}" direction="in" />
</method>
<!-- <!--
Imei: Imei:
@@ -192,6 +216,10 @@
procedure, e.g. if the device is roaming or no explicit settings were requested, procedure, e.g. if the device is roaming or no explicit settings were requested,
so the properties shown in the #org.freedesktop.ModemManager1.Modem.Modem3gpp.InitialEpsBearer:InitialEpsBearer so the properties shown in the #org.freedesktop.ModemManager1.Modem.Modem3gpp.InitialEpsBearer:InitialEpsBearer
may be totally different. may be totally different.
This is a read-only property, updating these settings should be done using the
<link linkend="gdbus-method-org-freedesktop-ModemManager1-Modem-Modem3gpp.SetInitialEpsBearerSettings">SetInitialEpsBearerSettings()</link>
method.
--> -->
<property name="InitialEpsBearerSettings" type="a{sv}" access="read" /> <property name="InitialEpsBearerSettings" type="a{sv}" access="read" />

View File

@@ -1029,6 +1029,92 @@ mm_modem_3gpp_get_initial_eps_bearer_sync (MMModem3gpp *self,
/*****************************************************************************/ /*****************************************************************************/
/**
* mm_modem_3gpp_set_initial_eps_bearer_settings_finish:
* @self: A #MMModem3gpp.
* @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_3gpp_set_initial_eps_bearer_settings().
* @error: Return location for error or %NULL.
*
* Finishes an operation started with mm_modem_3gpp_set_initial_eps_bearer_settings().
*
* Returns: %TRUE if the operation was successful, %FALSE if @error is set.
*/
gboolean
mm_modem_3gpp_set_initial_eps_bearer_settings_finish (MMModem3gpp *self,
GAsyncResult *res,
GError **error)
{
return mm_gdbus_modem3gpp_call_set_initial_eps_bearer_settings_finish (MM_GDBUS_MODEM3GPP (self), res, error);
}
/**
* mm_modem_3gpp_set_initial_eps_bearer_settings:
* @self: A #MMModem3gpp.
* @config: A #MMBearerProperties object with the properties to use.
* @cancellable: (allow-none): A #GCancellable or %NULL.
* @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
* @user_data: User data to pass to @callback.
*
* Asynchronously configures the settings for the initial LTE default bearer.
*
* When the operation is finished, @callback will be invoked in the
* <link linkend="g-main-context-push-thread-default">thread-default main loop</link>
* of the thread you are calling this method from. You can then call
* mm_modem_3gpp_set_initial_eps_bearer_settings_finish() to get the result of the operation.
*/
void
mm_modem_3gpp_set_initial_eps_bearer_settings (MMModem3gpp *self,
MMBearerProperties *config,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GVariant *dictionary;
dictionary = mm_bearer_properties_get_dictionary (config);
mm_gdbus_modem3gpp_call_set_initial_eps_bearer_settings (MM_GDBUS_MODEM3GPP (self),
dictionary,
cancellable,
callback,
user_data);
g_variant_unref (dictionary);
}
/**
* mm_modem_3gpp_set_initial_eps_bearer_settings_sync:
* @self: A #MMModem3gpp.
* @config: A #MMBearerProperties object with the properties to use.
* @cancellable: (allow-none): A #GCancellable or %NULL.
* @error: Return location for error or %NULL.
*
* Synchronously configures the settings for the initial LTE default bearer.
*
* The calling thread is blocked until a reply is received. See
* mm_modem_3gpp_set_initial_eps_bearer_settings() for the asynchronous
* version of this method.
*
* Returns: %TRUE if the operation was successful, %FALSE if @error is set.
*/
gboolean
mm_modem_3gpp_set_initial_eps_bearer_settings_sync (MMModem3gpp *self,
MMBearerProperties *config,
GCancellable *cancellable,
GError **error)
{
gboolean result;
GVariant *dictionary;
dictionary = mm_bearer_properties_get_dictionary (config);
result = mm_gdbus_modem3gpp_call_set_initial_eps_bearer_settings_sync (MM_GDBUS_MODEM3GPP (self),
dictionary,
cancellable,
error);
g_variant_unref (dictionary);
return result;
}
/*****************************************************************************/
static void static void
mm_modem_3gpp_init (MMModem3gpp *self) mm_modem_3gpp_init (MMModem3gpp *self)
{ {

View File

@@ -154,6 +154,19 @@ MMBearer *mm_modem_3gpp_get_initial_eps_bearer_sync (MMModem3gpp *sel
GCancellable *cancellable, GCancellable *cancellable,
GError **error); GError **error);
void mm_modem_3gpp_set_initial_eps_bearer_settings (MMModem3gpp *self,
MMBearerProperties *config,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean mm_modem_3gpp_set_initial_eps_bearer_settings_finish (MMModem3gpp *self,
GAsyncResult *res,
GError **error);
gboolean mm_modem_3gpp_set_initial_eps_bearer_settings_sync (MMModem3gpp *self,
MMBearerProperties *config,
GCancellable *cancellable,
GError **error);
/* Deprecated APIs */ /* Deprecated APIs */
G_DEPRECATED G_DEPRECATED
MMModem3gppSubscriptionState mm_modem_3gpp_get_subscription_state (MMModem3gpp *self); MMModem3gppSubscriptionState mm_modem_3gpp_get_subscription_state (MMModem3gpp *self);

View File

@@ -913,6 +913,163 @@ handle_set_eps_ue_mode_operation (MmGdbusModem3gpp *skeleton,
/*****************************************************************************/ /*****************************************************************************/
typedef struct {
MmGdbusModem3gpp *skeleton;
GDBusMethodInvocation *invocation;
MMIfaceModem3gpp *self;
GVariant *dictionary;
MMBearerProperties *config;
} HandleSetInitialEpsBearerSettingsContext;
static void
handle_set_initial_eps_bearer_settings_context_free (HandleSetInitialEpsBearerSettingsContext *ctx)
{
g_clear_object (&ctx->config);
g_variant_unref (ctx->dictionary);
g_object_unref (ctx->skeleton);
g_object_unref (ctx->invocation);
g_object_unref (ctx->self);
g_slice_free (HandleSetInitialEpsBearerSettingsContext, ctx);
}
static void
after_set_load_initial_eps_bearer_settings_ready (MMIfaceModem3gpp *self,
GAsyncResult *res,
HandleSetInitialEpsBearerSettingsContext *ctx)
{
GError *error = NULL;
MMBearerProperties *new_config;
new_config = MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_initial_eps_bearer_settings_finish (self, res, &error);
if (error) {
g_dbus_method_invocation_take_error (ctx->invocation, error);
handle_set_initial_eps_bearer_settings_context_free (ctx);
return;
}
if (!mm_bearer_properties_cmp (new_config, ctx->config)) {
g_dbus_method_invocation_return_error_literal (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Initial EPS bearer settings were not updated");
} else {
GVariant *dictionary;
dictionary = mm_bearer_properties_get_dictionary (new_config);
mm_gdbus_modem3gpp_set_initial_eps_bearer_settings (ctx->skeleton, dictionary);
if (dictionary)
g_variant_unref (dictionary);
mm_gdbus_modem3gpp_complete_set_initial_eps_bearer_settings (ctx->skeleton, ctx->invocation);
}
handle_set_initial_eps_bearer_settings_context_free (ctx);
g_object_unref (new_config);
}
static void
set_initial_eps_bearer_settings_ready (MMIfaceModem3gpp *self,
GAsyncResult *res,
HandleSetInitialEpsBearerSettingsContext *ctx)
{
GError *error = NULL;
if (!MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->set_initial_eps_bearer_settings_finish (self, res, &error)) {
g_dbus_method_invocation_take_error (ctx->invocation, error);
handle_set_initial_eps_bearer_settings_context_free (ctx);
return;
}
if (MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_initial_eps_bearer_settings &&
MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_initial_eps_bearer_settings_finish) {
MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_initial_eps_bearer_settings (
self,
(GAsyncReadyCallback)after_set_load_initial_eps_bearer_settings_ready,
ctx);
return;
}
/* Assume we're ok */
mm_gdbus_modem3gpp_complete_set_initial_eps_bearer_settings (ctx->skeleton, ctx->invocation);
handle_set_initial_eps_bearer_settings_context_free (ctx);
}
static void
set_initial_eps_bearer_settings_auth_ready (MMBaseModem *self,
GAsyncResult *res,
HandleSetInitialEpsBearerSettingsContext *ctx)
{
GError *error = NULL;
MMBearerProperties *old_config = NULL;
GVariant *old_dictionary;
if (!mm_base_modem_authorize_finish (self, res, &error)) {
g_dbus_method_invocation_take_error (ctx->invocation, error);
handle_set_initial_eps_bearer_settings_context_free (ctx);
return;
}
/* If UE mode update is not implemented, report an error */
if (!MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->set_initial_eps_bearer_settings ||
!MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->set_initial_eps_bearer_settings_finish) {
g_dbus_method_invocation_return_error (ctx->invocation,
MM_CORE_ERROR,
MM_CORE_ERROR_UNSUPPORTED,
"Cannot set initial EPS bearer settings: operation not supported");
handle_set_initial_eps_bearer_settings_context_free (ctx);
return;
}
ctx->config = mm_bearer_properties_new_from_dictionary (ctx->dictionary, &error);
if (!ctx->config) {
g_dbus_method_invocation_take_error (ctx->invocation, error);
handle_set_initial_eps_bearer_settings_context_free (ctx);
return;
}
/* If the user doesn't specify explicit auth settings, assume NONE as default */
if (mm_bearer_properties_get_allowed_auth (ctx->config) == MM_BEARER_ALLOWED_AUTH_UNKNOWN)
mm_bearer_properties_set_allowed_auth (ctx->config, MM_BEARER_ALLOWED_AUTH_NONE);
old_dictionary = mm_gdbus_modem3gpp_get_initial_eps_bearer_settings (ctx->skeleton);
if (old_dictionary)
old_config = mm_bearer_properties_new_from_dictionary (old_dictionary, NULL);
if (old_config && mm_bearer_properties_cmp (ctx->config, old_config)) {
mm_gdbus_modem3gpp_complete_set_initial_eps_bearer_settings (ctx->skeleton, ctx->invocation);
handle_set_initial_eps_bearer_settings_context_free (ctx);
} else {
MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->set_initial_eps_bearer_settings (
MM_IFACE_MODEM_3GPP (self),
ctx->config,
(GAsyncReadyCallback)set_initial_eps_bearer_settings_ready,
ctx);
}
g_clear_object (&old_config);
}
static gboolean
handle_set_initial_eps_bearer_settings (MmGdbusModem3gpp *skeleton,
GDBusMethodInvocation *invocation,
GVariant *dictionary,
MMIfaceModem3gpp *self)
{
HandleSetInitialEpsBearerSettingsContext *ctx;
ctx = g_slice_new0 (HandleSetInitialEpsBearerSettingsContext);
ctx->skeleton = g_object_ref (skeleton);
ctx->invocation = g_object_ref (invocation);
ctx->self = g_object_ref (self);
ctx->dictionary = g_variant_ref (dictionary);
mm_base_modem_authorize (MM_BASE_MODEM (self),
invocation,
MM_AUTHORIZATION_DEVICE_CONTROL,
(GAsyncReadyCallback)set_initial_eps_bearer_settings_auth_ready,
ctx);
return TRUE;
}
/*****************************************************************************/
gboolean gboolean
mm_iface_modem_3gpp_run_registration_checks_finish (MMIfaceModem3gpp *self, mm_iface_modem_3gpp_run_registration_checks_finish (MMIfaceModem3gpp *self,
GAsyncResult *res, GAsyncResult *res,
@@ -2288,6 +2445,10 @@ interface_initialization_step (GTask *task)
"handle-set-eps-ue-mode-operation", "handle-set-eps-ue-mode-operation",
G_CALLBACK (handle_set_eps_ue_mode_operation), G_CALLBACK (handle_set_eps_ue_mode_operation),
self); self);
g_signal_connect (ctx->skeleton,
"handle-set-initial-eps-bearer-settings",
G_CALLBACK (handle_set_initial_eps_bearer_settings),
self);
/* Finally, export the new interface */ /* Finally, export the new interface */
mm_gdbus_object_skeleton_set_modem3gpp (MM_GDBUS_OBJECT_SKELETON (self), mm_gdbus_object_skeleton_set_modem3gpp (MM_GDBUS_OBJECT_SKELETON (self),

View File

@@ -222,6 +222,15 @@ struct _MMIfaceModem3gpp {
gboolean (* set_eps_ue_mode_operation_finish) (MMIfaceModem3gpp *self, gboolean (* set_eps_ue_mode_operation_finish) (MMIfaceModem3gpp *self,
GAsyncResult *res, GAsyncResult *res,
GError **error); GError **error);
/* Set initial EPS bearer settings */
void (* set_initial_eps_bearer_settings) (MMIfaceModem3gpp *self,
MMBearerProperties *properties,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (* set_initial_eps_bearer_settings_finish) (MMIfaceModem3gpp *self,
GAsyncResult *res,
GError **error);
}; };
GType mm_iface_modem_3gpp_get_type (void); GType mm_iface_modem_3gpp_get_type (void);