Commit Graph

987 Commits

Author SHA1 Message Date
Aleksander Morgado f64a5a06c8 qmicli: use G_SOURCE_CONTINUE to reset the unix signal handler 2016-11-30 11:22:02 +01:00
Aleksander Morgado 7b14d888e3 qmicli,helpers: fix uninitialized variables 2016-11-28 17:16:34 +01:00
Aleksander Morgado 99c36dc005 qmicli,helpers: more strict approach validating the unique id string
We don't want e.g. an array that has some printable ASCII bytes, then
NUL bytes and then some more printable ASCII bytes. We require a totally
valid ASCII string, suffixed with NUL bytes if the string is shorter
than 16 bytes.

Plus, we avoid g_str_is_ascii(), which is only available in GLib 2.40.0.
2016-11-28 15:12:46 +01:00
Aleksander Morgado 56d8b97684 qmicli,dms: firmware image unique id seems to be ASCII
But just in case leave the raw-hex printable string fallback if it isn't.
2016-11-28 14:55:11 +01:00
Aleksander Morgado 93e5025ca6 qmicli,dms: implement --dms-get-firmware-preference 2016-11-28 14:42:34 +01:00
Aleksander Morgado 39474a3f92 qmicli,dms: error if missing fields in --dms-set-firmware-preference 2016-11-28 14:42:12 +01:00
Aleksander Morgado 3d671dfd7f qmicli,dms: improve output when setting firmware preference 2016-11-28 14:42:02 +01:00
Aleksander Morgado 4231c03a38 qmicli,dms: plug memleaks when setting firmware preference
Not a big deal, because qmicli exits after the operation, but anyway.
2016-11-28 14:41:34 +01:00
Aleksander Morgado da8ff1ee7e build: require glib 2.36
We want to start using new GLib features like e.g. GTask, available in
GLib 2.36.
2016-11-28 14:40:53 +01:00
Aleksander Morgado 0c94e818c5 qmicli: use g_clear_object() to cleanup cancellable after async operation 2016-11-25 14:49:12 +01:00
Aleksander Morgado 793d5a5da8 qmicli: use g_unix_signal_add() to setup signals
So that we can safely call GLib/GIO functions from within the signal handlers.
2016-11-25 14:41:05 +01:00
Aleksander Morgado 6f4925848f qmicli: fix second ctrl+c handling in qmicli
A single ctrl+c cancels the GCancellable, and the second ctrl+c should
have stopped the GMainLoop, but that was never happening.
2016-11-25 14:18:56 +01:00
Aleksander Morgado 54f2dde462 qmicli,pdc: print ongoing messages instead of debug 2016-11-23 14:34:48 +01:00
Aleksander Morgado d41dec3ed1 qmicli,pdc: use correct identifier to print gsize
qmicli-pdc.c: In function 'load_config_input_create_chunk':
    qmicli-pdc.c:1022:14: error: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'gsize {aka unsigned int}' [-Werror=format=]
         g_debug ("Uploaded %lu of %lu\n", config_file->offset, full_size);
