Commit Graph
100 Commits
Author SHA1 Message Date
Aleksander Morgado 97ae345d9e api: add 'Since' tags
These are not actively used by gdbus-codegen or gtk-doc, but they're
helpful anyway so that users know when a given API method was
introduced.
2021-03-23 12:50:17 +01:00
Aleksander Morgado dd3cb6e774 docs,libmm-glib: add low-level SAR interface reference 2021-03-23 12:50:17 +01:00
Aleksander Morgado e30e3ac56d docs,libmm-glib: add missing reference to mm_sim_preferred_network_list_free() 2021-03-23 12:50:17 +01:00
Aleksander Morgado 3e05b3a982 docs,api: include missing reference to the SAR interface 2021-03-23 12:02:20 +01:00
Aleksander Morgado 7ad2e3ce9c build: add support for the new SAR interface
Include the new SAR interface in the build so that gdbus-codegen
generates support for it in libmm-glib as well as proper documentation
in the API reference.
2021-03-23 08:49:30 +00:00
Aleksander Morgado 09cead8279 api,sar: improve documentation and add example of SAR mapping table 2021-03-23 08:49:30 +00:00
Aleksander Morgado a21233c7ab api: define bearer settings only in the 'Properties' property
Avoid defining them multiple times in the Modem.CreateBearer(),
Simple.Connect() and Modem3gpp.SetInitialEpsBearerSettings() methods.
2021-03-22 15:31:50 +01:00
Aleksander Morgado 634682b602 cinterion: make sure FALSE sets GError in parse_smong_response()
The g_regex_match_full() method may return FALSE without setting the
GError, so that case needs to be considered.

In addition to that, the following g_assert() was not doing what it
should have been, as it was comparing the address of the variable and
not the variable itself; rework the code to avoid that as well:
  g_assert (access_tech != MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN);
2021-03-21 13:44:16 +01:00
Aleksander Morgado d01bca493d cinterion: make sure FALSE sets GError in provcfg_response_to_cid()
The g_regex_match_full() method may return FALSE without setting the
GError, so that case needs to be considered.

Reported by Jan Mazura.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/347
2021-03-21 13:40:01 +01:00
Aleksander Morgado 5285e958ab cinterion: allow '*' in Prov/Cfg response
E.g. in a Cinterion PLS8-E (REVISION 04.004) to match the following
line:

  ^SCFG: "MEopMode/Prov/Cfg","fallback*"

Fix suggested by Jan Mazura.

See https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/347
2021-03-21 13:39:33 +01:00
Aleksander Morgado ab007a4496 base-modem: plug leaks when organizing ports
The GLists maintained in the logic need to be explicitly freed (just
the lists, not the list contents) if we exit early on error or if we
end up deciding that the specific ports are available but unsupported
by the plugin (e.g. if a plugin that doesn't support net ports finds
net ports in the modem).

  ==225333== 24 bytes in 1 blocks are definitely lost in loss record 2,024 of 5,525
  ==225333==    at 0x483E77F: malloc (vg_replace_malloc.c:307)
  ==225333==    by 0x506C539: g_malloc (in /usr/lib/libglib-2.0.so.0.6600.7)
  ==225333==    by 0x508DC8F: g_slice_alloc (in /usr/lib/libglib-2.0.so.0.6600.7)
  ==225333==    by 0x50636B4: g_list_append (in /usr/lib/libglib-2.0.so.0.6600.7)
  ==225333==    by 0x17E671: mm_base_modem_organize_ports (mm-base-modem.c:1298)
  ==225333==    by 0x1E4409: mm_plugin_create_modem (mm-plugin.c:1094)
  ==225333==    by 0x162C81: mm_device_create_modem (mm-device.c:481)
  ==225333==    by 0x15DE60: device_support_check_ready (mm-base-manager.c:218)
  ==225333==    by 0x4EA8173: ??? (in /usr/lib/libgio-2.0.so.0.6600.7)
  ==225333==    by 0x4EAC6E8: ??? (in /usr/lib/libgio-2.0.so.0.6600.7)
  ==225333==    by 0x16730F: device_context_run_ready (mm-plugin-manager.c:1533)
  ==225333==    by 0x4EA8173: ??? (in /usr/lib/libgio-2.0.so.0.6600.7)
