annotate gen/ota-set-msisdn.c @ 11:b4b4a822286c default tip

add INSTALL
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 21 May 2024 01:06:04 +0000
parents a33d4d8079d2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This program generates the OTA RFM payload (to be fed to ota-smswrap-*
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * tools) for programming the MSISDN record.
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdlib.h>
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <string.h>
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <strings.h>
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 main(argc, argv)
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 char **argv;
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 {
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 int rc;
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 u_char record[80], *fixp;
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 unsigned record_len, n;
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 if (argc < 3 || argc > 4) {
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 fprintf(stderr,
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 "usage: %s record-len phone-number [alpha-tag]\n",
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 argv[0]);
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 exit(1);
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 }
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 record_len = strtoul(argv[1], 0, 0);
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 if (record_len < 14 || record_len > 80) {
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 fprintf(stderr,
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 "error: specified MSISDN record length is out of range\n");
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 exit(1);
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 }
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 memset(record, 0xFF, record_len);
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 fixp = record + record_len - 14;
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 rc = encode_phone_number_arg(argv[2], fixp, 0);
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 if (rc < 0)
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 exit(1); /* error msg already printed */
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 if (argv[3]) {
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 rc = qstring_arg_to_gsm7(argv[3], record, record_len - 14);
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 if (rc < 0)
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 exit(1); /* error msg already printed */
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 }
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 /* emit output */
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 printf("A0A40000023F00\n"); /* SELECT MF */
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 printf("A0A40000027F10\n"); /* SELECT DF_TELECOM */
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 printf("A0A40000026F40\n"); /* SELECT EF_MSISDN */
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 printf("A0DC0104%02X\n", record_len); /* UPDATE RECORD */
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 for (n = 0; n < record_len; n++)
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 printf("%02X", record[n]);
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 putchar('\n');
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 exit(0);
a33d4d8079d2 ota-set-msisdn utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 }