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