FreeCalypso > hg > sms-coding-utils
comparison libcoding/grokdcs.c @ 27:7418ca2e9949
libcoding: add functions from freecalypso-tools/uptools/libcoding
that are needed for sms-pdu-decode & pcm-sms-decode
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 13 Jun 2024 02:29:29 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
26:c8cb05b69118 | 27:7418ca2e9949 |
---|---|
1 /* | |
2 * This library module implements the function that distills the complex | |
3 * set of possible SMS DCS octet values to just one of 4 possibilities: | |
4 * 7-bit text (7), 8-bit data octets (8), UCS-2 text (16) or compressed | |
5 * data (9). | |
6 * | |
7 * The decoding is based on the 3GPP TS 23.038 V11.0.0 spec; | |
8 * reserved encodings are treated as 7-bit text as the spec instructs. | |
9 */ | |
10 | |
11 sms_dcs_classify(dcs) | |
12 { | |
13 if (!(dcs & 0x80)) { | |
14 if (dcs & 0x20) | |
15 return(9); | |
16 switch (dcs & 0xC) { | |
17 case 0: | |
18 return(7); | |
19 case 4: | |
20 return(8); | |
21 case 8: | |
22 return(16); | |
23 default: | |
24 /* reserved, treating as 7-bit per the spec */ | |
25 return(7); | |
26 } | |
27 } | |
28 switch (dcs & 0xF0) { | |
29 case 0x80: | |
30 case 0x90: | |
31 case 0xA0: | |
32 case 0xB0: | |
33 /* reserved, treating as 7-bit per the spec */ | |
34 return(7); | |
35 case 0xC0: | |
36 case 0xD0: | |
37 return(7); | |
38 case 0xE0: | |
39 return(16); | |
40 case 0xF0: | |
41 if (dcs & 4) | |
42 return(8); | |
43 else | |
44 return(7); | |
45 } | |
46 } |