FreeCalypso > hg > sms-coding-utils
annotate gen-pdu/main.c @ 27:7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
that are needed for sms-pdu-decode & pcm-sms-decode
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 13 Jun 2024 02:29:29 +0000 |
parents | 590b0b5bcbbb |
children |
rev | line source |
---|---|
9
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This C file is the main module for sms-gen-tpdu utility. |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdlib.h> |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <string.h> |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <strings.h> |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 int dir_mo, include_sca; |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 u_char sc_addr[12], user_addr[12]; |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 u_char mr_byte, pid_byte, dcs_byte; |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 u_char scts_buf[7]; |
18
590b0b5bcbbb
sms-gen-tpdu: support setting VP for MO
Mychaela Falconia <falcon@freecalypso.org>
parents:
16
diff
changeset
|
15 u_char vp_format, vp_buf[7]; |
9
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 int is_septet, scts_is_set; |
16
d9d722033ff1
sms-gen-tpdu: add support for first octet flags
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
17 int flag_rp, flag_sr, flag_lp, flag_mms, flag_rd; |
9
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 char input_line[512]; |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 int input_lineno; |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 static void |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 init_defaults() |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 { |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 sc_addr[0] = 0; |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 user_addr[0] = 0; |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 user_addr[1] = 0x80; |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 mr_byte = 0xFF; |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 pid_byte = 0; |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 dcs_byte = 0; |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 is_septet = 1; |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 } |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 main(argc, argv) |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 char **argv; |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 { |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 if (argc != 2) { |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 usage: fprintf(stderr, "usage: %s mo|mt|sc-mo|sc-mt\n", argv[0]); |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 exit(1); |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 } |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 if (!strcmp(argv[1], "mo")) { |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 dir_mo = 1; |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 include_sca = 0; |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 } else if (!strcmp(argv[1], "mt")) { |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 dir_mo = 0; |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 include_sca = 0; |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 } else if (!strcmp(argv[1], "sc-mo")) { |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 dir_mo = 1; |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 include_sca = 1; |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 } else if (!strcmp(argv[1], "sc-mt")) { |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 dir_mo = 0; |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 include_sca = 1; |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 } else |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 goto usage; |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 init_defaults(); |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 for (input_lineno = 1; fgets(input_line, sizeof input_line, stdin); |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 input_lineno++) |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 process_input_line(); |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 exit(0); |
003660a57f99
new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 } |