Commit Graph

137 Commits

Author SHA1 Message Date
Aleksander Morgado
5d176a1e61 base-modem: explicitly say if NET or TTY data ports are supported
A modem that creates exclusively bearer objects that work with NET
ports (e.g. all QMI or MBIM modems) must not add any TTY port in the
list of data ports.

A modem that creates exclusively bearer objects that work with TTY
ports (e.g. the generic modem) must not add any NET port in the
list of data ports.

A modem that may use both TTY and NET ports should add all in the list
of data ports.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/324
Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/329
2021-03-04 18:03:28 +01:00
Aleksander Morgado
1b35d74c15 kernel-device: add get_interface_number() method
We already have methods to query for interface specific attributes
like class/subclass/protocol, so add a new one for the interface
number, and make sure we use ATTRS{bInterfaceNumber} to load it
always, instead of assuming the ID_USB_INTERFACE_NUM property is set.
2021-02-24 20:47:57 +01:00
Aleksander Morgado
5d150ed23e core,plugins: consolidate connection/disconnection timeout values
Each different plugin or protocol had a different connection attempt
value. E.g. QMI and MBIM both used 60s max for the connection attempt,
while the u-blox plugin had up to 180s for ECM based connection
setups.

This commit consolidates all plugins and protocols to use the same
timeout values for commands that may take long to respond, e.g. a
connection atempt under low signal quality conditions.

A value of 180s for the connection attempt steps and 120s for a
disconnection attempt step is considered. Note, though, that in some
cases (like a IPv4v6 setup attempt using QMI) we may have more than
one such long step, so this doesn't mean that a connection attempt
will always take less than 180s.

Users of the connection/disconnection APIs should be able to handle
the case where the attempt times out in their side (e.g. with a lower
DBus request timeout), and which would not mean the actual request
they did really failed. E.g. a connection attempt with a DBus timeout
of 30s may fail in the user with a timeout error, but the attempt
would still go on for as much as the plugin/protocol needs.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/270
2020-11-14 09:41:43 +00:00
Giacinto Cifelli
4d58278d7f changed default authentication algorithm to CHAP
CHAP is almost universal nowadays, and so it is a better default
than PAP

Not changed for uBlox, that prefers an error if not specified,
and for Huawei, which uses NONE with user/pwd and has 2 CHAP choices
2020-07-24 16:34:40 +02:00
Aleksander Morgado
8722215f7e plugins: use logging module name as plugin name 2020-04-08 17:53:42 +02:00
Aleksander Morgado
662f8afc56 option,hso: port to use object logging 2020-04-08 16:35:09 +02:00
Aleksander Morgado
0f708daf0b modem-helpers: port supported modes filtering to use object logging 2020-04-08 16:35:09 +02:00
Aleksander Morgado
00dc961cad iface-modem-location: common helper code to test raw gps 2020-02-07 14:42:16 +00:00
Aleksander Morgado
accd1a5841 base-modem: define new helper MMBaseModemAtCommandAlloc
It has the same exact format as MMBaseModemAtCommand, but its contents
are assumed heap allocated.