2021-03-18 14:27:34 +01:00
Aleksander Morgado 3e58fbe547 base-bearer: ignore forced disconnections
If using PPP, ModemManager is never in charge of deciding when the
connection is finished, because that would end up making ModemManager
try to use the TTY port while pppd is still using it.

When the modem goes unregistered for some time, we should not force
the disconnection of the bearer object, we still need to wait for pppd
to tell us the modem is disconnected.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/331
2021-03-17 09:19:17 +00:00
Aleksander Morgado 952f416577 bearer-mbim: if no explicit 'multiplex' setting, treat as 'requested' 2021-03-17 09:39:10 +01:00
Aleksander Morgado 8f3df02ba1 broadband-modem-mbim: report up to 256 multiplexed bearers
As defined in the MBIM protocol (session id 0 to 255).
2021-03-17 09:39:10 +01:00
Aleksander Morgado 2d374b1c41 bearer-mbim: implement multiplex support 2021-03-17 09:39:10 +01:00
Aleksander Morgado 32c4b20066 port-mbim: implement new link setup/cleanup methods
These are really wrappers around the MbimDevice methods, only making
sure the MMPortMbim is open before they're used.
2021-03-17 09:39:10 +01:00
Aleksander Morgado e5305498b7 bearer-mbim: session id 0 by default in all non-multiplexed connections
The original logic in the MBIM modem would assume that if we had more
than one network interface in the same modem, we could connect
multiple data interfaces, each one with a different session. That
logic is actually wrong, when using the master (non-multiplexed)
network interface we should always use session id 0, which is the one
holding all non-VLAN-tagged traffic.

So, remove the logic that automatically creates new bearers with a
different session id, as that is really wrong.
2021-03-17 09:39:10 +01:00
Aleksander Morgado 0830f9510c bearer-mbim: refactor and switch to autoptr
Also, keep track of the MMPortMbim instead of the MbimDevice directly,
because the new multiplex support will require operations on the port
as well, not only on the device.
2021-03-17 09:39:10 +01:00
Aleksander Morgado 1fa8ce3f08 broadband-modem-mbim: reset all net ports during initialization
We want to start with the data ports as clean as possible when the
modem is initialized, so we make sure the master interface is down and
that all links found are removed. This ensures a clean restart if
e.g. the daemon crashes for some other reason.
2021-03-17 09:39:10 +01:00
Aleksander Morgado 37d4f5c129 port-mbim: implement port reset logic 2021-03-17 09:36:53 +01:00
Aleksander Morgado 340fa919d9 build: require libmbim 1.25.2 for multiplex support 2021-03-17 09:36:53 +01:00
Aleksander Morgado fdfd4b270a shared-qmi: acquisition order preference TLV always same items
The acquisition order preference TLV must always have the same number
of elements, just the order of the elements should be different.

Also, always prefer the acquisition order preference TLV to the
GSM+WCDMA specific one, which is the same logic the modem applies.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/340
2021-03-15 17:46:49 +01:00
Aleksander Morgado bb5bc9c8c5 shared-qmi: process all feature checks in SSP response together
Loading capabilities is the very first step of the state machines, and
so we can rely on the "NAS Get SSP" method performed there to process
all feature checks of the SSP response.
2021-03-15 17:46:41 +01:00
Aleksander Morgado 65a7624ffd shared-qmi: if getting TP/SSP fails, assume unsupported
Until now we were only considering TP/SSP unsupported if we received
a QMI protocol error (e.g. reporting unknown command).

