diff options
-rw-r--r-- | plugins/sierra/mm-broadband-bearer-sierra.c | 54 |
1 files changed, 45 insertions, 9 deletions
diff --git a/plugins/sierra/mm-broadband-bearer-sierra.c b/plugins/sierra/mm-broadband-bearer-sierra.c index 4b20380f..c3a7bc86 100644 --- a/plugins/sierra/mm-broadband-bearer-sierra.c +++ b/plugins/sierra/mm-broadband-bearer-sierra.c @@ -59,7 +59,7 @@ typedef struct { static void dial_3gpp_context_complete_and_free (Dial3gppContext *ctx) { - g_simple_async_result_complete (ctx->result); + g_simple_async_result_complete_in_idle (ctx->result); g_object_unref (ctx->cancellable); g_object_unref (ctx->result); g_object_unref (ctx->primary); @@ -184,18 +184,54 @@ dial_3gpp_context_step (Dial3gppContext *ctx) gchar *command; const gchar *user; const gchar *password; + MMBearerAllowedAuth allowed_auth; user = mm_bearer_properties_get_user (mm_bearer_peek_config (MM_BEARER (ctx->self))); password = mm_bearer_properties_get_password (mm_bearer_peek_config (MM_BEARER (ctx->self))); - - if (!user || !password) - command = g_strdup_printf ("$QCPDPP=%d,0", - ctx->cid); - else - command = g_strdup_printf ("$QCPDPP=%d,1,\"%s\",\"%s\"", + allowed_auth = mm_bearer_properties_get_allowed_auth (mm_bearer_peek_config (MM_BEARER (ctx->self))); + + if (!user || !password || allowed_auth == MM_BEARER_ALLOWED_AUTH_NONE) { + mm_dbg ("Not using authentication"); + command = g_strdup_printf ("$QCPDPP=%d,0", ctx->cid); + } else { + gchar *quoted_user; + gchar *quoted_password; + guint sierra_auth; + + if (allowed_auth == MM_BEARER_ALLOWED_AUTH_UNKNOWN) { + mm_dbg ("Using default (PAP) authentication method"); + sierra_auth = 1; + } else if (allowed_auth & MM_BEARER_ALLOWED_AUTH_PAP) { + mm_dbg ("Using PAP authentication method"); + sierra_auth = 1; + } else if (allowed_auth & MM_BEARER_ALLOWED_AUTH_CHAP) { + mm_dbg ("Using CHAP authentication method"); + sierra_auth = 2; + } else { + gchar *str; + + str = mm_bearer_allowed_auth_build_string_from_mask (allowed_auth); + g_simple_async_result_set_error ( + ctx->result, + MM_CORE_ERROR, + MM_CORE_ERROR_UNSUPPORTED, + "Cannot use any of the specified authentication methods (%s)", + str); + g_free (str); + dial_3gpp_context_complete_and_free (ctx); + return; + } + + quoted_user = mm_at_serial_port_quote_string (user); + quoted_password = mm_at_serial_port_quote_string (password); + command = g_strdup_printf ("$QCPDPP=%d,%u,%s,%s", ctx->cid, - password, - user); + sierra_auth, + quoted_password, + quoted_user); + g_free (quoted_user); + g_free (quoted_password); + } mm_base_modem_at_command_full (ctx->modem, ctx->primary, |