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
This commit is contained in:
Denis Kenzior 2009-10-02 14:52:52 -05:00
parent 53496c6a32
commit c9a2eedc08
3 changed files with 28 additions and 12 deletions

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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);