Neels Hofmeyr | 17518fe | 2017-06-20 04:35:06 +0200 | [diff] [blame] | 1 | /*! \file card_fs_sim.c |
| 2 | * classic SIM card specific structures/routines. */ |
Harald Welte | ad41863 | 2012-09-10 10:49:59 +0200 | [diff] [blame] | 3 | /* |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 4 | * (C) 2012-2014 by Harald Welte <laforge@gnumonks.org> |
Harald Welte | ad41863 | 2012-09-10 10:49:59 +0200 | [diff] [blame] | 5 | * |
| 6 | * All Rights Reserved |
| 7 | * |
Harald Welte | e08da97 | 2017-11-13 01:00:26 +0900 | [diff] [blame] | 8 | * SPDX-License-Identifier: GPL-2.0+ |
| 9 | * |
Harald Welte | ad41863 | 2012-09-10 10:49:59 +0200 | [diff] [blame] | 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License along |
| 21 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 22 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 23 | * |
| 24 | */ |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 25 | |
| 26 | #include <errno.h> |
| 27 | #include <string.h> |
| 28 | |
| 29 | #include <osmocom/sim/sim.h> |
| 30 | #include <osmocom/core/talloc.h> |
| 31 | #include <osmocom/gsm/gsm48.h> |
| 32 | |
| 33 | #include "sim_int.h" |
| 34 | |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 35 | /* 3GPP TS 51.011 / Chapter 9.4 */ |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 36 | static const struct osim_card_sw ts11_11_sw[] = { |
| 37 | { |
| 38 | 0x9000, 0xffff, SW_TYPE_STR, SW_CLS_OK, |
| 39 | .u.str = "Normal ending of the command", |
| 40 | }, { |
| 41 | 0x9100, 0xff00, SW_TYPE_STR, SW_CLS_OK, |
| 42 | .u.str = "Normal ending of the command - proactive command from SIM pending", |
| 43 | }, { |
| 44 | 0x9e00, 0xff00, SW_TYPE_STR, SW_CLS_OK, |
| 45 | .u.str = "Normal ending of the command - response data for SIM data download", |
| 46 | }, { |
| 47 | 0x9f00, 0xff00, SW_TYPE_STR, SW_CLS_OK, |
| 48 | .u.str = "Normal ending of the command - response data available", |
| 49 | }, { |
| 50 | 0x9300, 0xffff, SW_TYPE_STR, SW_CLS_POSTP, |
| 51 | .u.str = "SIM Application Toolkit is busy, command cannot be executed at present", |
| 52 | }, { |
| 53 | 0x9200, 0xfff0, SW_TYPE_STR, SW_CLS_WARN, |
Thorsten Alteholz | 5a9dbf8 | 2018-04-08 19:13:25 +0200 | [diff] [blame] | 54 | .u.str = "Memory management - Command successful but after using an internal update retry X times", |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 55 | }, { |
| 56 | 0x9240, 0xffff, SW_TYPE_STR, SW_CLS_ERROR, |
| 57 | .u.str = "Memory management - Memory problem", |
| 58 | }, { |
| 59 | 0x9400, 0xffff, SW_TYPE_STR, SW_CLS_ERROR, |
| 60 | .u.str = "Referencing management - no EF selected", |
| 61 | }, { |
| 62 | 0x9402, 0xffff, SW_TYPE_STR, SW_CLS_ERROR, |
| 63 | .u.str = "Referencing management - out of range (invalid address)", |
| 64 | }, { |
| 65 | 0x9404, 0xffff, SW_TYPE_STR, SW_CLS_ERROR, |
| 66 | .u.str = "Referencing management - file ID not found / pattern not found", |
| 67 | }, { |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 68 | 0x9408, 0xffff, SW_TYPE_STR, SW_CLS_ERROR, |
| 69 | .u.str = "Referencing management - file is inconsistent with the command", |
| 70 | }, { |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 71 | 0x9802, 0xffff, SW_TYPE_STR, SW_CLS_ERROR, |
| 72 | .u.str = "Security management - no CHV initialized", |
| 73 | }, { |
| 74 | 0x9804, 0xffff, SW_TYPE_STR, SW_CLS_ERROR, |
| 75 | .u.str = "Security management - access condition not fulfilled", |
| 76 | }, { |
| 77 | 0x9808, 0xffff, SW_TYPE_STR, SW_CLS_ERROR, |
| 78 | .u.str = "Security management - in contradiction with CHV status", |
| 79 | }, { |
| 80 | 0x9810, 0xffff, SW_TYPE_STR, SW_CLS_ERROR, |
| 81 | .u.str = "Security management - in contradiction with invalidation status", |
| 82 | }, { |
| 83 | 0x9840, 0xffff, SW_TYPE_STR, SW_CLS_ERROR, |
| 84 | .u.str = "Security management - unsuccessful CHV verification, no attempt left", |
| 85 | }, { |
| 86 | 0x9850, 0xffff, SW_TYPE_STR, SW_CLS_ERROR, |
| 87 | .u.str = "Security management - increase cannot be performed, max value reached", |
| 88 | }, { |
| 89 | 0x6700, 0xff00, SW_TYPE_STR, SW_CLS_ERROR, |
| 90 | .u.str = "Application independent - incorrect parameter P3", |
| 91 | }, { |
| 92 | 0x6b00, 0xff00, SW_TYPE_STR, SW_CLS_ERROR, |
| 93 | .u.str = "Application independent - incorrect parameter P1 or P2", |
| 94 | }, { |
| 95 | 0x6d00, 0xff00, SW_TYPE_STR, SW_CLS_ERROR, |
| 96 | .u.str = "Application independent - unknown instruction code", |
| 97 | }, { |
| 98 | 0x6e00, 0xff00, SW_TYPE_STR, SW_CLS_ERROR, |
| 99 | .u.str = "Application independent - wrong instruction class", |
| 100 | }, { |
| 101 | 0x6f00, 0xff00, SW_TYPE_STR, SW_CLS_ERROR, |
| 102 | .u.str = "Application independent - technical problem with no diagnostic given", |
| 103 | }, |
| 104 | OSIM_CARD_SW_LAST |
| 105 | }; |
| 106 | |
| 107 | static const struct osim_card_sw *sim_card_sws[] = { |
| 108 | ts11_11_sw, |
| 109 | NULL |
| 110 | }; |
| 111 | |
| 112 | static int iccid_decode(struct osim_decoded_data *dd, |
| 113 | const struct osim_file_desc *desc, |
| 114 | int len, uint8_t *data) |
| 115 | { |
| 116 | struct osim_decoded_element *elem; |
| 117 | |
| 118 | elem = element_alloc(dd, "ICCID", ELEM_T_BCD, ELEM_REPR_DEC); |
| 119 | elem->length = len; |
| 120 | elem->u.buf = talloc_memdup(elem, data, len); |
| 121 | |
| 122 | return 0; |
| 123 | } |
| 124 | |
| 125 | static int elp_decode(struct osim_decoded_data *dd, |
| 126 | const struct osim_file_desc *desc, |
| 127 | int len, uint8_t *data) |
| 128 | { |
| 129 | int i, num_lp = len / 2; |
| 130 | |
| 131 | for (i = 0; i < num_lp; i++) { |
| 132 | uint8_t *cur = data + i*2; |
| 133 | struct osim_decoded_element *elem; |
| 134 | elem = element_alloc(dd, "Language Code", ELEM_T_STRING, ELEM_REPR_NONE); |
| 135 | elem->u.buf = (uint8_t *) talloc_strndup(elem, (const char *) cur, 2); |
| 136 | } |
| 137 | |
| 138 | return 0; |
| 139 | } |
| 140 | |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 141 | /* 10.3.1 */ |
| 142 | int gsm_lp_decode(struct osim_decoded_data *dd, |
| 143 | const struct osim_file_desc *desc, |
| 144 | int len, uint8_t *data) |
| 145 | { |
| 146 | int i; |
| 147 | |
| 148 | for (i = 0; i < len; i++) { |
| 149 | struct osim_decoded_element *elem; |
| 150 | elem = element_alloc(dd, "Language Code", ELEM_T_UINT8, ELEM_REPR_DEC); |
| 151 | elem->u.u8 = data[i]; |
| 152 | } |
| 153 | |
| 154 | return 0; |
| 155 | } |
| 156 | |
| 157 | /* 10.3.2 */ |
| 158 | int gsm_imsi_decode(struct osim_decoded_data *dd, |
| 159 | const struct osim_file_desc *desc, |
| 160 | int len, uint8_t *data) |
| 161 | { |
| 162 | struct osim_decoded_element *elem; |
| 163 | |
| 164 | if (len < 2) |
| 165 | return -EINVAL; |
| 166 | |
| 167 | elem = element_alloc(dd, "IMSI", ELEM_T_BCD, ELEM_REPR_DEC); |
| 168 | elem->length = data[0]; |
| 169 | elem->u.buf = talloc_memdup(elem, data+1, len-1); |
| 170 | |
| 171 | return 0; |
| 172 | } |
| 173 | |
| 174 | /* 10.3.3 */ |
| 175 | static int gsm_kc_decode(struct osim_decoded_data *dd, |
| 176 | const struct osim_file_desc *desc, |
| 177 | int len, uint8_t *data) |
| 178 | { |
| 179 | struct osim_decoded_element *kc, *cksn; |
| 180 | |
| 181 | if (len < 9) |
| 182 | return -EINVAL; |
| 183 | |
| 184 | kc = element_alloc(dd, "Kc", ELEM_T_BYTES, ELEM_REPR_HEX); |
| 185 | kc->u.buf = talloc_memdup(kc, data, 8); |
| 186 | cksn = element_alloc(dd, "CKSN", ELEM_T_UINT8, ELEM_REPR_DEC); |
| 187 | cksn->u.u8 = data[8]; |
| 188 | |
| 189 | return 0; |
| 190 | } |
| 191 | |
| 192 | /* 10.3.4 */ |
| 193 | static int gsm_plmnsel_decode(struct osim_decoded_data *dd, |
| 194 | const struct osim_file_desc *desc, |
| 195 | int len, uint8_t *data) |
| 196 | { |
| 197 | int i, n_plmn = len / 3; |
| 198 | |
| 199 | if (n_plmn < 1) |
| 200 | return -EINVAL; |
| 201 | |
| 202 | for (i = 0; i < n_plmn; i++) { |
| 203 | uint8_t *cur = data + 3*i; |
| 204 | struct osim_decoded_element *elem, *mcc, *mnc; |
| 205 | uint8_t ra_buf[6]; |
| 206 | struct gprs_ra_id ra_id; |
| 207 | |
| 208 | memset(ra_buf, 0, sizeof(ra_buf)); |
| 209 | memcpy(ra_buf, cur, 3); |
| 210 | gsm48_parse_ra(&ra_id, ra_buf); |
| 211 | |
| 212 | elem = element_alloc(dd, "PLMN", ELEM_T_GROUP, ELEM_REPR_NONE); |
| 213 | |
| 214 | mcc = element_alloc_sub(elem, "MCC", ELEM_T_UINT16, ELEM_REPR_DEC); |
| 215 | mcc->u.u16 = ra_id.mcc; |
| 216 | |
| 217 | mnc = element_alloc_sub(elem, "MNC", ELEM_T_UINT16, ELEM_REPR_DEC); |
| 218 | mnc->u.u16 = ra_id.mnc; |
Neels Hofmeyr | c4fce14 | 2018-02-20 13:47:08 +0100 | [diff] [blame] | 219 | /* TODO: what about ra_id.mnc_3_digits? */ |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | return 0; |
| 223 | } |
| 224 | |
| 225 | /* 10.3.5 */ |
| 226 | int gsm_hpplmn_decode(struct osim_decoded_data *dd, |
| 227 | const struct osim_file_desc *desc, |
| 228 | int len, uint8_t *data) |
| 229 | { |
| 230 | struct osim_decoded_element *elem; |
| 231 | |
| 232 | elem = element_alloc(dd, "Time interval", ELEM_T_UINT8, ELEM_REPR_DEC); |
| 233 | elem->u.u8 = *data; |
| 234 | |
| 235 | return 0; |
| 236 | } |
| 237 | |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 238 | /* Chapter 10.1. Contents of the EFs at the MF level */ |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 239 | static const struct osim_file_desc sim_ef_in_mf[] = { |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 240 | EF_TRANSP(0x2FE2, SFI_NONE, "EF.ICCID", 0, 10, 10, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 241 | "ICC Identification", &iccid_decode, NULL), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 242 | EF_TRANSP(0x2F05, SFI_NONE, "EF.PL", F_OPTIONAL, 2, 20, |
| 243 | "Preferred language", &elp_decode, NULL), |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 244 | }; |
| 245 | |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 246 | /* Chapter 10.3.x Contents of files at the GSM application level */ |
Harald Welte | 6729a97 | 2014-10-26 19:04:56 +0100 | [diff] [blame] | 247 | static const struct osim_file_desc sim_ef_in_gsm[] = { |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 248 | EF_TRANSP(0x6F05, SFI_NONE, "EF.LP", 0, 1, 16, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 249 | "Language preference", &gsm_lp_decode, NULL), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 250 | EF_TRANSP(0x6F07, SFI_NONE, "EF.IMSI", 0, 9, 9, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 251 | "IMSI", &gsm_imsi_decode, NULL), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 252 | EF_TRANSP(0x6F20, SFI_NONE, "EF.Kc", 0, 9, 9, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 253 | "Ciphering key Kc", &gsm_kc_decode, NULL), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 254 | EF_TRANSP(0x6F30, SFI_NONE, "EF.PLMNsel", F_OPTIONAL, 24, 72, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 255 | "PLMN selector", &gsm_plmnsel_decode, NULL), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 256 | EF_TRANSP(0x6F31, SFI_NONE, "EF.HPPLMN", 0, 1, 1, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 257 | "Higher Priority PLMN search period", &gsm_hpplmn_decode, NULL), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 258 | EF_TRANSP_N(0x6F37, SFI_NONE, "EF.ACMmax", F_OPTIONAL, 3, 3, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 259 | "ACM maximum value"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 260 | EF_TRANSP_N(0x6F38, SFI_NONE, "EF.SST", 0, 2, 16, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 261 | "SIM service table"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 262 | EF_CYCLIC_N(0x6F39, SFI_NONE, "EF.ACM", F_OPTIONAL, 3, 3, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 263 | "Accumulated call meter"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 264 | EF_TRANSP_N(0x6F3E, SFI_NONE, "EF.GID1", F_OPTIONAL, 1, 8, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 265 | "Group Identifier Level 1"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 266 | EF_TRANSP_N(0x6F3F, SFI_NONE, "EF.GID2", F_OPTIONAL, 1, 8, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 267 | "Group Identifier Level 2"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 268 | EF_TRANSP_N(0x6F46, SFI_NONE, "EF.SPN", F_OPTIONAL, 17, 17, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 269 | "Service Provider Name"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 270 | EF_TRANSP_N(0x6F41, SFI_NONE, "EF.PUCT", F_OPTIONAL, 5, 5, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 271 | "Price per unit and currency table"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 272 | EF_TRANSP_N(0x6F45, SFI_NONE, "EF.CBMI", F_OPTIONAL, 2, 32, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 273 | "Cell broadcast massage identifier selection"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 274 | EF_TRANSP_N(0x6F74, SFI_NONE, "EF.BCCH", 0, 16, 16, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 275 | "Broadcast control channels"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 276 | EF_TRANSP_N(0x6F78, SFI_NONE, "EF.ACC", 0, 2, 2, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 277 | "Access control class"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 278 | EF_TRANSP_N(0x6F7B, SFI_NONE, "EF.FPLMN", 0, 12, 12, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 279 | "Forbidden PLMNs"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 280 | EF_TRANSP_N(0x6F7E, SFI_NONE, "EF.LOCI", 0, 11, 11, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 281 | "Location information"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 282 | EF_TRANSP_N(0x6FAD, SFI_NONE, "EF.AD", 0, 3, 8, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 283 | "Administrative data"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 284 | EF_TRANSP_N(0x6FAE, SFI_NONE, "EF.Phase", 0, 1, 1, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 285 | "Phase identification"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 286 | EF_TRANSP_N(0x6FB1, SFI_NONE, "EF.VGCS", F_OPTIONAL, 4, 80, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 287 | "Voice Group Call Service"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 288 | EF_TRANSP_N(0x6FB2, SFI_NONE, "EF.VGCSS", F_OPTIONAL, 7, 7, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 289 | "Voice Group Call Service Status"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 290 | EF_TRANSP_N(0x6FB3, SFI_NONE, "EF.VBS", F_OPTIONAL, 4, 80, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 291 | "Voice Broadcast Service"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 292 | EF_TRANSP_N(0x6FB4, SFI_NONE, "EF.VBSS", F_OPTIONAL, 7, 7, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 293 | "Voice Broadcast Service Status"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 294 | EF_TRANSP_N(0x6FB5, SFI_NONE, "EF.eMLPP", F_OPTIONAL, 2, 2, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 295 | "enhanced Mult Level Pre-emption and Priority"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 296 | EF_TRANSP_N(0x6FB6, SFI_NONE, "EF.AAeM", F_OPTIONAL, 1, 1, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 297 | "Automatic Answer for eMLPP Service"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 298 | EF_TRANSP_N(0x6F48, SFI_NONE, "EF.CBMID", F_OPTIONAL, 2, 32, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 299 | "Cell Broadcast Message Identifier for Data Download"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 300 | EF_TRANSP_N(0x6FB7, SFI_NONE, "EF.ECC", F_OPTIONAL, 3, 15, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 301 | "Emergency Call Code"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 302 | EF_TRANSP_N(0x6F50, SFI_NONE, "EF.CBMIR", F_OPTIONAL, 4, 64, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 303 | "Cell broadcast message identifier range selection"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 304 | EF_TRANSP_N(0x6F2C, SFI_NONE, "EF.DCK", F_OPTIONAL, 16, 16, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 305 | "De-personalization Control Keys"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 306 | EF_TRANSP_N(0x6F32, SFI_NONE, "EF.CNL", F_OPTIONAL, 6, 60, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 307 | "Co-operative Network List"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 308 | EF_LIN_FIX_N(0x6F51, SFI_NONE, "EF.NIA", F_OPTIONAL, 1, 17, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 309 | "Network's Indication of Alerting"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 310 | EF_TRANSP_N(0x6F52, SFI_NONE, "EF.KcGPRS", F_OPTIONAL, 9, 9, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 311 | "GPRS Ciphering key KcGPRS"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 312 | EF_TRANSP_N(0x6F53, SFI_NONE, "EF.LOCIGPRS", F_OPTIONAL, 14, 14, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 313 | "GPRS location information"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 314 | EF_TRANSP_N(0x6F54, SFI_NONE, "EF.SUME", F_OPTIONAL, 1, 64, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 315 | "SetUpMenu Elements"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 316 | EF_TRANSP_N(0x6F60, SFI_NONE, "EF.PLMNwAcT", F_OPTIONAL, 40, 80, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 317 | "User controlled PLMN Selector with Access Technology"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 318 | EF_TRANSP_N(0x6F61, SFI_NONE, "EF.OPLMNwAcT", F_OPTIONAL, 40, 80, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 319 | "Operator controlled PLMN Selector with Access Technology"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 320 | EF_TRANSP_N(0x6F62, SFI_NONE, "EF.HPLMNwAcT", F_OPTIONAL, 5, 20, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 321 | "HPLMN Selector with Access Technology"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 322 | EF_TRANSP_N(0x6F63, SFI_NONE, "EF.CPBCCH", F_OPTIONAL, 2, 20, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 323 | "CPBCCH Information"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 324 | EF_TRANSP_N(0x6F64, SFI_NONE, "EF.InvScan", F_OPTIONAL, 1, 1, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 325 | "Investigation Scan"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 326 | EF_LIN_FIX_N(0x6FC5, SFI_NONE, "EF.PNN", F_OPTIONAL, 3, 20, |
| 327 | "PLMN Network Name"), |
| 328 | EF_LIN_FIX_N(0x6FC6, SFI_NONE, "EF.OPL", F_OPTIONAL, 8, 8, |
| 329 | "PLMN Operator PLMN List"), |
| 330 | EF_LIN_FIX_N(0x6FC7, SFI_NONE, "EF.MBDN", F_OPTIONAL, 14, 30, |
| 331 | "Mailbox Dialling Number"), |
| 332 | EF_LIN_FIX_N(0x6FC9, SFI_NONE, "EF.MBI", F_OPTIONAL, 4, 4, |
| 333 | "Maibox Identifier"), |
| 334 | EF_LIN_FIX_N(0x6FCA, SFI_NONE, "EF.MWIS", F_OPTIONAL, 5, 5, |
| 335 | "Message Waiting Indication Status"), |
| 336 | EF_LIN_FIX_N(0x6FCB, SFI_NONE, "EF.CFIS", F_OPTIONAL, 16, 16, |
| 337 | "Call Forwarding Indication Status"), |
| 338 | EF_LIN_FIX_N(0x6FC8, SFI_NONE, "EF.EXT6", F_OPTIONAL, 13, 13, |
| 339 | "Extension6 (MBDN)"), |
| 340 | EF_LIN_FIX_N(0x6FCC, SFI_NONE, "EF.EXT7", F_OPTIONAL, 13, 13, |
| 341 | "Extension7 (CFIS)"), |
| 342 | EF_TRANSP_N(0x6FCD, SFI_NONE, "EF.SPDI", F_OPTIONAL, 1, 32, |
| 343 | "Extension7 (CFIS)"), |
| 344 | EF_LIN_FIX_N(0x6FCE, SFI_NONE, "EF.MMSN", F_OPTIONAL, 4, 32, |
| 345 | "MMS Notification"), |
| 346 | EF_LIN_FIX_N(0x6FCF, SFI_NONE, "EF.EXT8", F_OPTIONAL, 2, 18, |
| 347 | "Extension8 (MMSN)"), |
| 348 | EF_TRANSP_N(0x6FD0, SFI_NONE, "EF.MMSICP", F_OPTIONAL, 1, 64, |
| 349 | "MMS Issuer Connectivity Parameters"), |
| 350 | EF_LIN_FIX_N(0x6FD1, SFI_NONE, "EF.MMSUP", F_OPTIONAL, 1, 64, |
| 351 | "MMS User Preferences"), |
| 352 | EF_TRANSP_N(0x6FD2, SFI_NONE, "EF.MMSUCP", F_OPTIONAL, 1, 64, |
| 353 | "MMS User Connectivity Parameters"), |
| 354 | }; |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 355 | |
| 356 | /* 10.4.1 Contents of the files at the SoLSA level */ |
| 357 | static const struct osim_file_desc sim_ef_in_solsa[] = { |
| 358 | EF_TRANSP_N(0x4F30, SFI_NONE, "EF.SAI", F_OPTIONAL, 1, 32, |
| 359 | "SoLSA Access Indicator"), |
| 360 | EF_LIN_FIX_N(0x4F31, SFI_NONE, "EF.SLL", F_OPTIONAL, 1, 32, |
| 361 | "SoLSA LSA List"), |
| 362 | /* LSA Descriptor files */ |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 363 | }; |
| 364 | |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 365 | /* 10.4.2 Contents of files at the MExE level */ |
| 366 | static const struct osim_file_desc sim_ef_in_mexe[] = { |
| 367 | EF_TRANSP_N(0x4F40, SFI_NONE, "EF.MExE-ST", F_OPTIONAL, 1, 8, |
| 368 | "MExE Service table"), |
| 369 | EF_LIN_FIX_N(0x4F41, SFI_NONE, "EF.ORPK", F_OPTIONAL, 11, 32, |
| 370 | "Operator Root Public Key"), |
| 371 | EF_LIN_FIX_N(0x4F42, SFI_NONE, "EF.ARPK", F_OPTIONAL, 11, 32, |
| 372 | "Administrator Root Public Key"), |
| 373 | EF_LIN_FIX_N(0x4F43, SFI_NONE, "EF.TRPK", F_OPTIONAL, 11, 32, |
| 374 | "Third Party Root Public Key"), |
| 375 | }; |
| 376 | |
| 377 | /* 10.5 Contents of files at the telecom level */ |
Harald Welte | 6729a97 | 2014-10-26 19:04:56 +0100 | [diff] [blame] | 378 | static const struct osim_file_desc sim_ef_in_telecom[] = { |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 379 | EF_LIN_FIX_N(0x6F3A, SFI_NONE, "EF.ADN", F_OPTIONAL, 14, 30, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 380 | "Abbreviated dialling numbers"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 381 | EF_LIN_FIX_N(0x6F3B, SFI_NONE, "EF.FDN", F_OPTIONAL, 14, 30, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 382 | "Fixed dialling numbers"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 383 | EF_LIN_FIX_N(0x6F3C, SFI_NONE, "EF.SMS", F_OPTIONAL, 176, 176, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 384 | "Short messages"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 385 | EF_LIN_FIX_N(0x6F3D, SFI_NONE, "EF.CCP", F_OPTIONAL, 14, 14, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 386 | "Capability configuration parameters"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 387 | EF_LIN_FIX_N(0x6F4F, SFI_NONE, "EF.ECCP", F_OPTIONAL, 15, 15, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 388 | "Extended Capability configuration parameters"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 389 | EF_LIN_FIX_N(0x6F40, SFI_NONE, "EF.MSISDN", F_OPTIONAL, 14, 30, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 390 | "MSISDN"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 391 | EF_LIN_FIX_N(0x6F42, SFI_NONE, "EF.SMSP", F_OPTIONAL, 28, 44, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 392 | "Short message service parameters"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 393 | EF_TRANSP_N(0x6F43, SFI_NONE, "EF.SMSS", F_OPTIONAL, 2, 3, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 394 | "SMS Status"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 395 | EF_CYCLIC_N(0x6F44, SFI_NONE, "EF.LND", F_OPTIONAL, 14, 30, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 396 | "Last number dialled"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 397 | EF_LIN_FIX_N(0x6F49, SFI_NONE, "EF.SDN", F_OPTIONAL, 14, 30, |
| 398 | "Service Dialling Numbers"), |
| 399 | EF_LIN_FIX_N(0x6F4A, SFI_NONE, "EF.EXT1", F_OPTIONAL, 13, 13, |
| 400 | "Extension 1 (ADN/SSC, MSISDN, LND)"), |
| 401 | EF_LIN_FIX_N(0x6F4B, SFI_NONE, "EF.EXT2", F_OPTIONAL, 13, 13, |
| 402 | "Extension 2 (FDN/SSC)"), |
| 403 | EF_LIN_FIX_N(0x6F4C, SFI_NONE, "EF.EXT3", F_OPTIONAL, 13, 13, |
| 404 | "Extension 3 (SDN)"), |
| 405 | EF_LIN_FIX_N(0x6F4D, SFI_NONE, "EF.BDN", F_OPTIONAL, 15, 31, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 406 | "Barred dialling numbers"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 407 | EF_LIN_FIX_N(0x6F4E, SFI_NONE, "EF.EXT4", F_OPTIONAL, 13, 13, |
| 408 | "Extension 4 (BDN/SSC)"), |
| 409 | EF_LIN_FIX_N(0x6F47, SFI_NONE, "EF.SMSR", F_OPTIONAL, 30, 30, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 410 | "Short message status reports"), |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 411 | EF_LIN_FIX_N(0x6F58, SFI_NONE, "EF.CMI", F_OPTIONAL, 1, 17, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 412 | "Comparison Method Information"), |
| 413 | }; |
| 414 | |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 415 | /* 10.6.1 Contents of files at the telecom graphics level */ |
| 416 | const struct osim_file_desc sim_ef_in_graphics[] = { |
| 417 | EF_LIN_FIX_N(0x4F20, SFI_NONE, "EF.IMG", F_OPTIONAL, 11, 38, |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 418 | "Image"), |
| 419 | }; |
| 420 | |
Harald Welte | 6729a97 | 2014-10-26 19:04:56 +0100 | [diff] [blame] | 421 | int osim_int_cprof_add_gsm(struct osim_file_desc *mf) |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 422 | { |
Harald Welte | 6729a97 | 2014-10-26 19:04:56 +0100 | [diff] [blame] | 423 | struct osim_file_desc *gsm; |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 424 | |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 425 | gsm = add_df_with_ef(mf, 0x7F20, "DF.GSM", sim_ef_in_gsm, |
| 426 | ARRAY_SIZE(sim_ef_in_gsm)); |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 427 | /* Chapter 10.2: DFs at the GSM Application Level */ |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 428 | add_df_with_ef(gsm, 0x5F30, "DF.IRIDIUM", NULL, 0); |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 429 | add_df_with_ef(gsm, 0x5F31, "DF.GLOBALSTAR", NULL, 0); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 430 | add_df_with_ef(gsm, 0x5F32, "DF.ICO", NULL, 0); |
| 431 | add_df_with_ef(gsm, 0x5F33, "DF.ACeS", NULL, 0); |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 432 | add_df_with_ef(gsm, 0x5F3C, "DF.MExE", sim_ef_in_mexe, |
| 433 | ARRAY_SIZE(sim_ef_in_mexe)); |
| 434 | add_df_with_ef(gsm, 0x5F40, "DF.EIA/TIA-533", NULL, 0); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 435 | add_df_with_ef(gsm, 0x5F60, "DF.CTS", NULL, 0); |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 436 | add_df_with_ef(gsm, 0x5F70, "DF.SoLSA", sim_ef_in_solsa, |
| 437 | ARRAY_SIZE(sim_ef_in_solsa)); |
| 438 | |
Harald Welte | 6729a97 | 2014-10-26 19:04:56 +0100 | [diff] [blame] | 439 | return 0; |
| 440 | } |
| 441 | |
| 442 | int osim_int_cprof_add_telecom(struct osim_file_desc *mf) |
| 443 | { |
| 444 | struct osim_file_desc *tc; |
| 445 | |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 446 | tc = add_df_with_ef(mf, 0x7F10, "DF.TELECOM", sim_ef_in_telecom, |
| 447 | ARRAY_SIZE(sim_ef_in_telecom)); |
| 448 | add_df_with_ef(tc, 0x5F50, "DF.GRAPHICS", sim_ef_in_graphics, |
| 449 | ARRAY_SIZE(sim_ef_in_graphics)); |
Harald Welte | bb5f3c7 | 2014-05-04 13:59:41 +0200 | [diff] [blame] | 450 | add_df_with_ef(mf, 0x7F22, "DF.IS-41", NULL, 0); |
| 451 | add_df_with_ef(mf, 0x7F23, "DF.FP-CTS", NULL, 0); /* TS 11.19 */ |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 452 | |
Harald Welte | 6729a97 | 2014-10-26 19:04:56 +0100 | [diff] [blame] | 453 | return 0; |
| 454 | } |
| 455 | |
| 456 | struct osim_card_profile *osim_cprof_sim(void *ctx) |
| 457 | { |
| 458 | struct osim_card_profile *cprof; |
| 459 | struct osim_file_desc *mf; |
| 460 | int rc; |
| 461 | |
| 462 | cprof = talloc_zero(ctx, struct osim_card_profile); |
| 463 | cprof->name = "GSM SIM"; |
| 464 | cprof->sws = sim_card_sws; |
| 465 | |
| 466 | mf = alloc_df(cprof, 0x3f00, "MF"); |
| 467 | |
| 468 | cprof->mf = mf; |
| 469 | |
| 470 | /* According to Figure 8 */ |
| 471 | add_filedesc(mf, sim_ef_in_mf, ARRAY_SIZE(sim_ef_in_mf)); |
| 472 | |
| 473 | rc = osim_int_cprof_add_gsm(mf); |
| 474 | rc |= osim_int_cprof_add_telecom(mf); |
| 475 | if (rc != 0) { |
| 476 | talloc_free(cprof); |
| 477 | return NULL; |
| 478 | } |
| 479 | |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 480 | return cprof; |
| 481 | } |