diff options
author | Ujjwal Pande <ujjwalpande@google.com> | 2023-10-04 18:27:43 +0000 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2023-10-11 14:07:53 +0000 |
commit | ae02c47634141c532db62559d1b5baa5048f70cd (patch) | |
tree | 8726e5e6a9536c0e5161ef354d5b126d887f3a27 | |
parent | b7433b4c1499dbdbd7eac10a4ff2111fd4fdd6f4 (diff) |
ModemManager: Add force option to set initial EPS bearer settings
Adding a new force option to force send initial EPS bearer settings to
modem even if they match the existing ones. Currently settings are
not sent to the modem if they match old settings
-rw-r--r-- | libmm-glib/mm-bearer-properties.c | 75 | ||||
-rw-r--r-- | libmm-glib/mm-bearer-properties.h | 4 | ||||
-rw-r--r-- | src/mm-iface-modem-3gpp.c | 7 |
3 files changed, 83 insertions, 3 deletions
diff --git a/libmm-glib/mm-bearer-properties.c b/libmm-glib/mm-bearer-properties.c index 6005405c..e5e7e3d2 100644 --- a/libmm-glib/mm-bearer-properties.c +++ b/libmm-glib/mm-bearer-properties.c @@ -46,6 +46,12 @@ G_DEFINE_TYPE (MMBearerProperties, mm_bearer_properties, G_TYPE_OBJECT) #define PROPERTY_ALLOW_ROAMING "allow-roaming" #define PROPERTY_RM_PROTOCOL "rm-protocol" #define PROPERTY_MULTIPLEX "multiplex" +/* special property to force send initial EPS bearer settings to the modem, + * even if new bearer properties match the existing ones. + * It is only applicable while setting the initial bearer settings and does + * not apply to any other bearer setting operations like simple connect etc. + * This property is not sent to the modem*/ +#define PROPERTY_FORCE "force" /* no longer used properties */ #define DEPRECATED_PROPERTY_NUMBER "number" @@ -57,6 +63,9 @@ struct _MMBearerPropertiesPrivate { /* Roaming allowance */ gboolean allow_roaming_set; gboolean allow_roaming; + /* Force send to modem */ + gboolean force_set; + gboolean force; /* Protocol of the Rm interface */ MMModemCdmaRmProtocol rm_protocol; /* Multiplex support */ @@ -492,6 +501,50 @@ mm_bearer_properties_get_allow_roaming (MMBearerProperties *self) /*****************************************************************************/ /** + * mm_bearer_properties_set_force: + * @self: a #MMBearerProperties. + * @force: boolean value. + * + * Sets the flag to indicate whether initial EPS bearer settings should be + * forced sent to the modem even if they match existing properties. + * This method does not apply when the bearer properties are used for other + * operations. + * + * Since: 1.24 + */ +void +mm_bearer_properties_set_force (MMBearerProperties *self, + gboolean force) +{ + g_return_if_fail (MM_IS_BEARER_PROPERTIES (self)); + + self->priv->force = force; + self->priv->force_set = TRUE; +} + +/** + * mm_bearer_properties_get_force: + * @self: a #MMBearerProperties. + * + * Checks whether initial EPS bearer settings should be forced sent + * to the modem.This method does not apply when the bearer properties are + * used for other operations. + * + * Returns: %TRUE if force send is required, %FALSE otherwise. + * + * Since: 1.24 + */ +gboolean +mm_bearer_properties_get_force (MMBearerProperties *self) +{ + g_return_val_if_fail (MM_IS_BEARER_PROPERTIES (self), FALSE); + + return self->priv->force; +} + +/*****************************************************************************/ + +/** * mm_bearer_properties_set_rm_protocol: * @self: a #MMBearerProperties. * @protocol: a #MMModemCdmaRmProtocol. @@ -616,6 +669,13 @@ mm_bearer_properties_get_dictionary (MMBearerProperties *self) PROPERTY_MULTIPLEX, g_variant_new_uint32 (self->priv->multiplex)); + if (self->priv->force_set) + g_variant_builder_add (&builder, + "{sv}", + PROPERTY_FORCE, + g_variant_new_boolean (self->priv->force)); + + /* Merge dictionaries */ profile_dictionary = mm_3gpp_profile_get_dictionary (self->priv->profile); g_variant_iter_init (&iter, profile_dictionary); @@ -678,6 +738,12 @@ mm_bearer_properties_consume_string (MMBearerProperties *self, mm_bearer_properties_set_multiplex (self, multiplex); } else if (g_str_equal (key, DEPRECATED_PROPERTY_NUMBER)) { /* NO-OP */ + } else if (g_str_equal (key, PROPERTY_FORCE)) { + gboolean force; + + force = mm_common_get_boolean_from_string (value, &inner_error); + if (!inner_error) + mm_bearer_properties_set_force (self, force); } else { inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED, "Invalid properties string, unsupported key '%s'", key); @@ -758,7 +824,9 @@ mm_bearer_properties_consume_variant (MMBearerProperties *self, mm_bearer_properties_set_multiplex (self, g_variant_get_uint32 (value)); else if (g_str_equal (key, DEPRECATED_PROPERTY_NUMBER)) { /* NO-OP */ - } else { + } else if (g_str_equal (key, PROPERTY_FORCE)) + mm_bearer_properties_set_force (self, g_variant_get_boolean (value)); + else { /* Set error */ g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_INVALID_ARGS, "Invalid properties dictionary, unexpected key '%s'", key); @@ -961,6 +1029,10 @@ mm_bearer_properties_print (MMBearerProperties *self, aux = mm_modem_cdma_rm_protocol_get_string (self->priv->rm_protocol); g_ptr_array_add (array, g_strdup_printf (PROPERTY_RM_PROTOCOL ": %s", aux)); } + if (self->priv->force_set) { + aux = mm_common_str_boolean (self->priv->force); + g_ptr_array_add (array, g_strdup_printf (PROPERTY_FORCE ": %s", aux)); + } return array; } @@ -1012,6 +1084,7 @@ mm_bearer_properties_init (MMBearerProperties *self) self->priv->allow_roaming = TRUE; self->priv->rm_protocol = MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN; self->priv->multiplex = MM_BEARER_MULTIPLEX_SUPPORT_UNKNOWN; + self->priv->force = FALSE; } static void diff --git a/libmm-glib/mm-bearer-properties.h b/libmm-glib/mm-bearer-properties.h index 9e522022..fad85e15 100644 --- a/libmm-glib/mm-bearer-properties.h +++ b/libmm-glib/mm-bearer-properties.h @@ -93,6 +93,9 @@ void mm_bearer_properties_set_access_type_preference (MMBearerProperties MMBearerAccessTypePreference access_type_preference); void mm_bearer_properties_set_roaming_allowance (MMBearerProperties *self, MMBearerRoamingAllowance roaming_allowance); +void mm_bearer_properties_set_force (MMBearerProperties *self, + gboolean force); + const gchar *mm_bearer_properties_get_apn (MMBearerProperties *self); MMBearerAllowedAuth mm_bearer_properties_get_allowed_auth (MMBearerProperties *self); @@ -107,6 +110,7 @@ MMModemCdmaRmProtocol mm_bearer_properties_get_rm_protocol (MM MMBearerMultiplexSupport mm_bearer_properties_get_multiplex (MMBearerProperties *self); MMBearerAccessTypePreference mm_bearer_properties_get_access_type_preference (MMBearerProperties *self); MMBearerRoamingAllowance mm_bearer_properties_get_roaming_allowance (MMBearerProperties *self); +gboolean mm_bearer_properties_get_force (MMBearerProperties *self); /*****************************************************************************/ /* ModemManager/libmm-glib/mmcli specific methods */ diff --git a/src/mm-iface-modem-3gpp.c b/src/mm-iface-modem-3gpp.c index 0261c215..0e3cf697 100644 --- a/src/mm-iface-modem-3gpp.c +++ b/src/mm-iface-modem-3gpp.c @@ -1300,6 +1300,7 @@ set_initial_eps_bearer_settings_auth_ready (MMBaseModem GAsyncResult *res, HandleSetInitialEpsBearerSettingsContext *ctx) { + gboolean force = FALSE; GError *error = NULL; GVariant *old_dictionary; g_autoptr(MMBearerProperties) old_config = NULL; @@ -1326,14 +1327,16 @@ set_initial_eps_bearer_settings_auth_ready (MMBaseModem return; } - mm_obj_info (self, "processing user request to set initial EPS bearer settings..."); + force = mm_bearer_properties_get_force (ctx->config); + mm_obj_info (self, "processing user request to set initial EPS bearer settings%s...", force ? " (forced)" : ""); + mm_log_bearer_properties (self, MM_LOG_LEVEL_INFO, " ", ctx->config); 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_BEARER_PROPERTIES_CMP_FLAGS_EPS)) { + if (!force && old_config && mm_bearer_properties_cmp (ctx->config, old_config, MM_BEARER_PROPERTIES_CMP_FLAGS_EPS)) { mm_obj_info (self, "skipped setting initial EPS bearer settings: same configuration provided"); mm_gdbus_modem3gpp_complete_set_initial_eps_bearer_settings (ctx->skeleton, ctx->invocation); handle_set_initial_eps_bearer_settings_context_free (ctx); |