* [PATCH] Return SIM file access conditions from read_file_info.
@ 2009-07-20 16:11 Andrzej Zaborowski
2009-07-27 23:13 ` Denis Kenzior
0 siblings, 1 reply; 3+ messages in thread
From: Andrzej Zaborowski @ 2009-07-20 16:11 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4837 bytes --]
---
drivers/atmodem/sim.c | 28 +++++++++++++++++++++++-----
src/driver.h | 23 ++++++++++++++++++++++-
src/sim.c | 3 ++-
3 files changed, 47 insertions(+), 7 deletions(-)
diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
index 01b5719..81b566a 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);
}
}
diff --git a/src/driver.h b/src/driver.h
index f324c1c..c730eea 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -101,6 +101,25 @@ 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
@@ -162,7 +181,9 @@ typedef void (*ofono_call_barring_cb_t)(const struct ofono_error *error,
typedef void (*ofono_sim_file_info_cb_t)(const struct ofono_error *error,
int filelength,
enum ofono_sim_file_structure structure,
- int recordlength, void *data);
+ int recordlength,
+ enum ofono_sim_file_access *access,
+ void *data);
typedef void (*ofono_sim_read_cb_t)(const struct ofono_error *error,
const unsigned char *sdata, int length,
diff --git a/src/sim.c b/src/sim.c
index 86f2e98..787ebc7 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -356,7 +356,8 @@ 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, void *data)
+ int record_length,
+ enum ofono_sim_file_access *access, void *data)
{
struct ofono_modem *modem = data;
struct sim_manager_data *sim = modem->sim_manager;
--
1.6.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] Return SIM file access conditions from read_file_info.
2009-07-20 16:11 [PATCH] Return SIM file access conditions from read_file_info Andrzej Zaborowski
@ 2009-07-27 23:13 ` Denis Kenzior
2009-07-27 23:24 ` Andrzej Zaborowski
0 siblings, 1 reply; 3+ messages in thread
From: Denis Kenzior @ 2009-07-27 23:13 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 663 bytes --]
Hi,
I've pushed this patch with some modifications afterward. From reading the
spec myself, I noticed that our interpretations are a 'bit' different.
According to TS 11.11 9.3:
- Read is in byte 9, upper 4 bits
- Update is in byte 9, lower 4 bits
- Increate is in byte 10, upper 4 bits
- Rehabilitate is in byte 11, upper 4 bits
- Invalidate is in byte 11, lower 4 bits
I've reworked the code according to the above spec.
Yet in your implementation they were in bytes 10-12 with lower & upper
swapped. E.g. Read in byte 10, lower 4 bits.
Can you confirm that my interpretation is correct, or am I missing something?
Regards,
-Denis
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Return SIM file access conditions from read_file_info.
2009-07-27 23:13 ` Denis Kenzior
@ 2009-07-27 23:24 ` Andrzej Zaborowski
0 siblings, 0 replies; 3+ messages in thread
From: Andrzej Zaborowski @ 2009-07-27 23:24 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 906 bytes --]
2009/7/28 Denis Kenzior <denkenz@gmail.com>:
> I've pushed this patch with some modifications afterward. From reading the
> spec myself, I noticed that our interpretations are a 'bit' different.
>
> According to TS 11.11 9.3:
> - Read is in byte 9, upper 4 bits
> - Update is in byte 9, lower 4 bits
> - Increate is in byte 10, upper 4 bits
> - Rehabilitate is in byte 11, upper 4 bits
> - Invalidate is in byte 11, lower 4 bits
>
> I've reworked the code according to the above spec.
>
> Yet in your implementation they were in bytes 10-12 with lower & upper
> swapped. E.g. Read in byte 10, lower 4 bits.
>
> Can you confirm that my interpretation is correct, or am I missing something?
Yes, this is correct and I was about to send a new patch for it,
tested on a real SIM. My doc to pdf converter doesn't display the
tables (with bitfields) correctly in GSM specs.
Regards
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-07-27 23:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-20 16:11 [PATCH] Return SIM file access conditions from read_file_info Andrzej Zaborowski
2009-07-27 23:13 ` Denis Kenzior
2009-07-27 23:24 ` Andrzej Zaborowski
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.