diff options
Diffstat (limited to 'drivers/atmodem/sim.c')
-rw-r--r-- | drivers/atmodem/sim.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c index 01b5719b..81b566ae 100644 --- a/drivers/atmodem/sim.c +++ b/drivers/atmodem/sim.c @@ -40,6 +40,13 @@ static const char *crsm_prefix[] = { "+CRSM:", NULL }; +static inline enum ofono_sim_file_access file_access_condition_decode(int bcd) +{ + if (bcd >= 4 && bcd <= 14) + return OFONO_SIM_FILE_ACCESS_ADM; + return bcd; +} + static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer user_data) { struct cb_data *cbd = user_data; @@ -50,12 +57,13 @@ static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer user_data) gint sw1, sw2, len; int flen, rlen; enum ofono_sim_file_structure str; + enum ofono_sim_file_access access[__OFONO_SIM_FILE_CONDITION_NUM]; dump_response("at_crsm_info_cb", ok, result); decode_at_error(&error, g_at_result_final_response(result)); if (!ok) { - cb(&error, -1, -1, -1, cbd->data); + cb(&error, -1, -1, -1, NULL, cbd->data); return; } @@ -64,7 +72,7 @@ static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer user_data) if (!g_at_result_iter_next(&iter, "+CRSM:")) { DECLARE_FAILURE(e); - cb(&e, -1, -1, -1, cbd->data); + cb(&e, -1, -1, -1, NULL, cbd->data); return; } @@ -78,7 +86,7 @@ static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer user_data) (response[13] == 0x01 && len < 15)) { DECLARE_FAILURE(e); - cb(&e, -1, -1, -1, cbd->data); + cb(&e, -1, -1, -1, NULL, cbd->data); return; } @@ -86,13 +94,23 @@ static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer user_data) flen = (response[2] << 8) | response[3]; str = response[13]; + access[OFONO_SIM_FILE_CONDITION_UPDATE] = + file_access_condition_decode((response[9] >> 4) & 0xf); + access[OFONO_SIM_FILE_CONDITION_READ] = + file_access_condition_decode((response[9] >> 0) & 0xf); + access[OFONO_SIM_FILE_CONDITION_INCREASE] = + file_access_condition_decode((response[10] >> 0) & 0xf); + access[OFONO_SIM_FILE_CONDITION_INVALIDATE] = + file_access_condition_decode((response[11] >> 4) & 0xf); + access[OFONO_SIM_FILE_CONDITION_REHABILITATE] = + file_access_condition_decode((response[11] >> 0) & 0xf); if (str == 0x01) rlen = response[14]; else rlen = 0; - cb(&error, flen, str, rlen, cbd->data); + cb(&error, flen, str, rlen, access, cbd->data); } static void at_sim_read_info(struct ofono_modem *modem, int fileid, @@ -118,7 +136,7 @@ error: { DECLARE_FAILURE(error); - cb(&error, -1, -1, -1, data); + cb(&error, -1, -1, -1, NULL, data); } } |