From be55ba4ab3e706caa9cbc6c854e78d045c723f9a Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Fri, 2 Oct 2009 14:02:28 -0500 Subject: Refactor: Move elementary file type checking Every single EF read callback checks the file type reported out of the SIM is what it expects. Instead this should be done in one place and the errors reported accordingly --- src/cbs.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) (limited to 'src/cbs.c') diff --git a/src/cbs.c b/src/cbs.c index fd050302..9cffb6bf 100644 --- a/src/cbs.c +++ b/src/cbs.c @@ -514,9 +514,7 @@ struct ofono_cbs *ofono_cbs_create(struct ofono_modem *modem, return cbs; } -static void sim_cbmi_read_cb(int ok, - enum ofono_sim_file_structure structure, - int length, int record, +static void sim_cbmi_read_cb(int ok, int length, int record, const unsigned char *data, int record_length, void *userdata) { @@ -528,9 +526,6 @@ static void sim_cbmi_read_cb(int ok, if (!ok) return; - if (structure != OFONO_SIM_FILE_STRUCTURE_TRANSPARENT) - return; - if ((length % 2) == 1 || length < 2) return; @@ -570,9 +565,7 @@ static void sim_cbmi_read_cb(int ok, cbs->efcbmi_contents = NULL; } -static void sim_cbmir_read_cb(int ok, - enum ofono_sim_file_structure structure, - int length, int record, +static void sim_cbmir_read_cb(int ok, int length, int record, const unsigned char *data, int record_length, void *userdata) { @@ -585,9 +578,6 @@ static void sim_cbmir_read_cb(int ok, if (!ok) return; - if (structure != OFONO_SIM_FILE_STRUCTURE_TRANSPARENT) - return; - if ((length % 4) != 0) return; @@ -629,9 +619,7 @@ static void sim_cbmir_read_cb(int ok, cbs->efcbmir_contents = NULL; } -static void sim_cbmid_read_cb(int ok, - enum ofono_sim_file_structure structure, - int length, int record, +static void sim_cbmid_read_cb(int ok, int length, int record, const unsigned char *data, int record_length, void *userdata) { @@ -643,9 +631,6 @@ static void sim_cbmid_read_cb(int ok, if (!ok) return; - if (structure != OFONO_SIM_FILE_STRUCTURE_TRANSPARENT) - return; - if ((length % 2) == 1 || length < 2) return; @@ -689,11 +674,14 @@ static void cbs_got_imsi(struct ofono_cbs *cbs) ofono_debug("Got IMSI: %s", imsi); ofono_sim_read(cbs->sim, SIM_EFCBMI_FILEID, - sim_cbmi_read_cb, cbs); + OFONO_SIM_FILE_STRUCTURE_TRANSPARENT, + sim_cbmi_read_cb, cbs); ofono_sim_read(cbs->sim, SIM_EFCBMIR_FILEID, - sim_cbmir_read_cb, cbs); + OFONO_SIM_FILE_STRUCTURE_TRANSPARENT, + sim_cbmir_read_cb, cbs); ofono_sim_read(cbs->sim, SIM_EFCBMID_FILEID, - sim_cbmid_read_cb, cbs); + OFONO_SIM_FILE_STRUCTURE_TRANSPARENT, + sim_cbmid_read_cb, cbs); } static gboolean reset_base_station_name(gpointer user) -- cgit v1.2.3