FreeCalypso > hg > fc-pcsc-tools
annotate simtool/fplmn.c @ 219:ac41c42ce806
scripts/fcsim1-defprog created
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 07 Mar 2021 20:24:05 +0000 |
parents | 7ecc08e55d39 |
children |
rev | line source |
---|---|
53
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
2 * This module implements commands for working with EF_FPLMN. |
53
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
99
d2e800abd257
fc-simtool plmnsel-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
53
diff
changeset
|
7 #include <stdlib.h> |
100
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
8 #include <string.h> |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
9 #include <strings.h> |
53
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include "simresp.h" |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include "curfile.h" |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include "file_id.h" |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 static |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
15 select_ef_fplmn() |
53
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 { |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 int rc; |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 rc = select_op(DF_GSM); |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 if (rc < 0) |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 return(rc); |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
22 rc = select_op(EF_FPLMN); |
53
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 if (rc < 0) |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 return(rc); |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 rc = parse_ef_select_response(); |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 if (rc < 0) |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 return(rc); |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 if (curfile_structure != 0x00) { |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
29 fprintf(stderr, "error: EF_FPLMN is not transparent\n"); |
53
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 return(-1); |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 } |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
32 if (curfile_total_size != 12) { |
53
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 fprintf(stderr, |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
34 "error: EF_FPLMN size does not equal 12 bytes\n"); |
53
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 return(-1); |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 } |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 return(0); |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 } |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 |
109
8a27f45bc1e6
fc-simtool fplmn-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
40 cmd_fplmn_dump(argc, argv, outf) |
101
63c76f9d678a
plmnsel-dump can now write to file
Mychaela Falconia <falcon@freecalypso.org>
parents:
100
diff
changeset
|
41 char **argv; |
109
8a27f45bc1e6
fc-simtool fplmn-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
42 FILE *outf; |
53
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 { |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
44 int rc; |
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
45 u_char *dp; |
53
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 char ascbuf[8]; |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
47 unsigned idx; |
53
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
49 rc = select_ef_fplmn(); |
53
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 if (rc < 0) |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 return(rc); |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
52 rc = readbin_op(0, 12); |
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
53 if (rc < 0) |
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
54 return(rc); |
53
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 dp = sim_resp_data; |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
56 for (idx = 0; idx < 4; idx++, dp += 3) { |
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
57 if (idx) |
109
8a27f45bc1e6
fc-simtool fplmn-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
58 putc(' ', outf); |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
59 if (dp[0] == 0xFF && dp[1] == 0xFF && dp[2] == 0xFF) |
109
8a27f45bc1e6
fc-simtool fplmn-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
60 fputs("-blank-", outf); |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
61 else { |
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
62 decode_plmn_3bytes(dp, ascbuf, 1); |
109
8a27f45bc1e6
fc-simtool fplmn-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
63 fputs(ascbuf, outf); |
53
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 } |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 } |
109
8a27f45bc1e6
fc-simtool fplmn-dump: support output redirection
Mychaela Falconia <falcon@freecalypso.org>
parents:
103
diff
changeset
|
66 putc('\n', outf); |
53
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 return(0); |
4eb447be01c0
fc-simtool plmnsel-dump implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 } |
99
d2e800abd257
fc-simtool plmnsel-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
53
diff
changeset
|
69 |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
70 cmd_fplmn_write(argc, argv) |
99
d2e800abd257
fc-simtool plmnsel-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
53
diff
changeset
|
71 char **argv; |
d2e800abd257
fc-simtool plmnsel-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
53
diff
changeset
|
72 { |
d2e800abd257
fc-simtool plmnsel-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
53
diff
changeset
|
73 int rc; |
d2e800abd257
fc-simtool plmnsel-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
53
diff
changeset
|
74 unsigned idx; |
d2e800abd257
fc-simtool plmnsel-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
53
diff
changeset
|
75 u_char rec[3]; |
d2e800abd257
fc-simtool plmnsel-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
53
diff
changeset
|
76 |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
77 rc = select_ef_fplmn(); |
99
d2e800abd257
fc-simtool plmnsel-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
53
diff
changeset
|
78 if (rc < 0) |
d2e800abd257
fc-simtool plmnsel-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
53
diff
changeset
|
79 return(rc); |
d2e800abd257
fc-simtool plmnsel-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
53
diff
changeset
|
80 idx = strtoul(argv[1], 0, 0); |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
81 if (idx >= 4) { |
99
d2e800abd257
fc-simtool plmnsel-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
53
diff
changeset
|
82 fprintf(stderr, "error: specified index is out of range\n"); |
d2e800abd257
fc-simtool plmnsel-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
53
diff
changeset
|
83 return(-1); |
d2e800abd257
fc-simtool plmnsel-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
53
diff
changeset
|
84 } |
d2e800abd257
fc-simtool plmnsel-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
53
diff
changeset
|
85 rc = encode_plmn_3bytes(argv[2], rec); |
197
3ddbc3fea5f0
encode_plmn_3bytes() error handling change
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
86 if (rc < 0) { |
3ddbc3fea5f0
encode_plmn_3bytes() error handling change
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
87 fprintf(stderr, "error: invalid MCC-MNC argument\n"); |
99
d2e800abd257
fc-simtool plmnsel-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
53
diff
changeset
|
88 return(rc); |
197
3ddbc3fea5f0
encode_plmn_3bytes() error handling change
Mychaela Falconia <falcon@freecalypso.org>
parents:
109
diff
changeset
|
89 } |
99
d2e800abd257
fc-simtool plmnsel-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
53
diff
changeset
|
90 return update_bin_op(idx * 3, rec, 3); |
d2e800abd257
fc-simtool plmnsel-write command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
53
diff
changeset
|
91 } |
100
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
92 |
199
7ecc08e55d39
fc-simtool fplmn-write-list command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
197
diff
changeset
|
93 cmd_fplmn_write_list(argc, argv) |
7ecc08e55d39
fc-simtool fplmn-write-list command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
197
diff
changeset
|
94 char **argv; |
7ecc08e55d39
fc-simtool fplmn-write-list command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
197
diff
changeset
|
95 { |
7ecc08e55d39
fc-simtool fplmn-write-list command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
197
diff
changeset
|
96 int rc; |
7ecc08e55d39
fc-simtool fplmn-write-list command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
197
diff
changeset
|
97 u_char buf[12]; |
7ecc08e55d39
fc-simtool fplmn-write-list command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
197
diff
changeset
|
98 |
7ecc08e55d39
fc-simtool fplmn-write-list command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
197
diff
changeset
|
99 rc = select_ef_fplmn(); |
7ecc08e55d39
fc-simtool fplmn-write-list command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
197
diff
changeset
|
100 if (rc < 0) |
7ecc08e55d39
fc-simtool fplmn-write-list command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
197
diff
changeset
|
101 return(rc); |
7ecc08e55d39
fc-simtool fplmn-write-list command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
197
diff
changeset
|
102 rc = read_plmn_list_from_file(argv[1], buf, 12); |
7ecc08e55d39
fc-simtool fplmn-write-list command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
197
diff
changeset
|
103 if (rc < 0) |
7ecc08e55d39
fc-simtool fplmn-write-list command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
197
diff
changeset
|
104 return(rc); |
7ecc08e55d39
fc-simtool fplmn-write-list command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
197
diff
changeset
|
105 return update_bin_op(0, buf, 12); |
7ecc08e55d39
fc-simtool fplmn-write-list command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
197
diff
changeset
|
106 } |
7ecc08e55d39
fc-simtool fplmn-write-list command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
197
diff
changeset
|
107 |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
108 cmd_fplmn_erase(argc, argv) |
100
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
109 char **argv; |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
110 { |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
111 int rc; |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
112 unsigned idx, start, end; |
100
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
113 u_char rec[3]; |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
114 |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
115 rc = select_ef_fplmn(); |
100
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
116 if (rc < 0) |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
117 return(rc); |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
118 start = strtoul(argv[1], 0, 0); |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
119 if (start >= 4) { |
100
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
120 fprintf(stderr, |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
121 "error: specified starting index is out of range\n"); |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
122 return(-1); |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
123 } |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
124 if (!argv[2]) |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
125 end = start; |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
126 else if (!strcmp(argv[2], "end")) |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
127 end = 3; |
100
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
128 else { |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
129 end = strtoul(argv[1], 0, 0); |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
130 if (end >= 4) { |
100
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
131 fprintf(stderr, |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
132 "error: specified ending index is out of range\n"); |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
133 return(-1); |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
134 } |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
135 if (start > end) { |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
136 fprintf(stderr, |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
137 "error: reverse index range specified\n"); |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
138 return(-1); |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
139 } |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
140 } |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
141 memset(rec, 0xFF, 3); |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
142 for (idx = start; idx <= end; idx++) { |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
143 rc = update_bin_op(idx * 3, rec, 3); |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
144 if (rc < 0) |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
145 return(rc); |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
146 } |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
147 return(0); |
a75c0aafb367
plmnsel-erase command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
99
diff
changeset
|
148 } |
102
9ce95d9c5c34
plmnsel-erase-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
101
diff
changeset
|
149 |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
150 cmd_fplmn_erase_all(argc, argv) |
102
9ce95d9c5c34
plmnsel-erase-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
101
diff
changeset
|
151 char **argv; |
9ce95d9c5c34
plmnsel-erase-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
101
diff
changeset
|
152 { |
9ce95d9c5c34
plmnsel-erase-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
101
diff
changeset
|
153 int rc; |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
154 u_char ffbuf[12]; |
102
9ce95d9c5c34
plmnsel-erase-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
101
diff
changeset
|
155 |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
156 rc = select_ef_fplmn(); |
102
9ce95d9c5c34
plmnsel-erase-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
101
diff
changeset
|
157 if (rc < 0) |
9ce95d9c5c34
plmnsel-erase-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
101
diff
changeset
|
158 return(rc); |
103
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
159 memset(ffbuf, 0xFF, 12); |
9b2cb2b9c910
fc-simtool fplmn-* commands implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
102
diff
changeset
|
160 return update_bin_op(0, ffbuf, 12); |
102
9ce95d9c5c34
plmnsel-erase-all command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
101
diff
changeset
|
161 } |