diff options
-rw-r--r-- | src/mm-modem-helpers.c | 31 | ||||
-rw-r--r-- | src/mm-modem-helpers.h | 5 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c index 9652c6f4..80924f00 100644 --- a/src/mm-modem-helpers.c +++ b/src/mm-modem-helpers.c @@ -1102,6 +1102,37 @@ mm_3gpp_parse_cscs_test_response (const gchar *reply, /*************************************************************************/ gboolean +mm_3gpp_parse_cgpaddr_write_response (const gchar *reply, + guint *cid, + gchar **ip) +{ + GRegex *r; + GMatchInfo *match_info; + gboolean success = FALSE; + + g_return_val_if_fail (reply != NULL, FALSE); + g_return_val_if_fail (cid != NULL, FALSE); + g_return_val_if_fail (ip != NULL, FALSE); + + r = g_regex_new ("\\+CGPADDR:\\s*(\\d+)\\s*,\\s*\"(.*)\"", + G_REGEX_OPTIMIZE | G_REGEX_RAW, + 0, NULL); + g_assert (r != NULL); + + if (g_regex_match (r, reply, 0, &match_info)) { + if (mm_get_uint_from_match_info (match_info, 1, cid) && + (*ip = mm_get_string_unquoted_from_match_info (match_info, 2)) != NULL) + success = TRUE; + } + g_match_info_free (match_info); + g_regex_unref (r); + + return success; +} + +/*************************************************************************/ + +gboolean mm_3gpp_parse_clck_test_response (const gchar *reply, MMModem3gppFacility *out_facilities) { diff --git a/src/mm-modem-helpers.h b/src/mm-modem-helpers.h index eb02337e..47091925 100644 --- a/src/mm-modem-helpers.h +++ b/src/mm-modem-helpers.h @@ -125,6 +125,11 @@ gboolean mm_3gpp_parse_cpms_test_response (const gchar *reply, gboolean mm_3gpp_parse_cscs_test_response (const gchar *reply, MMModemCharset *out_charsets); +/* AT+CGPADDR=X (IP address) response parser */ +gboolean mm_3gpp_parse_cgpaddr_write_response (const gchar *reply, + guint *cid, + gchar **ip); + /* AT+CLCK=? (Supported locks) response parser */ gboolean mm_3gpp_parse_clck_test_response (const gchar *reply, MMModem3gppFacility *out_facilities); |