Harald Welte | ad41863 | 2012-09-10 10:49:59 +0200 | [diff] [blame] | 1 | /* libosmosim test application - currently simply dumps a USIM */ |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 2 | /* (C) 2012-2020 by Harald Welte <laforge@gnumonks.org> |
Harald Welte | ad41863 | 2012-09-10 10:49:59 +0200 | [diff] [blame] | 3 | * All Rights Reserved |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
Harald Welte | ad41863 | 2012-09-10 10:49:59 +0200 | [diff] [blame] | 15 | */ |
| 16 | |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 17 | #include <stdio.h> |
| 18 | #include <stdlib.h> |
| 19 | #include <errno.h> |
| 20 | #include <string.h> |
Eric Wild | 94cd4ac | 2019-10-31 19:18:45 +0100 | [diff] [blame] | 21 | #include <getopt.h> |
Alexander Huemer | aab4a24 | 2015-11-06 20:55:24 +0100 | [diff] [blame] | 22 | #include <arpa/inet.h> |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 23 | |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 24 | #include <unistd.h> |
| 25 | #include <sys/stat.h> |
| 26 | #include <sys/types.h> |
| 27 | #include <fcntl.h> |
| 28 | #include <limits.h> |
| 29 | |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 30 | #include <osmocom/core/msgb.h> |
| 31 | #include <osmocom/core/talloc.h> |
| 32 | #include <osmocom/sim/sim.h> |
| 33 | #include <osmocom/gsm/tlv.h> |
| 34 | |
| 35 | |
Harald Welte | ad41863 | 2012-09-10 10:49:59 +0200 | [diff] [blame] | 36 | /* FIXME: this needs to be moved to card_fs_uicc.c */ |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 37 | |
Harald Welte | 053bebc | 2020-02-15 18:58:16 +0100 | [diff] [blame] | 38 | static uint8_t g_class = 0x00; /* UICC/USIM */ |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 39 | static const char *g_output_dir; |
Harald Welte | 053bebc | 2020-02-15 18:58:16 +0100 | [diff] [blame] | 40 | |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 41 | /* 11.1.1 */ |
| 42 | static struct msgb *_select_file(struct osim_chan_hdl *st, uint8_t p1, uint8_t p2, |
| 43 | const uint8_t *data, uint8_t data_len) |
| 44 | { |
Vadim Yanitskiy | 1cd9991 | 2017-05-15 21:37:16 +0300 | [diff] [blame] | 45 | struct msgb *msg; |
Harald Welte | f12d40f | 2017-02-08 15:46:53 +0000 | [diff] [blame] | 46 | uint8_t *dst; |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 47 | |
Harald Welte | 053bebc | 2020-02-15 18:58:16 +0100 | [diff] [blame] | 48 | msg = osim_new_apdumsg(g_class, 0xA4, p1, p2, data_len, 256); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 49 | dst = msgb_put(msg, data_len); |
| 50 | memcpy(dst, data, data_len); |
| 51 | |
| 52 | osim_transceive_apdu(st, msg); |
| 53 | |
| 54 | return msg; |
| 55 | } |
| 56 | |
| 57 | /* 11.1.1 */ |
| 58 | static struct msgb *select_adf(struct osim_chan_hdl *st, const uint8_t *adf, uint8_t adf_len) |
| 59 | { |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 60 | return _select_file(st, 0x04, 0x04, adf,adf_len); |
| 61 | } |
| 62 | |
| 63 | /* 11.1.1 */ |
| 64 | static struct msgb *select_file(struct osim_chan_hdl *st, uint16_t fid) |
| 65 | { |
| 66 | uint16_t cfid = htons(fid); |
Harald Welte | 053bebc | 2020-02-15 18:58:16 +0100 | [diff] [blame] | 67 | uint8_t p2 = 0x04; |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 68 | |
Harald Welte | 053bebc | 2020-02-15 18:58:16 +0100 | [diff] [blame] | 69 | /* Classic SIM cards don't support 0x04 (Return FCP) */ |
| 70 | if (g_class == 0xA0) |
| 71 | p2 = 0x00; |
| 72 | |
| 73 | return _select_file(st, 0x00, p2, (uint8_t *)&cfid, 2); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 74 | } |
| 75 | |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 76 | #if 0 |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 77 | /* 11.1.9 */ |
Harald Welte | f12d40f | 2017-02-08 15:46:53 +0000 | [diff] [blame] | 78 | static int verify_pin(struct osim_chan_hdl *st, uint8_t pin_nr, char *pin) |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 79 | { |
| 80 | struct msgb *msg; |
| 81 | char *pindst; |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 82 | |
| 83 | if (strlen(pin) > 8) |
| 84 | return -EINVAL; |
| 85 | |
Harald Welte | 053bebc | 2020-02-15 18:58:16 +0100 | [diff] [blame] | 86 | msg = osim_new_apdumsg(g_class, 0x20, 0x00, pin_nr, 8, 0); |
Harald Welte | f12d40f | 2017-02-08 15:46:53 +0000 | [diff] [blame] | 87 | pindst = (char *) msgb_put(msg, 8); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 88 | memset(pindst, 0xFF, 8); |
Neels Hofmeyr | 95fdbc1 | 2018-07-26 17:14:40 +0200 | [diff] [blame] | 89 | /* Do not copy the terminating \0 */ |
| 90 | memcpy(pindst, pin, strlen(pin)); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 91 | |
| 92 | return osim_transceive_apdu(st, msg); |
| 93 | } |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 94 | #endif |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 95 | |
| 96 | /* 11.1.5 */ |
| 97 | static struct msgb *read_record_nr(struct osim_chan_hdl *st, uint8_t rec_nr, uint16_t rec_size) |
| 98 | { |
| 99 | struct msgb *msg; |
| 100 | |
Harald Welte | 053bebc | 2020-02-15 18:58:16 +0100 | [diff] [blame] | 101 | msg = osim_new_apdumsg(g_class, 0xB2, rec_nr, 0x04, 0, rec_size); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 102 | |
| 103 | osim_transceive_apdu(st, msg); |
| 104 | |
| 105 | return msg; |
| 106 | } |
| 107 | |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 108 | /* 11.1.3 */ |
| 109 | static struct msgb *read_binary(struct osim_chan_hdl *st, uint16_t offset, uint16_t len) |
| 110 | { |
| 111 | struct msgb *msg; |
| 112 | |
| 113 | if (offset > 0x7fff || len > 256) |
| 114 | return NULL; |
| 115 | |
Harald Welte | 053bebc | 2020-02-15 18:58:16 +0100 | [diff] [blame] | 116 | msg = osim_new_apdumsg(g_class, 0xB0, offset >> 8, offset & 0xff, 0, len & 0xff); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 117 | |
| 118 | osim_transceive_apdu(st, msg); |
| 119 | |
| 120 | return msg; |
| 121 | } |
| 122 | |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 123 | static int dump_fcp_template(struct tlv_parsed *tp) |
| 124 | { |
| 125 | int i; |
| 126 | |
| 127 | for (i = 0; i < ARRAY_SIZE(tp->lv); i++) { |
| 128 | if (TLVP_PRESENT(tp, i)) |
| 129 | printf("Tag 0x%02x (%s): %s\n", i, |
| 130 | get_value_string(ts102221_fcp_vals, i), |
| 131 | osmo_hexdump(TLVP_VAL(tp, i), TLVP_LEN(tp, i))); |
| 132 | } |
| 133 | |
| 134 | return 0; |
| 135 | } |
| 136 | |
| 137 | static int dump_fcp_template_msg(struct msgb *msg) |
| 138 | { |
| 139 | struct tlv_parsed tp; |
| 140 | int rc; |
| 141 | |
Harald Welte | a5c9255 | 2012-09-10 21:05:42 +0200 | [diff] [blame] | 142 | rc = tlv_parse(&tp, &ts102221_fcp_tlv_def, msgb_apdu_de(msg)+2, msgb_apdu_le(msg)-2, 0, 0); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 143 | if (rc < 0) |
| 144 | return rc; |
| 145 | |
| 146 | return dump_fcp_template(&tp); |
| 147 | } |
| 148 | |
| 149 | struct osim_fcp_fd_decoded { |
| 150 | enum osim_file_type type; |
| 151 | enum osim_ef_type ef_type; |
| 152 | uint16_t rec_len; |
| 153 | uint8_t num_rec; |
| 154 | }; |
| 155 | |
| 156 | static const enum osim_file_type iso2ftype[8] = { |
| 157 | [0] = TYPE_EF, |
| 158 | [1] = TYPE_EF_INT, |
| 159 | [7] = TYPE_DF, |
| 160 | }; |
| 161 | |
| 162 | static const enum osim_ef_type iso2eftype[8] = { |
| 163 | [1] = EF_TYPE_TRANSP, |
| 164 | [2] = EF_TYPE_RECORD_FIXED, |
| 165 | [6] = EF_TYPE_RECORD_CYCLIC, |
| 166 | }; |
| 167 | |
| 168 | static int osim_fcp_fd_decode(struct osim_fcp_fd_decoded *ofd, const uint8_t *fcp, int fcp_len) |
| 169 | { |
| 170 | memset(ofd, 0, sizeof(*ofd)); |
| 171 | |
| 172 | if (fcp_len != 2 && fcp_len != 5) |
| 173 | return -EINVAL; |
| 174 | |
| 175 | ofd->type = iso2ftype[(fcp[0] >> 3) & 7]; |
| 176 | if (ofd->type != TYPE_DF) |
| 177 | ofd->ef_type = iso2eftype[fcp[0] & 7]; |
| 178 | |
| 179 | if (fcp[1] != 0x21) |
| 180 | return -EINVAL; |
| 181 | |
| 182 | if (fcp_len >= 5) { |
| 183 | ofd->rec_len = ntohs(*(uint16_t *)(fcp+2)); |
| 184 | ofd->num_rec = fcp[4]; |
| 185 | } |
| 186 | |
| 187 | return 0; |
| 188 | } |
| 189 | |
Harald Welte | 053bebc | 2020-02-15 18:58:16 +0100 | [diff] [blame] | 190 | /* TS 51.011 Section 9.3 Type of File */ |
| 191 | static const enum osim_file_type sim2ftype[8] = { |
| 192 | [1] = TYPE_MF, |
| 193 | [2] = TYPE_DF, |
| 194 | [4] = TYPE_EF, |
| 195 | }; |
| 196 | |
| 197 | /* TS 51.011 Section 9.3 Structure of File */ |
| 198 | static const enum osim_ef_type sim2eftype[8] = { |
| 199 | [0] = EF_TYPE_TRANSP, |
| 200 | [1] = EF_TYPE_RECORD_FIXED, |
| 201 | [3] = EF_TYPE_RECORD_CYCLIC, |
| 202 | }; |
| 203 | |
| 204 | /* TS 51.011 Section 9.2.1 */ |
| 205 | static int osim_fcp_fd_decode_sim(struct osim_fcp_fd_decoded *ofd, const uint8_t *fcp, int fcp_len) |
| 206 | { |
| 207 | memset(ofd, 0, sizeof(*ofd)); |
| 208 | |
| 209 | if (fcp_len < 14) |
| 210 | return -EINVAL; |
| 211 | |
| 212 | ofd->type = sim2ftype[fcp[6] & 7]; |
| 213 | switch (ofd->type) { |
| 214 | case TYPE_EF: |
| 215 | ofd->ef_type = sim2eftype[fcp[13] & 7]; |
| 216 | if (fcp_len < 13 + fcp[12]) |
| 217 | return -EINVAL; |
| 218 | switch (ofd->ef_type) { |
| 219 | case EF_TYPE_RECORD_FIXED: |
| 220 | case EF_TYPE_RECORD_CYCLIC: |
| 221 | if (fcp_len < 15) |
| 222 | return -EINVAL; |
| 223 | ofd->rec_len = fcp[14]; |
| 224 | ofd->num_rec = ntohs(*(uint16_t *)(fcp+2)) / ofd->rec_len; |
| 225 | break; |
| 226 | default: |
| 227 | break; |
| 228 | } |
| 229 | break; |
| 230 | case TYPE_MF: |
| 231 | case TYPE_DF: |
| 232 | if (fcp_len < 22) |
| 233 | return -EINVAL; |
| 234 | break; |
| 235 | default: |
| 236 | break; |
| 237 | } |
| 238 | |
| 239 | return 0; |
| 240 | } |
| 241 | |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 242 | /*! scan an UICC for all installed apps; allocate osim_card_app_hdl for each of them */ |
| 243 | static int osim_uicc_scan_apps(struct osim_chan_hdl *st) |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 244 | { |
| 245 | struct tlv_parsed tp; |
| 246 | struct osim_fcp_fd_decoded ofd; |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 247 | struct msgb *msg; |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 248 | uint8_t *cur; |
| 249 | int rc, i; |
| 250 | |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 251 | /* we don't know where we currently might be; go back to MF */ |
| 252 | msg = select_file(st, 0x3f00); |
| 253 | if (!msg) |
| 254 | return -EIO; |
| 255 | if (msgb_apdu_sw(msg) != 0x9000) |
| 256 | return -msgb_apdu_sw(msg); |
| 257 | |
| 258 | /* select EF.DIR */ |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 259 | msg = select_file(st, 0x2f00); |
Harald Welte | 053bebc | 2020-02-15 18:58:16 +0100 | [diff] [blame] | 260 | if (!msg) |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 261 | return -EIO; |
Harald Welte | 053bebc | 2020-02-15 18:58:16 +0100 | [diff] [blame] | 262 | /* return status word in case of error */ |
| 263 | if (msgb_apdu_sw(msg) != 0x9000) |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 264 | return -msgb_apdu_sw(msg); |
Harald Welte | 053bebc | 2020-02-15 18:58:16 +0100 | [diff] [blame] | 265 | |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 266 | /* various FCP related sanity checks */ |
Harald Welte | 053bebc | 2020-02-15 18:58:16 +0100 | [diff] [blame] | 267 | rc = tlv_parse(&tp, &ts102221_fcp_tlv_def, msgb_apdu_de(msg)+2, msgb_apdu_le(msg)-2, 0, 0); |
| 268 | if (rc < 0) { |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 269 | fprintf(stderr, "Error decoding EF.DIR FCP TLV\n"); |
Harald Welte | 053bebc | 2020-02-15 18:58:16 +0100 | [diff] [blame] | 270 | msgb_free(msg); |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 271 | return -EINVAL; |
Harald Welte | 053bebc | 2020-02-15 18:58:16 +0100 | [diff] [blame] | 272 | } |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 273 | |
| 274 | dump_fcp_template(&tp); |
| 275 | |
| 276 | if (!TLVP_PRESENT(&tp, UICC_FCP_T_FILE_DESC) || |
| 277 | TLVP_LEN(&tp, UICC_FCP_T_FILE_DESC) < 5) { |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 278 | fprintf(stderr, "No EF.DIR FCP file description\n"); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 279 | msgb_free(msg); |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 280 | return -EINVAL; |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | rc = osim_fcp_fd_decode(&ofd, TLVP_VAL(&tp, UICC_FCP_T_FILE_DESC), |
| 284 | TLVP_LEN(&tp, UICC_FCP_T_FILE_DESC)); |
| 285 | if (rc < 0) { |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 286 | fprintf(stderr, "Error decoding EF.DIR FCP file description\n"); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 287 | msgb_free(msg); |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 288 | return -EINVAL; |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | if (ofd.type != TYPE_EF || ofd.ef_type != EF_TYPE_RECORD_FIXED) { |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 292 | fprintf(stderr, "EF.DIR is not a fixed record EF!?!\n"); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 293 | msgb_free(msg); |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 294 | return -EINVAL; |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | msgb_free(msg); |
| 298 | |
| 299 | printf("ofd rec_len = %u, num_rec = %u\n", ofd.rec_len, ofd.num_rec); |
| 300 | |
| 301 | for (i = 0; i < ofd.num_rec; i++) { |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 302 | const uint8_t *aid; |
| 303 | uint8_t aid_len; |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 304 | msg = read_record_nr(st, i+1, ofd.rec_len); |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 305 | if (!msg) { |
| 306 | fprintf(stderr, "Error reading Record %u of EF.DIR, skipping\n", i+1); |
| 307 | continue; |
| 308 | } |
| 309 | |
| 310 | /* Entries look like this: |
| 311 | * 61194f10 a0000000871002ffffffff8907090000 5005 5553696d31 ffffffffffffffffffffff */ |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 312 | |
| 313 | cur = msgb_apdu_de(msg); |
| 314 | if (msgb_apdu_le(msg) < 5) { |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 315 | fprintf(stderr, "Record length %u too short for EF.DIR, skipping\n", msgb_apdu_le(msg)); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 316 | msgb_free(msg); |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 317 | continue; |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | if (cur[0] != 0x61 || cur[1] < 0x03 || cur[1] > 0x7f || |
| 321 | cur[2] != 0x4F || cur[3] < 0x01 || cur[3] > 0x10) { |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 322 | fprintf(stderr, "Unexpected/unknown record in EF.DIR: %s, skipping\n", |
| 323 | osmo_hexdump_nospc(msgb_apdu_de(msg), msgb_apdu_le(msg))); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 324 | msgb_free(msg); |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 325 | continue; |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 326 | } |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 327 | aid_len = cur[3]; |
| 328 | aid = cur+4; |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 329 | |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 330 | /* FIXME: parse / pass label*/ |
| 331 | printf("Detected AID %s\n", osmo_hexdump_nospc(aid, aid_len)); |
| 332 | osim_card_hdl_add_app(st->card, aid, aid_len, NULL); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 333 | } |
| 334 | |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 335 | return i; |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 336 | } |
| 337 | |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 338 | |
| 339 | extern struct osim_card_profile *osim_cprof_sim(void *ctx); |
Harald Welte | 58d173a | 2020-03-21 13:40:28 +0100 | [diff] [blame] | 340 | extern struct osim_card_profile *osim_cprof_uicc(void *ctx, bool have_df_gsm); |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 341 | |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 342 | static int dump_file(struct osim_chan_hdl *chan, const char *short_name, uint16_t fid) |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 343 | { |
| 344 | struct tlv_parsed tp; |
| 345 | struct osim_fcp_fd_decoded ffdd; |
Harald Welte | a0ba4d9 | 2012-09-10 10:43:15 +0200 | [diff] [blame] | 346 | struct msgb *msg, *rmsg; |
| 347 | int rc, i, offset; |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 348 | FILE *f_data = NULL; |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 349 | |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 350 | /* Select the file */ |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 351 | msg = select_file(chan, fid); |
Harald Welte | a0ba4d9 | 2012-09-10 10:43:15 +0200 | [diff] [blame] | 352 | if (!msg) { |
Harald Welte | 835ed96 | 2020-03-19 18:00:04 +0100 | [diff] [blame] | 353 | fprintf(stderr, "Unable to select file\n"); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 354 | return -EIO; |
Harald Welte | a0ba4d9 | 2012-09-10 10:43:15 +0200 | [diff] [blame] | 355 | } |
| 356 | if (msgb_apdu_sw(msg) != 0x9000) { |
Harald Welte | 835ed96 | 2020-03-19 18:00:04 +0100 | [diff] [blame] | 357 | fprintf(stderr, "status 0x%04x selecting file\n", msgb_apdu_sw(msg)); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 358 | goto out; |
Harald Welte | a0ba4d9 | 2012-09-10 10:43:15 +0200 | [diff] [blame] | 359 | } |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 360 | |
Harald Welte | 053bebc | 2020-02-15 18:58:16 +0100 | [diff] [blame] | 361 | if (g_class != 0xA0) { |
| 362 | rc = tlv_parse(&tp, &ts102221_fcp_tlv_def, msgb_apdu_de(msg)+2, msgb_apdu_le(msg)-2, 0, 0); |
| 363 | if (rc < 0) { |
Harald Welte | 835ed96 | 2020-03-19 18:00:04 +0100 | [diff] [blame] | 364 | fprintf(stderr, "Unable to parse FCP: %s\n", msgb_hexdump(msg)); |
Harald Welte | 053bebc | 2020-02-15 18:58:16 +0100 | [diff] [blame] | 365 | goto out; |
| 366 | } |
| 367 | |
| 368 | if (!TLVP_PRESENT(&tp, UICC_FCP_T_FILE_DESC) || |
| 369 | TLVP_LEN(&tp, UICC_FCP_T_FILE_DESC) < 2) { |
Harald Welte | 835ed96 | 2020-03-19 18:00:04 +0100 | [diff] [blame] | 370 | fprintf(stderr, "No file descriptor present ?!?\n"); |
Harald Welte | 053bebc | 2020-02-15 18:58:16 +0100 | [diff] [blame] | 371 | goto out; |
| 372 | } |
| 373 | |
| 374 | rc = osim_fcp_fd_decode(&ffdd, TLVP_VAL(&tp, UICC_FCP_T_FILE_DESC), |
| 375 | TLVP_LEN(&tp, UICC_FCP_T_FILE_DESC)); |
| 376 | } else { |
| 377 | rc = osim_fcp_fd_decode_sim(&ffdd, msgb_apdu_de(msg), msgb_apdu_le(msg)); |
Harald Welte | a0ba4d9 | 2012-09-10 10:43:15 +0200 | [diff] [blame] | 378 | } |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 379 | |
Harald Welte | a0ba4d9 | 2012-09-10 10:43:15 +0200 | [diff] [blame] | 380 | if (rc < 0) { |
Harald Welte | 835ed96 | 2020-03-19 18:00:04 +0100 | [diff] [blame] | 381 | fprintf(stderr, "Unable to decode File Descriptor\n"); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 382 | goto out; |
Harald Welte | a0ba4d9 | 2012-09-10 10:43:15 +0200 | [diff] [blame] | 383 | } |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 384 | |
Harald Welte | a0ba4d9 | 2012-09-10 10:43:15 +0200 | [diff] [blame] | 385 | if (ffdd.type != TYPE_EF) { |
Harald Welte | 835ed96 | 2020-03-19 18:00:04 +0100 | [diff] [blame] | 386 | fprintf(stderr, "File Type != EF\n"); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 387 | goto out; |
Harald Welte | a0ba4d9 | 2012-09-10 10:43:15 +0200 | [diff] [blame] | 388 | } |
| 389 | |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 390 | if (g_output_dir) { |
| 391 | f_data = fopen(short_name, "w"); |
| 392 | if (!f_data) { |
| 393 | fprintf(stderr, "Couldn't create '%s': %s\n", short_name, strerror(errno)); |
| 394 | goto out; |
| 395 | } |
| 396 | } |
| 397 | |
Harald Welte | a0ba4d9 | 2012-09-10 10:43:15 +0200 | [diff] [blame] | 398 | printf("EF type: %u\n", ffdd.ef_type); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 399 | |
| 400 | switch (ffdd.ef_type) { |
| 401 | case EF_TYPE_RECORD_FIXED: |
| 402 | for (i = 0; i < ffdd.num_rec; i++) { |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 403 | const char *hex; |
Harald Welte | a0ba4d9 | 2012-09-10 10:43:15 +0200 | [diff] [blame] | 404 | rmsg = read_record_nr(chan, i+1, ffdd.rec_len); |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 405 | if (!rmsg) { |
| 406 | if (f_data) |
| 407 | fclose(f_data); |
Harald Welte | a0ba4d9 | 2012-09-10 10:43:15 +0200 | [diff] [blame] | 408 | return -EIO; |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 409 | } |
Harald Welte | 3a6bedf | 2020-03-22 10:30:10 +0100 | [diff] [blame] | 410 | printf("SW: %s\n", osim_print_sw(chan, msgb_apdu_sw(msg))); |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 411 | |
| 412 | hex = osmo_hexdump_nospc(msgb_apdu_de(rmsg), msgb_apdu_le(rmsg)); |
| 413 | printf("Rec %03u: %s\n", i+1, hex); |
| 414 | if (f_data) |
| 415 | fprintf(f_data, "%s\n", hex); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 416 | } |
| 417 | break; |
| 418 | case EF_TYPE_TRANSP: |
Philipp Maier | fde9fdc | 2020-02-26 12:00:23 +0100 | [diff] [blame] | 419 | if (g_class != 0xA0) { |
Harald Welte | 1705140 | 2020-03-22 11:25:32 +0100 | [diff] [blame] | 420 | if (!TLVP_PRESENT(&tp, UICC_FCP_T_FILE_SIZE)) |
Philipp Maier | fde9fdc | 2020-02-26 12:00:23 +0100 | [diff] [blame] | 421 | goto out; |
| 422 | i = ntohs(*(uint16_t *)TLVP_VAL(&tp, UICC_FCP_T_FILE_SIZE)); |
| 423 | printf("File size: %d bytes\n", i); |
| 424 | } else { |
Harald Welte | 835ed96 | 2020-03-19 18:00:04 +0100 | [diff] [blame] | 425 | fprintf(stderr, "Can not determine file size, invalid EF-type!\n"); |
Harald Welte | a0ba4d9 | 2012-09-10 10:43:15 +0200 | [diff] [blame] | 426 | goto out; |
Philipp Maier | fde9fdc | 2020-02-26 12:00:23 +0100 | [diff] [blame] | 427 | } |
Harald Welte | a0ba4d9 | 2012-09-10 10:43:15 +0200 | [diff] [blame] | 428 | for (offset = 0; offset < i-1; ) { |
| 429 | uint16_t remain_len = i - offset; |
| 430 | uint16_t read_len = OSMO_MIN(remain_len, 256); |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 431 | const char *hex; |
Harald Welte | a0ba4d9 | 2012-09-10 10:43:15 +0200 | [diff] [blame] | 432 | rmsg = read_binary(chan, offset, read_len); |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 433 | if (!rmsg) { |
| 434 | if (f_data) |
| 435 | fclose(f_data); |
Harald Welte | a0ba4d9 | 2012-09-10 10:43:15 +0200 | [diff] [blame] | 436 | return -EIO; |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 437 | } |
Harald Welte | a0ba4d9 | 2012-09-10 10:43:15 +0200 | [diff] [blame] | 438 | offset += read_len; |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 439 | hex = osmo_hexdump_nospc(msgb_apdu_de(rmsg), msgb_apdu_le(rmsg)); |
| 440 | printf("Content: %s\n", hex); |
| 441 | if (f_data) |
| 442 | fprintf(f_data, "%s", hex); |
Harald Welte | a0ba4d9 | 2012-09-10 10:43:15 +0200 | [diff] [blame] | 443 | } |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 444 | break; |
| 445 | default: |
| 446 | goto out; |
| 447 | } |
| 448 | |
| 449 | out: |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 450 | if (f_data) |
| 451 | fclose(f_data); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 452 | msgb_free(msg); |
| 453 | return -EINVAL; |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 454 | |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 455 | } |
| 456 | |
Eric Wild | 94cd4ac | 2019-10-31 19:18:45 +0100 | [diff] [blame] | 457 | static void print_help(void) |
| 458 | { |
| 459 | printf( "osmo-sim-test Usage:\n" |
| 460 | " -h --help This message\n" |
| 461 | " -n --reader-num NR Open reader number NR\n" |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 462 | " -o --output-dir DIR To-be-created output directory for filesystem dump\n" |
Eric Wild | 94cd4ac | 2019-10-31 19:18:45 +0100 | [diff] [blame] | 463 | ); |
| 464 | } |
| 465 | |
| 466 | static int readernum = 0; |
| 467 | |
| 468 | static void handle_options(int argc, char **argv) |
| 469 | { |
| 470 | while (1) { |
| 471 | int option_index = 0, c; |
| 472 | const struct option long_options[] = { |
| 473 | { "help", 0, 0, 'h' }, |
| 474 | { "reader-num", 1, 0, 'n' }, |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 475 | { "output-dir", 1, 0, 'o' }, |
Eric Wild | 94cd4ac | 2019-10-31 19:18:45 +0100 | [diff] [blame] | 476 | {0,0,0,0} |
| 477 | }; |
| 478 | |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 479 | c = getopt_long(argc, argv, "hn:o:", |
Eric Wild | 94cd4ac | 2019-10-31 19:18:45 +0100 | [diff] [blame] | 480 | long_options, &option_index); |
| 481 | if (c == -1) |
| 482 | break; |
| 483 | |
| 484 | switch (c) { |
| 485 | case 'h': |
| 486 | print_help(); |
| 487 | exit(0); |
| 488 | break; |
| 489 | case 'n': |
| 490 | readernum = atoi(optarg); |
| 491 | break; |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 492 | case 'o': |
| 493 | g_output_dir = optarg; |
| 494 | break; |
Eric Wild | 94cd4ac | 2019-10-31 19:18:45 +0100 | [diff] [blame] | 495 | default: |
| 496 | exit(2); |
| 497 | break; |
| 498 | } |
| 499 | } |
| 500 | |
| 501 | if (argc > optind) { |
| 502 | fprintf(stderr, "Unsupported positional arguments on command line\n"); |
| 503 | exit(2); |
| 504 | } |
| 505 | } |
| 506 | |
Harald Welte | 3a1a3bb | 2020-02-15 18:56:18 +0100 | [diff] [blame] | 507 | |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 508 | static void mkdir_and_chdir(const char *name, mode_t mode) |
| 509 | { |
| 510 | int rc; |
| 511 | rc = mkdir(name, mode); |
| 512 | if (rc < 0) { |
| 513 | fprintf(stderr, "Cannot create '%s': %s\n", name, strerror(errno)); |
| 514 | exit(24); |
| 515 | } |
| 516 | rc = chdir(name); |
| 517 | if (rc < 0) { |
| 518 | fprintf(stderr, "Cannot change to just-created '%s': %s\n", name, strerror(errno)); |
| 519 | exit(24); |
| 520 | } |
| 521 | } |
| 522 | |
| 523 | |
Harald Welte | 3a1a3bb | 2020-02-15 18:56:18 +0100 | [diff] [blame] | 524 | static void iterate_fs(struct osim_chan_hdl *chan) |
| 525 | { |
| 526 | const struct osim_file_desc *prev_cwd; |
| 527 | struct osim_file_desc *ofd; |
| 528 | |
| 529 | /* iterate over all files in current working directory */ |
| 530 | llist_for_each_entry(ofd, &chan->cwd->child_list, list) { |
| 531 | struct msgb *m; |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 532 | char prev_dir[PATH_MAX]; |
| 533 | |
Harald Welte | 3a1a3bb | 2020-02-15 18:56:18 +0100 | [diff] [blame] | 534 | printf("\n\n================ %s (%s) ==================\n", |
| 535 | ofd->short_name, ofd->long_name); |
| 536 | |
| 537 | m = select_file(chan, ofd->fid); |
| 538 | if (msgb_apdu_sw(m) != 0x9000) { |
| 539 | msgb_free(m); |
| 540 | continue; |
| 541 | } |
| 542 | dump_fcp_template_msg(m); |
| 543 | msgb_free(m); |
| 544 | |
| 545 | /* If this is a DF, recurse into it */ |
| 546 | switch (ofd->type) { |
| 547 | case TYPE_DF: |
| 548 | /* the select above has just changed into this directory */ |
| 549 | prev_cwd = chan->cwd; |
| 550 | chan->cwd = ofd; |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 551 | if (g_output_dir) { |
| 552 | if (!getcwd(prev_dir, sizeof(prev_dir))) { |
| 553 | fprintf(stderr, "Cannot determine cwd: %s\n", strerror(errno)); |
| 554 | exit(23); |
| 555 | continue; |
| 556 | } |
| 557 | mkdir_and_chdir(ofd->short_name, 0750); |
| 558 | } |
Harald Welte | 3a1a3bb | 2020-02-15 18:56:18 +0100 | [diff] [blame] | 559 | iterate_fs(chan); |
| 560 | /* "pop" the directory from the stack */ |
| 561 | chan->cwd = prev_cwd; |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 562 | if (g_output_dir) |
| 563 | OSMO_ASSERT(chdir("..") == 0); |
Harald Welte | 3a1a3bb | 2020-02-15 18:56:18 +0100 | [diff] [blame] | 564 | break; |
| 565 | default: |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 566 | dump_file(chan, ofd->short_name, ofd->fid); |
Harald Welte | 3a1a3bb | 2020-02-15 18:56:18 +0100 | [diff] [blame] | 567 | break; |
| 568 | } |
| 569 | } |
| 570 | } |
| 571 | |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 572 | static void iterate_apps(struct osim_chan_hdl *chan) |
| 573 | { |
| 574 | struct osim_card_app_hdl *cah; |
| 575 | |
| 576 | llist_for_each_entry(cah, &chan->card->apps, list) { |
| 577 | const struct osim_card_app_profile *cap = cah->prof; |
| 578 | struct msgb *msg; |
| 579 | |
| 580 | if (!cap) { |
| 581 | fprintf(stderr, "Unknown AID %s; skipping\n", |
| 582 | osmo_hexdump_nospc(cah->aid, cah->aid_len)); |
| 583 | continue; |
| 584 | } |
| 585 | |
| 586 | msg = select_adf(chan, cah->aid, cah->aid_len); |
| 587 | if (!msg) { |
| 588 | fprintf(stderr, "Error selectiong ADF for AID %s; skipping\n", |
| 589 | osmo_hexdump_nospc(cah->aid, cah->aid_len)); |
| 590 | continue; |
| 591 | } |
Harald Welte | 3a6bedf | 2020-03-22 10:30:10 +0100 | [diff] [blame] | 592 | printf("SW: %s\n", osim_print_sw(chan, msgb_apdu_sw(msg))); |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 593 | chan->cur_app = cah; |
| 594 | chan->cwd = cap->adf; |
| 595 | |
| 596 | if (g_output_dir) |
| 597 | mkdir_and_chdir(cap->adf->short_name, 0750); |
| 598 | |
| 599 | iterate_fs(chan); |
| 600 | |
| 601 | if (g_output_dir) |
| 602 | OSMO_ASSERT(chdir("..") == 0); |
| 603 | } |
| 604 | } |
| 605 | |
Harald Welte | 3a1a3bb | 2020-02-15 18:56:18 +0100 | [diff] [blame] | 606 | |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 607 | int main(int argc, char **argv) |
| 608 | { |
| 609 | struct osim_reader_hdl *reader; |
| 610 | struct osim_card_hdl *card; |
| 611 | struct osim_chan_hdl *chan; |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 612 | int rc; |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 613 | |
Eric Wild | 94cd4ac | 2019-10-31 19:18:45 +0100 | [diff] [blame] | 614 | handle_options(argc, argv); |
| 615 | |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 616 | osim_init(NULL); |
| 617 | |
Harald Welte | 870f94d | 2020-03-19 19:10:34 +0100 | [diff] [blame] | 618 | if (g_output_dir) { |
| 619 | int rc; |
| 620 | rc = mkdir(g_output_dir, 0750); |
| 621 | if (rc < 0) { |
| 622 | fprintf(stderr, "Cannot create directory '%s': %s\n", g_output_dir, |
| 623 | strerror(errno)); |
| 624 | exit(5); |
| 625 | } |
| 626 | rc = chdir(g_output_dir); |
| 627 | if (rc < 0) { |
| 628 | fprintf(stderr, "Cannot change to just-created directory '%s': %s\n", |
| 629 | g_output_dir, strerror(errno)); |
| 630 | exit(5); |
| 631 | } |
| 632 | } |
| 633 | |
Eric Wild | 94cd4ac | 2019-10-31 19:18:45 +0100 | [diff] [blame] | 634 | reader = osim_reader_open(OSIM_READER_DRV_PCSC, readernum, "", NULL); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 635 | if (!reader) |
| 636 | exit(1); |
Harald Welte | 55790aa | 2014-10-26 18:46:50 +0100 | [diff] [blame] | 637 | card = osim_card_open(reader, OSIM_PROTO_T0); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 638 | if (!card) |
| 639 | exit(2); |
| 640 | chan = llist_entry(card->channels.next, struct osim_chan_hdl, list); |
| 641 | if (!chan) |
| 642 | exit(3); |
| 643 | |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 644 | //verify_pin(chan, 1, "1653"); |
| 645 | |
| 646 | rc = osim_uicc_scan_apps(chan); |
| 647 | if (rc >= 0) { |
Harald Welte | 58d173a | 2020-03-21 13:40:28 +0100 | [diff] [blame] | 648 | chan->card->prof = osim_cprof_uicc(chan->card, true); |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 649 | chan->cwd = chan->card->prof->mf; |
| 650 | } else if (rc == -0x6e00) { |
Harald Welte | 053bebc | 2020-02-15 18:58:16 +0100 | [diff] [blame] | 651 | /* CLA not supported: must be classic SIM, not USIM */ |
| 652 | g_class = 0xA0; |
| 653 | chan->card->prof = osim_cprof_sim(chan->card); |
| 654 | chan->cwd = chan->card->prof->mf; |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 655 | } else if (rc < 0) { |
| 656 | exit(4); |
Harald Welte | 053bebc | 2020-02-15 18:58:16 +0100 | [diff] [blame] | 657 | } |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 658 | |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 659 | /* first iterate over normal file system */ |
Harald Welte | 3a1a3bb | 2020-02-15 18:56:18 +0100 | [diff] [blame] | 660 | iterate_fs(chan); |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 661 | |
Harald Welte | 429adec | 2020-03-20 13:05:40 +0100 | [diff] [blame] | 662 | /* then itereate over all apps and their file system */ |
| 663 | iterate_apps(chan); |
| 664 | |
Harald Welte | d54c2ee | 2012-01-17 18:25:50 +0100 | [diff] [blame] | 665 | exit(0); |
| 666 | } |