aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2016-12-14 13:54:04 +0100
committerAleksander Morgado <aleksander@aleksander.es>2017-01-04 14:11:17 +0100
commit9f725bc96a0e0aa67440694799371f05c11bd74d (patch)
tree12360ecd2ca8bdd325cffb7d26f1551afeef1c46
parentaf2d6c1c4b7f815862313bf0f84b1ff0e91ccd60 (diff)
cinterion: default to PAP if no auth explicitly given
This is the same logic used in other implementations (e.g. QMI).
-rw-r--r--plugins/cinterion/mm-broadband-bearer-cinterion.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/plugins/cinterion/mm-broadband-bearer-cinterion.c b/plugins/cinterion/mm-broadband-bearer-cinterion.c
index 16ddd3e1..79a4a9c5 100644
--- a/plugins/cinterion/mm-broadband-bearer-cinterion.c
+++ b/plugins/cinterion/mm-broadband-bearer-cinterion.c
@@ -103,39 +103,44 @@ parse_auth_type (MMBearerAllowedAuth mm_auth)
}
}
+/* AT^SGAUTH=<cid>[, <auth_type>[, <passwd>, <user>]] */
static gchar *
build_auth_string (MMBearerProperties *config,
guint cid)
{
const gchar *user;
const gchar *passwd;
+ gboolean has_user;
+ gboolean has_passwd;
MMBearerAllowedAuth auth;
BearerCinterionAuthType encoded_auth = BEARER_CINTERION_AUTH_UNKNOWN;
- user = mm_bearer_properties_get_user (config);
- passwd = mm_bearer_properties_get_password (config);
+ user = mm_bearer_properties_get_user (config);
+ passwd = mm_bearer_properties_get_password (config);
+ auth = mm_bearer_properties_get_allowed_auth (config);
- /* Normal use case is no user & pass so return as quick as possible */
- if (!user && !passwd)
- return NULL;
-
- auth = mm_bearer_properties_get_allowed_auth (config);
+ has_user = (user && user[0]);
+ has_passwd = (passwd && passwd[0]);
encoded_auth = parse_auth_type (auth);
- /* Default to no authentication if not specified */
+ /* When 'none' requested, we won't require user/password */
+ if (encoded_auth == BEARER_CINTERION_AUTH_NONE) {
+ if (has_user || has_passwd)
+ mm_warn ("APN user/password given but 'none' authentication requested");
+ return g_strdup_printf ("^SGAUTH=%u,%d", cid, encoded_auth);
+ }
+
+ /* No explicit auth type requested? */
if (encoded_auth == BEARER_CINTERION_AUTH_UNKNOWN) {
- encoded_auth = BEARER_CINTERION_AUTH_NONE;
- mm_dbg ("Unable to detect authentication type. Defaulting to 'none'");
+ /* If no user/passwd given, do nothing */
+ if (!has_user && !has_passwd)
+ return NULL;
+
+ /* If user/passwd given, default to PAP */
+ mm_dbg ("APN user/password given but no authentication type explicitly requested: defaulting to 'PAP'");
+ encoded_auth = BEARER_CINTERION_AUTH_PAP;
}
- /* TODO: Haven't tested this as I can't get a hold of a SIM w/ this feature atm.
- * Write Command
- * AT^SGAUTH=<cid>[, <auth_type>[, <passwd>, <user>]]
- * Response(s)
- * OK
- * ERROR
- * +CME ERROR: <err>
- */
return g_strdup_printf ("^SGAUTH=%u,%d,%s,%s", cid, encoded_auth, passwd, user);
}