FreeCalypso > hg > fc-pcsc-tools
comparison simtool/miscadm.c @ 210:9797417ececa
fc-simtool write-acc command implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 07 Mar 2021 06:26:20 +0000 |
parents | 2545dd27ca38 |
children | 31cd62f91522 |
comparison
equal
deleted
inserted
replaced
209:eb16c8841486 | 210:9797417ececa |
---|---|
4 * with some card-vendor-dependent ADM key. | 4 * with some card-vendor-dependent ADM key. |
5 */ | 5 */ |
6 | 6 |
7 #include <sys/types.h> | 7 #include <sys/types.h> |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <stdlib.h> | |
9 #include "curfile.h" | 10 #include "curfile.h" |
10 #include "file_id.h" | 11 #include "file_id.h" |
11 | 12 |
12 static | 13 static |
13 write_iccid_bin(binrec) | 14 write_iccid_bin(binrec) |
133 nibbles[0] = 9; | 134 nibbles[0] = 9; |
134 binrec[0] = 8; | 135 binrec[0] = 8; |
135 pack_reversed_nibbles(nibbles, binrec + 1, 8); | 136 pack_reversed_nibbles(nibbles, binrec + 1, 8); |
136 return write_imsi_bin(binrec); | 137 return write_imsi_bin(binrec); |
137 } | 138 } |
139 | |
140 static | |
141 write_acc_bin(binrec) | |
142 u_char *binrec; | |
143 { | |
144 int rc; | |
145 | |
146 rc = select_op(DF_GSM); | |
147 if (rc < 0) | |
148 return(rc); | |
149 rc = select_op(EF_ACC); | |
150 if (rc < 0) | |
151 return(rc); | |
152 rc = parse_ef_select_response(); | |
153 if (rc < 0) | |
154 return(rc); | |
155 if (curfile_structure != 0x00 || curfile_total_size != 2) { | |
156 fprintf(stderr, | |
157 "error: EF_ACC is not a transparent EF of 2 bytes\n"); | |
158 return(-1); | |
159 } | |
160 return update_bin_op(0, binrec, 2); | |
161 } | |
162 | |
163 cmd_write_acc(argc, argv) | |
164 char **argv; | |
165 { | |
166 unsigned acc; | |
167 u_char binrec[2]; | |
168 | |
169 acc = strtoul(argv[1], 0, 16); | |
170 if (acc > 0xFFFF) { | |
171 fprintf(stderr, "error: ACC argument is out of range\n"); | |
172 return(-1); | |
173 } | |
174 binrec[0] = acc >> 8; | |
175 binrec[1] = acc; | |
176 return write_acc_bin(binrec); | |
177 } |