helpers-mbim: new method to convert auth settings to/from MM
This commit is contained in:

committed by
Dan Williams

parent
4cb6751daf
commit
d6e2c69129
@@ -952,30 +952,12 @@ connect_context_step (GTask *task)
|
|||||||
auth = MBIM_AUTH_PROTOCOL_NONE;
|
auth = MBIM_AUTH_PROTOCOL_NONE;
|
||||||
} else {
|
} else {
|
||||||
MMBearerAllowedAuth bearer_auth;
|
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);
|
bearer_auth = mm_bearer_properties_get_allowed_auth (ctx->properties);
|
||||||
g_task_return_new_error (
|
auth = mm_bearer_allowed_auth_to_mbim_auth_protocol (bearer_auth, &error);
|
||||||
task,
|
if (error) {
|
||||||
MM_CORE_ERROR,
|
g_task_return_error (task, error);
|
||||||
MM_CORE_ERROR_UNSUPPORTED,
|
|
||||||
"Cannot use any of the specified authentication methods (%s)",
|
|
||||||
str);
|
|
||||||
g_object_unref (task);
|
g_object_unref (task);
|
||||||
g_free (str);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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
|
MMSmsState
|
||||||
mm_sms_state_from_mbim_message_status (MbimSmsStatus status)
|
mm_sms_state_from_mbim_message_status (MbimSmsStatus status)
|
||||||
{
|
{
|
||||||
|
@@ -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);
|
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 */
|
/* MBIM/SMS to MM translations */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user