diff options
Diffstat (limited to 'src/qmicli/qmicli-wds.c')
-rw-r--r-- | src/qmicli/qmicli-wds.c | 62 |
1 files changed, 62 insertions, 0 deletions
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; |