We now also consider TP/SSP unsupported if the actual request
succeeds, but an error is reported in the response. There is no point
in considering TP/SSP supported if the plain get request without input
TLVs given fails.
2021-03-15 17:21:50 +01:00
Aleksander Morgado 1a5f90f15b shared-qmi: add missing feature check flag initialization to UNKNOWN 2021-03-15 17:21:50 +01:00
Aleksander Morgado 67b64eb7ee shared-qmi: rename feature check variables
We want the "extended_lte_band_preference" with the "nas_ssp" prefix,
as we're going to add more checks for SSP features.
2021-03-15 14:58:54 +01:00
Aleksander Morgado abc417f37a sierra: disable CPOL in the EM7345
Using CPOL? in the EM7345 (firmware FIH7160_V1.1_MODEM_01.1349.12)
ends up with the whole AT port stuck and non-responsive, which leads
to flagging the modem as unusable later on as soon as 10 consecutive
AT command timeouts happen.

In order to avoid that, we explicitly disable all CPOL based features
in this specific module.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/336
2021-03-12 12:41:35 +01:00
Aleksander Morgado e0a6d5d76b base-sim: allow disabling CPOL based preferred networks features 2021-03-12 12:41:35 +01:00
Aleksander Morgado e00e113dc9 docs,libmm-glib: add missing reference to private method 2021-03-11 16:03:23 +01:00
Aleksander Morgado fdfcd30308 bearer-qmi: avoid increasing self reference during dispose()
The reset_bearer_connection() method is called during dispose, and if
a link had been created during the connection attempt, we would be
increasing the reference to the bearer object during dispose(), which
should never happen.

Just avoid passing any callback to the cleanup_link() method, as we
really were using that only for logging purposes.
2021-03-11 11:38:29 +01:00
Aleksander Morgado a772b70632 bearer-mbim: plug MbimDevice leak in disconnection context 2021-03-11 10:33:00 +01:00
Aleksander Morgado bd075aeba0 bearer-qmi: if no explicit 'multiplex' setting, default to 'requested' 2021-03-10 15:18:00 +01:00
Aleksander Morgado 0b72d9b566 port-qmi: flag multiplexing as unsupported in BAM-DMUX
In BAM-DMUX based setups we already have multiple network interfaces
exposed in the system, which we bind to using the SIO port number.

So, disable QMAP multiplexing in this case, to simplify the setup and
avoid attempting to create additional net links when connecting
multiple bearers.
2021-03-10 15:18:00 +01:00
Aleksander Morgado 791c7908e4 port-qmi: initialize net port driver information early
The MMPortQmi may need to know very early what kind of net ports are
going to be used later on during connection, e.g. to decide what kind
of multiplexing capabilities are available and such.

So, once we have organized ports in the modem, we'll take the driver
of the first network port in the list of data ports, and pass it down
to all QMI ports setup in the modem object.
2021-03-10 15:18:00 +01:00
Aleksander Morgado 4f4ce02c43 port-qmi: compute max amount of multiplexed links supported
For the qmi_wwan driver, we have imposed a limitation of max 4 links
when using the add_mux/del_mux interface, because we're forced to
precreate links before multiplexing may be enabled.

When using rmnet over qmi_wwan, or rmnet over other drivers, we don't
have any limitation other than the one imposed by the WDA protocol
itself. The amount of links that may be created in this case is
1 + (QMI_DEVICE_MUX_ID_MAX - QMI_DEVICE_MUX_ID_MIN).

This information is loaded in the MMPortQmi, used to create the
MMBearerList in the QMI modem, and finally populated in the
'MaxActiveMultiplexedBearers' property of the modem interface.
2021-03-10 15:17:59 +01:00
Aleksander Morgado 499d954857 port-qmi: setup master MTU link to max aggregation data size
This step is required when using the qmi_wwan add_mux/del_mux logic,
and must be done before changing the kernel data format to raw-ip.
2021-03-10 15:17:59 +01:00
Aleksander Morgado b0f26a1f0b bearer-qmi: bring master interface up on connection attempt
The user of the ModemManager API will bring up the data network
interface exposed in the Bearer IP settings (i.e. the link interface
when using multiplexing). But for instantiated network links, we also
need to have the master interface brought up before any traffic can go
through the link interface.

