comparison gen/ota-set-msisdn.c @ 7:a33d4d8079d2

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