[PATCH v2] qmicli: add --wds-set-ip-family command

Aleksander Morgado aleksander at aleksander.es
Wed Apr 19 08:30:18 UTC 2017


On 18/04/17 23:22, Reinhard Speyerer wrote:
> Add qmicli --wds-set-ip-family command as suggested by Aleksander Morgado
> to enable proper dual stack support.
> 
> Signed-off-by: Reinhard Speyerer <rspmn at arcor.de>
> ---
> v2: shorten command description and fix set_ip_family_ready() indentation
> 

Pushed to git master, thanks.

>  src/qmicli/qmicli-completion |  4 +++
>  src/qmicli/qmicli-wds.c      | 62 ++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 66 insertions(+)
> 
> 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;
> 


-- 
Aleksander
https://aleksander.es


More information about the libqmi-devel mailing list