aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mm-broadband-bearer.c37
-rw-r--r--src/mm-modem-helpers.c4
-rw-r--r--src/tests/test-modem-helpers.c7
3 files changed, 29 insertions, 19 deletions
diff --git a/src/mm-broadband-bearer.c b/src/mm-broadband-bearer.c
index 0a0d235e..6321de25 100644
--- a/src/mm-broadband-bearer.c
+++ b/src/mm-broadband-bearer.c
@@ -867,29 +867,30 @@ parse_pdp_list (MMBaseModem *modem,
MM3gppPdpContext *pdp = l->data;
if (pdp->pdp_type == ctx->ip_family) {
+ const gchar *apn;
+
+ apn = mm_bearer_properties_get_apn (mm_base_bearer_peek_config (MM_BASE_BEARER (ctx->self)));
+
+ /* First requested, then existing */
+ if (mm_3gpp_cmp_apn_name (apn, pdp->apn)) {
+ gchar *ip_family_str;
+
+ /* Found a PDP context with the same APN and PDP type, we'll use it. */
+ ip_family_str = mm_bearer_ip_family_build_string_from_mask (pdp->pdp_type);
+ mm_dbg ("Found PDP context with CID %u and PDP type %s for APN '%s'",
+ pdp->cid, ip_family_str, apn ? apn : "");
+ cid = pdp->cid;
+ ctx->use_existing_cid = TRUE;
+ g_free (ip_family_str);
+ /* In this case, stop searching */
+ break;
+ }
+
/* 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",
pdp->cid);
cid = pdp->cid;
- } else {
- const gchar *apn;
-
- apn = mm_bearer_properties_get_apn (mm_base_bearer_peek_config (MM_BASE_BEARER (ctx->self)));
- /* First requested, then existing */
- if (mm_3gpp_cmp_apn_name (apn, pdp->apn)) {
- gchar *ip_family_str;
-
- /* Found a PDP context with the same APN and PDP type, we'll use it. */
- ip_family_str = mm_bearer_ip_family_build_string_from_mask (pdp->pdp_type);
- mm_dbg ("Found PDP context with CID %u and PDP type %s for APN '%s'",
- pdp->cid, ip_family_str, apn);
- cid = pdp->cid;
- ctx->use_existing_cid = TRUE;
- g_free (ip_family_str);
- /* In this case, stop searching */
- break;
- }
}
}
diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c
index 48cd1e16..c2586712 100644
--- a/src/mm-modem-helpers.c
+++ b/src/mm-modem-helpers.c
@@ -1305,6 +1305,10 @@ mm_3gpp_cmp_apn_name (const gchar *requested,
size_t requested_len;
size_t existing_len;
+ /* If both empty, that's a good match */
+ if ((!existing || !existing[0]) && (!requested || !requested[0]))
+ return TRUE;
+
/* Both must be given to compare properly */
if (!existing || !existing[0] || !requested || !requested[0])
return FALSE;
diff --git a/src/tests/test-modem-helpers.c b/src/tests/test-modem-helpers.c
index c2cc1105..483b56f5 100644
--- a/src/tests/test-modem-helpers.c
+++ b/src/tests/test-modem-helpers.c
@@ -2166,17 +2166,22 @@ typedef struct {
} TestApnCmp;
static const TestApnCmp test_apn_cmp[] = {
+ { "", "", TRUE },
+ { NULL, "", TRUE },
+ { "", NULL, TRUE },
+ { NULL, NULL, TRUE },
{ "m2m.com.attz", "m2m.com.attz", TRUE },
{ "m2m.com.attz", "M2M.COM.ATTZ", TRUE },
{ "M2M.COM.ATTZ", "m2m.com.attz", TRUE },
{ "m2m.com.attz.mnc170.mcc310.gprs", "m2m.com.attz", TRUE },
{ "ac.vodafone.es.MNC001.MCC214.GPRS", "ac.vodafone.es", TRUE },
+ { "", "m2m.com.attz", FALSE },
+ { "m2m.com.attz", "", FALSE },
{ "m2m.com.attz", "m2m.com.attz.mnc170.mcc310.gprs", FALSE },
{ "ac.vodafone.es", "ac.vodafone.es.MNC001.MCC214.GPRS", FALSE },
{ "internet.test", "internet", FALSE },
{ "internet.test", "INTERNET", FALSE },
{ "internet.test", "internet.tes", FALSE },
- { "", "", FALSE },
};
static void