broadband-bearer: allow matching empty APN when looking for PDP CID
The PDP contexts that are found with an empty APN configured are right now used as placeholders that can be overwritten with the user provided APN if no direct match is found. We want to keep that logic in place, but for the case where we do get an empty APN requested by the user, we need to perform the full context match, so that the first PDP context matching the empty APN is used. Right now we're overwriting with the empty APN again the last PDP context found with an empty APN, which doesn't make much sense: Apr 27 08:15:21 ModemManager[4251]: <debug> Found '3' PDP contexts Apr 27 08:15:21 ModemManager[4251]: <debug> PDP context [cid=1] [type='ipv4'] [apn=''] Apr 27 08:15:21 ModemManager[4251]: <debug> PDP context [cid=2] [type='ipv4'] [apn='broadband'] Apr 27 08:15:21 ModemManager[4251]: <debug> PDP context [cid=15] [type='ipv4'] [apn=''] Apr 27 08:15:21 ModemManager[4251]: <debug> Found PDP context with CID 1 and no APN Apr 27 08:15:21 ModemManager[4251]: <debug> Found PDP context with CID 15 and no APN Apr 27 08:15:21 ModemManager[4251]: <debug> (ttyUSB3) device open count is 3 (open) Apr 27 08:15:21 ModemManager[4251]: <debug> (ttyUSB3) device open count is 2 (close) Apr 27 08:15:21 ModemManager[4251]: <debug> (ttyUSB3): --> 'AT+CGDCONT=15,"IP",""<CR>' Apr 27 08:15:21 ModemManager[4251]: <debug> (ttyUSB3): <-- '<CR><LF>OK<CR><LF>'
This commit is contained in:
@@ -867,15 +867,10 @@ parse_pdp_list (MMBaseModem *modem,
|
|||||||
MM3gppPdpContext *pdp = l->data;
|
MM3gppPdpContext *pdp = l->data;
|
||||||
|
|
||||||
if (pdp->pdp_type == ctx->ip_family) {
|
if (pdp->pdp_type == ctx->ip_family) {
|
||||||
/* 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;
|
const gchar *apn;
|
||||||
|
|
||||||
apn = mm_bearer_properties_get_apn (mm_base_bearer_peek_config (MM_BASE_BEARER (ctx->self)));
|
apn = mm_bearer_properties_get_apn (mm_base_bearer_peek_config (MM_BASE_BEARER (ctx->self)));
|
||||||
|
|
||||||
/* First requested, then existing */
|
/* First requested, then existing */
|
||||||
if (mm_3gpp_cmp_apn_name (apn, pdp->apn)) {
|
if (mm_3gpp_cmp_apn_name (apn, pdp->apn)) {
|
||||||
gchar *ip_family_str;
|
gchar *ip_family_str;
|
||||||
@@ -883,13 +878,19 @@ parse_pdp_list (MMBaseModem *modem,
|
|||||||
/* Found a PDP context with the same APN and PDP type, we'll use it. */
|
/* 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);
|
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'",
|
mm_dbg ("Found PDP context with CID %u and PDP type %s for APN '%s'",
|
||||||
pdp->cid, ip_family_str, apn);
|
pdp->cid, ip_family_str, apn ? apn : "");
|
||||||
cid = pdp->cid;
|
cid = pdp->cid;
|
||||||
ctx->use_existing_cid = TRUE;
|
ctx->use_existing_cid = TRUE;
|
||||||
g_free (ip_family_str);
|
g_free (ip_family_str);
|
||||||
/* In this case, stop searching */
|
/* In this case, stop searching */
|
||||||
break;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1305,6 +1305,10 @@ mm_3gpp_cmp_apn_name (const gchar *requested,
|
|||||||
size_t requested_len;
|
size_t requested_len;
|
||||||
size_t existing_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 */
|
/* Both must be given to compare properly */
|
||||||
if (!existing || !existing[0] || !requested || !requested[0])
|
if (!existing || !existing[0] || !requested || !requested[0])
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@@ -2166,17 +2166,22 @@ typedef struct {
|
|||||||
} TestApnCmp;
|
} TestApnCmp;
|
||||||
|
|
||||||
static const TestApnCmp test_apn_cmp[] = {
|
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", "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 },
|
{ "m2m.com.attz.mnc170.mcc310.gprs", "m2m.com.attz", TRUE },
|
||||||
{ "ac.vodafone.es.MNC001.MCC214.GPRS", "ac.vodafone.es", 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 },
|
{ "m2m.com.attz", "m2m.com.attz.mnc170.mcc310.gprs", FALSE },
|
||||||
{ "ac.vodafone.es", "ac.vodafone.es.MNC001.MCC214.GPRS", FALSE },
|
{ "ac.vodafone.es", "ac.vodafone.es.MNC001.MCC214.GPRS", FALSE },
|
||||||
{ "internet.test", "internet", FALSE },
|
{ "internet.test", "internet", FALSE },
|
||||||
{ "internet.test", "INTERNET", FALSE },
|
{ "internet.test", "INTERNET", FALSE },
|
||||||
{ "internet.test", "internet.tes", FALSE },
|
{ "internet.test", "internet.tes", FALSE },
|
||||||
{ "", "", FALSE },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user