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