2
|
1 /*
|
|
2 * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
|
|
3 * Universitaet Berlin. See the accompanying file "COPYRIGHT" for
|
|
4 * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
|
|
5 */
|
|
6
|
|
7 /* $Header: /home/kbs/jutta/src/gsm/gsm-1.0/src/RCS/gsm_explode.c,v 1.1 1992/10/28 00:15:50 jutta Exp $ */
|
|
8
|
|
9 #include "private.h"
|
|
10 #include "gsm.h"
|
|
11 #include "proto.h"
|
|
12
|
|
13 int gsm_explode P3((s, c, target), gsm s, gsm_byte * c,
|
|
14 gsm_signal * target)
|
|
15 {
|
|
16 /* GSM_MAGIC = (*c >> 4) & 0xF; */
|
|
17
|
|
18 if (((*c >> 4) & 0x0F) != GSM_MAGIC)
|
|
19 return -1;
|
|
20
|
|
21 #define LARc target
|
|
22
|
|
23 LARc[0] = (*c++ & 0xF) << 2; /* 1 */
|
|
24 LARc[0] |= (*c >> 6) & 0x3;
|
|
25 LARc[1] = *c++ & 0x3F;
|
|
26 LARc[2] = (*c >> 3) & 0x1F;
|
|
27 LARc[3] = (*c++ & 0x7) << 2;
|
|
28 LARc[3] |= (*c >> 6) & 0x3;
|
|
29 LARc[4] = (*c >> 2) & 0xF;
|
|
30 LARc[5] = (*c++ & 0x3) << 2;
|
|
31 LARc[5] |= (*c >> 6) & 0x3;
|
|
32 LARc[6] = (*c >> 3) & 0x7;
|
|
33 LARc[7] = *c++ & 0x7;
|
|
34
|
|
35 #define Nc (target + 8)
|
|
36
|
|
37 Nc[0] = (*c >> 1) & 0x7F;
|
|
38
|
|
39 #define bc (target + 9)
|
|
40
|
|
41 bc[0] = (*c++ & 0x1) << 1;
|
|
42 bc[0] |= (*c >> 7) & 0x1;
|
|
43
|
|
44 #define Mc (target + 10)
|
|
45
|
|
46 Mc[0] = (*c >> 5) & 0x3;
|
|
47
|
|
48 #define xmaxc (target + 11)
|
|
49
|
|
50 xmaxc[0] = (*c++ & 0x1F) << 1;
|
|
51 xmaxc[0] |= (*c >> 7) & 0x1;
|
|
52
|
|
53 #define xmc (target + 12)
|
|
54
|
|
55 xmc[0] = (*c >> 4) & 0x7;
|
|
56 xmc[1] = (*c >> 1) & 0x7;
|
|
57 xmc[2] = (*c++ & 0x1) << 2;
|
|
58 xmc[2] |= (*c >> 6) & 0x3;
|
|
59 xmc[3] = (*c >> 3) & 0x7;
|
|
60 xmc[4] = *c++ & 0x7;
|
|
61 xmc[5] = (*c >> 5) & 0x7;
|
|
62 xmc[6] = (*c >> 2) & 0x7;
|
|
63 xmc[7] = (*c++ & 0x3) << 1; /* 10 */
|
|
64 xmc[7] |= (*c >> 7) & 0x1;
|
|
65 xmc[8] = (*c >> 4) & 0x7;
|
|
66 xmc[9] = (*c >> 1) & 0x7;
|
|
67 xmc[10] = (*c++ & 0x1) << 2;
|
|
68 xmc[10] |= (*c >> 6) & 0x3;
|
|
69 xmc[11] = (*c >> 3) & 0x7;
|
|
70 xmc[12] = *c++ & 0x7;
|
|
71
|
|
72 #undef Nc
|
|
73 #define Nc (target + 25 - 1)
|
|
74
|
|
75 Nc[1] = (*c >> 1) & 0x7F;
|
|
76
|
|
77 #undef bc
|
|
78 #define bc (target + 26 - 1)
|
|
79
|
|
80 bc[1] = (*c++ & 0x1) << 1;
|
|
81 bc[1] |= (*c >> 7) & 0x1;
|
|
82
|
|
83 #undef Mc
|
|
84 #define Mc (target + 27 - 1)
|
|
85
|
|
86 Mc[1] = (*c >> 5) & 0x3;
|
|
87
|
|
88 #undef xmaxc
|
|
89 #define xmaxc (target + 28 - 1)
|
|
90
|
|
91 xmaxc[1] = (*c++ & 0x1F) << 1;
|
|
92 xmaxc[1] |= (*c >> 7) & 0x1;
|
|
93
|
|
94 #undef xmc
|
|
95 #define xmc (target + 29 - 13)
|
|
96
|
|
97 xmc[13] = (*c >> 4) & 0x7;
|
|
98 xmc[14] = (*c >> 1) & 0x7;
|
|
99 xmc[15] = (*c++ & 0x1) << 2;
|
|
100 xmc[15] |= (*c >> 6) & 0x3;
|
|
101 xmc[16] = (*c >> 3) & 0x7;
|
|
102 xmc[17] = *c++ & 0x7;
|
|
103 xmc[18] = (*c >> 5) & 0x7;
|
|
104 xmc[19] = (*c >> 2) & 0x7;
|
|
105 xmc[20] = (*c++ & 0x3) << 1;
|
|
106 xmc[20] |= (*c >> 7) & 0x1;
|
|
107 xmc[21] = (*c >> 4) & 0x7;
|
|
108 xmc[22] = (*c >> 1) & 0x7;
|
|
109 xmc[23] = (*c++ & 0x1) << 2;
|
|
110 xmc[23] |= (*c >> 6) & 0x3;
|
|
111 xmc[24] = (*c >> 3) & 0x7;
|
|
112 xmc[25] = *c++ & 0x7;
|
|
113
|
|
114 #undef Nc
|
|
115 #define Nc (target + 42 - 2)
|
|
116
|
|
117 Nc[2] = (*c >> 1) & 0x7F;
|
|
118
|
|
119 #undef bc
|
|
120 #define bc (target + 43 - 2)
|
|
121
|
|
122 bc[2] = (*c++ & 0x1) << 1; /* 20 */
|
|
123 bc[2] |= (*c >> 7) & 0x1;
|
|
124
|
|
125 #undef Mc
|
|
126 #define Mc (target + 44 - 2)
|
|
127
|
|
128 Mc[2] = (*c >> 5) & 0x3;
|
|
129
|
|
130 #undef xmaxc
|
|
131 #define xmaxc (target + 45 - 2)
|
|
132
|
|
133 xmaxc[2] = (*c++ & 0x1F) << 1;
|
|
134 xmaxc[2] |= (*c >> 7) & 0x1;
|
|
135
|
|
136 #undef xmc
|
|
137 #define xmc (target + 46 - 26)
|
|
138
|
|
139 xmc[26] = (*c >> 4) & 0x7;
|
|
140 xmc[27] = (*c >> 1) & 0x7;
|
|
141 xmc[28] = (*c++ & 0x1) << 2;
|
|
142 xmc[28] |= (*c >> 6) & 0x3;
|
|
143 xmc[29] = (*c >> 3) & 0x7;
|
|
144 xmc[30] = *c++ & 0x7;
|
|
145 xmc[31] = (*c >> 5) & 0x7;
|
|
146 xmc[32] = (*c >> 2) & 0x7;
|
|
147 xmc[33] = (*c++ & 0x3) << 1;
|
|
148 xmc[33] |= (*c >> 7) & 0x1;
|
|
149 xmc[34] = (*c >> 4) & 0x7;
|
|
150 xmc[35] = (*c >> 1) & 0x7;
|
|
151 xmc[36] = (*c++ & 0x1) << 2;
|
|
152 xmc[36] |= (*c >> 6) & 0x3;
|
|
153 xmc[37] = (*c >> 3) & 0x7;
|
|
154 xmc[38] = *c++ & 0x7;
|
|
155
|
|
156 #undef Nc
|
|
157 #define Nc (target + 59 - 3)
|
|
158
|
|
159 Nc[3] = (*c >> 1) & 0x7F;
|
|
160
|
|
161 #undef bc
|
|
162 #define bc (target + 60 - 3)
|
|
163
|
|
164 bc[3] = (*c++ & 0x1) << 1;
|
|
165 bc[3] |= (*c >> 7) & 0x1;
|
|
166
|
|
167 #undef Mc
|
|
168 #define Mc (target + 61 - 3)
|
|
169
|
|
170 Mc[3] = (*c >> 5) & 0x3;
|
|
171
|
|
172 #undef xmaxc
|
|
173 #define xmaxc (target + 62 - 3)
|
|
174
|
|
175 xmaxc[3] = (*c++ & 0x1F) << 1;
|
|
176 xmaxc[3] |= (*c >> 7) & 0x1;
|
|
177
|
|
178 #undef xmc
|
|
179 #define xmc (target + 63 - 39)
|
|
180
|
|
181 xmc[39] = (*c >> 4) & 0x7;
|
|
182 xmc[40] = (*c >> 1) & 0x7;
|
|
183 xmc[41] = (*c++ & 0x1) << 2;
|
|
184 xmc[41] |= (*c >> 6) & 0x3;
|
|
185 xmc[42] = (*c >> 3) & 0x7;
|
|
186 xmc[43] = *c++ & 0x7; /* 30 */
|
|
187 xmc[44] = (*c >> 5) & 0x7;
|
|
188 xmc[45] = (*c >> 2) & 0x7;
|
|
189 xmc[46] = (*c++ & 0x3) << 1;
|
|
190 xmc[46] |= (*c >> 7) & 0x1;
|
|
191 xmc[47] = (*c >> 4) & 0x7;
|
|
192 xmc[48] = (*c >> 1) & 0x7;
|
|
193 xmc[49] = (*c++ & 0x1) << 2;
|
|
194 xmc[49] |= (*c >> 6) & 0x3;
|
|
195 xmc[50] = (*c >> 3) & 0x7;
|
|
196 xmc[51] = *c & 0x7; /* 33 */
|
|
197
|
|
198 return 0;
|
|
199 }
|