diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-bearer-mbim.c | 26 | ||||
-rw-r--r-- | src/mm-modem-helpers-mbim.c | 50 | ||||
-rw-r--r-- | src/mm-modem-helpers-mbim.h | 4 |
3 files changed, 58 insertions, 22 deletions
diff --git a/src/mm-bearer-mbim.c b/src/mm-bearer-mbim.c index 652f6825..8bf5d770 100644 --- a/src/mm-bearer-mbim.c +++ b/src/mm-bearer-mbim.c @@ -952,30 +952,12 @@ connect_context_step (GTask *task) auth = MBIM_AUTH_PROTOCOL_NONE; } else { MMBearerAllowedAuth bearer_auth; - bearer_auth = mm_bearer_properties_get_allowed_auth (ctx->properties); - if (bearer_auth == MM_BEARER_ALLOWED_AUTH_UNKNOWN) { - mm_dbg ("Using default (PAP) authentication method"); - auth = MBIM_AUTH_PROTOCOL_PAP; - } else if (bearer_auth & MM_BEARER_ALLOWED_AUTH_PAP) { - auth = MBIM_AUTH_PROTOCOL_PAP; - } else if (bearer_auth & MM_BEARER_ALLOWED_AUTH_CHAP) { - auth = MBIM_AUTH_PROTOCOL_CHAP; - } else if (bearer_auth & MM_BEARER_ALLOWED_AUTH_MSCHAPV2) { - auth = MBIM_AUTH_PROTOCOL_MSCHAPV2; - } else if (bearer_auth & MM_BEARER_ALLOWED_AUTH_NONE) { - auth = MBIM_AUTH_PROTOCOL_NONE; - } else { - gchar *str; - str = mm_bearer_allowed_auth_build_string_from_mask (bearer_auth); - g_task_return_new_error ( - task, - MM_CORE_ERROR, - MM_CORE_ERROR_UNSUPPORTED, - "Cannot use any of the specified authentication methods (%s)", - str); + bearer_auth = mm_bearer_properties_get_allowed_auth (ctx->properties); + auth = mm_bearer_allowed_auth_to_mbim_auth_protocol (bearer_auth, &error); + if (error) { + g_task_return_error (task, error); g_object_unref (task); - g_free (str); return; } } diff --git a/src/mm-modem-helpers-mbim.c b/src/mm-modem-helpers-mbim.c index 680b774b..fd5948bb 100644 --- a/src/mm-modem-helpers-mbim.c +++ b/src/mm-modem-helpers-mbim.c @@ -315,6 +315,56 @@ mm_mobile_equipment_error_from_mbim_nw_error (MbimNwError nw_error) /*****************************************************************************/ +MMBearerAllowedAuth +mm_bearer_allowed_auth_from_mbim_auth_protocol (MbimAuthProtocol auth_protocol) +{ + switch (auth_protocol) { + case MBIM_AUTH_PROTOCOL_NONE: + return MM_BEARER_ALLOWED_AUTH_NONE; + case MBIM_AUTH_PROTOCOL_PAP: + return MM_BEARER_ALLOWED_AUTH_PAP; + case MBIM_AUTH_PROTOCOL_CHAP: + return MM_BEARER_ALLOWED_AUTH_CHAP; + case MBIM_AUTH_PROTOCOL_MSCHAPV2: + return MM_BEARER_ALLOWED_AUTH_MSCHAPV2; + default: + return MM_BEARER_ALLOWED_AUTH_UNKNOWN; + } +} + +MbimAuthProtocol +mm_bearer_allowed_auth_to_mbim_auth_protocol (MMBearerAllowedAuth bearer_auth, + GError **error) +{ + gchar *str; + + /* NOTE: the input is a BITMASK, so we try to find a "best match" */ + + if (bearer_auth == MM_BEARER_ALLOWED_AUTH_UNKNOWN) { + mm_dbg ("Using default (PAP) authentication method"); + return MBIM_AUTH_PROTOCOL_PAP; + } + if (bearer_auth & MM_BEARER_ALLOWED_AUTH_PAP) + return MBIM_AUTH_PROTOCOL_PAP; + if (bearer_auth & MM_BEARER_ALLOWED_AUTH_CHAP) + return MBIM_AUTH_PROTOCOL_CHAP; + if (bearer_auth & MM_BEARER_ALLOWED_AUTH_MSCHAPV2) + return MBIM_AUTH_PROTOCOL_MSCHAPV2; + if (bearer_auth & MM_BEARER_ALLOWED_AUTH_NONE) + return MBIM_AUTH_PROTOCOL_NONE; + + str = mm_bearer_allowed_auth_build_string_from_mask (bearer_auth); + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_UNSUPPORTED, + "No match for the requested authentication methods (%s)", + str); + g_free (str); + return MBIM_AUTH_PROTOCOL_NONE; +} + +/*****************************************************************************/ + MMSmsState mm_sms_state_from_mbim_message_status (MbimSmsStatus status) { diff --git a/src/mm-modem-helpers-mbim.h b/src/mm-modem-helpers-mbim.h index 6ef51f36..3ae190ee 100644 --- a/src/mm-modem-helpers-mbim.h +++ b/src/mm-modem-helpers-mbim.h @@ -39,6 +39,10 @@ GList *mm_3gpp_network_info_list_from_mbim_providers (const MbimProvider *const GError *mm_mobile_equipment_error_from_mbim_nw_error (MbimNwError nw_error); +MMBearerAllowedAuth mm_bearer_allowed_auth_from_mbim_auth_protocol (MbimAuthProtocol auth_protocol); +MbimAuthProtocol mm_bearer_allowed_auth_to_mbim_auth_protocol (MMBearerAllowedAuth bearer_auth, + GError **error); + /*****************************************************************************/ /* MBIM/SMS to MM translations */ |