aboutsummaryrefslogtreecommitdiff
path: root/src/mm-base-sim.c
AgeCommit message (Collapse)Author
2025-05-11base-sim: Setup auth provider and its cancellableMaciej S. Szmigiero
Otherwise we'll get a NULL pointer dereference segfault in mm_auth when sending SIM PIN. Looks like MMBaseSim was accidentally missed during the conversion done by the commit in the Fixes tag below. Fixes: ef5cee3ab578 ("auth-provider: move auth provider logic into each class") Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2025-05-08Move log parent and connection property binding to helperDan Williams
Continues removing usage of MMBaseModem in a bunch of files by splitting out bits of its usage to separate interfaces. Signed-off-by: Dan Williams <dan@ioncontrol.co>
2025-05-08auth-provider: move auth provider logic into each classDan Williams
Rather than make all of them rely on MMBaseModem for it. This lets us disentangle dependencies for easier unit testing. For interfaces, rather than casting directly to MMBaseModem use intermediate interfaces (MMIfaceAuth and MMIfaceOpLock) that tests can fake out. Signed-off-by: Dan Williams <dan@ioncontrol.co>
2024-09-25sim: add common helpers to parse operator name and mnc lengthMichal Mazur
2024-05-08base-sim: avoid printing IMSI/ICCID and others twiceAleksander Morgado
The logic initializing the SIM object already prints the loaded fields, taking into account that some of them should be treated as personal info (so redacted by default). [modem0/sim0] loaded SIM identifier: 8988211000000123456 [modem0/sim0] loaded SIM identifier: ### [modem0/sim0] loaded IMSI: 901700000012345 [modem0/sim0] loaded IMSI: ###
2024-03-13base-sim: log user requestsAleksander Morgado
2023-12-01base-sim: increase operator identifier loading timeoutPetr Krasnoshchekov
SIMCOM A760xE-H modems can answer to AT+CRSM=176,28589,0,0,4 request in 10s or more, so use rather big timeout (20s)
2023-10-27core: ensure all errors returned in DBus operations are normalizedAleksander Morgado
We want to ensure that all errors reported via DBus operations are normalized to MM-specific errors. We don't want to return QMI or MBIM specific errors, as those are protocol specific and we don't want DBus clients to need to rely on knowing which is the protocol in use by the device.
2022-11-04base-sim: include GID1/GID2 loaded values in info levelAleksander Morgado
2022-11-04base-sim: decrease severity of logs that don't affect functionalityAleksander Morgado
Instead of warning about various unimportant things failing that don't affect functionality, just print the logs in debug level and go on. E.g. this warning can be completely skipped: <wrn> [modem0/sim0] couldn't load GID2: Couldn't read data from UIM: QMI protocol error (16): 'NotProvisioned'
2022-11-04base-sim: improve logging during initializationAleksander Morgado
We will print all the loaded SIM contents, treating as personal info the SIM ICCID, IMSI and EID.
2022-11-04core,log: new 'MSG' log level between 'INFO' and 'WARN'Aleksander Morgado
We're bumping the current "INFO" level messages to the new "MSG" level, also making the new level the default. The old "INFO" level will be used to setup an intermediate level of logging which is not as verbose as "DEBUG" but still provides some capabilities to analyze the behavior of a modem.
2022-11-03base-sim: fix length when reading GID1/GID2Aleksander Morgado
We were attempting to read 15 bytes unconditionally, regardless of the size of the EF_gid1 and EF_gid2 files. This operation would succeed in some SIM cards even if the actual file lengths are shorter: AT+CRSM=176,28478,0,0,15 +CRSM: 144,0,"FFFF" OK But the operation would fail in some other SIM cards due to the length mismatch: AT+CRSM=176,28478,0,0,15 +CRSM: 103,0 OK Using 0 as requested length instructs the modem to read the length specified in the EF status information, which is also the same approach we do in QMI and MBIM. AT+CRSM=176,28478,0,0,0 +CRSM: 144,0,"FFFF" OK
2022-10-27base-sim: fix loading GID2Aleksander Morgado
We were not even trying to load it if GID1 was successfully loaded.
2022-09-30base-sim: implement GID1 and GID2 loading using AT commandsAleksander Morgado
2022-08-19base-sim: add steps to load GID1 and GID2 during initAleksander Morgado
2022-05-25iface-modem: skip setting up carrier config on esim without profilesAleksander Morgado
2022-05-25base-sim: skip loading SIM identifier in eSIM without profilesAleksander Morgado
2022-05-25base-sim: disallow SIM user operations in eSIM without profilesAleksander Morgado
2022-05-25base-sim: skip loading SIM properties based on SIM typeAleksander Morgado
If the reported eSIM doesn't have profiles, there is no point in trying to load properties like ICCID, IMSI or operator name/id. If the reported SIM is a physical SIM, there is no point in trying to load properties like EID or eSIM status.
2022-05-25base-sim: don't reload properties that may have been already initializedAleksander Morgado
If we created the SIM objects during the SIM slots processing, we should not attempt to reload the settings that were already set during the re-initialization, as that may end up clearing the initial properties.
2022-05-25base-sim: remove bogus comments in initializationAleksander Morgado
All properties loaded during initialization are meant to be loaded only once, no point in saying that for each property.
2022-05-20iface-modem: common SIM event reporting logicAleksander Morgado
We no longer have separate mm_base_modem_process_sim_event() and mm_broadband_modem_sim_hot_swap_detected() methods. The only difference between both of them was that one of them would attempt to cleanup the ports context associated to the SIM hot swap event logic as soon as a swap was detected, in order to avoid queueing up multiple such events. The previous logic wasn't working well, though, as there could be mixed AT+QMI or AT+MBIM devices that would also require that same cleanup and so we didn't always know which one should have been called. Now we have a single mm_iface_modem_process_sim_event() method, which will trigger the reprobe and disabling, but which will also perform the cleanup of the SIM ports swap setup as specified by the implementation. So, if a plugin explicitly initializes the serial ports context for SIM hot swap handling, it should also explicitly clean it up. Also, the initialization of the serial ports context for SIM hot swap handling is no longer done automatically for all modems, it will be done only for those modems using it; i.e. the modems that explicitly report support SIM hot swap handling using AT URCs.
2021-12-11base-sim: new 'SimType', 'Removability' and 'EsimStatus' propertiesAleksander Morgado
We implement the methods to load the properties during SIM object initialization.
2021-12-11base-sim: reorder init ready() methodsAleksander Morgado
The ready() methods for each step in the initialization sequence must be ordered from bottom to top, so that we can read the logic in that same order.
2021-05-22base-sim: ignore personalization locks after SIM unlockMichal Mazur
2021-03-12base-sim: allow disabling CPOL based preferred networks featuresAleksander Morgado
2021-03-12base-sim: select the desired format for loading preferred networksTeijo Kinnunen
Before invoking AT+CPOL? for loading preferred networks list from SIM, AT+CPOL=,2 is executed to make sure that the returned operator codes are in expected (numeric) format.
2021-03-09modem-helpers,mm-base-sim: Sim.SetPreferredNetworks AT implementationTeijo Kinnunen
Implement Sim.SetPreferredNetworks method by using the AT+CPOL command.
2021-03-09api,sim: add new Sim.SetPreferredNetworks methodTeijo Kinnunen
This commit includes D-Bus processing and documentation, but not any modem access implementation.
2021-03-09base-sim: select PLMN list before reading preferred networksTeijo Kinnunen
Before reading preferred network list with AT+CPOL?, AT+CPLS=0 is now invoked first to make sure that the correct PLMN list (i.e. user-defined) is selected.
2021-02-26libmm-glib,modem-helpers,mm-base-sim: implement Sim.PreferredNetworksTeijo Kinnunen
The ModemManager1.Sim.PreferredNetworks property contains the preferred networks (and access technologies, if available) configured to the SIM card. This commit implements preferred networks reading with AT+CPOL.
2021-02-23charsets: make charset_gsm_unpacked_to_utf8() privateAleksander Morgado
Use the generic mm_modem_charset_bytearray_to_utf8() instead.
2021-02-23charsets: make translit optional in gsm_unpacked_to_utf8()Aleksander Morgado
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-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: 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-11-26base-sim: Reprobe modem if puk lock is discovered after sending pin1Pavan Holla
Enabling/Disabling/Changing/Sending the PIN1 lock is usually limited to 3 retries. If these attempts are exhausted, the modem is puk_locked. We reprobe the modem to get rid of any unwanted interfaces and move to a locked state.
2020-11-26base-sim: Reprobe modem if lock status cannot be read after sending pukPavan Holla
If the lock status cannot be read during a puk unblock attempt, reprobe the modem. It is likely that the SIM was permanently blocked if the lock status cannot be read.
2020-10-19mm-shared-qmi: load EID during SIM slot loadingEric Caruso
SIMs can be created with an EID fetched during load_sim_slots while initializing the modem, if present. Since load_eid would be implemented with the same mechanism we avoid using it here (if Get Slot Status fails once, it probably doesn't make a lot of sense to try it again).
2020-10-19mm-base-sim: add EID D-Bus propertyEric Caruso
This provides a new D-Bus property on the Sim object that exposes the EID of the SIM, if available.
2020-08-28base-sim: allow explicit wait for SIM readiness during initializationAleksander Morgado
Before attempting to load any SIM property value, allow checking whether the SIM is ready for operation or not. This action is implicitly done by the "unlock required check" step that is triggered before initializing the primary SIM card, but it would not be done when initializing other available SIM cards.
2020-08-28base-sim: allow creating preinitialized SIM objectsAleksander Morgado
The default SIM creation method will attempt to initialize the SIM properties during the object creation. This new method allows creating SIM objects with already known property values, and therefore not explicitly running the asynchronous initialization process.
2020-08-28base-sim: new 'slot number' propertyAleksander Morgado
This new property helps us identify in which SIM slot the SIM card is inserted, when multiple slots are available, in the [1,N] range. For the single-SIM systems this value will always be '0'. This property is not publicly exposed in DBus, it is considered an implementation detail.
2020-08-28base-sim: only allow operations on active SIMsAleksander Morgado
If a SIM is inactive we cannot perform any SIM-PIN or SIM-PUK related operation with it.
2020-08-28api,sim: new 'Active' propertyAleksander Morgado
In preparation for the multi-SIM setup, we need a way to tell whether a given SIM card is active or not in the system. On systems with one single SIM slot, the available SIM card will always be active. On Multi-SIM Single-Standby setups we may have multiple SIM slots with multiple SIM cards, but only one of them will be active at any given time. On Multi-SIM Multi-Standby setups we may have multiple SIM slots with multiple SIM cards that may be active at the same time. E.g. the QMI protocol allows up to 5 different active SIM cards (primary, secondary, tertiary...).
2020-04-08base-sim: port to use object loggingAleksander Morgado
2020-04-08base-sim: set dbus id as soon as object is createdAleksander Morgado
2020-02-12base-sim: don't allow sending PIN/PUK if not requiredAleksander Morgado
This avoids issues when e.g. sending SIM-PIN while the modem is already unlocked or when SIM-PIN is not enabled. Under those conditions, the needlessly sent SIM-PIN unlock attempt may fail while libmm-glib/mmcli reports a successful operation. E.g.: # mmcli --sim=/org/freedesktop/ModemManager1/SIM/0 --pin=3497 successfully sent PIN code to the SIM But in reality... Wed Nov 20 14:38:52 2019 daemon.debug [4254]: <debug> [1574260732.489513] Verifying PIN... Wed Nov 20 14:38:52 2019 daemon.debug [4254]: [/dev/cdc-wdm0] sent message... <<<<<< RAW: <<<<<< length = 27 <<<<<< data = 01:1A:00:00:0B:02:00:09:00:26:00:0E:00:02:06:00:01:04:33:34:39:37:01:02:00:06:00 Wed Nov 20 14:38:52 2019 daemon.debug [4254]: [/dev/cdc-wdm0] sent generic request (translated)... <<<<<< QMUX: <<<<<< length = 26 <<<<<< flags = 0x00 <<<<<< service = "uim" <<<<<< client = 2 <<<<<< QMI: <<<<<< flags = "none" <<<<<< transaction = 9 <<<<<< tlv_length = 14 <<<<<< message = "Verify PIN" (0x0026) <<<<<< TLV: <<<<<< type = "Info" (0x02) <<<<<< length = 6 <<<<<< value = 01:04:33:34:39:37 <<<<<< translated = [ pin_id = 'pin1' pin_value = '3497' ] Wed Nov 20 14:38:52 2019 daemon.debug [4254]: [/dev/cdc-wdm0] received message... <<<<<< RAW: <<<<<< length = 30 <<<<<< data = 01:1D:00:80:0B:02:02:09:00:26:00:11:00:02:04:00:01:00:52:00:13:02:00:69:84:10:02:00:03:0A Wed Nov 20 14:38:52 2019 daemon.debug [4254]: [/dev/cdc-wdm0] received generic response (translated)... <<<<<< QMUX: <<<<<< length = 29 <<<<<< flags = 0x80 <<<<<< service = "uim" <<<<<< client = 2 <<<<<< QMI: <<<<<< flags = "response" <<<<<< transaction = 9 <<<<<< tlv_length = 17 <<<<<< message = "Verify PIN" (0x0026) <<<<<< TLV: <<<<<< type = "Result" (0x02) <<<<<< length = 4 <<<<<< value = 01:00:52:00 <<<<<< translated = FAILURE: AccessDenied As we already know what the current lock status is, just abort the user operation if the unlock operation isn't required.
2020-02-12base-sim: avoid using 'self' to refer to the modemAleksander Morgado