FreeCalypso > hg > freecalypso-hwlab
annotate uicc/select.c @ 159:a5e2b6e3bdf7
fc-uicc-tool: fix-sysmo-msisdn command ported over
| author | Mychaela Falconia <falcon@freecalypso.org> | 
|---|---|
| date | Sun, 07 Feb 2021 04:07:24 +0000 | 
| parents | 65a2a96386cd | 
| children | 
| rev | line source | 
|---|---|
| 130 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 1 #include <sys/types.h> | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 2 #include <ctype.h> | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 3 #include <string.h> | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 4 #include <strings.h> | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 5 #include <stdio.h> | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 6 #include <stdlib.h> | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 7 #include <pcsclite.h> | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 8 #include <winscard.h> | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 9 #include "globals.h" | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 10 | 
| 139 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 11 u_char std_aid_usim[7] = {0xA0, 0x00, 0x00, 0x00, 0x87, 0x10, 0x02}; | 
| 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 12 u_char std_aid_isim[7] = {0xA0, 0x00, 0x00, 0x00, 0x87, 0x10, 0x04}; | 
| 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 13 | 
| 130 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 14 select_op(file_id) | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 15 unsigned file_id; | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 16 { | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 17 u_char cmd[7]; | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 18 int rc; | 
| 131 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 19 unsigned expect_resp_len; | 
| 130 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 20 | 
| 144 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 21 last_sel_file_record_len = 0; | 
| 130 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 22 /* SELECT command APDU */ | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 23 cmd[0] = 0x00; | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 24 cmd[1] = 0xA4; | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 25 cmd[2] = 0x00; | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 26 cmd[3] = 0x04; | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 27 cmd[4] = 2; | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 28 cmd[5] = file_id >> 8; | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 29 cmd[6] = file_id; | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 30 rc = apdu_exchange(cmd, 7); | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 31 if (rc < 0) | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 32 return(rc); | 
| 131 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 33 if ((sim_resp_sw & 0xFF00) != 0x6100) { | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 34 fprintf(stderr, | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 35 "error or unexpected SW response to SELECT of 0x%04X: %04X\n", | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 36 file_id, sim_resp_sw); | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 37 return(-1); | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 38 } | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 39 expect_resp_len = sim_resp_sw & 0xFF; | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 40 /* GET RESPONSE follow-up */ | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 41 cmd[1] = 0xC0; | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 42 cmd[2] = 0; | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 43 cmd[3] = 0; | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 44 cmd[4] = expect_resp_len; | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 45 rc = apdu_exchange(cmd, 5); | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 46 if (rc < 0) | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 47 return(rc); | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 48 if (sim_resp_sw != 0x9000) { | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 49 fprintf(stderr, | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 50 "bad SW resp to GET RESPONSE after SELECT: %04X\n", | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 51 sim_resp_sw); | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 52 return(-1); | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 53 } | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 54 if (sim_resp_data_len != expect_resp_len) { | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 55 fprintf(stderr, | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 56 "error: GET RESPONSE after SELECT returned %u bytes, expected %u\n", | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 57 sim_resp_data_len, expect_resp_len); | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 58 return(-1); | 
| 
d0929cb42e1c
fc-uicc-tool: GET RESPONSE after SELECT
 Mychaela Falconia <falcon@freecalypso.org> parents: 
130diff
changeset | 59 } | 
| 130 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 60 return(0); | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 61 } | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 62 | 
| 138 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 63 select_aid_op(aid, aid_len) | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 64 u_char *aid; | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 65 unsigned aid_len; | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 66 { | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 67 u_char cmd[21]; | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 68 int rc; | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 69 unsigned expect_resp_len; | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 70 | 
| 144 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 71 last_sel_file_record_len = 0; | 
| 138 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 72 /* SELECT command APDU */ | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 73 cmd[0] = 0x00; | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 74 cmd[1] = 0xA4; | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 75 cmd[2] = 0x04; | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 76 cmd[3] = 0x04; | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 77 cmd[4] = aid_len; | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 78 bcopy(aid, cmd + 5, aid_len); | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 79 rc = apdu_exchange(cmd, aid_len + 5); | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 80 if (rc < 0) | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 81 return(rc); | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 82 if ((sim_resp_sw & 0xFF00) != 0x6100) { | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 83 fprintf(stderr, | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 84 "error or unexpected SW response to SELECT by AID: %04X\n", | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 85 sim_resp_sw); | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 86 return(-1); | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 87 } | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 88 expect_resp_len = sim_resp_sw & 0xFF; | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 89 /* GET RESPONSE follow-up */ | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 90 cmd[1] = 0xC0; | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 91 cmd[2] = 0; | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 92 cmd[3] = 0; | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 93 cmd[4] = expect_resp_len; | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 94 rc = apdu_exchange(cmd, 5); | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 95 if (rc < 0) | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 96 return(rc); | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 97 if (sim_resp_sw != 0x9000) { | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 98 fprintf(stderr, | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 99 "bad SW resp to GET RESPONSE after SELECT: %04X\n", | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 100 sim_resp_sw); | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 101 return(-1); | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 102 } | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 103 if (sim_resp_data_len != expect_resp_len) { | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 104 fprintf(stderr, | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 105 "error: GET RESPONSE after SELECT returned %u bytes, expected %u\n", | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 106 sim_resp_data_len, expect_resp_len); | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 107 return(-1); | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 108 } | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 109 return(0); | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 110 } | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 111 | 
| 132 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 112 select_resp_header_check(ret_offset, ret_length) | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 113 unsigned *ret_offset, *ret_length; | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 114 { | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 115 unsigned offset, len; | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 116 | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 117 if (sim_resp_data_len < 2) { | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 118 tooshort: fprintf(stderr, "error: SELECT response is too short\n"); | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 119 return(-1); | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 120 } | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 121 if (sim_resp_data[0] != 0x62) { | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 122 fprintf(stderr, "error: SELECT response first byte != 0x62\n"); | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 123 return(-1); | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 124 } | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 125 len = sim_resp_data[1]; | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 126 if (len <= 0x7F) { | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 127 offset = 2; | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 128 return_check: if (offset + len > sim_resp_data_len) | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 129 goto tooshort; | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 130 if (ret_offset) | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 131 *ret_offset = offset; | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 132 if (ret_length) | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 133 *ret_length = len; | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 134 return(0); | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 135 } | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 136 if (len != 0x81) { | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 137 fprintf(stderr, "SELECT response: first length byte is bad\n"); | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 138 return(-1); | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 139 } | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 140 if (sim_resp_data_len < 3) | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 141 goto tooshort; | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 142 len = sim_resp_data[2]; | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 143 offset = 3; | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 144 goto return_check; | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 145 } | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 146 | 
| 144 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 147 static void | 
| 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 148 check_for_record_struct(tlv) | 
| 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 149 u_char *tlv; | 
| 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 150 { | 
| 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 151 unsigned reclen; | 
| 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 152 | 
| 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 153 if (tlv[1] != 5) | 
| 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 154 return; | 
| 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 155 if (tlv[2] & 0x80) | 
| 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 156 return; | 
| 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 157 if ((tlv[2] & 0x38) == 0x38) | 
| 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 158 return; | 
| 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 159 if ((tlv[2] & 0x03) != 0x02) | 
| 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 160 return; | 
| 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 161 reclen = (tlv[4] << 8) | tlv[5]; | 
| 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 162 if (reclen < 1 || reclen > 255) | 
| 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 163 return; | 
| 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 164 last_sel_file_record_len = reclen; | 
| 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 165 } | 
| 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 166 | 
| 132 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 167 parse_and_display_select_response() | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 168 { | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 169 unsigned offset, totlen, reclen, n; | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 170 u_char *dp, *endp; | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 171 int rc; | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 172 | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 173 rc = select_resp_header_check(&offset, &totlen); | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 174 if (rc < 0) | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 175 return(rc); | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 176 dp = sim_resp_data + offset; | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 177 endp = sim_resp_data + offset + totlen; | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 178 while (dp < endp) { | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 179 if (endp - dp < 2) { | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 180 trunc_error: fprintf(stderr, | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 181 "error: truncated TLV record in SELECT response\n"); | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 182 return(-1); | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 183 } | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 184 if ((dp[0] & 0x1F) == 0x1F) { | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 185 fprintf(stderr, | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 186 "error: extended tag not supported in SELECT response\n"); | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 187 return(-1); | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 188 } | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 189 if (dp[1] & 0x80) { | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 190 fprintf(stderr, | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 191 "error: extended length not supported in SELECT response\n"); | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 192 return(-1); | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 193 } | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 194 reclen = dp[1] + 2; | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 195 if (endp - dp < reclen) | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 196 goto trunc_error; | 
| 144 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 197 if (dp[0] == 0x82) | 
| 
429a8f80426e
fc-uicc-tool: catch record length from manual select
 Mychaela Falconia <falcon@freecalypso.org> parents: 
139diff
changeset | 198 check_for_record_struct(dp); | 
| 132 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 199 for (n = 0; n < reclen; n++) { | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 200 if (n) | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 201 putchar(' '); | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 202 printf("%02X", *dp++); | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 203 } | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 204 putchar('\n'); | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 205 } | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 206 return(0); | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 207 } | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 208 | 
| 130 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 209 cmd_select(argc, argv) | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 210 char **argv; | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 211 { | 
| 132 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 212 int file_id, rc; | 
| 130 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 213 | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 214 if (isxdigit(argv[1][0]) && isxdigit(argv[1][1]) && | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 215 isxdigit(argv[1][2]) && isxdigit(argv[1][3]) && !argv[1][4]) | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 216 file_id = strtoul(argv[1], 0, 16); | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 217 else | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 218 file_id = find_symbolic_file_name(argv[1]); | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 219 if (file_id < 0) { | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 220 fprintf(stderr, | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 221 "error: file ID argument is not a hex value or a recognized symbolic name\n"); | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 222 return(-1); | 
| 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 223 } | 
| 132 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 224 rc = select_op(file_id); | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 225 if (rc < 0) | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 226 return(rc); | 
| 
5af88fa11b54
fc-uicc-tool: SELECT response parsing implemented (basic)
 Mychaela Falconia <falcon@freecalypso.org> parents: 
131diff
changeset | 227 return parse_and_display_select_response(); | 
| 130 
f691a19f191d
fc-uicc-tool skeleton started
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 228 } | 
| 134 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 229 | 
| 138 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 230 cmd_select_aid(argc, argv) | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 231 char **argv; | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 232 { | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 233 u_char aid[16]; | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 234 unsigned aid_len; | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 235 int rc; | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 236 | 
| 158 
65a2a96386cd
fc-uicc-tool: hex string parsing with min and max length,
 Mychaela Falconia <falcon@freecalypso.org> parents: 
144diff
changeset | 237 rc = decode_hex_data_from_string(argv[1], aid, 1, 16); | 
| 138 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 238 if (rc < 0) | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 239 return(rc); | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 240 aid_len = rc; | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 241 rc = select_aid_op(aid, aid_len); | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 242 if (rc < 0) | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 243 return(rc); | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 244 return parse_and_display_select_response(); | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 245 } | 
| 
baf5bd698764
fc-uicc-tool: select-aid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
135diff
changeset | 246 | 
| 139 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 247 cmd_select_usim() | 
| 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 248 { | 
| 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 249 int rc; | 
| 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 250 | 
| 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 251 rc = select_aid_op(std_aid_usim, 7); | 
| 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 252 if (rc < 0) | 
| 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 253 return(rc); | 
| 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 254 return parse_and_display_select_response(); | 
| 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 255 } | 
| 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 256 | 
| 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 257 cmd_select_isim() | 
| 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 258 { | 
| 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 259 int rc; | 
| 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 260 | 
| 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 261 rc = select_aid_op(std_aid_isim, 7); | 
| 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 262 if (rc < 0) | 
| 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 263 return(rc); | 
| 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 264 return parse_and_display_select_response(); | 
| 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 265 } | 
| 
6c6e8705dc70
fc-uicc-tool: select-usim and select-isim implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
138diff
changeset | 266 | 
| 134 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 267 u_char * | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 268 extract_select_resp_tag(sought_tag) | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 269 unsigned sought_tag; | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 270 { | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 271 unsigned offset, totlen, reclen; | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 272 u_char *dp, *endp; | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 273 int rc; | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 274 | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 275 rc = select_resp_header_check(&offset, &totlen); | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 276 if (rc < 0) | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 277 return(0); | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 278 dp = sim_resp_data + offset; | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 279 endp = sim_resp_data + offset + totlen; | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 280 while (dp < endp) { | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 281 if (endp - dp < 2) { | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 282 trunc_error: fprintf(stderr, | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 283 "error: truncated TLV record in SELECT response\n"); | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 284 return(0); | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 285 } | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 286 if ((dp[0] & 0x1F) == 0x1F) { | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 287 fprintf(stderr, | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 288 "error: extended tag not supported in SELECT response\n"); | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 289 return(0); | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 290 } | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 291 if (dp[1] & 0x80) { | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 292 fprintf(stderr, | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 293 "error: extended length not supported in SELECT response\n"); | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 294 return(0); | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 295 } | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 296 reclen = dp[1] + 2; | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 297 if (endp - dp < reclen) | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 298 goto trunc_error; | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 299 if (dp[0] == sought_tag) | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 300 return(dp); | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 301 dp += reclen; | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 302 } | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 303 fprintf(stderr, "error: tag 0x%02X not found in SELECT response\n", | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 304 sought_tag); | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 305 return(0); | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 306 } | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 307 | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 308 select_resp_get_transparent(lenp) | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 309 unsigned *lenp; | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 310 { | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 311 u_char *tlv; | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 312 | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 313 tlv = extract_select_resp_tag(0x82); | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 314 if (!tlv) | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 315 return(-1); | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 316 if (tlv[1] != 2) { | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 317 bad_file_desc: fprintf(stderr, "error: file type is not transparent EF\n"); | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 318 return(-1); | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 319 } | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 320 if (tlv[2] & 0x80) | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 321 goto bad_file_desc; | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 322 if ((tlv[2] & 0x38) == 0x38) | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 323 goto bad_file_desc; | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 324 if ((tlv[2] & 0x07) != 0x01) | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 325 goto bad_file_desc; | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 326 tlv = extract_select_resp_tag(0x80); | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 327 if (!tlv) | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 328 return(-1); | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 329 if (tlv[1] != 2) { | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 330 fprintf(stderr, | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 331 "error: file size TLV element has wrong length\n"); | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 332 return(-1); | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 333 } | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 334 if (lenp) | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 335 *lenp = (tlv[2] << 8) | tlv[3]; | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 336 return(0); | 
| 
69628bcfec17
fc-uicc-tool: iccid command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
132diff
changeset | 337 } | 
| 135 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 338 | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 339 select_resp_get_linear_fixed(rec_len_ret, rec_count_ret) | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 340 unsigned *rec_len_ret, *rec_count_ret; | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 341 { | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 342 u_char *tlv; | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 343 unsigned reclen; | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 344 | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 345 tlv = extract_select_resp_tag(0x82); | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 346 if (!tlv) | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 347 return(-1); | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 348 if (tlv[1] != 5) { | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 349 bad_file_desc: fprintf(stderr, "error: file type is not linear fixed EF\n"); | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 350 return(-1); | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 351 } | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 352 if (tlv[2] & 0x80) | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 353 goto bad_file_desc; | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 354 if ((tlv[2] & 0x38) == 0x38) | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 355 goto bad_file_desc; | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 356 if ((tlv[2] & 0x07) != 0x02) | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 357 goto bad_file_desc; | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 358 reclen = (tlv[4] << 8) | tlv[5]; | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 359 if (reclen < 1 || reclen > 255) { | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 360 fprintf(stderr, | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 361 "error: SELECT response gives invalid record length\n"); | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 362 return(-1); | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 363 } | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 364 if (rec_len_ret) | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 365 *rec_len_ret = reclen; | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 366 if (rec_count_ret) | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 367 *rec_count_ret = tlv[6]; | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 368 return(0); | 
| 
51d6aaa43a7b
fc-uicc-tool: telecom-sum command implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
134diff
changeset | 369 } | 
