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 | |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 23 | import from TELNETasp_PortType all; |
| 24 | import from Osmocom_VTY_Functions all; |
| 25 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 26 | import from MNCC_Emulation all; |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 27 | import from MNCC_Types all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 28 | |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 29 | import from MGCP_Emulation all; |
| 30 | import from MGCP_Types all; |
| 31 | import from MGCP_Templates all; |
| 32 | import from SDP_Types all; |
| 33 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 34 | import from GSUP_Emulation all; |
| 35 | import from GSUP_Types all; |
| 36 | import from IPA_Emulation all; |
| 37 | |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 38 | import from BSSAP_Types all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 39 | import from BSSAP_Adapter all; |
| 40 | import from BSSAP_CodecPort all; |
| 41 | import from BSSMAP_Templates all; |
| 42 | import from BSSMAP_Emulation all; |
| 43 | import from BSC_ConnectionHandler all; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 44 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 45 | import from MobileL3_Types all; |
| 46 | import from MobileL3_CommonIE_Types all; |
| 47 | import from L3_Templates all; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 48 | |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 49 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 50 | type component MTC_CT extends BSSAP_Adapter_CT, CTRL_Adapter_CT { |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 51 | var boolean g_initialized := false; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 52 | |
| 53 | /* no 'adapter_CT' for MNCC or GSUP */ |
| 54 | var MNCC_Emulation_CT vc_MNCC; |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 55 | var MGCP_Emulation_CT vc_MGCP; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 56 | var GSUP_Emulation_CT vc_GSUP; |
| 57 | var IPA_Emulation_CT vc_GSUP_IPA; |
| 58 | |
| 59 | /* only to get events from IPA underneath GSUP */ |
| 60 | port IPA_CTRL_PT GSUP_IPA_EVENT; |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 61 | /* VTY to MSC */ |
| 62 | port TELNETasp_PT MSCVTY; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | modulepar { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 66 | /* remote parameters of IUT */ |
| 67 | charstring mp_msc_ip := "127.0.0.1"; |
| 68 | integer mp_msc_ctrl_port := 4255; |
| 69 | integer mp_msc_vty_port := 4254; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 70 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 71 | /* local parameters of emulated HLR */ |
| 72 | charstring mp_hlr_ip := "127.0.0.1"; |
| 73 | integer mp_hlr_port := 4222; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 74 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 75 | charstring mp_msc_mncc := "/tmp/mncc"; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 79 | function f_init_mncc(charstring id) runs on MTC_CT { |
| 80 | id := id & "-MNCC"; |
| 81 | var MnccOps ops := { |
| 82 | create_cb := refers(MNCC_Emulation.ExpectedCreateCallback), |
| 83 | unitdata_cb := refers(MNCC_Emulation.DummyUnitdataCallback) |
| 84 | } |
| 85 | |
| 86 | vc_MNCC := MNCC_Emulation_CT.create(id); |
| 87 | map(vc_MNCC:MNCC, system:MNCC_CODEC_PT); |
| 88 | vc_MNCC.start(MNCC_Emulation.main(ops, id, mp_msc_mncc)); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 89 | } |
| 90 | |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 91 | function f_init_mgcp(charstring id) runs on MTC_CT { |
| 92 | id := id & "-MGCP"; |
| 93 | var MGCPOps ops := { |
| 94 | create_cb := refers(MGCP_Emulation.ExpectedCreateCallback), |
| 95 | unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback) |
| 96 | } |
| 97 | var MGCP_conn_parameters pars := { |
| 98 | callagent_ip := "127.0.0.1", |
| 99 | callagent_udp_port := -1, |
| 100 | mgw_ip := "127.0.0.1", |
| 101 | mgw_udp_port := 2427 |
| 102 | } |
| 103 | |
| 104 | vc_MGCP := MGCP_Emulation_CT.create(id); |
| 105 | map(vc_MGCP:MGCP, system:MGCP_CODEC_PT); |
| 106 | vc_MGCP.start(MGCP_Emulation.main(ops, pars, id)); |
| 107 | } |
| 108 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 109 | function f_init_gsup(charstring id) runs on MTC_CT { |
| 110 | id := id & "-GSUP"; |
| 111 | var GsupOps ops := { |
| 112 | create_cb := refers(GSUP_Emulation.ExpectedCreateCallback) |
| 113 | } |
| 114 | |
| 115 | vc_GSUP_IPA := IPA_Emulation_CT.create(id & "-IPA"); |
| 116 | vc_GSUP := GSUP_Emulation_CT.create(id); |
| 117 | |
| 118 | map(vc_GSUP_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 119 | connect(vc_GSUP:GSUP, vc_GSUP_IPA:IPA_GSUP_PORT); |
| 120 | /* we use this hack to get events like ASP_IPA_EVENT_UP */ |
| 121 | connect(vc_GSUP_IPA:IPA_CTRL_PORT, self:GSUP_IPA_EVENT); |
| 122 | |
| 123 | vc_GSUP.start(GSUP_Emulation.main(ops, id)); |
| 124 | vc_GSUP_IPA.start(IPA_Emulation.main_server(mp_hlr_ip, mp_hlr_port)); |
| 125 | |
| 126 | /* wait for incoming connection to GSUP port before proceeding */ |
| 127 | timer T := 10.0; |
| 128 | T.start; |
| 129 | alt { |
| 130 | [] GSUP_IPA_EVENT.receive(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_UP)) { } |
| 131 | [] T.timeout { |
| 132 | setverdict(inconc, "No connection to GSUP Port"); |
| 133 | self.stop |
| 134 | } |
| 135 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 136 | } |
| 137 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 138 | function f_init() runs on MTC_CT { |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 139 | |
| 140 | if (g_initialized == true) { |
| 141 | return; |
| 142 | } |
| 143 | g_initialized := true; |
| 144 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 145 | f_bssap_init("MSC_Test", BSC_BssmapOps); |
| 146 | f_ipa_ctrl_start(mp_msc_ip, mp_msc_ctrl_port); |
| 147 | f_init_mncc("MSC_Test"); |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 148 | f_init_mgcp("MSC_Test"); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 149 | f_init_gsup("MSC_Test"); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 150 | |
| 151 | map(self:MSCVTY, system:MSCVTY); |
| 152 | f_vty_set_prompts(MSCVTY); |
| 153 | f_vty_transceive(MSCVTY, "enable"); |
Harald Welte | b14c77a | 2018-01-25 17:25:44 +0100 | [diff] [blame] | 154 | |
| 155 | /* set some defaults */ |
| 156 | f_vty_config(MSCVTY, "network", "authentication optional"); |
| 157 | f_vty_config(MSCVTY, "msc", "assign-tmsi"); |
| 158 | f_vty_config(MSCVTY, "network", "encryption a5 0"); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | template PDU_BSSAP ts_BSSAP_BSSMAP := { |
| 162 | discriminator := '0'B, |
| 163 | spare := '0000000'B, |
| 164 | dlci := omit, |
| 165 | lengthIndicator := 0, /* overwritten by codec */ |
| 166 | pdu := ? |
| 167 | } |
| 168 | |
| 169 | template PDU_BSSAP tr_BSSAP_BSSMAP := { |
| 170 | discriminator := '0'B, |
| 171 | spare := '0000000'B, |
| 172 | dlci := omit, |
| 173 | lengthIndicator := ?, |
| 174 | pdu := { |
| 175 | bssmap := ? |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | |
| 180 | type integer BssmapCause; |
| 181 | |
| 182 | template (value) BSSMAP_IE_Cause ts_BSSMAP_IE_Cause(BssmapCause val) := { |
| 183 | elementIdentifier := '04'O, |
| 184 | lengthIndicator := 0, |
| 185 | causeValue := int2bit(val, 7), |
| 186 | extensionCauseValue := '0'B, |
| 187 | spare1 := omit |
| 188 | } |
| 189 | |
| 190 | template (value) PDU_BSSAP ts_BSSMAP_Reset(BssmapCause cause) modifies ts_BSSAP_BSSMAP := { |
| 191 | pdu := { |
| 192 | bssmap := { |
| 193 | reset := { |
| 194 | messageType := '30'O, |
| 195 | cause := ts_BSSMAP_IE_Cause(cause), |
| 196 | a_InterfaceSelectorForReset := omit |
| 197 | } |
| 198 | } |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | template (value) PDU_BSSAP ts_BSSMAP_ResetAck modifies ts_BSSAP_BSSMAP := { |
| 203 | pdu := { |
| 204 | bssmap := { |
| 205 | resetAck := { |
| 206 | messageType := '31'O, |
| 207 | a_InterfaceSelectorForReset := omit |
| 208 | } |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | template PDU_BSSAP tr_BSSMAP_ResetAck modifies tr_BSSAP_BSSMAP := { |
| 214 | pdu := { |
| 215 | bssmap := { |
| 216 | resetAck := { |
| 217 | messageType := '31'O, |
| 218 | a_InterfaceSelectorForReset := * |
| 219 | } |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | template BSSMAP_IE_CellIdentifier ts_BSSMAP_IE_CellID := { |
| 225 | elementIdentifier := '05'O, |
| 226 | lengthIndicator := 0, |
| 227 | cellIdentifierDiscriminator := '0000'B, |
| 228 | spare1_4 := '0000'B, |
| 229 | cellIdentification := ? |
| 230 | } |
| 231 | |
| 232 | type uint16_t BssmapLAC; |
| 233 | type uint16_t BssmapCI; |
| 234 | |
| 235 | /* |
| 236 | template BSSMAP_IE_CellIdentifier ts_CellId_CGI(mcc, mnc, lac, ci) |
| 237 | modifies ts_BSSMAP_IE_CellID := { |
| 238 | cellIdentification := { |
| 239 | cI_LAC_CGI := { |
| 240 | mnc_mcc := FIXME, |
| 241 | lac := int2oct(lac, 2), |
| 242 | ci := int2oct(ci, 2) |
| 243 | } |
| 244 | } |
| 245 | } |
| 246 | */ |
| 247 | |
| 248 | template BSSMAP_IE_CellIdentifier ts_CellID_LAC_CI(BssmapLAC lac, BssmapCI ci) |
| 249 | modifies ts_BSSMAP_IE_CellID := { |
| 250 | cellIdentification := { |
| 251 | cI_LAC_CI := { |
| 252 | lac := int2oct(lac, 2), |
| 253 | ci := int2oct(ci, 2) |
| 254 | } |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | template BSSMAP_IE_CellIdentifier ts_CellId_CI(BssmapCI ci) |
| 259 | modifies ts_BSSMAP_IE_CellID := { |
| 260 | cellIdentification := { |
| 261 | cI_CI := int2oct(ci, 2) |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | template BSSMAP_IE_CellIdentifier ts_CellId_none |
| 266 | modifies ts_BSSMAP_IE_CellID := { |
| 267 | cellIdentification := { |
| 268 | cI_noCell := ''O |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | |
| 273 | template BSSMAP_IE_Layer3Information ts_BSSMAP_IE_L3Info(octetstring l3info) := { |
| 274 | elementIdentifier := '17'O, |
| 275 | lengthIndicator := 0, |
| 276 | layer3info := l3info |
| 277 | } |
| 278 | |
| 279 | template PDU_BSSAP ts_BSSMAP_ComplL3(BSSMAP_IE_CellIdentifier cell_id, octetstring l3_info) |
| 280 | modifies ts_BSSAP_BSSMAP := { |
| 281 | pdu := { |
| 282 | bssmap := { |
| 283 | completeLayer3Information := { |
| 284 | messageType := '57'O, |
| 285 | cellIdentifier := cell_id, |
| 286 | layer3Information := ts_BSSMAP_IE_L3Info(l3_info), |
| 287 | chosenChannel := omit, |
| 288 | lSAIdentifier := omit, |
| 289 | aPDU := omit, |
| 290 | codecList := omit, |
| 291 | redirectAttemptFlag := omit, |
| 292 | sendSequenceNumber := omit, |
| 293 | iMSI := omit |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | template PDU_BSSAP ts_BSSMAP_HandoReq(BssmapCause cause, BSSMAP_IE_CellIdentifierList cid_list) |
| 300 | modifies ts_BSSAP_BSSMAP := { |
| 301 | pdu := { |
| 302 | bssmap := { |
| 303 | handoverRequired := { |
| 304 | messageType := '11'O, |
| 305 | cause := ts_BSSMAP_IE_Cause(cause), |
| 306 | responseRequest := omit, |
| 307 | cellIdentifierList := cid_list, |
| 308 | circuitPoolList := omit, |
| 309 | currentChannelType1 := omit, |
| 310 | speechVersion := omit, |
| 311 | queueingIndicator := omit, |
| 312 | oldToNewBSSInfo := omit, |
| 313 | sourceToTargetRNCTransparentInfo := omit, |
| 314 | sourceToTargetRNCTransparentInfoCDMA := omit, |
| 315 | gERANClassmark := omit, |
| 316 | talkerPriority := omit, |
| 317 | speechCodec := omit, |
| 318 | cSG_Identifier := omit |
| 319 | } |
| 320 | } |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | // enc_PDU_BSSAP |
| 325 | |
| 326 | 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] | 327 | 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] | 328 | } |
| 329 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 330 | 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] | 331 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 332 | private function f_concat_pad(integer tot_len, hexstring prefix, integer suffix) return hexstring { |
| 333 | var integer suffix_len := tot_len - lengthof(prefix); |
| 334 | var charstring suffix_ch := int2str(suffix); |
| 335 | var integer pad_len := suffix_len - lengthof(suffix_ch); |
| 336 | |
| 337 | return prefix & int2hex(0, pad_len) & str2hex(suffix_ch); |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 338 | } |
| 339 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 340 | function f_gen_imei(integer suffix) return hexstring { |
| 341 | return f_concat_pad(15, '49999'H, suffix); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 342 | } |
| 343 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 344 | function f_gen_imsi(integer suffix) return hexstring { |
| 345 | return f_concat_pad(15, '26242'H, suffix); |
| 346 | } |
| 347 | |
| 348 | function f_gen_msisdn(integer suffix) return hexstring { |
| 349 | return f_concat_pad(12, '49123'H, suffix); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | /* FIXME: move into BSC_ConnectionHandler? */ |
| 353 | function f_start_handler(void_fn fn, charstring id, integer imsi_suffix) runs on MTC_CT return BSC_ConnHdlr { |
| 354 | var BSC_ConnHdlr vc_conn; |
| 355 | var BSC_ConnHdlrPars pars := { |
| 356 | sccp_addr_own := g_sccp_addr_own, |
| 357 | sccp_addr_peer := g_sccp_addr_peer, |
| 358 | cell_id := valueof(ts_CellId_CGI('262'H, '042'H, 23, 42)), |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 359 | imei := f_gen_imei(imsi_suffix), |
| 360 | imsi := f_gen_imsi(imsi_suffix), |
| 361 | msisdn := f_gen_msisdn(imsi_suffix), |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 362 | tmsi := omit, |
Harald Welte | 8260057 | 2018-01-21 20:54:08 +0100 | [diff] [blame] | 363 | cm2 := valueof(ts_CM2_default), |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 364 | cm3 := omit, |
Harald Welte | 148a708 | 2018-01-26 18:56:43 +0100 | [diff] [blame] | 365 | vec := omit |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 366 | }; |
| 367 | |
| 368 | vc_conn := BSC_ConnHdlr.create(id); |
| 369 | /* BSSMAP part / A interface */ |
| 370 | connect(vc_conn:BSSAP, vc_BSSMAP:CLIENT); |
| 371 | connect(vc_conn:BSSAP_PROC, vc_BSSMAP:PROC); |
| 372 | /* MNCC part */ |
| 373 | connect(vc_conn:MNCC, vc_MNCC:MNCC_CLIENT); |
| 374 | connect(vc_conn:MNCC_PROC, vc_MNCC:MNCC_PROC); |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 375 | /* MGCP part */ |
| 376 | connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT); |
| 377 | connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 378 | /* GSUP part */ |
| 379 | connect(vc_conn:GSUP, vc_GSUP:GSUP_CLIENT); |
| 380 | connect(vc_conn:GSUP_PROC, vc_GSUP:GSUP_PROC); |
| 381 | |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 382 | /* We cannot use vc_conn.start(f_init_handler(fn, id, pars)); as we cannot have |
| 383 | * a stand-alone 'derefers()' call, see https://www.eclipse.org/forums/index.php/t/1091364/ */ |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 384 | vc_conn.start(derefers(fn)(id, pars)); |
| 385 | return vc_conn; |
| 386 | } |
| 387 | |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 388 | function f_vty_config(TELNETasp_PT pt, charstring config_node, charstring cmd) |
| 389 | { |
| 390 | /* enter config mode; enter node */ |
| 391 | f_vty_enter_config(pt); |
| 392 | f_vty_transceive(pt, config_node); |
| 393 | /* execute command */ |
| 394 | f_vty_transceive(pt, cmd); |
| 395 | /* leave config mode */ |
| 396 | f_vty_transceive(pt, "end"); |
| 397 | } |
| 398 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 399 | private function f_tc_lu_imsi_noauth_tmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 400 | f_init_handler(pars); |
Harald Welte | 8a121b3 | 2018-01-22 03:00:41 +0100 | [diff] [blame] | 401 | f_perform_lu(false, true, true); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 402 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 403 | testcase TC_lu_imsi_noauth_tmsi() runs on MTC_CT { |
| 404 | var BSC_ConnHdlr vc_conn; |
| 405 | f_init(); |
| 406 | |
| 407 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_tmsi), testcasename(), 1); |
| 408 | vc_conn.done; |
| 409 | } |
| 410 | |
| 411 | private function f_tc_lu_imsi_noauth_notmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 412 | f_init_handler(pars); |
Harald Welte | 8a121b3 | 2018-01-22 03:00:41 +0100 | [diff] [blame] | 413 | f_perform_lu(false, false, true); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 414 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 415 | testcase TC_lu_imsi_noauth_notmsi() runs on MTC_CT { |
| 416 | var BSC_ConnHdlr vc_conn; |
| 417 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 418 | f_vty_config(MSCVTY, "msc", "no assign-tmsi"); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 419 | |
| 420 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_notmsi), testcasename(), 2); |
| 421 | vc_conn.done; |
| 422 | } |
| 423 | |
| 424 | /* Do LU by IMSI, refuse it on GSUP and expect LU REJ back to MS */ |
| 425 | private function f_tc_lu_imsi_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 426 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 427 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 428 | |
| 429 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 430 | f_bssap_compl_l3(l3_lu); |
| 431 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 432 | GSUP.send(ts_GSUP_UL_ERR(g_pars.imsi, 23)); |
| 433 | alt { |
| 434 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej(int2oct(23,1)))) { } |
| 435 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 436 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
| 437 | self.stop; |
| 438 | } |
| 439 | } |
| 440 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 441 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 442 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 443 | setverdict(pass); |
| 444 | } |
| 445 | testcase TC_lu_imsi_reject() runs on MTC_CT { |
| 446 | var BSC_ConnHdlr vc_conn; |
| 447 | f_init(); |
| 448 | |
| 449 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_reject), testcasename(), 3); |
| 450 | vc_conn.done; |
| 451 | } |
| 452 | |
| 453 | /* Do LU by IMSI, timeout on GSUP */ |
| 454 | private function f_tc_lu_imsi_timeout_gsup(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 455 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 456 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 457 | |
| 458 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 459 | f_bssap_compl_l3(l3_lu); |
| 460 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 461 | /* Normally the HLR would need to respond here, but we decide to force a timeout here */ |
| 462 | alt { |
| 463 | /* FIXME: Expect specific reject cause */ |
| 464 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { } |
| 465 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 466 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
| 467 | self.stop; |
| 468 | } |
| 469 | } |
| 470 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 471 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 472 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 473 | setverdict(pass); |
| 474 | } |
| 475 | testcase TC_lu_imsi_timeout_gsup() runs on MTC_CT { |
| 476 | var BSC_ConnHdlr vc_conn; |
| 477 | f_init(); |
| 478 | |
| 479 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_timeout_gsup), testcasename(), 4); |
| 480 | vc_conn.done; |
| 481 | } |
| 482 | |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 483 | private function f_tc_lu_imsi_auth_tmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 484 | f_init_handler(pars); |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 485 | f_perform_lu(true, true, true); |
| 486 | } |
| 487 | testcase TC_lu_imsi_auth_tmsi() runs on MTC_CT { |
| 488 | var BSC_ConnHdlr vc_conn; |
| 489 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 490 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 491 | |
| 492 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi), testcasename(), 5); |
| 493 | vc_conn.done; |
| 494 | } |
| 495 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 496 | |
| 497 | /* Send CM SERVICE REQ for IMSI that has never performed LU before */ |
| 498 | private function f_tc_cmserv_imsi_unknown(charstring id, BSC_ConnHdlrPars pars) |
| 499 | runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 500 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 501 | |
| 502 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 503 | var BSSMAP_IE_CellIdentifier cell_id := valueof(ts_CellId_CGI('262'H, '042'H, 23, 42)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 504 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi)); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 505 | |
| 506 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 507 | |
| 508 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 509 | f_bssap_compl_l3(l3_info); |
| 510 | |
| 511 | timer T := 10.0; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 512 | T.start; |
| 513 | alt { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 514 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)) { } |
| 515 | //[] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_ACC)) { } |
| 516 | [] BSSAP.receive { setverdict(fail, "Received unexpected BSSAP"); } |
| 517 | [] GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)) { |
| 518 | setverdict(fail, "Unexpected GSUP UL REQ"); |
| 519 | } |
| 520 | [] T.timeout { setverdict(inconc, "Timeout waiting for CM SERV REQ"); } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 521 | } |
| 522 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 523 | alt { |
| 524 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 525 | setverdict(pass); |
| 526 | } |
| 527 | [] BSSAP.receive { setverdict(fail, "Received unexpected BSSAP"); } |
| 528 | [] T.timeout { setverdict(inconc, "Timeout waiting for CM SERV REQ"); } |
| 529 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 530 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 531 | testcase TC_cmserv_imsi_unknown() runs on MTC_CT { |
| 532 | var BSC_ConnHdlr vc_conn; |
| 533 | f_init(); |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 534 | vc_conn := f_start_handler(refers(f_tc_cmserv_imsi_unknown), testcasename(), 6); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 535 | vc_conn.done; |
| 536 | } |
| 537 | |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 538 | private function f_tc_lu_and_mo_call(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 539 | f_init_handler(pars); |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 540 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 541 | cpars.bss_rtp_port := 1110; |
| 542 | cpars.mgcp_connection_id_bss := '22222'H; |
| 543 | cpars.mgcp_connection_id_mss := '33333'H; |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 544 | |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 545 | f_perform_lu(cpars.expect_auth, true, true); |
| 546 | f_mo_call(cpars); |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 547 | } |
| 548 | testcase TC_lu_and_mo_call() runs on MTC_CT { |
| 549 | var BSC_ConnHdlr vc_conn; |
| 550 | f_init(); |
| 551 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 552 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_call), testcasename(), 7); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 553 | vc_conn.done; |
| 554 | } |
| 555 | |
| 556 | /* Test LU (with authentication enabled), where HLR times out sending SAI response */ |
| 557 | private function f_tc_lu_auth_sai_timeout(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 558 | f_init_handler(pars); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 559 | |
| 560 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 561 | var PDU_DTAP_MT dtap_mt; |
| 562 | |
| 563 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 564 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 565 | |
| 566 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 567 | f_bssap_compl_l3(l3_lu); |
| 568 | |
| 569 | /* Send Early Classmark, just for the fun of it */ |
| 570 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 571 | |
| 572 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 573 | /* The HLR would normally return an auth vector here, but we fail to do so. */ |
| 574 | |
| 575 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)); |
| 576 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 577 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 578 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 579 | setverdict(pass); |
| 580 | } |
| 581 | testcase TC_lu_auth_sai_timeout() runs on MTC_CT { |
| 582 | var BSC_ConnHdlr vc_conn; |
| 583 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 584 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 585 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 586 | vc_conn := f_start_handler(refers(f_tc_lu_auth_sai_timeout), testcasename(), 8); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 587 | vc_conn.done; |
| 588 | } |
| 589 | |
| 590 | /* Test LU (with authentication enabled), where HLR rejects sending SAI error */ |
| 591 | private function f_tc_lu_auth_sai_err(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 592 | f_init_handler(pars); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 593 | |
| 594 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 595 | var PDU_DTAP_MT dtap_mt; |
| 596 | |
| 597 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 598 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 599 | |
| 600 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 601 | f_bssap_compl_l3(l3_lu); |
| 602 | |
| 603 | /* Send Early Classmark, just for the fun of it */ |
| 604 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 605 | |
| 606 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 607 | GSUP.send(ts_GSUP_SAI_ERR(g_pars.imsi, 13)); |
| 608 | |
| 609 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)); |
| 610 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 611 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 612 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 613 | setverdict(pass); |
| 614 | } |
| 615 | testcase TC_lu_auth_sai_err() runs on MTC_CT { |
| 616 | var BSC_ConnHdlr vc_conn; |
| 617 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 618 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 619 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 620 | vc_conn := f_start_handler(refers(f_tc_lu_auth_sai_err), testcasename(), 9); |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 621 | vc_conn.done; |
| 622 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 623 | |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 624 | /* Test LU but BSC will send a clear request in the middle */ |
| 625 | private function f_tc_lu_clear_request(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 626 | f_init_handler(pars); |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 627 | |
| 628 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 629 | var PDU_DTAP_MT dtap_mt; |
| 630 | |
| 631 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 632 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 633 | |
| 634 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 635 | f_bssap_compl_l3(l3_lu); |
| 636 | |
| 637 | /* Send Early Classmark, just for the fun of it */ |
| 638 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 639 | |
| 640 | f_sleep(1.0); |
| 641 | /* send clear request in the middle of the LU */ |
| 642 | BSSAP.send(ts_BSSMAP_ClearRequest(0)); |
| 643 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 644 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 645 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 646 | setverdict(pass); |
| 647 | } |
| 648 | testcase TC_lu_clear_request() runs on MTC_CT { |
| 649 | var BSC_ConnHdlr vc_conn; |
| 650 | f_init(); |
| 651 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 652 | vc_conn := f_start_handler(refers(f_tc_lu_clear_request), testcasename(), 10); |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 653 | vc_conn.done; |
| 654 | } |
| 655 | |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 656 | /* Test LU but BSC will send a clear request in the middle */ |
| 657 | private function f_tc_lu_disconnect(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 658 | f_init_handler(pars); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 659 | |
| 660 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 661 | var PDU_DTAP_MT dtap_mt; |
| 662 | |
| 663 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 664 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 665 | |
| 666 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 667 | f_bssap_compl_l3(l3_lu); |
| 668 | |
| 669 | /* Send Early Classmark, just for the fun of it */ |
| 670 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 671 | |
| 672 | f_sleep(1.0); |
| 673 | /* send clear request in the middle of the LU */ |
| 674 | BSSAP.send(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_REQ); |
| 675 | setverdict(pass); |
| 676 | } |
| 677 | testcase TC_lu_disconnect() runs on MTC_CT { |
| 678 | var BSC_ConnHdlr vc_conn; |
| 679 | f_init(); |
| 680 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 681 | vc_conn := f_start_handler(refers(f_tc_lu_disconnect), testcasename(), 11); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 682 | vc_conn.done; |
| 683 | } |
| 684 | |
| 685 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 686 | /* Test LU but with illegal mobile identity type = IMEI */ |
| 687 | private function f_tc_lu_by_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 688 | f_init_handler(pars); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 689 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 690 | 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] | 691 | var PDU_DTAP_MT dtap_mt; |
| 692 | |
| 693 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 694 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 695 | |
| 696 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 697 | f_bssap_compl_l3(l3_lu); |
| 698 | |
| 699 | /* Send Early Classmark, just for the fun of it */ |
| 700 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 701 | /* wait for LU reject, ignore any ID REQ */ |
| 702 | alt { |
| 703 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { } |
| 704 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req)) { repeat; } |
| 705 | } |
| 706 | /* wait for normal teardown */ |
| 707 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 708 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 709 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 710 | setverdict(pass); |
| 711 | } |
| 712 | testcase TC_lu_by_imei() runs on MTC_CT { |
| 713 | var BSC_ConnHdlr vc_conn; |
| 714 | f_init(); |
| 715 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 716 | vc_conn := f_start_handler(refers(f_tc_lu_by_imei), testcasename(), 12); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 717 | vc_conn.done; |
| 718 | } |
| 719 | |
| 720 | /* Test LU by TMSI with unknown TMSI, expect (and answer) ID REQ. */ |
| 721 | private function f_tc_lu_tmsi_noauth_unknown(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 722 | f_init_handler(pars); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 723 | |
| 724 | var PDU_ML3_MS_NW l3_lu := f_build_lu_tmsi('01020304'O); /* FIXME: Random */ |
| 725 | var PDU_DTAP_MT dtap_mt; |
| 726 | |
| 727 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 728 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 729 | |
| 730 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 731 | f_bssap_compl_l3(l3_lu); |
| 732 | |
| 733 | /* Send Early Classmark, just for the fun of it */ |
| 734 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 735 | |
| 736 | /* Wait for + respond to ID REQ (IMSI) */ |
| 737 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req('001'B))); |
| 738 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp_IMSI(g_pars.imsi))); |
| 739 | |
| 740 | /* Expect MSC to do UpdateLocation to HLR; respond to it */ |
| 741 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 742 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 743 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 744 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 745 | |
| 746 | alt { |
Harald Welte | 7ec4fa8 | 2018-01-27 10:57:40 +0100 | [diff] [blame] | 747 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 748 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_TmsiRealloc_Cmpl)); |
| 749 | } |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 750 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 751 | setverdict(fail, "Expected LU ACK, but received REJ"); |
| 752 | } |
| 753 | } |
| 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_lu_by_tmsi_noauth_unknown() runs on MTC_CT { |
| 762 | var BSC_ConnHdlr vc_conn; |
| 763 | f_init(); |
| 764 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 765 | vc_conn := f_start_handler(refers(f_tc_lu_tmsi_noauth_unknown), testcasename(), 13); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 766 | vc_conn.done; |
| 767 | } |
| 768 | |
| 769 | |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 770 | /* Test IMSI DETACH (MI=IMSI) */ |
| 771 | private function f_tc_imsi_detach_by_imsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 772 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 773 | |
| 774 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 775 | |
| 776 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 777 | f_bssap_compl_l3(valueof(ts_ML3_MO_MM_IMSI_DET_Ind(mi))); |
| 778 | |
| 779 | /* Send Early Classmark, just for the fun of it? */ |
| 780 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 781 | |
| 782 | /* wait for normal teardown */ |
| 783 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 784 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 785 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 786 | setverdict(pass); |
| 787 | } |
| 788 | testcase TC_imsi_detach_by_imsi() runs on MTC_CT { |
| 789 | var BSC_ConnHdlr vc_conn; |
| 790 | f_init(); |
| 791 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 792 | vc_conn := f_start_handler(refers(f_tc_imsi_detach_by_imsi), testcasename(), 14); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 793 | vc_conn.done; |
| 794 | } |
| 795 | |
| 796 | /* Test IMSI DETACH (MI=TMSI) */ |
| 797 | private function f_tc_imsi_detach_by_tmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 798 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 799 | |
| 800 | var MobileIdentityLV mi := valueof(ts_MI_TMSI_LV('01020304'O)); |
| 801 | |
| 802 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 803 | f_bssap_compl_l3(valueof(ts_ML3_MO_MM_IMSI_DET_Ind(mi))); |
| 804 | |
| 805 | /* Send Early Classmark, just for the fun of it? */ |
| 806 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 807 | |
| 808 | /* wait for normal teardown */ |
| 809 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 810 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 811 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 812 | setverdict(pass); |
| 813 | } |
| 814 | testcase TC_imsi_detach_by_tmsi() runs on MTC_CT { |
| 815 | var BSC_ConnHdlr vc_conn; |
| 816 | f_init(); |
| 817 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 818 | vc_conn := f_start_handler(refers(f_tc_imsi_detach_by_tmsi), testcasename(), 15); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 819 | vc_conn.done; |
| 820 | } |
| 821 | |
| 822 | /* Test IMSI DETACH (MI=IMEI), which is illegal */ |
| 823 | private function f_tc_imsi_detach_by_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 824 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 825 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 826 | var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 827 | |
| 828 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 829 | f_bssap_compl_l3(valueof(ts_ML3_MO_MM_IMSI_DET_Ind(mi))); |
| 830 | |
| 831 | /* Send Early Classmark, just for the fun of it? */ |
| 832 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 833 | |
| 834 | /* wait for normal teardown */ |
| 835 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 836 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 837 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 838 | setverdict(pass); |
| 839 | } |
| 840 | testcase TC_imsi_detach_by_imei() runs on MTC_CT { |
| 841 | var BSC_ConnHdlr vc_conn; |
| 842 | f_init(); |
| 843 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 844 | vc_conn := f_start_handler(refers(f_tc_imsi_detach_by_imei), testcasename(), 16); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 845 | vc_conn.done; |
| 846 | } |
| 847 | |
| 848 | |
| 849 | /* helper function for an emergency call. caller passes in mobile identity to use */ |
| 850 | private function f_emerg_call(MobileIdentityLV mi) runs on BSC_ConnHdlr { |
| 851 | |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 852 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_EMERG_CALL, mi)); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 853 | f_bssap_compl_l3(l3_info); |
| 854 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_ACC)); |
| 855 | |
| 856 | var hexstring called := '112'H; |
| 857 | var integer tid := 0; |
| 858 | var MNCC_PDU mncc; |
| 859 | f_create_mncc_expect(hex2str(called)); |
| 860 | |
| 861 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_EMERG_SETUP(tid))); |
| 862 | MNCC.receive(tr_MNCC_SETUP_ind(?, tr_MNCC_number(hex2str(called)))) -> value mncc; |
| 863 | /* FIXME: extract call_id */ |
| 864 | |
| 865 | /* Call Proceeding */ |
| 866 | MNCC.send(ts_MNCC_CALL_PROC_req(mncc.u.signal.callref, ts_MNCC_bcap_voice)); |
| 867 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CALL_PROC(tid))); |
| 868 | |
| 869 | /* Alerting */ |
| 870 | MNCC.send(ts_MNCC_ALERT_req(mncc.u.signal.callref)); |
| 871 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_ALERTING(tid))); |
| 872 | |
| 873 | /* Answer. This causes TCH assignment in case of "late assignment" */ |
Harald Welte | 4017d55 | 2018-01-26 21:40:05 +0100 | [diff] [blame] | 874 | //MNCC.send(ts_MNCC_SETUP_COMPL_req(mncc.u.signal.callref)); |
| 875 | MNCC.send(ts_MNCC_SETUP_rsp(mncc.u.signal.callref)); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 876 | |
| 877 | f_sleep(3.0); |
| 878 | |
| 879 | /* Hangup by "B" side */ |
| 880 | MNCC.send(ts_MNCC_DISC_req(mncc.u.signal.callref, valueof(ts_MNCC_cause(23)))); |
| 881 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_DISC(tid))); |
| 882 | |
| 883 | /* Release of call */ |
| 884 | MNCC.send(ts_MNCC_REL_req(mncc.u.signal.callref, valueof(ts_MNCC_cause(42)))); |
| 885 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(tid))); |
| 886 | |
| 887 | /* clearing of radio channel */ |
| 888 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 889 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 890 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 891 | |
| 892 | f_sleep(5.0); |
| 893 | } |
| 894 | |
| 895 | /* establish an emergency call by IMEI, no SIM inserted (and hence no IMSI) */ |
| 896 | private function f_tc_emerg_call_imei_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 897 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 898 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 899 | var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 900 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_EMERG_CALL, mi)); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 901 | f_bssap_compl_l3(l3_info); |
| 902 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ('05'O))); |
Harald Welte | f6b62ee | 2018-01-24 21:49:32 +0100 | [diff] [blame] | 903 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 904 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 905 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 906 | setverdict(pass); |
| 907 | } |
| 908 | testcase TC_emerg_call_imei_reject() runs on MTC_CT { |
| 909 | var BSC_ConnHdlr vc_conn; |
| 910 | f_init(); |
| 911 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 912 | vc_conn := f_start_handler(refers(f_tc_emerg_call_imei_reject), testcasename(), 17); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 913 | vc_conn.done; |
| 914 | } |
| 915 | |
Harald Welte | d5b9140 | 2018-01-24 18:48:16 +0100 | [diff] [blame] | 916 | /* establish an emergency call by IMSI, SIM inserted (and hence IMSI) */ |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 917 | private function f_tc_emerg_call_imsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 918 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 919 | /* First perform location update to ensure subscriber is known */ |
| 920 | f_perform_lu(false, true, true); |
| 921 | /* Then issue emergency call identified by IMSI */ |
| 922 | f_emerg_call(valueof(ts_MI_IMSI_LV(g_pars.imsi))); |
| 923 | } |
| 924 | testcase TC_emerg_call_imsi() runs on MTC_CT { |
| 925 | var BSC_ConnHdlr vc_conn; |
| 926 | f_init(); |
| 927 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 928 | vc_conn := f_start_handler(refers(f_tc_emerg_call_imsi), testcasename(), 18); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 929 | vc_conn.done; |
| 930 | } |
| 931 | |
| 932 | /* CM Service Request for VGCS -> reject */ |
| 933 | private function f_tc_cm_serv_req_vgcs_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 934 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 935 | |
| 936 | /* First perform location update to ensure subscriber is known */ |
| 937 | f_perform_lu(false, true, true); |
| 938 | |
| 939 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 940 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_VGCS, mi)); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 941 | f_bssap_compl_l3(l3_info); |
| 942 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ(int2oct(32,1)))); |
Harald Welte | f6b62ee | 2018-01-24 21:49:32 +0100 | [diff] [blame] | 943 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 944 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 945 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 946 | setverdict(pass); |
| 947 | } |
| 948 | testcase TC_cm_serv_req_vgcs_reject() runs on MTC_CT { |
| 949 | var BSC_ConnHdlr vc_conn; |
| 950 | f_init(); |
| 951 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 952 | vc_conn := f_start_handler(refers(f_tc_cm_serv_req_vgcs_reject), testcasename(), 19); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 953 | vc_conn.done; |
| 954 | } |
| 955 | |
| 956 | /* CM Service Request for VBS -> reject */ |
| 957 | private function f_tc_cm_serv_req_vbs_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 958 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 959 | |
| 960 | /* First perform location update to ensure subscriber is known */ |
| 961 | f_perform_lu(false, true, true); |
| 962 | |
| 963 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 964 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_VBS, mi)); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 965 | f_bssap_compl_l3(l3_info); |
| 966 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ(int2oct(32,1)))); |
Harald Welte | f6b62ee | 2018-01-24 21:49:32 +0100 | [diff] [blame] | 967 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 968 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 969 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 970 | setverdict(pass); |
| 971 | } |
| 972 | testcase TC_cm_serv_req_vbs_reject() runs on MTC_CT { |
| 973 | var BSC_ConnHdlr vc_conn; |
| 974 | f_init(); |
| 975 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 976 | vc_conn := f_start_handler(refers(f_tc_cm_serv_req_vbs_reject), testcasename(), 20); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 977 | vc_conn.done; |
| 978 | } |
| 979 | |
| 980 | /* CM Service Request for LCS -> reject */ |
| 981 | private function f_tc_cm_serv_req_lcs_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 982 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 983 | |
| 984 | /* First perform location update to ensure subscriber is known */ |
| 985 | f_perform_lu(false, true, true); |
| 986 | |
| 987 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 988 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_LCS, mi)); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 989 | f_bssap_compl_l3(l3_info); |
| 990 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ(int2oct(32,1)))); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 991 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 992 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 993 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 994 | setverdict(pass); |
| 995 | } |
| 996 | testcase TC_cm_serv_req_lcs_reject() runs on MTC_CT { |
| 997 | var BSC_ConnHdlr vc_conn; |
| 998 | f_init(); |
| 999 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 1000 | vc_conn := f_start_handler(refers(f_tc_cm_serv_req_lcs_reject), testcasename(), 21); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1001 | vc_conn.done; |
| 1002 | } |
| 1003 | |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1004 | /* CM Re-Establishment Request */ |
| 1005 | private function f_tc_cm_reest_req_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1006 | f_init_handler(pars); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1007 | |
| 1008 | /* First perform location update to ensure subscriber is known */ |
| 1009 | f_perform_lu(false, true, true); |
| 1010 | |
| 1011 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 1012 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_REEST_REQ(0, mi)); |
| 1013 | f_bssap_compl_l3(l3_info); |
| 1014 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ(int2oct(32,1)))); |
| 1015 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 1016 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 1017 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 1018 | setverdict(pass); |
| 1019 | } |
| 1020 | testcase TC_cm_reest_req_reject() runs on MTC_CT { |
| 1021 | var BSC_ConnHdlr vc_conn; |
| 1022 | f_init(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1023 | |
| 1024 | vc_conn := f_start_handler(refers(f_tc_cm_reest_req_reject), testcasename(), 22); |
| 1025 | vc_conn.done; |
| 1026 | } |
| 1027 | |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1028 | /* Test LU (with authentication enabled), with wrong response from MS */ |
| 1029 | private function f_tc_lu_auth_2G_fail(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1030 | f_init_handler(pars); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1031 | |
| 1032 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 1033 | |
| 1034 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1035 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1036 | |
| 1037 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 1038 | f_bssap_compl_l3(l3_lu); |
| 1039 | |
| 1040 | /* Send Early Classmark, just for the fun of it */ |
| 1041 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1042 | |
| 1043 | var AuthVector vec := f_gen_auth_vec_2g(); |
| 1044 | var GSUP_IE auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G(vec.rand, vec.sres, vec.kc)); |
| 1045 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 1046 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
| 1047 | |
| 1048 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_AUTH_REQ(vec.rand))); |
| 1049 | /* Send back wrong auth response */ |
| 1050 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MT_MM_AUTH_RESP_2G('00000000'O))); |
| 1051 | |
| 1052 | /* Expect GSUP AUTH FAIL REP to HLR */ |
| 1053 | GSUP.receive(tr_GSUP_AUTH_FAIL_IND(g_pars.imsi)); |
| 1054 | |
| 1055 | /* Expect LU REJECT with Cause == Illegal MS */ |
| 1056 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej('03'O))); |
| 1057 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 1058 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 1059 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 1060 | setverdict(pass); |
| 1061 | } |
| 1062 | testcase TC_lu_auth_2G_fail() runs on MTC_CT { |
| 1063 | var BSC_ConnHdlr vc_conn; |
| 1064 | f_init(); |
| 1065 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1066 | |
| 1067 | vc_conn := f_start_handler(refers(f_tc_lu_auth_2G_fail), testcasename(), 23); |
| 1068 | vc_conn.done; |
| 1069 | } |
| 1070 | |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 1071 | private function f_tc_lu_imsi_auth_tmsi_encr_13_13(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1072 | f_init_handler(pars); |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 1073 | f_perform_lu(true, true, true, true); |
| 1074 | } |
| 1075 | testcase TC_lu_imsi_auth_tmsi_encr_13_13() runs on MTC_CT { |
| 1076 | var BSC_ConnHdlr vc_conn; |
| 1077 | f_init(); |
| 1078 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 1079 | f_vty_config(MSCVTY, "network", "encryption a5 1 3"); |
| 1080 | |
| 1081 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_13_13), testcasename(), 24); |
| 1082 | vc_conn.done; |
| 1083 | } |
| 1084 | |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1085 | /* Test Complete L3 without payload */ |
| 1086 | private function f_tc_cl3_no_payload(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1087 | f_init_handler(pars); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1088 | |
| 1089 | /* Send Complete L3 Info with empty L3 frame */ |
| 1090 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own, |
| 1091 | valueof(ts_BSSMAP_ComplL3(g_pars.cell_id, ''O)))); |
| 1092 | |
| 1093 | alt { |
| 1094 | [] BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
| 1095 | /* Expect LU REJECT with Cause == Illegal MS */ |
| 1096 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 1097 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 1098 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 1099 | } |
| 1100 | } |
| 1101 | setverdict(pass); |
| 1102 | } |
| 1103 | testcase TC_cl3_no_payload() runs on MTC_CT { |
| 1104 | var BSC_ConnHdlr vc_conn; |
| 1105 | f_init(); |
| 1106 | |
| 1107 | vc_conn := f_start_handler(refers(f_tc_cl3_no_payload), testcasename(), 24); |
| 1108 | vc_conn.done; |
| 1109 | } |
| 1110 | |
| 1111 | /* Test Complete L3 with random payload */ |
| 1112 | private function f_tc_cl3_rnd_payload(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1113 | f_init_handler(pars); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1114 | |
| 1115 | var integer len := float2int(rnd() * 256.0); |
| 1116 | var octetstring payl := f_rnd_octstring(len); |
| 1117 | |
| 1118 | /* Send Complete L3 Info with empty L3 frame */ |
| 1119 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own, |
| 1120 | valueof(ts_BSSMAP_ComplL3(g_pars.cell_id, payl)))); |
| 1121 | |
| 1122 | alt { |
| 1123 | /* Immediate disconnect */ |
| 1124 | [] BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
| 1125 | /* Expect LU REJECT with Cause == Illegal MS */ |
| 1126 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 1127 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 1128 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 1129 | } |
| 1130 | [] BSSAP.receive(tr_PDU_DTAP_MT(?)) { repeat; } |
| 1131 | } |
| 1132 | setverdict(pass); |
| 1133 | } |
| 1134 | testcase TC_cl3_rnd_payload() runs on MTC_CT { |
| 1135 | var BSC_ConnHdlr vc_conn; |
| 1136 | f_init(); |
| 1137 | |
| 1138 | vc_conn := f_start_handler(refers(f_tc_cl3_rnd_payload), testcasename(), 24); |
| 1139 | vc_conn.done; |
| 1140 | } |
| 1141 | |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1142 | /* Test Complete L3 with random payload */ |
| 1143 | private function f_tc_establish_and_nothing(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1144 | f_init_handler(pars); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1145 | |
| 1146 | f_perform_lu(false, true, true, false); |
| 1147 | |
| 1148 | f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)), false, false); |
| 1149 | timer T := 30.0; |
Harald Welte | 946a538 | 2018-01-26 22:53:14 +0100 | [diff] [blame] | 1150 | T.start; |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1151 | alt { |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1152 | [] T.timeout { setverdict(fail, "Timeout waiting for channel release"); self.stop; } |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1153 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 1154 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 1155 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 1156 | setverdict(pass); |
| 1157 | } |
| 1158 | [] BSSAP.receive { repeat; } |
| 1159 | [] MNCC.receive { repeat; } |
| 1160 | [] GSUP.receive { repeat; } |
| 1161 | [] MGCP.receive { repeat; } |
| 1162 | } |
| 1163 | } |
| 1164 | testcase TC_establish_and_nothing() runs on MTC_CT { |
| 1165 | var BSC_ConnHdlr vc_conn; |
| 1166 | f_init(); |
| 1167 | |
| 1168 | vc_conn := f_start_handler(refers(f_tc_establish_and_nothing), testcasename(), 25); |
| 1169 | vc_conn.done; |
| 1170 | } |
| 1171 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1172 | /* Test MO Call SETUP with no response from MNCC */ |
| 1173 | private function f_tc_mo_setup_and_nothing(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1174 | f_init_handler(pars); |
| 1175 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1176 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1177 | |
| 1178 | f_perform_lu(false, true, true, false); |
| 1179 | |
| 1180 | f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)), false, false); |
| 1181 | f_create_mncc_expect(hex2str(cpars.called_party)); |
| 1182 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1183 | |
| 1184 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_SETUP(cpars.transaction_id, cpars.called_party))); |
| 1185 | |
| 1186 | timer T := 30.0; |
Harald Welte | 946a538 | 2018-01-26 22:53:14 +0100 | [diff] [blame] | 1187 | T.start; |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1188 | alt { |
| 1189 | [] T.timeout { setverdict(fail, "Timeout waiting for channel release"); self.stop; } |
| 1190 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 1191 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 1192 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 1193 | setverdict(pass); |
| 1194 | } |
| 1195 | [] BSSAP.receive { repeat; } |
| 1196 | [] MNCC.receive { repeat; } |
| 1197 | [] GSUP.receive { repeat; } |
| 1198 | [] MGCP.receive { repeat; } |
| 1199 | } |
| 1200 | } |
| 1201 | testcase TC_mo_setup_and_nothing() runs on MTC_CT { |
| 1202 | var BSC_ConnHdlr vc_conn; |
| 1203 | f_init(); |
| 1204 | |
| 1205 | vc_conn := f_start_handler(refers(f_tc_mo_setup_and_nothing), testcasename(), 26); |
| 1206 | vc_conn.done; |
| 1207 | } |
| 1208 | |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1209 | /* Test MO Call with no response to RAN-side CRCX */ |
| 1210 | private function f_tc_mo_crcx_ran_timeout(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1211 | f_init_handler(pars); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1212 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1213 | var MNCC_PDU mncc; |
| 1214 | var MgcpCommand mgcp_cmd; |
| 1215 | |
| 1216 | f_perform_lu(false, true, true, false); |
| 1217 | |
| 1218 | f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)), false, false); |
| 1219 | f_create_mncc_expect(hex2str(cpars.called_party)); |
| 1220 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1221 | |
| 1222 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_SETUP(cpars.transaction_id, cpars.called_party))); |
| 1223 | MNCC.receive(tr_MNCC_SETUP_ind(?, tr_MNCC_number(hex2str(cpars.called_party)))) -> value mncc; |
| 1224 | cpars.mncc_callref := mncc.u.signal.callref; |
| 1225 | MNCC.send(ts_MNCC_CALL_PROC_req(cpars.mncc_callref, cpars.mncc_bearer_cap)); |
| 1226 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CALL_PROC(cpars.transaction_id))); |
| 1227 | |
| 1228 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
Harald Welte | 1852a84 | 2018-01-26 22:53:36 +0100 | [diff] [blame] | 1229 | cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
| 1230 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1231 | /* never respond to this */ |
| 1232 | |
| 1233 | timer T := 30.0; |
Harald Welte | 946a538 | 2018-01-26 22:53:14 +0100 | [diff] [blame] | 1234 | T.start; |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1235 | alt { |
| 1236 | [] T.timeout { setverdict(fail, "Timeout waiting for channel release"); self.stop; } |
| 1237 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 1238 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 1239 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 1240 | setverdict(pass); |
| 1241 | } |
| 1242 | [] BSSAP.receive { repeat; } |
| 1243 | [] MNCC.receive { repeat; } |
| 1244 | [] GSUP.receive { repeat; } |
| 1245 | [] MGCP.receive { repeat; } |
| 1246 | } |
| 1247 | } |
| 1248 | testcase TC_mo_crcx_ran_timeout() runs on MTC_CT { |
| 1249 | var BSC_ConnHdlr vc_conn; |
| 1250 | f_init(); |
| 1251 | |
| 1252 | vc_conn := f_start_handler(refers(f_tc_mo_crcx_ran_timeout), testcasename(), 27); |
| 1253 | vc_conn.done; |
| 1254 | } |
| 1255 | |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1256 | /* Test MO Call with reject to RAN-side CRCX */ |
| 1257 | private function f_tc_mo_crcx_ran_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1258 | f_init_handler(pars); |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1259 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1260 | var MNCC_PDU mncc; |
| 1261 | var MgcpCommand mgcp_cmd; |
| 1262 | |
| 1263 | f_perform_lu(false, true, true, false); |
| 1264 | |
| 1265 | f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)), false, false); |
| 1266 | f_create_mncc_expect(hex2str(cpars.called_party)); |
| 1267 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1268 | |
| 1269 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_SETUP(cpars.transaction_id, cpars.called_party))); |
| 1270 | MNCC.receive(tr_MNCC_SETUP_ind(?, tr_MNCC_number(hex2str(cpars.called_party)))) -> value mncc; |
| 1271 | cpars.mncc_callref := mncc.u.signal.callref; |
| 1272 | MNCC.send(ts_MNCC_CALL_PROC_req(cpars.mncc_callref, cpars.mncc_bearer_cap)); |
| 1273 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CALL_PROC(cpars.transaction_id))); |
| 1274 | |
| 1275 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
| 1276 | cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
| 1277 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
| 1278 | /* Respond to CRCX with error */ |
| 1279 | var MgcpResponse mgcp_rsp := { |
| 1280 | line := { |
| 1281 | code := "542", |
| 1282 | trans_id := mgcp_cmd.line.trans_id, |
| 1283 | string := "FORCED_FAIL" |
| 1284 | }, |
| 1285 | params := omit, |
| 1286 | sdp := omit |
| 1287 | } |
| 1288 | MGCP.send(mgcp_rsp); |
| 1289 | |
| 1290 | timer T := 30.0; |
| 1291 | T.start; |
| 1292 | alt { |
| 1293 | [] T.timeout { setverdict(fail, "Timeout waiting for channel release"); self.stop; } |
| 1294 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 1295 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 1296 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 1297 | setverdict(pass); |
| 1298 | } |
| 1299 | [] BSSAP.receive { repeat; } |
| 1300 | [] MNCC.receive { repeat; } |
| 1301 | [] GSUP.receive { repeat; } |
| 1302 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 1303 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
| 1304 | f_create_mgcp_delete_ep(cpars.mgcp_ep); |
Harald Welte | ec6e5b4 | 2018-01-27 12:45:15 +0100 | [diff] [blame] | 1305 | repeat; |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1306 | } |
| 1307 | [] MGCP.receive { repeat; } |
| 1308 | } |
| 1309 | } |
| 1310 | testcase TC_mo_crcx_ran_reject() runs on MTC_CT { |
| 1311 | var BSC_ConnHdlr vc_conn; |
| 1312 | f_init(); |
| 1313 | |
| 1314 | vc_conn := f_start_handler(refers(f_tc_mo_crcx_ran_reject), testcasename(), 28); |
| 1315 | vc_conn.done; |
| 1316 | } |
| 1317 | |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1318 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1319 | /* helper function to start a MT call: MNCC SETUP; Paging; DChan est.; DTAP SETUP */ |
| 1320 | private function f_mt_call_start(inout CallParameters cpars) runs on BSC_ConnHdlr { |
| 1321 | var MNCC_PDU mncc; |
| 1322 | var MgcpCommand mgcp_cmd; |
| 1323 | var OCT4 tmsi; |
| 1324 | |
| 1325 | f_perform_lu(false, true, true, false); |
| 1326 | if (isvalue(g_pars.tmsi)) { |
| 1327 | tmsi := g_pars.tmsi; |
| 1328 | } else { |
| 1329 | tmsi := 'FFFFFFFF'O; |
| 1330 | } |
| 1331 | f_bssmap_register_imsi(g_pars.imsi, tmsi); |
| 1332 | |
| 1333 | /* Allocate call reference and send SETUP via MNCC to MSC */ |
| 1334 | cpars.mncc_callref := f_rnd_int(2147483648); |
| 1335 | MNCC.send(ts_MNCC_SETUP_req(cpars.mncc_callref, hex2str(g_pars.msisdn), |
| 1336 | hex2str(cpars.called_party), hex2str(g_pars.imsi))); |
| 1337 | |
| 1338 | /* MSC->BSC: expect PAGING from MSC */ |
| 1339 | BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)); |
| 1340 | /* MS -> MSC: PAGING RESPONSE */ |
| 1341 | f_establish_fully_pag(valueof(ts_MI_IMSI_LV(g_pars.imsi)), false, false); |
| 1342 | |
| 1343 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1344 | |
| 1345 | /* MSC->MS: SETUP */ |
| 1346 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_SETUP(cpars.transaction_id, *, cpars.called_party))); |
| 1347 | } |
| 1348 | |
| 1349 | /* Test MT Call */ |
| 1350 | private function f_tc_mt_crcx_ran_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1351 | f_init_handler(pars); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1352 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
| 1353 | var MNCC_PDU mncc; |
| 1354 | var MgcpCommand mgcp_cmd; |
| 1355 | |
| 1356 | f_mt_call_start(cpars); |
| 1357 | |
| 1358 | /* MS->MSC: CALL CONFIRMED */ |
| 1359 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CALL_CONF(cpars.transaction_id))); |
| 1360 | |
| 1361 | MNCC.receive(tr_MNCC_CALL_CONF_ind(cpars.mncc_callref)); |
| 1362 | |
| 1363 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
| 1364 | cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
| 1365 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
| 1366 | /* Respond to CRCX with error */ |
| 1367 | var MgcpResponse mgcp_rsp := { |
| 1368 | line := { |
| 1369 | code := "542", |
| 1370 | trans_id := mgcp_cmd.line.trans_id, |
| 1371 | string := "FORCED_FAIL" |
| 1372 | }, |
| 1373 | params := omit, |
| 1374 | sdp := omit |
| 1375 | } |
| 1376 | MGCP.send(mgcp_rsp); |
| 1377 | |
| 1378 | timer T := 30.0; |
| 1379 | T.start; |
| 1380 | alt { |
| 1381 | [] T.timeout { setverdict(fail, "Timeout waiting for channel release"); self.stop; } |
| 1382 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 1383 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 1384 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 1385 | setverdict(pass); |
| 1386 | } |
| 1387 | [] BSSAP.receive { repeat; } |
| 1388 | [] MNCC.receive { repeat; } |
| 1389 | [] GSUP.receive { repeat; } |
| 1390 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 1391 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
| 1392 | f_create_mgcp_delete_ep(cpars.mgcp_ep); |
| 1393 | repeat; |
| 1394 | } |
| 1395 | [] MGCP.receive { repeat; } |
| 1396 | } |
| 1397 | } |
| 1398 | testcase TC_mt_crcx_ran_reject() runs on MTC_CT { |
| 1399 | var BSC_ConnHdlr vc_conn; |
| 1400 | f_init(); |
| 1401 | |
| 1402 | vc_conn := f_start_handler(refers(f_tc_mt_crcx_ran_reject), testcasename(), 29); |
| 1403 | vc_conn.done; |
| 1404 | } |
| 1405 | |
| 1406 | |
| 1407 | /* Test MT Call T310 timer */ |
| 1408 | private function f_tc_mt_t310(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1409 | f_init_handler(pars); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1410 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
| 1411 | var MNCC_PDU mncc; |
| 1412 | var MgcpCommand mgcp_cmd; |
| 1413 | |
| 1414 | f_mt_call_start(cpars); |
| 1415 | |
| 1416 | /* MS->MSC: CALL CONFIRMED */ |
| 1417 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CALL_CONF(cpars.transaction_id))); |
| 1418 | MNCC.receive(tr_MNCC_CALL_CONF_ind(cpars.mncc_callref)); |
| 1419 | |
| 1420 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
| 1421 | cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
| 1422 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
| 1423 | /* FIXME: Respond to CRCX */ |
| 1424 | |
| 1425 | /* old libosmocore T310 default timeout is 180s. so let's wait 190 */ |
| 1426 | timer T := 190.0; |
| 1427 | T.start; |
| 1428 | alt { |
| 1429 | [] T.timeout { setverdict(fail, "Timeout waiting for T310"); self.stop; } |
| 1430 | [] MNCC.receive(tr_MNCC_DISC_ind(cpars.mncc_callref)) { |
| 1431 | MNCC.send(ts_MNCC_REL_req(cpars.mncc_callref, valueof(ts_MNCC_cause(23)))); |
| 1432 | } |
| 1433 | } |
| 1434 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_DISC(cpars.transaction_id))); |
| 1435 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))); |
| 1436 | /* FIXME: We're sending this with TIflag 0: allocated by sender, which is wrong */ |
| 1437 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_REL_COMPL(cpars.transaction_id))); |
| 1438 | |
| 1439 | alt { |
| 1440 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 1441 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 1442 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 1443 | setverdict(pass); |
| 1444 | } |
| 1445 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 1446 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
| 1447 | f_create_mgcp_delete_ep(cpars.mgcp_ep); |
| 1448 | repeat; |
| 1449 | } |
| 1450 | } |
| 1451 | } |
| 1452 | testcase TC_mt_t310() runs on MTC_CT { |
| 1453 | var BSC_ConnHdlr vc_conn; |
| 1454 | f_init(); |
| 1455 | |
| 1456 | vc_conn := f_start_handler(refers(f_tc_mt_t310), testcasename(), 30); |
| 1457 | vc_conn.done; |
| 1458 | } |
| 1459 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1460 | |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1461 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1462 | /* TODO: |
| 1463 | * continue to send repeated MO signalling messages to keep channel open: does MSC tmeout? |
| 1464 | * malformed messages (missing IE, invalid message type): properly rejected? |
| 1465 | * MT call while LU or is ongoing: Do we use existing lchan or page while lchan active? |
| 1466 | * 3G/2G auth permutations |
| 1467 | * encryption algorithms vs. classmark vs. vty config |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1468 | * send new transaction after/during clear (like SMS, ...) |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1469 | * too long L3 INFO in DTAP |
| 1470 | * too long / padded BSSAP |
| 1471 | * too long / short TLV values |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1472 | */ |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 1473 | |
| 1474 | |
| 1475 | control { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 1476 | execute( TC_cmserv_imsi_unknown() ); |
| 1477 | execute( TC_lu_imsi_noauth_tmsi() ); |
| 1478 | //execute( TC_lu_imsi_noauth_notmsi() ); |
| 1479 | execute( TC_lu_imsi_reject() ); |
| 1480 | execute( TC_lu_imsi_timeout_gsup() ); |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 1481 | execute( TC_lu_and_mo_call() ); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 1482 | execute( TC_lu_auth_sai_timeout() ); |
| 1483 | execute( TC_lu_auth_sai_err() ); |
Harald Welte | e1a2f3c | 2018-01-24 17:28:48 +0100 | [diff] [blame] | 1484 | execute( TC_lu_clear_request() ); |
| 1485 | execute( TC_lu_disconnect() ); |
| 1486 | execute( TC_lu_by_imei() ); |
| 1487 | execute( TC_lu_by_tmsi_noauth_unknown() ); |
| 1488 | execute( TC_imsi_detach_by_imsi() ); |
| 1489 | execute( TC_imsi_detach_by_tmsi() ); |
| 1490 | execute( TC_imsi_detach_by_imei() ); |
| 1491 | execute( TC_emerg_call_imei_reject() ); |
| 1492 | execute( TC_emerg_call_imsi() ); |
| 1493 | execute( TC_cm_serv_req_vgcs_reject() ); |
| 1494 | execute( TC_cm_serv_req_vbs_reject() ); |
| 1495 | execute( TC_cm_serv_req_lcs_reject() ); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1496 | execute( TC_cm_reest_req_reject() ); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1497 | execute( TC_lu_auth_2G_fail() ); |
| 1498 | execute( TC_lu_imsi_auth_tmsi_encr_13_13() ); |
| 1499 | execute( TC_cl3_no_payload() ); |
| 1500 | execute( TC_cl3_rnd_payload() ); |
Harald Welte | 1852a84 | 2018-01-26 22:53:36 +0100 | [diff] [blame] | 1501 | execute( TC_establish_and_nothing() ); |
| 1502 | execute( TC_mo_setup_and_nothing() ); |
| 1503 | execute( TC_mo_crcx_ran_timeout() ); |
| 1504 | execute( TC_mo_crcx_ran_reject() ); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 1505 | } |
| 1506 | |
| 1507 | |
| 1508 | } |