Commit Graph

289 Commits

Author SHA1 Message Date
Jonas Bonn 3beeff758d treewide: Remove superfluous use of _GNU_SOURCE
There are a large number of files in the tree that define _GNU_SOURCE
despite not actually using features hidden behind this flag.  This patch
removes all these definitions in one fell swoop...
2018-10-17 10:01:57 -05:00
Denis Kenzior d715486525 sim: Fix not updating sim pin state
In case we try to enter the PIN/PUK and fail to enter a correct code,
the PIN/PUK retries are not rechecked as they should be.

Reported by: Florent Beillonnet <florent.beillonnet@gmail.com>
2018-06-05 12:56:05 -05:00
Denis Kenzior d65a2fc377 sim: Do not leak aid_list
==31530== 366 (48 direct, 318 indirect) bytes in 3 blocks are definitely lost in loss record 165 of 186
==31530==    at 0x4C2BF8F: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==31530==    by 0x50BB3A3: g_malloc (gmem.c:94)
==31530==    by 0x50D62B4: g_slice_alloc (gslice.c:1025)
==31530==    by 0x50D7A1E: g_slist_prepend (gslist.c:254)
==31530==    by 0x4DD0B3: sim_parse_app_template_entries (simutil.c:1590)
==31530==    by 0x4D2242: discover_apps_cb (sim.c:1509)
==31530==    by 0x45E364: at_discover_apps_cb (sim.c:1579)
==31530==    by 0x49CB5F: at_chat_finish_command (gatchat.c:459)
==31530==    by 0x49DAC7: at_chat_handle_command_response (gatchat.c:521)
==31530==    by 0x49DAC7: have_line (gatchat.c:600)
==31530==    by 0x49DAC7: new_bytes (gatchat.c:759)
==31530==    by 0x49FCEF: received_data (gatio.c:122)
==31530==    by 0x510C2F3: g_io_unix_dispatch (giounix.c:165)
==31530==    by 0x50B2D44: g_main_dispatch (gmain.c:3203)
2018-02-28 11:22:46 -06:00
Denis Kenzior 984d88492d sim: Fix crash
aid_sessions was not properly reset to NULL when freed:

Program received signal SIGSEGV, Segmentation fault.
__ofono_watchlist_free (watchlist=0x0) at src/watch.c:91
91		for (l = watchlist->items; l; l = l->next) {
(gdb) bt
    func=0x4ceca0 <aid_session_free>, user_data=0x0)
    at /var/tmp/portage/dev-libs/glib-2.50.3-r1/work/glib-2.50.3/glib/gslist.c:878
    free_func=0x4ceca0 <aid_session_free>)
    at /var/tmp/portage/dev-libs/glib-2.50.3-r1/work/glib-2.50.3/glib/gslist.c:172
    at src/sim.c:2605
    user_data=<optimized out>) at plugins/phonesim.c:511
    func=0x49c8a0 <at_notify_call_callback>, user_data=0x7fffffffdbc0)
    at /var/tmp/portage/dev-libs/glib-2.50.3-r1/work/glib-2.50.3/glib/gslist.c:878
    chat=0x7b70b0) at gatchat/gatchat.c:417
2018-02-28 10:44:26 -06:00
Slava Monich 72758ef34b sim: Don't submit parallel EFpl reads
In addition to not doing unnecessary SIM I/O, this fixes memory leaks
like this one:

