blob: 23d2077cbb94a60e6a4eb7e6c0cf9c9e9d5046d1 [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>
4
5/* GSM TS 04.08 definitions */
6struct gsm_lchan;
7
Andreas Eversberg014cb872010-07-12 09:11:00 +02008/* Chapter 10.5.1.5 */
Harald Welteec8b4502010-02-20 20:34:29 +01009struct gsm48_classmark1 {
Andreas Eversberg014cb872010-07-12 09:11:00 +020010 uint8_t pwr_lev:3,
Harald Welteec8b4502010-02-20 20:34:29 +010011 a5_1:1,
Andreas Eversberg014cb872010-07-12 09:11:00 +020012 es_ind:1,
13 rev_lev:2,
14 spare:1;
15} __attribute__ ((packed));
16
17/* Chapter 10.5.1.6 */
18struct gsm48_classmark2 {
19 uint8_t pwr_lev:3,
20 a5_1:1,
21 es_ind:1,
22 rev_lev:2,
23 spare:1;
24 uint8_t fc:1,
25 vgcs:1,
26 vbs:1,
27 sm_cap:1,
28 ss_scr:2,
29 ps_cap:1,
30 spare2:1;
31 uint8_t a5_2:1,
32 a5_3:1,
33 cmsp:1,
34 solsa:1,
35 spare3:1,
36 lcsva_cap:1,
37 spare4:1,
38 cm3:1;
39} __attribute__ ((packed));
40
41/* Chapter 10.5.2.1b.3 */
42struct gsm48_range_1024 {
43 uint8_t w1_hi:2,
44 f0:1,
45 form_id:5;
46 uint8_t w1_lo;
47 uint8_t w2_hi;
48 uint8_t w3_hi:7,
49 w2_lo:1;
50 uint8_t w4_hi:6,
51 w3_lo:2;
52 uint8_t w5_hi:6,
53 w4_lo:2;
54 uint8_t w6_hi:6,
55 w5_lo:2;
56 uint8_t w7_hi:6,
57 w6_lo:2;
58 uint8_t w8_hi:6,
59 w7_lo:2;
60 uint8_t w9:7,
61 w8_lo:1;
62 uint8_t w11_hi:1,
63 w10:7;
64 uint8_t w12_hi:2,
65 w11_lo:6;
66 uint8_t w13_hi:3,
67 w12_lo:5;
68 uint8_t w14_hi:4,
69 w13_lo:4;
70 uint8_t w15_hi:5,
71 w14_lo:3;
72 uint8_t w16:6,
73 w15_lo:2;
74} __attribute__ ((packed));
75
76/* Chapter 10.5.2.1b.4 */
77struct gsm48_range_512 {
78 uint8_t orig_arfcn_hi:1,
79 form_id:7;
80 uint8_t orig_arfcn_mid;
81 uint8_t w1_hi:7,
82 orig_arfcn_lo:1;
83 uint8_t w2_hi:6,
84 w1_lo:2;
85 uint8_t w3_hi:6,
86 w2_lo:2;
87 uint8_t w4_hi:6,
88 w3_lo:2;
89 uint8_t w5:7,
90 w4_lo:1;
91 uint8_t w7_hi:1,
92 w6:7;
93 uint8_t w8_hi:2,
94 w7_lo:6;
95 uint8_t w9_hi:4,
96 w8_lo:4;
97 uint8_t w10:6,
98 w9_lo:2;
99 uint8_t w12_hi:2,
100 w11:6;
101 uint8_t w13_hi:4,
102 w12_lo:4;
103 uint8_t w14:6,
104 w13_lo:2;
105 uint8_t w16_hi:2,
106 w15:6;
107 uint8_t w17:5,
108 w16_lo:3;
109} __attribute__ ((packed));
110
111/* Chapter 10.5.2.1b.5 */
112struct gsm48_range_256 {
113 uint8_t orig_arfcn_hi:1,
114 form_id:7;
115 uint8_t orig_arfcn_mid;
116 uint8_t w1_hi:7,
117 orig_arfcn_lo:1;
118 uint8_t w2:7,
119 w1_lo:1;
120 uint8_t w4_hi:1,
121 w3:7;
122 uint8_t w5_hi:3,
123 w4_lo:5;
124 uint8_t w6_hi:5,
125 w5_lo:3;
126 uint8_t w8_hi:1,
127 w7:6,
128 w6_lo:1;
129 uint8_t w9_hi:4,
130 w8_lo:4;
131 uint8_t w11_hi:2,
132 w10:5,
133 w9_lo:1;
134 uint8_t w12:5,
135 w11_lo:3;
136 uint8_t w14_hi:3,
137 w13:5;
138 uint8_t w16_hi:1,
139 w15:5,
140 w14_lo:2;
141 uint8_t w18_hi:1,
142 w17:4,
143 w16_lo:3;
144 uint8_t w20_hi:1,
145 w19:4,
146 w18_lo:3;
147 uint8_t spare:1,
148 w21:4,
149 w20_lo:3;
150} __attribute__ ((packed));
151
152/* Chapter 10.5.2.1b.6 */
153struct gsm48_range_128 {
154 uint8_t orig_arfcn_hi:1,
155 form_id:7;
156 uint8_t orig_arfcn_mid;
157 uint8_t w1:7,
158 orig_arfcn_lo:1;
159 uint8_t w3_hi:2,
160 w2:6;
161 uint8_t w4_hi:4,
162 w3_lo:4;
163 uint8_t w6_hi:2,
164 w5:5,
165 w4_lo:1;
166 uint8_t w7:5,
167 w6_lo:3;
168 uint8_t w9:4,
169 w8:4;
170 uint8_t w11:4,
171 w10:4;
172 uint8_t w13:4,
173 w12:4;
174 uint8_t w15:4,
175 w14:4;
176 uint8_t w18_hi:2,
177 w17:3,
178 w16:3;
179 uint8_t w21_hi:1,
180 w20:3,
181 w19:3,
182 w18_lo:1;
183 uint8_t w23:3,
184 w22:3,
185 w21_lo:2;
186 uint8_t w26_hi:2,
187 w25:3,
188 w24:3;
189 uint8_t spare:1,
190 w28:3,
191 w27:3,
192 w26_lo:1;
193} __attribute__ ((packed));
194
195/* Chapter 10.5.2.1b.7 */
196struct gsm48_var_bit {
197 uint8_t orig_arfcn_hi:1,
198 form_id:7;
199 uint8_t orig_arfcn_mid;
200 uint8_t rrfcn1_7:7,
201 orig_arfcn_lo:1;
202 uint8_t rrfcn8_111[13];
Harald Welteec8b4502010-02-20 20:34:29 +0100203} __attribute__ ((packed));
204
205/* Chapter 10.5.2.5 */
206struct gsm48_chan_desc {
207 uint8_t chan_nr;
208 union {
209 struct {
210 uint8_t maio_high:4,
211 h:1,
212 tsc:3;
213 uint8_t hsn:6,
214 maio_low:2;
Andreas Eversberg4b332d72012-02-07 20:02:17 +0100215 } __attribute__ ((packed)) h1;
Harald Welteec8b4502010-02-20 20:34:29 +0100216 struct {
217 uint8_t arfcn_high:2,
218 spare:2,
219 h:1,
220 tsc:3;
221 uint8_t arfcn_low;
Andreas Eversberg4b332d72012-02-07 20:02:17 +0100222 } __attribute__ ((packed)) h0;
223 } __attribute__ ((packed));
Harald Welteec8b4502010-02-20 20:34:29 +0100224} __attribute__ ((packed));
225
Andreas Eversberg014cb872010-07-12 09:11:00 +0200226/* Chapter 10.5.2.20 */
227struct gsm48_meas_res {
228 uint8_t rxlev_full:6,
229 dtx_used:1,
230 ba_used:1;
231 uint8_t rxlev_sub:6,
232 meas_valid:1,
233 spare:1;
234 uint8_t no_nc_n_hi:1,
235 rxqual_sub:3,
236 rxqual_full:3,
237 spare2:1;
238 uint8_t rxlev_nc1:6,
239 no_nc_n_lo:2;
240 uint8_t bsic_nc1_hi:3,
241 bcch_f_nc1:5;
242 uint8_t rxlev_nc2_hi:5,
243 bsic_nc1_lo:3;
244 uint8_t bsic_nc2_hi:2,
245 bcch_f_nc2:5,
246 rxlev_nc2_lo:1;
247 uint8_t rxlev_nc3_hi:4,
248 bsic_nc2_lo:4;
249 uint8_t bsic_nc3_hi:1,
250 bcch_f_nc3:5,
251 rxlev_nc3_lo:2;
252 uint8_t rxlev_nc4_hi:3,
253 bsic_nc3_lo:5;
254 uint8_t bcch_f_nc4:5,
255 rxlev_nc4_lo:3;
256 uint8_t rxlev_nc5_hi:2,
257 bsic_nc4:6;
258 uint8_t bcch_f_nc5_hi:4,
259 rxlev_nc5_lo:4;
260 uint8_t rxlev_nc6_hi:1,
261 bsic_nc5:6,
262 bcch_f_nc5_lo:1;
263 uint8_t bcch_f_nc6_hi:3,
264 rxlev_nc6_lo:5;
265 uint8_t bsic_nc6:6,
266 bcch_f_nc6_lo:2;
267} __attribute__ ((packed));
268
Harald Welteec8b4502010-02-20 20:34:29 +0100269/* Chapter 10.5.2.21aa */
270struct gsm48_multi_rate_conf {
271 uint8_t smod : 2,
272 spare: 1,
273 icmi : 1,
274 nscb : 1,
275 ver : 3;
276 uint8_t m4_75 : 1,
277 m5_15 : 1,
278 m5_90 : 1,
279 m6_70 : 1,
280 m7_40 : 1,
281 m7_95 : 1,
282 m10_2 : 1,
283 m12_2 : 1;
284} __attribute__((packed));
285
Andreas Eversberg014cb872010-07-12 09:11:00 +0200286/* Chapter 10.5.2.28(a) */
287struct gsm48_power_cmd {
288 uint8_t power_level:5,
289 spare:2,
290 atc:1;
291} __attribute__((packed));
292
293/* Chapter 10.5.2.29 */
294struct gsm48_rach_control {
295 uint8_t re :1,
296 cell_bar :1,
297 tx_integer :4,
298 max_trans :2;
299 uint8_t t2;
300 uint8_t t3;
301} __attribute__ ((packed));
302
303
Harald Welteec8b4502010-02-20 20:34:29 +0100304/* Chapter 10.5.2.30 */
305struct gsm48_req_ref {
306 uint8_t ra;
307 uint8_t t3_high:3,
Andreas Eversberg93364fc2010-06-25 02:50:06 +0200308 t1:5;
Harald Welteec8b4502010-02-20 20:34:29 +0100309 uint8_t t2:5,
310 t3_low:3;
311} __attribute__ ((packed));
312
Andreas Eversberg014cb872010-07-12 09:11:00 +0200313/* Chapter 10.5.2.38 */
314struct gsm48_start_time {
315 uint8_t t3_high:3,
316 t1:5;
317 uint8_t t2:5,
318 t3_low:3;
319} __attribute__ ((packed));
320
321/* Chapter 10.5.2.39 */
322struct gsm48_sync_ind {
323 uint8_t si:2,
324 rot:1,
325 nci:1,
326 sync_ie:4;
327} __attribute__((packed));
328
Harald Welteec8b4502010-02-20 20:34:29 +0100329/*
330 * Chapter 9.1.5/9.1.6
331 *
332 * For 9.1.6 the chan_desc has the meaning of 10.5.2.5a
333 */
334struct gsm48_chan_mode_modify {
335 struct gsm48_chan_desc chan_desc;
336 uint8_t mode;
337} __attribute__ ((packed));
338
339enum gsm48_chan_mode {
340 GSM48_CMODE_SIGN = 0x00,
341 GSM48_CMODE_SPEECH_V1 = 0x01,
342 GSM48_CMODE_SPEECH_EFR = 0x21,
343 GSM48_CMODE_SPEECH_AMR = 0x41,
344 GSM48_CMODE_DATA_14k5 = 0x0f,
345 GSM48_CMODE_DATA_12k0 = 0x03,
346 GSM48_CMODE_DATA_6k0 = 0x0b,
Bhaskar31e844b2013-05-16 17:06:35 +0530347 GSM48_CMODE_DATA_3k6 = 0x13,
Harald Welteec8b4502010-02-20 20:34:29 +0100348};
349
350/* Chapter 9.1.2 */
351struct gsm48_ass_cmd {
352 /* Semantic is from 10.5.2.5a */
353 struct gsm48_chan_desc chan_desc;
354 uint8_t power_command;
355 uint8_t data[0];
356} __attribute__((packed));
357
Andreas Eversbergfa832012010-09-01 23:37:07 +0200358/* Chapter 9.1.13 */
359struct gsm48_frq_redef {
360 /* Semantic is from 10.5.2.5a */
361 struct gsm48_chan_desc chan_desc;
362 uint8_t mob_alloc_len;
363 uint8_t mob_alloc[0];
364} __attribute__((packed));
365
Harald Welteec8b4502010-02-20 20:34:29 +0100366/* Chapter 10.5.2.2 */
367struct gsm48_cell_desc {
368 uint8_t bcc:3,
369 ncc:3,
370 arfcn_hi:2;
371 uint8_t arfcn_lo;
372} __attribute__((packed));
373
374/* Chapter 9.1.15 */
375struct gsm48_ho_cmd {
376 struct gsm48_cell_desc cell_desc;
377 struct gsm48_chan_desc chan_desc;
378 uint8_t ho_ref;
379 uint8_t power_command;
380 uint8_t data[0];
381} __attribute__((packed));
382
383/* Chapter 9.1.18 */
384struct gsm48_imm_ass {
385 uint8_t l2_plen;
386 uint8_t proto_discr;
387 uint8_t msg_type;
388 uint8_t page_mode;
389 struct gsm48_chan_desc chan_desc;
390 struct gsm48_req_ref req_ref;
391 uint8_t timing_advance;
392 uint8_t mob_alloc_len;
393 uint8_t mob_alloc[0];
394} __attribute__ ((packed));
395
Holger Hans Peter Freyther5dcef3c2010-05-15 22:35:25 +0800396/* Chapter 9.1.25 */
397struct gsm48_pag_resp {
398 uint8_t spare:4,
399 key_seq:4;
400 uint32_t classmark2;
401 uint8_t mi_len;
402 uint8_t mi[0];
403} __attribute__ ((packed));
404
Harald Welteec8b4502010-02-20 20:34:29 +0100405/* Chapter 10.5.1.3 */
406struct gsm48_loc_area_id {
407 uint8_t digits[3]; /* BCD! */
408 uint16_t lac;
409} __attribute__ ((packed));
410
411/* Section 9.2.2 */
412struct gsm48_auth_req {
413 uint8_t key_seq:4,
414 spare:4;
415 uint8_t rand[16];
416} __attribute__ ((packed));
417
Sylvain Munautd005eab2010-06-10 13:30:50 +0200418/* Section 9.2.3 */
419struct gsm48_auth_resp {
420 uint8_t sres[4];
421} __attribute__ ((packed));
422
Harald Welteec8b4502010-02-20 20:34:29 +0100423/* Section 9.2.15 */
424struct gsm48_loc_upd_req {
425 uint8_t type:4,
426 key_seq:4;
427 struct gsm48_loc_area_id lai;
428 struct gsm48_classmark1 classmark1;
429 uint8_t mi_len;
430 uint8_t mi[0];
431} __attribute__ ((packed));
432
433/* Section 10.1 */
434struct gsm48_hdr {
435 uint8_t proto_discr;
436 uint8_t msg_type;
437 uint8_t data[0];
438} __attribute__ ((packed));
439
440/* Section 9.1.3x System information Type header */
441struct gsm48_system_information_type_header {
442 uint8_t l2_plen;
443 uint8_t rr_protocol_discriminator :4,
444 skip_indicator:4;
445 uint8_t system_information;
446} __attribute__ ((packed));
447
Harald Welteec8b4502010-02-20 20:34:29 +0100448/* Section 10.5.2.4 Cell Selection Parameters */
449struct gsm48_cell_sel_par {
450 uint8_t ms_txpwr_max_ccch:5, /* GSM 05.08 MS-TXPWR-MAX-CCCH */
451 cell_resel_hyst:3; /* GSM 05.08 CELL-RESELECT-HYSTERESIS */
452 uint8_t rxlev_acc_min:6, /* GSM 05.08 RXLEV-ACCESS-MIN */
453 neci:1,
454 acs:1;
455} __attribute__ ((packed));
456
457/* Section 10.5.2.11 Control Channel Description , Figure 10.5.33 */
458struct gsm48_control_channel_descr {
459 uint8_t ccch_conf :3,
460 bs_ag_blks_res :3,
461 att :1,
462 spare1 :1;
463 uint8_t bs_pa_mfrms : 3,
464 spare2 :5;
465 uint8_t t3212;
466} __attribute__ ((packed));
467
468struct gsm48_cell_options {
469 uint8_t radio_link_timeout:4,
470 dtx:2,
471 pwrc:1,
472 spare:1;
473} __attribute__ ((packed));
474
475/* Section 9.2.9 CM service request */
476struct gsm48_service_request {
477 uint8_t cm_service_type : 4,
478 cipher_key_seq : 4;
479 /* length + 3 bytes */
480 uint32_t classmark;
481 uint8_t mi_len;
482 uint8_t mi[0];
483 /* optional priority level */
484} __attribute__ ((packed));
485
486/* Section 9.1.31 System information Type 1 */
487struct gsm48_system_information_type_1 {
488 struct gsm48_system_information_type_header header;
489 uint8_t cell_channel_description[16];
490 struct gsm48_rach_control rach_control;
491 uint8_t rest_octets[0]; /* NCH position on the CCCH */
492} __attribute__ ((packed));
493
494/* Section 9.1.32 System information Type 2 */
495struct gsm48_system_information_type_2 {
496 struct gsm48_system_information_type_header header;
497 uint8_t bcch_frequency_list[16];
498 uint8_t ncc_permitted;
499 struct gsm48_rach_control rach_control;
500} __attribute__ ((packed));
501
Andreas Eversberg014cb872010-07-12 09:11:00 +0200502/* Section 9.1.33 System information Type 2bis */
503struct gsm48_system_information_type_2bis {
504 struct gsm48_system_information_type_header header;
505 uint8_t bcch_frequency_list[16];
506 struct gsm48_rach_control rach_control;
507 uint8_t rest_octets[0];
508} __attribute__ ((packed));
509
510/* Section 9.1.34 System information Type 2ter */
511struct gsm48_system_information_type_2ter {
512 struct gsm48_system_information_type_header header;
513 uint8_t ext_bcch_frequency_list[16];
514 uint8_t rest_octets[0];
515} __attribute__ ((packed));
516
Maxe859aec2016-03-11 12:24:04 +0100517/* Section 9.1.34a System information Type 2quater */
518struct gsm48_system_information_type_2quater {
519 struct gsm48_system_information_type_header header;
520 uint8_t rest_octets[0];
521} __attribute__ ((packed));
522
Harald Welteec8b4502010-02-20 20:34:29 +0100523/* Section 9.1.35 System information Type 3 */
524struct gsm48_system_information_type_3 {
525 struct gsm48_system_information_type_header header;
526 uint16_t cell_identity;
527 struct gsm48_loc_area_id lai;
528 struct gsm48_control_channel_descr control_channel_desc;
529 struct gsm48_cell_options cell_options;
530 struct gsm48_cell_sel_par cell_sel_par;
531 struct gsm48_rach_control rach_control;
532 uint8_t rest_octets[0];
533} __attribute__ ((packed));
534
535/* Section 9.1.36 System information Type 4 */
536struct gsm48_system_information_type_4 {
537 struct gsm48_system_information_type_header header;
538 struct gsm48_loc_area_id lai;
539 struct gsm48_cell_sel_par cell_sel_par;
540 struct gsm48_rach_control rach_control;
541 /* optional CBCH conditional CBCH... followed by
542 mandantory SI 4 Reset Octets
543 */
544 uint8_t data[0];
545} __attribute__ ((packed));
546
547/* Section 9.1.37 System information Type 5 */
548struct gsm48_system_information_type_5 {
549 uint8_t rr_protocol_discriminator :4,
550 skip_indicator:4;
551 uint8_t system_information;
552 uint8_t bcch_frequency_list[16];
553} __attribute__ ((packed));
554
Andreas Eversberg014cb872010-07-12 09:11:00 +0200555/* Section 9.1.38 System information Type 5bis */
556struct gsm48_system_information_type_5bis {
557 uint8_t rr_protocol_discriminator :4,
558 skip_indicator:4;
559 uint8_t system_information;
560 uint8_t bcch_frequency_list[16];
561} __attribute__ ((packed));
562
563/* Section 9.1.39 System information Type 5ter */
564struct gsm48_system_information_type_5ter {
565 uint8_t rr_protocol_discriminator :4,
566 skip_indicator:4;
567 uint8_t system_information;
568 uint8_t bcch_frequency_list[16];
569} __attribute__ ((packed));
570
Harald Welteec8b4502010-02-20 20:34:29 +0100571/* Section 9.1.40 System information Type 6 */
572struct gsm48_system_information_type_6 {
573 uint8_t rr_protocol_discriminator :4,
574 skip_indicator:4;
575 uint8_t system_information;
576 uint16_t cell_identity;
577 struct gsm48_loc_area_id lai;
578 struct gsm48_cell_options cell_options;
579 uint8_t ncc_permitted;
580 uint8_t rest_octets[0];
581} __attribute__ ((packed));
582
583/* Section 9.1.43a System Information type 13 */
584struct gsm48_system_information_type_13 {
585 struct gsm48_system_information_type_header header;
586 uint8_t rest_octets[0];
587} __attribute__ ((packed));
588
589/* Section 9.2.12 IMSI Detach Indication */
590struct gsm48_imsi_detach_ind {
591 struct gsm48_classmark1 classmark1;
592 uint8_t mi_len;
593 uint8_t mi[0];
594} __attribute__ ((packed));
595
Andreas Eversberg014cb872010-07-12 09:11:00 +0200596/* Section 9.1.1 */
597struct gsm48_add_ass {
598 /* Semantic is from 10.5.2.5 */
599 struct gsm48_chan_desc chan_desc;
600 uint8_t data[0];
601} __attribute__((packed));
602
603/* Section 9.1.3 */
604struct gsm48_ass_cpl {
605 uint8_t rr_cause;
606} __attribute__((packed));
607
608/* Section 9.1.4 */
609struct gsm48_ass_fail {
610 uint8_t rr_cause;
611} __attribute__((packed));
612
Andreas Eversbergfa832012010-09-01 23:37:07 +0200613/* Section 9.1.3 */
614struct gsm48_ho_cpl {
615 uint8_t rr_cause;
616 uint8_t data[0];
617} __attribute__((packed));
618
619/* Section 9.1.4 */
620struct gsm48_ho_fail {
621 uint8_t rr_cause;
622} __attribute__((packed));
623
Andreas Eversberg014cb872010-07-12 09:11:00 +0200624/* Section 9.1.7 */
625struct gsm48_chan_rel {
626 uint8_t rr_cause;
627 uint8_t data[0];
628} __attribute__((packed));
629
630/* Section 9.1.9 */
631struct gsm48_cip_mode_cmd {
632 uint8_t sc:1,
633 alg_id:3,
Sylvain Munaut77b6f6c2010-09-17 13:55:45 +0200634 cr:1,
635 spare:3;
Andreas Eversberg014cb872010-07-12 09:11:00 +0200636} __attribute__((packed));
637
638/* Section 9.1.11 */
639struct gsm48_cm_change {
640 uint8_t cm2_len;
641 struct gsm48_classmark2 cm2;
642 uint8_t data[0];
643} __attribute__((packed));
644
645/* Section 9.1.19 */
646struct gsm48_imm_ass_ext {
647 uint8_t l2_plen;
648 uint8_t proto_discr;
649 uint8_t msg_type;
650 uint8_t page_mode;
651 struct gsm48_chan_desc chan_desc1;
652 struct gsm48_req_ref req_ref1;
653 uint8_t timing_advance1;
654 struct gsm48_chan_desc chan_desc2;
655 struct gsm48_req_ref req_ref2;
656 uint8_t timing_advance2;
657 uint8_t mob_alloc_len;
658 uint8_t mob_alloc[0];
659} __attribute__ ((packed));
660
661/* Section 9.1.20 */
662struct gsm48_imm_ass_rej {
663 uint8_t l2_plen;
664 uint8_t proto_discr;
665 uint8_t msg_type;
666 uint8_t page_mode;
667 struct gsm48_req_ref req_ref1;
668 uint8_t wait_ind1;
669 struct gsm48_req_ref req_ref2;
670 uint8_t wait_ind2;
671 struct gsm48_req_ref req_ref3;
672 uint8_t wait_ind3;
673 struct gsm48_req_ref req_ref4;
674 uint8_t wait_ind4;
675 uint8_t rest[0];
676} __attribute__ ((packed));
677
678/* Section 9.1.22 */
679struct gsm48_paging1 {
680 uint8_t l2_plen;
681 uint8_t proto_discr;
682 uint8_t msg_type;
683 uint8_t pag_mode:2,
684 spare:2,
685 cneed1:2,
686 cneed2:2;
687 uint8_t data[0];
688} __attribute__((packed));
689
690/* Section 9.1.23 */
691struct gsm48_paging2 {
692 uint8_t l2_plen;
693 uint8_t proto_discr;
694 uint8_t msg_type;
695 uint8_t pag_mode:2,
696 spare:2,
697 cneed1:2,
698 cneed2:2;
699 uint32_t tmsi1;
700 uint32_t tmsi2;
701 uint8_t data[0];
702} __attribute__((packed));
703
704/* Section 9.1.24 */
705struct gsm48_paging3 {
706 uint8_t l2_plen;
707 uint8_t proto_discr;
708 uint8_t msg_type;
709 uint8_t pag_mode:2,
710 spare:2,
711 cneed1:2,
712 cneed2:2;
713 uint32_t tmsi1;
714 uint32_t tmsi2;
715 uint32_t tmsi3;
716 uint32_t tmsi4;
717 uint8_t cneed3:2,
718 cneed4:2,
719 spare2:4;
720 uint8_t rest[0];
721} __attribute__((packed));
722
723/* Section 9.1.25 */
724struct gsm48_pag_rsp {
725 uint8_t key_seq:3,
726 spare:5;
727 uint8_t cm2_len;
728 struct gsm48_classmark2 cm2;
729 uint8_t data[0];
730} __attribute__((packed));
731
732/* Section 9.1.29 */
733struct gsm48_rr_status {
734 uint8_t rr_cause;
735} __attribute__((packed));
736
Harald Welteec8b4502010-02-20 20:34:29 +0100737/* Section 10.2 + GSM 04.07 12.2.3.1.1 */
738#define GSM48_PDISC_GROUP_CC 0x00
739#define GSM48_PDISC_BCAST_CC 0x01
740#define GSM48_PDISC_PDSS1 0x02
741#define GSM48_PDISC_CC 0x03
742#define GSM48_PDISC_PDSS2 0x04
743#define GSM48_PDISC_MM 0x05
744#define GSM48_PDISC_RR 0x06
745#define GSM48_PDISC_MM_GPRS 0x08
746#define GSM48_PDISC_SMS 0x09
747#define GSM48_PDISC_SM_GPRS 0x0a
748#define GSM48_PDISC_NC_SS 0x0b
749#define GSM48_PDISC_LOC 0x0c
Neels Hofmeyr282e9082016-03-14 16:06:46 +0100750#define GSM48_PDISC_EXTEND 0x0e
Harald Welteec8b4502010-02-20 20:34:29 +0100751#define GSM48_PDISC_MASK 0x0f
752#define GSM48_PDISC_USSD 0x11
753
Neels Hofmeyr282e9082016-03-14 16:06:46 +0100754static inline uint8_t gsm48_hdr_pdisc(const struct gsm48_hdr *hdr)
755{
756 /*
757 * 3GPP TS 24.007 version 12.0.0 Release 12,
758 * 11.2.3.1.1 Protocol discriminator
759 */
760 uint8_t pdisc = hdr->proto_discr & GSM48_PDISC_MASK;
761 if (pdisc == GSM48_PDISC_EXTEND)
762 return hdr->proto_discr;
763 return pdisc;
764}
765
766static inline uint8_t gsm48_hdr_msg_type_r98(const struct gsm48_hdr *hdr)
767{
768 /*
769 * 3GPP TS 24.007 version 12.0.0 Release 12,
770 * 11.2.3.2.1 Message type octet (when accessing Release 98 and older
771 * networks only)
772 */
773 switch (gsm48_hdr_pdisc(hdr)) {
774 case GSM48_PDISC_MM:
775 case GSM48_PDISC_CC:
776 case GSM48_PDISC_NC_SS:
777 case GSM48_PDISC_GROUP_CC:
778 case GSM48_PDISC_BCAST_CC:
779 case GSM48_PDISC_LOC:
780 return hdr->msg_type & 0xbf;
781 default:
782 return hdr->msg_type;
783 }
784}
785
786static inline uint8_t gsm48_hdr_msg_type_r99(const struct gsm48_hdr *hdr)
787{
788 /*
789 * 3GPP TS 24.007 version 12.0.0 Release 12,
790 * 11.2.3.2.2 Message type octet (when accessing Release 99 and newer
791 * networks)
792 */
793 switch (gsm48_hdr_pdisc(hdr)) {
794 case GSM48_PDISC_MM:
795 case GSM48_PDISC_CC:
796 return hdr->msg_type & 0x3f;
797 case GSM48_PDISC_NC_SS:
798 case GSM48_PDISC_GROUP_CC:
799 case GSM48_PDISC_BCAST_CC:
800 case GSM48_PDISC_LOC:
801 return hdr->msg_type & 0xbf;
802 default:
803 return hdr->msg_type;
804 }
805}
806
807#define gsm48_hdr_msg_type gsm48_hdr_msg_type_r98
808
Harald Welteec8b4502010-02-20 20:34:29 +0100809/* Section 10.4 */
810#define GSM48_MT_RR_INIT_REQ 0x3c
811#define GSM48_MT_RR_ADD_ASS 0x3b
812#define GSM48_MT_RR_IMM_ASS 0x3f
813#define GSM48_MT_RR_IMM_ASS_EXT 0x39
814#define GSM48_MT_RR_IMM_ASS_REJ 0x3a
815
816#define GSM48_MT_RR_CIPH_M_CMD 0x35
817#define GSM48_MT_RR_CIPH_M_COMPL 0x32
818
819#define GSM48_MT_RR_CFG_CHG_CMD 0x30
820#define GSM48_MT_RR_CFG_CHG_ACK 0x31
821#define GSM48_MT_RR_CFG_CHG_REJ 0x33
822
823#define GSM48_MT_RR_ASS_CMD 0x2e
824#define GSM48_MT_RR_ASS_COMPL 0x29
825#define GSM48_MT_RR_ASS_FAIL 0x2f
826#define GSM48_MT_RR_HANDO_CMD 0x2b
827#define GSM48_MT_RR_HANDO_COMPL 0x2c
828#define GSM48_MT_RR_HANDO_FAIL 0x28
829#define GSM48_MT_RR_HANDO_INFO 0x2d
830
831#define GSM48_MT_RR_CELL_CHG_ORDER 0x08
832#define GSM48_MT_RR_PDCH_ASS_CMD 0x23
833
834#define GSM48_MT_RR_CHAN_REL 0x0d
835#define GSM48_MT_RR_PART_REL 0x0a
836#define GSM48_MT_RR_PART_REL_COMP 0x0f
837
838#define GSM48_MT_RR_PAG_REQ_1 0x21
839#define GSM48_MT_RR_PAG_REQ_2 0x22
840#define GSM48_MT_RR_PAG_REQ_3 0x24
841#define GSM48_MT_RR_PAG_RESP 0x27
842#define GSM48_MT_RR_NOTIF_NCH 0x20
843#define GSM48_MT_RR_NOTIF_FACCH 0x25
844#define GSM48_MT_RR_NOTIF_RESP 0x26
845
846#define GSM48_MT_RR_SYSINFO_8 0x18
847#define GSM48_MT_RR_SYSINFO_1 0x19
848#define GSM48_MT_RR_SYSINFO_2 0x1a
849#define GSM48_MT_RR_SYSINFO_3 0x1b
850#define GSM48_MT_RR_SYSINFO_4 0x1c
851#define GSM48_MT_RR_SYSINFO_5 0x1d
852#define GSM48_MT_RR_SYSINFO_6 0x1e
853#define GSM48_MT_RR_SYSINFO_7 0x1f
854
855#define GSM48_MT_RR_SYSINFO_2bis 0x02
856#define GSM48_MT_RR_SYSINFO_2ter 0x03
Maxe859aec2016-03-11 12:24:04 +0100857#define GSM48_MT_RR_SYSINFO_2quater 0x07
Harald Welteec8b4502010-02-20 20:34:29 +0100858#define GSM48_MT_RR_SYSINFO_5bis 0x05
859#define GSM48_MT_RR_SYSINFO_5ter 0x06
860#define GSM48_MT_RR_SYSINFO_9 0x04
861#define GSM48_MT_RR_SYSINFO_13 0x00
862
863#define GSM48_MT_RR_SYSINFO_16 0x3d
864#define GSM48_MT_RR_SYSINFO_17 0x3e
865
866#define GSM48_MT_RR_CHAN_MODE_MODIF 0x10
867#define GSM48_MT_RR_STATUS 0x12
868#define GSM48_MT_RR_CHAN_MODE_MODIF_ACK 0x17
869#define GSM48_MT_RR_FREQ_REDEF 0x14
870#define GSM48_MT_RR_MEAS_REP 0x15
871#define GSM48_MT_RR_CLSM_CHG 0x16
872#define GSM48_MT_RR_CLSM_ENQ 0x13
873#define GSM48_MT_RR_EXT_MEAS_REP 0x36
874#define GSM48_MT_RR_EXT_MEAS_REP_ORD 0x37
875#define GSM48_MT_RR_GPRS_SUSP_REQ 0x34
876
Bhaskare6b45d82013-05-16 17:11:51 +0530877#define GSM48_MT_RR_VGCS_UPL_GRANT 0x09
Harald Welteec8b4502010-02-20 20:34:29 +0100878#define GSM48_MT_RR_UPLINK_RELEASE 0x0e
879#define GSM48_MT_RR_UPLINK_FREE 0x0c
880#define GSM48_MT_RR_UPLINK_BUSY 0x2a
881#define GSM48_MT_RR_TALKER_IND 0x11
882
883#define GSM48_MT_RR_APP_INFO 0x38
884
885/* Table 10.2/3GPP TS 04.08 */
886#define GSM48_MT_MM_IMSI_DETACH_IND 0x01
887#define GSM48_MT_MM_LOC_UPD_ACCEPT 0x02
888#define GSM48_MT_MM_LOC_UPD_REJECT 0x04
889#define GSM48_MT_MM_LOC_UPD_REQUEST 0x08
890
891#define GSM48_MT_MM_AUTH_REJ 0x11
892#define GSM48_MT_MM_AUTH_REQ 0x12
893#define GSM48_MT_MM_AUTH_RESP 0x14
894#define GSM48_MT_MM_ID_REQ 0x18
895#define GSM48_MT_MM_ID_RESP 0x19
896#define GSM48_MT_MM_TMSI_REALL_CMD 0x1a
897#define GSM48_MT_MM_TMSI_REALL_COMPL 0x1b
898
899#define GSM48_MT_MM_CM_SERV_ACC 0x21
900#define GSM48_MT_MM_CM_SERV_REJ 0x22
901#define GSM48_MT_MM_CM_SERV_ABORT 0x23
902#define GSM48_MT_MM_CM_SERV_REQ 0x24
903#define GSM48_MT_MM_CM_SERV_PROMPT 0x25
904#define GSM48_MT_MM_CM_REEST_REQ 0x28
905#define GSM48_MT_MM_ABORT 0x29
906
907#define GSM48_MT_MM_NULL 0x30
908#define GSM48_MT_MM_STATUS 0x31
909#define GSM48_MT_MM_INFO 0x32
910
911/* Table 10.3/3GPP TS 04.08 */
912#define GSM48_MT_CC_ALERTING 0x01
913#define GSM48_MT_CC_CALL_CONF 0x08
914#define GSM48_MT_CC_CALL_PROC 0x02
915#define GSM48_MT_CC_CONNECT 0x07
916#define GSM48_MT_CC_CONNECT_ACK 0x0f
917#define GSM48_MT_CC_EMERG_SETUP 0x0e
918#define GSM48_MT_CC_PROGRESS 0x03
919#define GSM48_MT_CC_ESTAB 0x04
920#define GSM48_MT_CC_ESTAB_CONF 0x06
921#define GSM48_MT_CC_RECALL 0x0b
922#define GSM48_MT_CC_START_CC 0x09
923#define GSM48_MT_CC_SETUP 0x05
924
925#define GSM48_MT_CC_MODIFY 0x17
926#define GSM48_MT_CC_MODIFY_COMPL 0x1f
927#define GSM48_MT_CC_MODIFY_REJECT 0x13
928#define GSM48_MT_CC_USER_INFO 0x10
929#define GSM48_MT_CC_HOLD 0x18
930#define GSM48_MT_CC_HOLD_ACK 0x19
931#define GSM48_MT_CC_HOLD_REJ 0x1a
932#define GSM48_MT_CC_RETR 0x1c
933#define GSM48_MT_CC_RETR_ACK 0x1d
934#define GSM48_MT_CC_RETR_REJ 0x1e
935
936#define GSM48_MT_CC_DISCONNECT 0x25
937#define GSM48_MT_CC_RELEASE 0x2d
938#define GSM48_MT_CC_RELEASE_COMPL 0x2a
939
940#define GSM48_MT_CC_CONG_CTRL 0x39
941#define GSM48_MT_CC_NOTIFY 0x3e
942#define GSM48_MT_CC_STATUS 0x3d
943#define GSM48_MT_CC_STATUS_ENQ 0x34
944#define GSM48_MT_CC_START_DTMF 0x35
945#define GSM48_MT_CC_STOP_DTMF 0x31
946#define GSM48_MT_CC_STOP_DTMF_ACK 0x32
947#define GSM48_MT_CC_START_DTMF_ACK 0x36
948#define GSM48_MT_CC_START_DTMF_REJ 0x37
949#define GSM48_MT_CC_FACILITY 0x3a
950
951/* FIXME: Table 10.4 / 10.4a (GPRS) */
952
Andreas Eversberg014cb872010-07-12 09:11:00 +0200953/* Section 10.5.3.3 CM service type */
954#define GSM48_CMSERV_MO_CALL_PACKET 1
955#define GSM48_CMSERV_EMERGENCY 2
956#define GSM48_CMSERV_SMS 4
957#define GSM48_CMSERV_SUP_SERV 8
958#define GSM48_CMSERV_VGCS 9
959#define GSM48_CMSERV_VBS 10
960#define GSM48_CMSERV_LOC_SERV 11
961
Harald Welteec8b4502010-02-20 20:34:29 +0100962/* Section 10.5.2.26, Table 10.5.64 */
963#define GSM48_PM_MASK 0x03
964#define GSM48_PM_NORMAL 0x00
965#define GSM48_PM_EXTENDED 0x01
966#define GSM48_PM_REORG 0x02
967#define GSM48_PM_SAME 0x03
968
969/* Chapter 10.5.3.5 / Table 10.5.93 */
970#define GSM48_LUPD_NORMAL 0x0
971#define GSM48_LUPD_PERIODIC 0x1
972#define GSM48_LUPD_IMSI_ATT 0x2
973#define GSM48_LUPD_RESERVED 0x3
974
975/* Table 10.5.4 */
976#define GSM_MI_TYPE_MASK 0x07
977#define GSM_MI_TYPE_NONE 0x00
978#define GSM_MI_TYPE_IMSI 0x01
979#define GSM_MI_TYPE_IMEI 0x02
980#define GSM_MI_TYPE_IMEISV 0x03
981#define GSM_MI_TYPE_TMSI 0x04
982#define GSM_MI_ODD 0x08
983
Andreas Eversberg014cb872010-07-12 09:11:00 +0200984#define GSM48_IE_MOBILE_ID 0x17 /* 10.5.1.4 */
Harald Welteec8b4502010-02-20 20:34:29 +0100985#define GSM48_IE_NAME_LONG 0x43 /* 10.5.3.5a */
986#define GSM48_IE_NAME_SHORT 0x45 /* 10.5.3.5a */
987#define GSM48_IE_UTC 0x46 /* 10.5.3.8 */
988#define GSM48_IE_NET_TIME_TZ 0x47 /* 10.5.3.9 */
989#define GSM48_IE_LSA_IDENT 0x48 /* 10.5.3.11 */
Jacob Erlbeck1c3f0882013-09-16 10:29:57 +0200990#define GSM48_IE_NET_DST 0x49 /* 10.5.3.12 [24.008] */
Harald Welteec8b4502010-02-20 20:34:29 +0100991
992#define GSM48_IE_BEARER_CAP 0x04 /* 10.5.4.5 */
993#define GSM48_IE_CAUSE 0x08 /* 10.5.4.11 */
994#define GSM48_IE_CC_CAP 0x15 /* 10.5.4.5a */
995#define GSM48_IE_ALERT 0x19 /* 10.5.4.26 */
996#define GSM48_IE_FACILITY 0x1c /* 10.5.4.15 */
997#define GSM48_IE_PROGR_IND 0x1e /* 10.5.4.21 */
998#define GSM48_IE_AUX_STATUS 0x24 /* 10.5.4.4 */
999#define GSM48_IE_NOTIFY 0x27 /* 10.5.4.20 */
1000#define GSM48_IE_KPD_FACILITY 0x2c /* 10.5.4.17 */
1001#define GSM48_IE_SIGNAL 0x34 /* 10.5.4.23 */
1002#define GSM48_IE_CONN_BCD 0x4c /* 10.5.4.13 */
1003#define GSM48_IE_CONN_SUB 0x4d /* 10.5.4.14 */
1004#define GSM48_IE_CALLING_BCD 0x5c /* 10.5.4.9 */
1005#define GSM48_IE_CALLING_SUB 0x5d /* 10.5.4.10 */
1006#define GSM48_IE_CALLED_BCD 0x5e /* 10.5.4.7 */
1007#define GSM48_IE_CALLED_SUB 0x6d /* 10.5.4.8 */
1008#define GSM48_IE_REDIR_BCD 0x74 /* 10.5.4.21a */
1009#define GSM48_IE_REDIR_SUB 0x75 /* 10.5.4.21b */
1010#define GSM48_IE_LOWL_COMPAT 0x7c /* 10.5.4.18 */
1011#define GSM48_IE_HIGHL_COMPAT 0x7d /* 10.5.4.16 */
1012#define GSM48_IE_USER_USER 0x7e /* 10.5.4.25 */
1013#define GSM48_IE_SS_VERS 0x7f /* 10.5.4.24 */
1014#define GSM48_IE_MORE_DATA 0xa0 /* 10.5.4.19 */
1015#define GSM48_IE_CLIR_SUPP 0xa1 /* 10.5.4.11a */
1016#define GSM48_IE_CLIR_INVOC 0xa2 /* 10.5.4.11b */
1017#define GSM48_IE_REV_C_SETUP 0xa3 /* 10.5.4.22a */
1018#define GSM48_IE_REPEAT_CIR 0xd1 /* 10.5.4.22 */
1019#define GSM48_IE_REPEAT_SEQ 0xd3 /* 10.5.4.22 */
1020
1021/* Section 10.5.4.11 / Table 10.5.122 */
1022#define GSM48_CAUSE_CS_GSM 0x60
1023
1024/* Section 9.1.2 / Table 9.3 */
Andreas Eversberg014cb872010-07-12 09:11:00 +02001025/* RR elements */
1026#define GSM48_IE_VGCS_TARGET 0x01
1027//#define GSM48_IE_VGCS_T_MODE_I 0x01
1028#define GSM48_IE_FRQSHORT_AFTER 0x02
1029#define GSM48_IE_MUL_RATE_CFG 0x03 /* 10.5.2.21aa */
1030#define GSM48_IE_FREQ_L_AFTER 0x05
Harald Welteec8b4502010-02-20 20:34:29 +01001031#define GSM48_IE_MSLOT_DESC 0x10
Harald Welteec8b4502010-02-20 20:34:29 +01001032#define GSM48_IE_CHANMODE_2 0x11
Andreas Eversberg014cb872010-07-12 09:11:00 +02001033#define GSM48_IE_FRQSHORT_BEFORE 0x12
1034//#define GSM48_IE_FRQSHORT_BEFOR 0x12
Harald Welteec8b4502010-02-20 20:34:29 +01001035#define GSM48_IE_CHANMODE_3 0x13
1036#define GSM48_IE_CHANMODE_4 0x14
1037#define GSM48_IE_CHANMODE_5 0x15
1038#define GSM48_IE_CHANMODE_6 0x16
1039#define GSM48_IE_CHANMODE_7 0x17
1040#define GSM48_IE_CHANMODE_8 0x18
1041#define GSM48_IE_CHANDESC_2 0x64
Harald Welte639f74b2010-06-15 09:32:14 +02001042#define GSM48_IE_MA_AFTER 0x72
1043#define GSM48_IE_START_TIME 0x7c
1044#define GSM48_IE_FREQ_L_BEFORE 0x19
Andreas Eversberg014cb872010-07-12 09:11:00 +02001045//#define GSM48_IE_FRQLIST_BEFORE 0x19
Harald Welte639f74b2010-06-15 09:32:14 +02001046#define GSM48_IE_CH_DESC_1_BEFORE 0x1c
Andreas Eversberg014cb872010-07-12 09:11:00 +02001047//#define GSM48_IE_CHDES_1_BEFORE 0x1c
Harald Welte639f74b2010-06-15 09:32:14 +02001048#define GSM48_IE_CH_DESC_2_BEFORE 0x1d
Andreas Eversberg014cb872010-07-12 09:11:00 +02001049//#define GSM48_IE_CHDES_2_BEFORE 0x1d
Harald Welte639f74b2010-06-15 09:32:14 +02001050#define GSM48_IE_F_CH_SEQ_BEFORE 0x1e
Andreas Eversberg014cb872010-07-12 09:11:00 +02001051//#define GSM48_IE_FRQSEQ_BEFORE 0x1e
1052#define GSM48_IE_CLASSMARK3 0x20
Harald Welte639f74b2010-06-15 09:32:14 +02001053#define GSM48_IE_MA_BEFORE 0x21
Andreas Eversberg014cb872010-07-12 09:11:00 +02001054#define GSM48_IE_RR_PACKET_UL 0x22
1055#define GSM48_IE_RR_PACKET_DL 0x23
1056#define GSM48_IE_CELL_CH_DESC 0x62
1057#define GSM48_IE_CHANMODE_1 0x63
1058#define GSM48_IE_CHDES_2_AFTER 0x64
1059#define GSM48_IE_MODE_SEC_CH 0x66
1060#define GSM48_IE_F_CH_SEQ_AFTER 0x69
1061#define GSM48_IE_MA_AFTER 0x72
1062#define GSM48_IE_BA_RANGE 0x73
1063#define GSM48_IE_GROUP_CHDES 0x74
1064#define GSM48_IE_BA_LIST_PREF 0x75
1065#define GSM48_IE_MOB_OVSERV_DIF 0x77
1066#define GSM48_IE_REALTIME_DIFF 0x7b
1067#define GSM48_IE_START_TIME 0x7c
1068#define GSM48_IE_TIMING_ADVANCE 0x7d
1069#define GSM48_IE_GROUP_CIP_SEQ 0x80
1070#define GSM48_IE_CIP_MODE_SET 0x90
1071#define GSM48_IE_GPRS_RESUMPT 0xc0
1072#define GSM48_IE_SYNC_IND 0xd0
1073/* System Information 4 (types are equal IEs above) */
1074#define GSM48_IE_CBCH_CHAN_DESC 0x64
1075#define GSM48_IE_CBCH_MOB_AL 0x72
Harald Welte639f74b2010-06-15 09:32:14 +02001076
Andreas Eversberg014cb872010-07-12 09:11:00 +02001077/* Additional MM elements */
1078#define GSM48_IE_LOCATION_AREA 0x13
1079#define GSM48_IE_PRIORITY_LEV 0x80
1080#define GSM48_IE_FOLLOW_ON_PROC 0xa1
1081#define GSM48_IE_CTS_PERMISSION 0xa2
Harald Welteec8b4502010-02-20 20:34:29 +01001082
1083/* Section 10.5.4.23 / Table 10.5.130 */
1084enum gsm48_signal_val {
1085 GSM48_SIGNAL_DIALTONE = 0x00,
1086 GSM48_SIGNAL_RINGBACK = 0x01,
1087 GSM48_SIGNAL_INTERCEPT = 0x02,
1088 GSM48_SIGNAL_NET_CONG = 0x03,
1089 GSM48_SIGNAL_BUSY = 0x04,
1090 GSM48_SIGNAL_CONFIRM = 0x05,
1091 GSM48_SIGNAL_ANSWER = 0x06,
1092 GSM48_SIGNAL_CALL_WAIT = 0x07,
1093 GSM48_SIGNAL_OFF_HOOK = 0x08,
1094 GSM48_SIGNAL_OFF = 0x3f,
1095 GSM48_SIGNAL_ALERT_OFF = 0x4f,
1096};
1097
1098enum gsm48_cause_loc {
1099 GSM48_CAUSE_LOC_USER = 0x00,
1100 GSM48_CAUSE_LOC_PRN_S_LU = 0x01,
1101 GSM48_CAUSE_LOC_PUN_S_LU = 0x02,
1102 GSM48_CAUSE_LOC_TRANS_NET = 0x03,
1103 GSM48_CAUSE_LOC_PUN_S_RU = 0x04,
1104 GSM48_CAUSE_LOC_PRN_S_RU = 0x05,
1105 /* not defined */
1106 GSM48_CAUSE_LOC_INN_NET = 0x07,
1107 GSM48_CAUSE_LOC_NET_BEYOND = 0x0a,
1108};
1109
1110/* Section 10.5.2.31 RR Cause / Table 10.5.70 */
1111enum gsm48_rr_cause {
1112 GSM48_RR_CAUSE_NORMAL = 0x00,
1113 GSM48_RR_CAUSE_ABNORMAL_UNSPEC = 0x01,
1114 GSM48_RR_CAUSE_ABNORMAL_UNACCT = 0x02,
1115 GSM48_RR_CAUSE_ABNORMAL_TIMER = 0x03,
1116 GSM48_RR_CAUSE_ABNORMAL_NOACT = 0x04,
1117 GSM48_RR_CAUSE_PREMPTIVE_REL = 0x05,
Andreas Eversbergc8cac642013-06-19 20:58:59 +02001118 GSM48_RR_CAUSE_HNDOVER_IMP = 0x08,
1119 GSM48_RR_CAUSE_CHAN_MODE_UNACCT = 0x09,
1120 GSM48_RR_CAUSE_FREQ_NOT_IMPL = 0x0a,
Harald Welteec8b4502010-02-20 20:34:29 +01001121 GSM48_RR_CAUSE_CALL_CLEARED = 0x41,
1122 GSM48_RR_CAUSE_SEMANT_INCORR = 0x5f,
1123 GSM48_RR_CAUSE_INVALID_MAND_INF = 0x60,
1124 GSM48_RR_CAUSE_MSG_TYPE_N = 0x61,
1125 GSM48_RR_CAUSE_MSG_TYPE_N_COMPAT= 0x62,
1126 GSM48_RR_CAUSE_COND_IE_ERROR = 0x64,
1127 GSM48_RR_CAUSE_NO_CELL_ALLOC_A = 0x65,
1128 GSM48_RR_CAUSE_PROT_ERROR_UNSPC = 0x6f,
1129};
1130
1131/* Section 10.5.4.11 CC Cause / Table 10.5.123 */
1132enum gsm48_cc_cause {
1133 GSM48_CC_CAUSE_UNASSIGNED_NR = 1,
1134 GSM48_CC_CAUSE_NO_ROUTE = 3,
1135 GSM48_CC_CAUSE_CHAN_UNACCEPT = 6,
1136 GSM48_CC_CAUSE_OP_DET_BARRING = 8,
1137 GSM48_CC_CAUSE_NORM_CALL_CLEAR = 16,
1138 GSM48_CC_CAUSE_USER_BUSY = 17,
1139 GSM48_CC_CAUSE_USER_NOTRESPOND = 18,
1140 GSM48_CC_CAUSE_USER_ALERTING_NA = 19,
1141 GSM48_CC_CAUSE_CALL_REJECTED = 21,
1142 GSM48_CC_CAUSE_NUMBER_CHANGED = 22,
1143 GSM48_CC_CAUSE_PRE_EMPTION = 25,
1144 GSM48_CC_CAUSE_NONSE_USER_CLR = 26,
1145 GSM48_CC_CAUSE_DEST_OOO = 27,
1146 GSM48_CC_CAUSE_INV_NR_FORMAT = 28,
1147 GSM48_CC_CAUSE_FACILITY_REJ = 29,
1148 GSM48_CC_CAUSE_RESP_STATUS_INQ = 30,
1149 GSM48_CC_CAUSE_NORMAL_UNSPEC = 31,
1150 GSM48_CC_CAUSE_NO_CIRCUIT_CHAN = 34,
1151 GSM48_CC_CAUSE_NETWORK_OOO = 38,
1152 GSM48_CC_CAUSE_TEMP_FAILURE = 41,
1153 GSM48_CC_CAUSE_SWITCH_CONG = 42,
1154 GSM48_CC_CAUSE_ACC_INF_DISCARD = 43,
1155 GSM48_CC_CAUSE_REQ_CHAN_UNAVAIL = 44,
1156 GSM48_CC_CAUSE_RESOURCE_UNAVAIL = 47,
1157 GSM48_CC_CAUSE_QOS_UNAVAIL = 49,
1158 GSM48_CC_CAUSE_REQ_FAC_NOT_SUBSC= 50,
1159 GSM48_CC_CAUSE_INC_BARRED_CUG = 55,
1160 GSM48_CC_CAUSE_BEARER_CAP_UNAUTH= 57,
1161 GSM48_CC_CAUSE_BEARER_CA_UNAVAIL= 58,
1162 GSM48_CC_CAUSE_SERV_OPT_UNAVAIL = 63,
1163 GSM48_CC_CAUSE_BEARERSERV_UNIMPL= 65,
1164 GSM48_CC_CAUSE_ACM_GE_ACM_MAX = 68,
1165 GSM48_CC_CAUSE_REQ_FAC_NOTIMPL = 69,
1166 GSM48_CC_CAUSE_RESTR_BCAP_AVAIL = 70,
1167 GSM48_CC_CAUSE_SERV_OPT_UNIMPL = 79,
1168 GSM48_CC_CAUSE_INVAL_TRANS_ID = 81,
1169 GSM48_CC_CAUSE_USER_NOT_IN_CUG = 87,
1170 GSM48_CC_CAUSE_INCOMPAT_DEST = 88,
1171 GSM48_CC_CAUSE_INVAL_TRANS_NET = 91,
1172 GSM48_CC_CAUSE_SEMANTIC_INCORR = 95,
1173 GSM48_CC_CAUSE_INVAL_MAND_INF = 96,
1174 GSM48_CC_CAUSE_MSGTYPE_NOTEXIST = 97,
1175 GSM48_CC_CAUSE_MSGTYPE_INCOMPAT = 98,
1176 GSM48_CC_CAUSE_IE_NOTEXIST = 99,
1177 GSM48_CC_CAUSE_COND_IE_ERR = 100,
1178 GSM48_CC_CAUSE_MSG_INCOMP_STATE = 101,
1179 GSM48_CC_CAUSE_RECOVERY_TIMER = 102,
1180 GSM48_CC_CAUSE_PROTO_ERR = 111,
1181 GSM48_CC_CAUSE_INTERWORKING = 127,
1182};
1183
1184/* Annex G, GSM specific cause values for mobility management */
1185enum gsm48_reject_value {
1186 GSM48_REJECT_IMSI_UNKNOWN_IN_HLR = 2,
1187 GSM48_REJECT_ILLEGAL_MS = 3,
1188 GSM48_REJECT_IMSI_UNKNOWN_IN_VLR = 4,
1189 GSM48_REJECT_IMEI_NOT_ACCEPTED = 5,
1190 GSM48_REJECT_ILLEGAL_ME = 6,
1191 GSM48_REJECT_PLMN_NOT_ALLOWED = 11,
1192 GSM48_REJECT_LOC_NOT_ALLOWED = 12,
1193 GSM48_REJECT_ROAMING_NOT_ALLOWED = 13,
1194 GSM48_REJECT_NETWORK_FAILURE = 17,
1195 GSM48_REJECT_CONGESTION = 22,
1196 GSM48_REJECT_SRV_OPT_NOT_SUPPORTED = 32,
1197 GSM48_REJECT_RQD_SRV_OPT_NOT_SUPPORTED = 33,
1198 GSM48_REJECT_SRV_OPT_TMP_OUT_OF_ORDER = 34,
1199 GSM48_REJECT_CALL_CAN_NOT_BE_IDENTIFIED = 38,
1200 GSM48_REJECT_INCORRECT_MESSAGE = 95,
1201 GSM48_REJECT_INVALID_MANDANTORY_INF = 96,
1202 GSM48_REJECT_MSG_TYPE_NOT_IMPLEMENTED = 97,
1203 GSM48_REJECT_MSG_TYPE_NOT_COMPATIBLE = 98,
1204 GSM48_REJECT_INF_ELEME_NOT_IMPLEMENTED = 99,
1205 GSM48_REJECT_CONDTIONAL_IE_ERROR = 100,
1206 GSM48_REJECT_MSG_NOT_COMPATIBLE = 101,
1207 GSM48_REJECT_PROTOCOL_ERROR = 111,
1208
1209 /* according to G.6 Additional cause codes for GMM */
1210 GSM48_REJECT_GPRS_NOT_ALLOWED = 7,
1211 GSM48_REJECT_SERVICES_NOT_ALLOWED = 8,
1212 GSM48_REJECT_MS_IDENTITY_NOT_DERVIVABLE = 9,
1213 GSM48_REJECT_IMPLICITLY_DETACHED = 10,
1214 GSM48_REJECT_GPRS_NOT_ALLOWED_IN_PLMN = 14,
1215 GSM48_REJECT_MSC_TMP_NOT_REACHABLE = 16,
1216};
1217
1218enum chreq_type {
1219 CHREQ_T_EMERG_CALL,
1220 CHREQ_T_CALL_REEST_TCH_F,
1221 CHREQ_T_CALL_REEST_TCH_H,
1222 CHREQ_T_CALL_REEST_TCH_H_DBL,
1223 CHREQ_T_SDCCH,
1224 CHREQ_T_TCH_F,
1225 CHREQ_T_VOICE_CALL_TCH_H,
1226 CHREQ_T_DATA_CALL_TCH_H,
1227 CHREQ_T_LOCATION_UPD,
1228 CHREQ_T_PAG_R_ANY_NECI0,
1229 CHREQ_T_PAG_R_ANY_NECI1,
1230 CHREQ_T_PAG_R_TCH_F,
1231 CHREQ_T_PAG_R_TCH_FH,
1232 CHREQ_T_LMU,
1233 CHREQ_T_RESERVED_SDCCH,
1234 CHREQ_T_RESERVED_IGNORE,
1235};
1236
1237/* Chapter 11.3 */
1238#define GSM48_T301 180, 0
1239#define GSM48_T303 30, 0
1240#define GSM48_T305 30, 0
1241#define GSM48_T306 30, 0
1242#define GSM48_T308 10, 0
1243#define GSM48_T310 180, 0
1244#define GSM48_T313 30, 0
1245#define GSM48_T323 30, 0
1246#define GSM48_T331 30, 0
1247#define GSM48_T333 30, 0
1248#define GSM48_T334 25, 0 /* min 15 */
1249#define GSM48_T338 30, 0
Andreas Eversberg014cb872010-07-12 09:11:00 +02001250#define GSM48_T303_MS 30, 0
1251#define GSM48_T305_MS 30, 0
1252#define GSM48_T308_MS 30, 0
1253#define GSM48_T310_MS 30, 0
1254#define GSM48_T313_MS 30, 0
1255#define GSM48_T323_MS 30, 0
1256#define GSM48_T332_MS 30, 0
1257#define GSM48_T335_MS 30, 0
Harald Welteec8b4502010-02-20 20:34:29 +01001258
1259/* Chapter 5.1.2.2 */
1260#define GSM_CSTATE_NULL 0
1261#define GSM_CSTATE_INITIATED 1
Andreas Eversberg1ef041f2010-04-09 07:52:12 +02001262#define GSM_CSTATE_MM_CONNECTION_PEND 2 /* see 10.5.4.6 */
Harald Welteec8b4502010-02-20 20:34:29 +01001263#define GSM_CSTATE_MO_CALL_PROC 3
1264#define GSM_CSTATE_CALL_DELIVERED 4
1265#define GSM_CSTATE_CALL_PRESENT 6
1266#define GSM_CSTATE_CALL_RECEIVED 7
1267#define GSM_CSTATE_CONNECT_REQUEST 8
1268#define GSM_CSTATE_MO_TERM_CALL_CONF 9
1269#define GSM_CSTATE_ACTIVE 10
1270#define GSM_CSTATE_DISCONNECT_REQ 12
1271#define GSM_CSTATE_DISCONNECT_IND 12
1272#define GSM_CSTATE_RELEASE_REQ 19
1273#define GSM_CSTATE_MO_ORIG_MODIFY 26
1274#define GSM_CSTATE_MO_TERM_MODIFY 27
1275#define GSM_CSTATE_CONNECT_IND 28
1276
1277#define SBIT(a) (1 << a)
1278#define ALL_STATES 0xffffffff
1279
1280/* Table 10.5.3/3GPP TS 04.08: Location Area Identification information element */
1281#define GSM_LAC_RESERVED_DETACHED 0x0
1282#define GSM_LAC_RESERVED_ALL_BTS 0xfffe
1283
1284/* GSM 04.08 Bearer Capability: Information Transfer Capability */
1285enum gsm48_bcap_itcap {
1286 GSM48_BCAP_ITCAP_SPEECH = 0,
1287 GSM48_BCAP_ITCAP_UNR_DIG_INF = 1,
1288 GSM48_BCAP_ITCAP_3k1_AUDIO = 2,
1289 GSM48_BCAP_ITCAP_FAX_G3 = 3,
1290 GSM48_BCAP_ITCAP_OTHER = 5,
1291 GSM48_BCAP_ITCAP_RESERVED = 7,
1292};
1293
1294/* GSM 04.08 Bearer Capability: Transfer Mode */
1295enum gsm48_bcap_tmod {
1296 GSM48_BCAP_TMOD_CIRCUIT = 0,
1297 GSM48_BCAP_TMOD_PACKET = 1,
1298};
1299
1300/* GSM 04.08 Bearer Capability: Coding Standard */
1301enum gsm48_bcap_coding {
1302 GSM48_BCAP_CODING_GSM_STD = 0,
1303};
1304
1305/* GSM 04.08 Bearer Capability: Radio Channel Requirements */
1306enum gsm48_bcap_rrq {
1307 GSM48_BCAP_RRQ_FR_ONLY = 1,
1308 GSM48_BCAP_RRQ_DUAL_HR = 2,
1309 GSM48_BCAP_RRQ_DUAL_FR = 3,
1310};
1311
Harald Weltec8a0b932012-08-24 21:27:26 +02001312/* GSM 04.08 Bearer Capability: Rate Adaption */
1313enum gsm48_bcap_ra {
1314 GSM48_BCAP_RA_NONE = 0,
1315 GSM48_BCAP_RA_V110_X30 = 1,
1316 GSM48_BCAP_RA_X31 = 2,
1317 GSM48_BCAP_RA_OTHER = 3,
1318};
1319
1320/* GSM 04.08 Bearer Capability: Signalling access protocol */
1321enum gsm48_bcap_sig_access {
1322 GSM48_BCAP_SA_I440_I450 = 1,
1323 GSM48_BCAP_SA_X21 = 2,
1324 GSM48_BCAP_SA_X28_DP_IN = 3,
1325 GSM48_BCAP_SA_X28_DP_UN = 4,
1326 GSM48_BCAP_SA_X28_NDP = 5,
1327 GSM48_BCAP_SA_X32 = 6,
1328};
1329
1330/* GSM 04.08 Bearer Capability: User Rate */
1331enum gsm48_bcap_user_rate {
1332 GSM48_BCAP_UR_300 = 1,
1333 GSM48_BCAP_UR_1200 = 2,
1334 GSM48_BCAP_UR_2400 = 3,
1335 GSM48_BCAP_UR_4800 = 4,
1336 GSM48_BCAP_UR_9600 = 5,
1337 GSM48_BCAP_UR_12000 = 6,
1338 GSM48_BCAP_UR_1200_75 = 7,
1339};
1340
1341/* GSM 04.08 Bearer Capability: Parity */
1342enum gsm48_bcap_parity {
1343 GSM48_BCAP_PAR_ODD = 0,
1344 GSM48_BCAP_PAR_EVEN = 2,
1345 GSM48_BCAP_PAR_NONE = 3,
1346 GSM48_BCAP_PAR_ZERO = 4,
1347 GSM48_BCAP_PAR_ONE = 5,
1348};
1349
1350/* GSM 04.08 Bearer Capability: Intermediate Rate */
1351enum gsm48_bcap_interm_rate {
1352 GSM48_BCAP_IR_8k = 2,
1353 GSM48_BCAP_IR_16k = 3,
1354};
1355
1356/* GSM 04.08 Bearer Capability: Transparency */
1357enum gsm48_bcap_transp {
1358 GSM48_BCAP_TR_TRANSP = 0,
1359 GSM48_BCAP_TR_RLP = 1,
1360 GSM48_BCAP_TR_TR_PREF = 2,
1361 GSM48_BCAP_TR_RLP_PREF = 3,
1362};
1363
1364/* GSM 04.08 Bearer Capability: Modem Type */
1365enum gsm48_bcap_modem_type {
1366 GSM48_BCAP_MT_NONE = 0,
1367 GSM48_BCAP_MT_V21 = 1,
1368 GSM48_BCAP_MT_V22 = 2,
1369 GSM48_BCAP_MT_V22bis = 3,
1370 GSM48_BCAP_MT_V23 = 4,
1371 GSM48_BCAP_MT_V26ter = 5,
1372 GSM48_BCAP_MT_V32 = 6,
1373 GSM48_BCAP_MT_UNDEF = 7,
1374 GSM48_BCAP_MT_AUTO_1 = 8,
1375};
1376
Harald Welte30a8ec42012-08-24 23:00:05 +02001377/* GSM 04.08 Bearer Capability: Speech Version Indication */
1378enum gsm48_bcap_speech_ver {
1379 GSM48_BCAP_SV_FR = 0,
1380 GSM48_BCAP_SV_HR = 1,
1381 GSM48_BCAP_SV_EFR = 2,
1382 GSM48_BCAP_SV_AMR_F = 4,
1383 GSM48_BCAP_SV_AMR_H = 5,
1384};
1385
Harald Welteec8b4502010-02-20 20:34:29 +01001386#define GSM48_TMSI_LEN 5
1387#define GSM48_MID_TMSI_LEN (GSM48_TMSI_LEN + 2)
1388#define GSM48_MI_SIZE 32
1389
Harald Weltea1c4f762010-05-01 11:59:42 +02001390/* Chapter 10.4.4.15 */
1391struct gsm48_ra_id {
1392 uint8_t digits[3]; /* MCC + MNC BCD digits */
1393 uint16_t lac; /* Location Area Code */
1394 uint8_t rac; /* Routing Area Code */
1395} __attribute__ ((packed));
1396
Harald Welteb5503132011-05-24 15:01:53 +02001397#define GSM48_CELL_CHAN_DESC_SIZE 16
Harald Weltea1c4f762010-05-01 11:59:42 +02001398
Harald Welteb5503132011-05-24 15:01:53 +02001399#define GSM_MACBLOCK_LEN 23
1400#define GSM_MACBLOCK_PADDING 0x2b