The only real purpose of this type is to allow defining static
constant MMBaseModemAtCommand variables without warnings when using
-Wdiscarded-qualifiers.
2020-01-31 15:18:35 +01:00
Aleksander Morgado
68f3eeeaa7 option,hso: fix warnings with -Wsign-compare
option/mm-broadband-bearer-hso.c: In function ‘ip_config_ready’:
  option/mm-broadband-bearer-hso.c:128:21: error: comparison of integer expressions of different signedness: ‘gint’ {aka ‘int’} and ‘guint’ {aka ‘unsigned int’} [-Werror=sign-compare]
    128 |                 num != ctx->cid) {
        |                     ^~
2020-01-31 15:18:35 +01:00
Aleksander Morgado
bbeabb495e helpers: new macro to CLAMP high threshold only
Useful when clamping a unsigned integer with low threshold set to 0,
which would give us compiler warnings with -Wtype-limits when using
CLAMP(), e.g.:

  via/mm-broadband-modem-via.c: In function ‘handle_evdo_quality_change’:
  /usr/include/glib-2.0/glib/gmacros.h:811:63: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
    811 | #define CLAMP(x, low, high)  (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
        |                                                               ^
  via/mm-broadband-modem-via.c:284:19: note: in expansion of macro ‘CLAMP’
    284 |         quality = CLAMP (quality, 0, 100);
        |                   ^~~~~
2020-01-31 15:18:35 +01:00
Aleksander Morgado
92cc41e060 option: fix warnings with -Wimplicit-fallthrough
option/mm-broadband-modem-option.c: In function ‘load_access_technologies_step’:
  option/mm-broadband-modem-option.c:565:18: error: this statement may fall through [-Werror=implicit-fallthrough=]
    565 |         ctx->step++;
        |         ~~~~~~~~~^~
  option/mm-broadband-modem-option.c:567:5: note: here
    567 |     case ACCESS_TECHNOLOGIES_STEP_OSSYS:
        |     ^~~~
  option/mm-broadband-modem-option.c:587:18: error: this statement may fall through [-Werror=implicit-fallthrough=]
    587 |         ctx->step++;
        |         ~~~~~~~~~^~
  option/mm-broadband-modem-option.c:589:5: note: here
    589 |     case ACCESS_TECHNOLOGIES_STEP_OWCTI:
        |     ^~~~
  option/mm-broadband-modem-option.c:600:18: error: this statement may fall through [-Werror=implicit-fallthrough=]
    600 |         ctx->step++;
        |         ~~~~~~~~~^~
  option/mm-broadband-modem-option.c:602:5: note: here
    602 |     case ACCESS_TECHNOLOGIES_STEP_LAST:
        |     ^~~~
2020-01-31 14:52:50 +01:00
Aleksander Morgado
cff9d4a797 option: fix warnings with -Wdiscarded-qualifiers
option/mm-broadband-modem-option.c:978:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
    978 |     { "_OSSYS=1",  3, FALSE, NULL },
        |       ^~~~~~~~~~
  option/mm-broadband-modem-option.c:979:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
    979 |     { "_OCTI=1",   3, FALSE, NULL },
        |       ^~~~~~~~~
  option/mm-broadband-modem-option.c:980:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
    980 |     { "_OUWCTI=1", 3, FALSE, NULL },
        |       ^~~~~~~~~~~
  option/mm-broadband-modem-option.c:981:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
    981 |     { "_OSQI=1",   3, FALSE, NULL },
        |       ^~~~~~~~~
  option/mm-broadband-modem-option.c:1033:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   1033 |     { "_OSSYS=0",  3, FALSE, NULL },
        |       ^~~~~~~~~~
  option/mm-broadband-modem-option.c:1034:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   1034 |     { "_OCTI=0",   3, FALSE, NULL },
        |       ^~~~~~~~~
  option/mm-broadband-modem-option.c:1035:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   1035 |     { "_OUWCTI=0", 3, FALSE, NULL },
        |       ^~~~~~~~~~~
  option/mm-broadband-modem-option.c:1036:7: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
   1036 |     { "_OSQI=0",   3, FALSE, NULL },
        |       ^~~~~~~~~
2020-01-31 14:52:50 +01:00
Aleksander Morgado
2fd6d401f5 option: fix warnings with -Wswitch-default 2020-01-31 14:52:49 +01:00
Aleksander Morgado
2d779b97c4 option: setup as loadable 'shared' utils 2019-11-27 10:11:43 +00:00
Aleksander Morgado
09d563fd34 hso: make report_connection_status() a separate logical block
This block is a subclassed method from MMBaseBearer, which we just
happen to also use as part of the 3GPP dial logic in the connection
attempt.

So make it a separate logical block, and call the processing of the
connection attempt if one is found.

This change makes it similar to the same logic in the Icera plugin.
2017-12-05 10:55:41 +01:00
Aleksander Morgado
b6e3cb463d hso: use a 60s timeout to wait for connection unsolicited messages
Same amount of time as in the Icera plugin.
2017-12-05 10:55:41 +01:00
Aleksander Morgado
90116bf1be hso: port dial_3gpp() to GTask 2017-12-05 10:55:41 +01:00
Ben Chan
795ecad0e6 hso: port disconnect_3gpp to use GTask 2017-09-20 09:30:27 -07:00
Ben Chan
ee80e1f660 hso: port get_ip_config_3gpp to use GTask 2017-09-20 09:30:27 -07:00
Ben Chan
8bae1a785a hso: port {enable,disable}_location_gathering to use GTask 2017-09-20 09:30:27 -07:00
Ben Chan
227eae3f31 hso: port location_load_capabilities to use GTask 2017-09-20 09:30:27 -07:00
Ben Chan
616cfa9959 hso: port modem_3gpp_{setup,cleanup}_unsolicited_events to use GTask 2017-09-20 09:30:27 -07:00
Ben Chan
0131f9b006 hso: port modem_create_bearer to use GTask 2017-09-20 09:30:27 -07:00
Ben Chan
d23dd2343a hso: port load_unlock_retries to use GTask 2017-09-20 09:30:27 -07:00
Ben Chan
a62d34c35a hso: port hso_custom_init to use GTask 2017-09-20 09:30:27 -07:00
Aleksander Morgado
bb5cd9b4e2 option: remove unneeded explicit casts 2017-09-18 21:23:05 -07:00
Ben Chan
5ffc3b7a92 option: port modem_3gpp_disable_unsolicited_events to use GTask 2017-09-18 20:25:28 -07:00
Ben Chan
cb23ba7cba option: port modem_3gpp_enable_unsolicited_events to use GTask 2017-09-18 20:25:28 -07:00
Ben Chan
3fdfe5e3ab option: port modem_3gpp_{setup,cleanup}_unsolicited_events to use GTask 2017-09-18 20:25:28 -07:00
Ben Chan
7546b95122 option: port modem_after_power_up to use GTask 2017-09-18 20:25:28 -07:00
Ben Chan
6ad9ccbfa2 option: port set_current_modes to use GTask 2017-09-18 20:25:28 -07:00
Ben Chan
78432e7910 option: port load_access_technologies to use GTask 2017-09-18 20:25:28 -07:00
Ben Chan
0c726981ca option: port load_supported_modes to use GTask 2017-09-18 20:25:28 -07:00
Aleksander Morgado
a29610f25d plugin,port-probe: always cast SEND_DELAY value to guint64
Program received signal SIGSEGV, Segmentation fault.
    strchr () at ../sysdeps/arm/armv6/strchr.S:28
    28    ../sysdeps/arm/armv6/strchr.S: No such file or directory.
    (gdb) bt
    #0  strchr () at ../sysdeps/arm/armv6/strchr.S:28
    #1  0x76b121c8 in g_param_spec_pool_lookup () from ~/buildroot/output/staging/lib/libgobject-2.0.so.0
    #2  0x76b0cf44 in g_object_new_valist () from ~/buildroot/output/staging/lib/libgobject-2.0.so.0
    #3  0x76b0d39c in g_object_new () from ~/buildroot/output/staging/lib/libgobject-2.0.so.0
    #4  0x75f75e40 in mm_plugin_create () at ublox/mm-plugin-ublox.c:99
    #5  0x00031550 in load_plugin (path=0xe9b68 "/usr/lib/ModemManager/libmm-plugin-ublox.so") at mm-plugin-manager.c:1521
    #6  load_plugins (error=0x7efffa68, self=0xdc4f0) at mm-plugin-manager.c:1574
    #7  initable_init (initable=<optimized out>, cancellable=<optimized out>, error=0x7efffa68) at mm-plugin-manager.c:1679
    #8  0x76b9b278 in g_initable_new_valist () from ~/buildroot/output/staging/lib/libgio-2.0.so.0
    #9  0x76b9b2e0 in g_initable_new () from ~/buildroot/output/staging/lib/libgio-2.0.so.0
    #10 0x000324d0 in mm_plugin_manager_new (plugin_dir=0xe9c40 "/usr/lib/ModemManager", error=error@entry=0x7efffa68) at mm-plugin-manager.c:1620
    #11 0x0002da08 in initable_init (initable=0xddb40, cancellable=<optimized out>, error=0x7efffa68) at mm-base-manager.c:1113
    #12 0x76b9b278 in g_initable_new_valist () from ~/buildroot/output/staging/lib/libgio-2.0.so.0
    #13 0x76b9b2e0 in g_initable_new () from ~/buildroot/output/staging/lib/libgio-2.0.so.0
    #14 0x0002e81c in mm_base_manager_new (connection=connection@entry=0xe1070, plugin_dir=plugin_dir@entry=0x9efb0 "/usr/lib/ModemManager",
        auto_scan=auto_scan@entry=1, initial_kernel_events=initial_kernel_events@entry=0x0, enable_test=0, error=0x7efffa68, error@entry=0x7efffa60)
        at mm-base-manager.c:957
    #15 0x0002b6ec in bus_acquired_cb (connection=0xe1070, name=<optimized out>, user_data=<optimized out>) at main.c:87
    #16 0x76c26864 in connection_get_cb () from ~/buildroot/output/staging/lib/libgio-2.0.so.0
    #17 0x76bc76cc in g_task_return_now () from ~/buildroot/output/staging/lib/libgio-2.0.so.0
    #18 0x76bc7d50 in g_task_return () from
    ~/buildroot/output/staging/lib/libgio-2.0.so.0

