bdd0ff80a4b8b294cdd079e5410cdc02d3f60152
[osmocom-bb.git] / include / osmocore / protocol / gsm_04_08.h
1 #ifndef PROTO_GSM_04_08_H
2 #define PROTO_GSM_04_08_H
3
4 #include <stdint.h>
5
6 /* GSM TS 04.08  definitions */
7 struct gsm_lchan;
8
9 struct gsm48_classmark1 {
10         uint8_t spare:1,
11                  rev_level:2,
12                  es_ind:1,
13                  a5_1:1,
14                  pwr_lev:3;
15 } __attribute__ ((packed));
16
17 /* Chapter 10.5.2.5 */
18 struct gsm48_chan_desc {
19         uint8_t chan_nr;
20         union {
21                 struct {
22                         uint8_t maio_high:4,
23                                  h:1,
24                                  tsc:3;
25                         uint8_t hsn:6,
26                                  maio_low:2;
27                 } h1;
28                 struct {
29                         uint8_t arfcn_high:2,
30                                  spare:2,
31                                  h:1,
32                                  tsc:3;
33                         uint8_t arfcn_low;
34                 } h0;
35         };
36 } __attribute__ ((packed));
37
38 /* Chapter 10.5.2.21aa */
39 struct gsm48_multi_rate_conf {
40         uint8_t smod : 2,
41                  spare: 1,
42                  icmi : 1,
43                  nscb : 1,
44                  ver : 3;
45         uint8_t m4_75 : 1,
46                  m5_15 : 1,
47                  m5_90 : 1,
48                  m6_70 : 1,
49                  m7_40 : 1,
50                  m7_95 : 1,
51                  m10_2 : 1,
52                  m12_2 : 1;
53 } __attribute__((packed));
54
55 /* Chapter 10.5.2.30 */
56 struct gsm48_req_ref {
57         uint8_t ra;
58         uint8_t t3_high:3,
59                  t1:5;
60         uint8_t t2:5,
61                  t3_low:3;
62 } __attribute__ ((packed));
63
64 /*
65  * Chapter 9.1.5/9.1.6
66  *
67  * For 9.1.6 the chan_desc has the meaning of 10.5.2.5a
68  */
69 struct gsm48_chan_mode_modify {
70         struct gsm48_chan_desc chan_desc;
71         uint8_t mode;
72 } __attribute__ ((packed));
73
74 enum gsm48_chan_mode {
75         GSM48_CMODE_SIGN        = 0x00,
76         GSM48_CMODE_SPEECH_V1   = 0x01,
77         GSM48_CMODE_SPEECH_EFR  = 0x21,
78         GSM48_CMODE_SPEECH_AMR  = 0x41,
79         GSM48_CMODE_DATA_14k5   = 0x0f,
80         GSM48_CMODE_DATA_12k0   = 0x03,
81         GSM48_CMODE_DATA_6k0    = 0x0b,
82         GSM48_CMODE_DATA_3k6    = 0x23,
83 };
84
85 /* Chapter 9.1.2 */
86 struct gsm48_ass_cmd {
87         /* Semantic is from 10.5.2.5a */
88         struct gsm48_chan_desc chan_desc;
89         uint8_t power_command;
90         uint8_t data[0];
91 } __attribute__((packed));
92
93 /* Chapter 10.5.2.2 */
94 struct gsm48_cell_desc {
95         uint8_t bcc:3,
96                  ncc:3,
97                  arfcn_hi:2;
98         uint8_t arfcn_lo;
99 } __attribute__((packed));
100
101 /* Chapter 9.1.15 */
102 struct gsm48_ho_cmd {
103         struct gsm48_cell_desc cell_desc;
104         struct gsm48_chan_desc chan_desc;
105         uint8_t ho_ref;
106         uint8_t power_command;
107         uint8_t data[0];
108 } __attribute__((packed));
109
110 /* Chapter 9.1.18 */
111 struct gsm48_imm_ass {
112         uint8_t l2_plen;
113         uint8_t proto_discr;
114         uint8_t msg_type;
115         uint8_t page_mode;
116         struct gsm48_chan_desc chan_desc;
117         struct gsm48_req_ref req_ref;
118         uint8_t timing_advance;
119         uint8_t mob_alloc_len;
120         uint8_t mob_alloc[0];
121 } __attribute__ ((packed));
122
123 /* Chapter 9.1.25 */
124 struct gsm48_pag_resp {
125         uint8_t spare:4,
126                  key_seq:4;
127         uint32_t classmark2;
128         uint8_t mi_len;
129         uint8_t mi[0];
130 } __attribute__ ((packed));
131
132 /* Chapter 10.5.1.3 */
133 struct gsm48_loc_area_id {
134         uint8_t digits[3];      /* BCD! */
135         uint16_t lac;
136 } __attribute__ ((packed));
137
138 /* Section 9.2.2 */
139 struct gsm48_auth_req {
140         uint8_t key_seq:4,
141                  spare:4;
142         uint8_t rand[16];
143 } __attribute__ ((packed));
144
145 /* Section 9.2.3 */
146 struct gsm48_auth_resp {
147         uint8_t sres[4];
148 } __attribute__ ((packed));
149
150 /* Section 9.2.15 */
151 struct gsm48_loc_upd_req {
152         uint8_t type:4,
153                  key_seq:4;
154         struct gsm48_loc_area_id lai;
155         struct gsm48_classmark1 classmark1;
156         uint8_t mi_len;
157         uint8_t mi[0];
158 } __attribute__ ((packed));
159
160 /* Section 10.1 */
161 struct gsm48_hdr {
162         uint8_t proto_discr;
163         uint8_t msg_type;
164         uint8_t data[0];
165 } __attribute__ ((packed));
166
167 /* Section 9.1.3x System information Type header */
168 struct gsm48_system_information_type_header {
169         uint8_t l2_plen;
170         uint8_t rr_protocol_discriminator :4,
171                 skip_indicator:4; 
172         uint8_t system_information;
173 } __attribute__ ((packed));
174
175 struct gsm48_rach_control {
176         uint8_t re :1,
177                  cell_bar :1,
178                  tx_integer :4,
179                  max_trans :2;
180         uint8_t t2;
181         uint8_t t3;
182 } __attribute__ ((packed));
183
184 /* Section 10.5.2.4 Cell Selection Parameters */
185 struct gsm48_cell_sel_par {
186         uint8_t ms_txpwr_max_ccch:5,    /* GSM 05.08 MS-TXPWR-MAX-CCCH */
187                  cell_resel_hyst:3;     /* GSM 05.08 CELL-RESELECT-HYSTERESIS */
188         uint8_t rxlev_acc_min:6,        /* GSM 05.08 RXLEV-ACCESS-MIN */
189                  neci:1,
190                  acs:1;
191 } __attribute__ ((packed));
192
193 /* Section 10.5.2.11 Control Channel Description , Figure 10.5.33 */
194 struct gsm48_control_channel_descr {
195         uint8_t ccch_conf :3,
196                 bs_ag_blks_res :3,
197                 att :1,
198                 spare1 :1;
199         uint8_t bs_pa_mfrms : 3,
200                 spare2 :5;
201         uint8_t t3212;
202 } __attribute__ ((packed));
203
204 struct gsm48_cell_options {
205         uint8_t radio_link_timeout:4,
206                  dtx:2,
207                  pwrc:1,
208                  spare:1;
209 } __attribute__ ((packed));
210
211 /* Section 9.2.9 CM service request */
212 struct gsm48_service_request {
213         uint8_t cm_service_type : 4,
214                  cipher_key_seq  : 4;
215         /* length + 3 bytes */
216         uint32_t classmark;
217         uint8_t mi_len;
218         uint8_t mi[0];
219         /* optional priority level */
220 } __attribute__ ((packed));
221
222 /* Section 9.1.31 System information Type 1 */
223 struct gsm48_system_information_type_1 {
224         struct gsm48_system_information_type_header header;
225         uint8_t cell_channel_description[16];
226         struct gsm48_rach_control rach_control;
227         uint8_t rest_octets[0]; /* NCH position on the CCCH */
228 } __attribute__ ((packed));
229
230 /* Section 9.1.32 System information Type 2 */
231 struct gsm48_system_information_type_2 {
232         struct gsm48_system_information_type_header header;
233         uint8_t bcch_frequency_list[16];
234         uint8_t ncc_permitted;
235         struct gsm48_rach_control rach_control;
236 } __attribute__ ((packed));
237
238 /* Section 9.1.35 System information Type 3 */
239 struct gsm48_system_information_type_3 {
240         struct gsm48_system_information_type_header header;
241         uint16_t cell_identity;
242         struct gsm48_loc_area_id lai;
243         struct gsm48_control_channel_descr control_channel_desc;
244         struct gsm48_cell_options cell_options;
245         struct gsm48_cell_sel_par cell_sel_par;
246         struct gsm48_rach_control rach_control;
247         uint8_t rest_octets[0];
248 } __attribute__ ((packed));
249
250 /* Section 9.1.36 System information Type 4 */
251 struct gsm48_system_information_type_4 {
252         struct gsm48_system_information_type_header header;
253         struct gsm48_loc_area_id lai;
254         struct gsm48_cell_sel_par cell_sel_par;
255         struct gsm48_rach_control rach_control;
256         /*      optional CBCH conditional CBCH... followed by
257                 mandantory SI 4 Reset Octets
258          */
259         uint8_t data[0];
260 } __attribute__ ((packed));
261
262 /* Section 9.1.37 System information Type 5 */
263 struct gsm48_system_information_type_5 {
264         uint8_t rr_protocol_discriminator :4,
265                 skip_indicator:4; 
266         uint8_t system_information;
267         uint8_t bcch_frequency_list[16];
268 } __attribute__ ((packed));
269
270 /* Section 9.1.40 System information Type 6 */
271 struct gsm48_system_information_type_6 {
272         uint8_t rr_protocol_discriminator :4,
273                 skip_indicator:4; 
274         uint8_t system_information;
275         uint16_t cell_identity;
276         struct gsm48_loc_area_id lai;
277         struct gsm48_cell_options cell_options;
278         uint8_t ncc_permitted;
279         uint8_t rest_octets[0];
280 } __attribute__ ((packed));
281
282 /* Section 9.1.43a System Information type 13 */
283 struct gsm48_system_information_type_13 {
284         struct gsm48_system_information_type_header header;
285         uint8_t rest_octets[0];
286 } __attribute__ ((packed));
287
288 /* Section 9.2.12 IMSI Detach Indication */
289 struct gsm48_imsi_detach_ind {
290         struct gsm48_classmark1 classmark1;
291         uint8_t mi_len;
292         uint8_t mi[0];
293 } __attribute__ ((packed));
294
295 /* Section 10.2 + GSM 04.07 12.2.3.1.1 */
296 #define GSM48_PDISC_GROUP_CC    0x00
297 #define GSM48_PDISC_BCAST_CC    0x01
298 #define GSM48_PDISC_PDSS1       0x02
299 #define GSM48_PDISC_CC          0x03
300 #define GSM48_PDISC_PDSS2       0x04
301 #define GSM48_PDISC_MM          0x05
302 #define GSM48_PDISC_RR          0x06
303 #define GSM48_PDISC_MM_GPRS     0x08
304 #define GSM48_PDISC_SMS         0x09
305 #define GSM48_PDISC_SM_GPRS     0x0a
306 #define GSM48_PDISC_NC_SS       0x0b
307 #define GSM48_PDISC_LOC         0x0c
308 #define GSM48_PDISC_MASK        0x0f
309 #define GSM48_PDISC_USSD        0x11
310
311 /* Section 10.4 */
312 #define GSM48_MT_RR_INIT_REQ            0x3c
313 #define GSM48_MT_RR_ADD_ASS             0x3b
314 #define GSM48_MT_RR_IMM_ASS             0x3f
315 #define GSM48_MT_RR_IMM_ASS_EXT         0x39
316 #define GSM48_MT_RR_IMM_ASS_REJ         0x3a
317
318 #define GSM48_MT_RR_CIPH_M_CMD          0x35
319 #define GSM48_MT_RR_CIPH_M_COMPL        0x32
320
321 #define GSM48_MT_RR_CFG_CHG_CMD         0x30
322 #define GSM48_MT_RR_CFG_CHG_ACK         0x31
323 #define GSM48_MT_RR_CFG_CHG_REJ         0x33
324
325 #define GSM48_MT_RR_ASS_CMD             0x2e
326 #define GSM48_MT_RR_ASS_COMPL           0x29
327 #define GSM48_MT_RR_ASS_FAIL            0x2f
328 #define GSM48_MT_RR_HANDO_CMD           0x2b
329 #define GSM48_MT_RR_HANDO_COMPL         0x2c
330 #define GSM48_MT_RR_HANDO_FAIL          0x28
331 #define GSM48_MT_RR_HANDO_INFO          0x2d
332
333 #define GSM48_MT_RR_CELL_CHG_ORDER      0x08
334 #define GSM48_MT_RR_PDCH_ASS_CMD        0x23
335
336 #define GSM48_MT_RR_CHAN_REL            0x0d
337 #define GSM48_MT_RR_PART_REL            0x0a
338 #define GSM48_MT_RR_PART_REL_COMP       0x0f
339
340 #define GSM48_MT_RR_PAG_REQ_1           0x21
341 #define GSM48_MT_RR_PAG_REQ_2           0x22
342 #define GSM48_MT_RR_PAG_REQ_3           0x24
343 #define GSM48_MT_RR_PAG_RESP            0x27
344 #define GSM48_MT_RR_NOTIF_NCH           0x20
345 #define GSM48_MT_RR_NOTIF_FACCH         0x25
346 #define GSM48_MT_RR_NOTIF_RESP          0x26
347
348 #define GSM48_MT_RR_SYSINFO_8           0x18
349 #define GSM48_MT_RR_SYSINFO_1           0x19
350 #define GSM48_MT_RR_SYSINFO_2           0x1a
351 #define GSM48_MT_RR_SYSINFO_3           0x1b
352 #define GSM48_MT_RR_SYSINFO_4           0x1c
353 #define GSM48_MT_RR_SYSINFO_5           0x1d
354 #define GSM48_MT_RR_SYSINFO_6           0x1e
355 #define GSM48_MT_RR_SYSINFO_7           0x1f
356
357 #define GSM48_MT_RR_SYSINFO_2bis        0x02
358 #define GSM48_MT_RR_SYSINFO_2ter        0x03
359 #define GSM48_MT_RR_SYSINFO_5bis        0x05
360 #define GSM48_MT_RR_SYSINFO_5ter        0x06
361 #define GSM48_MT_RR_SYSINFO_9           0x04
362 #define GSM48_MT_RR_SYSINFO_13          0x00
363
364 #define GSM48_MT_RR_SYSINFO_16          0x3d
365 #define GSM48_MT_RR_SYSINFO_17          0x3e
366
367 #define GSM48_MT_RR_CHAN_MODE_MODIF     0x10
368 #define GSM48_MT_RR_STATUS              0x12
369 #define GSM48_MT_RR_CHAN_MODE_MODIF_ACK 0x17
370 #define GSM48_MT_RR_FREQ_REDEF          0x14
371 #define GSM48_MT_RR_MEAS_REP            0x15
372 #define GSM48_MT_RR_CLSM_CHG            0x16
373 #define GSM48_MT_RR_CLSM_ENQ            0x13
374 #define GSM48_MT_RR_EXT_MEAS_REP        0x36
375 #define GSM48_MT_RR_EXT_MEAS_REP_ORD    0x37
376 #define GSM48_MT_RR_GPRS_SUSP_REQ       0x34
377
378 #define GSM48_MT_RR_VGCS_UPL_GRANT      0x08
379 #define GSM48_MT_RR_UPLINK_RELEASE      0x0e
380 #define GSM48_MT_RR_UPLINK_FREE         0x0c
381 #define GSM48_MT_RR_UPLINK_BUSY         0x2a
382 #define GSM48_MT_RR_TALKER_IND          0x11
383
384 #define GSM48_MT_RR_APP_INFO            0x38
385
386 /* Table 10.2/3GPP TS 04.08 */
387 #define GSM48_MT_MM_IMSI_DETACH_IND     0x01
388 #define GSM48_MT_MM_LOC_UPD_ACCEPT      0x02
389 #define GSM48_MT_MM_LOC_UPD_REJECT      0x04
390 #define GSM48_MT_MM_LOC_UPD_REQUEST     0x08
391
392 #define GSM48_MT_MM_AUTH_REJ            0x11
393 #define GSM48_MT_MM_AUTH_REQ            0x12
394 #define GSM48_MT_MM_AUTH_RESP           0x14
395 #define GSM48_MT_MM_ID_REQ              0x18
396 #define GSM48_MT_MM_ID_RESP             0x19
397 #define GSM48_MT_MM_TMSI_REALL_CMD      0x1a
398 #define GSM48_MT_MM_TMSI_REALL_COMPL    0x1b
399
400 #define GSM48_MT_MM_CM_SERV_ACC         0x21
401 #define GSM48_MT_MM_CM_SERV_REJ         0x22
402 #define GSM48_MT_MM_CM_SERV_ABORT       0x23
403 #define GSM48_MT_MM_CM_SERV_REQ         0x24
404 #define GSM48_MT_MM_CM_SERV_PROMPT      0x25
405 #define GSM48_MT_MM_CM_REEST_REQ        0x28
406 #define GSM48_MT_MM_ABORT               0x29
407
408 #define GSM48_MT_MM_NULL                0x30
409 #define GSM48_MT_MM_STATUS              0x31
410 #define GSM48_MT_MM_INFO                0x32
411
412 /* Table 10.3/3GPP TS 04.08 */
413 #define GSM48_MT_CC_ALERTING            0x01
414 #define GSM48_MT_CC_CALL_CONF           0x08
415 #define GSM48_MT_CC_CALL_PROC           0x02
416 #define GSM48_MT_CC_CONNECT             0x07
417 #define GSM48_MT_CC_CONNECT_ACK         0x0f
418 #define GSM48_MT_CC_EMERG_SETUP         0x0e
419 #define GSM48_MT_CC_PROGRESS            0x03
420 #define GSM48_MT_CC_ESTAB               0x04
421 #define GSM48_MT_CC_ESTAB_CONF          0x06
422 #define GSM48_MT_CC_RECALL              0x0b
423 #define GSM48_MT_CC_START_CC            0x09
424 #define GSM48_MT_CC_SETUP               0x05
425
426 #define GSM48_MT_CC_MODIFY              0x17
427 #define GSM48_MT_CC_MODIFY_COMPL        0x1f
428 #define GSM48_MT_CC_MODIFY_REJECT       0x13
429 #define GSM48_MT_CC_USER_INFO           0x10
430 #define GSM48_MT_CC_HOLD                0x18
431 #define GSM48_MT_CC_HOLD_ACK            0x19
432 #define GSM48_MT_CC_HOLD_REJ            0x1a
433 #define GSM48_MT_CC_RETR                0x1c
434 #define GSM48_MT_CC_RETR_ACK            0x1d
435 #define GSM48_MT_CC_RETR_REJ            0x1e
436
437 #define GSM48_MT_CC_DISCONNECT          0x25
438 #define GSM48_MT_CC_RELEASE             0x2d
439 #define GSM48_MT_CC_RELEASE_COMPL       0x2a
440
441 #define GSM48_MT_CC_CONG_CTRL           0x39
442 #define GSM48_MT_CC_NOTIFY              0x3e
443 #define GSM48_MT_CC_STATUS              0x3d
444 #define GSM48_MT_CC_STATUS_ENQ          0x34
445 #define GSM48_MT_CC_START_DTMF          0x35
446 #define GSM48_MT_CC_STOP_DTMF           0x31
447 #define GSM48_MT_CC_STOP_DTMF_ACK       0x32
448 #define GSM48_MT_CC_START_DTMF_ACK      0x36
449 #define GSM48_MT_CC_START_DTMF_REJ      0x37
450 #define GSM48_MT_CC_FACILITY            0x3a
451
452 /* FIXME: Table 10.4 / 10.4a (GPRS) */
453
454 /* Section 10.5.2.26, Table 10.5.64 */
455 #define GSM48_PM_MASK           0x03
456 #define GSM48_PM_NORMAL         0x00
457 #define GSM48_PM_EXTENDED       0x01
458 #define GSM48_PM_REORG          0x02
459 #define GSM48_PM_SAME           0x03
460
461 /* Chapter 10.5.3.5 / Table 10.5.93 */
462 #define GSM48_LUPD_NORMAL       0x0
463 #define GSM48_LUPD_PERIODIC     0x1
464 #define GSM48_LUPD_IMSI_ATT     0x2
465 #define GSM48_LUPD_RESERVED     0x3
466
467 /* Table 10.5.4 */
468 #define GSM_MI_TYPE_MASK        0x07
469 #define GSM_MI_TYPE_NONE        0x00
470 #define GSM_MI_TYPE_IMSI        0x01
471 #define GSM_MI_TYPE_IMEI        0x02
472 #define GSM_MI_TYPE_IMEISV      0x03
473 #define GSM_MI_TYPE_TMSI        0x04
474 #define GSM_MI_ODD              0x08
475
476 #define GSM48_IE_MUL_RATE_CFG   0x03    /* 10.5.2.21aa */
477 #define GSM48_IE_MOBILE_ID      0x17
478 #define GSM48_IE_NAME_LONG      0x43    /* 10.5.3.5a */
479 #define GSM48_IE_NAME_SHORT     0x45    /* 10.5.3.5a */
480 #define GSM48_IE_UTC            0x46    /* 10.5.3.8 */
481 #define GSM48_IE_NET_TIME_TZ    0x47    /* 10.5.3.9 */
482 #define GSM48_IE_LSA_IDENT      0x48    /* 10.5.3.11 */
483
484 #define GSM48_IE_BEARER_CAP     0x04    /* 10.5.4.5 */
485 #define GSM48_IE_CAUSE          0x08    /* 10.5.4.11 */
486 #define GSM48_IE_CC_CAP         0x15    /* 10.5.4.5a */
487 #define GSM48_IE_ALERT          0x19    /* 10.5.4.26 */
488 #define GSM48_IE_FACILITY       0x1c    /* 10.5.4.15 */
489 #define GSM48_IE_PROGR_IND      0x1e    /* 10.5.4.21 */
490 #define GSM48_IE_AUX_STATUS     0x24    /* 10.5.4.4 */
491 #define GSM48_IE_NOTIFY         0x27    /* 10.5.4.20 */
492 #define GSM48_IE_KPD_FACILITY   0x2c    /* 10.5.4.17 */
493 #define GSM48_IE_SIGNAL         0x34    /* 10.5.4.23 */
494 #define GSM48_IE_CONN_BCD       0x4c    /* 10.5.4.13 */
495 #define GSM48_IE_CONN_SUB       0x4d    /* 10.5.4.14 */
496 #define GSM48_IE_CALLING_BCD    0x5c    /* 10.5.4.9 */
497 #define GSM48_IE_CALLING_SUB    0x5d    /* 10.5.4.10 */
498 #define GSM48_IE_CALLED_BCD     0x5e    /* 10.5.4.7 */
499 #define GSM48_IE_CALLED_SUB     0x6d    /* 10.5.4.8 */
500 #define GSM48_IE_REDIR_BCD      0x74    /* 10.5.4.21a */
501 #define GSM48_IE_REDIR_SUB      0x75    /* 10.5.4.21b */
502 #define GSM48_IE_LOWL_COMPAT    0x7c    /* 10.5.4.18 */
503 #define GSM48_IE_HIGHL_COMPAT   0x7d    /* 10.5.4.16 */
504 #define GSM48_IE_USER_USER      0x7e    /* 10.5.4.25 */
505 #define GSM48_IE_SS_VERS        0x7f    /* 10.5.4.24 */
506 #define GSM48_IE_MORE_DATA      0xa0    /* 10.5.4.19 */
507 #define GSM48_IE_CLIR_SUPP      0xa1    /* 10.5.4.11a */
508 #define GSM48_IE_CLIR_INVOC     0xa2    /* 10.5.4.11b */
509 #define GSM48_IE_REV_C_SETUP    0xa3    /* 10.5.4.22a */
510 #define GSM48_IE_REPEAT_CIR     0xd1    /* 10.5.4.22 */
511 #define GSM48_IE_REPEAT_SEQ     0xd3    /* 10.5.4.22 */
512
513 /* Section 10.5.4.11 / Table 10.5.122 */
514 #define GSM48_CAUSE_CS_GSM      0x60
515
516 /* Section 9.1.2 / Table 9.3 */
517 #define GSM48_IE_FRQLIST_AFTER  0x05
518 #define GSM48_IE_CELL_CH_DESC   0x62
519 #define GSM48_IE_MSLOT_DESC     0x10
520 #define GSM48_IE_CHANMODE_1     0x63
521 #define GSM48_IE_CHANMODE_2     0x11
522 #define GSM48_IE_CHANMODE_3     0x13
523 #define GSM48_IE_CHANMODE_4     0x14
524 #define GSM48_IE_CHANMODE_5     0x15
525 #define GSM48_IE_CHANMODE_6     0x16
526 #define GSM48_IE_CHANMODE_7     0x17
527 #define GSM48_IE_CHANMODE_8     0x18
528 #define GSM48_IE_CHANDESC_2     0x64
529 #define GSM48_IE_MA_AFTER       0x72
530 #define GSM48_IE_START_TIME     0x7c
531 #define GSM48_IE_FREQ_L_BEFORE  0x19
532 #define GSM48_IE_CH_DESC_1_BEFORE       0x1c
533 #define GSM48_IE_CH_DESC_2_BEFORE       0x1d
534 #define GSM48_IE_F_CH_SEQ_BEFORE        0x1e
535 #define GSM48_IE_MA_BEFORE      0x21
536 #define GSM48_IE_VGCS_T_MODE_I  0x01
537
538 /* FIXME */
539
540 /* Section 10.5.4.23 / Table 10.5.130 */
541 enum gsm48_signal_val {
542         GSM48_SIGNAL_DIALTONE   = 0x00,
543         GSM48_SIGNAL_RINGBACK   = 0x01,
544         GSM48_SIGNAL_INTERCEPT  = 0x02,
545         GSM48_SIGNAL_NET_CONG   = 0x03,
546         GSM48_SIGNAL_BUSY       = 0x04,
547         GSM48_SIGNAL_CONFIRM    = 0x05,
548         GSM48_SIGNAL_ANSWER     = 0x06,
549         GSM48_SIGNAL_CALL_WAIT  = 0x07,
550         GSM48_SIGNAL_OFF_HOOK   = 0x08,
551         GSM48_SIGNAL_OFF        = 0x3f,
552         GSM48_SIGNAL_ALERT_OFF  = 0x4f,
553 };
554
555 enum gsm48_cause_loc {
556         GSM48_CAUSE_LOC_USER            = 0x00,
557         GSM48_CAUSE_LOC_PRN_S_LU        = 0x01,
558         GSM48_CAUSE_LOC_PUN_S_LU        = 0x02,
559         GSM48_CAUSE_LOC_TRANS_NET       = 0x03,
560         GSM48_CAUSE_LOC_PUN_S_RU        = 0x04,
561         GSM48_CAUSE_LOC_PRN_S_RU        = 0x05,
562         /* not defined */
563         GSM48_CAUSE_LOC_INN_NET         = 0x07,
564         GSM48_CAUSE_LOC_NET_BEYOND      = 0x0a,
565 };
566
567 /* Section 10.5.2.31 RR Cause / Table 10.5.70 */
568 enum gsm48_rr_cause {
569         GSM48_RR_CAUSE_NORMAL           = 0x00,
570         GSM48_RR_CAUSE_ABNORMAL_UNSPEC  = 0x01,
571         GSM48_RR_CAUSE_ABNORMAL_UNACCT  = 0x02,
572         GSM48_RR_CAUSE_ABNORMAL_TIMER   = 0x03,
573         GSM48_RR_CAUSE_ABNORMAL_NOACT   = 0x04,
574         GSM48_RR_CAUSE_PREMPTIVE_REL    = 0x05,
575         GSM48_RR_CAUSE_HNDOVER_IMP      = 0x06,
576         GSM48_RR_CAUSE_CHAN_MODE_UNACCT = 0x07,
577         GSM48_RR_CAUSE_FREQ_NOT_IMPL    = 0x08,
578         GSM48_RR_CAUSE_CALL_CLEARED     = 0x41,
579         GSM48_RR_CAUSE_SEMANT_INCORR    = 0x5f,
580         GSM48_RR_CAUSE_INVALID_MAND_INF = 0x60,
581         GSM48_RR_CAUSE_MSG_TYPE_N       = 0x61,
582         GSM48_RR_CAUSE_MSG_TYPE_N_COMPAT= 0x62,
583         GSM48_RR_CAUSE_COND_IE_ERROR    = 0x64,
584         GSM48_RR_CAUSE_NO_CELL_ALLOC_A  = 0x65,
585         GSM48_RR_CAUSE_PROT_ERROR_UNSPC = 0x6f,
586 };
587
588 /* Section 10.5.4.11 CC Cause / Table 10.5.123 */
589 enum gsm48_cc_cause {
590         GSM48_CC_CAUSE_UNASSIGNED_NR    = 1,
591         GSM48_CC_CAUSE_NO_ROUTE         = 3,
592         GSM48_CC_CAUSE_CHAN_UNACCEPT    = 6,
593         GSM48_CC_CAUSE_OP_DET_BARRING   = 8,
594         GSM48_CC_CAUSE_NORM_CALL_CLEAR  = 16,
595         GSM48_CC_CAUSE_USER_BUSY        = 17,
596         GSM48_CC_CAUSE_USER_NOTRESPOND  = 18,
597         GSM48_CC_CAUSE_USER_ALERTING_NA = 19,
598         GSM48_CC_CAUSE_CALL_REJECTED    = 21,
599         GSM48_CC_CAUSE_NUMBER_CHANGED   = 22,
600         GSM48_CC_CAUSE_PRE_EMPTION      = 25,
601         GSM48_CC_CAUSE_NONSE_USER_CLR   = 26,
602         GSM48_CC_CAUSE_DEST_OOO         = 27,
603         GSM48_CC_CAUSE_INV_NR_FORMAT    = 28,
604         GSM48_CC_CAUSE_FACILITY_REJ     = 29,
605         GSM48_CC_CAUSE_RESP_STATUS_INQ  = 30,
606         GSM48_CC_CAUSE_NORMAL_UNSPEC    = 31,
607         GSM48_CC_CAUSE_NO_CIRCUIT_CHAN  = 34,
608         GSM48_CC_CAUSE_NETWORK_OOO      = 38,
609         GSM48_CC_CAUSE_TEMP_FAILURE     = 41,
610         GSM48_CC_CAUSE_SWITCH_CONG      = 42,
611         GSM48_CC_CAUSE_ACC_INF_DISCARD  = 43,
612         GSM48_CC_CAUSE_REQ_CHAN_UNAVAIL = 44,
613         GSM48_CC_CAUSE_RESOURCE_UNAVAIL = 47,
614         GSM48_CC_CAUSE_QOS_UNAVAIL      = 49,
615         GSM48_CC_CAUSE_REQ_FAC_NOT_SUBSC= 50,
616         GSM48_CC_CAUSE_INC_BARRED_CUG   = 55,
617         GSM48_CC_CAUSE_BEARER_CAP_UNAUTH= 57,
618         GSM48_CC_CAUSE_BEARER_CA_UNAVAIL= 58,
619         GSM48_CC_CAUSE_SERV_OPT_UNAVAIL = 63,
620         GSM48_CC_CAUSE_BEARERSERV_UNIMPL= 65,
621         GSM48_CC_CAUSE_ACM_GE_ACM_MAX   = 68,
622         GSM48_CC_CAUSE_REQ_FAC_NOTIMPL  = 69,
623         GSM48_CC_CAUSE_RESTR_BCAP_AVAIL = 70,
624         GSM48_CC_CAUSE_SERV_OPT_UNIMPL  = 79,
625         GSM48_CC_CAUSE_INVAL_TRANS_ID   = 81,
626         GSM48_CC_CAUSE_USER_NOT_IN_CUG  = 87,
627         GSM48_CC_CAUSE_INCOMPAT_DEST    = 88,
628         GSM48_CC_CAUSE_INVAL_TRANS_NET  = 91,
629         GSM48_CC_CAUSE_SEMANTIC_INCORR  = 95,
630         GSM48_CC_CAUSE_INVAL_MAND_INF   = 96,
631         GSM48_CC_CAUSE_MSGTYPE_NOTEXIST = 97,
632         GSM48_CC_CAUSE_MSGTYPE_INCOMPAT = 98,
633         GSM48_CC_CAUSE_IE_NOTEXIST      = 99,
634         GSM48_CC_CAUSE_COND_IE_ERR      = 100,
635         GSM48_CC_CAUSE_MSG_INCOMP_STATE = 101,
636         GSM48_CC_CAUSE_RECOVERY_TIMER   = 102,
637         GSM48_CC_CAUSE_PROTO_ERR        = 111,
638         GSM48_CC_CAUSE_INTERWORKING     = 127,
639 };
640
641 /* Annex G, GSM specific cause values for mobility management */
642 enum gsm48_reject_value {
643         GSM48_REJECT_IMSI_UNKNOWN_IN_HLR        = 2,
644         GSM48_REJECT_ILLEGAL_MS                 = 3,
645         GSM48_REJECT_IMSI_UNKNOWN_IN_VLR        = 4,
646         GSM48_REJECT_IMEI_NOT_ACCEPTED          = 5,
647         GSM48_REJECT_ILLEGAL_ME                 = 6,
648         GSM48_REJECT_PLMN_NOT_ALLOWED           = 11,
649         GSM48_REJECT_LOC_NOT_ALLOWED            = 12,
650         GSM48_REJECT_ROAMING_NOT_ALLOWED        = 13,
651         GSM48_REJECT_NETWORK_FAILURE            = 17,
652         GSM48_REJECT_CONGESTION                 = 22,
653         GSM48_REJECT_SRV_OPT_NOT_SUPPORTED      = 32,
654         GSM48_REJECT_RQD_SRV_OPT_NOT_SUPPORTED  = 33,
655         GSM48_REJECT_SRV_OPT_TMP_OUT_OF_ORDER   = 34,
656         GSM48_REJECT_CALL_CAN_NOT_BE_IDENTIFIED = 38,
657         GSM48_REJECT_INCORRECT_MESSAGE          = 95,
658         GSM48_REJECT_INVALID_MANDANTORY_INF     = 96,
659         GSM48_REJECT_MSG_TYPE_NOT_IMPLEMENTED   = 97,
660         GSM48_REJECT_MSG_TYPE_NOT_COMPATIBLE    = 98,
661         GSM48_REJECT_INF_ELEME_NOT_IMPLEMENTED  = 99,
662         GSM48_REJECT_CONDTIONAL_IE_ERROR        = 100,
663         GSM48_REJECT_MSG_NOT_COMPATIBLE         = 101,
664         GSM48_REJECT_PROTOCOL_ERROR             = 111,
665
666         /* according to G.6 Additional cause codes for GMM */
667         GSM48_REJECT_GPRS_NOT_ALLOWED           = 7,
668         GSM48_REJECT_SERVICES_NOT_ALLOWED       = 8,
669         GSM48_REJECT_MS_IDENTITY_NOT_DERVIVABLE = 9,
670         GSM48_REJECT_IMPLICITLY_DETACHED        = 10,
671         GSM48_REJECT_GPRS_NOT_ALLOWED_IN_PLMN   = 14,
672         GSM48_REJECT_MSC_TMP_NOT_REACHABLE      = 16,
673 };
674
675 enum chreq_type {
676         CHREQ_T_EMERG_CALL,
677         CHREQ_T_CALL_REEST_TCH_F,
678         CHREQ_T_CALL_REEST_TCH_H,
679         CHREQ_T_CALL_REEST_TCH_H_DBL,
680         CHREQ_T_SDCCH,
681         CHREQ_T_TCH_F,
682         CHREQ_T_VOICE_CALL_TCH_H,
683         CHREQ_T_DATA_CALL_TCH_H,
684         CHREQ_T_LOCATION_UPD,
685         CHREQ_T_PAG_R_ANY_NECI0,
686         CHREQ_T_PAG_R_ANY_NECI1,
687         CHREQ_T_PAG_R_TCH_F,
688         CHREQ_T_PAG_R_TCH_FH,
689         CHREQ_T_LMU,
690         CHREQ_T_RESERVED_SDCCH,
691         CHREQ_T_RESERVED_IGNORE,
692 };
693
694 /* Chapter 11.3 */
695 #define GSM48_T301      180, 0
696 #define GSM48_T303      30, 0
697 #define GSM48_T305      30, 0
698 #define GSM48_T306      30, 0
699 #define GSM48_T308      10, 0
700 #define GSM48_T310      180, 0
701 #define GSM48_T313      30, 0
702 #define GSM48_T323      30, 0
703 #define GSM48_T331      30, 0
704 #define GSM48_T333      30, 0
705 #define GSM48_T334      25, 0 /* min 15 */
706 #define GSM48_T338      30, 0
707
708 /* Chapter 5.1.2.2 */
709 #define GSM_CSTATE_NULL                 0
710 #define GSM_CSTATE_INITIATED            1
711 #define GSM_CSTATE_MM_CONNECTION_PEND   2 /* see 10.5.4.6 */
712 #define GSM_CSTATE_MO_CALL_PROC         3
713 #define GSM_CSTATE_CALL_DELIVERED       4
714 #define GSM_CSTATE_CALL_PRESENT         6
715 #define GSM_CSTATE_CALL_RECEIVED        7
716 #define GSM_CSTATE_CONNECT_REQUEST      8
717 #define GSM_CSTATE_MO_TERM_CALL_CONF    9
718 #define GSM_CSTATE_ACTIVE               10
719 #define GSM_CSTATE_DISCONNECT_REQ       12
720 #define GSM_CSTATE_DISCONNECT_IND       12
721 #define GSM_CSTATE_RELEASE_REQ          19
722 #define GSM_CSTATE_MO_ORIG_MODIFY       26
723 #define GSM_CSTATE_MO_TERM_MODIFY       27
724 #define GSM_CSTATE_CONNECT_IND          28
725
726 #define SBIT(a) (1 << a)
727 #define ALL_STATES 0xffffffff
728
729 /* Table 10.5.3/3GPP TS 04.08: Location Area Identification information element */
730 #define GSM_LAC_RESERVED_DETACHED       0x0
731 #define GSM_LAC_RESERVED_ALL_BTS        0xfffe
732
733 /* GSM 04.08 Bearer Capability: Information Transfer Capability */
734 enum gsm48_bcap_itcap {
735         GSM48_BCAP_ITCAP_SPEECH         = 0,
736         GSM48_BCAP_ITCAP_UNR_DIG_INF    = 1,
737         GSM48_BCAP_ITCAP_3k1_AUDIO      = 2,
738         GSM48_BCAP_ITCAP_FAX_G3         = 3,
739         GSM48_BCAP_ITCAP_OTHER          = 5,
740         GSM48_BCAP_ITCAP_RESERVED       = 7,
741 };
742
743 /* GSM 04.08 Bearer Capability: Transfer Mode */
744 enum gsm48_bcap_tmod {
745         GSM48_BCAP_TMOD_CIRCUIT         = 0,
746         GSM48_BCAP_TMOD_PACKET          = 1,
747 };
748
749 /* GSM 04.08 Bearer Capability: Coding Standard */
750 enum gsm48_bcap_coding {
751         GSM48_BCAP_CODING_GSM_STD       = 0,
752 };
753
754 /* GSM 04.08 Bearer Capability: Radio Channel Requirements */
755 enum gsm48_bcap_rrq {
756         GSM48_BCAP_RRQ_FR_ONLY  = 1,
757         GSM48_BCAP_RRQ_DUAL_HR  = 2,
758         GSM48_BCAP_RRQ_DUAL_FR  = 3,
759 };
760
761 #define GSM48_TMSI_LEN  5
762 #define GSM48_MID_TMSI_LEN      (GSM48_TMSI_LEN + 2)
763 #define GSM48_MI_SIZE 32
764
765 /* Chapter 10.4.4.15 */
766 struct gsm48_ra_id {
767         uint8_t digits[3];      /* MCC + MNC BCD digits */
768         uint16_t lac;           /* Location Area Code */
769         uint8_t rac;            /* Routing Area Code */
770 } __attribute__ ((packed));
771
772
773
774 #endif /* PROTO_GSM_04_08_H */