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