See similar bug in GStreamer:
https://bugzilla.gnome.org/show_bug.cgi?id=740191
2017-09-05 20:16:18 +02:00
Aleksander Morgado
a3c980c78b option,hso: fix async completion in 3gpp event handlers setting 2017-07-17 10:20:17 +02:00
Aleksander Morgado
f3a301db3c option: fix async completion in 3gpp event handlers setting 2017-07-17 10:20:17 +02:00
Aleksander Morgado
2eb55d3224 plugins: use G_N_ELEMENTS when iterating ports array 2017-05-30 17:28:23 +02:00
Aleksander Morgado
fcd4a8c5dc altair,hso,samsung: setup send-delay=0 for probing
The Altair, Option HSO and Samsung plugins all use the send-delay=0
setting once the modem object has been created. For consistency, use
the same setting during port probing.
2017-05-30 17:18:32 +02:00
Ben Chan
254f2e3412 plugins: remove explicit GDestroyNotify cast on g_free / g_object_unref
g_free and g_object_unref are in form of  `void (*)(gpointer)`, which
matches the GDestroyNotify signature. An explicit GDestroyNotify cast on
g_free and g_object_unref is thus not needed.
2017-03-29 10:22:18 +02:00
Aleksander Morgado
820ab01ddf kernel-device: ID_USB_INTERFACE_NUM should be read as an hex string
The original g_udev_device_get_property_as_int() uses strtol() without
an explicit base (i.e. 0) so that the base is autodetected from the
string whenever possible (e.g. if prefixes with '0x' it is treated as a
hexadecimal string).

