diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2010-10-25 22:51:09 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2010-10-25 22:51:09 +0200 |
commit | 125519ccbb77b5c3d49096b269c6c907e1bfb226 (patch) | |
tree | de748079e615dc3299775ce4d73fddd4396b30ae /drivers | |
parent | ef4d2fb322ae94dbf586977927063bff73a9a409 (diff) | |
download | ofono-125519ccbb77b5c3d49096b269c6c907e1bfb226.tar.bz2 |
ifxmodem: Fix handling of AT+XDNS with multiple contexts
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ifxmodem/gprs-context.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/drivers/ifxmodem/gprs-context.c b/drivers/ifxmodem/gprs-context.c index 4369a240..94c4030b 100644 --- a/drivers/ifxmodem/gprs-context.c +++ b/drivers/ifxmodem/gprs-context.c @@ -164,8 +164,9 @@ static void dns_cb(gboolean ok, GAtResult *result, gpointer user_data) struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc); char buf[64]; int cid; - const char *address; + const char *dns1, *dns2; GAtResultIter iter; + gboolean found = FALSE; if (!ok) { ofono_error("Unable to get DNS details"); @@ -175,25 +176,26 @@ static void dns_cb(gboolean ok, GAtResult *result, gpointer user_data) g_at_result_iter_init(&iter, result); - if (!g_at_result_iter_next(&iter, "+XDNS:")) - goto error; - - if (!g_at_result_iter_next_number(&iter, &cid)) - goto error; + while (g_at_result_iter_next(&iter, "+XDNS:")) { + if (!g_at_result_iter_next_number(&iter, &cid)) + goto error; - if ((unsigned int) cid != gcd->active_context) - goto error; + if (!g_at_result_iter_next_string(&iter, &dns1)) + goto error; - if (!g_at_result_iter_next_string(&iter, &address)) - goto error; + if (!g_at_result_iter_next_string(&iter, &dns2)) + goto error; - strncpy(gcd->dns1, address, sizeof(gcd->dns1)); + if ((unsigned int) cid == gcd->active_context) { + found = TRUE; + strncpy(gcd->dns1, dns1, sizeof(gcd->dns1)); + strncpy(gcd->dns2, dns2, sizeof(gcd->dns2)); + } + } - if (!g_at_result_iter_next_string(&iter, &address)) + if (found == FALSE) goto error; - strncpy(gcd->dns2, address, sizeof(gcd->dns2)); - ofono_info("IP: %s", gcd->address); ofono_info("DNS: %s, %s", gcd->dns1, gcd->dns2); |