All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sim: Read EFsst
@ 2010-08-25 11:29 Yang Gu
  2010-08-25 17:17 ` Denis Kenzior
  0 siblings, 1 reply; 5+ messages in thread
From: Yang Gu @ 2010-08-25 11:29 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 5684 bytes --]

---
 src/sim.c     |   31 +++++++++++++++++++++++++++-
 src/simutil.c |   18 ++++++++++++++++
 src/simutil.h |   63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 111 insertions(+), 1 deletions(-)

diff --git a/src/sim.c b/src/sim.c
index 9bc9906..1491edd 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -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,
diff --git a/src/simutil.c b/src/simutil.c
index 2d0764c..c7c221e 100644
--- a/src/simutil.c
+++ b/src/simutil.c
@@ -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;
+}
diff --git a/src/simutil.h b/src/simutil.h
index 4db950b..9ecc044 100644
--- a/src/simutil.h
+++ b/src/simutil.h
@@ -27,6 +27,7 @@ enum sim_fileid {
 	SIM_EF_CPHS_INFORMATION_FILEID = 0x6f16,
 	SIM_EF_CPHS_MBDN_FILEID = 0x6f17,
 	SIM_EFUST_FILEID = 0x6f38,
+	SIM_EFSST_FILEID = 0x6f38, /* same with EFust */
 	SIM_EFMSISDN_FILEID = 0x6f40,
 	SIM_EFSPN_FILEID = 0x6f46,
 	SIM_EFSDN_FILEID = 0x6f49,
@@ -153,6 +154,64 @@ enum sim_est_service {
 	SIM_EST_SERVICE_ACL				= 2
 };
 
+/* 51.011 Section 10.3.7 */
+enum sim_sst_service {
+	SIM_SST_SERVICE_CHV1_DISABLE 			= 0,
+	SIM_SST_SERVICE_ADN				= 1,
+	SIM_SST_SERVICE_FDN				= 2,
+	SIM_SST_SERVICE_SMS				= 3,
+	SIM_SST_SERVICE_AOC				= 4,
+	SIM_SST_SERVICE_CCP				= 5,
+	SIM_SST_SERVICE_PLMN_SELECTOR			= 6,
+	SIM_SST_SERVICE_MSISDN				= 8,
+	SIM_SST_SERVICE_EXT_1				= 9,
+	SIM_SST_SERVICE_EXT_2				= 10,
+	SIM_SST_SERVICE_SMSP				= 11,
+	SIM_SST_SERVICE_LND				= 12,
+	SIM_SST_SERVICE_CBS_ID				= 13,
+	SIM_SST_SERVICE_GROUP_ID_LEVEL_1		= 14,
+	SIM_SST_SERVICE_GROUP_ID_LEVEL_2		= 15,
+	SIM_SST_SERVICE_PROVIDER_NAME			= 16,
+	SIM_SST_SERVICE_SDN				= 17,
+	SIM_SST_SERVICE_EXT_3				= 18,
+	SIM_SST_SERVICE_EFVGCS_EFVGCSS			= 20,
+	SIM_SST_SERVICE_EFVBS_EFVBSS			= 21,
+	SIM_SST_SERVICE_PRECEDENCE_PREEMPTION		= 22,
+	SIM_SST_SERVICE_EMLPP				= 23,
+	SIM_SST_SERVICE_DATA_DOWNLOAD_SMS_CB		= 24,
+	SIM_SST_SERVICE_DATA_DOWNLOAD_SMS_PP		= 25,
+	SIM_SST_SERVICE_MENU_SELECTION			= 26,
+	SIM_SST_SERVICE_CALL_CONTROL			= 27,
+	SIM_SST_SERVICE_PROACTIVE_SIM			= 28,
+	SIM_SST_SERVICE_CBS_ID_RANGE			= 29,
+	SIM_SST_SERVICE_BDN				= 30,
+	SIM_SST_SERVICE_EXT_4				= 31,
+	SIM_SST_SERVICE_DEPERSONALISATION_CTRL_KEY	= 32,
+	SIM_SST_SERVICE_NETWORK_LIST			= 33,
+	SIM_SST_SERVICE_SMSR				= 34,
+	SIM_SST_SERVICE_NIA				= 35,
+	SIM_SST_SERVICE_MO_SMS_SIM			= 36,
+	SIM_SST_SERVICE_GPRS				= 37,
+	SIM_SST_SERVICE_IMG				= 38,
+	SIM_SST_SERVICE_SOLSA				= 39,
+	SIM_SST_SERVICE_USSD_CALL_CONTROL		= 40,
+	SIM_SST_SERVICE_RUN_AT_COMMAND			= 41,
+	SIM_SST_SERVICE_USER_PLMN			= 42,
+	SIM_SST_SERVICE_OPERATOR_PLMN			= 43,
+	SIM_SST_SERVICE_HPLMN				= 44,
+	SIM_SST_SERVICE_CPBCCH				= 45,
+	SIM_SST_SERVICE_INVESTIGATION_SCAN		= 46,
+	SIM_SST_SERVICE_EXT_CCP				= 47,
+	SIM_SST_SERVICE_MEXE				= 48,
+	SIM_SST_SERVICE_RPLMN				= 49,
+	SIM_SST_SERVICE_PLMN_NETWORK_NAME		= 50,
+	SIM_SST_SERVICE_OPERATOR_PLMN_LIST		= 51,
+	SIM_SST_SERVICE_MAILBOX_DIALLING_NUMBERS	= 52,
+	SIM_SST_SERVICE_MWIS				= 53,
+	SIM_SST_SERVICE_CFIS				= 54,
+	SIM_SST_SERVICE_PROVIDER_DISPLAY_INFO		= 55
+};
+
 #define SIM_EFSPN_DC_HOME_PLMN_BIT 0x1
 #define SIM_EFSPN_DC_ROAMING_SPN_BIT 0x2
 
@@ -371,3 +430,7 @@ gboolean sim_ust_is_available(unsigned char *service_ust, unsigned char len,
 						enum sim_ust_service index);
 gboolean sim_est_is_active(unsigned char *service_est, unsigned char len,
 						enum sim_est_service index);
+gboolean sim_sst_is_available(unsigned char *service_sst, unsigned char len,
+						enum sim_sst_service index);
+gboolean sim_sst_is_active(unsigned char *service_sst, unsigned char len,
+						enum sim_sst_service index);
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] sim: Read EFsst
  2010-08-25 11:29 [PATCH] sim: Read EFsst Yang Gu
@ 2010-08-25 17:17 ` Denis Kenzior
  2010-08-26  9:12   ` Gu, Yang
  2010-08-26 10:12   ` Gu, Yang
  0 siblings, 2 replies; 5+ messages in thread
