blob: ee8dd749eec34dec681b44d8ead67fe57df446f4 [file] [log] [blame]
Harald Weltead418632012-09-10 10:49:59 +02001/* classic SIM card specific structures/routines */
2/*
Harald Weltebb5f3c72014-05-04 13:59:41 +02003 * (C) 2012-2014 by Harald Welte <laforge@gnumonks.org>
Harald Weltead418632012-09-10 10:49:59 +02004 *
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 */
Harald Welted54c2ee2012-01-17 18:25:50 +010022
23#include <errno.h>
24#include <string.h>
25
26#include <osmocom/sim/sim.h>
27#include <osmocom/core/talloc.h>
28#include <osmocom/gsm/gsm48.h>
29
30#include "sim_int.h"
31
Harald Weltebb5f3c72014-05-04 13:59:41 +020032/* 3GPP TS 51.011 / Chapter 9.4 */
Harald Welted54c2ee2012-01-17 18:25:50 +010033static const struct osim_card_sw ts11_11_sw[] = {
34 {
35 0x9000, 0xffff, SW_TYPE_STR, SW_CLS_OK,
36 .u.str = "Normal ending of the command",
37 }, {
38 0x9100, 0xff00, SW_TYPE_STR, SW_CLS_OK,
39 .u.str = "Normal ending of the command - proactive command from SIM pending",
40 }, {
41 0x9e00, 0xff00, SW_TYPE_STR, SW_CLS_OK,
42 .u.str = "Normal ending of the command - response data for SIM data download",
43 }, {
44 0x9f00, 0xff00, SW_TYPE_STR, SW_CLS_OK,
45 .u.str = "Normal ending of the command - response data available",
46 }, {
47 0x9300, 0xffff, SW_TYPE_STR, SW_CLS_POSTP,
48 .u.str = "SIM Application Toolkit is busy, command cannot be executed at present",
49 }, {
50 0x9200, 0xfff0, SW_TYPE_STR, SW_CLS_WARN,
51 .u.str = "Memory management - Command successful but after using an internal updat retry X times",
52 }, {
53 0x9240, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
54 .u.str = "Memory management - Memory problem",
55 }, {
56 0x9400, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
57 .u.str = "Referencing management - no EF selected",
58 }, {
59 0x9402, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
60 .u.str = "Referencing management - out of range (invalid address)",
61 }, {
62 0x9404, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
63 .u.str = "Referencing management - file ID not found / pattern not found",
64 }, {
Harald Weltebb5f3c72014-05-04 13:59:41 +020065 0x9408, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
66 .u.str = "Referencing management - file is inconsistent with the command",
67 }, {
Harald Welted54c2ee2012-01-17 18:25:50 +010068 0x9802, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
69 .u.str = "Security management - no CHV initialized",
70 }, {
71 0x9804, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
72 .u.str = "Security management - access condition not fulfilled",
73 }, {
74 0x9808, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
75 .u.str = "Security management - in contradiction with CHV status",
76 }, {
77 0x9810, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
78 .u.str = "Security management - in contradiction with invalidation status",
79 }, {
80 0x9840, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
81 .u.str = "Security management - unsuccessful CHV verification, no attempt left",
82 }, {
83 0x9850, 0xffff, SW_TYPE_STR, SW_CLS_ERROR,
84 .u.str = "Security management - increase cannot be performed, max value reached",
85 }, {
86 0x6700, 0xff00, SW_TYPE_STR, SW_CLS_ERROR,
87 .u.str = "Application independent - incorrect parameter P3",
88 }, {
89 0x6b00, 0xff00, SW_TYPE_STR, SW_CLS_ERROR,
90 .u.str = "Application independent - incorrect parameter P1 or P2",
91 }, {
92 0x6d00, 0xff00, SW_TYPE_STR, SW_CLS_ERROR,
93 .u.str = "Application independent - unknown instruction code",
94 }, {
95 0x6e00, 0xff00, SW_TYPE_STR, SW_CLS_ERROR,
96 .u.str = "Application independent - wrong instruction class",
97 }, {
98 0x6f00, 0xff00, SW_TYPE_STR, SW_CLS_ERROR,
99 .u.str = "Application independent - technical problem with no diagnostic given",
100 },
101 OSIM_CARD_SW_LAST
102};
103
104static const struct osim_card_sw *sim_card_sws[] = {
105 ts11_11_sw,
106 NULL
107};
108
109static int iccid_decode(struct osim_decoded_data *dd,
110 const struct osim_file_desc *desc,
111 int len, uint8_t *data)
112{
113 struct osim_decoded_element *elem;
114
115 elem = element_alloc(dd, "ICCID", ELEM_T_BCD, ELEM_REPR_DEC);
116 elem->length = len;
117 elem->u.buf = talloc_memdup(elem, data, len);
118
119 return 0;
120}
121
122static int elp_decode(struct osim_decoded_data *dd,
123 const struct osim_file_desc *desc,
124 int len, uint8_t *data)
125{
126 int i, num_lp = len / 2;
127
128 for (i = 0; i < num_lp; i++) {
129 uint8_t *cur = data + i*2;
130 struct osim_decoded_element *elem;
131 elem = element_alloc(dd, "Language Code", ELEM_T_STRING, ELEM_REPR_NONE);
132 elem->u.buf = (uint8_t *) talloc_strndup(elem, (const char *) cur, 2);
133 }
134
135 return 0;
136}
137
138static int default_decode(struct osim_decoded_data *dd,
139 const struct osim_file_desc *desc,
140 int len, uint8_t *data)
141{
142 struct osim_decoded_element *elem;
143
144 elem = element_alloc(dd, "Unknown Payload", ELEM_T_BYTES, ELEM_REPR_HEX);
145 elem->u.buf = talloc_memdup(elem, data, len);
146
147 return 0;
148}
149
150
151/* 10.3.1 */
152int gsm_lp_decode(struct osim_decoded_data *dd,
153 const struct osim_file_desc *desc,
154 int len, uint8_t *data)
155{
156 int i;
157
158 for (i = 0; i < len; i++) {
159 struct osim_decoded_element *elem;
160 elem = element_alloc(dd, "Language Code", ELEM_T_UINT8, ELEM_REPR_DEC);
161 elem->u.u8 = data[i];
162 }
163
164 return 0;
165}
166
167/* 10.3.2 */
168int gsm_imsi_decode(struct osim_decoded_data *dd,
169 const struct osim_file_desc *desc,
170 int len, uint8_t *data)
171{
172 struct osim_decoded_element *elem;
173
174 if (len < 2)
175 return -EINVAL;
176
177 elem = element_alloc(dd, "IMSI", ELEM_T_BCD, ELEM_REPR_DEC);
178 elem->length = data[0];
179 elem->u.buf = talloc_memdup(elem, data+1, len-1);
180
181 return 0;
182}
183
184/* 10.3.3 */
185static int gsm_kc_decode(struct osim_decoded_data *dd,
186 const struct osim_file_desc *desc,
187 int len, uint8_t *data)
188{
189 struct osim_decoded_element *kc, *cksn;
190
191 if (len < 9)
192 return -EINVAL;
193
194 kc = element_alloc(dd, "Kc", ELEM_T_BYTES, ELEM_REPR_HEX);
195 kc->u.buf = talloc_memdup(kc, data, 8);
196 cksn = element_alloc(dd, "CKSN", ELEM_T_UINT8, ELEM_REPR_DEC);
197 cksn->u.u8 = data[8];
198
199 return 0;
200}
201
202/* 10.3.4 */
203static int gsm_plmnsel_decode(struct osim_decoded_data *dd,
204 const struct osim_file_desc *desc,
205 int len, uint8_t *data)
206{
207 int i, n_plmn = len / 3;
208
209 if (n_plmn < 1)
210 return -EINVAL;
211
212 for (i = 0; i < n_plmn; i++) {
213 uint8_t *cur = data + 3*i;
214 struct osim_decoded_element *elem, *mcc, *mnc;
215 uint8_t ra_buf[6];
216 struct gprs_ra_id ra_id;
217
218 memset(ra_buf, 0, sizeof(ra_buf));
219 memcpy(ra_buf, cur, 3);
220 gsm48_parse_ra(&ra_id, ra_buf);
221
222 elem = element_alloc(dd, "PLMN", ELEM_T_GROUP, ELEM_REPR_NONE);
223
224 mcc = element_alloc_sub(elem, "MCC", ELEM_T_UINT16, ELEM_REPR_DEC);
225 mcc->u.u16 = ra_id.mcc;
226
227 mnc = element_alloc_sub(elem, "MNC", ELEM_T_UINT16, ELEM_REPR_DEC);
228 mnc->u.u16 = ra_id.mnc;
229 }
230
231 return 0;
232}
233
234/* 10.3.5 */
235int gsm_hpplmn_decode(struct osim_decoded_data *dd,
236 const struct osim_file_desc *desc,
237 int len, uint8_t *data)
238{
239 struct osim_decoded_element *elem;
240
241 elem = element_alloc(dd, "Time interval", ELEM_T_UINT8, ELEM_REPR_DEC);
242 elem->u.u8 = *data;
243
244 return 0;
245}
246
Harald Weltebb5f3c72014-05-04 13:59:41 +0200247/* Chapter 10.1. Contents of the EFs at the MF level */
Harald Welted54c2ee2012-01-17 18:25:50 +0100248static const struct osim_file_desc sim_ef_in_mf[] = {
Harald Weltebb5f3c72014-05-04 13:59:41 +0200249 EF_TRANSP(0x2FE2, SFI_NONE, "EF.ICCID", 0, 10, 10,
Harald Welted54c2ee2012-01-17 18:25:50 +0100250 "ICC Identification", &iccid_decode, NULL),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200251 EF_TRANSP(0x2F05, SFI_NONE, "EF.PL", F_OPTIONAL, 2, 20,
252 "Preferred language", &elp_decode, NULL),
Harald Welted54c2ee2012-01-17 18:25:50 +0100253};
254
Harald Weltebb5f3c72014-05-04 13:59:41 +0200255/* Chapter 10.3.x Contents of files at the GSM application level */
256const struct osim_file_desc sim_ef_in_gsm[] = {
257 EF_TRANSP(0x6F05, SFI_NONE, "EF.LP", 0, 1, 16,
Harald Welted54c2ee2012-01-17 18:25:50 +0100258 "Language preference", &gsm_lp_decode, NULL),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200259 EF_TRANSP(0x6F07, SFI_NONE, "EF.IMSI", 0, 9, 9,
Harald Welted54c2ee2012-01-17 18:25:50 +0100260 "IMSI", &gsm_imsi_decode, NULL),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200261 EF_TRANSP(0x6F20, SFI_NONE, "EF.Kc", 0, 9, 9,
Harald Welted54c2ee2012-01-17 18:25:50 +0100262 "Ciphering key Kc", &gsm_kc_decode, NULL),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200263 EF_TRANSP(0x6F30, SFI_NONE, "EF.PLMNsel", F_OPTIONAL, 24, 72,
Harald Welted54c2ee2012-01-17 18:25:50 +0100264 "PLMN selector", &gsm_plmnsel_decode, NULL),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200265 EF_TRANSP(0x6F31, SFI_NONE, "EF.HPPLMN", 0, 1, 1,
Harald Welted54c2ee2012-01-17 18:25:50 +0100266 "Higher Priority PLMN search period", &gsm_hpplmn_decode, NULL),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200267 EF_TRANSP_N(0x6F37, SFI_NONE, "EF.ACMmax", F_OPTIONAL, 3, 3,
Harald Welted54c2ee2012-01-17 18:25:50 +0100268 "ACM maximum value"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200269 EF_TRANSP_N(0x6F38, SFI_NONE, "EF.SST", 0, 2, 16,
Harald Welted54c2ee2012-01-17 18:25:50 +0100270 "SIM service table"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200271 EF_CYCLIC_N(0x6F39, SFI_NONE, "EF.ACM", F_OPTIONAL, 3, 3,
Harald Welted54c2ee2012-01-17 18:25:50 +0100272 "Accumulated call meter"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200273 EF_TRANSP_N(0x6F3E, SFI_NONE, "EF.GID1", F_OPTIONAL, 1, 8,
Harald Welted54c2ee2012-01-17 18:25:50 +0100274 "Group Identifier Level 1"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200275 EF_TRANSP_N(0x6F3F, SFI_NONE, "EF.GID2", F_OPTIONAL, 1, 8,
Harald Welted54c2ee2012-01-17 18:25:50 +0100276 "Group Identifier Level 2"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200277 EF_TRANSP_N(0x6F46, SFI_NONE, "EF.SPN", F_OPTIONAL, 17, 17,
Harald Welted54c2ee2012-01-17 18:25:50 +0100278 "Service Provider Name"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200279 EF_TRANSP_N(0x6F41, SFI_NONE, "EF.PUCT", F_OPTIONAL, 5, 5,
Harald Welted54c2ee2012-01-17 18:25:50 +0100280 "Price per unit and currency table"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200281 EF_TRANSP_N(0x6F45, SFI_NONE, "EF.CBMI", F_OPTIONAL, 2, 32,
Harald Welted54c2ee2012-01-17 18:25:50 +0100282 "Cell broadcast massage identifier selection"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200283 EF_TRANSP_N(0x6F74, SFI_NONE, "EF.BCCH", 0, 16, 16,
Harald Welted54c2ee2012-01-17 18:25:50 +0100284 "Broadcast control channels"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200285 EF_TRANSP_N(0x6F78, SFI_NONE, "EF.ACC", 0, 2, 2,
Harald Welted54c2ee2012-01-17 18:25:50 +0100286 "Access control class"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200287 EF_TRANSP_N(0x6F7B, SFI_NONE, "EF.FPLMN", 0, 12, 12,
Harald Welted54c2ee2012-01-17 18:25:50 +0100288 "Forbidden PLMNs"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200289 EF_TRANSP_N(0x6F7E, SFI_NONE, "EF.LOCI", 0, 11, 11,
Harald Welted54c2ee2012-01-17 18:25:50 +0100290 "Location information"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200291 EF_TRANSP_N(0x6FAD, SFI_NONE, "EF.AD", 0, 3, 8,
Harald Welted54c2ee2012-01-17 18:25:50 +0100292 "Administrative data"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200293 EF_TRANSP_N(0x6FAE, SFI_NONE, "EF.Phase", 0, 1, 1,
Harald Welted54c2ee2012-01-17 18:25:50 +0100294 "Phase identification"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200295 EF_TRANSP_N(0x6FB1, SFI_NONE, "EF.VGCS", F_OPTIONAL, 4, 80,
Harald Welted54c2ee2012-01-17 18:25:50 +0100296 "Voice Group Call Service"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200297 EF_TRANSP_N(0x6FB2, SFI_NONE, "EF.VGCSS", F_OPTIONAL, 7, 7,
Harald Welted54c2ee2012-01-17 18:25:50 +0100298 "Voice Group Call Service Status"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200299 EF_TRANSP_N(0x6FB3, SFI_NONE, "EF.VBS", F_OPTIONAL, 4, 80,
Harald Welted54c2ee2012-01-17 18:25:50 +0100300 "Voice Broadcast Service"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200301 EF_TRANSP_N(0x6FB4, SFI_NONE, "EF.VBSS", F_OPTIONAL, 7, 7,
Harald Welted54c2ee2012-01-17 18:25:50 +0100302 "Voice Broadcast Service Status"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200303 EF_TRANSP_N(0x6FB5, SFI_NONE, "EF.eMLPP", F_OPTIONAL, 2, 2,
Harald Welted54c2ee2012-01-17 18:25:50 +0100304 "enhanced Mult Level Pre-emption and Priority"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200305 EF_TRANSP_N(0x6FB6, SFI_NONE, "EF.AAeM", F_OPTIONAL, 1, 1,
Harald Welted54c2ee2012-01-17 18:25:50 +0100306 "Automatic Answer for eMLPP Service"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200307 EF_TRANSP_N(0x6F48, SFI_NONE, "EF.CBMID", F_OPTIONAL, 2, 32,
Harald Welted54c2ee2012-01-17 18:25:50 +0100308 "Cell Broadcast Message Identifier for Data Download"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200309 EF_TRANSP_N(0x6FB7, SFI_NONE, "EF.ECC", F_OPTIONAL, 3, 15,
Harald Welted54c2ee2012-01-17 18:25:50 +0100310 "Emergency Call Code"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200311 EF_TRANSP_N(0x6F50, SFI_NONE, "EF.CBMIR", F_OPTIONAL, 4, 64,
Harald Welted54c2ee2012-01-17 18:25:50 +0100312 "Cell broadcast message identifier range selection"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200313 EF_TRANSP_N(0x6F2C, SFI_NONE, "EF.DCK", F_OPTIONAL, 16, 16,
Harald Welted54c2ee2012-01-17 18:25:50 +0100314 "De-personalization Control Keys"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200315 EF_TRANSP_N(0x6F32, SFI_NONE, "EF.CNL", F_OPTIONAL, 6, 60,
Harald Welted54c2ee2012-01-17 18:25:50 +0100316 "Co-operative Network List"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200317 EF_LIN_FIX_N(0x6F51, SFI_NONE, "EF.NIA", F_OPTIONAL, 1, 17,
Harald Welted54c2ee2012-01-17 18:25:50 +0100318 "Network's Indication of Alerting"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200319 EF_TRANSP_N(0x6F52, SFI_NONE, "EF.KcGPRS", F_OPTIONAL, 9, 9,
Harald Welted54c2ee2012-01-17 18:25:50 +0100320 "GPRS Ciphering key KcGPRS"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200321 EF_TRANSP_N(0x6F53, SFI_NONE, "EF.LOCIGPRS", F_OPTIONAL, 14, 14,
Harald Welted54c2ee2012-01-17 18:25:50 +0100322 "GPRS location information"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200323 EF_TRANSP_N(0x6F54, SFI_NONE, "EF.SUME", F_OPTIONAL, 1, 64,
Harald Welted54c2ee2012-01-17 18:25:50 +0100324 "SetUpMenu Elements"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200325 EF_TRANSP_N(0x6F60, SFI_NONE, "EF.PLMNwAcT", F_OPTIONAL, 40, 80,
Harald Welted54c2ee2012-01-17 18:25:50 +0100326 "User controlled PLMN Selector with Access Technology"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200327 EF_TRANSP_N(0x6F61, SFI_NONE, "EF.OPLMNwAcT", F_OPTIONAL, 40, 80,
Harald Welted54c2ee2012-01-17 18:25:50 +0100328 "Operator controlled PLMN Selector with Access Technology"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200329 EF_TRANSP_N(0x6F62, SFI_NONE, "EF.HPLMNwAcT", F_OPTIONAL, 5, 20,
Harald Welted54c2ee2012-01-17 18:25:50 +0100330 "HPLMN Selector with Access Technology"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200331 EF_TRANSP_N(0x6F63, SFI_NONE, "EF.CPBCCH", F_OPTIONAL, 2, 20,
Harald Welted54c2ee2012-01-17 18:25:50 +0100332 "CPBCCH Information"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200333 EF_TRANSP_N(0x6F64, SFI_NONE, "EF.InvScan", F_OPTIONAL, 1, 1,
Harald Welted54c2ee2012-01-17 18:25:50 +0100334 "Investigation Scan"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200335 EF_LIN_FIX_N(0x6FC5, SFI_NONE, "EF.PNN", F_OPTIONAL, 3, 20,
336 "PLMN Network Name"),
337 EF_LIN_FIX_N(0x6FC6, SFI_NONE, "EF.OPL", F_OPTIONAL, 8, 8,
338 "PLMN Operator PLMN List"),
339 EF_LIN_FIX_N(0x6FC7, SFI_NONE, "EF.MBDN", F_OPTIONAL, 14, 30,
340 "Mailbox Dialling Number"),
341 EF_LIN_FIX_N(0x6FC9, SFI_NONE, "EF.MBI", F_OPTIONAL, 4, 4,
342 "Maibox Identifier"),
343 EF_LIN_FIX_N(0x6FCA, SFI_NONE, "EF.MWIS", F_OPTIONAL, 5, 5,
344 "Message Waiting Indication Status"),
345 EF_LIN_FIX_N(0x6FCB, SFI_NONE, "EF.CFIS", F_OPTIONAL, 16, 16,
346 "Call Forwarding Indication Status"),
347 EF_LIN_FIX_N(0x6FC8, SFI_NONE, "EF.EXT6", F_OPTIONAL, 13, 13,
348 "Extension6 (MBDN)"),
349 EF_LIN_FIX_N(0x6FCC, SFI_NONE, "EF.EXT7", F_OPTIONAL, 13, 13,
350 "Extension7 (CFIS)"),
351 EF_TRANSP_N(0x6FCD, SFI_NONE, "EF.SPDI", F_OPTIONAL, 1, 32,
352 "Extension7 (CFIS)"),
353 EF_LIN_FIX_N(0x6FCE, SFI_NONE, "EF.MMSN", F_OPTIONAL, 4, 32,
354 "MMS Notification"),
355 EF_LIN_FIX_N(0x6FCF, SFI_NONE, "EF.EXT8", F_OPTIONAL, 2, 18,
356 "Extension8 (MMSN)"),
357 EF_TRANSP_N(0x6FD0, SFI_NONE, "EF.MMSICP", F_OPTIONAL, 1, 64,
358 "MMS Issuer Connectivity Parameters"),
359 EF_LIN_FIX_N(0x6FD1, SFI_NONE, "EF.MMSUP", F_OPTIONAL, 1, 64,
360 "MMS User Preferences"),
361 EF_TRANSP_N(0x6FD2, SFI_NONE, "EF.MMSUCP", F_OPTIONAL, 1, 64,
362 "MMS User Connectivity Parameters"),
363};
364const size_t sim_ef_in_gsm_num = ARRAY_SIZE(sim_ef_in_gsm);
365
366/* 10.4.1 Contents of the files at the SoLSA level */
367static const struct osim_file_desc sim_ef_in_solsa[] = {
368 EF_TRANSP_N(0x4F30, SFI_NONE, "EF.SAI", F_OPTIONAL, 1, 32,
369 "SoLSA Access Indicator"),
370 EF_LIN_FIX_N(0x4F31, SFI_NONE, "EF.SLL", F_OPTIONAL, 1, 32,
371 "SoLSA LSA List"),
372 /* LSA Descriptor files */
Harald Welted54c2ee2012-01-17 18:25:50 +0100373};
374
Harald Weltebb5f3c72014-05-04 13:59:41 +0200375/* 10.4.2 Contents of files at the MExE level */
376static const struct osim_file_desc sim_ef_in_mexe[] = {
377 EF_TRANSP_N(0x4F40, SFI_NONE, "EF.MExE-ST", F_OPTIONAL, 1, 8,
378 "MExE Service table"),
379 EF_LIN_FIX_N(0x4F41, SFI_NONE, "EF.ORPK", F_OPTIONAL, 11, 32,
380 "Operator Root Public Key"),
381 EF_LIN_FIX_N(0x4F42, SFI_NONE, "EF.ARPK", F_OPTIONAL, 11, 32,
382 "Administrator Root Public Key"),
383 EF_LIN_FIX_N(0x4F43, SFI_NONE, "EF.TRPK", F_OPTIONAL, 11, 32,
384 "Third Party Root Public Key"),
385};
386
387/* 10.5 Contents of files at the telecom level */
388const struct osim_file_desc sim_ef_in_telecom[] = {
389 EF_LIN_FIX_N(0x6F3A, SFI_NONE, "EF.ADN", F_OPTIONAL, 14, 30,
Harald Welted54c2ee2012-01-17 18:25:50 +0100390 "Abbreviated dialling numbers"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200391 EF_LIN_FIX_N(0x6F3B, SFI_NONE, "EF.FDN", F_OPTIONAL, 14, 30,
Harald Welted54c2ee2012-01-17 18:25:50 +0100392 "Fixed dialling numbers"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200393 EF_LIN_FIX_N(0x6F3C, SFI_NONE, "EF.SMS", F_OPTIONAL, 176, 176,
Harald Welted54c2ee2012-01-17 18:25:50 +0100394 "Short messages"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200395 EF_LIN_FIX_N(0x6F3D, SFI_NONE, "EF.CCP", F_OPTIONAL, 14, 14,
Harald Welted54c2ee2012-01-17 18:25:50 +0100396 "Capability configuration parameters"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200397 EF_LIN_FIX_N(0x6F4F, SFI_NONE, "EF.ECCP", F_OPTIONAL, 15, 15,
Harald Welted54c2ee2012-01-17 18:25:50 +0100398 "Extended Capability configuration parameters"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200399 EF_LIN_FIX_N(0x6F40, SFI_NONE, "EF.MSISDN", F_OPTIONAL, 14, 30,
Harald Welted54c2ee2012-01-17 18:25:50 +0100400 "MSISDN"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200401 EF_LIN_FIX_N(0x6F42, SFI_NONE, "EF.SMSP", F_OPTIONAL, 28, 44,
Harald Welted54c2ee2012-01-17 18:25:50 +0100402 "Short message service parameters"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200403 EF_TRANSP_N(0x6F43, SFI_NONE, "EF.SMSS", F_OPTIONAL, 2, 3,
Harald Welted54c2ee2012-01-17 18:25:50 +0100404 "SMS Status"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200405 EF_CYCLIC_N(0x6F44, SFI_NONE, "EF.LND", F_OPTIONAL, 14, 30,
Harald Welted54c2ee2012-01-17 18:25:50 +0100406 "Last number dialled"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200407 EF_LIN_FIX_N(0x6F49, SFI_NONE, "EF.SDN", F_OPTIONAL, 14, 30,
408 "Service Dialling Numbers"),
409 EF_LIN_FIX_N(0x6F4A, SFI_NONE, "EF.EXT1", F_OPTIONAL, 13, 13,
410 "Extension 1 (ADN/SSC, MSISDN, LND)"),
411 EF_LIN_FIX_N(0x6F4B, SFI_NONE, "EF.EXT2", F_OPTIONAL, 13, 13,
412 "Extension 2 (FDN/SSC)"),
413 EF_LIN_FIX_N(0x6F4C, SFI_NONE, "EF.EXT3", F_OPTIONAL, 13, 13,
414 "Extension 3 (SDN)"),
415 EF_LIN_FIX_N(0x6F4D, SFI_NONE, "EF.BDN", F_OPTIONAL, 15, 31,
Harald Welted54c2ee2012-01-17 18:25:50 +0100416 "Barred dialling numbers"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200417 EF_LIN_FIX_N(0x6F4E, SFI_NONE, "EF.EXT4", F_OPTIONAL, 13, 13,
418 "Extension 4 (BDN/SSC)"),
419 EF_LIN_FIX_N(0x6F47, SFI_NONE, "EF.SMSR", F_OPTIONAL, 30, 30,
Harald Welted54c2ee2012-01-17 18:25:50 +0100420 "Short message status reports"),
Harald Weltebb5f3c72014-05-04 13:59:41 +0200421 EF_LIN_FIX_N(0x6F58, SFI_NONE, "EF.CMI", F_OPTIONAL, 1, 17,
Harald Welted54c2ee2012-01-17 18:25:50 +0100422 "Comparison Method Information"),
423};
Harald Weltebb5f3c72014-05-04 13:59:41 +0200424const size_t sim_ef_in_telecom_num = ARRAY_SIZE(sim_ef_in_telecom);
Harald Welted54c2ee2012-01-17 18:25:50 +0100425
Harald Weltebb5f3c72014-05-04 13:59:41 +0200426/* 10.6.1 Contents of files at the telecom graphics level */
427const struct osim_file_desc sim_ef_in_graphics[] = {
428 EF_LIN_FIX_N(0x4F20, SFI_NONE, "EF.IMG", F_OPTIONAL, 11, 38,
Harald Welted54c2ee2012-01-17 18:25:50 +0100429 "Image"),
430};
Harald Weltebb5f3c72014-05-04 13:59:41 +0200431const size_t sim_ef_in_graphics_num = ARRAY_SIZE(sim_ef_in_graphics);
Harald Welted54c2ee2012-01-17 18:25:50 +0100432
433struct osim_card_profile *osim_cprof_sim(void *ctx)
434{
435 struct osim_card_profile *cprof;
436 struct osim_file_desc *mf, *gsm, *tc;
437
438 cprof = talloc_zero(ctx, struct osim_card_profile);
439 cprof->name = "GSM SIM";
440 cprof->sws = sim_card_sws;
441
442 mf = alloc_df(cprof, 0x3f00, "MF");
443
444 cprof->mf = mf;
445
Harald Weltebb5f3c72014-05-04 13:59:41 +0200446 /* According to Figure 8 */
Harald Welted54c2ee2012-01-17 18:25:50 +0100447 add_filedesc(mf, sim_ef_in_mf, ARRAY_SIZE(sim_ef_in_mf));
448 gsm = add_df_with_ef(mf, 0x7F20, "DF.GSM", sim_ef_in_gsm,
449 ARRAY_SIZE(sim_ef_in_gsm));
Harald Weltebb5f3c72014-05-04 13:59:41 +0200450 /* Chapter 10.2: DFs at the GSM Application Level */
Harald Welted54c2ee2012-01-17 18:25:50 +0100451 add_df_with_ef(gsm, 0x5F30, "DF.IRIDIUM", NULL, 0);
Harald Weltebb5f3c72014-05-04 13:59:41 +0200452 add_df_with_ef(gsm, 0x5F31, "DF.GLOBALSTAR", NULL, 0);
Harald Welted54c2ee2012-01-17 18:25:50 +0100453 add_df_with_ef(gsm, 0x5F32, "DF.ICO", NULL, 0);
454 add_df_with_ef(gsm, 0x5F33, "DF.ACeS", NULL, 0);
Harald Weltebb5f3c72014-05-04 13:59:41 +0200455 add_df_with_ef(gsm, 0x5F3C, "DF.MExE", sim_ef_in_mexe,
456 ARRAY_SIZE(sim_ef_in_mexe));
457 add_df_with_ef(gsm, 0x5F40, "DF.EIA/TIA-533", NULL, 0);
Harald Welted54c2ee2012-01-17 18:25:50 +0100458 add_df_with_ef(gsm, 0x5F60, "DF.CTS", NULL, 0);
Harald Weltebb5f3c72014-05-04 13:59:41 +0200459 add_df_with_ef(gsm, 0x5F70, "DF.SoLSA", sim_ef_in_solsa,
460 ARRAY_SIZE(sim_ef_in_solsa));
461
Harald Welted54c2ee2012-01-17 18:25:50 +0100462 tc = add_df_with_ef(mf, 0x7F10, "DF.TELECOM", sim_ef_in_telecom,
463 ARRAY_SIZE(sim_ef_in_telecom));
464 add_df_with_ef(tc, 0x5F50, "DF.GRAPHICS", sim_ef_in_graphics,
465 ARRAY_SIZE(sim_ef_in_graphics));
Harald Weltebb5f3c72014-05-04 13:59:41 +0200466 add_df_with_ef(mf, 0x7F22, "DF.IS-41", NULL, 0);
467 add_df_with_ef(mf, 0x7F23, "DF.FP-CTS", NULL, 0); /* TS 11.19 */
Harald Welted54c2ee2012-01-17 18:25:50 +0100468
469 return cprof;
470}