2016-11-23 14:33:21 +01:00
Aleksander Morgado 672b77127a qmicli: avoid converting to dB invalid SINR values
https://bugs.freedesktop.org/show_bug.cgi?id=92106
2016-11-17 10:59:33 +01:00
Aleksander Morgado cc50e92f19 build: set qmi-pdc.h as nodist 2016-10-31 16:23:50 +01:00
Aleksander Morgado 0148e81aa9 libqmi-glib,device: make sure transaction ids are unique
Otherwise, we may end up with transactions timing out and segfaulting as they
aren't found in the tracking table (e.g. if the replacing transaction finishes
before the timeout of the replaced transaction is fired off).

    ==573== Command: /usr/libexec/qmi-proxy --no-exit --verbose
    ==573== Parent PID: 567
    ==573==
    ==573== Invalid write of size 8
    ==573==    at 0x4E9A07A: transaction_timed_out (qmi-device.c:248)
    ==573==    by 0x5D24EB2: ??? (in /usr/lib/libglib-2.0.so.0.5000.1)
    ==573==    by 0x5D24439: g_main_context_dispatch (in /usr/lib/libglib-2.0.so.0.5000.1)
    ==573==    by 0x5D247EF: ??? (in /usr/lib/libglib-2.0.so.0.5000.1)
    ==573==    by 0x5D24B11: g_main_loop_run (in /usr/lib/libglib-2.0.so.0.5000.1)
    ==573==    by 0x40139D: main (qmi-proxy.c:220)
    ==573==  Address 0x10 is not stack'd, malloc'd or (recently) free'd
    ==573==
    ==573==
    ==573== Process terminating with default action of signal 11 (SIGSEGV): dumping core
    ==573==  Access not within mapped region at address 0x10
    ==573==    at 0x4E9A07A: transaction_timed_out (qmi-device.c:248)
    ==573==    by 0x5D24EB2: ??? (in /usr/lib/libglib-2.0.so.0.5000.1)
    ==573==    by 0x5D24439: g_main_context_dispatch (in /usr/lib/libglib-2.0.so.0.5000.1)
    ==573==    by 0x5D247EF: ??? (in /usr/lib/libglib-2.0.so.0.5000.1)
    ==573==    by 0x5D24B11: g_main_loop_run (in /usr/lib/libglib-2.0.so.0.5000.1)
    ==573==    by 0x40139D: main (qmi-proxy.c:220)
    ==573==  If you believe this happened as a result of a stack
    ==573==  overflow in your program's main thread (unlikely but
    ==573==  possible), you can try to increase the size of the
    ==573==  main thread stack using the --main-stacksize= flag.
    ==573==  The main thread stack size used in this run was 8388608.
2016-10-28 00:37:49 +02:00
Aleksander Morgado c1442b3a7f libqmi-glib,device: make sure transaction is removed from table on early errors 2016-10-27 23:02:47 +02:00
Aleksander Morgado b760b98a5d libqmi-glib,proxy: fix segfault when trying to use already disposed clients
If the client which originated the request exits (e.g. HUP received in its
 socket) before the actual response from the QmiDevice arrives, we'll end up
 trying to access the Client info (as kept in request->client) even if it has
 already been freed.

 Fix that, by making the Client a ref-counted object, and passing around full
 references of the Client where needed, e.g.:
   * In the async callbacks where Client is passed as data.
   * Inside each Request.

