Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 1 | module MSC_Tests { |
| 2 | |
| 3 | import from General_Types all; |
| 4 | import from Osmocom_Types all; |
| 5 | |
| 6 | import from M3UA_Types all; |
| 7 | import from M3UA_Emulation all; |
| 8 | |
| 9 | import from MTP3asp_Types all; |
| 10 | import from MTP3asp_PortType all; |
| 11 | |
| 12 | import from SCCPasp_Types all; |
| 13 | import from SCCP_Types all; |
| 14 | import from SCCP_Emulation all; |
| 15 | |
| 16 | import from SCTPasp_Types all; |
| 17 | import from SCTPasp_PortType all; |
| 18 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 19 | import from Osmocom_CTRL_Functions all; |
| 20 | import from Osmocom_CTRL_Types all; |
| 21 | import from Osmocom_CTRL_Adapter all; |
| 22 | |
| 23 | import from MNCC_Emulation all; |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 24 | import from MNCC_Types all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 25 | |
| 26 | import from GSUP_Emulation all; |
| 27 | import from GSUP_Types all; |
| 28 | import from IPA_Emulation all; |
| 29 | |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 30 | import from BSSAP_Types all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 31 | import from BSSAP_Adapter all; |
| 32 | import from BSSAP_CodecPort all; |
| 33 | import from BSSMAP_Templates all; |
| 34 | import from BSSMAP_Emulation all; |
| 35 | import from BSC_ConnectionHandler all; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 36 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 37 | import from MobileL3_Types all; |
| 38 | import from MobileL3_CommonIE_Types all; |
| 39 | import from L3_Templates all; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 40 | |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 41 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 42 | type component MTC_CT extends BSSAP_Adapter_CT, CTRL_Adapter_CT { |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 43 | var boolean g_initialized := false; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 44 | |
| 45 | /* no 'adapter_CT' for MNCC or GSUP */ |
| 46 | var MNCC_Emulation_CT vc_MNCC; |
| 47 | var GSUP_Emulation_CT vc_GSUP; |
| 48 | var IPA_Emulation_CT vc_GSUP_IPA; |
| 49 | |
| 50 | /* only to get events from IPA underneath GSUP */ |
| 51 | port IPA_CTRL_PT GSUP_IPA_EVENT; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | modulepar { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 55 | /* remote parameters of IUT */ |
| 56 | charstring mp_msc_ip := "127.0.0.1"; |
| 57 | integer mp_msc_ctrl_port := 4255; |
| 58 | integer mp_msc_vty_port := 4254; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 59 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 60 | /* local parameters of emulated HLR */ |
| 61 | charstring mp_hlr_ip := "127.0.0.1"; |
| 62 | integer mp_hlr_port := 4222; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 63 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 64 | charstring mp_msc_mncc := "/tmp/mncc"; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 68 | function f_init_mncc(charstring id) runs on MTC_CT { |
| 69 | id := id & "-MNCC"; |
| 70 | var MnccOps ops := { |
| 71 | create_cb := refers(MNCC_Emulation.ExpectedCreateCallback), |
| 72 | unitdata_cb := refers(MNCC_Emulation.DummyUnitdataCallback) |
| 73 | } |
| 74 | |
| 75 | vc_MNCC := MNCC_Emulation_CT.create(id); |
| 76 | map(vc_MNCC:MNCC, system:MNCC_CODEC_PT); |
| 77 | vc_MNCC.start(MNCC_Emulation.main(ops, id, mp_msc_mncc)); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 78 | } |
| 79 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 80 | function f_init_gsup(charstring id) runs on MTC_CT { |
| 81 | id := id & "-GSUP"; |
| 82 | var GsupOps ops := { |
| 83 | create_cb := refers(GSUP_Emulation.ExpectedCreateCallback) |
| 84 | } |
| 85 | |
| 86 | vc_GSUP_IPA := IPA_Emulation_CT.create(id & "-IPA"); |
| 87 | vc_GSUP := GSUP_Emulation_CT.create(id); |
| 88 | |
| 89 | map(vc_GSUP_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 90 | connect(vc_GSUP:GSUP, vc_GSUP_IPA:IPA_GSUP_PORT); |
| 91 | /* we use this hack to get events like ASP_IPA_EVENT_UP */ |
| 92 | connect(vc_GSUP_IPA:IPA_CTRL_PORT, self:GSUP_IPA_EVENT); |
| 93 | |
| 94 | vc_GSUP.start(GSUP_Emulation.main(ops, id)); |
| 95 | vc_GSUP_IPA.start(IPA_Emulation.main_server(mp_hlr_ip, mp_hlr_port)); |
| 96 | |
| 97 | /* wait for incoming connection to GSUP port before proceeding */ |
| 98 | timer T := 10.0; |
| 99 | T.start; |
| 100 | alt { |
| 101 | [] GSUP_IPA_EVENT.receive(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_UP)) { } |
| 102 | [] T.timeout { |
| 103 | setverdict(inconc, "No connection to GSUP Port"); |
| 104 | self.stop |
| 105 | } |
| 106 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 107 | } |
| 108 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 109 | function f_init() runs on MTC_CT { |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 110 | |
| 111 | if (g_initialized == true) { |
| 112 | return; |
| 113 | } |
| 114 | g_initialized := true; |
| 115 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 116 | f_bssap_init("MSC_Test", BSC_BssmapOps); |
| 117 | f_ipa_ctrl_start(mp_msc_ip, mp_msc_ctrl_port); |
| 118 | f_init_mncc("MSC_Test"); |
| 119 | f_init_gsup("MSC_Test"); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | template PDU_BSSAP ts_BSSAP_BSSMAP := { |
| 123 | discriminator := '0'B, |
| 124 | spare := '0000000'B, |
| 125 | dlci := omit, |
| 126 | lengthIndicator := 0, /* overwritten by codec */ |
| 127 | pdu := ? |
| 128 | } |
| 129 | |
| 130 | template PDU_BSSAP tr_BSSAP_BSSMAP := { |
| 131 | discriminator := '0'B, |
| 132 | spare := '0000000'B, |
| 133 | dlci := omit, |
| 134 | lengthIndicator := ?, |
| 135 | pdu := { |
| 136 | bssmap := ? |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | |
| 141 | type integer BssmapCause; |
| 142 | |
| 143 | template (value) BSSMAP_IE_Cause ts_BSSMAP_IE_Cause(BssmapCause val) := { |
| 144 | elementIdentifier := '04'O, |
| 145 | lengthIndicator := 0, |
| 146 | causeValue := int2bit(val, 7), |
| 147 | extensionCauseValue := '0'B, |
| 148 | spare1 := omit |
| 149 | } |
| 150 | |
| 151 | template (value) PDU_BSSAP ts_BSSMAP_Reset(BssmapCause cause) modifies ts_BSSAP_BSSMAP := { |
| 152 | pdu := { |
| 153 | bssmap := { |
| 154 | reset := { |
| 155 | messageType := '30'O, |
| 156 | cause := ts_BSSMAP_IE_Cause(cause), |
| 157 | a_InterfaceSelectorForReset := omit |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | template (value) PDU_BSSAP ts_BSSMAP_ResetAck modifies ts_BSSAP_BSSMAP := { |
| 164 | pdu := { |
| 165 | bssmap := { |
| 166 | resetAck := { |
| 167 | messageType := '31'O, |
| 168 | a_InterfaceSelectorForReset := omit |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | template PDU_BSSAP tr_BSSMAP_ResetAck modifies tr_BSSAP_BSSMAP := { |
| 175 | pdu := { |
| 176 | bssmap := { |
| 177 | resetAck := { |
| 178 | messageType := '31'O, |
| 179 | a_InterfaceSelectorForReset := * |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | template BSSMAP_IE_CellIdentifier ts_BSSMAP_IE_CellID := { |
| 186 | elementIdentifier := '05'O, |
| 187 | lengthIndicator := 0, |
| 188 | cellIdentifierDiscriminator := '0000'B, |
| 189 | spare1_4 := '0000'B, |
| 190 | cellIdentification := ? |
| 191 | } |
| 192 | |
| 193 | type uint16_t BssmapLAC; |
| 194 | type uint16_t BssmapCI; |
| 195 | |
| 196 | /* |
| 197 | template BSSMAP_IE_CellIdentifier ts_CellId_CGI(mcc, mnc, lac, ci) |
| 198 | modifies ts_BSSMAP_IE_CellID := { |
| 199 | cellIdentification := { |
| 200 | cI_LAC_CGI := { |
| 201 | mnc_mcc := FIXME, |
| 202 | lac := int2oct(lac, 2), |
| 203 | ci := int2oct(ci, 2) |
| 204 | } |
| 205 | } |
| 206 | } |
| 207 | */ |
| 208 | |
| 209 | template BSSMAP_IE_CellIdentifier ts_CellID_LAC_CI(BssmapLAC lac, BssmapCI ci) |
| 210 | modifies ts_BSSMAP_IE_CellID := { |
| 211 | cellIdentification := { |
| 212 | cI_LAC_CI := { |
| 213 | lac := int2oct(lac, 2), |
| 214 | ci := int2oct(ci, 2) |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | template BSSMAP_IE_CellIdentifier ts_CellId_CI(BssmapCI ci) |
| 220 | modifies ts_BSSMAP_IE_CellID := { |
| 221 | cellIdentification := { |
| 222 | cI_CI := int2oct(ci, 2) |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | template BSSMAP_IE_CellIdentifier ts_CellId_none |
| 227 | modifies ts_BSSMAP_IE_CellID := { |
| 228 | cellIdentification := { |
| 229 | cI_noCell := ''O |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | |
| 234 | template BSSMAP_IE_Layer3Information ts_BSSMAP_IE_L3Info(octetstring l3info) := { |
| 235 | elementIdentifier := '17'O, |
| 236 | lengthIndicator := 0, |
| 237 | layer3info := l3info |
| 238 | } |
| 239 | |
| 240 | template PDU_BSSAP ts_BSSMAP_ComplL3(BSSMAP_IE_CellIdentifier cell_id, octetstring l3_info) |
| 241 | modifies ts_BSSAP_BSSMAP := { |
| 242 | pdu := { |
| 243 | bssmap := { |
| 244 | completeLayer3Information := { |
| 245 | messageType := '57'O, |
| 246 | cellIdentifier := cell_id, |
| 247 | layer3Information := ts_BSSMAP_IE_L3Info(l3_info), |
| 248 | chosenChannel := omit, |
| 249 | lSAIdentifier := omit, |
| 250 | aPDU := omit, |
| 251 | codecList := omit, |
| 252 | redirectAttemptFlag := omit, |
| 253 | sendSequenceNumber := omit, |
| 254 | iMSI := omit |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | template PDU_BSSAP ts_BSSMAP_HandoReq(BssmapCause cause, BSSMAP_IE_CellIdentifierList cid_list) |
| 261 | modifies ts_BSSAP_BSSMAP := { |
| 262 | pdu := { |
| 263 | bssmap := { |
| 264 | handoverRequired := { |
| 265 | messageType := '11'O, |
| 266 | cause := ts_BSSMAP_IE_Cause(cause), |
| 267 | responseRequest := omit, |
| 268 | cellIdentifierList := cid_list, |
| 269 | circuitPoolList := omit, |
| 270 | currentChannelType1 := omit, |
| 271 | speechVersion := omit, |
| 272 | queueingIndicator := omit, |
| 273 | oldToNewBSSInfo := omit, |
| 274 | sourceToTargetRNCTransparentInfo := omit, |
| 275 | sourceToTargetRNCTransparentInfoCDMA := omit, |
| 276 | gERANClassmark := omit, |
| 277 | talkerPriority := omit, |
| 278 | speechCodec := omit, |
| 279 | cSG_Identifier := omit |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | // enc_PDU_BSSAP |
| 286 | |
| 287 | function f_send_BSSAP_UNITDATA(template PDU_BSSAP bssap) runs on MTC_CT { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 288 | BSSAP.send(ts_BSSAP_UNITDATA_req(g_sccp_addr_peer, g_sccp_addr_own, bssap)) |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 289 | } |
| 290 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 291 | type function void_fn(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 292 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 293 | function f_gen_imei(hexstring prefix, integer suffix) return hexstring { |
| 294 | var integer suffix_len := 15 - lengthof(prefix); |
| 295 | suffix_len := suffix_len; |
| 296 | return prefix & int2hex(suffix, suffix_len); |
| 297 | } |
| 298 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 299 | function f_gen_imsi(hexstring prefix, integer suffix) return hexstring { |
| 300 | var integer suffix_len := 15 - lengthof(prefix); |
| 301 | suffix_len := suffix_len-1; /* FIXME: fix odd IMSI length */ |
| 302 | return prefix & int2hex(suffix, suffix_len); |
| 303 | } |
| 304 | |
| 305 | function f_gen_msisdn(hexstring prefix, integer suffix) return hexstring { |
| 306 | var integer suffix_len := 12 - lengthof(prefix); |
| 307 | return prefix & int2hex(suffix, suffix_len); |
| 308 | } |
| 309 | |
| 310 | /* FIXME: move into BSC_ConnectionHandler? */ |
| 311 | function f_start_handler(void_fn fn, charstring id, integer imsi_suffix) runs on MTC_CT return BSC_ConnHdlr { |
| 312 | var BSC_ConnHdlr vc_conn; |
| 313 | var BSC_ConnHdlrPars pars := { |
| 314 | sccp_addr_own := g_sccp_addr_own, |
| 315 | sccp_addr_peer := g_sccp_addr_peer, |
| 316 | cell_id := valueof(ts_CellId_CGI('262'H, '042'H, 23, 42)), |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 317 | imei := f_gen_imei('49999'H, imsi_suffix), |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 318 | imsi := f_gen_imsi('26242'H, imsi_suffix), |
Harald Welte | 8260057 | 2018-01-21 20:54:08 +0100 | [diff] [blame] | 319 | msisdn := f_gen_msisdn('491239999'H, imsi_suffix), |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 320 | tmsi := omit, |
Harald Welte | 8260057 | 2018-01-21 20:54:08 +0100 | [diff] [blame] | 321 | cm2 := valueof(ts_CM2_default), |
| 322 | cm3 := omit |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 323 | }; |
| 324 | |
| 325 | vc_conn := BSC_ConnHdlr.create(id); |
| 326 | /* BSSMAP part / A interface */ |
| 327 | connect(vc_conn:BSSAP, vc_BSSMAP:CLIENT); |
| 328 | connect(vc_conn:BSSAP_PROC, vc_BSSMAP:PROC); |
| 329 | /* MNCC part */ |
| 330 | connect(vc_conn:MNCC, vc_MNCC:MNCC_CLIENT); |
| 331 | connect(vc_conn:MNCC_PROC, vc_MNCC:MNCC_PROC); |
| 332 | /* GSUP part */ |
| 333 | connect(vc_conn:GSUP, vc_GSUP:GSUP_CLIENT); |
| 334 | connect(vc_conn:GSUP_PROC, vc_GSUP:GSUP_PROC); |
| 335 | |
| 336 | vc_conn.start(derefers(fn)(id, pars)); |
| 337 | return vc_conn; |
| 338 | } |
| 339 | |
| 340 | function f_sleep(float seconds) { |
| 341 | timer T := seconds; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 342 | T.start; |
| 343 | T.timeout; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 344 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 345 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 346 | private function f_tc_lu_imsi_noauth_tmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 347 | g_pars := pars; |
Harald Welte | 8a121b3 | 2018-01-22 03:00:41 +0100 | [diff] [blame] | 348 | f_perform_lu(false, true, true); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 349 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 350 | testcase TC_lu_imsi_noauth_tmsi() runs on MTC_CT { |
| 351 | var BSC_ConnHdlr vc_conn; |
| 352 | f_init(); |
| 353 | |
| 354 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_tmsi), testcasename(), 1); |
| 355 | vc_conn.done; |
| 356 | } |
| 357 | |
| 358 | private function f_tc_lu_imsi_noauth_notmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 359 | g_pars := pars; |
Harald Welte | 8a121b3 | 2018-01-22 03:00:41 +0100 | [diff] [blame] | 360 | f_perform_lu(false, false, true); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 361 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 362 | testcase TC_lu_imsi_noauth_notmsi() runs on MTC_CT { |
| 363 | var BSC_ConnHdlr vc_conn; |
| 364 | f_init(); |
| 365 | |
| 366 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_notmsi), testcasename(), 2); |
| 367 | vc_conn.done; |
| 368 | } |
| 369 | |
| 370 | /* Do LU by IMSI, refuse it on GSUP and expect LU REJ back to MS */ |
| 371 | private function f_tc_lu_imsi_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 372 | g_pars := pars; |
| 373 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 374 | |
| 375 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 376 | f_bssap_compl_l3(l3_lu); |
| 377 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 378 | GSUP.send(ts_GSUP_UL_ERR(g_pars.imsi, 23)); |
| 379 | alt { |
| 380 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej(int2oct(23,1)))) { } |
| 381 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 382 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
| 383 | self.stop; |
| 384 | } |
| 385 | } |
| 386 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 387 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 388 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 389 | setverdict(pass); |
| 390 | } |
| 391 | testcase TC_lu_imsi_reject() runs on MTC_CT { |
| 392 | var BSC_ConnHdlr vc_conn; |
| 393 | f_init(); |
| 394 | |
| 395 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_reject), testcasename(), 3); |
| 396 | vc_conn.done; |
| 397 | } |
| 398 | |
| 399 | /* Do LU by IMSI, timeout on GSUP */ |
| 400 | private function f_tc_lu_imsi_timeout_gsup(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 401 | g_pars := pars; |
| 402 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 403 | |
| 404 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 405 | f_bssap_compl_l3(l3_lu); |
| 406 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 407 | /* Normally the HLR would need to respond here, but we decide to force a timeout here */ |
| 408 | alt { |
| 409 | /* FIXME: Expect specific reject cause */ |
| 410 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { } |
| 411 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 412 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
| 413 | self.stop; |
| 414 | } |
| 415 | } |
| 416 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 417 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 418 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 419 | setverdict(pass); |
| 420 | } |
| 421 | testcase TC_lu_imsi_timeout_gsup() runs on MTC_CT { |
| 422 | var BSC_ConnHdlr vc_conn; |
| 423 | f_init(); |
| 424 | |
| 425 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_timeout_gsup), testcasename(), 4); |
| 426 | vc_conn.done; |
| 427 | } |
| 428 | |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 429 | private function f_tc_lu_imsi_auth_tmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 430 | g_pars := pars; |
| 431 | f_perform_lu(true, true, true); |
| 432 | } |
| 433 | testcase TC_lu_imsi_auth_tmsi() runs on MTC_CT { |
| 434 | var BSC_ConnHdlr vc_conn; |
| 435 | f_init(); |
| 436 | |
| 437 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi), testcasename(), 5); |
| 438 | vc_conn.done; |
| 439 | } |
| 440 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 441 | |
| 442 | /* Send CM SERVICE REQ for IMSI that has never performed LU before */ |
| 443 | private function f_tc_cmserv_imsi_unknown(charstring id, BSC_ConnHdlrPars pars) |
| 444 | runs on BSC_ConnHdlr { |
| 445 | |
| 446 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 447 | var BSSMAP_IE_CellIdentifier cell_id := valueof(ts_CellId_CGI('262'H, '042'H, 23, 42)); |
| 448 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ('0001'B, mi)); |
| 449 | |
| 450 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 451 | |
| 452 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 453 | f_bssap_compl_l3(l3_info); |
| 454 | |
| 455 | timer T := 10.0; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 456 | T.start; |
| 457 | alt { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 458 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)) { } |
| 459 | //[] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_ACC)) { } |
| 460 | [] BSSAP.receive { setverdict(fail, "Received unexpected BSSAP"); } |
| 461 | [] GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)) { |
| 462 | setverdict(fail, "Unexpected GSUP UL REQ"); |
| 463 | } |
| 464 | [] T.timeout { setverdict(inconc, "Timeout waiting for CM SERV REQ"); } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 465 | } |
| 466 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 467 | alt { |
| 468 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 469 | setverdict(pass); |
| 470 | } |
| 471 | [] BSSAP.receive { setverdict(fail, "Received unexpected BSSAP"); } |
| 472 | [] T.timeout { setverdict(inconc, "Timeout waiting for CM SERV REQ"); } |
| 473 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 474 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 475 | testcase TC_cmserv_imsi_unknown() runs on MTC_CT { |
| 476 | var BSC_ConnHdlr vc_conn; |
| 477 | f_init(); |
| 478 | vc_conn := f_start_handler(refers(f_tc_cmserv_imsi_unknown), testcasename(), 5); |
| 479 | vc_conn.done; |
| 480 | } |
| 481 | |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 482 | private function f_tc_lu_and_mo_call(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 483 | g_pars := pars; |
| 484 | f_perform_lu(false, true, true); |
| 485 | |
| 486 | f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)), false); |
| 487 | |
| 488 | var hexstring called := '12345'H; |
| 489 | var integer tid := 0; |
| 490 | var MNCC_PDU mncc; |
| 491 | f_create_mncc_expect(hex2str(called)); |
| 492 | |
| 493 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_SETUP(tid, called))); |
| 494 | MNCC.receive(tr_MNCC_SETUP_ind(?, tr_MNCC_number(hex2str(called)))) -> value mncc; |
| 495 | /* FIXME: extract call_id */ |
| 496 | |
| 497 | /* Call Proceeding */ |
| 498 | MNCC.send(ts_MNCC_CALL_PROC_req(mncc.u.signal.callref, ts_MNCC_bcap_voice)); |
| 499 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CALL_PROC(tid))); |
| 500 | |
| 501 | /* Alerting */ |
| 502 | MNCC.send(ts_MNCC_ALERT_req(mncc.u.signal.callref)); |
| 503 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_ALERTING(tid))); |
| 504 | |
| 505 | /* Answer. This causes TCH assignment in case of "late assignment" */ |
| 506 | MNCC.send(ts_MNCC_SETUP_COMPL_req(mncc.u.signal.callref)); |
| 507 | |
| 508 | f_sleep(3.0); |
| 509 | |
| 510 | /* Hangup by "B" side */ |
| 511 | MNCC.send(ts_MNCC_DISC_req(mncc.u.signal.callref, valueof(ts_MNCC_cause(23)))); |
| 512 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_DISC(tid))); |
| 513 | |
| 514 | /* Release of call */ |
| 515 | MNCC.send(ts_MNCC_REL_req(mncc.u.signal.callref, valueof(ts_MNCC_cause(42)))); |
| 516 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(tid))); |
| 517 | |
| 518 | /* clearing of radio channel */ |
| 519 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 520 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 521 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 522 | |
| 523 | f_sleep(5.0); |
| 524 | } |
| 525 | testcase TC_lu_and_mo_call() runs on MTC_CT { |
| 526 | var BSC_ConnHdlr vc_conn; |
| 527 | f_init(); |
| 528 | |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 529 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_call), testcasename(), 6); |
| 530 | vc_conn.done; |
| 531 | } |
| 532 | |
| 533 | /* Test LU (with authentication enabled), where HLR times out sending SAI response */ |
| 534 | private function f_tc_lu_auth_sai_timeout(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 535 | g_pars := pars; |
| 536 | |
| 537 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 538 | var PDU_DTAP_MT dtap_mt; |
| 539 | |
| 540 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 541 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 542 | |
| 543 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 544 | f_bssap_compl_l3(l3_lu); |
| 545 | |
| 546 | /* Send Early Classmark, just for the fun of it */ |
| 547 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 548 | |
| 549 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 550 | /* The HLR would normally return an auth vector here, but we fail to do so. */ |
| 551 | |
| 552 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)); |
| 553 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 554 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 555 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 556 | setverdict(pass); |
| 557 | } |
| 558 | testcase TC_lu_auth_sai_timeout() runs on MTC_CT { |
| 559 | var BSC_ConnHdlr vc_conn; |
| 560 | f_init(); |
| 561 | |
| 562 | vc_conn := f_start_handler(refers(f_tc_lu_auth_sai_timeout), testcasename(), 7); |
| 563 | vc_conn.done; |
| 564 | } |
| 565 | |
| 566 | /* Test LU (with authentication enabled), where HLR rejects sending SAI error */ |
| 567 | private function f_tc_lu_auth_sai_err(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 568 | g_pars := pars; |
| 569 | |
| 570 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 571 | var PDU_DTAP_MT dtap_mt; |
| 572 | |
| 573 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 574 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 575 | |
| 576 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 577 | f_bssap_compl_l3(l3_lu); |
| 578 | |
| 579 | /* Send Early Classmark, just for the fun of it */ |
| 580 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 581 | |
| 582 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 583 | GSUP.send(ts_GSUP_SAI_ERR(g_pars.imsi, 13)); |
| 584 | |
| 585 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)); |
| 586 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 587 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 588 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 589 | setverdict(pass); |
| 590 | } |
| 591 | testcase TC_lu_auth_sai_err() runs on MTC_CT { |
| 592 | var BSC_ConnHdlr vc_conn; |
| 593 | f_init(); |
| 594 | |
| 595 | vc_conn := f_start_handler(refers(f_tc_lu_auth_sai_err), testcasename(), 8); |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 596 | vc_conn.done; |
| 597 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 598 | |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 599 | /* Test LU but BSC will send a clear request in the middle */ |
| 600 | private function f_tc_lu_clear_request(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 601 | g_pars := pars; |
| 602 | |
| 603 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 604 | var PDU_DTAP_MT dtap_mt; |
| 605 | |
| 606 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 607 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 608 | |
| 609 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 610 | f_bssap_compl_l3(l3_lu); |
| 611 | |
| 612 | /* Send Early Classmark, just for the fun of it */ |
| 613 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 614 | |
| 615 | f_sleep(1.0); |
| 616 | /* send clear request in the middle of the LU */ |
| 617 | BSSAP.send(ts_BSSMAP_ClearRequest(0)); |
| 618 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 619 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 620 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 621 | setverdict(pass); |
| 622 | } |
| 623 | testcase TC_lu_clear_request() runs on MTC_CT { |
| 624 | var BSC_ConnHdlr vc_conn; |
| 625 | f_init(); |
| 626 | |
| 627 | vc_conn := f_start_handler(refers(f_tc_lu_clear_request), testcasename(), 8); |
| 628 | vc_conn.done; |
| 629 | } |
| 630 | |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 631 | /* Test LU but BSC will send a clear request in the middle */ |
| 632 | private function f_tc_lu_disconnect(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 633 | g_pars := pars; |
| 634 | |
| 635 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 636 | var PDU_DTAP_MT dtap_mt; |
| 637 | |
| 638 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 639 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 640 | |
| 641 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 642 | f_bssap_compl_l3(l3_lu); |
| 643 | |
| 644 | /* Send Early Classmark, just for the fun of it */ |
| 645 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 646 | |
| 647 | f_sleep(1.0); |
| 648 | /* send clear request in the middle of the LU */ |
| 649 | BSSAP.send(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_REQ); |
| 650 | setverdict(pass); |
| 651 | } |
| 652 | testcase TC_lu_disconnect() runs on MTC_CT { |
| 653 | var BSC_ConnHdlr vc_conn; |
| 654 | f_init(); |
| 655 | |
| 656 | vc_conn := f_start_handler(refers(f_tc_lu_disconnect), testcasename(), 9); |
| 657 | vc_conn.done; |
| 658 | } |
| 659 | |
| 660 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 661 | /* Test LU but with illegal mobile identity type = IMEI */ |
| 662 | private function f_tc_lu_by_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 663 | g_pars := pars; |
| 664 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 665 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imei(g_pars.imei) |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 666 | var PDU_DTAP_MT dtap_mt; |
| 667 | |
| 668 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 669 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 670 | |
| 671 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 672 | f_bssap_compl_l3(l3_lu); |
| 673 | |
| 674 | /* Send Early Classmark, just for the fun of it */ |
| 675 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 676 | /* wait for LU reject, ignore any ID REQ */ |
| 677 | alt { |
| 678 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { } |
| 679 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req)) { repeat; } |
| 680 | } |
| 681 | /* wait for normal teardown */ |
| 682 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 683 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 684 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 685 | setverdict(pass); |
| 686 | } |
| 687 | testcase TC_lu_by_imei() runs on MTC_CT { |
| 688 | var BSC_ConnHdlr vc_conn; |
| 689 | f_init(); |
| 690 | |
| 691 | vc_conn := f_start_handler(refers(f_tc_lu_by_imei), testcasename(), 9); |
| 692 | vc_conn.done; |
| 693 | } |
| 694 | |
| 695 | /* Test LU by TMSI with unknown TMSI, expect (and answer) ID REQ. */ |
| 696 | private function f_tc_lu_tmsi_noauth_unknown(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 697 | g_pars := pars; |
| 698 | |
| 699 | var PDU_ML3_MS_NW l3_lu := f_build_lu_tmsi('01020304'O); /* FIXME: Random */ |
| 700 | var PDU_DTAP_MT dtap_mt; |
| 701 | |
| 702 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 703 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 704 | |
| 705 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 706 | f_bssap_compl_l3(l3_lu); |
| 707 | |
| 708 | /* Send Early Classmark, just for the fun of it */ |
| 709 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 710 | |
| 711 | /* Wait for + respond to ID REQ (IMSI) */ |
| 712 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req('001'B))); |
| 713 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp_IMSI(g_pars.imsi))); |
| 714 | |
| 715 | /* Expect MSC to do UpdateLocation to HLR; respond to it */ |
| 716 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 717 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 718 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 719 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 720 | |
| 721 | alt { |
| 722 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { } |
| 723 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 724 | setverdict(fail, "Expected LU ACK, but received REJ"); |
| 725 | } |
| 726 | } |
| 727 | |
| 728 | /* wait for normal teardown */ |
| 729 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 730 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 731 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 732 | setverdict(pass); |
| 733 | } |
| 734 | testcase TC_lu_by_tmsi_noauth_unknown() runs on MTC_CT { |
| 735 | var BSC_ConnHdlr vc_conn; |
| 736 | f_init(); |
| 737 | |
| 738 | vc_conn := f_start_handler(refers(f_tc_lu_tmsi_noauth_unknown), testcasename(), 1); |
| 739 | vc_conn.done; |
| 740 | } |
| 741 | |
| 742 | |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 743 | /* Test IMSI DETACH (MI=IMSI) */ |
| 744 | private function f_tc_imsi_detach_by_imsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 745 | g_pars := pars; |
| 746 | |
| 747 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 748 | |
| 749 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 750 | f_bssap_compl_l3(valueof(ts_ML3_MO_MM_IMSI_DET_Ind(mi))); |
| 751 | |
| 752 | /* Send Early Classmark, just for the fun of it? */ |
| 753 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 754 | |
| 755 | /* wait for normal teardown */ |
| 756 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 757 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 758 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 759 | setverdict(pass); |
| 760 | } |
| 761 | testcase TC_imsi_detach_by_imsi() runs on MTC_CT { |
| 762 | var BSC_ConnHdlr vc_conn; |
| 763 | f_init(); |
| 764 | |
| 765 | vc_conn := f_start_handler(refers(f_tc_imsi_detach_by_imsi), testcasename(), 2); |
| 766 | vc_conn.done; |
| 767 | } |
| 768 | |
| 769 | /* Test IMSI DETACH (MI=TMSI) */ |
| 770 | private function f_tc_imsi_detach_by_tmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 771 | g_pars := pars; |
| 772 | |
| 773 | var MobileIdentityLV mi := valueof(ts_MI_TMSI_LV('01020304'O)); |
| 774 | |
| 775 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 776 | f_bssap_compl_l3(valueof(ts_ML3_MO_MM_IMSI_DET_Ind(mi))); |
| 777 | |
| 778 | /* Send Early Classmark, just for the fun of it? */ |
| 779 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 780 | |
| 781 | /* wait for normal teardown */ |
| 782 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 783 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 784 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 785 | setverdict(pass); |
| 786 | } |
| 787 | testcase TC_imsi_detach_by_tmsi() runs on MTC_CT { |
| 788 | var BSC_ConnHdlr vc_conn; |
| 789 | f_init(); |
| 790 | |
| 791 | vc_conn := f_start_handler(refers(f_tc_imsi_detach_by_tmsi), testcasename(), 3); |
| 792 | vc_conn.done; |
| 793 | } |
| 794 | |
| 795 | /* Test IMSI DETACH (MI=IMEI), which is illegal */ |
| 796 | private function f_tc_imsi_detach_by_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 797 | g_pars := pars; |
| 798 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 799 | var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 800 | |
| 801 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 802 | f_bssap_compl_l3(valueof(ts_ML3_MO_MM_IMSI_DET_Ind(mi))); |
| 803 | |
| 804 | /* Send Early Classmark, just for the fun of it? */ |
| 805 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 806 | |
| 807 | /* wait for normal teardown */ |
| 808 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 809 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 810 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 811 | setverdict(pass); |
| 812 | } |
| 813 | testcase TC_imsi_detach_by_imei() runs on MTC_CT { |
| 814 | var BSC_ConnHdlr vc_conn; |
| 815 | f_init(); |
| 816 | |
| 817 | vc_conn := f_start_handler(refers(f_tc_imsi_detach_by_imei), testcasename(), 4); |
| 818 | vc_conn.done; |
| 819 | } |
| 820 | |
| 821 | |
| 822 | /* helper function for an emergency call. caller passes in mobile identity to use */ |
| 823 | private function f_emerg_call(MobileIdentityLV mi) runs on BSC_ConnHdlr { |
| 824 | |
| 825 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ('0010'B, mi)); |
| 826 | f_bssap_compl_l3(l3_info); |
| 827 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_ACC)); |
| 828 | |
| 829 | var hexstring called := '112'H; |
| 830 | var integer tid := 0; |
| 831 | var MNCC_PDU mncc; |
| 832 | f_create_mncc_expect(hex2str(called)); |
| 833 | |
| 834 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_EMERG_SETUP(tid))); |
| 835 | MNCC.receive(tr_MNCC_SETUP_ind(?, tr_MNCC_number(hex2str(called)))) -> value mncc; |
| 836 | /* FIXME: extract call_id */ |
| 837 | |
| 838 | /* Call Proceeding */ |
| 839 | MNCC.send(ts_MNCC_CALL_PROC_req(mncc.u.signal.callref, ts_MNCC_bcap_voice)); |
| 840 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CALL_PROC(tid))); |
| 841 | |
| 842 | /* Alerting */ |
| 843 | MNCC.send(ts_MNCC_ALERT_req(mncc.u.signal.callref)); |
| 844 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_ALERTING(tid))); |
| 845 | |
| 846 | /* Answer. This causes TCH assignment in case of "late assignment" */ |
| 847 | MNCC.send(ts_MNCC_SETUP_COMPL_req(mncc.u.signal.callref)); |
| 848 | |
| 849 | f_sleep(3.0); |
| 850 | |
| 851 | /* Hangup by "B" side */ |
| 852 | MNCC.send(ts_MNCC_DISC_req(mncc.u.signal.callref, valueof(ts_MNCC_cause(23)))); |
| 853 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_DISC(tid))); |
| 854 | |
| 855 | /* Release of call */ |
| 856 | MNCC.send(ts_MNCC_REL_req(mncc.u.signal.callref, valueof(ts_MNCC_cause(42)))); |
| 857 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(tid))); |
| 858 | |
| 859 | /* clearing of radio channel */ |
| 860 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 861 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 862 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 863 | |
| 864 | f_sleep(5.0); |
| 865 | } |
| 866 | |
| 867 | /* establish an emergency call by IMEI, no SIM inserted (and hence no IMSI) */ |
| 868 | private function f_tc_emerg_call_imei_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 869 | g_pars := pars; |
| 870 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 871 | var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 872 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ('0010'B, mi)); |
| 873 | f_bssap_compl_l3(l3_info); |
| 874 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ('05'O))); |
| 875 | setverdict(pass); |
| 876 | } |
| 877 | testcase TC_emerg_call_imei_reject() runs on MTC_CT { |
| 878 | var BSC_ConnHdlr vc_conn; |
| 879 | f_init(); |
| 880 | |
| 881 | vc_conn := f_start_handler(refers(f_tc_emerg_call_imei_reject), testcasename(), 5); |
| 882 | vc_conn.done; |
| 883 | } |
| 884 | |
Harald Welte | d5b9140 | 2018-01-24 18:48:16 +0100 | [diff] [blame] | 885 | /* establish an emergency call by IMSI, SIM inserted (and hence IMSI) */ |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 886 | private function f_tc_emerg_call_imsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 887 | g_pars := pars; |
| 888 | /* First perform location update to ensure subscriber is known */ |
| 889 | f_perform_lu(false, true, true); |
| 890 | /* Then issue emergency call identified by IMSI */ |
| 891 | f_emerg_call(valueof(ts_MI_IMSI_LV(g_pars.imsi))); |
| 892 | } |
| 893 | testcase TC_emerg_call_imsi() runs on MTC_CT { |
| 894 | var BSC_ConnHdlr vc_conn; |
| 895 | f_init(); |
| 896 | |
| 897 | vc_conn := f_start_handler(refers(f_tc_emerg_call_imsi), testcasename(), 6); |
| 898 | vc_conn.done; |
| 899 | } |
| 900 | |
| 901 | /* CM Service Request for VGCS -> reject */ |
| 902 | private function f_tc_cm_serv_req_vgcs_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 903 | g_pars := pars; |
| 904 | |
| 905 | /* First perform location update to ensure subscriber is known */ |
| 906 | f_perform_lu(false, true, true); |
| 907 | |
| 908 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 909 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ('1001'B, mi)); |
| 910 | f_bssap_compl_l3(l3_info); |
| 911 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ(int2oct(32,1)))); |
| 912 | setverdict(pass); |
| 913 | } |
| 914 | testcase TC_cm_serv_req_vgcs_reject() runs on MTC_CT { |
| 915 | var BSC_ConnHdlr vc_conn; |
| 916 | f_init(); |
| 917 | |
| 918 | vc_conn := f_start_handler(refers(f_tc_cm_serv_req_vgcs_reject), testcasename(), 7); |
| 919 | vc_conn.done; |
| 920 | } |
| 921 | |
| 922 | /* CM Service Request for VBS -> reject */ |
| 923 | private function f_tc_cm_serv_req_vbs_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 924 | g_pars := pars; |
| 925 | |
| 926 | /* First perform location update to ensure subscriber is known */ |
| 927 | f_perform_lu(false, true, true); |
| 928 | |
| 929 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 930 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ('1010'B, mi)); |
| 931 | f_bssap_compl_l3(l3_info); |
| 932 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ(int2oct(32,1)))); |
| 933 | setverdict(pass); |
| 934 | } |
| 935 | testcase TC_cm_serv_req_vbs_reject() runs on MTC_CT { |
| 936 | var BSC_ConnHdlr vc_conn; |
| 937 | f_init(); |
| 938 | |
| 939 | vc_conn := f_start_handler(refers(f_tc_cm_serv_req_vbs_reject), testcasename(), 8); |
| 940 | vc_conn.done; |
| 941 | } |
| 942 | |
| 943 | /* CM Service Request for LCS -> reject */ |
| 944 | private function f_tc_cm_serv_req_lcs_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 945 | g_pars := pars; |
| 946 | |
| 947 | /* First perform location update to ensure subscriber is known */ |
| 948 | f_perform_lu(false, true, true); |
| 949 | |
| 950 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 951 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ('1011'B, mi)); |
| 952 | f_bssap_compl_l3(l3_info); |
| 953 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ(int2oct(32,1)))); |
| 954 | setverdict(pass); |
| 955 | } |
| 956 | testcase TC_cm_serv_req_lcs_reject() runs on MTC_CT { |
| 957 | var BSC_ConnHdlr vc_conn; |
| 958 | f_init(); |
| 959 | |
| 960 | vc_conn := f_start_handler(refers(f_tc_cm_serv_req_lcs_reject), testcasename(), 9); |
| 961 | vc_conn.done; |
| 962 | } |
| 963 | |
| 964 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 965 | /* TODO: |
| 966 | * continue to send repeated MO signalling messages to keep channel open: does MSC tmeout? |
| 967 | * malformed messages (missing IE, invalid message type): properly rejected? |
| 968 | * MT call while LU or is ongoing: Do we use existing lchan or page while lchan active? |
| 969 | * 3G/2G auth permutations |
| 970 | * encryption algorithms vs. classmark vs. vty config |
| 971 | * emergency call |
| 972 | * IMSI DETACH |
| 973 | * send new transaction after/during clear (like SMS, ...) |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 974 | * too long L3 INFO in DTAP |
| 975 | * too long / padded BSSAP |
| 976 | * too long / short TLV values |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 977 | */ |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 978 | |
| 979 | |
| 980 | control { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 981 | execute( TC_cmserv_imsi_unknown() ); |
| 982 | execute( TC_lu_imsi_noauth_tmsi() ); |
| 983 | //execute( TC_lu_imsi_noauth_notmsi() ); |
| 984 | execute( TC_lu_imsi_reject() ); |
| 985 | execute( TC_lu_imsi_timeout_gsup() ); |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 986 | execute( TC_lu_and_mo_call() ); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 987 | execute( TC_lu_auth_sai_timeout() ); |
| 988 | execute( TC_lu_auth_sai_err() ); |
Harald Welte | e1a2f3c | 2018-01-24 17:28:48 +0100 | [diff] [blame] | 989 | execute( TC_lu_clear_request() ); |
| 990 | execute( TC_lu_disconnect() ); |
| 991 | execute( TC_lu_by_imei() ); |
| 992 | execute( TC_lu_by_tmsi_noauth_unknown() ); |
| 993 | execute( TC_imsi_detach_by_imsi() ); |
| 994 | execute( TC_imsi_detach_by_tmsi() ); |
| 995 | execute( TC_imsi_detach_by_imei() ); |
| 996 | execute( TC_emerg_call_imei_reject() ); |
| 997 | execute( TC_emerg_call_imsi() ); |
| 998 | execute( TC_cm_serv_req_vgcs_reject() ); |
| 999 | execute( TC_cm_serv_req_vbs_reject() ); |
| 1000 | execute( TC_cm_serv_req_lcs_reject() ); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 1001 | } |
| 1002 | |
| 1003 | |
| 1004 | } |