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