libosmogsm  0.9.3
Osmocom GSM library
include/osmocom/gsm/protocol/gsm_04_08.h
00001 #pragma once
00002 
00003 #include <stdint.h>
00004 
00005 /* GSM TS 04.08  definitions */
00006 struct gsm_lchan;
00007 
00008 /* Chapter 10.5.1.5 */
00009 struct gsm48_classmark1 {
00010         uint8_t pwr_lev:3,
00011                  a5_1:1,
00012                  es_ind:1,
00013                  rev_lev:2,
00014                  spare:1;
00015 } __attribute__ ((packed));
00016 
00017 /* Chapter 10.5.1.6 */
00018 struct gsm48_classmark2 {
00019         uint8_t pwr_lev:3,
00020                  a5_1:1,
00021                  es_ind:1,
00022                  rev_lev:2,
00023                  spare:1;
00024         uint8_t fc:1,
00025                  vgcs:1,
00026                  vbs:1,
00027                  sm_cap:1,
00028                  ss_scr:2,
00029                  ps_cap:1,
00030                  spare2:1;
00031         uint8_t a5_2:1,
00032                  a5_3:1,
00033                  cmsp:1,
00034                  solsa:1,
00035                  spare3:1,
00036                  lcsva_cap:1,
00037                  spare4:1,
00038                  cm3:1;
00039 } __attribute__ ((packed));
00040 
00041 /* Chapter 10.5.2.1b.3 */
00042 struct gsm48_range_1024 {
00043         uint8_t w1_hi:2,
00044                  f0:1,
00045                  form_id:5;
00046         uint8_t w1_lo;
00047         uint8_t w2_hi;
00048         uint8_t w3_hi:7,
00049                  w2_lo:1;
00050         uint8_t w4_hi:6,
00051                  w3_lo:2;
00052         uint8_t w5_hi:6,
00053                  w4_lo:2;
00054         uint8_t w6_hi:6,
00055                  w5_lo:2;
00056         uint8_t w7_hi:6,
00057                  w6_lo:2;
00058         uint8_t w8_hi:6,
00059                  w7_lo:2;
00060         uint8_t w9:7,
00061                  w8_lo:1;
00062         uint8_t w11_hi:1,
00063                  w10:7;
00064         uint8_t w12_hi:2,
00065                  w11_lo:6;
00066         uint8_t w13_hi:3,
00067                  w12_lo:5;
00068         uint8_t w14_hi:4,
00069                  w13_lo:4;
00070         uint8_t w15_hi:5,
00071                  w14_lo:3;
00072         uint8_t w16:6,
00073                  w15_lo:2;
00074 } __attribute__ ((packed));
00075 
00076 /* Chapter 10.5.2.1b.4 */
00077 struct gsm48_range_512 {
00078         uint8_t orig_arfcn_hi:1,
00079                  form_id:7;
00080         uint8_t orig_arfcn_mid;
00081         uint8_t w1_hi:7,
00082                  orig_arfcn_lo:1;
00083         uint8_t w2_hi:6,
00084                  w1_lo:2;
00085         uint8_t w3_hi:6,
00086                  w2_lo:2;
00087         uint8_t w4_hi:6,
00088                  w3_lo:2;
00089         uint8_t w5:7,
00090                  w4_lo:1;
00091         uint8_t w7_hi:1,
00092                  w6:7;
00093         uint8_t w8_hi:2,
00094                  w7_lo:6;
00095         uint8_t w9_hi:4,
00096                  w8_lo:4;
00097         uint8_t w10:6,
00098                  w9_lo:2;
00099         uint8_t w12_hi:2,
00100                  w11:6;
00101         uint8_t w13_hi:4,
00102                  w12_lo:4;
00103         uint8_t w14:6,
00104                  w13_lo:2;
00105         uint8_t w16_hi:2,
00106                  w15:6;
00107         uint8_t w17:5,
00108                  w16_lo:3;
00109 } __attribute__ ((packed));
00110 
00111 /* Chapter 10.5.2.1b.5 */
00112 struct gsm48_range_256 {
00113         uint8_t orig_arfcn_hi:1,
00114                  form_id:7;
00115         uint8_t orig_arfcn_mid;
00116         uint8_t w1_hi:7,
00117                  orig_arfcn_lo:1;
00118         uint8_t w2:7,
00119                  w1_lo:1;
00120         uint8_t w4_hi:1,
00121                  w3:7;
00122         uint8_t w5_hi:3,
00123                  w4_lo:5;
00124         uint8_t w6_hi:5,
00125                  w5_lo:3;
00126         uint8_t w8_hi:1,
00127                  w7:6,
00128                  w6_lo:1;
00129         uint8_t w9_hi:4,
00130                  w8_lo:4;
00131         uint8_t w11_hi:2,
00132                  w10:5,
00133                  w9_lo:1;
00134         uint8_t w12:5,
00135                  w11_lo:3;
00136         uint8_t w14_hi:3,
00137                  w13:5;
00138         uint8_t w16_hi:1,
00139                  w15:5,
00140                  w14_lo:2;
00141         uint8_t w18_hi:1,
00142                  w17:4,
00143                  w16_lo:3;
00144         uint8_t w20_hi:1,
00145                  w19:4,
00146                  w18_lo:3;
00147         uint8_t spare:1,
00148                  w21:4,
00149                  w20_lo:3;
00150 } __attribute__ ((packed));
00151 
00152 /* Chapter 10.5.2.1b.6 */
00153 struct gsm48_range_128 {
00154         uint8_t orig_arfcn_hi:1,
00155                  form_id:7;
00156         uint8_t orig_arfcn_mid;
00157         uint8_t w1:7,
00158                  orig_arfcn_lo:1;
00159         uint8_t w3_hi:2,
00160                  w2:6;
00161         uint8_t w4_hi:4,
00162                  w3_lo:4;
00163         uint8_t w6_hi:2,
00164                  w5:5,
00165                  w4_lo:1;
00166         uint8_t w7:5,
00167                  w6_lo:3;
00168         uint8_t w9:4,
00169                  w8:4;
00170         uint8_t w11:4,
00171                  w10:4;
00172         uint8_t w13:4,
00173                  w12:4;
00174         uint8_t w15:4,
00175                  w14:4;
00176         uint8_t w18_hi:2,
00177                  w17:3,
00178                  w16:3;
00179         uint8_t w21_hi:1,
00180                  w20:3,
00181                  w19:3,
00182                  w18_lo:1;
00183         uint8_t w23:3,
00184                  w22:3,
00185                  w21_lo:2;
00186         uint8_t w26_hi:2,
00187                  w25:3,
00188                  w24:3;
00189         uint8_t spare:1,
00190                  w28:3,
00191                  w27:3,
00192                  w26_lo:1;
00193 } __attribute__ ((packed));
00194 
00195 /* Chapter 10.5.2.1b.7 */
00196 struct gsm48_var_bit {
00197         uint8_t orig_arfcn_hi:1,
00198                  form_id:7;
00199         uint8_t orig_arfcn_mid;
00200         uint8_t rrfcn1_7:7,
00201                  orig_arfcn_lo:1;
00202         uint8_t rrfcn8_111[13];
00203 } __attribute__ ((packed));
00204 
00205 /* Chapter 10.5.2.5 */
00206 struct gsm48_chan_desc {
00207         uint8_t chan_nr;
00208         union {
00209                 struct {
00210                         uint8_t maio_high:4,
00211                                  h:1,
00212                                  tsc:3;
00213                         uint8_t hsn:6,
00214                                  maio_low:2;
00215                 } __attribute__ ((packed)) h1;
00216                 struct {
00217                         uint8_t arfcn_high:2,
00218                                  spare:2,
00219                                  h:1,
00220                                  tsc:3;
00221                         uint8_t arfcn_low;
00222                 } __attribute__ ((packed)) h0;
00223         } __attribute__ ((packed));
00224 } __attribute__ ((packed));
00225 
00226 /* Chapter 10.5.2.20 */
00227 struct gsm48_meas_res {
00228         uint8_t rxlev_full:6,
00229                  dtx_used:1,
00230                  ba_used:1;
00231         uint8_t rxlev_sub:6,
00232                  meas_valid:1,
00233                  spare:1;
00234         uint8_t no_nc_n_hi:1,
00235                  rxqual_sub:3,
00236                  rxqual_full:3,
00237                  spare2:1;
00238         uint8_t rxlev_nc1:6,
00239                  no_nc_n_lo:2;
00240         uint8_t bsic_nc1_hi:3,
00241                  bcch_f_nc1:5;
00242         uint8_t rxlev_nc2_hi:5,
00243                  bsic_nc1_lo:3;
00244         uint8_t bsic_nc2_hi:2,
00245                  bcch_f_nc2:5,
00246                  rxlev_nc2_lo:1;
00247         uint8_t rxlev_nc3_hi:4,
00248                  bsic_nc2_lo:4;
00249         uint8_t bsic_nc3_hi:1,
00250                  bcch_f_nc3:5,
00251                  rxlev_nc3_lo:2;
00252         uint8_t rxlev_nc4_hi:3,
00253                  bsic_nc3_lo:5;
00254         uint8_t bcch_f_nc4:5,
00255                  rxlev_nc4_lo:3;
00256         uint8_t rxlev_nc5_hi:2,
00257                  bsic_nc4:6;
00258         uint8_t bcch_f_nc5_hi:4,
00259                  rxlev_nc5_lo:4;
00260         uint8_t rxlev_nc6_hi:1,
00261                  bsic_nc5:6,
00262                  bcch_f_nc5_lo:1;
00263         uint8_t bcch_f_nc6_hi:3,
00264                  rxlev_nc6_lo:5;
00265         uint8_t bsic_nc6:6,
00266                  bcch_f_nc6_lo:2;
00267 } __attribute__ ((packed));
00268 
00269 /* Chapter 10.5.2.21aa */
00270 struct gsm48_multi_rate_conf {
00271         uint8_t smod : 2,
00272                  spare: 1,
00273                  icmi : 1,
00274                  nscb : 1,
00275                  ver : 3;
00276         uint8_t m4_75 : 1,
00277                  m5_15 : 1,
00278                  m5_90 : 1,
00279                  m6_70 : 1,
00280                  m7_40 : 1,
00281                  m7_95 : 1,
00282                  m10_2 : 1,
00283                  m12_2 : 1;
00284 } __attribute__((packed));
00285 
00286 /* Chapter 10.5.2.28(a) */
00287 struct gsm48_power_cmd {
00288         uint8_t power_level:5,
00289                  spare:2,
00290                  atc:1;
00291 } __attribute__((packed));
00292 
00293 /* Chapter 10.5.2.29 */
00294 struct gsm48_rach_control {
00295         uint8_t re :1,
00296                  cell_bar :1,
00297                  tx_integer :4,
00298                  max_trans :2;
00299         uint8_t t2;
00300         uint8_t t3;
00301 } __attribute__ ((packed));
00302 
00303 
00304 /* Chapter 10.5.2.30 */
00305 struct gsm48_req_ref {
00306         uint8_t ra;
00307         uint8_t t3_high:3,
00308                  t1:5;
00309         uint8_t t2:5,
00310                  t3_low:3;
00311 } __attribute__ ((packed));
00312 
00313 /* Chapter 10.5.2.38 */
00314 struct gsm48_start_time {
00315         uint8_t t3_high:3,
00316                  t1:5;
00317         uint8_t t2:5,
00318                  t3_low:3;
00319 } __attribute__ ((packed));
00320 
00321 /* Chapter 10.5.2.39 */
00322 struct gsm48_sync_ind {
00323         uint8_t si:2,
00324                  rot:1,
00325                  nci:1,
00326                  sync_ie:4;
00327 } __attribute__((packed));
00328 
00329 /*
00330  * Chapter 9.1.5/9.1.6
00331  *
00332  * For 9.1.6 the chan_desc has the meaning of 10.5.2.5a
00333  */
00334 struct gsm48_chan_mode_modify {
00335         struct gsm48_chan_desc chan_desc;
00336         uint8_t mode;
00337 } __attribute__ ((packed));
00338 
00339 enum gsm48_chan_mode {
00340         GSM48_CMODE_SIGN        = 0x00,
00341         GSM48_CMODE_SPEECH_V1   = 0x01,
00342         GSM48_CMODE_SPEECH_EFR  = 0x21,
00343         GSM48_CMODE_SPEECH_AMR  = 0x41,
00344         GSM48_CMODE_DATA_14k5   = 0x0f,
00345         GSM48_CMODE_DATA_12k0   = 0x03,
00346         GSM48_CMODE_DATA_6k0    = 0x0b,
00347         GSM48_CMODE_DATA_3k6    = 0x13,
00348 };
00349 
00350 /* Chapter 9.1.2 */
00351 struct gsm48_ass_cmd {
00352         /* Semantic is from 10.5.2.5a */
00353         struct gsm48_chan_desc chan_desc;
00354         uint8_t power_command;
00355         uint8_t data[0];
00356 } __attribute__((packed));
00357 
00358 /* Chapter 9.1.13 */
00359 struct gsm48_frq_redef {
00360         /* Semantic is from 10.5.2.5a */
00361         struct gsm48_chan_desc chan_desc;
00362         uint8_t mob_alloc_len;
00363         uint8_t mob_alloc[0];
00364 } __attribute__((packed));
00365 
00366 /* Chapter 10.5.2.2 */
00367 struct gsm48_cell_desc {
00368         uint8_t bcc:3,
00369                  ncc:3,
00370                  arfcn_hi:2;
00371         uint8_t arfcn_lo;
00372 } __attribute__((packed));
00373 
00374 /* Chapter 9.1.15 */
00375 struct gsm48_ho_cmd {
00376         struct gsm48_cell_desc cell_desc;
00377         struct gsm48_chan_desc chan_desc;
00378         uint8_t ho_ref;
00379         uint8_t power_command;
00380         uint8_t data[0];
00381 } __attribute__((packed));
00382 
00383 /* Chapter 9.1.18 */
00384 struct gsm48_imm_ass {
00385         uint8_t l2_plen;
00386         uint8_t proto_discr;
00387         uint8_t msg_type;
00388         uint8_t page_mode;
00389         struct gsm48_chan_desc chan_desc;
00390         struct gsm48_req_ref req_ref;
00391         uint8_t timing_advance;
00392         uint8_t mob_alloc_len;
00393         uint8_t mob_alloc[0];
00394 } __attribute__ ((packed));
00395 
00396 /* Chapter 9.1.25 */
00397 struct gsm48_pag_resp {
00398         uint8_t spare:4,
00399                  key_seq:4;
00400         uint32_t classmark2;
00401         uint8_t mi_len;
00402         uint8_t mi[0];
00403 } __attribute__ ((packed));
00404 
00405 /* Chapter 10.5.1.3 */
00406 struct gsm48_loc_area_id {
00407         uint8_t digits[3];      /* BCD! */
00408         uint16_t lac;
00409 } __attribute__ ((packed));
00410 
00411 /* Section 9.2.2 */
00412 struct gsm48_auth_req {
00413         uint8_t key_seq:4,
00414                  spare:4;
00415         uint8_t rand[16];
00416 } __attribute__ ((packed));
00417 
00418 /* Section 9.2.3 */
00419 struct gsm48_auth_resp {
00420         uint8_t sres[4];
00421 } __attribute__ ((packed));
00422 
00423 /* Section 9.2.15 */
00424 struct gsm48_loc_upd_req {
00425         uint8_t type:4,
00426                  key_seq:4;
00427         struct gsm48_loc_area_id lai;
00428         struct gsm48_classmark1 classmark1;
00429         uint8_t mi_len;
00430         uint8_t mi[0];
00431 } __attribute__ ((packed));
00432 
00433 /* Section 10.1 */
00434 struct gsm48_hdr {
00435         uint8_t proto_discr;
00436         uint8_t msg_type;
00437         uint8_t data[0];
00438 } __attribute__ ((packed));
00439 
00440 /* Section 9.1.3x System information Type header */
00441 struct gsm48_system_information_type_header {
00442         uint8_t l2_plen;
00443         uint8_t rr_protocol_discriminator :4,
00444                 skip_indicator:4; 
00445         uint8_t system_information;
00446 } __attribute__ ((packed));
00447 
00448 /* Section 10.5.2.4 Cell Selection Parameters */
00449 struct gsm48_cell_sel_par {
00450         uint8_t ms_txpwr_max_ccch:5,    /* GSM 05.08 MS-TXPWR-MAX-CCCH */
00451                  cell_resel_hyst:3;     /* GSM 05.08 CELL-RESELECT-HYSTERESIS */
00452         uint8_t rxlev_acc_min:6,        /* GSM 05.08 RXLEV-ACCESS-MIN */
00453                  neci:1,
00454                  acs:1;
00455 } __attribute__ ((packed));
00456 
00457 /* Section 10.5.2.11 Control Channel Description , Figure 10.5.33 */
00458 struct gsm48_control_channel_descr {
00459         uint8_t ccch_conf :3,
00460                 bs_ag_blks_res :3,
00461                 att :1,
00462                 spare1 :1;
00463         uint8_t bs_pa_mfrms : 3,
00464                 spare2 :5;
00465         uint8_t t3212;
00466 } __attribute__ ((packed));
00467 
00468 struct gsm48_cell_options {
00469         uint8_t radio_link_timeout:4,
00470                  dtx:2,
00471                  pwrc:1,
00472                  spare:1;
00473 } __attribute__ ((packed));
00474 
00475 /* Section 9.2.9 CM service request */
00476 struct gsm48_service_request {
00477         uint8_t cm_service_type : 4,
00478                  cipher_key_seq  : 4;
00479         /* length + 3 bytes */
00480         uint32_t classmark;
00481         uint8_t mi_len;
00482         uint8_t mi[0];
00483         /* optional priority level */
00484 } __attribute__ ((packed));
00485 
00486 /* Section 9.1.31 System information Type 1 */
00487 struct gsm48_system_information_type_1 {
00488         struct gsm48_system_information_type_header header;
00489         uint8_t cell_channel_description[16];
00490         struct gsm48_rach_control rach_control;
00491         uint8_t rest_octets[0]; /* NCH position on the CCCH */
00492 } __attribute__ ((packed));
00493 
00494 /* Section 9.1.32 System information Type 2 */
00495 struct gsm48_system_information_type_2 {
00496         struct gsm48_system_information_type_header header;
00497         uint8_t bcch_frequency_list[16];
00498         uint8_t ncc_permitted;
00499         struct gsm48_rach_control rach_control;
00500 } __attribute__ ((packed));
00501 
00502 /* Section 9.1.33 System information Type 2bis */
00503 struct gsm48_system_information_type_2bis {
00504         struct gsm48_system_information_type_header header;
00505         uint8_t bcch_frequency_list[16];
00506         struct gsm48_rach_control rach_control;
00507         uint8_t rest_octets[0];
00508 } __attribute__ ((packed));
00509 
00510 /* Section 9.1.34 System information Type 2ter */
00511 struct gsm48_system_information_type_2ter {
00512         struct gsm48_system_information_type_header header;
00513         uint8_t ext_bcch_frequency_list[16];
00514         uint8_t rest_octets[0];
00515 } __attribute__ ((packed));
00516 
00517 /* Section 9.1.35 System information Type 3 */
00518 struct gsm48_system_information_type_3 {
00519         struct gsm48_system_information_type_header header;
00520         uint16_t cell_identity;
00521         struct gsm48_loc_area_id lai;
00522         struct gsm48_control_channel_descr control_channel_desc;
00523         struct gsm48_cell_options cell_options;
00524         struct gsm48_cell_sel_par cell_sel_par;
00525         struct gsm48_rach_control rach_control;
00526         uint8_t rest_octets[0];
00527 } __attribute__ ((packed));
00528 
00529 /* Section 9.1.36 System information Type 4 */
00530 struct gsm48_system_information_type_4 {
00531         struct gsm48_system_information_type_header header;
00532         struct gsm48_loc_area_id lai;
00533         struct gsm48_cell_sel_par cell_sel_par;
00534         struct gsm48_rach_control rach_control;
00535         /*      optional CBCH conditional CBCH... followed by
00536                 mandantory SI 4 Reset Octets
00537          */
00538         uint8_t data[0];
00539 } __attribute__ ((packed));
00540 
00541 /* Section 9.1.37 System information Type 5 */
00542 struct gsm48_system_information_type_5 {
00543         uint8_t rr_protocol_discriminator :4,
00544                 skip_indicator:4; 
00545         uint8_t system_information;
00546         uint8_t bcch_frequency_list[16];
00547 } __attribute__ ((packed));
00548 
00549 /* Section 9.1.38 System information Type 5bis */
00550 struct gsm48_system_information_type_5bis {
00551         uint8_t rr_protocol_discriminator :4,
00552                  skip_indicator:4;
00553         uint8_t system_information;
00554         uint8_t bcch_frequency_list[16];
00555 } __attribute__ ((packed));
00556 
00557 /* Section 9.1.39 System information Type 5ter */
00558 struct gsm48_system_information_type_5ter {
00559         uint8_t rr_protocol_discriminator :4,
00560                  skip_indicator:4;
00561         uint8_t system_information;
00562         uint8_t bcch_frequency_list[16];
00563 } __attribute__ ((packed));
00564 
00565 /* Section 9.1.40 System information Type 6 */
00566 struct gsm48_system_information_type_6 {
00567         uint8_t rr_protocol_discriminator :4,
00568                 skip_indicator:4; 
00569         uint8_t system_information;
00570         uint16_t cell_identity;
00571         struct gsm48_loc_area_id lai;
00572         struct gsm48_cell_options cell_options;
00573         uint8_t ncc_permitted;
00574         uint8_t rest_octets[0];
00575 } __attribute__ ((packed));
00576 
00577 /* Section 9.1.43a System Information type 13 */
00578 struct gsm48_system_information_type_13 {
00579         struct gsm48_system_information_type_header header;
00580         uint8_t rest_octets[0];
00581 } __attribute__ ((packed));
00582 
00583 /* Section 9.2.12 IMSI Detach Indication */
00584 struct gsm48_imsi_detach_ind {
00585         struct gsm48_classmark1 classmark1;
00586         uint8_t mi_len;
00587         uint8_t mi[0];
00588 } __attribute__ ((packed));
00589 
00590 /* Section 9.1.1 */
00591 struct gsm48_add_ass {
00592         /* Semantic is from 10.5.2.5 */
00593         struct gsm48_chan_desc chan_desc;
00594         uint8_t data[0];
00595 } __attribute__((packed));
00596 
00597 /* Section 9.1.3 */
00598 struct gsm48_ass_cpl {
00599         uint8_t rr_cause;
00600 } __attribute__((packed));
00601 
00602 /* Section 9.1.4 */
00603 struct gsm48_ass_fail {
00604         uint8_t rr_cause;
00605 } __attribute__((packed));
00606 
00607 /* Section 9.1.3 */
00608 struct gsm48_ho_cpl {
00609         uint8_t rr_cause;
00610         uint8_t data[0];
00611 } __attribute__((packed));
00612 
00613 /* Section 9.1.4 */
00614 struct gsm48_ho_fail {
00615         uint8_t rr_cause;
00616 } __attribute__((packed));
00617 
00618 /* Section 9.1.7 */
00619 struct gsm48_chan_rel {
00620         uint8_t rr_cause;
00621         uint8_t data[0];
00622 } __attribute__((packed));
00623 
00624 /* Section 9.1.9 */
00625 struct gsm48_cip_mode_cmd {
00626         uint8_t sc:1,
00627                  alg_id:3,
00628                  cr:1,
00629                  spare:3;
00630 } __attribute__((packed));
00631 
00632 /* Section 9.1.11 */
00633 struct gsm48_cm_change {
00634         uint8_t cm2_len;
00635         struct gsm48_classmark2 cm2;
00636         uint8_t data[0];
00637 } __attribute__((packed));
00638 
00639 /* Section 9.1.19 */
00640 struct gsm48_imm_ass_ext {
00641         uint8_t l2_plen;
00642         uint8_t proto_discr;
00643         uint8_t msg_type;
00644         uint8_t page_mode;
00645         struct gsm48_chan_desc chan_desc1;
00646         struct gsm48_req_ref req_ref1;
00647         uint8_t timing_advance1;
00648         struct gsm48_chan_desc chan_desc2;
00649         struct gsm48_req_ref req_ref2;
00650         uint8_t timing_advance2;
00651         uint8_t mob_alloc_len;
00652         uint8_t mob_alloc[0];
00653 } __attribute__ ((packed));
00654 
00655 /* Section 9.1.20 */
00656 struct gsm48_imm_ass_rej {
00657         uint8_t l2_plen;
00658         uint8_t proto_discr;
00659         uint8_t msg_type;
00660         uint8_t page_mode;
00661         struct gsm48_req_ref req_ref1;
00662         uint8_t wait_ind1;
00663         struct gsm48_req_ref req_ref2;
00664         uint8_t wait_ind2;
00665         struct gsm48_req_ref req_ref3;
00666         uint8_t wait_ind3;
00667         struct gsm48_req_ref req_ref4;
00668         uint8_t wait_ind4;
00669         uint8_t rest[0];
00670 } __attribute__ ((packed));
00671 
00672 /* Section 9.1.22 */
00673 struct gsm48_paging1 {
00674         uint8_t l2_plen;
00675         uint8_t proto_discr;
00676         uint8_t msg_type;
00677         uint8_t pag_mode:2,
00678                  spare:2,
00679                  cneed1:2,
00680                  cneed2:2;
00681         uint8_t data[0];
00682 } __attribute__((packed));
00683 
00684 /* Section 9.1.23 */
00685 struct gsm48_paging2 {
00686         uint8_t l2_plen;
00687         uint8_t proto_discr;
00688         uint8_t msg_type;
00689         uint8_t pag_mode:2,
00690                  spare:2,
00691                  cneed1:2,
00692                  cneed2:2;
00693         uint32_t tmsi1;
00694         uint32_t tmsi2;
00695         uint8_t data[0];
00696 } __attribute__((packed));
00697 
00698 /* Section 9.1.24 */
00699 struct gsm48_paging3 {
00700         uint8_t l2_plen;
00701         uint8_t proto_discr;
00702         uint8_t msg_type;
00703         uint8_t pag_mode:2,
00704                  spare:2,
00705                  cneed1:2,
00706                  cneed2:2;
00707         uint32_t tmsi1;
00708         uint32_t tmsi2;
00709         uint32_t tmsi3;
00710         uint32_t tmsi4;
00711         uint8_t cneed3:2,
00712                  cneed4:2,
00713                  spare2:4;
00714         uint8_t rest[0];
00715 } __attribute__((packed));
00716 
00717 /* Section 9.1.25 */
00718 struct gsm48_pag_rsp {
00719         uint8_t key_seq:3,
00720                  spare:5;
00721         uint8_t cm2_len;
00722         struct gsm48_classmark2 cm2;
00723         uint8_t data[0];
00724 } __attribute__((packed));
00725 
00726 /* Section 9.1.29 */
00727 struct gsm48_rr_status {
00728         uint8_t rr_cause;
00729 } __attribute__((packed));
00730 
00731 /* Section 10.2 + GSM 04.07 12.2.3.1.1 */
00732 #define GSM48_PDISC_GROUP_CC    0x00
00733 #define GSM48_PDISC_BCAST_CC    0x01
00734 #define GSM48_PDISC_PDSS1       0x02
00735 #define GSM48_PDISC_CC          0x03
00736 #define GSM48_PDISC_PDSS2       0x04
00737 #define GSM48_PDISC_MM          0x05
00738 #define GSM48_PDISC_RR          0x06
00739 #define GSM48_PDISC_MM_GPRS     0x08
00740 #define GSM48_PDISC_SMS         0x09
00741 #define GSM48_PDISC_SM_GPRS     0x0a
00742 #define GSM48_PDISC_NC_SS       0x0b
00743 #define GSM48_PDISC_LOC         0x0c
00744 #define GSM48_PDISC_MASK        0x0f
00745 #define GSM48_PDISC_USSD        0x11
00746 
00747 /* Section 10.4 */
00748 #define GSM48_MT_RR_INIT_REQ            0x3c
00749 #define GSM48_MT_RR_ADD_ASS             0x3b
00750 #define GSM48_MT_RR_IMM_ASS             0x3f
00751 #define GSM48_MT_RR_IMM_ASS_EXT         0x39
00752 #define GSM48_MT_RR_IMM_ASS_REJ         0x3a
00753 
00754 #define GSM48_MT_RR_CIPH_M_CMD          0x35
00755 #define GSM48_MT_RR_CIPH_M_COMPL        0x32
00756 
00757 #define GSM48_MT_RR_CFG_CHG_CMD         0x30
00758 #define GSM48_MT_RR_CFG_CHG_ACK         0x31
00759 #define GSM48_MT_RR_CFG_CHG_REJ         0x33
00760 
00761 #define GSM48_MT_RR_ASS_CMD             0x2e
00762 #define GSM48_MT_RR_ASS_COMPL           0x29
00763 #define GSM48_MT_RR_ASS_FAIL            0x2f
00764 #define GSM48_MT_RR_HANDO_CMD           0x2b
00765 #define GSM48_MT_RR_HANDO_COMPL         0x2c
00766 #define GSM48_MT_RR_HANDO_FAIL          0x28
00767 #define GSM48_MT_RR_HANDO_INFO          0x2d
00768 
00769 #define GSM48_MT_RR_CELL_CHG_ORDER      0x08
00770 #define GSM48_MT_RR_PDCH_ASS_CMD        0x23
00771 
00772 #define GSM48_MT_RR_CHAN_REL            0x0d
00773 #define GSM48_MT_RR_PART_REL            0x0a
00774 #define GSM48_MT_RR_PART_REL_COMP       0x0f
00775 
00776 #define GSM48_MT_RR_PAG_REQ_1           0x21
00777 #define GSM48_MT_RR_PAG_REQ_2           0x22
00778 #define GSM48_MT_RR_PAG_REQ_3           0x24
00779 #define GSM48_MT_RR_PAG_RESP            0x27
00780 #define GSM48_MT_RR_NOTIF_NCH           0x20
00781 #define GSM48_MT_RR_NOTIF_FACCH         0x25
00782 #define GSM48_MT_RR_NOTIF_RESP          0x26
00783 
00784 #define GSM48_MT_RR_SYSINFO_8           0x18
00785 #define GSM48_MT_RR_SYSINFO_1           0x19
00786 #define GSM48_MT_RR_SYSINFO_2           0x1a
00787 #define GSM48_MT_RR_SYSINFO_3           0x1b
00788 #define GSM48_MT_RR_SYSINFO_4           0x1c
00789 #define GSM48_MT_RR_SYSINFO_5           0x1d
00790 #define GSM48_MT_RR_SYSINFO_6           0x1e
00791 #define GSM48_MT_RR_SYSINFO_7           0x1f
00792 
00793 #define GSM48_MT_RR_SYSINFO_2bis        0x02
00794 #define GSM48_MT_RR_SYSINFO_2ter        0x03
00795 #define GSM48_MT_RR_SYSINFO_5bis        0x05
00796 #define GSM48_MT_RR_SYSINFO_5ter        0x06
00797 #define GSM48_MT_RR_SYSINFO_9           0x04
00798 #define GSM48_MT_RR_SYSINFO_13          0x00
00799 
00800 #define GSM48_MT_RR_SYSINFO_16          0x3d
00801 #define GSM48_MT_RR_SYSINFO_17          0x3e
00802 
00803 #define GSM48_MT_RR_CHAN_MODE_MODIF     0x10
00804 #define GSM48_MT_RR_STATUS              0x12
00805 #define GSM48_MT_RR_CHAN_MODE_MODIF_ACK 0x17
00806 #define GSM48_MT_RR_FREQ_REDEF          0x14
00807 #define GSM48_MT_RR_MEAS_REP            0x15
00808 #define GSM48_MT_RR_CLSM_CHG            0x16
00809 #define GSM48_MT_RR_CLSM_ENQ            0x13
00810 #define GSM48_MT_RR_EXT_MEAS_REP        0x36
00811 #define GSM48_MT_RR_EXT_MEAS_REP_ORD    0x37
00812 #define GSM48_MT_RR_GPRS_SUSP_REQ       0x34
00813 
00814 #define GSM48_MT_RR_VGCS_UPL_GRANT      0x09
00815 #define GSM48_MT_RR_UPLINK_RELEASE      0x0e
00816 #define GSM48_MT_RR_UPLINK_FREE         0x0c
00817 #define GSM48_MT_RR_UPLINK_BUSY         0x2a
00818 #define GSM48_MT_RR_TALKER_IND          0x11
00819 
00820 #define GSM48_MT_RR_APP_INFO            0x38
00821 
00822 /* Table 10.2/3GPP TS 04.08 */
00823 #define GSM48_MT_MM_IMSI_DETACH_IND     0x01
00824 #define GSM48_MT_MM_LOC_UPD_ACCEPT      0x02
00825 #define GSM48_MT_MM_LOC_UPD_REJECT      0x04
00826 #define GSM48_MT_MM_LOC_UPD_REQUEST     0x08
00827 
00828 #define GSM48_MT_MM_AUTH_REJ            0x11
00829 #define GSM48_MT_MM_AUTH_REQ            0x12
00830 #define GSM48_MT_MM_AUTH_RESP           0x14
00831 #define GSM48_MT_MM_ID_REQ              0x18
00832 #define GSM48_MT_MM_ID_RESP             0x19
00833 #define GSM48_MT_MM_TMSI_REALL_CMD      0x1a
00834 #define GSM48_MT_MM_TMSI_REALL_COMPL    0x1b
00835 
00836 #define GSM48_MT_MM_CM_SERV_ACC         0x21
00837 #define GSM48_MT_MM_CM_SERV_REJ         0x22
00838 #define GSM48_MT_MM_CM_SERV_ABORT       0x23
00839 #define GSM48_MT_MM_CM_SERV_REQ         0x24
00840 #define GSM48_MT_MM_CM_SERV_PROMPT      0x25
00841 #define GSM48_MT_MM_CM_REEST_REQ        0x28
00842 #define GSM48_MT_MM_ABORT               0x29
00843 
00844 #define GSM48_MT_MM_NULL                0x30
00845 #define GSM48_MT_MM_STATUS              0x31
00846 #define GSM48_MT_MM_INFO                0x32
00847 
00848 /* Table 10.3/3GPP TS 04.08 */
00849 #define GSM48_MT_CC_ALERTING            0x01
00850 #define GSM48_MT_CC_CALL_CONF           0x08
00851 #define GSM48_MT_CC_CALL_PROC           0x02
00852 #define GSM48_MT_CC_CONNECT             0x07
00853 #define GSM48_MT_CC_CONNECT_ACK         0x0f
00854 #define GSM48_MT_CC_EMERG_SETUP         0x0e
00855 #define GSM48_MT_CC_PROGRESS            0x03
00856 #define GSM48_MT_CC_ESTAB               0x04
00857 #define GSM48_MT_CC_ESTAB_CONF          0x06
00858 #define GSM48_MT_CC_RECALL              0x0b
00859 #define GSM48_MT_CC_START_CC            0x09
00860 #define GSM48_MT_CC_SETUP               0x05
00861 
00862 #define GSM48_MT_CC_MODIFY              0x17
00863 #define GSM48_MT_CC_MODIFY_COMPL        0x1f
00864 #define GSM48_MT_CC_MODIFY_REJECT       0x13
00865 #define GSM48_MT_CC_USER_INFO           0x10
00866 #define GSM48_MT_CC_HOLD                0x18
00867 #define GSM48_MT_CC_HOLD_ACK            0x19
00868 #define GSM48_MT_CC_HOLD_REJ            0x1a
00869 #define GSM48_MT_CC_RETR                0x1c
00870 #define GSM48_MT_CC_RETR_ACK            0x1d
00871 #define GSM48_MT_CC_RETR_REJ            0x1e
00872 
00873 #define GSM48_MT_CC_DISCONNECT          0x25
00874 #define GSM48_MT_CC_RELEASE             0x2d
00875 #define GSM48_MT_CC_RELEASE_COMPL       0x2a
00876 
00877 #define GSM48_MT_CC_CONG_CTRL           0x39
00878 #define GSM48_MT_CC_NOTIFY              0x3e
00879 #define GSM48_MT_CC_STATUS              0x3d
00880 #define GSM48_MT_CC_STATUS_ENQ          0x34
00881 #define GSM48_MT_CC_START_DTMF          0x35
00882 #define GSM48_MT_CC_STOP_DTMF           0x31
00883 #define GSM48_MT_CC_STOP_DTMF_ACK       0x32
00884 #define GSM48_MT_CC_START_DTMF_ACK      0x36
00885 #define GSM48_MT_CC_START_DTMF_REJ      0x37
00886 #define GSM48_MT_CC_FACILITY            0x3a
00887 
00888 /* FIXME: Table 10.4 / 10.4a (GPRS) */
00889 
00890 /* Section 10.5.3.3 CM service type */
00891 #define GSM48_CMSERV_MO_CALL_PACKET     1
00892 #define GSM48_CMSERV_EMERGENCY          2
00893 #define GSM48_CMSERV_SMS                4
00894 #define GSM48_CMSERV_SUP_SERV           8
00895 #define GSM48_CMSERV_VGCS               9
00896 #define GSM48_CMSERV_VBS                10
00897 #define GSM48_CMSERV_LOC_SERV           11
00898 
00899 /* Section 10.5.2.26, Table 10.5.64 */
00900 #define GSM48_PM_MASK           0x03
00901 #define GSM48_PM_NORMAL         0x00
00902 #define GSM48_PM_EXTENDED       0x01
00903 #define GSM48_PM_REORG          0x02
00904 #define GSM48_PM_SAME           0x03
00905 
00906 /* Chapter 10.5.3.5 / Table 10.5.93 */
00907 #define GSM48_LUPD_NORMAL       0x0
00908 #define GSM48_LUPD_PERIODIC     0x1
00909 #define GSM48_LUPD_IMSI_ATT     0x2
00910 #define GSM48_LUPD_RESERVED     0x3
00911 
00912 /* Table 10.5.4 */
00913 #define GSM_MI_TYPE_MASK        0x07
00914 #define GSM_MI_TYPE_NONE        0x00
00915 #define GSM_MI_TYPE_IMSI        0x01
00916 #define GSM_MI_TYPE_IMEI        0x02
00917 #define GSM_MI_TYPE_IMEISV      0x03
00918 #define GSM_MI_TYPE_TMSI        0x04
00919 #define GSM_MI_ODD              0x08
00920 
00921 #define GSM48_IE_MOBILE_ID      0x17    /* 10.5.1.4 */
00922 #define GSM48_IE_NAME_LONG      0x43    /* 10.5.3.5a */
00923 #define GSM48_IE_NAME_SHORT     0x45    /* 10.5.3.5a */
00924 #define GSM48_IE_UTC            0x46    /* 10.5.3.8 */
00925 #define GSM48_IE_NET_TIME_TZ    0x47    /* 10.5.3.9 */
00926 #define GSM48_IE_LSA_IDENT      0x48    /* 10.5.3.11 */
00927 #define GSM48_IE_NET_DST        0x49    /* 10.5.3.12 [24.008] */
00928 
00929 #define GSM48_IE_BEARER_CAP     0x04    /* 10.5.4.5 */
00930 #define GSM48_IE_CAUSE          0x08    /* 10.5.4.11 */
00931 #define GSM48_IE_CC_CAP         0x15    /* 10.5.4.5a */
00932 #define GSM48_IE_ALERT          0x19    /* 10.5.4.26 */
00933 #define GSM48_IE_FACILITY       0x1c    /* 10.5.4.15 */
00934 #define GSM48_IE_PROGR_IND      0x1e    /* 10.5.4.21 */
00935 #define GSM48_IE_AUX_STATUS     0x24    /* 10.5.4.4 */
00936 #define GSM48_IE_NOTIFY         0x27    /* 10.5.4.20 */
00937 #define GSM48_IE_KPD_FACILITY   0x2c    /* 10.5.4.17 */
00938 #define GSM48_IE_SIGNAL         0x34    /* 10.5.4.23 */
00939 #define GSM48_IE_CONN_BCD       0x4c    /* 10.5.4.13 */
00940 #define GSM48_IE_CONN_SUB       0x4d    /* 10.5.4.14 */
00941 #define GSM48_IE_CALLING_BCD    0x5c    /* 10.5.4.9 */
00942 #define GSM48_IE_CALLING_SUB    0x5d    /* 10.5.4.10 */
00943 #define GSM48_IE_CALLED_BCD     0x5e    /* 10.5.4.7 */
00944 #define GSM48_IE_CALLED_SUB     0x6d    /* 10.5.4.8 */
00945 #define GSM48_IE_REDIR_BCD      0x74    /* 10.5.4.21a */
00946 #define GSM48_IE_REDIR_SUB      0x75    /* 10.5.4.21b */
00947 #define GSM48_IE_LOWL_COMPAT    0x7c    /* 10.5.4.18 */
00948 #define GSM48_IE_HIGHL_COMPAT   0x7d    /* 10.5.4.16 */
00949 #define GSM48_IE_USER_USER      0x7e    /* 10.5.4.25 */
00950 #define GSM48_IE_SS_VERS        0x7f    /* 10.5.4.24 */
00951 #define GSM48_IE_MORE_DATA      0xa0    /* 10.5.4.19 */
00952 #define GSM48_IE_CLIR_SUPP      0xa1    /* 10.5.4.11a */
00953 #define GSM48_IE_CLIR_INVOC     0xa2    /* 10.5.4.11b */
00954 #define GSM48_IE_REV_C_SETUP    0xa3    /* 10.5.4.22a */
00955 #define GSM48_IE_REPEAT_CIR     0xd1    /* 10.5.4.22 */
00956 #define GSM48_IE_REPEAT_SEQ     0xd3    /* 10.5.4.22 */
00957 
00958 /* Section 10.5.4.11 / Table 10.5.122 */
00959 #define GSM48_CAUSE_CS_GSM      0x60
00960 
00961 /* Section 9.1.2 / Table 9.3 */
00962 /* RR elements */
00963 #define GSM48_IE_VGCS_TARGET    0x01
00964 //#define GSM48_IE_VGCS_T_MODE_I        0x01
00965 #define GSM48_IE_FRQSHORT_AFTER 0x02
00966 #define GSM48_IE_MUL_RATE_CFG   0x03    /* 10.5.2.21aa */
00967 #define GSM48_IE_FREQ_L_AFTER   0x05
00968 #define GSM48_IE_MSLOT_DESC     0x10
00969 #define GSM48_IE_CHANMODE_2     0x11
00970 #define GSM48_IE_FRQSHORT_BEFORE 0x12
00971 //#define GSM48_IE_FRQSHORT_BEFOR 0x12
00972 #define GSM48_IE_CHANMODE_3     0x13
00973 #define GSM48_IE_CHANMODE_4     0x14
00974 #define GSM48_IE_CHANMODE_5     0x15
00975 #define GSM48_IE_CHANMODE_6     0x16
00976 #define GSM48_IE_CHANMODE_7     0x17
00977 #define GSM48_IE_CHANMODE_8     0x18
00978 #define GSM48_IE_CHANDESC_2     0x64
00979 #define GSM48_IE_MA_AFTER       0x72
00980 #define GSM48_IE_START_TIME     0x7c
00981 #define GSM48_IE_FREQ_L_BEFORE  0x19
00982 //#define GSM48_IE_FRQLIST_BEFORE       0x19
00983 #define GSM48_IE_CH_DESC_1_BEFORE       0x1c
00984 //#define GSM48_IE_CHDES_1_BEFORE 0x1c
00985 #define GSM48_IE_CH_DESC_2_BEFORE       0x1d
00986 //#define GSM48_IE_CHDES_2_BEFORE       0x1d
00987 #define GSM48_IE_F_CH_SEQ_BEFORE        0x1e
00988 //#define GSM48_IE_FRQSEQ_BEFORE        0x1e
00989 #define GSM48_IE_CLASSMARK3     0x20
00990 #define GSM48_IE_MA_BEFORE      0x21
00991 #define GSM48_IE_RR_PACKET_UL   0x22
00992 #define GSM48_IE_RR_PACKET_DL   0x23
00993 #define GSM48_IE_CELL_CH_DESC   0x62
00994 #define GSM48_IE_CHANMODE_1     0x63
00995 #define GSM48_IE_CHDES_2_AFTER  0x64
00996 #define GSM48_IE_MODE_SEC_CH    0x66
00997 #define GSM48_IE_F_CH_SEQ_AFTER 0x69
00998 #define GSM48_IE_MA_AFTER       0x72
00999 #define GSM48_IE_BA_RANGE       0x73
01000 #define GSM48_IE_GROUP_CHDES    0x74
01001 #define GSM48_IE_BA_LIST_PREF   0x75
01002 #define GSM48_IE_MOB_OVSERV_DIF 0x77
01003 #define GSM48_IE_REALTIME_DIFF  0x7b
01004 #define GSM48_IE_START_TIME     0x7c
01005 #define GSM48_IE_TIMING_ADVANCE 0x7d
01006 #define GSM48_IE_GROUP_CIP_SEQ  0x80
01007 #define GSM48_IE_CIP_MODE_SET   0x90
01008 #define GSM48_IE_GPRS_RESUMPT   0xc0
01009 #define GSM48_IE_SYNC_IND       0xd0
01010 /* System Information 4 (types are equal IEs above) */
01011 #define GSM48_IE_CBCH_CHAN_DESC 0x64
01012 #define GSM48_IE_CBCH_MOB_AL    0x72
01013 
01014 /* Additional MM elements */
01015 #define GSM48_IE_LOCATION_AREA  0x13
01016 #define GSM48_IE_PRIORITY_LEV   0x80
01017 #define GSM48_IE_FOLLOW_ON_PROC 0xa1
01018 #define GSM48_IE_CTS_PERMISSION 0xa2
01019 
01020 /* Section 10.5.4.23 / Table 10.5.130 */
01021 enum gsm48_signal_val {
01022         GSM48_SIGNAL_DIALTONE   = 0x00,
01023         GSM48_SIGNAL_RINGBACK   = 0x01,
01024         GSM48_SIGNAL_INTERCEPT  = 0x02,
01025         GSM48_SIGNAL_NET_CONG   = 0x03,
01026         GSM48_SIGNAL_BUSY       = 0x04,
01027         GSM48_SIGNAL_CONFIRM    = 0x05,
01028         GSM48_SIGNAL_ANSWER     = 0x06,
01029         GSM48_SIGNAL_CALL_WAIT  = 0x07,
01030         GSM48_SIGNAL_OFF_HOOK   = 0x08,
01031         GSM48_SIGNAL_OFF        = 0x3f,
01032         GSM48_SIGNAL_ALERT_OFF  = 0x4f,
01033 };
01034 
01035 enum gsm48_cause_loc {
01036         GSM48_CAUSE_LOC_USER            = 0x00,
01037         GSM48_CAUSE_LOC_PRN_S_LU        = 0x01,
01038         GSM48_CAUSE_LOC_PUN_S_LU        = 0x02,
01039         GSM48_CAUSE_LOC_TRANS_NET       = 0x03,
01040         GSM48_CAUSE_LOC_PUN_S_RU        = 0x04,
01041         GSM48_CAUSE_LOC_PRN_S_RU        = 0x05,
01042         /* not defined */
01043         GSM48_CAUSE_LOC_INN_NET         = 0x07,
01044         GSM48_CAUSE_LOC_NET_BEYOND      = 0x0a,
01045 };
01046 
01047 /* Section 10.5.2.31 RR Cause / Table 10.5.70 */
01048 enum gsm48_rr_cause {
01049         GSM48_RR_CAUSE_NORMAL           = 0x00,
01050         GSM48_RR_CAUSE_ABNORMAL_UNSPEC  = 0x01,
01051         GSM48_RR_CAUSE_ABNORMAL_UNACCT  = 0x02,
01052         GSM48_RR_CAUSE_ABNORMAL_TIMER   = 0x03,
01053         GSM48_RR_CAUSE_ABNORMAL_NOACT   = 0x04,
01054         GSM48_RR_CAUSE_PREMPTIVE_REL    = 0x05,
01055         GSM48_RR_CAUSE_HNDOVER_IMP      = 0x08,
01056         GSM48_RR_CAUSE_CHAN_MODE_UNACCT = 0x09,
01057         GSM48_RR_CAUSE_FREQ_NOT_IMPL    = 0x0a,
01058         GSM48_RR_CAUSE_CALL_CLEARED     = 0x41,
01059         GSM48_RR_CAUSE_SEMANT_INCORR    = 0x5f,
01060         GSM48_RR_CAUSE_INVALID_MAND_INF = 0x60,
01061         GSM48_RR_CAUSE_MSG_TYPE_N       = 0x61,
01062         GSM48_RR_CAUSE_MSG_TYPE_N_COMPAT= 0x62,
01063         GSM48_RR_CAUSE_COND_IE_ERROR    = 0x64,
01064         GSM48_RR_CAUSE_NO_CELL_ALLOC_A  = 0x65,
01065         GSM48_RR_CAUSE_PROT_ERROR_UNSPC = 0x6f,
01066 };
01067 
01068 /* Section 10.5.4.11 CC Cause / Table 10.5.123 */
01069 enum gsm48_cc_cause {
01070         GSM48_CC_CAUSE_UNASSIGNED_NR    = 1,
01071         GSM48_CC_CAUSE_NO_ROUTE         = 3,
01072         GSM48_CC_CAUSE_CHAN_UNACCEPT    = 6,
01073         GSM48_CC_CAUSE_OP_DET_BARRING   = 8,
01074         GSM48_CC_CAUSE_NORM_CALL_CLEAR  = 16,
01075         GSM48_CC_CAUSE_USER_BUSY        = 17,
01076         GSM48_CC_CAUSE_USER_NOTRESPOND  = 18,
01077         GSM48_CC_CAUSE_USER_ALERTING_NA = 19,
01078         GSM48_CC_CAUSE_CALL_REJECTED    = 21,
01079         GSM48_CC_CAUSE_NUMBER_CHANGED   = 22,
01080         GSM48_CC_CAUSE_PRE_EMPTION      = 25,
01081         GSM48_CC_CAUSE_NONSE_USER_CLR   = 26,
01082         GSM48_CC_CAUSE_DEST_OOO         = 27,
01083         GSM48_CC_CAUSE_INV_NR_FORMAT    = 28,
01084         GSM48_CC_CAUSE_FACILITY_REJ     = 29,
01085         GSM48_CC_CAUSE_RESP_STATUS_INQ  = 30,
01086         GSM48_CC_CAUSE_NORMAL_UNSPEC    = 31,
01087         GSM48_CC_CAUSE_NO_CIRCUIT_CHAN  = 34,
01088         GSM48_CC_CAUSE_NETWORK_OOO      = 38,
01089         GSM48_CC_CAUSE_TEMP_FAILURE     = 41,
01090         GSM48_CC_CAUSE_SWITCH_CONG      = 42,
01091         GSM48_CC_CAUSE_ACC_INF_DISCARD  = 43,
01092         GSM48_CC_CAUSE_REQ_CHAN_UNAVAIL = 44,
01093         GSM48_CC_CAUSE_RESOURCE_UNAVAIL = 47,
01094         GSM48_CC_CAUSE_QOS_UNAVAIL      = 49,
01095         GSM48_CC_CAUSE_REQ_FAC_NOT_SUBSC= 50,
01096         GSM48_CC_CAUSE_INC_BARRED_CUG   = 55,
01097         GSM48_CC_CAUSE_BEARER_CAP_UNAUTH= 57,
01098         GSM48_CC_CAUSE_BEARER_CA_UNAVAIL= 58,
01099         GSM48_CC_CAUSE_SERV_OPT_UNAVAIL = 63,
01100         GSM48_CC_CAUSE_BEARERSERV_UNIMPL= 65,
01101         GSM48_CC_CAUSE_ACM_GE_ACM_MAX   = 68,
01102         GSM48_CC_CAUSE_REQ_FAC_NOTIMPL  = 69,
01103         GSM48_CC_CAUSE_RESTR_BCAP_AVAIL = 70,
01104         GSM48_CC_CAUSE_SERV_OPT_UNIMPL  = 79,
01105         GSM48_CC_CAUSE_INVAL_TRANS_ID   = 81,
01106         GSM48_CC_CAUSE_USER_NOT_IN_CUG  = 87,
01107         GSM48_CC_CAUSE_INCOMPAT_DEST    = 88,
01108         GSM48_CC_CAUSE_INVAL_TRANS_NET  = 91,
01109         GSM48_CC_CAUSE_SEMANTIC_INCORR  = 95,
01110         GSM48_CC_CAUSE_INVAL_MAND_INF   = 96,
01111         GSM48_CC_CAUSE_MSGTYPE_NOTEXIST = 97,
01112         GSM48_CC_CAUSE_MSGTYPE_INCOMPAT = 98,
01113         GSM48_CC_CAUSE_IE_NOTEXIST      = 99,
01114         GSM48_CC_CAUSE_COND_IE_ERR      = 100,
01115         GSM48_CC_CAUSE_MSG_INCOMP_STATE = 101,
01116         GSM48_CC_CAUSE_RECOVERY_TIMER   = 102,
01117         GSM48_CC_CAUSE_PROTO_ERR        = 111,
01118         GSM48_CC_CAUSE_INTERWORKING     = 127,
01119 };
01120 
01121 /* Annex G, GSM specific cause values for mobility management */
01122 enum gsm48_reject_value {
01123         GSM48_REJECT_IMSI_UNKNOWN_IN_HLR        = 2,
01124         GSM48_REJECT_ILLEGAL_MS                 = 3,
01125         GSM48_REJECT_IMSI_UNKNOWN_IN_VLR        = 4,
01126         GSM48_REJECT_IMEI_NOT_ACCEPTED          = 5,
01127         GSM48_REJECT_ILLEGAL_ME                 = 6,
01128         GSM48_REJECT_PLMN_NOT_ALLOWED           = 11,
01129         GSM48_REJECT_LOC_NOT_ALLOWED            = 12,
01130         GSM48_REJECT_ROAMING_NOT_ALLOWED        = 13,
01131         GSM48_REJECT_NETWORK_FAILURE            = 17,
01132         GSM48_REJECT_CONGESTION                 = 22,
01133         GSM48_REJECT_SRV_OPT_NOT_SUPPORTED      = 32,
01134         GSM48_REJECT_RQD_SRV_OPT_NOT_SUPPORTED  = 33,
01135         GSM48_REJECT_SRV_OPT_TMP_OUT_OF_ORDER   = 34,
01136         GSM48_REJECT_CALL_CAN_NOT_BE_IDENTIFIED = 38,
01137         GSM48_REJECT_INCORRECT_MESSAGE          = 95,
01138         GSM48_REJECT_INVALID_MANDANTORY_INF     = 96,
01139         GSM48_REJECT_MSG_TYPE_NOT_IMPLEMENTED   = 97,
01140         GSM48_REJECT_MSG_TYPE_NOT_COMPATIBLE    = 98,
01141         GSM48_REJECT_INF_ELEME_NOT_IMPLEMENTED  = 99,
01142         GSM48_REJECT_CONDTIONAL_IE_ERROR        = 100,
01143         GSM48_REJECT_MSG_NOT_COMPATIBLE         = 101,
01144         GSM48_REJECT_PROTOCOL_ERROR             = 111,
01145 
01146         /* according to G.6 Additional cause codes for GMM */
01147         GSM48_REJECT_GPRS_NOT_ALLOWED           = 7,
01148         GSM48_REJECT_SERVICES_NOT_ALLOWED       = 8,
01149         GSM48_REJECT_MS_IDENTITY_NOT_DERVIVABLE = 9,
01150         GSM48_REJECT_IMPLICITLY_DETACHED        = 10,
01151         GSM48_REJECT_GPRS_NOT_ALLOWED_IN_PLMN   = 14,
01152         GSM48_REJECT_MSC_TMP_NOT_REACHABLE      = 16,
01153 };
01154 
01155 enum chreq_type {
01156         CHREQ_T_EMERG_CALL,
01157         CHREQ_T_CALL_REEST_TCH_F,
01158         CHREQ_T_CALL_REEST_TCH_H,
01159         CHREQ_T_CALL_REEST_TCH_H_DBL,
01160         CHREQ_T_SDCCH,
01161         CHREQ_T_TCH_F,
01162         CHREQ_T_VOICE_CALL_TCH_H,
01163         CHREQ_T_DATA_CALL_TCH_H,
01164         CHREQ_T_LOCATION_UPD,
01165         CHREQ_T_PAG_R_ANY_NECI0,
01166         CHREQ_T_PAG_R_ANY_NECI1,
01167         CHREQ_T_PAG_R_TCH_F,
01168         CHREQ_T_PAG_R_TCH_FH,
01169         CHREQ_T_LMU,
01170         CHREQ_T_RESERVED_SDCCH,
01171         CHREQ_T_RESERVED_IGNORE,
01172 };
01173 
01174 /* Chapter 11.3 */
01175 #define GSM48_T301      180, 0
01176 #define GSM48_T303      30, 0
01177 #define GSM48_T305      30, 0
01178 #define GSM48_T306      30, 0
01179 #define GSM48_T308      10, 0
01180 #define GSM48_T310      180, 0
01181 #define GSM48_T313      30, 0
01182 #define GSM48_T323      30, 0
01183 #define GSM48_T331      30, 0
01184 #define GSM48_T333      30, 0
01185 #define GSM48_T334      25, 0 /* min 15 */
01186 #define GSM48_T338      30, 0
01187 #define GSM48_T303_MS   30, 0
01188 #define GSM48_T305_MS   30, 0
01189 #define GSM48_T308_MS   30, 0
01190 #define GSM48_T310_MS   30, 0
01191 #define GSM48_T313_MS   30, 0
01192 #define GSM48_T323_MS   30, 0
01193 #define GSM48_T332_MS   30, 0
01194 #define GSM48_T335_MS   30, 0
01195 
01196 /* Chapter 5.1.2.2 */
01197 #define GSM_CSTATE_NULL                 0
01198 #define GSM_CSTATE_INITIATED            1
01199 #define GSM_CSTATE_MM_CONNECTION_PEND   2 /* see 10.5.4.6 */
01200 #define GSM_CSTATE_MO_CALL_PROC         3
01201 #define GSM_CSTATE_CALL_DELIVERED       4
01202 #define GSM_CSTATE_CALL_PRESENT         6
01203 #define GSM_CSTATE_CALL_RECEIVED        7
01204 #define GSM_CSTATE_CONNECT_REQUEST      8
01205 #define GSM_CSTATE_MO_TERM_CALL_CONF    9
01206 #define GSM_CSTATE_ACTIVE               10
01207 #define GSM_CSTATE_DISCONNECT_REQ       12
01208 #define GSM_CSTATE_DISCONNECT_IND       12
01209 #define GSM_CSTATE_RELEASE_REQ          19
01210 #define GSM_CSTATE_MO_ORIG_MODIFY       26
01211 #define GSM_CSTATE_MO_TERM_MODIFY       27
01212 #define GSM_CSTATE_CONNECT_IND          28
01213 
01214 #define SBIT(a) (1 << a)
01215 #define ALL_STATES 0xffffffff
01216 
01217 /* Table 10.5.3/3GPP TS 04.08: Location Area Identification information element */
01218 #define GSM_LAC_RESERVED_DETACHED       0x0
01219 #define GSM_LAC_RESERVED_ALL_BTS        0xfffe
01220 
01221 /* GSM 04.08 Bearer Capability: Information Transfer Capability */
01222 enum gsm48_bcap_itcap {
01223         GSM48_BCAP_ITCAP_SPEECH         = 0,
01224         GSM48_BCAP_ITCAP_UNR_DIG_INF    = 1,
01225         GSM48_BCAP_ITCAP_3k1_AUDIO      = 2,
01226         GSM48_BCAP_ITCAP_FAX_G3         = 3,
01227         GSM48_BCAP_ITCAP_OTHER          = 5,
01228         GSM48_BCAP_ITCAP_RESERVED       = 7,
01229 };
01230 
01231 /* GSM 04.08 Bearer Capability: Transfer Mode */
01232 enum gsm48_bcap_tmod {
01233         GSM48_BCAP_TMOD_CIRCUIT         = 0,
01234         GSM48_BCAP_TMOD_PACKET          = 1,
01235 };
01236 
01237 /* GSM 04.08 Bearer Capability: Coding Standard */
01238 enum gsm48_bcap_coding {
01239         GSM48_BCAP_CODING_GSM_STD       = 0,
01240 };
01241 
01242 /* GSM 04.08 Bearer Capability: Radio Channel Requirements */
01243 enum gsm48_bcap_rrq {
01244         GSM48_BCAP_RRQ_FR_ONLY  = 1,
01245         GSM48_BCAP_RRQ_DUAL_HR  = 2,
01246         GSM48_BCAP_RRQ_DUAL_FR  = 3,
01247 };
01248 
01249 /* GSM 04.08 Bearer Capability: Rate Adaption */
01250 enum gsm48_bcap_ra {
01251         GSM48_BCAP_RA_NONE      = 0,
01252         GSM48_BCAP_RA_V110_X30  = 1,
01253         GSM48_BCAP_RA_X31       = 2,
01254         GSM48_BCAP_RA_OTHER     = 3,
01255 };
01256 
01257 /* GSM 04.08 Bearer Capability: Signalling access protocol */
01258 enum gsm48_bcap_sig_access {
01259         GSM48_BCAP_SA_I440_I450 = 1,
01260         GSM48_BCAP_SA_X21       = 2,
01261         GSM48_BCAP_SA_X28_DP_IN = 3,
01262         GSM48_BCAP_SA_X28_DP_UN = 4,
01263         GSM48_BCAP_SA_X28_NDP   = 5,
01264         GSM48_BCAP_SA_X32       = 6,
01265 };
01266 
01267 /* GSM 04.08 Bearer Capability: User Rate */
01268 enum gsm48_bcap_user_rate {
01269         GSM48_BCAP_UR_300       = 1,
01270         GSM48_BCAP_UR_1200      = 2,
01271         GSM48_BCAP_UR_2400      = 3,
01272         GSM48_BCAP_UR_4800      = 4,
01273         GSM48_BCAP_UR_9600      = 5,
01274         GSM48_BCAP_UR_12000     = 6,
01275         GSM48_BCAP_UR_1200_75   = 7,
01276 };
01277 
01278 /* GSM 04.08 Bearer Capability: Parity */
01279 enum gsm48_bcap_parity {
01280         GSM48_BCAP_PAR_ODD      = 0,
01281         GSM48_BCAP_PAR_EVEN     = 2,
01282         GSM48_BCAP_PAR_NONE     = 3,
01283         GSM48_BCAP_PAR_ZERO     = 4,
01284         GSM48_BCAP_PAR_ONE      = 5,
01285 };
01286 
01287 /* GSM 04.08 Bearer Capability: Intermediate Rate */
01288 enum gsm48_bcap_interm_rate {
01289         GSM48_BCAP_IR_8k        = 2,
01290         GSM48_BCAP_IR_16k       = 3,
01291 };
01292 
01293 /* GSM 04.08 Bearer Capability: Transparency */
01294 enum gsm48_bcap_transp {
01295         GSM48_BCAP_TR_TRANSP    = 0,
01296         GSM48_BCAP_TR_RLP       = 1,
01297         GSM48_BCAP_TR_TR_PREF   = 2,
01298         GSM48_BCAP_TR_RLP_PREF  = 3,
01299 };
01300 
01301 /* GSM 04.08 Bearer Capability: Modem Type */
01302 enum gsm48_bcap_modem_type {
01303         GSM48_BCAP_MT_NONE      = 0,
01304         GSM48_BCAP_MT_V21       = 1,
01305         GSM48_BCAP_MT_V22       = 2,
01306         GSM48_BCAP_MT_V22bis    = 3,
01307         GSM48_BCAP_MT_V23       = 4,
01308         GSM48_BCAP_MT_V26ter    = 5,
01309         GSM48_BCAP_MT_V32       = 6,
01310         GSM48_BCAP_MT_UNDEF     = 7,
01311         GSM48_BCAP_MT_AUTO_1    = 8,
01312 };
01313 
01314 /* GSM 04.08 Bearer Capability: Speech Version Indication */
01315 enum gsm48_bcap_speech_ver {
01316         GSM48_BCAP_SV_FR        = 0,
01317         GSM48_BCAP_SV_HR        = 1,
01318         GSM48_BCAP_SV_EFR       = 2,
01319         GSM48_BCAP_SV_AMR_F     = 4,
01320         GSM48_BCAP_SV_AMR_H     = 5,
01321 };
01322 
01323 #define GSM48_TMSI_LEN  5
01324 #define GSM48_MID_TMSI_LEN      (GSM48_TMSI_LEN + 2)
01325 #define GSM48_MI_SIZE 32
01326 
01327 /* Chapter 10.4.4.15 */
01328 struct gsm48_ra_id {
01329         uint8_t digits[3];      /* MCC + MNC BCD digits */
01330         uint16_t lac;           /* Location Area Code */
01331         uint8_t rac;            /* Routing Area Code */
01332 } __attribute__ ((packed));
01333 
01334 #define GSM48_CELL_CHAN_DESC_SIZE       16
01335 
01336 #define GSM_MACBLOCK_LEN        23
01337 #define GSM_MACBLOCK_PADDING    0x2b