[PATCH] mbimcli: fix parsing --query-connection-state and --disconnect args after 4e58451
Dan Williams
dcbw at redhat.com
Wed Sep 9 10:12:32 PDT 2015
>From f6d10eb69eefeb190c9349fdbd3a23b0e838913e Mon Sep 17 00:00:00 2001
From: Dan Williams <dcbw at redhat.com>
Date: Wed, 9 Sep 2015 12:06:00 -0500
Subject: [PATCH] mbimcli: fix parsing --query-connection-state and
--disconnect args after 4e58451
Fixes: 4e58451a744dbc3f086e9c1dd2d7469ff70d50ef ("mbimcli: add support for Basic Connect session IDs")
Reported-by: David Ward
---
src/mbimcli/mbimcli-basic-connect.c | 34 ++++++++++++++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/src/mbimcli/mbimcli-basic-connect.c b/src/mbimcli/mbimcli-basic-connect.c
index 8fdff82..9b74677 100644
--- a/src/mbimcli/mbimcli-basic-connect.c
+++ b/src/mbimcli/mbimcli-basic-connect.c
@@ -67,6 +67,16 @@ static gchar *set_connect_activate_str;
static gchar *set_connect_deactivate_str;
static gboolean query_packet_statistics_flag;
+static gboolean query_connection_state_arg_parse (const char *option_name,
+ const char *value,
+ gpointer user_data,
+ GError **error);
+
+static gboolean disconnect_arg_parse (const char *option_name,
+ const char *value,
+ gpointer user_data,
+ GError **error);
+
static GOptionEntry entries[] = {
{ "query-device-caps", 0, 0, G_OPTION_ARG_NONE, &query_device_caps_flag,
"Query device capabilities",
@@ -148,7 +158,7 @@ static GOptionEntry entries[] = {
"Detach from the packet service",
NULL
},
- { "query-connection-state", 0, 0, G_OPTION_ARG_NONE, &query_connect_str,
+ { "query-connection-state", 0, G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, G_CALLBACK (query_connection_state_arg_parse),
"Query connection state (SessionID is optional, defaults to 0)",
"[SessionID]"
},
@@ -156,7 +166,7 @@ static GOptionEntry entries[] = {
"Connect (allowed keys: session-id, apn, auth (PAP|CHAP|MSCHAPV2), username, password)",
"[\"key=value,...\"]"
},
- { "disconnect", 0, 0, G_OPTION_ARG_STRING, &set_connect_deactivate_str,
+ { "disconnect", 0, G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, G_CALLBACK (disconnect_arg_parse),
"Disconnect (SessionID is optional, defaults to 0)",
"[SessionID]"
},
@@ -182,6 +192,26 @@ mbimcli_basic_connect_get_option_group (void)
return group;
}
+static gboolean
+query_connection_state_arg_parse (const char *option_name,
+ const char *value,
+ gpointer user_data,
+ GError **error)
+{
+ query_connect_str = g_strdup (value ? value : "0");
+ return TRUE;
+}
+
+static gboolean
+disconnect_arg_parse (const char *option_name,
+ const char *value,
+ gpointer user_data,
+ GError **error)
+{
+ set_connect_deactivate_str = g_strdup (value ? value : "0");
+ return TRUE;
+}
+
gboolean
mbimcli_basic_connect_options_enabled (void)
{
--
2.1.0
More information about the libmbim-devel
mailing list