blob: 485e240cdbd50c8dbc6a6731375afe1c12ec19d3 [file] [log] [blame]
Harald Welte52b1f982008-12-23 20:25:15 +00001#ifndef _GSM_04_08_H
2#define _GSM_04_08_H
3
4/* GSM TS 04.08 definitions */
Holger Freyther1adb4ff2009-02-04 00:04:52 +00005struct gsm_lchan;
Harald Welte52b1f982008-12-23 20:25:15 +00006
Harald Weltef7c43522009-06-09 20:24:21 +00007struct 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
Harald Welte52b1f982008-12-23 20:25:15 +000015/* 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 };
Harald Welteb84e2f42008-12-28 23:42:04 +000034} __attribute__ ((packed));
Harald Welte52b1f982008-12-23 20:25:15 +000035
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;
Harald Welteb84e2f42008-12-28 23:42:04 +000043} __attribute__ ((packed));
Harald Welte52b1f982008-12-23 20:25:15 +000044
Harald Welte7584aea2009-02-11 11:44:12 +000045/* 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 Welte9943c5b2009-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 Welte8e4ae952009-02-18 03:28:01 +000061
Harald Welte52b1f982008-12-23 20:25:15 +000062/* 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];
Harald Welteb84e2f42008-12-28 23:42:04 +000073} __attribute__ ((packed));
Harald Welte52b1f982008-12-23 20:25:15 +000074
Harald Welte4b634542008-12-27 01:55:51 +000075/* Chapter 10.5.1.3 */
Harald Welte52b1f982008-12-23 20:25:15 +000076struct gsm48_loc_area_id {
77 u_int8_t digits[3]; /* BCD! */
78 u_int16_t lac;
79} __attribute__ ((packed));
80
Sylvain Munaut849f5542009-09-27 11:10:17 +020081/* Section 9.2.2 */
82struct gsm48_auth_req {
83 u_int8_t key_seq:4,
84 spare:4;
85 u_int8_t rand[16];
86} __attribute__ ((packed));
87
Harald Welte52b1f982008-12-23 20:25:15 +000088/* Section 9.2.15 */
89struct gsm48_loc_upd_req {
90 u_int8_t type:4,
91 key_seq:4;
92 struct gsm48_loc_area_id lai;
Harald Weltef7c43522009-06-09 20:24:21 +000093 struct gsm48_classmark1 classmark1;
Harald Welte52b1f982008-12-23 20:25:15 +000094 u_int8_t mi_len;
95 u_int8_t mi[0];
96} __attribute__ ((packed));
97
98/* Section 10.1 */
99struct gsm48_hdr {
100 u_int8_t proto_discr;
101 u_int8_t msg_type;
102 u_int8_t data[0];
103} __attribute__ ((packed));
104
Holger Freyther5e85c8e2008-12-28 16:32:39 +0000105/* Section 9.1.3x System information Type header */
106struct gsm48_system_information_type_header {
107 u_int8_t l2_plen;
108 u_int8_t rr_protocol_discriminator :4,
109 skip_indicator:4;
110 u_int8_t system_information;
111} __attribute__ ((packed));
112
Harald Weltede9226d2008-12-29 02:37:23 +0000113struct gsm48_rach_control {
114 u_int8_t re :1,
115 cell_bar :1,
116 tx_integer :4,
117 max_trans :2;
118 u_int8_t t2;
119 u_int8_t t3;
120} __attribute__ ((packed));
121
Harald Weltee1228552009-08-09 14:38:32 +0200122/* Section 10.5.2.4 Cell Selection Parameters */
123struct gsm48_cell_sel_par {
124 u_int8_t ms_txpwr_max_ccch:5, /* GSM 05.08 MS-TXPWR-MAX-CCCH */
125 cell_resel_hyst:3; /* GSM 05.08 CELL-RESELECT-HYSTERESIS */
126 u_int8_t rxlev_acc_min:6, /* GSM 05.08 RXLEV-ACCESS-MIN */
127 neci:1,
128 acs:1;
129} __attribute__ ((packed));
130
Holger Freyther1adb4ff2009-02-04 00:04:52 +0000131/* Section 10.5.2.11 Control Channel Description , Figure 10.5.33 */
132struct gsm48_control_channel_descr {
133 u_int8_t ccch_conf :3,
134 bs_ag_blks_res :3,
135 att :1,
136 spare1 :1;
137 u_int8_t bs_pa_mfrms : 3,
138 spare2 :5;
139 u_int8_t t3212;
140} __attribute__ ((packed));
141
Harald Welteba4cf162009-01-10 01:49:35 +0000142/* Section 9.2.9 CM service request */
143struct gsm48_service_request {
144 u_int8_t cm_service_type : 4,
145 cipher_key_seq : 4;
146 /* length + 3 bytes */
147 u_int32_t classmark;
148 u_int8_t mi_len;
149 u_int8_t mi[0];
150 /* optional priority level */
151} __attribute__ ((packed));
152
Holger Freyther5e85c8e2008-12-28 16:32:39 +0000153/* Section 9.1.31 System information Type 1 */
154struct gsm48_system_information_type_1 {
155 struct gsm48_system_information_type_header header;
156 u_int8_t cell_channel_description[16];
Harald Weltede9226d2008-12-29 02:37:23 +0000157 struct gsm48_rach_control rach_control;
Holger Freyther5e85c8e2008-12-28 16:32:39 +0000158 u_int8_t s1_reset;
159} __attribute__ ((packed));
160
161/* Section 9.1.32 System information Type 2 */
162struct gsm48_system_information_type_2 {
163 struct gsm48_system_information_type_header header;
164 u_int8_t bcch_frequency_list[16];
165 u_int8_t ncc_permitted;
Harald Weltede9226d2008-12-29 02:37:23 +0000166 struct gsm48_rach_control rach_control;
Holger Freyther5e85c8e2008-12-28 16:32:39 +0000167} __attribute__ ((packed));
168
169/* Section 9.1.35 System information Type 3 */
170struct gsm48_system_information_type_3 {
171 struct gsm48_system_information_type_header header;
172 u_int16_t cell_identity;
173 struct gsm48_loc_area_id lai;
Holger Freyther1adb4ff2009-02-04 00:04:52 +0000174 struct gsm48_control_channel_descr control_channel_desc;
Holger Freyther5e85c8e2008-12-28 16:32:39 +0000175 u_int8_t cell_options;
Harald Weltee1228552009-08-09 14:38:32 +0200176 struct gsm48_cell_sel_par cell_sel_par;
Harald Weltede9226d2008-12-29 02:37:23 +0000177 struct gsm48_rach_control rach_control;
Holger Freyther5e85c8e2008-12-28 16:32:39 +0000178 u_int8_t s3_reset_octets[4];
179} __attribute__ ((packed));
180
181/* Section 9.1.36 System information Type 4 */
182struct gsm48_system_information_type_4 {
183 struct gsm48_system_information_type_header header;
184 struct gsm48_loc_area_id lai;
Harald Weltee1228552009-08-09 14:38:32 +0200185 struct gsm48_cell_sel_par cell_sel_par;
Harald Weltede9226d2008-12-29 02:37:23 +0000186 struct gsm48_rach_control rach_control;
Holger Freyther5e85c8e2008-12-28 16:32:39 +0000187 /* optional CBCH conditional CBCH... followed by
188 mandantory SI 4 Reset Octets
189 */
190 u_int8_t data[0];
191} __attribute__ ((packed));
192
193/* Section 9.1.37 System information Type 5 */
194struct gsm48_system_information_type_5 {
195 u_int8_t rr_protocol_discriminator :4,
196 skip_indicator:4;
197 u_int8_t system_information;
198 u_int8_t bcch_frequency_list[16];
199} __attribute__ ((packed));
200
201/* Section 9.1.40 System information Type 6 */
202struct gsm48_system_information_type_6 {
203 u_int8_t rr_protocol_discriminator :4,
204 skip_indicator:4;
205 u_int8_t system_information;
Holger Hans Peter Freytherc4a49e32009-08-21 14:44:12 +0200206 u_int16_t cell_identity;
Holger Freyther5e85c8e2008-12-28 16:32:39 +0000207 struct gsm48_loc_area_id lai;
208 u_int8_t cell_options;
209 u_int8_t ncc_permitted;
210 u_int8_t si_6_reset[0];
211} __attribute__ ((packed));
212
Harald Welte2f74aa42009-02-22 21:14:04 +0000213/* Section 9.2.12 IMSI Detach Indication */
214struct gsm48_imsi_detach_ind {
Harald Weltef7c43522009-06-09 20:24:21 +0000215 struct gsm48_classmark1 classmark1;
Harald Welte2f74aa42009-02-22 21:14:04 +0000216 u_int8_t mi_len;
217 u_int8_t mi[0];
218} __attribute__ ((packed));
219
Harald Weltebcae43f2008-12-27 21:45:37 +0000220/* Section 10.2 + GSM 04.07 12.2.3.1.1 */
221#define GSM48_PDISC_GROUP_CC 0x00
222#define GSM48_PDISC_BCAST_CC 0x01
223#define GSM48_PDISC_PDSS1 0x02
Harald Welte4b634542008-12-27 01:55:51 +0000224#define GSM48_PDISC_CC 0x03
Harald Weltebcae43f2008-12-27 21:45:37 +0000225#define GSM48_PDISC_PDSS2 0x04
Harald Welte52b1f982008-12-23 20:25:15 +0000226#define GSM48_PDISC_MM 0x05
227#define GSM48_PDISC_RR 0x06
228#define GSM48_PDISC_MM_GPRS 0x08
Harald Weltebcae43f2008-12-27 21:45:37 +0000229#define GSM48_PDISC_SMS 0x09
230#define GSM48_PDISC_SM_GPRS 0x0a
231#define GSM48_PDISC_NC_SS 0x0b
232#define GSM48_PDISC_LOC 0x0c
Harald Weltede9226d2008-12-29 02:37:23 +0000233#define GSM48_PDISC_MASK 0x0f
Harald Weltea27d8d22009-03-10 12:13:42 +0000234#define GSM48_PDISC_USSD 0x11
Harald Welte52b1f982008-12-23 20:25:15 +0000235
236/* Section 10.4 */
237#define GSM48_MT_RR_INIT_REQ 0x3c
238#define GSM48_MT_RR_ADD_ASS 0x3b
239#define GSM48_MT_RR_IMM_ASS 0x3f
240#define GSM48_MT_RR_IMM_ASS_EXT 0x39
241#define GSM48_MT_RR_IMM_ASS_REJ 0x3a
242
243#define GSM48_MT_RR_CIPH_M_CMD 0x35
244#define GSM48_MT_RR_CIPH_M_COMPL 0x32
245
246#define GSM48_MT_RR_CFG_CHG_CMD 0x30
247#define GSM48_MT_RR_CFG_CHG_ACK 0x31
248#define GSM48_MT_RR_CFG_CHG_REJ 0x33
249
250#define GSM48_MT_RR_ASS_CMD 0x2e
251#define GSM48_MT_RR_ASS_COMPL 0x29
252#define GSM48_MT_RR_ASS_FAIL 0x2f
253#define GSM48_MT_RR_HANDO_CMD 0x2b
254#define GSM48_MT_RR_HANDO_COMPL 0x2c
255#define GSM48_MT_RR_HANDO_FAIL 0x28
256#define GSM48_MT_RR_HANDO_INFO 0x2d
257
258#define GSM48_MT_RR_CELL_CHG_ORDER 0x08
259#define GSM48_MT_RR_PDCH_ASS_CMD 0x23
260
261#define GSM48_MT_RR_CHAN_REL 0x0d
262#define GSM48_MT_RR_PART_REL 0x0a
263#define GSM48_MT_RR_PART_REL_COMP 0x0f
264
265#define GSM48_MT_RR_PAG_REQ_1 0x21
266#define GSM48_MT_RR_PAG_REQ_2 0x22
267#define GSM48_MT_RR_PAG_REQ_3 0x24
268#define GSM48_MT_RR_PAG_RESP 0x27
269#define GSM48_MT_RR_NOTIF_NCH 0x20
270#define GSM48_MT_RR_NOTIF_FACCH 0x25
271#define GSM48_MT_RR_NOTIF_RESP 0x26
272
273#define GSM48_MT_RR_SYSINFO_8 0x18
274#define GSM48_MT_RR_SYSINFO_1 0x19
275#define GSM48_MT_RR_SYSINFO_2 0x1a
276#define GSM48_MT_RR_SYSINFO_3 0x1b
277#define GSM48_MT_RR_SYSINFO_4 0x1c
278#define GSM48_MT_RR_SYSINFO_5 0x1d
279#define GSM48_MT_RR_SYSINFO_6 0x1e
280#define GSM48_MT_RR_SYSINFO_7 0x1f
281
282#define GSM48_MT_RR_SYSINFO_2bis 0x02
283#define GSM48_MT_RR_SYSINFO_2ter 0x03
284#define GSM48_MT_RR_SYSINFO_5bis 0x05
285#define GSM48_MT_RR_SYSINFO_5ter 0x06
286#define GSM48_MT_RR_SYSINFO_9 0x04
287#define GSM48_MT_RR_SYSINFO_13 0x00
288
289#define GSM48_MT_RR_SYSINFO_16 0x3d
290#define GSM48_MT_RR_SYSINFO_17 0x3e
291
292#define GSM48_MT_RR_CHAN_MODE_MODIF 0x10
293#define GSM48_MT_RR_STATUS 0x12
294#define GSM48_MT_RR_CHAN_MODE_MODIF_ACK 0x17
295#define GSM48_MT_RR_FREQ_REDEF 0x14
296#define GSM48_MT_RR_MEAS_REP 0x15
297#define GSM48_MT_RR_CLSM_CHG 0x16
298#define GSM48_MT_RR_CLSM_ENQ 0x13
299#define GSM48_MT_RR_EXT_MEAS_REP 0x36
300#define GSM48_MT_RR_EXT_MEAS_REP_ORD 0x37
301#define GSM48_MT_RR_GPRS_SUSP_REQ 0x34
302
303#define GSM48_MT_RR_VGCS_UPL_GRANT 0x08
304#define GSM48_MT_RR_UPLINK_RELEASE 0x0e
305#define GSM48_MT_RR_UPLINK_FREE 0x0c
306#define GSM48_MT_RR_UPLINK_BUSY 0x2a
307#define GSM48_MT_RR_TALKER_IND 0x11
308
309#define GSM48_MT_RR_APP_INFO 0x38
310
311/* Table 10.2/3GPP TS 04.08 */
312#define GSM48_MT_MM_IMSI_DETACH_IND 0x01
313#define GSM48_MT_MM_LOC_UPD_ACCEPT 0x02
314#define GSM48_MT_MM_LOC_UPD_REJECT 0x04
315#define GSM48_MT_MM_LOC_UPD_REQUEST 0x08
316
317#define GSM48_MT_MM_AUTH_REJ 0x11
318#define GSM48_MT_MM_AUTH_REQ 0x12
319#define GSM48_MT_MM_AUTH_RESP 0x14
320#define GSM48_MT_MM_ID_REQ 0x18
321#define GSM48_MT_MM_ID_RESP 0x19
322#define GSM48_MT_MM_TMSI_REALL_CMD 0x1a
323#define GSM48_MT_MM_TMSI_REALL_COMPL 0x1b
324
325#define GSM48_MT_MM_CM_SERV_ACC 0x21
326#define GSM48_MT_MM_CM_SERV_REJ 0x22
327#define GSM48_MT_MM_CM_SERV_ABORT 0x23
328#define GSM48_MT_MM_CM_SERV_REQ 0x24
329#define GSM48_MT_MM_CM_SERV_PROMPT 0x25
330#define GSM48_MT_MM_CM_REEST_REQ 0x28
331#define GSM48_MT_MM_ABORT 0x29
332
333#define GSM48_MT_MM_NULL 0x30
334#define GSM48_MT_MM_STATUS 0x31
335#define GSM48_MT_MM_INFO 0x32
336
337/* Table 10.3/3GPP TS 04.08 */
338#define GSM48_MT_CC_ALERTING 0x01
339#define GSM48_MT_CC_CALL_CONF 0x08
340#define GSM48_MT_CC_CALL_PROC 0x02
341#define GSM48_MT_CC_CONNECT 0x07
342#define GSM48_MT_CC_CONNECT_ACK 0x0f
343#define GSM48_MT_CC_EMERG_SETUP 0x0e
344#define GSM48_MT_CC_PROGRESS 0x03
345#define GSM48_MT_CC_ESTAB 0x04
346#define GSM48_MT_CC_ESTAB_CONF 0x06
347#define GSM48_MT_CC_RECALL 0x0b
348#define GSM48_MT_CC_START_CC 0x09
349#define GSM48_MT_CC_SETUP 0x05
350
351#define GSM48_MT_CC_MODIFY 0x17
352#define GSM48_MT_CC_MODIFY_COMPL 0x1f
353#define GSM48_MT_CC_MODIFY_REJECT 0x13
354#define GSM48_MT_CC_USER_INFO 0x10
355#define GSM48_MT_CC_HOLD 0x18
356#define GSM48_MT_CC_HOLD_ACK 0x19
357#define GSM48_MT_CC_HOLD_REJ 0x1a
358#define GSM48_MT_CC_RETR 0x1c
359#define GSM48_MT_CC_RETR_ACK 0x1d
360#define GSM48_MT_CC_RETR_REJ 0x1e
361
362#define GSM48_MT_CC_DISCONNECT 0x25
363#define GSM48_MT_CC_RELEASE 0x2d
Harald Welte7ccf7782009-02-17 01:43:01 +0000364#define GSM48_MT_CC_RELEASE_COMPL 0x2a
Harald Welte52b1f982008-12-23 20:25:15 +0000365
366#define GSM48_MT_CC_CONG_CTRL 0x39
367#define GSM48_MT_CC_NOTIFY 0x3e
368#define GSM48_MT_CC_STATUS 0x3d
369#define GSM48_MT_CC_STATUS_ENQ 0x34
370#define GSM48_MT_CC_START_DTMF 0x35
371#define GSM48_MT_CC_STOP_DTMF 0x31
372#define GSM48_MT_CC_STOP_DTMF_ACK 0x32
373#define GSM48_MT_CC_START_DTMF_ACK 0x36
374#define GSM48_MT_CC_START_DTMF_REJ 0x37
375#define GSM48_MT_CC_FACILITY 0x3a
376
377/* FIXME: Table 10.4 / 10.4a (GPRS) */
378
379/* Section 10.5.2.26, Table 10.5.64 */
380#define GSM48_PM_MASK 0x03
381#define GSM48_PM_NORMAL 0x00
382#define GSM48_PM_EXTENDED 0x01
383#define GSM48_PM_REORG 0x02
384#define GSM48_PM_SAME 0x03
385
Harald Welte2f74aa42009-02-22 21:14:04 +0000386/* Chapter 10.5.3.5 / Table 10.5.93 */
387#define GSM48_LUPD_NORMAL 0x0
388#define GSM48_LUPD_PERIODIC 0x1
389#define GSM48_LUPD_IMSI_ATT 0x2
390#define GSM48_LUPD_RESERVED 0x3
391
Harald Welte52b1f982008-12-23 20:25:15 +0000392/* Table 10.5.4 */
393#define GSM_MI_TYPE_MASK 0x07
394#define GSM_MI_TYPE_NONE 0x00
395#define GSM_MI_TYPE_IMSI 0x01
396#define GSM_MI_TYPE_IMEI 0x02
397#define GSM_MI_TYPE_IMEISV 0x03
398#define GSM_MI_TYPE_TMSI 0x04
399#define GSM_MI_ODD 0x08
400
Harald Welte4b634542008-12-27 01:55:51 +0000401#define GSM48_IE_MOBILE_ID 0x17
Harald Weltec6ba9c22008-12-30 18:01:02 +0000402#define GSM48_IE_NAME_LONG 0x43 /* 10.5.3.5a */
403#define GSM48_IE_NAME_SHORT 0x45 /* 10.5.3.5a */
404#define GSM48_IE_UTC 0x46 /* 10.5.3.8 */
405#define GSM48_IE_NET_TIME_TZ 0x47 /* 10.5.3.9 */
406#define GSM48_IE_LSA_IDENT 0x48 /* 10.5.3.11 */
Harald Welte4b634542008-12-27 01:55:51 +0000407
Harald Welte7584aea2009-02-11 11:44:12 +0000408#define GSM48_IE_BEARER_CAP 0x04 /* 10.5.4.5 */
409#define GSM48_IE_CAUSE 0x08 /* 10.5.4.11 */
410#define GSM48_IE_CC_CAP 0x15 /* 10.5.4.5a */
411#define GSM48_IE_ALERT 0x19 /* 10.5.4.26 */
412#define GSM48_IE_FACILITY 0x1c /* 10.5.4.15 */
413#define GSM48_IE_PROGR_IND 0x1e /* 10.5.4.21 */
414#define GSM48_IE_AUX_STATUS 0x24 /* 10.5.4.4 */
Harald Welte0c389302009-06-10 12:08:54 +0800415#define GSM48_IE_NOTIFY 0x27 /* 10.5.4.20 */
Harald Welte7584aea2009-02-11 11:44:12 +0000416#define GSM48_IE_KPD_FACILITY 0x2c /* 10.5.4.17 */
417#define GSM48_IE_SIGNAL 0x34 /* 10.5.4.23 */
Harald Welte0c389302009-06-10 12:08:54 +0800418#define GSM48_IE_CONN_BCD 0x4c /* 10.5.4.13 */
419#define GSM48_IE_CONN_SUB 0x4d /* 10.5.4.14 */
Harald Welte7584aea2009-02-11 11:44:12 +0000420#define GSM48_IE_CALLING_BCD 0x5c /* 10.5.4.9 */
421#define GSM48_IE_CALLING_SUB 0x5d /* 10.5.4.10 */
422#define GSM48_IE_CALLED_BCD 0x5e /* 10.5.4.7 */
423#define GSM48_IE_CALLED_SUB 0x6d /* 10.5.4.8 */
424#define GSM48_IE_REDIR_BCD 0x74 /* 10.5.4.21a */
425#define GSM48_IE_REDIR_SUB 0x75 /* 10.5.4.21b */
426#define GSM48_IE_LOWL_COMPAT 0x7c /* 10.5.4.18 */
427#define GSM48_IE_HIGHL_COMPAT 0x7d /* 10.5.4.16 */
428#define GSM48_IE_USER_USER 0x7e /* 10.5.4.25 */
429#define GSM48_IE_SS_VERS 0x7f /* 10.5.4.24 */
430#define GSM48_IE_MORE_DATA 0xa0 /* 10.5.4.19 */
431#define GSM48_IE_CLIR_SUPP 0xa1 /* 10.5.4.11a */
432#define GSM48_IE_CLIR_INVOC 0xa2 /* 10.5.4.11b */
433#define GSM48_IE_REV_C_SETUP 0xa3 /* 10.5.4.22a */
Harald Welte0c389302009-06-10 12:08:54 +0800434#define GSM48_IE_REPEAT_CIR 0xd1 /* 10.5.4.22 */
435#define GSM48_IE_REPEAT_SEQ 0xd3 /* 10.5.4.22 */
Harald Welte7584aea2009-02-11 11:44:12 +0000436
Harald Welte4b634542008-12-27 01:55:51 +0000437/* Section 10.5.4.11 / Table 10.5.122 */
438#define GSM48_CAUSE_CS_GSM 0x60
439
Harald Welte4a543e82009-02-28 13:17:55 +0000440/* Section 9.1.2 / Table 9.3 */
441#define GSM48_IE_FRQLIST_AFTER 0x05
442#define GSM48_IE_CELL_CH_DESC 0x62
443#define GSM48_IE_MSLOT_DESC 0x10
444#define GSM48_IE_CHANMODE_1 0x63
445#define GSM48_IE_CHANMODE_2 0x11
446#define GSM48_IE_CHANMODE_3 0x13
447#define GSM48_IE_CHANMODE_4 0x14
448#define GSM48_IE_CHANMODE_5 0x15
449#define GSM48_IE_CHANMODE_6 0x16
450#define GSM48_IE_CHANMODE_7 0x17
451#define GSM48_IE_CHANMODE_8 0x18
452#define GSM48_IE_CHANDESC_2 0x64
453/* FIXME */
454
Harald Welte7584aea2009-02-11 11:44:12 +0000455/* Section 10.5.4.23 / Table 10.5.130 */
456enum gsm48_signal_val {
457 GSM48_SIGNAL_DIALTONE = 0x00,
458 GSM48_SIGNAL_RINGBACK = 0x01,
459 GSM48_SIGNAL_INTERCEPT = 0x02,
460 GSM48_SIGNAL_NET_CONG = 0x03,
461 GSM48_SIGNAL_BUSY = 0x04,
462 GSM48_SIGNAL_CONFIRM = 0x05,
463 GSM48_SIGNAL_ANSWER = 0x06,
464 GSM48_SIGNAL_CALL_WAIT = 0x07,
465 GSM48_SIGNAL_OFF_HOOK = 0x08,
466 GSM48_SIGNAL_OFF = 0x3f,
467 GSM48_SIGNAL_ALERT_OFF = 0x4f,
468};
469
Harald Welte4b634542008-12-27 01:55:51 +0000470enum gsm48_cause_loc {
471 GSM48_CAUSE_LOC_USER = 0x00,
472 GSM48_CAUSE_LOC_PRN_S_LU = 0x01,
473 GSM48_CAUSE_LOC_PUN_S_LU = 0x02,
474 GSM48_CAUSE_LOC_TRANS_NET = 0x03,
475 GSM48_CAUSE_LOC_PUN_S_RU = 0x04,
476 GSM48_CAUSE_LOC_PRN_S_RU = 0x05,
477 /* not defined */
478 GSM48_CAUSE_LOC_INN_NET = 0x07,
479 GSM48_CAUSE_LOC_NET_BEYOND = 0x0a,
480};
481
Holger Freythere64a7a32009-02-06 21:55:37 +0000482/* Section 10.5.2.31 RR Cause / Table 10.5.70 */
483enum gsm48_rr_cause {
484 GSM48_RR_CAUSE_NORMAL = 0x00,
485 GSM48_RR_CAUSE_ABNORMAL_UNSPEC = 0x01,
486 GSM48_RR_CAUSE_ABNORMAL_UNACCT = 0x02,
487 GSM48_RR_CAUSE_ABNORMAL_TIMER = 0x03,
488 GSM48_RR_CAUSE_ABNORMAL_NOACT = 0x04,
489 GSM48_RR_CAUSE_PREMPTIVE_REL = 0x05,
490 GSM48_RR_CAUSE_HNDOVER_IMP = 0x06,
491 GSM48_RR_CAUSE_CHAN_MODE_UNACCT = 0x07,
492 GSM48_RR_CAUSE_FREQ_NOT_IMPL = 0x08,
Harald Weltecf5b3592009-05-01 18:28:42 +0000493 GSM48_RR_CAUSE_CALL_CLEARED = 0x41,
Holger Freythere64a7a32009-02-06 21:55:37 +0000494 GSM48_RR_CAUSE_SEMANT_INCORR = 0x5f,
495 GSM48_RR_CAUSE_INVALID_MAND_INF = 0x60,
496 GSM48_RR_CAUSE_MSG_TYPE_N = 0x61,
497 GSM48_RR_CAUSE_MSG_TYPE_N_COMPAT= 0x62,
498 GSM48_RR_CAUSE_COND_IE_ERROR = 0x64,
499 GSM48_RR_CAUSE_NO_CELL_ALLOC_A = 0x65,
500 GSM48_RR_CAUSE_PROT_ERROR_UNSPC = 0x6f,
501};
502
Harald Weltec66b71c2009-06-11 14:23:20 +0800503/* Section 10.5.4.11 CC Cause / Table 10.5.123 */
504enum gsm48_cc_cause {
505 GSM48_CC_CAUSE_UNASSIGNED_NR = 1,
506 GSM48_CC_CAUSE_NO_ROUTE = 3,
507 GSM48_CC_CAUSE_CHAN_UNACCEPT = 6,
508 GSM48_CC_CAUSE_OP_DET_BARRING = 8,
509 GSM48_CC_CAUSE_NORM_CALL_CLEAR = 16,
510 GSM48_CC_CAUSE_USER_BUSY = 17,
511 GSM48_CC_CAUSE_USER_NOTRESPOND = 18,
512 GSM48_CC_CAUSE_USER_ALERTING_NA = 19,
513 GSM48_CC_CAUSE_CALL_REJECTED = 21,
514 GSM48_CC_CAUSE_NUMBER_CHANGED = 22,
515 GSM48_CC_CAUSE_PRE_EMPTION = 25,
516 GSM48_CC_CAUSE_NONSE_USER_CLR = 26,
517 GSM48_CC_CAUSE_DEST_OOO = 27,
518 GSM48_CC_CAUSE_INV_NR_FORMAT = 28,
519 GSM48_CC_CAUSE_FACILITY_REJ = 29,
520 GSM48_CC_CAUSE_RESP_STATUS_INQ = 30,
521 GSM48_CC_CAUSE_NORMAL_UNSPEC = 31,
522 GSM48_CC_CAUSE_NO_CIRCUIT_CHAN = 34,
523 GSM48_CC_CAUSE_NETWORK_OOO = 38,
524 GSM48_CC_CAUSE_TEMP_FAILURE = 41,
525 GSM48_CC_CAUSE_SWITCH_CONG = 42,
526 GSM48_CC_CAUSE_ACC_INF_DISCARD = 43,
527 GSM48_CC_CAUSE_REQ_CHAN_UNAVAIL = 44,
528 GSM48_CC_CAUSE_RESOURCE_UNAVAIL = 47,
529 GSM48_CC_CAUSE_QOS_UNAVAIL = 49,
530 GSM48_CC_CAUSE_REQ_FAC_NOT_SUBSC= 50,
531 GSM48_CC_CAUSE_INC_BARRED_CUG = 55,
532 GSM48_CC_CAUSE_BEARER_CAP_UNAUTH= 57,
533 GSM48_CC_CAUSE_BEARER_CA_UNAVAIL= 58,
534 GSM48_CC_CAUSE_SERV_OPT_UNAVAIL = 63,
535 GSM48_CC_CAUSE_BEARERSERV_UNIMPL= 65,
536 GSM48_CC_CAUSE_ACM_GE_ACM_MAX = 68,
537 GSM48_CC_CAUSE_REQ_FAC_NOTIMPL = 69,
538 GSM48_CC_CAUSE_RESTR_BCAP_AVAIL = 70,
539 GSM48_CC_CAUSE_SERV_OPT_UNIMPL = 79,
540 GSM48_CC_CAUSE_INVAL_TRANS_ID = 81,
541 GSM48_CC_CAUSE_USER_NOT_IN_CUG = 87,
542 GSM48_CC_CAUSE_INCOMPAT_DEST = 88,
543 GSM48_CC_CAUSE_INVAL_TRANS_NET = 91,
544 GSM48_CC_CAUSE_SEMANTIC_INCORR = 95,
545 GSM48_CC_CAUSE_INVAL_MAND_INF = 96,
546 GSM48_CC_CAUSE_MSGTYPE_NOTEXIST = 97,
547 GSM48_CC_CAUSE_MSGTYPE_INCOMPAT = 98,
548 GSM48_CC_CAUSE_IE_NOTEXIST = 99,
549 GSM48_CC_CAUSE_COND_IE_ERR = 100,
550 GSM48_CC_CAUSE_MSG_INCOMP_STATE = 101,
551 GSM48_CC_CAUSE_RECOVERY_TIMER = 102,
552 GSM48_CC_CAUSE_PROTO_ERR = 111,
553 GSM48_CC_CAUSE_INTERWORKING = 127,
554};
555
Holger Freythera7677942008-12-30 16:18:16 +0000556/* Annex G, GSM specific cause values for mobility management */
557enum gsm48_reject_value {
558 GSM48_REJECT_IMSI_UNKNOWN_IN_HLR = 2,
559 GSM48_REJECT_ILLEGAL_MS = 3,
560 GSM48_REJECT_IMSI_UNKNOWN_IN_VLR = 4,
561 GSM48_REJECT_IMEI_NOT_ACCEPTED = 5,
562 GSM48_REJECT_ILLEGAL_ME = 6,
563 GSM48_REJECT_PLMN_NOT_ALLOWED = 11,
564 GSM48_REJECT_LOC_NOT_ALLOWED = 12,
565 GSM48_REJECT_ROAMING_NOT_ALLOWED = 13,
566 GSM48_REJECT_NETWORK_FAILURE = 17,
567 GSM48_REJECT_CONGESTION = 22,
568 GSM48_REJECT_SRV_OPT_NOT_SUPPORTED = 32,
569 GSM48_REJECT_RQD_SRV_OPT_NOT_SUPPORTED = 33,
570 GSM48_REJECT_SRV_OPT_TMP_OUT_OF_ORDER = 34,
571 GSM48_REJECT_CALL_CAN_NOT_BE_IDENTIFIED = 38,
572 GSM48_REJECT_INCORRECT_MESSAGE = 95,
573 GSM48_REJECT_INVALID_MANDANTORY_INF = 96,
574 GSM48_REJECT_MSG_TYPE_NOT_IMPLEMENTED = 97,
575 GSM48_REJECT_MSG_TYPE_NOT_COMPATIBLE = 98,
576 GSM48_REJECT_INF_ELEME_NOT_IMPLEMENTED = 99,
577 GSM48_REJECT_CONDTIONAL_IE_ERROR = 100,
578 GSM48_REJECT_MSG_NOT_COMPATIBLE = 101,
579 GSM48_REJECT_PROTOCOL_ERROR = 111,
580
581 /* according to G.6 Additional cause codes for GMM */
582 GSM48_REJECT_GPRS_NOT_ALLOWED = 7,
583 GSM48_REJECT_SERVICES_NOT_ALLOWED = 8,
584 GSM48_REJECT_MS_IDENTITY_NOT_DERVIVABLE = 9,
585 GSM48_REJECT_IMPLICITLY_DETACHED = 10,
586 GSM48_REJECT_GPRS_NOT_ALLOWED_IN_PLMN = 14,
587 GSM48_REJECT_MSC_TMP_NOT_REACHABLE = 16,
588};
589
590
Harald Weltef7c43522009-06-09 20:24:21 +0000591/* extracted from a L3 measurement report IE */
592struct gsm_meas_rep_cell {
593 u_int8_t rxlev;
594 u_int8_t bcch_freq; /* fixme: translate to ARFCN */
595 u_int8_t bsic;
596};
597
598struct gsm_meas_rep {
599 unsigned int flags;
600 u_int8_t rxlev_full;
601 u_int8_t rxqual_full;
602 u_int8_t rxlev_sub;
603 u_int8_t rxqual_sub;
604 int num_cell;
605 struct gsm_meas_rep_cell cell[6];
606};
607#define MEAS_REP_F_DTX 0x01
608#define MEAS_REP_F_VALID 0x02
609#define MEAS_REP_F_BA1 0x04
610
611void gsm48_parse_meas_rep(struct gsm_meas_rep *rep, const u_int8_t *data,
612 int len);
613
Harald Welte4bfdfe72009-06-10 23:11:52 +0800614enum chreq_type {
615 CHREQ_T_EMERG_CALL,
616 CHREQ_T_CALL_REEST_TCH_F,
617 CHREQ_T_CALL_REEST_TCH_H,
618 CHREQ_T_CALL_REEST_TCH_H_DBL,
619 CHREQ_T_SDCCH,
620 CHREQ_T_TCH_F,
621 CHREQ_T_VOICE_CALL_TCH_H,
622 CHREQ_T_DATA_CALL_TCH_H,
623 CHREQ_T_LOCATION_UPD,
624 CHREQ_T_PAG_R_ANY,
625 CHREQ_T_PAG_R_TCH_F,
626 CHREQ_T_PAG_R_TCH_FH,
627};
628
629/* Chapter 11.3 */
630#define GSM48_T301 180, 0
631#define GSM48_T303 30, 0
632#define GSM48_T305 30, 0
633#define GSM48_T306 30, 0
634#define GSM48_T308 10, 0
635#define GSM48_T310 180, 0
636#define GSM48_T313 30, 0
637#define GSM48_T323 30, 0
638#define GSM48_T331 30, 0
639#define GSM48_T333 30, 0
640#define GSM48_T334 25, 0 /* min 15 */
641#define GSM48_T338 30, 0
642
643/* Chapter 5.1.2.2 */
644#define GSM_CSTATE_NULL 0
645#define GSM_CSTATE_INITIATED 1
646#define GSM_CSTATE_MO_CALL_PROC 3
647#define GSM_CSTATE_CALL_DELIVERED 4
648#define GSM_CSTATE_CALL_PRESENT 6
649#define GSM_CSTATE_CALL_RECEIVED 7
650#define GSM_CSTATE_CONNECT_REQUEST 8
651#define GSM_CSTATE_MO_TERM_CALL_CONF 9
652#define GSM_CSTATE_ACTIVE 10
653#define GSM_CSTATE_DISCONNECT_REQ 12
654#define GSM_CSTATE_DISCONNECT_IND 12
655#define GSM_CSTATE_RELEASE_REQ 19
656#define GSM_CSTATE_MO_ORIG_MODIFY 26
657#define GSM_CSTATE_MO_TERM_MODIFY 27
658#define GSM_CSTATE_CONNECT_IND 28
659
660#define SBIT(a) (1 << a)
661#define ALL_STATES 0xffffffff
Harald Weltef7c43522009-06-09 20:24:21 +0000662
Holger Hans Peter Freythere48b9562009-10-01 04:07:15 +0200663/* Table 10.5.3/3GPP TS 04.08: Location Area Identification information element */
664#define GSM_LAC_RESERVED_DETACHED 0x0
665#define GSM_LAC_RESERVED_ALL_BTS 0xfffe
666
Harald Welte5072be92009-07-29 11:38:46 +0200667/* GSM 04.08 Bearer Capability: Information Transfer Capability */
668enum gsm48_bcap_itcap {
669 GSM48_BCAP_ITCAP_SPEECH = 0,
670 GSM48_BCAP_ITCAP_UNR_DIG_INF = 1,
671 GSM48_BCAP_ITCAP_3k1_AUDIO = 2,
672 GSM48_BCAP_ITCAP_FAX_G3 = 3,
673 GSM48_BCAP_ITCAP_OTHER = 5,
674 GSM48_BCAP_ITCAP_RESERVED = 7,
675};
676
677/* GSM 04.08 Bearer Capability: Transfer Mode */
678enum gsm48_bcap_tmod {
679 GSM48_BCAP_TMOD_CIRCUIT = 0,
680 GSM48_BCAP_TMOD_PACKET = 1,
681};
682
683/* GSM 04.08 Bearer Capability: Coding Standard */
684enum gsm48_bcap_coding {
685 GSM48_BCAP_CODING_GSM_STD = 0,
686};
687
688/* GSM 04.08 Bearer Capability: Radio Channel Requirements */
689enum gsm48_bcap_rrq {
690 GSM48_BCAP_RRQ_FR_ONLY = 1,
691 GSM48_BCAP_RRQ_DUAL_HR = 2,
692 GSM48_BCAP_RRQ_DUAL_FR = 3,
693};
694
Holger Hans Peter Freyther1494a762009-08-01 07:26:59 +0200695
696#define GSM48_TMSI_LEN 5
697#define GSM48_MID_TMSI_LEN (GSM48_TMSI_LEN + 2)
Holger Hans Peter Freytherd1862d72009-08-19 07:54:59 +0200698#define GSM48_MI_SIZE 32
Holger Hans Peter Freyther1494a762009-08-01 07:26:59 +0200699
700
Harald Welte8470bf22008-12-25 23:28:35 +0000701struct msgb;
702struct gsm_bts;
Harald Welte0932d1e2009-02-16 22:53:52 +0000703struct gsm_subscriber;
Harald Welte4bfdfe72009-06-10 23:11:52 +0800704struct gsm_network;
Harald Welte39e2ead2009-07-23 21:13:03 +0200705struct gsm_trans;
Harald Welte8470bf22008-12-25 23:28:35 +0000706
Holger Freythere97f7fb2008-12-31 18:52:11 +0000707/* config options controlling the behaviour of the lower leves */
Holger Freyther89824fc2008-12-30 16:18:18 +0000708void gsm0408_allow_everyone(int allow);
Holger Freythere97f7fb2008-12-31 18:52:11 +0000709void gsm0408_set_reject_cause(int cause);
710
Harald Welte (local)daef6062009-08-14 11:41:12 +0200711int gsm0408_rcvmsg(struct msgb *msg, u_int8_t link_id);
Holger Freyther17746612008-12-28 16:32:44 +0000712void gsm0408_generate_lai(struct gsm48_loc_area_id *lai48, u_int16_t mcc,
713 u_int16_t mnc, u_int16_t lac);
Harald Welte8470bf22008-12-25 23:28:35 +0000714enum gsm_chan_t get_ctype_by_chreq(struct gsm_bts *bts, u_int8_t ra);
Harald Weltee14a57c2008-12-29 04:08:28 +0000715enum gsm_chreq_reason_t get_reason_by_chreq(struct gsm_bts *bts, u_int8_t ra);
Harald Welte8470bf22008-12-25 23:28:35 +0000716
Harald Weltec6ba9c22008-12-30 18:01:02 +0000717int gsm48_tx_mm_info(struct gsm_lchan *lchan);
Harald Welte7984d5c2009-08-12 22:56:50 +0200718int gsm48_tx_mm_auth_req(struct gsm_lchan *lchan, u_int8_t *rand);
719int gsm48_tx_mm_auth_rej(struct gsm_lchan *lchan);
Holger Freyther819dd202009-01-04 03:52:50 +0000720struct msgb *gsm48_msgb_alloc(void);
Harald Welte39e2ead2009-07-23 21:13:03 +0200721int gsm48_sendmsg(struct msgb *msg, struct gsm_trans *trans);
Holger Hans Peter Freyther5d0e56f2009-08-20 08:41:24 +0200722int gsm48_generate_mid_from_tmsi(u_int8_t *buf, u_int32_t tmsi);
723int gsm48_generate_mid_from_imsi(u_int8_t *buf, const char* imsi);
Holger Hans Peter Freytherd1862d72009-08-19 07:54:59 +0200724int gsm48_mi_to_string(char *string, const int str_len, const u_int8_t *mi, const int mi_len);
Harald Weltec6ba9c22008-12-30 18:01:02 +0000725
Holger Freythere64a7a32009-02-06 21:55:37 +0000726int gsm48_send_rr_release(struct gsm_lchan *lchan);
Holger Hans Peter Freytherca6bc1d2009-10-05 14:00:14 +0200727int gsm48_send_rr_ciph_mode(struct gsm_lchan *lchan, int want_imeisv);
Harald Welte (local)6eef5642009-08-15 23:32:44 +0200728int gsm48_send_rr_app_info(struct gsm_lchan *lchan, u_int8_t apdu_id,
729 u_int8_t apdu_len, u_int8_t *apdu);
Harald Welte8470bf22008-12-25 23:28:35 +0000730
Harald Welte4bfdfe72009-06-10 23:11:52 +0800731int bsc_upqueue(struct gsm_network *net);
732
733int mncc_send(struct gsm_network *net, int msg_type, void *arg);
734
Harald Welte0932d1e2009-02-16 22:53:52 +0000735/* convert a ASCII phone number to call-control BCD */
736int encode_bcd_number(u_int8_t *bcd_lv, u_int8_t max_len,
Harald Welte0c389302009-06-10 12:08:54 +0800737 int h_len, const char *input);
738int decode_bcd_number(char *output, int output_len, const u_int8_t *bcd_lv,
739 int h_len);
Harald Welte0932d1e2009-02-16 22:53:52 +0000740
Holger Hans Peter Freyther1494a762009-08-01 07:26:59 +0200741extern const char *gsm0408_cc_msg_names[];
742
Holger Hans Peter Freytheradc14782009-08-21 04:57:35 +0200743int send_siemens_mrpci(struct gsm_lchan *lchan, u_int8_t *classmark2_lv);
Holger Hans Peter Freyther3ee5d3e2009-08-21 05:18:21 +0200744int gsm48_paging_extract_mi(struct msgb *msg, char *mi_string, u_int8_t *mi_type);
745int gsm48_handle_paging_resp(struct msgb *msg, struct gsm_subscriber *subscr);
Holger Hans Peter Freytheradc14782009-08-21 04:57:35 +0200746
Harald Welte52b1f982008-12-23 20:25:15 +0000747#endif