We don't check whether the master interface is already up before
attempting to bring it up, we just attempt to bring it up.
2021-03-10 12:58:12 +01:00
Aleksander Morgado 1643c3d3db bearer-qmi: create data port link if multiplex is requested/required
If the user requests or requires to use multiplexing support, try to
create a data port link and bind the WDS client(s) to it.

If the multiplex is requested but not required, we allow link creation
failures or setups where multiplexing isn't supported; we just go on
with the default connection setup without multiplexing, as long as
there is no bearer connected on the same data network interface.

If the multiplex is required and for any reason it cannot be fully
setup, we will fail the connection attempt right away.

The data port link is created in the system via the QmiDevice in the
open MMPortQmi, but it MUST be notified by the kernel (e.g. via udev
or via kernel events) before the connection attempt goes on.
2021-03-10 12:58:12 +01:00
Aleksander Morgado db5cb302c9 port-qmi: don't allow switching to non-multiplexed mode if links exist
If the port has net links that have been setup, don't allow switching
it from multiplexing mode to non-multiplexing mode.
2021-03-10 12:58:12 +01:00
Aleksander Morgado f58d3ef93f port-qmi: new methods to setup/cleanup net links
The logic to setup/cleanup net links is based on the QmiDevice net
link addition/removal operations.

When the qmi_wwan add_mux/del_mux based logic is in use, we default to
precreate 4 net links and we limit the amount of bearers that may be
connected to that maximum, because it is not guaranteed that the
qmi_wwan driver is able to create new links once the master interface
is up; and the master interface needs to be up for a proper data
connection.

For all other drivers, or when qmi_wwan uses qmap-pass-through, we
allow adding/deleting new links at any moment, without needing to rely
on the precreated ones.
2021-03-10 12:58:12 +01:00
Aleksander Morgado b3fb87cdf6 base-modem: new method to wait for an explicit link port
When new link ports are created, the QmiDevice link management methods
try to make sure that the port exists in the system by the time the
link addition method returns, but that doesn't guarantee that the port
has also been notified by the kernel to ModemManager (e.g. via udev or
via kernel events).

This new method allows to do a explicit wait for a given port link; if
we already have it it will return right away, and otherwise we'll wait
for it to be notified via the "link port grabbed" signal.
2021-03-10 12:58:12 +01:00
Aleksander Morgado 897e48709d base-modem: allow grabbing link ports after modem is created
We will grab the ports and make them available through find_ports() or
peek_port() or get_port().

The link ports are not 'organized' so they won't be available in
e.g. get_data_ports(), which is fine, because we don't want to mix
them with the real data ports exposed by the device.

Link port additions and removals are also notified via signals in the
modem object, so that explicit wait for specific ports can be done.
2021-03-10 12:58:12 +01:00
Aleksander Morgado 21174f289f kernel-device-generic: setup 'lower device' for virtual ports 2021-03-10 10:59:22 +01:00
Aleksander Morgado 591db5e455 kernel-device-udev: setup 'lower device' for virtual ports 2021-03-10 10:59:22 +01:00
Aleksander Morgado 73830f0bd0 kernel-device: new helper to load lower device link names
Based exclusively on sysfs for now. We could do this via netlink if
needed as well.
2021-03-10 10:59:22 +01:00
Aleksander Morgado 6a791dd8b7 kernel-device: new 'lower device' property for physdev info
We can now setup a 'lower device' object that will be the one
providing all physdev info. This is useful when using virtual ports
that refer to a 'lower' real physical device, in order to bind
together all those ports on the same modem object.
2021-03-10 10:59:22 +01:00
Aleksander Morgado ec73efc551 port-qmi: add support for QMAP data aggregation
We now allow requesting for multiplex support in the set data format
operation of the MMPortQmi.

If multiplexing is supported, we'll configure both the modem (link
layer protocol and data aggregation protocol) and the kernel expected
data format (if qmi_wwan in use).

