blob: c052e4c8d578b2afaf6aacf6ec566ae960c9c714 [file] [log] [blame]
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02001/*! \file gsm_04_08.h
2 * GSM TS 04.08 definitions. */
3
Sylvain Munaut12ba7782014-06-16 10:13:40 +02004#pragma once
Harald Welteec8b4502010-02-20 20:34:29 +01005
6#include <stdint.h>
Maxfe65fa72016-05-10 17:17:05 +02007#include <stdbool.h>
Harald Welteec8b4502010-02-20 20:34:29 +01008
Maxfb348ee2016-03-30 21:14:53 +02009#include <osmocom/core/utils.h>
Ruben Undheim720ac4a2016-05-27 22:03:59 +020010#include <osmocom/core/endian.h>
11
Harald Welteec8b4502010-02-20 20:34:29 +010012struct gsm_lchan;
13
Andreas Eversberg014cb872010-07-12 09:11:00 +020014/* Chapter 10.5.1.5 */
Harald Welteec8b4502010-02-20 20:34:29 +010015struct gsm48_classmark1 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +010016#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +020017 uint8_t pwr_lev:3,
Harald Welteec8b4502010-02-20 20:34:29 +010018 a5_1:1,
Andreas Eversberg014cb872010-07-12 09:11:00 +020019 es_ind:1,
20 rev_lev:2,
21 spare:1;
Neels Hofmeyrb2600392018-11-16 00:20:39 +010022#elif OSMO_IS_BIG_ENDIAN
23/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
24 uint8_t spare:1, rev_lev:2, es_ind:1, a5_1:1, pwr_lev:3;
25#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +020026} __attribute__ ((packed));
27
28/* Chapter 10.5.1.6 */
29struct gsm48_classmark2 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +010030#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +020031 uint8_t pwr_lev:3,
32 a5_1:1,
33 es_ind:1,
34 rev_lev:2,
35 spare:1;
36 uint8_t fc:1,
37 vgcs:1,
38 vbs:1,
39 sm_cap:1,
40 ss_scr:2,
41 ps_cap:1,
42 spare2:1;
43 uint8_t a5_2:1,
44 a5_3:1,
45 cmsp:1,
46 solsa:1,
47 spare3:1,
48 lcsva_cap:1,
49 spare4:1,
50 cm3:1;
Neels Hofmeyrb2600392018-11-16 00:20:39 +010051#elif OSMO_IS_BIG_ENDIAN
52/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
53 uint8_t spare:1, rev_lev:2, es_ind:1, a5_1:1, pwr_lev:3;
54 uint8_t spare2:1, ps_cap:1, ss_scr:2, sm_cap:1, vbs:1, vgcs:1, fc:1;
55 uint8_t cm3:1, spare4:1, lcsva_cap:1, spare3:1, solsa:1, cmsp:1, a5_3:1, a5_2:1;
56#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +020057} __attribute__ ((packed));
58
Neels Hofmeyr7740d262019-01-16 16:53:26 +010059struct osmo_gsm48_classmark {
60 bool classmark1_set;
61 struct gsm48_classmark1 classmark1;
62 uint8_t classmark2_len;
63 struct gsm48_classmark2 classmark2;
64 uint8_t classmark3_len;
65 uint8_t classmark3[14]; /* if cm3 gets extended by spec, it will be truncated */
66};
67
68bool osmo_gsm48_classmark_is_r99(const struct osmo_gsm48_classmark *cm);
69bool osmo_gsm48_classmark1_is_r99(const struct gsm48_classmark1 *cm1);
70bool osmo_gsm48_classmark2_is_r99(const struct gsm48_classmark2 *cm2, uint8_t cm2_len);
71int osmo_gsm48_classmark_supports_a5(const struct osmo_gsm48_classmark *cm, uint8_t a5);
72const char *osmo_gsm48_classmark_a5_name(const struct osmo_gsm48_classmark *cm);
73void osmo_gsm48_classmark_update(struct osmo_gsm48_classmark *dst, const struct osmo_gsm48_classmark *src);
74
Andreas Eversberg014cb872010-07-12 09:11:00 +020075/* Chapter 10.5.2.1b.3 */
Ruben Undheim720ac4a2016-05-27 22:03:59 +020076#if OSMO_IS_LITTLE_ENDIAN == 1
Andreas Eversberg014cb872010-07-12 09:11:00 +020077struct gsm48_range_1024 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +010078#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +020079 uint8_t w1_hi:2,
80 f0:1,
81 form_id:5;
82 uint8_t w1_lo;
83 uint8_t w2_hi;
84 uint8_t w3_hi:7,
85 w2_lo:1;
86 uint8_t w4_hi:6,
87 w3_lo:2;
88 uint8_t w5_hi:6,
89 w4_lo:2;
90 uint8_t w6_hi:6,
91 w5_lo:2;
92 uint8_t w7_hi:6,
93 w6_lo:2;
94 uint8_t w8_hi:6,
95 w7_lo:2;
96 uint8_t w9:7,
97 w8_lo:1;
98 uint8_t w11_hi:1,
99 w10:7;
100 uint8_t w12_hi:2,
101 w11_lo:6;
102 uint8_t w13_hi:3,
103 w12_lo:5;
104 uint8_t w14_hi:4,
105 w13_lo:4;
106 uint8_t w15_hi:5,
107 w14_lo:3;
108 uint8_t w16:6,
109 w15_lo:2;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100110#elif OSMO_IS_BIG_ENDIAN
111/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
112 uint8_t form_id:5, f0:1, w1_hi:2;
113 uint8_t w1_lo;
114 uint8_t w2_hi;
115 uint8_t w2_lo:1, w3_hi:7;
116 uint8_t w3_lo:2, w4_hi:6;
117 uint8_t w4_lo:2, w5_hi:6;
118 uint8_t w5_lo:2, w6_hi:6;
119 uint8_t w6_lo:2, w7_hi:6;
120 uint8_t w7_lo:2, w8_hi:6;
121 uint8_t w8_lo:1, w9:7;
122 uint8_t w10:7, w11_hi:1;
123 uint8_t w11_lo:6, w12_hi:2;
124 uint8_t w12_lo:5, w13_hi:3;
125 uint8_t w13_lo:4, w14_hi:4;
126 uint8_t w14_lo:3, w15_hi:5;
127 uint8_t w15_lo:2, w16:6;
128#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200129} __attribute__ ((packed));
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200130#else
131struct gsm48_range_1024 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100132#if OSMO_IS_LITTLE_ENDIAN
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200133 uint8_t form_id:5,
134 f0:1,
135 w1_hi:2;
136 uint8_t w1_lo;
137 uint8_t w2_hi;
138 uint8_t w2_lo:1,
139 w3_hi:7;
140 uint8_t w3_lo:2,
141 w4_hi:6;
142 uint8_t w4_lo:2,
143 w5_hi:6;
144 uint8_t w5_lo:2,
145 w6_hi:6;
146 uint8_t w6_lo:2,
147 w7_hi:6;
148 uint8_t w7_lo:2,
149 w8_hi:6;
150 uint8_t w8_lo:1,
151 w9:7;
152 uint8_t w10:7,
153 w11_hi:1;
154 uint8_t w11_lo:6,
155 w12_hi:2;
156 uint8_t w12_lo:5,
157 w13_hi:3;
158 uint8_t w13_lo:4,
159 w14_hi:4;
160 uint8_t w14_lo:3,
161 w15_hi:5;
162 uint8_t w15_lo:2,
163 w16:6;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100164#elif OSMO_IS_BIG_ENDIAN
165/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
166 uint8_t w1_hi:2, f0:1, form_id:5;
167 uint8_t w1_lo;
168 uint8_t w2_hi;
169 uint8_t w3_hi:7, w2_lo:1;
170 uint8_t w4_hi:6, w3_lo:2;
171 uint8_t w5_hi:6, w4_lo:2;
172 uint8_t w6_hi:6, w5_lo:2;
173 uint8_t w7_hi:6, w6_lo:2;
174 uint8_t w8_hi:6, w7_lo:2;
175 uint8_t w9:7, w8_lo:1;
176 uint8_t w11_hi:1, w10:7;
177 uint8_t w12_hi:2, w11_lo:6;
178 uint8_t w13_hi:3, w12_lo:5;
179 uint8_t w14_hi:4, w13_lo:4;
180 uint8_t w15_hi:5, w14_lo:3;
181 uint8_t w16:6, w15_lo:2;
182#endif
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200183} __attribute__ ((packed));
184#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200185
186/* Chapter 10.5.2.1b.4 */
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200187#if OSMO_IS_LITTLE_ENDIAN == 1
Andreas Eversberg014cb872010-07-12 09:11:00 +0200188struct gsm48_range_512 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100189#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +0200190 uint8_t orig_arfcn_hi:1,
191 form_id:7;
192 uint8_t orig_arfcn_mid;
193 uint8_t w1_hi:7,
194 orig_arfcn_lo:1;
195 uint8_t w2_hi:6,
196 w1_lo:2;
197 uint8_t w3_hi:6,
198 w2_lo:2;
199 uint8_t w4_hi:6,
200 w3_lo:2;
201 uint8_t w5:7,
202 w4_lo:1;
203 uint8_t w7_hi:1,
204 w6:7;
205 uint8_t w8_hi:2,
206 w7_lo:6;
207 uint8_t w9_hi:4,
208 w8_lo:4;
209 uint8_t w10:6,
210 w9_lo:2;
211 uint8_t w12_hi:2,
212 w11:6;
213 uint8_t w13_hi:4,
214 w12_lo:4;
215 uint8_t w14:6,
216 w13_lo:2;
217 uint8_t w16_hi:2,
218 w15:6;
219 uint8_t w17:5,
220 w16_lo:3;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100221#elif OSMO_IS_BIG_ENDIAN
222/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
223 uint8_t form_id:7, orig_arfcn_hi:1;
224 uint8_t orig_arfcn_mid;
225 uint8_t orig_arfcn_lo:1, w1_hi:7;
226 uint8_t w1_lo:2, w2_hi:6;
227 uint8_t w2_lo:2, w3_hi:6;
228 uint8_t w3_lo:2, w4_hi:6;
229 uint8_t w4_lo:1, w5:7;
230 uint8_t w6:7, w7_hi:1;
231 uint8_t w7_lo:6, w8_hi:2;
232 uint8_t w8_lo:4, w9_hi:4;
233 uint8_t w9_lo:2, w10:6;
234 uint8_t w11:6, w12_hi:2;
235 uint8_t w12_lo:4, w13_hi:4;
236 uint8_t w13_lo:2, w14:6;
237 uint8_t w15:6, w16_hi:2;
238 uint8_t w16_lo:3, w17:5;
239#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200240} __attribute__ ((packed));
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200241#else
242struct gsm48_range_512 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100243#if OSMO_IS_LITTLE_ENDIAN
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200244 uint8_t form_id:7,
245 orig_arfcn_hi:1;
246 uint8_t orig_arfcn_mid;
247 uint8_t orig_arfcn_lo:1,
248 w1_hi:7;
249 uint8_t w1_lo:2,
250 w2_hi:6;
251 uint8_t w2_lo:2,
252 w3_hi:6;
253 uint8_t w3_lo:2,
254 w4_hi:6;
255 uint8_t w4_lo:1,
256 w5:7;
257 uint8_t w6:7,
258 w7_hi:1;
259 uint8_t w7_lo:6,
260 w8_hi:2;
261 uint8_t w8_lo:4,
262 w9_hi:4;
263 uint8_t w9_lo:2,
264 w10:6;
265 uint8_t w11:6,
266 w12_hi:2;
267 uint8_t w12_lo:4,
268 w13_hi:4;
269 uint8_t w13_lo:2,
270 w14:6;
271 uint8_t w15:6,
272 w16_hi:2;
273 uint8_t w16_lo:3,
274 w17:5;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100275#elif OSMO_IS_BIG_ENDIAN
276/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
277 uint8_t orig_arfcn_hi:1, form_id:7;
278 uint8_t orig_arfcn_mid;
279 uint8_t w1_hi:7, orig_arfcn_lo:1;
280 uint8_t w2_hi:6, w1_lo:2;
281 uint8_t w3_hi:6, w2_lo:2;
282 uint8_t w4_hi:6, w3_lo:2;
283 uint8_t w5:7, w4_lo:1;
284 uint8_t w7_hi:1, w6:7;
285 uint8_t w8_hi:2, w7_lo:6;
286 uint8_t w9_hi:4, w8_lo:4;
287 uint8_t w10:6, w9_lo:2;
288 uint8_t w12_hi:2, w11:6;
289 uint8_t w13_hi:4, w12_lo:4;
290 uint8_t w14:6, w13_lo:2;
291 uint8_t w16_hi:2, w15:6;
292 uint8_t w17:5, w16_lo:3;
293#endif
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200294} __attribute__ ((packed));
295#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200296
297/* Chapter 10.5.2.1b.5 */
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200298#if OSMO_IS_LITTLE_ENDIAN == 1
Andreas Eversberg014cb872010-07-12 09:11:00 +0200299struct gsm48_range_256 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100300#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +0200301 uint8_t orig_arfcn_hi:1,
302 form_id:7;
303 uint8_t orig_arfcn_mid;
304 uint8_t w1_hi:7,
305 orig_arfcn_lo:1;
306 uint8_t w2:7,
307 w1_lo:1;
308 uint8_t w4_hi:1,
309 w3:7;
310 uint8_t w5_hi:3,
311 w4_lo:5;
312 uint8_t w6_hi:5,
313 w5_lo:3;
314 uint8_t w8_hi:1,
315 w7:6,
316 w6_lo:1;
317 uint8_t w9_hi:4,
318 w8_lo:4;
319 uint8_t w11_hi:2,
320 w10:5,
321 w9_lo:1;
322 uint8_t w12:5,
323 w11_lo:3;
324 uint8_t w14_hi:3,
325 w13:5;
326 uint8_t w16_hi:1,
327 w15:5,
328 w14_lo:2;
329 uint8_t w18_hi:1,
330 w17:4,
331 w16_lo:3;
332 uint8_t w20_hi:1,
333 w19:4,
334 w18_lo:3;
335 uint8_t spare:1,
336 w21:4,
337 w20_lo:3;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100338#elif OSMO_IS_BIG_ENDIAN
339/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
340 uint8_t form_id:7, orig_arfcn_hi:1;
341 uint8_t orig_arfcn_mid;
342 uint8_t orig_arfcn_lo:1, w1_hi:7;
343 uint8_t w1_lo:1, w2:7;
344 uint8_t w3:7, w4_hi:1;
345 uint8_t w4_lo:5, w5_hi:3;
346 uint8_t w5_lo:3, w6_hi:5;
347 uint8_t w6_lo:1, w7:6, w8_hi:1;
348 uint8_t w8_lo:4, w9_hi:4;
349 uint8_t w9_lo:1, w10:5, w11_hi:2;
350 uint8_t w11_lo:3, w12:5;
351 uint8_t w13:5, w14_hi:3;
352 uint8_t w14_lo:2, w15:5, w16_hi:1;
353 uint8_t w16_lo:3, w17:4, w18_hi:1;
354 uint8_t w18_lo:3, w19:4, w20_hi:1;
355 uint8_t w20_lo:3, w21:4, spare:1;
356#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200357} __attribute__ ((packed));
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200358#else
359struct gsm48_range_256 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100360#if OSMO_IS_LITTLE_ENDIAN
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200361 uint8_t form_id:7,
362 orig_arfcn_hi:1;
363 uint8_t orig_arfcn_mid;
364 uint8_t orig_arfcn_lo:1,
365 w1_hi:7;
366 uint8_t w1_lo:1,
367 w2:7;
368 uint8_t w3:7,
369 w4_hi:1;
370 uint8_t w4_lo:5,
371 w5_hi:3;
372 uint8_t w5_lo:3,
373 w6_hi:5;
374 uint8_t w6_lo:1,
375 w7:6,
376 w8_hi:1;
377 uint8_t w8_lo:4,
378 w9_hi:4;
379 uint8_t w9_lo:1,
380 w10:5,
381 w11_hi:2;
382 uint8_t w11_lo:3,
383 w12:5;
384 uint8_t w13:5,
385 w14_hi:3;
386 uint8_t w14_lo:2,
387 w15:5,
388 w16_hi:1;
389 uint8_t w16_lo:3,
390 w17:4,
391 w18_hi:1;
392 uint8_t w18_lo:3,
393 w19:4,
394 w20_hi:1;
395 uint8_t w20_lo:3,
396 w21:4,
397 spare:1;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100398#elif OSMO_IS_BIG_ENDIAN
399/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
400 uint8_t orig_arfcn_hi:1, form_id:7;
401 uint8_t orig_arfcn_mid;
402 uint8_t w1_hi:7, orig_arfcn_lo:1;
403 uint8_t w2:7, w1_lo:1;
404 uint8_t w4_hi:1, w3:7;
405 uint8_t w5_hi:3, w4_lo:5;
406 uint8_t w6_hi:5, w5_lo:3;
407 uint8_t w8_hi:1, w7:6, w6_lo:1;
408 uint8_t w9_hi:4, w8_lo:4;
409 uint8_t w11_hi:2, w10:5, w9_lo:1;
410 uint8_t w12:5, w11_lo:3;
411 uint8_t w14_hi:3, w13:5;
412 uint8_t w16_hi:1, w15:5, w14_lo:2;
413 uint8_t w18_hi:1, w17:4, w16_lo:3;
414 uint8_t w20_hi:1, w19:4, w18_lo:3;
415 uint8_t spare:1, w21:4, w20_lo:3;
416#endif
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200417} __attribute__ ((packed));
418#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200419
420/* Chapter 10.5.2.1b.6 */
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200421#if OSMO_IS_LITTLE_ENDIAN == 1
Andreas Eversberg014cb872010-07-12 09:11:00 +0200422struct gsm48_range_128 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100423#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +0200424 uint8_t orig_arfcn_hi:1,
425 form_id:7;
426 uint8_t orig_arfcn_mid;
427 uint8_t w1:7,
428 orig_arfcn_lo:1;
429 uint8_t w3_hi:2,
430 w2:6;
431 uint8_t w4_hi:4,
432 w3_lo:4;
433 uint8_t w6_hi:2,
434 w5:5,
435 w4_lo:1;
436 uint8_t w7:5,
437 w6_lo:3;
438 uint8_t w9:4,
439 w8:4;
440 uint8_t w11:4,
441 w10:4;
442 uint8_t w13:4,
443 w12:4;
444 uint8_t w15:4,
445 w14:4;
446 uint8_t w18_hi:2,
447 w17:3,
448 w16:3;
449 uint8_t w21_hi:1,
450 w20:3,
451 w19:3,
452 w18_lo:1;
453 uint8_t w23:3,
454 w22:3,
455 w21_lo:2;
456 uint8_t w26_hi:2,
457 w25:3,
458 w24:3;
459 uint8_t spare:1,
460 w28:3,
461 w27:3,
462 w26_lo:1;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100463#elif OSMO_IS_BIG_ENDIAN
464/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
465 uint8_t form_id:7, orig_arfcn_hi:1;
466 uint8_t orig_arfcn_mid;
467 uint8_t orig_arfcn_lo:1, w1:7;
468 uint8_t w2:6, w3_hi:2;
469 uint8_t w3_lo:4, w4_hi:4;
470 uint8_t w4_lo:1, w5:5, w6_hi:2;
471 uint8_t w6_lo:3, w7:5;
472 uint8_t w8:4, w9:4;
473 uint8_t w10:4, w11:4;
474 uint8_t w12:4, w13:4;
475 uint8_t w14:4, w15:4;
476 uint8_t w16:3, w17:3, w18_hi:2;
477 uint8_t w18_lo:1, w19:3, w20:3, w21_hi:1;
478 uint8_t w21_lo:2, w22:3, w23:3;
479 uint8_t w24:3, w25:3, w26_hi:2;
480 uint8_t w26_lo:1, w27:3, w28:3, spare:1;
481#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200482} __attribute__ ((packed));
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200483#else
484struct gsm48_range_128 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100485#if OSMO_IS_LITTLE_ENDIAN
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200486 uint8_t form_id:7,
487 orig_arfcn_hi:1;
488 uint8_t orig_arfcn_mid;
489 uint8_t orig_arfcn_lo:1,
490 w1:7;
491 uint8_t w2:6,
492 w3_hi:2;
493 uint8_t w3_lo:4,
494 w4_hi:4;
495 uint8_t w4_lo:1,
496 w5:5,
497 w6_hi:2;
498 uint8_t w6_lo:3,
499 w7:5;
500 uint8_t w8:4,
501 w9:4;
502 uint8_t w10:4,
503 w11:4;
504 uint8_t w12:4,
505 w13:4;
506 uint8_t w14:4,
507 w15:4;
508 uint8_t w16:3,
509 w17:3,
510 w18_hi:2;
511 uint8_t w18_lo:1,
512 w19:3,
513 w20:3,
514 w21_hi:1;
515 uint8_t w21_lo:2,
516 w22:3,
517 w23:3;
518 uint8_t w24:3,
519 w25:3,
520 w26_hi:2;
521 uint8_t w26_lo:1,
522 w27:3,
523 w28:3,
524 spare:1;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100525#elif OSMO_IS_BIG_ENDIAN
526/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
527 uint8_t orig_arfcn_hi:1, form_id:7;
528 uint8_t orig_arfcn_mid;
529 uint8_t w1:7, orig_arfcn_lo:1;
530 uint8_t w3_hi:2, w2:6;
531 uint8_t w4_hi:4, w3_lo:4;
532 uint8_t w6_hi:2, w5:5, w4_lo:1;
533 uint8_t w7:5, w6_lo:3;
534 uint8_t w9:4, w8:4;
535 uint8_t w11:4, w10:4;
536 uint8_t w13:4, w12:4;
537 uint8_t w15:4, w14:4;
538 uint8_t w18_hi:2, w17:3, w16:3;
539 uint8_t w21_hi:1, w20:3, w19:3, w18_lo:1;
540 uint8_t w23:3, w22:3, w21_lo:2;
541 uint8_t w26_hi:2, w25:3, w24:3;
542 uint8_t spare:1, w28:3, w27:3, w26_lo:1;
543#endif
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200544} __attribute__ ((packed));
545#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200546
547/* Chapter 10.5.2.1b.7 */
548struct gsm48_var_bit {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100549#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +0200550 uint8_t orig_arfcn_hi:1,
551 form_id:7;
552 uint8_t orig_arfcn_mid;
553 uint8_t rrfcn1_7:7,
554 orig_arfcn_lo:1;
555 uint8_t rrfcn8_111[13];
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100556#elif OSMO_IS_BIG_ENDIAN
557/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
558 uint8_t form_id:7, orig_arfcn_hi:1;
559 uint8_t orig_arfcn_mid;
560 uint8_t orig_arfcn_lo:1, rrfcn1_7:7;
561 uint8_t rrfcn8_111[13];
562#endif
Harald Welteec8b4502010-02-20 20:34:29 +0100563} __attribute__ ((packed));
564
565/* Chapter 10.5.2.5 */
566struct gsm48_chan_desc {
567 uint8_t chan_nr;
568 union {
569 struct {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100570#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +0100571 uint8_t maio_high:4,
572 h:1,
573 tsc:3;
574 uint8_t hsn:6,
575 maio_low:2;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100576#elif OSMO_IS_BIG_ENDIAN
577/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
578 uint8_t tsc:3, h:1, maio_high:4;
579 uint8_t maio_low:2, hsn:6;
580#endif
Andreas Eversberg4b332d72012-02-07 20:02:17 +0100581 } __attribute__ ((packed)) h1;
Harald Welteec8b4502010-02-20 20:34:29 +0100582 struct {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100583#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +0100584 uint8_t arfcn_high:2,
585 spare:2,
586 h:1,
587 tsc:3;
588 uint8_t arfcn_low;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100589#elif OSMO_IS_BIG_ENDIAN
590/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
591 uint8_t tsc:3, h:1, spare:2, arfcn_high:2;
592 uint8_t arfcn_low;
593#endif
Andreas Eversberg4b332d72012-02-07 20:02:17 +0100594 } __attribute__ ((packed)) h0;
595 } __attribute__ ((packed));
Harald Welteec8b4502010-02-20 20:34:29 +0100596} __attribute__ ((packed));
597
Andreas Eversberg014cb872010-07-12 09:11:00 +0200598/* Chapter 10.5.2.20 */
599struct gsm48_meas_res {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100600#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +0200601 uint8_t rxlev_full:6,
602 dtx_used:1,
603 ba_used:1;
604 uint8_t rxlev_sub:6,
605 meas_valid:1,
606 spare:1;
607 uint8_t no_nc_n_hi:1,
608 rxqual_sub:3,
609 rxqual_full:3,
610 spare2:1;
611 uint8_t rxlev_nc1:6,
612 no_nc_n_lo:2;
613 uint8_t bsic_nc1_hi:3,
614 bcch_f_nc1:5;
615 uint8_t rxlev_nc2_hi:5,
616 bsic_nc1_lo:3;
617 uint8_t bsic_nc2_hi:2,
618 bcch_f_nc2:5,
619 rxlev_nc2_lo:1;
620 uint8_t rxlev_nc3_hi:4,
621 bsic_nc2_lo:4;
622 uint8_t bsic_nc3_hi:1,
623 bcch_f_nc3:5,
624 rxlev_nc3_lo:2;
625 uint8_t rxlev_nc4_hi:3,
626 bsic_nc3_lo:5;
627 uint8_t bcch_f_nc4:5,
628 rxlev_nc4_lo:3;
629 uint8_t rxlev_nc5_hi:2,
630 bsic_nc4:6;
631 uint8_t bcch_f_nc5_hi:4,
632 rxlev_nc5_lo:4;
633 uint8_t rxlev_nc6_hi:1,
634 bsic_nc5:6,
635 bcch_f_nc5_lo:1;
636 uint8_t bcch_f_nc6_hi:3,
637 rxlev_nc6_lo:5;
638 uint8_t bsic_nc6:6,
639 bcch_f_nc6_lo:2;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100640#elif OSMO_IS_BIG_ENDIAN
641/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
642 uint8_t ba_used:1, dtx_used:1, rxlev_full:6;
643 uint8_t spare:1, meas_valid:1, rxlev_sub:6;
644 uint8_t spare2:1, rxqual_full:3, rxqual_sub:3, no_nc_n_hi:1;
645 uint8_t no_nc_n_lo:2, rxlev_nc1:6;
646 uint8_t bcch_f_nc1:5, bsic_nc1_hi:3;
647 uint8_t bsic_nc1_lo:3, rxlev_nc2_hi:5;
648 uint8_t rxlev_nc2_lo:1, bcch_f_nc2:5, bsic_nc2_hi:2;
649 uint8_t bsic_nc2_lo:4, rxlev_nc3_hi:4;
650 uint8_t rxlev_nc3_lo:2, bcch_f_nc3:5, bsic_nc3_hi:1;
651 uint8_t bsic_nc3_lo:5, rxlev_nc4_hi:3;
652 uint8_t rxlev_nc4_lo:3, bcch_f_nc4:5;
653 uint8_t bsic_nc4:6, rxlev_nc5_hi:2;
654 uint8_t rxlev_nc5_lo:4, bcch_f_nc5_hi:4;
655 uint8_t bcch_f_nc5_lo:1, bsic_nc5:6, rxlev_nc6_hi:1;
656 uint8_t rxlev_nc6_lo:5, bcch_f_nc6_hi:3;
657 uint8_t bcch_f_nc6_lo:2, bsic_nc6:6;
658#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200659} __attribute__ ((packed));
660
Harald Welteec8b4502010-02-20 20:34:29 +0100661/* Chapter 10.5.2.21aa */
662struct gsm48_multi_rate_conf {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100663#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +0100664 uint8_t smod : 2,
665 spare: 1,
666 icmi : 1,
667 nscb : 1,
668 ver : 3;
669 uint8_t m4_75 : 1,
670 m5_15 : 1,
671 m5_90 : 1,
672 m6_70 : 1,
673 m7_40 : 1,
674 m7_95 : 1,
675 m10_2 : 1,
676 m12_2 : 1;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100677#elif OSMO_IS_BIG_ENDIAN
678/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
679 uint8_t ver:3, nscb:1, icmi:1, spare:1, smod:2;
680 uint8_t m12_2:1, m10_2:1, m7_95:1, m7_40:1, m6_70:1, m5_90:1, m5_15:1, m4_75:1;
681#endif
Harald Welteec8b4502010-02-20 20:34:29 +0100682} __attribute__((packed));
683
Andreas Eversberg014cb872010-07-12 09:11:00 +0200684/* Chapter 10.5.2.28(a) */
685struct gsm48_power_cmd {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100686#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +0200687 uint8_t power_level:5,
688 spare:2,
689 atc:1;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100690#elif OSMO_IS_BIG_ENDIAN
691/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
692 uint8_t atc:1, spare:2, power_level:5;
693#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200694} __attribute__((packed));
695
696/* Chapter 10.5.2.29 */
697struct gsm48_rach_control {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100698#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +0200699 uint8_t re :1,
700 cell_bar :1,
701 tx_integer :4,
702 max_trans :2;
Stefan Sperling18595152018-02-06 13:20:23 +0100703 uint8_t t2; /* ACC 8-15 barred flags */
704 uint8_t t3; /* ACC 0-7 barred flags */
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100705#elif OSMO_IS_BIG_ENDIAN
706/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
707 uint8_t max_trans:2, tx_integer:4, cell_bar:1, re:1;
708 uint8_t t2;
709 uint8_t t3;
710#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200711} __attribute__ ((packed));
712
Stefan Sperling18595152018-02-06 13:20:23 +0100713/*
714 * Mark an Access Control Class as barred.
715 * \param[in] rach_control A Rach Control Information Element.
716 * \param[in] acc Access Control Class number (0 - 15) which shall be barred.
717 */
718static inline void gsm48_barr_acc(struct gsm48_rach_control *rach_control, unsigned int acc)
719{
720 OSMO_ASSERT(acc >= 0 && acc <= 15);
721 if (acc >= 8)
722 rach_control->t2 |= (1 << (acc - 8));
723 else
724 rach_control->t3 |= (1 << (acc));
725}
726
727/*
728 * Mark an Access Control Class as allowed.
729 * \param[in] rach_control A Rach Control Information Element.
730 * \param[in] acc Access Control Class number (0 - 15) which shall be allowed.
731 */
732static inline void gsm48_allow_acc(struct gsm48_rach_control *rach_control, unsigned int acc)
733{
734 OSMO_ASSERT(acc >= 0 && acc <= 15);
735 if (acc >= 8)
736 rach_control->t2 &= ~(1 << (acc - 8));
737 else
738 rach_control->t3 &= ~(1 << (acc));
739}
740
741/*
742 * Indicate whether an Access Control Class is barred.
743 * \param[in] rach_control A Rach Control Information Element.
744 * \param[in] acc Access Control Class number (0 - 15).
745 * \returns true if the Access Control class is barred, false otherwise
746 */
747static inline bool gsm48_acc_is_barred(struct gsm48_rach_control *rach_control, unsigned int acc)
748{
749 OSMO_ASSERT(acc >= 0 && acc <= 15);
750 if (acc >= 8)
751 return (rach_control->t2 & (1 << (acc - 8))) != 0;
752 return (rach_control->t3 & (1 << (acc))) != 0;
753}
Andreas Eversberg014cb872010-07-12 09:11:00 +0200754
Harald Welteec8b4502010-02-20 20:34:29 +0100755/* Chapter 10.5.2.30 */
756struct gsm48_req_ref {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100757#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +0100758 uint8_t ra;
759 uint8_t t3_high:3,
Andreas Eversberg93364fc2010-06-25 02:50:06 +0200760 t1:5;
Harald Welteec8b4502010-02-20 20:34:29 +0100761 uint8_t t2:5,
762 t3_low:3;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100763#elif OSMO_IS_BIG_ENDIAN
764/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
765 uint8_t ra;
766 uint8_t t1:5, t3_high:3;
767 uint8_t t3_low:3, t2:5;
768#endif
Harald Welteec8b4502010-02-20 20:34:29 +0100769} __attribute__ ((packed));
770
Andreas Eversberg014cb872010-07-12 09:11:00 +0200771/* Chapter 10.5.2.38 */
772struct gsm48_start_time {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100773#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +0200774 uint8_t t3_high:3,
775 t1:5;
776 uint8_t t2:5,
777 t3_low:3;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100778#elif OSMO_IS_BIG_ENDIAN
779/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
780 uint8_t t1:5, t3_high:3;
781 uint8_t t3_low:3, t2:5;
782#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200783} __attribute__ ((packed));
784
785/* Chapter 10.5.2.39 */
786struct gsm48_sync_ind {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100787#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +0200788 uint8_t si:2,
789 rot:1,
790 nci:1,
791 sync_ie:4;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100792#elif OSMO_IS_BIG_ENDIAN
793/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
794 uint8_t sync_ie:4, nci:1, rot:1, si:2;
795#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200796} __attribute__((packed));
797
Harald Welteec8b4502010-02-20 20:34:29 +0100798/*
799 * Chapter 9.1.5/9.1.6
800 *
801 * For 9.1.6 the chan_desc has the meaning of 10.5.2.5a
802 */
803struct gsm48_chan_mode_modify {
804 struct gsm48_chan_desc chan_desc;
805 uint8_t mode;
806} __attribute__ ((packed));
807
808enum gsm48_chan_mode {
809 GSM48_CMODE_SIGN = 0x00,
810 GSM48_CMODE_SPEECH_V1 = 0x01,
811 GSM48_CMODE_SPEECH_EFR = 0x21,
812 GSM48_CMODE_SPEECH_AMR = 0x41,
813 GSM48_CMODE_DATA_14k5 = 0x0f,
814 GSM48_CMODE_DATA_12k0 = 0x03,
815 GSM48_CMODE_DATA_6k0 = 0x0b,
Bhaskar31e844b2013-05-16 17:06:35 +0530816 GSM48_CMODE_DATA_3k6 = 0x13,
Harald Welteec8b4502010-02-20 20:34:29 +0100817};
818
Maxfb348ee2016-03-30 21:14:53 +0200819extern const struct value_string gsm48_chan_mode_names[];
Philipp Maier5796a212018-07-12 17:48:26 +0200820static inline const char *gsm48_chan_mode_name(enum gsm48_chan_mode val)
821{ return get_value_string(gsm48_chan_mode_names, val); }
Maxfb348ee2016-03-30 21:14:53 +0200822
Harald Welteec8b4502010-02-20 20:34:29 +0100823/* Chapter 9.1.2 */
824struct gsm48_ass_cmd {
825 /* Semantic is from 10.5.2.5a */
826 struct gsm48_chan_desc chan_desc;
827 uint8_t power_command;
828 uint8_t data[0];
829} __attribute__((packed));
830
Andreas Eversbergfa832012010-09-01 23:37:07 +0200831/* Chapter 9.1.13 */
832struct gsm48_frq_redef {
833 /* Semantic is from 10.5.2.5a */
834 struct gsm48_chan_desc chan_desc;
835 uint8_t mob_alloc_len;
836 uint8_t mob_alloc[0];
837} __attribute__((packed));
838
Harald Welte548e3712017-07-10 22:32:08 +0200839/* Chapter 9.1.13b GPRS suspension request */
840struct gsm48_gprs_susp_req {
841 uint32_t tlli;
842 uint8_t ra_id[6];
843 uint8_t cause;
844 uint8_t options[0];
845} __attribute__ ((packed));
846
Harald Welteec8b4502010-02-20 20:34:29 +0100847/* Chapter 10.5.2.2 */
848struct gsm48_cell_desc {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100849#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +0100850 uint8_t bcc:3,
851 ncc:3,
852 arfcn_hi:2;
853 uint8_t arfcn_lo;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100854#elif OSMO_IS_BIG_ENDIAN
855/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
856 uint8_t arfcn_hi:2, ncc:3, bcc:3;
857 uint8_t arfcn_lo;
858#endif
Harald Welteec8b4502010-02-20 20:34:29 +0100859} __attribute__((packed));
860
861/* Chapter 9.1.15 */
862struct gsm48_ho_cmd {
863 struct gsm48_cell_desc cell_desc;
864 struct gsm48_chan_desc chan_desc;
865 uint8_t ho_ref;
866 uint8_t power_command;
867 uint8_t data[0];
868} __attribute__((packed));
869
870/* Chapter 9.1.18 */
871struct gsm48_imm_ass {
872 uint8_t l2_plen;
873 uint8_t proto_discr;
874 uint8_t msg_type;
875 uint8_t page_mode;
876 struct gsm48_chan_desc chan_desc;
877 struct gsm48_req_ref req_ref;
878 uint8_t timing_advance;
879 uint8_t mob_alloc_len;
880 uint8_t mob_alloc[0];
881} __attribute__ ((packed));
882
Holger Hans Peter Freyther5dcef3c2010-05-15 22:35:25 +0800883/* Chapter 9.1.25 */
884struct gsm48_pag_resp {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100885#if OSMO_IS_LITTLE_ENDIAN
Holger Hans Peter Freyther5dcef3c2010-05-15 22:35:25 +0800886 uint8_t spare:4,
887 key_seq:4;
888 uint32_t classmark2;
889 uint8_t mi_len;
890 uint8_t mi[0];
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100891#elif OSMO_IS_BIG_ENDIAN
892/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
893 uint8_t key_seq:4, spare:4;
894 uint32_t classmark2;
895 uint8_t mi_len;
896 uint8_t mi[0];
897#endif
Holger Hans Peter Freyther5dcef3c2010-05-15 22:35:25 +0800898} __attribute__ ((packed));
899
Harald Welteec8b4502010-02-20 20:34:29 +0100900/* Chapter 10.5.1.3 */
901struct gsm48_loc_area_id {
902 uint8_t digits[3]; /* BCD! */
903 uint16_t lac;
904} __attribute__ ((packed));
905
906/* Section 9.2.2 */
907struct gsm48_auth_req {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100908#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +0100909 uint8_t key_seq:4,
910 spare:4;
911 uint8_t rand[16];
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100912#elif OSMO_IS_BIG_ENDIAN
913/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
914 uint8_t spare:4, key_seq:4;
915 uint8_t rand[16];
916#endif
Harald Welteec8b4502010-02-20 20:34:29 +0100917} __attribute__ ((packed));
918
Sylvain Munautd005eab2010-06-10 13:30:50 +0200919/* Section 9.2.3 */
920struct gsm48_auth_resp {
921 uint8_t sres[4];
922} __attribute__ ((packed));
923
Harald Welteec8b4502010-02-20 20:34:29 +0100924/* Section 9.2.15 */
925struct gsm48_loc_upd_req {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100926#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +0100927 uint8_t type:4,
928 key_seq:4;
929 struct gsm48_loc_area_id lai;
930 struct gsm48_classmark1 classmark1;
931 uint8_t mi_len;
932 uint8_t mi[0];
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100933#elif OSMO_IS_BIG_ENDIAN
934/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
935 uint8_t key_seq:4, type:4;
936 struct gsm48_loc_area_id lai;
937 struct gsm48_classmark1 classmark1;
938 uint8_t mi_len;
939 uint8_t mi[0];
940#endif
Harald Welteec8b4502010-02-20 20:34:29 +0100941} __attribute__ ((packed));
942
943/* Section 10.1 */
944struct gsm48_hdr {
945 uint8_t proto_discr;
946 uint8_t msg_type;
947 uint8_t data[0];
948} __attribute__ ((packed));
949
950/* Section 9.1.3x System information Type header */
951struct gsm48_system_information_type_header {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100952#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +0100953 uint8_t l2_plen;
954 uint8_t rr_protocol_discriminator :4,
955 skip_indicator:4;
956 uint8_t system_information;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100957#elif OSMO_IS_BIG_ENDIAN
958/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
959 uint8_t l2_plen;
960 uint8_t skip_indicator:4, rr_protocol_discriminator:4;
961 uint8_t system_information;
962#endif
Harald Welteec8b4502010-02-20 20:34:29 +0100963} __attribute__ ((packed));
964
Harald Welteec8b4502010-02-20 20:34:29 +0100965/* Section 10.5.2.4 Cell Selection Parameters */
966struct gsm48_cell_sel_par {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100967#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +0100968 uint8_t ms_txpwr_max_ccch:5, /* GSM 05.08 MS-TXPWR-MAX-CCCH */
969 cell_resel_hyst:3; /* GSM 05.08 CELL-RESELECT-HYSTERESIS */
970 uint8_t rxlev_acc_min:6, /* GSM 05.08 RXLEV-ACCESS-MIN */
971 neci:1,
972 acs:1;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100973#elif OSMO_IS_BIG_ENDIAN
974/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
975 uint8_t cell_resel_hyst:3, ms_txpwr_max_ccch:5;
976 uint8_t acs:1, neci:1, rxlev_acc_min:6;
977#endif
Harald Welteec8b4502010-02-20 20:34:29 +0100978} __attribute__ ((packed));
979
Neels Hofmeyrd1c2fc62017-02-21 14:51:40 +0100980/* 3GPP TS 44.018 Section 10.5.2.11 Control Channel Description */
Harald Welteec8b4502010-02-20 20:34:29 +0100981struct gsm48_control_channel_descr {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100982#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +0100983 uint8_t ccch_conf :3,
984 bs_ag_blks_res :3,
985 att :1,
Neels Hofmeyrd1c2fc62017-02-21 14:51:40 +0100986 mscr :1;
Harald Welteec8b4502010-02-20 20:34:29 +0100987 uint8_t bs_pa_mfrms : 3,
Neels Hofmeyrd1c2fc62017-02-21 14:51:40 +0100988 spare_1 :2,
989 cbq3 :2,
990 spare_2 :1;
Harald Welteec8b4502010-02-20 20:34:29 +0100991 uint8_t t3212;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100992#elif OSMO_IS_BIG_ENDIAN
993/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
994 uint8_t mscr:1, att:1, bs_ag_blks_res:3, ccch_conf:3;
995 uint8_t spare_2:1, cbq3:2, spare_1:2, bs_pa_mfrms:3;
996 uint8_t t3212;
997#endif
Harald Welteec8b4502010-02-20 20:34:29 +0100998} __attribute__ ((packed));
999
Maxfe65fa72016-05-10 17:17:05 +02001000enum gsm48_dtx_mode {
1001 GSM48_DTX_MAY_BE_USED,
1002 GSM48_DTX_SHALL_BE_USED,
1003 GSM48_DTX_SHALL_NOT_BE_USED
1004};
1005
1006/* Cell Options for SI6, SACCH (10.5.2.3a.2) or SI3, BCCH (Table 10.5.2.3.1),
1007 3GPP TS 44.018 */
Harald Welteec8b4502010-02-20 20:34:29 +01001008struct gsm48_cell_options {
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001009#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +01001010 uint8_t radio_link_timeout:4,
1011 dtx:2,
1012 pwrc:1,
Maxfe65fa72016-05-10 17:17:05 +02001013 /* either DN-IND or top bit of DTX IND */
1014 d:1;
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001015#elif OSMO_IS_BIG_ENDIAN
1016/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
1017 uint8_t d:1, pwrc:1, dtx:2, radio_link_timeout:4;
1018#endif
Harald Welteec8b4502010-02-20 20:34:29 +01001019} __attribute__ ((packed));
1020
1021/* Section 9.2.9 CM service request */
1022struct gsm48_service_request {
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001023#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +01001024 uint8_t cm_service_type : 4,
1025 cipher_key_seq : 4;
1026 /* length + 3 bytes */
1027 uint32_t classmark;
1028 uint8_t mi_len;
1029 uint8_t mi[0];
1030 /* optional priority level */
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001031#elif OSMO_IS_BIG_ENDIAN
1032/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
1033 uint8_t cipher_key_seq:4, cm_service_type:4;
1034 uint32_t classmark;
1035 uint8_t mi_len;
1036 uint8_t mi[0];
1037#endif
Harald Welteec8b4502010-02-20 20:34:29 +01001038} __attribute__ ((packed));
1039
1040/* Section 9.1.31 System information Type 1 */
1041struct gsm48_system_information_type_1 {
1042 struct gsm48_system_information_type_header header;
1043 uint8_t cell_channel_description[16];
1044 struct gsm48_rach_control rach_control;
1045 uint8_t rest_octets[0]; /* NCH position on the CCCH */
1046} __attribute__ ((packed));
1047
1048/* Section 9.1.32 System information Type 2 */
1049struct gsm48_system_information_type_2 {
1050 struct gsm48_system_information_type_header header;
1051 uint8_t bcch_frequency_list[16];
1052 uint8_t ncc_permitted;
1053 struct gsm48_rach_control rach_control;
1054} __attribute__ ((packed));
1055
Andreas Eversberg014cb872010-07-12 09:11:00 +02001056/* Section 9.1.33 System information Type 2bis */
1057struct gsm48_system_information_type_2bis {
1058 struct gsm48_system_information_type_header header;
1059 uint8_t bcch_frequency_list[16];
1060 struct gsm48_rach_control rach_control;
1061 uint8_t rest_octets[0];
1062} __attribute__ ((packed));
1063
1064/* Section 9.1.34 System information Type 2ter */
1065struct gsm48_system_information_type_2ter {
1066 struct gsm48_system_information_type_header header;
1067 uint8_t ext_bcch_frequency_list[16];
1068 uint8_t rest_octets[0];
1069} __attribute__ ((packed));
1070
Maxe859aec2016-03-11 12:24:04 +01001071/* Section 9.1.34a System information Type 2quater */
1072struct gsm48_system_information_type_2quater {
1073 struct gsm48_system_information_type_header header;
1074 uint8_t rest_octets[0];
1075} __attribute__ ((packed));
1076
Harald Welteec8b4502010-02-20 20:34:29 +01001077/* Section 9.1.35 System information Type 3 */
1078struct gsm48_system_information_type_3 {
1079 struct gsm48_system_information_type_header header;
1080 uint16_t cell_identity;
1081 struct gsm48_loc_area_id lai;
1082 struct gsm48_control_channel_descr control_channel_desc;
1083 struct gsm48_cell_options cell_options;
1084 struct gsm48_cell_sel_par cell_sel_par;
1085 struct gsm48_rach_control rach_control;
1086 uint8_t rest_octets[0];
1087} __attribute__ ((packed));
1088
1089/* Section 9.1.36 System information Type 4 */
1090struct gsm48_system_information_type_4 {
1091 struct gsm48_system_information_type_header header;
1092 struct gsm48_loc_area_id lai;
1093 struct gsm48_cell_sel_par cell_sel_par;
1094 struct gsm48_rach_control rach_control;
1095 /* optional CBCH conditional CBCH... followed by
1096 mandantory SI 4 Reset Octets
1097 */
1098 uint8_t data[0];
1099} __attribute__ ((packed));
1100
1101/* Section 9.1.37 System information Type 5 */
1102struct gsm48_system_information_type_5 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001103#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +01001104 uint8_t rr_protocol_discriminator :4,
1105 skip_indicator:4;
1106 uint8_t system_information;
1107 uint8_t bcch_frequency_list[16];
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001108#elif OSMO_IS_BIG_ENDIAN
1109/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
1110 uint8_t skip_indicator:4, rr_protocol_discriminator:4;
1111 uint8_t system_information;
1112 uint8_t bcch_frequency_list[16];
1113#endif
Harald Welteec8b4502010-02-20 20:34:29 +01001114} __attribute__ ((packed));
1115
Andreas Eversberg014cb872010-07-12 09:11:00 +02001116/* Section 9.1.38 System information Type 5bis */
1117struct gsm48_system_information_type_5bis {
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001118#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +02001119 uint8_t rr_protocol_discriminator :4,
1120 skip_indicator:4;
1121 uint8_t system_information;
1122 uint8_t bcch_frequency_list[16];
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001123#elif OSMO_IS_BIG_ENDIAN
1124/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
1125 uint8_t skip_indicator:4, rr_protocol_discriminator:4;
1126 uint8_t system_information;
1127 uint8_t bcch_frequency_list[16];
1128#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +02001129} __attribute__ ((packed));
1130
1131/* Section 9.1.39 System information Type 5ter */
1132struct gsm48_system_information_type_5ter {
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001133#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +02001134 uint8_t rr_protocol_discriminator :4,
1135 skip_indicator:4;
1136 uint8_t system_information;
1137 uint8_t bcch_frequency_list[16];
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001138#elif OSMO_IS_BIG_ENDIAN
1139/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
1140 uint8_t skip_indicator:4, rr_protocol_discriminator:4;
1141 uint8_t system_information;
1142 uint8_t bcch_frequency_list[16];
1143#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +02001144} __attribute__ ((packed));
1145
Harald Welteec8b4502010-02-20 20:34:29 +01001146/* Section 9.1.40 System information Type 6 */
1147struct gsm48_system_information_type_6 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001148#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +01001149 uint8_t rr_protocol_discriminator :4,
1150 skip_indicator:4;
1151 uint8_t system_information;
1152 uint16_t cell_identity;
1153 struct gsm48_loc_area_id lai;
1154 struct gsm48_cell_options cell_options;
1155 uint8_t ncc_permitted;
1156 uint8_t rest_octets[0];
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001157#elif OSMO_IS_BIG_ENDIAN
1158/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
1159 uint8_t skip_indicator:4, rr_protocol_discriminator:4;
1160 uint8_t system_information;
1161 uint16_t cell_identity;
1162 struct gsm48_loc_area_id lai;
1163 struct gsm48_cell_options cell_options;
1164 uint8_t ncc_permitted;
1165 uint8_t rest_octets[0];
1166#endif
Harald Welteec8b4502010-02-20 20:34:29 +01001167} __attribute__ ((packed));
1168
1169/* Section 9.1.43a System Information type 13 */
1170struct gsm48_system_information_type_13 {
1171 struct gsm48_system_information_type_header header;
1172 uint8_t rest_octets[0];
1173} __attribute__ ((packed));
1174
1175/* Section 9.2.12 IMSI Detach Indication */
1176struct gsm48_imsi_detach_ind {
1177 struct gsm48_classmark1 classmark1;
1178 uint8_t mi_len;
1179 uint8_t mi[0];
1180} __attribute__ ((packed));
1181
Andreas Eversberg014cb872010-07-12 09:11:00 +02001182/* Section 9.1.1 */
1183struct gsm48_add_ass {
1184 /* Semantic is from 10.5.2.5 */
1185 struct gsm48_chan_desc chan_desc;
1186 uint8_t data[0];
1187} __attribute__((packed));
1188
1189/* Section 9.1.3 */
1190struct gsm48_ass_cpl {
1191 uint8_t rr_cause;
1192} __attribute__((packed));
1193
1194/* Section 9.1.4 */
1195struct gsm48_ass_fail {
1196 uint8_t rr_cause;
1197} __attribute__((packed));
1198
Andreas Eversbergfa832012010-09-01 23:37:07 +02001199/* Section 9.1.3 */
1200struct gsm48_ho_cpl {
1201 uint8_t rr_cause;
1202 uint8_t data[0];
1203} __attribute__((packed));
1204
1205/* Section 9.1.4 */
1206struct gsm48_ho_fail {
1207 uint8_t rr_cause;
1208} __attribute__((packed));
1209
Andreas Eversberg014cb872010-07-12 09:11:00 +02001210/* Section 9.1.7 */
1211struct gsm48_chan_rel {
1212 uint8_t rr_cause;
1213 uint8_t data[0];
1214} __attribute__((packed));
1215
1216/* Section 9.1.9 */
1217struct gsm48_cip_mode_cmd {
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001218#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +02001219 uint8_t sc:1,
1220 alg_id:3,
Sylvain Munaut77b6f6c2010-09-17 13:55:45 +02001221 cr:1,
1222 spare:3;
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001223#elif OSMO_IS_BIG_ENDIAN
1224/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
1225 uint8_t spare:3, cr:1, alg_id:3, sc:1;
1226#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +02001227} __attribute__((packed));
1228
1229/* Section 9.1.11 */
1230struct gsm48_cm_change {
1231 uint8_t cm2_len;
1232 struct gsm48_classmark2 cm2;
1233 uint8_t data[0];
1234} __attribute__((packed));
1235
1236/* Section 9.1.19 */
1237struct gsm48_imm_ass_ext {
1238 uint8_t l2_plen;
1239 uint8_t proto_discr;
1240 uint8_t msg_type;
1241 uint8_t page_mode;
1242 struct gsm48_chan_desc chan_desc1;
1243 struct gsm48_req_ref req_ref1;
1244 uint8_t timing_advance1;
1245 struct gsm48_chan_desc chan_desc2;
1246 struct gsm48_req_ref req_ref2;
1247 uint8_t timing_advance2;
1248 uint8_t mob_alloc_len;
1249 uint8_t mob_alloc[0];
1250} __attribute__ ((packed));
1251
1252/* Section 9.1.20 */
1253struct gsm48_imm_ass_rej {
1254 uint8_t l2_plen;
1255 uint8_t proto_discr;
1256 uint8_t msg_type;
1257 uint8_t page_mode;
1258 struct gsm48_req_ref req_ref1;
1259 uint8_t wait_ind1;
1260 struct gsm48_req_ref req_ref2;
1261 uint8_t wait_ind2;
1262 struct gsm48_req_ref req_ref3;
1263 uint8_t wait_ind3;
1264 struct gsm48_req_ref req_ref4;
1265 uint8_t wait_ind4;
1266 uint8_t rest[0];
1267} __attribute__ ((packed));
1268
1269/* Section 9.1.22 */
1270struct gsm48_paging1 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001271#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +02001272 uint8_t l2_plen;
1273 uint8_t proto_discr;
1274 uint8_t msg_type;
1275 uint8_t pag_mode:2,
1276 spare:2,
1277 cneed1:2,
1278 cneed2:2;
1279 uint8_t data[0];
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001280#elif OSMO_IS_BIG_ENDIAN
1281/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
1282 uint8_t l2_plen;
1283 uint8_t proto_discr;
1284 uint8_t msg_type;
1285 uint8_t cneed2:2, cneed1:2, spare:2, pag_mode:2;
1286 uint8_t data[0];
1287#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +02001288} __attribute__((packed));
1289
1290/* Section 9.1.23 */
1291struct gsm48_paging2 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001292#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +02001293 uint8_t l2_plen;
1294 uint8_t proto_discr;
1295 uint8_t msg_type;
1296 uint8_t pag_mode:2,
1297 spare:2,
1298 cneed1:2,
1299 cneed2:2;
1300 uint32_t tmsi1;
1301 uint32_t tmsi2;
1302 uint8_t data[0];
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001303#elif OSMO_IS_BIG_ENDIAN
1304/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
1305 uint8_t l2_plen;
1306 uint8_t proto_discr;
1307 uint8_t msg_type;
1308 uint8_t cneed2:2, cneed1:2, spare:2, pag_mode:2;
1309 uint32_t tmsi1;
1310 uint32_t tmsi2;
1311 uint8_t data[0];
1312#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +02001313} __attribute__((packed));
1314
1315/* Section 9.1.24 */
1316struct gsm48_paging3 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001317#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +02001318 uint8_t l2_plen;
1319 uint8_t proto_discr;
1320 uint8_t msg_type;
1321 uint8_t pag_mode:2,
1322 spare:2,
1323 cneed1:2,
1324 cneed2:2;
1325 uint32_t tmsi1;
1326 uint32_t tmsi2;
1327 uint32_t tmsi3;
1328 uint32_t tmsi4;
1329 uint8_t cneed3:2,
1330 cneed4:2,
1331 spare2:4;
1332 uint8_t rest[0];
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001333#elif OSMO_IS_BIG_ENDIAN
1334/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
1335 uint8_t l2_plen;
1336 uint8_t proto_discr;
1337 uint8_t msg_type;
1338 uint8_t cneed2:2, cneed1:2, spare:2, pag_mode:2;
1339 uint32_t tmsi1;
1340 uint32_t tmsi2;
1341 uint32_t tmsi3;
1342 uint32_t tmsi4;
1343 uint8_t spare2:4, cneed4:2, cneed3:2;
1344 uint8_t rest[0];
1345#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +02001346} __attribute__((packed));
1347
1348/* Section 9.1.25 */
1349struct gsm48_pag_rsp {
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001350#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +02001351 uint8_t key_seq:3,
1352 spare:5;
1353 uint8_t cm2_len;
1354 struct gsm48_classmark2 cm2;
1355 uint8_t data[0];
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001356#elif OSMO_IS_BIG_ENDIAN
1357/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
1358 uint8_t spare:5, key_seq:3;
1359 uint8_t cm2_len;
1360 struct gsm48_classmark2 cm2;
1361 uint8_t data[0];
1362#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +02001363} __attribute__((packed));
1364
1365/* Section 9.1.29 */
1366struct gsm48_rr_status {
1367 uint8_t rr_cause;
1368} __attribute__((packed));
1369
Harald Welte3f066dd2017-05-29 15:59:03 +02001370/* Section 10.2 + GSM 04.07 12.2.3.1.1 + 3GPP TS 24.007 11.2.3.1.1 */
Harald Welteec8b4502010-02-20 20:34:29 +01001371#define GSM48_PDISC_GROUP_CC 0x00
1372#define GSM48_PDISC_BCAST_CC 0x01
Harald Welte3f066dd2017-05-29 15:59:03 +02001373#define GSM48_PDISC_PDSS1 0x02 /* 04.07 only */
Harald Welteec8b4502010-02-20 20:34:29 +01001374#define GSM48_PDISC_CC 0x03
Harald Welte3f066dd2017-05-29 15:59:03 +02001375#define GSM48_PDISC_PDSS2 0x04 /* 04.07 only */
1376#define GSM48_PDISC_GTTP 0x04 /* 24.007 only */
Harald Welteec8b4502010-02-20 20:34:29 +01001377#define GSM48_PDISC_MM 0x05
1378#define GSM48_PDISC_RR 0x06
1379#define GSM48_PDISC_MM_GPRS 0x08
1380#define GSM48_PDISC_SMS 0x09
1381#define GSM48_PDISC_SM_GPRS 0x0a
1382#define GSM48_PDISC_NC_SS 0x0b
1383#define GSM48_PDISC_LOC 0x0c
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001384#define GSM48_PDISC_EXTEND 0x0e
Harald Welte3f066dd2017-05-29 15:59:03 +02001385#define GSM48_PDISC_TEST 0x0f /* as per 11.10, 04.14 */
Harald Welteec8b4502010-02-20 20:34:29 +01001386#define GSM48_PDISC_MASK 0x0f
Harald Welteec8b4502010-02-20 20:34:29 +01001387
Neels Hofmeyrdbd994c2017-03-09 23:07:02 +01001388extern const struct value_string gsm48_pdisc_names[];
1389static inline const char *gsm48_pdisc_name(uint8_t val)
1390{ return get_value_string(gsm48_pdisc_names, val); }
1391
Maxfdca25d2016-07-05 16:06:28 +02001392bool gsm48_hdr_gmm_cipherable(const struct gsm48_hdr *hdr);
1393
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001394static inline uint8_t gsm48_hdr_pdisc(const struct gsm48_hdr *hdr)
1395{
1396 /*
1397 * 3GPP TS 24.007 version 12.0.0 Release 12,
1398 * 11.2.3.1.1 Protocol discriminator
1399 */
1400 uint8_t pdisc = hdr->proto_discr & GSM48_PDISC_MASK;
1401 if (pdisc == GSM48_PDISC_EXTEND)
1402 return hdr->proto_discr;
1403 return pdisc;
1404}
1405
Neels Hofmeyrda7bf4d2016-03-14 16:06:48 +01001406static inline uint8_t gsm48_hdr_trans_id(const struct gsm48_hdr *hdr)
1407{
1408 /*
1409 * 3GPP TS 24.007 version 12.0.0 Release 12,
1410 * 11.2.3.1.3 Transaction identifier
1411 */
1412 return (hdr->proto_discr & 0xf0) >> 4;
1413}
1414
Maxda34bf02016-07-17 16:37:56 +02001415#define GSM48_TA_INVALID 220
1416
Neels Hofmeyr87e45502017-06-20 00:17:59 +02001417/*! Check if TA is valid according to 3GPP TS 44.018 ยง 10.5.2.40
Maxedb57e72016-07-14 11:35:17 +02001418 * \param[in] ta Timing Advance value
1419 * \returns true if ta is valid, false otherwise
1420 * Note: Rules for GSM400 band are ignored as it's not implemented in practice.
1421 */
1422static inline bool gsm48_ta_is_valid(uint8_t ta)
1423{
1424 return (ta < 64);
1425}
1426
Neels Hofmeyrda7bf4d2016-03-14 16:06:48 +01001427static inline uint8_t gsm48_hdr_trans_id_flip_ti(const struct gsm48_hdr *hdr)
1428{
1429 return gsm48_hdr_trans_id(hdr) ^ 0x08;
1430}
1431
1432static inline uint8_t gsm48_hdr_trans_id_no_ti(const struct gsm48_hdr *hdr)
1433{
1434 return gsm48_hdr_trans_id(hdr) & 0x07;
1435}
1436
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001437static inline uint8_t gsm48_hdr_msg_type_r98(const struct gsm48_hdr *hdr)
1438{
1439 /*
1440 * 3GPP TS 24.007 version 12.0.0 Release 12,
1441 * 11.2.3.2.1 Message type octet (when accessing Release 98 and older
1442 * networks only)
1443 */
1444 switch (gsm48_hdr_pdisc(hdr)) {
1445 case GSM48_PDISC_MM:
1446 case GSM48_PDISC_CC:
1447 case GSM48_PDISC_NC_SS:
1448 case GSM48_PDISC_GROUP_CC:
1449 case GSM48_PDISC_BCAST_CC:
1450 case GSM48_PDISC_LOC:
Harald Welte143aed72018-02-03 21:14:47 +01001451 return hdr->msg_type & 0x3f;
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001452 default:
1453 return hdr->msg_type;
1454 }
1455}
1456
1457static inline uint8_t gsm48_hdr_msg_type_r99(const struct gsm48_hdr *hdr)
1458{
1459 /*
1460 * 3GPP TS 24.007 version 12.0.0 Release 12,
1461 * 11.2.3.2.2 Message type octet (when accessing Release 99 and newer
1462 * networks)
1463 */
1464 switch (gsm48_hdr_pdisc(hdr)) {
1465 case GSM48_PDISC_MM:
1466 case GSM48_PDISC_CC:
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001467 case GSM48_PDISC_NC_SS:
Harald Weltef1076ed2018-02-03 21:16:45 +01001468 return hdr->msg_type & 0x3f;
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001469 case GSM48_PDISC_GROUP_CC:
1470 case GSM48_PDISC_BCAST_CC:
1471 case GSM48_PDISC_LOC:
Harald Welte143aed72018-02-03 21:14:47 +01001472 return hdr->msg_type & 0x3f;
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001473 default:
1474 return hdr->msg_type;
1475 }
1476}
1477
Maxfe65fa72016-05-10 17:17:05 +02001478void gsm48_set_dtx(struct gsm48_cell_options *op, enum gsm48_dtx_mode full,
1479 enum gsm48_dtx_mode half, bool is_bcch);
1480
Neels Hofmeyrc656fae2016-03-14 16:06:47 +01001481#define gsm48_hdr_msg_type gsm48_hdr_msg_type_r99
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001482
Harald Welteec8b4502010-02-20 20:34:29 +01001483/* Section 10.4 */
1484#define GSM48_MT_RR_INIT_REQ 0x3c
1485#define GSM48_MT_RR_ADD_ASS 0x3b
1486#define GSM48_MT_RR_IMM_ASS 0x3f
1487#define GSM48_MT_RR_IMM_ASS_EXT 0x39
1488#define GSM48_MT_RR_IMM_ASS_REJ 0x3a
Philipp72e43f02016-10-27 13:35:20 +02001489#define GSM48_MT_RR_DTM_ASS_FAIL 0x48
1490#define GSM48_MT_RR_DTM_REJECT 0x49
1491#define GSM48_MT_RR_DTM_REQUEST 0x4A
1492#define GSM48_MT_RR_PACKET_ASS 0x4B
Harald Welteec8b4502010-02-20 20:34:29 +01001493
1494#define GSM48_MT_RR_CIPH_M_CMD 0x35
1495#define GSM48_MT_RR_CIPH_M_COMPL 0x32
1496
1497#define GSM48_MT_RR_CFG_CHG_CMD 0x30
1498#define GSM48_MT_RR_CFG_CHG_ACK 0x31
1499#define GSM48_MT_RR_CFG_CHG_REJ 0x33
1500
1501#define GSM48_MT_RR_ASS_CMD 0x2e
1502#define GSM48_MT_RR_ASS_COMPL 0x29
1503#define GSM48_MT_RR_ASS_FAIL 0x2f
1504#define GSM48_MT_RR_HANDO_CMD 0x2b
1505#define GSM48_MT_RR_HANDO_COMPL 0x2c
1506#define GSM48_MT_RR_HANDO_FAIL 0x28
1507#define GSM48_MT_RR_HANDO_INFO 0x2d
Philipp72e43f02016-10-27 13:35:20 +02001508#define GSM48_MT_RR_HANDO_INFO 0x2d
1509#define GSM48_MT_RR_DTM_ASS_CMD 0x4c
Harald Welteec8b4502010-02-20 20:34:29 +01001510
1511#define GSM48_MT_RR_CELL_CHG_ORDER 0x08
1512#define GSM48_MT_RR_PDCH_ASS_CMD 0x23
1513
1514#define GSM48_MT_RR_CHAN_REL 0x0d
1515#define GSM48_MT_RR_PART_REL 0x0a
1516#define GSM48_MT_RR_PART_REL_COMP 0x0f
1517
1518#define GSM48_MT_RR_PAG_REQ_1 0x21
1519#define GSM48_MT_RR_PAG_REQ_2 0x22
1520#define GSM48_MT_RR_PAG_REQ_3 0x24
1521#define GSM48_MT_RR_PAG_RESP 0x27
1522#define GSM48_MT_RR_NOTIF_NCH 0x20
Philipp72e43f02016-10-27 13:35:20 +02001523#define GSM48_MT_RR_NOTIF_FACCH 0x25 /* (Reserved) */
Harald Welteec8b4502010-02-20 20:34:29 +01001524#define GSM48_MT_RR_NOTIF_RESP 0x26
Philipp72e43f02016-10-27 13:35:20 +02001525#define GSM48_MT_RR_PACKET_NOTIF 0x4e
Philipp349784c2016-10-10 15:03:23 +02001526#define GSM48_MT_RR_UTRAN_CLSM_CHG 0x60
1527#define GSM48_MT_RR_CDMA2K_CLSM_CHG 0x62
1528#define GSM48_MT_RR_IS_TO_UTRAN_HANDO 0x63
1529#define GSM48_MT_RR_IS_TO_CDMA2K_HANDO 0x64
1530
Harald Welteec8b4502010-02-20 20:34:29 +01001531#define GSM48_MT_RR_SYSINFO_8 0x18
1532#define GSM48_MT_RR_SYSINFO_1 0x19
1533#define GSM48_MT_RR_SYSINFO_2 0x1a
1534#define GSM48_MT_RR_SYSINFO_3 0x1b
1535#define GSM48_MT_RR_SYSINFO_4 0x1c
1536#define GSM48_MT_RR_SYSINFO_5 0x1d
1537#define GSM48_MT_RR_SYSINFO_6 0x1e
1538#define GSM48_MT_RR_SYSINFO_7 0x1f
1539
1540#define GSM48_MT_RR_SYSINFO_2bis 0x02
1541#define GSM48_MT_RR_SYSINFO_2ter 0x03
Maxe859aec2016-03-11 12:24:04 +01001542#define GSM48_MT_RR_SYSINFO_2quater 0x07
Harald Welteec8b4502010-02-20 20:34:29 +01001543#define GSM48_MT_RR_SYSINFO_5bis 0x05
1544#define GSM48_MT_RR_SYSINFO_5ter 0x06
1545#define GSM48_MT_RR_SYSINFO_9 0x04
1546#define GSM48_MT_RR_SYSINFO_13 0x00
1547
1548#define GSM48_MT_RR_SYSINFO_16 0x3d
1549#define GSM48_MT_RR_SYSINFO_17 0x3e
1550
Philipp72e43f02016-10-27 13:35:20 +02001551#define GSM48_MT_RR_SYSINFO_18 0x40
1552#define GSM48_MT_RR_SYSINFO_19 0x41
1553#define GSM48_MT_RR_SYSINFO_20 0x42
1554
Harald Welteec8b4502010-02-20 20:34:29 +01001555#define GSM48_MT_RR_CHAN_MODE_MODIF 0x10
1556#define GSM48_MT_RR_STATUS 0x12
1557#define GSM48_MT_RR_CHAN_MODE_MODIF_ACK 0x17
1558#define GSM48_MT_RR_FREQ_REDEF 0x14
1559#define GSM48_MT_RR_MEAS_REP 0x15
1560#define GSM48_MT_RR_CLSM_CHG 0x16
1561#define GSM48_MT_RR_CLSM_ENQ 0x13
1562#define GSM48_MT_RR_EXT_MEAS_REP 0x36
1563#define GSM48_MT_RR_EXT_MEAS_REP_ORD 0x37
1564#define GSM48_MT_RR_GPRS_SUSP_REQ 0x34
Philipp72e43f02016-10-27 13:35:20 +02001565#define GSM48_MT_RR_DTM_INFO 0x4d
Harald Welteec8b4502010-02-20 20:34:29 +01001566
Bhaskare6b45d82013-05-16 17:11:51 +05301567#define GSM48_MT_RR_VGCS_UPL_GRANT 0x09
Harald Welteec8b4502010-02-20 20:34:29 +01001568#define GSM48_MT_RR_UPLINK_RELEASE 0x0e
1569#define GSM48_MT_RR_UPLINK_FREE 0x0c
1570#define GSM48_MT_RR_UPLINK_BUSY 0x2a
1571#define GSM48_MT_RR_TALKER_IND 0x11
1572
1573#define GSM48_MT_RR_APP_INFO 0x38
1574
1575/* Table 10.2/3GPP TS 04.08 */
1576#define GSM48_MT_MM_IMSI_DETACH_IND 0x01
1577#define GSM48_MT_MM_LOC_UPD_ACCEPT 0x02
1578#define GSM48_MT_MM_LOC_UPD_REJECT 0x04
1579#define GSM48_MT_MM_LOC_UPD_REQUEST 0x08
1580
1581#define GSM48_MT_MM_AUTH_REJ 0x11
1582#define GSM48_MT_MM_AUTH_REQ 0x12
1583#define GSM48_MT_MM_AUTH_RESP 0x14
Neels Hofmeyr55a43b82017-02-02 20:27:55 +01001584#define GSM48_MT_MM_AUTH_FAIL 0x1c
Harald Welteec8b4502010-02-20 20:34:29 +01001585#define GSM48_MT_MM_ID_REQ 0x18
1586#define GSM48_MT_MM_ID_RESP 0x19
1587#define GSM48_MT_MM_TMSI_REALL_CMD 0x1a
1588#define GSM48_MT_MM_TMSI_REALL_COMPL 0x1b
1589
1590#define GSM48_MT_MM_CM_SERV_ACC 0x21
1591#define GSM48_MT_MM_CM_SERV_REJ 0x22
1592#define GSM48_MT_MM_CM_SERV_ABORT 0x23
1593#define GSM48_MT_MM_CM_SERV_REQ 0x24
1594#define GSM48_MT_MM_CM_SERV_PROMPT 0x25
1595#define GSM48_MT_MM_CM_REEST_REQ 0x28
1596#define GSM48_MT_MM_ABORT 0x29
1597
1598#define GSM48_MT_MM_NULL 0x30
1599#define GSM48_MT_MM_STATUS 0x31
1600#define GSM48_MT_MM_INFO 0x32
1601
1602/* Table 10.3/3GPP TS 04.08 */
1603#define GSM48_MT_CC_ALERTING 0x01
1604#define GSM48_MT_CC_CALL_CONF 0x08
1605#define GSM48_MT_CC_CALL_PROC 0x02
1606#define GSM48_MT_CC_CONNECT 0x07
1607#define GSM48_MT_CC_CONNECT_ACK 0x0f
1608#define GSM48_MT_CC_EMERG_SETUP 0x0e
1609#define GSM48_MT_CC_PROGRESS 0x03
1610#define GSM48_MT_CC_ESTAB 0x04
1611#define GSM48_MT_CC_ESTAB_CONF 0x06
1612#define GSM48_MT_CC_RECALL 0x0b
1613#define GSM48_MT_CC_START_CC 0x09
1614#define GSM48_MT_CC_SETUP 0x05
1615
1616#define GSM48_MT_CC_MODIFY 0x17
1617#define GSM48_MT_CC_MODIFY_COMPL 0x1f
1618#define GSM48_MT_CC_MODIFY_REJECT 0x13
1619#define GSM48_MT_CC_USER_INFO 0x10
1620#define GSM48_MT_CC_HOLD 0x18
1621#define GSM48_MT_CC_HOLD_ACK 0x19
1622#define GSM48_MT_CC_HOLD_REJ 0x1a
1623#define GSM48_MT_CC_RETR 0x1c
1624#define GSM48_MT_CC_RETR_ACK 0x1d
1625#define GSM48_MT_CC_RETR_REJ 0x1e
1626
1627#define GSM48_MT_CC_DISCONNECT 0x25
1628#define GSM48_MT_CC_RELEASE 0x2d
1629#define GSM48_MT_CC_RELEASE_COMPL 0x2a
1630
1631#define GSM48_MT_CC_CONG_CTRL 0x39
1632#define GSM48_MT_CC_NOTIFY 0x3e
1633#define GSM48_MT_CC_STATUS 0x3d
1634#define GSM48_MT_CC_STATUS_ENQ 0x34
1635#define GSM48_MT_CC_START_DTMF 0x35
1636#define GSM48_MT_CC_STOP_DTMF 0x31
1637#define GSM48_MT_CC_STOP_DTMF_ACK 0x32
1638#define GSM48_MT_CC_START_DTMF_ACK 0x36
1639#define GSM48_MT_CC_START_DTMF_REJ 0x37
1640#define GSM48_MT_CC_FACILITY 0x3a
1641
Neels Hofmeyr00ab9ed2017-03-09 23:27:56 +01001642extern const struct value_string gsm48_rr_msgtype_names[];
1643extern const struct value_string gsm48_mm_msgtype_names[];
1644extern const struct value_string gsm48_cc_msgtype_names[];
1645const char *gsm48_pdisc_msgtype_name(uint8_t pdisc, uint8_t msg_type);
1646
Harald Welteec8b4502010-02-20 20:34:29 +01001647/* FIXME: Table 10.4 / 10.4a (GPRS) */
1648
Andreas Eversberg014cb872010-07-12 09:11:00 +02001649/* Section 10.5.3.3 CM service type */
Neels Hofmeyrf8963f92019-01-10 23:33:32 +01001650enum osmo_cm_service_type {
1651 GSM48_CMSERV_MO_CALL_PACKET = 1,
1652 GSM48_CMSERV_EMERGENCY = 2,
1653 GSM48_CMSERV_SMS = 4,
1654 GSM48_CMSERV_SUP_SERV = 8,
1655 GSM48_CMSERV_VGCS = 9,
1656 GSM48_CMSERV_VBS = 10,
1657 GSM48_CMSERV_LOC_SERV = 11,
1658 GSM48_CMSERV_MAX_VAL = GSM48_CMSERV_LOC_SERV
1659};
1660
1661extern const struct value_string osmo_cm_service_type_names[];
1662static inline const char *osmo_cm_service_type_name(enum osmo_cm_service_type val)
1663{ return get_value_string(osmo_cm_service_type_names, val); }
Andreas Eversberg014cb872010-07-12 09:11:00 +02001664
Harald Welteec8b4502010-02-20 20:34:29 +01001665/* Section 10.5.2.26, Table 10.5.64 */
1666#define GSM48_PM_MASK 0x03
1667#define GSM48_PM_NORMAL 0x00
1668#define GSM48_PM_EXTENDED 0x01
1669#define GSM48_PM_REORG 0x02
1670#define GSM48_PM_SAME 0x03
1671
1672/* Chapter 10.5.3.5 / Table 10.5.93 */
1673#define GSM48_LUPD_NORMAL 0x0
1674#define GSM48_LUPD_PERIODIC 0x1
1675#define GSM48_LUPD_IMSI_ATT 0x2
1676#define GSM48_LUPD_RESERVED 0x3
1677
Neels Hofmeyr92f3f5e2019-01-05 00:39:13 +01001678extern const struct value_string osmo_lu_type_names[];
1679static inline const char *osmo_lu_type_name(uint8_t lu_type)
1680{ return get_value_string(osmo_lu_type_names, lu_type); }
1681
Harald Welteec8b4502010-02-20 20:34:29 +01001682/* Table 10.5.4 */
1683#define GSM_MI_TYPE_MASK 0x07
1684#define GSM_MI_TYPE_NONE 0x00
1685#define GSM_MI_TYPE_IMSI 0x01
1686#define GSM_MI_TYPE_IMEI 0x02
1687#define GSM_MI_TYPE_IMEISV 0x03
1688#define GSM_MI_TYPE_TMSI 0x04
1689#define GSM_MI_ODD 0x08
1690
Andreas Eversberg014cb872010-07-12 09:11:00 +02001691#define GSM48_IE_MOBILE_ID 0x17 /* 10.5.1.4 */
Harald Welteec8b4502010-02-20 20:34:29 +01001692#define GSM48_IE_NAME_LONG 0x43 /* 10.5.3.5a */
1693#define GSM48_IE_NAME_SHORT 0x45 /* 10.5.3.5a */
1694#define GSM48_IE_UTC 0x46 /* 10.5.3.8 */
1695#define GSM48_IE_NET_TIME_TZ 0x47 /* 10.5.3.9 */
1696#define GSM48_IE_LSA_IDENT 0x48 /* 10.5.3.11 */
Jacob Erlbeck1c3f0882013-09-16 10:29:57 +02001697#define GSM48_IE_NET_DST 0x49 /* 10.5.3.12 [24.008] */
Harald Welteec8b4502010-02-20 20:34:29 +01001698
1699#define GSM48_IE_BEARER_CAP 0x04 /* 10.5.4.5 */
1700#define GSM48_IE_CAUSE 0x08 /* 10.5.4.11 */
1701#define GSM48_IE_CC_CAP 0x15 /* 10.5.4.5a */
1702#define GSM48_IE_ALERT 0x19 /* 10.5.4.26 */
1703#define GSM48_IE_FACILITY 0x1c /* 10.5.4.15 */
1704#define GSM48_IE_PROGR_IND 0x1e /* 10.5.4.21 */
1705#define GSM48_IE_AUX_STATUS 0x24 /* 10.5.4.4 */
1706#define GSM48_IE_NOTIFY 0x27 /* 10.5.4.20 */
1707#define GSM48_IE_KPD_FACILITY 0x2c /* 10.5.4.17 */
1708#define GSM48_IE_SIGNAL 0x34 /* 10.5.4.23 */
1709#define GSM48_IE_CONN_BCD 0x4c /* 10.5.4.13 */
1710#define GSM48_IE_CONN_SUB 0x4d /* 10.5.4.14 */
1711#define GSM48_IE_CALLING_BCD 0x5c /* 10.5.4.9 */
1712#define GSM48_IE_CALLING_SUB 0x5d /* 10.5.4.10 */
1713#define GSM48_IE_CALLED_BCD 0x5e /* 10.5.4.7 */
1714#define GSM48_IE_CALLED_SUB 0x6d /* 10.5.4.8 */
1715#define GSM48_IE_REDIR_BCD 0x74 /* 10.5.4.21a */
1716#define GSM48_IE_REDIR_SUB 0x75 /* 10.5.4.21b */
1717#define GSM48_IE_LOWL_COMPAT 0x7c /* 10.5.4.18 */
1718#define GSM48_IE_HIGHL_COMPAT 0x7d /* 10.5.4.16 */
1719#define GSM48_IE_USER_USER 0x7e /* 10.5.4.25 */
1720#define GSM48_IE_SS_VERS 0x7f /* 10.5.4.24 */
1721#define GSM48_IE_MORE_DATA 0xa0 /* 10.5.4.19 */
1722#define GSM48_IE_CLIR_SUPP 0xa1 /* 10.5.4.11a */
1723#define GSM48_IE_CLIR_INVOC 0xa2 /* 10.5.4.11b */
1724#define GSM48_IE_REV_C_SETUP 0xa3 /* 10.5.4.22a */
1725#define GSM48_IE_REPEAT_CIR 0xd1 /* 10.5.4.22 */
1726#define GSM48_IE_REPEAT_SEQ 0xd3 /* 10.5.4.22 */
1727
1728/* Section 10.5.4.11 / Table 10.5.122 */
1729#define GSM48_CAUSE_CS_GSM 0x60
1730
1731/* Section 9.1.2 / Table 9.3 */
Andreas Eversberg014cb872010-07-12 09:11:00 +02001732/* RR elements */
1733#define GSM48_IE_VGCS_TARGET 0x01
1734//#define GSM48_IE_VGCS_T_MODE_I 0x01
1735#define GSM48_IE_FRQSHORT_AFTER 0x02
1736#define GSM48_IE_MUL_RATE_CFG 0x03 /* 10.5.2.21aa */
1737#define GSM48_IE_FREQ_L_AFTER 0x05
Harald Welteec8b4502010-02-20 20:34:29 +01001738#define GSM48_IE_MSLOT_DESC 0x10
Harald Welteec8b4502010-02-20 20:34:29 +01001739#define GSM48_IE_CHANMODE_2 0x11
Andreas Eversberg014cb872010-07-12 09:11:00 +02001740#define GSM48_IE_FRQSHORT_BEFORE 0x12
1741//#define GSM48_IE_FRQSHORT_BEFOR 0x12
Harald Welteec8b4502010-02-20 20:34:29 +01001742#define GSM48_IE_CHANMODE_3 0x13
1743#define GSM48_IE_CHANMODE_4 0x14
1744#define GSM48_IE_CHANMODE_5 0x15
1745#define GSM48_IE_CHANMODE_6 0x16
1746#define GSM48_IE_CHANMODE_7 0x17
1747#define GSM48_IE_CHANMODE_8 0x18
1748#define GSM48_IE_CHANDESC_2 0x64
Harald Welte639f74b2010-06-15 09:32:14 +02001749#define GSM48_IE_MA_AFTER 0x72
1750#define GSM48_IE_START_TIME 0x7c
1751#define GSM48_IE_FREQ_L_BEFORE 0x19
Andreas Eversberg014cb872010-07-12 09:11:00 +02001752//#define GSM48_IE_FRQLIST_BEFORE 0x19
Harald Welte639f74b2010-06-15 09:32:14 +02001753#define GSM48_IE_CH_DESC_1_BEFORE 0x1c
Andreas Eversberg014cb872010-07-12 09:11:00 +02001754//#define GSM48_IE_CHDES_1_BEFORE 0x1c
Harald Welte639f74b2010-06-15 09:32:14 +02001755#define GSM48_IE_CH_DESC_2_BEFORE 0x1d
Andreas Eversberg014cb872010-07-12 09:11:00 +02001756//#define GSM48_IE_CHDES_2_BEFORE 0x1d
Harald Welte639f74b2010-06-15 09:32:14 +02001757#define GSM48_IE_F_CH_SEQ_BEFORE 0x1e
Andreas Eversberg014cb872010-07-12 09:11:00 +02001758//#define GSM48_IE_FRQSEQ_BEFORE 0x1e
1759#define GSM48_IE_CLASSMARK3 0x20
Harald Welte639f74b2010-06-15 09:32:14 +02001760#define GSM48_IE_MA_BEFORE 0x21
Andreas Eversberg014cb872010-07-12 09:11:00 +02001761#define GSM48_IE_RR_PACKET_UL 0x22
1762#define GSM48_IE_RR_PACKET_DL 0x23
1763#define GSM48_IE_CELL_CH_DESC 0x62
1764#define GSM48_IE_CHANMODE_1 0x63
1765#define GSM48_IE_CHDES_2_AFTER 0x64
1766#define GSM48_IE_MODE_SEC_CH 0x66
1767#define GSM48_IE_F_CH_SEQ_AFTER 0x69
1768#define GSM48_IE_MA_AFTER 0x72
1769#define GSM48_IE_BA_RANGE 0x73
1770#define GSM48_IE_GROUP_CHDES 0x74
1771#define GSM48_IE_BA_LIST_PREF 0x75
1772#define GSM48_IE_MOB_OVSERV_DIF 0x77
Harald Weltecf2caeb2019-02-03 00:37:20 +01001773#define GSM48_IE_CELL_SEL_IND_AFTER_REL 0x77 /* 44.018 Section 9.1.7 */
Andreas Eversberg014cb872010-07-12 09:11:00 +02001774#define GSM48_IE_REALTIME_DIFF 0x7b
1775#define GSM48_IE_START_TIME 0x7c
Harald Weltecf2caeb2019-02-03 00:37:20 +01001776#define GSM48_IE_INDIVIDUAL_PRIORITIES 0x7c /* 44.018 Section 9.1.7 */
Andreas Eversberg014cb872010-07-12 09:11:00 +02001777#define GSM48_IE_TIMING_ADVANCE 0x7d
1778#define GSM48_IE_GROUP_CIP_SEQ 0x80
1779#define GSM48_IE_CIP_MODE_SET 0x90
1780#define GSM48_IE_GPRS_RESUMPT 0xc0
1781#define GSM48_IE_SYNC_IND 0xd0
1782/* System Information 4 (types are equal IEs above) */
1783#define GSM48_IE_CBCH_CHAN_DESC 0x64
1784#define GSM48_IE_CBCH_MOB_AL 0x72
Harald Welte639f74b2010-06-15 09:32:14 +02001785
Andreas Eversberg014cb872010-07-12 09:11:00 +02001786/* Additional MM elements */
1787#define GSM48_IE_LOCATION_AREA 0x13
Harald Welte82f94ef2016-05-05 23:33:27 +02001788#define GSM48_IE_AUTN 0x20
Neels Hofmeyr55a43b82017-02-02 20:27:55 +01001789#define GSM48_IE_AUTH_RES_EXT 0x21
1790#define GSM48_IE_AUTS 0x22
Andreas Eversberg014cb872010-07-12 09:11:00 +02001791#define GSM48_IE_PRIORITY_LEV 0x80
1792#define GSM48_IE_FOLLOW_ON_PROC 0xa1
1793#define GSM48_IE_CTS_PERMISSION 0xa2
Harald Welteec8b4502010-02-20 20:34:29 +01001794
Keith05d32782018-05-28 14:08:10 +02001795/* Section 10.5.4.21 / Table 10.5.127 */
1796
1797enum gsm48_progress_desc {
1798 GSM48_PROGR_NOT_E2E = 0x00,
1799 GSM48_PROGR_DEST_NOT_PLMN = 0x02,
1800 GSM48_PROGR_ORIG_NOT_PLMN = 0x03,
1801 GSM48_PROGR_RETURNED = 0x04,
1802 GSM48_PROGR_IN_BAND_AVAIL = 0x08,
1803 GSM48_PROGR_CALL_E2E = 0x20,
1804 GSM48_PROGR_QUEUEING = 0x40,
1805};
1806
Harald Welteec8b4502010-02-20 20:34:29 +01001807/* Section 10.5.4.23 / Table 10.5.130 */
1808enum gsm48_signal_val {
1809 GSM48_SIGNAL_DIALTONE = 0x00,
1810 GSM48_SIGNAL_RINGBACK = 0x01,
1811 GSM48_SIGNAL_INTERCEPT = 0x02,
1812 GSM48_SIGNAL_NET_CONG = 0x03,
1813 GSM48_SIGNAL_BUSY = 0x04,
1814 GSM48_SIGNAL_CONFIRM = 0x05,
1815 GSM48_SIGNAL_ANSWER = 0x06,
1816 GSM48_SIGNAL_CALL_WAIT = 0x07,
1817 GSM48_SIGNAL_OFF_HOOK = 0x08,
1818 GSM48_SIGNAL_OFF = 0x3f,
1819 GSM48_SIGNAL_ALERT_OFF = 0x4f,
1820};
1821
Keithadfa1992018-05-25 15:24:06 +02001822/* Section 10.5.4.11 / Table 10.5.122 */
1823enum gsm48_cause_coding {
1824 GSM48_CAUSE_CODING_CCITT_Q931 = 0x00,
1825 GSM48_CAUSE_CODING_RESERVED = 0x01,
1826 GSM48_CAUSE_CODING_NATIONAL = 0x02,
1827 GSM48_CAUSE_CODING_GSM = 0x03,
1828};
1829
Harald Welteec8b4502010-02-20 20:34:29 +01001830enum gsm48_cause_loc {
1831 GSM48_CAUSE_LOC_USER = 0x00,
1832 GSM48_CAUSE_LOC_PRN_S_LU = 0x01,
1833 GSM48_CAUSE_LOC_PUN_S_LU = 0x02,
1834 GSM48_CAUSE_LOC_TRANS_NET = 0x03,
1835 GSM48_CAUSE_LOC_PUN_S_RU = 0x04,
1836 GSM48_CAUSE_LOC_PRN_S_RU = 0x05,
1837 /* not defined */
1838 GSM48_CAUSE_LOC_INN_NET = 0x07,
1839 GSM48_CAUSE_LOC_NET_BEYOND = 0x0a,
1840};
1841
Neels Hofmeyr6ad50aa2019-01-14 20:28:56 +01001842/* 3GPP TS 44.018 10.5.2.31 RR Cause / Table 10.5.70 */
Harald Welteec8b4502010-02-20 20:34:29 +01001843enum gsm48_rr_cause {
1844 GSM48_RR_CAUSE_NORMAL = 0x00,
1845 GSM48_RR_CAUSE_ABNORMAL_UNSPEC = 0x01,
1846 GSM48_RR_CAUSE_ABNORMAL_UNACCT = 0x02,
1847 GSM48_RR_CAUSE_ABNORMAL_TIMER = 0x03,
1848 GSM48_RR_CAUSE_ABNORMAL_NOACT = 0x04,
1849 GSM48_RR_CAUSE_PREMPTIVE_REL = 0x05,
Andreas Eversbergc8cac642013-06-19 20:58:59 +02001850 GSM48_RR_CAUSE_HNDOVER_IMP = 0x08,
1851 GSM48_RR_CAUSE_CHAN_MODE_UNACCT = 0x09,
1852 GSM48_RR_CAUSE_FREQ_NOT_IMPL = 0x0a,
Harald Welteec8b4502010-02-20 20:34:29 +01001853 GSM48_RR_CAUSE_CALL_CLEARED = 0x41,
1854 GSM48_RR_CAUSE_SEMANT_INCORR = 0x5f,
1855 GSM48_RR_CAUSE_INVALID_MAND_INF = 0x60,
1856 GSM48_RR_CAUSE_MSG_TYPE_N = 0x61,
1857 GSM48_RR_CAUSE_MSG_TYPE_N_COMPAT= 0x62,
1858 GSM48_RR_CAUSE_COND_IE_ERROR = 0x64,
1859 GSM48_RR_CAUSE_NO_CELL_ALLOC_A = 0x65,
1860 GSM48_RR_CAUSE_PROT_ERROR_UNSPC = 0x6f,
1861};
1862
1863/* Section 10.5.4.11 CC Cause / Table 10.5.123 */
1864enum gsm48_cc_cause {
1865 GSM48_CC_CAUSE_UNASSIGNED_NR = 1,
1866 GSM48_CC_CAUSE_NO_ROUTE = 3,
1867 GSM48_CC_CAUSE_CHAN_UNACCEPT = 6,
1868 GSM48_CC_CAUSE_OP_DET_BARRING = 8,
1869 GSM48_CC_CAUSE_NORM_CALL_CLEAR = 16,
1870 GSM48_CC_CAUSE_USER_BUSY = 17,
1871 GSM48_CC_CAUSE_USER_NOTRESPOND = 18,
1872 GSM48_CC_CAUSE_USER_ALERTING_NA = 19,
1873 GSM48_CC_CAUSE_CALL_REJECTED = 21,
1874 GSM48_CC_CAUSE_NUMBER_CHANGED = 22,
1875 GSM48_CC_CAUSE_PRE_EMPTION = 25,
1876 GSM48_CC_CAUSE_NONSE_USER_CLR = 26,
1877 GSM48_CC_CAUSE_DEST_OOO = 27,
1878 GSM48_CC_CAUSE_INV_NR_FORMAT = 28,
1879 GSM48_CC_CAUSE_FACILITY_REJ = 29,
1880 GSM48_CC_CAUSE_RESP_STATUS_INQ = 30,
1881 GSM48_CC_CAUSE_NORMAL_UNSPEC = 31,
1882 GSM48_CC_CAUSE_NO_CIRCUIT_CHAN = 34,
1883 GSM48_CC_CAUSE_NETWORK_OOO = 38,
1884 GSM48_CC_CAUSE_TEMP_FAILURE = 41,
1885 GSM48_CC_CAUSE_SWITCH_CONG = 42,
1886 GSM48_CC_CAUSE_ACC_INF_DISCARD = 43,
1887 GSM48_CC_CAUSE_REQ_CHAN_UNAVAIL = 44,
1888 GSM48_CC_CAUSE_RESOURCE_UNAVAIL = 47,
1889 GSM48_CC_CAUSE_QOS_UNAVAIL = 49,
1890 GSM48_CC_CAUSE_REQ_FAC_NOT_SUBSC= 50,
1891 GSM48_CC_CAUSE_INC_BARRED_CUG = 55,
1892 GSM48_CC_CAUSE_BEARER_CAP_UNAUTH= 57,
1893 GSM48_CC_CAUSE_BEARER_CA_UNAVAIL= 58,
1894 GSM48_CC_CAUSE_SERV_OPT_UNAVAIL = 63,
1895 GSM48_CC_CAUSE_BEARERSERV_UNIMPL= 65,
1896 GSM48_CC_CAUSE_ACM_GE_ACM_MAX = 68,
1897 GSM48_CC_CAUSE_REQ_FAC_NOTIMPL = 69,
1898 GSM48_CC_CAUSE_RESTR_BCAP_AVAIL = 70,
1899 GSM48_CC_CAUSE_SERV_OPT_UNIMPL = 79,
1900 GSM48_CC_CAUSE_INVAL_TRANS_ID = 81,
1901 GSM48_CC_CAUSE_USER_NOT_IN_CUG = 87,
1902 GSM48_CC_CAUSE_INCOMPAT_DEST = 88,
1903 GSM48_CC_CAUSE_INVAL_TRANS_NET = 91,
1904 GSM48_CC_CAUSE_SEMANTIC_INCORR = 95,
1905 GSM48_CC_CAUSE_INVAL_MAND_INF = 96,
1906 GSM48_CC_CAUSE_MSGTYPE_NOTEXIST = 97,
1907 GSM48_CC_CAUSE_MSGTYPE_INCOMPAT = 98,
1908 GSM48_CC_CAUSE_IE_NOTEXIST = 99,
1909 GSM48_CC_CAUSE_COND_IE_ERR = 100,
1910 GSM48_CC_CAUSE_MSG_INCOMP_STATE = 101,
1911 GSM48_CC_CAUSE_RECOVERY_TIMER = 102,
1912 GSM48_CC_CAUSE_PROTO_ERR = 111,
1913 GSM48_CC_CAUSE_INTERWORKING = 127,
1914};
1915
Keith3cdaa8d2018-08-31 20:09:18 +02001916extern const struct value_string gsm48_cc_cause_names[];
1917static inline const char *gsm48_cc_cause_name(enum gsm48_cc_cause val)
1918{ return get_value_string(gsm48_cc_cause_names, val); }
1919
Harald Welteec8b4502010-02-20 20:34:29 +01001920/* Annex G, GSM specific cause values for mobility management */
1921enum gsm48_reject_value {
1922 GSM48_REJECT_IMSI_UNKNOWN_IN_HLR = 2,
1923 GSM48_REJECT_ILLEGAL_MS = 3,
1924 GSM48_REJECT_IMSI_UNKNOWN_IN_VLR = 4,
1925 GSM48_REJECT_IMEI_NOT_ACCEPTED = 5,
1926 GSM48_REJECT_ILLEGAL_ME = 6,
1927 GSM48_REJECT_PLMN_NOT_ALLOWED = 11,
1928 GSM48_REJECT_LOC_NOT_ALLOWED = 12,
1929 GSM48_REJECT_ROAMING_NOT_ALLOWED = 13,
1930 GSM48_REJECT_NETWORK_FAILURE = 17,
Neels Hofmeyr55a43b82017-02-02 20:27:55 +01001931 GSM48_REJECT_SYNCH_FAILURE = 21,
Harald Welteec8b4502010-02-20 20:34:29 +01001932 GSM48_REJECT_CONGESTION = 22,
1933 GSM48_REJECT_SRV_OPT_NOT_SUPPORTED = 32,
1934 GSM48_REJECT_RQD_SRV_OPT_NOT_SUPPORTED = 33,
1935 GSM48_REJECT_SRV_OPT_TMP_OUT_OF_ORDER = 34,
1936 GSM48_REJECT_CALL_CAN_NOT_BE_IDENTIFIED = 38,
1937 GSM48_REJECT_INCORRECT_MESSAGE = 95,
1938 GSM48_REJECT_INVALID_MANDANTORY_INF = 96,
1939 GSM48_REJECT_MSG_TYPE_NOT_IMPLEMENTED = 97,
1940 GSM48_REJECT_MSG_TYPE_NOT_COMPATIBLE = 98,
1941 GSM48_REJECT_INF_ELEME_NOT_IMPLEMENTED = 99,
1942 GSM48_REJECT_CONDTIONAL_IE_ERROR = 100,
1943 GSM48_REJECT_MSG_NOT_COMPATIBLE = 101,
1944 GSM48_REJECT_PROTOCOL_ERROR = 111,
1945
1946 /* according to G.6 Additional cause codes for GMM */
1947 GSM48_REJECT_GPRS_NOT_ALLOWED = 7,
1948 GSM48_REJECT_SERVICES_NOT_ALLOWED = 8,
1949 GSM48_REJECT_MS_IDENTITY_NOT_DERVIVABLE = 9,
1950 GSM48_REJECT_IMPLICITLY_DETACHED = 10,
1951 GSM48_REJECT_GPRS_NOT_ALLOWED_IN_PLMN = 14,
1952 GSM48_REJECT_MSC_TMP_NOT_REACHABLE = 16,
1953};
1954
Neels Hofmeyraead2412018-04-06 04:31:00 +02001955extern const struct value_string gsm48_reject_value_names[];
1956static inline const char *gsm48_reject_value_name(enum gsm48_reject_value val)
1957{ return get_value_string(gsm48_reject_value_names, val); }
1958
Harald Welteec8b4502010-02-20 20:34:29 +01001959enum chreq_type {
1960 CHREQ_T_EMERG_CALL,
1961 CHREQ_T_CALL_REEST_TCH_F,
1962 CHREQ_T_CALL_REEST_TCH_H,
1963 CHREQ_T_CALL_REEST_TCH_H_DBL,
1964 CHREQ_T_SDCCH,
1965 CHREQ_T_TCH_F,
1966 CHREQ_T_VOICE_CALL_TCH_H,
1967 CHREQ_T_DATA_CALL_TCH_H,
1968 CHREQ_T_LOCATION_UPD,
1969 CHREQ_T_PAG_R_ANY_NECI0,
1970 CHREQ_T_PAG_R_ANY_NECI1,
1971 CHREQ_T_PAG_R_TCH_F,
1972 CHREQ_T_PAG_R_TCH_FH,
1973 CHREQ_T_LMU,
1974 CHREQ_T_RESERVED_SDCCH,
1975 CHREQ_T_RESERVED_IGNORE,
Alexander Couzensf48e8a82016-12-05 15:57:42 +01001976 CHREQ_T_PDCH_ONE_PHASE,
1977 CHREQ_T_PDCH_TWO_PHASE,
Alexander Couzens953f9292017-03-14 13:47:29 +01001978 _NUM_CHREQ_T,
Harald Welteec8b4502010-02-20 20:34:29 +01001979};
1980
1981/* Chapter 11.3 */
1982#define GSM48_T301 180, 0
1983#define GSM48_T303 30, 0
1984#define GSM48_T305 30, 0
1985#define GSM48_T306 30, 0
Harald Weltee50b0092018-01-27 09:40:34 +01001986#define GSM48_T308 10, 0 /* no spec default */
Harald Weltecd827102018-01-27 09:43:03 +01001987#define GSM48_T310 30, 0 /* no spec default */
Harald Weltee50b0092018-01-27 09:40:34 +01001988#define GSM48_T313 30, 0 /* no spec default */
Harald Welteec8b4502010-02-20 20:34:29 +01001989#define GSM48_T323 30, 0
Harald Weltee50b0092018-01-27 09:40:34 +01001990#define GSM48_T331 30, 0 /* no spec default */
1991#define GSM48_T333 30, 0 /* no spec default */
1992#define GSM48_T334 25, 0 /* min 15s */
1993#define GSM48_T338 30, 0 /* no spec default */
Andreas Eversberg014cb872010-07-12 09:11:00 +02001994#define GSM48_T303_MS 30, 0
1995#define GSM48_T305_MS 30, 0
1996#define GSM48_T308_MS 30, 0
1997#define GSM48_T310_MS 30, 0
1998#define GSM48_T313_MS 30, 0
1999#define GSM48_T323_MS 30, 0
2000#define GSM48_T332_MS 30, 0
2001#define GSM48_T335_MS 30, 0
Harald Welteec8b4502010-02-20 20:34:29 +01002002
2003/* Chapter 5.1.2.2 */
2004#define GSM_CSTATE_NULL 0
2005#define GSM_CSTATE_INITIATED 1
Andreas Eversberg1ef041f2010-04-09 07:52:12 +02002006#define GSM_CSTATE_MM_CONNECTION_PEND 2 /* see 10.5.4.6 */
Harald Welteec8b4502010-02-20 20:34:29 +01002007#define GSM_CSTATE_MO_CALL_PROC 3
2008#define GSM_CSTATE_CALL_DELIVERED 4
2009#define GSM_CSTATE_CALL_PRESENT 6
2010#define GSM_CSTATE_CALL_RECEIVED 7
2011#define GSM_CSTATE_CONNECT_REQUEST 8
2012#define GSM_CSTATE_MO_TERM_CALL_CONF 9
2013#define GSM_CSTATE_ACTIVE 10
2014#define GSM_CSTATE_DISCONNECT_REQ 12
2015#define GSM_CSTATE_DISCONNECT_IND 12
2016#define GSM_CSTATE_RELEASE_REQ 19
2017#define GSM_CSTATE_MO_ORIG_MODIFY 26
2018#define GSM_CSTATE_MO_TERM_MODIFY 27
2019#define GSM_CSTATE_CONNECT_IND 28
2020
2021#define SBIT(a) (1 << a)
2022#define ALL_STATES 0xffffffff
2023
2024/* Table 10.5.3/3GPP TS 04.08: Location Area Identification information element */
2025#define GSM_LAC_RESERVED_DETACHED 0x0
2026#define GSM_LAC_RESERVED_ALL_BTS 0xfffe
2027
2028/* GSM 04.08 Bearer Capability: Information Transfer Capability */
2029enum gsm48_bcap_itcap {
2030 GSM48_BCAP_ITCAP_SPEECH = 0,
2031 GSM48_BCAP_ITCAP_UNR_DIG_INF = 1,
2032 GSM48_BCAP_ITCAP_3k1_AUDIO = 2,
2033 GSM48_BCAP_ITCAP_FAX_G3 = 3,
2034 GSM48_BCAP_ITCAP_OTHER = 5,
2035 GSM48_BCAP_ITCAP_RESERVED = 7,
2036};
2037
2038/* GSM 04.08 Bearer Capability: Transfer Mode */
2039enum gsm48_bcap_tmod {
2040 GSM48_BCAP_TMOD_CIRCUIT = 0,
2041 GSM48_BCAP_TMOD_PACKET = 1,
2042};
2043
2044/* GSM 04.08 Bearer Capability: Coding Standard */
2045enum gsm48_bcap_coding {
2046 GSM48_BCAP_CODING_GSM_STD = 0,
2047};
2048
2049/* GSM 04.08 Bearer Capability: Radio Channel Requirements */
2050enum gsm48_bcap_rrq {
2051 GSM48_BCAP_RRQ_FR_ONLY = 1,
2052 GSM48_BCAP_RRQ_DUAL_HR = 2,
2053 GSM48_BCAP_RRQ_DUAL_FR = 3,
2054};
2055
Harald Weltec8a0b932012-08-24 21:27:26 +02002056/* GSM 04.08 Bearer Capability: Rate Adaption */
2057enum gsm48_bcap_ra {
2058 GSM48_BCAP_RA_NONE = 0,
2059 GSM48_BCAP_RA_V110_X30 = 1,
2060 GSM48_BCAP_RA_X31 = 2,
2061 GSM48_BCAP_RA_OTHER = 3,
2062};
2063
2064/* GSM 04.08 Bearer Capability: Signalling access protocol */
2065enum gsm48_bcap_sig_access {
2066 GSM48_BCAP_SA_I440_I450 = 1,
2067 GSM48_BCAP_SA_X21 = 2,
2068 GSM48_BCAP_SA_X28_DP_IN = 3,
2069 GSM48_BCAP_SA_X28_DP_UN = 4,
2070 GSM48_BCAP_SA_X28_NDP = 5,
2071 GSM48_BCAP_SA_X32 = 6,
2072};
2073
2074/* GSM 04.08 Bearer Capability: User Rate */
2075enum gsm48_bcap_user_rate {
2076 GSM48_BCAP_UR_300 = 1,
2077 GSM48_BCAP_UR_1200 = 2,
2078 GSM48_BCAP_UR_2400 = 3,
2079 GSM48_BCAP_UR_4800 = 4,
2080 GSM48_BCAP_UR_9600 = 5,
2081 GSM48_BCAP_UR_12000 = 6,
2082 GSM48_BCAP_UR_1200_75 = 7,
2083};
2084
2085/* GSM 04.08 Bearer Capability: Parity */
2086enum gsm48_bcap_parity {
2087 GSM48_BCAP_PAR_ODD = 0,
2088 GSM48_BCAP_PAR_EVEN = 2,
2089 GSM48_BCAP_PAR_NONE = 3,
2090 GSM48_BCAP_PAR_ZERO = 4,
2091 GSM48_BCAP_PAR_ONE = 5,
2092};
2093
2094/* GSM 04.08 Bearer Capability: Intermediate Rate */
2095enum gsm48_bcap_interm_rate {
2096 GSM48_BCAP_IR_8k = 2,
2097 GSM48_BCAP_IR_16k = 3,
2098};
2099
2100/* GSM 04.08 Bearer Capability: Transparency */
2101enum gsm48_bcap_transp {
2102 GSM48_BCAP_TR_TRANSP = 0,
2103 GSM48_BCAP_TR_RLP = 1,
2104 GSM48_BCAP_TR_TR_PREF = 2,
2105 GSM48_BCAP_TR_RLP_PREF = 3,
2106};
2107
2108/* GSM 04.08 Bearer Capability: Modem Type */
2109enum gsm48_bcap_modem_type {
2110 GSM48_BCAP_MT_NONE = 0,
2111 GSM48_BCAP_MT_V21 = 1,
2112 GSM48_BCAP_MT_V22 = 2,
2113 GSM48_BCAP_MT_V22bis = 3,
2114 GSM48_BCAP_MT_V23 = 4,
2115 GSM48_BCAP_MT_V26ter = 5,
2116 GSM48_BCAP_MT_V32 = 6,
2117 GSM48_BCAP_MT_UNDEF = 7,
2118 GSM48_BCAP_MT_AUTO_1 = 8,
2119};
2120
Neels Hofmeyr87e45502017-06-20 00:17:59 +02002121/*! GSM 04.08 Bearer Capability: Speech Version Indication
Philipp Maier3d9191e2017-05-31 17:22:03 +02002122 * (See also 3GPP TS 24.008, Table 10.5.103) */
Harald Welte30a8ec42012-08-24 23:00:05 +02002123enum gsm48_bcap_speech_ver {
Philipp Maiera9e193b2017-06-16 16:47:06 +02002124 GSM48_BCAP_SV_FR = 0, /*!< GSM FR V1 (GSM FR) */
2125 GSM48_BCAP_SV_HR = 1, /*!< GSM HR V1 (GSM HR) */
2126 GSM48_BCAP_SV_EFR = 2, /*!< GSM FR V2 (GSM EFR) */
2127 GSM48_BCAP_SV_AMR_F = 4, /*!< GSM FR V3 (FR AMR) */
2128 GSM48_BCAP_SV_AMR_H = 5, /*!< GSM HR V3 (HR_AMR) */
Philipp Maier3d9191e2017-05-31 17:22:03 +02002129 GSM48_BCAP_SV_AMR_OFW = 6, /*!< GSM FR V4 (OFR AMR-WB) */
2130 GSM48_BCAP_SV_AMR_OHW = 7, /*!< GSM HR V4 (OHR AMR-WB) */
2131 GSM48_BCAP_SV_AMR_FW = 8, /*!< GSM FR V5 (FR AMR-WB) */
2132 GSM48_BCAP_SV_AMR_OH = 11, /*!< GSM HR V6 (OHR AMR) */
Harald Welte30a8ec42012-08-24 23:00:05 +02002133};
2134
Harald Welteec8b4502010-02-20 20:34:29 +01002135#define GSM48_TMSI_LEN 5
2136#define GSM48_MID_TMSI_LEN (GSM48_TMSI_LEN + 2)
2137#define GSM48_MI_SIZE 32
2138
Maxff2eeda2018-01-04 18:43:44 +01002139/* 3GPP TS 24.008 ยง 10.5.5.15 Routing area identification */
Harald Weltea1c4f762010-05-01 11:59:42 +02002140struct gsm48_ra_id {
2141 uint8_t digits[3]; /* MCC + MNC BCD digits */
2142 uint16_t lac; /* Location Area Code */
2143 uint8_t rac; /* Routing Area Code */
2144} __attribute__ ((packed));
2145
Harald Welteb5503132011-05-24 15:01:53 +02002146#define GSM48_CELL_CHAN_DESC_SIZE 16
Harald Weltea1c4f762010-05-01 11:59:42 +02002147
Harald Welteb5503132011-05-24 15:01:53 +02002148#define GSM_MACBLOCK_LEN 23
2149#define GSM_MACBLOCK_PADDING 0x2b
Harald Welte55478082018-02-09 22:39:29 +01002150
2151/* Table 10.5.118 / 3GPP TS 24.008 Section 10.5.4.7 */
2152enum gsm48_type_of_number {
2153 GSM48_TON_UNKNOWN = 0,
2154 GSM48_TON_INTERNATIONAL = 1,
2155 GSM48_TON_NATIONAL = 2,
2156 GSM48_TON_NET_SPEC = 3,
2157 GSM48_TON_SHORT_CODE = 4,
2158 /* reserved */
2159};
2160
2161/* Table 10.5.118 / 3GPP TS 24.008 Section 10.5.4.7 */
2162enum gsm48_numbering_plan {
2163 GSM48_NPI_UNKNOWN = 0,
2164 GSM48_NPI_ISDN_E164 = 1,
2165 GSM48_NPI_DATA_X121 = 3,
2166 GSM48_NPI_TELEX_F69 = 4,
2167 GSM48_NPI_NATIONAL = 8,
2168 GSM48_NPI_PRIVATE = 9,
2169 GSM48_NPI_CTS = 11,
2170 /* reserved */
2171};