Skip to contentSkip to conversation

sim: Read EFsst

PATCH In review Yang Gu 2 participants 2 messages Aug 31, 2010

lore
Share & tools
lore

Yang Gu

author
#0 lore raw

PATCH v3 1/1 sim: Read EFsst

---
 src/sim.c     |   40 +++++++++++++++++++++++++++++++++--
 src/simutil.c |   18 ++++++++++++++++
 src/simutil.h |   63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 118 insertions(+), 3 deletions(-)
src/sim.c +37 -3
index fd9b412..ff559a9 100644
@@ -101,6 +101,8 @@ struct ofono_sim {
 	unsigned char efust_length;
 	unsigned char *efest;
 	unsigned char efest_length;
+	unsigned char *efsst;
+	unsigned char efsst_length;
 };
 
 struct msisdn_set_request {
@@ -1072,6 +1074,27 @@ static void sim_retrieve_imsi(struct ofono_sim *sim)
 	sim->driver->read_imsi(sim, sim_imsi_cb, sim);
 }
 
+static void sim_efsst_read_cb(int ok, int length, int record,
+				const unsigned char *data,
+				int record_length, void *userdata)
+{
+	struct ofono_sim *sim = userdata;
+
+	if (!ok)
+		goto out;
+
+	if (length < 2) {
+		ofono_error("EFsst shall contain@least two bytes");
+		goto out;
+	}
+
+	sim->efsst = g_memdup(data, length);
+	sim->efsst_length = length;
+
+out:
+	sim_retrieve_imsi(sim);
+}
+
 static void sim_efest_read_cb(int ok, int length, int record,
 				const unsigned char *data,
 				int record_length, void *userdata)
@@ -1192,9 +1215,14 @@ static void sim_initialize_after_pin(struct ofono_sim *sim)
 			sim_cphs_information_read_cb, sim);
 
 	/* Also retrieve the GSM service table */
-	ofono_sim_read(sim, SIM_EFUST_FILEID,
-			OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
-			sim_efust_read_cb, sim);
+	if (sim->phase >= OFONO_SIM_PHASE_3G)
+		ofono_sim_read(sim, SIM_EFUST_FILEID,
+				OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
+				sim_efust_read_cb, sim);
+	else
+		ofono_sim_read(sim, SIM_EFSST_FILEID,
+				OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
+				sim_efsst_read_cb, sim);
 }
 
 static void sim_pin_query_cb(const struct ofono_error *error,
@@ -2046,6 +2074,12 @@ static void sim_free_state(struct ofono_sim *sim)
 		sim->efest_length = 0;
 	}
 
+	if (sim->efsst) {
+		g_free(sim->efsst);
+		sim->efsst = NULL;
+		sim->efsst_length = 0;
+	}
+
 	sim->mnc_length = 0;
 
 	if (sim->efimg) {
src/simutil.c +18 -0
index ac054ae..4af6810 100644
@@ -1434,3 +1434,21 @@ gboolean sim_est_is_active(unsigned char *efest, unsigned char len,
 
 	return (efest[index / 8] >> (index % 8)) & 1;
 }
+
+gboolean sim_sst_is_available(unsigned char *efsst, unsigned char len,
+						enum sim_sst_service index)
+{
+	if (index >= len * 4u)
+		return FALSE;
+
+	return (efsst[index / 4] >> ((index % 4) * 2)) & 1;
+}
+
+gboolean sim_sst_is_active(unsigned char *efsst, unsigned char len,
+						enum sim_sst_service index)
+{
+	if (index >= len * 4u)
+		return FALSE;
+
+	return (efsst[index / 4] >> (((index % 4) * 2) + 1)) & 1;
+}
src/simutil.h +63 -0

78 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#1 lore raw

Hi Yang,

Quoted 6 lines · Yang Gu
---
 src/sim.c     |   40 +++++++++++++++++++++++++++++++++--
 src/simutil.c |   18 ++++++++++++++++
 src/simutil.h |   63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 118 insertions(+), 3 deletions(-)

Patch has been applied, thanks.

Regards,
-Denis