The logic adds additional preferences over the different choices we
may find in the logic:
  * In newer modems, by default QMAPv5 is preferred over QMAP as data
    aggregation protocol.
  * If using qmi_wwan, by default rmnet (qmap-pass-through) is
    preferred over add_mux/del_mux (raw-ip) kernel expected data
    format.

These preferences are only considered if the specific support is found
in the setup.

Whenever we change the multiplexing support, an internal port reset
operation will be run, in order to bring the state of the setup to a
clean known one.
2021-03-10 10:59:22 +01:00
Aleksander Morgado 140094bb47 broadband-modem-qmi: reset all QMI/NET ports on initialization
If the daemon boots and it finds already existing modems in the
system (i.e. not hotplugged), we will attempt to reset all QMI/NET
ports, so that the state in which the ports are is a known one.

This logic allows us to cleanup any possible existing network link if
e.g. the daemon crashes and is restarted by the system.
2021-03-10 10:59:22 +01:00
Aleksander Morgado 7b20550ac0 port-qmi: implement port reset logic
The port reset operation will attempt to setup the QMI and associated
NET ports to the same state as they has when the modem was originally
detected: no mux links, net interface down and (for the qmi_wwan based
devices) expected kernel data format set to 802.3.

By default, the external calls to the port reset logic will require
the port to be closed (i.e. no internal QmiDevice), so a new temporary
QmiDevice will be created just for this operation. The new QmiDevice
doesn't even need to be open, as the reset operations just uses the
device to attempt to remove net links.

The internal call to the port reset logic uses an input QmiDevice
which may be the newly allocated one in the external call, or the
internal QmiDevice, if there is one.
2021-03-10 10:59:22 +01:00
Aleksander Morgado 032a86915a port-net: new 'MMPortNet' object with netlink capabilities
Right now just with the support to setup link properties like up/down
state or the link mtu.

This features are required when using QMAP based multiplexing with the
qmi_wwan kernel driver.
2021-03-10 10:59:22 +01:00
Aleksander Morgado b45948a20d port-qmi: rework WDA-based logic and avoid setup during port open
The new logic is implemented as a separate async method with its own
state machine, which allows selecting different data format setups
with an strict preference.

Until now, we would not attempt to re-configure the link layer
protocol in the modem interface if we could instead change the
expected data format in the kernel. E.g. a MC7304 exposing one
interface in 802.3 format and another one in raw-ip format would be
used in either 802.3 or raw-ip, depending on the network interface
being connected.

This logic changes now, and we now by default always prefer raw-ip
over 802.3. E.g. the same MC7304 would now always be used in raw-ip
mode, regardless of whether the interface was by default in raw-ip or
not. Obviously, raw-ip will only be used if the kernel data format can
be changed. If the qmi_wwan driver in use is older than 4.5, the
default link layer protocol attempted would be 802.3, if the modem
supports it.

In addition to this change in logic, we also now avoid setting up the
WDA data format as soon as the port is opened; instead we defer that
logic until a connection request arrives, because once QMAP support is
integrated, we'll need to know whether the user requested the
multiplexing support or not. Therefore, during port open we just
query current state and during the connection attempt we reconfigure
either modem or kernel or both.

If WDA is unsupported, the logic falls back to CTL-based link layer
protocol configuration, as it use to.

The logic now also supports WDA Set/Get Data Format operations with
the newest modems that require the explicit endpoint info TLV. As soon
as the first failure is reported asking for the endpoint TLV, we'll
flag the port as requiring the endpoint info always.
2021-03-10 10:59:22 +01:00
Aleksander Morgado cd2f8d9d63 port-qmi: keep track of the endpoint info
The endpoint info of a given MMPortQmi is immutable (it's associated
to the specific kernel driver in use and to the specific physical
interface number of the device).

We'll load it as soon as the kernel device object is set in the port,
and we'll keep it in the private struct so that it can be used at any
time, e.g. by the WDA Get/Set Data Format operations on newest
devices, where the endpoint info TLV is mandatory.
2021-03-10 10:59:22 +01:00
Aleksander Morgado d1a893775e docs: add api indices for 1.18 2021-03-10 10:59:22 +01:00
Aleksander Morgado 73db7f205c api,bearer: new 'Multiplexed' property
This property will be TRUE if the bearer has the data session
connected through a multiplexed interface.

