diff options
author | James Prestwood <james.prestwood@linux.intel.com> | 2017-11-06 14:37:58 -0800 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2017-11-06 17:09:10 -0600 |
commit | efe436285183ef3e07b5d33822d155423d83ea43 (patch) | |
tree | 929467a77f502beb073b9f2013d6ee1df5aa7a00 /src/sim.c | |
parent | 8f9c2e1a272a84512a1a895ace94b1c6d34864cc (diff) | |
download | ofono-efe436285183ef3e07b5d33822d155423d83ea43.tar.gz |
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.
Diffstat (limited to 'src/sim.c')
-rw-r--r-- | src/sim.c | 44 |
1 files changed, 44 insertions, 0 deletions
@@ -126,6 +126,7 @@ struct ofono_sim { struct sim_fs *simfs_isim; struct ofono_sim_context *context; struct ofono_sim_context *early_context; + struct ofono_sim_context *isim_context; unsigned char *iidf_image; unsigned int *iidf_watch_ids; @@ -138,6 +139,7 @@ struct ofono_sim { GSList *aid_sessions; GSList *aid_list; + char *impi; }; struct msisdn_set_request { @@ -409,6 +411,10 @@ static DBusMessage *sim_get_properties(DBusConnection *conn, ofono_dbus_dict_append(&dict, "ServiceProviderName", DBUS_TYPE_STRING, &sim->spn); + if (sim->impi) + ofono_dbus_dict_append(&dict, "ImsPrivateIdentity", + DBUS_TYPE_STRING, &sim->impi); + fdn = sim->fixed_dialing; ofono_dbus_dict_append(&dict, "FixedDialing", DBUS_TYPE_BOOLEAN, &fdn); @@ -1458,6 +1464,25 @@ static void sim_set_ready(struct ofono_sim *sim) call_state_watches(sim); } +static void impi_read_cb(int ok, int total_length, int record, + const unsigned char *data, + int record_length, void *userdata) +{ + struct ofono_sim *sim = userdata; + + if (!ok) { + DBG("error reading IMPI"); + return; + } + + if (data[0] != 0x80) { + DBG("invalid TLV tag 0x%02x", data[0]); + return; + } + + sim->impi = g_strndup((const char *)data + 2, data[1]); +} + static void discover_apps_cb(const struct ofono_error *error, const unsigned char *dataobj, int len, void *data) @@ -1490,6 +1515,12 @@ static void discover_apps_cb(const struct ofono_error *error, * the FS structure so the ISIM EF's can be accessed. */ sim->simfs_isim = sim_fs_new(sim, sim->driver); + sim->isim_context = ofono_sim_context_create_isim( + sim); + /* attempt to get the NAI from EFimpi */ + ofono_sim_read_bytes(sim->isim_context, + SIM_ISIM_EFIMPI_FILEID, 0, 255, NULL, + 0, impi_read_cb, sim); } iter = g_slist_next(iter); @@ -2551,6 +2582,14 @@ static void sim_free_main_state(struct ofono_sim *sim) sim->context = NULL; } + if (sim->isim_context) { + ofono_sim_context_free(sim->isim_context); + sim->isim_context = NULL; + } + + if (sim->impi) + g_free(sim->impi); + if (sim->aid_sessions) g_slist_free_full(sim->aid_sessions, aid_session_free); } @@ -3410,6 +3449,11 @@ void __ofono_sim_refresh(struct ofono_sim *sim, GSList *file_list, } } +const char *__ofono_sim_get_impi(struct ofono_sim *sim) +{ + return sim->impi; +} + static void open_channel_cb(const struct ofono_error *error, int session_id, void *data); |