comparison simtool/miscadm.c @ 182:f4edccd4b583

fc-simtool: write-iccid-sh{18,19} commands implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 06 Mar 2021 05:07:46 +0000
parents 63b640562e21
children 2545dd27ca38
comparison
equal deleted inserted replaced
181:63b640562e21 182:f4edccd4b583
43 return(rc); 43 return(rc);
44 pack_reversed_nibbles(nibbles, binrec, 10); 44 pack_reversed_nibbles(nibbles, binrec, 10);
45 return write_iccid_bin(binrec); 45 return write_iccid_bin(binrec);
46 } 46 }
47 47
48 cmd_write_iccid_sh18(argc, argv)
49 char **argv;
50 {
51 int rc;
52 u_char nibbles[20], binrec[10];
53
54 rc = parse_decimal_shorthand(argv[1], nibbles, 18);
55 if (rc < 0)
56 return(rc);
57 nibbles[18] = compute_iccid_luhn(nibbles);
58 nibbles[19] = 0xF;
59 pack_reversed_nibbles(nibbles, binrec, 10);
60 return write_iccid_bin(binrec);
61 }
62
63 cmd_write_iccid_sh19(argc, argv)
64 char **argv;
65 {
66 int rc;
67 u_char nibbles[20], binrec[10];
68
69 rc = parse_decimal_shorthand(argv[1], nibbles, 19);
70 if (rc < 0)
71 return(rc);
72 if (nibbles[18] != compute_iccid_luhn(nibbles)) {
73 fprintf(stderr, "error: Luhn check digit mismatch\n");
74 return(-1);
75 }
76 nibbles[19] = 0xF;
77 pack_reversed_nibbles(nibbles, binrec, 10);
78 return write_iccid_bin(binrec);
79 }
80
48 static 81 static
49 write_imsi_bin(binrec) 82 write_imsi_bin(binrec)
50 u_char *binrec; 83 u_char *binrec;
51 { 84 {
52 int rc; 85 int rc;