But, for ID_USB_INTERFACE_NUM, we explicitly require reading the number
as an hex string, even if we don't have any '0x' prefix.

Reported-by: Matthew Stanger <stangerm2@gmail.com>
2016-11-07 19:41:05 +01:00
Aleksander Morgado
37bd614212 broadband-modem: implement default connection monitoring logic
A default implementation to monitor the ongoing connection is provided in the
generic MMBroadbandModem, based on AT+CGACT? to check whether the PDP context
of the connection (identified by the cached cid) is active or not.

This commit also disables the connection monitoring logic in those plugins that
have custom connection methods.
2016-10-12 11:29:52 +02:00
Aleksander Morgado
ae9ede926a core: use the kernel device object in the port object and the plugin interface
The mm_base_modem_grab_port() now receives a MMKernelDevice directly from the
plugin, which is then stored in the MMPort corresponding to the port.

This means that we have direct access to e.g. all properties set by udev rules
everywhere, and we don't need additional GUdevClient objects (e.g. like the one
used in the Huawei plugin to detect NDISDUP support during runtime).

For virtual ports (e.g. generated during unit tests), we have a new 'generic'
kernel device object which just provides the values from the kernel device
properties given during its creation.
2016-09-29 15:43:05 +02:00
Aleksander Morgado
aa4577dfb9 core: new kernel device object instead of an explicit GUdevDevice
Instead of relying constantly on GUdevDevice objects reported by GUdev, we now
use a new generic object (MMKernelDevice) for which we provide an initial GUdev
based backend.
2016-09-29 15:43:05 +02:00
Aleksander Morgado
1f813c4e96 core: allow identifying devices by a user-provided 'uid'
All ports of the same modem reported by the kernel will all be associated with
a common 'uid' (unique id), which uniquely identifies the physical device. This
logic was already in place, what we do now is avoid calling it  the 'sysfs
path' of the physical device, because we may not want to use that to identify
a device.

