comparison simtool/miscadm.c @ 66:3ef90bd13fbe

fc-simtool write-imsi command implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 15 Feb 2021 00:28:10 +0000
parents
children 105aa3d1a494
comparison
equal deleted inserted replaced
65:cc48ac3b151c 66:3ef90bd13fbe
1 /*
2 * This module implements write-iccid and write-imsi commands,
3 * available only in the admin programming phase after authenticating
4 * with some card-vendor-dependent ADM key.
5 */
6
7 #include <sys/types.h>
8 #include <stdio.h>
9 #include "curfile.h"
10 #include "file_id.h"
11
12 cmd_write_imsi(argc, argv)
13 char **argv;
14 {
15 int rc;
16 u_char nibbles[16], binrec[9];
17 unsigned ndig;
18
19 rc = parse_decimal_string_arg(argv[1], nibbles + 1, 15);
20 if (rc < 0)
21 return(rc);
22 ndig = rc;
23 if (ndig & 1)
24 nibbles[0] = 9;
25 else
26 nibbles[0] = 1;
27 binrec[0] = (ndig + 2) >> 1;
28 pack_reversed_nibbles(nibbles, binrec + 1, 8);
29 rc = select_op(DF_GSM);
30 if (rc < 0)
31 return(rc);
32 rc = select_op(EF_IMSI);
33 if (rc < 0)
34 return(rc);
35 rc = parse_ef_select_response();
36 if (rc < 0)
37 return(rc);
38 if (curfile_structure != 0x00 || curfile_total_size != 9) {
39 fprintf(stderr,
40 "error: EF_IMSI is not a transparent EF of 9 bytes\n");
41 return(-1);
42 }
43 return update_bin_op(0, binrec, 9);
44 }