Doing this we make sure each operation has a totally valid Client until the
operation finishes, even if the client gets disconnected in between.

     ==311== Invalid read of size 8
     ==311==    at 0x4E9381C: track_cid (qmi-proxy.c:443)
     ==311==    by 0x4E93A45: device_command_ready (qmi-proxy.c:492)
     ==311==    by 0x52BEC18: g_simple_async_result_complete (gsimpleasyncresult.c:777)
     ==311==    by 0x52BEC4E: complete_in_idle_cb (gsimpleasyncresult.c:789)
     ==311==    by 0x583FA6D: g_idle_dispatch (gmain.c:5250)
     ==311==    by 0x583D47A: g_main_dispatch (gmain.c:3065)
     ==311==    by 0x583E237: g_main_context_dispatch (gmain.c:3641)
     ==311==    by 0x583E463: g_main_context_iterate (gmain.c:3712)
     ==311==    by 0x583E79C: g_main_loop_run (gmain.c:3906)
     ==311==    by 0x401411: main (qmi-proxy.c:220)
     ==311==  Address 0x87c7450 is 48 bytes inside a block of size 64 free'd
     ==311==    at 0x4C2A0C0: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
     ==311==    by 0x584519E: g_free (gmem.c:197)
     ==311==    by 0x585BBF6: g_slice_free1 (gslice.c:1124)
     ==311==    by 0x4E92CC5: client_free (qmi-proxy.c:149)
     ==311==    by 0x4E92DD4: connection_close (qmi-proxy.c:177)
     ==311==    by 0x4E93CFF: connection_readable_cb (qmi-proxy.c:586)
     ==311==    by 0x52C2A4D: socket_source_dispatch (gsocket.c:3264)
     ==311==    by 0x583D47A: g_main_dispatch (gmain.c:3065)
     ==311==    by 0x583E237: g_main_context_dispatch (gmain.c:3641)
     ==311==    by 0x583E463: g_main_context_iterate (gmain.c:3712)
     ==311==    by 0x583E79C: g_main_loop_run (gmain.c:3906)
     ==311==    by 0x401411: main (qmi-proxy.c:220)
     ==311==  Block was alloc'd at
     ==311==    at 0x4C2B3D0: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
     ==311==    by 0x584502D: g_malloc (gmem.c:104)
     ==311==    by 0x585B990: g_slice_alloc (gslice.c:1016)
     ==311==    by 0x585B9D4: g_slice_alloc0 (gslice.c:1042)
     ==311==    by 0x4E93FC5: incoming_cb (qmi-proxy.c:655)
     ==311==    by 0x60F2A4B: ffi_call_unix64 (unix64.S:75)
     ==311==    by 0x60F24B8: ffi_call (ffi64.c:492)
     ==311==    by 0x55BB773: g_cclosure_marshal_generic (gclosure.c:1454)
     ==311==    by 0x55BA093: g_closure_invoke (gclosure.c:777)
     ==311==    by 0x55D1B45: signal_emit_unlocked_R (gsignal.c:3586)
     ==311==    by 0x55D0F00: g_signal_emit_valist (gsignal.c:3340)
     ==311==    by 0x55D1383: g_signal_emit (gsignal.c:3386)

 and:

     ==9308== Invalid read of size 8
     ==9308==    at 0x4E93641: device_new_ready (qmi-proxy.c:348)
     ==9308==    by 0x52BEC18: g_simple_async_result_complete (gsimpleasyncresult.c:777)
     ==9308==    by 0x52BEC4E: complete_in_idle_cb (gsimpleasyncresult.c:789)
     ==9308==    by 0x583FA6D: g_idle_dispatch (gmain.c:5250)
     ==9308==    by 0x583D47A: g_main_dispatch (gmain.c:3065)
     ==9308==    by 0x583E237: g_main_context_dispatch (gmain.c:3641)
     ==9308==    by 0x583E463: g_main_context_iterate (gmain.c:3712)
     ==9308==    by 0x583E79C: g_main_loop_run (gmain.c:3906)
     ==9308==    by 0x401411: main (qmi-proxy.c:220)
     ==9308==  Address 0x8d04930 is 32 bytes inside a block of size 72 free'd
     ==9308==    at 0x4C2A0C0: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
     ==9308==    by 0x584519E: g_free (gmem.c:197)
     ==9308==    by 0x585BBF6: g_slice_free1 (gslice.c:1124)
     ==9308==    by 0x4E92EAB: client_free (qmi-proxy.c:159)
     ==9308==    by 0x4E92FBA: connection_close (qmi-proxy.c:187)
     ==9308==    by 0x4E93FC1: connection_readable_cb (qmi-proxy.c:626)
     ==9308==    by 0x52C2A4D: socket_source_dispatch (gsocket.c:3264)
     ==9308==    by 0x583D47A: g_main_dispatch (gmain.c:3065)
     ==9308==    by 0x583E237: g_main_context_dispatch (gmain.c:3641)
     ==9308==    by 0x583E463: g_main_context_iterate (gmain.c:3712)
     ==9308==    by 0x583E79C: g_main_loop_run (gmain.c:3906)
     ==9308==    by 0x401411: main (qmi-proxy.c:220)
     ==9308==  Block was alloc'd at
     ==9308==    at 0x4C2B3D0: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
     ==9308==    by 0x584502D: g_malloc (gmem.c:104)
     ==9308==    by 0x585B990: g_slice_alloc (gslice.c:1016)
     ==9308==    by 0x585B9D4: g_slice_alloc0 (gslice.c:1042)
     ==9308==    by 0x4E94287: incoming_cb (qmi-proxy.c:695)
     ==9308==    by 0x60F2A4B: ffi_call_unix64 (unix64.S:75)
     ==9308==    by 0x60F24B8: ffi_call (ffi64.c:492)
     ==9308==    by 0x55BB773: g_cclosure_marshal_generic (gclosure.c:1454)
     ==9308==    by 0x55BA093: g_closure_invoke (gclosure.c:777)
     ==9308==    by 0x55D1B45: signal_emit_unlocked_R (gsignal.c:3586)
     ==9308==    by 0x55D0F00: g_signal_emit_valist (gsignal.c:3340)
     ==9308==    by 0x55D1383: g_signal_emit (gsignal.c:3386)
