blob: e781677c39f6ecb58f00f93bf3ae64ab450b2c5a [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
7/* Chapter 10.5.2.5 */
8struct gsm48_chan_desc {
9 u_int8_t chan_nr;
10 union {
11 struct {
12 u_int8_t maio_high:4,
13 h:1,
14 tsc:3;
15 u_int8_t hsn:6,
16 maio_low:2;
17 } h1;
18 struct {
19 u_int8_t arfcn_high:2,
20 spare:2,
21 h:1,
22 tsc:3;
23 u_int8_t arfcn_low;
24 } h0;
25 };
Harald Welteb84e2f42008-12-28 23:42:04 +000026} __attribute__ ((packed));
Harald Welte52b1f982008-12-23 20:25:15 +000027
28/* Chapter 10.5.2.30 */
29struct gsm48_req_ref {
30 u_int8_t ra;
31 u_int8_t t3_high:3,
32 t1_:5;
33 u_int8_t t2:5,
34 t3_low:3;
Harald Welteb84e2f42008-12-28 23:42:04 +000035} __attribute__ ((packed));
Harald Welte52b1f982008-12-23 20:25:15 +000036
37/* Chapter 9.1.18 */
38struct gsm48_imm_ass {
39 u_int8_t l2_plen;
40 u_int8_t proto_discr;
41 u_int8_t msg_type;
42 u_int8_t page_mode;
43 struct gsm48_chan_desc chan_desc;
44 struct gsm48_req_ref req_ref;
45 u_int8_t timing_advance;
46 u_int8_t mob_alloc_len;
47 u_int8_t mob_alloc[0];
Harald Welteb84e2f42008-12-28 23:42:04 +000048} __attribute__ ((packed));
Harald Welte52b1f982008-12-23 20:25:15 +000049
Harald Welte4b634542008-12-27 01:55:51 +000050/* Chapter 10.5.1.3 */
Harald Welte52b1f982008-12-23 20:25:15 +000051struct gsm48_loc_area_id {
52 u_int8_t digits[3]; /* BCD! */
53 u_int16_t lac;
54} __attribute__ ((packed));
55
56/* Section 9.2.15 */
57struct gsm48_loc_upd_req {
58 u_int8_t type:4,
59 key_seq:4;
60 struct gsm48_loc_area_id lai;
61 u_int8_t classmark1;
Harald Welte52b1f982008-12-23 20:25:15 +000062 u_int8_t mi_len;
63 u_int8_t mi[0];
64} __attribute__ ((packed));
65
66/* Section 10.1 */
67struct gsm48_hdr {
68 u_int8_t proto_discr;
69 u_int8_t msg_type;
70 u_int8_t data[0];
71} __attribute__ ((packed));
72
Holger Freyther5e85c8e2008-12-28 16:32:39 +000073/* Section 9.1.3x System information Type header */
74struct gsm48_system_information_type_header {
75 u_int8_t l2_plen;
76 u_int8_t rr_protocol_discriminator :4,
77 skip_indicator:4;
78 u_int8_t system_information;
79} __attribute__ ((packed));
80
Harald Weltede9226d2008-12-29 02:37:23 +000081struct gsm48_rach_control {
82 u_int8_t re :1,
83 cell_bar :1,
84 tx_integer :4,
85 max_trans :2;
86 u_int8_t t2;
87 u_int8_t t3;
88} __attribute__ ((packed));
89
Holger Freyther1adb4ff2009-02-04 00:04:52 +000090/* Section 10.5.2.11 Control Channel Description , Figure 10.5.33 */
91struct gsm48_control_channel_descr {
92 u_int8_t ccch_conf :3,
93 bs_ag_blks_res :3,
94 att :1,
95 spare1 :1;
96 u_int8_t bs_pa_mfrms : 3,
97 spare2 :5;
98 u_int8_t t3212;
99} __attribute__ ((packed));
100
Harald Welte2d35ae62009-02-06 12:02:13 +0000101/* Section 9.1.25 PAGING RESPONSE */
102struct gsm48_paging_response {
103 u_int8_t spare:4,
104 cipher_keyt_seq:4;
105 /* length + 3 bytes */
106 u_int32_t classmark2;
107 u_int8_t mi_len;
108 u_int8_t mi[0];
109} __attribute__ ((packed));
110
Harald Welteba4cf162009-01-10 01:49:35 +0000111/* Section 9.2.9 CM service request */
112struct gsm48_service_request {
113 u_int8_t cm_service_type : 4,
114 cipher_key_seq : 4;
115 /* length + 3 bytes */
116 u_int32_t classmark;
117 u_int8_t mi_len;
118 u_int8_t mi[0];
119 /* optional priority level */
120} __attribute__ ((packed));
121
Holger Freyther5e85c8e2008-12-28 16:32:39 +0000122/* Section 9.1.31 System information Type 1 */
123struct gsm48_system_information_type_1 {
124 struct gsm48_system_information_type_header header;
125 u_int8_t cell_channel_description[16];
Harald Weltede9226d2008-12-29 02:37:23 +0000126 struct gsm48_rach_control rach_control;
Holger Freyther5e85c8e2008-12-28 16:32:39 +0000127 u_int8_t s1_reset;
128} __attribute__ ((packed));
129
130/* Section 9.1.32 System information Type 2 */
131struct gsm48_system_information_type_2 {
132 struct gsm48_system_information_type_header header;
133 u_int8_t bcch_frequency_list[16];
134 u_int8_t ncc_permitted;
Harald Weltede9226d2008-12-29 02:37:23 +0000135 struct gsm48_rach_control rach_control;
Holger Freyther5e85c8e2008-12-28 16:32:39 +0000136} __attribute__ ((packed));
137
138/* Section 9.1.35 System information Type 3 */
139struct gsm48_system_information_type_3 {
140 struct gsm48_system_information_type_header header;
141 u_int16_t cell_identity;
142 struct gsm48_loc_area_id lai;
Holger Freyther1adb4ff2009-02-04 00:04:52 +0000143 struct gsm48_control_channel_descr control_channel_desc;
Holger Freyther5e85c8e2008-12-28 16:32:39 +0000144 u_int8_t cell_options;
145 u_int8_t cell_selection[2];
Harald Weltede9226d2008-12-29 02:37:23 +0000146 struct gsm48_rach_control rach_control;
Holger Freyther5e85c8e2008-12-28 16:32:39 +0000147 u_int8_t s3_reset_octets[4];
148} __attribute__ ((packed));
149
150/* Section 9.1.36 System information Type 4 */
151struct gsm48_system_information_type_4 {
152 struct gsm48_system_information_type_header header;
153 struct gsm48_loc_area_id lai;
154 u_int8_t cell_selection[2];
Harald Weltede9226d2008-12-29 02:37:23 +0000155 struct gsm48_rach_control rach_control;
Holger Freyther5e85c8e2008-12-28 16:32:39 +0000156 /* optional CBCH conditional CBCH... followed by
157 mandantory SI 4 Reset Octets
158 */
159 u_int8_t data[0];
160} __attribute__ ((packed));
161
162/* Section 9.1.37 System information Type 5 */
163struct gsm48_system_information_type_5 {
164 u_int8_t rr_protocol_discriminator :4,
165 skip_indicator:4;
166 u_int8_t system_information;
167 u_int8_t bcch_frequency_list[16];
168} __attribute__ ((packed));
169
170/* Section 9.1.40 System information Type 6 */
171struct gsm48_system_information_type_6 {
172 u_int8_t rr_protocol_discriminator :4,
173 skip_indicator:4;
174 u_int8_t system_information;
175 u_int8_t cell_identity[2];
176 struct gsm48_loc_area_id lai;
177 u_int8_t cell_options;
178 u_int8_t ncc_permitted;
179 u_int8_t si_6_reset[0];
180} __attribute__ ((packed));
181
Harald Weltebcae43f2008-12-27 21:45:37 +0000182/* Section 10.2 + GSM 04.07 12.2.3.1.1 */
183#define GSM48_PDISC_GROUP_CC 0x00
184#define GSM48_PDISC_BCAST_CC 0x01
185#define GSM48_PDISC_PDSS1 0x02
Harald Welte4b634542008-12-27 01:55:51 +0000186#define GSM48_PDISC_CC 0x03
Harald Weltebcae43f2008-12-27 21:45:37 +0000187#define GSM48_PDISC_PDSS2 0x04
Harald Welte52b1f982008-12-23 20:25:15 +0000188#define GSM48_PDISC_MM 0x05
189#define GSM48_PDISC_RR 0x06
190#define GSM48_PDISC_MM_GPRS 0x08
Harald Weltebcae43f2008-12-27 21:45:37 +0000191#define GSM48_PDISC_SMS 0x09
192#define GSM48_PDISC_SM_GPRS 0x0a
193#define GSM48_PDISC_NC_SS 0x0b
194#define GSM48_PDISC_LOC 0x0c
Harald Weltede9226d2008-12-29 02:37:23 +0000195#define GSM48_PDISC_MASK 0x0f
Harald Welte52b1f982008-12-23 20:25:15 +0000196
197/* Section 10.4 */
198#define GSM48_MT_RR_INIT_REQ 0x3c
199#define GSM48_MT_RR_ADD_ASS 0x3b
200#define GSM48_MT_RR_IMM_ASS 0x3f
201#define GSM48_MT_RR_IMM_ASS_EXT 0x39
202#define GSM48_MT_RR_IMM_ASS_REJ 0x3a
203
204#define GSM48_MT_RR_CIPH_M_CMD 0x35
205#define GSM48_MT_RR_CIPH_M_COMPL 0x32
206
207#define GSM48_MT_RR_CFG_CHG_CMD 0x30
208#define GSM48_MT_RR_CFG_CHG_ACK 0x31
209#define GSM48_MT_RR_CFG_CHG_REJ 0x33
210
211#define GSM48_MT_RR_ASS_CMD 0x2e
212#define GSM48_MT_RR_ASS_COMPL 0x29
213#define GSM48_MT_RR_ASS_FAIL 0x2f
214#define GSM48_MT_RR_HANDO_CMD 0x2b
215#define GSM48_MT_RR_HANDO_COMPL 0x2c
216#define GSM48_MT_RR_HANDO_FAIL 0x28
217#define GSM48_MT_RR_HANDO_INFO 0x2d
218
219#define GSM48_MT_RR_CELL_CHG_ORDER 0x08
220#define GSM48_MT_RR_PDCH_ASS_CMD 0x23
221
222#define GSM48_MT_RR_CHAN_REL 0x0d
223#define GSM48_MT_RR_PART_REL 0x0a
224#define GSM48_MT_RR_PART_REL_COMP 0x0f
225
226#define GSM48_MT_RR_PAG_REQ_1 0x21
227#define GSM48_MT_RR_PAG_REQ_2 0x22
228#define GSM48_MT_RR_PAG_REQ_3 0x24
229#define GSM48_MT_RR_PAG_RESP 0x27
230#define GSM48_MT_RR_NOTIF_NCH 0x20
231#define GSM48_MT_RR_NOTIF_FACCH 0x25
232#define GSM48_MT_RR_NOTIF_RESP 0x26
233
234#define GSM48_MT_RR_SYSINFO_8 0x18
235#define GSM48_MT_RR_SYSINFO_1 0x19
236#define GSM48_MT_RR_SYSINFO_2 0x1a
237#define GSM48_MT_RR_SYSINFO_3 0x1b
238#define GSM48_MT_RR_SYSINFO_4 0x1c
239#define GSM48_MT_RR_SYSINFO_5 0x1d
240#define GSM48_MT_RR_SYSINFO_6 0x1e
241#define GSM48_MT_RR_SYSINFO_7 0x1f
242
243#define GSM48_MT_RR_SYSINFO_2bis 0x02
244#define GSM48_MT_RR_SYSINFO_2ter 0x03
245#define GSM48_MT_RR_SYSINFO_5bis 0x05
246#define GSM48_MT_RR_SYSINFO_5ter 0x06
247#define GSM48_MT_RR_SYSINFO_9 0x04
248#define GSM48_MT_RR_SYSINFO_13 0x00
249
250#define GSM48_MT_RR_SYSINFO_16 0x3d
251#define GSM48_MT_RR_SYSINFO_17 0x3e
252
253#define GSM48_MT_RR_CHAN_MODE_MODIF 0x10
254#define GSM48_MT_RR_STATUS 0x12
255#define GSM48_MT_RR_CHAN_MODE_MODIF_ACK 0x17
256#define GSM48_MT_RR_FREQ_REDEF 0x14
257#define GSM48_MT_RR_MEAS_REP 0x15
258#define GSM48_MT_RR_CLSM_CHG 0x16
259#define GSM48_MT_RR_CLSM_ENQ 0x13
260#define GSM48_MT_RR_EXT_MEAS_REP 0x36
261#define GSM48_MT_RR_EXT_MEAS_REP_ORD 0x37
262#define GSM48_MT_RR_GPRS_SUSP_REQ 0x34
263
264#define GSM48_MT_RR_VGCS_UPL_GRANT 0x08
265#define GSM48_MT_RR_UPLINK_RELEASE 0x0e
266#define GSM48_MT_RR_UPLINK_FREE 0x0c
267#define GSM48_MT_RR_UPLINK_BUSY 0x2a
268#define GSM48_MT_RR_TALKER_IND 0x11
269
270#define GSM48_MT_RR_APP_INFO 0x38
271
272/* Table 10.2/3GPP TS 04.08 */
273#define GSM48_MT_MM_IMSI_DETACH_IND 0x01
274#define GSM48_MT_MM_LOC_UPD_ACCEPT 0x02
275#define GSM48_MT_MM_LOC_UPD_REJECT 0x04
276#define GSM48_MT_MM_LOC_UPD_REQUEST 0x08
277
278#define GSM48_MT_MM_AUTH_REJ 0x11
279#define GSM48_MT_MM_AUTH_REQ 0x12
280#define GSM48_MT_MM_AUTH_RESP 0x14
281#define GSM48_MT_MM_ID_REQ 0x18
282#define GSM48_MT_MM_ID_RESP 0x19
283#define GSM48_MT_MM_TMSI_REALL_CMD 0x1a
284#define GSM48_MT_MM_TMSI_REALL_COMPL 0x1b
285
286#define GSM48_MT_MM_CM_SERV_ACC 0x21
287#define GSM48_MT_MM_CM_SERV_REJ 0x22
288#define GSM48_MT_MM_CM_SERV_ABORT 0x23
289#define GSM48_MT_MM_CM_SERV_REQ 0x24
290#define GSM48_MT_MM_CM_SERV_PROMPT 0x25
291#define GSM48_MT_MM_CM_REEST_REQ 0x28
292#define GSM48_MT_MM_ABORT 0x29
293
294#define GSM48_MT_MM_NULL 0x30
295#define GSM48_MT_MM_STATUS 0x31
296#define GSM48_MT_MM_INFO 0x32
297
298/* Table 10.3/3GPP TS 04.08 */
299#define GSM48_MT_CC_ALERTING 0x01
300#define GSM48_MT_CC_CALL_CONF 0x08
301#define GSM48_MT_CC_CALL_PROC 0x02
302#define GSM48_MT_CC_CONNECT 0x07
303#define GSM48_MT_CC_CONNECT_ACK 0x0f
304#define GSM48_MT_CC_EMERG_SETUP 0x0e
305#define GSM48_MT_CC_PROGRESS 0x03
306#define GSM48_MT_CC_ESTAB 0x04
307#define GSM48_MT_CC_ESTAB_CONF 0x06
308#define GSM48_MT_CC_RECALL 0x0b
309#define GSM48_MT_CC_START_CC 0x09
310#define GSM48_MT_CC_SETUP 0x05
311
312#define GSM48_MT_CC_MODIFY 0x17
313#define GSM48_MT_CC_MODIFY_COMPL 0x1f
314#define GSM48_MT_CC_MODIFY_REJECT 0x13
315#define GSM48_MT_CC_USER_INFO 0x10
316#define GSM48_MT_CC_HOLD 0x18
317#define GSM48_MT_CC_HOLD_ACK 0x19
318#define GSM48_MT_CC_HOLD_REJ 0x1a
319#define GSM48_MT_CC_RETR 0x1c
320#define GSM48_MT_CC_RETR_ACK 0x1d
321#define GSM48_MT_CC_RETR_REJ 0x1e
322
323#define GSM48_MT_CC_DISCONNECT 0x25
324#define GSM48_MT_CC_RELEASE 0x2d
325#define GSM48_MT_CC_RELEASE_COMPL 0xea
326
327#define GSM48_MT_CC_CONG_CTRL 0x39
328#define GSM48_MT_CC_NOTIFY 0x3e
329#define GSM48_MT_CC_STATUS 0x3d
330#define GSM48_MT_CC_STATUS_ENQ 0x34
331#define GSM48_MT_CC_START_DTMF 0x35
332#define GSM48_MT_CC_STOP_DTMF 0x31
333#define GSM48_MT_CC_STOP_DTMF_ACK 0x32
334#define GSM48_MT_CC_START_DTMF_ACK 0x36
335#define GSM48_MT_CC_START_DTMF_REJ 0x37
336#define GSM48_MT_CC_FACILITY 0x3a
337
338/* FIXME: Table 10.4 / 10.4a (GPRS) */
339
340/* Section 10.5.2.26, Table 10.5.64 */
341#define GSM48_PM_MASK 0x03
342#define GSM48_PM_NORMAL 0x00
343#define GSM48_PM_EXTENDED 0x01
344#define GSM48_PM_REORG 0x02
345#define GSM48_PM_SAME 0x03
346
347/* Table 10.5.4 */
348#define GSM_MI_TYPE_MASK 0x07
349#define GSM_MI_TYPE_NONE 0x00
350#define GSM_MI_TYPE_IMSI 0x01
351#define GSM_MI_TYPE_IMEI 0x02
352#define GSM_MI_TYPE_IMEISV 0x03
353#define GSM_MI_TYPE_TMSI 0x04
354#define GSM_MI_ODD 0x08
355
Harald Welte4b634542008-12-27 01:55:51 +0000356#define GSM48_IE_MOBILE_ID 0x17
Harald Weltec6ba9c22008-12-30 18:01:02 +0000357#define GSM48_IE_NAME_LONG 0x43 /* 10.5.3.5a */
358#define GSM48_IE_NAME_SHORT 0x45 /* 10.5.3.5a */
359#define GSM48_IE_UTC 0x46 /* 10.5.3.8 */
360#define GSM48_IE_NET_TIME_TZ 0x47 /* 10.5.3.9 */
361#define GSM48_IE_LSA_IDENT 0x48 /* 10.5.3.11 */
Harald Welte4b634542008-12-27 01:55:51 +0000362
363/* Section 10.5.4.11 / Table 10.5.122 */
364#define GSM48_CAUSE_CS_GSM 0x60
365
366enum gsm48_cause_loc {
367 GSM48_CAUSE_LOC_USER = 0x00,
368 GSM48_CAUSE_LOC_PRN_S_LU = 0x01,
369 GSM48_CAUSE_LOC_PUN_S_LU = 0x02,
370 GSM48_CAUSE_LOC_TRANS_NET = 0x03,
371 GSM48_CAUSE_LOC_PUN_S_RU = 0x04,
372 GSM48_CAUSE_LOC_PRN_S_RU = 0x05,
373 /* not defined */
374 GSM48_CAUSE_LOC_INN_NET = 0x07,
375 GSM48_CAUSE_LOC_NET_BEYOND = 0x0a,
376};
377
Holger Freythera7677942008-12-30 16:18:16 +0000378/* Annex G, GSM specific cause values for mobility management */
379enum gsm48_reject_value {
380 GSM48_REJECT_IMSI_UNKNOWN_IN_HLR = 2,
381 GSM48_REJECT_ILLEGAL_MS = 3,
382 GSM48_REJECT_IMSI_UNKNOWN_IN_VLR = 4,
383 GSM48_REJECT_IMEI_NOT_ACCEPTED = 5,
384 GSM48_REJECT_ILLEGAL_ME = 6,
385 GSM48_REJECT_PLMN_NOT_ALLOWED = 11,
386 GSM48_REJECT_LOC_NOT_ALLOWED = 12,
387 GSM48_REJECT_ROAMING_NOT_ALLOWED = 13,
388 GSM48_REJECT_NETWORK_FAILURE = 17,
389 GSM48_REJECT_CONGESTION = 22,
390 GSM48_REJECT_SRV_OPT_NOT_SUPPORTED = 32,
391 GSM48_REJECT_RQD_SRV_OPT_NOT_SUPPORTED = 33,
392 GSM48_REJECT_SRV_OPT_TMP_OUT_OF_ORDER = 34,
393 GSM48_REJECT_CALL_CAN_NOT_BE_IDENTIFIED = 38,
394 GSM48_REJECT_INCORRECT_MESSAGE = 95,
395 GSM48_REJECT_INVALID_MANDANTORY_INF = 96,
396 GSM48_REJECT_MSG_TYPE_NOT_IMPLEMENTED = 97,
397 GSM48_REJECT_MSG_TYPE_NOT_COMPATIBLE = 98,
398 GSM48_REJECT_INF_ELEME_NOT_IMPLEMENTED = 99,
399 GSM48_REJECT_CONDTIONAL_IE_ERROR = 100,
400 GSM48_REJECT_MSG_NOT_COMPATIBLE = 101,
401 GSM48_REJECT_PROTOCOL_ERROR = 111,
402
403 /* according to G.6 Additional cause codes for GMM */
404 GSM48_REJECT_GPRS_NOT_ALLOWED = 7,
405 GSM48_REJECT_SERVICES_NOT_ALLOWED = 8,
406 GSM48_REJECT_MS_IDENTITY_NOT_DERVIVABLE = 9,
407 GSM48_REJECT_IMPLICITLY_DETACHED = 10,
408 GSM48_REJECT_GPRS_NOT_ALLOWED_IN_PLMN = 14,
409 GSM48_REJECT_MSC_TMP_NOT_REACHABLE = 16,
410};
411
412
Harald Welte8470bf22008-12-25 23:28:35 +0000413struct msgb;
414struct gsm_bts;
415
Holger Freythere97f7fb2008-12-31 18:52:11 +0000416/* config options controlling the behaviour of the lower leves */
Holger Freyther89824fc2008-12-30 16:18:18 +0000417void gsm0408_allow_everyone(int allow);
Holger Freythere97f7fb2008-12-31 18:52:11 +0000418void gsm0408_set_reject_cause(int cause);
419
Harald Welte8470bf22008-12-25 23:28:35 +0000420int gsm0408_rcvmsg(struct msgb *msg);
Holger Freyther17746612008-12-28 16:32:44 +0000421void gsm0408_generate_lai(struct gsm48_loc_area_id *lai48, u_int16_t mcc,
422 u_int16_t mnc, u_int16_t lac);
Holger Freytherabade7a2008-12-29 06:42:15 +0000423int gsm48_cc_tx_setup(struct gsm_lchan *lchan);
Harald Welte8470bf22008-12-25 23:28:35 +0000424enum gsm_chan_t get_ctype_by_chreq(struct gsm_bts *bts, u_int8_t ra);
Harald Weltee14a57c2008-12-29 04:08:28 +0000425enum gsm_chreq_reason_t get_reason_by_chreq(struct gsm_bts *bts, u_int8_t ra);
Harald Welte8470bf22008-12-25 23:28:35 +0000426
Harald Weltec6ba9c22008-12-30 18:01:02 +0000427int gsm48_tx_mm_info(struct gsm_lchan *lchan);
Holger Freyther819dd202009-01-04 03:52:50 +0000428struct msgb *gsm48_msgb_alloc(void);
Holger Freyther3e2c3232009-01-04 03:55:31 +0000429int gsm48_sendmsg(struct msgb *msg);
Holger Freytherca362a62009-01-04 21:05:01 +0000430int generate_mid_from_tmsi(u_int8_t *buf, u_int32_t tmsi);
Harald Weltec6ba9c22008-12-30 18:01:02 +0000431
Harald Welte8470bf22008-12-25 23:28:35 +0000432
Harald Welte52b1f982008-12-23 20:25:15 +0000433#endif