FreeCalypso > hg > fc-sim-tools
comparison simtool/inval_rehab.c @ 10:ddd767f6e15b
fc-simtool ported over
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 14 Mar 2021 07:11:25 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
9:c9ef9e91dd8e | 10:ddd767f6e15b |
---|---|
1 /* | |
2 * This module implements the rarely-used INVALIDATE and REHABILITATE | |
3 * SIM protocol commands. | |
4 */ | |
5 | |
6 #include <sys/types.h> | |
7 #include <stdio.h> | |
8 #include "simresp.h" | |
9 #include "file_id.h" | |
10 | |
11 current_ef_inval() | |
12 { | |
13 u_char cmd[5]; | |
14 int rc; | |
15 | |
16 /* INVALIDATE command APDU */ | |
17 cmd[0] = 0xA0; | |
18 cmd[1] = 0x04; | |
19 cmd[2] = 0; | |
20 cmd[3] = 0; | |
21 cmd[4] = 0; | |
22 rc = apdu_exchange(cmd, 5); | |
23 if (rc < 0) | |
24 return(rc); | |
25 if (sim_resp_sw != 0x9000) { | |
26 fprintf(stderr, "bad SW response to INVALIDATE: %04X\n", | |
27 sim_resp_sw); | |
28 return(-1); | |
29 } | |
30 return(0); | |
31 } | |
32 | |
33 current_ef_rehab() | |
34 { | |
35 u_char cmd[5]; | |
36 int rc; | |
37 | |
38 /* REHABILITATE command APDU */ | |
39 cmd[0] = 0xA0; | |
40 cmd[1] = 0x44; | |
41 cmd[2] = 0; | |
42 cmd[3] = 0; | |
43 cmd[4] = 0; | |
44 rc = apdu_exchange(cmd, 5); | |
45 if (rc < 0) | |
46 return(rc); | |
47 if (sim_resp_sw != 0x9000) { | |
48 fprintf(stderr, "bad SW response to REHABILITATE: %04X\n", | |
49 sim_resp_sw); | |
50 return(-1); | |
51 } | |
52 return(0); | |
53 } | |
54 | |
55 cmd_inval_adn() | |
56 { | |
57 int rc; | |
58 | |
59 rc = select_op(DF_TELECOM); | |
60 if (rc < 0) | |
61 return(rc); | |
62 rc = select_op(EF_ADN); | |
63 if (rc < 0) | |
64 return(rc); | |
65 return current_ef_inval(); | |
66 } | |
67 | |
68 cmd_rehab_adn() | |
69 { | |
70 int rc; | |
71 | |
72 rc = select_op(DF_TELECOM); | |
73 if (rc < 0) | |
74 return(rc); | |
75 rc = select_op(EF_ADN); | |
76 if (rc < 0) | |
77 return(rc); | |
78 return current_ef_rehab(); | |
79 } | |
80 | |
81 cmd_rehab_imsi() | |
82 { | |
83 int rc; | |
84 | |
85 rc = select_op(DF_GSM); | |
86 if (rc < 0) | |
87 return(rc); | |
88 rc = select_op(EF_IMSI); | |
89 if (rc < 0) | |
90 return(rc); | |
91 return current_ef_rehab(); | |
92 } | |
93 | |
94 cmd_rehab_loci() | |
95 { | |
96 int rc; | |
97 | |
98 rc = select_op(DF_GSM); | |
99 if (rc < 0) | |
100 return(rc); | |
101 rc = select_op(EF_LOCI); | |
102 if (rc < 0) | |
103 return(rc); | |
104 return current_ef_rehab(); | |
105 } |