annotate uptools/sms-pdu-decode/pdu-common.c @ 934:0d6be90ae74f

rvinterf -v TM: send hex dump only to log file if we have one
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 23 May 2023 06:49:10 +0000
parents 30fbaa652ea5
children 411d1cc14326
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;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 printf("VP-Relative: ");
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
599
18bfc10ba20e sms-pdu-decode: more prep for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents: 598
diff changeset
249 process_pdu(require_exact_length)
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
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
257 if (handle_sca() < 0)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
258 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
259 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
260 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
261 if (first_octet & 2) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
262 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
263 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
264 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
265 if (first_octet & 1) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
266 if (handle_mr() < 0)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
267 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
268 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
269 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
270 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
271 if (handle_pid() < 0)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
272 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
273 if (handle_dcs() < 0)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
274 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
275 if (first_octet & 1) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
276 if (handle_vp() < 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 } else {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
279 if (handle_scts() < 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 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
282 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
283 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
284 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
285 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
286 udl = pdu[pdu_ptr++];
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
287 if (dcs_distilled == 7) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
288 if (udl > 160) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
289 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
290 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
291 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
292 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
293 } else {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
294 if (udl > 140) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
295 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
296 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
297 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
298 udl_octets = udl;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
299 }
599
18bfc10ba20e sms-pdu-decode: more prep for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents: 598
diff changeset
300 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
301 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
302 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
303 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
304 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
305 if (first_octet & 0x40) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
306 if (!udl) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
307 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
308 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
309 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
310 udhl = pdu[pdu_ptr];
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
311 udh_octets = udhl + 1;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
312 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
313 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
314 return(-1);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
315 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
316 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
317 if (dcs_distilled == 7)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
318 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
319 else
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
320 udh_chars = udh_octets;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
321 } else {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
322 udhl = 0;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
323 udh_octets = 0;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
324 udh_chars = 0;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
325 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
326 if (udh_chars >= udl) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
327 ud_chars = 0;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
328 printf("Length: 0\n");
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
329 } else {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
330 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
331 if (dcs_distilled == 7)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
332 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
333 if (global_hexdump_mode)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
334 do_hexdump = 1;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
335 else switch (dcs_distilled) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
336 case 7:
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
337 do_hexdump = 0;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
338 break;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
339 case 8:
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
340 case 9:
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
341 do_hexdump = 1;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
342 break;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
343 case 16:
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
344 if (ud_chars & 1)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
345 do_hexdump = 1;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
346 else
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
347 do_hexdump = 0;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
348 break;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
349 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
350 if (do_hexdump)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
351 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
352 else {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
353 switch (dcs_distilled) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
354 case 7:
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
355 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
356 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
357 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
358 break;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
359 case 16:
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
360 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
361 ud_chars,
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
362 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
363 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
364 break;
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
365 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
366 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
367 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
368 printf("->%u", decoded_len);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
369 putchar('\n');
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
370 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
371 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
372
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
373 if (udhl) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
374 printf("\nUDH:\n");
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
375 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
376 }
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
377 if (!ud_chars)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
378 return(0);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
379 putchar('\n');
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
380 if (do_hexdump) {
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
381 if (dcs_distilled == 7)
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
382 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
383 else
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
384 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
385 } else
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
386 puts(decode_buf);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
387 return(0);
9f7a263ad7f0 sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
388 }