diff options
author | André Valentin <avalentin@marcant.net> | 2013-01-09 12:14:23 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2013-01-09 12:14:23 +0100 |
commit | d4057ebd8b0202a15ed6e020633fcda0892a1d78 (patch) | |
tree | be888077d952e59847ddb5850ae93380333ce799 | |
parent | e380940cc43d073568bf22feb69738ff8473b591 (diff) |
cli: allow specifying auth info in the start network command
-rw-r--r-- | cli/qmicli-wds.c | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/cli/qmicli-wds.c b/cli/qmicli-wds.c index 4f0e897..07541b4 100644 --- a/cli/qmicli-wds.c +++ b/cli/qmicli-wds.c @@ -57,8 +57,8 @@ static gboolean noop_flag; static GOptionEntry entries[] = { { "wds-start-network", 0, 0, G_OPTION_ARG_STRING, &start_network_str, - "Start network", - "[APN]" + "Start network (Authentication, Username and Password are optional)", + "[(APN),(PAP|CHAP|BOTH),(Username),(Password)]" }, { "wds-follow-network", 0, 0, G_OPTION_ARG_NONE, &follow_network_flag, "Follow the network status until disconnected. Use with `--wds-start-network'", @@ -596,8 +596,40 @@ qmicli_wds_run (QmiDevice *device, /* Use the input string as APN */ if (start_network_str[0]) { + gchar **split; + + split = g_strsplit (start_network_str, ",", 0); + input = qmi_message_wds_start_network_input_new (); - qmi_message_wds_start_network_input_set_apn (input, start_network_str, NULL); + qmi_message_wds_start_network_input_set_apn (input, split[0], NULL); + + if (split[1]) { + QmiWdsAuthentication qmiwdsauth; + + /* Use authentication method */ + if (g_ascii_strcasecmp (split[1], "PAP") == 0) { + qmiwdsauth = QMI_WDS_AUTHENTICATION_PAP; + } else if (g_ascii_strcasecmp (split[1], "CHAP") == 0) { + qmiwdsauth = QMI_WDS_AUTHENTICATION_CHAP; + } else if (g_ascii_strcasecmp (split[1], "BOTH") == 0) { + qmiwdsauth = (QMI_WDS_AUTHENTICATION_PAP | QMI_WDS_AUTHENTICATION_CHAP); + } else { + qmiwdsauth = QMI_WDS_AUTHENTICATION_NONE; + } + + qmi_message_wds_start_network_input_set_authentication_preference (input, qmiwdsauth, NULL); + + /* Username */ + if (split[2] && strlen (split[2])) { + qmi_message_wds_start_network_input_set_username (input, split[2], NULL); + + /* Password */ + if (split[3] && strlen (split[3])) { + qmi_message_wds_start_network_input_set_password (input, split[3], NULL); + } + } + } + g_strfreev (split); } g_debug ("Asynchronously starting network..."); |