comparison uicc/writeops.c @ 22:1b1468869ccf

new trimmed fc-uicc-tool is here
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 12 Feb 2021 04:34:53 +0000
parents
children
comparison
equal deleted inserted replaced
21:d4dc86195382 22:1b1468869ccf
1 #include <sys/types.h>
2 #include <string.h>
3 #include <strings.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include "simresp.h"
7
8 update_bin_op(offset, data, len)
9 unsigned offset, len;
10 u_char *data;
11 {
12 u_char cmd[260];
13 int rc;
14
15 /* UPDATE BINARY command APDU */
16 cmd[0] = 0x00;
17 cmd[1] = 0xD6;
18 cmd[2] = offset >> 8;
19 cmd[3] = offset;
20 cmd[4] = len;
21 bcopy(data, cmd + 5, len);
22 rc = apdu_exchange(cmd, len + 5);
23 if (rc < 0)
24 return(rc);
25 if (sim_resp_sw != 0x9000) {
26 fprintf(stderr, "bad SW response to UPDATE BINARY: %04X\n",
27 sim_resp_sw);
28 return(-1);
29 }
30 return(0);
31 }
32
33 update_rec_op(recno, mode, data, len)
34 unsigned recno, mode, len;
35 u_char *data;
36 {
37 u_char cmd[260];
38 int rc;
39
40 /* UPDATE RECORD command APDU */
41 cmd[0] = 0x00;
42 cmd[1] = 0xDC;
43 cmd[2] = recno;
44 cmd[3] = mode;
45 cmd[4] = len;
46 bcopy(data, cmd + 5, len);
47 rc = apdu_exchange(cmd, len + 5);
48 if (rc < 0)
49 return(rc);
50 if (sim_resp_sw != 0x9000) {
51 fprintf(stderr, "bad SW response to UPDATE RECORD: %04X\n",
52 sim_resp_sw);
53 return(-1);
54 }
55 return(0);
56 }