aboutsummaryrefslogtreecommitdiff
path: root/libmm-glib/mm-common-helpers.c
AgeCommit message (Collapse)Author
2025-03-29libmm-glib,helpers: Add helpers to parse CB channels in and out of stringsGuido Günther
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-03-28libmm-glib,helpers: Add helpers for CellBroadcast channel listsGuido Günther
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2023-10-27api,errors: new MMCarrierLockError typeAleksander Morgado
This new error type will be used to report errors in the carrier lock operations performed through ModemManager. They have a one to one mapping to the MBIM status specific errors.
2023-04-27libmm-glib: separate files for flags and enums typesAleksander Morgado
This allows us to skip needing to include the non-existent build_string_from_mask() or get_string() counterparts in the documentation index.
2023-02-17libmm-glib,common-helpers: Add multiple apn-type managementFrederic Martinsons
Fixes #676 Signed-off-by: Frederic Martinsons <frederic.martinsons@gmail.com>
2023-01-18libmm-glib,common-helpers: undeprecate g_date_time_format_iso8601()Lubomir Rintel
Avoid a deprecation warning with too new glib: ../libmm-glib/mm-common-helpers.c: In function ‘date_time_format_iso8601’: ../libmm-glib/mm-common-helpers.c:1729:5: warning: ‘g_date_time_format_iso8601’ is deprecated: Not available before 2.62 [-Wdeprecated-declarations] 1729 | return g_date_time_format_iso8601 (dt); | ^~~~~~ This call site is protected by version guards and provides an alternative implementation in date_time_format_iso8601().
2023-01-18libmm-glib,common-helpers: avoid using g_time_zone_new_offset()Lubomir Rintel
It requires newer glib than we do: ../libmm-glib/mm-common-helpers.c: In function ‘mm_new_iso8601_time’: ../libmm-glib/mm-common-helpers.c:1787:9: warning: ‘g_time_zone_new_offset’ is deprecated: Not available before 2.58 [-Wdeprecated-declarations] 1787 | tz = g_time_zone_new_offset (offset_minutes * 60); | ^~ In file included from /usr/include/glib-2.0/glib/gdatetime.h:33: /usr/include/glib-2.0/glib/gtimezone.h:67:25: note: declared here 67 | GTimeZone * g_time_zone_new_offset (gint32 seconds); | ^~~~~~~~~~~~~~~~~~~~~~ Let's not use the routine with older versions of glib.
2022-11-04libmm-glib,common: add helpers to build printable stringsAleksander Morgado
2022-10-05libmm-glib,common-helpers: minor coding style fix in mm_new_iso8601_time()Aleksander Morgado
2022-10-05libmm-glib,common-helpers: don't assume new_from_unix_utc() always succeedsAleksander Morgado
The g_date_time_new_from_unix_utc() method in glib2 may fail if the given timestamp is too far into the future. The value is supposed to be seconds since unix time origin, but internally it will be converted into usecs, so any value longer than G_MAXINT64 / USEC_PER_SECOND isn't allowed. This is currently used in the CLI, and we're anyway ignoring the error returned in that case, but at least it won't crash if it ever happens.
2022-04-08sms: prevent crash if date is out of rangeCarlo Lobrano
g_date_time_new, and g_date_time_new_utc return NULL if inputs are out of range, and currently mm_new_iso8601_time passes the GDateTime created by those two functions to date_time_format_iso8601 without checking for NULL values, causing a g_date_time_format_iso8601 crash if PDU data is corrupted with wrong date. To prevent this, mm_new_iso8601_time now can return NULL and set a new GError if GDateTime created by g_date_time_new is NULL. Fixes #546
2021-12-24libmm-glib: new 'profile-source' in 3GPP profileAleksander Morgado
Not applicable to bearer properties, as this is exclusively a proflie management setting, unrelated to connection attempts.
2021-12-24libmm-glib: new 'access-type-preference' in 3GPP profile and bearer propertiesAleksander Morgado
2021-12-24libmm-glib: new helper to handle the 5GNR registration settingsAleksander Morgado
2021-11-16libmm-glib: fix license in sourcesAleksander Morgado
The libmm-glib library is LGPLv2+, not GPLv2+.
2021-11-02api,3gpp: new 'SetPacketServiceState()' methodAleksander Morgado
2021-10-22cli, plugins: factorize usage of iso8601 datetime formatFrederic Martinsons
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com> Includes updates by Aleksander Morgado to fix coding style issues.
2021-10-22api,bearer: new 'start-date' field in bearer statisticsFrederic Martinsons
It stores the epoch timestamp of the current bearer session start. If there is no connected bearer, it is set to 0 and not displayed in mmcli output. Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com> Includes updates by Aleksander Morgado to fix coding style issues.
2021-07-09libmm-glib,common-helpers: fix build with glib 2.56Benoît Monin
The support of autoptr for GEnumClass and GFlagsClass was introduced in glib 2.58. To keep compatibility with glib 2.56, declare the autoptr cleanup functions. Fixes #397
2021-07-01libmm-glib,modem: use helper macros to manage the monitored propertiesAleksander Morgado
2021-07-01libmm-glib,common-helpers: refactor helper methodsAleksander Morgado
Remove unused methods, like all the variant_to_array() ones, and reorder some others so that both header and source file have the same order always.
2021-05-23api,bearer: new 'ConnectionError' propertyAleksander Morgado
This new property will provide detailed information about the failed connection attempt, or about the network initiated disconnection. The property will be cleared only if a new connection attempt is triggered, and so it can be used to investigate why a given attempt failed without needing to be the one who triggered the attempt (e.g. so that failures in NetworkManager-triggered connection attempts can be investigated looking at the DBus API). The property is built as a (ss) tuple, but the libmm-glib interface provides methods to read this property as a GError.
2021-05-22libmm-glib: setup common helper to register DBus errorsAleksander Morgado
2021-05-18libmm-glib,common-helpers: avoid signed vs unsigned comparisonsAleksander Morgado
mm-common-helpers.c: In function 'mm_get_int_from_str': mm-common-helpers.c:1349:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (eol == num) ^~ mm-common-helpers.c: In function 'mm_utils_hexstr2bin': mm-common-helpers.c:1718:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (i = 0; i < len; i += 2) { ^
2021-04-30libmm-glib: add helper to get 3gpp facility from stringMichal Mazur
2021-04-29api,bearer: new 'apn-type' settingAleksander Morgado
This new setting allows the user setting up the connection to specify the purpose of the connection being brought up. Until now, we would always assume that connections are exclusively brought up for connecting to the Internet, also limited by the inability to connect to multiple different APNs at the same time. But that may really not be true as there may be additional services that may be accessed through other APNs, like MMS services or even private networks for companies that have their own APNs on a given operator (e.g. not that uncommon with banks and connected cars). The new APN type setting will not change the way the bearer is connected, but will allow the connection manager to decide what kind of networking setup the specific connection needs. This new setting can be provided by the user itself, or implicitly read from the device if the device stores this information.
2021-03-10api,simple: new 'multiplex' setting in bearer propertiesAleksander Morgado
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-09mmcli,sim: implement --sim-set-preferred-networks functionTeijo Kinnunen
2021-02-23libmm-glib,common-helpers: make hexstr2bin() return a guint8 arrayAleksander Morgado
It makes much more sense than returning a gchar array, as gchar is signed.
2021-02-23libmm-glib,common-helpers: ishexstr() fails on empty input stringAleksander Morgado
2021-02-23libmm-glib,common-helpers: hexstr2bin fails on empty input stringAleksander Morgado
Also, remove the trailing NUL byte that was appended to the output binary stream, as it's not needed in any case.
2021-02-23libmm-glib,common-helpers: make hexstr2bin() accept input string lengthAleksander Morgado
Optionally given explicitly, and -1 can be used to assume it's NUL-terminated.
2021-02-23libmm-glib,common-helpers: make hexstr2bin() return a GErrorAleksander Morgado
This util method checks whether the input string is a valid hex string, so make sure we return a GError on failure.
2020-05-19libmm-glib,helpers: use locale-independent strtod()Aleksander Morgado
Otherwise parsing may fail, e.g. as in this unit test: # Start of smoni tests # DEBUG: testing SMONI response: ^SMONI: 2G,71,-61,262,02,0143,83BA,33,33,3,6,G,NOCONN # DEBUG: testing SMONI response: ^SMONI: 2G,SEARCH,SEARCH # DEBUG: testing SMONI response: ^SMONI: 2G,673,-89,262,07,4EED,A500,16,16,7,4,G,5,-107,LIMSRV # DEBUG: testing SMONI response: ^SMONI: 2G,673,-80,262,07,4EED,A500,35,35,7,4,G,643,4,0,-80,0,S_FR # DEBUG: testing SMONI response: ^SMONI: 3G,10564,296,-7.5,-79,262,02,0143,00228FF,-92,-78,NOCONN ** ERROR:cinterion/tests/test-modem-helpers-cinterion.c:1036:test_smoni_response: assertion failed (fabs (ecn0 - smoni_response_tests[i].ecn0) < 0.1): (0,5 < 0,1) Bail out! ERROR:cinterion/tests/test-modem-helpers-cinterion.c:1036:test_smoni_response: assertion failed (fabs (ecn0 - smoni_response_tests[i].ecn0) < 0.1): (0,5 < 0,1) Aborted (core dumped)
2020-04-09libmm-glib,helpers: ignore all leading whitespaces when parsing numbersAleksander Morgado
2020-04-09libmm-glib,helpers: allow reading hex strings from match infoAleksander Morgado
2020-04-09libmm-glib,helpers: skip quotes when reading numbers from match infosAleksander Morgado
Useful when the regex applied to the parseable strings don't have an special ignore rule for the quotes.
2020-04-09api,modem: improve capabilities related documentationAleksander Morgado
And remove the unused mm_common_build_capability_combinations_any() method in the common non-public library code.
2020-01-31libmm-glib,helpers: allow \r\n in string to number conversionsAleksander Morgado
It's not uncommon that we may want to parse a simple AT response that contains a single number by doing mm_strip_tag() followed by mm_get_uint_from_str(). In order to do this, we need to have the helper methods that convert strings to numbers support \r\n characters at the end of the string, as we would have in AT responses.
2020-01-06libmm-glib,common-helpers: allow yes/no as booleans in stringAleksander Morgado
E.g. so that the settings passed on Simple.Connect() or Bearer.Connect() are parsed correctly from the user string: daemon.notice netifd: wan (30476): simple connect=apn=internet,ip-type=ipv4,allow-roaming=yes daemon.notice netifd: wan (30476): Error parsing connect string: 'Invalid properties string, unexpected key 'allow-roaming'' This also goes inline with e.g. the --create-bearer help in the man page that suggests using yes/no for the allow-roaming setting.
2019-09-17plugins,telit: refactor #BND command supportAleksander Morgado
And added support for several new things, including: * Setting "any" band now attempts to set all supported bands. * Added new 2G band value '5' (egsm+dcs+pcs+g850). * Setup support for two different 3G band combinations, a default one plus an alternate one applicable to the LM940/960 models only. The alternate combination is selected via udev tags. During the refactor, the following Telit-specific helpers were also removed and exchanged with more generic counterparts. * mm_telit_bands_contains() -> mm_common_bands_garray_lookup() * mm_telit_get_band_flags_from_string() -> mm_parse_uint_list()
2019-03-29libmm-glib,common: new helper methods to read guint64 valuesAleksander Morgado
We use strtoull() to read a "unsigned long long" that is always at least 64bits, even in 32bit systems.
2018-10-04libmm-glib: use helper function to convert enum/flags from stringThomas Haller
2018-10-04libmm-glib, modem-helpers: unref enum/flags GType classes in enum gettersThomas Haller
2018-08-21libmm-glib: new common helpers to check band typesAleksander Morgado
2018-01-20modem-3gpp: allow loading and changing EPS UE mode of operationAleksander Morgado
The UE modes of operation for LTE are defined in 3GPP TS 24.301 (e.g. section 4.3 in v10.3.0): * PS mode 1: EPS only, 'voice centric' * PS mode 2: EPS only, 'data centric' * CS/PS mode 1: EPS and non-EPS, 'voice centric' * CS/PS mode 2: EPS and non-EPS, 'data centric' The mode specifies, among other things, how the UE should behave w.r.t CS fallback depending on the capabilities reported by the network.
2017-02-10libmm-glib: set clear func by default in the MMModemPortInfo arrayAleksander Morgado
So that we don't leak the port names allocated within each MMModemPortInfo. ==261== 672 bytes in 84 blocks are definitely lost in loss record 7,314 of 7,383 ==261== at 0x402C51E: malloc (vg_replace_malloc.c:299) ==261== by 0x4484878: g_malloc (gmem.c:94) ==261== by 0x449D51D: g_strdup (gstrfuncs.c:363) ==261== by 0x44B5B73: g_variant_dup_string (gvariant.c:1529) ==261== by 0x44B945E: g_variant_valist_get_nnp (gvariant.c:4775) ==261== by 0x44B945E: g_variant_valist_get_leaf (gvariant.c:4945) ==261== by 0x44B945E: g_variant_valist_get (gvariant.c:5126) ==261== by 0x44B922C: g_variant_valist_get (gvariant.c:5161) ==261== by 0x44B9FC9: g_variant_get_va (gvariant.c:5388) ==261== by 0x44BA3C5: g_variant_get_child (gvariant.c:5486) ==261== by 0x6613FA8: mm_common_ports_variant_to_garray (mm-common-helpers.c:238) ==261== by 0x6601AB9: ensure_internal_ports (mm-modem.c:766) ==261== by 0x6603E42: mm_modem_peek_ports (mm-modem.c:825) ==261== by 0x65CD94D: owns_port (nm-modem-broadband.c:196) Reported-by: Piotr Figiel <p.figiel@camlintechnologies.com>
2016-10-12iface-modem: always sort supported and current bands before exposing themAleksander Morgado
2016-09-29core: allow building and running without udevAleksander Morgado
Instead of relying on the udev daemon and GUDev to manage the devices reported by the kernel, we can now run ModemManager relying solely on the kernel events reported via the new ReportKernelEvent() API. Therefore, the '--no-auto-scan' option is implicit for the ModemManager daemon when udev is disabled in the build. Additionally, a new custom implementation of the kernel device object is provided, which uses sysfs to load the properties and attributes required in each kernel device, instead of using a GUdevDevice. The udev rule files are kept in place, and a simple custom parser is provided which preloads all rules in memory once and then applies them to the different kernel objects reported via ReportKernelEvent(), e.g. to set port type hints. A simple unit test setup is prepared to validate the udev rules during the `check' Makefile target.
2016-08-10libmm-glib,helpers: don't warn when trying to read invalid match info indexAleksander Morgado
We may want to use the mm_get_()_from_match_info() calls to read optional items, so that the method returns FALSE if the item index doesn't apply. So, avoid the implicit warning issued by g_return_val_if_fail().