annotate uptools/sms-pdu-decode/pdu-common.c @ 1009:4a153059abbb

doc/DUART28-boot-control: update for fc-linux-patch and fc-usbser-tools
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 12 Dec 2023 06:57:11 +0000
parents b515a97e5dff
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
598
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 #include <sys/types.h>
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 #include <ctype.h>
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 #include <stdio.h>
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 #include <stdlib.h>
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <string.h>
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <strings.h>
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 int ascii_ext_mode, global_hexdump_mode;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 u_char pdu[176];
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 unsigned pdu_length;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 static u_char first_octet;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 static unsigned pdu_ptr;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 static int dcs_distilled;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 static
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 handle_sca()
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 unsigned sca_len;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 char digits[21];
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 sca_len = pdu[0];
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 pdu_ptr = 1;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 if (!sca_len)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 return(0);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 if (sca_len < 2 || sca_len > 11) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 printf("Decode-Error: invalid SCA length\n");
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 if (pdu_ptr + sca_len > pdu_length) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 printf("Decode-Error: SCA goes past PDU end\n");
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 pdu_ptr += sca_len;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 decode_address_digits(pdu + 2, digits, sc_addr_ndigits(pdu));
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 printf("SCA: %s%s (type 0x%02X)\n", pdu[1] == 0x91 ? "+" : "", digits,
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 pdu[1]);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 return(0);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 static
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 handle_first_octet()
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 if (pdu_ptr >= pdu_length) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 printf("Decode-Error: end of PDU before FO\n");
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 first_octet = pdu[pdu_ptr++];
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 printf("First-Octet: 0x%02X\n", first_octet);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 return(0);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 static
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 handle_mr()
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 if (pdu_ptr >= pdu_length) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 printf("Decode-Error: end of PDU before MR\n");
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 printf("MR: 0x%02X\n", pdu[pdu_ptr++]);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 return(0);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 static
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 handle_user_addr(direction)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 char *direction;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 unsigned addr_field_len, alpha_nsep;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 char digits[21];
800
8dc93aac9a9c pcm-sms-decode & sms-pdu-decode: use new function for
Mychaela Falconia <falcon@freecalypso.org>
parents: 599
diff changeset
71 u_char alpha_gsm7[11];
598
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 if (pdu_ptr >= pdu_length) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 printf("Decode-Error: end of PDU before %s address\n",
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 direction);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 if (pdu[pdu_ptr] > 20) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 printf("Decode-Error: %s address > 20 digits\n", direction);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 addr_field_len = ((pdu[pdu_ptr] + 1) >> 1) + 2;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 if (pdu_ptr + addr_field_len > pdu_length) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 printf("Decode-Error: %s address goes past PDU end\n",
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 direction);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 if (!pdu[pdu_ptr])
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 printf("%s: empty-addr (type 0x%02X)\n", direction,
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 pdu[pdu_ptr+1]);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 else if ((pdu[pdu_ptr+1] & 0x70) == 0x50 &&
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 alpha_addr_valid(pdu[pdu_ptr], &alpha_nsep)) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 gsm7_unpack(pdu + pdu_ptr + 2, alpha_gsm7, alpha_nsep);
800
8dc93aac9a9c pcm-sms-decode & sms-pdu-decode: use new function for
Mychaela Falconia <falcon@freecalypso.org>
parents: 599
diff changeset
94 printf("%s: ", direction);
8dc93aac9a9c pcm-sms-decode & sms-pdu-decode: use new function for
Mychaela Falconia <falcon@freecalypso.org>
parents: 599
diff changeset
95 print_gsm7_string_to_file(alpha_gsm7, alpha_nsep, stdout);
8dc93aac9a9c pcm-sms-decode & sms-pdu-decode: use new function for
Mychaela Falconia <falcon@freecalypso.org>
parents: 599
diff changeset
96 printf(" (type 0x%02X)\n", pdu[pdu_ptr+1]);
598
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 } else {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 decode_address_digits(pdu + pdu_ptr + 2, digits, pdu[pdu_ptr]);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 printf("%s: %s%s (type 0x%02X)\n", direction,
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 pdu[pdu_ptr+1] == 0x91 ? "+" : "", digits,
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 pdu[pdu_ptr+1]);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 pdu_ptr += addr_field_len;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 return(0);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 static
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 handle_pid()
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 if (pdu_ptr >= pdu_length) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 printf("Decode-Error: end of PDU before PID\n");
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 printf("PID: 0x%02X\n", pdu[pdu_ptr++]);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 return(0);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 static
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 handle_dcs()
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 u_char dcs;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 char *strtype;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 if (pdu_ptr >= pdu_length) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 printf("Decode-Error: end of PDU before DCS\n");
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 dcs = pdu[pdu_ptr++];
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 dcs_distilled = sms_dcs_classify(dcs);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 switch (dcs_distilled) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 case 7:
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 strtype = "7-bit";
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 break;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 case 8:
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 strtype = "raw octets";
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 break;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 case 9:
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 strtype = "compressed";
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 break;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 case 16:
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 strtype = "UCS-2";
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 break;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 printf("DCS: 0x%02X (%s)\n", dcs, strtype);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 return(0);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 static
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 handle_scts()
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 char str[21];
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 if (pdu_ptr + 7 > pdu_length) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 printf("Decode-Error: end of PDU before SCTS\n");
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 gsm_timestamp_decode(pdu + pdu_ptr, str);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 printf("SC-Timestamp: %s\n", str);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 pdu_ptr += 7;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 return(0);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 static
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 handle_vp_abs()
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 char str[21];
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 if (pdu_ptr + 7 > pdu_length) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 printf("Decode-Error: end of PDU before VP-abs\n");
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 gsm_timestamp_decode(pdu + pdu_ptr, str);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 printf("VP-Absolute: %s\n", str);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 pdu_ptr += 7;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 return(0);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 static
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 handle_vp_rel()
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 unsigned vprel, hours, min;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 if (pdu_ptr >= pdu_length) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184 printf("Decode-Error: end of PDU before VP-rel\n");
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187 vprel = pdu[pdu_ptr++];
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 if (vprel <= 143) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 min = (vprel + 1) * 5;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190 goto hhmm;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 } else if (vprel <= 167) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 min = (vprel - 143) * 30 + 12 * 60;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 goto hhmm;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194 } else if (vprel <= 196) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 printf("VP-Relative: %u days\n", vprel - 166);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 return(0);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 } else {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 printf("VP-Relative: %u weeks\n", vprel - 192);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 return(0);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 hhmm: hours = min / 60;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203 min %= 60;
963
b515a97e5dff sms-pdu-decode family: fix VP-Relative header spacing
Mychaela Falconia <falcon@freecalypso.org>
parents: 960
diff changeset
204 printf("VP-Relative:");
598
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 if (hours)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206 printf(" %u hour%s", hours, hours != 1 ? "s" : "");
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207 if (min)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 printf(" %u min", min);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 putchar('\n');
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210 return(0);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
213 static
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 handle_vp_enh()
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215 {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216 if (pdu_ptr + 7 > pdu_length) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217 printf("Decode-Error: end of PDU before VP-enh\n");
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220 printf("VP-Enhanced: %02X %02X %02X %02X %02X %02X %02X\n",
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 pdu[pdu_ptr], pdu[pdu_ptr+1], pdu[pdu_ptr+2], pdu[pdu_ptr+3],
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 pdu[pdu_ptr+4], pdu[pdu_ptr+5], pdu[pdu_ptr+6]);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223 pdu_ptr += 7;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224 return(0);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
227 static
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
228 handle_vp()
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
229 {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
230 int rc;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
231
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
232 switch (first_octet & 0x18) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
233 case 0x00:
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
234 rc = 0;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
235 break;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
236 case 0x08:
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
237 rc = handle_vp_enh();
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
238 break;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
239 case 0x10:
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
240 rc = handle_vp_rel();
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
241 break;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
242 case 0x18:
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
243 rc = handle_vp_abs();
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
244 break;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
245 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
246 return(rc);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
247 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
248
960
411d1cc14326 sms-pdu-decode family: prepare for SC address becoming optional
Mychaela Falconia <falcon@freecalypso.org>
parents: 804
diff changeset
249 process_pdu(require_exact_length, expect_sca)
598
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
250 {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
251 unsigned udl, udl_octets;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
252 unsigned udhl, udh_octets, udh_chars, ud_chars;
802
1c599681fd60 pcm-sms-decode & sms-pdu-decode: revamp bad char decoding
Mychaela Falconia <falcon@freecalypso.org>
parents: 800
diff changeset
253 u_char ud7[160], decode_buf[481];
598
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
254 int do_hexdump;
804
30fbaa652ea5 pcm-sms-decode & sms-pdu-decode: rm remains of bad chars count
Mychaela Falconia <falcon@freecalypso.org>
parents: 802
diff changeset
255 unsigned decoded_len;
598
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
256
960
411d1cc14326 sms-pdu-decode family: prepare for SC address becoming optional
Mychaela Falconia <falcon@freecalypso.org>
parents: 804
diff changeset
257 if (expect_sca) {
411d1cc14326 sms-pdu-decode family: prepare for SC address becoming optional
Mychaela Falconia <falcon@freecalypso.org>
parents: 804
diff changeset
258 if (handle_sca() < 0)
411d1cc14326 sms-pdu-decode family: prepare for SC address becoming optional
Mychaela Falconia <falcon@freecalypso.org>
parents: 804
diff changeset
259 return(-1);
411d1cc14326 sms-pdu-decode family: prepare for SC address becoming optional
Mychaela Falconia <falcon@freecalypso.org>
parents: 804
diff changeset
260 } else
411d1cc14326 sms-pdu-decode family: prepare for SC address becoming optional
Mychaela Falconia <falcon@freecalypso.org>
parents: 804
diff changeset
261 pdu_ptr = 0;
598
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
262 if (handle_first_octet() < 0)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
263 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
264 if (first_octet & 2) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
265 printf("Decode-Error: MTI not supported\n");
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
266 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
267 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
268 if (first_octet & 1) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
269 if (handle_mr() < 0)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
270 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
271 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
272 if (handle_user_addr(first_octet & 1 ? "To" : "From") < 0)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
273 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
274 if (handle_pid() < 0)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
275 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
276 if (handle_dcs() < 0)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
277 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
278 if (first_octet & 1) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
279 if (handle_vp() < 0)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
280 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
281 } else {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
282 if (handle_scts() < 0)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
283 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
284 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
285 if (pdu_ptr >= pdu_length) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
286 printf("Decode-Error: end of PDU before UDL\n");
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
287 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
288 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
289 udl = pdu[pdu_ptr++];
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
290 if (dcs_distilled == 7) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
291 if (udl > 160) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
292 printf("Decode-Error: UDL %u > 160\n", udl);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
293 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
294 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
295 udl_octets = (udl * 7 + 7) / 8;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
296 } else {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
297 if (udl > 140) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
298 printf("Decode-Error: UDL %u > 140\n", udl);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
299 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
300 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
301 udl_octets = udl;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
302 }
599
18bfc10ba20e sms-pdu-decode: more prep for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents: 598
diff changeset
303 if (require_exact_length && pdu_length - pdu_ptr != udl_octets) {
598
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
304 printf("Decode-Error: UD length in PDU %u != expected %u\n",
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
305 pdu_length - pdu_ptr, udl_octets);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
306 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
307 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
308 if (first_octet & 0x40) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
309 if (!udl) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
310 printf("Decode-Error: UDHI set with UDL=0\n");
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
311 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
312 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
313 udhl = pdu[pdu_ptr];
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
314 udh_octets = udhl + 1;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
315 if (udh_octets > udl_octets) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
316 printf("Decode-Error: UDHL exceeds UDL\n");
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
317 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
318 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
319 printf("UDH-Length: %u\n", udhl);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
320 if (dcs_distilled == 7)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
321 udh_chars = (udh_octets * 8 + 6) / 7;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
322 else
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
323 udh_chars = udh_octets;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
324 } else {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
325 udhl = 0;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
326 udh_octets = 0;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
327 udh_chars = 0;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
328 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
329 if (udh_chars >= udl) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
330 ud_chars = 0;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
331 printf("Length: 0\n");
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
332 } else {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
333 ud_chars = udl - udh_chars;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
334 if (dcs_distilled == 7)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
335 gsm7_unpack(pdu + pdu_ptr, ud7, udl);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
336 if (global_hexdump_mode)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
337 do_hexdump = 1;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
338 else switch (dcs_distilled) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
339 case 7:
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
340 do_hexdump = 0;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
341 break;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
342 case 8:
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
343 case 9:
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
344 do_hexdump = 1;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
345 break;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
346 case 16:
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
347 if (ud_chars & 1)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
348 do_hexdump = 1;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
349 else
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
350 do_hexdump = 0;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
351 break;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
352 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
353 if (do_hexdump)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
354 printf("Length: %u (raw)\n", ud_chars);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
355 else {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
356 switch (dcs_distilled) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
357 case 7:
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
358 gsm7_to_ascii_or_ext(ud7 + udh_chars, ud_chars,
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
359 decode_buf, &decoded_len,
804
30fbaa652ea5 pcm-sms-decode & sms-pdu-decode: rm remains of bad chars count
Mychaela Falconia <falcon@freecalypso.org>
parents: 802
diff changeset
360 ascii_ext_mode, 1);
598
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
361 break;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
362 case 16:
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
363 ucs2_to_ascii_or_ext(pdu + pdu_ptr + udh_chars,
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
364 ud_chars,
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
365 decode_buf, &decoded_len,
804
30fbaa652ea5 pcm-sms-decode & sms-pdu-decode: rm remains of bad chars count
Mychaela Falconia <falcon@freecalypso.org>
parents: 802
diff changeset
366 ascii_ext_mode, 1);
598
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
367 break;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
368 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
369 printf("Length: %u", ud_chars);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
370 if (decoded_len != ud_chars)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
371 printf("->%u", decoded_len);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
372 putchar('\n');
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
373 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
374 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
375
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
376 if (udhl) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
377 printf("\nUDH:\n");
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
378 msg_bits_hexdump(pdu + pdu_ptr + 1, udhl);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
379 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
380 if (!ud_chars)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
381 return(0);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
382 putchar('\n');
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
383 if (do_hexdump) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
384 if (dcs_distilled == 7)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
385 msg_bits_hexdump(ud7 + udh_chars, ud_chars);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
386 else
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
387 msg_bits_hexdump(pdu + pdu_ptr + udh_chars, ud_chars);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
388 } else
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
389 puts(decode_buf);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
390 return(0);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
391 }