2016-10-27 22:18:18 +02:00
Aleksander Morgado 5a370d0929 libqmi-glib,proxy: plug memleak on command error 2016-10-27 22:18:18 +02:00
Aleksander Morgado 5284d3e247 libqmi-glib,proxy: print error message on response forwarding error, and plug memleak 2016-10-27 22:18:18 +02:00
Aleksander Morgado 237d8c38ff libqmi-glib,proxy: print error message on proxy open response error, and plug memleak 2016-10-27 22:18:18 +02:00
Aleksander Morgado 13747cf3b0 libqmi-glib,proxy: print error message when indication cannot be forwarded 2016-10-27 22:18:18 +02:00
Aleksander Morgado 0c6d51f352 build: include PDC service enums in dist
https://bugs.freedesktop.org/show_bug.cgi?id=98459
2016-10-27 22:07:53 +02:00
Aliaksandr Barouski cd3a91ee2b pdc: minor fixes in qmicli logging 2016-10-26 14:59:43 +02:00
Aliaksandr Barouski 402c7af4da pdc: use NOT_PROVISIONED to detect 'no configs'
changed logic a bit to support situation when there is no config activated. In
this case indication generated with error NOT_PROVISIONED.
2016-10-26 14:59:43 +02:00
Aleksander Morgado 06fda6aadc pdc: 2s of timeout to wait for configs list
There won't be any indication if no configs are available.

Based on a patch from Aliaksandr Barouski <alex.borovsky@gmail.com>.
2016-10-26 14:59:43 +02:00
Aleksander Morgado c16265115f qmicli: minor fix in comment text 2016-10-26 14:59:43 +02:00
Aleksander Morgado 041ee874d5 qmicli,pdc: refactor coding style and fix invalid frees
Mostly coding style fixes, although the patch also fixes several allocation
issues when freeing GSlices.
2016-10-26 14:59:43 +02:00
Aleksander Morgado 38c24b2bdf qmicli: remove unused helpers 2016-10-26 14:59:43 +02:00
Aleksander Morgado cb0f12a10e qmicli: refactor qmicli_read_binary_array_from_string() helper
The original implementation actually had some bugs when freeing the output
array in error conditions. Also, use g_ascii_xdigit_value() instead of
custom conversions.
2016-10-26 14:59:43 +02:00
Aleksander Morgado d4d7252086 pdc: no need to CamelCase parameter names 2016-10-26 14:59:43 +02:00
Aliaksandr Barouski 24cdbd32e9 pdc: new PDC service implementation
Added calls for configure hp4120 LTE modem
2016-10-26 14:59:43 +02:00
Aleksander Morgado fa39dc14a6 dms: new 'Change Device Download Mode' command
Based on a patch from Aliaksandr Barouski <alex.borovsky@gmail.com>

https://bugs.freedesktop.org/show_bug.cgi?id=96465
2016-10-24 12:31:52 +02:00
Dan Williams c847091b17 qmicli/nas: add --nas-get-rf-band-info 2016-10-11 11:43:51 -05:00
Dan Williams 4d9899b418 wds: make WDS Extended Error Code TLV a common-ref 2016-10-06 10:12:04 -05:00
Dan Williams d13c26c07d wds: add more TLVs and ModifyProfile/DeleteProfile requests 2016-10-06 10:12:04 -05:00
Dan Williams 7de80b7cf7 wds: add more Profile-related TLVs 2016-10-06 10:12:04 -05:00
Dan Williams ffa1cf2447 wds: move common Profile-related TLVs to common-refs 2016-10-06 10:12:04 -05:00
Dan Williams d90fae4dba wds: add Go Dormant, Go Active, and Get Dormancy Status 2016-10-06 10:12:04 -05:00
Dan Williams dda73618bd wds: add Set Event Report and Event Report Indication 2016-10-06 10:12:04 -05:00
Dan Williams e2f9d3d591 qmi-codegen: allow fields to be hidden with 'visible':'no'
We want to mark some TLV fields as reserved and not exposed through the
public API due to alignment or other issues.
2016-10-06 10:12:04 -05:00
Dan Williams 4c678418f3 qmicli: fix handling of unspecified ip_type in --wds-start-network
QMI_WDS_IP_FAMILY_UNSPECIFIED = 8 but ip_type gets initialized to
0, so the "IP Family Preference" was always being sent with an
unrecognized value.

