Commit Graph

18 Commits

Author SHA1 Message Date
Aleksander Morgado
74fc5baca2 core: port GRegex/GMatchInfo to use autoptr()
The behavior of GRegex changed in 2.73.2 once it was ported from pcre1
to pcre2. In some cases it was made more strict, which is fine, in
other cases it exposed some change in how it behaves on certain
matches that is not extremely clear whether it's ok or not.

See https://gitlab.gnome.org/GNOME/glib/-/issues/2729
See https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/601
See https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/621

Either way, one thing that was assumed was that initializing all
GRegex/GMatchInfo variables to NULL and making sure they're NULL
before they're initialized by glib (especially the GMatchInfo) was a
good and safer approach.

So, whenever possible, g_autoptr() is used to cleanup the allocated
GMatchInfo/GRegex variables, and otherwise, g_clear_pointer() is used
to ensure that no free/unref is attempted unless the given variable is
not NULL, and also so that the variable is reseted to NULL after being
disposed.
2022-09-05 17:33:11 +00:00
Daniele Palmas
473c41dc63 plugins: add MM_PLUGIN_REQUIRED_QCDM to plugins requiring QCDM
The new QCDM port probing and grabbing mechanism implements a new
property for detecting the plugins which require the QCDM port to
be probed and grabbed.

Add the property to the affected plugins.
2022-06-19 13:40:48 +00:00
Daniele Palmas
654c5f5014 base-modem: add subsystem vendor ID property
Subsystem vendor ID can be used for identifying PCI modems,
so expose the property.
2022-05-24 09:22:06 +02:00
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
8722215f7e plugins: use logging module name as plugin name 2020-04-08 17:53:42 +02:00
Aleksander Morgado
c891595e3f via: port to use object logging 2020-04-08 16:35:10 +02:00
Aleksander Morgado
1bf9937cd5 via: fix warnings with -Wdiscarded-qualifiers
via/mm-plugin-via.c: In function ‘mm_plugin_create’:
  via/mm-plugin-via.c:59:54: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
     59 |     static const mm_str_pair product_strings[] = { { "via",    "cbp7" },
        |                                                      ^~~~~
  via/mm-plugin-via.c:59:64: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
     59 |     static const mm_str_pair product_strings[] = { { "via",    "cbp7" },
        |                                                                ^~~~~~
  via/mm-plugin-via.c:60:54: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
     60 |                                                    { "fusion", "2770p" },
        |                                                      ^~~~~~~~
  via/mm-plugin-via.c:60:64: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
     60 |                                                    { "fusion", "2770p" },
        |                                                                ^~~~~~~
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
Ben Chan
7f78ef5010 via: fix memory leak in parent_setup_registration_checks_ready
This patch fixes a potential memory leak in
parent_setup_registration_checks_ready() where the allocated
SetupRegistrationChecksResults may be leaked when the MMIfaceModemCdma
parent's setup_registration_checks() fails.
2019-04-03 10:57:14 -07:00
Ben Chan
a20686c24c via: port modem_cdma_{setup,cleanup}_unsolicited_events to use GTask 2017-10-20 09:44:56 +02:00
Aleksander Morgado
a1d355784b via: port get_detailed_registration_state() to GTask 2017-10-06 09:55:25 +02:00
Aleksander Morgado
0c8842695f via: port cdma_setup_registration_checks to GTask 2017-10-06 09:46:57 +02:00
Aleksander Morgado
24e8785a83 via: fix async completion in cdma event handlers setting 2017-07-17 10:14:13 +02:00
Aleksander Morgado
2eb55d3224 plugins: use G_N_ELEMENTS when iterating ports array 2017-05-30 17:28:23 +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
6f235b9948 ports: rename 'MMAtSerialPort' to 'MMPortSerialAt' 2014-02-13 13:40:01 +01:00
Aleksander Morgado
fa76ca95a7 via: new 'Via CBP7' plugin
This is the port to git master of the following commit:

commit ff8c60641aa2ea41080c15f81f633b3f78e07bf8
Author: Dan Williams <dcbw@redhat.com>
Date:   Mon Sep 10 17:12:38 2012 -0500

    via: new plugin for CBP7-based CDMA and EVDO devices (bgo #683525)

    The Via baseband is used in a number of CDMA/EVDO devices, from
    ChinaTelecom USB sticks, to the Fusion Wireless/UBlox 2770p, to
    various Motorola Android phones.
2012-10-09 16:42:40 +02:00