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 | } |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 440 | f_expect_clear(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 441 | } |
| 442 | testcase TC_lu_imsi_reject() runs on MTC_CT { |
| 443 | var BSC_ConnHdlr vc_conn; |
| 444 | f_init(); |
| 445 | |
| 446 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_reject), testcasename(), 3); |
| 447 | vc_conn.done; |
| 448 | } |
| 449 | |
| 450 | /* Do LU by IMSI, timeout on GSUP */ |
| 451 | 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] | 452 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 453 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 454 | |
| 455 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 456 | f_bssap_compl_l3(l3_lu); |
| 457 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 458 | /* Normally the HLR would need to respond here, but we decide to force a timeout here */ |
| 459 | alt { |
| 460 | /* FIXME: Expect specific reject cause */ |
| 461 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { } |
| 462 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 463 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
| 464 | self.stop; |
| 465 | } |
| 466 | } |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 467 | f_expect_clear(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 468 | } |
| 469 | testcase TC_lu_imsi_timeout_gsup() runs on MTC_CT { |
| 470 | var BSC_ConnHdlr vc_conn; |
| 471 | f_init(); |
| 472 | |
| 473 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_timeout_gsup), testcasename(), 4); |
| 474 | vc_conn.done; |
| 475 | } |
| 476 | |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 477 | 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] | 478 | f_init_handler(pars); |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 479 | f_perform_lu(true, true, true); |
| 480 | } |
| 481 | testcase TC_lu_imsi_auth_tmsi() runs on MTC_CT { |
| 482 | var BSC_ConnHdlr vc_conn; |
| 483 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 484 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 485 | |
| 486 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi), testcasename(), 5); |
| 487 | vc_conn.done; |
| 488 | } |
| 489 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 490 | |
| 491 | /* Send CM SERVICE REQ for IMSI that has never performed LU before */ |
| 492 | private function f_tc_cmserv_imsi_unknown(charstring id, BSC_ConnHdlrPars pars) |
| 493 | runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 494 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 495 | |
| 496 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 497 | 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] | 498 | 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] | 499 | |
| 500 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 501 | |
| 502 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 503 | f_bssap_compl_l3(l3_info); |
| 504 | |
| 505 | timer T := 10.0; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 506 | T.start; |
| 507 | alt { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 508 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)) { } |
| 509 | //[] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_ACC)) { } |
| 510 | [] BSSAP.receive { setverdict(fail, "Received unexpected BSSAP"); } |
| 511 | [] GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)) { |
| 512 | setverdict(fail, "Unexpected GSUP UL REQ"); |
| 513 | } |
| 514 | [] T.timeout { setverdict(inconc, "Timeout waiting for CM SERV REQ"); } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 515 | } |
| 516 | |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 517 | f_expect_clear(); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 518 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 519 | testcase TC_cmserv_imsi_unknown() runs on MTC_CT { |
| 520 | var BSC_ConnHdlr vc_conn; |
| 521 | f_init(); |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 522 | 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] | 523 | vc_conn.done; |
| 524 | } |
| 525 | |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 526 | 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] | 527 | f_init_handler(pars); |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 528 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 529 | cpars.bss_rtp_port := 1110; |
| 530 | cpars.mgcp_connection_id_bss := '22222'H; |
| 531 | cpars.mgcp_connection_id_mss := '33333'H; |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 532 | |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 533 | f_perform_lu(cpars.expect_auth, true, true); |
| 534 | f_mo_call(cpars); |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 535 | } |
| 536 | testcase TC_lu_and_mo_call() runs on MTC_CT { |
| 537 | var BSC_ConnHdlr vc_conn; |
| 538 | f_init(); |
| 539 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 540 | 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] | 541 | vc_conn.done; |
| 542 | } |
| 543 | |
| 544 | /* Test LU (with authentication enabled), where HLR times out sending SAI response */ |
| 545 | 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] | 546 | f_init_handler(pars); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 547 | |
| 548 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 549 | var PDU_DTAP_MT dtap_mt; |
| 550 | |
| 551 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 552 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 553 | |
| 554 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 555 | f_bssap_compl_l3(l3_lu); |
| 556 | |
| 557 | /* Send Early Classmark, just for the fun of it */ |
| 558 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 559 | |
| 560 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 561 | /* The HLR would normally return an auth vector here, but we fail to do so. */ |
| 562 | |
| 563 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 564 | f_expect_clear(); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 565 | } |
| 566 | testcase TC_lu_auth_sai_timeout() runs on MTC_CT { |
| 567 | var BSC_ConnHdlr vc_conn; |
| 568 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 569 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 570 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 571 | 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] | 572 | vc_conn.done; |
| 573 | } |
| 574 | |
| 575 | /* Test LU (with authentication enabled), where HLR rejects sending SAI error */ |
| 576 | 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] | 577 | f_init_handler(pars); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 578 | |
| 579 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 580 | var PDU_DTAP_MT dtap_mt; |
| 581 | |
| 582 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 583 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 584 | |
| 585 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 586 | f_bssap_compl_l3(l3_lu); |
| 587 | |
| 588 | /* Send Early Classmark, just for the fun of it */ |
| 589 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 590 | |
| 591 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 592 | GSUP.send(ts_GSUP_SAI_ERR(g_pars.imsi, 13)); |
| 593 | |
| 594 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 595 | f_expect_clear(); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 596 | } |
| 597 | testcase TC_lu_auth_sai_err() runs on MTC_CT { |
| 598 | var BSC_ConnHdlr vc_conn; |
| 599 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 600 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 601 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 602 | 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] | 603 | vc_conn.done; |
| 604 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 605 | |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 606 | /* Test LU but BSC will send a clear request in the middle */ |
| 607 | 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] | 608 | f_init_handler(pars); |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 609 | |
| 610 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 611 | var PDU_DTAP_MT dtap_mt; |
| 612 | |
| 613 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 614 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 615 | |
| 616 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 617 | f_bssap_compl_l3(l3_lu); |
| 618 | |
| 619 | /* Send Early Classmark, just for the fun of it */ |
| 620 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 621 | |
| 622 | f_sleep(1.0); |
| 623 | /* send clear request in the middle of the LU */ |
| 624 | BSSAP.send(ts_BSSMAP_ClearRequest(0)); |
| 625 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 626 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 627 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 628 | setverdict(pass); |
| 629 | } |
| 630 | testcase TC_lu_clear_request() runs on MTC_CT { |
| 631 | var BSC_ConnHdlr vc_conn; |
| 632 | f_init(); |
| 633 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 634 | 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] | 635 | vc_conn.done; |
| 636 | } |
| 637 | |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 638 | /* Test LU but BSC will send a clear request in the middle */ |
| 639 | 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] | 640 | f_init_handler(pars); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 641 | |
| 642 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 643 | var PDU_DTAP_MT dtap_mt; |
| 644 | |
| 645 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 646 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 647 | |
| 648 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 649 | f_bssap_compl_l3(l3_lu); |
| 650 | |
| 651 | /* Send Early Classmark, just for the fun of it */ |
| 652 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 653 | |
| 654 | f_sleep(1.0); |
| 655 | /* send clear request in the middle of the LU */ |
| 656 | BSSAP.send(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_REQ); |
| 657 | setverdict(pass); |
| 658 | } |
| 659 | testcase TC_lu_disconnect() runs on MTC_CT { |
| 660 | var BSC_ConnHdlr vc_conn; |
| 661 | f_init(); |
| 662 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 663 | vc_conn := f_start_handler(refers(f_tc_lu_disconnect), testcasename(), 11); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 664 | vc_conn.done; |
| 665 | } |
| 666 | |
| 667 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 668 | /* Test LU but with illegal mobile identity type = IMEI */ |
| 669 | 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] | 670 | f_init_handler(pars); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 671 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 672 | 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] | 673 | var PDU_DTAP_MT dtap_mt; |
| 674 | |
| 675 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 676 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 677 | |
| 678 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 679 | f_bssap_compl_l3(l3_lu); |
| 680 | |
| 681 | /* Send Early Classmark, just for the fun of it */ |
| 682 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 683 | /* wait for LU reject, ignore any ID REQ */ |
| 684 | alt { |
| 685 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { } |
| 686 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req)) { repeat; } |
| 687 | } |
| 688 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 689 | f_expect_clear(); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 690 | } |
| 691 | testcase TC_lu_by_imei() runs on MTC_CT { |
| 692 | var BSC_ConnHdlr vc_conn; |
| 693 | f_init(); |
| 694 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 695 | 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] | 696 | vc_conn.done; |
| 697 | } |
| 698 | |
| 699 | /* Test LU by TMSI with unknown TMSI, expect (and answer) ID REQ. */ |
| 700 | 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] | 701 | f_init_handler(pars); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 702 | |
| 703 | var PDU_ML3_MS_NW l3_lu := f_build_lu_tmsi('01020304'O); /* FIXME: Random */ |
| 704 | var PDU_DTAP_MT dtap_mt; |
| 705 | |
| 706 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 707 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 708 | |
| 709 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 710 | f_bssap_compl_l3(l3_lu); |
| 711 | |
| 712 | /* Send Early Classmark, just for the fun of it */ |
| 713 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 714 | |
| 715 | /* Wait for + respond to ID REQ (IMSI) */ |
| 716 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req('001'B))); |
| 717 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp_IMSI(g_pars.imsi))); |
| 718 | |
| 719 | /* Expect MSC to do UpdateLocation to HLR; respond to it */ |
| 720 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 721 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 722 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 723 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 724 | |
| 725 | alt { |
Harald Welte | 7ec4fa8 | 2018-01-27 10:57:40 +0100 | [diff] [blame] | 726 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 727 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_TmsiRealloc_Cmpl)); |
| 728 | } |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 729 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 730 | setverdict(fail, "Expected LU ACK, but received REJ"); |
| 731 | } |
| 732 | } |
| 733 | |
| 734 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 735 | f_expect_clear(); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 736 | } |
| 737 | testcase TC_lu_by_tmsi_noauth_unknown() runs on MTC_CT { |
| 738 | var BSC_ConnHdlr vc_conn; |
| 739 | f_init(); |
| 740 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 741 | 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] | 742 | vc_conn.done; |
| 743 | } |
| 744 | |
| 745 | |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 746 | /* Test IMSI DETACH (MI=IMSI) */ |
| 747 | 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] | 748 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 749 | |
| 750 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 751 | |
| 752 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 753 | f_bssap_compl_l3(valueof(ts_ML3_MO_MM_IMSI_DET_Ind(mi))); |
| 754 | |
| 755 | /* Send Early Classmark, just for the fun of it? */ |
| 756 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 757 | |
| 758 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 759 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 760 | } |
| 761 | testcase TC_imsi_detach_by_imsi() 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_imsi_detach_by_imsi), testcasename(), 14); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 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 { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 771 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 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 */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 782 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 783 | } |
| 784 | testcase TC_imsi_detach_by_tmsi() runs on MTC_CT { |
| 785 | var BSC_ConnHdlr vc_conn; |
| 786 | f_init(); |
| 787 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 788 | 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] | 789 | vc_conn.done; |
| 790 | } |
| 791 | |
| 792 | /* Test IMSI DETACH (MI=IMEI), which is illegal */ |
| 793 | 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] | 794 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 795 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 796 | var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 797 | |
| 798 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 799 | f_bssap_compl_l3(valueof(ts_ML3_MO_MM_IMSI_DET_Ind(mi))); |
| 800 | |
| 801 | /* Send Early Classmark, just for the fun of it? */ |
| 802 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 803 | |
| 804 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 805 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 806 | } |
| 807 | testcase TC_imsi_detach_by_imei() runs on MTC_CT { |
| 808 | var BSC_ConnHdlr vc_conn; |
| 809 | f_init(); |
| 810 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 811 | 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] | 812 | vc_conn.done; |
| 813 | } |
| 814 | |
| 815 | |
| 816 | /* helper function for an emergency call. caller passes in mobile identity to use */ |
| 817 | private function f_emerg_call(MobileIdentityLV mi) runs on BSC_ConnHdlr { |
| 818 | |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 819 | 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] | 820 | f_bssap_compl_l3(l3_info); |
| 821 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_ACC)); |
| 822 | |
| 823 | var hexstring called := '112'H; |
| 824 | var integer tid := 0; |
| 825 | var MNCC_PDU mncc; |
| 826 | f_create_mncc_expect(hex2str(called)); |
| 827 | |
| 828 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_EMERG_SETUP(tid))); |
| 829 | MNCC.receive(tr_MNCC_SETUP_ind(?, tr_MNCC_number(hex2str(called)))) -> value mncc; |
| 830 | /* FIXME: extract call_id */ |
| 831 | |
| 832 | /* Call Proceeding */ |
| 833 | MNCC.send(ts_MNCC_CALL_PROC_req(mncc.u.signal.callref, ts_MNCC_bcap_voice)); |
| 834 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CALL_PROC(tid))); |
| 835 | |
| 836 | /* Alerting */ |
| 837 | MNCC.send(ts_MNCC_ALERT_req(mncc.u.signal.callref)); |
| 838 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_ALERTING(tid))); |
| 839 | |
| 840 | /* Answer. This causes TCH assignment in case of "late assignment" */ |
Harald Welte | 4017d55 | 2018-01-26 21:40:05 +0100 | [diff] [blame] | 841 | //MNCC.send(ts_MNCC_SETUP_COMPL_req(mncc.u.signal.callref)); |
| 842 | MNCC.send(ts_MNCC_SETUP_rsp(mncc.u.signal.callref)); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 843 | |
| 844 | f_sleep(3.0); |
| 845 | |
| 846 | /* Hangup by "B" side */ |
| 847 | MNCC.send(ts_MNCC_DISC_req(mncc.u.signal.callref, valueof(ts_MNCC_cause(23)))); |
| 848 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_DISC(tid))); |
| 849 | |
| 850 | /* Release of call */ |
| 851 | MNCC.send(ts_MNCC_REL_req(mncc.u.signal.callref, valueof(ts_MNCC_cause(42)))); |
| 852 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(tid))); |
| 853 | |
| 854 | /* clearing of radio channel */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 855 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 856 | } |
| 857 | |
| 858 | /* establish an emergency call by IMEI, no SIM inserted (and hence no IMSI) */ |
| 859 | 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] | 860 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 861 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 862 | var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 863 | 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] | 864 | f_bssap_compl_l3(l3_info); |
| 865 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ('05'O))); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 866 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 867 | } |
| 868 | testcase TC_emerg_call_imei_reject() runs on MTC_CT { |
| 869 | var BSC_ConnHdlr vc_conn; |
| 870 | f_init(); |
| 871 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 872 | 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] | 873 | vc_conn.done; |
| 874 | } |
| 875 | |
Harald Welte | d5b9140 | 2018-01-24 18:48:16 +0100 | [diff] [blame] | 876 | /* establish an emergency call by IMSI, SIM inserted (and hence IMSI) */ |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 877 | 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] | 878 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 879 | /* First perform location update to ensure subscriber is known */ |
| 880 | f_perform_lu(false, true, true); |
| 881 | /* Then issue emergency call identified by IMSI */ |
| 882 | f_emerg_call(valueof(ts_MI_IMSI_LV(g_pars.imsi))); |
| 883 | } |
| 884 | testcase TC_emerg_call_imsi() runs on MTC_CT { |
| 885 | var BSC_ConnHdlr vc_conn; |
| 886 | f_init(); |
| 887 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 888 | 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] | 889 | vc_conn.done; |
| 890 | } |
| 891 | |
| 892 | /* CM Service Request for VGCS -> reject */ |
| 893 | 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] | 894 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 895 | |
| 896 | /* First perform location update to ensure subscriber is known */ |
| 897 | f_perform_lu(false, true, true); |
| 898 | |
| 899 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
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_VGCS, 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(int2oct(32,1)))); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 903 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 904 | } |
| 905 | testcase TC_cm_serv_req_vgcs_reject() runs on MTC_CT { |
| 906 | var BSC_ConnHdlr vc_conn; |
| 907 | f_init(); |
| 908 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 909 | 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] | 910 | vc_conn.done; |
| 911 | } |
| 912 | |
| 913 | /* CM Service Request for VBS -> reject */ |
| 914 | 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] | 915 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 916 | |
| 917 | /* First perform location update to ensure subscriber is known */ |
| 918 | f_perform_lu(false, true, true); |
| 919 | |
| 920 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 921 | 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] | 922 | f_bssap_compl_l3(l3_info); |
| 923 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ(int2oct(32,1)))); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 924 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 925 | } |
| 926 | testcase TC_cm_serv_req_vbs_reject() runs on MTC_CT { |
| 927 | var BSC_ConnHdlr vc_conn; |
| 928 | f_init(); |
| 929 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 930 | 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] | 931 | vc_conn.done; |
| 932 | } |
| 933 | |
| 934 | /* CM Service Request for LCS -> reject */ |
| 935 | 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] | 936 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 937 | |
| 938 | /* First perform location update to ensure subscriber is known */ |
| 939 | f_perform_lu(false, true, true); |
| 940 | |
| 941 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 942 | 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] | 943 | f_bssap_compl_l3(l3_info); |
| 944 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ(int2oct(32,1)))); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 945 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 946 | } |
| 947 | testcase TC_cm_serv_req_lcs_reject() runs on MTC_CT { |
| 948 | var BSC_ConnHdlr vc_conn; |
| 949 | f_init(); |
| 950 | |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 951 | 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] | 952 | vc_conn.done; |
| 953 | } |
| 954 | |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 955 | /* CM Re-Establishment Request */ |
| 956 | 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] | 957 | f_init_handler(pars); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 958 | |
| 959 | /* First perform location update to ensure subscriber is known */ |
| 960 | f_perform_lu(false, true, true); |
| 961 | |
| 962 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 963 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_REEST_REQ(0, mi)); |
| 964 | f_bssap_compl_l3(l3_info); |
| 965 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ(int2oct(32,1)))); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 966 | f_expect_clear(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 967 | } |
| 968 | testcase TC_cm_reest_req_reject() runs on MTC_CT { |
| 969 | var BSC_ConnHdlr vc_conn; |
| 970 | f_init(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 971 | |
| 972 | vc_conn := f_start_handler(refers(f_tc_cm_reest_req_reject), testcasename(), 22); |
| 973 | vc_conn.done; |
| 974 | } |
| 975 | |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 976 | /* Test LU (with authentication enabled), with wrong response from MS */ |
| 977 | 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] | 978 | f_init_handler(pars); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 979 | |
| 980 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 981 | |
| 982 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 983 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 984 | |
| 985 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 986 | f_bssap_compl_l3(l3_lu); |
| 987 | |
| 988 | /* Send Early Classmark, just for the fun of it */ |
| 989 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 990 | |
| 991 | var AuthVector vec := f_gen_auth_vec_2g(); |
| 992 | var GSUP_IE auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G(vec.rand, vec.sres, vec.kc)); |
| 993 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 994 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
| 995 | |
| 996 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_AUTH_REQ(vec.rand))); |
| 997 | /* Send back wrong auth response */ |
| 998 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MT_MM_AUTH_RESP_2G('00000000'O))); |
| 999 | |
| 1000 | /* Expect GSUP AUTH FAIL REP to HLR */ |
| 1001 | GSUP.receive(tr_GSUP_AUTH_FAIL_IND(g_pars.imsi)); |
| 1002 | |
| 1003 | /* Expect LU REJECT with Cause == Illegal MS */ |
| 1004 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej('03'O))); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1005 | f_expect_clear(); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1006 | } |
| 1007 | testcase TC_lu_auth_2G_fail() runs on MTC_CT { |
| 1008 | var BSC_ConnHdlr vc_conn; |
| 1009 | f_init(); |
| 1010 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1011 | |
| 1012 | vc_conn := f_start_handler(refers(f_tc_lu_auth_2G_fail), testcasename(), 23); |
| 1013 | vc_conn.done; |
| 1014 | } |
| 1015 | |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 1016 | 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] | 1017 | f_init_handler(pars); |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 1018 | f_perform_lu(true, true, true, true); |
| 1019 | } |
| 1020 | testcase TC_lu_imsi_auth_tmsi_encr_13_13() runs on MTC_CT { |
| 1021 | var BSC_ConnHdlr vc_conn; |
| 1022 | f_init(); |
| 1023 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 1024 | f_vty_config(MSCVTY, "network", "encryption a5 1 3"); |
| 1025 | |
| 1026 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_13_13), testcasename(), 24); |
| 1027 | vc_conn.done; |
| 1028 | } |
| 1029 | |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1030 | /* Test Complete L3 without payload */ |
| 1031 | 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] | 1032 | f_init_handler(pars); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1033 | |
| 1034 | /* Send Complete L3 Info with empty L3 frame */ |
| 1035 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own, |
| 1036 | valueof(ts_BSSMAP_ComplL3(g_pars.cell_id, ''O)))); |
| 1037 | |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1038 | timer T := 5.0; |
| 1039 | T.start; |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1040 | alt { |
| 1041 | [] BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
| 1042 | /* Expect LU REJECT with Cause == Illegal MS */ |
| 1043 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 1044 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 1045 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 1046 | } |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1047 | [] T.timeout { |
| 1048 | setverdict(inconc, "Timeout waiting for ClearCommand or SCCP Release"); |
| 1049 | self.stop; |
| 1050 | } |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1051 | } |
| 1052 | setverdict(pass); |
| 1053 | } |
| 1054 | testcase TC_cl3_no_payload() runs on MTC_CT { |
| 1055 | var BSC_ConnHdlr vc_conn; |
| 1056 | f_init(); |
| 1057 | |
| 1058 | vc_conn := f_start_handler(refers(f_tc_cl3_no_payload), testcasename(), 24); |
| 1059 | vc_conn.done; |
| 1060 | } |
| 1061 | |
| 1062 | /* Test Complete L3 with random payload */ |
| 1063 | 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] | 1064 | f_init_handler(pars); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1065 | |
| 1066 | var integer len := float2int(rnd() * 256.0); |
| 1067 | var octetstring payl := f_rnd_octstring(len); |
| 1068 | |
| 1069 | /* Send Complete L3 Info with empty L3 frame */ |
| 1070 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own, |
| 1071 | valueof(ts_BSSMAP_ComplL3(g_pars.cell_id, payl)))); |
| 1072 | |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1073 | timer T := 5.0; |
| 1074 | T.start; |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1075 | alt { |
| 1076 | /* Immediate disconnect */ |
| 1077 | [] BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
| 1078 | /* Expect LU REJECT with Cause == Illegal MS */ |
| 1079 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 1080 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 1081 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 1082 | } |
| 1083 | [] BSSAP.receive(tr_PDU_DTAP_MT(?)) { repeat; } |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1084 | [] T.timeout { |
| 1085 | setverdict(inconc, "Timeout waiting for ClearCommand or SCCP Release"); |
| 1086 | self.stop; |
| 1087 | } |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1088 | } |
| 1089 | setverdict(pass); |
| 1090 | } |
| 1091 | testcase TC_cl3_rnd_payload() runs on MTC_CT { |
| 1092 | var BSC_ConnHdlr vc_conn; |
| 1093 | f_init(); |
| 1094 | |
| 1095 | vc_conn := f_start_handler(refers(f_tc_cl3_rnd_payload), testcasename(), 24); |
| 1096 | vc_conn.done; |
| 1097 | } |
| 1098 | |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1099 | /* Test Complete L3 with random payload */ |
| 1100 | 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] | 1101 | f_init_handler(pars); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1102 | |
| 1103 | f_perform_lu(false, true, true, false); |
| 1104 | |
| 1105 | f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)), false, false); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1106 | f_expect_clear(); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1107 | } |
| 1108 | testcase TC_establish_and_nothing() runs on MTC_CT { |
| 1109 | var BSC_ConnHdlr vc_conn; |
| 1110 | f_init(); |
| 1111 | |
| 1112 | vc_conn := f_start_handler(refers(f_tc_establish_and_nothing), testcasename(), 25); |
| 1113 | vc_conn.done; |
| 1114 | } |
| 1115 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1116 | /* Test MO Call SETUP with no response from MNCC */ |
| 1117 | 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] | 1118 | f_init_handler(pars); |
| 1119 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1120 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1121 | |
| 1122 | f_perform_lu(false, true, true, false); |
| 1123 | |
| 1124 | f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)), false, false); |
| 1125 | f_create_mncc_expect(hex2str(cpars.called_party)); |
| 1126 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1127 | |
| 1128 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_SETUP(cpars.transaction_id, cpars.called_party))); |
| 1129 | |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1130 | f_expect_clear(30.0); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1131 | } |
| 1132 | testcase TC_mo_setup_and_nothing() runs on MTC_CT { |
| 1133 | var BSC_ConnHdlr vc_conn; |
| 1134 | f_init(); |
| 1135 | |
| 1136 | vc_conn := f_start_handler(refers(f_tc_mo_setup_and_nothing), testcasename(), 26); |
| 1137 | vc_conn.done; |
| 1138 | } |
| 1139 | |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1140 | /* Test MO Call with no response to RAN-side CRCX */ |
| 1141 | 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] | 1142 | f_init_handler(pars); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1143 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1144 | var MNCC_PDU mncc; |
| 1145 | var MgcpCommand mgcp_cmd; |
| 1146 | |
| 1147 | f_perform_lu(false, true, true, false); |
| 1148 | |
| 1149 | f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)), false, false); |
| 1150 | f_create_mncc_expect(hex2str(cpars.called_party)); |
| 1151 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1152 | |
| 1153 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_SETUP(cpars.transaction_id, cpars.called_party))); |
| 1154 | MNCC.receive(tr_MNCC_SETUP_ind(?, tr_MNCC_number(hex2str(cpars.called_party)))) -> value mncc; |
| 1155 | cpars.mncc_callref := mncc.u.signal.callref; |
| 1156 | MNCC.send(ts_MNCC_CALL_PROC_req(cpars.mncc_callref, cpars.mncc_bearer_cap)); |
| 1157 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CALL_PROC(cpars.transaction_id))); |
| 1158 | |
| 1159 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
Harald Welte | 1852a84 | 2018-01-26 22:53:36 +0100 | [diff] [blame] | 1160 | cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
| 1161 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1162 | /* never respond to this */ |
| 1163 | |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1164 | f_expect_clear(30.0); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1165 | } |
| 1166 | testcase TC_mo_crcx_ran_timeout() runs on MTC_CT { |
| 1167 | var BSC_ConnHdlr vc_conn; |
| 1168 | f_init(); |
| 1169 | |
| 1170 | vc_conn := f_start_handler(refers(f_tc_mo_crcx_ran_timeout), testcasename(), 27); |
| 1171 | vc_conn.done; |
| 1172 | } |
| 1173 | |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1174 | /* Test MO Call with reject to RAN-side CRCX */ |
| 1175 | 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] | 1176 | f_init_handler(pars); |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1177 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1178 | var MNCC_PDU mncc; |
| 1179 | var MgcpCommand mgcp_cmd; |
| 1180 | |
| 1181 | f_perform_lu(false, true, true, false); |
| 1182 | |
| 1183 | f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)), false, false); |
| 1184 | f_create_mncc_expect(hex2str(cpars.called_party)); |
| 1185 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1186 | |
| 1187 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_SETUP(cpars.transaction_id, cpars.called_party))); |
| 1188 | MNCC.receive(tr_MNCC_SETUP_ind(?, tr_MNCC_number(hex2str(cpars.called_party)))) -> value mncc; |
| 1189 | cpars.mncc_callref := mncc.u.signal.callref; |
| 1190 | MNCC.send(ts_MNCC_CALL_PROC_req(cpars.mncc_callref, cpars.mncc_bearer_cap)); |
| 1191 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CALL_PROC(cpars.transaction_id))); |
| 1192 | |
| 1193 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
| 1194 | cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
| 1195 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
| 1196 | /* Respond to CRCX with error */ |
| 1197 | var MgcpResponse mgcp_rsp := { |
| 1198 | line := { |
| 1199 | code := "542", |
| 1200 | trans_id := mgcp_cmd.line.trans_id, |
| 1201 | string := "FORCED_FAIL" |
| 1202 | }, |
| 1203 | params := omit, |
| 1204 | sdp := omit |
| 1205 | } |
| 1206 | MGCP.send(mgcp_rsp); |
| 1207 | |
| 1208 | timer T := 30.0; |
| 1209 | T.start; |
| 1210 | alt { |
| 1211 | [] T.timeout { setverdict(fail, "Timeout waiting for channel release"); self.stop; } |
| 1212 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 1213 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 1214 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 1215 | setverdict(pass); |
| 1216 | } |
| 1217 | [] BSSAP.receive { repeat; } |
| 1218 | [] MNCC.receive { repeat; } |
| 1219 | [] GSUP.receive { repeat; } |
| 1220 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 1221 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
| 1222 | f_create_mgcp_delete_ep(cpars.mgcp_ep); |
Harald Welte | ec6e5b4 | 2018-01-27 12:45:15 +0100 | [diff] [blame] | 1223 | repeat; |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1224 | } |
| 1225 | [] MGCP.receive { repeat; } |
| 1226 | } |
| 1227 | } |
| 1228 | testcase TC_mo_crcx_ran_reject() runs on MTC_CT { |
| 1229 | var BSC_ConnHdlr vc_conn; |
| 1230 | f_init(); |
| 1231 | |
| 1232 | vc_conn := f_start_handler(refers(f_tc_mo_crcx_ran_reject), testcasename(), 28); |
| 1233 | vc_conn.done; |
| 1234 | } |
| 1235 | |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1236 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1237 | /* helper function to start a MT call: MNCC SETUP; Paging; DChan est.; DTAP SETUP */ |
| 1238 | private function f_mt_call_start(inout CallParameters cpars) runs on BSC_ConnHdlr { |
| 1239 | var MNCC_PDU mncc; |
| 1240 | var MgcpCommand mgcp_cmd; |
| 1241 | var OCT4 tmsi; |
| 1242 | |
| 1243 | f_perform_lu(false, true, true, false); |
| 1244 | if (isvalue(g_pars.tmsi)) { |
| 1245 | tmsi := g_pars.tmsi; |
| 1246 | } else { |
| 1247 | tmsi := 'FFFFFFFF'O; |
| 1248 | } |
| 1249 | f_bssmap_register_imsi(g_pars.imsi, tmsi); |
| 1250 | |
| 1251 | /* Allocate call reference and send SETUP via MNCC to MSC */ |
| 1252 | cpars.mncc_callref := f_rnd_int(2147483648); |
| 1253 | MNCC.send(ts_MNCC_SETUP_req(cpars.mncc_callref, hex2str(g_pars.msisdn), |
| 1254 | hex2str(cpars.called_party), hex2str(g_pars.imsi))); |
| 1255 | |
| 1256 | /* MSC->BSC: expect PAGING from MSC */ |
| 1257 | BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)); |
| 1258 | /* MS -> MSC: PAGING RESPONSE */ |
| 1259 | f_establish_fully_pag(valueof(ts_MI_IMSI_LV(g_pars.imsi)), false, false); |
| 1260 | |
| 1261 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1262 | |
| 1263 | /* MSC->MS: SETUP */ |
| 1264 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_SETUP(cpars.transaction_id, *, cpars.called_party))); |
| 1265 | } |
| 1266 | |
| 1267 | /* Test MT Call */ |
| 1268 | 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] | 1269 | f_init_handler(pars); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1270 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
| 1271 | var MNCC_PDU mncc; |
| 1272 | var MgcpCommand mgcp_cmd; |
| 1273 | |
| 1274 | f_mt_call_start(cpars); |
| 1275 | |
| 1276 | /* MS->MSC: CALL CONFIRMED */ |
| 1277 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CALL_CONF(cpars.transaction_id))); |
| 1278 | |
| 1279 | MNCC.receive(tr_MNCC_CALL_CONF_ind(cpars.mncc_callref)); |
| 1280 | |
| 1281 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
| 1282 | cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
| 1283 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
| 1284 | /* Respond to CRCX with error */ |
| 1285 | var MgcpResponse mgcp_rsp := { |
| 1286 | line := { |
| 1287 | code := "542", |
| 1288 | trans_id := mgcp_cmd.line.trans_id, |
| 1289 | string := "FORCED_FAIL" |
| 1290 | }, |
| 1291 | params := omit, |
| 1292 | sdp := omit |
| 1293 | } |
| 1294 | MGCP.send(mgcp_rsp); |
| 1295 | |
| 1296 | timer T := 30.0; |
| 1297 | T.start; |
| 1298 | alt { |
| 1299 | [] T.timeout { setverdict(fail, "Timeout waiting for channel release"); self.stop; } |
| 1300 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 1301 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 1302 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 1303 | setverdict(pass); |
| 1304 | } |
| 1305 | [] BSSAP.receive { repeat; } |
| 1306 | [] MNCC.receive { repeat; } |
| 1307 | [] GSUP.receive { repeat; } |
| 1308 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 1309 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
| 1310 | f_create_mgcp_delete_ep(cpars.mgcp_ep); |
| 1311 | repeat; |
| 1312 | } |
| 1313 | [] MGCP.receive { repeat; } |
| 1314 | } |
| 1315 | } |
| 1316 | testcase TC_mt_crcx_ran_reject() runs on MTC_CT { |
| 1317 | var BSC_ConnHdlr vc_conn; |
| 1318 | f_init(); |
| 1319 | |
| 1320 | vc_conn := f_start_handler(refers(f_tc_mt_crcx_ran_reject), testcasename(), 29); |
| 1321 | vc_conn.done; |
| 1322 | } |
| 1323 | |
| 1324 | |
| 1325 | /* Test MT Call T310 timer */ |
| 1326 | private function f_tc_mt_t310(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | ad2952e | 2018-01-27 14:12:46 +0100 | [diff] [blame] | 1327 | f_init_handler(pars, 200.0); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1328 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
| 1329 | var MNCC_PDU mncc; |
| 1330 | var MgcpCommand mgcp_cmd; |
| 1331 | |
| 1332 | f_mt_call_start(cpars); |
| 1333 | |
| 1334 | /* MS->MSC: CALL CONFIRMED */ |
| 1335 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CALL_CONF(cpars.transaction_id))); |
| 1336 | MNCC.receive(tr_MNCC_CALL_CONF_ind(cpars.mncc_callref)); |
| 1337 | |
| 1338 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
| 1339 | cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
| 1340 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
| 1341 | /* FIXME: Respond to CRCX */ |
| 1342 | |
| 1343 | /* old libosmocore T310 default timeout is 180s. so let's wait 190 */ |
| 1344 | timer T := 190.0; |
| 1345 | T.start; |
| 1346 | alt { |
| 1347 | [] T.timeout { setverdict(fail, "Timeout waiting for T310"); self.stop; } |
| 1348 | [] MNCC.receive(tr_MNCC_DISC_ind(cpars.mncc_callref)) { |
| 1349 | MNCC.send(ts_MNCC_REL_req(cpars.mncc_callref, valueof(ts_MNCC_cause(23)))); |
| 1350 | } |
| 1351 | } |
| 1352 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_DISC(cpars.transaction_id))); |
| 1353 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))); |
| 1354 | /* FIXME: We're sending this with TIflag 0: allocated by sender, which is wrong */ |
| 1355 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_REL_COMPL(cpars.transaction_id))); |
| 1356 | |
| 1357 | alt { |
| 1358 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 1359 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 1360 | BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 1361 | setverdict(pass); |
| 1362 | } |
| 1363 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 1364 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
| 1365 | f_create_mgcp_delete_ep(cpars.mgcp_ep); |
| 1366 | repeat; |
| 1367 | } |
| 1368 | } |
| 1369 | } |
| 1370 | testcase TC_mt_t310() runs on MTC_CT { |
| 1371 | var BSC_ConnHdlr vc_conn; |
| 1372 | f_init(); |
| 1373 | |
| 1374 | vc_conn := f_start_handler(refers(f_tc_mt_t310), testcasename(), 30); |
| 1375 | vc_conn.done; |
| 1376 | } |
| 1377 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1378 | |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1379 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1380 | /* TODO: |
| 1381 | * continue to send repeated MO signalling messages to keep channel open: does MSC tmeout? |
| 1382 | * malformed messages (missing IE, invalid message type): properly rejected? |
| 1383 | * MT call while LU or is ongoing: Do we use existing lchan or page while lchan active? |
| 1384 | * 3G/2G auth permutations |
| 1385 | * encryption algorithms vs. classmark vs. vty config |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1386 | * send new transaction after/during clear (like SMS, ...) |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1387 | * too long L3 INFO in DTAP |
| 1388 | * too long / padded BSSAP |
| 1389 | * too long / short TLV values |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1390 | */ |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 1391 | |
| 1392 | |
| 1393 | control { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 1394 | execute( TC_lu_imsi_noauth_tmsi() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 1395 | execute( TC_lu_imsi_noauth_notmsi() ); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 1396 | execute( TC_lu_imsi_reject() ); |
| 1397 | execute( TC_lu_imsi_timeout_gsup() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 1398 | execute( TC_lu_imsi_auth_tmsi() ); |
| 1399 | execute( TC_cmserv_imsi_unknown() ); |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 1400 | execute( TC_lu_and_mo_call() ); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 1401 | execute( TC_lu_auth_sai_timeout() ); |
| 1402 | execute( TC_lu_auth_sai_err() ); |
Harald Welte | e1a2f3c | 2018-01-24 17:28:48 +0100 | [diff] [blame] | 1403 | execute( TC_lu_clear_request() ); |
| 1404 | execute( TC_lu_disconnect() ); |
| 1405 | execute( TC_lu_by_imei() ); |
| 1406 | execute( TC_lu_by_tmsi_noauth_unknown() ); |
| 1407 | execute( TC_imsi_detach_by_imsi() ); |
| 1408 | execute( TC_imsi_detach_by_tmsi() ); |
| 1409 | execute( TC_imsi_detach_by_imei() ); |
| 1410 | execute( TC_emerg_call_imei_reject() ); |
| 1411 | execute( TC_emerg_call_imsi() ); |
| 1412 | execute( TC_cm_serv_req_vgcs_reject() ); |
| 1413 | execute( TC_cm_serv_req_vbs_reject() ); |
| 1414 | execute( TC_cm_serv_req_lcs_reject() ); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1415 | execute( TC_cm_reest_req_reject() ); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1416 | execute( TC_lu_auth_2G_fail() ); |
| 1417 | execute( TC_lu_imsi_auth_tmsi_encr_13_13() ); |
| 1418 | execute( TC_cl3_no_payload() ); |
| 1419 | execute( TC_cl3_rnd_payload() ); |
Harald Welte | 1852a84 | 2018-01-26 22:53:36 +0100 | [diff] [blame] | 1420 | execute( TC_establish_and_nothing() ); |
| 1421 | execute( TC_mo_setup_and_nothing() ); |
| 1422 | execute( TC_mo_crcx_ran_timeout() ); |
| 1423 | execute( TC_mo_crcx_ran_reject() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 1424 | execute( TC_mt_crcx_ran_reject() ); |
| 1425 | execute( TC_mt_t310() ); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 1426 | } |
| 1427 | |
| 1428 | |
| 1429 | } |