aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2014-10-26 19:04:56 +0100
committerHarald Welte <laforge@gnumonks.org>2014-10-26 19:50:55 +0100
commit6729a9776aeffde08b11342dfc53e33873a33594 (patch)
treeb7f79e60df52b63a5dbbf61b9856156e611479ab /src
parentdb2b52ee8477a0223114aeadc15c3bfe8c2ee1fd (diff)
make sure to register DF.TELECOM and DF.GSM for SIM, USIM + TSIM
before we only did it partially, and by exporting data from sim, rather than the new osim_int_cprof_add_{gsm,telecom}() functions.
Diffstat (limited to 'src')
-rw-r--r--src/sim/card_fs_sim.c56
-rw-r--r--src/sim/card_fs_tetra.c12
-rw-r--r--src/sim/card_fs_usim.c20
-rw-r--r--src/sim/gsm_int.h10
4 files changed, 56 insertions, 42 deletions
diff --git a/src/sim/card_fs_sim.c b/src/sim/card_fs_sim.c
index e1244242..432c945b 100644
--- a/src/sim/card_fs_sim.c
+++ b/src/sim/card_fs_sim.c
@@ -240,7 +240,7 @@ static const struct osim_file_desc sim_ef_in_mf[] = {
};
/* Chapter 10.3.x Contents of files at the GSM application level */
-const struct osim_file_desc sim_ef_in_gsm[] = {
+static const struct osim_file_desc sim_ef_in_gsm[] = {
EF_TRANSP(0x6F05, SFI_NONE, "EF.LP", 0, 1, 16,
"Language preference", &gsm_lp_decode, NULL),
EF_TRANSP(0x6F07, SFI_NONE, "EF.IMSI", 0, 9, 9,
@@ -348,7 +348,6 @@ const struct osim_file_desc sim_ef_in_gsm[] = {
EF_TRANSP_N(0x6FD2, SFI_NONE, "EF.MMSUCP", F_OPTIONAL, 1, 64,
"MMS User Connectivity Parameters"),
};
-const size_t sim_ef_in_gsm_num = ARRAY_SIZE(sim_ef_in_gsm);
/* 10.4.1 Contents of the files at the SoLSA level */
static const struct osim_file_desc sim_ef_in_solsa[] = {
@@ -372,7 +371,7 @@ static const struct osim_file_desc sim_ef_in_mexe[] = {
};
/* 10.5 Contents of files at the telecom level */
-const struct osim_file_desc sim_ef_in_telecom[] = {
+static const struct osim_file_desc sim_ef_in_telecom[] = {
EF_LIN_FIX_N(0x6F3A, SFI_NONE, "EF.ADN", F_OPTIONAL, 14, 30,
"Abbreviated dialling numbers"),
EF_LIN_FIX_N(0x6F3B, SFI_NONE, "EF.FDN", F_OPTIONAL, 14, 30,
@@ -408,30 +407,17 @@ const struct osim_file_desc sim_ef_in_telecom[] = {
EF_LIN_FIX_N(0x6F58, SFI_NONE, "EF.CMI", F_OPTIONAL, 1, 17,
"Comparison Method Information"),
};
-const size_t sim_ef_in_telecom_num = ARRAY_SIZE(sim_ef_in_telecom);
/* 10.6.1 Contents of files at the telecom graphics level */
const struct osim_file_desc sim_ef_in_graphics[] = {
EF_LIN_FIX_N(0x4F20, SFI_NONE, "EF.IMG", F_OPTIONAL, 11, 38,
"Image"),
};
-const size_t sim_ef_in_graphics_num = ARRAY_SIZE(sim_ef_in_graphics);
-struct osim_card_profile *osim_cprof_sim(void *ctx)
+int osim_int_cprof_add_gsm(struct osim_file_desc *mf)
{
- struct osim_card_profile *cprof;
- struct osim_file_desc *mf, *gsm, *tc;
-
- cprof = talloc_zero(ctx, struct osim_card_profile);
- cprof->name = "GSM SIM";
- cprof->sws = sim_card_sws;
-
- mf = alloc_df(cprof, 0x3f00, "MF");
-
- cprof->mf = mf;
+ struct osim_file_desc *gsm;
- /* According to Figure 8 */
- add_filedesc(mf, sim_ef_in_mf, ARRAY_SIZE(sim_ef_in_mf));
gsm = add_df_with_ef(mf, 0x7F20, "DF.GSM", sim_ef_in_gsm,
ARRAY_SIZE(sim_ef_in_gsm));
/* Chapter 10.2: DFs at the GSM Application Level */
@@ -446,6 +432,13 @@ struct osim_card_profile *osim_cprof_sim(void *ctx)
add_df_with_ef(gsm, 0x5F70, "DF.SoLSA", sim_ef_in_solsa,
ARRAY_SIZE(sim_ef_in_solsa));
+ return 0;
+}
+
+int osim_int_cprof_add_telecom(struct osim_file_desc *mf)
+{
+ struct osim_file_desc *tc;
+
tc = add_df_with_ef(mf, 0x7F10, "DF.TELECOM", sim_ef_in_telecom,
ARRAY_SIZE(sim_ef_in_telecom));
add_df_with_ef(tc, 0x5F50, "DF.GRAPHICS", sim_ef_in_graphics,
@@ -453,5 +446,32 @@ struct osim_card_profile *osim_cprof_sim(void *ctx)
add_df_with_ef(mf, 0x7F22, "DF.IS-41", NULL, 0);
add_df_with_ef(mf, 0x7F23, "DF.FP-CTS", NULL, 0); /* TS 11.19 */
+ return 0;
+}
+
+struct osim_card_profile *osim_cprof_sim(void *ctx)
+{
+ struct osim_card_profile *cprof;
+ struct osim_file_desc *mf;
+ int rc;
+
+ cprof = talloc_zero(ctx, struct osim_card_profile);
+ cprof->name = "GSM SIM";
+ cprof->sws = sim_card_sws;
+
+ mf = alloc_df(cprof, 0x3f00, "MF");
+
+ cprof->mf = mf;
+
+ /* According to Figure 8 */
+ add_filedesc(mf, sim_ef_in_mf, ARRAY_SIZE(sim_ef_in_mf));
+
+ rc = osim_int_cprof_add_gsm(mf);
+ rc |= osim_int_cprof_add_telecom(mf);
+ if (rc != 0) {
+ talloc_free(cprof);
+ return NULL;
+ }
+
return cprof;
}
diff --git a/src/sim/card_fs_tetra.c b/src/sim/card_fs_tetra.c
index e581875d..625adbd2 100644
--- a/src/sim/card_fs_tetra.c
+++ b/src/sim/card_fs_tetra.c
@@ -242,7 +242,8 @@ static const struct osim_file_desc sim_ef_in_tetra[] = {
struct osim_card_profile *osim_cprof_tsim(void *ctx)
{
struct osim_card_profile *cprof;
- struct osim_file_desc *mf, *tc;
+ struct osim_file_desc *mf;
+ int rc;
cprof = talloc_zero(ctx, struct osim_card_profile);
cprof->name = "TETRA SIM";
@@ -256,10 +257,11 @@ struct osim_card_profile *osim_cprof_tsim(void *ctx)
add_df_with_ef(mf, 0x7F20, "DF.TETRA", sim_ef_in_tetra,
ARRAY_SIZE(sim_ef_in_tetra));
- tc = add_df_with_ef(mf, 0x7F10, "DF.TELECOM", sim_ef_in_telecom,
- sim_ef_in_telecom_num);
- add_df_with_ef(tc, 0x5F50, "DF.GRAPHICS", sim_ef_in_graphics,
- sim_ef_in_graphics_num);
+ rc = osim_int_cprof_add_telecom(mf);
+ if (rc != 0) {
+ talloc_free(cprof);
+ return NULL;
+ }
return cprof;
}
diff --git a/src/sim/card_fs_usim.c b/src/sim/card_fs_usim.c
index 02002cd2..22c193f8 100644
--- a/src/sim/card_fs_usim.c
+++ b/src/sim/card_fs_usim.c
@@ -332,7 +332,8 @@ static const uint8_t adf_usim_aid[] = { 0xA0, 0x00, 0x00, 0x00, 0x87, 0x10, 0x02
struct osim_card_profile *osim_cprof_usim(void *ctx)
{
struct osim_card_profile *cprof;
- struct osim_file_desc *mf, *gsm, *tc, *uadf;
+ struct osim_file_desc *mf, *uadf;
+ int rc;
cprof = talloc_zero(ctx, struct osim_card_profile);
cprof->name = "3GPP USIM";
@@ -367,16 +368,13 @@ struct osim_card_profile *osim_cprof_usim(void *ctx)
/* OMA BCAST Smart Card Profile */
add_df_with_ef(uadf, 0x5F80, "DF.BCAST", NULL, 0);
- /* DF.TELECOM as sub-directory of MF */
- tc = add_df_with_ef(mf, 0x7F10, "DF.TELECOM", sim_ef_in_telecom,
- sim_ef_in_telecom_num);
- add_df_with_ef(tc, 0x5F50, "DF.GRAPHICS", sim_ef_in_graphics,
- sim_ef_in_graphics_num);
-
- /* DF.GSM for backwards compatibility */
- gsm = add_df_with_ef(mf, 0x7F20, "DF.GSM", sim_ef_in_gsm,
- sim_ef_in_gsm_num);
- /* FIXME: DF's below DF.GSM (51.011) */
+ /* DF.GSM and DF.TELECOM hierarchy as sub-directory of MF */
+ rc = osim_int_cprof_add_gsm(mf);
+ rc |= osim_int_cprof_add_telecom(mf);
+ if (rc != 0) {
+ talloc_free(cprof);
+ return NULL;
+ }
return cprof;
}
diff --git a/src/sim/gsm_int.h b/src/sim/gsm_int.h
index c79a0be2..54a2fbf2 100644
--- a/src/sim/gsm_int.h
+++ b/src/sim/gsm_int.h
@@ -1,14 +1,8 @@
#include <sys/types.h>
#include <osmocom/sim/sim.h>
-const struct osim_file_desc *sim_ef_in_gsm;
-const size_t sim_ef_in_gsm_num;
-
-const struct osim_file_desc *sim_ef_in_graphics;
-const size_t sim_ef_in_graphics_num;
-
-const struct osim_file_desc *sim_ef_in_telecom;
-const size_t sim_ef_in_telecom_num;
+int osim_int_cprof_add_gsm(struct osim_file_desc *mf);
+int osim_int_cprof_add_telecom(struct osim_file_desc *mf);
int gsm_hpplmn_decode(struct osim_decoded_data *dd,
const struct osim_file_desc *desc,