annotate simtool/inval_rehab.c @ 128:01aed8d0685a

doc/Low-level-commands: raw apdu command documented
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 20 Feb 2021 20:10:18 +0000
parents 7faec607500f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
124
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module implements the rarely-used INVALIDATE and REHABILITATE
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * SIM protocol commands.
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include "simresp.h"
125
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
9 #include "file_id.h"
124
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 current_ef_inval()
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 {
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 u_char cmd[5];
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 int rc;
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 /* INVALIDATE command APDU */
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 cmd[0] = 0xA0;
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 cmd[1] = 0x04;
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 cmd[2] = 0;
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 cmd[3] = 0;
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 cmd[4] = 0;
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 rc = apdu_exchange(cmd, 5);
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 if (rc < 0)
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 return(rc);
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 if (sim_resp_sw != 0x9000) {
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 fprintf(stderr, "bad SW response to INVALIDATE: %04X\n",
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 sim_resp_sw);
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 return(-1);
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 }
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 return(0);
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 }
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 current_ef_rehab()
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 {
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 u_char cmd[5];
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 int rc;
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 /* REHABILITATE command APDU */
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 cmd[0] = 0xA0;
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 cmd[1] = 0x44;
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 cmd[2] = 0;
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 cmd[3] = 0;
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 cmd[4] = 0;
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 rc = apdu_exchange(cmd, 5);
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 if (rc < 0)
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 return(rc);
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 if (sim_resp_sw != 0x9000) {
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 fprintf(stderr, "bad SW response to REHABILITATE: %04X\n",
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 sim_resp_sw);
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 return(-1);
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 }
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 return(0);
d0d1c0b35831 fc-simtool: add low-level cur-ef-{inval,rehab} commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 }
125
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
54
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
55 cmd_inval_adn()
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
56 {
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
57 int rc;
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
58
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
59 rc = select_op(DF_TELECOM);
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
60 if (rc < 0)
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
61 return(rc);
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
62 rc = select_op(EF_ADN);
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
63 if (rc < 0)
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
64 return(rc);
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
65 return current_ef_inval();
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
66 }
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
67
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
68 cmd_rehab_adn()
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
69 {
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
70 int rc;
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
71
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
72 rc = select_op(DF_TELECOM);
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
73 if (rc < 0)
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
74 return(rc);
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
75 rc = select_op(EF_ADN);
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
76 if (rc < 0)
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
77 return(rc);
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
78 return current_ef_rehab();
e5d534fa5924 fc-simtool: {inval,rehab}-adn commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 124
diff changeset
79 }
126
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
80
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
81 cmd_rehab_imsi()
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
82 {
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
83 int rc;
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
84
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
85 rc = select_op(DF_GSM);
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
86 if (rc < 0)
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
87 return(rc);
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
88 rc = select_op(EF_IMSI);
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
89 if (rc < 0)
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
90 return(rc);
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
91 return current_ef_rehab();
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
92 }
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
93
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
94 cmd_rehab_loci()
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
95 {
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
96 int rc;
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
97
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
98 rc = select_op(DF_GSM);
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
99 if (rc < 0)
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
100 return(rc);
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
101 rc = select_op(EF_LOCI);
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
102 if (rc < 0)
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
103 return(rc);
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
104 return current_ef_rehab();
7faec607500f rehab-{imsi,loci} commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 125
diff changeset
105 }