aboutsummaryrefslogtreecommitdiff
path: root/src/mm-modem-helpers-qmi.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2021-04-08 11:15:21 +0200
committerAleksander Morgado <aleksander@aleksander.es>2021-04-29 10:13:22 +0000
commitfffe49d03e650239390e0f65cc969b9713183488 (patch)
tree57ae8e5b1f91287fe420e40da7c244709cdfa69c /src/mm-modem-helpers-qmi.c
parent865014510a976fdccb1c59d5bcf41bd8cbfc46d1 (diff)
modem-helpers-qmi: perform validation in allowed_auth_to_qmi_authentication()
If we find that none of the requested auth settings are supported, we should fail and return an error. Also, make sure we set the CHAP fallback default only if either user or password are given.
Diffstat (limited to 'src/mm-modem-helpers-qmi.c')
-rw-r--r--src/mm-modem-helpers-qmi.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/mm-modem-helpers-qmi.c b/src/mm-modem-helpers-qmi.c
index 2b68ff18..a53fe2fa 100644
--- a/src/mm-modem-helpers-qmi.c
+++ b/src/mm-modem-helpers-qmi.c
@@ -1467,16 +1467,33 @@ mm_sms_state_from_qmi_message_tag (QmiWmsMessageTagType tag)
/*****************************************************************************/
QmiWdsAuthentication
-mm_bearer_allowed_auth_to_qmi_authentication (MMBearerAllowedAuth auth)
+mm_bearer_allowed_auth_to_qmi_authentication (MMBearerAllowedAuth auth,
+ gpointer log_object,
+ GError **error)
{
- QmiWdsAuthentication out;
+ QmiWdsAuthentication out;
+ g_autofree gchar *str = NULL;
+ if (auth == MM_BEARER_ALLOWED_AUTH_UNKNOWN) {
+ mm_obj_dbg (log_object, "using default (CHAP) authentication method");
+ return QMI_WDS_AUTHENTICATION_CHAP;
+ }
+
+ if (auth == MM_BEARER_ALLOWED_AUTH_NONE)
+ return QMI_WDS_AUTHENTICATION_NONE;
+
+ /* otherwise find a bitmask that matches the input bitmask */
out = QMI_WDS_AUTHENTICATION_NONE;
if (auth & MM_BEARER_ALLOWED_AUTH_PAP)
out |= QMI_WDS_AUTHENTICATION_PAP;
if (auth & MM_BEARER_ALLOWED_AUTH_CHAP)
out |= QMI_WDS_AUTHENTICATION_CHAP;
+ /* and if the bitmask cannot be built, error out */
+ str = mm_bearer_allowed_auth_build_string_from_mask (auth);
+ g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
+ "Unsupported authentication methods (%s)",
+ str);
return out;
}