This logic now also enables the possibility of "naming" the modems in a unique
way by setting the "ID_MM_PHYSDEV_UID" property in the "usb_device" that owns
all the ports.

E.g. a custom device has 4 modems in 4 different USB ports. The device path of
each USB device will always be the same, so the naming rules could go like this:

    $ vim /usr/lib/udev/rules.d/78-mm-naming.rules

    ACTION!="add|change|move", GOTO="mm_naming_rules_end"
    DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.1", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-1"
    DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.2", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-2"
    DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.3", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-3"
    DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.5/4-1.5.4", ENV{ID_MM_PHYSDEV_UID}="USB-MODEM-4"
    LABEL="mm_naming_rules_end"

Each of the modems found will have a unique UID retrieved from the previous list
of rules. Then, "mmcli" has also been updated to allow using the UID instead of
the modem DBus path or index, e.g.:

    $ sudo mmcli -m USB-MODEM-1
    /org/freedesktop/ModemManager1/Modem/0 (device id '988d83252c0598f670c2d69d5f41e077204a92fd')
      -------------------------
      Hardware |   manufacturer: 'ZTE CORPORATION'
               |          model: 'MF637'
               |       revision: 'BD_W7P673A3F3V1.0.0B04'
               |      supported: 'gsm-umts'
               |        current: 'gsm-umts'
               |   equipment id: '356516027657837'
      -------------------------
      System   |         device: 'USB-MODEM-1'
               |        drivers: 'option'
               |         plugin: 'ZTE'
               |   primary port: 'ttyUSB5'
               |          ports: 'ttyUSB5 (at)'
    ...

    $ sudo mmcli -m USB-MODEM-1 --enable
    ...
2016-09-29 15:41:21 +02:00
Ting-Yuan Huang
969189d42c plugin-manager: protect mm_plugin_{major,minor}_version
This patch makes declarations bind to definitions within the same module
to prevent the potential ambiguity if referenced directly.

AddressSanitizer think they violated one definition rule, although
those symbols are accessed by address through their modules and do
not depend on the order of the libararies loaded.
2016-05-28 13:59:54 +02:00
Aleksander Morgado
ffde429843 core: use G_SOURCE_REMOVE and G_SOURCE_CONTINUE in GSourceFuncs 2015-12-02 17:07:39 +01:00
Aleksander Morgado
3ca267b01f bearer: rename 'MMBearer' to 'MMBaseBearer'
Just so that we don't have same header names in src/ and /libmm-glib.
2014-07-06 16:55:29 +02:00
Aleksander Morgado
054c77224d option,hso: add missing GPS unamanged capability 2014-07-04 09:52:19 +02:00
Aleksander Morgado
40cdf3bac4 option,hso: print port type before parsing 2014-07-02 12:28:56 +02:00