If the bearer is disconnected, or connected without multiplexing, the
property will report FALSE.
2021-03-10 10:59:22 +01:00
Aleksander Morgado 05b9ab7c25 api,modem: new 'MaxActiveMultiplexedBearers' property
In addition to the amount of bearers a user may connect without
multiplexing enabled (the default until now), we now also expose the
maximum number of bearers a user may connect after enabling
multiplexing over one single network interface (if supported).

The method responsible for creating the MMBearerList is now also
subclassable, so that implementations supporting multiplexing can
provide their own version with their own thresholds.
2021-03-10 10:59:22 +01:00
Aleksander Morgado 35e20a48c8 api,modem: deprecate the 'MaxBearers' property
This property was never initialized with a correct value, we would
always use the same value as used for MaxActiveBearers, which isn't
technically right. Just suggest to ignore this property, and flag
it as deprecated.

In addition to deprecating the API property, we will internally no
longer limit the amount of bearer objects that may be created with
different connection settings. The bearer object exposed in DBus is a
representation of the connection that may be setup, and so we can hold
as many representations as we want as long as the amount of connected
bearers doesn't exceed the maximum amount for each modem.

Leaving around the disconnected modems also serves another purpose.
Each bearer holds information about the amount of times a connection
with it has been attempted, and the amount of data transferred through
it. If we use the Simple.Connect() method to connect the modem using
different bearer settings, we won't lose the information of the past
connection attempts with different settings.
2021-03-10 10:59:22 +01:00
Aleksander Morgado 064e92e9b7 api,simple: new 'multiplex' setting in bearer properties
Both the Simple.Connect() and Modem.CreateBearer() are updated to
allow a new 'multiplex' setting in the properties provided by the user
in both of these methods.

The new setting expects a MMBearerMultiplexSupport enum indicating
what kind of multiplex needs the user has:
 * none: if multiplex must not be used.
 * requested: if multiplex should be used if available.
 * required: if multiplex must be used.

The underlying implementations will take care of accepting or
rejecting the setting depending on the system and modem capabilities.
2021-03-10 10:59:19 +01:00
Aleksander Morgado a659970634 broadband-modem-qmi: update EPS/5GS reg state when idle/searching
Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/317
2021-03-05 17:36:33 +00:00
Aleksander Morgado 55d60f3c12 sms: common timeout of 180s for the send operation
On low signal quality conditions, the process of sending the SMS to
the network may take a really long time, way more than the 30s used as
default in some implementations.

We now define a common timeout value of 180s for this operation in all
protocols.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/328
2021-03-04 20:45:00 +00: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 b509229d57 broadband-modem-qmi: use updated system info API 2021-03-02 14:38:35 +01:00
Aleksander Morgado 496c4e30e9 broadband-modem-qmi: enable network reject indications
We will issue warnings in the log whenever a network reject indication
is received.
2021-03-02 14:38:35 +01:00
Aleksander Morgado 438ff54d03 libmm-glib,tests: include string.h explicitly
For strlen()
2021-03-01 16:02:33 +01:00
Aleksander Morgado da0e610f5f modem-helpers-mbim: include string.h explicitly
For strstr()
2021-03-01 15:56:14 +01:00
Aleksander Morgado a9611c6279 utils: import ptr array lookup with GEqualFunc from GLib 2.54
This fixes the build when using GLib < 2.54.
2021-03-01 15:55:22 +01:00
Aleksander Morgado fbc1636001 docs: add api index for 1.18 2021-02-26 12:28:01 +01:00
Aleksander Morgado c7d366671f shared-qmi: network registration cancellation logic with asserts disabled
g_assert() calls may be disabled, and if so, the network registration
task would never get completed.
2021-02-26 11:18:22 +01:00
Aleksander Morgado f10e4af919 libmm-glib,bearer-properties: fix 'allow roaming' comparison
Fix the 'allow roaming' setting comparison, which was breaking the
whole bearer properties comparison logic, and therefore making
Simple.Connect() recreate over and over the bearer with the same
settings.

