Skip to contentSkip to conversation

sim: Read EFsst

PATCH Superseded Yang Gu 4 participants 5 messages Aug 25, 2010 – Aug 26, 2010

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Yang Gu

author
#0 lore raw

PATCH 1/1 sim: Read EFsst

---
 src/sim.c     |   31 +++++++++++++++++++++++++++-
 src/simutil.c |   18 ++++++++++++++++
 src/simutil.h |   63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 111 insertions(+), 1 deletions(-)
src/sim.c +30 -1
index 9bc9906..1491edd 100644
@@ -99,6 +99,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 {
@@ -1048,7 +1050,7 @@ out:
 	sim_retrieve_imsi(sim);
 }
 
-static void sim_efust_read_cb(int ok, int length, int record,
+static void sim_efsst_read_cb(int ok, int length, int record,
 				const unsigned char *data,
 				int record_length, void *userdata)
 {
@@ -1057,6 +1059,27 @@ static void sim_efust_read_cb(int ok, int length, int record,
 	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_efust_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 error;
+
 	if (length < 1) {
 		ofono_error("EFust shall contain@least one byte");
 		goto out;
@@ -1073,6 +1096,12 @@ static void sim_efust_read_cb(int ok, int length, int record,
 
 out:
 	sim_retrieve_imsi(sim);
+	return;
+
+error:
+	ofono_sim_read(sim, SIM_EFSST_FILEID,
+			OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
+			sim_efsst_read_cb, sim);
 }
 
 static void sim_cphs_information_read_cb(int ok, int length, int record,
src/simutil.c +18 -0
index 2d0764c..c7c221e 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 * 4)
+		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 * 4)
+		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 34 lines
src/sim.c +22 -1
-static void sim_efust_read_cb(int ok, int length, int record,
+static void sim_efsst_read_cb(int ok, int length, int record,
 				const unsigned char *data,
 				int record_length, void *userdata)
 {
@@ -1057,6 +1059,27 @@ static void sim_efust_read_cb(int ok, int length, int record,
 	if (!ok)
 		goto out;
 
+	if (length < 2) {
+		ofono_error("EFsst shall contain at least two bytes");
+		goto out;
+	}
+
+	sim->efsst = g_memdup(data, length);
+	sim->efsst_length = length;
+
+out:
+	sim_retrieve_imsi(sim);
+}
+
+static void sim_efust_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 error;
+
 	if (length < 1) {
 		ofono_error("EFust shall contain at least one byte");
 		goto out;

src/sim.c static void sim_efust_read_cb(int ok, int length, int record, · line 1105

Quoted 10 lines
src/sim.c +6 -0
@@ -1073,6 +1096,12 @@ static void sim_efust_read_cb(int ok, int length, int record,
 
 out:
 	sim_retrieve_imsi(sim);
+	return;
+
+error:
+	ofono_sim_read(sim, SIM_EFSST_FILEID,
+			OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
+			sim_efsst_read_cb, sim);
 }

That is really not how it works. If the file ID is the same then you need some other information to determine whether this is a phase 3 or a phase 2 SIM. Look at how EFecc reading in voicecall.c is done. In other words, this function needs to make an intelligent decision whether this is EFsst or EFust.

In your case the only heuristic we have is EFphase, which is mandatory for all Phase 2 SIMs (and absent in all Phase 3 SIMs).

Regards,
-Denis

#2 lore raw

Hi Denis,

Quoted 18 lines

src/sim.c static void sim_efust_read_cb(int ok, int length, int record, · line 1105

Quoted 9 lines

out:

src/sim.c +6 -0
 	sim_retrieve_imsi(sim);
+	return;
+
+error:
+	ofono_sim_read(sim, SIM_EFSST_FILEID,
+			OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
+			sim_efsst_read_cb, sim);
 }

That is really not how it works. If the file ID is the same then you need some other information to determine whether this is a phase 3 or a phase 2 SIM. Look at how EFecc reading in voicecall.c is done. In other words, this function needs to make an intelligent decision whether this is EFsst or EFust.

In your case the only heuristic we have is EFphase, which is mandatory for all Phase 2 SIMs (and absent in all Phase 3 SIMs).

#3 lore raw
In reply to Denis Kenzior

Hi Denis,

Quoted 31 lines

src/sim.c static void sim_efust_read_cb(int ok, int length, int

Quoted 13 lines
src/sim.c +9 -0
+static void sim_efust_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 error;
+
 	if (length < 1) {
 		ofono_error("EFust shall contain at least one byte");
 		goto out;
@@ -1073,6 +1096,12 @@ static void sim_efust_read_cb(int ok, int length, int

record,

src/sim.c static void sim_efust_read_cb(int ok, int length, int record, · line 1105

Quoted 10 lines
src/sim.c +6 -0
 out:
 	sim_retrieve_imsi(sim);
+	return;
+
+error:
+	ofono_sim_read(sim, SIM_EFSST_FILEID,
+			OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
+			sim_efsst_read_cb, sim);
 }

That is really not how it works. If the file ID is the same then you need some other information to determine whether this is a phase 3 or a phase 2 SIM. Look at how EFecc reading in voicecall.c is done. In other words, this function needs to make an intelligent decision whether this is EFsst or EFust.

Quoted 2 lines

In your case the only heuristic we have is EFphase, which is mandatory for all Phase 2 SIMs (and absent in all Phase 3 SIMs).

Last time, you mentioned " 3G device + 3G sim -> EFust and EFest, while 2G device + 3G sim -> EFsst". And I think EFphase only means the SIM phase. So just using SIM phase to do the judgement would put us in a risk if we have a phase 3 SIM and 2G device, right? You also mentioned this is the best way we currently have. Do you hint we have no (general) way to get the phase of device?

But I still think there is some problem here: For this case, EFust and EFsst have the same file id and type. So I suppose they can't co-exist in the SIM file system. Otherwise, we couldn't read them by just using the file id and file type. If so, and if I were a SIM manufacturer, how should I decide which one, EFust and EFsst, will be put in? I would have no knowledge what the phase of user's device. So the rule to obey is to have my choice match the EFphase. That is, 3G sim -> EFust and 2G sim ->EFsst.

Another two related questions: 1) Can we have two files with different id but same purpose, one for phase 2 and the other for phase 3, coexist in SIM file system? Thinking about if we change the id of EFsst. This case also hints one of them must be invalid if it's allowed. 2) Can we have two files with same id but different types coexist in SIM file system? According to the assumption of current code with EFecc, I think the answer is no. Just need a confirmation.

Regards,
-Yang

#4 lore raw

Hi,

Quoted 3 lines · Yang

Last time, you mentioned " 3G device + 3G sim -> EFust and EFest, while 2G device + 3G sim -> EFsst". And I think EFphase only means the SIM phase. So just using SIM phase to do the judgement would put us in a risk if we have a phase 3 SIM and 2G device, right? You also mentioned this is the best way we currently have. Do you hint we have no (general) way to get the phase of device?

But I still think there is some problem here: For this case, EFust and EFsst have the same file id and type. So I suppose they can't co-exist in the SIM file system. Otherwise, we couldn't read them by just using the file id and file type. If so, and if I were a SIM manufacturer, how should I decide which one, EFust and EFsst, will be put in? I would have no knowledge what the phase of user's device. So the rule to obey is to have my choice match the EFphase. That is, 3G sim -> EFust and 2G sim ->EFsst.

As far as I understand, a 3G SIM can actually have two filesystems. One of them contains the EFphase, EFsst, and other files, while the other filesystem contains EFust, EFest and no EFphase (some files will be the same). That's why we have separate cache for them. If a 2G modem initiates the card as 2G then the card needs to consistently act as a 2G card.

Regards