diff options
author | Denis Kenzior <denkenz@gmail.com> | 2009-11-18 17:13:28 -0600 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2009-11-18 18:07:11 -0600 |
commit | 8722828eb3fda3ca0f62ec266ac8e603243383e8 (patch) | |
tree | db52c8814f8fe6ec25c8270e1769c0779dd0a087 /drivers | |
parent | 08ff8b6cd91af7cc9728f779ab796bc42172d66d (diff) | |
download | ofono-8722828eb3fda3ca0f62ec266ac8e603243383e8.tar.bz2 |
Parse the weird response of _OWANDATA
The strings are unquoted and preceded by space. Don't these people read
specs?
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hsomodem/gprs-context.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/drivers/hsomodem/gprs-context.c b/drivers/hsomodem/gprs-context.c index 7ade32e8..2e0c08a4 100644 --- a/drivers/hsomodem/gprs-context.c +++ b/drivers/hsomodem/gprs-context.c @@ -206,10 +206,10 @@ static void owandata_cb(gboolean ok, GAtResult *result, gpointer user_data) struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc); GAtResultIter iter; unsigned int cid; - const char *ip; - const char *gateway; - const char *dns1; - const char *dns2; + const char *ip = NULL; + const char *gateway = NULL; + const char *dns1 = NULL; + const char *dns2 = NULL; if (!ok) return; @@ -220,10 +220,26 @@ static void owandata_cb(gboolean ok, GAtResult *result, gpointer user_data) return; g_at_result_iter_next_number(&iter, &cid); - g_at_result_iter_next_string(&iter, &ip); - g_at_result_iter_next_string(&iter, &gateway); - g_at_result_iter_next_string(&iter, &dns1); - g_at_result_iter_next_string(&iter, &dns2); + g_at_result_iter_next_unquoted_string(&iter, &ip); + g_at_result_iter_next_unquoted_string(&iter, &gateway); + g_at_result_iter_next_unquoted_string(&iter, &dns1); + g_at_result_iter_next_unquoted_string(&iter, &dns2); + + if (ip && ip[0] == ' ') + ip += 1; + + if (gateway && gateway[0] == ' ') + gateway += 1; + + if (dns1 && dns1[0] == ' ') + dns1 += 1; + + if (dns2 && dns2[0] == ' ') + dns2 += 1; + + /* Don't bother reporting the same DNS twice */ + if (g_str_equal(dns1, dns2)) + dns2 = NULL; ofono_info("Got the following parameters for context: %d", cid); ofono_info("IP: %s, Gateway: %s", ip, gateway); |