diff options
author | Aleksander Morgado <aleksandermj@chromium.org> | 2023-02-17 14:18:16 +0000 |
---|---|---|
committer | Aleksander Morgado <aleksandermj@chromium.org> | 2023-02-20 11:07:38 +0000 |
commit | 6d1f4aee305a6ebeae7bec8b745de33d5368371d (patch) | |
tree | b608fed991d2b5feae23d83e2f7e94dc1288029d /src | |
parent | 278678d8ed818a778377dcb57f5611b04c631450 (diff) |
broadband-modem-mbim: limit the use of context types defined in MBIMEx
The Tethering context type UUID was defined by Microsoft in its
extensions as `5e4e0601-48dc-4e2b-acb8-08b4016bbaac` (along with
others like Admin, Xcap, App and EmergencyCalling), see
https://learn.microsoft.com/en-us/windows-hardware/drivers/network/mb-provisioned-context-operations.
These UUIDs are expected to be usable only if the modem supports
`MBIM_CID_MS_PROVISIONED_CONTEXT_V2` (CID=1) in the Basic Connect
Extensions service (3d01dcc5-fef5-4d05-0d3abef7058e9aaf).
If the modem doesn't support these, we should try to fallback to a
more generic APN type automatically, e.g. "Internet", which was
defined in MBIM 1.0 and should always be supported.
There should be no problem in a modem to have 2 separate PDN
connections with the same context type.
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-bearer-mbim.c | 16 | ||||
-rw-r--r-- | src/mm-broadband-modem-mbim.c | 20 | ||||
-rw-r--r-- | src/mm-broadband-modem-mbim.h | 2 | ||||
-rw-r--r-- | src/mm-modem-helpers-mbim.c | 35 | ||||
-rw-r--r-- | src/mm-modem-helpers-mbim.h | 1 |
5 files changed, 57 insertions, 17 deletions
diff --git a/src/mm-bearer-mbim.c b/src/mm-bearer-mbim.c index 28aa9638..713b7aaf 100644 --- a/src/mm-bearer-mbim.c +++ b/src/mm-bearer-mbim.c @@ -907,9 +907,13 @@ load_settings_from_profile (MMBearerMbim *self, MMBearerApnType default_apn_type, GError **error) { - MMBearerAllowedAuth bearer_auth; - MMBearerApnType apn_type; - GError *inner_error = NULL; + MMBearerAllowedAuth bearer_auth; + MMBearerApnType apn_type; + GError *inner_error = NULL; + g_autoptr(MMBaseModem) modem = NULL; + + g_object_get (self, MM_BASE_BEARER_MODEM, &modem, NULL); + g_assert (modem); /* APN settings */ ctx->apn = g_strdup (mm_3gpp_profile_get_apn (profile)); @@ -922,7 +926,11 @@ load_settings_from_profile (MMBearerMbim *self, } apn_type = default_apn_type; } - ctx->context_type = mm_bearer_apn_type_to_mbim_context_type (apn_type, self, &inner_error); + ctx->context_type = mm_bearer_apn_type_to_mbim_context_type ( + apn_type, + mm_broadband_modem_mbim_is_context_type_ext_supported (MM_BROADBAND_MODEM_MBIM (modem)), + self, + &inner_error); if (inner_error) { g_propagate_error (error, inner_error); return FALSE; diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c index d5e03430..6b88f16c 100644 --- a/src/mm-broadband-modem-mbim.c +++ b/src/mm-broadband-modem-mbim.c @@ -120,6 +120,7 @@ struct _MMBroadbandModemMbimPrivate { /* Supported features */ gboolean is_profile_management_supported; gboolean is_profile_management_ext_supported; + gboolean is_context_type_ext_supported; gboolean is_pco_supported; gboolean is_lte_attach_info_supported; gboolean is_nr5g_registration_settings_supported; @@ -390,6 +391,14 @@ mm_broadband_modem_mbim_peek_port_mbim_for_data (MMBroadbandModemMbim *self, } /*****************************************************************************/ + +gboolean +mm_broadband_modem_mbim_is_context_type_ext_supported (MMBroadbandModemMbim *self) +{ + return self->priv->is_context_type_ext_supported; +} + +/*****************************************************************************/ /* Current capabilities (Modem interface) */ typedef struct { @@ -3281,6 +3290,8 @@ query_device_services_ready (MbimDevice *device, mm_obj_dbg (self, "Base stations info is supported"); self->priv->is_base_stations_info_supported = TRUE; } else if (device_services[i]->cids[j] == MBIM_CID_MS_BASIC_CONNECT_EXTENSIONS_PROVISIONED_CONTEXTS) { + mm_obj_dbg (self, "Context types extension is supported"); + self->priv->is_context_type_ext_supported = TRUE; if (mm_context_get_test_mbimex_profile_management ()) { mm_obj_dbg (self, "Profile management extension is supported"); self->priv->is_profile_management_ext_supported = TRUE; @@ -7223,7 +7234,10 @@ modem_3gpp_profile_manager_store_profile (MMIfaceModem3gppProfileManager *_self, ctx->apn_type = mm_3gpp_profile_get_apn_type (profile); apn_type_str = mm_bearer_apn_type_build_string_from_mask (ctx->apn_type); - context_type = mm_bearer_apn_type_to_mbim_context_type (ctx->apn_type, self, &error); + context_type = mm_bearer_apn_type_to_mbim_context_type (ctx->apn_type, + self->priv->is_context_type_ext_supported, + self, + &error); if (error) { g_prefix_error (&error, "Failed to convert mbim context type from apn type: "); g_task_return_error (task, error); @@ -7398,11 +7412,11 @@ modem_3gpp_profile_manager_delete_profile (MMIfaceModem3gppProfileManager *_self MbimContextType context_type; g_assert (self->priv->is_profile_management_ext_supported); + g_assert (self->priv->is_context_type_ext_supported); apn_type = mm_3gpp_profile_get_apn_type (profile); g_assert (apn_type != MM_BEARER_APN_TYPE_NONE); - - context_type = mm_bearer_apn_type_to_mbim_context_type (apn_type, self, &error); + context_type = mm_bearer_apn_type_to_mbim_context_type (apn_type, TRUE, self, &error); if (error) g_prefix_error (&error, "Failed to convert mbim context type from apn type: "); else { diff --git a/src/mm-broadband-modem-mbim.h b/src/mm-broadband-modem-mbim.h index e1174540..c6c7bae9 100644 --- a/src/mm-broadband-modem-mbim.h +++ b/src/mm-broadband-modem-mbim.h @@ -71,4 +71,6 @@ void mm_broadband_modem_mbim_get_speeds (MMBroadbandModemMbim *self, guint64 *uplink_speed, guint64 *downlink_speed); +gboolean mm_broadband_modem_mbim_is_context_type_ext_supported (MMBroadbandModemMbim *self); + #endif /* MM_BROADBAND_MODEM_MBIM_H */ diff --git a/src/mm-modem-helpers-mbim.c b/src/mm-modem-helpers-mbim.c index 223f9e62..7db91e5c 100644 --- a/src/mm-modem-helpers-mbim.c +++ b/src/mm-modem-helpers-mbim.c @@ -562,6 +562,7 @@ mm_bearer_apn_type_from_mbim_context_type (MbimContextType context_type) MbimContextType mm_bearer_apn_type_to_mbim_context_type (MMBearerApnType apn_type, + gboolean mbim_extensions_supported, gpointer log_object, GError **error) { @@ -580,8 +581,6 @@ mm_bearer_apn_type_to_mbim_context_type (MMBearerApnType apn_type, return MBIM_CONTEXT_TYPE_IMS; if (apn_type & MM_BEARER_APN_TYPE_MMS) return MBIM_CONTEXT_TYPE_MMS; - if (apn_type &MM_BEARER_APN_TYPE_MANAGEMENT) - return MBIM_CONTEXT_TYPE_ADMIN; if (apn_type & MM_BEARER_APN_TYPE_VOICE) return MBIM_CONTEXT_TYPE_VOICE; if (apn_type & MM_BEARER_APN_TYPE_PRIVATE) @@ -592,14 +591,30 @@ mm_bearer_apn_type_to_mbim_context_type (MMBearerApnType apn_type, return MBIM_CONTEXT_TYPE_VIDEO_SHARE; if (apn_type & MM_BEARER_APN_TYPE_LOCAL) return MBIM_CONTEXT_TYPE_LOCAL; - if (apn_type & MM_BEARER_APN_TYPE_APP) - return MBIM_CONTEXT_TYPE_APP; - if (apn_type & MM_BEARER_APN_TYPE_XCAP) - return MBIM_CONTEXT_TYPE_XCAP; - if (apn_type & MM_BEARER_APN_TYPE_TETHERING) - return MBIM_CONTEXT_TYPE_TETHERING; - if (apn_type & MM_BEARER_APN_TYPE_EMERGENCY) - return MBIM_CONTEXT_TYPE_EMERGENCY_CALLING; + + if (mbim_extensions_supported) { + if (apn_type & MM_BEARER_APN_TYPE_MANAGEMENT) + return MBIM_CONTEXT_TYPE_ADMIN; + if (apn_type & MM_BEARER_APN_TYPE_APP) + return MBIM_CONTEXT_TYPE_APP; + if (apn_type & MM_BEARER_APN_TYPE_XCAP) + return MBIM_CONTEXT_TYPE_XCAP; + if (apn_type & MM_BEARER_APN_TYPE_TETHERING) + return MBIM_CONTEXT_TYPE_TETHERING; + if (apn_type & MM_BEARER_APN_TYPE_EMERGENCY) + return MBIM_CONTEXT_TYPE_EMERGENCY_CALLING; + } else { + if ((apn_type & MM_BEARER_APN_TYPE_MANAGEMENT) || + (apn_type & MM_BEARER_APN_TYPE_APP) || + (apn_type & MM_BEARER_APN_TYPE_XCAP) || + (apn_type & MM_BEARER_APN_TYPE_TETHERING) || + (apn_type & MM_BEARER_APN_TYPE_EMERGENCY)) { + mm_obj_dbg (log_object, + "MS extensions unsupported: " + "fallback to using default (internet) APN type"); + return MBIM_CONTEXT_TYPE_INTERNET; + } + } str = mm_bearer_apn_type_build_string_from_mask (apn_type); g_set_error (error, diff --git a/src/mm-modem-helpers-mbim.h b/src/mm-modem-helpers-mbim.h index 2237857a..e07cff62 100644 --- a/src/mm-modem-helpers-mbim.h +++ b/src/mm-modem-helpers-mbim.h @@ -66,6 +66,7 @@ MbimContextIpType mm_bearer_ip_family_to_mbim_context_ip_type (MMBearerIpFa GError **error); MMBearerApnType mm_bearer_apn_type_from_mbim_context_type (MbimContextType context_type); MbimContextType mm_bearer_apn_type_to_mbim_context_type (MMBearerApnType apn_type, + gboolean mbim_extensions_supported, gpointer log_object, GError **error); |