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