summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2009-10-02 14:52:52 -0500
committerDenis Kenzior <denkenz@gmail.com>2009-10-02 18:25:56 -0500
commitc9a2eedc08b5a7ba625dac3764f176676c11d304 (patch)
treee7ba2479fc2e0609850510cc52c5486e36c2a5d9
parent53496c6a32d36cc694dbb9162048a78de10c4646 (diff)
downloadofono-c9a2eedc08b5a7ba625dac3764f176676c11d304.tar.bz2
Add utility to parse 2G GET_RESPONSE data
This format is described in 51.011 and the older 11.11. It is not supported by newer 3G UICC based devices & sim card combinations
-rw-r--r--drivers/atmodem/sim.c14
-rw-r--r--src/simutil.c22
-rw-r--r--src/simutil.h4
3 files changed, 28 insertions, 12 deletions
diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
index d04b736c..7b8cede3 100644
--- a/drivers/atmodem/sim.c
+++ b/drivers/atmodem/sim.c
@@ -50,7 +50,7 @@ static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer user_data)
const guint8 *response;
gint sw1, sw2, len;
int flen, rlen;
- enum ofono_sim_file_structure str;
+ int str;
unsigned char access[3];
dump_response("at_crsm_info_cb", ok, result);
@@ -82,17 +82,7 @@ static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer user_data)
ofono_debug("crsm_info_cb: %02x, %02x, %i", sw1, sw2, len);
- flen = (response[2] << 8) | response[3];
- str = response[13];
-
- access[0] = response[8];
- access[1] = response[9];
- access[2] = response[10];
-
- if (str == 0x01 || str == 0x03)
- rlen = response[14];
- else
- rlen = 0;
+ sim_parse_2G_get_response(response, len, &flen, &rlen, &str, access);
cb(&error, flen, str, rlen, access, cbd->data);
}
diff --git a/src/simutil.c b/src/simutil.c
index 9cdf8247..2b5db2af 100644
--- a/src/simutil.c
+++ b/src/simutil.c
@@ -573,3 +573,25 @@ struct sim_ef_info *sim_ef_db_lookup(unsigned short id)
return result;
}
+
+gboolean sim_parse_2G_get_response(unsigned char *response, int len,
+ int *file_len, int *record_len,
+ int *structure, unsigned char *access)
+{
+ if (len < 14)
+ return FALSE;
+
+ *file_len = (response[2] << 8) | response[3];
+ *structure = response[13];
+
+ access[0] = response[8];
+ access[1] = response[9];
+ access[2] = response[10];
+
+ if (response[13] == 0x01 || response[13] == 0x03)
+ *record_len = response[14];
+ else
+ *record_len = 0;
+
+ return TRUE;
+}
diff --git a/src/simutil.h b/src/simutil.h
index 4f2d3210..805ead03 100644
--- a/src/simutil.h
+++ b/src/simutil.h
@@ -106,3 +106,7 @@ void sim_adn_build(unsigned char *data, int length,
const char *identifier);
struct sim_ef_info *sim_ef_db_lookup(unsigned short efid);
+
+gboolean sim_parse_2G_get_response(unsigned char *response, int len,
+ int *file_len, int *record_len,
+ int *structure, unsigned char *access);