blob: 604a5df4c20c90e02170f36698b7685d7689f97f [file] [log] [blame]
Sylvain Munaut12ba7782014-06-16 10:13:40 +02001#pragma once
Harald Welteec8b4502010-02-20 20:34:29 +01002
3#include <stdint.h>
Maxfe65fa72016-05-10 17:17:05 +02004#include <stdbool.h>
Harald Welteec8b4502010-02-20 20:34:29 +01005
Maxfb348ee2016-03-30 21:14:53 +02006#include <osmocom/core/utils.h>
Ruben Undheim720ac4a2016-05-27 22:03:59 +02007#include <osmocom/core/endian.h>
8
Harald Welteec8b4502010-02-20 20:34:29 +01009/* GSM TS 04.08 definitions */
10struct gsm_lchan;
11
Andreas Eversberg014cb872010-07-12 09:11:00 +020012/* Chapter 10.5.1.5 */
Harald Welteec8b4502010-02-20 20:34:29 +010013struct gsm48_classmark1 {
Andreas Eversberg014cb872010-07-12 09:11:00 +020014 uint8_t pwr_lev:3,
Harald Welteec8b4502010-02-20 20:34:29 +010015 a5_1:1,
Andreas Eversberg014cb872010-07-12 09:11:00 +020016 es_ind:1,
17 rev_lev:2,
18 spare:1;
19} __attribute__ ((packed));
20
21/* Chapter 10.5.1.6 */
22struct gsm48_classmark2 {
23 uint8_t pwr_lev:3,
24 a5_1:1,
25 es_ind:1,
26 rev_lev:2,
27 spare:1;
28 uint8_t fc:1,
29 vgcs:1,
30 vbs:1,
31 sm_cap:1,
32 ss_scr:2,
33 ps_cap:1,
34 spare2:1;
35 uint8_t a5_2:1,
36 a5_3:1,
37 cmsp:1,
38 solsa:1,
39 spare3:1,
40 lcsva_cap:1,
41 spare4:1,
42 cm3:1;
43} __attribute__ ((packed));
44
45/* Chapter 10.5.2.1b.3 */
Ruben Undheim720ac4a2016-05-27 22:03:59 +020046#if OSMO_IS_LITTLE_ENDIAN == 1
Andreas Eversberg014cb872010-07-12 09:11:00 +020047struct gsm48_range_1024 {
48 uint8_t w1_hi:2,
49 f0:1,
50 form_id:5;
51 uint8_t w1_lo;
52 uint8_t w2_hi;
53 uint8_t w3_hi:7,
54 w2_lo:1;
55 uint8_t w4_hi:6,
56 w3_lo:2;
57 uint8_t w5_hi:6,
58 w4_lo:2;
59 uint8_t w6_hi:6,
60 w5_lo:2;
61 uint8_t w7_hi:6,
62 w6_lo:2;
63 uint8_t w8_hi:6,
64 w7_lo:2;
65 uint8_t w9:7,
66 w8_lo:1;
67 uint8_t w11_hi:1,
68 w10:7;
69 uint8_t w12_hi:2,
70 w11_lo:6;
71 uint8_t w13_hi:3,
72 w12_lo:5;
73 uint8_t w14_hi:4,
74 w13_lo:4;
75 uint8_t w15_hi:5,
76 w14_lo:3;
77 uint8_t w16:6,
78 w15_lo:2;
79} __attribute__ ((packed));
Ruben Undheim720ac4a2016-05-27 22:03:59 +020080#else
81struct gsm48_range_1024 {
82 uint8_t form_id:5,
83 f0:1,
84 w1_hi:2;
85 uint8_t w1_lo;
86 uint8_t w2_hi;
87 uint8_t w2_lo:1,
88 w3_hi:7;
89 uint8_t w3_lo:2,
90 w4_hi:6;
91 uint8_t w4_lo:2,
92 w5_hi:6;
93 uint8_t w5_lo:2,
94 w6_hi:6;
95 uint8_t w6_lo:2,
96 w7_hi:6;
97 uint8_t w7_lo:2,
98 w8_hi:6;
99 uint8_t w8_lo:1,
100 w9:7;
101 uint8_t w10:7,
102 w11_hi:1;
103 uint8_t w11_lo:6,
104 w12_hi:2;
105 uint8_t w12_lo:5,
106 w13_hi:3;
107 uint8_t w13_lo:4,
108 w14_hi:4;
109 uint8_t w14_lo:3,
110 w15_hi:5;
111 uint8_t w15_lo:2,
112 w16:6;
113} __attribute__ ((packed));
114#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200115
116/* Chapter 10.5.2.1b.4 */
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200117#if OSMO_IS_LITTLE_ENDIAN == 1
Andreas Eversberg014cb872010-07-12 09:11:00 +0200118struct gsm48_range_512 {
119 uint8_t orig_arfcn_hi:1,
120 form_id:7;
121 uint8_t orig_arfcn_mid;
122 uint8_t w1_hi:7,
123 orig_arfcn_lo:1;
124 uint8_t w2_hi:6,
125 w1_lo:2;
126 uint8_t w3_hi:6,
127 w2_lo:2;
128 uint8_t w4_hi:6,
129 w3_lo:2;
130 uint8_t w5:7,
131 w4_lo:1;
132 uint8_t w7_hi:1,
133 w6:7;
134 uint8_t w8_hi:2,
135 w7_lo:6;
136 uint8_t w9_hi:4,
137 w8_lo:4;
138 uint8_t w10:6,
139 w9_lo:2;
140 uint8_t w12_hi:2,
141 w11:6;
142 uint8_t w13_hi:4,
143 w12_lo:4;
144 uint8_t w14:6,
145 w13_lo:2;
146 uint8_t w16_hi:2,
147 w15:6;
148 uint8_t w17:5,
149 w16_lo:3;
150} __attribute__ ((packed));
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200151#else
152struct gsm48_range_512 {
153 uint8_t form_id:7,
154 orig_arfcn_hi:1;
155 uint8_t orig_arfcn_mid;
156 uint8_t orig_arfcn_lo:1,
157 w1_hi:7;
158 uint8_t w1_lo:2,
159 w2_hi:6;
160 uint8_t w2_lo:2,
161 w3_hi:6;
162 uint8_t w3_lo:2,
163 w4_hi:6;
164 uint8_t w4_lo:1,
165 w5:7;
166 uint8_t w6:7,
167 w7_hi:1;
168 uint8_t w7_lo:6,
169 w8_hi:2;
170 uint8_t w8_lo:4,
171 w9_hi:4;
172 uint8_t w9_lo:2,
173 w10:6;
174 uint8_t w11:6,
175 w12_hi:2;
176 uint8_t w12_lo:4,
177 w13_hi:4;
178 uint8_t w13_lo:2,
179 w14:6;
180 uint8_t w15:6,
181 w16_hi:2;
182 uint8_t w16_lo:3,
183 w17:5;
184} __attribute__ ((packed));
185#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200186
187/* Chapter 10.5.2.1b.5 */
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200188#if OSMO_IS_LITTLE_ENDIAN == 1
Andreas Eversberg014cb872010-07-12 09:11:00 +0200189struct gsm48_range_256 {
190 uint8_t orig_arfcn_hi:1,
191 form_id:7;
192 uint8_t orig_arfcn_mid;
193 uint8_t w1_hi:7,
194 orig_arfcn_lo:1;
195 uint8_t w2:7,
196 w1_lo:1;
197 uint8_t w4_hi:1,
198 w3:7;
199 uint8_t w5_hi:3,
200 w4_lo:5;
201 uint8_t w6_hi:5,
202 w5_lo:3;
203 uint8_t w8_hi:1,
204 w7:6,
205 w6_lo:1;
206 uint8_t w9_hi:4,
207 w8_lo:4;
208 uint8_t w11_hi:2,
209 w10:5,
210 w9_lo:1;
211 uint8_t w12:5,
212 w11_lo:3;
213 uint8_t w14_hi:3,
214 w13:5;
215 uint8_t w16_hi:1,
216 w15:5,
217 w14_lo:2;
218 uint8_t w18_hi:1,
219 w17:4,
220 w16_lo:3;
221 uint8_t w20_hi:1,
222 w19:4,
223 w18_lo:3;
224 uint8_t spare:1,
225 w21:4,
226 w20_lo:3;
227} __attribute__ ((packed));
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200228#else
229struct gsm48_range_256 {
230 uint8_t form_id:7,
231 orig_arfcn_hi:1;
232 uint8_t orig_arfcn_mid;
233 uint8_t orig_arfcn_lo:1,
234 w1_hi:7;
235 uint8_t w1_lo:1,
236 w2:7;
237 uint8_t w3:7,
238 w4_hi:1;
239 uint8_t w4_lo:5,
240 w5_hi:3;
241 uint8_t w5_lo:3,
242 w6_hi:5;
243 uint8_t w6_lo:1,
244 w7:6,
245 w8_hi:1;
246 uint8_t w8_lo:4,
247 w9_hi:4;
248 uint8_t w9_lo:1,
249 w10:5,
250 w11_hi:2;
251 uint8_t w11_lo:3,
252 w12:5;
253 uint8_t w13:5,
254 w14_hi:3;
255 uint8_t w14_lo:2,
256 w15:5,
257 w16_hi:1;
258 uint8_t w16_lo:3,
259 w17:4,
260 w18_hi:1;
261 uint8_t w18_lo:3,
262 w19:4,
263 w20_hi:1;
264 uint8_t w20_lo:3,
265 w21:4,
266 spare:1;
267} __attribute__ ((packed));
268#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200269
270/* Chapter 10.5.2.1b.6 */
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200271#if OSMO_IS_LITTLE_ENDIAN == 1
Andreas Eversberg014cb872010-07-12 09:11:00 +0200272struct gsm48_range_128 {
273 uint8_t orig_arfcn_hi:1,
274 form_id:7;
275 uint8_t orig_arfcn_mid;
276 uint8_t w1:7,
277 orig_arfcn_lo:1;
278 uint8_t w3_hi:2,
279 w2:6;
280 uint8_t w4_hi:4,
281 w3_lo:4;
282 uint8_t w6_hi:2,
283 w5:5,
284 w4_lo:1;
285 uint8_t w7:5,
286 w6_lo:3;
287 uint8_t w9:4,
288 w8:4;
289 uint8_t w11:4,
290 w10:4;
291 uint8_t w13:4,
292 w12:4;
293 uint8_t w15:4,
294 w14:4;
295 uint8_t w18_hi:2,
296 w17:3,
297 w16:3;
298 uint8_t w21_hi:1,
299 w20:3,
300 w19:3,
301 w18_lo:1;
302 uint8_t w23:3,
303 w22:3,
304 w21_lo:2;
305 uint8_t w26_hi:2,
306 w25:3,
307 w24:3;
308 uint8_t spare:1,
309 w28:3,
310 w27:3,
311 w26_lo:1;
312} __attribute__ ((packed));
Ruben Undheim720ac4a2016-05-27 22:03:59 +0200313#else
314struct gsm48_range_128 {
315 uint8_t form_id:7,
316 orig_arfcn_hi:1;
317 uint8_t orig_arfcn_mid;
318 uint8_t orig_arfcn_lo:1,
319 w1:7;
320 uint8_t w2:6,
321 w3_hi:2;
322 uint8_t w3_lo:4,
323 w4_hi:4;
324 uint8_t w4_lo:1,
325 w5:5,
326 w6_hi:2;
327 uint8_t w6_lo:3,
328 w7:5;
329 uint8_t w8:4,
330 w9:4;
331 uint8_t w10:4,
332 w11:4;
333 uint8_t w12:4,
334 w13:4;
335 uint8_t w14:4,
336 w15:4;
337 uint8_t w16:3,
338 w17:3,
339 w18_hi:2;
340 uint8_t w18_lo:1,
341 w19:3,
342 w20:3,
343 w21_hi:1;
344 uint8_t w21_lo:2,
345 w22:3,
346 w23:3;
347 uint8_t w24:3,
348 w25:3,
349 w26_hi:2;
350 uint8_t w26_lo:1,
351 w27:3,
352 w28:3,
353 spare:1;
354} __attribute__ ((packed));
355#endif
Andreas Eversberg014cb872010-07-12 09:11:00 +0200356
357/* Chapter 10.5.2.1b.7 */
358struct gsm48_var_bit {
359 uint8_t orig_arfcn_hi:1,
360 form_id:7;
361 uint8_t orig_arfcn_mid;
362 uint8_t rrfcn1_7:7,
363 orig_arfcn_lo:1;
364 uint8_t rrfcn8_111[13];
Harald Welteec8b4502010-02-20 20:34:29 +0100365} __attribute__ ((packed));
366
367/* Chapter 10.5.2.5 */
368struct gsm48_chan_desc {
369 uint8_t chan_nr;
370 union {
371 struct {
372 uint8_t maio_high:4,
373 h:1,
374 tsc:3;
375 uint8_t hsn:6,
376 maio_low:2;
Andreas Eversberg4b332d72012-02-07 20:02:17 +0100377 } __attribute__ ((packed)) h1;
Harald Welteec8b4502010-02-20 20:34:29 +0100378 struct {
379 uint8_t arfcn_high:2,
380 spare:2,
381 h:1,
382 tsc:3;
383 uint8_t arfcn_low;
Andreas Eversberg4b332d72012-02-07 20:02:17 +0100384 } __attribute__ ((packed)) h0;
385 } __attribute__ ((packed));
Harald Welteec8b4502010-02-20 20:34:29 +0100386} __attribute__ ((packed));
387
Andreas Eversberg014cb872010-07-12 09:11:00 +0200388/* Chapter 10.5.2.20 */
389struct gsm48_meas_res {
390 uint8_t rxlev_full:6,
391 dtx_used:1,
392 ba_used:1;
393 uint8_t rxlev_sub:6,
394 meas_valid:1,
395 spare:1;
396 uint8_t no_nc_n_hi:1,
397 rxqual_sub:3,
398 rxqual_full:3,
399 spare2:1;
400 uint8_t rxlev_nc1:6,
401 no_nc_n_lo:2;
402 uint8_t bsic_nc1_hi:3,
403 bcch_f_nc1:5;
404 uint8_t rxlev_nc2_hi:5,
405 bsic_nc1_lo:3;
406 uint8_t bsic_nc2_hi:2,
407 bcch_f_nc2:5,
408 rxlev_nc2_lo:1;
409 uint8_t rxlev_nc3_hi:4,
410 bsic_nc2_lo:4;
411 uint8_t bsic_nc3_hi:1,
412 bcch_f_nc3:5,
413 rxlev_nc3_lo:2;
414 uint8_t rxlev_nc4_hi:3,
415 bsic_nc3_lo:5;
416 uint8_t bcch_f_nc4:5,
417 rxlev_nc4_lo:3;
418 uint8_t rxlev_nc5_hi:2,
419 bsic_nc4:6;
420 uint8_t bcch_f_nc5_hi:4,
421 rxlev_nc5_lo:4;
422 uint8_t rxlev_nc6_hi:1,
423 bsic_nc5:6,
424 bcch_f_nc5_lo:1;
425 uint8_t bcch_f_nc6_hi:3,
426 rxlev_nc6_lo:5;
427 uint8_t bsic_nc6:6,
428 bcch_f_nc6_lo:2;
429} __attribute__ ((packed));
430
Harald Welteec8b4502010-02-20 20:34:29 +0100431/* Chapter 10.5.2.21aa */
432struct gsm48_multi_rate_conf {
433 uint8_t smod : 2,
434 spare: 1,
435 icmi : 1,
436 nscb : 1,
437 ver : 3;
438 uint8_t m4_75 : 1,
439 m5_15 : 1,
440 m5_90 : 1,
441 m6_70 : 1,
442 m7_40 : 1,
443 m7_95 : 1,
444 m10_2 : 1,
445 m12_2 : 1;
446} __attribute__((packed));
447
Andreas Eversberg014cb872010-07-12 09:11:00 +0200448/* Chapter 10.5.2.28(a) */
449struct gsm48_power_cmd {
450 uint8_t power_level:5,
451 spare:2,
452 atc:1;
453} __attribute__((packed));
454
455/* Chapter 10.5.2.29 */
456struct gsm48_rach_control {
457 uint8_t re :1,
458 cell_bar :1,
459 tx_integer :4,
460 max_trans :2;
461 uint8_t t2;
462 uint8_t t3;
463} __attribute__ ((packed));
464
465
Harald Welteec8b4502010-02-20 20:34:29 +0100466/* Chapter 10.5.2.30 */
467struct gsm48_req_ref {
468 uint8_t ra;
469 uint8_t t3_high:3,
Andreas Eversberg93364fc2010-06-25 02:50:06 +0200470 t1:5;
Harald Welteec8b4502010-02-20 20:34:29 +0100471 uint8_t t2:5,
472 t3_low:3;
473} __attribute__ ((packed));
474
Andreas Eversberg014cb872010-07-12 09:11:00 +0200475/* Chapter 10.5.2.38 */
476struct gsm48_start_time {
477 uint8_t t3_high:3,
478 t1:5;
479 uint8_t t2:5,
480 t3_low:3;
481} __attribute__ ((packed));
482
483/* Chapter 10.5.2.39 */
484struct gsm48_sync_ind {
485 uint8_t si:2,
486 rot:1,
487 nci:1,
488 sync_ie:4;
489} __attribute__((packed));
490
Harald Welteec8b4502010-02-20 20:34:29 +0100491/*
492 * Chapter 9.1.5/9.1.6
493 *
494 * For 9.1.6 the chan_desc has the meaning of 10.5.2.5a
495 */
496struct gsm48_chan_mode_modify {
497 struct gsm48_chan_desc chan_desc;
498 uint8_t mode;
499} __attribute__ ((packed));
500
501enum gsm48_chan_mode {
502 GSM48_CMODE_SIGN = 0x00,
503 GSM48_CMODE_SPEECH_V1 = 0x01,
504 GSM48_CMODE_SPEECH_EFR = 0x21,
505 GSM48_CMODE_SPEECH_AMR = 0x41,
506 GSM48_CMODE_DATA_14k5 = 0x0f,
507 GSM48_CMODE_DATA_12k0 = 0x03,
508 GSM48_CMODE_DATA_6k0 = 0x0b,
Bhaskar31e844b2013-05-16 17:06:35 +0530509 GSM48_CMODE_DATA_3k6 = 0x13,
Harald Welteec8b4502010-02-20 20:34:29 +0100510};
511
Maxfb348ee2016-03-30 21:14:53 +0200512extern const struct value_string gsm48_chan_mode_names[];
513
Harald Welteec8b4502010-02-20 20:34:29 +0100514/* Chapter 9.1.2 */
515struct gsm48_ass_cmd {
516 /* Semantic is from 10.5.2.5a */
517 struct gsm48_chan_desc chan_desc;
518 uint8_t power_command;
519 uint8_t data[0];
520} __attribute__((packed));
521
Andreas Eversbergfa832012010-09-01 23:37:07 +0200522/* Chapter 9.1.13 */
523struct gsm48_frq_redef {
524 /* Semantic is from 10.5.2.5a */
525 struct gsm48_chan_desc chan_desc;
526 uint8_t mob_alloc_len;
527 uint8_t mob_alloc[0];
528} __attribute__((packed));
529
Harald Welteec8b4502010-02-20 20:34:29 +0100530/* Chapter 10.5.2.2 */
531struct gsm48_cell_desc {
532 uint8_t bcc:3,
533 ncc:3,
534 arfcn_hi:2;
535 uint8_t arfcn_lo;
536} __attribute__((packed));
537
538/* Chapter 9.1.15 */
539struct gsm48_ho_cmd {
540 struct gsm48_cell_desc cell_desc;
541 struct gsm48_chan_desc chan_desc;
542 uint8_t ho_ref;
543 uint8_t power_command;
544 uint8_t data[0];
545} __attribute__((packed));
546
547/* Chapter 9.1.18 */
548struct gsm48_imm_ass {
549 uint8_t l2_plen;
550 uint8_t proto_discr;
551 uint8_t msg_type;
552 uint8_t page_mode;
553 struct gsm48_chan_desc chan_desc;
554 struct gsm48_req_ref req_ref;
555 uint8_t timing_advance;
556 uint8_t mob_alloc_len;
557 uint8_t mob_alloc[0];
558} __attribute__ ((packed));
559
Holger Hans Peter Freyther5dcef3c2010-05-15 22:35:25 +0800560/* Chapter 9.1.25 */
561struct gsm48_pag_resp {
562 uint8_t spare:4,
563 key_seq:4;
564 uint32_t classmark2;
565 uint8_t mi_len;
566 uint8_t mi[0];
567} __attribute__ ((packed));
568
Harald Welteec8b4502010-02-20 20:34:29 +0100569/* Chapter 10.5.1.3 */
570struct gsm48_loc_area_id {
571 uint8_t digits[3]; /* BCD! */
572 uint16_t lac;
573} __attribute__ ((packed));
574
575/* Section 9.2.2 */
576struct gsm48_auth_req {
577 uint8_t key_seq:4,
578 spare:4;
579 uint8_t rand[16];
580} __attribute__ ((packed));
581
Sylvain Munautd005eab2010-06-10 13:30:50 +0200582/* Section 9.2.3 */
583struct gsm48_auth_resp {
584 uint8_t sres[4];
585} __attribute__ ((packed));
586
Harald Welteec8b4502010-02-20 20:34:29 +0100587/* Section 9.2.15 */
588struct gsm48_loc_upd_req {
589 uint8_t type:4,
590 key_seq:4;
591 struct gsm48_loc_area_id lai;
592 struct gsm48_classmark1 classmark1;
593 uint8_t mi_len;
594 uint8_t mi[0];
595} __attribute__ ((packed));
596
597/* Section 10.1 */
598struct gsm48_hdr {
599 uint8_t proto_discr;
600 uint8_t msg_type;
601 uint8_t data[0];
602} __attribute__ ((packed));
603
604/* Section 9.1.3x System information Type header */
605struct gsm48_system_information_type_header {
606 uint8_t l2_plen;
607 uint8_t rr_protocol_discriminator :4,
608 skip_indicator:4;
609 uint8_t system_information;
610} __attribute__ ((packed));
611
Harald Welteec8b4502010-02-20 20:34:29 +0100612/* Section 10.5.2.4 Cell Selection Parameters */
613struct gsm48_cell_sel_par {
614 uint8_t ms_txpwr_max_ccch:5, /* GSM 05.08 MS-TXPWR-MAX-CCCH */
615 cell_resel_hyst:3; /* GSM 05.08 CELL-RESELECT-HYSTERESIS */
616 uint8_t rxlev_acc_min:6, /* GSM 05.08 RXLEV-ACCESS-MIN */
617 neci:1,
618 acs:1;
619} __attribute__ ((packed));
620
Neels Hofmeyrd1c2fc62017-02-21 14:51:40 +0100621/* 3GPP TS 44.018 Section 10.5.2.11 Control Channel Description */
Harald Welteec8b4502010-02-20 20:34:29 +0100622struct gsm48_control_channel_descr {
623 uint8_t ccch_conf :3,
624 bs_ag_blks_res :3,
625 att :1,
Neels Hofmeyrd1c2fc62017-02-21 14:51:40 +0100626 mscr :1;
Harald Welteec8b4502010-02-20 20:34:29 +0100627 uint8_t bs_pa_mfrms : 3,
Neels Hofmeyrd1c2fc62017-02-21 14:51:40 +0100628 spare_1 :2,
629 cbq3 :2,
630 spare_2 :1;
Harald Welteec8b4502010-02-20 20:34:29 +0100631 uint8_t t3212;
632} __attribute__ ((packed));
633
Maxfe65fa72016-05-10 17:17:05 +0200634enum gsm48_dtx_mode {
635 GSM48_DTX_MAY_BE_USED,
636 GSM48_DTX_SHALL_BE_USED,
637 GSM48_DTX_SHALL_NOT_BE_USED
638};
639
640/* Cell Options for SI6, SACCH (10.5.2.3a.2) or SI3, BCCH (Table 10.5.2.3.1),
641 3GPP TS 44.018 */
Harald Welteec8b4502010-02-20 20:34:29 +0100642struct gsm48_cell_options {
643 uint8_t radio_link_timeout:4,
644 dtx:2,
645 pwrc:1,
Maxfe65fa72016-05-10 17:17:05 +0200646 /* either DN-IND or top bit of DTX IND */
647 d:1;
Harald Welteec8b4502010-02-20 20:34:29 +0100648} __attribute__ ((packed));
649
650/* Section 9.2.9 CM service request */
651struct gsm48_service_request {
652 uint8_t cm_service_type : 4,
653 cipher_key_seq : 4;
654 /* length + 3 bytes */
655 uint32_t classmark;
656 uint8_t mi_len;
657 uint8_t mi[0];
658 /* optional priority level */
659} __attribute__ ((packed));
660
661/* Section 9.1.31 System information Type 1 */
662struct gsm48_system_information_type_1 {
663 struct gsm48_system_information_type_header header;
664 uint8_t cell_channel_description[16];
665 struct gsm48_rach_control rach_control;
666 uint8_t rest_octets[0]; /* NCH position on the CCCH */
667} __attribute__ ((packed));
668
669/* Section 9.1.32 System information Type 2 */
670struct gsm48_system_information_type_2 {
671 struct gsm48_system_information_type_header header;
672 uint8_t bcch_frequency_list[16];
673 uint8_t ncc_permitted;
674 struct gsm48_rach_control rach_control;
675} __attribute__ ((packed));
676
Andreas Eversberg014cb872010-07-12 09:11:00 +0200677/* Section 9.1.33 System information Type 2bis */
678struct gsm48_system_information_type_2bis {
679 struct gsm48_system_information_type_header header;
680 uint8_t bcch_frequency_list[16];
681 struct gsm48_rach_control rach_control;
682 uint8_t rest_octets[0];
683} __attribute__ ((packed));
684
685/* Section 9.1.34 System information Type 2ter */
686struct gsm48_system_information_type_2ter {
687 struct gsm48_system_information_type_header header;
688 uint8_t ext_bcch_frequency_list[16];
689 uint8_t rest_octets[0];
690} __attribute__ ((packed));
691
Maxe859aec2016-03-11 12:24:04 +0100692/* Section 9.1.34a System information Type 2quater */
693struct gsm48_system_information_type_2quater {
694 struct gsm48_system_information_type_header header;
695 uint8_t rest_octets[0];
696} __attribute__ ((packed));
697
Harald Welteec8b4502010-02-20 20:34:29 +0100698/* Section 9.1.35 System information Type 3 */
699struct gsm48_system_information_type_3 {
700 struct gsm48_system_information_type_header header;
701 uint16_t cell_identity;
702 struct gsm48_loc_area_id lai;
703 struct gsm48_control_channel_descr control_channel_desc;
704 struct gsm48_cell_options cell_options;
705 struct gsm48_cell_sel_par cell_sel_par;
706 struct gsm48_rach_control rach_control;
707 uint8_t rest_octets[0];
708} __attribute__ ((packed));
709
710/* Section 9.1.36 System information Type 4 */
711struct gsm48_system_information_type_4 {
712 struct gsm48_system_information_type_header header;
713 struct gsm48_loc_area_id lai;
714 struct gsm48_cell_sel_par cell_sel_par;
715 struct gsm48_rach_control rach_control;
716 /* optional CBCH conditional CBCH... followed by
717 mandantory SI 4 Reset Octets
718 */
719 uint8_t data[0];
720} __attribute__ ((packed));
721
722/* Section 9.1.37 System information Type 5 */
723struct gsm48_system_information_type_5 {
724 uint8_t rr_protocol_discriminator :4,
725 skip_indicator:4;
726 uint8_t system_information;
727 uint8_t bcch_frequency_list[16];
728} __attribute__ ((packed));
729
Andreas Eversberg014cb872010-07-12 09:11:00 +0200730/* Section 9.1.38 System information Type 5bis */
731struct gsm48_system_information_type_5bis {
732 uint8_t rr_protocol_discriminator :4,
733 skip_indicator:4;
734 uint8_t system_information;
735 uint8_t bcch_frequency_list[16];
736} __attribute__ ((packed));
737
738/* Section 9.1.39 System information Type 5ter */
739struct gsm48_system_information_type_5ter {
740 uint8_t rr_protocol_discriminator :4,
741 skip_indicator:4;
742 uint8_t system_information;
743 uint8_t bcch_frequency_list[16];
744} __attribute__ ((packed));
745
Harald Welteec8b4502010-02-20 20:34:29 +0100746/* Section 9.1.40 System information Type 6 */
747struct gsm48_system_information_type_6 {
748 uint8_t rr_protocol_discriminator :4,
749 skip_indicator:4;
750 uint8_t system_information;
751 uint16_t cell_identity;
752 struct gsm48_loc_area_id lai;
753 struct gsm48_cell_options cell_options;
754 uint8_t ncc_permitted;
755 uint8_t rest_octets[0];
756} __attribute__ ((packed));
757
758/* Section 9.1.43a System Information type 13 */
759struct gsm48_system_information_type_13 {
760 struct gsm48_system_information_type_header header;
761 uint8_t rest_octets[0];
762} __attribute__ ((packed));
763
764/* Section 9.2.12 IMSI Detach Indication */
765struct gsm48_imsi_detach_ind {
766 struct gsm48_classmark1 classmark1;
767 uint8_t mi_len;
768 uint8_t mi[0];
769} __attribute__ ((packed));
770
Andreas Eversberg014cb872010-07-12 09:11:00 +0200771/* Section 9.1.1 */
772struct gsm48_add_ass {
773 /* Semantic is from 10.5.2.5 */
774 struct gsm48_chan_desc chan_desc;
775 uint8_t data[0];
776} __attribute__((packed));
777
778/* Section 9.1.3 */
779struct gsm48_ass_cpl {
780 uint8_t rr_cause;
781} __attribute__((packed));
782
783/* Section 9.1.4 */
784struct gsm48_ass_fail {
785 uint8_t rr_cause;
786} __attribute__((packed));
787
Andreas Eversbergfa832012010-09-01 23:37:07 +0200788/* Section 9.1.3 */
789struct gsm48_ho_cpl {
790 uint8_t rr_cause;
791 uint8_t data[0];
792} __attribute__((packed));
793
794/* Section 9.1.4 */
795struct gsm48_ho_fail {
796 uint8_t rr_cause;
797} __attribute__((packed));
798
Andreas Eversberg014cb872010-07-12 09:11:00 +0200799/* Section 9.1.7 */
800struct gsm48_chan_rel {
801 uint8_t rr_cause;
802 uint8_t data[0];
803} __attribute__((packed));
804
805/* Section 9.1.9 */
806struct gsm48_cip_mode_cmd {
807 uint8_t sc:1,
808 alg_id:3,
Sylvain Munaut77b6f6c2010-09-17 13:55:45 +0200809 cr:1,
810 spare:3;
Andreas Eversberg014cb872010-07-12 09:11:00 +0200811} __attribute__((packed));
812
813/* Section 9.1.11 */
814struct gsm48_cm_change {
815 uint8_t cm2_len;
816 struct gsm48_classmark2 cm2;
817 uint8_t data[0];
818} __attribute__((packed));
819
820/* Section 9.1.19 */
821struct gsm48_imm_ass_ext {
822 uint8_t l2_plen;
823 uint8_t proto_discr;
824 uint8_t msg_type;
825 uint8_t page_mode;
826 struct gsm48_chan_desc chan_desc1;
827 struct gsm48_req_ref req_ref1;
828 uint8_t timing_advance1;
829 struct gsm48_chan_desc chan_desc2;
830 struct gsm48_req_ref req_ref2;
831 uint8_t timing_advance2;
832 uint8_t mob_alloc_len;
833 uint8_t mob_alloc[0];
834} __attribute__ ((packed));
835
836/* Section 9.1.20 */
837struct gsm48_imm_ass_rej {
838 uint8_t l2_plen;
839 uint8_t proto_discr;
840 uint8_t msg_type;
841 uint8_t page_mode;
842 struct gsm48_req_ref req_ref1;
843 uint8_t wait_ind1;
844 struct gsm48_req_ref req_ref2;
845 uint8_t wait_ind2;
846 struct gsm48_req_ref req_ref3;
847 uint8_t wait_ind3;
848 struct gsm48_req_ref req_ref4;
849 uint8_t wait_ind4;
850 uint8_t rest[0];
851} __attribute__ ((packed));
852
853/* Section 9.1.22 */
854struct gsm48_paging1 {
855 uint8_t l2_plen;
856 uint8_t proto_discr;
857 uint8_t msg_type;
858 uint8_t pag_mode:2,
859 spare:2,
860 cneed1:2,
861 cneed2:2;
862 uint8_t data[0];
863} __attribute__((packed));
864
865/* Section 9.1.23 */
866struct gsm48_paging2 {
867 uint8_t l2_plen;
868 uint8_t proto_discr;
869 uint8_t msg_type;
870 uint8_t pag_mode:2,
871 spare:2,
872 cneed1:2,
873 cneed2:2;
874 uint32_t tmsi1;
875 uint32_t tmsi2;
876 uint8_t data[0];
877} __attribute__((packed));
878
879/* Section 9.1.24 */
880struct gsm48_paging3 {
881 uint8_t l2_plen;
882 uint8_t proto_discr;
883 uint8_t msg_type;
884 uint8_t pag_mode:2,
885 spare:2,
886 cneed1:2,
887 cneed2:2;
888 uint32_t tmsi1;
889 uint32_t tmsi2;
890 uint32_t tmsi3;
891 uint32_t tmsi4;
892 uint8_t cneed3:2,
893 cneed4:2,
894 spare2:4;
895 uint8_t rest[0];
896} __attribute__((packed));
897
898/* Section 9.1.25 */
899struct gsm48_pag_rsp {
900 uint8_t key_seq:3,
901 spare:5;
902 uint8_t cm2_len;
903 struct gsm48_classmark2 cm2;
904 uint8_t data[0];
905} __attribute__((packed));
906
907/* Section 9.1.29 */
908struct gsm48_rr_status {
909 uint8_t rr_cause;
910} __attribute__((packed));
911
Harald Welte3f066dd2017-05-29 15:59:03 +0200912/* 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 +0100913#define GSM48_PDISC_GROUP_CC 0x00
914#define GSM48_PDISC_BCAST_CC 0x01
Harald Welte3f066dd2017-05-29 15:59:03 +0200915#define GSM48_PDISC_PDSS1 0x02 /* 04.07 only */
Harald Welteec8b4502010-02-20 20:34:29 +0100916#define GSM48_PDISC_CC 0x03
Harald Welte3f066dd2017-05-29 15:59:03 +0200917#define GSM48_PDISC_PDSS2 0x04 /* 04.07 only */
918#define GSM48_PDISC_GTTP 0x04 /* 24.007 only */
Harald Welteec8b4502010-02-20 20:34:29 +0100919#define GSM48_PDISC_MM 0x05
920#define GSM48_PDISC_RR 0x06
921#define GSM48_PDISC_MM_GPRS 0x08
922#define GSM48_PDISC_SMS 0x09
923#define GSM48_PDISC_SM_GPRS 0x0a
924#define GSM48_PDISC_NC_SS 0x0b
925#define GSM48_PDISC_LOC 0x0c
Neels Hofmeyr282e9082016-03-14 16:06:46 +0100926#define GSM48_PDISC_EXTEND 0x0e
Harald Welte3f066dd2017-05-29 15:59:03 +0200927#define GSM48_PDISC_TEST 0x0f /* as per 11.10, 04.14 */
Harald Welteec8b4502010-02-20 20:34:29 +0100928#define GSM48_PDISC_MASK 0x0f
929#define GSM48_PDISC_USSD 0x11
930
Neels Hofmeyrdbd994c2017-03-09 23:07:02 +0100931extern const struct value_string gsm48_pdisc_names[];
932static inline const char *gsm48_pdisc_name(uint8_t val)
933{ return get_value_string(gsm48_pdisc_names, val); }
934
Maxfdca25d2016-07-05 16:06:28 +0200935bool gsm48_hdr_gmm_cipherable(const struct gsm48_hdr *hdr);
936
Neels Hofmeyr282e9082016-03-14 16:06:46 +0100937static inline uint8_t gsm48_hdr_pdisc(const struct gsm48_hdr *hdr)
938{
939 /*
940 * 3GPP TS 24.007 version 12.0.0 Release 12,
941 * 11.2.3.1.1 Protocol discriminator
942 */
943 uint8_t pdisc = hdr->proto_discr & GSM48_PDISC_MASK;
944 if (pdisc == GSM48_PDISC_EXTEND)
945 return hdr->proto_discr;
946 return pdisc;
947}
948
Neels Hofmeyrda7bf4d2016-03-14 16:06:48 +0100949static inline uint8_t gsm48_hdr_trans_id(const struct gsm48_hdr *hdr)
950{
951 /*
952 * 3GPP TS 24.007 version 12.0.0 Release 12,
953 * 11.2.3.1.3 Transaction identifier
954 */
955 return (hdr->proto_discr & 0xf0) >> 4;
956}
957
Maxda34bf02016-07-17 16:37:56 +0200958#define GSM48_TA_INVALID 220
959
Maxedb57e72016-07-14 11:35:17 +0200960/*! \brief Check if TA is valid according to 3GPP TS 44.018 § 10.5.2.40
961 * \param[in] ta Timing Advance value
962 * \returns true if ta is valid, false otherwise
963 * Note: Rules for GSM400 band are ignored as it's not implemented in practice.
964 */
965static inline bool gsm48_ta_is_valid(uint8_t ta)
966{
967 return (ta < 64);
968}
969
Neels Hofmeyrda7bf4d2016-03-14 16:06:48 +0100970static inline uint8_t gsm48_hdr_trans_id_flip_ti(const struct gsm48_hdr *hdr)
971{
972 return gsm48_hdr_trans_id(hdr) ^ 0x08;
973}
974
975static inline uint8_t gsm48_hdr_trans_id_no_ti(const struct gsm48_hdr *hdr)
976{
977 return gsm48_hdr_trans_id(hdr) & 0x07;
978}
979
Neels Hofmeyr282e9082016-03-14 16:06:46 +0100980static inline uint8_t gsm48_hdr_msg_type_r98(const struct gsm48_hdr *hdr)
981{
982 /*
983 * 3GPP TS 24.007 version 12.0.0 Release 12,
984 * 11.2.3.2.1 Message type octet (when accessing Release 98 and older
985 * networks only)
986 */
987 switch (gsm48_hdr_pdisc(hdr)) {
988 case GSM48_PDISC_MM:
989 case GSM48_PDISC_CC:
990 case GSM48_PDISC_NC_SS:
991 case GSM48_PDISC_GROUP_CC:
992 case GSM48_PDISC_BCAST_CC:
993 case GSM48_PDISC_LOC:
994 return hdr->msg_type & 0xbf;
995 default:
996 return hdr->msg_type;
997 }
998}
999
1000static inline uint8_t gsm48_hdr_msg_type_r99(const struct gsm48_hdr *hdr)
1001{
1002 /*
1003 * 3GPP TS 24.007 version 12.0.0 Release 12,
1004 * 11.2.3.2.2 Message type octet (when accessing Release 99 and newer
1005 * networks)
1006 */
1007 switch (gsm48_hdr_pdisc(hdr)) {
1008 case GSM48_PDISC_MM:
1009 case GSM48_PDISC_CC:
1010 return hdr->msg_type & 0x3f;
1011 case GSM48_PDISC_NC_SS:
1012 case GSM48_PDISC_GROUP_CC:
1013 case GSM48_PDISC_BCAST_CC:
1014 case GSM48_PDISC_LOC:
1015 return hdr->msg_type & 0xbf;
1016 default:
1017 return hdr->msg_type;
1018 }
1019}
1020
Maxfe65fa72016-05-10 17:17:05 +02001021void gsm48_set_dtx(struct gsm48_cell_options *op, enum gsm48_dtx_mode full,
1022 enum gsm48_dtx_mode half, bool is_bcch);
1023
Neels Hofmeyrc656fae2016-03-14 16:06:47 +01001024#define gsm48_hdr_msg_type gsm48_hdr_msg_type_r99
Neels Hofmeyr282e9082016-03-14 16:06:46 +01001025
Harald Welteec8b4502010-02-20 20:34:29 +01001026/* Section 10.4 */
1027#define GSM48_MT_RR_INIT_REQ 0x3c
1028#define GSM48_MT_RR_ADD_ASS 0x3b
1029#define GSM48_MT_RR_IMM_ASS 0x3f
1030#define GSM48_MT_RR_IMM_ASS_EXT 0x39
1031#define GSM48_MT_RR_IMM_ASS_REJ 0x3a
Philipp72e43f02016-10-27 13:35:20 +02001032#define GSM48_MT_RR_DTM_ASS_FAIL 0x48
1033#define GSM48_MT_RR_DTM_REJECT 0x49
1034#define GSM48_MT_RR_DTM_REQUEST 0x4A
1035#define GSM48_MT_RR_PACKET_ASS 0x4B
Harald Welteec8b4502010-02-20 20:34:29 +01001036
1037#define GSM48_MT_RR_CIPH_M_CMD 0x35
1038#define GSM48_MT_RR_CIPH_M_COMPL 0x32
1039
1040#define GSM48_MT_RR_CFG_CHG_CMD 0x30
1041#define GSM48_MT_RR_CFG_CHG_ACK 0x31
1042#define GSM48_MT_RR_CFG_CHG_REJ 0x33
1043
1044#define GSM48_MT_RR_ASS_CMD 0x2e
1045#define GSM48_MT_RR_ASS_COMPL 0x29
1046#define GSM48_MT_RR_ASS_FAIL 0x2f
1047#define GSM48_MT_RR_HANDO_CMD 0x2b
1048#define GSM48_MT_RR_HANDO_COMPL 0x2c
1049#define GSM48_MT_RR_HANDO_FAIL 0x28
1050#define GSM48_MT_RR_HANDO_INFO 0x2d
Philipp72e43f02016-10-27 13:35:20 +02001051#define GSM48_MT_RR_HANDO_INFO 0x2d
1052#define GSM48_MT_RR_DTM_ASS_CMD 0x4c
Harald Welteec8b4502010-02-20 20:34:29 +01001053
1054#define GSM48_MT_RR_CELL_CHG_ORDER 0x08
1055#define GSM48_MT_RR_PDCH_ASS_CMD 0x23
1056
1057#define GSM48_MT_RR_CHAN_REL 0x0d
1058#define GSM48_MT_RR_PART_REL 0x0a
1059#define GSM48_MT_RR_PART_REL_COMP 0x0f
1060
1061#define GSM48_MT_RR_PAG_REQ_1 0x21
1062#define GSM48_MT_RR_PAG_REQ_2 0x22
1063#define GSM48_MT_RR_PAG_REQ_3 0x24
1064#define GSM48_MT_RR_PAG_RESP 0x27
1065#define GSM48_MT_RR_NOTIF_NCH 0x20
Philipp72e43f02016-10-27 13:35:20 +02001066#define GSM48_MT_RR_NOTIF_FACCH 0x25 /* (Reserved) */
Harald Welteec8b4502010-02-20 20:34:29 +01001067#define GSM48_MT_RR_NOTIF_RESP 0x26
Philipp72e43f02016-10-27 13:35:20 +02001068#define GSM48_MT_RR_PACKET_NOTIF 0x4e
Philipp349784c2016-10-10 15:03:23 +02001069#define GSM48_MT_RR_UTRAN_CLSM_CHG 0x60
1070#define GSM48_MT_RR_CDMA2K_CLSM_CHG 0x62
1071#define GSM48_MT_RR_IS_TO_UTRAN_HANDO 0x63
1072#define GSM48_MT_RR_IS_TO_CDMA2K_HANDO 0x64
1073
Harald Welteec8b4502010-02-20 20:34:29 +01001074#define GSM48_MT_RR_SYSINFO_8 0x18
1075#define GSM48_MT_RR_SYSINFO_1 0x19
1076#define GSM48_MT_RR_SYSINFO_2 0x1a
1077#define GSM48_MT_RR_SYSINFO_3 0x1b
1078#define GSM48_MT_RR_SYSINFO_4 0x1c
1079#define GSM48_MT_RR_SYSINFO_5 0x1d
1080#define GSM48_MT_RR_SYSINFO_6 0x1e
1081#define GSM48_MT_RR_SYSINFO_7 0x1f
1082
1083#define GSM48_MT_RR_SYSINFO_2bis 0x02
1084#define GSM48_MT_RR_SYSINFO_2ter 0x03
Maxe859aec2016-03-11 12:24:04 +01001085#define GSM48_MT_RR_SYSINFO_2quater 0x07
Harald Welteec8b4502010-02-20 20:34:29 +01001086#define GSM48_MT_RR_SYSINFO_5bis 0x05
1087#define GSM48_MT_RR_SYSINFO_5ter 0x06
1088#define GSM48_MT_RR_SYSINFO_9 0x04
1089#define GSM48_MT_RR_SYSINFO_13 0x00
1090
1091#define GSM48_MT_RR_SYSINFO_16 0x3d
1092#define GSM48_MT_RR_SYSINFO_17 0x3e
1093
Philipp72e43f02016-10-27 13:35:20 +02001094#define GSM48_MT_RR_SYSINFO_18 0x40
1095#define GSM48_MT_RR_SYSINFO_19 0x41
1096#define GSM48_MT_RR_SYSINFO_20 0x42
1097
Harald Welteec8b4502010-02-20 20:34:29 +01001098#define GSM48_MT_RR_CHAN_MODE_MODIF 0x10
1099#define GSM48_MT_RR_STATUS 0x12
1100#define GSM48_MT_RR_CHAN_MODE_MODIF_ACK 0x17
1101#define GSM48_MT_RR_FREQ_REDEF 0x14
1102#define GSM48_MT_RR_MEAS_REP 0x15
1103#define GSM48_MT_RR_CLSM_CHG 0x16
1104#define GSM48_MT_RR_CLSM_ENQ 0x13
1105#define GSM48_MT_RR_EXT_MEAS_REP 0x36
1106#define GSM48_MT_RR_EXT_MEAS_REP_ORD 0x37
1107#define GSM48_MT_RR_GPRS_SUSP_REQ 0x34
Philipp72e43f02016-10-27 13:35:20 +02001108#define GSM48_MT_RR_DTM_INFO 0x4d
Harald Welteec8b4502010-02-20 20:34:29 +01001109
Bhaskare6b45d82013-05-16 17:11:51 +05301110#define GSM48_MT_RR_VGCS_UPL_GRANT 0x09
Harald Welteec8b4502010-02-20 20:34:29 +01001111#define GSM48_MT_RR_UPLINK_RELEASE 0x0e
1112#define GSM48_MT_RR_UPLINK_FREE 0x0c
1113#define GSM48_MT_RR_UPLINK_BUSY 0x2a
1114#define GSM48_MT_RR_TALKER_IND 0x11
1115
1116#define GSM48_MT_RR_APP_INFO 0x38
1117
1118/* Table 10.2/3GPP TS 04.08 */
1119#define GSM48_MT_MM_IMSI_DETACH_IND 0x01
1120#define GSM48_MT_MM_LOC_UPD_ACCEPT 0x02
1121#define GSM48_MT_MM_LOC_UPD_REJECT 0x04
1122#define GSM48_MT_MM_LOC_UPD_REQUEST 0x08
1123
1124#define GSM48_MT_MM_AUTH_REJ 0x11
1125#define GSM48_MT_MM_AUTH_REQ 0x12
1126#define GSM48_MT_MM_AUTH_RESP 0x14
Neels Hofmeyr55a43b82017-02-02 20:27:55 +01001127#define GSM48_MT_MM_AUTH_FAIL 0x1c
Harald Welteec8b4502010-02-20 20:34:29 +01001128#define GSM48_MT_MM_ID_REQ 0x18
1129#define GSM48_MT_MM_ID_RESP 0x19
1130#define GSM48_MT_MM_TMSI_REALL_CMD 0x1a
1131#define GSM48_MT_MM_TMSI_REALL_COMPL 0x1b
1132
1133#define GSM48_MT_MM_CM_SERV_ACC 0x21
1134#define GSM48_MT_MM_CM_SERV_REJ 0x22
1135#define GSM48_MT_MM_CM_SERV_ABORT 0x23
1136#define GSM48_MT_MM_CM_SERV_REQ 0x24
1137#define GSM48_MT_MM_CM_SERV_PROMPT 0x25
1138#define GSM48_MT_MM_CM_REEST_REQ 0x28
1139#define GSM48_MT_MM_ABORT 0x29
1140
1141#define GSM48_MT_MM_NULL 0x30
1142#define GSM48_MT_MM_STATUS 0x31
1143#define GSM48_MT_MM_INFO 0x32
1144
1145/* Table 10.3/3GPP TS 04.08 */
1146#define GSM48_MT_CC_ALERTING 0x01
1147#define GSM48_MT_CC_CALL_CONF 0x08
1148#define GSM48_MT_CC_CALL_PROC 0x02
1149#define GSM48_MT_CC_CONNECT 0x07
1150#define GSM48_MT_CC_CONNECT_ACK 0x0f
1151#define GSM48_MT_CC_EMERG_SETUP 0x0e
1152#define GSM48_MT_CC_PROGRESS 0x03
1153#define GSM48_MT_CC_ESTAB 0x04
1154#define GSM48_MT_CC_ESTAB_CONF 0x06
1155#define GSM48_MT_CC_RECALL 0x0b
1156#define GSM48_MT_CC_START_CC 0x09
1157#define GSM48_MT_CC_SETUP 0x05
1158
1159#define GSM48_MT_CC_MODIFY 0x17
1160#define GSM48_MT_CC_MODIFY_COMPL 0x1f
1161#define GSM48_MT_CC_MODIFY_REJECT 0x13
1162#define GSM48_MT_CC_USER_INFO 0x10
1163#define GSM48_MT_CC_HOLD 0x18
1164#define GSM48_MT_CC_HOLD_ACK 0x19
1165#define GSM48_MT_CC_HOLD_REJ 0x1a
1166#define GSM48_MT_CC_RETR 0x1c
1167#define GSM48_MT_CC_RETR_ACK 0x1d
1168#define GSM48_MT_CC_RETR_REJ 0x1e
1169
1170#define GSM48_MT_CC_DISCONNECT 0x25
1171#define GSM48_MT_CC_RELEASE 0x2d
1172#define GSM48_MT_CC_RELEASE_COMPL 0x2a
1173
1174#define GSM48_MT_CC_CONG_CTRL 0x39
1175#define GSM48_MT_CC_NOTIFY 0x3e
1176#define GSM48_MT_CC_STATUS 0x3d
1177#define GSM48_MT_CC_STATUS_ENQ 0x34
1178#define GSM48_MT_CC_START_DTMF 0x35
1179#define GSM48_MT_CC_STOP_DTMF 0x31
1180#define GSM48_MT_CC_STOP_DTMF_ACK 0x32
1181#define GSM48_MT_CC_START_DTMF_ACK 0x36
1182#define GSM48_MT_CC_START_DTMF_REJ 0x37
1183#define GSM48_MT_CC_FACILITY 0x3a
1184
Neels Hofmeyr00ab9ed2017-03-09 23:27:56 +01001185extern const struct value_string gsm48_rr_msgtype_names[];
1186extern const struct value_string gsm48_mm_msgtype_names[];
1187extern const struct value_string gsm48_cc_msgtype_names[];
1188const char *gsm48_pdisc_msgtype_name(uint8_t pdisc, uint8_t msg_type);
1189
Harald Welteec8b4502010-02-20 20:34:29 +01001190/* FIXME: Table 10.4 / 10.4a (GPRS) */
1191
Andreas Eversberg014cb872010-07-12 09:11:00 +02001192/* Section 10.5.3.3 CM service type */
1193#define GSM48_CMSERV_MO_CALL_PACKET 1
1194#define GSM48_CMSERV_EMERGENCY 2
1195#define GSM48_CMSERV_SMS 4
1196#define GSM48_CMSERV_SUP_SERV 8
1197#define GSM48_CMSERV_VGCS 9
1198#define GSM48_CMSERV_VBS 10
1199#define GSM48_CMSERV_LOC_SERV 11
1200
Harald Welteec8b4502010-02-20 20:34:29 +01001201/* Section 10.5.2.26, Table 10.5.64 */
1202#define GSM48_PM_MASK 0x03
1203#define GSM48_PM_NORMAL 0x00
1204#define GSM48_PM_EXTENDED 0x01
1205#define GSM48_PM_REORG 0x02
1206#define GSM48_PM_SAME 0x03
1207
1208/* Chapter 10.5.3.5 / Table 10.5.93 */
1209#define GSM48_LUPD_NORMAL 0x0
1210#define GSM48_LUPD_PERIODIC 0x1
1211#define GSM48_LUPD_IMSI_ATT 0x2
1212#define GSM48_LUPD_RESERVED 0x3
1213
1214/* Table 10.5.4 */
1215#define GSM_MI_TYPE_MASK 0x07
1216#define GSM_MI_TYPE_NONE 0x00
1217#define GSM_MI_TYPE_IMSI 0x01
1218#define GSM_MI_TYPE_IMEI 0x02
1219#define GSM_MI_TYPE_IMEISV 0x03
1220#define GSM_MI_TYPE_TMSI 0x04
1221#define GSM_MI_ODD 0x08
1222
Andreas Eversberg014cb872010-07-12 09:11:00 +02001223#define GSM48_IE_MOBILE_ID 0x17 /* 10.5.1.4 */
Harald Welteec8b4502010-02-20 20:34:29 +01001224#define GSM48_IE_NAME_LONG 0x43 /* 10.5.3.5a */
1225#define GSM48_IE_NAME_SHORT 0x45 /* 10.5.3.5a */
1226#define GSM48_IE_UTC 0x46 /* 10.5.3.8 */
1227#define GSM48_IE_NET_TIME_TZ 0x47 /* 10.5.3.9 */
1228#define GSM48_IE_LSA_IDENT 0x48 /* 10.5.3.11 */
Jacob Erlbeck1c3f0882013-09-16 10:29:57 +02001229#define GSM48_IE_NET_DST 0x49 /* 10.5.3.12 [24.008] */
Harald Welteec8b4502010-02-20 20:34:29 +01001230
1231#define GSM48_IE_BEARER_CAP 0x04 /* 10.5.4.5 */
1232#define GSM48_IE_CAUSE 0x08 /* 10.5.4.11 */
1233#define GSM48_IE_CC_CAP 0x15 /* 10.5.4.5a */
1234#define GSM48_IE_ALERT 0x19 /* 10.5.4.26 */
1235#define GSM48_IE_FACILITY 0x1c /* 10.5.4.15 */
1236#define GSM48_IE_PROGR_IND 0x1e /* 10.5.4.21 */
1237#define GSM48_IE_AUX_STATUS 0x24 /* 10.5.4.4 */
1238#define GSM48_IE_NOTIFY 0x27 /* 10.5.4.20 */
1239#define GSM48_IE_KPD_FACILITY 0x2c /* 10.5.4.17 */
1240#define GSM48_IE_SIGNAL 0x34 /* 10.5.4.23 */
1241#define GSM48_IE_CONN_BCD 0x4c /* 10.5.4.13 */
1242#define GSM48_IE_CONN_SUB 0x4d /* 10.5.4.14 */
1243#define GSM48_IE_CALLING_BCD 0x5c /* 10.5.4.9 */
1244#define GSM48_IE_CALLING_SUB 0x5d /* 10.5.4.10 */
1245#define GSM48_IE_CALLED_BCD 0x5e /* 10.5.4.7 */
1246#define GSM48_IE_CALLED_SUB 0x6d /* 10.5.4.8 */
1247#define GSM48_IE_REDIR_BCD 0x74 /* 10.5.4.21a */
1248#define GSM48_IE_REDIR_SUB 0x75 /* 10.5.4.21b */
1249#define GSM48_IE_LOWL_COMPAT 0x7c /* 10.5.4.18 */
1250#define GSM48_IE_HIGHL_COMPAT 0x7d /* 10.5.4.16 */
1251#define GSM48_IE_USER_USER 0x7e /* 10.5.4.25 */
1252#define GSM48_IE_SS_VERS 0x7f /* 10.5.4.24 */
1253#define GSM48_IE_MORE_DATA 0xa0 /* 10.5.4.19 */
1254#define GSM48_IE_CLIR_SUPP 0xa1 /* 10.5.4.11a */
1255#define GSM48_IE_CLIR_INVOC 0xa2 /* 10.5.4.11b */
1256#define GSM48_IE_REV_C_SETUP 0xa3 /* 10.5.4.22a */
1257#define GSM48_IE_REPEAT_CIR 0xd1 /* 10.5.4.22 */
1258#define GSM48_IE_REPEAT_SEQ 0xd3 /* 10.5.4.22 */
1259
1260/* Section 10.5.4.11 / Table 10.5.122 */
1261#define GSM48_CAUSE_CS_GSM 0x60
1262
1263/* Section 9.1.2 / Table 9.3 */
Andreas Eversberg014cb872010-07-12 09:11:00 +02001264/* RR elements */
1265#define GSM48_IE_VGCS_TARGET 0x01
1266//#define GSM48_IE_VGCS_T_MODE_I 0x01
1267#define GSM48_IE_FRQSHORT_AFTER 0x02
1268#define GSM48_IE_MUL_RATE_CFG 0x03 /* 10.5.2.21aa */
1269#define GSM48_IE_FREQ_L_AFTER 0x05
Harald Welteec8b4502010-02-20 20:34:29 +01001270#define GSM48_IE_MSLOT_DESC 0x10
Harald Welteec8b4502010-02-20 20:34:29 +01001271#define GSM48_IE_CHANMODE_2 0x11
Andreas Eversberg014cb872010-07-12 09:11:00 +02001272#define GSM48_IE_FRQSHORT_BEFORE 0x12
1273//#define GSM48_IE_FRQSHORT_BEFOR 0x12
Harald Welteec8b4502010-02-20 20:34:29 +01001274#define GSM48_IE_CHANMODE_3 0x13
1275#define GSM48_IE_CHANMODE_4 0x14
1276#define GSM48_IE_CHANMODE_5 0x15
1277#define GSM48_IE_CHANMODE_6 0x16
1278#define GSM48_IE_CHANMODE_7 0x17
1279#define GSM48_IE_CHANMODE_8 0x18
1280#define GSM48_IE_CHANDESC_2 0x64
Harald Welte639f74b2010-06-15 09:32:14 +02001281#define GSM48_IE_MA_AFTER 0x72
1282#define GSM48_IE_START_TIME 0x7c
1283#define GSM48_IE_FREQ_L_BEFORE 0x19
Andreas Eversberg014cb872010-07-12 09:11:00 +02001284//#define GSM48_IE_FRQLIST_BEFORE 0x19
Harald Welte639f74b2010-06-15 09:32:14 +02001285#define GSM48_IE_CH_DESC_1_BEFORE 0x1c
Andreas Eversberg014cb872010-07-12 09:11:00 +02001286//#define GSM48_IE_CHDES_1_BEFORE 0x1c
Harald Welte639f74b2010-06-15 09:32:14 +02001287#define GSM48_IE_CH_DESC_2_BEFORE 0x1d
Andreas Eversberg014cb872010-07-12 09:11:00 +02001288//#define GSM48_IE_CHDES_2_BEFORE 0x1d
Harald Welte639f74b2010-06-15 09:32:14 +02001289#define GSM48_IE_F_CH_SEQ_BEFORE 0x1e
Andreas Eversberg014cb872010-07-12 09:11:00 +02001290//#define GSM48_IE_FRQSEQ_BEFORE 0x1e
1291#define GSM48_IE_CLASSMARK3 0x20
Harald Welte639f74b2010-06-15 09:32:14 +02001292#define GSM48_IE_MA_BEFORE 0x21
Andreas Eversberg014cb872010-07-12 09:11:00 +02001293#define GSM48_IE_RR_PACKET_UL 0x22
1294#define GSM48_IE_RR_PACKET_DL 0x23
1295#define GSM48_IE_CELL_CH_DESC 0x62
1296#define GSM48_IE_CHANMODE_1 0x63
1297#define GSM48_IE_CHDES_2_AFTER 0x64
1298#define GSM48_IE_MODE_SEC_CH 0x66
1299#define GSM48_IE_F_CH_SEQ_AFTER 0x69
1300#define GSM48_IE_MA_AFTER 0x72
1301#define GSM48_IE_BA_RANGE 0x73
1302#define GSM48_IE_GROUP_CHDES 0x74
1303#define GSM48_IE_BA_LIST_PREF 0x75
1304#define GSM48_IE_MOB_OVSERV_DIF 0x77
1305#define GSM48_IE_REALTIME_DIFF 0x7b
1306#define GSM48_IE_START_TIME 0x7c
1307#define GSM48_IE_TIMING_ADVANCE 0x7d
1308#define GSM48_IE_GROUP_CIP_SEQ 0x80
1309#define GSM48_IE_CIP_MODE_SET 0x90
1310#define GSM48_IE_GPRS_RESUMPT 0xc0
1311#define GSM48_IE_SYNC_IND 0xd0
1312/* System Information 4 (types are equal IEs above) */
1313#define GSM48_IE_CBCH_CHAN_DESC 0x64
1314#define GSM48_IE_CBCH_MOB_AL 0x72
Harald Welte639f74b2010-06-15 09:32:14 +02001315
Andreas Eversberg014cb872010-07-12 09:11:00 +02001316/* Additional MM elements */
1317#define GSM48_IE_LOCATION_AREA 0x13
Harald Welte82f94ef2016-05-05 23:33:27 +02001318#define GSM48_IE_AUTN 0x20
Neels Hofmeyr55a43b82017-02-02 20:27:55 +01001319#define GSM48_IE_AUTH_RES_EXT 0x21
1320#define GSM48_IE_AUTS 0x22
Andreas Eversberg014cb872010-07-12 09:11:00 +02001321#define GSM48_IE_PRIORITY_LEV 0x80
1322#define GSM48_IE_FOLLOW_ON_PROC 0xa1
1323#define GSM48_IE_CTS_PERMISSION 0xa2
Harald Welteec8b4502010-02-20 20:34:29 +01001324
1325/* Section 10.5.4.23 / Table 10.5.130 */
1326enum gsm48_signal_val {
1327 GSM48_SIGNAL_DIALTONE = 0x00,
1328 GSM48_SIGNAL_RINGBACK = 0x01,
1329 GSM48_SIGNAL_INTERCEPT = 0x02,
1330 GSM48_SIGNAL_NET_CONG = 0x03,
1331 GSM48_SIGNAL_BUSY = 0x04,
1332 GSM48_SIGNAL_CONFIRM = 0x05,
1333 GSM48_SIGNAL_ANSWER = 0x06,
1334 GSM48_SIGNAL_CALL_WAIT = 0x07,
1335 GSM48_SIGNAL_OFF_HOOK = 0x08,
1336 GSM48_SIGNAL_OFF = 0x3f,
1337 GSM48_SIGNAL_ALERT_OFF = 0x4f,
1338};
1339
1340enum gsm48_cause_loc {
1341 GSM48_CAUSE_LOC_USER = 0x00,
1342 GSM48_CAUSE_LOC_PRN_S_LU = 0x01,
1343 GSM48_CAUSE_LOC_PUN_S_LU = 0x02,
1344 GSM48_CAUSE_LOC_TRANS_NET = 0x03,
1345 GSM48_CAUSE_LOC_PUN_S_RU = 0x04,
1346 GSM48_CAUSE_LOC_PRN_S_RU = 0x05,
1347 /* not defined */
1348 GSM48_CAUSE_LOC_INN_NET = 0x07,
1349 GSM48_CAUSE_LOC_NET_BEYOND = 0x0a,
1350};
1351
1352/* Section 10.5.2.31 RR Cause / Table 10.5.70 */
1353enum gsm48_rr_cause {
1354 GSM48_RR_CAUSE_NORMAL = 0x00,
1355 GSM48_RR_CAUSE_ABNORMAL_UNSPEC = 0x01,
1356 GSM48_RR_CAUSE_ABNORMAL_UNACCT = 0x02,
1357 GSM48_RR_CAUSE_ABNORMAL_TIMER = 0x03,
1358 GSM48_RR_CAUSE_ABNORMAL_NOACT = 0x04,
1359 GSM48_RR_CAUSE_PREMPTIVE_REL = 0x05,
Andreas Eversbergc8cac642013-06-19 20:58:59 +02001360 GSM48_RR_CAUSE_HNDOVER_IMP = 0x08,
1361 GSM48_RR_CAUSE_CHAN_MODE_UNACCT = 0x09,
1362 GSM48_RR_CAUSE_FREQ_NOT_IMPL = 0x0a,
Harald Welteec8b4502010-02-20 20:34:29 +01001363 GSM48_RR_CAUSE_CALL_CLEARED = 0x41,
1364 GSM48_RR_CAUSE_SEMANT_INCORR = 0x5f,
1365 GSM48_RR_CAUSE_INVALID_MAND_INF = 0x60,
1366 GSM48_RR_CAUSE_MSG_TYPE_N = 0x61,
1367 GSM48_RR_CAUSE_MSG_TYPE_N_COMPAT= 0x62,
1368 GSM48_RR_CAUSE_COND_IE_ERROR = 0x64,
1369 GSM48_RR_CAUSE_NO_CELL_ALLOC_A = 0x65,
1370 GSM48_RR_CAUSE_PROT_ERROR_UNSPC = 0x6f,
1371};
1372
1373/* Section 10.5.4.11 CC Cause / Table 10.5.123 */
1374enum gsm48_cc_cause {
1375 GSM48_CC_CAUSE_UNASSIGNED_NR = 1,
1376 GSM48_CC_CAUSE_NO_ROUTE = 3,
1377 GSM48_CC_CAUSE_CHAN_UNACCEPT = 6,
1378 GSM48_CC_CAUSE_OP_DET_BARRING = 8,
1379 GSM48_CC_CAUSE_NORM_CALL_CLEAR = 16,
1380 GSM48_CC_CAUSE_USER_BUSY = 17,
1381 GSM48_CC_CAUSE_USER_NOTRESPOND = 18,
1382 GSM48_CC_CAUSE_USER_ALERTING_NA = 19,
1383 GSM48_CC_CAUSE_CALL_REJECTED = 21,
1384 GSM48_CC_CAUSE_NUMBER_CHANGED = 22,
1385 GSM48_CC_CAUSE_PRE_EMPTION = 25,
1386 GSM48_CC_CAUSE_NONSE_USER_CLR = 26,
1387 GSM48_CC_CAUSE_DEST_OOO = 27,
1388 GSM48_CC_CAUSE_INV_NR_FORMAT = 28,
1389 GSM48_CC_CAUSE_FACILITY_REJ = 29,
1390 GSM48_CC_CAUSE_RESP_STATUS_INQ = 30,
1391 GSM48_CC_CAUSE_NORMAL_UNSPEC = 31,
1392 GSM48_CC_CAUSE_NO_CIRCUIT_CHAN = 34,
1393 GSM48_CC_CAUSE_NETWORK_OOO = 38,
1394 GSM48_CC_CAUSE_TEMP_FAILURE = 41,
1395 GSM48_CC_CAUSE_SWITCH_CONG = 42,
1396 GSM48_CC_CAUSE_ACC_INF_DISCARD = 43,
1397 GSM48_CC_CAUSE_REQ_CHAN_UNAVAIL = 44,
1398 GSM48_CC_CAUSE_RESOURCE_UNAVAIL = 47,
1399 GSM48_CC_CAUSE_QOS_UNAVAIL = 49,
1400 GSM48_CC_CAUSE_REQ_FAC_NOT_SUBSC= 50,
1401 GSM48_CC_CAUSE_INC_BARRED_CUG = 55,
1402 GSM48_CC_CAUSE_BEARER_CAP_UNAUTH= 57,
1403 GSM48_CC_CAUSE_BEARER_CA_UNAVAIL= 58,
1404 GSM48_CC_CAUSE_SERV_OPT_UNAVAIL = 63,
1405 GSM48_CC_CAUSE_BEARERSERV_UNIMPL= 65,
1406 GSM48_CC_CAUSE_ACM_GE_ACM_MAX = 68,
1407 GSM48_CC_CAUSE_REQ_FAC_NOTIMPL = 69,
1408 GSM48_CC_CAUSE_RESTR_BCAP_AVAIL = 70,
1409 GSM48_CC_CAUSE_SERV_OPT_UNIMPL = 79,
1410 GSM48_CC_CAUSE_INVAL_TRANS_ID = 81,
1411 GSM48_CC_CAUSE_USER_NOT_IN_CUG = 87,
1412 GSM48_CC_CAUSE_INCOMPAT_DEST = 88,
1413 GSM48_CC_CAUSE_INVAL_TRANS_NET = 91,
1414 GSM48_CC_CAUSE_SEMANTIC_INCORR = 95,
1415 GSM48_CC_CAUSE_INVAL_MAND_INF = 96,
1416 GSM48_CC_CAUSE_MSGTYPE_NOTEXIST = 97,
1417 GSM48_CC_CAUSE_MSGTYPE_INCOMPAT = 98,
1418 GSM48_CC_CAUSE_IE_NOTEXIST = 99,
1419 GSM48_CC_CAUSE_COND_IE_ERR = 100,
1420 GSM48_CC_CAUSE_MSG_INCOMP_STATE = 101,
1421 GSM48_CC_CAUSE_RECOVERY_TIMER = 102,
1422 GSM48_CC_CAUSE_PROTO_ERR = 111,
1423 GSM48_CC_CAUSE_INTERWORKING = 127,
1424};
1425
1426/* Annex G, GSM specific cause values for mobility management */
1427enum gsm48_reject_value {
1428 GSM48_REJECT_IMSI_UNKNOWN_IN_HLR = 2,
1429 GSM48_REJECT_ILLEGAL_MS = 3,
1430 GSM48_REJECT_IMSI_UNKNOWN_IN_VLR = 4,
1431 GSM48_REJECT_IMEI_NOT_ACCEPTED = 5,
1432 GSM48_REJECT_ILLEGAL_ME = 6,
1433 GSM48_REJECT_PLMN_NOT_ALLOWED = 11,
1434 GSM48_REJECT_LOC_NOT_ALLOWED = 12,
1435 GSM48_REJECT_ROAMING_NOT_ALLOWED = 13,
1436 GSM48_REJECT_NETWORK_FAILURE = 17,
Neels Hofmeyr55a43b82017-02-02 20:27:55 +01001437 GSM48_REJECT_SYNCH_FAILURE = 21,
Harald Welteec8b4502010-02-20 20:34:29 +01001438 GSM48_REJECT_CONGESTION = 22,
1439 GSM48_REJECT_SRV_OPT_NOT_SUPPORTED = 32,
1440 GSM48_REJECT_RQD_SRV_OPT_NOT_SUPPORTED = 33,
1441 GSM48_REJECT_SRV_OPT_TMP_OUT_OF_ORDER = 34,
1442 GSM48_REJECT_CALL_CAN_NOT_BE_IDENTIFIED = 38,
1443 GSM48_REJECT_INCORRECT_MESSAGE = 95,
1444 GSM48_REJECT_INVALID_MANDANTORY_INF = 96,
1445 GSM48_REJECT_MSG_TYPE_NOT_IMPLEMENTED = 97,
1446 GSM48_REJECT_MSG_TYPE_NOT_COMPATIBLE = 98,
1447 GSM48_REJECT_INF_ELEME_NOT_IMPLEMENTED = 99,
1448 GSM48_REJECT_CONDTIONAL_IE_ERROR = 100,
1449 GSM48_REJECT_MSG_NOT_COMPATIBLE = 101,
1450 GSM48_REJECT_PROTOCOL_ERROR = 111,
1451
1452 /* according to G.6 Additional cause codes for GMM */
1453 GSM48_REJECT_GPRS_NOT_ALLOWED = 7,
1454 GSM48_REJECT_SERVICES_NOT_ALLOWED = 8,
1455 GSM48_REJECT_MS_IDENTITY_NOT_DERVIVABLE = 9,
1456 GSM48_REJECT_IMPLICITLY_DETACHED = 10,
1457 GSM48_REJECT_GPRS_NOT_ALLOWED_IN_PLMN = 14,
1458 GSM48_REJECT_MSC_TMP_NOT_REACHABLE = 16,
1459};
1460
1461enum chreq_type {
1462 CHREQ_T_EMERG_CALL,
1463 CHREQ_T_CALL_REEST_TCH_F,
1464 CHREQ_T_CALL_REEST_TCH_H,
1465 CHREQ_T_CALL_REEST_TCH_H_DBL,
1466 CHREQ_T_SDCCH,
1467 CHREQ_T_TCH_F,
1468 CHREQ_T_VOICE_CALL_TCH_H,
1469 CHREQ_T_DATA_CALL_TCH_H,
1470 CHREQ_T_LOCATION_UPD,
1471 CHREQ_T_PAG_R_ANY_NECI0,
1472 CHREQ_T_PAG_R_ANY_NECI1,
1473 CHREQ_T_PAG_R_TCH_F,
1474 CHREQ_T_PAG_R_TCH_FH,
1475 CHREQ_T_LMU,
1476 CHREQ_T_RESERVED_SDCCH,
1477 CHREQ_T_RESERVED_IGNORE,
Alexander Couzensf48e8a82016-12-05 15:57:42 +01001478 CHREQ_T_PDCH_ONE_PHASE,
1479 CHREQ_T_PDCH_TWO_PHASE,
Alexander Couzens953f9292017-03-14 13:47:29 +01001480 _NUM_CHREQ_T,
Harald Welteec8b4502010-02-20 20:34:29 +01001481};
1482
1483/* Chapter 11.3 */
1484#define GSM48_T301 180, 0
1485#define GSM48_T303 30, 0
1486#define GSM48_T305 30, 0
1487#define GSM48_T306 30, 0
1488#define GSM48_T308 10, 0
1489#define GSM48_T310 180, 0
1490#define GSM48_T313 30, 0
1491#define GSM48_T323 30, 0
1492#define GSM48_T331 30, 0
1493#define GSM48_T333 30, 0
1494#define GSM48_T334 25, 0 /* min 15 */
1495#define GSM48_T338 30, 0
Andreas Eversberg014cb872010-07-12 09:11:00 +02001496#define GSM48_T303_MS 30, 0
1497#define GSM48_T305_MS 30, 0
1498#define GSM48_T308_MS 30, 0
1499#define GSM48_T310_MS 30, 0
1500#define GSM48_T313_MS 30, 0
1501#define GSM48_T323_MS 30, 0
1502#define GSM48_T332_MS 30, 0
1503#define GSM48_T335_MS 30, 0
Harald Welteec8b4502010-02-20 20:34:29 +01001504
1505/* Chapter 5.1.2.2 */
1506#define GSM_CSTATE_NULL 0
1507#define GSM_CSTATE_INITIATED 1
Andreas Eversberg1ef041f2010-04-09 07:52:12 +02001508#define GSM_CSTATE_MM_CONNECTION_PEND 2 /* see 10.5.4.6 */
Harald Welteec8b4502010-02-20 20:34:29 +01001509#define GSM_CSTATE_MO_CALL_PROC 3
1510#define GSM_CSTATE_CALL_DELIVERED 4
1511#define GSM_CSTATE_CALL_PRESENT 6
1512#define GSM_CSTATE_CALL_RECEIVED 7
1513#define GSM_CSTATE_CONNECT_REQUEST 8
1514#define GSM_CSTATE_MO_TERM_CALL_CONF 9
1515#define GSM_CSTATE_ACTIVE 10
1516#define GSM_CSTATE_DISCONNECT_REQ 12
1517#define GSM_CSTATE_DISCONNECT_IND 12
1518#define GSM_CSTATE_RELEASE_REQ 19
1519#define GSM_CSTATE_MO_ORIG_MODIFY 26
1520#define GSM_CSTATE_MO_TERM_MODIFY 27
1521#define GSM_CSTATE_CONNECT_IND 28
1522
1523#define SBIT(a) (1 << a)
1524#define ALL_STATES 0xffffffff
1525
1526/* Table 10.5.3/3GPP TS 04.08: Location Area Identification information element */
1527#define GSM_LAC_RESERVED_DETACHED 0x0
1528#define GSM_LAC_RESERVED_ALL_BTS 0xfffe
1529
1530/* GSM 04.08 Bearer Capability: Information Transfer Capability */
1531enum gsm48_bcap_itcap {
1532 GSM48_BCAP_ITCAP_SPEECH = 0,
1533 GSM48_BCAP_ITCAP_UNR_DIG_INF = 1,
1534 GSM48_BCAP_ITCAP_3k1_AUDIO = 2,
1535 GSM48_BCAP_ITCAP_FAX_G3 = 3,
1536 GSM48_BCAP_ITCAP_OTHER = 5,
1537 GSM48_BCAP_ITCAP_RESERVED = 7,
1538};
1539
1540/* GSM 04.08 Bearer Capability: Transfer Mode */
1541enum gsm48_bcap_tmod {
1542 GSM48_BCAP_TMOD_CIRCUIT = 0,
1543 GSM48_BCAP_TMOD_PACKET = 1,
1544};
1545
1546/* GSM 04.08 Bearer Capability: Coding Standard */
1547enum gsm48_bcap_coding {
1548 GSM48_BCAP_CODING_GSM_STD = 0,
1549};
1550
1551/* GSM 04.08 Bearer Capability: Radio Channel Requirements */
1552enum gsm48_bcap_rrq {
1553 GSM48_BCAP_RRQ_FR_ONLY = 1,
1554 GSM48_BCAP_RRQ_DUAL_HR = 2,
1555 GSM48_BCAP_RRQ_DUAL_FR = 3,
1556};
1557
Harald Weltec8a0b932012-08-24 21:27:26 +02001558/* GSM 04.08 Bearer Capability: Rate Adaption */
1559enum gsm48_bcap_ra {
1560 GSM48_BCAP_RA_NONE = 0,
1561 GSM48_BCAP_RA_V110_X30 = 1,
1562 GSM48_BCAP_RA_X31 = 2,
1563 GSM48_BCAP_RA_OTHER = 3,
1564};
1565
1566/* GSM 04.08 Bearer Capability: Signalling access protocol */
1567enum gsm48_bcap_sig_access {
1568 GSM48_BCAP_SA_I440_I450 = 1,
1569 GSM48_BCAP_SA_X21 = 2,
1570 GSM48_BCAP_SA_X28_DP_IN = 3,
1571 GSM48_BCAP_SA_X28_DP_UN = 4,
1572 GSM48_BCAP_SA_X28_NDP = 5,
1573 GSM48_BCAP_SA_X32 = 6,
1574};
1575
1576/* GSM 04.08 Bearer Capability: User Rate */
1577enum gsm48_bcap_user_rate {
1578 GSM48_BCAP_UR_300 = 1,
1579 GSM48_BCAP_UR_1200 = 2,
1580 GSM48_BCAP_UR_2400 = 3,
1581 GSM48_BCAP_UR_4800 = 4,
1582 GSM48_BCAP_UR_9600 = 5,
1583 GSM48_BCAP_UR_12000 = 6,
1584 GSM48_BCAP_UR_1200_75 = 7,
1585};
1586
1587/* GSM 04.08 Bearer Capability: Parity */
1588enum gsm48_bcap_parity {
1589 GSM48_BCAP_PAR_ODD = 0,
1590 GSM48_BCAP_PAR_EVEN = 2,
1591 GSM48_BCAP_PAR_NONE = 3,
1592 GSM48_BCAP_PAR_ZERO = 4,
1593 GSM48_BCAP_PAR_ONE = 5,
1594};
1595
1596/* GSM 04.08 Bearer Capability: Intermediate Rate */
1597enum gsm48_bcap_interm_rate {
1598 GSM48_BCAP_IR_8k = 2,
1599 GSM48_BCAP_IR_16k = 3,
1600};
1601
1602/* GSM 04.08 Bearer Capability: Transparency */
1603enum gsm48_bcap_transp {
1604 GSM48_BCAP_TR_TRANSP = 0,
1605 GSM48_BCAP_TR_RLP = 1,
1606 GSM48_BCAP_TR_TR_PREF = 2,
1607 GSM48_BCAP_TR_RLP_PREF = 3,
1608};
1609
1610/* GSM 04.08 Bearer Capability: Modem Type */
1611enum gsm48_bcap_modem_type {
1612 GSM48_BCAP_MT_NONE = 0,
1613 GSM48_BCAP_MT_V21 = 1,
1614 GSM48_BCAP_MT_V22 = 2,
1615 GSM48_BCAP_MT_V22bis = 3,
1616 GSM48_BCAP_MT_V23 = 4,
1617 GSM48_BCAP_MT_V26ter = 5,
1618 GSM48_BCAP_MT_V32 = 6,
1619 GSM48_BCAP_MT_UNDEF = 7,
1620 GSM48_BCAP_MT_AUTO_1 = 8,
1621};
1622
Philipp Maier3d9191e2017-05-31 17:22:03 +02001623/*! \brief GSM 04.08 Bearer Capability: Speech Version Indication
1624 * (See also 3GPP TS 24.008, Table 10.5.103) */
Harald Welte30a8ec42012-08-24 23:00:05 +02001625enum gsm48_bcap_speech_ver {
Philipp Maiera9e193b2017-06-16 16:47:06 +02001626 GSM48_BCAP_SV_FR = 0, /*!< GSM FR V1 (GSM FR) */
1627 GSM48_BCAP_SV_HR = 1, /*!< GSM HR V1 (GSM HR) */
1628 GSM48_BCAP_SV_EFR = 2, /*!< GSM FR V2 (GSM EFR) */
1629 GSM48_BCAP_SV_AMR_F = 4, /*!< GSM FR V3 (FR AMR) */
1630 GSM48_BCAP_SV_AMR_H = 5, /*!< GSM HR V3 (HR_AMR) */
Philipp Maier3d9191e2017-05-31 17:22:03 +02001631 GSM48_BCAP_SV_AMR_OFW = 6, /*!< GSM FR V4 (OFR AMR-WB) */
1632 GSM48_BCAP_SV_AMR_OHW = 7, /*!< GSM HR V4 (OHR AMR-WB) */
1633 GSM48_BCAP_SV_AMR_FW = 8, /*!< GSM FR V5 (FR AMR-WB) */
1634 GSM48_BCAP_SV_AMR_OH = 11, /*!< GSM HR V6 (OHR AMR) */
Harald Welte30a8ec42012-08-24 23:00:05 +02001635};
1636
Harald Welteec8b4502010-02-20 20:34:29 +01001637#define GSM48_TMSI_LEN 5
1638#define GSM48_MID_TMSI_LEN (GSM48_TMSI_LEN + 2)
1639#define GSM48_MI_SIZE 32
1640
Harald Weltea1c4f762010-05-01 11:59:42 +02001641/* Chapter 10.4.4.15 */
1642struct gsm48_ra_id {
1643 uint8_t digits[3]; /* MCC + MNC BCD digits */
1644 uint16_t lac; /* Location Area Code */
1645 uint8_t rac; /* Routing Area Code */
1646} __attribute__ ((packed));
1647
Harald Welteb5503132011-05-24 15:01:53 +02001648#define GSM48_CELL_CHAN_DESC_SIZE 16
Harald Weltea1c4f762010-05-01 11:59:42 +02001649
Harald Welteb5503132011-05-24 15:01:53 +02001650#define GSM_MACBLOCK_LEN 23
1651#define GSM_MACBLOCK_PADDING 0x2b