Fixes 5629f47a59
2021-02-25 15:23:36 +01:00
Aleksander Morgado aba237df4e broadband-modem-qmi: allow lookup of QMI for data without SIO port 2021-02-25 14:13:03 +01:00
Aleksander Morgado 381e2f382b base-modem: separate method to lookup exact port by name
There's no point in returning a list of all ports with a given name,
just provide a lookup method that returns the single port with the
given name.
2021-02-25 14:13:03 +01:00
Aleksander Morgado b8e076f9c4 kernel-device-udev: keep track of the client object
Instead of creating new clients internally whenever we need them, just
make sure each MMKernelDeviceUdev object keeps a full reference to the
GUdevClient that generated all GUdevDevices.
2021-02-25 12:13:16 +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 6250603496 build: improve releasing notes 2021-02-24 09:16:49 +01:00
Aleksander Morgado 4a06a02765 charsets: detect iconv() support in runtime
The only purpose of this is to log what we found, nothing else, as a
quick way to detect platform support for the charsets we need.
2021-02-23 11:35:11 +00:00
Aleksander Morgado 8a8e00168b charsets: define common translit fallback character 2021-02-23 11:35:11 +00:00
Aleksander Morgado c84454c1b0 charsets: remove charset_hex_to_utf8()
No longer used, replaced by the new common conversion methods.
2021-02-23 11:35:11 +00:00
Aleksander Morgado 0ff3eb7ee0 charsets: remove take_and_convert methods
These methods worked in a very strict way for some encodings, and in a
very very loose way for others. E.g. when converting from hex-encoded
UCS-2, we would attempt to convert as much text as we could even if
the input string was truly not even close to UCS-2. This kind of "do
our best" could make sense when processing e.g. the operator name
reported by the modem, as that is some string to show to the user and
there may be no strict requirement to have it perfectly fine. But the
kind of loose comparison done for UCS-2 doesn't make sense e.g. when
converting USSD responses or SMS messages.
2021-02-23 11:35:11 +00:00
Aleksander Morgado ab4c31ec0b cinterion: rework mno decoding to use str_to_utf8() 2021-02-23 11:35:11 +00:00
Aleksander Morgado 6bc07b4b14 cinterion: rework band encoding to use str_to_utf8()
Also providing support to report errors when attempting to decode the
strings.
2021-02-23 11:35:11 +00:00
Aleksander Morgado 16df1e17e6 helpers: rework normalize_operator() to use str_to_utf8()
Instead of blindly assuming that we can take whatever string given as
valid UTF-8, we'll always attempt to convert from the current modem
charset into UTF-8. Before we were doing this for hex-encoded UCS2,
but not for example for GSM-7.