==10096== 74 (56 direct, 18 indirect) bytes in 2 blocks are definitely lost in loss record 1,252 of 1,342
==10096==    at 0x4841BF0: calloc (vg_replace_malloc.c)
==10096==    by 0x4B03117: g_malloc0 (gmem.c)
==10096==    by 0xF83DF: concat_lang_prefs (sim.c)
==10096==    by 0xF8697: sim_efpl_read_cb (sim.c)
==10096==    by 0x12CBF7: sim_fs_op_read_block_cb (simfs.c)
2017-12-08 10:23:35 -06:00
Denis Kenzior 9b7d58d85a sim: Remove stale comment 2017-11-08 21:02:22 -06:00
Denis Kenzior 54d56d763e sim: Introduce ofono_sim_initialized_notify
This change is likely to break multiple drivers.  One can easily emulate
the current behavior (pre-this commit) by calling
ofono_sim_initialized_notify after ofono_sim_inserted_notify.
2017-11-08 21:02:22 -06:00
Denis Kenzior 57e0b26f22 sim: Compact all booleans into the bitfield 2017-11-08 21:02:22 -06:00
Denis Kenzior ec3a59afb6 sim: Use gcc's bitfield instead of managing flags 2017-11-08 21:02:22 -06:00
James Prestwood 2564ac717a sim: logical access API implementation
Implemented wrapper for the sim drivers logical
access API
2017-11-07 10:55:01 -06:00
James Prestwood efe4362851 sim: added ImsPrivateIdentity to SimManager
If the ISIM AID is found a new AID based context will be
created and the EFIMPI file will be read from the SIM
which contains the ImsPrivateIdentity.
2017-11-06 17:09:10 -06:00
James Prestwood b754949032 sim: implement create ISIM context
API to create a sim context for the ISIM application, if found.
During AID discovery, if an ISIM AID is found, a new fs object is
initialized for the ISIM which will be used for any future
ISIM context creation.
2017-11-06 16:17:32 -06:00
James Prestwood d0865cbf6e sim: AID session management
Accessing an AID requires opening a channel to that application.
This patch implements session management API's so that other atoms
can access a given AID. Now any atom can get a session ID from the
sim atom. This will either reuse an existing session or open a new
channel. Once done, the atom should release the session which will
automatically close the channel when no atoms are using it.

The major functional change to the sim atom is the AID discovery
phase of initialization. Now, the sim atom is not 'ready' until AID
discovery finishes where before, the sim was 'ready' after the IMSI
had been obtained. If application discovery is not supported then
the the sim atom behaves as it did before.
2017-11-03 17:51:04 -05:00
Slava Monich 30c742439d sim: Move atom registration to the end of ofono_sim_register
The state needs to be checked prior to calling __ofono_atom_register
because atom registration calls OFONO_ATOM_WATCH_CONDITION_REGISTERED
callbacks each of which may call ofono_sim_inserted_notify. Should
that happen, by the time __ofono_atom_register returns, ofono_sim
will be in OFONO_SIM_STATE_INSERTED state and sim_initialize will
be called twice if the initial state was OFONO_SIM_STATE_NOT_PRESENT.
If nothing else, that results in memory leaks like this one (because
IMSI will be queried twice, among other things):

