FreeCalypso > hg > fc-pcsc-tools
comparison simtool/sstdump.c @ 48:9a21f4353158
fc-simtool sst-dump implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 13 Feb 2021 03:09:44 +0000 |
parents | |
children | bbc2821288aa |
comparison
equal
deleted
inserted
replaced
47:ae3342497fea | 48:9a21f4353158 |
---|---|
1 /* | |
2 * This module implements the sst-dump command, | |
3 * providing a more readable form of the SIM Service Table. | |
4 */ | |
5 | |
6 #include <sys/types.h> | |
7 #include <stdio.h> | |
8 #include "simresp.h" | |
9 #include "curfile.h" | |
10 #include "file_id.h" | |
11 | |
12 cmd_sst_dump() | |
13 { | |
14 int rc; | |
15 unsigned byte, pos, code, nserv; | |
16 | |
17 rc = select_op(DF_GSM); | |
18 if (rc < 0) | |
19 return(rc); | |
20 rc = select_op(EF_SST); | |
21 if (rc < 0) | |
22 return(rc); | |
23 rc = parse_ef_select_response(); | |
24 if (rc < 0) | |
25 return(rc); | |
26 if (curfile_structure != 0x00) { | |
27 fprintf(stderr, "error: EF_SST is not transparent\n"); | |
28 return(-1); | |
29 } | |
30 if (curfile_total_size < 2) { | |
31 fprintf(stderr, | |
32 "error: EF_SST is shorter than spec minimum of 2 bytes\n"); | |
33 return(-1); | |
34 } | |
35 if (curfile_total_size > 256) { | |
36 fprintf(stderr, | |
37 "error: EF_SST is longer than our 256 byte limit\n"); | |
38 return(-1); | |
39 } | |
40 rc = readbin_op(0, curfile_total_size); | |
41 if (rc < 0) | |
42 return(rc); | |
43 nserv = 1; | |
44 for (byte = 0; byte < curfile_total_size; byte++) { | |
45 for (pos = 0; pos < 8; pos += 2) { | |
46 code = (sim_resp_data[byte] >> pos) & 3; | |
47 if (code == 3) | |
48 printf("#%u: activated\n", nserv); | |
49 else if (code == 1) | |
50 printf("#%u: allocated\n", nserv); | |
51 nserv++; | |
52 } | |
53 } | |
54 return(0); | |
55 } |