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