==3017== 16 bytes in 1 blocks are definitely lost in loss record 187 of 475
==3017==    at 0x483F380: malloc (vg_replace_malloc.c:296)
==3017==    by 0x4AFB0DF: g_malloc (gmem.c:94)
==3017==    by 0x4B12185: g_strdup (gstrfuncs.c:363)
==3017==    by 0xF79D3: sim_imsi_obtained (sim.c:1535)
==3017==    by 0xF7BB3: sim_imsi_cb (sim.c:1594)
==3017==    by 0x66C23: at_cimi_cb (sim.c:441)
==3017==    by 0xA6B53: at_chat_finish_command (gatchat.c:459)
==3017==    by 0xA6D9F: at_chat_handle_command_response (gatchat.c:521)
==3017==    by 0xA70AF: have_line (gatchat.c:600)
==3017==    by 0xA76DF: new_bytes (gatchat.c:759)
==3017==    by 0xABACF: received_data (gatio.c:122)
==3017==    by 0xAD093: watch_dispatch (gatmux.c:461)
==3017==    by 0xAC5D3: dispatch_sources (gatmux.c:180)
==3017==    by 0xAC98F: received_data (gatmux.c:265)
==3017==    by 0x4AF606F: g_main_dispatch (gmain.c:3154)
==3017==    by 0x4AF606F: g_main_context_dispatch (gmain.c:3769)
==3017==    by 0x4AF631D: g_main_context_iterate.isra.4 (gmain.c:3840)
==3017==    by 0x4AF658F: g_main_loop_run (gmain.c:4034)
==3017==    by 0xBE8AF: main (main.c:261)
2017-10-27 08:56:10 -05:00
James Prestwood a8f609727d sim: new API to check for a UST service only
The existing service check API takes both SST and UST services
and could inadvertently return success on a service if one
(SST or UST) service did not exist. This adds an API specifically
for checking for a UST service, and if the UST dir is not available
it will return FALSE, rather than possibly returning true on some
other SST service.
2017-10-11 10:31:10 -05:00
Christophe Ronco c5fbfaa55f sim: backup driver read_imsi by IMSI via EF read
If read_imsi driver function fails, try to obtain IMSI via EF read
2017-01-09 12:25:00 -06:00
Slava Monich aaf70beb06 sim: Stop facility lock query sequence on removal
SIM card can be removed while the query is in progress. There's
still a remote possibility that SIM card is removed and inserted
back while the query is pending, that would start the second query
sequence and end up invoking sim_initialize() twice. But at least
these checks reduce the probability of something like that happening.
2017-01-06 12:25:48 -06:00
Samrat Guha Niyogi 27f9da901f sim: remove locked_pin reset from sim_free_main_state 2016-08-08 21:17:22 -05:00
Denis Kenzior 3b5475d942 sim: Fix style 2016-08-06 10:52:30 -05:00
Samrat Guha Niyogi 162f6985e3 sim: query facility during initialization in chain manner
query facility during initialization is modified from back
to back invocation to chain manner to keep it inline with
RIL design. All vendor RIL does not support back to back
handling since RIL telephony framework sends the request
synchronously.
2016-08-06 10:50:27 -05:00
Denis Kenzior f4a90e5e0d sim: return false for SIM_PASSWORD_NONE 2016-07-20 16:26:42 -05:00
Slava Monich 103e8fd42e sim: Query the status of SC facility lock 2016-07-06 11:12:21 -05:00
Samrat Guha Niyogi 7b2f8b0f6e sim: Query the status of PS and PN facility locks 2016-04-27 11:01:09 -05:00
John Ernberg d8821a48d0 sim: Remove explicit casts 2016-04-22 15:40:43 -05:00
Caiwen Zhang 66160f9b63 sim: fix crash when going into state LOCKED_OUT
After input PIN wrong 3 times, sim main state (include spn_watches)
is freed. but the watch id still be kept by other atoms (network and
gprs), when remove the atom, it will try to remove the watch from
spn_watches, ofono daemon will crash.
2016-04-20 21:28:10 -05:00
Slava Monich 5e4ce76bba sim: Implement ServiceProviderName property 2016-01-27 10:42:09 -06:00
Denis Kenzior 48da783732 sim: Fix up whitespace issues 2015-06-18 14:59:06 -05:00
Tommi Kenakkala eebe2f3ac2 Emit LockedPins after pin_type is queried
Fixes property change not being emited when hot-swapping a
PIN-enabled card.
2015-06-18 14:56:05 -05:00
Tommi Kenakkala 4677729502 sim: Reset pin_type on card remove
Fixes PinRequired not being emitted when a card is inserted
2015-06-17 23:09:03 -05:00
Denis Kenzior 7dca0a7315 sim: Fix pin retries bogus values on some arch-es
On some architectures the SimManager.Retries property was getting bogus
values.  This is because we were sending an array which pointed to int
values instead of the expected unsigned char values.

