aboutsummaryrefslogtreecommitdiff
path: root/plugins/cinterion/mm-modem-helpers-cinterion.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2020-09-09 10:55:33 +0200
committerAleksander Morgado <aleksander@aleksander.es>2020-11-04 09:50:13 +0100
commitf280573f6ded8da447f8f3bc934c4d3204a27f1c (patch)
tree44c081ab4dcebe8baf9719819516b075ad64f598 /plugins/cinterion/mm-modem-helpers-cinterion.c
parenteb338c967f613b4de8ef2933d496e1bc0936f037 (diff)
cinterion: setup SGAUTH response parser as a helper method
Diffstat (limited to 'plugins/cinterion/mm-modem-helpers-cinterion.c')
-rw-r--r--plugins/cinterion/mm-modem-helpers-cinterion.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/plugins/cinterion/mm-modem-helpers-cinterion.c b/plugins/cinterion/mm-modem-helpers-cinterion.c
index bb449505..7bdc8c9e 100644
--- a/plugins/cinterion/mm-modem-helpers-cinterion.c
+++ b/plugins/cinterion/mm-modem-helpers-cinterion.c
@@ -847,6 +847,51 @@ mm_cinterion_parse_swwan_response (const gchar *response,
}
/*****************************************************************************/
+/* ^SGAUTH response parser */
+
+/* at^sgauth?
+ * ^SGAUTH: 1,2,"vf"
+ * ^SGAUTH: 3,0,""
+ * ^SGAUTH: 4,0
+ *
+ * OK
+ */
+
+gboolean
+mm_cinterion_parse_sgauth_response (const gchar *response,
+ guint cid,
+ MMBearerAllowedAuth *out_auth,
+ gchar **out_username,
+ GError **error)
+{
+ g_autoptr(GRegex) r = NULL;
+ g_autoptr(GMatchInfo) match_info = NULL;
+
+ r = g_regex_new ("\\^SGAUTH:\\s*(\\d+),(\\d+),?\"?([a-zA-Z0-9_-]+)?\"?", 0, 0, NULL);
+ g_assert (r != NULL);
+
+ g_regex_match_full (r, response, strlen (response), 0, 0, &match_info, NULL);
+ while (g_match_info_matches (match_info)) {
+ guint sgauth_cid = 0;
+
+ if (mm_get_uint_from_match_info (match_info, 1, &sgauth_cid) &&
+ (sgauth_cid == cid)) {
+ guint cinterion_auth_type = 0;
+
+ mm_get_uint_from_match_info (match_info, 2, &cinterion_auth_type);
+ *out_auth = mm_auth_type_from_cinterion_auth_type (cinterion_auth_type);
+ *out_username = mm_get_string_unquoted_from_match_info (match_info, 3);
+ return TRUE;
+ }
+ g_match_info_next (match_info, NULL);
+ }
+
+ g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_NOT_FOUND,
+ "Auth settings for context %u not found", cid);
+ return FALSE;
+}
+
+/*****************************************************************************/
/* ^SMONG response parser */
static MMModemAccessTechnology