Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1 | #ifndef _GSM_04_08_H |
| 2 | #define _GSM_04_08_H |
| 3 | |
| 4 | /* GSM TS 04.08 definitions */ |
| 5 | |
| 6 | /* Chapter 10.5.2.5 */ |
| 7 | struct gsm48_chan_desc { |
| 8 | u_int8_t chan_nr; |
| 9 | union { |
| 10 | struct { |
| 11 | u_int8_t maio_high:4, |
| 12 | h:1, |
| 13 | tsc:3; |
| 14 | u_int8_t hsn:6, |
| 15 | maio_low:2; |
| 16 | } h1; |
| 17 | struct { |
| 18 | u_int8_t arfcn_high:2, |
| 19 | spare:2, |
| 20 | h:1, |
| 21 | tsc:3; |
| 22 | u_int8_t arfcn_low; |
| 23 | } h0; |
| 24 | }; |
Harald Welte | b84e2f4 | 2008-12-28 23:42:04 +0000 | [diff] [blame] | 25 | } __attribute__ ((packed)); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 26 | |
| 27 | /* Chapter 10.5.2.30 */ |
| 28 | struct gsm48_req_ref { |
| 29 | u_int8_t ra; |
| 30 | u_int8_t t3_high:3, |
| 31 | t1_:5; |
| 32 | u_int8_t t2:5, |
| 33 | t3_low:3; |
Harald Welte | b84e2f4 | 2008-12-28 23:42:04 +0000 | [diff] [blame] | 34 | } __attribute__ ((packed)); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 35 | |
| 36 | /* Chapter 9.1.18 */ |
| 37 | struct gsm48_imm_ass { |
| 38 | u_int8_t l2_plen; |
| 39 | u_int8_t proto_discr; |
| 40 | u_int8_t msg_type; |
| 41 | u_int8_t page_mode; |
| 42 | struct gsm48_chan_desc chan_desc; |
| 43 | struct gsm48_req_ref req_ref; |
| 44 | u_int8_t timing_advance; |
| 45 | u_int8_t mob_alloc_len; |
| 46 | u_int8_t mob_alloc[0]; |
Harald Welte | b84e2f4 | 2008-12-28 23:42:04 +0000 | [diff] [blame] | 47 | } __attribute__ ((packed)); |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 48 | |
Harald Welte | 4b63454 | 2008-12-27 01:55:51 +0000 | [diff] [blame] | 49 | /* Chapter 10.5.1.3 */ |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 50 | struct gsm48_loc_area_id { |
| 51 | u_int8_t digits[3]; /* BCD! */ |
| 52 | u_int16_t lac; |
| 53 | } __attribute__ ((packed)); |
| 54 | |
| 55 | /* Section 9.2.15 */ |
| 56 | struct gsm48_loc_upd_req { |
| 57 | u_int8_t type:4, |
| 58 | key_seq:4; |
| 59 | struct gsm48_loc_area_id lai; |
| 60 | u_int8_t classmark1; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 61 | u_int8_t mi_len; |
| 62 | u_int8_t mi[0]; |
| 63 | } __attribute__ ((packed)); |
| 64 | |
| 65 | /* Section 10.1 */ |
| 66 | struct gsm48_hdr { |
| 67 | u_int8_t proto_discr; |
| 68 | u_int8_t msg_type; |
| 69 | u_int8_t data[0]; |
| 70 | } __attribute__ ((packed)); |
| 71 | |
Holger Freyther | 5e85c8e | 2008-12-28 16:32:39 +0000 | [diff] [blame] | 72 | /* Section 9.1.3x System information Type header */ |
| 73 | struct gsm48_system_information_type_header { |
| 74 | u_int8_t l2_plen; |
| 75 | u_int8_t rr_protocol_discriminator :4, |
| 76 | skip_indicator:4; |
| 77 | u_int8_t system_information; |
| 78 | } __attribute__ ((packed)); |
| 79 | |
| 80 | /* Section 9.1.31 System information Type 1 */ |
| 81 | struct gsm48_system_information_type_1 { |
| 82 | struct gsm48_system_information_type_header header; |
| 83 | u_int8_t cell_channel_description[16]; |
| 84 | u_int8_t rach_control_parameter[3]; |
| 85 | u_int8_t s1_reset; |
| 86 | } __attribute__ ((packed)); |
| 87 | |
| 88 | /* Section 9.1.32 System information Type 2 */ |
| 89 | struct gsm48_system_information_type_2 { |
| 90 | struct gsm48_system_information_type_header header; |
| 91 | u_int8_t bcch_frequency_list[16]; |
| 92 | u_int8_t ncc_permitted; |
| 93 | u_int8_t rach_control_parameter[3]; |
| 94 | } __attribute__ ((packed)); |
| 95 | |
| 96 | /* Section 9.1.35 System information Type 3 */ |
| 97 | struct gsm48_system_information_type_3 { |
| 98 | struct gsm48_system_information_type_header header; |
| 99 | u_int16_t cell_identity; |
| 100 | struct gsm48_loc_area_id lai; |
| 101 | u_int8_t control_channel_description[3]; |
| 102 | u_int8_t cell_options; |
| 103 | u_int8_t cell_selection[2]; |
| 104 | u_int8_t rach_control_parameter[3]; |
| 105 | u_int8_t s3_reset_octets[4]; |
| 106 | } __attribute__ ((packed)); |
| 107 | |
| 108 | /* Section 9.1.36 System information Type 4 */ |
| 109 | struct gsm48_system_information_type_4 { |
| 110 | struct gsm48_system_information_type_header header; |
| 111 | struct gsm48_loc_area_id lai; |
| 112 | u_int8_t cell_selection[2]; |
| 113 | u_int8_t rach_control_parameter[3]; |
| 114 | /* optional CBCH conditional CBCH... followed by |
| 115 | mandantory SI 4 Reset Octets |
| 116 | */ |
| 117 | u_int8_t data[0]; |
| 118 | } __attribute__ ((packed)); |
| 119 | |
| 120 | /* Section 9.1.37 System information Type 5 */ |
| 121 | struct gsm48_system_information_type_5 { |
| 122 | u_int8_t rr_protocol_discriminator :4, |
| 123 | skip_indicator:4; |
| 124 | u_int8_t system_information; |
| 125 | u_int8_t bcch_frequency_list[16]; |
| 126 | } __attribute__ ((packed)); |
| 127 | |
| 128 | /* Section 9.1.40 System information Type 6 */ |
| 129 | struct gsm48_system_information_type_6 { |
| 130 | u_int8_t rr_protocol_discriminator :4, |
| 131 | skip_indicator:4; |
| 132 | u_int8_t system_information; |
| 133 | u_int8_t cell_identity[2]; |
| 134 | struct gsm48_loc_area_id lai; |
| 135 | u_int8_t cell_options; |
| 136 | u_int8_t ncc_permitted; |
| 137 | u_int8_t si_6_reset[0]; |
| 138 | } __attribute__ ((packed)); |
| 139 | |
Harald Welte | bcae43f | 2008-12-27 21:45:37 +0000 | [diff] [blame] | 140 | /* Section 10.2 + GSM 04.07 12.2.3.1.1 */ |
| 141 | #define GSM48_PDISC_GROUP_CC 0x00 |
| 142 | #define GSM48_PDISC_BCAST_CC 0x01 |
| 143 | #define GSM48_PDISC_PDSS1 0x02 |
Harald Welte | 4b63454 | 2008-12-27 01:55:51 +0000 | [diff] [blame] | 144 | #define GSM48_PDISC_CC 0x03 |
Harald Welte | bcae43f | 2008-12-27 21:45:37 +0000 | [diff] [blame] | 145 | #define GSM48_PDISC_PDSS2 0x04 |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 146 | #define GSM48_PDISC_MM 0x05 |
| 147 | #define GSM48_PDISC_RR 0x06 |
| 148 | #define GSM48_PDISC_MM_GPRS 0x08 |
Harald Welte | bcae43f | 2008-12-27 21:45:37 +0000 | [diff] [blame] | 149 | #define GSM48_PDISC_SMS 0x09 |
| 150 | #define GSM48_PDISC_SM_GPRS 0x0a |
| 151 | #define GSM48_PDISC_NC_SS 0x0b |
| 152 | #define GSM48_PDISC_LOC 0x0c |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 153 | |
| 154 | /* Section 10.4 */ |
| 155 | #define GSM48_MT_RR_INIT_REQ 0x3c |
| 156 | #define GSM48_MT_RR_ADD_ASS 0x3b |
| 157 | #define GSM48_MT_RR_IMM_ASS 0x3f |
| 158 | #define GSM48_MT_RR_IMM_ASS_EXT 0x39 |
| 159 | #define GSM48_MT_RR_IMM_ASS_REJ 0x3a |
| 160 | |
| 161 | #define GSM48_MT_RR_CIPH_M_CMD 0x35 |
| 162 | #define GSM48_MT_RR_CIPH_M_COMPL 0x32 |
| 163 | |
| 164 | #define GSM48_MT_RR_CFG_CHG_CMD 0x30 |
| 165 | #define GSM48_MT_RR_CFG_CHG_ACK 0x31 |
| 166 | #define GSM48_MT_RR_CFG_CHG_REJ 0x33 |
| 167 | |
| 168 | #define GSM48_MT_RR_ASS_CMD 0x2e |
| 169 | #define GSM48_MT_RR_ASS_COMPL 0x29 |
| 170 | #define GSM48_MT_RR_ASS_FAIL 0x2f |
| 171 | #define GSM48_MT_RR_HANDO_CMD 0x2b |
| 172 | #define GSM48_MT_RR_HANDO_COMPL 0x2c |
| 173 | #define GSM48_MT_RR_HANDO_FAIL 0x28 |
| 174 | #define GSM48_MT_RR_HANDO_INFO 0x2d |
| 175 | |
| 176 | #define GSM48_MT_RR_CELL_CHG_ORDER 0x08 |
| 177 | #define GSM48_MT_RR_PDCH_ASS_CMD 0x23 |
| 178 | |
| 179 | #define GSM48_MT_RR_CHAN_REL 0x0d |
| 180 | #define GSM48_MT_RR_PART_REL 0x0a |
| 181 | #define GSM48_MT_RR_PART_REL_COMP 0x0f |
| 182 | |
| 183 | #define GSM48_MT_RR_PAG_REQ_1 0x21 |
| 184 | #define GSM48_MT_RR_PAG_REQ_2 0x22 |
| 185 | #define GSM48_MT_RR_PAG_REQ_3 0x24 |
| 186 | #define GSM48_MT_RR_PAG_RESP 0x27 |
| 187 | #define GSM48_MT_RR_NOTIF_NCH 0x20 |
| 188 | #define GSM48_MT_RR_NOTIF_FACCH 0x25 |
| 189 | #define GSM48_MT_RR_NOTIF_RESP 0x26 |
| 190 | |
| 191 | #define GSM48_MT_RR_SYSINFO_8 0x18 |
| 192 | #define GSM48_MT_RR_SYSINFO_1 0x19 |
| 193 | #define GSM48_MT_RR_SYSINFO_2 0x1a |
| 194 | #define GSM48_MT_RR_SYSINFO_3 0x1b |
| 195 | #define GSM48_MT_RR_SYSINFO_4 0x1c |
| 196 | #define GSM48_MT_RR_SYSINFO_5 0x1d |
| 197 | #define GSM48_MT_RR_SYSINFO_6 0x1e |
| 198 | #define GSM48_MT_RR_SYSINFO_7 0x1f |
| 199 | |
| 200 | #define GSM48_MT_RR_SYSINFO_2bis 0x02 |
| 201 | #define GSM48_MT_RR_SYSINFO_2ter 0x03 |
| 202 | #define GSM48_MT_RR_SYSINFO_5bis 0x05 |
| 203 | #define GSM48_MT_RR_SYSINFO_5ter 0x06 |
| 204 | #define GSM48_MT_RR_SYSINFO_9 0x04 |
| 205 | #define GSM48_MT_RR_SYSINFO_13 0x00 |
| 206 | |
| 207 | #define GSM48_MT_RR_SYSINFO_16 0x3d |
| 208 | #define GSM48_MT_RR_SYSINFO_17 0x3e |
| 209 | |
| 210 | #define GSM48_MT_RR_CHAN_MODE_MODIF 0x10 |
| 211 | #define GSM48_MT_RR_STATUS 0x12 |
| 212 | #define GSM48_MT_RR_CHAN_MODE_MODIF_ACK 0x17 |
| 213 | #define GSM48_MT_RR_FREQ_REDEF 0x14 |
| 214 | #define GSM48_MT_RR_MEAS_REP 0x15 |
| 215 | #define GSM48_MT_RR_CLSM_CHG 0x16 |
| 216 | #define GSM48_MT_RR_CLSM_ENQ 0x13 |
| 217 | #define GSM48_MT_RR_EXT_MEAS_REP 0x36 |
| 218 | #define GSM48_MT_RR_EXT_MEAS_REP_ORD 0x37 |
| 219 | #define GSM48_MT_RR_GPRS_SUSP_REQ 0x34 |
| 220 | |
| 221 | #define GSM48_MT_RR_VGCS_UPL_GRANT 0x08 |
| 222 | #define GSM48_MT_RR_UPLINK_RELEASE 0x0e |
| 223 | #define GSM48_MT_RR_UPLINK_FREE 0x0c |
| 224 | #define GSM48_MT_RR_UPLINK_BUSY 0x2a |
| 225 | #define GSM48_MT_RR_TALKER_IND 0x11 |
| 226 | |
| 227 | #define GSM48_MT_RR_APP_INFO 0x38 |
| 228 | |
| 229 | /* Table 10.2/3GPP TS 04.08 */ |
| 230 | #define GSM48_MT_MM_IMSI_DETACH_IND 0x01 |
| 231 | #define GSM48_MT_MM_LOC_UPD_ACCEPT 0x02 |
| 232 | #define GSM48_MT_MM_LOC_UPD_REJECT 0x04 |
| 233 | #define GSM48_MT_MM_LOC_UPD_REQUEST 0x08 |
| 234 | |
| 235 | #define GSM48_MT_MM_AUTH_REJ 0x11 |
| 236 | #define GSM48_MT_MM_AUTH_REQ 0x12 |
| 237 | #define GSM48_MT_MM_AUTH_RESP 0x14 |
| 238 | #define GSM48_MT_MM_ID_REQ 0x18 |
| 239 | #define GSM48_MT_MM_ID_RESP 0x19 |
| 240 | #define GSM48_MT_MM_TMSI_REALL_CMD 0x1a |
| 241 | #define GSM48_MT_MM_TMSI_REALL_COMPL 0x1b |
| 242 | |
| 243 | #define GSM48_MT_MM_CM_SERV_ACC 0x21 |
| 244 | #define GSM48_MT_MM_CM_SERV_REJ 0x22 |
| 245 | #define GSM48_MT_MM_CM_SERV_ABORT 0x23 |
| 246 | #define GSM48_MT_MM_CM_SERV_REQ 0x24 |
| 247 | #define GSM48_MT_MM_CM_SERV_PROMPT 0x25 |
| 248 | #define GSM48_MT_MM_CM_REEST_REQ 0x28 |
| 249 | #define GSM48_MT_MM_ABORT 0x29 |
| 250 | |
| 251 | #define GSM48_MT_MM_NULL 0x30 |
| 252 | #define GSM48_MT_MM_STATUS 0x31 |
| 253 | #define GSM48_MT_MM_INFO 0x32 |
| 254 | |
| 255 | /* Table 10.3/3GPP TS 04.08 */ |
| 256 | #define GSM48_MT_CC_ALERTING 0x01 |
| 257 | #define GSM48_MT_CC_CALL_CONF 0x08 |
| 258 | #define GSM48_MT_CC_CALL_PROC 0x02 |
| 259 | #define GSM48_MT_CC_CONNECT 0x07 |
| 260 | #define GSM48_MT_CC_CONNECT_ACK 0x0f |
| 261 | #define GSM48_MT_CC_EMERG_SETUP 0x0e |
| 262 | #define GSM48_MT_CC_PROGRESS 0x03 |
| 263 | #define GSM48_MT_CC_ESTAB 0x04 |
| 264 | #define GSM48_MT_CC_ESTAB_CONF 0x06 |
| 265 | #define GSM48_MT_CC_RECALL 0x0b |
| 266 | #define GSM48_MT_CC_START_CC 0x09 |
| 267 | #define GSM48_MT_CC_SETUP 0x05 |
| 268 | |
| 269 | #define GSM48_MT_CC_MODIFY 0x17 |
| 270 | #define GSM48_MT_CC_MODIFY_COMPL 0x1f |
| 271 | #define GSM48_MT_CC_MODIFY_REJECT 0x13 |
| 272 | #define GSM48_MT_CC_USER_INFO 0x10 |
| 273 | #define GSM48_MT_CC_HOLD 0x18 |
| 274 | #define GSM48_MT_CC_HOLD_ACK 0x19 |
| 275 | #define GSM48_MT_CC_HOLD_REJ 0x1a |
| 276 | #define GSM48_MT_CC_RETR 0x1c |
| 277 | #define GSM48_MT_CC_RETR_ACK 0x1d |
| 278 | #define GSM48_MT_CC_RETR_REJ 0x1e |
| 279 | |
| 280 | #define GSM48_MT_CC_DISCONNECT 0x25 |
| 281 | #define GSM48_MT_CC_RELEASE 0x2d |
| 282 | #define GSM48_MT_CC_RELEASE_COMPL 0xea |
| 283 | |
| 284 | #define GSM48_MT_CC_CONG_CTRL 0x39 |
| 285 | #define GSM48_MT_CC_NOTIFY 0x3e |
| 286 | #define GSM48_MT_CC_STATUS 0x3d |
| 287 | #define GSM48_MT_CC_STATUS_ENQ 0x34 |
| 288 | #define GSM48_MT_CC_START_DTMF 0x35 |
| 289 | #define GSM48_MT_CC_STOP_DTMF 0x31 |
| 290 | #define GSM48_MT_CC_STOP_DTMF_ACK 0x32 |
| 291 | #define GSM48_MT_CC_START_DTMF_ACK 0x36 |
| 292 | #define GSM48_MT_CC_START_DTMF_REJ 0x37 |
| 293 | #define GSM48_MT_CC_FACILITY 0x3a |
| 294 | |
| 295 | /* FIXME: Table 10.4 / 10.4a (GPRS) */ |
| 296 | |
| 297 | /* Section 10.5.2.26, Table 10.5.64 */ |
| 298 | #define GSM48_PM_MASK 0x03 |
| 299 | #define GSM48_PM_NORMAL 0x00 |
| 300 | #define GSM48_PM_EXTENDED 0x01 |
| 301 | #define GSM48_PM_REORG 0x02 |
| 302 | #define GSM48_PM_SAME 0x03 |
| 303 | |
| 304 | /* Table 10.5.4 */ |
| 305 | #define GSM_MI_TYPE_MASK 0x07 |
| 306 | #define GSM_MI_TYPE_NONE 0x00 |
| 307 | #define GSM_MI_TYPE_IMSI 0x01 |
| 308 | #define GSM_MI_TYPE_IMEI 0x02 |
| 309 | #define GSM_MI_TYPE_IMEISV 0x03 |
| 310 | #define GSM_MI_TYPE_TMSI 0x04 |
| 311 | #define GSM_MI_ODD 0x08 |
| 312 | |
Harald Welte | 4b63454 | 2008-12-27 01:55:51 +0000 | [diff] [blame] | 313 | #define GSM48_IE_MOBILE_ID 0x17 |
| 314 | |
| 315 | /* Section 10.5.4.11 / Table 10.5.122 */ |
| 316 | #define GSM48_CAUSE_CS_GSM 0x60 |
| 317 | |
| 318 | enum gsm48_cause_loc { |
| 319 | GSM48_CAUSE_LOC_USER = 0x00, |
| 320 | GSM48_CAUSE_LOC_PRN_S_LU = 0x01, |
| 321 | GSM48_CAUSE_LOC_PUN_S_LU = 0x02, |
| 322 | GSM48_CAUSE_LOC_TRANS_NET = 0x03, |
| 323 | GSM48_CAUSE_LOC_PUN_S_RU = 0x04, |
| 324 | GSM48_CAUSE_LOC_PRN_S_RU = 0x05, |
| 325 | /* not defined */ |
| 326 | GSM48_CAUSE_LOC_INN_NET = 0x07, |
| 327 | GSM48_CAUSE_LOC_NET_BEYOND = 0x0a, |
| 328 | }; |
| 329 | |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 330 | struct msgb; |
| 331 | struct gsm_bts; |
| 332 | |
| 333 | int gsm0408_rcvmsg(struct msgb *msg); |
Holger Freyther | 1774661 | 2008-12-28 16:32:44 +0000 | [diff] [blame] | 334 | void gsm0408_generate_lai(struct gsm48_loc_area_id *lai48, u_int16_t mcc, |
| 335 | u_int16_t mnc, u_int16_t lac); |
Harald Welte | 8470bf2 | 2008-12-25 23:28:35 +0000 | [diff] [blame] | 336 | enum gsm_chan_t get_ctype_by_chreq(struct gsm_bts *bts, u_int8_t ra); |
| 337 | |
| 338 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 339 | #endif |