summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/atmodem/sim.c26
-rw-r--r--src/driver.h21
-rw-r--r--src/sim.c22
-rw-r--r--src/simutil.h17
4 files changed, 39 insertions, 47 deletions
diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
index 81b566ae..bfee723d 100644
--- a/drivers/atmodem/sim.c
+++ b/drivers/atmodem/sim.c
@@ -40,13 +40,6 @@
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;
@@ -57,7 +50,7 @@ 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];
+ unsigned char access[3];
dump_response("at_crsm_info_cb", ok, result);
decode_at_error(&error, g_at_result_final_response(result));
@@ -94,18 +87,11 @@ 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)
+
+ access[0] = response[8];
+ access[1] = response[9];
+ access[2] = response[10];
+
rlen = response[14];
else
rlen = 0;
diff --git a/src/driver.h b/src/driver.h
index dfd28a0f..928c20a2 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -101,25 +101,6 @@ enum ofono_sim_file_structure {
OFONO_SIM_FILE_STRUCTURE_CYCLIC = 3
};
-/* 51.011 Section 9.3 */
-enum ofono_sim_file_access {
- OFONO_SIM_FILE_ACCESS_ALWAYS = 0,
- OFONO_SIM_FILE_ACCESS_CHV1 = 1,
- OFONO_SIM_FILE_ACCESS_CHV2 = 2,
- OFONO_SIM_FILE_ACCESS_RESERVED = 3,
- OFONO_SIM_FILE_ACCESS_ADM = 4,
- OFONO_SIM_FILE_ACCESS_NEVER = 15,
-};
-
-enum ofono_sim_file_condition {
- OFONO_SIM_FILE_CONDITION_READ = 0,
- OFONO_SIM_FILE_CONDITION_UPDATE,
- OFONO_SIM_FILE_CONDITION_INCREASE,
- OFONO_SIM_FILE_CONDITION_INVALIDATE,
- OFONO_SIM_FILE_CONDITION_REHABILITATE,
- __OFONO_SIM_FILE_CONDITION_NUM,
-};
-
/* Notification functions, the integer values here should map to
* values obtained from the modem. The enumerations are the same
* as the values for the fields found in 3GPP TS 27.007
@@ -182,7 +163,7 @@ typedef void (*ofono_sim_file_info_cb_t)(const struct ofono_error *error,
int filelength,
enum ofono_sim_file_structure structure,
int recordlength,
- enum ofono_sim_file_access *access,
+ const unsigned char access[3],
void *data);
typedef void (*ofono_sim_read_cb_t)(const struct ofono_error *error,
diff --git a/src/sim.c b/src/sim.c
index 8119b5c3..ff4e63dc 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -417,30 +417,38 @@ static gboolean sim_op_retrieve_next(gpointer user)
static void sim_op_info_cb(const struct ofono_error *error, int length,
enum ofono_sim_file_structure structure,
int record_length,
- enum ofono_sim_file_access *access, void *data)
+ const unsigned char access[3], void *data)
{
struct ofono_modem *modem = data;
struct sim_manager_data *sim = modem->sim_manager;
struct sim_file_op *op = g_queue_peek_head(sim->simop_q);
-
char *imsi = sim->imsi;
char *path;
unsigned char fileinfo[6];
int fd = -1;
+ enum sim_file_access update;
+ enum sim_file_access invalidate;
+ enum sim_file_access rehabilitate;
if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
sim_op_error(modem);
return;
}
+ /* TS 11.11, Section 9.3 */
+ update = file_access_condition_decode(access[0] & 0xf);
+ rehabilitate = file_access_condition_decode((access[2] >> 4) & 0xf);
+ invalidate = file_access_condition_decode(access[2] & 0xf);
+
op->structure = structure;
op->length = length;
/* Never cache card holder writable files */
- op->cache = (
- access[OFONO_SIM_FILE_CONDITION_UPDATE] ==
- OFONO_SIM_FILE_ACCESS_ADM ||
- access[OFONO_SIM_FILE_CONDITION_UPDATE] ==
- OFONO_SIM_FILE_ACCESS_NEVER);
+ op->cache = (update == SIM_FILE_ACCESS_ADM ||
+ update == SIM_FILE_ACCESS_NEVER) &&
+ (invalidate == SIM_FILE_ACCESS_ADM ||
+ invalidate == SIM_FILE_ACCESS_NEVER) &&
+ (rehabilitate == SIM_FILE_ACCESS_ADM ||
+ rehabilitate == SIM_FILE_ACCESS_NEVER);
if (structure == OFONO_SIM_FILE_STRUCTURE_TRANSPARENT)
op->record_length = length;
diff --git a/src/simutil.h b/src/simutil.h
index d74706a2..d6526fca 100644
--- a/src/simutil.h
+++ b/src/simutil.h
@@ -27,6 +27,16 @@ enum sim_fileid {
SIM_EFSPDI_FILEID = 0x6fcd,
};
+/* 51.011 Section 9.3 */
+enum sim_file_access {
+ SIM_FILE_ACCESS_ALWAYS = 0,
+ SIM_FILE_ACCESS_CHV1 = 1,
+ SIM_FILE_ACCESS_CHV2 = 2,
+ SIM_FILE_ACCESS_RESERVED = 3,
+ SIM_FILE_ACCESS_ADM = 4,
+ SIM_FILE_ACCESS_NEVER = 15,
+};
+
#define SIM_EFSPN_DC_HOME_PLMN_BIT 0x1
#define SIM_EFSPN_DC_ROAMING_SPN_BIT 0x2
@@ -59,3 +69,10 @@ struct sim_spdi *sim_spdi_new(const guint8 *tlv, int length);
gboolean sim_spdi_lookup(struct sim_spdi *spdi,
const char *mcc, const char *mnc);
void sim_spdi_free(struct sim_spdi *spdi);
+
+static inline enum sim_file_access file_access_condition_decode(int bcd)
+{
+ if (bcd >= 4 && bcd <= 14)
+ return SIM_FILE_ACCESS_ADM;
+ return bcd;
+}