FreeCalypso > hg > fc-sim-tools
annotate utils/sim-iccid-mkrange.c @ 93:6041c601304d
fcsim1-mkprov: revert OTA key addition
It appears that GrcardSIM2 cards (which is what we got for FCSIM1)
do not support OTA after all, contrary to what we were previously
led to believe by some tech support emails from Grcard - apparently
those support emails and OTA descriptions referred to some other
card model(s).
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Wed, 21 Apr 2021 05:38:39 +0000 |
| parents | 9c9f6adbaedb |
| children |
| rev | line source |
|---|---|
|
17
372ecc4aa2c4
off-line utils ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
|
25
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
17
diff
changeset
|
2 * This program is a special utility for generating lists of ICCIDs |
|
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
17
diff
changeset
|
3 * following the 18+1 convention. The first argument is the starting |
|
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
17
diff
changeset
|
4 * ICCID without Luhn (entered as shorthand, expanded to 18 digits), |
|
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
17
diff
changeset
|
5 * the second argument is the number of consecutive ICCIDs to generate. |
|
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
17
diff
changeset
|
6 * The output is a list of full 19-digit ICCIDs. |
|
17
372ecc4aa2c4
off-line utils ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 */ |
|
372ecc4aa2c4
off-line utils ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 |
|
372ecc4aa2c4
off-line utils ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <sys/types.h> |
|
372ecc4aa2c4
off-line utils ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdio.h> |
|
372ecc4aa2c4
off-line utils ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <stdlib.h> |
|
372ecc4aa2c4
off-line utils ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
|
372ecc4aa2c4
off-line utils ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 main(argc, argv) |
|
372ecc4aa2c4
off-line utils ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 char **argv; |
|
372ecc4aa2c4
off-line utils ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 { |
|
372ecc4aa2c4
off-line utils ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 u_char digits[19]; |
|
372ecc4aa2c4
off-line utils ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 char asc[20]; |
|
25
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
17
diff
changeset
|
18 unsigned total, n; |
|
17
372ecc4aa2c4
off-line utils ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 int rc; |
|
372ecc4aa2c4
off-line utils ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 |
|
25
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
17
diff
changeset
|
21 if (argc != 3) { |
|
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
17
diff
changeset
|
22 fprintf(stderr, "usage: %s start-iccid num-cards\n", argv[0]); |
|
17
372ecc4aa2c4
off-line utils ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 exit(1); |
|
372ecc4aa2c4
off-line utils ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 } |
|
372ecc4aa2c4
off-line utils ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 rc = parse_decimal_shorthand(argv[1], digits, 18); |
|
372ecc4aa2c4
off-line utils ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 if (rc < 0) |
|
372ecc4aa2c4
off-line utils ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 exit(1); /* error msg already printed */ |
|
25
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
17
diff
changeset
|
28 total = atoi(argv[2]); |
|
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
17
diff
changeset
|
29 for (n = 0; n < total; n++) { |
|
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
17
diff
changeset
|
30 digits[18] = compute_iccid_luhn(digits); |
|
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
17
diff
changeset
|
31 nibbles_to_ascii(digits, 19, asc); |
|
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
17
diff
changeset
|
32 puts(asc); |
|
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
17
diff
changeset
|
33 decimal_string_increment(digits, 18); |
|
9c9f6adbaedb
sim-iccid-mkrange utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
17
diff
changeset
|
34 } |
|
17
372ecc4aa2c4
off-line utils ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 exit(0); |
|
372ecc4aa2c4
off-line utils ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 } |
