aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/mmcli-bearer.c3
-rw-r--r--docs/reference/api/ModemManager-sections.txt1
-rw-r--r--include/ModemManager-enums.h16
-rw-r--r--introspection/org.freedesktop.ModemManager1.Modem.Simple.xml4
-rw-r--r--introspection/org.freedesktop.ModemManager1.Modem.xml2
-rw-r--r--libmm-common/mm-bearer-properties.c36
-rw-r--r--libmm-common/mm-bearer-properties.h4
-rw-r--r--libmm-common/mm-common-helpers.c22
-rw-r--r--libmm-common/mm-common-helpers.h2
-rw-r--r--libmm-common/mm-simple-connect-properties.c6
-rw-r--r--libmm-common/mm-simple-connect-properties.h30
-rw-r--r--src/mm-broadband-bearer.c22
-rw-r--r--src/mm-modem-helpers.c68
-rw-r--r--src/mm-modem-helpers.h5
-rw-r--r--src/tests/test-modem-helpers.c4
15 files changed, 163 insertions, 62 deletions
diff --git a/cli/mmcli-bearer.c b/cli/mmcli-bearer.c
index 651508ef..e7aa6e79 100644
--- a/cli/mmcli-bearer.c
+++ b/cli/mmcli-bearer.c
@@ -169,7 +169,8 @@ print_bearer_info (MMBearer *bearer)
" | Rm protocol: '%s'\n",
VALIDATE_NONE (mm_bearer_properties_get_apn (properties)),
mm_bearer_properties_get_allow_roaming (properties) ? "allowed" : "forbidden",
- VALIDATE_NONE (mm_bearer_properties_get_ip_type (properties)),
+ VALIDATE_UNKNOWN (mm_bearer_ip_family_get_string (
+ mm_bearer_properties_get_ip_type (properties))),
VALIDATE_NONE (mm_bearer_properties_get_user (properties)),
VALIDATE_NONE (mm_bearer_properties_get_password (properties)),
VALIDATE_NONE (mm_bearer_properties_get_number (properties)),
diff --git a/docs/reference/api/ModemManager-sections.txt b/docs/reference/api/ModemManager-sections.txt
index 31683bd8..06f1311a 100644
--- a/docs/reference/api/ModemManager-sections.txt
+++ b/docs/reference/api/ModemManager-sections.txt
@@ -1,6 +1,7 @@
<SECTION>
<FILE>mm-enums</FILE>
<TITLE>Flags and Enumerations</TITLE>
+MMBearerIpFamily
MMBearerIpMethod
MMModem3gppFacility
MMModem3gppNetworkAvailability
diff --git a/include/ModemManager-enums.h b/include/ModemManager-enums.h
index 7ad10655..d853106d 100644
--- a/include/ModemManager-enums.h
+++ b/include/ModemManager-enums.h
@@ -445,6 +445,22 @@ typedef enum { /*< underscore_name=mm_bearer_ip_method >*/
} MMBearerIpMethod;
/**
+ * MMBearerIpFamily:
+ * @MM_BEARER_IP_FAMILY_UNKNOWN: Unknown.
+ * @MM_BEARER_IP_FAMILY_IPV4: IPv4.
+ * @MM_BEARER_IP_FAMILY_IPV6: IPv6.
+ * @MM_BEARER_IP_FAMILY_IPV4V6: IPv4 and IPv6.
+ *
+ * Type of IP family to be used in a given Bearer.
+ */
+typedef enum { /*< underscore_name=mm_bearer_ip_family >*/
+ MM_BEARER_IP_FAMILY_UNKNOWN = 0,
+ MM_BEARER_IP_FAMILY_IPV4 = 4,
+ MM_BEARER_IP_FAMILY_IPV6 = 6,
+ MM_BEARER_IP_FAMILY_IPV4V6 = 10
+} MMBearerIpFamily;
+
+/**
* MMModemCdmaRegistrationState:
* @MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN: Registration status is unknown or the device is not registered.
* @MM_MODEM_CDMA_REGISTRATION_STATE_REGISTERED: Registered, but roaming status is unknown or cannot be provided by the device. The device may or may not be roaming.
diff --git a/introspection/org.freedesktop.ModemManager1.Modem.Simple.xml b/introspection/org.freedesktop.ModemManager1.Modem.Simple.xml
index fc3745f3..3eccbbcc 100644
--- a/introspection/org.freedesktop.ModemManager1.Modem.Simple.xml
+++ b/introspection/org.freedesktop.ModemManager1.Modem.Simple.xml
@@ -82,8 +82,8 @@
<varlistentry><term><literal>"ip-type"</literal></term>
<listitem>
For GSM/UMTS and LTE devices the IP addressing type to use,
- one of "IPV4", "IPV4V6" or "IPV6".
- Given as a string value (signature <literal>"s"</literal>).
+ given as a <link linkend="MMBearerIpFamily">MMBearerIpFamily</link>
+ value (signature <literal>"u"</literal>).
</listitem>
</varlistentry>
<varlistentry><term><literal>"user"</literal></term>
diff --git a/introspection/org.freedesktop.ModemManager1.Modem.xml b/introspection/org.freedesktop.ModemManager1.Modem.xml
index 1a6b4519..5869db7f 100644
--- a/introspection/org.freedesktop.ModemManager1.Modem.xml
+++ b/introspection/org.freedesktop.ModemManager1.Modem.xml
@@ -62,7 +62,7 @@
<varlistentry><term><literal>"apn"</literal></term>
<listitem><para>Access Point Name, given as a string value (signature <literal>"s"</literal>). Required in 3GPP.</para></listitem></varlistentry>
<varlistentry><term><literal>"ip-type"</literal></term>
- <listitem><para>Addressing type, given as a string value (signature <literal>"s"</literal>). One of <literal>"IPV4"</literal>, <literal>"IPV4V6"</literal>, or <literal>"IPV6"</literal>. Optional in 3GPP and CDMA.</para></listitem></varlistentry>
+ <listitem><para>Addressing type, given as a <link linkend="MMBearerIpFamily">MMBearerIpFamily</link> value (signature <literal>"u"</literal>). Optional in 3GPP and CDMA.</para></listitem></varlistentry>
<varlistentry><term><literal>"user"</literal></term>
<listitem><para>User name (if any) required by the network, given as a string value (signature <literal>"s"</literal>). Optional in 3GPP.</para></listitem></varlistentry>
<varlistentry><term><literal>"password"</literal></term>
diff --git a/libmm-common/mm-bearer-properties.c b/libmm-common/mm-bearer-properties.c
index cb660fe4..ab7d4408 100644
--- a/libmm-common/mm-bearer-properties.c
+++ b/libmm-common/mm-bearer-properties.c
@@ -33,7 +33,7 @@ struct _MMBearerPropertiesPrivate {
/* APN */
gchar *apn;
/* IP type */
- gchar *ip_type;
+ MMBearerIpFamily ip_type;
/* Number */
gchar *number;
/* User */
@@ -81,12 +81,11 @@ mm_bearer_properties_set_password (MMBearerProperties *self,
void
mm_bearer_properties_set_ip_type (MMBearerProperties *self,
- const gchar *ip_type)
+ MMBearerIpFamily ip_type)
{
g_return_if_fail (MM_IS_BEARER_PROPERTIES (self));
- g_free (self->priv->ip_type);
- self->priv->ip_type = g_strdup (ip_type);
+ self->priv->ip_type = ip_type;
}
void
@@ -144,10 +143,10 @@ mm_bearer_properties_get_password (MMBearerProperties *self)
return self->priv->password;
}
-const gchar *
+MMBearerIpFamily
mm_bearer_properties_get_ip_type (MMBearerProperties *self)
{
- g_return_val_if_fail (MM_IS_BEARER_PROPERTIES (self), NULL);
+ g_return_val_if_fail (MM_IS_BEARER_PROPERTIES (self), MM_BEARER_IP_FAMILY_UNKNOWN);
return self->priv->ip_type;
}
@@ -209,11 +208,11 @@ mm_bearer_properties_get_dictionary (MMBearerProperties *self)
PROPERTY_PASSWORD,
g_variant_new_string (self->priv->password));
- if (self->priv->ip_type)
+ if (self->priv->ip_type != MM_BEARER_IP_FAMILY_UNKNOWN)
g_variant_builder_add (&builder,
"{sv}",
PROPERTY_IP_TYPE,
- g_variant_new_string (self->priv->ip_type));
+ g_variant_new_uint32 (self->priv->ip_type));
if (self->priv->number)
g_variant_builder_add (&builder,
@@ -252,9 +251,17 @@ mm_bearer_properties_consume_string (MMBearerProperties *self,
mm_bearer_properties_set_user (self, value);
else if (g_str_equal (key, PROPERTY_PASSWORD))
mm_bearer_properties_set_password (self, value);
- else if (g_str_equal (key, PROPERTY_IP_TYPE))
- mm_bearer_properties_set_ip_type (self, value);
- else if (g_str_equal (key, PROPERTY_ALLOW_ROAMING)) {
+ else if (g_str_equal (key, PROPERTY_IP_TYPE)) {
+ GError *inner_error = NULL;
+ MMBearerIpFamily ip_type;
+
+ ip_type = mm_common_get_ip_type_from_string (value, &inner_error);
+ if (inner_error) {
+ g_propagate_error (error, inner_error);
+ return FALSE;
+ }
+ mm_bearer_properties_set_ip_type (self, ip_type);
+ } else if (g_str_equal (key, PROPERTY_ALLOW_ROAMING)) {
GError *inner_error = NULL;
gboolean allow_roaming;
@@ -352,7 +359,7 @@ mm_bearer_properties_consume_variant (MMBearerProperties *properties,
else if (g_str_equal (key, PROPERTY_IP_TYPE))
mm_bearer_properties_set_ip_type (
properties,
- g_variant_get_string (value, NULL));
+ g_variant_get_uint32 (value));
else if (g_str_equal (key, PROPERTY_NUMBER))
mm_bearer_properties_set_number (
properties,
@@ -445,7 +452,7 @@ mm_bearer_properties_cmp (MMBearerProperties *a,
MMBearerProperties *b)
{
return ((!g_strcmp0 (a->priv->apn, b->priv->apn)) &&
- (!g_strcmp0 (a->priv->ip_type, b->priv->ip_type)) &&
+ (a->priv->ip_type == b->priv->ip_type) &&
(!g_strcmp0 (a->priv->number, b->priv->number)) &&
(!g_strcmp0 (a->priv->user, b->priv->user)) &&
(!g_strcmp0 (a->priv->password, b->priv->password)) &&
@@ -479,7 +486,7 @@ mm_bearer_properties_init (MMBearerProperties *self)
* even better approach would likely be to query which PDP types the
* modem supports (using AT+CGDCONT=?), and set the default accordingly
*/
- self->priv->ip_type = g_strdup ("IPV4");
+ self->priv->ip_type = MM_BEARER_IP_FAMILY_IPV4;
}
static void
@@ -490,7 +497,6 @@ finalize (GObject *object)
g_free (self->priv->apn);
g_free (self->priv->user);
g_free (self->priv->password);
- g_free (self->priv->ip_type);
g_free (self->priv->number);
G_OBJECT_CLASS (mm_bearer_properties_parent_class)->finalize (object);
diff --git a/libmm-common/mm-bearer-properties.h b/libmm-common/mm-bearer-properties.h
index 3288c33f..8272e6b6 100644
--- a/libmm-common/mm-bearer-properties.h
+++ b/libmm-common/mm-bearer-properties.h
@@ -58,7 +58,7 @@ void mm_bearer_properties_set_user (MMBearerProperties *properties,
void mm_bearer_properties_set_password (MMBearerProperties *properties,
const gchar *password);
void mm_bearer_properties_set_ip_type (MMBearerProperties *properties,
- const gchar *ip_type);
+ MMBearerIpFamily ip_type);
void mm_bearer_properties_set_allow_roaming (MMBearerProperties *properties,
gboolean allow_roaming);
void mm_bearer_properties_set_number (MMBearerProperties *properties,
@@ -69,7 +69,7 @@ void mm_bearer_properties_set_rm_protocol (MMBearerProperties *properties,
const gchar *mm_bearer_properties_get_apn (MMBearerProperties *properties);
const gchar *mm_bearer_properties_get_user (MMBearerProperties *properties);
const gchar *mm_bearer_properties_get_password (MMBearerProperties *properties);
-const gchar *mm_bearer_properties_get_ip_type (MMBearerProperties *properties);
+MMBearerIpFamily mm_bearer_properties_get_ip_type (MMBearerProperties *properties);
gboolean mm_bearer_properties_get_allow_roaming (MMBearerProperties *properties);
const gchar *mm_bearer_properties_get_number (MMBearerProperties *properties);
MMModemCdmaRmProtocol mm_bearer_properties_get_rm_protocol (MMBearerProperties *properties);
diff --git a/libmm-common/mm-common-helpers.c b/libmm-common/mm-common-helpers.c
index ca96d752..488c771e 100644
--- a/libmm-common/mm-common-helpers.c
+++ b/libmm-common/mm-common-helpers.c
@@ -334,6 +334,28 @@ mm_common_get_rm_protocol_from_string (const gchar *str,
return MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN;
}
+MMBearerIpFamily
+mm_common_get_ip_type_from_string (const gchar *str,
+ GError **error)
+{
+ GEnumClass *enum_class;
+ guint i;
+
+ enum_class = G_ENUM_CLASS (g_type_class_ref (MM_TYPE_BEARER_IP_FAMILY));
+
+ for (i = 0; enum_class->values[i].value_nick; i++) {
+ if (!g_ascii_strcasecmp (str, enum_class->values[i].value_nick))
+ return enum_class->values[i].value;
+ }
+
+ g_set_error (error,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_INVALID_ARGS,
+ "Couldn't match '%s' with a valid MMBearerIpFamily value",
+ str);
+ return MM_BEARER_IP_FAMILY_UNKNOWN;
+}
+
GVariant *
mm_common_build_bands_unknown (void)
{
diff --git a/libmm-common/mm-common-helpers.h b/libmm-common/mm-common-helpers.h
index 98d97f41..13d5b505 100644
--- a/libmm-common/mm-common-helpers.h
+++ b/libmm-common/mm-common-helpers.h
@@ -36,6 +36,8 @@ gboolean mm_common_get_boolean_from_string (const gchar *value,
GError **error);
MMModemCdmaRmProtocol mm_common_get_rm_protocol_from_string (const gchar *str,
GError **error);
+MMBearerIpFamily mm_common_get_ip_type_from_string (const gchar *str,
+ GError **error);
GArray *mm_common_bands_variant_to_garray (GVariant *variant);
MMModemBand *mm_common_bands_variant_to_array (GVariant *variant,
diff --git a/libmm-common/mm-simple-connect-properties.c b/libmm-common/mm-simple-connect-properties.c
index ba69d42a..a0ef96a7 100644
--- a/libmm-common/mm-simple-connect-properties.c
+++ b/libmm-common/mm-simple-connect-properties.c
@@ -124,7 +124,7 @@ mm_simple_connect_properties_set_password (MMSimpleConnectProperties *self,
void
mm_simple_connect_properties_set_ip_type (MMSimpleConnectProperties *self,
- const gchar *ip_type)
+ MMBearerIpFamily ip_type)
{
g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self));
@@ -228,10 +228,10 @@ mm_simple_connect_properties_get_password (MMSimpleConnectProperties *self)
return mm_bearer_properties_get_password (self->priv->bearer_properties);
}
-const gchar *
+MMBearerIpFamily
mm_simple_connect_properties_get_ip_type (MMSimpleConnectProperties *self)
{
- g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), NULL);
+ g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), MM_BEARER_IP_FAMILY_UNKNOWN);
return mm_bearer_properties_get_ip_type (self->priv->bearer_properties);
}
diff --git a/libmm-common/mm-simple-connect-properties.h b/libmm-common/mm-simple-connect-properties.h
index 84ce7723..04c8d34b 100644
--- a/libmm-common/mm-simple-connect-properties.h
+++ b/libmm-common/mm-simple-connect-properties.h
@@ -68,26 +68,26 @@ void mm_simple_connect_properties_set_user (MMSimpleConnectProperties *
void mm_simple_connect_properties_set_password (MMSimpleConnectProperties *properties,
const gchar *password);
void mm_simple_connect_properties_set_ip_type (MMSimpleConnectProperties *properties,
- const gchar *ip_type);
+ MMBearerIpFamily ip_type);
void mm_simple_connect_properties_set_allow_roaming (MMSimpleConnectProperties *properties,
gboolean allow_roaming);
void mm_simple_connect_properties_set_number (MMSimpleConnectProperties *properties,
const gchar *number);
-const gchar *mm_simple_connect_properties_get_pin (MMSimpleConnectProperties *properties);
-const gchar *mm_simple_connect_properties_get_operator_id (MMSimpleConnectProperties *properties);
-void mm_simple_connect_properties_get_bands (MMSimpleConnectProperties *properties,
- const MMModemBand **bands,
- guint *n_bands);
-void mm_simple_connect_properties_get_allowed_modes (MMSimpleConnectProperties *properties,
- MMModemMode *allowed,
- MMModemMode *preferred);
-const gchar *mm_simple_connect_properties_get_apn (MMSimpleConnectProperties *properties);
-const gchar *mm_simple_connect_properties_get_user (MMSimpleConnectProperties *properties);
-const gchar *mm_simple_connect_properties_get_password (MMSimpleConnectProperties *properties);
-const gchar *mm_simple_connect_properties_get_ip_type (MMSimpleConnectProperties *properties);
-gboolean mm_simple_connect_properties_get_allow_roaming (MMSimpleConnectProperties *properties);
-const gchar *mm_simple_connect_properties_get_number (MMSimpleConnectProperties *properties);
+const gchar *mm_simple_connect_properties_get_pin (MMSimpleConnectProperties *properties);
+const gchar *mm_simple_connect_properties_get_operator_id (MMSimpleConnectProperties *properties);
+void mm_simple_connect_properties_get_bands (MMSimpleConnectProperties *properties,
+ const MMModemBand **bands,
+ guint *n_bands);
+void mm_simple_connect_properties_get_allowed_modes (MMSimpleConnectProperties *properties,
+ MMModemMode *allowed,
+ MMModemMode *preferred);
+const gchar *mm_simple_connect_properties_get_apn (MMSimpleConnectProperties *properties);
+const gchar *mm_simple_connect_properties_get_user (MMSimpleConnectProperties *properties);
+const gchar *mm_simple_connect_properties_get_password (MMSimpleConnectProperties *properties);
+MMBearerIpFamily mm_simple_connect_properties_get_ip_type (MMSimpleConnectProperties *properties);
+gboolean mm_simple_connect_properties_get_allow_roaming (MMSimpleConnectProperties *properties);
+const gchar *mm_simple_connect_properties_get_number (MMSimpleConnectProperties *properties);
MMBearerProperties *mm_simple_connect_properties_get_bearer_properties (MMSimpleConnectProperties *properties);
diff --git a/src/mm-broadband-bearer.c b/src/mm-broadband-bearer.c
index 995d8417..6918d89a 100644
--- a/src/mm-broadband-bearer.c
+++ b/src/mm-broadband-bearer.c
@@ -752,6 +752,7 @@ find_cid_ready (MMBaseModem *modem,
GVariant *result;
gchar *command;
GError *error = NULL;
+ const gchar *pdp_type;
result = mm_base_modem_at_sequence_full_finish (modem, res, NULL, &error);
if (!result) {
@@ -768,10 +769,20 @@ find_cid_ready (MMBaseModem *modem,
return;
/* Initialize PDP context with our APN */
+ pdp_type = mm_3gpp_get_pdp_type_from_ip_family (mm_bearer_properties_get_ip_type (mm_bearer_peek_config (MM_BEARER (ctx->self))));
+ if (!pdp_type) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_INVALID_ARGS,
+ "Invalid PDP type requested");
+ detailed_connect_context_complete_and_free (ctx);
+ return;
+ }
+
ctx->cid = g_variant_get_uint32 (result);
command = g_strdup_printf ("+CGDCONT=%u,\"%s\",\"%s\"",
ctx->cid,
- mm_bearer_properties_get_ip_type (mm_bearer_peek_config (MM_BEARER (ctx->self))),
+ pdp_type,
mm_bearer_properties_get_apn (mm_bearer_peek_config (MM_BEARER (ctx->self))));
mm_base_modem_at_command_full (ctx->modem,
ctx->primary,
@@ -830,7 +841,8 @@ parse_cid_range (MMBaseModem *modem,
pdp_type = g_match_info_fetch (match_info, 3);
- if (g_str_equal (pdp_type, mm_bearer_properties_get_ip_type (mm_bearer_peek_config (MM_BEARER (ctx->self))))) {
+ if (mm_3gpp_get_ip_family_from_pdp_type (pdp_type) ==
+ mm_bearer_properties_get_ip_type (mm_bearer_peek_config (MM_BEARER (ctx->self)))) {
gchar *max_cid_range_str;
guint max_cid_range;
@@ -914,9 +926,9 @@ parse_pdp_list (MMBaseModem *modem,
mm_dbg (" PDP context [cid=%u] [type='%s'] [apn='%s']",
pdp->cid,
- pdp->pdp_type ? pdp->pdp_type : "",
+ mm_bearer_ip_family_get_string (pdp->pdp_type),
pdp->apn ? pdp->apn : "");
- if (g_str_equal (pdp->pdp_type, mm_bearer_properties_get_ip_type (mm_bearer_peek_config (MM_BEARER (ctx->self))))) {
+ if (pdp->pdp_type == mm_bearer_properties_get_ip_type (mm_bearer_peek_config (MM_BEARER (ctx->self)))) {
/* PDP with no APN set? we may use that one if not exact match found */
if (!pdp->apn || !pdp->apn[0]) {
mm_dbg ("Found PDP context with CID %u and no APN",
@@ -930,7 +942,7 @@ parse_pdp_list (MMBaseModem *modem,
g_str_equal (pdp->apn, apn)) {
/* Found a PDP context with the same CID and PDP type, we'll use it. */
mm_dbg ("Found PDP context with CID %u and PDP type %s for APN '%s'",
- pdp->cid, pdp->pdp_type, pdp->apn);
+ pdp->cid, mm_bearer_ip_family_get_string (pdp->pdp_type), pdp->apn);
cid = pdp->cid;
/* In this case, stop searching */
break;
diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c
index 6019dfe9..6717ed26 100644
--- a/src/mm-modem-helpers.c
+++ b/src/mm-modem-helpers.c
@@ -500,9 +500,8 @@ mm_3gpp_parse_cops_test_response (const gchar *reply,
static void
mm_3gpp_pdp_context_free (MM3gppPdpContext *pdp)
{
- g_free (pdp->pdp_type);
g_free (pdp->apn);
- g_free (pdp);
+ g_slice_free (MM3gppPdpContext, pdp);
}
void
@@ -540,21 +539,31 @@ mm_3gpp_parse_cgdcont_read_response (const gchar *reply,
while (!inner_error &&
g_match_info_matches (match_info)) {
- MM3gppPdpContext *pdp;
-
- pdp = g_new0 (MM3gppPdpContext, 1);
- if (!mm_get_uint_from_match_info (match_info, 1, &pdp->cid)) {
- inner_error = g_error_new (MM_CORE_ERROR,
- MM_CORE_ERROR_FAILED,
- "Couldn't parse CID from reply: '%s'",
- reply);
- break;
- }
- pdp->pdp_type = mm_get_string_unquoted_from_match_info (match_info, 2);
- pdp->apn = mm_get_string_unquoted_from_match_info (match_info, 3);
+ gchar *str;
+ MMBearerIpFamily ip_family;
+
+ str = mm_get_string_unquoted_from_match_info (match_info, 2);
+ ip_family = mm_3gpp_get_ip_family_from_pdp_type (str);
+ if (ip_family == MM_BEARER_IP_FAMILY_UNKNOWN)
+ mm_dbg ("Ignoring PDP context type: '%s'", str);
+ else {
+ MM3gppPdpContext *pdp;
+
+ pdp = g_slice_new0 (MM3gppPdpContext);
+ if (!mm_get_uint_from_match_info (match_info, 1, &pdp->cid)) {
+ inner_error = g_error_new (MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't parse CID from reply: '%s'",
+ reply);
+ break;
+ }
+ pdp->pdp_type = ip_family;
+ pdp->apn = mm_get_string_unquoted_from_match_info (match_info, 3);
- list = g_list_prepend (list, pdp);
+ list = g_list_prepend (list, pdp);
+ }
+ g_free (str);
g_match_info_next (match_info, &inner_error);
}
@@ -1427,6 +1436,35 @@ mm_3gpp_parse_operator (const gchar *reply,
/*************************************************************************/
+const gchar *
+mm_3gpp_get_pdp_type_from_ip_family (MMBearerIpFamily family)
+{
+ switch (family) {
+ case MM_BEARER_IP_FAMILY_IPV4:
+ return "IP";
+ case MM_BEARER_IP_FAMILY_IPV6:
+ return "IPV6";
+ case MM_BEARER_IP_FAMILY_IPV4V6:
+ return "IPV4V6";
+ default:
+ return NULL;
+ }
+}
+
+MMBearerIpFamily
+mm_3gpp_get_ip_family_from_pdp_type (const gchar *pdp_type)
+{
+ if (g_str_equal (pdp_type, "IP"))
+ return MM_BEARER_IP_FAMILY_IPV4;
+ if (g_str_equal (pdp_type, "IPV6"))
+ return MM_BEARER_IP_FAMILY_IPV6;
+ if (g_str_equal (pdp_type, "IPV4V6"))
+ return MM_BEARER_IP_FAMILY_IPV4V6;
+ return MM_BEARER_IP_FAMILY_UNKNOWN;
+}
+
+/*************************************************************************/
+
gboolean
mm_cdma_parse_spservice_read_response (const gchar *reply,
MMModemCdmaRegistrationState *out_cdma_1x_state,
diff --git a/src/mm-modem-helpers.h b/src/mm-modem-helpers.h
index 8da0a176..9733ead0 100644
--- a/src/mm-modem-helpers.h
+++ b/src/mm-modem-helpers.h
@@ -85,7 +85,7 @@ GList *mm_3gpp_parse_cops_test_response (const gchar *reply,
/* AT+CGDCONT? (PDP context query) response parser */
typedef struct {
guint cid;
- gchar *pdp_type;
+ MMBearerIpFamily pdp_type;
gchar *apn;
} MM3gppPdpContext;
void mm_3gpp_pdp_context_list_free (GList *pdp_list);
@@ -152,6 +152,9 @@ MMModemAccessTechnology mm_string_to_access_tech (const gchar *string);
gchar *mm_3gpp_parse_operator (const gchar *reply,
MMModemCharset cur_charset);
+const gchar *mm_3gpp_get_pdp_type_from_ip_family (MMBearerIpFamily family);
+MMBearerIpFamily mm_3gpp_get_ip_family_from_pdp_type (const gchar *pdp_type);
+
/*****************************************************************************/
/* CDMA specific helpers and utilities */
/*****************************************************************************/
diff --git a/src/tests/test-modem-helpers.c b/src/tests/test-modem-helpers.c
index abe8a3c1..12904a8e 100644
--- a/src/tests/test-modem-helpers.c
+++ b/src/tests/test-modem-helpers.c
@@ -1244,7 +1244,7 @@ test_cgdcont_results (const gchar *desc,
if (pdp->cid == expected->cid) {
found = TRUE;
- g_assert_cmpstr (pdp->pdp_type, ==, expected->pdp_type);
+ g_assert_cmpuint (pdp->pdp_type, ==, expected->pdp_type);
g_assert_cmpstr (pdp->apn, ==, expected->apn);
}
}
@@ -1260,7 +1260,7 @@ test_cgdcont_response_nokia (void *f, gpointer d)
{
const gchar *reply = "+CGDCONT: 1,\"IP\",,,0,0";
static MM3gppPdpContext expected[] = {
- { 1, "IP", NULL }
+ { 1, MM_BEARER_IP_FAMILY_IPV4, NULL }
};
test_cgdcont_results ("Nokia", reply, &expected[0], G_N_ELEMENTS (expected));