annotate gen-pdu/main.c @ 16:d9d722033ff1

sms-gen-tpdu: add support for first octet flags
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 27 Aug 2023 07:32:46 +0000
parents 003660a57f99
children 590b0b5bcbbb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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];
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 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
16 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
17
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 char input_line[512];
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 int input_lineno;
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 static void
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 init_defaults()
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 {
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 sc_addr[0] = 0;
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 user_addr[0] = 0;
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 user_addr[1] = 0x80;
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 mr_byte = 0xFF;
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 pid_byte = 0;
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 dcs_byte = 0;
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 is_septet = 1;
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 }
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 main(argc, argv)
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 char **argv;
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 {
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 if (argc != 2) {
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 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
38 exit(1);
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 }
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 if (!strcmp(argv[1], "mo")) {
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 dir_mo = 1;
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 include_sca = 0;
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 } else if (!strcmp(argv[1], "mt")) {
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 dir_mo = 0;
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 include_sca = 0;
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 } else if (!strcmp(argv[1], "sc-mo")) {
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 dir_mo = 1;
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 include_sca = 1;
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 } else if (!strcmp(argv[1], "sc-mt")) {
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 dir_mo = 0;
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 include_sca = 1;
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 } else
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 goto usage;
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 init_defaults();
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 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
56 input_lineno++)
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 process_input_line();
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 exit(0);
003660a57f99 new program sms-gen-tpdu
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 }