Fixes: 81c21379 qmicli: add support for IP type to --wds-start-networ
2016-10-05 10:49:43 -05:00
Dan Williams b7bd0ffc1f docs: add missing reference for 'WDS create profile' 2016-10-04 07:28:51 -05:00
Dan Williams 4d373376b6 qmi-device: assume reasonable DMS version if WDS is high enough
Some devices (Quectel EC21) lie about their supported DMS version,
so assume a reasonable DMS version if the WDS version is high enough.
2016-09-30 09:25:01 -05:00
Dan Williams 66de6130ab qmicli,dms: report offline reason for LOW_POWER mode too
If the device cannot exit low-power mode it sometimes reports a reason,
like pri-image-misconfiguration.
2016-09-26 16:42:10 -05:00
Dan Williams b90b182a2a wds: add CreateProfile 2016-09-23 17:02:00 -05:00
Dan Williams 687fc4dae3 dms: Get Band Capabilities supported on DMS 1.1
But only seems supported on GSM/UMTS firmware.  Tested on Novatel USB1000:

[07 Sep 2016, 10:43:19] [Debug] [/dev/cdc-wdm1] QMI Device supports 6 services:
[07 Sep 2016, 10:43:19] [Debug] [/dev/cdc-wdm1]    ctl (1.0)
[07 Sep 2016, 10:43:19] [Debug] [/dev/cdc-wdm1]    wds (1.1)
[07 Sep 2016, 10:43:19] [Debug] [/dev/cdc-wdm1]    dms (1.1)
[07 Sep 2016, 10:43:19] [Debug] [/dev/cdc-wdm1]    nas (1.0)
[07 Sep 2016, 10:43:19] [Debug] [/dev/cdc-wdm1]    wms (1.0)
[07 Sep 2016, 10:43:19] [Debug] [/dev/cdc-wdm1]    pds (1.0)
2016-09-07 11:11:07 -05:00
Dan Williams df98c06057 dms: Read ERI File supported on DMS 1.1
Need CDMA/EVDO firmware for it though.  Tested on Novatel USB1000:

[07 Sep 2016, 10:43:19] [Debug] [/dev/cdc-wdm1] QMI Device supports 6 services:
[07 Sep 2016, 10:43:19] [Debug] [/dev/cdc-wdm1]    ctl (1.0)
[07 Sep 2016, 10:43:19] [Debug] [/dev/cdc-wdm1]    wds (1.1)
[07 Sep 2016, 10:43:19] [Debug] [/dev/cdc-wdm1]    dms (1.1)
[07 Sep 2016, 10:43:19] [Debug] [/dev/cdc-wdm1]    nas (1.0)
[07 Sep 2016, 10:43:19] [Debug] [/dev/cdc-wdm1]    wms (1.0)
[07 Sep 2016, 10:43:19] [Debug] [/dev/cdc-wdm1]    pds (1.0)
2016-09-07 10:59:53 -05:00
Dan Williams 927f794d59 dms: User Lock State messages supported on DMS 1.1
Tested on Novatel USB1000:

[07 Sep 2016, 10:43:19] [Debug] [/dev/cdc-wdm1] QMI Device supports 6 services:
[07 Sep 2016, 10:43:19] [Debug] [/dev/cdc-wdm1]    ctl (1.0)
[07 Sep 2016, 10:43:19] [Debug] [/dev/cdc-wdm1]    wds (1.1)
[07 Sep 2016, 10:43:19] [Debug] [/dev/cdc-wdm1]    dms (1.1)
[07 Sep 2016, 10:43:19] [Debug] [/dev/cdc-wdm1]    nas (1.0)
[07 Sep 2016, 10:43:19] [Debug] [/dev/cdc-wdm1]    wms (1.0)
[07 Sep 2016, 10:43:19] [Debug] [/dev/cdc-wdm1]    pds (1.0)
2016-09-07 10:58:17 -05:00