blob: e218295c4e1f05278c19ac8c699154972b73705c [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 {
Andreas Eversberg014cb872010-07-12 09:11:00 +020016 uint8_t pwr_lev:3,
Harald Welteec8b4502010-02-20 20:34:29 +010017 a5_1:1,
Andreas Eversberg014cb872010-07-12 09:11:00 +020018 es_ind:1,
19 rev_lev:2,
20 spare:1;
21} __attribute__ ((packed));
22
23/* Chapter 10.5.1.6 */
24struct gsm48_classmark2 {
25 uint8_t pwr_lev:3,
26 a5_1:1,
27 es_ind:1,
28 rev_lev:2,
29 spare:1;
30 uint8_t fc:1,
31 vgcs:1,
32 vbs:1,
33 sm_cap:1,
34 ss_scr:2,
35 ps_cap:1,
36 spare2:1;
37 uint8_t a5_2:1,
38 a5_3:1,
39 cmsp:1,
40 solsa:1,
41 spare3:1,
42 lcsva_cap:1,
43 spare4:1,
44 cm3:1;
45} __attribute__ ((packed));
46
47/* Chapter 10.5.2.1b.3 */
Ruben Undheim720ac4a2016-05-27 22:03:59 +020048#if OSMO_IS_LITTLE_ENDIAN == 1
Andreas Eversberg014cb872010-07-12 09:11:00 +020049struct gsm48_range_1024 {
50 uint8_t w1_hi:2,
51 f0:1,
52 form_id:5;
53 uint8_t w1_lo;
54 uint8_t w2_hi;
55 uint8_t w3_hi:7,
56 w2_lo:1;
57 uint8_t w4_hi:6,
58 w3_lo:2;
59 uint8_t w5_hi:6,
60 w4_lo:2;
61 uint8_t w6_hi:6,
62 w5_lo:2;
63 uint8_t w7_hi:6,
64 w6_lo:2;
65 uint8_t w8_hi:6,
66 w7_lo:2;
67 uint8_t w9:7,
68 w8_lo:1;
69 uint8_t w11_hi:1,
70 w10:7;
71 uint8_t w12_hi:2,
72 w11_lo:6;
73 uint8_t w13_hi:3,
74 w12_lo:5;
75 uint8_t w14_hi:4,
76 w13_lo:4;
77 uint8_t w15_hi:5,
78 w14_lo:3;
79 uint8_t w16:6,
80 w15_lo:2;
81} __attribute__ ((packed));
Ruben Undheim720ac4a2016-05-27 22:03:59 +020082#else
83struct gsm48_range_1024 {
84 uint8_t form_id:5,
85 f0:1,
86 w1_hi:2;
87 uint8_t w1_lo;
88 uint8_t w2_hi;
89 uint8_t w2_lo:1,
90 w3_hi:7;
91 uint8_t w3_lo:2,
92 w4_hi:6;
93 uint8_t w4_lo:2,
94 w5_hi:6;
95 uint8_t w5_lo:2,
96 w6_hi:6;
97 uint8_t w6_lo:2,
98 w7_hi:6;
99 uint8_t w7_lo:2,
100 w8_hi:6;
101 uint8_t w8_lo:1,
102 w9:7;
103 uint8_t w10:7,
104 w11_hi:1;
105 uint8_t w11_lo:6,
106 w12_hi:2;
107 uint8_t w12_lo:5,
108 w13_hi:3;
109 uint8_t w13_lo:4,
110 w14_hi:4;
111 uint8_t w14_lo:3,
112 w15_hi:5;
113 uint8_t w15_lo:2,
114 w16:6;
115} __attribute__ ((packed));
116#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200117
118/* Chapter 10.5.2.1b.4 */
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200119#if OSMO_IS_LITTLE_ENDIAN == 1
Andreas Eversberg014cb872010-07-12 09:11:00 +0200120struct gsm48_range_512 {
121 uint8_t orig_arfcn_hi:1,
122 form_id:7;
123 uint8_t orig_arfcn_mid;
124 uint8_t w1_hi:7,
125 orig_arfcn_lo:1;
126 uint8_t w2_hi:6,
127 w1_lo:2;
128 uint8_t w3_hi:6,
129 w2_lo:2;
130 uint8_t w4_hi:6,
131 w3_lo:2;
132 uint8_t w5:7,
133 w4_lo:1;
134 uint8_t w7_hi:1,
135 w6:7;
136 uint8_t w8_hi:2,
137 w7_lo:6;
138 uint8_t w9_hi:4,
139 w8_lo:4;
140 uint8_t w10:6,
141 w9_lo:2;
142 uint8_t w12_hi:2,
143 w11:6;
144 uint8_t w13_hi:4,
145 w12_lo:4;
146 uint8_t w14:6,
147 w13_lo:2;
148 uint8_t w16_hi:2,
149 w15:6;
150 uint8_t w17:5,
151 w16_lo:3;
152} __attribute__ ((packed));
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200153#else
154struct gsm48_range_512 {
155 uint8_t form_id:7,
156 orig_arfcn_hi:1;
157 uint8_t orig_arfcn_mid;
158 uint8_t orig_arfcn_lo:1,
159 w1_hi:7;
160 uint8_t w1_lo:2,
161 w2_hi:6;
162 uint8_t w2_lo:2,
163 w3_hi:6;
164 uint8_t w3_lo:2,
165 w4_hi:6;
166 uint8_t w4_lo:1,
167 w5:7;
168 uint8_t w6:7,
169 w7_hi:1;
170 uint8_t w7_lo:6,
171 w8_hi:2;
172 uint8_t w8_lo:4,
173 w9_hi:4;
174 uint8_t w9_lo:2,
175 w10:6;
176 uint8_t w11:6,
177 w12_hi:2;
178 uint8_t w12_lo:4,
179 w13_hi:4;
180 uint8_t w13_lo:2,
181 w14:6;
182 uint8_t w15:6,
183 w16_hi:2;
184 uint8_t w16_lo:3,
185 w17:5;
186} __attribute__ ((packed));
187#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200188
189/* Chapter 10.5.2.1b.5 */
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200190#if OSMO_IS_LITTLE_ENDIAN == 1
Andreas Eversberg014cb872010-07-12 09:11:00 +0200191struct gsm48_range_256 {
192 uint8_t orig_arfcn_hi:1,
193 form_id:7;
194 uint8_t orig_arfcn_mid;
195 uint8_t w1_hi:7,
196 orig_arfcn_lo:1;
197 uint8_t w2:7,
198 w1_lo:1;
199 uint8_t w4_hi:1,
200 w3:7;
201 uint8_t w5_hi:3,
202 w4_lo:5;
203 uint8_t w6_hi:5,
204 w5_lo:3;
205 uint8_t w8_hi:1,
206 w7:6,
207 w6_lo:1;
208 uint8_t w9_hi:4,
209 w8_lo:4;
210 uint8_t w11_hi:2,
211 w10:5,
212 w9_lo:1;
213 uint8_t w12:5,
214 w11_lo:3;
215 uint8_t w14_hi:3,
216 w13:5;
217 uint8_t w16_hi:1,
218 w15:5,
219 w14_lo:2;
220 uint8_t w18_hi:1,
221 w17:4,
222 w16_lo:3;
223 uint8_t w20_hi:1,
224 w19:4,
225 w18_lo:3;
226 uint8_t spare:1,
227 w21:4,
228 w20_lo:3;
229} __attribute__ ((packed));
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200230#else
231struct gsm48_range_256 {
232 uint8_t form_id:7,
233 orig_arfcn_hi:1;
234 uint8_t orig_arfcn_mid;
235 uint8_t orig_arfcn_lo:1,
236 w1_hi:7;
237 uint8_t w1_lo:1,
238 w2:7;
239 uint8_t w3:7,
240 w4_hi:1;
241 uint8_t w4_lo:5,
242 w5_hi:3;
243 uint8_t w5_lo:3,
244 w6_hi:5;
245 uint8_t w6_lo:1,
246 w7:6,
247 w8_hi:1;
248 uint8_t w8_lo:4,
249 w9_hi:4;
250 uint8_t w9_lo:1,
251 w10:5,
252 w11_hi:2;
253 uint8_t w11_lo:3,
254 w12:5;
255 uint8_t w13:5,
256 w14_hi:3;
257 uint8_t w14_lo:2,
258 w15:5,
259 w16_hi:1;
260 uint8_t w16_lo:3,
261 w17:4,
262 w18_hi:1;
263 uint8_t w18_lo:3,
264 w19:4,
265 w20_hi:1;
266 uint8_t w20_lo:3,
267 w21:4,
268 spare:1;
269} __attribute__ ((packed));
270#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200271
272/* Chapter 10.5.2.1b.6 */
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200273#if OSMO_IS_LITTLE_ENDIAN == 1
Andreas Eversberg014cb872010-07-12 09:11:00 +0200274struct gsm48_range_128 {
275 uint8_t orig_arfcn_hi:1,
276 form_id:7;
277 uint8_t orig_arfcn_mid;
278 uint8_t w1:7,
279 orig_arfcn_lo:1;
280 uint8_t w3_hi:2,
281 w2:6;
282 uint8_t w4_hi:4,
283 w3_lo:4;
284 uint8_t w6_hi:2,
285 w5:5,
286 w4_lo:1;
287 uint8_t w7:5,
288 w6_lo:3;
289 uint8_t w9:4,
290 w8:4;
291 uint8_t w11:4,
292 w10:4;
293 uint8_t w13:4,
294 w12:4;
295 uint8_t w15:4,
296 w14:4;
297 uint8_t w18_hi:2,
298 w17:3,
299 w16:3;
300 uint8_t w21_hi:1,
301 w20:3,
302 w19:3,
303 w18_lo:1;
304 uint8_t w23:3,
305 w22:3,
306 w21_lo:2;
307 uint8_t w26_hi:2,
308 w25:3,
309 w24:3;
310 uint8_t spare:1,
311 w28:3,
312 w27:3,
313 w26_lo:1;
314} __attribute__ ((packed));
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200315#else
316struct gsm48_range_128 {
317 uint8_t form_id:7,
318 orig_arfcn_hi:1;
319 uint8_t orig_arfcn_mid;
320 uint8_t orig_arfcn_lo:1,
321 w1:7;
322 uint8_t w2:6,
323 w3_hi:2;
324 uint8_t w3_lo:4,
325 w4_hi:4;
326 uint8_t w4_lo:1,
327 w5:5,
328 w6_hi:2;
329 uint8_t w6_lo:3,
330 w7:5;
331 uint8_t w8:4,
332 w9:4;
333 uint8_t w10:4,
334 w11:4;
335 uint8_t w12:4,
336 w13:4;
337 uint8_t w14:4,
338 w15:4;
339 uint8_t w16:3,
340 w17:3,
341 w18_hi:2;
342 uint8_t w18_lo:1,
343 w19:3,
344 w20:3,
345 w21_hi:1;
346 uint8_t w21_lo:2,
347 w22:3,
348 w23:3;
349 uint8_t w24:3,
350 w25:3,
351 w26_hi:2;
352 uint8_t w26_lo:1,
353 w27:3,
354 w28:3,
355 spare:1;
356} __attribute__ ((packed));
357#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200358
359/* Chapter 10.5.2.1b.7 */
360struct gsm48_var_bit {
361 uint8_t orig_arfcn_hi:1,
362 form_id:7;
363 uint8_t orig_arfcn_mid;
364 uint8_t rrfcn1_7:7,
365 orig_arfcn_lo:1;
366 uint8_t rrfcn8_111[13];
Harald Welteec8b4502010-02-20 20:34:29 +0100367} __attribute__ ((packed));
368
369/* Chapter 10.5.2.5 */
370struct gsm48_chan_desc {
371 uint8_t chan_nr;
372 union {
373 struct {
374 uint8_t maio_high:4,
375 h:1,
376 tsc:3;
377 uint8_t hsn:6,
378 maio_low:2;
Andreas Eversberg4b332d72012-02-07 20:02:17 +0100379 } __attribute__ ((packed)) h1;
Harald Welteec8b4502010-02-20 20:34:29 +0100380 struct {
381 uint8_t arfcn_high:2,
382 spare:2,
383 h:1,
384 tsc:3;
385 uint8_t arfcn_low;
Andreas Eversberg4b332d72012-02-07 20:02:17 +0100386 } __attribute__ ((packed)) h0;
387 } __attribute__ ((packed));
Harald Welteec8b4502010-02-20 20:34:29 +0100388} __attribute__ ((packed));
389
Andreas Eversberg014cb872010-07-12 09:11:00 +0200390/* Chapter 10.5.2.20 */
391struct gsm48_meas_res {
392 uint8_t rxlev_full:6,
393 dtx_used:1,
394 ba_used:1;
395 uint8_t rxlev_sub:6,
396 meas_valid:1,
397 spare:1;
398 uint8_t no_nc_n_hi:1,
399 rxqual_sub:3,
400 rxqual_full:3,
401 spare2:1;
402 uint8_t rxlev_nc1:6,
403 no_nc_n_lo:2;
404 uint8_t bsic_nc1_hi:3,
405 bcch_f_nc1:5;
406 uint8_t rxlev_nc2_hi:5,
407 bsic_nc1_lo:3;
408 uint8_t bsic_nc2_hi:2,
409 bcch_f_nc2:5,
410 rxlev_nc2_lo:1;
411 uint8_t rxlev_nc3_hi:4,
412 bsic_nc2_lo:4;
413 uint8_t bsic_nc3_hi:1,
414 bcch_f_nc3:5,
415 rxlev_nc3_lo:2;
416 uint8_t rxlev_nc4_hi:3,
417 bsic_nc3_lo:5;
418 uint8_t bcch_f_nc4:5,
419 rxlev_nc4_lo:3;
420 uint8_t rxlev_nc5_hi:2,
421 bsic_nc4:6;
422 uint8_t bcch_f_nc5_hi:4,
423 rxlev_nc5_lo:4;
424 uint8_t rxlev_nc6_hi:1,
425 bsic_nc5:6,
426 bcch_f_nc5_lo:1;
427 uint8_t bcch_f_nc6_hi:3,
428 rxlev_nc6_lo:5;
429 uint8_t bsic_nc6:6,
430 bcch_f_nc6_lo:2;
431} __attribute__ ((packed));
432
Harald Welteec8b4502010-02-20 20:34:29 +0100433/* Chapter 10.5.2.21aa */
434struct gsm48_multi_rate_conf {
435 uint8_t smod : 2,
436 spare: 1,
437 icmi : 1,
438 nscb : 1,
439 ver : 3;
440 uint8_t m4_75 : 1,
441 m5_15 : 1,
442 m5_90 : 1,
443 m6_70 : 1,
444 m7_40 : 1,
445 m7_95 : 1,
446 m10_2 : 1,
447 m12_2 : 1;
448} __attribute__((packed));
449
Andreas Eversberg014cb872010-07-12 09:11:00 +0200450/* Chapter 10.5.2.28(a) */
451struct gsm48_power_cmd {
452 uint8_t power_level:5,
453 spare:2,
454 atc:1;
455} __attribute__((packed));
456
457/* Chapter 10.5.2.29 */
458struct gsm48_rach_control {
459 uint8_t re :1,
460 cell_bar :1,
461 tx_integer :4,
462 max_trans :2;
Stefan Sperling18595152018-02-06 13:20:23 +0100463 uint8_t t2; /* ACC 8-15 barred flags */
464 uint8_t t3; /* ACC 0-7 barred flags */
Andreas Eversberg014cb872010-07-12 09:11:00 +0200465} __attribute__ ((packed));
466
Stefan Sperling18595152018-02-06 13:20:23 +0100467/*
468 * Mark an Access Control Class as barred.
469 * \param[in] rach_control A Rach Control Information Element.
470 * \param[in] acc Access Control Class number (0 - 15) which shall be barred.
471 */
472static inline void gsm48_barr_acc(struct gsm48_rach_control *rach_control, unsigned int acc)
473{
474 OSMO_ASSERT(acc >= 0 && acc <= 15);
475 if (acc >= 8)
476 rach_control->t2 |= (1 << (acc - 8));
477 else
478 rach_control->t3 |= (1 << (acc));
479}
480
481/*
482 * Mark an Access Control Class as allowed.
483 * \param[in] rach_control A Rach Control Information Element.
484 * \param[in] acc Access Control Class number (0 - 15) which shall be allowed.
485 */
486static inline void gsm48_allow_acc(struct gsm48_rach_control *rach_control, unsigned int acc)
487{
488 OSMO_ASSERT(acc >= 0 && acc <= 15);
489 if (acc >= 8)
490 rach_control->t2 &= ~(1 << (acc - 8));
491 else
492 rach_control->t3 &= ~(1 << (acc));
493}
494
495/*
496 * Indicate whether an Access Control Class is barred.
497 * \param[in] rach_control A Rach Control Information Element.
498 * \param[in] acc Access Control Class number (0 - 15).
499 * \returns true if the Access Control class is barred, false otherwise
500 */
501static inline bool gsm48_acc_is_barred(struct gsm48_rach_control *rach_control, unsigned int acc)
502{
503 OSMO_ASSERT(acc >= 0 && acc <= 15);
504 if (acc >= 8)
505 return (rach_control->t2 & (1 << (acc - 8))) != 0;
506 return (rach_control->t3 & (1 << (acc))) != 0;
507}
Andreas Eversberg014cb872010-07-12 09:11:00 +0200508
Harald Welteec8b4502010-02-20 20:34:29 +0100509/* Chapter 10.5.2.30 */
510struct gsm48_req_ref {
511 uint8_t ra;
512 uint8_t t3_high:3,
Andreas Eversberg93364fc2010-06-25 02:50:06 +0200513 t1:5;
Harald Welteec8b4502010-02-20 20:34:29 +0100514 uint8_t t2:5,
515 t3_low:3;
516} __attribute__ ((packed));
517
Andreas Eversberg014cb872010-07-12 09:11:00 +0200518/* Chapter 10.5.2.38 */
519struct gsm48_start_time {
520 uint8_t t3_high:3,
521 t1:5;
522 uint8_t t2:5,
523 t3_low:3;
524} __attribute__ ((packed));
525
526/* Chapter 10.5.2.39 */
527struct gsm48_sync_ind {
528 uint8_t si:2,
529 rot:1,
530 nci:1,
531 sync_ie:4;
532} __attribute__((packed));
533
Harald Welteec8b4502010-02-20 20:34:29 +0100534/*
535 * Chapter 9.1.5/9.1.6
536 *
537 * For 9.1.6 the chan_desc has the meaning of 10.5.2.5a
538 */
539struct gsm48_chan_mode_modify {
540 struct gsm48_chan_desc chan_desc;
541 uint8_t mode;
542} __attribute__ ((packed));
543
544enum gsm48_chan_mode {
545 GSM48_CMODE_SIGN = 0x00,
546 GSM48_CMODE_SPEECH_V1 = 0x01,
547 GSM48_CMODE_SPEECH_EFR = 0x21,
548 GSM48_CMODE_SPEECH_AMR = 0x41,
549 GSM48_CMODE_DATA_14k5 = 0x0f,
550 GSM48_CMODE_DATA_12k0 = 0x03,
551 GSM48_CMODE_DATA_6k0 = 0x0b,
Bhaskar31e844b2013-05-16 17:06:35 +0530552 GSM48_CMODE_DATA_3k6 = 0x13,
Harald Welteec8b4502010-02-20 20:34:29 +0100553};
554
Maxfb348ee2016-03-30 21:14:53 +0200555extern const struct value_string gsm48_chan_mode_names[];
Philipp Maier5796a212018-07-12 17:48:26 +0200556static inline const char *gsm48_chan_mode_name(enum gsm48_chan_mode val)
557{ return get_value_string(gsm48_chan_mode_names, val); }
Maxfb348ee2016-03-30 21:14:53 +0200558
Harald Welteec8b4502010-02-20 20:34:29 +0100559/* Chapter 9.1.2 */
560struct gsm48_ass_cmd {
561 /* Semantic is from 10.5.2.5a */
562 struct gsm48_chan_desc chan_desc;
563 uint8_t power_command;
564 uint8_t data[0];
565} __attribute__((packed));
566
Andreas Eversbergfa832012010-09-01 23:37:07 +0200567/* Chapter 9.1.13 */
568struct gsm48_frq_redef {
569 /* Semantic is from 10.5.2.5a */
570 struct gsm48_chan_desc chan_desc;
571 uint8_t mob_alloc_len;
572 uint8_t mob_alloc[0];
573} __attribute__((packed));
574
Harald Welte548e3712017-07-10 22:32:08 +0200575/* Chapter 9.1.13b GPRS suspension request */
576struct gsm48_gprs_susp_req {
577 uint32_t tlli;
578 uint8_t ra_id[6];
579 uint8_t cause;
580 uint8_t options[0];
581} __attribute__ ((packed));
582
Harald Welteec8b4502010-02-20 20:34:29 +0100583/* Chapter 10.5.2.2 */
584struct gsm48_cell_desc {
585 uint8_t bcc:3,
586 ncc:3,
587 arfcn_hi:2;
588 uint8_t arfcn_lo;
589} __attribute__((packed));
590
591/* Chapter 9.1.15 */
592struct gsm48_ho_cmd {
593 struct gsm48_cell_desc cell_desc;
594 struct gsm48_chan_desc chan_desc;
595 uint8_t ho_ref;
596 uint8_t power_command;
597 uint8_t data[0];
598} __attribute__((packed));
599
600/* Chapter 9.1.18 */
601struct gsm48_imm_ass {
602 uint8_t l2_plen;
603 uint8_t proto_discr;
604 uint8_t msg_type;
605 uint8_t page_mode;
606 struct gsm48_chan_desc chan_desc;
607 struct gsm48_req_ref req_ref;
608 uint8_t timing_advance;
609 uint8_t mob_alloc_len;
610 uint8_t mob_alloc[0];
611} __attribute__ ((packed));
612
Holger Hans Peter Freyther5dcef3c2010-05-15 22:35:25 +0800613/* Chapter 9.1.25 */
614struct gsm48_pag_resp {
615 uint8_t spare:4,
616 key_seq:4;
617 uint32_t classmark2;
618 uint8_t mi_len;
619 uint8_t mi[0];
620} __attribute__ ((packed));
621
Harald Welteec8b4502010-02-20 20:34:29 +0100622/* Chapter 10.5.1.3 */
623struct gsm48_loc_area_id {
624 uint8_t digits[3]; /* BCD! */
625 uint16_t lac;
626} __attribute__ ((packed));
627
628/* Section 9.2.2 */
629struct gsm48_auth_req {
630 uint8_t key_seq:4,
631 spare:4;
632 uint8_t rand[16];
633} __attribute__ ((packed));
634
Sylvain Munautd005eab2010-06-10 13:30:50 +0200635/* Section 9.2.3 */
636struct gsm48_auth_resp {
637 uint8_t sres[4];
638} __attribute__ ((packed));
639
Harald Welteec8b4502010-02-20 20:34:29 +0100640/* Section 9.2.15 */
641struct gsm48_loc_upd_req {
642 uint8_t type:4,
643 key_seq:4;
644 struct gsm48_loc_area_id lai;
645 struct gsm48_classmark1 classmark1;
646 uint8_t mi_len;
647 uint8_t mi[0];
648} __attribute__ ((packed));
649
650/* Section 10.1 */
651struct gsm48_hdr {
652 uint8_t proto_discr;
653 uint8_t msg_type;
654 uint8_t data[0];
655} __attribute__ ((packed));
656
657/* Section 9.1.3x System information Type header */
658struct gsm48_system_information_type_header {
659 uint8_t l2_plen;
660 uint8_t rr_protocol_discriminator :4,
661 skip_indicator:4;
662 uint8_t system_information;
663} __attribute__ ((packed));
664
Harald Welteec8b4502010-02-20 20:34:29 +0100665/* Section 10.5.2.4 Cell Selection Parameters */
666struct gsm48_cell_sel_par {
667 uint8_t ms_txpwr_max_ccch:5, /* GSM 05.08 MS-TXPWR-MAX-CCCH */
668 cell_resel_hyst:3; /* GSM 05.08 CELL-RESELECT-HYSTERESIS */
669 uint8_t rxlev_acc_min:6, /* GSM 05.08 RXLEV-ACCESS-MIN */
670 neci:1,
671 acs:1;
672} __attribute__ ((packed));
673
Neels Hofmeyrd1c2fc62017-02-21 14:51:40 +0100674/* 3GPP TS 44.018 Section 10.5.2.11 Control Channel Description */
Harald Welteec8b4502010-02-20 20:34:29 +0100675struct gsm48_control_channel_descr {
676 uint8_t ccch_conf :3,
677 bs_ag_blks_res :3,
678 att :1,
Neels Hofmeyrd1c2fc62017-02-21 14:51:40 +0100679 mscr :1;
Harald Welteec8b4502010-02-20 20:34:29 +0100680 uint8_t bs_pa_mfrms : 3,
Neels Hofmeyrd1c2fc62017-02-21 14:51:40 +0100681 spare_1 :2,
682 cbq3 :2,
683 spare_2 :1;
Harald Welteec8b4502010-02-20 20:34:29 +0100684 uint8_t t3212;
685} __attribute__ ((packed));
686
Maxfe65fa72016-05-10 17:17:05 +0200687enum gsm48_dtx_mode {
688 GSM48_DTX_MAY_BE_USED,
689 GSM48_DTX_SHALL_BE_USED,
690 GSM48_DTX_SHALL_NOT_BE_USED
691};
692
693/* Cell Options for SI6, SACCH (10.5.2.3a.2) or SI3, BCCH (Table 10.5.2.3.1),
694 3GPP TS 44.018 */
Harald Welteec8b4502010-02-20 20:34:29 +0100695struct gsm48_cell_options {
696 uint8_t radio_link_timeout:4,
697 dtx:2,
698 pwrc:1,
Maxfe65fa72016-05-10 17:17:05 +0200699 /* either DN-IND or top bit of DTX IND */
700 d:1;
Harald Welteec8b4502010-02-20 20:34:29 +0100701} __attribute__ ((packed));
702
703/* Section 9.2.9 CM service request */
704struct gsm48_service_request {
705 uint8_t cm_service_type : 4,
706 cipher_key_seq : 4;
707 /* length + 3 bytes */
708 uint32_t classmark;
709 uint8_t mi_len;
710 uint8_t mi[0];
711 /* optional priority level */
712} __attribute__ ((packed));
713
714/* Section 9.1.31 System information Type 1 */
715struct gsm48_system_information_type_1 {
716 struct gsm48_system_information_type_header header;
717 uint8_t cell_channel_description[16];
718 struct gsm48_rach_control rach_control;
719 uint8_t rest_octets[0]; /* NCH position on the CCCH */
720} __attribute__ ((packed));
721
722/* Section 9.1.32 System information Type 2 */
723struct gsm48_system_information_type_2 {
724 struct gsm48_system_information_type_header header;
725 uint8_t bcch_frequency_list[16];
726 uint8_t ncc_permitted;
727 struct gsm48_rach_control rach_control;
728} __attribute__ ((packed));
729
Andreas Eversberg014cb872010-07-12 09:11:00 +0200730/* Section 9.1.33 System information Type 2bis */
731struct gsm48_system_information_type_2bis {
732 struct gsm48_system_information_type_header header;
733 uint8_t bcch_frequency_list[16];
734 struct gsm48_rach_control rach_control;
735 uint8_t rest_octets[0];
736} __attribute__ ((packed));
737
738/* Section 9.1.34 System information Type 2ter */
739struct gsm48_system_information_type_2ter {
740 struct gsm48_system_information_type_header header;
741 uint8_t ext_bcch_frequency_list[16];
742 uint8_t rest_octets[0];
743} __attribute__ ((packed));
744
Maxe859aec2016-03-11 12:24:04 +0100745/* Section 9.1.34a System information Type 2quater */
746struct gsm48_system_information_type_2quater {
747 struct gsm48_system_information_type_header header;
748 uint8_t rest_octets[0];
749} __attribute__ ((packed));
750
Harald Welteec8b4502010-02-20 20:34:29 +0100751/* Section 9.1.35 System information Type 3 */
752struct gsm48_system_information_type_3 {
753 struct gsm48_system_information_type_header header;
754 uint16_t cell_identity;
755 struct gsm48_loc_area_id lai;
756 struct gsm48_control_channel_descr control_channel_desc;
757 struct gsm48_cell_options cell_options;
758 struct gsm48_cell_sel_par cell_sel_par;
759 struct gsm48_rach_control rach_control;
760 uint8_t rest_octets[0];
761} __attribute__ ((packed));
762
763/* Section 9.1.36 System information Type 4 */
764struct gsm48_system_information_type_4 {
765 struct gsm48_system_information_type_header header;
766 struct gsm48_loc_area_id lai;
767 struct gsm48_cell_sel_par cell_sel_par;
768 struct gsm48_rach_control rach_control;
769 /* optional CBCH conditional CBCH... followed by
770 mandantory SI 4 Reset Octets
771 */
772 uint8_t data[0];
773} __attribute__ ((packed));
774
775/* Section 9.1.37 System information Type 5 */
776struct gsm48_system_information_type_5 {
777 uint8_t rr_protocol_discriminator :4,
778 skip_indicator:4;
779 uint8_t system_information;
780 uint8_t bcch_frequency_list[16];
781} __attribute__ ((packed));
782
Andreas Eversberg014cb872010-07-12 09:11:00 +0200783/* Section 9.1.38 System information Type 5bis */
784struct gsm48_system_information_type_5bis {
785 uint8_t rr_protocol_discriminator :4,
786 skip_indicator:4;
787 uint8_t system_information;
788 uint8_t bcch_frequency_list[16];
789} __attribute__ ((packed));
790
791/* Section 9.1.39 System information Type 5ter */
792struct gsm48_system_information_type_5ter {
793 uint8_t rr_protocol_discriminator :4,
794 skip_indicator:4;
795 uint8_t system_information;
796 uint8_t bcch_frequency_list[16];
797} __attribute__ ((packed));
798
Harald Welteec8b4502010-02-20 20:34:29 +0100799/* Section 9.1.40 System information Type 6 */
800struct gsm48_system_information_type_6 {
801 uint8_t rr_protocol_discriminator :4,
802 skip_indicator:4;
803 uint8_t system_information;
804 uint16_t cell_identity;
805 struct gsm48_loc_area_id lai;
806 struct gsm48_cell_options cell_options;
807 uint8_t ncc_permitted;
808 uint8_t rest_octets[0];
809} __attribute__ ((packed));
810
811/* Section 9.1.43a System Information type 13 */
812struct gsm48_system_information_type_13 {
813 struct gsm48_system_information_type_header header;
814 uint8_t rest_octets[0];
815} __attribute__ ((packed));
816
817/* Section 9.2.12 IMSI Detach Indication */
818struct gsm48_imsi_detach_ind {
819 struct gsm48_classmark1 classmark1;
820 uint8_t mi_len;
821 uint8_t mi[0];
822} __attribute__ ((packed));
823
Andreas Eversberg014cb872010-07-12 09:11:00 +0200824/* Section 9.1.1 */
825struct gsm48_add_ass {
826 /* Semantic is from 10.5.2.5 */
827 struct gsm48_chan_desc chan_desc;
828 uint8_t data[0];
829} __attribute__((packed));
830
831/* Section 9.1.3 */
832struct gsm48_ass_cpl {
833 uint8_t rr_cause;
834} __attribute__((packed));
835
836/* Section 9.1.4 */
837struct gsm48_ass_fail {
838 uint8_t rr_cause;
839} __attribute__((packed));
840
Andreas Eversbergfa832012010-09-01 23:37:07 +0200841/* Section 9.1.3 */
842struct gsm48_ho_cpl {
843 uint8_t rr_cause;
844 uint8_t data[0];
845} __attribute__((packed));
846
847/* Section 9.1.4 */
848struct gsm48_ho_fail {
849 uint8_t rr_cause;
850} __attribute__((packed));
851
Andreas Eversberg014cb872010-07-12 09:11:00 +0200852/* Section 9.1.7 */
853struct gsm48_chan_rel {
854 uint8_t rr_cause;
855 uint8_t data[0];
856} __attribute__((packed));
857
858/* Section 9.1.9 */
859struct gsm48_cip_mode_cmd {
860 uint8_t sc:1,
861 alg_id:3,
Sylvain Munaut77b6f6c2010-09-17 13:55:45 +0200862 cr:1,
863 spare:3;
Andreas Eversberg014cb872010-07-12 09:11:00 +0200864} __attribute__((packed));
865
866/* Section 9.1.11 */
867struct gsm48_cm_change {
868 uint8_t cm2_len;
869 struct gsm48_classmark2 cm2;
870 uint8_t data[0];
871} __attribute__((packed));
872
873/* Section 9.1.19 */
874struct gsm48_imm_ass_ext {
875 uint8_t l2_plen;
876 uint8_t proto_discr;
877 uint8_t msg_type;
878 uint8_t page_mode;
879 struct gsm48_chan_desc chan_desc1;
880 struct gsm48_req_ref req_ref1;
881 uint8_t timing_advance1;
882 struct gsm48_chan_desc chan_desc2;
883 struct gsm48_req_ref req_ref2;
884 uint8_t timing_advance2;
885 uint8_t mob_alloc_len;
886 uint8_t mob_alloc[0];
887} __attribute__ ((packed));
888
889/* Section 9.1.20 */
890struct gsm48_imm_ass_rej {
891 uint8_t l2_plen;
892 uint8_t proto_discr;
893 uint8_t msg_type;
894 uint8_t page_mode;
895 struct gsm48_req_ref req_ref1;
896 uint8_t wait_ind1;
897 struct gsm48_req_ref req_ref2;
898 uint8_t wait_ind2;
899 struct gsm48_req_ref req_ref3;
900 uint8_t wait_ind3;
901 struct gsm48_req_ref req_ref4;
902 uint8_t wait_ind4;
903 uint8_t rest[0];
904} __attribute__ ((packed));
905
906/* Section 9.1.22 */
907struct gsm48_paging1 {
908 uint8_t l2_plen;
909 uint8_t proto_discr;
910 uint8_t msg_type;
911 uint8_t pag_mode:2,
912 spare:2,
913 cneed1:2,
914 cneed2:2;
915 uint8_t data[0];
916} __attribute__((packed));
917
918/* Section 9.1.23 */
919struct gsm48_paging2 {
920 uint8_t l2_plen;
921 uint8_t proto_discr;
922 uint8_t msg_type;
923 uint8_t pag_mode:2,
924 spare:2,
925 cneed1:2,
926 cneed2:2;
927 uint32_t tmsi1;
928 uint32_t tmsi2;
929 uint8_t data[0];
930} __attribute__((packed));
931
932/* Section 9.1.24 */
933struct gsm48_paging3 {
934 uint8_t l2_plen;
935 uint8_t proto_discr;
936 uint8_t msg_type;
937 uint8_t pag_mode:2,
938 spare:2,
939 cneed1:2,
940 cneed2:2;
941 uint32_t tmsi1;
942 uint32_t tmsi2;
943 uint32_t tmsi3;
944 uint32_t tmsi4;
945 uint8_t cneed3:2,
946 cneed4:2,
947 spare2:4;
948 uint8_t rest[0];
949} __attribute__((packed));
950
951/* Section 9.1.25 */
952struct gsm48_pag_rsp {
953 uint8_t key_seq:3,
954 spare:5;
955 uint8_t cm2_len;
956 struct gsm48_classmark2 cm2;
957 uint8_t data[0];
958} __attribute__((packed));
959
960/* Section 9.1.29 */
961struct gsm48_rr_status {
962 uint8_t rr_cause;
963} __attribute__((packed));
964
Harald Welte3f066dd2017-05-29 15:59:03 +0200965/* 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 +0100966#define GSM48_PDISC_GROUP_CC 0x00
967#define GSM48_PDISC_BCAST_CC 0x01
Harald Welte3f066dd2017-05-29 15:59:03 +0200968#define GSM48_PDISC_PDSS1 0x02 /* 04.07 only */
Harald Welteec8b4502010-02-20 20:34:29 +0100969#define GSM48_PDISC_CC 0x03
Harald Welte3f066dd2017-05-29 15:59:03 +0200970#define GSM48_PDISC_PDSS2 0x04 /* 04.07 only */
971#define GSM48_PDISC_GTTP 0x04 /* 24.007 only */
Harald Welteec8b4502010-02-20 20:34:29 +0100972#define GSM48_PDISC_MM 0x05
973#define GSM48_PDISC_RR 0x06
974#define GSM48_PDISC_MM_GPRS 0x08
975#define GSM48_PDISC_SMS 0x09
976#define GSM48_PDISC_SM_GPRS 0x0a
977#define GSM48_PDISC_NC_SS 0x0b
978#define GSM48_PDISC_LOC 0x0c
Neels Hofmeyr282e9082016-03-14 16:06:46 +0100979#define GSM48_PDISC_EXTEND 0x0e
Harald Welte3f066dd2017-05-29 15:59:03 +0200980#define GSM48_PDISC_TEST 0x0f /* as per 11.10, 04.14 */
Harald Welteec8b4502010-02-20 20:34:29 +0100981#define GSM48_PDISC_MASK 0x0f
Harald Welteec8b4502010-02-20 20:34:29 +0100982
Neels Hofmeyrdbd994c2017-03-09 23:07:02 +0100983extern const struct value_string gsm48_pdisc_names[];
984static inline const char *gsm48_pdisc_name(uint8_t val)
985{ return get_value_string(gsm48_pdisc_names, val); }
986
Maxfdca25d2016-07-05 16:06:28 +0200987bool gsm48_hdr_gmm_cipherable(const struct gsm48_hdr *hdr);
988
Neels Hofmeyr282e9082016-03-14 16:06:46 +0100989static inline uint8_t gsm48_hdr_pdisc(const struct gsm48_hdr *hdr)
990{
991 /*
992 * 3GPP TS 24.007 version 12.0.0 Release 12,
993 * 11.2.3.1.1 Protocol discriminator
994 */
995 uint8_t pdisc = hdr->proto_discr & GSM48_PDISC_MASK;
996 if (pdisc == GSM48_PDISC_EXTEND)
997 return hdr->proto_discr;
998 return pdisc;
999}
1000
Neels Hofmeyrda7bf4d2016-03-14 16:06:48 +01001001static inline uint8_t gsm48_hdr_trans_id(const struct gsm48_hdr *hdr)
1002{
1003 /*
1004 * 3GPP TS 24.007 version 12.0.0 Release 12,
1005 * 11.2.3.1.3 Transaction identifier
1006 */
1007 return (hdr->proto_discr & 0xf0) >> 4;
1008}
1009
Maxda34bf02016-07-17 16:37:56 +02001010#define GSM48_TA_INVALID 220
1011
Neels Hofmeyr87e45502017-06-20 00:17:59 +02001012/*! Check if TA is valid according to 3GPP TS 44.018 ยง 10.5.2.40
Maxedb57e72016-07-14 11:35:17 +02001013 * \param[in] ta Timing Advance value
1014 * \returns true if ta is valid, false otherwise
1015 * Note: Rules for GSM400 band are ignored as it's not implemented in practice.
1016 */
1017static inline bool gsm48_ta_is_valid(uint8_t ta)
1018{
1019 return (ta < 64);
1020}
1021
Neels Hofmeyrda7bf4d2016-03-14 16:06:48 +01001022static inline uint8_t gsm48_hdr_trans_id_flip_ti(const struct gsm48_hdr *hdr)
1023{
1024 return gsm48_hdr_trans_id(hdr) ^ 0x08;
1025}
1026
1027static inline uint8_t gsm48_hdr_trans_id_no_ti(const struct gsm48_hdr *hdr)
1028{
1029 return gsm48_hdr_trans_id(hdr) & 0x07;
1030}
1031
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001032static inline uint8_t gsm48_hdr_msg_type_r98(const struct gsm48_hdr *hdr)
1033{
1034 /*
1035 * 3GPP TS 24.007 version 12.0.0 Release 12,
1036 * 11.2.3.2.1 Message type octet (when accessing Release 98 and older
1037 * networks only)
1038 */
1039 switch (gsm48_hdr_pdisc(hdr)) {
1040 case GSM48_PDISC_MM:
1041 case GSM48_PDISC_CC:
1042 case GSM48_PDISC_NC_SS:
1043 case GSM48_PDISC_GROUP_CC:
1044 case GSM48_PDISC_BCAST_CC:
1045 case GSM48_PDISC_LOC:
Harald Welte143aed72018-02-03 21:14:47 +01001046 return hdr->msg_type & 0x3f;
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001047 default:
1048 return hdr->msg_type;
1049 }
1050}
1051
1052static inline uint8_t gsm48_hdr_msg_type_r99(const struct gsm48_hdr *hdr)
1053{
1054 /*
1055 * 3GPP TS 24.007 version 12.0.0 Release 12,
1056 * 11.2.3.2.2 Message type octet (when accessing Release 99 and newer
1057 * networks)
1058 */
1059 switch (gsm48_hdr_pdisc(hdr)) {
1060 case GSM48_PDISC_MM:
1061 case GSM48_PDISC_CC:
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001062 case GSM48_PDISC_NC_SS:
Harald Weltef1076ed2018-02-03 21:16:45 +01001063 return hdr->msg_type & 0x3f;
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001064 case GSM48_PDISC_GROUP_CC:
1065 case GSM48_PDISC_BCAST_CC:
1066 case GSM48_PDISC_LOC:
Harald Welte143aed72018-02-03 21:14:47 +01001067 return hdr->msg_type & 0x3f;
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001068 default:
1069 return hdr->msg_type;
1070 }
1071}
1072
Maxfe65fa72016-05-10 17:17:05 +02001073void gsm48_set_dtx(struct gsm48_cell_options *op, enum gsm48_dtx_mode full,
1074 enum gsm48_dtx_mode half, bool is_bcch);
1075
Neels Hofmeyrc656fae2016-03-14 16:06:47 +01001076#define gsm48_hdr_msg_type gsm48_hdr_msg_type_r99
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001077
Harald Welteec8b4502010-02-20 20:34:29 +01001078/* Section 10.4 */
1079#define GSM48_MT_RR_INIT_REQ 0x3c
1080#define GSM48_MT_RR_ADD_ASS 0x3b
1081#define GSM48_MT_RR_IMM_ASS 0x3f
1082#define GSM48_MT_RR_IMM_ASS_EXT 0x39
1083#define GSM48_MT_RR_IMM_ASS_REJ 0x3a
Philipp72e43f02016-10-27 13:35:20 +02001084#define GSM48_MT_RR_DTM_ASS_FAIL 0x48
1085#define GSM48_MT_RR_DTM_REJECT 0x49
1086#define GSM48_MT_RR_DTM_REQUEST 0x4A
1087#define GSM48_MT_RR_PACKET_ASS 0x4B
Harald Welteec8b4502010-02-20 20:34:29 +01001088
1089#define GSM48_MT_RR_CIPH_M_CMD 0x35
1090#define GSM48_MT_RR_CIPH_M_COMPL 0x32
1091
1092#define GSM48_MT_RR_CFG_CHG_CMD 0x30
1093#define GSM48_MT_RR_CFG_CHG_ACK 0x31
1094#define GSM48_MT_RR_CFG_CHG_REJ 0x33
1095
1096#define GSM48_MT_RR_ASS_CMD 0x2e
1097#define GSM48_MT_RR_ASS_COMPL 0x29
1098#define GSM48_MT_RR_ASS_FAIL 0x2f
1099#define GSM48_MT_RR_HANDO_CMD 0x2b
1100#define GSM48_MT_RR_HANDO_COMPL 0x2c
1101#define GSM48_MT_RR_HANDO_FAIL 0x28
1102#define GSM48_MT_RR_HANDO_INFO 0x2d
Philipp72e43f02016-10-27 13:35:20 +02001103#define GSM48_MT_RR_HANDO_INFO 0x2d
1104#define GSM48_MT_RR_DTM_ASS_CMD 0x4c
Harald Welteec8b4502010-02-20 20:34:29 +01001105
1106#define GSM48_MT_RR_CELL_CHG_ORDER 0x08
1107#define GSM48_MT_RR_PDCH_ASS_CMD 0x23
1108
1109#define GSM48_MT_RR_CHAN_REL 0x0d
1110#define GSM48_MT_RR_PART_REL 0x0a
1111#define GSM48_MT_RR_PART_REL_COMP 0x0f
1112
1113#define GSM48_MT_RR_PAG_REQ_1 0x21
1114#define GSM48_MT_RR_PAG_REQ_2 0x22
1115#define GSM48_MT_RR_PAG_REQ_3 0x24
1116#define GSM48_MT_RR_PAG_RESP 0x27
1117#define GSM48_MT_RR_NOTIF_NCH 0x20
Philipp72e43f02016-10-27 13:35:20 +02001118#define GSM48_MT_RR_NOTIF_FACCH 0x25 /* (Reserved) */
Harald Welteec8b4502010-02-20 20:34:29 +01001119#define GSM48_MT_RR_NOTIF_RESP 0x26
Philipp72e43f02016-10-27 13:35:20 +02001120#define GSM48_MT_RR_PACKET_NOTIF 0x4e
Philipp349784c2016-10-10 15:03:23 +02001121#define GSM48_MT_RR_UTRAN_CLSM_CHG 0x60
1122#define GSM48_MT_RR_CDMA2K_CLSM_CHG 0x62
1123#define GSM48_MT_RR_IS_TO_UTRAN_HANDO 0x63
1124#define GSM48_MT_RR_IS_TO_CDMA2K_HANDO 0x64
1125
Harald Welteec8b4502010-02-20 20:34:29 +01001126#define GSM48_MT_RR_SYSINFO_8 0x18
1127#define GSM48_MT_RR_SYSINFO_1 0x19
1128#define GSM48_MT_RR_SYSINFO_2 0x1a
1129#define GSM48_MT_RR_SYSINFO_3 0x1b
1130#define GSM48_MT_RR_SYSINFO_4 0x1c
1131#define GSM48_MT_RR_SYSINFO_5 0x1d
1132#define GSM48_MT_RR_SYSINFO_6 0x1e
1133#define GSM48_MT_RR_SYSINFO_7 0x1f
1134
1135#define GSM48_MT_RR_SYSINFO_2bis 0x02
1136#define GSM48_MT_RR_SYSINFO_2ter 0x03
Maxe859aec2016-03-11 12:24:04 +01001137#define GSM48_MT_RR_SYSINFO_2quater 0x07
Harald Welteec8b4502010-02-20 20:34:29 +01001138#define GSM48_MT_RR_SYSINFO_5bis 0x05
1139#define GSM48_MT_RR_SYSINFO_5ter 0x06
1140#define GSM48_MT_RR_SYSINFO_9 0x04
1141#define GSM48_MT_RR_SYSINFO_13 0x00
1142
1143#define GSM48_MT_RR_SYSINFO_16 0x3d
1144#define GSM48_MT_RR_SYSINFO_17 0x3e
1145
Philipp72e43f02016-10-27 13:35:20 +02001146#define GSM48_MT_RR_SYSINFO_18 0x40
1147#define GSM48_MT_RR_SYSINFO_19 0x41
1148#define GSM48_MT_RR_SYSINFO_20 0x42
1149
Harald Welteec8b4502010-02-20 20:34:29 +01001150#define GSM48_MT_RR_CHAN_MODE_MODIF 0x10
1151#define GSM48_MT_RR_STATUS 0x12
1152#define GSM48_MT_RR_CHAN_MODE_MODIF_ACK 0x17
1153#define GSM48_MT_RR_FREQ_REDEF 0x14
1154#define GSM48_MT_RR_MEAS_REP 0x15
1155#define GSM48_MT_RR_CLSM_CHG 0x16
1156#define GSM48_MT_RR_CLSM_ENQ 0x13
1157#define GSM48_MT_RR_EXT_MEAS_REP 0x36
1158#define GSM48_MT_RR_EXT_MEAS_REP_ORD 0x37
1159#define GSM48_MT_RR_GPRS_SUSP_REQ 0x34
Philipp72e43f02016-10-27 13:35:20 +02001160#define GSM48_MT_RR_DTM_INFO 0x4d
Harald Welteec8b4502010-02-20 20:34:29 +01001161
Bhaskare6b45d82013-05-16 17:11:51 +05301162#define GSM48_MT_RR_VGCS_UPL_GRANT 0x09
Harald Welteec8b4502010-02-20 20:34:29 +01001163#define GSM48_MT_RR_UPLINK_RELEASE 0x0e
1164#define GSM48_MT_RR_UPLINK_FREE 0x0c
1165#define GSM48_MT_RR_UPLINK_BUSY 0x2a
1166#define GSM48_MT_RR_TALKER_IND 0x11
1167
1168#define GSM48_MT_RR_APP_INFO 0x38
1169
1170/* Table 10.2/3GPP TS 04.08 */
1171#define GSM48_MT_MM_IMSI_DETACH_IND 0x01
1172#define GSM48_MT_MM_LOC_UPD_ACCEPT 0x02
1173#define GSM48_MT_MM_LOC_UPD_REJECT 0x04
1174#define GSM48_MT_MM_LOC_UPD_REQUEST 0x08
1175
1176#define GSM48_MT_MM_AUTH_REJ 0x11
1177#define GSM48_MT_MM_AUTH_REQ 0x12
1178#define GSM48_MT_MM_AUTH_RESP 0x14
Neels Hofmeyr55a43b82017-02-02 20:27:55 +01001179#define GSM48_MT_MM_AUTH_FAIL 0x1c
Harald Welteec8b4502010-02-20 20:34:29 +01001180#define GSM48_MT_MM_ID_REQ 0x18
1181#define GSM48_MT_MM_ID_RESP 0x19
1182#define GSM48_MT_MM_TMSI_REALL_CMD 0x1a
1183#define GSM48_MT_MM_TMSI_REALL_COMPL 0x1b
1184
1185#define GSM48_MT_MM_CM_SERV_ACC 0x21
1186#define GSM48_MT_MM_CM_SERV_REJ 0x22
1187#define GSM48_MT_MM_CM_SERV_ABORT 0x23
1188#define GSM48_MT_MM_CM_SERV_REQ 0x24
1189#define GSM48_MT_MM_CM_SERV_PROMPT 0x25
1190#define GSM48_MT_MM_CM_REEST_REQ 0x28
1191#define GSM48_MT_MM_ABORT 0x29
1192
1193#define GSM48_MT_MM_NULL 0x30
1194#define GSM48_MT_MM_STATUS 0x31
1195#define GSM48_MT_MM_INFO 0x32
1196
1197/* Table 10.3/3GPP TS 04.08 */
1198#define GSM48_MT_CC_ALERTING 0x01
1199#define GSM48_MT_CC_CALL_CONF 0x08
1200#define GSM48_MT_CC_CALL_PROC 0x02
1201#define GSM48_MT_CC_CONNECT 0x07
1202#define GSM48_MT_CC_CONNECT_ACK 0x0f
1203#define GSM48_MT_CC_EMERG_SETUP 0x0e
1204#define GSM48_MT_CC_PROGRESS 0x03
1205#define GSM48_MT_CC_ESTAB 0x04
1206#define GSM48_MT_CC_ESTAB_CONF 0x06
1207#define GSM48_MT_CC_RECALL 0x0b
1208#define GSM48_MT_CC_START_CC 0x09
1209#define GSM48_MT_CC_SETUP 0x05
1210
1211#define GSM48_MT_CC_MODIFY 0x17
1212#define GSM48_MT_CC_MODIFY_COMPL 0x1f
1213#define GSM48_MT_CC_MODIFY_REJECT 0x13
1214#define GSM48_MT_CC_USER_INFO 0x10
1215#define GSM48_MT_CC_HOLD 0x18
1216#define GSM48_MT_CC_HOLD_ACK 0x19
1217#define GSM48_MT_CC_HOLD_REJ 0x1a
1218#define GSM48_MT_CC_RETR 0x1c
1219#define GSM48_MT_CC_RETR_ACK 0x1d
1220#define GSM48_MT_CC_RETR_REJ 0x1e
1221
1222#define GSM48_MT_CC_DISCONNECT 0x25
1223#define GSM48_MT_CC_RELEASE 0x2d
1224#define GSM48_MT_CC_RELEASE_COMPL 0x2a
1225
1226#define GSM48_MT_CC_CONG_CTRL 0x39
1227#define GSM48_MT_CC_NOTIFY 0x3e
1228#define GSM48_MT_CC_STATUS 0x3d
1229#define GSM48_MT_CC_STATUS_ENQ 0x34
1230#define GSM48_MT_CC_START_DTMF 0x35
1231#define GSM48_MT_CC_STOP_DTMF 0x31
1232#define GSM48_MT_CC_STOP_DTMF_ACK 0x32
1233#define GSM48_MT_CC_START_DTMF_ACK 0x36
1234#define GSM48_MT_CC_START_DTMF_REJ 0x37
1235#define GSM48_MT_CC_FACILITY 0x3a
1236
Neels Hofmeyr00ab9ed2017-03-09 23:27:56 +01001237extern const struct value_string gsm48_rr_msgtype_names[];
1238extern const struct value_string gsm48_mm_msgtype_names[];
1239extern const struct value_string gsm48_cc_msgtype_names[];
1240const char *gsm48_pdisc_msgtype_name(uint8_t pdisc, uint8_t msg_type);
1241
Harald Welteec8b4502010-02-20 20:34:29 +01001242/* FIXME: Table 10.4 / 10.4a (GPRS) */
1243
Andreas Eversberg014cb872010-07-12 09:11:00 +02001244/* Section 10.5.3.3 CM service type */
1245#define GSM48_CMSERV_MO_CALL_PACKET 1
1246#define GSM48_CMSERV_EMERGENCY 2
1247#define GSM48_CMSERV_SMS 4
1248#define GSM48_CMSERV_SUP_SERV 8
1249#define GSM48_CMSERV_VGCS 9
1250#define GSM48_CMSERV_VBS 10
1251#define GSM48_CMSERV_LOC_SERV 11
1252
Harald Welteec8b4502010-02-20 20:34:29 +01001253/* Section 10.5.2.26, Table 10.5.64 */
1254#define GSM48_PM_MASK 0x03
1255#define GSM48_PM_NORMAL 0x00
1256#define GSM48_PM_EXTENDED 0x01
1257#define GSM48_PM_REORG 0x02
1258#define GSM48_PM_SAME 0x03
1259
1260/* Chapter 10.5.3.5 / Table 10.5.93 */
1261#define GSM48_LUPD_NORMAL 0x0
1262#define GSM48_LUPD_PERIODIC 0x1
1263#define GSM48_LUPD_IMSI_ATT 0x2
1264#define GSM48_LUPD_RESERVED 0x3
1265
1266/* Table 10.5.4 */
1267#define GSM_MI_TYPE_MASK 0x07
1268#define GSM_MI_TYPE_NONE 0x00
1269#define GSM_MI_TYPE_IMSI 0x01
1270#define GSM_MI_TYPE_IMEI 0x02
1271#define GSM_MI_TYPE_IMEISV 0x03
1272#define GSM_MI_TYPE_TMSI 0x04
1273#define GSM_MI_ODD 0x08
1274
Andreas Eversberg014cb872010-07-12 09:11:00 +02001275#define GSM48_IE_MOBILE_ID 0x17 /* 10.5.1.4 */
Harald Welteec8b4502010-02-20 20:34:29 +01001276#define GSM48_IE_NAME_LONG 0x43 /* 10.5.3.5a */
1277#define GSM48_IE_NAME_SHORT 0x45 /* 10.5.3.5a */
1278#define GSM48_IE_UTC 0x46 /* 10.5.3.8 */
1279#define GSM48_IE_NET_TIME_TZ 0x47 /* 10.5.3.9 */
1280#define GSM48_IE_LSA_IDENT 0x48 /* 10.5.3.11 */
Jacob Erlbeck1c3f0882013-09-16 10:29:57 +02001281#define GSM48_IE_NET_DST 0x49 /* 10.5.3.12 [24.008] */
Harald Welteec8b4502010-02-20 20:34:29 +01001282
1283#define GSM48_IE_BEARER_CAP 0x04 /* 10.5.4.5 */
1284#define GSM48_IE_CAUSE 0x08 /* 10.5.4.11 */
1285#define GSM48_IE_CC_CAP 0x15 /* 10.5.4.5a */
1286#define GSM48_IE_ALERT 0x19 /* 10.5.4.26 */
1287#define GSM48_IE_FACILITY 0x1c /* 10.5.4.15 */
1288#define GSM48_IE_PROGR_IND 0x1e /* 10.5.4.21 */
1289#define GSM48_IE_AUX_STATUS 0x24 /* 10.5.4.4 */
1290#define GSM48_IE_NOTIFY 0x27 /* 10.5.4.20 */
1291#define GSM48_IE_KPD_FACILITY 0x2c /* 10.5.4.17 */
1292#define GSM48_IE_SIGNAL 0x34 /* 10.5.4.23 */
1293#define GSM48_IE_CONN_BCD 0x4c /* 10.5.4.13 */
1294#define GSM48_IE_CONN_SUB 0x4d /* 10.5.4.14 */
1295#define GSM48_IE_CALLING_BCD 0x5c /* 10.5.4.9 */
1296#define GSM48_IE_CALLING_SUB 0x5d /* 10.5.4.10 */
1297#define GSM48_IE_CALLED_BCD 0x5e /* 10.5.4.7 */
1298#define GSM48_IE_CALLED_SUB 0x6d /* 10.5.4.8 */
1299#define GSM48_IE_REDIR_BCD 0x74 /* 10.5.4.21a */
1300#define GSM48_IE_REDIR_SUB 0x75 /* 10.5.4.21b */
1301#define GSM48_IE_LOWL_COMPAT 0x7c /* 10.5.4.18 */
1302#define GSM48_IE_HIGHL_COMPAT 0x7d /* 10.5.4.16 */
1303#define GSM48_IE_USER_USER 0x7e /* 10.5.4.25 */
1304#define GSM48_IE_SS_VERS 0x7f /* 10.5.4.24 */
1305#define GSM48_IE_MORE_DATA 0xa0 /* 10.5.4.19 */
1306#define GSM48_IE_CLIR_SUPP 0xa1 /* 10.5.4.11a */
1307#define GSM48_IE_CLIR_INVOC 0xa2 /* 10.5.4.11b */
1308#define GSM48_IE_REV_C_SETUP 0xa3 /* 10.5.4.22a */
1309#define GSM48_IE_REPEAT_CIR 0xd1 /* 10.5.4.22 */
1310#define GSM48_IE_REPEAT_SEQ 0xd3 /* 10.5.4.22 */
1311
1312/* Section 10.5.4.11 / Table 10.5.122 */
1313#define GSM48_CAUSE_CS_GSM 0x60
1314
1315/* Section 9.1.2 / Table 9.3 */
Andreas Eversberg014cb872010-07-12 09:11:00 +02001316/* RR elements */
1317#define GSM48_IE_VGCS_TARGET 0x01
1318//#define GSM48_IE_VGCS_T_MODE_I 0x01
1319#define GSM48_IE_FRQSHORT_AFTER 0x02
1320#define GSM48_IE_MUL_RATE_CFG 0x03 /* 10.5.2.21aa */
1321#define GSM48_IE_FREQ_L_AFTER 0x05
Harald Welteec8b4502010-02-20 20:34:29 +01001322#define GSM48_IE_MSLOT_DESC 0x10
Harald Welteec8b4502010-02-20 20:34:29 +01001323#define GSM48_IE_CHANMODE_2 0x11
Andreas Eversberg014cb872010-07-12 09:11:00 +02001324#define GSM48_IE_FRQSHORT_BEFORE 0x12
1325//#define GSM48_IE_FRQSHORT_BEFOR 0x12
Harald Welteec8b4502010-02-20 20:34:29 +01001326#define GSM48_IE_CHANMODE_3 0x13
1327#define GSM48_IE_CHANMODE_4 0x14
1328#define GSM48_IE_CHANMODE_5 0x15
1329#define GSM48_IE_CHANMODE_6 0x16
1330#define GSM48_IE_CHANMODE_7 0x17
1331#define GSM48_IE_CHANMODE_8 0x18
1332#define GSM48_IE_CHANDESC_2 0x64
Harald Welte639f74b2010-06-15 09:32:14 +02001333#define GSM48_IE_MA_AFTER 0x72
1334#define GSM48_IE_START_TIME 0x7c
1335#define GSM48_IE_FREQ_L_BEFORE 0x19
Andreas Eversberg014cb872010-07-12 09:11:00 +02001336//#define GSM48_IE_FRQLIST_BEFORE 0x19
Harald Welte639f74b2010-06-15 09:32:14 +02001337#define GSM48_IE_CH_DESC_1_BEFORE 0x1c
Andreas Eversberg014cb872010-07-12 09:11:00 +02001338//#define GSM48_IE_CHDES_1_BEFORE 0x1c
Harald Welte639f74b2010-06-15 09:32:14 +02001339#define GSM48_IE_CH_DESC_2_BEFORE 0x1d
Andreas Eversberg014cb872010-07-12 09:11:00 +02001340//#define GSM48_IE_CHDES_2_BEFORE 0x1d
Harald Welte639f74b2010-06-15 09:32:14 +02001341#define GSM48_IE_F_CH_SEQ_BEFORE 0x1e
Andreas Eversberg014cb872010-07-12 09:11:00 +02001342//#define GSM48_IE_FRQSEQ_BEFORE 0x1e
1343#define GSM48_IE_CLASSMARK3 0x20
Harald Welte639f74b2010-06-15 09:32:14 +02001344#define GSM48_IE_MA_BEFORE 0x21
Andreas Eversberg014cb872010-07-12 09:11:00 +02001345#define GSM48_IE_RR_PACKET_UL 0x22
1346#define GSM48_IE_RR_PACKET_DL 0x23
1347#define GSM48_IE_CELL_CH_DESC 0x62
1348#define GSM48_IE_CHANMODE_1 0x63
1349#define GSM48_IE_CHDES_2_AFTER 0x64
1350#define GSM48_IE_MODE_SEC_CH 0x66
1351#define GSM48_IE_F_CH_SEQ_AFTER 0x69
1352#define GSM48_IE_MA_AFTER 0x72
1353#define GSM48_IE_BA_RANGE 0x73
1354#define GSM48_IE_GROUP_CHDES 0x74
1355#define GSM48_IE_BA_LIST_PREF 0x75
1356#define GSM48_IE_MOB_OVSERV_DIF 0x77
1357#define GSM48_IE_REALTIME_DIFF 0x7b
1358#define GSM48_IE_START_TIME 0x7c
1359#define GSM48_IE_TIMING_ADVANCE 0x7d
1360#define GSM48_IE_GROUP_CIP_SEQ 0x80
1361#define GSM48_IE_CIP_MODE_SET 0x90
1362#define GSM48_IE_GPRS_RESUMPT 0xc0
1363#define GSM48_IE_SYNC_IND 0xd0
1364/* System Information 4 (types are equal IEs above) */
1365#define GSM48_IE_CBCH_CHAN_DESC 0x64
1366#define GSM48_IE_CBCH_MOB_AL 0x72
Harald Welte639f74b2010-06-15 09:32:14 +02001367
Andreas Eversberg014cb872010-07-12 09:11:00 +02001368/* Additional MM elements */
1369#define GSM48_IE_LOCATION_AREA 0x13
Harald Welte82f94ef2016-05-05 23:33:27 +02001370#define GSM48_IE_AUTN 0x20
Neels Hofmeyr55a43b82017-02-02 20:27:55 +01001371#define GSM48_IE_AUTH_RES_EXT 0x21
1372#define GSM48_IE_AUTS 0x22
Andreas Eversberg014cb872010-07-12 09:11:00 +02001373#define GSM48_IE_PRIORITY_LEV 0x80
1374#define GSM48_IE_FOLLOW_ON_PROC 0xa1
1375#define GSM48_IE_CTS_PERMISSION 0xa2
Harald Welteec8b4502010-02-20 20:34:29 +01001376
Keith05d32782018-05-28 14:08:10 +02001377/* Section 10.5.4.21 / Table 10.5.127 */
1378
1379enum gsm48_progress_desc {
1380 GSM48_PROGR_NOT_E2E = 0x00,
1381 GSM48_PROGR_DEST_NOT_PLMN = 0x02,
1382 GSM48_PROGR_ORIG_NOT_PLMN = 0x03,
1383 GSM48_PROGR_RETURNED = 0x04,
1384 GSM48_PROGR_IN_BAND_AVAIL = 0x08,
1385 GSM48_PROGR_CALL_E2E = 0x20,
1386 GSM48_PROGR_QUEUEING = 0x40,
1387};
1388
Harald Welteec8b4502010-02-20 20:34:29 +01001389/* Section 10.5.4.23 / Table 10.5.130 */
1390enum gsm48_signal_val {
1391 GSM48_SIGNAL_DIALTONE = 0x00,
1392 GSM48_SIGNAL_RINGBACK = 0x01,
1393 GSM48_SIGNAL_INTERCEPT = 0x02,
1394 GSM48_SIGNAL_NET_CONG = 0x03,
1395 GSM48_SIGNAL_BUSY = 0x04,
1396 GSM48_SIGNAL_CONFIRM = 0x05,
1397 GSM48_SIGNAL_ANSWER = 0x06,
1398 GSM48_SIGNAL_CALL_WAIT = 0x07,
1399 GSM48_SIGNAL_OFF_HOOK = 0x08,
1400 GSM48_SIGNAL_OFF = 0x3f,
1401 GSM48_SIGNAL_ALERT_OFF = 0x4f,
1402};
1403
Keithadfa1992018-05-25 15:24:06 +02001404/* Section 10.5.4.11 / Table 10.5.122 */
1405enum gsm48_cause_coding {
1406 GSM48_CAUSE_CODING_CCITT_Q931 = 0x00,
1407 GSM48_CAUSE_CODING_RESERVED = 0x01,
1408 GSM48_CAUSE_CODING_NATIONAL = 0x02,
1409 GSM48_CAUSE_CODING_GSM = 0x03,
1410};
1411
Harald Welteec8b4502010-02-20 20:34:29 +01001412enum gsm48_cause_loc {
1413 GSM48_CAUSE_LOC_USER = 0x00,
1414 GSM48_CAUSE_LOC_PRN_S_LU = 0x01,
1415 GSM48_CAUSE_LOC_PUN_S_LU = 0x02,
1416 GSM48_CAUSE_LOC_TRANS_NET = 0x03,
1417 GSM48_CAUSE_LOC_PUN_S_RU = 0x04,
1418 GSM48_CAUSE_LOC_PRN_S_RU = 0x05,
1419 /* not defined */
1420 GSM48_CAUSE_LOC_INN_NET = 0x07,
1421 GSM48_CAUSE_LOC_NET_BEYOND = 0x0a,
1422};
1423
1424/* Section 10.5.2.31 RR Cause / Table 10.5.70 */
1425enum gsm48_rr_cause {
1426 GSM48_RR_CAUSE_NORMAL = 0x00,
1427 GSM48_RR_CAUSE_ABNORMAL_UNSPEC = 0x01,
1428 GSM48_RR_CAUSE_ABNORMAL_UNACCT = 0x02,
1429 GSM48_RR_CAUSE_ABNORMAL_TIMER = 0x03,
1430 GSM48_RR_CAUSE_ABNORMAL_NOACT = 0x04,
1431 GSM48_RR_CAUSE_PREMPTIVE_REL = 0x05,
Andreas Eversbergc8cac642013-06-19 20:58:59 +02001432 GSM48_RR_CAUSE_HNDOVER_IMP = 0x08,
1433 GSM48_RR_CAUSE_CHAN_MODE_UNACCT = 0x09,
1434 GSM48_RR_CAUSE_FREQ_NOT_IMPL = 0x0a,
Harald Welteec8b4502010-02-20 20:34:29 +01001435 GSM48_RR_CAUSE_CALL_CLEARED = 0x41,
1436 GSM48_RR_CAUSE_SEMANT_INCORR = 0x5f,
1437 GSM48_RR_CAUSE_INVALID_MAND_INF = 0x60,
1438 GSM48_RR_CAUSE_MSG_TYPE_N = 0x61,
1439 GSM48_RR_CAUSE_MSG_TYPE_N_COMPAT= 0x62,
1440 GSM48_RR_CAUSE_COND_IE_ERROR = 0x64,
1441 GSM48_RR_CAUSE_NO_CELL_ALLOC_A = 0x65,
1442 GSM48_RR_CAUSE_PROT_ERROR_UNSPC = 0x6f,
1443};
1444
1445/* Section 10.5.4.11 CC Cause / Table 10.5.123 */
1446enum gsm48_cc_cause {
1447 GSM48_CC_CAUSE_UNASSIGNED_NR = 1,
1448 GSM48_CC_CAUSE_NO_ROUTE = 3,
1449 GSM48_CC_CAUSE_CHAN_UNACCEPT = 6,
1450 GSM48_CC_CAUSE_OP_DET_BARRING = 8,
1451 GSM48_CC_CAUSE_NORM_CALL_CLEAR = 16,
1452 GSM48_CC_CAUSE_USER_BUSY = 17,
1453 GSM48_CC_CAUSE_USER_NOTRESPOND = 18,
1454 GSM48_CC_CAUSE_USER_ALERTING_NA = 19,
1455 GSM48_CC_CAUSE_CALL_REJECTED = 21,
1456 GSM48_CC_CAUSE_NUMBER_CHANGED = 22,
1457 GSM48_CC_CAUSE_PRE_EMPTION = 25,
1458 GSM48_CC_CAUSE_NONSE_USER_CLR = 26,
1459 GSM48_CC_CAUSE_DEST_OOO = 27,
1460 GSM48_CC_CAUSE_INV_NR_FORMAT = 28,
1461 GSM48_CC_CAUSE_FACILITY_REJ = 29,
1462 GSM48_CC_CAUSE_RESP_STATUS_INQ = 30,
1463 GSM48_CC_CAUSE_NORMAL_UNSPEC = 31,
1464 GSM48_CC_CAUSE_NO_CIRCUIT_CHAN = 34,
1465 GSM48_CC_CAUSE_NETWORK_OOO = 38,
1466 GSM48_CC_CAUSE_TEMP_FAILURE = 41,
1467 GSM48_CC_CAUSE_SWITCH_CONG = 42,
1468 GSM48_CC_CAUSE_ACC_INF_DISCARD = 43,
1469 GSM48_CC_CAUSE_REQ_CHAN_UNAVAIL = 44,
1470 GSM48_CC_CAUSE_RESOURCE_UNAVAIL = 47,
1471 GSM48_CC_CAUSE_QOS_UNAVAIL = 49,
1472 GSM48_CC_CAUSE_REQ_FAC_NOT_SUBSC= 50,
1473 GSM48_CC_CAUSE_INC_BARRED_CUG = 55,
1474 GSM48_CC_CAUSE_BEARER_CAP_UNAUTH= 57,
1475 GSM48_CC_CAUSE_BEARER_CA_UNAVAIL= 58,
1476 GSM48_CC_CAUSE_SERV_OPT_UNAVAIL = 63,
1477 GSM48_CC_CAUSE_BEARERSERV_UNIMPL= 65,
1478 GSM48_CC_CAUSE_ACM_GE_ACM_MAX = 68,
1479 GSM48_CC_CAUSE_REQ_FAC_NOTIMPL = 69,
1480 GSM48_CC_CAUSE_RESTR_BCAP_AVAIL = 70,
1481 GSM48_CC_CAUSE_SERV_OPT_UNIMPL = 79,
1482 GSM48_CC_CAUSE_INVAL_TRANS_ID = 81,
1483 GSM48_CC_CAUSE_USER_NOT_IN_CUG = 87,
1484 GSM48_CC_CAUSE_INCOMPAT_DEST = 88,
1485 GSM48_CC_CAUSE_INVAL_TRANS_NET = 91,
1486 GSM48_CC_CAUSE_SEMANTIC_INCORR = 95,
1487 GSM48_CC_CAUSE_INVAL_MAND_INF = 96,
1488 GSM48_CC_CAUSE_MSGTYPE_NOTEXIST = 97,
1489 GSM48_CC_CAUSE_MSGTYPE_INCOMPAT = 98,
1490 GSM48_CC_CAUSE_IE_NOTEXIST = 99,
1491 GSM48_CC_CAUSE_COND_IE_ERR = 100,
1492 GSM48_CC_CAUSE_MSG_INCOMP_STATE = 101,
1493 GSM48_CC_CAUSE_RECOVERY_TIMER = 102,
1494 GSM48_CC_CAUSE_PROTO_ERR = 111,
1495 GSM48_CC_CAUSE_INTERWORKING = 127,
1496};
1497
Keith3cdaa8d2018-08-31 20:09:18 +02001498extern const struct value_string gsm48_cc_cause_names[];
1499static inline const char *gsm48_cc_cause_name(enum gsm48_cc_cause val)
1500{ return get_value_string(gsm48_cc_cause_names, val); }
1501
Harald Welteec8b4502010-02-20 20:34:29 +01001502/* Annex G, GSM specific cause values for mobility management */
1503enum gsm48_reject_value {
1504 GSM48_REJECT_IMSI_UNKNOWN_IN_HLR = 2,
1505 GSM48_REJECT_ILLEGAL_MS = 3,
1506 GSM48_REJECT_IMSI_UNKNOWN_IN_VLR = 4,
1507 GSM48_REJECT_IMEI_NOT_ACCEPTED = 5,
1508 GSM48_REJECT_ILLEGAL_ME = 6,
1509 GSM48_REJECT_PLMN_NOT_ALLOWED = 11,
1510 GSM48_REJECT_LOC_NOT_ALLOWED = 12,
1511 GSM48_REJECT_ROAMING_NOT_ALLOWED = 13,
1512 GSM48_REJECT_NETWORK_FAILURE = 17,
Neels Hofmeyr55a43b82017-02-02 20:27:55 +01001513 GSM48_REJECT_SYNCH_FAILURE = 21,
Harald Welteec8b4502010-02-20 20:34:29 +01001514 GSM48_REJECT_CONGESTION = 22,
1515 GSM48_REJECT_SRV_OPT_NOT_SUPPORTED = 32,
1516 GSM48_REJECT_RQD_SRV_OPT_NOT_SUPPORTED = 33,
1517 GSM48_REJECT_SRV_OPT_TMP_OUT_OF_ORDER = 34,
1518 GSM48_REJECT_CALL_CAN_NOT_BE_IDENTIFIED = 38,
1519 GSM48_REJECT_INCORRECT_MESSAGE = 95,
1520 GSM48_REJECT_INVALID_MANDANTORY_INF = 96,
1521 GSM48_REJECT_MSG_TYPE_NOT_IMPLEMENTED = 97,
1522 GSM48_REJECT_MSG_TYPE_NOT_COMPATIBLE = 98,
1523 GSM48_REJECT_INF_ELEME_NOT_IMPLEMENTED = 99,
1524 GSM48_REJECT_CONDTIONAL_IE_ERROR = 100,
1525 GSM48_REJECT_MSG_NOT_COMPATIBLE = 101,
1526 GSM48_REJECT_PROTOCOL_ERROR = 111,
1527
1528 /* according to G.6 Additional cause codes for GMM */
1529 GSM48_REJECT_GPRS_NOT_ALLOWED = 7,
1530 GSM48_REJECT_SERVICES_NOT_ALLOWED = 8,
1531 GSM48_REJECT_MS_IDENTITY_NOT_DERVIVABLE = 9,
1532 GSM48_REJECT_IMPLICITLY_DETACHED = 10,
1533 GSM48_REJECT_GPRS_NOT_ALLOWED_IN_PLMN = 14,
1534 GSM48_REJECT_MSC_TMP_NOT_REACHABLE = 16,
1535};
1536
Neels Hofmeyraead2412018-04-06 04:31:00 +02001537extern const struct value_string gsm48_reject_value_names[];
1538static inline const char *gsm48_reject_value_name(enum gsm48_reject_value val)
1539{ return get_value_string(gsm48_reject_value_names, val); }
1540
Harald Welteec8b4502010-02-20 20:34:29 +01001541enum chreq_type {
1542 CHREQ_T_EMERG_CALL,
1543 CHREQ_T_CALL_REEST_TCH_F,
1544 CHREQ_T_CALL_REEST_TCH_H,
1545 CHREQ_T_CALL_REEST_TCH_H_DBL,
1546 CHREQ_T_SDCCH,
1547 CHREQ_T_TCH_F,
1548 CHREQ_T_VOICE_CALL_TCH_H,
1549 CHREQ_T_DATA_CALL_TCH_H,
1550 CHREQ_T_LOCATION_UPD,
1551 CHREQ_T_PAG_R_ANY_NECI0,
1552 CHREQ_T_PAG_R_ANY_NECI1,
1553 CHREQ_T_PAG_R_TCH_F,
1554 CHREQ_T_PAG_R_TCH_FH,
1555 CHREQ_T_LMU,
1556 CHREQ_T_RESERVED_SDCCH,
1557 CHREQ_T_RESERVED_IGNORE,
Alexander Couzensf48e8a82016-12-05 15:57:42 +01001558 CHREQ_T_PDCH_ONE_PHASE,
1559 CHREQ_T_PDCH_TWO_PHASE,
Alexander Couzens953f9292017-03-14 13:47:29 +01001560 _NUM_CHREQ_T,
Harald Welteec8b4502010-02-20 20:34:29 +01001561};
1562
1563/* Chapter 11.3 */
1564#define GSM48_T301 180, 0
1565#define GSM48_T303 30, 0
1566#define GSM48_T305 30, 0
1567#define GSM48_T306 30, 0
Harald Weltee50b0092018-01-27 09:40:34 +01001568#define GSM48_T308 10, 0 /* no spec default */
Harald Weltecd827102018-01-27 09:43:03 +01001569#define GSM48_T310 30, 0 /* no spec default */
Harald Weltee50b0092018-01-27 09:40:34 +01001570#define GSM48_T313 30, 0 /* no spec default */
Harald Welteec8b4502010-02-20 20:34:29 +01001571#define GSM48_T323 30, 0
Harald Weltee50b0092018-01-27 09:40:34 +01001572#define GSM48_T331 30, 0 /* no spec default */
1573#define GSM48_T333 30, 0 /* no spec default */
1574#define GSM48_T334 25, 0 /* min 15s */
1575#define GSM48_T338 30, 0 /* no spec default */
Andreas Eversberg014cb872010-07-12 09:11:00 +02001576#define GSM48_T303_MS 30, 0
1577#define GSM48_T305_MS 30, 0
1578#define GSM48_T308_MS 30, 0
1579#define GSM48_T310_MS 30, 0
1580#define GSM48_T313_MS 30, 0
1581#define GSM48_T323_MS 30, 0
1582#define GSM48_T332_MS 30, 0
1583#define GSM48_T335_MS 30, 0
Harald Welteec8b4502010-02-20 20:34:29 +01001584
1585/* Chapter 5.1.2.2 */
1586#define GSM_CSTATE_NULL 0
1587#define GSM_CSTATE_INITIATED 1
Andreas Eversberg1ef041f2010-04-09 07:52:12 +02001588#define GSM_CSTATE_MM_CONNECTION_PEND 2 /* see 10.5.4.6 */
Harald Welteec8b4502010-02-20 20:34:29 +01001589#define GSM_CSTATE_MO_CALL_PROC 3
1590#define GSM_CSTATE_CALL_DELIVERED 4
1591#define GSM_CSTATE_CALL_PRESENT 6
1592#define GSM_CSTATE_CALL_RECEIVED 7
1593#define GSM_CSTATE_CONNECT_REQUEST 8
1594#define GSM_CSTATE_MO_TERM_CALL_CONF 9
1595#define GSM_CSTATE_ACTIVE 10
1596#define GSM_CSTATE_DISCONNECT_REQ 12
1597#define GSM_CSTATE_DISCONNECT_IND 12
1598#define GSM_CSTATE_RELEASE_REQ 19
1599#define GSM_CSTATE_MO_ORIG_MODIFY 26
1600#define GSM_CSTATE_MO_TERM_MODIFY 27
1601#define GSM_CSTATE_CONNECT_IND 28
1602
1603#define SBIT(a) (1 << a)
1604#define ALL_STATES 0xffffffff
1605
1606/* Table 10.5.3/3GPP TS 04.08: Location Area Identification information element */
1607#define GSM_LAC_RESERVED_DETACHED 0x0
1608#define GSM_LAC_RESERVED_ALL_BTS 0xfffe
1609
1610/* GSM 04.08 Bearer Capability: Information Transfer Capability */
1611enum gsm48_bcap_itcap {
1612 GSM48_BCAP_ITCAP_SPEECH = 0,
1613 GSM48_BCAP_ITCAP_UNR_DIG_INF = 1,
1614 GSM48_BCAP_ITCAP_3k1_AUDIO = 2,
1615 GSM48_BCAP_ITCAP_FAX_G3 = 3,
1616 GSM48_BCAP_ITCAP_OTHER = 5,
1617 GSM48_BCAP_ITCAP_RESERVED = 7,
1618};
1619
1620/* GSM 04.08 Bearer Capability: Transfer Mode */
1621enum gsm48_bcap_tmod {
1622 GSM48_BCAP_TMOD_CIRCUIT = 0,
1623 GSM48_BCAP_TMOD_PACKET = 1,
1624};
1625
1626/* GSM 04.08 Bearer Capability: Coding Standard */
1627enum gsm48_bcap_coding {
1628 GSM48_BCAP_CODING_GSM_STD = 0,
1629};
1630
1631/* GSM 04.08 Bearer Capability: Radio Channel Requirements */
1632enum gsm48_bcap_rrq {
1633 GSM48_BCAP_RRQ_FR_ONLY = 1,
1634 GSM48_BCAP_RRQ_DUAL_HR = 2,
1635 GSM48_BCAP_RRQ_DUAL_FR = 3,
1636};
1637
Harald Weltec8a0b932012-08-24 21:27:26 +02001638/* GSM 04.08 Bearer Capability: Rate Adaption */
1639enum gsm48_bcap_ra {
1640 GSM48_BCAP_RA_NONE = 0,
1641 GSM48_BCAP_RA_V110_X30 = 1,
1642 GSM48_BCAP_RA_X31 = 2,
1643 GSM48_BCAP_RA_OTHER = 3,
1644};
1645
1646/* GSM 04.08 Bearer Capability: Signalling access protocol */
1647enum gsm48_bcap_sig_access {
1648 GSM48_BCAP_SA_I440_I450 = 1,
1649 GSM48_BCAP_SA_X21 = 2,
1650 GSM48_BCAP_SA_X28_DP_IN = 3,
1651 GSM48_BCAP_SA_X28_DP_UN = 4,
1652 GSM48_BCAP_SA_X28_NDP = 5,
1653 GSM48_BCAP_SA_X32 = 6,
1654};
1655
1656/* GSM 04.08 Bearer Capability: User Rate */
1657enum gsm48_bcap_user_rate {
1658 GSM48_BCAP_UR_300 = 1,
1659 GSM48_BCAP_UR_1200 = 2,
1660 GSM48_BCAP_UR_2400 = 3,
1661 GSM48_BCAP_UR_4800 = 4,
1662 GSM48_BCAP_UR_9600 = 5,
1663 GSM48_BCAP_UR_12000 = 6,
1664 GSM48_BCAP_UR_1200_75 = 7,
1665};
1666
1667/* GSM 04.08 Bearer Capability: Parity */
1668enum gsm48_bcap_parity {
1669 GSM48_BCAP_PAR_ODD = 0,
1670 GSM48_BCAP_PAR_EVEN = 2,
1671 GSM48_BCAP_PAR_NONE = 3,
1672 GSM48_BCAP_PAR_ZERO = 4,
1673 GSM48_BCAP_PAR_ONE = 5,
1674};
1675
1676/* GSM 04.08 Bearer Capability: Intermediate Rate */
1677enum gsm48_bcap_interm_rate {
1678 GSM48_BCAP_IR_8k = 2,
1679 GSM48_BCAP_IR_16k = 3,
1680};
1681
1682/* GSM 04.08 Bearer Capability: Transparency */
1683enum gsm48_bcap_transp {
1684 GSM48_BCAP_TR_TRANSP = 0,
1685 GSM48_BCAP_TR_RLP = 1,
1686 GSM48_BCAP_TR_TR_PREF = 2,
1687 GSM48_BCAP_TR_RLP_PREF = 3,
1688};
1689
1690/* GSM 04.08 Bearer Capability: Modem Type */
1691enum gsm48_bcap_modem_type {
1692 GSM48_BCAP_MT_NONE = 0,
1693 GSM48_BCAP_MT_V21 = 1,
1694 GSM48_BCAP_MT_V22 = 2,
1695 GSM48_BCAP_MT_V22bis = 3,
1696 GSM48_BCAP_MT_V23 = 4,
1697 GSM48_BCAP_MT_V26ter = 5,
1698 GSM48_BCAP_MT_V32 = 6,
1699 GSM48_BCAP_MT_UNDEF = 7,
1700 GSM48_BCAP_MT_AUTO_1 = 8,
1701};
1702
Neels Hofmeyr87e45502017-06-20 00:17:59 +02001703/*! GSM 04.08 Bearer Capability: Speech Version Indication
Philipp Maier3d9191e2017-05-31 17:22:03 +02001704 * (See also 3GPP TS 24.008, Table 10.5.103) */
Harald Welte30a8ec42012-08-24 23:00:05 +02001705enum gsm48_bcap_speech_ver {
Philipp Maiera9e193b2017-06-16 16:47:06 +02001706 GSM48_BCAP_SV_FR = 0, /*!< GSM FR V1 (GSM FR) */
1707 GSM48_BCAP_SV_HR = 1, /*!< GSM HR V1 (GSM HR) */
1708 GSM48_BCAP_SV_EFR = 2, /*!< GSM FR V2 (GSM EFR) */
1709 GSM48_BCAP_SV_AMR_F = 4, /*!< GSM FR V3 (FR AMR) */
1710 GSM48_BCAP_SV_AMR_H = 5, /*!< GSM HR V3 (HR_AMR) */
Philipp Maier3d9191e2017-05-31 17:22:03 +02001711 GSM48_BCAP_SV_AMR_OFW = 6, /*!< GSM FR V4 (OFR AMR-WB) */
1712 GSM48_BCAP_SV_AMR_OHW = 7, /*!< GSM HR V4 (OHR AMR-WB) */
1713 GSM48_BCAP_SV_AMR_FW = 8, /*!< GSM FR V5 (FR AMR-WB) */
1714 GSM48_BCAP_SV_AMR_OH = 11, /*!< GSM HR V6 (OHR AMR) */
Harald Welte30a8ec42012-08-24 23:00:05 +02001715};
1716
Harald Welteec8b4502010-02-20 20:34:29 +01001717#define GSM48_TMSI_LEN 5
1718#define GSM48_MID_TMSI_LEN (GSM48_TMSI_LEN + 2)
1719#define GSM48_MI_SIZE 32
1720
Maxff2eeda2018-01-04 18:43:44 +01001721/* 3GPP TS 24.008 ยง 10.5.5.15 Routing area identification */
Harald Weltea1c4f762010-05-01 11:59:42 +02001722struct gsm48_ra_id {
1723 uint8_t digits[3]; /* MCC + MNC BCD digits */
1724 uint16_t lac; /* Location Area Code */
1725 uint8_t rac; /* Routing Area Code */
1726} __attribute__ ((packed));
1727
Harald Welteb5503132011-05-24 15:01:53 +02001728#define GSM48_CELL_CHAN_DESC_SIZE 16
Harald Weltea1c4f762010-05-01 11:59:42 +02001729
Harald Welteb5503132011-05-24 15:01:53 +02001730#define GSM_MACBLOCK_LEN 23
1731#define GSM_MACBLOCK_PADDING 0x2b
Harald Welte55478082018-02-09 22:39:29 +01001732
1733/* Table 10.5.118 / 3GPP TS 24.008 Section 10.5.4.7 */
1734enum gsm48_type_of_number {
1735 GSM48_TON_UNKNOWN = 0,
1736 GSM48_TON_INTERNATIONAL = 1,
1737 GSM48_TON_NATIONAL = 2,
1738 GSM48_TON_NET_SPEC = 3,
1739 GSM48_TON_SHORT_CODE = 4,
1740 /* reserved */
1741};
1742
1743/* Table 10.5.118 / 3GPP TS 24.008 Section 10.5.4.7 */
1744enum gsm48_numbering_plan {
1745 GSM48_NPI_UNKNOWN = 0,
1746 GSM48_NPI_ISDN_E164 = 1,
1747 GSM48_NPI_DATA_X121 = 3,
1748 GSM48_NPI_TELEX_F69 = 4,
1749 GSM48_NPI_NATIONAL = 8,
1750 GSM48_NPI_PRIVATE = 9,
1751 GSM48_NPI_CTS = 11,
1752 /* reserved */
1753};