From aad7e0664b310ccc463538a18ac5238cb7c0ac3c Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 4 May 2014 16:31:24 +0200 Subject: sim: Make TETRA SIM (TSIM) support compile --- src/sim/Makefile.am | 3 +- src/sim/card_fs_tetra.c | 314 ++++++++++++++++++++---------------------------- 2 files changed, 134 insertions(+), 183 deletions(-) (limited to 'src/sim') diff --git a/src/sim/Makefile.am b/src/sim/Makefile.am index 90df84ee..2b30ae99 100644 --- a/src/sim/Makefile.am +++ b/src/sim/Makefile.am @@ -13,7 +13,8 @@ noinst_HEADERS = sim_int.h gsm_int.h lib_LTLIBRARIES = libosmosim.la -libosmosim_la_SOURCES = core.c card_fs_sim.c card_fs_usim.c card_fs_uicc.c card_fs_isim.c reader.c reader_pcsc.c +libosmosim_la_SOURCES = core.c reader.c reader_pcsc.c \ + card_fs_sim.c card_fs_usim.c card_fs_uicc.c card_fs_isim.c card_fs_tetra.c libosmosim_la_LDFLAGS = -version-info $(LIBVERSION) libosmosim_la_LIBADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(PCSC_LIBS) diff --git a/src/sim/card_fs_tetra.c b/src/sim/card_fs_tetra.c index 13a277c1..e581875d 100644 --- a/src/sim/card_fs_tetra.c +++ b/src/sim/card_fs_tetra.c @@ -28,6 +28,7 @@ #include #include "sim_int.h" +#include "gsm_int.h" /* EN 300 812 V2.1.1 (2001-12) 9.4 */ static const struct osim_card_sw tsim_sw[] = { @@ -99,217 +100,166 @@ static const struct osim_card_sw tsim_sw[] = { }; static const struct osim_card_sw *tsim_card_sws[] = { - tsim1_sw, + tsim_sw, NULL }; /* Chapter 10.2.x */ static const struct osim_file_desc sim_ef_in_mf[] = { - EF_TRANSP(0x2FE2, "EF.ICCID", 0, 10, 10, - "ICC Identification", NULL, NULL), - EF_TRANSP(0x2F00, "EF.DIR", F_OPTIONAL, 8, 54, - "Application directory", NULL, NULL), - EF_TRANSP(0x2F05, "EF.LP", 0, 2, 32, - "Language preference", NULL, NULL), + EF_TRANSP_N(0x2FE2, SFI_NONE, "EF.ICCID", 0, 10, 10, + "ICC Identification"), + EF_TRANSP_N(0x2F00, SFI_NONE, "EF.DIR", F_OPTIONAL, 8, 54, + "Application directory"), + EF_TRANSP_N(0x2F05, SFI_NONE, "EF.LP", 0, 2, 32, + "Language preference"), }; //////////////////////////// /* Chapter 10.3.x */ static const struct osim_file_desc sim_ef_in_tetra[] = { - EF_TRANSP_N(0x6F01, "EF.SST", 0, 4, 8, + EF_TRANSP_N(0x6F01, SFI_NONE, "EF.SST", 0, 4, 8, "SIM service table"), - EF_TRANSP_N(0x6F02, "EF.ITSI", 0, 6, 6, - "ITSI", NULL, NULL), - EF_TRANSP_N(0x6F03, "EF.ITSIDIS", 0, 1, 1, - "ITSI Disable"); - EF_TRANSP_N(0x6F05, "EF.SCT", 0, 4, 4, - "Subscriber Class Table"); - EF_TRANSP_N(0x6F06, "EF.PHASE", 0, 1, 1, - "Phase identification"); - EF_KEY_N(0x6F07, "EF.CCK", F_OPTIONAL, 12, 12, - "Common Cipher Key"); - EF_TRANSP_N(0x6F08, "EF.CCKLOC", F_OPTIONAL, 31, 31, - "CCK location areas"); - EF_KEY_N(0x6F09, "EF.SCK", F_OPTIONAL, 12, 12, - "Static Cipher Keys"); + EF_TRANSP_N(0x6F02, SFI_NONE, "EF.ITSI", 0, 6, 6, + "ITSI"), + EF_TRANSP_N(0x6F03, SFI_NONE, "EF.ITSIDIS", 0, 1, 1, + "ITSI Disable"), + EF_TRANSP_N(0x6F05, SFI_NONE, "EF.SCT", 0, 4, 4, + "Subscriber Class Table"), + EF_TRANSP_N(0x6F06, SFI_NONE, "EF.PHASE", 0, 1, 1, + "Phase identification"), + EF_KEY_N(0x6F07, SFI_NONE, "EF.CCK", F_OPTIONAL, 12, 12, + "Common Cipher Key"), + EF_TRANSP_N(0x6F08, SFI_NONE, "EF.CCKLOC", F_OPTIONAL, 31, 31, + "CCK location areas"), + EF_KEY_N(0x6F09, SFI_NONE, "EF.SCK", F_OPTIONAL, 12, 12, + "Static Cipher Keys"), /* X+4 for each record, suggested 1 to 10 */ - EF_LIN_FIX_N(0x6F0A, "EF.GSSIS", 0, 5, 21, - "Static Cipher Keys"); + EF_LIN_FIX_N(0x6F0A, SFI_NONE, "EF.GSSIS", 0, 5, 21, + "Static Cipher Keys"), /* 2 for each record, one for each recod in GSSIS */ - EF_LIN_FIX_N(0x6F0B, "EF.GRDS", 0, 2, 2, - "Group related data for static GSSIS"); - EF_LIN_FIX_N(0x6F0C, "EF.GSSID", 0, 5, 21, - "Dynamic GSSIs"); + EF_LIN_FIX_N(0x6F0B, SFI_NONE, "EF.GRDS", 0, 2, 2, + "Group related data for static GSSIS"), + EF_LIN_FIX_N(0x6F0C, SFI_NONE, "EF.GSSID", 0, 5, 21, + "Dynamic GSSIs"), /* 2 for each record, one for each recod in GSSID */ - EF_LIN_FIX_N(0x6F0D, "EF.GRDD", 0, 2, 2, - "Dynamic GSSIs"); - EF_LIN_FIX_N(0x6F0E, "EF.GCK", F_OPTIONAL, 12, 12, - "Group Cipher Keys"); - EF_KEY_N(0x6F0F, "EF.MGCK", F_OPTIONAL, 12, 12, - "Modified Group Cipher Keys"); - EF_TRANSP_N(0x6F10, "EF.GINFO", 0, 9, 9, - "User's group information"); - EF_TRANSP_N(0x6F11, "EF.SEC", 0, 1, 1, - "Security settings"); - EF_CYCLIC_N(0x6F12, "EF.FORBID", 0, 3, 3, - "Security settings"); - EF_CYCLIC_N(0x6F13, "EF.PREF", F_OPTIONAL, 3, 3, - "Preferred networks"); - EF_TRANSP_N(0x6F14, "EF.SPN", F_OPTIONAL, 17, 17, - "Service Provider Name"); - EF_TRANSP_N(0x6F15, "EF.LOCI", F_OPTIONAL, 7, 7, - "Location Information"); - EF_TRANSP_N(0x6F16, "EF.DNWRK", 0, 3, 3, - "Broadcast network information"); - EF_LIN_FIX_N(0x6F17, "EF.NWT", 0, 5, 5, - "Network table"); - EF_LIN_FIX_N(0x6F18, "EF.GWT", F_OPTIONAL, 13, 13, - "Gateway table"); - EF_LIN_FIX_N(0x6F19, "EF.CMT", F_OPTIONAL, 5, 20, - "Call Modifier Table"); - EF_LIN_FIX_N(0x6F1A, "EF.ADNGWT", F_OPTIONAL, 13, 28, - "Abbreviated Dialling Number with Gateways"); - EF_LIN_FIX_N(0x6F1C, "EF.ADNTETRA", F_OPTIONAL, 9, 23, - "Abbreviated dialling numbers for TETRA network"); - EF_LIN_FIX_N(0x6F1D, "EF.EXTA", F_OPTIONAL, 20, 20, - "Extension A"); - EF_LIN_FIX_N(0x6F1E, "EF.FDNGWT", F_OPTIONAL, 13, 28, - "Fixed dialling numbers with Gateways"); - EF_LIN_FIX_N(0x6F1F, "EF.GWTEXT2", F_OPTIONAL, 13, 13, - "Gateway Extension2"); - EF_LIN_FIX_N(0x6F20, "EF.FDNTETRA", F_OPTIONAL, 9, 25, - "Fixed dialling numbers for TETRA network"); - EF_LIN_FIX_N(0x6F21, "EF.EXTB", F_OPTIONAL, 20, 20, - "Extension B"); - EF_LIN_FIX_N(0x6F22, "EF.LNDGWT", F_OPTIONAL, 13, 28, - "Last number dialled with Gateways"); - EF_CYCLIC_N(0x6F23, "EF.LNDTETRA", F_OPTIONAL, 9, 23, - "Last numbers dialled for TETRA network"); - EF_LIN_FIX_N(0x6F24, "EF.SDNGWT", F_OPTIONAL, 13, 28, - "Service Dialling Numbers with gateway"); - EF_LIN_FIX_N(0x6F25, "EF.GWTEXT3", F_OPTIONAL, 13, 13, - "Gateway Extension3"); - EF_LIN_FIX_N(0x6F26, "EF.SDNTETRA", F_OPTIONAL, 8, 22, - "Service Dialling Nubers for TETRA network"); - EF_LIN_FIX_N(0x6F27, "EF.STXT", F_OPTIONAL, 5, 18, - "Status message texts"); - EF_LIN_FIX_N(0x6F28, "EF.MSGTXT", F_OPTIONAL, 5, 18, - "SDS-1 message texts"); - EF_LIN_FIX_N(0x6F29, "EF.SDS123", F_OPTIONAL, 46, 46, - "Status and SDS type 1, 2 and 3 message storage"); - EF_LIN_FIX_N(0x6F2A, "EF.SDS4", F_OPTIONAL, 255, 255, - "Status and SDS type 4 message storage"); - EF_LIN_FIX_N(0x6F2B, "EF.MSGEXT", F_OPTIONAL, 16, 16, - "Message Extension"); - EF_LIN_FIX_N(0x6F2C, "EF.EADDR", 0, 17, 17, - "Emergency adresses"); - EF_TRANSP_N(0x6F2D, "EF.EINFO", 0, 2, 2, - "Emergency call information"); - EF_LIN_FIX_N(0x6F2E, "EF.DMOCh", F_OPTIONAL, 4, 4, - "DMO channel information"); - EF_TRANSP_N(0x6F2F, "EF.MSCh", F_OPTIONAL, 1, 16, - "MS allocation of DMO channels"); - EF_TRANSP_N(0x6F30, "EF.KH", F_OPTIONAL, 6, 6, - "List of Key Holders"); - EF_LIN_FIX_N(0x6F31, "EF.REPGATE", F_OPTIONAL, 2, 2, - "DMO repeater and gateway list"); - EF_TRANSP_N(0x6F32, "EF.AD", F_OPTIONAL, 2, 2, - "DMO repeater and gateway list"); - EF_TRANSP_N(0x6F33, "EF.PREF_LA", F_OPTIONAL, 2, 2, - "Preferred location areas"); - EF_CYCLIC_N(0x6F34, "EF.LNDComp", F_OPTIONAL, 3, 3, - "Composite LND file"); - EF_TRANSP_N(0x6F35, "EF.DFLTSTSTGGT", F_OPTIONAL, 16, 16, - "Status Default Target"); - EF_TRANSP_N(0x6F36, "EF.SDSMEM_STATUS", F_OPTIONAL, 7, 7, - "SDS Memory Status"); - EF_TRANSP_N(0x6F37, "EF.WELCOME", F_OPTIONAL, 32, 32, - "Welcome Message"); - EF_LIN_FIX_N(0x6F38, "EF.SDSR", F_OPTIONAL, 2, 2, - "SDS delivery report"); - EF_LIN_FIX_N(0x6F39, "EF.SDSP", F_OPTIONAL, 20, 35, - "SDS parameters"); - EF_TRANSP_N(0x6F46, "EF.DIALSC", 0, 5, 5, - "Dialling schemes for TETRA network"); - EF_TRANSP_N(0x6F3E, "EF.APN", F_OPTIONAL, 65, 65, - "APN table"); - EF_LIN_FIX_N(0x6FC0, "EF.PNI", F_OPTIONAL, 14, 14, - "Private Number Information"); + EF_LIN_FIX_N(0x6F0D, SFI_NONE, "EF.GRDD", 0, 2, 2, + "Dynamic GSSIs"), + EF_LIN_FIX_N(0x6F0E, SFI_NONE, "EF.GCK", F_OPTIONAL, 12, 12, + "Group Cipher Keys"), + EF_KEY_N(0x6F0F, SFI_NONE, "EF.MGCK", F_OPTIONAL, 12, 12, + "Modified Group Cipher Keys"), + EF_TRANSP_N(0x6F10, SFI_NONE, "EF.GINFO", 0, 9, 9, + "User's group information"), + EF_TRANSP_N(0x6F11, SFI_NONE, "EF.SEC", 0, 1, 1, + "Security settings"), + EF_CYCLIC_N(0x6F12, SFI_NONE, "EF.FORBID", 0, 3, 3, + "Security settings"), + EF_CYCLIC_N(0x6F13, SFI_NONE, "EF.PREF", F_OPTIONAL, 3, 3, + "Preferred networks"), + EF_TRANSP_N(0x6F14, SFI_NONE, "EF.SPN", F_OPTIONAL, 17, 17, + "Service Provider Name"), + EF_TRANSP_N(0x6F15, SFI_NONE, "EF.LOCI", F_OPTIONAL, 7, 7, + "Location Information"), + EF_TRANSP_N(0x6F16, SFI_NONE, "EF.DNWRK", 0, 3, 3, + "Broadcast network information"), + EF_LIN_FIX_N(0x6F17, SFI_NONE, "EF.NWT", 0, 5, 5, + "Network table"), + EF_LIN_FIX_N(0x6F18, SFI_NONE, "EF.GWT", F_OPTIONAL, 13, 13, + "Gateway table"), + EF_LIN_FIX_N(0x6F19, SFI_NONE, "EF.CMT", F_OPTIONAL, 5, 20, + "Call Modifier Table"), + EF_LIN_FIX_N(0x6F1A, SFI_NONE, "EF.ADNGWT", F_OPTIONAL, 13, 28, + "Abbreviated Dialling Number with Gateways"), + EF_LIN_FIX_N(0x6F1C, SFI_NONE, "EF.ADNTETRA", F_OPTIONAL, 9, 23, + "Abbreviated dialling numbers for TETRA network"), + EF_LIN_FIX_N(0x6F1D, SFI_NONE, "EF.EXTA", F_OPTIONAL, 20, 20, + "Extension A"), + EF_LIN_FIX_N(0x6F1E, SFI_NONE, "EF.FDNGWT", F_OPTIONAL, 13, 28, + "Fixed dialling numbers with Gateways"), + EF_LIN_FIX_N(0x6F1F, SFI_NONE, "EF.GWTEXT2", F_OPTIONAL, 13, 13, + "Gateway Extension2"), + EF_LIN_FIX_N(0x6F20, SFI_NONE, "EF.FDNTETRA", F_OPTIONAL, 9, 25, + "Fixed dialling numbers for TETRA network"), + EF_LIN_FIX_N(0x6F21, SFI_NONE, "EF.EXTB", F_OPTIONAL, 20, 20, + "Extension B"), + EF_LIN_FIX_N(0x6F22, SFI_NONE, "EF.LNDGWT", F_OPTIONAL, 13, 28, + "Last number dialled with Gateways"), + EF_CYCLIC_N(0x6F23, SFI_NONE, "EF.LNDTETRA", F_OPTIONAL, 9, 23, + "Last numbers dialled for TETRA network"), + EF_LIN_FIX_N(0x6F24, SFI_NONE, "EF.SDNGWT", F_OPTIONAL, 13, 28, + "Service Dialling Numbers with gateway"), + EF_LIN_FIX_N(0x6F25, SFI_NONE, "EF.GWTEXT3", F_OPTIONAL, 13, 13, + "Gateway Extension3"), + EF_LIN_FIX_N(0x6F26, SFI_NONE, "EF.SDNTETRA", F_OPTIONAL, 8, 22, + "Service Dialling Nubers for TETRA network"), + EF_LIN_FIX_N(0x6F27, SFI_NONE, "EF.STXT", F_OPTIONAL, 5, 18, + "Status message texts"), + EF_LIN_FIX_N(0x6F28, SFI_NONE, "EF.MSGTXT", F_OPTIONAL, 5, 18, + "SDS-1 message texts"), + EF_LIN_FIX_N(0x6F29, SFI_NONE, "EF.SDS123", F_OPTIONAL, 46, 46, + "Status and SDS type 1, 2 and 3 message storage"), + EF_LIN_FIX_N(0x6F2A, SFI_NONE, "EF.SDS4", F_OPTIONAL, 255, 255, + "Status and SDS type 4 message storage"), + EF_LIN_FIX_N(0x6F2B, SFI_NONE, "EF.MSGEXT", F_OPTIONAL, 16, 16, + "Message Extension"), + EF_LIN_FIX_N(0x6F2C, SFI_NONE, "EF.EADDR", 0, 17, 17, + "Emergency adresses"), + EF_TRANSP_N(0x6F2D, SFI_NONE, "EF.EINFO", 0, 2, 2, + "Emergency call information"), + EF_LIN_FIX_N(0x6F2E, SFI_NONE, "EF.DMOCh", F_OPTIONAL, 4, 4, + "DMO channel information"), + EF_TRANSP_N(0x6F2F, SFI_NONE, "EF.MSCh", F_OPTIONAL, 1, 16, + "MS allocation of DMO channels"), + EF_TRANSP_N(0x6F30, SFI_NONE, "EF.KH", F_OPTIONAL, 6, 6, + "List of Key Holders"), + EF_LIN_FIX_N(0x6F31, SFI_NONE, "EF.REPGATE", F_OPTIONAL, 2, 2, + "DMO repeater and gateway list"), + EF_TRANSP_N(0x6F32, SFI_NONE, "EF.AD", F_OPTIONAL, 2, 2, + "Administrative Data"), + EF_TRANSP_N(0x6F33, SFI_NONE, "EF.PREF_LA", F_OPTIONAL, 2, 2, + "Preferred location areas"), + EF_CYCLIC_N(0x6F34, SFI_NONE, "EF.LNDComp", F_OPTIONAL, 3, 3, + "Composite LND file"), + EF_TRANSP_N(0x6F35, SFI_NONE, "EF.DFLTSTSTGGT", F_OPTIONAL, 16, 16, + "Status Default Target"), + EF_TRANSP_N(0x6F36, SFI_NONE, "EF.SDSMEM_STATUS", F_OPTIONAL, 7, 7, + "SDS Memory Status"), + EF_TRANSP_N(0x6F37, SFI_NONE, "EF.WELCOME", F_OPTIONAL, 32, 32, + "Welcome Message"), + EF_LIN_FIX_N(0x6F38, SFI_NONE, "EF.SDSR", F_OPTIONAL, 2, 2, + "SDS delivery report"), + EF_LIN_FIX_N(0x6F39, SFI_NONE, "EF.SDSP", F_OPTIONAL, 20, 35, + "SDS parameters"), + EF_TRANSP_N(0x6F46, SFI_NONE, "EF.DIALSC", 0, 5, 5, + "Dialling schemes for TETRA network"), + EF_TRANSP_N(0x6F3E, SFI_NONE, "EF.APN", F_OPTIONAL, 65, 65, + "APN table"), + EF_LIN_FIX_N(0x6FC0, SFI_NONE, "EF.PNI", F_OPTIONAL, 14, 14, + "Private Number Information"), }; -//////////////////////////// - -/* 10.5. */ -static const struct osim_file_desc sim_ef_in_telecom[] = { - EF_LIN_FIX_N(0x6F3A, "EF.ADN", F_OPTIONAL, - "Abbreviated dialling numbers"), - EF_LIN_FIX_N(0x6F3B, "EF.FDN", F_OPTIONAL, - "Fixed dialling numbers"), - EF_LIN_FIX_N(0x6F3C, "EF.SMS", F_OPTIONAL, - "Short messages"), - EF_LIN_FIX_N(0x6F3D, "EF.CCP", F_OPTIONAL, - "Capability configuration parameters"), - EF_LIN_FIX_N(0x6F4F, "EF.ECCP", F_OPTIONAL, - "Extended Capability configuration parameters"), - EF_LIN_FIX_N(0x6F40, "EF.MSISDN", F_OPTIONAL, - "MSISDN"), - EF_LIN_FIX_N(0x6F42, "EF.SMSP", F_OPTIONAL, - "Short message service parameters"), - EF_TRANSP_N(0x6F43, "EF.SMSS", F_OPTIONAL, - "SMS Status"), - EF_CYCLIC_N(0x6F44, "EF.LND", F_OPTIONAL, - "Last number dialled"), - EF_LIN_FIX_N(0x6F4A, "EF.EXT1", F_OPTIONAL, - "Extension 1"), - EF_LIN_FIX_N(0x6F4B, "EF.EXT2", F_OPTIONAL, - "Extension 2"), - EF_LIN_FIX_N(0x6F4C, "EF.EXT3", F_OPTIONAL, - "Extension 3"), - EF_LIN_FIX_N(0x6F4D, "EF.BDN", F_OPTIONAL, - "Barred dialling numbers"), - EF_LIN_FIX_N(0x6F4E, "EF.EXT4", F_OPTIONAL, - "Extension 4"), - EF_LIN_FIX_N(0x6F47, "EF.SMSR", F_OPTIONAL, - "Short message status reports"), - EF_LIN_FIX_N(0x6F58, "EF.CMI", F_OPTIONAL, - "Comparison Method Information"), -}; - - -/* 10.6. */ -static const struct osim_file_desc sim_ef_in_graphics[] = { - EF_LIN_FIX_N(0x4F20, "EF.IMG", F_OPTIONAL, - "Image"), -}; - -struct osim_card_profile *osim_cprof_sim(void *ctx) +struct osim_card_profile *osim_cprof_tsim(void *ctx) { struct osim_card_profile *cprof; - struct osim_file_desc *mf, *gsm, *tc; + struct osim_file_desc *mf, *tc; cprof = talloc_zero(ctx, struct osim_card_profile); - cprof->name = "GSM SIM"; - cprof->sws = sim_card_sws; + cprof->name = "TETRA SIM"; + cprof->sws = tsim_card_sws; mf = alloc_df(cprof, 0x3f00, "MF"); cprof->mf = mf; 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)); - add_df_with_ef(gsm, 0x5F30, "DF.IRIDIUM", NULL, 0); - add_df_with_ef(gsm, 0x5F31, "DF.GLOBST", NULL, 0); - add_df_with_ef(gsm, 0x5F32, "DF.ICO", NULL, 0); - add_df_with_ef(gsm, 0x5F33, "DF.ACeS", NULL, 0); - add_df_with_ef(gsm, 0x5F40, "DF.ACeS", NULL, 0); - add_df_with_ef(gsm, 0x5F60, "DF.CTS", NULL, 0); - add_df_with_ef(gsm, 0x5F70, "DF.SoLSA", NULL, 0); + 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, - ARRAY_SIZE(sim_ef_in_telecom)); + sim_ef_in_telecom_num); add_df_with_ef(tc, 0x5F50, "DF.GRAPHICS", sim_ef_in_graphics, - ARRAY_SIZE(sim_ef_in_graphics)); + sim_ef_in_graphics_num); return cprof; } -- cgit v1.2.3