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