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

committed by
Dan Williams

parent
d6e2c69129
commit
48ba504f4e
@@ -973,30 +973,10 @@ connect_context_step (GTask *task)
|
||||
g_free (str);
|
||||
}
|
||||
|
||||
if (ip_family == MM_BEARER_IP_FAMILY_IPV4)
|
||||
ctx->ip_type = MBIM_CONTEXT_IP_TYPE_IPV4;
|
||||
else if (ip_family == MM_BEARER_IP_FAMILY_IPV6)
|
||||
ctx->ip_type = MBIM_CONTEXT_IP_TYPE_IPV6;
|
||||
else if (ip_family == MM_BEARER_IP_FAMILY_IPV4V6)
|
||||
ctx->ip_type = MBIM_CONTEXT_IP_TYPE_IPV4V6;
|
||||
else if (ip_family == (MM_BEARER_IP_FAMILY_IPV4 | MM_BEARER_IP_FAMILY_IPV6))
|
||||
ctx->ip_type = MBIM_CONTEXT_IP_TYPE_IPV4_AND_IPV6;
|
||||
else if (ip_family == MM_BEARER_IP_FAMILY_NONE ||
|
||||
ip_family == MM_BEARER_IP_FAMILY_ANY)
|
||||
/* A valid default IP family should have been specified */
|
||||
g_assert_not_reached ();
|
||||
else {
|
||||
gchar * str;
|
||||
|
||||
str = mm_bearer_ip_family_build_string_from_mask (ip_family);
|
||||
g_task_return_new_error (
|
||||
task,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_UNSUPPORTED,
|
||||
"Unsupported IP type configuration: '%s'",
|
||||
str);
|
||||
ctx->ip_type = mm_bearer_ip_family_to_mbim_context_ip_type (ip_family, &error);
|
||||
if (error) {
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
g_free (str);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -357,7 +357,7 @@ mm_bearer_allowed_auth_to_mbim_auth_protocol (MMBearerAllowedAuth bearer_auth,
|
||||
g_set_error (error,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_UNSUPPORTED,
|
||||
"No match for the requested authentication methods (%s)",
|
||||
"Unsupported authentication methods (%s)",
|
||||
str);
|
||||
g_free (str);
|
||||
return MBIM_AUTH_PROTOCOL_NONE;
|
||||
@@ -365,6 +365,60 @@ mm_bearer_allowed_auth_to_mbim_auth_protocol (MMBearerAllowedAuth bearer_auth,
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
MMBearerIpFamily
|
||||
mm_bearer_ip_family_from_mbim_context_ip_type (MbimContextIpType ip_type)
|
||||
{
|
||||
switch (ip_type) {
|
||||
case MBIM_CONTEXT_IP_TYPE_IPV4:
|
||||
return MM_BEARER_IP_FAMILY_IPV4;
|
||||
case MBIM_CONTEXT_IP_TYPE_IPV6:
|
||||
return MM_BEARER_IP_FAMILY_IPV6;
|
||||
case MBIM_CONTEXT_IP_TYPE_IPV4V6:
|
||||
return MM_BEARER_IP_FAMILY_IPV4V6;
|
||||
case MBIM_CONTEXT_IP_TYPE_IPV4_AND_IPV6:
|
||||
return MM_BEARER_IP_FAMILY_IPV4 | MM_BEARER_IP_FAMILY_IPV6;
|
||||
default:
|
||||
return MM_BEARER_IP_FAMILY_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
MbimContextIpType
|
||||
mm_bearer_ip_family_to_mbim_context_ip_type (MMBearerIpFamily ip_family,
|
||||
GError **error)
|
||||
{
|
||||
gchar *str;
|
||||
|
||||
/* NOTE: the input is a BITMASK, so we try to find a "best match" */
|
||||
|
||||
switch ((guint)ip_family) {
|
||||
case MM_BEARER_IP_FAMILY_IPV4:
|
||||
return MBIM_CONTEXT_IP_TYPE_IPV4;
|
||||
case MM_BEARER_IP_FAMILY_IPV6:
|
||||
return MBIM_CONTEXT_IP_TYPE_IPV6;
|
||||
case MM_BEARER_IP_FAMILY_IPV4V6:
|
||||
return MBIM_CONTEXT_IP_TYPE_IPV4V6;
|
||||
case (MM_BEARER_IP_FAMILY_IPV4 | MM_BEARER_IP_FAMILY_IPV6):
|
||||
return MBIM_CONTEXT_IP_TYPE_IPV4_AND_IPV6;
|
||||
case MM_BEARER_IP_FAMILY_NONE:
|
||||
case MM_BEARER_IP_FAMILY_ANY:
|
||||
/* A valid default IP family should have been specified */
|
||||
g_assert_not_reached ();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
str = mm_bearer_ip_family_build_string_from_mask (ip_family);
|
||||
g_set_error (error,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_UNSUPPORTED,
|
||||
"Unsupported IP type configuration: '%s'",
|
||||
str);
|
||||
g_free (str);
|
||||
return MBIM_CONTEXT_IP_TYPE_DEFAULT;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
MMSmsState
|
||||
mm_sms_state_from_mbim_message_status (MbimSmsStatus status)
|
||||
{
|
||||
|
@@ -42,6 +42,9 @@ 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);
|
||||
MMBearerIpFamily mm_bearer_ip_family_from_mbim_context_ip_type (MbimContextIpType ip_type);
|
||||
MbimContextIpType mm_bearer_ip_family_to_mbim_context_ip_type (MMBearerIpFamily ip_family,
|
||||
GError **error);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* MBIM/SMS to MM translations */
|
||||
|
Reference in New Issue
Block a user