[PATCH] add device-open-net cmdline option
Aleksander Morgado
aleksander at lanedo.com
Fri Dec 13 00:21:19 PST 2013
Hey Tim!
On 12/12/13 19:40, Tim Harvey wrote:
> The device-open-net cmdline option allows you to specify network-mode
> and qos-header mode flags when opening the device.
>
> This has been found to be necessary on some cards/modes such as the MC7750
> in LTE mode.
>
> I lack the propper hardware/signal to test this properly - review/testing
> needed.
>
> Signed-off-by: Tim Harvey <tharvey at gateworks.com>
> ---
It looked quite good, but ended up modifying the patch to take a slight
different approach, which is to parse the input string based on the
actual nicknames of the QmiDeviceOpenFlags enum type, as done with other
flag mask values passed in qmicli (even if only 4 flag values are
expected, but anyway, for consistency). I actually had to add type
generation for that flag and also for QmiDeviceReleaseClientFlags, which
where missing in libqmi-glib and was a bug on itself.
Also, the set of flags passed needs to be separated with "|", not with a
comma, as done for other sets of flags around, so all these are now valid:
--device-open-net="net-802-3|net-qos-header"
--device-open-net="net-802-3|net-no-qos-header"
--device-open-net="net-qos-header|net-802-3"
--device-open-net="net-no-qos-header|net-802-3"
... and so on
Changes are all in git master now.
Thanks for the good start! :)
> src/qmicli/qmicli.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 44 insertions(+)
>
> diff --git a/src/qmicli/qmicli.c b/src/qmicli/qmicli.c
> index dc63c41..d2b202e 100644
> --- a/src/qmicli/qmicli.c
> +++ b/src/qmicli/qmicli.c
> @@ -50,6 +50,7 @@ static gboolean get_service_version_info_flag;
> static gchar *device_set_instance_id_str;
> static gboolean device_open_version_info_flag;
> static gboolean device_open_sync_flag;
> +static gchar *device_open_net_str;
> static gboolean device_open_proxy_flag;
> static gchar *client_cid_str;
> static gboolean client_no_release_cid_flag;
> @@ -82,6 +83,10 @@ static GOptionEntry main_entries[] = {
> "Request to use the 'qmi-proxy' proxy",
> NULL
> },
> + { "device-open-net", 0, 0, G_OPTION_ARG_STRING, &device_open_net_str,
> + "Open device with specific net mode and qos flags <net-mode>,<net-flags>",
> + NULL
> + },
> { "client-cid", 0, 0, G_OPTION_ARG_STRING, &client_cid_str,
> "Use the given CID, don't allocate a new one",
> "[CID]"
> @@ -467,6 +472,45 @@ device_new_ready (GObject *unused,
> QmiDeviceOpenFlags open_flags = QMI_DEVICE_OPEN_FLAGS_NONE;
> GError *error = NULL;
>
> + if (device_open_net_str) {
> + gchar **split;
> +
> + /* Format of the string is:
> + * "(net-mode),(qos-header-mode)"
> + */
> + split = g_strsplit (device_open_net_str, ",", -1);
> + if (g_str_equal (split[0], "net-802-3")) {
> + open_flags |= QMI_DEVICE_OPEN_FLAGS_NET_802_3;
> + }
> +
> + else if (g_str_equal (split[0], "net-raw-ip")) {
> + open_flags |= QMI_DEVICE_OPEN_FLAGS_NET_RAW_IP;
> + }
> +
> + else {
> + g_printerr ("error: net-mode: expected 'net-802-3'"
> + " or 'net-raw-ip'\n");
> + }
> +
> + if (g_str_equal (split[1], "net-no-qos-header")) {
> + open_flags |= QMI_DEVICE_OPEN_FLAGS_NET_NO_QOS_HEADER;
> + }
> +
> + else if (g_str_equal (split[1], "net-qos-header")) {
> + open_flags |= QMI_DEVICE_OPEN_FLAGS_NET_QOS_HEADER;
> + }
> +
> + else {
> + g_printerr ("error: expected 'net-qos-header'"
> + " or 'net-no-qos-header'\n");
> + }
> + if (!split[0] || split[0][0] == '\0') {
> + g_printerr ("error: expected '', got: none\n");
> + }
> +
> + g_strfreev (split);
> + }
> +
> device = qmi_device_new_finish (res, &error);
> if (!device) {
> g_printerr ("error: couldn't create QmiDevice: %s\n",
>
--
Aleksander
More information about the libqmi-devel
mailing list