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