aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorReinhard Speyerer <rspmn@arcor.de>2017-04-18 23:22:35 +0200
committerAleksander Morgado <aleksander@aleksander.es>2017-04-19 10:28:02 +0200
commitd1b5a4971cea6fbcdc7ac7c3606f630314564072 (patch)
tree3b5c1006e4a95428ba10781b749ae860979cd22d /src
parentbf387a823c2579462a16bec599b3ae86d8ed3b87 (diff)
downloadexternal_libqmi-d1b5a4971cea6fbcdc7ac7c3606f630314564072.zip
external_libqmi-d1b5a4971cea6fbcdc7ac7c3606f630314564072.tar.gz
external_libqmi-d1b5a4971cea6fbcdc7ac7c3606f630314564072.tar.bz2
qmicli: add --wds-set-ip-family command
Add qmicli --wds-set-ip-family command as suggested by Aleksander Morgado to enable proper dual stack support. Signed-off-by: Reinhard Speyerer <rspmn@arcor.de>
Diffstat (limited to 'src')
-rw-r--r--src/qmicli/qmicli-completion4
-rw-r--r--src/qmicli/qmicli-wds.c62
2 files changed, 66 insertions, 0 deletions
diff --git a/src/qmicli/qmicli-completion b/src/qmicli/qmicli-completion
index 1a1b4b5..fa75668 100644
--- a/src/qmicli/qmicli-completion
+++ b/src/qmicli/qmicli-completion
@@ -118,6 +118,10 @@ _qmicli()
COMPREPLY=( $(compgen -W "[(MuxId),(Ep-Iface-Number)]" -- $cur) )
return 0
;;
+ '--wds-set-ip-family')
+ COMPREPLY=( $(compgen -W "[4|6]" -- $cur) )
+ return 0
+ ;;
'--uim-read-transparent')
COMPREPLY=( $(compgen -W "[0xNNNN,0xNNNN,...]" -- $cur) )
return 0
diff --git a/src/qmicli/qmicli-wds.c b/src/qmicli/qmicli-wds.c
index fcc5b49..c4744af 100644
--- a/src/qmicli/qmicli-wds.c
+++ b/src/qmicli/qmicli-wds.c
@@ -72,6 +72,7 @@ static gboolean get_supported_messages_flag;
static gboolean reset_flag;
static gboolean noop_flag;
static gchar *bind_mux_str;
+static gchar *set_ip_family_str;
static GOptionEntry entries[] = {
{ "wds-start-network", 0, 0, G_OPTION_ARG_STRING, &start_network_str,
@@ -146,6 +147,10 @@ static GOptionEntry entries[] = {
"Bind qmux data port to controller device (allowed keys: mux-id, ep-iface-number) to be used with `--client-no-release-cid'",
"[\"key=value,...\"]"
},
+ { "wds-set-ip-family", 0, 0, G_OPTION_ARG_STRING, &set_ip_family_str,
+ "Set IP family",
+ "[4|6]"
+ },
{ "wds-noop", 0, 0, G_OPTION_ARG_NONE, &noop_flag,
"Just allocate or release a WDS client. Use with `--client-no-release-cid' and/or `--client-cid'",
NULL
@@ -180,6 +185,7 @@ qmicli_wds_options_enabled (void)
n_actions = (!!start_network_str +
!!stop_network_str +
!!bind_mux_str +
+ !!set_ip_family_str +
get_current_settings_flag +
get_packet_service_status_flag +
get_packet_statistics_flag +
@@ -1687,6 +1693,33 @@ bind_mux_data_port_ready (QmiClientWds *client,
operation_shutdown (TRUE);
}
+static void
+set_ip_family_ready (QmiClientWds *client,
+ GAsyncResult *res)
+{
+ QmiMessageWdsSetIpFamilyOutput *output;
+ GError *error = NULL;
+
+ output = qmi_client_wds_set_ip_family_finish (client, res, &error);
+ if (!output) {
+ g_printerr ("error: operation failed: %s\n", error->message);
+ g_error_free (error);
+ operation_shutdown (FALSE);
+ return;
+ }
+
+ if (!qmi_message_wds_set_ip_family_output_get_result (output, &error)) {
+ g_printerr ("error: couldn't set IP family: %s\n", error->message);
+ g_error_free (error);
+ qmi_message_wds_set_ip_family_output_unref (output);
+ operation_shutdown (FALSE);
+ return;
+ }
+
+ qmi_message_wds_set_ip_family_output_unref (output);
+ operation_shutdown (TRUE);
+}
+
void
qmicli_wds_run (QmiDevice *device,
QmiClientWds *client,
@@ -1762,6 +1795,35 @@ qmicli_wds_run (QmiDevice *device,
return;
}
+ /* Request to set IP family? */
+ if (set_ip_family_str) {
+ QmiMessageWdsSetIpFamilyInput *input;
+
+ input = qmi_message_wds_set_ip_family_input_new ();
+ switch (atoi (set_ip_family_str)) {
+ case 4:
+ qmi_message_wds_set_ip_family_input_set_preference (input, QMI_WDS_IP_FAMILY_IPV4, NULL);
+ break;
+ case 6:
+ qmi_message_wds_set_ip_family_input_set_preference (input, QMI_WDS_IP_FAMILY_IPV6, NULL);
+ break;
+ default:
+ g_printerr ("error: unknown IP type '%s' (not 4 or 6)\n",
+ set_ip_family_str);
+ operation_shutdown (FALSE);
+ return;
+ }
+ g_debug ("Asynchronously set IP family...");
+ qmi_client_wds_set_ip_family (client,
+ input,
+ 10,
+ ctx->cancellable,
+ (GAsyncReadyCallback) set_ip_family_ready,
+ NULL);
+ qmi_message_wds_set_ip_family_input_unref (input);
+ return;
+ }
+
/* Request to get current settings? */
if (get_current_settings_flag) {
QmiMessageWdsGetCurrentSettingsInput *input;