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