From: Denis Kenzior @ 2010-08-25 17:17 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1672 bytes --]

Hi Yang,

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] sim: Read EFsst
  2010-08-25 17:17 ` Denis Kenzior
@ 2010-08-26  9:12   ` Gu, Yang
  2010-08-26 10:12   ` Gu, Yang
  1 sibling, 0 replies; 5+ messages in thread
From: Gu, Yang @ 2010-08-26  9:12 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 678 bytes --]

Hi Denis,


>>  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).





^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] sim: Read EFsst
  2010-08-25 17:17 ` Denis Kenzior
  2010-08-26  9:12   ` Gu, Yang
@ 2010-08-26 10:12   ` Gu, Yang
  2010-08-26 16:51     ` andrzej zaborowski
  1 sibling, 1 reply; 5+ messages in thread
From: Gu, Yang @ 2010-08-26 10:12 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2499 bytes --]

Hi Denis,


>> +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,
>>
>>  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).

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] sim: Read EFsst
  2010-08-26 10:12   ` Gu, Yang
@ 2010-08-26 16:51     ` andrzej zaborowski
  0 siblings, 0 replies; 5+ messages in thread
From: andrzej zaborowski @ 2010-08-26 16:51 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1352 bytes --]

Hi,

On 26 August 2010 12:12, Gu, Yang <yang.gu@intel.com> wrote:
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-08-26 16:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-25 11:29 [PATCH] sim: Read EFsst Yang Gu
2010-08-25 17:17 ` Denis Kenzior
2010-08-26  9:12   ` Gu, Yang
2010-08-26 10:12   ` Gu, Yang
2010-08-26 16:51     ` andrzej zaborowski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.