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