FreeCalypso > hg > freecalypso-tools
annotate uptools/sms-pdu-decode/pdu-common.c @ 666:51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 07 Mar 2020 19:28:09 +0000 |
parents | 18bfc10ba20e |
children | 8dc93aac9a9c |
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]; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 u_char alpha_gsm7[11], alpha_decoded[23]; |
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); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 gsm7_to_ascii_or_ext(alpha_gsm7, alpha_nsep, alpha_decoded, |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 (unsigned *) 0, ascii_ext_mode, 0, |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 (unsigned *) 0); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 printf("%s: \"%s\" (type 0x%02X)\n", direction, alpha_decoded, |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 pdu[pdu_ptr+1]); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 } else { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 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
|
101 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
|
102 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
|
103 pdu[pdu_ptr+1]); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 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
|
106 return(0); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 static |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 handle_pid() |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 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
|
113 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
|
114 return(-1); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 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
|
117 return(0); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 static |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 handle_dcs() |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 u_char dcs; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 char *strtype; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 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
|
127 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
|
128 return(-1); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 dcs = pdu[pdu_ptr++]; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 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
|
132 switch (dcs_distilled) { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 case 7: |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 strtype = "7-bit"; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 break; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 case 8: |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 strtype = "raw octets"; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 break; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 case 9: |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 strtype = "compressed"; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 break; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 case 16: |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 strtype = "UCS-2"; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 break; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 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
|
147 return(0); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 static |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 handle_scts() |
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 char str[21]; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 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
|
156 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
|
157 return(-1); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 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
|
160 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
|
161 pdu_ptr += 7; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 return(0); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 static |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 handle_vp_abs() |
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 char str[21]; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 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
|
171 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
|
172 return(-1); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 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
|
175 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
|
176 pdu_ptr += 7; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 return(0); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 static |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 handle_vp_rel() |
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 unsigned vprel, hours, min; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 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
|
186 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
|
187 return(-1); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 vprel = pdu[pdu_ptr++]; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 if (vprel <= 143) { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 min = (vprel + 1) * 5; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 goto hhmm; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 } else if (vprel <= 167) { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 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
|
195 goto hhmm; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 } else if (vprel <= 196) { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 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
|
198 return(0); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 } else { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 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
|
201 return(0); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 hhmm: hours = min / 60; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 min %= 60; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 printf("VP-Relative: "); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 if (hours) |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 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
|
209 if (min) |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 printf(" %u min", min); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 putchar('\n'); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 return(0); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 static |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 handle_vp_enh() |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 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
|
219 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
|
220 return(-1); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 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
|
223 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
|
224 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
|
225 pdu_ptr += 7; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 return(0); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 static |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 handle_vp() |
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 int rc; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 switch (first_octet & 0x18) { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 case 0x00: |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 rc = 0; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 break; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 case 0x08: |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 rc = handle_vp_enh(); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 break; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 case 0x10: |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 rc = handle_vp_rel(); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 break; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 case 0x18: |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 rc = handle_vp_abs(); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 break; |
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 return(rc); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 |
599
18bfc10ba20e
sms-pdu-decode: more prep for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
598
diff
changeset
|
251 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
|
252 { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 unsigned udl, udl_octets; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 unsigned udhl, udh_octets, udh_chars, ud_chars; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 u_char ud7[160], decode_buf[321]; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 int do_hexdump; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 unsigned decoded_len, badchars; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 if (handle_sca() < 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 (handle_first_octet() < 0) |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 return(-1); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 if (first_octet & 2) { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 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
|
265 return(-1); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 if (first_octet & 1) { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 if (handle_mr() < 0) |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 return(-1); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 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
|
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_pid() < 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 (handle_dcs() < 0) |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 return(-1); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 if (first_octet & 1) { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 if (handle_vp() < 0) |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 return(-1); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 } else { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 if (handle_scts() < 0) |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 return(-1); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 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
|
285 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
|
286 return(-1); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 udl = pdu[pdu_ptr++]; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 if (dcs_distilled == 7) { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 if (udl > 160) { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 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
|
292 return(-1); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 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
|
295 } else { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 if (udl > 140) { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 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
|
298 return(-1); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 udl_octets = udl; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 } |
599
18bfc10ba20e
sms-pdu-decode: more prep for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
598
diff
changeset
|
302 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
|
303 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
|
304 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
|
305 return(-1); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
306 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 if (first_octet & 0x40) { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 if (!udl) { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 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
|
310 return(-1); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
312 udhl = pdu[pdu_ptr]; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 udh_octets = udhl + 1; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
314 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
|
315 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
|
316 return(-1); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 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
|
319 if (dcs_distilled == 7) |
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 * 8 + 6) / 7; |
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 udh_chars = udh_octets; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 } else { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 udhl = 0; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 udh_octets = 0; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 udh_chars = 0; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
328 if (udh_chars >= udl) { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
329 ud_chars = 0; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
330 printf("Length: 0\n"); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
331 } else { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
332 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
|
333 if (dcs_distilled == 7) |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
334 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
|
335 if (global_hexdump_mode) |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
336 do_hexdump = 1; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
337 else switch (dcs_distilled) { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
338 case 7: |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
339 do_hexdump = 0; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
340 break; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
341 case 8: |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
342 case 9: |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
343 do_hexdump = 1; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
344 break; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
345 case 16: |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
346 if (ud_chars & 1) |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
347 do_hexdump = 1; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
348 else |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
349 do_hexdump = 0; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
350 break; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
351 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
352 if (do_hexdump) |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
353 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
|
354 else { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
355 switch (dcs_distilled) { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
356 case 7: |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
357 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
|
358 decode_buf, &decoded_len, |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
359 ascii_ext_mode, 1, |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
360 &badchars); |
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, |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
366 ascii_ext_mode, 1, |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
367 &badchars); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
368 break; |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
369 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
370 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
|
371 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
|
372 printf("->%u", decoded_len); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
373 if (badchars) |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
374 printf(" (%u bad char%s)", badchars, |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
375 badchars != 1 ? "s" : ""); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
376 putchar('\n'); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
377 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
378 } |
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 (udhl) { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
381 printf("\nUDH:\n"); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
382 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
|
383 } |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
384 if (!ud_chars) |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
385 return(0); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
386 putchar('\n'); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
387 if (do_hexdump) { |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
388 if (dcs_distilled == 7) |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
389 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
|
390 else |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
391 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
|
392 } else |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
393 puts(decode_buf); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
394 return(0); |
9f7a263ad7f0
sms-pdu-decode split in preparation for pcm-sms-decode addition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
395 } |