This fix allocates a temporary array of unsigned chars to hold the
actual D-Bus values being sent.  Additionally, the dictionary array is
changed to point to the temporary unsigned char based values instead of
the raw 'int' based retry values.
2014-12-04 08:57:48 -06:00
Denis Kenzior 509630ea98 sim: Fix crash
ofonod[32055]: ++++++++ backtrace ++++++++
ofonod[32055]: #0  0x7f6af0ee3b30 in /lib64/libc.so.6
ofonod[32055]: #1  0x4c2466 in __ofono_watchlist_remove_item() at
src/watch.c:57
ofonod[32055]: #2  0x4b5b73 in ofono_sim_remove_spn_watch() at
src/sim.c:2715
ofonod[32055]: #3  0x497c30 in netreg_unregister() at src/network.c:1817
ofonod[32055]: #4  0x4912e1 in __ofono_atom_unregister() at
src/modem.c:277
ofonod[32055]: #5  0x491387 in flush_atoms() at src/modem.c:425
ofonod[32055]: #6  0x4b6cb8 in __ofono_sim_refresh() at src/sim.c:3154
ofonod[32055]: #7  0x4b8c41 in handle_command_refresh() at
src/stk.c:2302
ofonod[32055]: #8  0x4baf0d in
ofono_stk_proactive_command_handled_notify() at src/stk.c:3048
ofonod[32055]: #9  0x46c60f in satn_notify() at
drivers/ifxmodem/stk.c:229
ofonod[32055]: #10 0x7f6af1711455 in /usr/lib64/libglib-2.0.so.0
ofonod[32055]: #11 0x43e729 in at_chat_match_notify() at
gatchat/gatchat.c:421
ofonod[32055]: #12 0x440da8 in received_data() at gatchat/gatio.c:125
ofonod[32055]: #13 0x441834 in dispatch_sources() at
gatchat/gatmux.c:157
ofonod[32055]: #14 0x441bbd in received_data() at gatchat/gatmux.c:215
ofonod[32055]: #15 0x7f6af173dfc3 in /usr/lib64/libglib-2.0.so.0
ofonod[32055]: #16 0x7f6af16ef065 in /usr/lib64/libglib-2.0.so.0
ofonod[32055]: #17 0x7f6af16efd0f in /usr/lib64/libglib-2.0.so.0
ofonod[32055]: #18 0x7f6af16efef9 in /usr/lib64/libglib-2.0.so.0
ofonod[32055]: #19 0x7f6af16f032f in /usr/lib64/libglib-2.0.so.0
ofonod[32055]: #20 0x48f5f8 in main() at src/main.c:249
ofonod[32055]: #21 0x7f6af0ed04bd in /lib64/libc.so.6
ofonod[32055]: +++++++++++++++++++++++++++
2012-11-28 10:31:14 -06:00
Denis Kenzior 00b37a5e64 sim: Fix crash
When modem is brought online, then sim removed and re-inserted.  We
crash when going online again due to the spn related data-structures not
being initialized properly
2012-11-28 10:31:14 -06:00
Denis Kenzior 736f44e0d3 sim: Read icons with a full SIM/USIM path 2012-11-23 07:22:25 -06:00
Denis Kenzior 19210edd3a sim: Update to the new sim reading API 2012-11-22 10:26:34 -06:00
Denis Kenzior b97e79b3df sim: Fix SIM re-init case of SIM Refresh
When the SIM is being refreshed, we try to access the SIM too fast after
the SIM REFRESH proactive command is received.  Instead set the sim atom
into the 'RESETTING' state and wait until the modem driver signals the
sim insertion again.
2012-11-22 06:50:08 -06:00
Denis Kenzior 454ca9f40e sim: destroy spn info as part of sim main state 2012-11-22 06:50:08 -06:00
August Mayer 22c0738981 sim: implement function to get password type 2012-08-16 00:59:18 -05:00
Marcel Holtmann 674cb0d167 sim: Add extra errors for EFmsisdn and EFad length mismatches 2012-06-25 00:00:45 -07:00
Denis Kenzior 72ce19bf3e sim: Fix use of uninitialized values
In the case of an error, sim_pin_query_cb should not assume the
pin_type value is valid.
2012-06-19 12:59:42 -05:00
Denis Kenzior d69269b77f sim: Don't re-init the SIM needlessly
When calling ChangePin with the wrong original PIN, we're still left in
the READY state.  Do not re-initialize the SIM needlessly in this case.
2012-06-19 12:54:37 -05:00
Denis Kenzior bc38ef91cd sim: Allow IMSI to be obtained via EF reads 2012-06-17 08:01:04 -05:00
Denis Kenzior e0e6e2c439 sim: Revert adding special callback for EFiccid
This reverts commit 1960dbbc79.
2012-06-16 09:50:05 -05:00
Denis Kenzior a8247d17af sim: Revert adding special callback for EFmsisdn
This reverts commit c3124b66d9.
2012-06-16 09:50:05 -05:00
Denis Kenzior bee063dd76 sim: Revert adding special callback for EFad
This reverts commit 5522df64fa.
2012-06-16 09:50:05 -05:00
Marcel Holtmann 5522df64fa sim: Add special callback for reading MCC and MNC value 2012-06-16 21:30:28 -07:00
Marcel Holtmann c3124b66d9 sim: Add special callback for reading MSISDN value 2012-06-16 20:52:18 -07:00
Marcel Holtmann 1960dbbc79 sim: Add special callback for reading ICCID value 2012-06-16 20:22:30 -07:00
Marcel Holtmann 10297b153a sim: Use ofono_bool_t instead of gboolean 2012-06-16 20:08:10 -07:00
Lucas De Marchi e0d6f9f0ce Do not set signature and reply in GDBus tables
Use GDBUS_* macros, so signature and reply fields are not set in each
method/signal.
2012-05-20 02:47:57 -07:00
Lucas De Marchi b3489f2ee8 Convert GDBus methods to use macro helpers
With these macro helpers we can separate in/out arguments and use their
own vector.
2012-05-20 02:47:57 -07:00