blob: c97df168d7385335de2b8b0069cc548ad1e7f3ee [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);
Harald Welte4a62eda2019-03-18 18:27:00 +010073char *osmo_gsm48_classmark_a5_name_buf(char *buf, size_t buf_len, const struct osmo_gsm48_classmark *cm);
Neels Hofmeyr7740d262019-01-16 16:53:26 +010074void osmo_gsm48_classmark_update(struct osmo_gsm48_classmark *dst, const struct osmo_gsm48_classmark *src);
75
Andreas Eversberg014cb872010-07-12 09:11:00 +020076/* Chapter 10.5.2.1b.3 */
Ruben Undheim720ac4a2016-05-27 22:03:59 +020077#if OSMO_IS_LITTLE_ENDIAN == 1
Andreas Eversberg014cb872010-07-12 09:11:00 +020078struct gsm48_range_1024 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +010079#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +020080 uint8_t w1_hi:2,
81 f0:1,
82 form_id:5;
83 uint8_t w1_lo;
84 uint8_t w2_hi;
85 uint8_t w3_hi:7,
86 w2_lo:1;
87 uint8_t w4_hi:6,
88 w3_lo:2;
89 uint8_t w5_hi:6,
90 w4_lo:2;
91 uint8_t w6_hi:6,
92 w5_lo:2;
93 uint8_t w7_hi:6,
94 w6_lo:2;
95 uint8_t w8_hi:6,
96 w7_lo:2;
97 uint8_t w9:7,
98 w8_lo:1;
99 uint8_t w11_hi:1,
100 w10:7;
101 uint8_t w12_hi:2,
102 w11_lo:6;
103 uint8_t w13_hi:3,
104 w12_lo:5;
105 uint8_t w14_hi:4,
106 w13_lo:4;
107 uint8_t w15_hi:5,
108 w14_lo:3;
109 uint8_t w16:6,
110 w15_lo:2;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100111#elif OSMO_IS_BIG_ENDIAN
112/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
113 uint8_t form_id:5, f0:1, w1_hi:2;
114 uint8_t w1_lo;
115 uint8_t w2_hi;
116 uint8_t w2_lo:1, w3_hi:7;
117 uint8_t w3_lo:2, w4_hi:6;
118 uint8_t w4_lo:2, w5_hi:6;
119 uint8_t w5_lo:2, w6_hi:6;
120 uint8_t w6_lo:2, w7_hi:6;
121 uint8_t w7_lo:2, w8_hi:6;
122 uint8_t w8_lo:1, w9:7;
123 uint8_t w10:7, w11_hi:1;
124 uint8_t w11_lo:6, w12_hi:2;
125 uint8_t w12_lo:5, w13_hi:3;
126 uint8_t w13_lo:4, w14_hi:4;
127 uint8_t w14_lo:3, w15_hi:5;
128 uint8_t w15_lo:2, w16:6;
129#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200130} __attribute__ ((packed));
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200131#else
132struct gsm48_range_1024 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100133#if OSMO_IS_LITTLE_ENDIAN
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200134 uint8_t form_id:5,
135 f0:1,
136 w1_hi:2;
137 uint8_t w1_lo;
138 uint8_t w2_hi;
139 uint8_t w2_lo:1,
140 w3_hi:7;
141 uint8_t w3_lo:2,
142 w4_hi:6;
143 uint8_t w4_lo:2,
144 w5_hi:6;
145 uint8_t w5_lo:2,
146 w6_hi:6;
147 uint8_t w6_lo:2,
148 w7_hi:6;
149 uint8_t w7_lo:2,
150 w8_hi:6;
151 uint8_t w8_lo:1,
152 w9:7;
153 uint8_t w10:7,
154 w11_hi:1;
155 uint8_t w11_lo:6,
156 w12_hi:2;
157 uint8_t w12_lo:5,
158 w13_hi:3;
159 uint8_t w13_lo:4,
160 w14_hi:4;
161 uint8_t w14_lo:3,
162 w15_hi:5;
163 uint8_t w15_lo:2,
164 w16:6;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100165#elif OSMO_IS_BIG_ENDIAN
166/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
167 uint8_t w1_hi:2, f0:1, form_id:5;
168 uint8_t w1_lo;
169 uint8_t w2_hi;
170 uint8_t w3_hi:7, w2_lo:1;
171 uint8_t w4_hi:6, w3_lo:2;
172 uint8_t w5_hi:6, w4_lo:2;
173 uint8_t w6_hi:6, w5_lo:2;
174 uint8_t w7_hi:6, w6_lo:2;
175 uint8_t w8_hi:6, w7_lo:2;
176 uint8_t w9:7, w8_lo:1;
177 uint8_t w11_hi:1, w10:7;
178 uint8_t w12_hi:2, w11_lo:6;
179 uint8_t w13_hi:3, w12_lo:5;
180 uint8_t w14_hi:4, w13_lo:4;
181 uint8_t w15_hi:5, w14_lo:3;
182 uint8_t w16:6, w15_lo:2;
183#endif
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200184} __attribute__ ((packed));
185#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200186
187/* Chapter 10.5.2.1b.4 */
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200188#if OSMO_IS_LITTLE_ENDIAN == 1
Andreas Eversberg014cb872010-07-12 09:11:00 +0200189struct gsm48_range_512 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100190#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +0200191 uint8_t orig_arfcn_hi:1,
192 form_id:7;
193 uint8_t orig_arfcn_mid;
194 uint8_t w1_hi:7,
195 orig_arfcn_lo:1;
196 uint8_t w2_hi:6,
197 w1_lo:2;
198 uint8_t w3_hi:6,
199 w2_lo:2;
200 uint8_t w4_hi:6,
201 w3_lo:2;
202 uint8_t w5:7,
203 w4_lo:1;
204 uint8_t w7_hi:1,
205 w6:7;
206 uint8_t w8_hi:2,
207 w7_lo:6;
208 uint8_t w9_hi:4,
209 w8_lo:4;
210 uint8_t w10:6,
211 w9_lo:2;
212 uint8_t w12_hi:2,
213 w11:6;
214 uint8_t w13_hi:4,
215 w12_lo:4;
216 uint8_t w14:6,
217 w13_lo:2;
218 uint8_t w16_hi:2,
219 w15:6;
220 uint8_t w17:5,
221 w16_lo:3;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100222#elif OSMO_IS_BIG_ENDIAN
223/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
224 uint8_t form_id:7, orig_arfcn_hi:1;
225 uint8_t orig_arfcn_mid;
226 uint8_t orig_arfcn_lo:1, w1_hi:7;
227 uint8_t w1_lo:2, w2_hi:6;
228 uint8_t w2_lo:2, w3_hi:6;
229 uint8_t w3_lo:2, w4_hi:6;
230 uint8_t w4_lo:1, w5:7;
231 uint8_t w6:7, w7_hi:1;
232 uint8_t w7_lo:6, w8_hi:2;
233 uint8_t w8_lo:4, w9_hi:4;
234 uint8_t w9_lo:2, w10:6;
235 uint8_t w11:6, w12_hi:2;
236 uint8_t w12_lo:4, w13_hi:4;
237 uint8_t w13_lo:2, w14:6;
238 uint8_t w15:6, w16_hi:2;
239 uint8_t w16_lo:3, w17:5;
240#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200241} __attribute__ ((packed));
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200242#else
243struct gsm48_range_512 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100244#if OSMO_IS_LITTLE_ENDIAN
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200245 uint8_t form_id:7,
246 orig_arfcn_hi:1;
247 uint8_t orig_arfcn_mid;
248 uint8_t orig_arfcn_lo:1,
249 w1_hi:7;
250 uint8_t w1_lo:2,
251 w2_hi:6;
252 uint8_t w2_lo:2,
253 w3_hi:6;
254 uint8_t w3_lo:2,
255 w4_hi:6;
256 uint8_t w4_lo:1,
257 w5:7;
258 uint8_t w6:7,
259 w7_hi:1;
260 uint8_t w7_lo:6,
261 w8_hi:2;
262 uint8_t w8_lo:4,
263 w9_hi:4;
264 uint8_t w9_lo:2,
265 w10:6;
266 uint8_t w11:6,
267 w12_hi:2;
268 uint8_t w12_lo:4,
269 w13_hi:4;
270 uint8_t w13_lo:2,
271 w14:6;
272 uint8_t w15:6,
273 w16_hi:2;
274 uint8_t w16_lo:3,
275 w17:5;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100276#elif OSMO_IS_BIG_ENDIAN
277/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
278 uint8_t orig_arfcn_hi:1, form_id:7;
279 uint8_t orig_arfcn_mid;
280 uint8_t w1_hi:7, orig_arfcn_lo:1;
281 uint8_t w2_hi:6, w1_lo:2;
282 uint8_t w3_hi:6, w2_lo:2;
283 uint8_t w4_hi:6, w3_lo:2;
284 uint8_t w5:7, w4_lo:1;
285 uint8_t w7_hi:1, w6:7;
286 uint8_t w8_hi:2, w7_lo:6;
287 uint8_t w9_hi:4, w8_lo:4;
288 uint8_t w10:6, w9_lo:2;
289 uint8_t w12_hi:2, w11:6;
290 uint8_t w13_hi:4, w12_lo:4;
291 uint8_t w14:6, w13_lo:2;
292 uint8_t w16_hi:2, w15:6;
293 uint8_t w17:5, w16_lo:3;
294#endif
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200295} __attribute__ ((packed));
296#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200297
298/* Chapter 10.5.2.1b.5 */
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200299#if OSMO_IS_LITTLE_ENDIAN == 1
Andreas Eversberg014cb872010-07-12 09:11:00 +0200300struct gsm48_range_256 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100301#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +0200302 uint8_t orig_arfcn_hi:1,
303 form_id:7;
304 uint8_t orig_arfcn_mid;
305 uint8_t w1_hi:7,
306 orig_arfcn_lo:1;
307 uint8_t w2:7,
308 w1_lo:1;
309 uint8_t w4_hi:1,
310 w3:7;
311 uint8_t w5_hi:3,
312 w4_lo:5;
313 uint8_t w6_hi:5,
314 w5_lo:3;
315 uint8_t w8_hi:1,
316 w7:6,
317 w6_lo:1;
318 uint8_t w9_hi:4,
319 w8_lo:4;
320 uint8_t w11_hi:2,
321 w10:5,
322 w9_lo:1;
323 uint8_t w12:5,
324 w11_lo:3;
325 uint8_t w14_hi:3,
326 w13:5;
327 uint8_t w16_hi:1,
328 w15:5,
329 w14_lo:2;
330 uint8_t w18_hi:1,
331 w17:4,
332 w16_lo:3;
333 uint8_t w20_hi:1,
334 w19:4,
335 w18_lo:3;
336 uint8_t spare:1,
337 w21:4,
338 w20_lo:3;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100339#elif OSMO_IS_BIG_ENDIAN
340/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
341 uint8_t form_id:7, orig_arfcn_hi:1;
342 uint8_t orig_arfcn_mid;
343 uint8_t orig_arfcn_lo:1, w1_hi:7;
344 uint8_t w1_lo:1, w2:7;
345 uint8_t w3:7, w4_hi:1;
346 uint8_t w4_lo:5, w5_hi:3;
347 uint8_t w5_lo:3, w6_hi:5;
348 uint8_t w6_lo:1, w7:6, w8_hi:1;
349 uint8_t w8_lo:4, w9_hi:4;
350 uint8_t w9_lo:1, w10:5, w11_hi:2;
351 uint8_t w11_lo:3, w12:5;
352 uint8_t w13:5, w14_hi:3;
353 uint8_t w14_lo:2, w15:5, w16_hi:1;
354 uint8_t w16_lo:3, w17:4, w18_hi:1;
355 uint8_t w18_lo:3, w19:4, w20_hi:1;
356 uint8_t w20_lo:3, w21:4, spare:1;
357#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200358} __attribute__ ((packed));
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200359#else
360struct gsm48_range_256 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100361#if OSMO_IS_LITTLE_ENDIAN
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200362 uint8_t form_id:7,
363 orig_arfcn_hi:1;
364 uint8_t orig_arfcn_mid;
365 uint8_t orig_arfcn_lo:1,
366 w1_hi:7;
367 uint8_t w1_lo:1,
368 w2:7;
369 uint8_t w3:7,
370 w4_hi:1;
371 uint8_t w4_lo:5,
372 w5_hi:3;
373 uint8_t w5_lo:3,
374 w6_hi:5;
375 uint8_t w6_lo:1,
376 w7:6,
377 w8_hi:1;
378 uint8_t w8_lo:4,
379 w9_hi:4;
380 uint8_t w9_lo:1,
381 w10:5,
382 w11_hi:2;
383 uint8_t w11_lo:3,
384 w12:5;
385 uint8_t w13:5,
386 w14_hi:3;
387 uint8_t w14_lo:2,
388 w15:5,
389 w16_hi:1;
390 uint8_t w16_lo:3,
391 w17:4,
392 w18_hi:1;
393 uint8_t w18_lo:3,
394 w19:4,
395 w20_hi:1;
396 uint8_t w20_lo:3,
397 w21:4,
398 spare:1;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100399#elif OSMO_IS_BIG_ENDIAN
400/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
401 uint8_t orig_arfcn_hi:1, form_id:7;
402 uint8_t orig_arfcn_mid;
403 uint8_t w1_hi:7, orig_arfcn_lo:1;
404 uint8_t w2:7, w1_lo:1;
405 uint8_t w4_hi:1, w3:7;
406 uint8_t w5_hi:3, w4_lo:5;
407 uint8_t w6_hi:5, w5_lo:3;
408 uint8_t w8_hi:1, w7:6, w6_lo:1;
409 uint8_t w9_hi:4, w8_lo:4;
410 uint8_t w11_hi:2, w10:5, w9_lo:1;
411 uint8_t w12:5, w11_lo:3;
412 uint8_t w14_hi:3, w13:5;
413 uint8_t w16_hi:1, w15:5, w14_lo:2;
414 uint8_t w18_hi:1, w17:4, w16_lo:3;
415 uint8_t w20_hi:1, w19:4, w18_lo:3;
416 uint8_t spare:1, w21:4, w20_lo:3;
417#endif
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200418} __attribute__ ((packed));
419#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200420
421/* Chapter 10.5.2.1b.6 */
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200422#if OSMO_IS_LITTLE_ENDIAN == 1
Andreas Eversberg014cb872010-07-12 09:11:00 +0200423struct gsm48_range_128 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100424#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +0200425 uint8_t orig_arfcn_hi:1,
426 form_id:7;
427 uint8_t orig_arfcn_mid;
428 uint8_t w1:7,
429 orig_arfcn_lo:1;
430 uint8_t w3_hi:2,
431 w2:6;
432 uint8_t w4_hi:4,
433 w3_lo:4;
434 uint8_t w6_hi:2,
435 w5:5,
436 w4_lo:1;
437 uint8_t w7:5,
438 w6_lo:3;
439 uint8_t w9:4,
440 w8:4;
441 uint8_t w11:4,
442 w10:4;
443 uint8_t w13:4,
444 w12:4;
445 uint8_t w15:4,
446 w14:4;
447 uint8_t w18_hi:2,
448 w17:3,
449 w16:3;
450 uint8_t w21_hi:1,
451 w20:3,
452 w19:3,
453 w18_lo:1;
454 uint8_t w23:3,
455 w22:3,
456 w21_lo:2;
457 uint8_t w26_hi:2,
458 w25:3,
459 w24:3;
460 uint8_t spare:1,
461 w28:3,
462 w27:3,
463 w26_lo:1;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100464#elif OSMO_IS_BIG_ENDIAN
465/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
466 uint8_t form_id:7, orig_arfcn_hi:1;
467 uint8_t orig_arfcn_mid;
468 uint8_t orig_arfcn_lo:1, w1:7;
469 uint8_t w2:6, w3_hi:2;
470 uint8_t w3_lo:4, w4_hi:4;
471 uint8_t w4_lo:1, w5:5, w6_hi:2;
472 uint8_t w6_lo:3, w7:5;
473 uint8_t w8:4, w9:4;
474 uint8_t w10:4, w11:4;
475 uint8_t w12:4, w13:4;
476 uint8_t w14:4, w15:4;
477 uint8_t w16:3, w17:3, w18_hi:2;
478 uint8_t w18_lo:1, w19:3, w20:3, w21_hi:1;
479 uint8_t w21_lo:2, w22:3, w23:3;
480 uint8_t w24:3, w25:3, w26_hi:2;
481 uint8_t w26_lo:1, w27:3, w28:3, spare:1;
482#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200483} __attribute__ ((packed));
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200484#else
485struct gsm48_range_128 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100486#if OSMO_IS_LITTLE_ENDIAN
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200487 uint8_t form_id:7,
488 orig_arfcn_hi:1;
489 uint8_t orig_arfcn_mid;
490 uint8_t orig_arfcn_lo:1,
491 w1:7;
492 uint8_t w2:6,
493 w3_hi:2;
494 uint8_t w3_lo:4,
495 w4_hi:4;
496 uint8_t w4_lo:1,
497 w5:5,
498 w6_hi:2;
499 uint8_t w6_lo:3,
500 w7:5;
501 uint8_t w8:4,
502 w9:4;
503 uint8_t w10:4,
504 w11:4;
505 uint8_t w12:4,
506 w13:4;
507 uint8_t w14:4,
508 w15:4;
509 uint8_t w16:3,
510 w17:3,
511 w18_hi:2;
512 uint8_t w18_lo:1,
513 w19:3,
514 w20:3,
515 w21_hi:1;
516 uint8_t w21_lo:2,
517 w22:3,
518 w23:3;
519 uint8_t w24:3,
520 w25:3,
521 w26_hi:2;
522 uint8_t w26_lo:1,
523 w27:3,
524 w28:3,
525 spare:1;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100526#elif OSMO_IS_BIG_ENDIAN
527/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
528 uint8_t orig_arfcn_hi:1, form_id:7;
529 uint8_t orig_arfcn_mid;
530 uint8_t w1:7, orig_arfcn_lo:1;
531 uint8_t w3_hi:2, w2:6;
532 uint8_t w4_hi:4, w3_lo:4;
533 uint8_t w6_hi:2, w5:5, w4_lo:1;
534 uint8_t w7:5, w6_lo:3;
535 uint8_t w9:4, w8:4;
536 uint8_t w11:4, w10:4;
537 uint8_t w13:4, w12:4;
538 uint8_t w15:4, w14:4;
539 uint8_t w18_hi:2, w17:3, w16:3;
540 uint8_t w21_hi:1, w20:3, w19:3, w18_lo:1;
541 uint8_t w23:3, w22:3, w21_lo:2;
542 uint8_t w26_hi:2, w25:3, w24:3;
543 uint8_t spare:1, w28:3, w27:3, w26_lo:1;
544#endif
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200545} __attribute__ ((packed));
546#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200547
548/* Chapter 10.5.2.1b.7 */
549struct gsm48_var_bit {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100550#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +0200551 uint8_t orig_arfcn_hi:1,
552 form_id:7;
553 uint8_t orig_arfcn_mid;
554 uint8_t rrfcn1_7:7,
555 orig_arfcn_lo:1;
556 uint8_t rrfcn8_111[13];
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100557#elif OSMO_IS_BIG_ENDIAN
558/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
559 uint8_t form_id:7, orig_arfcn_hi:1;
560 uint8_t orig_arfcn_mid;
561 uint8_t orig_arfcn_lo:1, rrfcn1_7:7;
562 uint8_t rrfcn8_111[13];
563#endif
Harald Welteec8b4502010-02-20 20:34:29 +0100564} __attribute__ ((packed));
565
566/* Chapter 10.5.2.5 */
567struct gsm48_chan_desc {
568 uint8_t chan_nr;
569 union {
570 struct {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100571#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +0100572 uint8_t maio_high:4,
573 h:1,
574 tsc:3;
575 uint8_t hsn:6,
576 maio_low:2;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100577#elif OSMO_IS_BIG_ENDIAN
578/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
579 uint8_t tsc:3, h:1, maio_high:4;
580 uint8_t maio_low:2, hsn:6;
581#endif
Andreas Eversberg4b332d72012-02-07 20:02:17 +0100582 } __attribute__ ((packed)) h1;
Harald Welteec8b4502010-02-20 20:34:29 +0100583 struct {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100584#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +0100585 uint8_t arfcn_high:2,
586 spare:2,
587 h:1,
588 tsc:3;
589 uint8_t arfcn_low;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100590#elif OSMO_IS_BIG_ENDIAN
591/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
592 uint8_t tsc:3, h:1, spare:2, arfcn_high:2;
593 uint8_t arfcn_low;
594#endif
Andreas Eversberg4b332d72012-02-07 20:02:17 +0100595 } __attribute__ ((packed)) h0;
596 } __attribute__ ((packed));
Harald Welteec8b4502010-02-20 20:34:29 +0100597} __attribute__ ((packed));
598
Andreas Eversberg014cb872010-07-12 09:11:00 +0200599/* Chapter 10.5.2.20 */
600struct gsm48_meas_res {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100601#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +0200602 uint8_t rxlev_full:6,
603 dtx_used:1,
604 ba_used:1;
605 uint8_t rxlev_sub:6,
606 meas_valid:1,
607 spare:1;
608 uint8_t no_nc_n_hi:1,
609 rxqual_sub:3,
610 rxqual_full:3,
611 spare2:1;
612 uint8_t rxlev_nc1:6,
613 no_nc_n_lo:2;
614 uint8_t bsic_nc1_hi:3,
615 bcch_f_nc1:5;
616 uint8_t rxlev_nc2_hi:5,
617 bsic_nc1_lo:3;
618 uint8_t bsic_nc2_hi:2,
619 bcch_f_nc2:5,
620 rxlev_nc2_lo:1;
621 uint8_t rxlev_nc3_hi:4,
622 bsic_nc2_lo:4;
623 uint8_t bsic_nc3_hi:1,
624 bcch_f_nc3:5,
625 rxlev_nc3_lo:2;
626 uint8_t rxlev_nc4_hi:3,
627 bsic_nc3_lo:5;
628 uint8_t bcch_f_nc4:5,
629 rxlev_nc4_lo:3;
630 uint8_t rxlev_nc5_hi:2,
631 bsic_nc4:6;
632 uint8_t bcch_f_nc5_hi:4,
633 rxlev_nc5_lo:4;
634 uint8_t rxlev_nc6_hi:1,
635 bsic_nc5:6,
636 bcch_f_nc5_lo:1;
637 uint8_t bcch_f_nc6_hi:3,
638 rxlev_nc6_lo:5;
639 uint8_t bsic_nc6:6,
640 bcch_f_nc6_lo:2;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100641#elif OSMO_IS_BIG_ENDIAN
642/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
643 uint8_t ba_used:1, dtx_used:1, rxlev_full:6;
644 uint8_t spare:1, meas_valid:1, rxlev_sub:6;
645 uint8_t spare2:1, rxqual_full:3, rxqual_sub:3, no_nc_n_hi:1;
646 uint8_t no_nc_n_lo:2, rxlev_nc1:6;
647 uint8_t bcch_f_nc1:5, bsic_nc1_hi:3;
648 uint8_t bsic_nc1_lo:3, rxlev_nc2_hi:5;
649 uint8_t rxlev_nc2_lo:1, bcch_f_nc2:5, bsic_nc2_hi:2;
650 uint8_t bsic_nc2_lo:4, rxlev_nc3_hi:4;
651 uint8_t rxlev_nc3_lo:2, bcch_f_nc3:5, bsic_nc3_hi:1;
652 uint8_t bsic_nc3_lo:5, rxlev_nc4_hi:3;
653 uint8_t rxlev_nc4_lo:3, bcch_f_nc4:5;
654 uint8_t bsic_nc4:6, rxlev_nc5_hi:2;
655 uint8_t rxlev_nc5_lo:4, bcch_f_nc5_hi:4;
656 uint8_t bcch_f_nc5_lo:1, bsic_nc5:6, rxlev_nc6_hi:1;
657 uint8_t rxlev_nc6_lo:5, bcch_f_nc6_hi:3;
658 uint8_t bcch_f_nc6_lo:2, bsic_nc6:6;
659#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200660} __attribute__ ((packed));
661
Harald Welteec8b4502010-02-20 20:34:29 +0100662/* Chapter 10.5.2.21aa */
663struct gsm48_multi_rate_conf {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100664#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +0100665 uint8_t smod : 2,
666 spare: 1,
667 icmi : 1,
668 nscb : 1,
669 ver : 3;
670 uint8_t m4_75 : 1,
671 m5_15 : 1,
672 m5_90 : 1,
673 m6_70 : 1,
674 m7_40 : 1,
675 m7_95 : 1,
676 m10_2 : 1,
677 m12_2 : 1;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100678#elif OSMO_IS_BIG_ENDIAN
679/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
680 uint8_t ver:3, nscb:1, icmi:1, spare:1, smod:2;
681 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;
682#endif
Harald Welteec8b4502010-02-20 20:34:29 +0100683} __attribute__((packed));
684
Andreas Eversberg014cb872010-07-12 09:11:00 +0200685/* Chapter 10.5.2.28(a) */
686struct gsm48_power_cmd {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100687#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +0200688 uint8_t power_level:5,
689 spare:2,
690 atc:1;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100691#elif OSMO_IS_BIG_ENDIAN
692/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
693 uint8_t atc:1, spare:2, power_level:5;
694#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200695} __attribute__((packed));
696
697/* Chapter 10.5.2.29 */
698struct gsm48_rach_control {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100699#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +0200700 uint8_t re :1,
701 cell_bar :1,
702 tx_integer :4,
703 max_trans :2;
Stefan Sperling18595152018-02-06 13:20:23 +0100704 uint8_t t2; /* ACC 8-15 barred flags */
705 uint8_t t3; /* ACC 0-7 barred flags */
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100706#elif OSMO_IS_BIG_ENDIAN
707/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
708 uint8_t max_trans:2, tx_integer:4, cell_bar:1, re:1;
709 uint8_t t2;
710 uint8_t t3;
711#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200712} __attribute__ ((packed));
713
Stefan Sperling18595152018-02-06 13:20:23 +0100714/*
715 * Mark an Access Control Class as barred.
716 * \param[in] rach_control A Rach Control Information Element.
717 * \param[in] acc Access Control Class number (0 - 15) which shall be barred.
718 */
719static inline void gsm48_barr_acc(struct gsm48_rach_control *rach_control, unsigned int acc)
720{
721 OSMO_ASSERT(acc >= 0 && acc <= 15);
722 if (acc >= 8)
723 rach_control->t2 |= (1 << (acc - 8));
724 else
725 rach_control->t3 |= (1 << (acc));
726}
727
728/*
729 * Mark an Access Control Class as allowed.
730 * \param[in] rach_control A Rach Control Information Element.
731 * \param[in] acc Access Control Class number (0 - 15) which shall be allowed.
732 */
733static inline void gsm48_allow_acc(struct gsm48_rach_control *rach_control, unsigned int acc)
734{
735 OSMO_ASSERT(acc >= 0 && acc <= 15);
736 if (acc >= 8)
737 rach_control->t2 &= ~(1 << (acc - 8));
738 else
739 rach_control->t3 &= ~(1 << (acc));
740}
741
742/*
743 * Indicate whether an Access Control Class is barred.
744 * \param[in] rach_control A Rach Control Information Element.
745 * \param[in] acc Access Control Class number (0 - 15).
746 * \returns true if the Access Control class is barred, false otherwise
747 */
748static inline bool gsm48_acc_is_barred(struct gsm48_rach_control *rach_control, unsigned int acc)
749{
750 OSMO_ASSERT(acc >= 0 && acc <= 15);
751 if (acc >= 8)
752 return (rach_control->t2 & (1 << (acc - 8))) != 0;
753 return (rach_control->t3 & (1 << (acc))) != 0;
754}
Andreas Eversberg014cb872010-07-12 09:11:00 +0200755
Harald Welteec8b4502010-02-20 20:34:29 +0100756/* Chapter 10.5.2.30 */
757struct gsm48_req_ref {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100758#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +0100759 uint8_t ra;
760 uint8_t t3_high:3,
Andreas Eversberg93364fc2010-06-25 02:50:06 +0200761 t1:5;
Harald Welteec8b4502010-02-20 20:34:29 +0100762 uint8_t t2:5,
763 t3_low:3;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100764#elif OSMO_IS_BIG_ENDIAN
765/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
766 uint8_t ra;
767 uint8_t t1:5, t3_high:3;
768 uint8_t t3_low:3, t2:5;
769#endif
Harald Welteec8b4502010-02-20 20:34:29 +0100770} __attribute__ ((packed));
771
Andreas Eversberg014cb872010-07-12 09:11:00 +0200772/* Chapter 10.5.2.38 */
773struct gsm48_start_time {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100774#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +0200775 uint8_t t3_high:3,
776 t1:5;
777 uint8_t t2:5,
778 t3_low:3;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100779#elif OSMO_IS_BIG_ENDIAN
780/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
781 uint8_t t1:5, t3_high:3;
782 uint8_t t3_low:3, t2:5;
783#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200784} __attribute__ ((packed));
785
786/* Chapter 10.5.2.39 */
787struct gsm48_sync_ind {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100788#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +0200789 uint8_t si:2,
790 rot:1,
791 nci:1,
792 sync_ie:4;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100793#elif OSMO_IS_BIG_ENDIAN
794/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
795 uint8_t sync_ie:4, nci:1, rot:1, si:2;
796#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200797} __attribute__((packed));
798
Harald Welteec8b4502010-02-20 20:34:29 +0100799/*
800 * Chapter 9.1.5/9.1.6
801 *
802 * For 9.1.6 the chan_desc has the meaning of 10.5.2.5a
803 */
804struct gsm48_chan_mode_modify {
805 struct gsm48_chan_desc chan_desc;
806 uint8_t mode;
807} __attribute__ ((packed));
808
809enum gsm48_chan_mode {
810 GSM48_CMODE_SIGN = 0x00,
811 GSM48_CMODE_SPEECH_V1 = 0x01,
812 GSM48_CMODE_SPEECH_EFR = 0x21,
813 GSM48_CMODE_SPEECH_AMR = 0x41,
814 GSM48_CMODE_DATA_14k5 = 0x0f,
815 GSM48_CMODE_DATA_12k0 = 0x03,
816 GSM48_CMODE_DATA_6k0 = 0x0b,
Bhaskar31e844b2013-05-16 17:06:35 +0530817 GSM48_CMODE_DATA_3k6 = 0x13,
Harald Welteec8b4502010-02-20 20:34:29 +0100818};
819
Maxfb348ee2016-03-30 21:14:53 +0200820extern const struct value_string gsm48_chan_mode_names[];
Philipp Maier5796a212018-07-12 17:48:26 +0200821static inline const char *gsm48_chan_mode_name(enum gsm48_chan_mode val)
822{ return get_value_string(gsm48_chan_mode_names, val); }
Maxfb348ee2016-03-30 21:14:53 +0200823
Harald Welteec8b4502010-02-20 20:34:29 +0100824/* Chapter 9.1.2 */
825struct gsm48_ass_cmd {
826 /* Semantic is from 10.5.2.5a */
827 struct gsm48_chan_desc chan_desc;
828 uint8_t power_command;
829 uint8_t data[0];
830} __attribute__((packed));
831
Andreas Eversbergfa832012010-09-01 23:37:07 +0200832/* Chapter 9.1.13 */
833struct gsm48_frq_redef {
834 /* Semantic is from 10.5.2.5a */
835 struct gsm48_chan_desc chan_desc;
836 uint8_t mob_alloc_len;
837 uint8_t mob_alloc[0];
838} __attribute__((packed));
839
Harald Welte548e3712017-07-10 22:32:08 +0200840/* Chapter 9.1.13b GPRS suspension request */
841struct gsm48_gprs_susp_req {
842 uint32_t tlli;
843 uint8_t ra_id[6];
844 uint8_t cause;
845 uint8_t options[0];
846} __attribute__ ((packed));
847
Harald Welteec8b4502010-02-20 20:34:29 +0100848/* Chapter 10.5.2.2 */
849struct gsm48_cell_desc {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100850#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +0100851 uint8_t bcc:3,
852 ncc:3,
853 arfcn_hi:2;
854 uint8_t arfcn_lo;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100855#elif OSMO_IS_BIG_ENDIAN
856/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
857 uint8_t arfcn_hi:2, ncc:3, bcc:3;
858 uint8_t arfcn_lo;
859#endif
Harald Welteec8b4502010-02-20 20:34:29 +0100860} __attribute__((packed));
861
862/* Chapter 9.1.15 */
863struct gsm48_ho_cmd {
864 struct gsm48_cell_desc cell_desc;
865 struct gsm48_chan_desc chan_desc;
866 uint8_t ho_ref;
867 uint8_t power_command;
868 uint8_t data[0];
869} __attribute__((packed));
870
871/* Chapter 9.1.18 */
872struct gsm48_imm_ass {
873 uint8_t l2_plen;
874 uint8_t proto_discr;
875 uint8_t msg_type;
876 uint8_t page_mode;
877 struct gsm48_chan_desc chan_desc;
878 struct gsm48_req_ref req_ref;
879 uint8_t timing_advance;
880 uint8_t mob_alloc_len;
881 uint8_t mob_alloc[0];
882} __attribute__ ((packed));
883
Holger Hans Peter Freyther5dcef3c2010-05-15 22:35:25 +0800884/* Chapter 9.1.25 */
885struct gsm48_pag_resp {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100886#if OSMO_IS_LITTLE_ENDIAN
Holger Hans Peter Freyther5dcef3c2010-05-15 22:35:25 +0800887 uint8_t spare:4,
888 key_seq:4;
889 uint32_t classmark2;
890 uint8_t mi_len;
891 uint8_t mi[0];
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100892#elif OSMO_IS_BIG_ENDIAN
893/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
894 uint8_t key_seq:4, spare:4;
895 uint32_t classmark2;
896 uint8_t mi_len;
897 uint8_t mi[0];
898#endif
Holger Hans Peter Freyther5dcef3c2010-05-15 22:35:25 +0800899} __attribute__ ((packed));
900
Harald Welteec8b4502010-02-20 20:34:29 +0100901/* Chapter 10.5.1.3 */
902struct gsm48_loc_area_id {
903 uint8_t digits[3]; /* BCD! */
904 uint16_t lac;
905} __attribute__ ((packed));
906
907/* Section 9.2.2 */
908struct gsm48_auth_req {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100909#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +0100910 uint8_t key_seq:4,
911 spare:4;
912 uint8_t rand[16];
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100913#elif OSMO_IS_BIG_ENDIAN
914/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
915 uint8_t spare:4, key_seq:4;
916 uint8_t rand[16];
917#endif
Harald Welteec8b4502010-02-20 20:34:29 +0100918} __attribute__ ((packed));
919
Sylvain Munautd005eab2010-06-10 13:30:50 +0200920/* Section 9.2.3 */
921struct gsm48_auth_resp {
922 uint8_t sres[4];
923} __attribute__ ((packed));
924
Harald Welteec8b4502010-02-20 20:34:29 +0100925/* Section 9.2.15 */
926struct gsm48_loc_upd_req {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100927#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +0100928 uint8_t type:4,
929 key_seq:4;
930 struct gsm48_loc_area_id lai;
931 struct gsm48_classmark1 classmark1;
932 uint8_t mi_len;
933 uint8_t mi[0];
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100934#elif OSMO_IS_BIG_ENDIAN
935/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
936 uint8_t key_seq:4, type:4;
937 struct gsm48_loc_area_id lai;
938 struct gsm48_classmark1 classmark1;
939 uint8_t mi_len;
940 uint8_t mi[0];
941#endif
Harald Welteec8b4502010-02-20 20:34:29 +0100942} __attribute__ ((packed));
943
944/* Section 10.1 */
945struct gsm48_hdr {
946 uint8_t proto_discr;
947 uint8_t msg_type;
948 uint8_t data[0];
949} __attribute__ ((packed));
950
951/* Section 9.1.3x System information Type header */
952struct gsm48_system_information_type_header {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100953#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +0100954 uint8_t l2_plen;
955 uint8_t rr_protocol_discriminator :4,
956 skip_indicator:4;
957 uint8_t system_information;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100958#elif OSMO_IS_BIG_ENDIAN
959/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
960 uint8_t l2_plen;
961 uint8_t skip_indicator:4, rr_protocol_discriminator:4;
962 uint8_t system_information;
963#endif
Harald Welteec8b4502010-02-20 20:34:29 +0100964} __attribute__ ((packed));
965
Harald Welteec8b4502010-02-20 20:34:29 +0100966/* Section 10.5.2.4 Cell Selection Parameters */
967struct gsm48_cell_sel_par {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100968#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +0100969 uint8_t ms_txpwr_max_ccch:5, /* GSM 05.08 MS-TXPWR-MAX-CCCH */
970 cell_resel_hyst:3; /* GSM 05.08 CELL-RESELECT-HYSTERESIS */
971 uint8_t rxlev_acc_min:6, /* GSM 05.08 RXLEV-ACCESS-MIN */
972 neci:1,
973 acs:1;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100974#elif OSMO_IS_BIG_ENDIAN
975/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
976 uint8_t cell_resel_hyst:3, ms_txpwr_max_ccch:5;
977 uint8_t acs:1, neci:1, rxlev_acc_min:6;
978#endif
Harald Welteec8b4502010-02-20 20:34:29 +0100979} __attribute__ ((packed));
980
Neels Hofmeyrd1c2fc62017-02-21 14:51:40 +0100981/* 3GPP TS 44.018 Section 10.5.2.11 Control Channel Description */
Harald Welteec8b4502010-02-20 20:34:29 +0100982struct gsm48_control_channel_descr {
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100983#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +0100984 uint8_t ccch_conf :3,
985 bs_ag_blks_res :3,
986 att :1,
Neels Hofmeyrd1c2fc62017-02-21 14:51:40 +0100987 mscr :1;
Harald Welteec8b4502010-02-20 20:34:29 +0100988 uint8_t bs_pa_mfrms : 3,
Neels Hofmeyrd1c2fc62017-02-21 14:51:40 +0100989 spare_1 :2,
990 cbq3 :2,
991 spare_2 :1;
Harald Welteec8b4502010-02-20 20:34:29 +0100992 uint8_t t3212;
Neels Hofmeyrb2600392018-11-16 00:20:39 +0100993#elif OSMO_IS_BIG_ENDIAN
994/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
995 uint8_t mscr:1, att:1, bs_ag_blks_res:3, ccch_conf:3;
996 uint8_t spare_2:1, cbq3:2, spare_1:2, bs_pa_mfrms:3;
997 uint8_t t3212;
998#endif
Harald Welteec8b4502010-02-20 20:34:29 +0100999} __attribute__ ((packed));
1000
Maxfe65fa72016-05-10 17:17:05 +02001001enum gsm48_dtx_mode {
1002 GSM48_DTX_MAY_BE_USED,
1003 GSM48_DTX_SHALL_BE_USED,
1004 GSM48_DTX_SHALL_NOT_BE_USED
1005};
1006
1007/* Cell Options for SI6, SACCH (10.5.2.3a.2) or SI3, BCCH (Table 10.5.2.3.1),
1008 3GPP TS 44.018 */
Harald Welteec8b4502010-02-20 20:34:29 +01001009struct gsm48_cell_options {
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001010#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +01001011 uint8_t radio_link_timeout:4,
1012 dtx:2,
1013 pwrc:1,
Maxfe65fa72016-05-10 17:17:05 +02001014 /* either DN-IND or top bit of DTX IND */
1015 d:1;
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001016#elif OSMO_IS_BIG_ENDIAN
1017/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
1018 uint8_t d:1, pwrc:1, dtx:2, radio_link_timeout:4;
1019#endif
Harald Welteec8b4502010-02-20 20:34:29 +01001020} __attribute__ ((packed));
1021
1022/* Section 9.2.9 CM service request */
1023struct gsm48_service_request {
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001024#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +01001025 uint8_t cm_service_type : 4,
1026 cipher_key_seq : 4;
1027 /* length + 3 bytes */
1028 uint32_t classmark;
1029 uint8_t mi_len;
1030 uint8_t mi[0];
1031 /* optional priority level */
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001032#elif OSMO_IS_BIG_ENDIAN
1033/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
1034 uint8_t cipher_key_seq:4, cm_service_type:4;
1035 uint32_t classmark;
1036 uint8_t mi_len;
1037 uint8_t mi[0];
1038#endif
Harald Welteec8b4502010-02-20 20:34:29 +01001039} __attribute__ ((packed));
1040
1041/* Section 9.1.31 System information Type 1 */
1042struct gsm48_system_information_type_1 {
1043 struct gsm48_system_information_type_header header;
1044 uint8_t cell_channel_description[16];
1045 struct gsm48_rach_control rach_control;
1046 uint8_t rest_octets[0]; /* NCH position on the CCCH */
1047} __attribute__ ((packed));
1048
1049/* Section 9.1.32 System information Type 2 */
1050struct gsm48_system_information_type_2 {
1051 struct gsm48_system_information_type_header header;
1052 uint8_t bcch_frequency_list[16];
1053 uint8_t ncc_permitted;
1054 struct gsm48_rach_control rach_control;
1055} __attribute__ ((packed));
1056
Andreas Eversberg014cb872010-07-12 09:11:00 +02001057/* Section 9.1.33 System information Type 2bis */
1058struct gsm48_system_information_type_2bis {
1059 struct gsm48_system_information_type_header header;
1060 uint8_t bcch_frequency_list[16];
1061 struct gsm48_rach_control rach_control;
1062 uint8_t rest_octets[0];
1063} __attribute__ ((packed));
1064
1065/* Section 9.1.34 System information Type 2ter */
1066struct gsm48_system_information_type_2ter {
1067 struct gsm48_system_information_type_header header;
1068 uint8_t ext_bcch_frequency_list[16];
1069 uint8_t rest_octets[0];
1070} __attribute__ ((packed));
1071
Maxe859aec2016-03-11 12:24:04 +01001072/* Section 9.1.34a System information Type 2quater */
1073struct gsm48_system_information_type_2quater {
1074 struct gsm48_system_information_type_header header;
1075 uint8_t rest_octets[0];
1076} __attribute__ ((packed));
1077
Harald Welteec8b4502010-02-20 20:34:29 +01001078/* Section 9.1.35 System information Type 3 */
1079struct gsm48_system_information_type_3 {
1080 struct gsm48_system_information_type_header header;
1081 uint16_t cell_identity;
1082 struct gsm48_loc_area_id lai;
1083 struct gsm48_control_channel_descr control_channel_desc;
1084 struct gsm48_cell_options cell_options;
1085 struct gsm48_cell_sel_par cell_sel_par;
1086 struct gsm48_rach_control rach_control;
1087 uint8_t rest_octets[0];
1088} __attribute__ ((packed));
1089
1090/* Section 9.1.36 System information Type 4 */
1091struct gsm48_system_information_type_4 {
1092 struct gsm48_system_information_type_header header;
1093 struct gsm48_loc_area_id lai;
1094 struct gsm48_cell_sel_par cell_sel_par;
1095 struct gsm48_rach_control rach_control;
1096 /* optional CBCH conditional CBCH... followed by
1097 mandantory SI 4 Reset Octets
1098 */
1099 uint8_t data[0];
1100} __attribute__ ((packed));
1101
1102/* Section 9.1.37 System information Type 5 */
1103struct gsm48_system_information_type_5 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001104#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +01001105 uint8_t rr_protocol_discriminator :4,
1106 skip_indicator:4;
1107 uint8_t system_information;
1108 uint8_t bcch_frequency_list[16];
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001109#elif OSMO_IS_BIG_ENDIAN
1110/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
1111 uint8_t skip_indicator:4, rr_protocol_discriminator:4;
1112 uint8_t system_information;
1113 uint8_t bcch_frequency_list[16];
1114#endif
Harald Welteec8b4502010-02-20 20:34:29 +01001115} __attribute__ ((packed));
1116
Andreas Eversberg014cb872010-07-12 09:11:00 +02001117/* Section 9.1.38 System information Type 5bis */
1118struct gsm48_system_information_type_5bis {
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001119#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +02001120 uint8_t rr_protocol_discriminator :4,
1121 skip_indicator:4;
1122 uint8_t system_information;
1123 uint8_t bcch_frequency_list[16];
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001124#elif OSMO_IS_BIG_ENDIAN
1125/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
1126 uint8_t skip_indicator:4, rr_protocol_discriminator:4;
1127 uint8_t system_information;
1128 uint8_t bcch_frequency_list[16];
1129#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +02001130} __attribute__ ((packed));
1131
1132/* Section 9.1.39 System information Type 5ter */
1133struct gsm48_system_information_type_5ter {
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001134#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +02001135 uint8_t rr_protocol_discriminator :4,
1136 skip_indicator:4;
1137 uint8_t system_information;
1138 uint8_t bcch_frequency_list[16];
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001139#elif OSMO_IS_BIG_ENDIAN
1140/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
1141 uint8_t skip_indicator:4, rr_protocol_discriminator:4;
1142 uint8_t system_information;
1143 uint8_t bcch_frequency_list[16];
1144#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +02001145} __attribute__ ((packed));
1146
Harald Welteec8b4502010-02-20 20:34:29 +01001147/* Section 9.1.40 System information Type 6 */
1148struct gsm48_system_information_type_6 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001149#if OSMO_IS_LITTLE_ENDIAN
Harald Welteec8b4502010-02-20 20:34:29 +01001150 uint8_t rr_protocol_discriminator :4,
1151 skip_indicator:4;
1152 uint8_t system_information;
1153 uint16_t cell_identity;
1154 struct gsm48_loc_area_id lai;
1155 struct gsm48_cell_options cell_options;
1156 uint8_t ncc_permitted;
1157 uint8_t rest_octets[0];
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001158#elif OSMO_IS_BIG_ENDIAN
1159/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
1160 uint8_t skip_indicator:4, rr_protocol_discriminator:4;
1161 uint8_t system_information;
1162 uint16_t cell_identity;
1163 struct gsm48_loc_area_id lai;
1164 struct gsm48_cell_options cell_options;
1165 uint8_t ncc_permitted;
1166 uint8_t rest_octets[0];
1167#endif
Harald Welteec8b4502010-02-20 20:34:29 +01001168} __attribute__ ((packed));
1169
1170/* Section 9.1.43a System Information type 13 */
1171struct gsm48_system_information_type_13 {
1172 struct gsm48_system_information_type_header header;
1173 uint8_t rest_octets[0];
1174} __attribute__ ((packed));
1175
1176/* Section 9.2.12 IMSI Detach Indication */
1177struct gsm48_imsi_detach_ind {
1178 struct gsm48_classmark1 classmark1;
1179 uint8_t mi_len;
1180 uint8_t mi[0];
1181} __attribute__ ((packed));
1182
Andreas Eversberg014cb872010-07-12 09:11:00 +02001183/* Section 9.1.1 */
1184struct gsm48_add_ass {
1185 /* Semantic is from 10.5.2.5 */
1186 struct gsm48_chan_desc chan_desc;
1187 uint8_t data[0];
1188} __attribute__((packed));
1189
1190/* Section 9.1.3 */
1191struct gsm48_ass_cpl {
1192 uint8_t rr_cause;
1193} __attribute__((packed));
1194
1195/* Section 9.1.4 */
1196struct gsm48_ass_fail {
1197 uint8_t rr_cause;
1198} __attribute__((packed));
1199
Andreas Eversbergfa832012010-09-01 23:37:07 +02001200/* Section 9.1.3 */
1201struct gsm48_ho_cpl {
1202 uint8_t rr_cause;
1203 uint8_t data[0];
1204} __attribute__((packed));
1205
1206/* Section 9.1.4 */
1207struct gsm48_ho_fail {
1208 uint8_t rr_cause;
1209} __attribute__((packed));
1210
Andreas Eversberg014cb872010-07-12 09:11:00 +02001211/* Section 9.1.7 */
1212struct gsm48_chan_rel {
1213 uint8_t rr_cause;
1214 uint8_t data[0];
1215} __attribute__((packed));
1216
1217/* Section 9.1.9 */
1218struct gsm48_cip_mode_cmd {
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001219#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +02001220 uint8_t sc:1,
1221 alg_id:3,
Sylvain Munaut77b6f6c2010-09-17 13:55:45 +02001222 cr:1,
1223 spare:3;
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001224#elif OSMO_IS_BIG_ENDIAN
1225/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
1226 uint8_t spare:3, cr:1, alg_id:3, sc:1;
1227#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +02001228} __attribute__((packed));
1229
1230/* Section 9.1.11 */
1231struct gsm48_cm_change {
1232 uint8_t cm2_len;
1233 struct gsm48_classmark2 cm2;
1234 uint8_t data[0];
1235} __attribute__((packed));
1236
1237/* Section 9.1.19 */
1238struct gsm48_imm_ass_ext {
1239 uint8_t l2_plen;
1240 uint8_t proto_discr;
1241 uint8_t msg_type;
1242 uint8_t page_mode;
1243 struct gsm48_chan_desc chan_desc1;
1244 struct gsm48_req_ref req_ref1;
1245 uint8_t timing_advance1;
1246 struct gsm48_chan_desc chan_desc2;
1247 struct gsm48_req_ref req_ref2;
1248 uint8_t timing_advance2;
1249 uint8_t mob_alloc_len;
1250 uint8_t mob_alloc[0];
1251} __attribute__ ((packed));
1252
1253/* Section 9.1.20 */
1254struct gsm48_imm_ass_rej {
1255 uint8_t l2_plen;
1256 uint8_t proto_discr;
1257 uint8_t msg_type;
1258 uint8_t page_mode;
1259 struct gsm48_req_ref req_ref1;
1260 uint8_t wait_ind1;
1261 struct gsm48_req_ref req_ref2;
1262 uint8_t wait_ind2;
1263 struct gsm48_req_ref req_ref3;
1264 uint8_t wait_ind3;
1265 struct gsm48_req_ref req_ref4;
1266 uint8_t wait_ind4;
1267 uint8_t rest[0];
1268} __attribute__ ((packed));
1269
1270/* Section 9.1.22 */
1271struct gsm48_paging1 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001272#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +02001273 uint8_t l2_plen;
1274 uint8_t proto_discr;
1275 uint8_t msg_type;
1276 uint8_t pag_mode:2,
1277 spare:2,
1278 cneed1:2,
1279 cneed2:2;
1280 uint8_t data[0];
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001281#elif OSMO_IS_BIG_ENDIAN
1282/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
1283 uint8_t l2_plen;
1284 uint8_t proto_discr;
1285 uint8_t msg_type;
1286 uint8_t cneed2:2, cneed1:2, spare:2, pag_mode:2;
1287 uint8_t data[0];
1288#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +02001289} __attribute__((packed));
1290
1291/* Section 9.1.23 */
1292struct gsm48_paging2 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001293#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +02001294 uint8_t l2_plen;
1295 uint8_t proto_discr;
1296 uint8_t msg_type;
1297 uint8_t pag_mode:2,
1298 spare:2,
1299 cneed1:2,
1300 cneed2:2;
1301 uint32_t tmsi1;
1302 uint32_t tmsi2;
1303 uint8_t data[0];
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001304#elif OSMO_IS_BIG_ENDIAN
1305/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
1306 uint8_t l2_plen;
1307 uint8_t proto_discr;
1308 uint8_t msg_type;
1309 uint8_t cneed2:2, cneed1:2, spare:2, pag_mode:2;
1310 uint32_t tmsi1;
1311 uint32_t tmsi2;
1312 uint8_t data[0];
1313#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +02001314} __attribute__((packed));
1315
1316/* Section 9.1.24 */
1317struct gsm48_paging3 {
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001318#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +02001319 uint8_t l2_plen;
1320 uint8_t proto_discr;
1321 uint8_t msg_type;
1322 uint8_t pag_mode:2,
1323 spare:2,
1324 cneed1:2,
1325 cneed2:2;
1326 uint32_t tmsi1;
1327 uint32_t tmsi2;
1328 uint32_t tmsi3;
1329 uint32_t tmsi4;
1330 uint8_t cneed3:2,
1331 cneed4:2,
1332 spare2:4;
1333 uint8_t rest[0];
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001334#elif OSMO_IS_BIG_ENDIAN
1335/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
1336 uint8_t l2_plen;
1337 uint8_t proto_discr;
1338 uint8_t msg_type;
1339 uint8_t cneed2:2, cneed1:2, spare:2, pag_mode:2;
1340 uint32_t tmsi1;
1341 uint32_t tmsi2;
1342 uint32_t tmsi3;
1343 uint32_t tmsi4;
1344 uint8_t spare2:4, cneed4:2, cneed3:2;
1345 uint8_t rest[0];
1346#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +02001347} __attribute__((packed));
1348
1349/* Section 9.1.25 */
1350struct gsm48_pag_rsp {
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001351#if OSMO_IS_LITTLE_ENDIAN
Andreas Eversberg014cb872010-07-12 09:11:00 +02001352 uint8_t key_seq:3,
1353 spare:5;
1354 uint8_t cm2_len;
1355 struct gsm48_classmark2 cm2;
1356 uint8_t data[0];
Neels Hofmeyrb2600392018-11-16 00:20:39 +01001357#elif OSMO_IS_BIG_ENDIAN
1358/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
1359 uint8_t spare:5, key_seq:3;
1360 uint8_t cm2_len;
1361 struct gsm48_classmark2 cm2;
1362 uint8_t data[0];
1363#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +02001364} __attribute__((packed));
1365
1366/* Section 9.1.29 */
1367struct gsm48_rr_status {
1368 uint8_t rr_cause;
1369} __attribute__((packed));
1370
Harald Welte3f066dd2017-05-29 15:59:03 +02001371/* 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 +01001372#define GSM48_PDISC_GROUP_CC 0x00
1373#define GSM48_PDISC_BCAST_CC 0x01
Harald Welte3f066dd2017-05-29 15:59:03 +02001374#define GSM48_PDISC_PDSS1 0x02 /* 04.07 only */
Harald Welteec8b4502010-02-20 20:34:29 +01001375#define GSM48_PDISC_CC 0x03
Harald Welte3f066dd2017-05-29 15:59:03 +02001376#define GSM48_PDISC_PDSS2 0x04 /* 04.07 only */
1377#define GSM48_PDISC_GTTP 0x04 /* 24.007 only */
Harald Welteec8b4502010-02-20 20:34:29 +01001378#define GSM48_PDISC_MM 0x05
1379#define GSM48_PDISC_RR 0x06
1380#define GSM48_PDISC_MM_GPRS 0x08
1381#define GSM48_PDISC_SMS 0x09
1382#define GSM48_PDISC_SM_GPRS 0x0a
1383#define GSM48_PDISC_NC_SS 0x0b
1384#define GSM48_PDISC_LOC 0x0c
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001385#define GSM48_PDISC_EXTEND 0x0e
Harald Welte3f066dd2017-05-29 15:59:03 +02001386#define GSM48_PDISC_TEST 0x0f /* as per 11.10, 04.14 */
Harald Welteec8b4502010-02-20 20:34:29 +01001387#define GSM48_PDISC_MASK 0x0f
Harald Welteec8b4502010-02-20 20:34:29 +01001388
Neels Hofmeyrdbd994c2017-03-09 23:07:02 +01001389extern const struct value_string gsm48_pdisc_names[];
1390static inline const char *gsm48_pdisc_name(uint8_t val)
1391{ return get_value_string(gsm48_pdisc_names, val); }
1392
Maxfdca25d2016-07-05 16:06:28 +02001393bool gsm48_hdr_gmm_cipherable(const struct gsm48_hdr *hdr);
1394
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001395static inline uint8_t gsm48_hdr_pdisc(const struct gsm48_hdr *hdr)
1396{
1397 /*
1398 * 3GPP TS 24.007 version 12.0.0 Release 12,
1399 * 11.2.3.1.1 Protocol discriminator
1400 */
1401 uint8_t pdisc = hdr->proto_discr & GSM48_PDISC_MASK;
1402 if (pdisc == GSM48_PDISC_EXTEND)
1403 return hdr->proto_discr;
1404 return pdisc;
1405}
1406
Neels Hofmeyrda7bf4d2016-03-14 16:06:48 +01001407static inline uint8_t gsm48_hdr_trans_id(const struct gsm48_hdr *hdr)
1408{
1409 /*
1410 * 3GPP TS 24.007 version 12.0.0 Release 12,
1411 * 11.2.3.1.3 Transaction identifier
1412 */
1413 return (hdr->proto_discr & 0xf0) >> 4;
1414}
1415
Maxda34bf02016-07-17 16:37:56 +02001416#define GSM48_TA_INVALID 220
1417
Neels Hofmeyr87e45502017-06-20 00:17:59 +02001418/*! Check if TA is valid according to 3GPP TS 44.018 ยง 10.5.2.40
Maxedb57e72016-07-14 11:35:17 +02001419 * \param[in] ta Timing Advance value
1420 * \returns true if ta is valid, false otherwise
1421 * Note: Rules for GSM400 band are ignored as it's not implemented in practice.
1422 */
1423static inline bool gsm48_ta_is_valid(uint8_t ta)
1424{
1425 return (ta < 64);
1426}
1427
Neels Hofmeyrda7bf4d2016-03-14 16:06:48 +01001428static inline uint8_t gsm48_hdr_trans_id_flip_ti(const struct gsm48_hdr *hdr)
1429{
1430 return gsm48_hdr_trans_id(hdr) ^ 0x08;
1431}
1432
1433static inline uint8_t gsm48_hdr_trans_id_no_ti(const struct gsm48_hdr *hdr)
1434{
1435 return gsm48_hdr_trans_id(hdr) & 0x07;
1436}
1437
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001438static inline uint8_t gsm48_hdr_msg_type_r98(const struct gsm48_hdr *hdr)
1439{
1440 /*
1441 * 3GPP TS 24.007 version 12.0.0 Release 12,
1442 * 11.2.3.2.1 Message type octet (when accessing Release 98 and older
1443 * networks only)
1444 */
1445 switch (gsm48_hdr_pdisc(hdr)) {
1446 case GSM48_PDISC_MM:
1447 case GSM48_PDISC_CC:
1448 case GSM48_PDISC_NC_SS:
1449 case GSM48_PDISC_GROUP_CC:
1450 case GSM48_PDISC_BCAST_CC:
1451 case GSM48_PDISC_LOC:
Harald Welte143aed72018-02-03 21:14:47 +01001452 return hdr->msg_type & 0x3f;
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001453 default:
1454 return hdr->msg_type;
1455 }
1456}
1457
1458static inline uint8_t gsm48_hdr_msg_type_r99(const struct gsm48_hdr *hdr)
1459{
1460 /*
1461 * 3GPP TS 24.007 version 12.0.0 Release 12,
1462 * 11.2.3.2.2 Message type octet (when accessing Release 99 and newer
1463 * networks)
1464 */
1465 switch (gsm48_hdr_pdisc(hdr)) {
1466 case GSM48_PDISC_MM:
1467 case GSM48_PDISC_CC:
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001468 case GSM48_PDISC_NC_SS:
Harald Weltef1076ed2018-02-03 21:16:45 +01001469 return hdr->msg_type & 0x3f;
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001470 case GSM48_PDISC_GROUP_CC:
1471 case GSM48_PDISC_BCAST_CC:
1472 case GSM48_PDISC_LOC:
Harald Welte143aed72018-02-03 21:14:47 +01001473 return hdr->msg_type & 0x3f;
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001474 default:
1475 return hdr->msg_type;
1476 }
1477}
1478
Maxfe65fa72016-05-10 17:17:05 +02001479void gsm48_set_dtx(struct gsm48_cell_options *op, enum gsm48_dtx_mode full,
1480 enum gsm48_dtx_mode half, bool is_bcch);
1481
Neels Hofmeyrc656fae2016-03-14 16:06:47 +01001482#define gsm48_hdr_msg_type gsm48_hdr_msg_type_r99
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001483
Harald Welteec8b4502010-02-20 20:34:29 +01001484/* Section 10.4 */
1485#define GSM48_MT_RR_INIT_REQ 0x3c
1486#define GSM48_MT_RR_ADD_ASS 0x3b
1487#define GSM48_MT_RR_IMM_ASS 0x3f
1488#define GSM48_MT_RR_IMM_ASS_EXT 0x39
1489#define GSM48_MT_RR_IMM_ASS_REJ 0x3a
Philipp72e43f02016-10-27 13:35:20 +02001490#define GSM48_MT_RR_DTM_ASS_FAIL 0x48
1491#define GSM48_MT_RR_DTM_REJECT 0x49
1492#define GSM48_MT_RR_DTM_REQUEST 0x4A
1493#define GSM48_MT_RR_PACKET_ASS 0x4B
Harald Welteec8b4502010-02-20 20:34:29 +01001494
1495#define GSM48_MT_RR_CIPH_M_CMD 0x35
1496#define GSM48_MT_RR_CIPH_M_COMPL 0x32
1497
1498#define GSM48_MT_RR_CFG_CHG_CMD 0x30
1499#define GSM48_MT_RR_CFG_CHG_ACK 0x31
1500#define GSM48_MT_RR_CFG_CHG_REJ 0x33
1501
1502#define GSM48_MT_RR_ASS_CMD 0x2e
1503#define GSM48_MT_RR_ASS_COMPL 0x29
1504#define GSM48_MT_RR_ASS_FAIL 0x2f
1505#define GSM48_MT_RR_HANDO_CMD 0x2b
1506#define GSM48_MT_RR_HANDO_COMPL 0x2c
1507#define GSM48_MT_RR_HANDO_FAIL 0x28
1508#define GSM48_MT_RR_HANDO_INFO 0x2d
Philipp72e43f02016-10-27 13:35:20 +02001509#define GSM48_MT_RR_HANDO_INFO 0x2d
1510#define GSM48_MT_RR_DTM_ASS_CMD 0x4c
Harald Welteec8b4502010-02-20 20:34:29 +01001511
1512#define GSM48_MT_RR_CELL_CHG_ORDER 0x08
1513#define GSM48_MT_RR_PDCH_ASS_CMD 0x23
1514
1515#define GSM48_MT_RR_CHAN_REL 0x0d
1516#define GSM48_MT_RR_PART_REL 0x0a
1517#define GSM48_MT_RR_PART_REL_COMP 0x0f
1518
1519#define GSM48_MT_RR_PAG_REQ_1 0x21
1520#define GSM48_MT_RR_PAG_REQ_2 0x22
1521#define GSM48_MT_RR_PAG_REQ_3 0x24
1522#define GSM48_MT_RR_PAG_RESP 0x27
1523#define GSM48_MT_RR_NOTIF_NCH 0x20
Philipp72e43f02016-10-27 13:35:20 +02001524#define GSM48_MT_RR_NOTIF_FACCH 0x25 /* (Reserved) */
Harald Welteec8b4502010-02-20 20:34:29 +01001525#define GSM48_MT_RR_NOTIF_RESP 0x26
Philipp72e43f02016-10-27 13:35:20 +02001526#define GSM48_MT_RR_PACKET_NOTIF 0x4e
Philipp349784c2016-10-10 15:03:23 +02001527#define GSM48_MT_RR_UTRAN_CLSM_CHG 0x60
1528#define GSM48_MT_RR_CDMA2K_CLSM_CHG 0x62
1529#define GSM48_MT_RR_IS_TO_UTRAN_HANDO 0x63
1530#define GSM48_MT_RR_IS_TO_CDMA2K_HANDO 0x64
1531
Harald Welteec8b4502010-02-20 20:34:29 +01001532#define GSM48_MT_RR_SYSINFO_8 0x18
1533#define GSM48_MT_RR_SYSINFO_1 0x19
1534#define GSM48_MT_RR_SYSINFO_2 0x1a
1535#define GSM48_MT_RR_SYSINFO_3 0x1b
1536#define GSM48_MT_RR_SYSINFO_4 0x1c
1537#define GSM48_MT_RR_SYSINFO_5 0x1d
1538#define GSM48_MT_RR_SYSINFO_6 0x1e
1539#define GSM48_MT_RR_SYSINFO_7 0x1f
1540
1541#define GSM48_MT_RR_SYSINFO_2bis 0x02
1542#define GSM48_MT_RR_SYSINFO_2ter 0x03
Maxe859aec2016-03-11 12:24:04 +01001543#define GSM48_MT_RR_SYSINFO_2quater 0x07
Harald Welteec8b4502010-02-20 20:34:29 +01001544#define GSM48_MT_RR_SYSINFO_5bis 0x05
1545#define GSM48_MT_RR_SYSINFO_5ter 0x06
1546#define GSM48_MT_RR_SYSINFO_9 0x04
1547#define GSM48_MT_RR_SYSINFO_13 0x00
1548
1549#define GSM48_MT_RR_SYSINFO_16 0x3d
1550#define GSM48_MT_RR_SYSINFO_17 0x3e
1551
Philipp72e43f02016-10-27 13:35:20 +02001552#define GSM48_MT_RR_SYSINFO_18 0x40
1553#define GSM48_MT_RR_SYSINFO_19 0x41
1554#define GSM48_MT_RR_SYSINFO_20 0x42
1555
Harald Welteec8b4502010-02-20 20:34:29 +01001556#define GSM48_MT_RR_CHAN_MODE_MODIF 0x10
1557#define GSM48_MT_RR_STATUS 0x12
1558#define GSM48_MT_RR_CHAN_MODE_MODIF_ACK 0x17
1559#define GSM48_MT_RR_FREQ_REDEF 0x14
1560#define GSM48_MT_RR_MEAS_REP 0x15
1561#define GSM48_MT_RR_CLSM_CHG 0x16
1562#define GSM48_MT_RR_CLSM_ENQ 0x13
1563#define GSM48_MT_RR_EXT_MEAS_REP 0x36
1564#define GSM48_MT_RR_EXT_MEAS_REP_ORD 0x37
1565#define GSM48_MT_RR_GPRS_SUSP_REQ 0x34
Philipp72e43f02016-10-27 13:35:20 +02001566#define GSM48_MT_RR_DTM_INFO 0x4d
Harald Welteec8b4502010-02-20 20:34:29 +01001567
Bhaskare6b45d82013-05-16 17:11:51 +05301568#define GSM48_MT_RR_VGCS_UPL_GRANT 0x09
Harald Welteec8b4502010-02-20 20:34:29 +01001569#define GSM48_MT_RR_UPLINK_RELEASE 0x0e
1570#define GSM48_MT_RR_UPLINK_FREE 0x0c
1571#define GSM48_MT_RR_UPLINK_BUSY 0x2a
1572#define GSM48_MT_RR_TALKER_IND 0x11
1573
1574#define GSM48_MT_RR_APP_INFO 0x38
1575
1576/* Table 10.2/3GPP TS 04.08 */
1577#define GSM48_MT_MM_IMSI_DETACH_IND 0x01
1578#define GSM48_MT_MM_LOC_UPD_ACCEPT 0x02
1579#define GSM48_MT_MM_LOC_UPD_REJECT 0x04
1580#define GSM48_MT_MM_LOC_UPD_REQUEST 0x08
1581
1582#define GSM48_MT_MM_AUTH_REJ 0x11
1583#define GSM48_MT_MM_AUTH_REQ 0x12
1584#define GSM48_MT_MM_AUTH_RESP 0x14
Neels Hofmeyr55a43b82017-02-02 20:27:55 +01001585#define GSM48_MT_MM_AUTH_FAIL 0x1c
Harald Welteec8b4502010-02-20 20:34:29 +01001586#define GSM48_MT_MM_ID_REQ 0x18
1587#define GSM48_MT_MM_ID_RESP 0x19
1588#define GSM48_MT_MM_TMSI_REALL_CMD 0x1a
1589#define GSM48_MT_MM_TMSI_REALL_COMPL 0x1b
1590
1591#define GSM48_MT_MM_CM_SERV_ACC 0x21
1592#define GSM48_MT_MM_CM_SERV_REJ 0x22
1593#define GSM48_MT_MM_CM_SERV_ABORT 0x23
1594#define GSM48_MT_MM_CM_SERV_REQ 0x24
1595#define GSM48_MT_MM_CM_SERV_PROMPT 0x25
1596#define GSM48_MT_MM_CM_REEST_REQ 0x28
1597#define GSM48_MT_MM_ABORT 0x29
1598
1599#define GSM48_MT_MM_NULL 0x30
1600#define GSM48_MT_MM_STATUS 0x31
1601#define GSM48_MT_MM_INFO 0x32
1602
1603/* Table 10.3/3GPP TS 04.08 */
1604#define GSM48_MT_CC_ALERTING 0x01
1605#define GSM48_MT_CC_CALL_CONF 0x08
1606#define GSM48_MT_CC_CALL_PROC 0x02
1607#define GSM48_MT_CC_CONNECT 0x07
1608#define GSM48_MT_CC_CONNECT_ACK 0x0f
1609#define GSM48_MT_CC_EMERG_SETUP 0x0e
1610#define GSM48_MT_CC_PROGRESS 0x03
1611#define GSM48_MT_CC_ESTAB 0x04
1612#define GSM48_MT_CC_ESTAB_CONF 0x06
1613#define GSM48_MT_CC_RECALL 0x0b
1614#define GSM48_MT_CC_START_CC 0x09
1615#define GSM48_MT_CC_SETUP 0x05
1616
1617#define GSM48_MT_CC_MODIFY 0x17
1618#define GSM48_MT_CC_MODIFY_COMPL 0x1f
1619#define GSM48_MT_CC_MODIFY_REJECT 0x13
1620#define GSM48_MT_CC_USER_INFO 0x10
1621#define GSM48_MT_CC_HOLD 0x18
1622#define GSM48_MT_CC_HOLD_ACK 0x19
1623#define GSM48_MT_CC_HOLD_REJ 0x1a
1624#define GSM48_MT_CC_RETR 0x1c
1625#define GSM48_MT_CC_RETR_ACK 0x1d
1626#define GSM48_MT_CC_RETR_REJ 0x1e
1627
1628#define GSM48_MT_CC_DISCONNECT 0x25
1629#define GSM48_MT_CC_RELEASE 0x2d
1630#define GSM48_MT_CC_RELEASE_COMPL 0x2a
1631
1632#define GSM48_MT_CC_CONG_CTRL 0x39
1633#define GSM48_MT_CC_NOTIFY 0x3e
1634#define GSM48_MT_CC_STATUS 0x3d
1635#define GSM48_MT_CC_STATUS_ENQ 0x34
1636#define GSM48_MT_CC_START_DTMF 0x35
1637#define GSM48_MT_CC_STOP_DTMF 0x31
1638#define GSM48_MT_CC_STOP_DTMF_ACK 0x32
1639#define GSM48_MT_CC_START_DTMF_ACK 0x36
1640#define GSM48_MT_CC_START_DTMF_REJ 0x37
1641#define GSM48_MT_CC_FACILITY 0x3a
1642
Neels Hofmeyr00ab9ed2017-03-09 23:27:56 +01001643extern const struct value_string gsm48_rr_msgtype_names[];
1644extern const struct value_string gsm48_mm_msgtype_names[];
1645extern const struct value_string gsm48_cc_msgtype_names[];
1646const char *gsm48_pdisc_msgtype_name(uint8_t pdisc, uint8_t msg_type);
Harald Welte4a62eda2019-03-18 18:27:00 +01001647char *gsm48_pdisc_msgtype_name_buf(char *buf, size_t buf_len, uint8_t pdisc, uint8_t msg_type);
Neels Hofmeyr00ab9ed2017-03-09 23:27:56 +01001648
Harald Welteec8b4502010-02-20 20:34:29 +01001649/* FIXME: Table 10.4 / 10.4a (GPRS) */
1650
Andreas Eversberg014cb872010-07-12 09:11:00 +02001651/* Section 10.5.3.3 CM service type */
Neels Hofmeyrf8963f92019-01-10 23:33:32 +01001652enum osmo_cm_service_type {
1653 GSM48_CMSERV_MO_CALL_PACKET = 1,
1654 GSM48_CMSERV_EMERGENCY = 2,
1655 GSM48_CMSERV_SMS = 4,
1656 GSM48_CMSERV_SUP_SERV = 8,
1657 GSM48_CMSERV_VGCS = 9,
1658 GSM48_CMSERV_VBS = 10,
1659 GSM48_CMSERV_LOC_SERV = 11,
1660 GSM48_CMSERV_MAX_VAL = GSM48_CMSERV_LOC_SERV
1661};
1662
1663extern const struct value_string osmo_cm_service_type_names[];
1664static inline const char *osmo_cm_service_type_name(enum osmo_cm_service_type val)
1665{ return get_value_string(osmo_cm_service_type_names, val); }
Andreas Eversberg014cb872010-07-12 09:11:00 +02001666
Harald Welteec8b4502010-02-20 20:34:29 +01001667/* Section 10.5.2.26, Table 10.5.64 */
1668#define GSM48_PM_MASK 0x03
1669#define GSM48_PM_NORMAL 0x00
1670#define GSM48_PM_EXTENDED 0x01
1671#define GSM48_PM_REORG 0x02
1672#define GSM48_PM_SAME 0x03
1673
1674/* Chapter 10.5.3.5 / Table 10.5.93 */
1675#define GSM48_LUPD_NORMAL 0x0
1676#define GSM48_LUPD_PERIODIC 0x1
1677#define GSM48_LUPD_IMSI_ATT 0x2
1678#define GSM48_LUPD_RESERVED 0x3
1679
Neels Hofmeyr92f3f5e2019-01-05 00:39:13 +01001680extern const struct value_string osmo_lu_type_names[];
1681static inline const char *osmo_lu_type_name(uint8_t lu_type)
1682{ return get_value_string(osmo_lu_type_names, lu_type); }
1683
Harald Welteec8b4502010-02-20 20:34:29 +01001684/* Table 10.5.4 */
1685#define GSM_MI_TYPE_MASK 0x07
1686#define GSM_MI_TYPE_NONE 0x00
1687#define GSM_MI_TYPE_IMSI 0x01
1688#define GSM_MI_TYPE_IMEI 0x02
1689#define GSM_MI_TYPE_IMEISV 0x03
1690#define GSM_MI_TYPE_TMSI 0x04
1691#define GSM_MI_ODD 0x08
1692
Andreas Eversberg014cb872010-07-12 09:11:00 +02001693#define GSM48_IE_MOBILE_ID 0x17 /* 10.5.1.4 */
Harald Welteec8b4502010-02-20 20:34:29 +01001694#define GSM48_IE_NAME_LONG 0x43 /* 10.5.3.5a */
1695#define GSM48_IE_NAME_SHORT 0x45 /* 10.5.3.5a */
1696#define GSM48_IE_UTC 0x46 /* 10.5.3.8 */
1697#define GSM48_IE_NET_TIME_TZ 0x47 /* 10.5.3.9 */
1698#define GSM48_IE_LSA_IDENT 0x48 /* 10.5.3.11 */
Jacob Erlbeck1c3f0882013-09-16 10:29:57 +02001699#define GSM48_IE_NET_DST 0x49 /* 10.5.3.12 [24.008] */
Harald Welteec8b4502010-02-20 20:34:29 +01001700
1701#define GSM48_IE_BEARER_CAP 0x04 /* 10.5.4.5 */
1702#define GSM48_IE_CAUSE 0x08 /* 10.5.4.11 */
1703#define GSM48_IE_CC_CAP 0x15 /* 10.5.4.5a */
1704#define GSM48_IE_ALERT 0x19 /* 10.5.4.26 */
1705#define GSM48_IE_FACILITY 0x1c /* 10.5.4.15 */
1706#define GSM48_IE_PROGR_IND 0x1e /* 10.5.4.21 */
1707#define GSM48_IE_AUX_STATUS 0x24 /* 10.5.4.4 */
1708#define GSM48_IE_NOTIFY 0x27 /* 10.5.4.20 */
1709#define GSM48_IE_KPD_FACILITY 0x2c /* 10.5.4.17 */
1710#define GSM48_IE_SIGNAL 0x34 /* 10.5.4.23 */
1711#define GSM48_IE_CONN_BCD 0x4c /* 10.5.4.13 */
1712#define GSM48_IE_CONN_SUB 0x4d /* 10.5.4.14 */
1713#define GSM48_IE_CALLING_BCD 0x5c /* 10.5.4.9 */
1714#define GSM48_IE_CALLING_SUB 0x5d /* 10.5.4.10 */
1715#define GSM48_IE_CALLED_BCD 0x5e /* 10.5.4.7 */
1716#define GSM48_IE_CALLED_SUB 0x6d /* 10.5.4.8 */
1717#define GSM48_IE_REDIR_BCD 0x74 /* 10.5.4.21a */
1718#define GSM48_IE_REDIR_SUB 0x75 /* 10.5.4.21b */
1719#define GSM48_IE_LOWL_COMPAT 0x7c /* 10.5.4.18 */
1720#define GSM48_IE_HIGHL_COMPAT 0x7d /* 10.5.4.16 */
1721#define GSM48_IE_USER_USER 0x7e /* 10.5.4.25 */
1722#define GSM48_IE_SS_VERS 0x7f /* 10.5.4.24 */
1723#define GSM48_IE_MORE_DATA 0xa0 /* 10.5.4.19 */
1724#define GSM48_IE_CLIR_SUPP 0xa1 /* 10.5.4.11a */
1725#define GSM48_IE_CLIR_INVOC 0xa2 /* 10.5.4.11b */
1726#define GSM48_IE_REV_C_SETUP 0xa3 /* 10.5.4.22a */
1727#define GSM48_IE_REPEAT_CIR 0xd1 /* 10.5.4.22 */
1728#define GSM48_IE_REPEAT_SEQ 0xd3 /* 10.5.4.22 */
1729
1730/* Section 10.5.4.11 / Table 10.5.122 */
1731#define GSM48_CAUSE_CS_GSM 0x60
1732
1733/* Section 9.1.2 / Table 9.3 */
Andreas Eversberg014cb872010-07-12 09:11:00 +02001734/* RR elements */
1735#define GSM48_IE_VGCS_TARGET 0x01
1736//#define GSM48_IE_VGCS_T_MODE_I 0x01
1737#define GSM48_IE_FRQSHORT_AFTER 0x02
1738#define GSM48_IE_MUL_RATE_CFG 0x03 /* 10.5.2.21aa */
1739#define GSM48_IE_FREQ_L_AFTER 0x05
Harald Welteec8b4502010-02-20 20:34:29 +01001740#define GSM48_IE_MSLOT_DESC 0x10
Harald Welteec8b4502010-02-20 20:34:29 +01001741#define GSM48_IE_CHANMODE_2 0x11
Andreas Eversberg014cb872010-07-12 09:11:00 +02001742#define GSM48_IE_FRQSHORT_BEFORE 0x12
1743//#define GSM48_IE_FRQSHORT_BEFOR 0x12
Harald Welteec8b4502010-02-20 20:34:29 +01001744#define GSM48_IE_CHANMODE_3 0x13
1745#define GSM48_IE_CHANMODE_4 0x14
1746#define GSM48_IE_CHANMODE_5 0x15
1747#define GSM48_IE_CHANMODE_6 0x16
1748#define GSM48_IE_CHANMODE_7 0x17
1749#define GSM48_IE_CHANMODE_8 0x18
1750#define GSM48_IE_CHANDESC_2 0x64
Harald Welte639f74b2010-06-15 09:32:14 +02001751#define GSM48_IE_MA_AFTER 0x72
1752#define GSM48_IE_START_TIME 0x7c
1753#define GSM48_IE_FREQ_L_BEFORE 0x19
Andreas Eversberg014cb872010-07-12 09:11:00 +02001754//#define GSM48_IE_FRQLIST_BEFORE 0x19
Harald Welte639f74b2010-06-15 09:32:14 +02001755#define GSM48_IE_CH_DESC_1_BEFORE 0x1c
Andreas Eversberg014cb872010-07-12 09:11:00 +02001756//#define GSM48_IE_CHDES_1_BEFORE 0x1c
Harald Welte639f74b2010-06-15 09:32:14 +02001757#define GSM48_IE_CH_DESC_2_BEFORE 0x1d
Andreas Eversberg014cb872010-07-12 09:11:00 +02001758//#define GSM48_IE_CHDES_2_BEFORE 0x1d
Harald Welte639f74b2010-06-15 09:32:14 +02001759#define GSM48_IE_F_CH_SEQ_BEFORE 0x1e
Andreas Eversberg014cb872010-07-12 09:11:00 +02001760//#define GSM48_IE_FRQSEQ_BEFORE 0x1e
1761#define GSM48_IE_CLASSMARK3 0x20
Harald Welte639f74b2010-06-15 09:32:14 +02001762#define GSM48_IE_MA_BEFORE 0x21
Andreas Eversberg014cb872010-07-12 09:11:00 +02001763#define GSM48_IE_RR_PACKET_UL 0x22
1764#define GSM48_IE_RR_PACKET_DL 0x23
1765#define GSM48_IE_CELL_CH_DESC 0x62
1766#define GSM48_IE_CHANMODE_1 0x63
1767#define GSM48_IE_CHDES_2_AFTER 0x64
1768#define GSM48_IE_MODE_SEC_CH 0x66
1769#define GSM48_IE_F_CH_SEQ_AFTER 0x69
1770#define GSM48_IE_MA_AFTER 0x72
1771#define GSM48_IE_BA_RANGE 0x73
1772#define GSM48_IE_GROUP_CHDES 0x74
1773#define GSM48_IE_BA_LIST_PREF 0x75
1774#define GSM48_IE_MOB_OVSERV_DIF 0x77
Harald Weltecf2caeb2019-02-03 00:37:20 +01001775#define GSM48_IE_CELL_SEL_IND_AFTER_REL 0x77 /* 44.018 Section 9.1.7 */
Andreas Eversberg014cb872010-07-12 09:11:00 +02001776#define GSM48_IE_REALTIME_DIFF 0x7b
1777#define GSM48_IE_START_TIME 0x7c
Harald Weltecf2caeb2019-02-03 00:37:20 +01001778#define GSM48_IE_INDIVIDUAL_PRIORITIES 0x7c /* 44.018 Section 9.1.7 */
Andreas Eversberg014cb872010-07-12 09:11:00 +02001779#define GSM48_IE_TIMING_ADVANCE 0x7d
1780#define GSM48_IE_GROUP_CIP_SEQ 0x80
1781#define GSM48_IE_CIP_MODE_SET 0x90
1782#define GSM48_IE_GPRS_RESUMPT 0xc0
1783#define GSM48_IE_SYNC_IND 0xd0
1784/* System Information 4 (types are equal IEs above) */
1785#define GSM48_IE_CBCH_CHAN_DESC 0x64
1786#define GSM48_IE_CBCH_MOB_AL 0x72
Harald Welte639f74b2010-06-15 09:32:14 +02001787
Andreas Eversberg014cb872010-07-12 09:11:00 +02001788/* Additional MM elements */
1789#define GSM48_IE_LOCATION_AREA 0x13
Harald Welte82f94ef2016-05-05 23:33:27 +02001790#define GSM48_IE_AUTN 0x20
Neels Hofmeyr55a43b82017-02-02 20:27:55 +01001791#define GSM48_IE_AUTH_RES_EXT 0x21
1792#define GSM48_IE_AUTS 0x22
Andreas Eversberg014cb872010-07-12 09:11:00 +02001793#define GSM48_IE_PRIORITY_LEV 0x80
1794#define GSM48_IE_FOLLOW_ON_PROC 0xa1
1795#define GSM48_IE_CTS_PERMISSION 0xa2
Harald Welteec8b4502010-02-20 20:34:29 +01001796
Keith05d32782018-05-28 14:08:10 +02001797/* Section 10.5.4.21 / Table 10.5.127 */
1798
1799enum gsm48_progress_desc {
1800 GSM48_PROGR_NOT_E2E = 0x00,
1801 GSM48_PROGR_DEST_NOT_PLMN = 0x02,
1802 GSM48_PROGR_ORIG_NOT_PLMN = 0x03,
1803 GSM48_PROGR_RETURNED = 0x04,
1804 GSM48_PROGR_IN_BAND_AVAIL = 0x08,
1805 GSM48_PROGR_CALL_E2E = 0x20,
1806 GSM48_PROGR_QUEUEING = 0x40,
1807};
1808
Harald Welteec8b4502010-02-20 20:34:29 +01001809/* Section 10.5.4.23 / Table 10.5.130 */
1810enum gsm48_signal_val {
1811 GSM48_SIGNAL_DIALTONE = 0x00,
1812 GSM48_SIGNAL_RINGBACK = 0x01,
1813 GSM48_SIGNAL_INTERCEPT = 0x02,
1814 GSM48_SIGNAL_NET_CONG = 0x03,
1815 GSM48_SIGNAL_BUSY = 0x04,
1816 GSM48_SIGNAL_CONFIRM = 0x05,
1817 GSM48_SIGNAL_ANSWER = 0x06,
1818 GSM48_SIGNAL_CALL_WAIT = 0x07,
1819 GSM48_SIGNAL_OFF_HOOK = 0x08,
1820 GSM48_SIGNAL_OFF = 0x3f,
1821 GSM48_SIGNAL_ALERT_OFF = 0x4f,
1822};
1823
Keithadfa1992018-05-25 15:24:06 +02001824/* Section 10.5.4.11 / Table 10.5.122 */
1825enum gsm48_cause_coding {
1826 GSM48_CAUSE_CODING_CCITT_Q931 = 0x00,
1827 GSM48_CAUSE_CODING_RESERVED = 0x01,
1828 GSM48_CAUSE_CODING_NATIONAL = 0x02,
1829 GSM48_CAUSE_CODING_GSM = 0x03,
1830};
1831
Harald Welteec8b4502010-02-20 20:34:29 +01001832enum gsm48_cause_loc {
1833 GSM48_CAUSE_LOC_USER = 0x00,
1834 GSM48_CAUSE_LOC_PRN_S_LU = 0x01,
1835 GSM48_CAUSE_LOC_PUN_S_LU = 0x02,
1836 GSM48_CAUSE_LOC_TRANS_NET = 0x03,
1837 GSM48_CAUSE_LOC_PUN_S_RU = 0x04,
1838 GSM48_CAUSE_LOC_PRN_S_RU = 0x05,
1839 /* not defined */
1840 GSM48_CAUSE_LOC_INN_NET = 0x07,
1841 GSM48_CAUSE_LOC_NET_BEYOND = 0x0a,
1842};
1843
Neels Hofmeyr6ad50aa2019-01-14 20:28:56 +01001844/* 3GPP TS 44.018 10.5.2.31 RR Cause / Table 10.5.70 */
Harald Welteec8b4502010-02-20 20:34:29 +01001845enum gsm48_rr_cause {
1846 GSM48_RR_CAUSE_NORMAL = 0x00,
1847 GSM48_RR_CAUSE_ABNORMAL_UNSPEC = 0x01,
1848 GSM48_RR_CAUSE_ABNORMAL_UNACCT = 0x02,
1849 GSM48_RR_CAUSE_ABNORMAL_TIMER = 0x03,
1850 GSM48_RR_CAUSE_ABNORMAL_NOACT = 0x04,
1851 GSM48_RR_CAUSE_PREMPTIVE_REL = 0x05,
Andreas Eversbergc8cac642013-06-19 20:58:59 +02001852 GSM48_RR_CAUSE_HNDOVER_IMP = 0x08,
1853 GSM48_RR_CAUSE_CHAN_MODE_UNACCT = 0x09,
1854 GSM48_RR_CAUSE_FREQ_NOT_IMPL = 0x0a,
Harald Welteec8b4502010-02-20 20:34:29 +01001855 GSM48_RR_CAUSE_CALL_CLEARED = 0x41,
1856 GSM48_RR_CAUSE_SEMANT_INCORR = 0x5f,
1857 GSM48_RR_CAUSE_INVALID_MAND_INF = 0x60,
1858 GSM48_RR_CAUSE_MSG_TYPE_N = 0x61,
1859 GSM48_RR_CAUSE_MSG_TYPE_N_COMPAT= 0x62,
1860 GSM48_RR_CAUSE_COND_IE_ERROR = 0x64,
1861 GSM48_RR_CAUSE_NO_CELL_ALLOC_A = 0x65,
1862 GSM48_RR_CAUSE_PROT_ERROR_UNSPC = 0x6f,
1863};
1864
1865/* Section 10.5.4.11 CC Cause / Table 10.5.123 */
1866enum gsm48_cc_cause {
1867 GSM48_CC_CAUSE_UNASSIGNED_NR = 1,
1868 GSM48_CC_CAUSE_NO_ROUTE = 3,
1869 GSM48_CC_CAUSE_CHAN_UNACCEPT = 6,
1870 GSM48_CC_CAUSE_OP_DET_BARRING = 8,
1871 GSM48_CC_CAUSE_NORM_CALL_CLEAR = 16,
1872 GSM48_CC_CAUSE_USER_BUSY = 17,
1873 GSM48_CC_CAUSE_USER_NOTRESPOND = 18,
1874 GSM48_CC_CAUSE_USER_ALERTING_NA = 19,
1875 GSM48_CC_CAUSE_CALL_REJECTED = 21,
1876 GSM48_CC_CAUSE_NUMBER_CHANGED = 22,
1877 GSM48_CC_CAUSE_PRE_EMPTION = 25,
1878 GSM48_CC_CAUSE_NONSE_USER_CLR = 26,
1879 GSM48_CC_CAUSE_DEST_OOO = 27,
1880 GSM48_CC_CAUSE_INV_NR_FORMAT = 28,
1881 GSM48_CC_CAUSE_FACILITY_REJ = 29,
1882 GSM48_CC_CAUSE_RESP_STATUS_INQ = 30,
1883 GSM48_CC_CAUSE_NORMAL_UNSPEC = 31,
1884 GSM48_CC_CAUSE_NO_CIRCUIT_CHAN = 34,
1885 GSM48_CC_CAUSE_NETWORK_OOO = 38,
1886 GSM48_CC_CAUSE_TEMP_FAILURE = 41,
1887 GSM48_CC_CAUSE_SWITCH_CONG = 42,
1888 GSM48_CC_CAUSE_ACC_INF_DISCARD = 43,
1889 GSM48_CC_CAUSE_REQ_CHAN_UNAVAIL = 44,
1890 GSM48_CC_CAUSE_RESOURCE_UNAVAIL = 47,
1891 GSM48_CC_CAUSE_QOS_UNAVAIL = 49,
1892 GSM48_CC_CAUSE_REQ_FAC_NOT_SUBSC= 50,
1893 GSM48_CC_CAUSE_INC_BARRED_CUG = 55,
1894 GSM48_CC_CAUSE_BEARER_CAP_UNAUTH= 57,
1895 GSM48_CC_CAUSE_BEARER_CA_UNAVAIL= 58,
1896 GSM48_CC_CAUSE_SERV_OPT_UNAVAIL = 63,
1897 GSM48_CC_CAUSE_BEARERSERV_UNIMPL= 65,
1898 GSM48_CC_CAUSE_ACM_GE_ACM_MAX = 68,
1899 GSM48_CC_CAUSE_REQ_FAC_NOTIMPL = 69,
1900 GSM48_CC_CAUSE_RESTR_BCAP_AVAIL = 70,
1901 GSM48_CC_CAUSE_SERV_OPT_UNIMPL = 79,
1902 GSM48_CC_CAUSE_INVAL_TRANS_ID = 81,
1903 GSM48_CC_CAUSE_USER_NOT_IN_CUG = 87,
1904 GSM48_CC_CAUSE_INCOMPAT_DEST = 88,
1905 GSM48_CC_CAUSE_INVAL_TRANS_NET = 91,
1906 GSM48_CC_CAUSE_SEMANTIC_INCORR = 95,
1907 GSM48_CC_CAUSE_INVAL_MAND_INF = 96,
1908 GSM48_CC_CAUSE_MSGTYPE_NOTEXIST = 97,
1909 GSM48_CC_CAUSE_MSGTYPE_INCOMPAT = 98,
1910 GSM48_CC_CAUSE_IE_NOTEXIST = 99,
1911 GSM48_CC_CAUSE_COND_IE_ERR = 100,
1912 GSM48_CC_CAUSE_MSG_INCOMP_STATE = 101,
1913 GSM48_CC_CAUSE_RECOVERY_TIMER = 102,
1914 GSM48_CC_CAUSE_PROTO_ERR = 111,
1915 GSM48_CC_CAUSE_INTERWORKING = 127,
1916};
1917
Keith3cdaa8d2018-08-31 20:09:18 +02001918extern const struct value_string gsm48_cc_cause_names[];
1919static inline const char *gsm48_cc_cause_name(enum gsm48_cc_cause val)
1920{ return get_value_string(gsm48_cc_cause_names, val); }
1921
Harald Welteec8b4502010-02-20 20:34:29 +01001922/* Annex G, GSM specific cause values for mobility management */
1923enum gsm48_reject_value {
1924 GSM48_REJECT_IMSI_UNKNOWN_IN_HLR = 2,
1925 GSM48_REJECT_ILLEGAL_MS = 3,
1926 GSM48_REJECT_IMSI_UNKNOWN_IN_VLR = 4,
1927 GSM48_REJECT_IMEI_NOT_ACCEPTED = 5,
1928 GSM48_REJECT_ILLEGAL_ME = 6,
1929 GSM48_REJECT_PLMN_NOT_ALLOWED = 11,
1930 GSM48_REJECT_LOC_NOT_ALLOWED = 12,
1931 GSM48_REJECT_ROAMING_NOT_ALLOWED = 13,
1932 GSM48_REJECT_NETWORK_FAILURE = 17,
Neels Hofmeyr55a43b82017-02-02 20:27:55 +01001933 GSM48_REJECT_SYNCH_FAILURE = 21,
Harald Welteec8b4502010-02-20 20:34:29 +01001934 GSM48_REJECT_CONGESTION = 22,
1935 GSM48_REJECT_SRV_OPT_NOT_SUPPORTED = 32,
1936 GSM48_REJECT_RQD_SRV_OPT_NOT_SUPPORTED = 33,
1937 GSM48_REJECT_SRV_OPT_TMP_OUT_OF_ORDER = 34,
1938 GSM48_REJECT_CALL_CAN_NOT_BE_IDENTIFIED = 38,
1939 GSM48_REJECT_INCORRECT_MESSAGE = 95,
1940 GSM48_REJECT_INVALID_MANDANTORY_INF = 96,
1941 GSM48_REJECT_MSG_TYPE_NOT_IMPLEMENTED = 97,
1942 GSM48_REJECT_MSG_TYPE_NOT_COMPATIBLE = 98,
1943 GSM48_REJECT_INF_ELEME_NOT_IMPLEMENTED = 99,
1944 GSM48_REJECT_CONDTIONAL_IE_ERROR = 100,
1945 GSM48_REJECT_MSG_NOT_COMPATIBLE = 101,
1946 GSM48_REJECT_PROTOCOL_ERROR = 111,
1947
1948 /* according to G.6 Additional cause codes for GMM */
1949 GSM48_REJECT_GPRS_NOT_ALLOWED = 7,
1950 GSM48_REJECT_SERVICES_NOT_ALLOWED = 8,
1951 GSM48_REJECT_MS_IDENTITY_NOT_DERVIVABLE = 9,
1952 GSM48_REJECT_IMPLICITLY_DETACHED = 10,
1953 GSM48_REJECT_GPRS_NOT_ALLOWED_IN_PLMN = 14,
1954 GSM48_REJECT_MSC_TMP_NOT_REACHABLE = 16,
1955};
1956
Neels Hofmeyraead2412018-04-06 04:31:00 +02001957extern const struct value_string gsm48_reject_value_names[];
1958static inline const char *gsm48_reject_value_name(enum gsm48_reject_value val)
1959{ return get_value_string(gsm48_reject_value_names, val); }
1960
Harald Welteec8b4502010-02-20 20:34:29 +01001961enum chreq_type {
1962 CHREQ_T_EMERG_CALL,
1963 CHREQ_T_CALL_REEST_TCH_F,
1964 CHREQ_T_CALL_REEST_TCH_H,
1965 CHREQ_T_CALL_REEST_TCH_H_DBL,
1966 CHREQ_T_SDCCH,
1967 CHREQ_T_TCH_F,
1968 CHREQ_T_VOICE_CALL_TCH_H,
1969 CHREQ_T_DATA_CALL_TCH_H,
1970 CHREQ_T_LOCATION_UPD,
1971 CHREQ_T_PAG_R_ANY_NECI0,
1972 CHREQ_T_PAG_R_ANY_NECI1,
1973 CHREQ_T_PAG_R_TCH_F,
1974 CHREQ_T_PAG_R_TCH_FH,
1975 CHREQ_T_LMU,
1976 CHREQ_T_RESERVED_SDCCH,
1977 CHREQ_T_RESERVED_IGNORE,
Alexander Couzensf48e8a82016-12-05 15:57:42 +01001978 CHREQ_T_PDCH_ONE_PHASE,
1979 CHREQ_T_PDCH_TWO_PHASE,
Alexander Couzens953f9292017-03-14 13:47:29 +01001980 _NUM_CHREQ_T,
Harald Welteec8b4502010-02-20 20:34:29 +01001981};
1982
1983/* Chapter 11.3 */
1984#define GSM48_T301 180, 0
1985#define GSM48_T303 30, 0
1986#define GSM48_T305 30, 0
1987#define GSM48_T306 30, 0
Harald Weltee50b0092018-01-27 09:40:34 +01001988#define GSM48_T308 10, 0 /* no spec default */
Harald Weltecd827102018-01-27 09:43:03 +01001989#define GSM48_T310 30, 0 /* no spec default */
Harald Weltee50b0092018-01-27 09:40:34 +01001990#define GSM48_T313 30, 0 /* no spec default */
Harald Welteec8b4502010-02-20 20:34:29 +01001991#define GSM48_T323 30, 0
Harald Weltee50b0092018-01-27 09:40:34 +01001992#define GSM48_T331 30, 0 /* no spec default */
1993#define GSM48_T333 30, 0 /* no spec default */
1994#define GSM48_T334 25, 0 /* min 15s */
1995#define GSM48_T338 30, 0 /* no spec default */
Andreas Eversberg014cb872010-07-12 09:11:00 +02001996#define GSM48_T303_MS 30, 0
1997#define GSM48_T305_MS 30, 0
1998#define GSM48_T308_MS 30, 0
1999#define GSM48_T310_MS 30, 0
2000#define GSM48_T313_MS 30, 0
2001#define GSM48_T323_MS 30, 0
2002#define GSM48_T332_MS 30, 0
2003#define GSM48_T335_MS 30, 0
Harald Welteec8b4502010-02-20 20:34:29 +01002004
2005/* Chapter 5.1.2.2 */
2006#define GSM_CSTATE_NULL 0
2007#define GSM_CSTATE_INITIATED 1
Andreas Eversberg1ef041f2010-04-09 07:52:12 +02002008#define GSM_CSTATE_MM_CONNECTION_PEND 2 /* see 10.5.4.6 */
Harald Welteec8b4502010-02-20 20:34:29 +01002009#define GSM_CSTATE_MO_CALL_PROC 3
2010#define GSM_CSTATE_CALL_DELIVERED 4
2011#define GSM_CSTATE_CALL_PRESENT 6
2012#define GSM_CSTATE_CALL_RECEIVED 7
2013#define GSM_CSTATE_CONNECT_REQUEST 8
2014#define GSM_CSTATE_MO_TERM_CALL_CONF 9
2015#define GSM_CSTATE_ACTIVE 10
2016#define GSM_CSTATE_DISCONNECT_REQ 12
2017#define GSM_CSTATE_DISCONNECT_IND 12
2018#define GSM_CSTATE_RELEASE_REQ 19
2019#define GSM_CSTATE_MO_ORIG_MODIFY 26
2020#define GSM_CSTATE_MO_TERM_MODIFY 27
2021#define GSM_CSTATE_CONNECT_IND 28
2022
2023#define SBIT(a) (1 << a)
2024#define ALL_STATES 0xffffffff
2025
2026/* Table 10.5.3/3GPP TS 04.08: Location Area Identification information element */
2027#define GSM_LAC_RESERVED_DETACHED 0x0
2028#define GSM_LAC_RESERVED_ALL_BTS 0xfffe
2029
2030/* GSM 04.08 Bearer Capability: Information Transfer Capability */
2031enum gsm48_bcap_itcap {
2032 GSM48_BCAP_ITCAP_SPEECH = 0,
2033 GSM48_BCAP_ITCAP_UNR_DIG_INF = 1,
2034 GSM48_BCAP_ITCAP_3k1_AUDIO = 2,
2035 GSM48_BCAP_ITCAP_FAX_G3 = 3,
2036 GSM48_BCAP_ITCAP_OTHER = 5,
2037 GSM48_BCAP_ITCAP_RESERVED = 7,
2038};
2039
2040/* GSM 04.08 Bearer Capability: Transfer Mode */
2041enum gsm48_bcap_tmod {
2042 GSM48_BCAP_TMOD_CIRCUIT = 0,
2043 GSM48_BCAP_TMOD_PACKET = 1,
2044};
2045
2046/* GSM 04.08 Bearer Capability: Coding Standard */
2047enum gsm48_bcap_coding {
2048 GSM48_BCAP_CODING_GSM_STD = 0,
2049};
2050
2051/* GSM 04.08 Bearer Capability: Radio Channel Requirements */
2052enum gsm48_bcap_rrq {
2053 GSM48_BCAP_RRQ_FR_ONLY = 1,
2054 GSM48_BCAP_RRQ_DUAL_HR = 2,
2055 GSM48_BCAP_RRQ_DUAL_FR = 3,
2056};
2057
Harald Weltec8a0b932012-08-24 21:27:26 +02002058/* GSM 04.08 Bearer Capability: Rate Adaption */
2059enum gsm48_bcap_ra {
2060 GSM48_BCAP_RA_NONE = 0,
2061 GSM48_BCAP_RA_V110_X30 = 1,
2062 GSM48_BCAP_RA_X31 = 2,
2063 GSM48_BCAP_RA_OTHER = 3,
2064};
2065
2066/* GSM 04.08 Bearer Capability: Signalling access protocol */
2067enum gsm48_bcap_sig_access {
2068 GSM48_BCAP_SA_I440_I450 = 1,
2069 GSM48_BCAP_SA_X21 = 2,
2070 GSM48_BCAP_SA_X28_DP_IN = 3,
2071 GSM48_BCAP_SA_X28_DP_UN = 4,
2072 GSM48_BCAP_SA_X28_NDP = 5,
2073 GSM48_BCAP_SA_X32 = 6,
2074};
2075
2076/* GSM 04.08 Bearer Capability: User Rate */
2077enum gsm48_bcap_user_rate {
2078 GSM48_BCAP_UR_300 = 1,
2079 GSM48_BCAP_UR_1200 = 2,
2080 GSM48_BCAP_UR_2400 = 3,
2081 GSM48_BCAP_UR_4800 = 4,
2082 GSM48_BCAP_UR_9600 = 5,
2083 GSM48_BCAP_UR_12000 = 6,
2084 GSM48_BCAP_UR_1200_75 = 7,
2085};
2086
2087/* GSM 04.08 Bearer Capability: Parity */
2088enum gsm48_bcap_parity {
2089 GSM48_BCAP_PAR_ODD = 0,
2090 GSM48_BCAP_PAR_EVEN = 2,
2091 GSM48_BCAP_PAR_NONE = 3,
2092 GSM48_BCAP_PAR_ZERO = 4,
2093 GSM48_BCAP_PAR_ONE = 5,
2094};
2095
2096/* GSM 04.08 Bearer Capability: Intermediate Rate */
2097enum gsm48_bcap_interm_rate {
2098 GSM48_BCAP_IR_8k = 2,
2099 GSM48_BCAP_IR_16k = 3,
2100};
2101
2102/* GSM 04.08 Bearer Capability: Transparency */
2103enum gsm48_bcap_transp {
2104 GSM48_BCAP_TR_TRANSP = 0,
2105 GSM48_BCAP_TR_RLP = 1,
2106 GSM48_BCAP_TR_TR_PREF = 2,
2107 GSM48_BCAP_TR_RLP_PREF = 3,
2108};
2109
2110/* GSM 04.08 Bearer Capability: Modem Type */
2111enum gsm48_bcap_modem_type {
2112 GSM48_BCAP_MT_NONE = 0,
2113 GSM48_BCAP_MT_V21 = 1,
2114 GSM48_BCAP_MT_V22 = 2,
2115 GSM48_BCAP_MT_V22bis = 3,
2116 GSM48_BCAP_MT_V23 = 4,
2117 GSM48_BCAP_MT_V26ter = 5,
2118 GSM48_BCAP_MT_V32 = 6,
2119 GSM48_BCAP_MT_UNDEF = 7,
2120 GSM48_BCAP_MT_AUTO_1 = 8,
2121};
2122
Neels Hofmeyr87e45502017-06-20 00:17:59 +02002123/*! GSM 04.08 Bearer Capability: Speech Version Indication
Philipp Maier3d9191e2017-05-31 17:22:03 +02002124 * (See also 3GPP TS 24.008, Table 10.5.103) */
Harald Welte30a8ec42012-08-24 23:00:05 +02002125enum gsm48_bcap_speech_ver {
Philipp Maiera9e193b2017-06-16 16:47:06 +02002126 GSM48_BCAP_SV_FR = 0, /*!< GSM FR V1 (GSM FR) */
2127 GSM48_BCAP_SV_HR = 1, /*!< GSM HR V1 (GSM HR) */
2128 GSM48_BCAP_SV_EFR = 2, /*!< GSM FR V2 (GSM EFR) */
2129 GSM48_BCAP_SV_AMR_F = 4, /*!< GSM FR V3 (FR AMR) */
2130 GSM48_BCAP_SV_AMR_H = 5, /*!< GSM HR V3 (HR_AMR) */
Philipp Maier3d9191e2017-05-31 17:22:03 +02002131 GSM48_BCAP_SV_AMR_OFW = 6, /*!< GSM FR V4 (OFR AMR-WB) */
2132 GSM48_BCAP_SV_AMR_OHW = 7, /*!< GSM HR V4 (OHR AMR-WB) */
2133 GSM48_BCAP_SV_AMR_FW = 8, /*!< GSM FR V5 (FR AMR-WB) */
2134 GSM48_BCAP_SV_AMR_OH = 11, /*!< GSM HR V6 (OHR AMR) */
Harald Welte30a8ec42012-08-24 23:00:05 +02002135};
2136
Harald Welteec8b4502010-02-20 20:34:29 +01002137#define GSM48_TMSI_LEN 5
2138#define GSM48_MID_TMSI_LEN (GSM48_TMSI_LEN + 2)
2139#define GSM48_MI_SIZE 32
2140
Maxff2eeda2018-01-04 18:43:44 +01002141/* 3GPP TS 24.008 ยง 10.5.5.15 Routing area identification */
Harald Weltea1c4f762010-05-01 11:59:42 +02002142struct gsm48_ra_id {
2143 uint8_t digits[3]; /* MCC + MNC BCD digits */
2144 uint16_t lac; /* Location Area Code */
2145 uint8_t rac; /* Routing Area Code */
2146} __attribute__ ((packed));
2147
Harald Welteb5503132011-05-24 15:01:53 +02002148#define GSM48_CELL_CHAN_DESC_SIZE 16
Harald Weltea1c4f762010-05-01 11:59:42 +02002149
Harald Welteb5503132011-05-24 15:01:53 +02002150#define GSM_MACBLOCK_LEN 23
2151#define GSM_MACBLOCK_PADDING 0x2b
Harald Welte55478082018-02-09 22:39:29 +01002152
2153/* Table 10.5.118 / 3GPP TS 24.008 Section 10.5.4.7 */
2154enum gsm48_type_of_number {
2155 GSM48_TON_UNKNOWN = 0,
2156 GSM48_TON_INTERNATIONAL = 1,
2157 GSM48_TON_NATIONAL = 2,
2158 GSM48_TON_NET_SPEC = 3,
2159 GSM48_TON_SHORT_CODE = 4,
2160 /* reserved */
2161};
2162
2163/* Table 10.5.118 / 3GPP TS 24.008 Section 10.5.4.7 */
2164enum gsm48_numbering_plan {
2165 GSM48_NPI_UNKNOWN = 0,
2166 GSM48_NPI_ISDN_E164 = 1,
2167 GSM48_NPI_DATA_X121 = 3,
2168 GSM48_NPI_TELEX_F69 = 4,
2169 GSM48_NPI_NATIONAL = 8,
2170 GSM48_NPI_PRIVATE = 9,
2171 GSM48_NPI_CTS = 11,
2172 /* reserved */
2173};