And due to the now applied GSM-7 conversion, the mf627a/mf627b +COPS
parsing unit tests are updated accordingly, because when converting
from an input string that contains byte 0x40 ('@' in UTF-8) as if it
were GSM-7, the 0x40 is taken as character '¡', encoded as 0xc2,0xa1
in UTF-8).
2021-02-23 11:35:11 +00:00
Aleksander Morgado 63fa9eee46 charsets,tests: update take_and_convert tests to str_from/to 2021-02-23 11:35:11 +00:00
Aleksander Morgado 3ac248a7a6 cinterion: move sequence to set bands to private ctx
The sequence of commands is exclusively used during the set current
bands operation, so there is no point in storing it in the private
object data.
2021-02-23 11:35:11 +00:00
Aleksander Morgado e5363b546b charsets: use new str_from_utf8() instead of take_and_convert_to_current_charset() 2021-02-23 11:35:11 +00:00
Aleksander Morgado 395ab06c03 charsets: use new bytearray_to_utf8() instead of hex_to_utf8() 2021-02-23 11:35:11 +00:00
Aleksander Morgado 5ea4a591a4 charsets: use new bytearray_to_utf8() instead of byte_array_to_utf8() 2021-02-23 11:35:11 +00:00
Aleksander Morgado 033e174e44 charsets: make charset_gsm_unpacked_to_utf8() private
Use the generic mm_modem_charset_bytearray_to_utf8() instead.
2021-02-23 11:35:11 +00:00
Aleksander Morgado 8bfdfb187b charsets: use new bytearray_from_utf8() instead of byte_array_append() 2021-02-23 11:35:11 +00:00
Aleksander Morgado 75b37e16b1 charsets: make charset_utf8_to_unpacked_gsm() private
Use the generic mm_modem_charset_bytearray_from_utf8() instead.
2021-02-23 11:35:11 +00:00
Aleksander Morgado 9c613d33e1 charsets: new common APIs to convert from/to charsets and UTF-8 2021-02-23 11:35:11 +00:00
Aleksander Morgado 6f32c8d38f charsets: avoid //TRANSLIT when converting to/from charsets
The //TRANSLIT extension is not always supported by the different
iconv() implementations that we may find out there, so let's
completely avoid using it.

For some of the charsets it actually didn't make much sense anyway,
e.g. as converting to UTF-16 or UTF-8 would always be possible without
requiring //TRANSLIT to take effect.

The //TRANSLIT extension was also being used sometimes in the source
charset identification, which was also not fully correct, as we would
only expect it in the target charset identification.
2021-02-23 11:35:11 +00:00
Aleksander Morgado bc449cbe87 charsets: make translit optional in utf8_to_unpacked_gsm()
If the conversion is not fully compatible, the user of the method
needs to request transliteration enabled explicitly in order to avoid
returning errors in this method.
2021-02-23 11:35:11 +00:00
Aleksander Morgado 5ce97abd73 charsets: make translit optional in gsm_unpacked_to_utf8()
Until now, this method would automatically apply transliteration;
i.e. replacing characters with '?' when no direct translation was
available.

We can attempt to do that transliteration on strings that are not
critical, e.g. the operator name reported by the network. But we
should not do that on other types of strings, e.g. on SMS contents
that may really have additional purposes than just being
human-readable.

This commit makes the transliteration option to be explicitly
requested by the caller.
2021-02-23 11:35:11 +00:00
Aleksander Morgado 5480cb67b2 libmm-glib,tests: add ishexstr/hexstr2bin/bin2hexstr unit tests 2021-02-23 11:35:11 +00:00
Aleksander Morgado 34de613dea libmm-glib,common-helpers: make hexstr2bin() return a guint8 array
It makes much more sense than returning a gchar array, as gchar is
signed.
2021-02-23 11:35:11 +00:00
Aleksander Morgado 6d8610d63e libmm-glib,common-helpers: ishexstr() fails on empty input string 2021-02-23 11:35:11 +00:00
Aleksander Morgado 8c30a6b6f8 libmm-glib,common-helpers: hexstr2bin fails on empty input string
Also, remove the trailing NUL byte that was appended to the output
binary stream, as it's not needed in any case.
2021-02-23 11:35:11 +00:00
Aleksander Morgado a211981d4a libmm-glib,common-helpers: make hexstr2bin() accept input string length
Optionally given explicitly, and -1 can be used to assume it's
NUL-terminated.
2021-02-23 11:35:11 +00:00
Aleksander Morgado 657cabcfce libmm-glib,common-helpers: make hexstr2bin() return a GError
This util method checks whether the input string is a valid hex
string, so make sure we return a GError on failure.
2021-02-23 11:35:11 +00:00
Aleksander Morgado dbdf67e9f7 charsets: remove unused charset_utf8_to_hex() method 2021-02-23 11:35:11 +00:00
Aleksander Morgado 8b590721df charsets: don't allow quoting in byte_array_append()
There's no point in adding a quoting option to this method; if the
caller needs the appended string quoted, it should quote it before
passing it to this method.

It was nowhere used anyway.
2021-02-23 11:35:11 +00:00