FreeCalypso > hg > fc-sim-tools
comparison simtool/stktest.c @ 94:3d9c50880ae7
fc-simtool fetch command implemented
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Wed, 21 Apr 2021 05:50:45 +0000 |
| parents | ddd767f6e15b |
| children | c06c0e2da24c |
comparison
equal
deleted
inserted
replaced
| 93:6041c601304d | 94:3d9c50880ae7 |
|---|---|
| 1 /* | 1 /* |
| 2 * This module implements some commands for testing SIM Toolkit functionality, | 2 * This module implements some commands for testing SIM Toolkit functionality, |
| 3 * just enough to be able to simulate SMS-PP SIM data download operations. | 3 * initially just enough to be able to simulate SMS-PP SIM data download |
| 4 * operations, but now also extending into basic exploration of proactive SIMs. | |
| 4 */ | 5 */ |
| 5 | 6 |
| 6 #include <sys/types.h> | 7 #include <sys/types.h> |
| 7 #include <stdio.h> | 8 #include <stdio.h> |
| 8 #include <stdlib.h> | 9 #include <stdlib.h> |
| 77 if (rc < 0) | 78 if (rc < 0) |
| 78 return(rc); | 79 return(rc); |
| 79 printf("%04X\n", sim_resp_sw); | 80 printf("%04X\n", sim_resp_sw); |
| 80 return(0); | 81 return(0); |
| 81 } | 82 } |
| 83 | |
| 84 cmd_fetch(argc, argv, outf) | |
| 85 char **argv; | |
| 86 FILE *outf; | |
| 87 { | |
| 88 u_char cmd[5]; | |
| 89 int rc; | |
| 90 unsigned len; | |
| 91 | |
| 92 len = strtoul(argv[1], 0, 0); | |
| 93 if (len < 1 || len > 256) { | |
| 94 fprintf(stderr, "error: length argument is out of range\n"); | |
| 95 return(-1); | |
| 96 } | |
| 97 /* FETCH command APDU */ | |
| 98 cmd[0] = 0xA0; | |
| 99 cmd[1] = 0x12; | |
| 100 cmd[2] = 0; | |
| 101 cmd[3] = 0; | |
| 102 cmd[4] = len; | |
| 103 rc = apdu_exchange(cmd, 5); | |
| 104 if (rc < 0) | |
| 105 return(rc); | |
| 106 if (sim_resp_sw != 0x9000) { | |
| 107 fprintf(stderr, "bad SW resp: %04X\n", sim_resp_sw); | |
| 108 return(-1); | |
| 109 } | |
| 110 display_sim_resp_in_hex(outf); | |
| 111 return(0); | |
| 112 } |
