Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 1 | module MSC_Tests { |
| 2 | |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 3 | /* Osmocom MSC test suite in in TTCN-3 |
| 4 | * (C) 2017-2019 Harald Welte <laforge@gnumonks.org> |
| 5 | * (C) 2018-2019 sysmocom - s.f.m.c. GmbH |
| 6 | * (C) 2018-2019 Vadim Yanitskiy <axilirator@gmail.com> |
| 7 | * All rights reserved. |
| 8 | * |
| 9 | * Released under the terms of GNU General Public License, Version 2 or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 13 | */ |
| 14 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 15 | friend module MSC_Tests_Iu; |
| 16 | |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 17 | import from General_Types all; |
| 18 | import from Osmocom_Types all; |
| 19 | |
| 20 | import from M3UA_Types all; |
| 21 | import from M3UA_Emulation all; |
| 22 | |
| 23 | import from MTP3asp_Types all; |
| 24 | import from MTP3asp_PortType all; |
| 25 | |
| 26 | import from SCCPasp_Types all; |
| 27 | import from SCCP_Types all; |
| 28 | import from SCCP_Emulation all; |
| 29 | |
| 30 | import from SCTPasp_Types all; |
| 31 | import from SCTPasp_PortType all; |
| 32 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 33 | import from Osmocom_CTRL_Functions all; |
| 34 | import from Osmocom_CTRL_Types all; |
| 35 | import from Osmocom_CTRL_Adapter all; |
| 36 | |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 37 | import from TELNETasp_PortType all; |
| 38 | import from Osmocom_VTY_Functions all; |
| 39 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 40 | import from MNCC_Emulation all; |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 41 | import from MNCC_Types all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 42 | |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 43 | import from MGCP_Emulation all; |
| 44 | import from MGCP_Types all; |
| 45 | import from MGCP_Templates all; |
| 46 | import from SDP_Types all; |
| 47 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 48 | import from GSUP_Emulation all; |
| 49 | import from GSUP_Types all; |
| 50 | import from IPA_Emulation all; |
| 51 | |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 52 | import from BSSAP_Types all; |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 53 | import from RAN_Adapter all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 54 | import from BSSAP_CodecPort all; |
| 55 | import from BSSMAP_Templates all; |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 56 | import from RAN_Emulation all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 57 | import from BSC_ConnectionHandler all; |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 58 | import from RANAP_Templates all; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 59 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 60 | import from SGsAP_Templates all; |
| 61 | import from SGsAP_Types all; |
| 62 | import from SGsAP_Emulation all; |
| 63 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 64 | import from MobileL3_Types all; |
| 65 | import from MobileL3_CommonIE_Types all; |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 66 | import from MobileL3_SMS_Types all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 67 | import from L3_Templates all; |
Harald Welte | 158a7ca | 2018-02-16 18:11:31 +0100 | [diff] [blame] | 68 | import from L3_Common all; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 69 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 70 | import from SMPP_Types all; |
| 71 | import from SMPP_Templates all; |
| 72 | import from SMPP_Emulation all; |
| 73 | |
Stefan Sperling | c307e68 | 2018-06-14 15:15:46 +0200 | [diff] [blame] | 74 | import from SCCP_Templates all; |
| 75 | |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 76 | import from SS_Types all; |
| 77 | import from SS_Templates all; |
| 78 | import from USSD_Helpers all; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 79 | import from DNS_Helpers all; |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 80 | |
Philipp Maier | 948747b | 2019-04-02 15:22:33 +0200 | [diff] [blame] | 81 | import from TCCConversion_Functions all; |
| 82 | |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 83 | const integer NUM_BSC := 3; |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 84 | type record of RAN_Configuration RAN_Configurations; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 85 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 86 | /* Needed for SGsAP SMS */ |
| 87 | import from MobileL3_SMS_Types all; |
| 88 | |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 89 | type component MTC_CT extends CTRL_Adapter_CT { |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 90 | var boolean g_initialized := false; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 91 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 92 | var RAN_Adapter g_bssap[NUM_BSC]; |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 93 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 94 | /* no 'adapter_CT' for MNCC or GSUP */ |
| 95 | var MNCC_Emulation_CT vc_MNCC; |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 96 | var MGCP_Emulation_CT vc_MGCP; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 97 | var GSUP_Emulation_CT vc_GSUP; |
| 98 | var IPA_Emulation_CT vc_GSUP_IPA; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 99 | var SMPP_Emulation_CT vc_SMPP; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 100 | var SGsAP_Emulation_CT vc_SGsAP; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 101 | |
| 102 | /* only to get events from IPA underneath GSUP */ |
| 103 | port IPA_CTRL_PT GSUP_IPA_EVENT; |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 104 | /* VTY to MSC */ |
| 105 | port TELNETasp_PT MSCVTY; |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 106 | |
| 107 | /* A port to directly send BSSAP messages. This port is used for |
| 108 | * tests that require low level access to sen arbitrary BSSAP |
| 109 | * messages. Run f_init_bssap_direct() to connect and initialize */ |
| 110 | port BSSAP_CODEC_PT BSSAP_DIRECT; |
| 111 | |
| 112 | /* When BSSAP messages are directly sent, then the connection |
| 113 | * handler is not active, which means that also no guard timer is |
| 114 | * set up. The following timer will serve as a replacement */ |
| 115 | timer Tguard_direct := 60.0; |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 116 | |
| 117 | /* Configure T(tias) over VTY, seconds */ |
| 118 | var integer g_msc_sccp_timer_ias := 7 * 60; |
| 119 | /* Configure T(tiar) over VTY, seconds */ |
| 120 | var integer g_msc_sccp_timer_iar := 15 * 60; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | modulepar { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 124 | /* remote parameters of IUT */ |
| 125 | charstring mp_msc_ip := "127.0.0.1"; |
| 126 | integer mp_msc_ctrl_port := 4255; |
| 127 | integer mp_msc_vty_port := 4254; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 128 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 129 | /* local parameters of emulated HLR */ |
Philipp Maier | 9b690e4 | 2018-12-21 11:50:03 +0100 | [diff] [blame] | 130 | boolean mp_mm_info := false; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 131 | charstring mp_hlr_ip := "127.0.0.1"; |
| 132 | integer mp_hlr_port := 4222; |
Harald Welte | 6126fb0 | 2018-01-27 20:08:24 +0100 | [diff] [blame] | 133 | charstring mp_mgw_ip := "127.0.0.1"; |
| 134 | integer mp_mgw_port := 2427; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 135 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 136 | charstring mp_msc_mncc := "/tmp/mncc"; |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 137 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 138 | integer mp_msc_smpp_port := 2775; |
| 139 | charstring mp_smpp_system_id := "msc_tester"; |
| 140 | charstring mp_smpp_password := "osmocom1"; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 141 | charstring mp_mme_name := "mmec01.mmegi0001.mme.epc.mnc070.mcc901.3gppnetwork.org"; |
| 142 | charstring mp_vlr_name := "vlr.example.net"; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 143 | |
Pau Espin Pedrol | 690d659 | 2019-05-31 17:56:32 +0200 | [diff] [blame] | 144 | /* Whether to enable osmux tests. Can be dropped completely and enable |
| 145 | unconditionally once new version of osmo-msc is released (current |
| 146 | version: 1.3.1) */ |
| 147 | boolean mp_enable_osmux_test := true; |
| 148 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 149 | RAN_Configurations mp_bssap_cfg := { |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 150 | { |
| 151 | sccp_service_type := "mtp3_itu", |
| 152 | sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" }, |
| 153 | own_pc := 185, |
| 154 | own_ssn := 254, |
| 155 | peer_pc := 187, |
| 156 | peer_ssn := 254, |
| 157 | sio := '83'O, |
| 158 | rctx := 0 |
| 159 | }, |
| 160 | { |
| 161 | sccp_service_type := "mtp3_itu", |
| 162 | sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" }, |
| 163 | own_pc := 186, |
| 164 | own_ssn := 254, |
| 165 | peer_pc := 187, |
| 166 | peer_ssn := 254, |
| 167 | sio := '83'O, |
| 168 | rctx := 1 |
| 169 | } |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 170 | }; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 171 | } |
| 172 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 173 | /* altstep for the global guard timer (only used when BSSAP_DIRECT |
| 174 | * is used for communication */ |
| 175 | private altstep as_Tguard_direct() runs on MTC_CT { |
| 176 | [] Tguard_direct.timeout { |
| 177 | setverdict(fail, "Tguard timeout"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 178 | mtc.stop; |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 179 | } |
| 180 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 181 | |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 182 | private altstep as_optional_cc_rel(CallParameters cpars, boolean respond := false) runs on BSC_ConnHdlr { |
| 183 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))) { |
| 184 | if (respond) { |
| 185 | var BIT1 tid_remote := '1'B; |
| 186 | if (cpars.mo_call) { |
| 187 | tid_remote := '0'B; |
| 188 | } |
| 189 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_REL_COMPL(cpars.transaction_id, tid_remote))); |
| 190 | } |
| 191 | } |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 192 | } |
| 193 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 194 | function f_init_smpp(charstring id) runs on MTC_CT { |
| 195 | id := id & "-SMPP"; |
| 196 | var EsmePars pars := { |
| 197 | mode := MODE_TRANSCEIVER, |
| 198 | bind := { |
| 199 | system_id := mp_smpp_system_id, |
| 200 | password := mp_smpp_password, |
| 201 | system_type := "MSC_Tests", |
| 202 | interface_version := hex2int('34'H), |
| 203 | addr_ton := unknown, |
| 204 | addr_npi := unknown, |
| 205 | address_range := "" |
| 206 | }, |
| 207 | esme_role := true |
| 208 | } |
| 209 | |
| 210 | vc_SMPP := SMPP_Emulation_CT.create(id); |
| 211 | map(vc_SMPP:SMPP_PORT, system:SMPP_PORT); |
| 212 | vc_SMPP.start(SMPP_Emulation.main_client(pars, mp_msc_ip, mp_msc_smpp_port, "", -1)); |
| 213 | } |
| 214 | |
| 215 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 216 | function f_init_mncc(charstring id) runs on MTC_CT { |
| 217 | id := id & "-MNCC"; |
| 218 | var MnccOps ops := { |
| 219 | create_cb := refers(MNCC_Emulation.ExpectedCreateCallback), |
| 220 | unitdata_cb := refers(MNCC_Emulation.DummyUnitdataCallback) |
| 221 | } |
| 222 | |
| 223 | vc_MNCC := MNCC_Emulation_CT.create(id); |
| 224 | map(vc_MNCC:MNCC, system:MNCC_CODEC_PT); |
| 225 | vc_MNCC.start(MNCC_Emulation.main(ops, id, mp_msc_mncc)); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 226 | } |
| 227 | |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 228 | function f_init_mgcp(charstring id) runs on MTC_CT { |
| 229 | id := id & "-MGCP"; |
| 230 | var MGCPOps ops := { |
| 231 | create_cb := refers(MGCP_Emulation.ExpectedCreateCallback), |
| 232 | unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback) |
| 233 | } |
| 234 | var MGCP_conn_parameters pars := { |
Harald Welte | 6126fb0 | 2018-01-27 20:08:24 +0100 | [diff] [blame] | 235 | callagent_ip := mp_msc_ip, |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 236 | callagent_udp_port := -1, |
Harald Welte | 6126fb0 | 2018-01-27 20:08:24 +0100 | [diff] [blame] | 237 | mgw_ip := mp_mgw_ip, |
Pau Espin Pedrol | 1a026a5 | 2019-06-18 17:21:52 +0200 | [diff] [blame] | 238 | mgw_udp_port := mp_mgw_port, |
| 239 | multi_conn_mode := false |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | vc_MGCP := MGCP_Emulation_CT.create(id); |
| 243 | map(vc_MGCP:MGCP, system:MGCP_CODEC_PT); |
| 244 | vc_MGCP.start(MGCP_Emulation.main(ops, pars, id)); |
| 245 | } |
| 246 | |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 247 | function ForwardUnitdataCallback(PDU_SGsAP msg) |
| 248 | runs on SGsAP_Emulation_CT return template PDU_SGsAP { |
| 249 | SGsAP_CLIENT.send(msg); |
| 250 | return omit; |
| 251 | } |
| 252 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 253 | function f_init_sgsap(charstring id) runs on MTC_CT { |
| 254 | id := id & "-SGsAP"; |
| 255 | var SGsAPOps ops := { |
| 256 | create_cb := refers(SGsAP_Emulation.ExpectedCreateCallback), |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 257 | unitdata_cb := refers(ForwardUnitdataCallback) |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 258 | } |
| 259 | var SGsAP_conn_parameters pars := { |
| 260 | remote_ip := mp_msc_ip, |
| 261 | remote_sctp_port := 29118, |
| 262 | local_ip := "", |
| 263 | local_sctp_port := -1 |
| 264 | } |
| 265 | |
| 266 | vc_SGsAP := SGsAP_Emulation_CT.create(id); |
| 267 | map(vc_SGsAP:SGsAP, system:SGsAP_CODEC_PT); |
| 268 | vc_SGsAP.start(SGsAP_Emulation.main(ops, pars, id)); |
| 269 | } |
| 270 | |
| 271 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 272 | function f_init_gsup(charstring id) runs on MTC_CT { |
| 273 | id := id & "-GSUP"; |
| 274 | var GsupOps ops := { |
| 275 | create_cb := refers(GSUP_Emulation.ExpectedCreateCallback) |
| 276 | } |
| 277 | |
| 278 | vc_GSUP_IPA := IPA_Emulation_CT.create(id & "-IPA"); |
| 279 | vc_GSUP := GSUP_Emulation_CT.create(id); |
| 280 | |
| 281 | map(vc_GSUP_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 282 | connect(vc_GSUP:GSUP, vc_GSUP_IPA:IPA_GSUP_PORT); |
| 283 | /* we use this hack to get events like ASP_IPA_EVENT_UP */ |
| 284 | connect(vc_GSUP_IPA:IPA_CTRL_PORT, self:GSUP_IPA_EVENT); |
| 285 | |
| 286 | vc_GSUP.start(GSUP_Emulation.main(ops, id)); |
| 287 | vc_GSUP_IPA.start(IPA_Emulation.main_server(mp_hlr_ip, mp_hlr_port)); |
| 288 | |
| 289 | /* wait for incoming connection to GSUP port before proceeding */ |
| 290 | timer T := 10.0; |
| 291 | T.start; |
| 292 | alt { |
| 293 | [] GSUP_IPA_EVENT.receive(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_UP)) { } |
| 294 | [] T.timeout { |
Harald Welte | 458fd37 | 2018-03-21 11:26:23 +0100 | [diff] [blame] | 295 | setverdict(fail, "No connection to GSUP Port"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 296 | mtc.stop |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 297 | } |
| 298 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 299 | } |
| 300 | |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 301 | function f_init(integer num_bsc := 1, boolean sgsap := false, boolean gsup := true, boolean osmux := false) runs on MTC_CT { |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 302 | |
| 303 | if (g_initialized == true) { |
| 304 | return; |
| 305 | } |
| 306 | g_initialized := true; |
| 307 | |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 308 | if (num_bsc > NUM_BSC) { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 309 | testcase.stop("excess number of BSC instances requested"); |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | for (var integer i := 0; i < num_bsc; i := i + 1) { |
| 313 | if (isbound(mp_bssap_cfg[i])) { |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 314 | var RanOps ranops := BSC_RanOps; |
| 315 | ranops.use_osmux := osmux; |
| 316 | f_ran_adapter_init(g_bssap[i], mp_bssap_cfg[i], "MSC_Test_" & int2str(i), ranops); |
Harald Welte | 3ca0ce1 | 2019-04-23 17:18:48 +0200 | [diff] [blame] | 317 | f_ran_adapter_start(g_bssap[i]); |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 318 | } else { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 319 | testcase.stop("missing BSSAP configuration"); |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 320 | } |
| 321 | } |
| 322 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 323 | f_ipa_ctrl_start(mp_msc_ip, mp_msc_ctrl_port); |
| 324 | f_init_mncc("MSC_Test"); |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 325 | f_init_mgcp("MSC_Test"); |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 326 | |
| 327 | if (gsup == true) { |
| 328 | f_init_gsup("MSC_Test"); |
| 329 | } |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 330 | f_init_smpp("MSC_Test"); |
Philipp Maier | 5786548 | 2019-01-07 18:33:13 +0100 | [diff] [blame] | 331 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 332 | if (sgsap == true) { |
Philipp Maier | 5786548 | 2019-01-07 18:33:13 +0100 | [diff] [blame] | 333 | f_init_sgsap("MSC_Test"); |
| 334 | } |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 335 | |
| 336 | map(self:MSCVTY, system:MSCVTY); |
| 337 | f_vty_set_prompts(MSCVTY); |
| 338 | f_vty_transceive(MSCVTY, "enable"); |
Harald Welte | b14c77a | 2018-01-25 17:25:44 +0100 | [diff] [blame] | 339 | |
| 340 | /* set some defaults */ |
| 341 | f_vty_config(MSCVTY, "network", "authentication optional"); |
| 342 | f_vty_config(MSCVTY, "msc", "assign-tmsi"); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 343 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 0"); |
Harald Welte | b14c77a | 2018-01-25 17:25:44 +0100 | [diff] [blame] | 344 | f_vty_config(MSCVTY, "network", "encryption a5 0"); |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 345 | f_vty_config(MSCVTY, "cs7 instance 0", "sccp-timer ias " & int2str(g_msc_sccp_timer_ias)); |
| 346 | f_vty_config(MSCVTY, "cs7 instance 0", "sccp-timer iar " & int2str(g_msc_sccp_timer_iar)); |
Pau Espin Pedrol | 690d659 | 2019-05-31 17:56:32 +0200 | [diff] [blame] | 347 | if (mp_enable_osmux_test) { |
| 348 | if (osmux) { |
| 349 | f_vty_config(MSCVTY, "msc", "osmux on"); |
| 350 | } else { |
| 351 | f_vty_config(MSCVTY, "msc", "osmux off"); |
| 352 | } |
Pau Espin Pedrol | 3dd33bc | 2019-05-31 17:51:20 +0200 | [diff] [blame] | 353 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 354 | } |
| 355 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 356 | /* Initialize for a direct connection to BSSAP. This function is an alternative |
| 357 | * to f_init() when the high level functions of the BSC_ConnectionHandler are |
| 358 | * not needed. */ |
| 359 | function f_init_bssap_direct() runs on MTC_CT { |
Harald Welte | 3ca0ce1 | 2019-04-23 17:18:48 +0200 | [diff] [blame] | 360 | f_ran_adapter_init(g_bssap[0], mp_bssap_cfg[0], "MSC_Test", omit); |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 361 | connect(g_bssap[0].vc_SCCP:SCCP_SP_PORT, self:BSSAP_DIRECT); |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 362 | |
| 363 | /* Start guard timer and activate it as default */ |
| 364 | Tguard_direct.start |
| 365 | activate(as_Tguard_direct()); |
| 366 | } |
| 367 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 368 | type function void_fn(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 369 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 370 | /* FIXME: move into BSC_ConnectionHandler? */ |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 371 | function f_init_pars(integer imsi_suffix, boolean sgsap := false, boolean gsup := true, integer ran_idx := 0, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 372 | boolean ran_is_geran := true, boolean use_osmux := false, OCT4 gsup_sid := '20000101'O) |
Harald Welte | f9abf8d | 2019-04-21 13:07:17 +0200 | [diff] [blame] | 373 | runs on MTC_CT return BSC_ConnHdlrPars { |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 374 | var BSC_ConnHdlrNetworkPars net_pars := { |
| 375 | kc_support := '0A'O, /* A5/1 and A5/3 enabled */ |
| 376 | expect_tmsi := true, |
| 377 | expect_auth := false, |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 378 | expect_ciph := false, |
| 379 | expect_imei := false, |
| 380 | expect_imei_early := false, |
| 381 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 382 | check_imei_error := false |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 383 | }; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 384 | var BSC_ConnHdlrPars pars := { |
Harald Welte | f9abf8d | 2019-04-21 13:07:17 +0200 | [diff] [blame] | 385 | sccp_addr_own := g_bssap[ran_idx].sccp_addr_own, |
| 386 | sccp_addr_peer := g_bssap[ran_idx].sccp_addr_peer, |
Harald Welte | edbab81 | 2018-03-18 16:02:25 +0100 | [diff] [blame] | 387 | cell_id := valueof(ts_CellId_CGI('262'H, '42'H, 23, 42)), |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 388 | imei := f_gen_imei(imsi_suffix), |
| 389 | imsi := f_gen_imsi(imsi_suffix), |
| 390 | msisdn := f_gen_msisdn(imsi_suffix), |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 391 | tmsi := omit, |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 392 | cm1 := valueof(ts_CM1), |
Harald Welte | 8260057 | 2018-01-21 20:54:08 +0100 | [diff] [blame] | 393 | cm2 := valueof(ts_CM2_default), |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 394 | cm3 := omit, |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 395 | vec := omit, |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 396 | net := net_pars, |
Philipp Maier | aeb29a8 | 2018-11-08 17:40:53 +0100 | [diff] [blame] | 397 | send_early_cm := true, |
| 398 | ipa_ctrl_ip := mp_msc_ip, |
| 399 | ipa_ctrl_port := mp_msc_ctrl_port, |
Philipp Maier | 9b690e4 | 2018-12-21 11:50:03 +0100 | [diff] [blame] | 400 | ipa_ctrl_enable := true, |
Philipp Maier | 5786548 | 2019-01-07 18:33:13 +0100 | [diff] [blame] | 401 | mm_info := mp_mm_info, |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 402 | sgsap_enable := sgsap, |
Harald Welte | f9abf8d | 2019-04-21 13:07:17 +0200 | [diff] [blame] | 403 | gsup_enable := gsup, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 404 | gsup_sid := gsup_sid, |
Harald Welte | c1f937a | 2019-04-21 21:19:23 +0200 | [diff] [blame] | 405 | ran_idx := ran_idx, |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 406 | use_umts_aka := false, |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 407 | ran_is_geran := ran_is_geran, |
| 408 | use_osmux := use_osmux |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 409 | }; |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 410 | if (not ran_is_geran) { |
| 411 | pars.use_umts_aka := true; |
| 412 | pars.net.expect_auth := true; |
| 413 | } |
Neels Hofmeyr | 9adaa70 | 2018-03-01 20:23:19 +0100 | [diff] [blame] | 414 | return pars; |
| 415 | } |
| 416 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 417 | function f_start_handler_with_pars(void_fn fn, BSC_ConnHdlrPars pars, integer bssap_idx := 0) runs on MTC_CT return BSC_ConnHdlr { |
Neels Hofmeyr | 9adaa70 | 2018-03-01 20:23:19 +0100 | [diff] [blame] | 418 | var BSC_ConnHdlr vc_conn; |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 419 | var charstring id := testcasename() & int2str(bssap_idx); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 420 | |
| 421 | vc_conn := BSC_ConnHdlr.create(id); |
| 422 | /* BSSMAP part / A interface */ |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 423 | connect(vc_conn:BSSAP, g_bssap[pars.ran_idx + bssap_idx].vc_RAN:CLIENT); |
| 424 | connect(vc_conn:BSSAP_PROC, g_bssap[pars.ran_idx + bssap_idx].vc_RAN:PROC); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 425 | /* MNCC part */ |
| 426 | connect(vc_conn:MNCC, vc_MNCC:MNCC_CLIENT); |
| 427 | connect(vc_conn:MNCC_PROC, vc_MNCC:MNCC_PROC); |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 428 | /* MGCP part */ |
| 429 | connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT); |
| 430 | connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 431 | /* GSUP part */ |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 432 | if (pars.gsup_enable == true) { |
| 433 | connect(vc_conn:GSUP, vc_GSUP:GSUP_CLIENT); |
| 434 | connect(vc_conn:GSUP_PROC, vc_GSUP:GSUP_PROC); |
| 435 | } |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 436 | /* SMPP part */ |
| 437 | connect(vc_conn:SMPP, vc_SMPP:SMPP_CLIENT); |
| 438 | connect(vc_conn:SMPP_PROC, vc_SMPP:SMPP_PROC); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 439 | /* SGs part */ |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 440 | if (pars.sgsap_enable == true) { |
Philipp Maier | 5786548 | 2019-01-07 18:33:13 +0100 | [diff] [blame] | 441 | connect(vc_conn:SGsAP, vc_SGsAP:SGsAP_CLIENT); |
| 442 | connect(vc_conn:SGsAP_PROC, vc_SGsAP:SGsAP_PROC); |
| 443 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 444 | |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 445 | /* We cannot use vc_conn.start(f_init_handler(fn, id, pars)); as we cannot have |
| 446 | * 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] | 447 | vc_conn.start(derefers(fn)(id, pars)); |
| 448 | return vc_conn; |
| 449 | } |
| 450 | |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 451 | function f_start_handler(void_fn fn, integer imsi_suffix, integer ran_idx := 0, boolean ran_is_geran := true, boolean use_osmux := false) |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 452 | runs on MTC_CT return BSC_ConnHdlr { |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 453 | return f_start_handler_with_pars(fn, f_init_pars(imsi_suffix, ran_idx := ran_idx, ran_is_geran := ran_is_geran, use_osmux := use_osmux)); |
Neels Hofmeyr | 9adaa70 | 2018-03-01 20:23:19 +0100 | [diff] [blame] | 454 | } |
| 455 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 456 | 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] | 457 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 458 | f_perform_lu(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 459 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 460 | testcase TC_lu_imsi_noauth_tmsi() runs on MTC_CT { |
| 461 | var BSC_ConnHdlr vc_conn; |
| 462 | f_init(); |
| 463 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 464 | 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] | 465 | vc_conn.done; |
| 466 | } |
| 467 | |
| 468 | 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] | 469 | pars.net.expect_tmsi := false; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 470 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 471 | f_perform_lu(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 472 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 473 | testcase TC_lu_imsi_noauth_notmsi() runs on MTC_CT { |
| 474 | var BSC_ConnHdlr vc_conn; |
| 475 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 476 | f_vty_config(MSCVTY, "msc", "no assign-tmsi"); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 477 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 478 | 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] | 479 | vc_conn.done; |
| 480 | } |
| 481 | |
| 482 | /* Do LU by IMSI, refuse it on GSUP and expect LU REJ back to MS */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 483 | friend 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] | 484 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 485 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 486 | |
| 487 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 488 | f_cl3_or_initial_ue(l3_lu); |
Neels Hofmeyr | d076c52 | 2019-11-28 01:00:52 +0100 | [diff] [blame] | 489 | f_mm_common(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 490 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 491 | GSUP.send(ts_GSUP_UL_ERR(g_pars.imsi, 23)); |
| 492 | alt { |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 493 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej(int2oct(23,1)))) { |
| 494 | f_expect_clear(); |
| 495 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 496 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 497 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 498 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 499 | } |
| 500 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 501 | } |
| 502 | testcase TC_lu_imsi_reject() runs on MTC_CT { |
| 503 | var BSC_ConnHdlr vc_conn; |
| 504 | f_init(); |
| 505 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 506 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_reject), 3); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 507 | vc_conn.done; |
| 508 | } |
| 509 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 510 | |
| 511 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 512 | /* Do LU by IMSI, timeout on GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 513 | friend 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] | 514 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 515 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 516 | |
| 517 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 518 | f_cl3_or_initial_ue(l3_lu); |
Neels Hofmeyr | d076c52 | 2019-11-28 01:00:52 +0100 | [diff] [blame] | 519 | f_mm_common(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 520 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 521 | /* Normally the HLR would need to respond here, but we decide to force a timeout here */ |
| 522 | alt { |
| 523 | /* FIXME: Expect specific reject cause */ |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 524 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 525 | f_expect_clear(); |
| 526 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 527 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 528 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 529 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 530 | } |
| 531 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 532 | } |
| 533 | testcase TC_lu_imsi_timeout_gsup() runs on MTC_CT { |
| 534 | var BSC_ConnHdlr vc_conn; |
| 535 | f_init(); |
| 536 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 537 | 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] | 538 | vc_conn.done; |
| 539 | } |
| 540 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 541 | |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 542 | 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] | 543 | pars.net.expect_auth := true; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 544 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 545 | f_perform_lu(); |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 546 | } |
| 547 | testcase TC_lu_imsi_auth_tmsi() runs on MTC_CT { |
| 548 | var BSC_ConnHdlr vc_conn; |
| 549 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 550 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 551 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 552 | 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] | 553 | vc_conn.done; |
| 554 | } |
| 555 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 556 | |
| 557 | friend function f_tc_lu_imsi_auth3g_tmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | 8a397ae | 2019-04-21 22:03:37 +0200 | [diff] [blame] | 558 | pars.net.expect_auth := true; |
| 559 | pars.use_umts_aka := true; |
| 560 | f_init_handler(pars); |
| 561 | f_perform_lu(); |
| 562 | } |
| 563 | testcase TC_lu_imsi_auth3g_tmsi() runs on MTC_CT { |
| 564 | var BSC_ConnHdlr vc_conn; |
| 565 | f_init(); |
| 566 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 567 | |
| 568 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth3g_tmsi), 1005); |
| 569 | vc_conn.done; |
| 570 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 571 | |
Pau Espin Pedrol | d3d54a9 | 2019-12-17 17:02:54 +0100 | [diff] [blame] | 572 | /* Proceed with LU but never receive an TMSI Realloc from MS after LU Accept (OS#4337). |
| 573 | * TS 24.008 sec 4.3.1.5 states MSC should simply release all MM connections. |
| 574 | */ |
| 575 | friend function f_tc_lu_imsi_timeout_tmsi_realloc(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 576 | |
| 577 | f_init_handler(pars); |
| 578 | |
| 579 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 580 | var PDU_DTAP_MT dtap_mt; |
| 581 | |
| 582 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 583 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 584 | |
| 585 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 586 | if (g_pars.ran_is_geran) { |
| 587 | f_bssap_compl_l3(l3_lu); |
| 588 | if (g_pars.send_early_cm) { |
| 589 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 590 | } |
| 591 | } else { |
| 592 | f_ranap_initial_ue(l3_lu); |
| 593 | } |
| 594 | |
| 595 | f_mm_imei_early(); |
| 596 | f_mm_common(); |
| 597 | f_msc_lu_hlr(); |
| 598 | f_mm_imei(); |
| 599 | |
| 600 | alt { |
| 601 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) -> value dtap_mt {} |
| 602 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 603 | setverdict(fail, "Expected LU ACK, but received LU REJ"); |
| 604 | mtc.stop; |
| 605 | } |
| 606 | } |
| 607 | |
| 608 | /* currently (due to bug OS#4337), an extra LU reject is received before |
| 609 | terminating the connection. Enabling following line makes the test |
| 610 | pass: */ |
| 611 | //f_expect_lu_reject('16'O); /* Cause: congestion */ |
| 612 | |
| 613 | /* f_expect_lu_reject() already waits for T"-1" (X1, 5 seconds), but give some |
| 614 | extra time to avoid race conditons... */ |
| 615 | f_expect_clear(7.0); |
| 616 | |
| 617 | setverdict(pass); |
| 618 | } |
| 619 | testcase TC_lu_imsi_timeout_tmsi_realloc() runs on MTC_CT { |
| 620 | var BSC_ConnHdlr vc_conn; |
| 621 | f_init(); |
| 622 | |
| 623 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_timeout_tmsi_realloc), 5); |
| 624 | vc_conn.done; |
| 625 | } |
| 626 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 627 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 628 | /* Send CM SERVICE REQ for IMSI that has never performed LU before */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 629 | friend function f_tc_cmserv_imsi_unknown(charstring id, BSC_ConnHdlrPars pars) |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 630 | runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 631 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 632 | |
| 633 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | edbab81 | 2018-03-18 16:02:25 +0100 | [diff] [blame] | 634 | 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] | 635 | 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] | 636 | |
| 637 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 638 | |
| 639 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 640 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | b781799 | 2019-05-09 13:15:39 +0200 | [diff] [blame] | 641 | f_mm_auth(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 642 | |
| 643 | timer T := 10.0; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 644 | T.start; |
| 645 | alt { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 646 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)) { } |
| 647 | //[] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_ACC)) { } |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 648 | [] BSSAP.receive { |
| 649 | setverdict(fail, "Received unexpected BSSAP"); |
| 650 | mtc.stop; |
| 651 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 652 | [] GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)) { |
| 653 | setverdict(fail, "Unexpected GSUP UL REQ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 654 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 655 | } |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 656 | [] T.timeout { |
| 657 | setverdict(fail, "Timeout waiting for CM SERV REQ"); |
| 658 | mtc.stop; |
| 659 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 660 | } |
| 661 | |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 662 | f_expect_clear(); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 663 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 664 | testcase TC_cmserv_imsi_unknown() runs on MTC_CT { |
| 665 | var BSC_ConnHdlr vc_conn; |
| 666 | f_init(); |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 667 | vc_conn := f_start_handler(refers(f_tc_cmserv_imsi_unknown), 6); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 668 | vc_conn.done; |
| 669 | } |
| 670 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 671 | |
| 672 | friend 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] | 673 | f_init_handler(pars); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 674 | var CallParameters cpars := valueof(t_CallParams); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 675 | f_perform_lu(); |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 676 | f_mo_call(cpars); |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 677 | } |
| 678 | testcase TC_lu_and_mo_call() runs on MTC_CT { |
| 679 | var BSC_ConnHdlr vc_conn; |
| 680 | f_init(); |
| 681 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 682 | 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] | 683 | vc_conn.done; |
| 684 | } |
| 685 | |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 686 | /* Verify T(iar) triggers and releases the channel */ |
| 687 | friend function f_lu_and_mo_call_sccp_tiar_timeout(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 688 | timer T_wait_iar := int2float(5 + 1); /* g_msc_sccp_timer_iar + Give extra time (+1 sec) */ |
| 689 | f_init_handler(pars); |
| 690 | var CallParameters cpars := valueof(t_CallParams); |
| 691 | f_perform_lu(); |
| 692 | f_mo_call_establish(cpars); |
| 693 | |
| 694 | /* Expect the channel cleared upon T(iar) triggered: */ |
| 695 | T_wait_iar.start; |
| 696 | alt { |
| 697 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) { |
| 698 | T_wait_iar.stop |
| 699 | setverdict(pass); |
| 700 | } |
| 701 | [] MGCP.receive(tr_DLCX(?)) { repeat; } |
| 702 | [] T_wait_iar.timeout { |
| 703 | setverdict(fail, "Timeout waiting for T(iar) triggered SCCP RSLD"); |
| 704 | mtc.stop; |
| 705 | } |
| 706 | } |
| 707 | |
| 708 | setverdict(pass); |
| 709 | } |
| 710 | testcase TC_lu_and_mo_call_sccp_tiar_timeout() runs on MTC_CT { |
| 711 | var BSC_ConnHdlr vc_conn; |
| 712 | |
| 713 | /* Set T(iar) in MSC low enough that it will trigger before other side |
| 714 | has time to keep alive with a T(ias). Keep recommended ratio of |
| 715 | T(iar) >= T(ias)*2 */ |
| 716 | g_msc_sccp_timer_ias := 2; |
| 717 | g_msc_sccp_timer_iar := 5; |
| 718 | |
| 719 | f_init(); |
| 720 | |
| 721 | vc_conn := f_start_handler(refers(f_lu_and_mo_call_sccp_tiar_timeout), 89); |
| 722 | vc_conn.done; |
| 723 | } |
| 724 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 725 | |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 726 | /* Test LU (with authentication enabled), where HLR times out sending SAI response */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 727 | friend 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] | 728 | f_init_handler(pars); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 729 | |
| 730 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 731 | var PDU_DTAP_MT dtap_mt; |
| 732 | |
| 733 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 734 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 735 | |
| 736 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 737 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 738 | |
| 739 | /* Send Early Classmark, just for the fun of it */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 740 | if (pars.ran_is_geran) { |
| 741 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 742 | } |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 743 | |
| 744 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 745 | /* The HLR would normally return an auth vector here, but we fail to do so. */ |
| 746 | |
| 747 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 748 | f_expect_clear(); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 749 | } |
| 750 | testcase TC_lu_auth_sai_timeout() runs on MTC_CT { |
| 751 | var BSC_ConnHdlr vc_conn; |
| 752 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 753 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 754 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 755 | 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] | 756 | vc_conn.done; |
| 757 | } |
| 758 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 759 | |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 760 | /* Test LU (with authentication enabled), where HLR rejects sending SAI error */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 761 | friend 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] | 762 | f_init_handler(pars); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 763 | |
| 764 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 765 | var PDU_DTAP_MT dtap_mt; |
| 766 | |
| 767 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 768 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 769 | |
| 770 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 771 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 772 | |
| 773 | /* Send Early Classmark, just for the fun of it */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 774 | if (pars.ran_is_geran) { |
| 775 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 776 | } |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 777 | |
| 778 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 779 | GSUP.send(ts_GSUP_SAI_ERR(g_pars.imsi, 13)); |
| 780 | |
| 781 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 782 | f_expect_clear(); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 783 | } |
| 784 | testcase TC_lu_auth_sai_err() runs on MTC_CT { |
| 785 | var BSC_ConnHdlr vc_conn; |
| 786 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 787 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 788 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 789 | 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] | 790 | vc_conn.done; |
| 791 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 792 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 793 | |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 794 | /* Test LU but BSC will send a clear request in the middle */ |
| 795 | 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] | 796 | f_init_handler(pars); |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 797 | |
| 798 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 799 | var PDU_DTAP_MT dtap_mt; |
| 800 | |
| 801 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 802 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 803 | |
| 804 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 805 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 806 | |
| 807 | /* Send Early Classmark, just for the fun of it */ |
| 808 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 809 | |
| 810 | f_sleep(1.0); |
| 811 | /* send clear request in the middle of the LU */ |
| 812 | BSSAP.send(ts_BSSMAP_ClearRequest(0)); |
Neels Hofmeyr | 2b326fa | 2018-04-06 00:59:36 +0200 | [diff] [blame] | 813 | alt { |
| 814 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { repeat; } |
| 815 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) {} |
| 816 | } |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 817 | BSSAP.send(ts_BSSMAP_ClearComplete); |
Harald Welte | 89a3249 | 2018-01-27 19:07:28 +0100 | [diff] [blame] | 818 | alt { |
| 819 | /* See https://osmocom.org/issues/2862 */ |
Neels Hofmeyr | 2b326fa | 2018-04-06 00:59:36 +0200 | [diff] [blame] | 820 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 821 | setverdict(fail, "Got a second Clear Command, only one expected"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 822 | mtc.stop; |
Neels Hofmeyr | 2b326fa | 2018-04-06 00:59:36 +0200 | [diff] [blame] | 823 | repeat; |
| 824 | } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 825 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
Harald Welte | 89a3249 | 2018-01-27 19:07:28 +0100 | [diff] [blame] | 826 | } |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 827 | setverdict(pass); |
| 828 | } |
| 829 | testcase TC_lu_clear_request() runs on MTC_CT { |
| 830 | var BSC_ConnHdlr vc_conn; |
| 831 | f_init(); |
| 832 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 833 | vc_conn := f_start_handler(refers(f_tc_lu_clear_request), 10); |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 834 | vc_conn.done; |
| 835 | } |
| 836 | |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 837 | /* Test LU but BSC will send a clear request in the middle */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 838 | friend 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] | 839 | f_init_handler(pars); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 840 | |
| 841 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 842 | var PDU_DTAP_MT dtap_mt; |
| 843 | |
| 844 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 845 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 846 | |
| 847 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 848 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 849 | |
| 850 | /* Send Early Classmark, just for the fun of it */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 851 | if (pars.ran_is_geran) { |
| 852 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 853 | } |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 854 | |
| 855 | f_sleep(1.0); |
| 856 | /* send clear request in the middle of the LU */ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 857 | BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 858 | setverdict(pass); |
Neels Hofmeyr | bb825c9 | 2019-03-06 15:35:50 +0100 | [diff] [blame] | 859 | f_sleep(1.0); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 860 | } |
| 861 | testcase TC_lu_disconnect() runs on MTC_CT { |
| 862 | var BSC_ConnHdlr vc_conn; |
| 863 | f_init(); |
| 864 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 865 | vc_conn := f_start_handler(refers(f_tc_lu_disconnect), 11); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 866 | vc_conn.done; |
| 867 | } |
| 868 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 869 | /* Test LU but with illegal mobile identity type = IMEI */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 870 | friend 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] | 871 | f_init_handler(pars); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 872 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 873 | 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] | 874 | var PDU_DTAP_MT dtap_mt; |
| 875 | |
| 876 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 877 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 878 | |
| 879 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 880 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 881 | |
| 882 | /* Send Early Classmark, just for the fun of it */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 883 | if (pars.ran_is_geran) { |
| 884 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 885 | } |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 886 | /* wait for LU reject, ignore any ID REQ */ |
| 887 | alt { |
| 888 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { } |
| 889 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req)) { repeat; } |
| 890 | } |
| 891 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 892 | f_expect_clear(); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 893 | } |
| 894 | testcase TC_lu_by_imei() runs on MTC_CT { |
| 895 | var BSC_ConnHdlr vc_conn; |
| 896 | f_init(); |
| 897 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 898 | vc_conn := f_start_handler(refers(f_tc_lu_by_imei), 12); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 899 | vc_conn.done; |
| 900 | } |
| 901 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 902 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 903 | /* Test LU by TMSI with unknown TMSI, expect (and answer) ID REQ. */ |
| 904 | private function f_tc_lu_tmsi_noauth_unknown(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Stefan Sperling | 04fc4bc | 2018-06-25 17:44:57 +0200 | [diff] [blame] | 905 | /* We piggyback a test for an MSC crash on overlong IMSI (OS#2864) onto this test. */ |
| 906 | var hexstring overlong_imsi := '012345789ABCDEF0123456789ABCDEF'H; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 907 | f_init_handler(pars); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 908 | |
| 909 | var PDU_ML3_MS_NW l3_lu := f_build_lu_tmsi('01020304'O); /* FIXME: Random */ |
| 910 | var PDU_DTAP_MT dtap_mt; |
| 911 | |
| 912 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 913 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 914 | |
| 915 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 916 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 917 | |
| 918 | /* Send Early Classmark, just for the fun of it */ |
| 919 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 920 | |
| 921 | /* Wait for + respond to ID REQ (IMSI) */ |
Oliver Smith | 3289845 | 2019-07-09 12:32:35 +0200 | [diff] [blame] | 922 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req(CM_ID_TYPE_IMSI))); |
Stefan Sperling | 04fc4bc | 2018-06-25 17:44:57 +0200 | [diff] [blame] | 923 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp_IMSI(overlong_imsi))); /* test for OS#2864 */ |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 924 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp_IMSI(g_pars.imsi))); |
| 925 | |
| 926 | /* Expect MSC to do UpdateLocation to HLR; respond to it */ |
| 927 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 928 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 929 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 930 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 931 | |
| 932 | alt { |
Harald Welte | 7ec4fa8 | 2018-01-27 10:57:40 +0100 | [diff] [blame] | 933 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 934 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_TmsiRealloc_Cmpl)); |
| 935 | } |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 936 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 937 | setverdict(fail, "Expected LU ACK, but received REJ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 938 | mtc.stop; |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 939 | } |
| 940 | } |
| 941 | |
Philipp Maier | 9b690e4 | 2018-12-21 11:50:03 +0100 | [diff] [blame] | 942 | /* Wait for MM-Information (if enabled) */ |
| 943 | f_expect_mm_info(); |
| 944 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 945 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 946 | f_expect_clear(); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 947 | } |
| 948 | testcase TC_lu_by_tmsi_noauth_unknown() runs on MTC_CT { |
| 949 | var BSC_ConnHdlr vc_conn; |
| 950 | f_init(); |
| 951 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 952 | 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] | 953 | vc_conn.done; |
| 954 | } |
| 955 | |
| 956 | |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 957 | /* Test IMSI DETACH (MI=IMSI) */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 958 | friend 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] | 959 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 960 | |
| 961 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 962 | |
| 963 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 964 | f_cl3_or_initial_ue(valueof(ts_ML3_MO_MM_IMSI_DET_Ind(mi))); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 965 | |
| 966 | /* Send Early Classmark, just for the fun of it? */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 967 | if (pars.ran_is_geran) { |
| 968 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 969 | } |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 970 | |
| 971 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 972 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 973 | } |
| 974 | testcase TC_imsi_detach_by_imsi() runs on MTC_CT { |
| 975 | var BSC_ConnHdlr vc_conn; |
| 976 | f_init(); |
| 977 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 978 | 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] | 979 | vc_conn.done; |
| 980 | } |
| 981 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 982 | |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 983 | /* Test IMSI DETACH (MI=TMSI) */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 984 | friend 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] | 985 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 986 | |
| 987 | var MobileIdentityLV mi := valueof(ts_MI_TMSI_LV('01020304'O)); |
| 988 | |
| 989 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 990 | f_cl3_or_initial_ue(valueof(ts_ML3_MO_MM_IMSI_DET_Ind(mi))); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 991 | |
| 992 | /* Send Early Classmark, just for the fun of it? */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 993 | if (pars.ran_is_geran) { |
| 994 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 995 | } |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 996 | |
| 997 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 998 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 999 | } |
| 1000 | testcase TC_imsi_detach_by_tmsi() runs on MTC_CT { |
| 1001 | var BSC_ConnHdlr vc_conn; |
| 1002 | f_init(); |
| 1003 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1004 | 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] | 1005 | vc_conn.done; |
| 1006 | } |
| 1007 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1008 | |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1009 | /* Test IMSI DETACH (MI=IMEI), which is illegal */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1010 | friend 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] | 1011 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1012 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 1013 | var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1014 | |
| 1015 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1016 | f_cl3_or_initial_ue(valueof(ts_ML3_MO_MM_IMSI_DET_Ind(mi))); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1017 | |
| 1018 | /* Send Early Classmark, just for the fun of it? */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1019 | if (pars.ran_is_geran) { |
| 1020 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1021 | } |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1022 | |
| 1023 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1024 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1025 | } |
| 1026 | testcase TC_imsi_detach_by_imei() runs on MTC_CT { |
| 1027 | var BSC_ConnHdlr vc_conn; |
| 1028 | f_init(); |
| 1029 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1030 | 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] | 1031 | vc_conn.done; |
| 1032 | } |
| 1033 | |
| 1034 | |
| 1035 | /* helper function for an emergency call. caller passes in mobile identity to use */ |
| 1036 | private function f_emerg_call(MobileIdentityLV mi) runs on BSC_ConnHdlr { |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 1037 | var CallParameters cpars := valueof(t_CallParams('112'H, 0)); |
| 1038 | cpars.emergency := true; |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1039 | |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 1040 | f_mo_call(cpars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1041 | } |
| 1042 | |
| 1043 | /* establish an emergency call by IMEI, no SIM inserted (and hence no IMSI) */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1044 | friend 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] | 1045 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1046 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 1047 | var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1048 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_EMERG_CALL, mi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1049 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1050 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ('05'O))); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1051 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1052 | } |
| 1053 | testcase TC_emerg_call_imei_reject() runs on MTC_CT { |
| 1054 | var BSC_ConnHdlr vc_conn; |
| 1055 | f_init(); |
| 1056 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1057 | 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] | 1058 | vc_conn.done; |
| 1059 | } |
| 1060 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1061 | |
Harald Welte | d5b9140 | 2018-01-24 18:48:16 +0100 | [diff] [blame] | 1062 | /* establish an emergency call by IMSI, SIM inserted (and hence IMSI) */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1063 | friend 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] | 1064 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1065 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1066 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1067 | /* Then issue emergency call identified by IMSI */ |
| 1068 | f_emerg_call(valueof(ts_MI_IMSI_LV(g_pars.imsi))); |
| 1069 | } |
| 1070 | testcase TC_emerg_call_imsi() runs on MTC_CT { |
| 1071 | var BSC_ConnHdlr vc_conn; |
| 1072 | f_init(); |
| 1073 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1074 | vc_conn := f_start_handler(refers(f_tc_emerg_call_imsi), 18); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1075 | vc_conn.done; |
| 1076 | } |
| 1077 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1078 | |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1079 | /* CM Service Request for VGCS -> reject */ |
| 1080 | 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] | 1081 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1082 | |
| 1083 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1084 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1085 | |
| 1086 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1087 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_VGCS, mi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1088 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1089 | 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] | 1090 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1091 | } |
| 1092 | testcase TC_cm_serv_req_vgcs_reject() runs on MTC_CT { |
| 1093 | var BSC_ConnHdlr vc_conn; |
| 1094 | f_init(); |
| 1095 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1096 | vc_conn := f_start_handler(refers(f_tc_cm_serv_req_vgcs_reject), 19); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1097 | vc_conn.done; |
| 1098 | } |
| 1099 | |
| 1100 | /* CM Service Request for VBS -> reject */ |
| 1101 | 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] | 1102 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1103 | |
| 1104 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1105 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1106 | |
| 1107 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1108 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_VBS, mi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1109 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1110 | 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] | 1111 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1112 | } |
| 1113 | testcase TC_cm_serv_req_vbs_reject() runs on MTC_CT { |
| 1114 | var BSC_ConnHdlr vc_conn; |
| 1115 | f_init(); |
| 1116 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1117 | 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] | 1118 | vc_conn.done; |
| 1119 | } |
| 1120 | |
| 1121 | /* CM Service Request for LCS -> reject */ |
| 1122 | 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] | 1123 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1124 | |
| 1125 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1126 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1127 | |
| 1128 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1129 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_LCS, mi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1130 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1131 | 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] | 1132 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1133 | } |
| 1134 | testcase TC_cm_serv_req_lcs_reject() runs on MTC_CT { |
| 1135 | var BSC_ConnHdlr vc_conn; |
| 1136 | f_init(); |
| 1137 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1138 | 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] | 1139 | vc_conn.done; |
| 1140 | } |
| 1141 | |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1142 | /* CM Re-Establishment Request */ |
| 1143 | 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] | 1144 | f_init_handler(pars); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1145 | |
| 1146 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1147 | f_perform_lu(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1148 | |
| 1149 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 1150 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_REEST_REQ(0, mi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1151 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1152 | 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] | 1153 | f_expect_clear(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1154 | } |
| 1155 | testcase TC_cm_reest_req_reject() runs on MTC_CT { |
| 1156 | var BSC_ConnHdlr vc_conn; |
| 1157 | f_init(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1158 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1159 | 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] | 1160 | vc_conn.done; |
| 1161 | } |
| 1162 | |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1163 | /* Test LU (with authentication enabled), with wrong response from MS */ |
| 1164 | 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] | 1165 | f_init_handler(pars); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1166 | |
| 1167 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 1168 | |
| 1169 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1170 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1171 | |
| 1172 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1173 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1174 | |
| 1175 | /* Send Early Classmark, just for the fun of it */ |
| 1176 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1177 | |
| 1178 | var AuthVector vec := f_gen_auth_vec_2g(); |
| 1179 | var GSUP_IE auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G(vec.rand, vec.sres, vec.kc)); |
| 1180 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 1181 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
| 1182 | |
| 1183 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_AUTH_REQ(vec.rand))); |
| 1184 | /* Send back wrong auth response */ |
| 1185 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MT_MM_AUTH_RESP_2G('00000000'O))); |
| 1186 | |
| 1187 | /* Expect GSUP AUTH FAIL REP to HLR */ |
| 1188 | GSUP.receive(tr_GSUP_AUTH_FAIL_IND(g_pars.imsi)); |
| 1189 | |
| 1190 | /* Expect LU REJECT with Cause == Illegal MS */ |
| 1191 | 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] | 1192 | f_expect_clear(); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1193 | } |
| 1194 | testcase TC_lu_auth_2G_fail() runs on MTC_CT { |
| 1195 | var BSC_ConnHdlr vc_conn; |
| 1196 | f_init(); |
| 1197 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1198 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1199 | 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] | 1200 | vc_conn.done; |
| 1201 | } |
| 1202 | |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 1203 | /* 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] | 1204 | 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] | 1205 | pars.net.expect_auth := true; |
| 1206 | pars.net.expect_ciph := true; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1207 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1208 | f_perform_lu(); |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 1209 | } |
| 1210 | testcase TC_lu_imsi_auth_tmsi_encr_13_13() runs on MTC_CT { |
| 1211 | var BSC_ConnHdlr vc_conn; |
| 1212 | f_init(); |
| 1213 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 1214 | f_vty_config(MSCVTY, "network", "encryption a5 1 3"); |
| 1215 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1216 | 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] | 1217 | vc_conn.done; |
| 1218 | } |
| 1219 | |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1220 | /* Test Complete L3 without payload */ |
| 1221 | 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] | 1222 | f_init_handler(pars); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1223 | |
| 1224 | /* Send Complete L3 Info with empty L3 frame */ |
| 1225 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own, |
| 1226 | valueof(ts_BSSMAP_ComplL3(g_pars.cell_id, ''O)))); |
| 1227 | |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1228 | timer T := 5.0; |
| 1229 | T.start; |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1230 | alt { |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1231 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1232 | /* Expect LU REJECT with Cause == Illegal MS */ |
Harald Welte | bdb3c45 | 2018-03-18 22:43:06 +0100 | [diff] [blame] | 1233 | [] BSSAP.receive(tr_PDU_DTAP_MT(?)) { repeat; } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1234 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND) { repeat; } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1235 | [] as_clear_cmd_compl_disc(); |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1236 | [] T.timeout { |
Daniel Willmann | 90829d6 | 2018-02-15 17:45:14 +0100 | [diff] [blame] | 1237 | setverdict(fail, "Timeout waiting for ClearCommand or SCCP Release"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1238 | mtc.stop; |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1239 | } |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1240 | } |
| 1241 | setverdict(pass); |
| 1242 | } |
| 1243 | testcase TC_cl3_no_payload() runs on MTC_CT { |
| 1244 | var BSC_ConnHdlr vc_conn; |
| 1245 | f_init(); |
| 1246 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1247 | vc_conn := f_start_handler(refers(f_tc_cl3_no_payload), 25); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1248 | vc_conn.done; |
| 1249 | } |
| 1250 | |
| 1251 | /* Test Complete L3 with random payload */ |
| 1252 | 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] | 1253 | f_init_handler(pars); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1254 | |
Daniel Willmann | aa14a38 | 2018-07-26 08:29:45 +0200 | [diff] [blame] | 1255 | /* length is limited by PDU_BSSAP length field which includes some |
| 1256 | * other fields beside l3info payload. So payl can only be 240 bytes |
| 1257 | * Since rnd() returns values < 1 multiply with 241 |
| 1258 | */ |
| 1259 | var integer len := float2int(rnd() * 241.0); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1260 | var octetstring payl := f_rnd_octstring(len); |
| 1261 | |
| 1262 | /* Send Complete L3 Info with empty L3 frame */ |
| 1263 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own, |
| 1264 | valueof(ts_BSSMAP_ComplL3(g_pars.cell_id, payl)))); |
| 1265 | |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1266 | timer T := 5.0; |
| 1267 | T.start; |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1268 | alt { |
| 1269 | /* Immediate disconnect */ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1270 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1271 | [] BSSAP.receive(tr_PDU_DTAP_MT(?)) { repeat; } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1272 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND) { repeat; } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1273 | [] as_clear_cmd_compl_disc(); |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1274 | [] T.timeout { |
Daniel Willmann | 90829d6 | 2018-02-15 17:45:14 +0100 | [diff] [blame] | 1275 | setverdict(fail, "Timeout waiting for ClearCommand or SCCP Release"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1276 | mtc.stop; |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1277 | } |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1278 | } |
| 1279 | setverdict(pass); |
| 1280 | } |
| 1281 | testcase TC_cl3_rnd_payload() runs on MTC_CT { |
| 1282 | var BSC_ConnHdlr vc_conn; |
| 1283 | f_init(); |
| 1284 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1285 | vc_conn := f_start_handler(refers(f_tc_cl3_rnd_payload), 26); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1286 | vc_conn.done; |
| 1287 | } |
| 1288 | |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1289 | /* Test Complete L3 with random payload */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1290 | friend 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] | 1291 | f_init_handler(pars); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1292 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1293 | f_perform_lu(); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1294 | |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1295 | f_establish_fully(); |
Daniel Willmann | 898a7e0 | 2018-05-17 12:16:16 +0200 | [diff] [blame] | 1296 | f_expect_clear(10.0); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1297 | } |
| 1298 | testcase TC_establish_and_nothing() runs on MTC_CT { |
| 1299 | var BSC_ConnHdlr vc_conn; |
| 1300 | f_init(); |
| 1301 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1302 | vc_conn := f_start_handler(refers(f_tc_establish_and_nothing), 27); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1303 | vc_conn.done; |
| 1304 | } |
| 1305 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1306 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1307 | /* Test MO Call SETUP with no response from MNCC */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1308 | friend function f_tc_mo_setup_and_nothing(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Philipp Maier | 109e6aa | 2018-10-17 10:53:32 +0200 | [diff] [blame] | 1309 | f_init_handler(pars, 190.0); |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1310 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1311 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1312 | cpars.mgw_conn_2.resp := 0; |
| 1313 | cpars.stop_after_cc_setup := true; |
| 1314 | |
| 1315 | f_vty_config(MSCVTY, "msc", "mncc guard-timeout 20"); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1316 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1317 | f_perform_lu(); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1318 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1319 | f_mo_call_establish(cpars); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1320 | |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 1321 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
| 1322 | |
Philipp Maier | 109e6aa | 2018-10-17 10:53:32 +0200 | [diff] [blame] | 1323 | f_expect_clear(185.0); |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 1324 | |
| 1325 | deactivate(ccrel); |
| 1326 | |
| 1327 | f_sleep(1.0); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1328 | } |
| 1329 | testcase TC_mo_setup_and_nothing() runs on MTC_CT { |
| 1330 | var BSC_ConnHdlr vc_conn; |
| 1331 | f_init(); |
| 1332 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1333 | 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] | 1334 | vc_conn.done; |
| 1335 | } |
| 1336 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1337 | |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1338 | /* Test MO Call with no response to RAN-side CRCX */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1339 | friend 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] | 1340 | f_init_handler(pars); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1341 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1342 | var MNCC_PDU mncc; |
| 1343 | var MgcpCommand mgcp_cmd; |
| 1344 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1345 | f_perform_lu(); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1346 | /* Do not respond to the second CRCX */ |
| 1347 | cpars.mgw_conn_2.resp := 0; |
| 1348 | f_mo_call_establish(cpars); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1349 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1350 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1351 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1352 | f_expect_clear(60.0); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1353 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1354 | deactivate(ccrel); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1355 | } |
| 1356 | testcase TC_mo_crcx_ran_timeout() runs on MTC_CT { |
| 1357 | var BSC_ConnHdlr vc_conn; |
| 1358 | f_init(); |
| 1359 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1360 | 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] | 1361 | vc_conn.done; |
| 1362 | } |
| 1363 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1364 | |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1365 | /* Test MO Call with reject to RAN-side CRCX */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1366 | friend 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] | 1367 | f_init_handler(pars); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1368 | |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1369 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1370 | |
| 1371 | /* Respond with error for the first CRCX */ |
| 1372 | cpars.mgw_conn_1.resp := -1; |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1373 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1374 | f_perform_lu(); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1375 | f_mo_call_establish(cpars); |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1376 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1377 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
| 1378 | f_expect_clear(60.0); |
| 1379 | deactivate(ccrel); |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1380 | } |
| 1381 | testcase TC_mo_crcx_ran_reject() runs on MTC_CT { |
| 1382 | var BSC_ConnHdlr vc_conn; |
| 1383 | f_init(); |
| 1384 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1385 | vc_conn := f_start_handler(refers(f_tc_mo_crcx_ran_reject), 30); |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1386 | vc_conn.done; |
| 1387 | } |
| 1388 | |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1389 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1390 | /* helper function to start a MT call: MNCC SETUP; Paging; DChan est.; DTAP SETUP */ |
| 1391 | private function f_mt_call_start(inout CallParameters cpars) runs on BSC_ConnHdlr { |
| 1392 | var MNCC_PDU mncc; |
| 1393 | var MgcpCommand mgcp_cmd; |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1394 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1395 | f_perform_lu(); |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 1396 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1397 | |
| 1398 | /* Allocate call reference and send SETUP via MNCC to MSC */ |
| 1399 | cpars.mncc_callref := f_rnd_int(2147483648); |
| 1400 | MNCC.send(ts_MNCC_SETUP_req(cpars.mncc_callref, hex2str(g_pars.msisdn), |
| 1401 | hex2str(cpars.called_party), hex2str(g_pars.imsi))); |
| 1402 | |
| 1403 | /* MSC->BSC: expect PAGING from MSC */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 1404 | f_expect_paging(); |
| 1405 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1406 | /* MS -> MSC: PAGING RESPONSE */ |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1407 | f_establish_fully(EST_TYPE_PAG_RESP); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1408 | |
| 1409 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1410 | |
| 1411 | /* MSC->MS: SETUP */ |
| 1412 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_SETUP(cpars.transaction_id, *, cpars.called_party))); |
| 1413 | } |
| 1414 | |
| 1415 | /* Test MT Call */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1416 | friend 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] | 1417 | f_init_handler(pars); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1418 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
| 1419 | var MNCC_PDU mncc; |
| 1420 | var MgcpCommand mgcp_cmd; |
| 1421 | |
| 1422 | f_mt_call_start(cpars); |
| 1423 | |
| 1424 | /* MS->MSC: CALL CONFIRMED */ |
| 1425 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CALL_CONF(cpars.transaction_id))); |
| 1426 | |
| 1427 | MNCC.receive(tr_MNCC_CALL_CONF_ind(cpars.mncc_callref)); |
| 1428 | |
| 1429 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
| 1430 | cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 1431 | |
| 1432 | /* Detect if the received CRCX is a wildcarded CRCX request. If yes, |
| 1433 | * set an endpoint name that fits the pattern. If not, just use the |
| 1434 | * endpoint name from the request */ |
| 1435 | if (match(mgcp_cmd.line.ep, t_MGCP_EP_wildcard)) { |
| 1436 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
| 1437 | } else { |
| 1438 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
| 1439 | } |
| 1440 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1441 | /* Respond to CRCX with error */ |
| 1442 | var MgcpResponse mgcp_rsp := { |
| 1443 | line := { |
| 1444 | code := "542", |
| 1445 | trans_id := mgcp_cmd.line.trans_id, |
| 1446 | string := "FORCED_FAIL" |
| 1447 | }, |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1448 | sdp := omit |
| 1449 | } |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 1450 | var MgcpParameter mgcp_rsp_param := { |
| 1451 | code := "Z", |
| 1452 | val := cpars.mgcp_ep |
| 1453 | }; |
| 1454 | mgcp_rsp.params[0] := mgcp_rsp_param; |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1455 | MGCP.send(mgcp_rsp); |
| 1456 | |
| 1457 | timer T := 30.0; |
| 1458 | T.start; |
| 1459 | alt { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1460 | [] T.timeout { |
| 1461 | setverdict(fail, "Timeout waiting for channel release"); |
| 1462 | mtc.stop; |
| 1463 | } |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1464 | [] MNCC.receive { repeat; } |
| 1465 | [] GSUP.receive { repeat; } |
| 1466 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 1467 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
| 1468 | f_create_mgcp_delete_ep(cpars.mgcp_ep); |
| 1469 | repeat; |
| 1470 | } |
| 1471 | [] MGCP.receive { repeat; } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1472 | [] as_clear_cmd_compl_disc(); |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 1473 | [] as_optional_cc_rel(cpars); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1474 | } |
| 1475 | } |
| 1476 | testcase TC_mt_crcx_ran_reject() runs on MTC_CT { |
| 1477 | var BSC_ConnHdlr vc_conn; |
| 1478 | f_init(); |
| 1479 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1480 | 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] | 1481 | vc_conn.done; |
| 1482 | } |
| 1483 | |
| 1484 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1485 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1486 | /* Test MT Call T310 timer */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1487 | friend 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] | 1488 | f_init_handler(pars, 200.0); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1489 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
| 1490 | var MNCC_PDU mncc; |
| 1491 | var MgcpCommand mgcp_cmd; |
| 1492 | |
| 1493 | f_mt_call_start(cpars); |
| 1494 | |
| 1495 | /* MS->MSC: CALL CONFIRMED */ |
| 1496 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CALL_CONF(cpars.transaction_id))); |
| 1497 | MNCC.receive(tr_MNCC_CALL_CONF_ind(cpars.mncc_callref)); |
| 1498 | |
| 1499 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
| 1500 | cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
| 1501 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
| 1502 | /* FIXME: Respond to CRCX */ |
| 1503 | |
| 1504 | /* old libosmocore T310 default timeout is 180s. so let's wait 190 */ |
| 1505 | timer T := 190.0; |
| 1506 | T.start; |
| 1507 | alt { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1508 | [] T.timeout { |
| 1509 | setverdict(fail, "Timeout waiting for T310"); |
| 1510 | mtc.stop; |
| 1511 | } |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1512 | [] MNCC.receive(tr_MNCC_DISC_ind(cpars.mncc_callref)) { |
| 1513 | MNCC.send(ts_MNCC_REL_req(cpars.mncc_callref, valueof(ts_MNCC_cause(23)))); |
| 1514 | } |
| 1515 | } |
| 1516 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_DISC(cpars.transaction_id))); |
| 1517 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))); |
| 1518 | /* FIXME: We're sending this with TIflag 0: allocated by sender, which is wrong */ |
| 1519 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_REL_COMPL(cpars.transaction_id))); |
| 1520 | |
| 1521 | alt { |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1522 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 1523 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
| 1524 | f_create_mgcp_delete_ep(cpars.mgcp_ep); |
| 1525 | repeat; |
| 1526 | } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1527 | [] as_clear_cmd_compl_disc(); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1528 | } |
| 1529 | } |
| 1530 | testcase TC_mt_t310() runs on MTC_CT { |
| 1531 | var BSC_ConnHdlr vc_conn; |
| 1532 | f_init(); |
| 1533 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1534 | vc_conn := f_start_handler(refers(f_tc_mt_t310), 32); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1535 | vc_conn.done; |
| 1536 | } |
| 1537 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1538 | |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1539 | /* Perform successful LU + MO call, then GSUP LocationCancel. Subscriber must be denied CM SERV */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1540 | friend function f_tc_gsup_cancel(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1541 | f_init_handler(pars); |
| 1542 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1543 | |
| 1544 | /* Location Update to make subscriber known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1545 | f_perform_lu(); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1546 | |
| 1547 | /* First MO call should succeed */ |
| 1548 | f_mo_call(cpars); |
| 1549 | |
| 1550 | /* Cancel the subscriber in the VLR */ |
| 1551 | GSUP.send(ts_GSUP_CL_REQ(g_pars.imsi, OSMO_GSUP_CANCEL_TYPE_WITHDRAW)); |
| 1552 | alt { |
| 1553 | [] GSUP.receive(tr_GSUP_CL_RES(g_pars.imsi)) { } |
| 1554 | [] GSUP.receive(tr_GSUP_CL_ERR(g_pars.imsi)) { |
| 1555 | setverdict(fail, "Received GSUP Location Cancel Error"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1556 | mtc.stop; |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1557 | } |
| 1558 | } |
| 1559 | |
| 1560 | /* Follow-up transactions should fail */ |
| 1561 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 1562 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1563 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1564 | alt { |
| 1565 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)) { } |
| 1566 | [] BSSAP.receive { |
| 1567 | setverdict(fail, "Received unexpected BSSAP instead of CM SERV REJ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1568 | mtc.stop; |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1569 | } |
| 1570 | } |
Neels Hofmeyr | 0f7429a | 2019-03-07 22:28:41 +0100 | [diff] [blame] | 1571 | |
| 1572 | f_expect_clear(); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1573 | setverdict(pass); |
| 1574 | } |
| 1575 | testcase TC_gsup_cancel() runs on MTC_CT { |
| 1576 | var BSC_ConnHdlr vc_conn; |
| 1577 | f_init(); |
| 1578 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1579 | vc_conn := f_start_handler(refers(f_tc_gsup_cancel), 33); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1580 | vc_conn.done; |
| 1581 | } |
| 1582 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1583 | |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1584 | /* A5/1 only permitted on network side, and MS capable to do it */ |
| 1585 | private function f_tc_lu_imsi_auth_tmsi_encr_1_13(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1586 | pars.net.expect_auth := true; |
| 1587 | pars.net.expect_ciph := true; |
| 1588 | pars.net.kc_support := '02'O; /* A5/1 only */ |
| 1589 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1590 | f_perform_lu(); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1591 | } |
| 1592 | testcase TC_lu_imsi_auth_tmsi_encr_1_13() runs on MTC_CT { |
| 1593 | var BSC_ConnHdlr vc_conn; |
| 1594 | f_init(); |
| 1595 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1596 | f_vty_config(MSCVTY, "network", "encryption a5 1"); |
| 1597 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1598 | 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] | 1599 | vc_conn.done; |
| 1600 | } |
| 1601 | |
| 1602 | /* A5/3 only permitted on network side, and MS capable to do it */ |
| 1603 | private function f_tc_lu_imsi_auth_tmsi_encr_3_13(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1604 | pars.net.expect_auth := true; |
| 1605 | pars.net.expect_ciph := true; |
| 1606 | pars.net.kc_support := '08'O; /* A5/3 only */ |
| 1607 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1608 | f_perform_lu(); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1609 | } |
| 1610 | testcase TC_lu_imsi_auth_tmsi_encr_3_13() runs on MTC_CT { |
| 1611 | var BSC_ConnHdlr vc_conn; |
| 1612 | f_init(); |
| 1613 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1614 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1615 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1616 | 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] | 1617 | vc_conn.done; |
| 1618 | } |
| 1619 | |
| 1620 | /* A5/3 only permitted on network side, and MS with only A5/1 support */ |
| 1621 | private function f_tc_lu_imsi_auth_tmsi_encr_3_1(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1622 | pars.net.expect_auth := true; |
| 1623 | pars.net.expect_ciph := true; |
| 1624 | pars.net.kc_support := '08'O; /* A5/3 only */ |
| 1625 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 1626 | f_init_handler(pars, 15.0); |
| 1627 | |
| 1628 | /* cannot use f_perform_lu() as we expect a reject */ |
| 1629 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 1630 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1631 | f_cl3_or_initial_ue(l3_lu); |
Neels Hofmeyr | 29b8da0 | 2018-03-01 18:09:45 +0100 | [diff] [blame] | 1632 | if (pars.send_early_cm) { |
| 1633 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1634 | } else { |
| 1635 | pars.cm1.esind := '0'B; |
| 1636 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1637 | f_mm_auth(); |
| 1638 | alt { |
Daniel Willmann | 52918e5 | 2018-09-20 14:39:09 +0200 | [diff] [blame] | 1639 | [] BSSAP.receive(tr_BSSMAP_ClassmarkReq) { |
| 1640 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1641 | repeat; |
| 1642 | } |
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"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1648 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1649 | } |
| 1650 | [] BSSAP.receive { |
Harald Welte | 458fd37 | 2018-03-21 11:26:23 +0100 | [diff] [blame] | 1651 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1652 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1653 | } |
| 1654 | } |
| 1655 | setverdict(pass); |
| 1656 | } |
| 1657 | testcase TC_lu_imsi_auth_tmsi_encr_3_1() 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 3"); |
| 1662 | |
Neels Hofmeyr | 29b8da0 | 2018-03-01 18:09:45 +0100 | [diff] [blame] | 1663 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_3_1), 360); |
| 1664 | vc_conn.done; |
| 1665 | } |
| 1666 | testcase TC_lu_imsi_auth_tmsi_encr_3_1_no_cm() runs on MTC_CT { |
| 1667 | var BSC_ConnHdlrPars pars; |
| 1668 | var BSC_ConnHdlr vc_conn; |
| 1669 | f_init(); |
| 1670 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1671 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1672 | |
| 1673 | pars := f_init_pars(361); |
| 1674 | pars.send_early_cm := false; |
| 1675 | 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] | 1676 | vc_conn.done; |
| 1677 | } |
Neels Hofmeyr | 1b3c6e3 | 2018-03-01 17:52:21 +0100 | [diff] [blame] | 1678 | testcase TC_lu_imsi_auth_tmsi_encr_3_1_log_msc_debug() runs on MTC_CT { |
| 1679 | var BSC_ConnHdlr vc_conn; |
| 1680 | f_init(); |
| 1681 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1682 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1683 | |
| 1684 | /* Make sure the MSC category is on DEBUG level to trigger the log |
| 1685 | * message that is reported in OS#2947 to trigger the segfault */ |
| 1686 | f_vty_config(MSCVTY, "log stderr", "logging level msc debug"); |
| 1687 | |
| 1688 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_3_1), 362); |
| 1689 | vc_conn.done; |
| 1690 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1691 | |
| 1692 | /* A5/1 + A5/3 only permitted on network side, and MS with only A5/2 support */ |
| 1693 | private function f_tc_lu_imsi_auth_tmsi_encr_13_2(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1694 | pars.net.expect_auth := true; |
| 1695 | pars.net.expect_ciph := true; |
| 1696 | pars.net.kc_support := '0A'O; /* A5/1 + A5/3 */ |
| 1697 | pars.cm1.a5_1 := '1'B; |
| 1698 | pars.cm2.a5_1 := '1'B; |
| 1699 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 1700 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '1'B; |
| 1701 | f_init_handler(pars, 15.0); |
| 1702 | |
| 1703 | /* cannot use f_perform_lu() as we expect a reject */ |
| 1704 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 1705 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1706 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1707 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1708 | f_mm_auth(); |
| 1709 | alt { |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1710 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 1711 | f_expect_clear(); |
| 1712 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1713 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?,?)) { |
| 1714 | setverdict(fail, "CipherModeCommand despite no A5 intersection"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1715 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1716 | } |
| 1717 | [] BSSAP.receive { |
Harald Welte | 458fd37 | 2018-03-21 11:26:23 +0100 | [diff] [blame] | 1718 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1719 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1720 | } |
| 1721 | } |
| 1722 | setverdict(pass); |
| 1723 | } |
| 1724 | testcase TC_lu_imsi_auth_tmsi_encr_13_2() runs on MTC_CT { |
| 1725 | var BSC_ConnHdlr vc_conn; |
| 1726 | f_init(); |
| 1727 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1728 | f_vty_config(MSCVTY, "network", "encryption a5 1 3"); |
| 1729 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1730 | 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] | 1731 | vc_conn.done; |
| 1732 | } |
| 1733 | |
| 1734 | /* A5/0 + A5/1 + A5/3 only permitted on network side, and MS with only A5/2 support */ |
| 1735 | private function f_tc_lu_imsi_auth_tmsi_encr_013_2(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1736 | pars.net.expect_auth := true; |
| 1737 | pars.net.expect_ciph := true; |
| 1738 | pars.net.kc_support := '0B'O; /* A5/1 + A5/3 */ |
| 1739 | pars.cm1.a5_1 := '1'B; |
| 1740 | pars.cm2.a5_1 := '1'B; |
| 1741 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 1742 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '1'B; |
| 1743 | f_init_handler(pars, 15.0); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1744 | f_perform_lu(); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1745 | } |
| 1746 | testcase TC_lu_imsi_auth_tmsi_encr_013_2() runs on MTC_CT { |
| 1747 | var BSC_ConnHdlr vc_conn; |
| 1748 | f_init(); |
| 1749 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1750 | f_vty_config(MSCVTY, "network", "encryption a5 0 1 3"); |
| 1751 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1752 | 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] | 1753 | vc_conn.done; |
| 1754 | } |
| 1755 | |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 1756 | /* LU followed by MT call (including paging) */ |
Neels Hofmeyr | 8fe8a90 | 2019-11-03 05:51:03 +0100 | [diff] [blame] | 1757 | friend function f_tc_lu_and_mt_call(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 1758 | f_init_handler(pars); |
Stefan Sperling | 26d57be | 2018-11-12 17:03:26 +0100 | [diff] [blame] | 1759 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 1760 | cpars.use_osmux := pars.use_osmux; |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 1761 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1762 | f_perform_lu(); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 1763 | f_mt_call(cpars); |
| 1764 | } |
| 1765 | testcase TC_lu_and_mt_call() runs on MTC_CT { |
| 1766 | var BSC_ConnHdlr vc_conn; |
| 1767 | f_init(); |
| 1768 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1769 | 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] | 1770 | vc_conn.done; |
| 1771 | } |
| 1772 | |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 1773 | testcase TC_lu_and_mt_call_osmux() runs on MTC_CT { |
| 1774 | var BSC_ConnHdlr vc_conn; |
| 1775 | f_init(1, false, true, true); |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 1776 | |
| 1777 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_call), 39, 0, true, true); |
| 1778 | vc_conn.done; |
| 1779 | } |
| 1780 | |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1781 | /* Test MO Call SETUP with DTMF */ |
| 1782 | private function f_tc_mo_setup_dtmf_dup(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1783 | f_init_handler(pars); |
| 1784 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1785 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1786 | f_perform_lu(); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1787 | f_mo_seq_dtmf_dup(cpars); |
| 1788 | } |
| 1789 | testcase TC_mo_setup_and_dtmf_dup() runs on MTC_CT { |
| 1790 | var BSC_ConnHdlr vc_conn; |
| 1791 | f_init(); |
| 1792 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1793 | 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] | 1794 | vc_conn.done; |
| 1795 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1796 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 1797 | testcase TC_cr_before_reset() runs on MTC_CT { |
| 1798 | timer T := 4.0; |
| 1799 | var boolean reset_ack_seen := false; |
| 1800 | f_init_bssap_direct(); |
| 1801 | |
Harald Welte | 3ca0ce1 | 2019-04-23 17:18:48 +0200 | [diff] [blame] | 1802 | f_ran_adapter_start(g_bssap[0]); |
Daniel Willmann | 42d1d5b | 2018-08-07 15:18:41 +0200 | [diff] [blame] | 1803 | |
Daniel Willmann | e801896 | 2018-08-21 14:18:00 +0200 | [diff] [blame] | 1804 | f_sleep(3.0); |
| 1805 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 1806 | /* Make a blind connection attemt, to trigger the deadlock condition */ |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 1807 | 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] | 1808 | |
| 1809 | /* Send a BSSMAP reset */ |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 1810 | 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] | 1811 | T.start |
| 1812 | alt { |
| 1813 | [] BSSAP_DIRECT.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_ResetAck)) { |
| 1814 | reset_ack_seen := true; |
| 1815 | repeat; |
| 1816 | } |
| 1817 | |
| 1818 | /* Acknowledge MSC sided reset requests */ |
| 1819 | [] BSSAP_DIRECT.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) { |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 1820 | 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] | 1821 | repeat; |
| 1822 | } |
| 1823 | |
| 1824 | /* Ignore all other messages (e.g CR from the connection request) */ |
| 1825 | [] BSSAP_DIRECT.receive { repeat } |
| 1826 | |
| 1827 | /* If we got no BSSMAP RESET ACK back, then the MSC entered the |
| 1828 | * deadlock situation. The MSC is then unable to respond to any |
| 1829 | * further BSSMAP RESET or any other sort of traffic. */ |
| 1830 | [reset_ack_seen == true] T.timeout { setverdict(pass) } |
| 1831 | [reset_ack_seen == false] T.timeout { |
| 1832 | setverdict(fail, "no BSSMAP RESET ACK seen!"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1833 | mtc.stop; |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 1834 | } |
Pau Espin Pedrol | 7e9178d | 2019-12-17 17:52:17 +0100 | [diff] [blame] | 1835 | } |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 1836 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1837 | |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 1838 | /* Test MO Call with no response to RAN-side CRCX or DTAP Release */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1839 | friend function f_tc_mo_release_timeout(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 1840 | f_init_handler(pars); |
| 1841 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1842 | var MNCC_PDU mncc; |
| 1843 | var MgcpCommand mgcp_cmd; |
| 1844 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1845 | /* Do not respond to the second CRCX */ |
| 1846 | cpars.mgw_conn_2.resp := 0; |
| 1847 | |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 1848 | f_perform_lu(); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1849 | f_mo_call_establish(cpars); |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 1850 | |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 1851 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 1852 | |
| 1853 | f_expect_clear(60.0); |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 1854 | |
| 1855 | deactivate(ccrel); |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 1856 | } |
| 1857 | testcase TC_mo_release_timeout() runs on MTC_CT { |
| 1858 | var BSC_ConnHdlr vc_conn; |
| 1859 | f_init(); |
| 1860 | |
| 1861 | vc_conn := f_start_handler(refers(f_tc_mo_release_timeout), 40); |
| 1862 | vc_conn.done; |
| 1863 | } |
| 1864 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1865 | |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 1866 | /* LU followed by MT call (including paging) */ |
| 1867 | private function f_tc_lu_and_mt_call_no_dlcx_resp(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1868 | f_init_handler(pars); |
Stefan Sperling | 26d57be | 2018-11-12 17:03:26 +0100 | [diff] [blame] | 1869 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 1870 | |
| 1871 | /* Intentionally disable the CRCX response */ |
| 1872 | cpars.mgw_drop_dlcx := true; |
| 1873 | |
| 1874 | /* Perform location update and call */ |
| 1875 | f_perform_lu(); |
| 1876 | f_mt_call(cpars); |
| 1877 | } |
| 1878 | testcase TC_lu_and_mt_call_no_dlcx_resp() runs on MTC_CT { |
| 1879 | var BSC_ConnHdlr vc_conn; |
| 1880 | f_init(); |
| 1881 | |
| 1882 | /* Perform an almost normal looking locationupdate + mt-call, but do |
| 1883 | * not respond to the DLCX at the end of the call */ |
| 1884 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_call_no_dlcx_resp), 41); |
| 1885 | vc_conn.done; |
| 1886 | |
| 1887 | /* Wait a guard period until the MGCP layer in the MSC times out, |
| 1888 | * if the MSC is vulnerable to the use-after-free situation that is |
| 1889 | * fixed by I78f1b6a9149488a4ad3f120c1e190a83c07d4b89 then it should |
| 1890 | * segfault now */ |
| 1891 | f_sleep(6.0); |
| 1892 | |
| 1893 | /* Run the init procedures once more. If the MSC has crashed, this |
| 1894 | * this will fail */ |
| 1895 | f_init(); |
| 1896 | } |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1897 | |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 1898 | /* Two BSSMAP resets from two different BSCs */ |
| 1899 | testcase TC_reset_two() runs on MTC_CT { |
| 1900 | var BSC_ConnHdlr vc_conn; |
| 1901 | f_init(2); |
| 1902 | f_sleep(2.0); |
| 1903 | setverdict(pass); |
| 1904 | } |
| 1905 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1906 | /* Two BSSMAP resets from two different BSCs plus one IuCS RANAP Reset */ |
| 1907 | testcase TC_reset_two_1iu() runs on MTC_CT { |
| 1908 | var BSC_ConnHdlr vc_conn; |
| 1909 | f_init(3); |
| 1910 | f_sleep(2.0); |
| 1911 | setverdict(pass); |
| 1912 | } |
| 1913 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 1914 | /*********************************************************************** |
| 1915 | * SMS Testing |
| 1916 | ***********************************************************************/ |
| 1917 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1918 | /* LU followed by MO SMS */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1919 | friend function f_tc_lu_and_mo_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1920 | var SmsParameters spars := valueof(t_SmsPars); |
| 1921 | |
| 1922 | f_init_handler(pars); |
| 1923 | |
| 1924 | /* Perform location update and call */ |
| 1925 | f_perform_lu(); |
| 1926 | |
| 1927 | f_establish_fully(EST_TYPE_MO_SMS); |
| 1928 | |
| 1929 | //spars.exp_rp_err := 96; /* invalid mandatory information */ |
| 1930 | f_mo_sms(spars); |
| 1931 | |
| 1932 | f_expect_clear(); |
| 1933 | } |
| 1934 | testcase TC_lu_and_mo_sms() runs on MTC_CT { |
| 1935 | var BSC_ConnHdlr vc_conn; |
| 1936 | f_init(); |
| 1937 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_sms), 42); |
| 1938 | vc_conn.done; |
| 1939 | } |
| 1940 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1941 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1942 | private function f_vty_sms_send(charstring imsi, charstring msisdn, charstring text) |
Neels Hofmeyr | 6aaeccf | 2019-03-06 15:32:26 +0100 | [diff] [blame] | 1943 | runs on BSC_ConnHdlr { |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1944 | f_vty_transceive(MSCVTY, "subscriber imsi "&imsi&" sms sender msisdn "&msisdn&" send "&text); |
| 1945 | } |
| 1946 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 1947 | /* Remove still pending SMS */ |
| 1948 | private function f_vty_sms_clear(charstring imsi) |
| 1949 | runs on BSC_ConnHdlr { |
| 1950 | f_vty_transceive(MSCVTY, "subscriber imsi " & imsi & " sms delete-all"); |
| 1951 | f_vty_transceive(MSCVTY, "sms-queue clear"); |
| 1952 | } |
| 1953 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1954 | /* LU followed by MT SMS */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1955 | friend function f_tc_lu_and_mt_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1956 | var SmsParameters spars := valueof(t_SmsPars); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1957 | |
| 1958 | f_init_handler(pars); |
| 1959 | |
| 1960 | /* Perform location update and call */ |
| 1961 | f_perform_lu(); |
| 1962 | |
| 1963 | /* register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 1964 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1965 | |
Neels Hofmeyr | 6aaeccf | 2019-03-06 15:32:26 +0100 | [diff] [blame] | 1966 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1967 | |
| 1968 | /* MSC->BSC: expect PAGING from MSC */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 1969 | f_expect_paging(); |
| 1970 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1971 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 1972 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 1973 | |
| 1974 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 1975 | f_mt_sms(spars); |
| 1976 | |
| 1977 | f_expect_clear(); |
| 1978 | } |
| 1979 | testcase TC_lu_and_mt_sms() runs on MTC_CT { |
| 1980 | var BSC_ConnHdlrPars pars; |
| 1981 | var BSC_ConnHdlr vc_conn; |
| 1982 | f_init(); |
| 1983 | pars := f_init_pars(43); |
| 1984 | vc_conn := f_start_handler_with_pars(refers(f_tc_lu_and_mt_sms), pars); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1985 | vc_conn.done; |
| 1986 | } |
| 1987 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1988 | |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 1989 | /* Paging for MT SMS but no response */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1990 | friend function f_tc_lu_and_mt_sms_paging_and_nothing(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 1991 | var SmsParameters spars := valueof(t_SmsPars); |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 1992 | |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 1993 | f_init_handler(pars, 150.0); |
| 1994 | |
| 1995 | /* Perform location update */ |
| 1996 | f_perform_lu(); |
| 1997 | |
| 1998 | /* register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 1999 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2000 | |
Neels Hofmeyr | 6aaeccf | 2019-03-06 15:32:26 +0100 | [diff] [blame] | 2001 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 2002 | |
Neels Hofmeyr | 1623774 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 2003 | /* Expect the MSC to page exactly once */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2004 | f_expect_paging(); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2005 | |
| 2006 | /* Wait some time to make sure the MSC is not delivering any further |
| 2007 | * paging messages or anything else that could be unexpected. */ |
| 2008 | timer T := 20.0; |
| 2009 | T.start |
| 2010 | alt { |
Vadim Yanitskiy | da77459 | 2020-01-15 10:33:47 +0700 | [diff] [blame] | 2011 | [pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 2012 | setverdict(fail, "paging seems not to stop!"); |
| 2013 | mtc.stop; |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2014 | } |
Vadim Yanitskiy | da77459 | 2020-01-15 10:33:47 +0700 | [diff] [blame] | 2015 | [not pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) { |
| 2016 | setverdict(fail, "paging seems not to stop!"); |
| 2017 | mtc.stop; |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2018 | } |
Vadim Yanitskiy | da77459 | 2020-01-15 10:33:47 +0700 | [diff] [blame] | 2019 | [] BSSAP.receive { |
| 2020 | setverdict(fail, "unexpected BSSAP message received"); |
| 2021 | self.stop; |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2022 | } |
Vadim Yanitskiy | da77459 | 2020-01-15 10:33:47 +0700 | [diff] [blame] | 2023 | [] T.timeout { |
| 2024 | setverdict(pass); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2025 | } |
| 2026 | } |
| 2027 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 2028 | f_vty_sms_clear(hex2str(g_pars.imsi)); |
| 2029 | |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2030 | setverdict(pass); |
| 2031 | } |
| 2032 | testcase TC_lu_and_mt_sms_paging_and_nothing() runs on MTC_CT { |
| 2033 | var BSC_ConnHdlrPars pars; |
| 2034 | var BSC_ConnHdlr vc_conn; |
| 2035 | f_init(); |
Philipp Maier | a99ad26 | 2019-01-22 15:35:42 +0100 | [diff] [blame] | 2036 | pars := f_init_pars(1843); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2037 | vc_conn := f_start_handler_with_pars(refers(f_tc_lu_and_mt_sms_paging_and_nothing), pars); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2038 | vc_conn.done; |
| 2039 | } |
| 2040 | |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2041 | /* LU followed by MT SMS with repeated paging */ |
| 2042 | friend function f_tc_lu_and_mt_sms_paging_repeated(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2043 | var SmsParameters spars := valueof(t_SmsPars); |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2044 | |
| 2045 | f_init_handler(pars); |
| 2046 | |
| 2047 | /* Perform location update and call */ |
| 2048 | f_perform_lu(); |
| 2049 | |
| 2050 | /* register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2051 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2052 | |
| 2053 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 2054 | |
Neels Hofmeyr | c3accec | 2019-11-28 01:09:47 +0100 | [diff] [blame] | 2055 | log("Expecting first Paging"); |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2056 | /* MSC->BSC: expect PAGING from MSC */ |
| 2057 | f_expect_paging(); |
| 2058 | |
Neels Hofmeyr | c3accec | 2019-11-28 01:09:47 +0100 | [diff] [blame] | 2059 | if (g_pars.ran_is_geran) { |
| 2060 | log("GERAN: expect no further Paging"); |
| 2061 | } else { |
| 2062 | log("UTRAN: expect more Paging"); |
| 2063 | } |
| 2064 | |
| 2065 | timer T := 5.0; |
| 2066 | T.start; |
| 2067 | alt { |
| 2068 | [g_pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 2069 | setverdict(fail, "GERAN should not repeat Paging, but received a second Paging"); |
| 2070 | mtc.stop; |
| 2071 | } |
| 2072 | [not g_pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) { |
| 2073 | log("UTRAN: second Paging received, as expected"); |
| 2074 | setverdict(pass); |
| 2075 | } |
| 2076 | [] T.timeout { |
| 2077 | if (g_pars.ran_is_geran) { |
| 2078 | log("GERAN: No further Paging received, as expected"); |
| 2079 | setverdict(pass); |
| 2080 | } else { |
| 2081 | setverdict(fail, "UTRAN: Expected a second Paging"); |
| 2082 | mtc.stop; |
| 2083 | } |
| 2084 | } |
| 2085 | } |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2086 | |
| 2087 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 2088 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2089 | |
| 2090 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 2091 | f_mt_sms(spars); |
| 2092 | |
| 2093 | f_expect_clear(); |
| 2094 | } |
| 2095 | testcase TC_lu_and_mt_sms_paging_repeated() runs on MTC_CT { |
| 2096 | var BSC_ConnHdlrPars pars; |
| 2097 | var BSC_ConnHdlr vc_conn; |
| 2098 | f_init(); |
| 2099 | pars := f_init_pars(1844); |
| 2100 | vc_conn := f_start_handler_with_pars(refers(f_tc_lu_and_mt_sms_paging_repeated), pars); |
| 2101 | vc_conn.done; |
| 2102 | } |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2103 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2104 | /* mobile originated SMS from MS/BTS/BSC side to SMPP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2105 | friend function f_tc_smpp_mo_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2106 | var SmsParameters spars := valueof(t_SmsPars); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2107 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2108 | f_init_handler(pars); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2109 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2110 | /* Perform location update so IMSI is known + registered in MSC/VLR */ |
| 2111 | f_perform_lu(); |
| 2112 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2113 | |
| 2114 | f_mo_sms(spars); |
| 2115 | |
| 2116 | var SMPP_PDU smpp; |
| 2117 | var template SMPP_PDU tr_smpp := tr_SMPP(c_SMPP_command_id_deliver_sm, ESME_ROK); |
| 2118 | tr_smpp.body.deliver_sm := { |
| 2119 | service_type := "CMT", |
| 2120 | source_addr_ton := network_specific, |
| 2121 | source_addr_npi := isdn, |
| 2122 | source_addr := hex2str(pars.msisdn), |
| 2123 | dest_addr_ton := f_sm_ton_from_gsm(spars.tp.da.tP_DA_NoPad.tP_TypeOfNumber), |
| 2124 | dest_addr_npi := f_sm_npi_from_gsm(spars.tp.da.tP_DA_NoPad.tP_NumberingPlanID), |
| 2125 | destination_addr := hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue), |
| 2126 | esm_class := '00000001'B, |
| 2127 | protocol_id := 0, |
| 2128 | priority_flag := 0, |
| 2129 | schedule_delivery_time := "", |
| 2130 | replace_if_present := 0, |
| 2131 | data_coding := '00000001'B, |
| 2132 | sm_default_msg_id := 0, |
| 2133 | sm_length := ?, |
| 2134 | short_message := spars.tp.ud, |
| 2135 | opt_pars := { |
| 2136 | { |
| 2137 | tag := user_message_reference, |
| 2138 | len := 2, |
| 2139 | opt_value := { |
| 2140 | int2_val := oct2int(spars.tp.msg_ref) |
| 2141 | } |
| 2142 | } |
| 2143 | } |
| 2144 | }; |
| 2145 | alt { |
| 2146 | [] SMPP.receive(tr_smpp) -> value smpp { |
| 2147 | SMPP.send(ts_SMPP_DELIVER_SM_resp(ESME_ROK, smpp.header.seq_num)); |
| 2148 | } |
| 2149 | [] SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)) { repeat; } |
| 2150 | } |
| 2151 | |
| 2152 | f_expect_clear(); |
| 2153 | } |
| 2154 | testcase TC_smpp_mo_sms() runs on MTC_CT { |
| 2155 | var BSC_ConnHdlr vc_conn; |
| 2156 | f_init(); |
| 2157 | f_vty_config2(MSCVTY, { "smpp", "esme msc_tester"}, "default-route"); |
| 2158 | vc_conn := f_start_handler(refers(f_tc_smpp_mo_sms), 44); |
| 2159 | vc_conn.done; |
| 2160 | f_vty_config2(MSCVTY, { "smpp", "esme msc_tester"}, "no default-route"); |
| 2161 | } |
| 2162 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2163 | |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 2164 | /* Test MO-SMS from MS/BTS/BSC towards HLR (via GSUP) */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2165 | friend function f_tc_gsup_mo_sms(charstring id, BSC_ConnHdlrPars pars) |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 2166 | runs on BSC_ConnHdlr { |
| 2167 | var SmsParameters spars := valueof(t_SmsPars); |
| 2168 | var GSUP_PDU gsup_msg_rx; |
| 2169 | var octetstring sm_tpdu; |
| 2170 | |
| 2171 | f_init_handler(pars); |
| 2172 | |
| 2173 | /* We need to inspect GSUP activity */ |
| 2174 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2175 | |
| 2176 | /* Perform location update */ |
| 2177 | f_perform_lu(); |
| 2178 | |
| 2179 | /* Send CM Service Request for SMS */ |
| 2180 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2181 | |
| 2182 | /* Prepare expected SM-RP-UI (SM TPDU) */ |
| 2183 | enc_TPDU_RP_DATA_MS_SGSN_fast( |
| 2184 | valueof(ts_SMS_SUBMIT(spars.tp.msg_ref, |
| 2185 | spars.tp.da, spars.tp.pid, spars.tp.dcs, |
| 2186 | spars.tp.udl, spars.tp.ud)), |
| 2187 | sm_tpdu); |
| 2188 | |
| 2189 | var template GSUP_PDU mo_forwardSM := tr_GSUP_MO_FORWARD_SM_REQ( |
| 2190 | imsi := g_pars.imsi, |
| 2191 | sm_rp_mr := spars.rp.msg_ref, |
Vadim Yanitskiy | 04dd5f7 | 2019-12-13 15:45:44 +0900 | [diff] [blame] | 2192 | /* SM-RP-DA: SMSC address */ |
| 2193 | sm_rp_da := tr_GSUP_SM_RP_DA_SMSC_ADDR(t_GSUP_SM_RP_Addr( |
| 2194 | number := spars.rp.smsc_addr.rP_NumberDigits, |
| 2195 | npi := spars.rp.smsc_addr.rP_NumberingPlanIdentification, |
| 2196 | ton := spars.rp.smsc_addr.rP_TypeOfNumber, |
| 2197 | ext := spars.rp.smsc_addr.rP_Ext)), |
| 2198 | /* SM-RP-OA: subscriber's MSISDN (filled in by MSC) */ |
| 2199 | sm_rp_oa := tr_GSUP_SM_RP_OA_MSISDN(t_GSUP_SM_RP_Addr( |
| 2200 | number := g_pars.msisdn, |
| 2201 | /* NOTE: MSISDN in g_pars lacks this info, assuming defaults */ |
| 2202 | npi := '0001'B, ton := '001'B, ext := '1'B)), |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 2203 | /* TODO: can we use decmatch here? */ |
| 2204 | sm_rp_ui := sm_tpdu |
| 2205 | ); |
| 2206 | |
| 2207 | /* Submit an SMS on DTAP and expect MO-forwardSM-Req on GSUP */ |
| 2208 | f_mo_sms_submit(spars); |
| 2209 | alt { |
| 2210 | [] GSUP.receive(mo_forwardSM) -> value gsup_msg_rx { |
Vadim Yanitskiy | a358dd4 | 2020-01-15 10:42:47 +0700 | [diff] [blame] | 2211 | log("RX MO-forwardSM-Req: ", gsup_msg_rx); |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 2212 | setverdict(pass); |
| 2213 | } |
| 2214 | [] GSUP.receive { |
| 2215 | log("RX unexpected GSUP message"); |
| 2216 | setverdict(fail); |
| 2217 | mtc.stop; |
| 2218 | } |
| 2219 | } |
| 2220 | |
| 2221 | /* Trigger RP-ACK by sending MO-forwardSM-Res */ |
| 2222 | GSUP.send(valueof(ts_GSUP_MO_FORWARD_SM_RES( |
| 2223 | imsi := g_pars.imsi, |
| 2224 | sm_rp_mr := spars.rp.msg_ref))); |
| 2225 | /* Expect RP-ACK on DTAP */ |
| 2226 | f_mo_sms_wait_rp_ack(spars); |
| 2227 | |
| 2228 | f_expect_clear(); |
| 2229 | } |
| 2230 | testcase TC_gsup_mo_sms() runs on MTC_CT { |
| 2231 | var BSC_ConnHdlr vc_conn; |
| 2232 | f_init(); |
| 2233 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2234 | vc_conn := f_start_handler(refers(f_tc_gsup_mo_sms), 88); |
| 2235 | vc_conn.done; |
| 2236 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2237 | } |
| 2238 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2239 | |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 2240 | /* Test MO-SMMA from MS/BTS/BSC towards HLR (via GSUP) */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2241 | friend function f_tc_gsup_mo_smma(charstring id, BSC_ConnHdlrPars pars) |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 2242 | runs on BSC_ConnHdlr { |
| 2243 | var SmsParameters spars := valueof(t_SmsPars); |
| 2244 | var GSUP_PDU gsup_msg_rx; |
| 2245 | |
| 2246 | f_init_handler(pars); |
| 2247 | |
| 2248 | /* We need to inspect GSUP activity */ |
| 2249 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2250 | |
| 2251 | /* Perform location update */ |
| 2252 | f_perform_lu(); |
| 2253 | |
| 2254 | /* Send CM Service Request for SMS */ |
| 2255 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2256 | |
| 2257 | var template GSUP_PDU mo_ReadyForSM := tr_GSUP_MO_READY_FOR_SM_REQ( |
| 2258 | imsi := g_pars.imsi, |
| 2259 | sm_rp_mr := spars.rp.msg_ref, |
| 2260 | sm_alert_rsn := GSUP_SM_ALERT_RSN_TYPE_MEM_AVAIL |
| 2261 | ); |
| 2262 | |
| 2263 | /* Submit an SMS on DTAP and expect MO-forwardSM-Req on GSUP */ |
| 2264 | f_mo_smma(spars); |
| 2265 | alt { |
| 2266 | [] GSUP.receive(mo_ReadyForSM) -> value gsup_msg_rx { |
Vadim Yanitskiy | a358dd4 | 2020-01-15 10:42:47 +0700 | [diff] [blame] | 2267 | log("RX MO-ReadyForSM-Req: ", gsup_msg_rx); |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 2268 | setverdict(pass); |
| 2269 | } |
| 2270 | [] GSUP.receive { |
| 2271 | log("RX unexpected GSUP message"); |
| 2272 | setverdict(fail); |
| 2273 | mtc.stop; |
| 2274 | } |
| 2275 | } |
| 2276 | |
| 2277 | /* Trigger RP-ACK by sending MO-forwardSM-Res */ |
| 2278 | GSUP.send(valueof(ts_GSUP_MO_READY_FOR_SM_RES( |
| 2279 | imsi := g_pars.imsi, |
| 2280 | sm_rp_mr := spars.rp.msg_ref))); |
| 2281 | /* Expect RP-ACK on DTAP */ |
| 2282 | f_mo_sms_wait_rp_ack(spars); |
| 2283 | |
| 2284 | f_expect_clear(); |
| 2285 | } |
| 2286 | testcase TC_gsup_mo_smma() runs on MTC_CT { |
| 2287 | var BSC_ConnHdlr vc_conn; |
| 2288 | f_init(); |
| 2289 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2290 | vc_conn := f_start_handler(refers(f_tc_gsup_mo_smma), 89); |
| 2291 | vc_conn.done; |
| 2292 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2293 | } |
| 2294 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2295 | |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2296 | /* Helper for sending MT SMS over GSUP */ |
| 2297 | private function f_gsup_forwardSM_req(SmsParameters spars, OCT1 mms := '00'O) |
| 2298 | runs on BSC_ConnHdlr { |
Vadim Yanitskiy | a52347c | 2019-12-12 17:32:33 +0900 | [diff] [blame] | 2299 | var GSUP_SM_RP_Addr msisdn := valueof(t_GSUP_SM_RP_Addr(g_pars.msisdn)); |
Vadim Yanitskiy | 04dd5f7 | 2019-12-13 15:45:44 +0900 | [diff] [blame] | 2300 | var GSUP_SM_RP_Addr smsc := valueof(t_GSUP_SM_RP_Addr( |
| 2301 | number := spars.rp.smsc_addr.rP_NumberDigits, |
| 2302 | npi := spars.rp.smsc_addr.rP_NumberingPlanIdentification, |
| 2303 | ton := spars.rp.smsc_addr.rP_TypeOfNumber, |
| 2304 | ext := spars.rp.smsc_addr.rP_Ext)); |
Vadim Yanitskiy | a52347c | 2019-12-12 17:32:33 +0900 | [diff] [blame] | 2305 | |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2306 | GSUP.send(ts_GSUP_MT_FORWARD_SM_REQ( |
| 2307 | imsi := g_pars.imsi, |
| 2308 | /* NOTE: MSC should assign RP-MR itself */ |
| 2309 | sm_rp_mr := 'FF'O, |
Vadim Yanitskiy | a52347c | 2019-12-12 17:32:33 +0900 | [diff] [blame] | 2310 | sm_rp_da := valueof(ts_GSUP_SM_RP_DA_MSISDN(msisdn)), |
Vadim Yanitskiy | 04dd5f7 | 2019-12-13 15:45:44 +0900 | [diff] [blame] | 2311 | sm_rp_oa := valueof(ts_GSUP_SM_RP_OA_SMSC_ADDR(smsc)), |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2312 | /* Encoded SMS TPDU (taken from Wireshark) |
| 2313 | * FIXME: we should encode spars somehow */ |
| 2314 | sm_rp_ui := '00068021436500008111328130858200'O, |
| 2315 | sm_rp_mms := mms |
| 2316 | )); |
| 2317 | } |
| 2318 | |
| 2319 | /* Test successful MT-SMS (RP-ACK) over GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2320 | friend function f_tc_gsup_mt_sms_ack(charstring id, BSC_ConnHdlrPars pars) |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2321 | runs on BSC_ConnHdlr { |
| 2322 | var SmsParameters spars := valueof(t_SmsPars); |
| 2323 | |
| 2324 | f_init_handler(pars); |
| 2325 | |
| 2326 | /* We need to inspect GSUP activity */ |
| 2327 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2328 | |
| 2329 | /* Perform location update */ |
| 2330 | f_perform_lu(); |
| 2331 | |
| 2332 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2333 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2334 | |
| 2335 | var template GSUP_PDU mt_forwardSM_res := tr_GSUP_MT_FORWARD_SM_RES( |
| 2336 | imsi := g_pars.imsi, |
| 2337 | /* NOTE: MSC should assign RP-MR itself */ |
| 2338 | sm_rp_mr := ? |
| 2339 | ); |
| 2340 | |
| 2341 | /* Submit a MT SMS on GSUP */ |
| 2342 | f_gsup_forwardSM_req(spars); |
| 2343 | |
| 2344 | /* Expect Paging Request and Establish DTAP / BSSAP / SCCP connection */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 2345 | f_expect_paging(); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2346 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2347 | |
| 2348 | /* Wait for MT SMS on DTAP */ |
| 2349 | f_mt_sms_expect(spars); |
| 2350 | |
| 2351 | /* Send RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 2352 | f_mt_sms_send_rp_ack(spars); |
| 2353 | alt { |
| 2354 | [] GSUP.receive(mt_forwardSM_res) { |
| 2355 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 2356 | setverdict(pass); |
| 2357 | } |
| 2358 | [] GSUP.receive { |
| 2359 | log("RX unexpected GSUP message"); |
| 2360 | setverdict(fail); |
| 2361 | mtc.stop; |
| 2362 | } |
| 2363 | } |
| 2364 | |
| 2365 | f_expect_clear(); |
| 2366 | } |
| 2367 | testcase TC_gsup_mt_sms_ack() runs on MTC_CT { |
| 2368 | var BSC_ConnHdlrPars pars; |
| 2369 | var BSC_ConnHdlr vc_conn; |
| 2370 | f_init(); |
| 2371 | pars := f_init_pars(90); |
| 2372 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2373 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_sms_ack), pars); |
| 2374 | vc_conn.done; |
| 2375 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2376 | } |
| 2377 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2378 | |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2379 | /* Test rejected MT-SMS (RP-ERROR) over GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2380 | friend function f_tc_gsup_mt_sms_err(charstring id, BSC_ConnHdlrPars pars) |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2381 | runs on BSC_ConnHdlr { |
| 2382 | var SmsParameters spars := valueof(t_SmsPars); |
| 2383 | var OCT1 sm_rp_cause := '78'O; /* dummy RP-Cause value */ |
| 2384 | |
| 2385 | f_init_handler(pars); |
| 2386 | |
| 2387 | /* We need to inspect GSUP activity */ |
| 2388 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2389 | |
| 2390 | /* Perform location update */ |
| 2391 | f_perform_lu(); |
| 2392 | |
| 2393 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2394 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2395 | |
| 2396 | var template GSUP_PDU mt_forwardSM_err := tr_GSUP_MT_FORWARD_SM_ERR( |
| 2397 | imsi := g_pars.imsi, |
| 2398 | /* NOTE: MSC should assign RP-MR itself */ |
| 2399 | sm_rp_mr := ?, |
| 2400 | sm_rp_cause := sm_rp_cause |
| 2401 | ); |
| 2402 | |
| 2403 | /* Submit a MT SMS on GSUP */ |
| 2404 | f_gsup_forwardSM_req(spars); |
| 2405 | |
| 2406 | /* Expect Paging Request and Establish DTAP / BSSAP / SCCP connection */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 2407 | f_expect_paging(); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2408 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2409 | |
| 2410 | /* Wait for MT SMS on DTAP */ |
| 2411 | f_mt_sms_expect(spars); |
| 2412 | |
| 2413 | /* Send RP-ERROR and expect MT-forwardSM-Err on GSUP */ |
| 2414 | f_mt_sms_send_rp_error(spars, oct2int(sm_rp_cause)); |
| 2415 | alt { |
| 2416 | [] GSUP.receive(mt_forwardSM_err) { |
| 2417 | log("RX MT-forwardSM-Err (RP-ERROR)"); |
| 2418 | setverdict(pass); |
| 2419 | mtc.stop; |
| 2420 | } |
| 2421 | [] GSUP.receive { |
| 2422 | log("RX unexpected GSUP message"); |
| 2423 | setverdict(fail); |
| 2424 | mtc.stop; |
| 2425 | } |
| 2426 | } |
| 2427 | |
| 2428 | f_expect_clear(); |
| 2429 | } |
| 2430 | testcase TC_gsup_mt_sms_err() runs on MTC_CT { |
| 2431 | var BSC_ConnHdlrPars pars; |
| 2432 | var BSC_ConnHdlr vc_conn; |
| 2433 | f_init(); |
| 2434 | pars := f_init_pars(91); |
| 2435 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2436 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_sms_err), pars); |
| 2437 | vc_conn.done; |
| 2438 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2439 | } |
| 2440 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2441 | |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 2442 | /* Test SM-RP-MR assignment for MT-SMS over GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2443 | friend function f_tc_gsup_mt_sms_rp_mr(charstring id, BSC_ConnHdlrPars pars) |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 2444 | runs on BSC_ConnHdlr { |
| 2445 | var SmsParameters spars1 := valueof(t_SmsPars); /* 1st SMS */ |
| 2446 | var SmsParameters spars2 := valueof(t_SmsPars); /* 2nd SMS */ |
| 2447 | |
| 2448 | f_init_handler(pars); |
| 2449 | |
| 2450 | /* We need to inspect GSUP activity */ |
| 2451 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2452 | |
| 2453 | /* Perform location update */ |
| 2454 | f_perform_lu(); |
| 2455 | |
| 2456 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2457 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 2458 | |
| 2459 | /* Submit the 1st MT SMS on GSUP */ |
| 2460 | log("TX MT-forwardSM-Req for the 1st SMS"); |
| 2461 | f_gsup_forwardSM_req(spars1); |
| 2462 | |
| 2463 | /* Expect Paging Request and Establish DTAP / BSSAP / SCCP connection */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 2464 | f_expect_paging(); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 2465 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2466 | |
| 2467 | /* Wait for 1st MT SMS on DTAP */ |
| 2468 | f_mt_sms_expect(spars1); |
| 2469 | log("RX the 1st SMS on DTAP, DTAP TID is ", spars1.tid, |
| 2470 | ", SM-RP-MR is ", spars1.rp.msg_ref); |
| 2471 | |
| 2472 | /* Submit the 2nd MT SMS on GSUP */ |
| 2473 | log("TX MT-forwardSM-Req for the 2nd SMS"); |
| 2474 | f_gsup_forwardSM_req(spars2); |
| 2475 | |
| 2476 | /* Wait for 2nd MT SMS on DTAP */ |
| 2477 | f_mt_sms_expect(spars2); |
| 2478 | log("RX the 2nd SMS on DTAP, DTAP TID is ", spars2.tid, |
| 2479 | ", SM-RP-MR is ", spars2.rp.msg_ref); |
| 2480 | |
| 2481 | /* Both transaction IDs shall be different */ |
| 2482 | if (spars1.tid == spars2.tid) { |
| 2483 | log("Both DTAP transaction IDs shall be different"); |
| 2484 | setverdict(fail); |
| 2485 | } |
| 2486 | |
| 2487 | /* Both SM-RP-MR values shall be different */ |
| 2488 | if (spars1.rp.msg_ref == spars2.rp.msg_ref) { |
| 2489 | log("Both SM-RP-MR values shall be different"); |
| 2490 | setverdict(fail); |
| 2491 | } |
| 2492 | |
| 2493 | /* Both SM-RP-MR values shall be assigned */ |
| 2494 | if (spars1.rp.msg_ref == 'FF'O) { |
| 2495 | log("Unassigned SM-RP-MR value for the 1st SMS"); |
| 2496 | setverdict(fail); |
| 2497 | } |
| 2498 | if (spars2.rp.msg_ref == 'FF'O) { |
| 2499 | log("Unassigned SM-RP-MR value for the 2nd SMS"); |
| 2500 | setverdict(fail); |
| 2501 | } |
| 2502 | |
| 2503 | /* Send the 1st RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 2504 | f_mt_sms_send_rp_ack(spars1); |
| 2505 | alt { |
| 2506 | [] GSUP.receive(tr_GSUP_MT_FORWARD_SM_RES( |
| 2507 | imsi := g_pars.imsi, |
| 2508 | sm_rp_mr := spars1.rp.msg_ref |
| 2509 | )) { |
| 2510 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 2511 | setverdict(pass); |
| 2512 | } |
| 2513 | [] GSUP.receive { |
| 2514 | log("RX unexpected GSUP message"); |
| 2515 | setverdict(fail); |
| 2516 | mtc.stop; |
| 2517 | } |
| 2518 | } |
| 2519 | |
| 2520 | /* Send the 2nd RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 2521 | f_mt_sms_send_rp_ack(spars2); |
| 2522 | alt { |
| 2523 | [] GSUP.receive(tr_GSUP_MT_FORWARD_SM_RES( |
| 2524 | imsi := g_pars.imsi, |
| 2525 | sm_rp_mr := spars2.rp.msg_ref |
| 2526 | )) { |
| 2527 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 2528 | setverdict(pass); |
| 2529 | } |
| 2530 | [] GSUP.receive { |
| 2531 | log("RX unexpected GSUP message"); |
| 2532 | setverdict(fail); |
| 2533 | mtc.stop; |
| 2534 | } |
| 2535 | } |
| 2536 | |
| 2537 | f_expect_clear(); |
| 2538 | } |
| 2539 | testcase TC_gsup_mt_sms_rp_mr() runs on MTC_CT { |
| 2540 | var BSC_ConnHdlrPars pars; |
| 2541 | var BSC_ConnHdlr vc_conn; |
| 2542 | f_init(); |
| 2543 | pars := f_init_pars(92); |
| 2544 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2545 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_sms_rp_mr), pars); |
| 2546 | vc_conn.done; |
| 2547 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2548 | } |
| 2549 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2550 | |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 2551 | /* Test SM-RP-MR assignment for MT-SMS over GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2552 | friend function f_tc_gsup_mo_mt_sms_rp_mr(charstring id, BSC_ConnHdlrPars pars) |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 2553 | runs on BSC_ConnHdlr { |
| 2554 | var SmsParameters spars_mo := valueof(t_SmsPars); /* MO SMMA */ |
| 2555 | var SmsParameters spars_mt := valueof(t_SmsPars); /* MT SMS */ |
| 2556 | |
| 2557 | f_init_handler(pars); |
| 2558 | |
| 2559 | /* We need to inspect GSUP activity */ |
| 2560 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2561 | |
| 2562 | /* Perform location update */ |
| 2563 | f_perform_lu(); |
| 2564 | |
| 2565 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2566 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 2567 | |
| 2568 | /* Send CM Service Request for MO SMMA */ |
| 2569 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2570 | |
| 2571 | /* Submit MO SMMA on DTAP */ |
| 2572 | log("Submit MO SMMA on DTAP, SM-RP-MR is '00'O"); |
| 2573 | spars_mo.rp.msg_ref := '00'O; |
| 2574 | f_mo_smma(spars_mo); |
| 2575 | |
| 2576 | /* Expect MO-forwardSM-Req for MO SMMA on GSUP */ |
| 2577 | alt { |
| 2578 | [] GSUP.receive(tr_GSUP_MO_READY_FOR_SM_REQ( |
| 2579 | imsi := g_pars.imsi, |
| 2580 | sm_rp_mr := spars_mo.rp.msg_ref, |
| 2581 | sm_alert_rsn := GSUP_SM_ALERT_RSN_TYPE_MEM_AVAIL |
| 2582 | )) { |
| 2583 | log("RX MO-ReadyForSM-Req, SM-RP-MR is '00'O"); |
| 2584 | setverdict(pass); |
| 2585 | } |
| 2586 | [] GSUP.receive { |
| 2587 | log("RX unexpected GSUP message"); |
| 2588 | setverdict(fail); |
| 2589 | mtc.stop; |
| 2590 | } |
| 2591 | } |
| 2592 | |
| 2593 | /* Submit MT SMS on GSUP */ |
| 2594 | log("TX MT-forwardSM-Req for the MT SMS"); |
| 2595 | f_gsup_forwardSM_req(spars_mt); |
| 2596 | |
| 2597 | /* Wait for MT SMS on DTAP */ |
| 2598 | f_mt_sms_expect(spars_mt); |
| 2599 | log("RX MT SMS on DTAP, DTAP TID is ", spars_mt.tid, |
| 2600 | ", SM-RP-MR is ", spars_mt.rp.msg_ref); |
| 2601 | |
| 2602 | /* Both SM-RP-MR values shall be different */ |
| 2603 | if (spars_mo.rp.msg_ref == spars_mt.rp.msg_ref) { |
| 2604 | log("Both SM-RP-MR values shall be different"); |
| 2605 | setverdict(fail); |
| 2606 | } |
| 2607 | |
| 2608 | /* SM-RP-MR value for MT SMS shall be assigned */ |
| 2609 | if (spars_mt.rp.msg_ref == 'FF'O) { |
| 2610 | log("Unassigned SM-RP-MR value for the MT SMS"); |
| 2611 | setverdict(fail); |
| 2612 | } |
| 2613 | |
| 2614 | /* Trigger RP-ACK for MO SMMA by sending MO-forwardSM-Res */ |
| 2615 | GSUP.send(valueof(ts_GSUP_MO_READY_FOR_SM_RES( |
| 2616 | imsi := g_pars.imsi, |
| 2617 | sm_rp_mr := spars_mo.rp.msg_ref))); |
| 2618 | /* Expect RP-ACK for MO SMMA on DTAP */ |
| 2619 | f_mo_sms_wait_rp_ack(spars_mo); |
| 2620 | |
| 2621 | /* Send RP-ACK for MT SMS and expect MT-forwardSM-Res on GSUP */ |
| 2622 | f_mt_sms_send_rp_ack(spars_mt); |
| 2623 | alt { |
| 2624 | [] GSUP.receive(tr_GSUP_MT_FORWARD_SM_RES( |
| 2625 | imsi := g_pars.imsi, |
| 2626 | sm_rp_mr := spars_mt.rp.msg_ref |
| 2627 | )) { |
| 2628 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 2629 | setverdict(pass); |
| 2630 | } |
| 2631 | [] GSUP.receive { |
| 2632 | log("RX unexpected GSUP message"); |
| 2633 | setverdict(fail); |
| 2634 | mtc.stop; |
| 2635 | } |
| 2636 | } |
| 2637 | |
| 2638 | f_expect_clear(); |
| 2639 | } |
| 2640 | testcase TC_gsup_mo_mt_sms_rp_mr() runs on MTC_CT { |
| 2641 | var BSC_ConnHdlrPars pars; |
| 2642 | var BSC_ConnHdlr vc_conn; |
| 2643 | f_init(); |
| 2644 | pars := f_init_pars(93); |
| 2645 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2646 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mo_mt_sms_rp_mr), pars); |
| 2647 | vc_conn.done; |
| 2648 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2649 | } |
| 2650 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2651 | |
Vadim Yanitskiy | 1cd11a0 | 2018-12-03 02:43:35 +0700 | [diff] [blame] | 2652 | /* Test multi-part MT-SMS over GSUP */ |
| 2653 | private function f_tc_gsup_mt_multi_part_sms(charstring id, BSC_ConnHdlrPars pars) |
| 2654 | runs on BSC_ConnHdlr { |
| 2655 | var SmsParameters spars := valueof(t_SmsPars); |
| 2656 | |
| 2657 | f_init_handler(pars); |
| 2658 | |
| 2659 | /* We need to inspect GSUP activity */ |
| 2660 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2661 | |
| 2662 | /* Perform location update */ |
| 2663 | f_perform_lu(); |
| 2664 | |
| 2665 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2666 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 1cd11a0 | 2018-12-03 02:43:35 +0700 | [diff] [blame] | 2667 | |
| 2668 | var template GSUP_PDU mt_forwardSM_res := tr_GSUP_MT_FORWARD_SM_RES( |
| 2669 | imsi := g_pars.imsi, |
| 2670 | /* NOTE: MSC should assign RP-MR itself */ |
| 2671 | sm_rp_mr := ? |
| 2672 | ); |
| 2673 | |
| 2674 | /* Send 4 messages (NOTE: SM-RP-UI remains unchanged) */ |
| 2675 | for (var integer i := 3; i >= 0; i := i-1) { |
| 2676 | /* Submit a MT SMS on GSUP (MMS is decremented) */ |
| 2677 | f_gsup_forwardSM_req(spars, int2oct(i, 1)); |
| 2678 | |
| 2679 | /* Expect Paging Request and Establish connection */ |
| 2680 | if (i == 3) { /* ... only once! */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2681 | f_expect_paging(); |
Vadim Yanitskiy | 1cd11a0 | 2018-12-03 02:43:35 +0700 | [diff] [blame] | 2682 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2683 | } |
| 2684 | |
| 2685 | /* Wait for MT SMS on DTAP */ |
| 2686 | f_mt_sms_expect(spars); |
| 2687 | |
| 2688 | /* Send RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 2689 | f_mt_sms_send_rp_ack(spars); |
| 2690 | alt { |
| 2691 | [] GSUP.receive(mt_forwardSM_res) { |
| 2692 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 2693 | setverdict(pass); |
| 2694 | } |
| 2695 | [] GSUP.receive { |
| 2696 | log("RX unexpected GSUP message"); |
| 2697 | setverdict(fail); |
| 2698 | mtc.stop; |
| 2699 | } |
| 2700 | } |
| 2701 | |
| 2702 | /* Keep some 'distance' between transmissions */ |
| 2703 | f_sleep(1.5); |
| 2704 | } |
| 2705 | |
| 2706 | f_expect_clear(); |
| 2707 | } |
| 2708 | testcase TC_gsup_mt_multi_part_sms() runs on MTC_CT { |
| 2709 | var BSC_ConnHdlrPars pars; |
| 2710 | var BSC_ConnHdlr vc_conn; |
| 2711 | f_init(); |
| 2712 | pars := f_init_pars(91); |
| 2713 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2714 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_multi_part_sms), pars); |
| 2715 | vc_conn.done; |
| 2716 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2717 | } |
| 2718 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2719 | /* convert GSM L3 TON to SMPP_TON enum */ |
| 2720 | function f_sm_ton_from_gsm(BIT3 ton) return SMPP_TON { |
| 2721 | select (ton) { |
| 2722 | case ('000'B) { return unknown; } |
| 2723 | case ('001'B) { return international; } |
| 2724 | case ('010'B) { return national; } |
| 2725 | case ('011'B) { return network_specific; } |
| 2726 | case ('100'B) { return subscriber_number; } |
| 2727 | case ('101'B) { return alphanumeric; } |
| 2728 | case ('110'B) { return abbreviated; } |
| 2729 | } |
| 2730 | setverdict(fail, "Unknown TON ", ton); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2731 | mtc.stop; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2732 | } |
| 2733 | /* convert GSM L3 NPI to SMPP_NPI enum */ |
| 2734 | function f_sm_npi_from_gsm(BIT4 npi) return SMPP_NPI { |
| 2735 | select (npi) { |
| 2736 | case ('0000'B) { return unknown; } |
| 2737 | case ('0001'B) { return isdn; } |
| 2738 | case ('0011'B) { return data; } |
| 2739 | case ('0100'B) { return telex; } |
| 2740 | case ('0110'B) { return land_mobile; } |
| 2741 | case ('1000'B) { return national; } |
| 2742 | case ('1001'B) { return private_; } |
| 2743 | case ('1010'B) { return ermes; } |
| 2744 | } |
| 2745 | setverdict(fail, "Unknown NPI ", npi); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2746 | mtc.stop; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2747 | } |
| 2748 | |
| 2749 | /* build a SMPP_SM from SmsParameters */ |
| 2750 | function f_mt_sm_from_spars(SmsParameters spars) |
| 2751 | runs on BSC_ConnHdlr return SMPP_SM { |
| 2752 | var SMPP_SM sm := { |
| 2753 | service_type := "CMT", |
| 2754 | source_addr_ton := f_sm_ton_from_gsm(spars.tp.da.tP_DA_NoPad.tP_TypeOfNumber), |
| 2755 | source_addr_npi := f_sm_npi_from_gsm(spars.tp.da.tP_DA_NoPad.tP_NumberingPlanID), |
| 2756 | source_addr := hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue), |
| 2757 | dest_addr_ton := international, |
| 2758 | dest_addr_npi := isdn, |
| 2759 | destination_addr := hex2str(g_pars.msisdn), |
| 2760 | esm_class := '00000001'B, |
| 2761 | protocol_id := 0, |
| 2762 | priority_flag := 0, |
| 2763 | schedule_delivery_time := "", |
| 2764 | validity_period := "", |
| 2765 | registered_delivery := '00000000'B, |
| 2766 | replace_if_present := 0, |
| 2767 | data_coding := '00000001'B, |
| 2768 | sm_default_msg_id := 0, |
| 2769 | sm_length := spars.tp.udl, |
| 2770 | short_message := spars.tp.ud, |
| 2771 | opt_pars := {} |
| 2772 | }; |
| 2773 | return sm; |
| 2774 | } |
| 2775 | |
| 2776 | /* helper function to encode SMS from 'spars', send it via SMPP to MSC; receive it on MS side */ |
| 2777 | private function f_smpp_mt_sms(SmsParameters spars, boolean trans_mode) runs on BSC_ConnHdlr { |
| 2778 | var SMPP_SM sm := f_mt_sm_from_spars(spars); |
| 2779 | if (trans_mode) { |
| 2780 | sm.esm_class := '00000010'B; |
| 2781 | } |
| 2782 | |
| 2783 | /* actually cause MSC to send a SMS via SUBMIT-SM from SMPP side */ |
| 2784 | SMPP.send(ts_SMPP_SUBMIT_SM(sm)); |
| 2785 | if (not match(sm.esm_class, tr_ESM_CLASS_TRANSACTION)) { |
| 2786 | /* if we're not in SMPP transaction mode, we expect the SMPP-level ACK |
| 2787 | * before we expect the SMS delivery on the BSC/radio side */ |
| 2788 | SMPP.receive(tr_SMPP(c_SMPP_command_id_submit_sm_resp, ESME_ROK)); |
| 2789 | } |
| 2790 | |
| 2791 | /* MSC->BSC: expect PAGING from MSC */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 2792 | f_expect_paging(); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2793 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 2794 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2795 | SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)); |
| 2796 | |
| 2797 | f_mt_sms(spars); |
| 2798 | |
| 2799 | if (match(sm.esm_class, tr_ESM_CLASS_TRANSACTION)) { |
| 2800 | SMPP.receive(tr_SMPP(c_SMPP_command_id_submit_sm_resp, ESME_ROK)); |
| 2801 | } |
| 2802 | f_expect_clear(); |
| 2803 | } |
| 2804 | |
| 2805 | /* mobile terminated SMS, from SMPP to BSC/BTS/MS */ |
| 2806 | private function f_tc_smpp_mt_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2807 | f_init_handler(pars); |
| 2808 | |
| 2809 | /* Perform location update so IMSI is known + registered in MSC/VLR */ |
| 2810 | f_perform_lu(); |
| 2811 | SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)); |
| 2812 | |
| 2813 | /* register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2814 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2815 | |
| 2816 | var SmsParameters spars := valueof(t_SmsPars); |
| 2817 | /* TODO: test with more intelligent user data; test different coding schemes */ |
| 2818 | spars.tp.ud := '00'O; |
| 2819 | spars.tp.udl := 1; |
| 2820 | |
| 2821 | /* first test the non-transaction store+forward mode */ |
| 2822 | f_smpp_mt_sms(spars, false); |
| 2823 | |
| 2824 | /* then test the transaction mode */ |
| 2825 | f_smpp_mt_sms(spars, true); |
| 2826 | } |
| 2827 | testcase TC_smpp_mt_sms() runs on MTC_CT { |
| 2828 | var BSC_ConnHdlr vc_conn; |
| 2829 | f_init(); |
| 2830 | vc_conn := f_start_handler(refers(f_tc_smpp_mt_sms), 45); |
| 2831 | vc_conn.done; |
| 2832 | } |
| 2833 | |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2834 | /*********************************************************************** |
| 2835 | * USSD Testing |
| 2836 | ***********************************************************************/ |
| 2837 | |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 2838 | private altstep as_unexp_gsup_or_bssap_msg() |
| 2839 | runs on BSC_ConnHdlr { |
| 2840 | [] GSUP.receive { |
| 2841 | setverdict(fail, "Unknown/unexpected GSUP received"); |
| 2842 | self.stop; |
| 2843 | } |
| 2844 | [] BSSAP.receive { |
| 2845 | setverdict(fail, "Unknown/unexpected BSSAP message received"); |
| 2846 | self.stop; |
| 2847 | } |
| 2848 | } |
| 2849 | |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 2850 | private function f_expect_gsup_msg(template GSUP_PDU msg, |
| 2851 | float T_val := 2.0) |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 2852 | runs on BSC_ConnHdlr return GSUP_PDU { |
| 2853 | var GSUP_PDU gsup_msg_complete; |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 2854 | timer T := T_val; |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 2855 | |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 2856 | T.start; |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 2857 | alt { |
| 2858 | [] GSUP.receive(msg) -> value gsup_msg_complete { |
| 2859 | setverdict(pass); |
| 2860 | } |
| 2861 | /* We don't expect anything else */ |
| 2862 | [] as_unexp_gsup_or_bssap_msg(); |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 2863 | [] T.timeout { |
| 2864 | setverdict(fail, "Timeout waiting for GSUP message: ", msg); |
| 2865 | } |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 2866 | } |
| 2867 | |
| 2868 | return gsup_msg_complete; |
| 2869 | } |
| 2870 | |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 2871 | private function f_expect_mt_dtap_msg(template PDU_ML3_NW_MS msg, |
| 2872 | float T_val := 2.0) |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 2873 | runs on BSC_ConnHdlr return PDU_ML3_NW_MS { |
| 2874 | var PDU_DTAP_MT bssap_msg_complete; |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 2875 | timer T := T_val; |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 2876 | |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 2877 | T.start; |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 2878 | alt { |
| 2879 | [] BSSAP.receive(tr_PDU_DTAP_MT(msg)) -> value bssap_msg_complete { |
| 2880 | setverdict(pass); |
| 2881 | } |
| 2882 | /* We don't expect anything else */ |
| 2883 | [] as_unexp_gsup_or_bssap_msg(); |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 2884 | [] T.timeout { |
| 2885 | setverdict(fail, "Timeout waiting for BSSAP message: ", msg); |
| 2886 | } |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 2887 | } |
| 2888 | |
| 2889 | return bssap_msg_complete.dtap; |
| 2890 | } |
| 2891 | |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 2892 | /* LU followed by MO USSD request */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2893 | friend function f_tc_lu_and_mo_ussd_single_request(charstring id, BSC_ConnHdlrPars pars) |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2894 | runs on BSC_ConnHdlr { |
| 2895 | f_init_handler(pars); |
| 2896 | |
| 2897 | /* Perform location update */ |
| 2898 | f_perform_lu(); |
| 2899 | |
| 2900 | /* Send CM Service Request for SS/USSD */ |
| 2901 | f_establish_fully(EST_TYPE_SS_ACT); |
| 2902 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 2903 | /* We need to inspect GSUP activity */ |
| 2904 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2905 | |
| 2906 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 2907 | invoke_id := 5, /* Phone may not start from 0 or 1 */ |
| 2908 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 2909 | ussd_string := "*#100#" |
| 2910 | ); |
| 2911 | |
| 2912 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 2913 | invoke_id := 5, /* InvokeID shall be the same for both REQ and RSP */ |
| 2914 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 2915 | ussd_string := "Your extension is " & hex2str(g_pars.msisdn) & "\r" |
| 2916 | ) |
| 2917 | |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2918 | /* Compose a new SS/REGISTER message with request */ |
| 2919 | var template (value) PDU_ML3_MS_NW ussd_req := ts_ML3_MO_SS_REGISTER( |
| 2920 | tid := 1, /* We just need a single transaction */ |
| 2921 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 2922 | facility := valueof(facility_req) |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2923 | ); |
| 2924 | |
| 2925 | /* Compose SS/RELEASE_COMPLETE template with expected response */ |
| 2926 | var template PDU_ML3_NW_MS ussd_rsp := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 2927 | tid := 1, /* Response should arrive within the same transaction */ |
| 2928 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 2929 | facility := valueof(facility_rsp) |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2930 | ); |
| 2931 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 2932 | /* Compose expected MSC -> HLR message */ |
| 2933 | var template GSUP_PDU gsup_req := tr_GSUP_PROC_SS_REQ( |
| 2934 | imsi := g_pars.imsi, |
| 2935 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 2936 | ss := valueof(facility_req) |
| 2937 | ); |
| 2938 | |
| 2939 | /* To be used for sending response with correct session ID */ |
| 2940 | var GSUP_PDU gsup_req_complete; |
| 2941 | |
| 2942 | /* Request own number */ |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2943 | BSSAP.send(ts_PDU_DTAP_MO(ussd_req)); |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 2944 | /* Expect GSUP message containing the SS payload */ |
| 2945 | gsup_req_complete := f_expect_gsup_msg(gsup_req); |
| 2946 | |
| 2947 | /* Compose the response from HLR using received session ID */ |
| 2948 | var template GSUP_PDU gsup_rsp := ts_GSUP_PROC_SS_REQ( |
| 2949 | imsi := g_pars.imsi, |
| 2950 | sid := gsup_req_complete.ies[1].val.session_id, |
| 2951 | state := OSMO_GSUP_SESSION_STATE_END, |
| 2952 | ss := valueof(facility_rsp) |
| 2953 | ); |
| 2954 | |
| 2955 | /* Finally, HLR terminates the session */ |
| 2956 | GSUP.send(gsup_rsp); |
| 2957 | /* Expect RELEASE_COMPLETE message with the response */ |
| 2958 | f_expect_mt_dtap_msg(ussd_rsp); |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2959 | |
| 2960 | f_expect_clear(); |
| 2961 | } |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 2962 | testcase TC_lu_and_mo_ussd_single_request() runs on MTC_CT { |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2963 | var BSC_ConnHdlr vc_conn; |
| 2964 | f_init(); |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 2965 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_ussd_single_request), 46); |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2966 | vc_conn.done; |
| 2967 | } |
| 2968 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2969 | |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 2970 | /* LU followed by MT USSD notification */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2971 | friend function f_tc_lu_and_mt_ussd_notification(charstring id, BSC_ConnHdlrPars pars) |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 2972 | runs on BSC_ConnHdlr { |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 2973 | timer T := 5.0; |
| 2974 | |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 2975 | f_init_handler(pars); |
| 2976 | |
| 2977 | /* Perform location update */ |
| 2978 | f_perform_lu(); |
| 2979 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 2980 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 2981 | |
| 2982 | /* We need to inspect GSUP activity */ |
| 2983 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2984 | |
| 2985 | /* Facility IE with network-originated USSD notification */ |
| 2986 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 2987 | op_code := SS_OP_CODE_USS_NOTIFY, |
| 2988 | ussd_string := "Mahlzeit!" |
| 2989 | ); |
| 2990 | |
| 2991 | /* Facility IE with acknowledgment to the USSD notification */ |
| 2992 | var template OCTN facility_rsp := enc_SS_FacilityInformation( |
| 2993 | /* In case of USSD notification, Return Result is empty */ |
| 2994 | valueof(ts_SS_USSD_FACILITY_RETURN_RESULT_EMPTY()) |
| 2995 | ); |
| 2996 | |
| 2997 | /* Compose a new MT SS/REGISTER message with USSD notification */ |
| 2998 | var template PDU_ML3_NW_MS ussd_ntf := tr_ML3_MT_SS_REGISTER( |
| 2999 | tid := 0, /* FIXME: most likely, it should be 0 */ |
| 3000 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3001 | facility := valueof(facility_req) |
| 3002 | ); |
| 3003 | |
| 3004 | /* Compose HLR -> MSC GSUP message */ |
| 3005 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 3006 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3007 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3008 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3009 | ss := valueof(facility_req) |
| 3010 | ); |
| 3011 | |
| 3012 | /* Send it to MSC and expect Paging Request */ |
| 3013 | GSUP.send(gsup_req); |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3014 | T.start; |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3015 | alt { |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3016 | [pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 3017 | setverdict(pass); |
| 3018 | } |
Harald Welte | 62113fc | 2019-05-09 13:04:02 +0200 | [diff] [blame] | 3019 | [not pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) { |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3020 | setverdict(pass); |
| 3021 | } |
| 3022 | /* We don't expect anything else */ |
| 3023 | [] as_unexp_gsup_or_bssap_msg(); |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3024 | [] T.timeout { |
| 3025 | setverdict(fail, "Timeout waiting for Paging Request"); |
| 3026 | } |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3027 | } |
| 3028 | |
| 3029 | /* Send Paging Response and expect USSD notification */ |
| 3030 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 3031 | /* Expect MT REGISTER message with USSD notification */ |
| 3032 | f_expect_mt_dtap_msg(ussd_ntf); |
| 3033 | |
| 3034 | /* Compose a new MO SS/FACILITY message with empty response */ |
| 3035 | var template (value) PDU_ML3_MS_NW ussd_rsp := ts_ML3_MO_SS_FACILITY( |
| 3036 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3037 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3038 | facility := valueof(facility_rsp) |
| 3039 | ); |
| 3040 | |
| 3041 | /* Compose expected MSC -> HLR GSUP message */ |
| 3042 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_REQ( |
| 3043 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3044 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3045 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 3046 | ss := valueof(facility_rsp) |
| 3047 | ); |
| 3048 | |
| 3049 | /* MS sends response to the notification */ |
| 3050 | BSSAP.send(ts_PDU_DTAP_MO(ussd_rsp)); |
| 3051 | /* Expect GSUP message containing the SS payload */ |
| 3052 | f_expect_gsup_msg(gsup_rsp); |
| 3053 | |
| 3054 | /* Compose expected MT SS/RELEASE COMPLETE message */ |
| 3055 | var template PDU_ML3_NW_MS ussd_term := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3056 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3057 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3058 | facility := omit |
| 3059 | ); |
| 3060 | |
| 3061 | /* Compose MSC -> HLR GSUP message */ |
| 3062 | var template GSUP_PDU gsup_term := ts_GSUP_PROC_SS_REQ( |
| 3063 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3064 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3065 | state := OSMO_GSUP_SESSION_STATE_END |
| 3066 | ); |
| 3067 | |
| 3068 | /* Finally, HLR terminates the session */ |
| 3069 | GSUP.send(gsup_term) |
| 3070 | /* Expect MT RELEASE COMPLETE without Facility IE */ |
| 3071 | f_expect_mt_dtap_msg(ussd_term); |
| 3072 | |
| 3073 | f_expect_clear(); |
| 3074 | } |
| 3075 | testcase TC_lu_and_mt_ussd_notification() runs on MTC_CT { |
| 3076 | var BSC_ConnHdlr vc_conn; |
| 3077 | f_init(); |
| 3078 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_ussd_notification), 47); |
| 3079 | vc_conn.done; |
| 3080 | } |
| 3081 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3082 | |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3083 | /* LU followed by MT call and MO USSD request during this call */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3084 | friend function f_tc_lu_and_mo_ussd_during_mt_call(charstring id, BSC_ConnHdlrPars pars) |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3085 | runs on BSC_ConnHdlr { |
| 3086 | f_init_handler(pars); |
| 3087 | |
| 3088 | /* Call parameters taken from f_tc_lu_and_mt_call */ |
| 3089 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3090 | |
| 3091 | /* Perform location update */ |
| 3092 | f_perform_lu(); |
| 3093 | |
| 3094 | /* Establish a MT call */ |
| 3095 | f_mt_call_establish(cpars); |
| 3096 | |
| 3097 | /* Hold the call for some time */ |
| 3098 | f_sleep(1.0); |
| 3099 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3100 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 3101 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3102 | ussd_string := "*#100#" |
| 3103 | ); |
| 3104 | |
| 3105 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 3106 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3107 | ussd_string := "Your extension is " & hex2str(g_pars.msisdn) & "\r" |
| 3108 | ) |
| 3109 | |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3110 | /* Compose a new SS/REGISTER message with request */ |
| 3111 | var template (value) PDU_ML3_MS_NW ussd_req := ts_ML3_MO_SS_REGISTER( |
| 3112 | tid := 1, /* We just need a single transaction */ |
| 3113 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3114 | facility := valueof(facility_req) |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3115 | ); |
| 3116 | |
| 3117 | /* Compose SS/RELEASE_COMPLETE template with expected response */ |
| 3118 | var template PDU_ML3_NW_MS ussd_rsp := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3119 | tid := 1, /* Response should arrive within the same transaction */ |
| 3120 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3121 | facility := valueof(facility_rsp) |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3122 | ); |
| 3123 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3124 | /* Compose expected MSC -> HLR message */ |
| 3125 | var template GSUP_PDU gsup_req := tr_GSUP_PROC_SS_REQ( |
| 3126 | imsi := g_pars.imsi, |
| 3127 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3128 | ss := valueof(facility_req) |
| 3129 | ); |
| 3130 | |
| 3131 | /* To be used for sending response with correct session ID */ |
| 3132 | var GSUP_PDU gsup_req_complete; |
| 3133 | |
| 3134 | /* Request own number */ |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3135 | BSSAP.send(ts_PDU_DTAP_MO(ussd_req)); |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3136 | /* Expect GSUP message containing the SS payload */ |
| 3137 | gsup_req_complete := f_expect_gsup_msg(gsup_req); |
| 3138 | |
| 3139 | /* Compose the response from HLR using received session ID */ |
| 3140 | var template GSUP_PDU gsup_rsp := ts_GSUP_PROC_SS_REQ( |
| 3141 | imsi := g_pars.imsi, |
| 3142 | sid := gsup_req_complete.ies[1].val.session_id, |
| 3143 | state := OSMO_GSUP_SESSION_STATE_END, |
| 3144 | ss := valueof(facility_rsp) |
| 3145 | ); |
| 3146 | |
| 3147 | /* Finally, HLR terminates the session */ |
| 3148 | GSUP.send(gsup_rsp); |
| 3149 | /* Expect RELEASE_COMPLETE message with the response */ |
| 3150 | f_expect_mt_dtap_msg(ussd_rsp); |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3151 | |
| 3152 | /* Hold the call for some time */ |
| 3153 | f_sleep(1.0); |
| 3154 | |
| 3155 | /* Release the call (does Clear Complete itself) */ |
| 3156 | f_call_hangup(cpars, true); |
| 3157 | } |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3158 | testcase TC_lu_and_mo_ussd_during_mt_call() runs on MTC_CT { |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3159 | var BSC_ConnHdlr vc_conn; |
| 3160 | f_init(); |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3161 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_ussd_during_mt_call), 48); |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3162 | vc_conn.done; |
| 3163 | } |
| 3164 | |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 3165 | /* BSSMAP Clear Request in the middle of a call, see OS#3062 */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3166 | friend function f_tc_mo_cc_bssmap_clear(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 3167 | f_init_handler(pars); |
| 3168 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 3169 | cpars.ran_clear_when_alerting := true; |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 3170 | |
| 3171 | f_perform_lu(); |
| 3172 | |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 3173 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 3174 | f_mo_call_establish(cpars); |
| 3175 | f_expect_clear() |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 3176 | deactivate(ccrel); |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 3177 | |
| 3178 | f_sleep(1.0); |
| 3179 | } |
| 3180 | testcase TC_mo_cc_bssmap_clear() runs on MTC_CT { |
| 3181 | var BSC_ConnHdlr vc_conn; |
| 3182 | f_init(); |
| 3183 | |
| 3184 | vc_conn := f_start_handler(refers(f_tc_mo_cc_bssmap_clear), 43); |
| 3185 | vc_conn.done; |
| 3186 | } |
| 3187 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3188 | |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3189 | /* LU followed by MT call and MT USSD request during this call */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3190 | friend function f_tc_lu_and_mt_ussd_during_mt_call(charstring id, BSC_ConnHdlrPars pars) |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3191 | runs on BSC_ConnHdlr { |
| 3192 | f_init_handler(pars); |
| 3193 | |
| 3194 | /* Call parameters taken from f_tc_lu_and_mt_call */ |
| 3195 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3196 | |
| 3197 | /* Perform location update */ |
| 3198 | f_perform_lu(); |
| 3199 | |
| 3200 | /* Establish a MT call */ |
| 3201 | f_mt_call_establish(cpars); |
| 3202 | |
| 3203 | /* Hold the call for some time */ |
| 3204 | f_sleep(1.0); |
| 3205 | |
| 3206 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 3207 | op_code := SS_OP_CODE_USS_REQUEST, |
| 3208 | ussd_string := "Please type anything..." |
| 3209 | ); |
| 3210 | |
| 3211 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 3212 | op_code := SS_OP_CODE_USS_REQUEST, |
| 3213 | ussd_string := "Nope." |
| 3214 | ) |
| 3215 | |
| 3216 | /* Compose MT SS/REGISTER message with network-originated request */ |
| 3217 | var template (value) PDU_ML3_NW_MS ussd_req := ts_ML3_MT_SS_REGISTER( |
| 3218 | tid := 0, /* FIXME: most likely, it should be 0 */ |
| 3219 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3220 | facility := valueof(facility_req) |
| 3221 | ); |
| 3222 | |
| 3223 | /* Compose HLR -> MSC GSUP message */ |
| 3224 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 3225 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3226 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3227 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3228 | ss := valueof(facility_req) |
| 3229 | ); |
| 3230 | |
| 3231 | /* Send it to MSC */ |
| 3232 | GSUP.send(gsup_req); |
| 3233 | /* Expect MT REGISTER message with USSD request */ |
| 3234 | f_expect_mt_dtap_msg(ussd_req); |
| 3235 | |
| 3236 | /* Compose a new MO SS/FACILITY message with response */ |
| 3237 | var template (value) PDU_ML3_MS_NW ussd_rsp := ts_ML3_MO_SS_FACILITY( |
| 3238 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3239 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3240 | facility := valueof(facility_rsp) |
| 3241 | ); |
| 3242 | |
| 3243 | /* Compose expected MSC -> HLR GSUP message */ |
| 3244 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_REQ( |
| 3245 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3246 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3247 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 3248 | ss := valueof(facility_rsp) |
| 3249 | ); |
| 3250 | |
| 3251 | /* MS sends response */ |
| 3252 | BSSAP.send(ts_PDU_DTAP_MO(ussd_rsp)); |
| 3253 | f_expect_gsup_msg(gsup_rsp); |
| 3254 | |
| 3255 | /* Compose expected MT SS/RELEASE COMPLETE message */ |
| 3256 | var template PDU_ML3_NW_MS ussd_term := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3257 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3258 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3259 | facility := omit |
| 3260 | ); |
| 3261 | |
| 3262 | /* Compose MSC -> HLR GSUP message */ |
| 3263 | var template GSUP_PDU gsup_term := ts_GSUP_PROC_SS_REQ( |
| 3264 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3265 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3266 | state := OSMO_GSUP_SESSION_STATE_END |
| 3267 | ); |
| 3268 | |
| 3269 | /* Finally, HLR terminates the session */ |
| 3270 | GSUP.send(gsup_term); |
| 3271 | /* Expect MT RELEASE COMPLETE without Facility IE */ |
| 3272 | f_expect_mt_dtap_msg(ussd_term); |
| 3273 | |
| 3274 | /* Hold the call for some time */ |
| 3275 | f_sleep(1.0); |
| 3276 | |
| 3277 | /* Release the call (does Clear Complete itself) */ |
| 3278 | f_call_hangup(cpars, true); |
| 3279 | } |
| 3280 | testcase TC_lu_and_mt_ussd_during_mt_call() runs on MTC_CT { |
| 3281 | var BSC_ConnHdlr vc_conn; |
| 3282 | f_init(); |
| 3283 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_ussd_during_mt_call), 49); |
| 3284 | vc_conn.done; |
| 3285 | } |
| 3286 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3287 | |
Vadim Yanitskiy | 2daf52d | 2018-06-21 04:19:58 +0700 | [diff] [blame] | 3288 | /* LU followed by MO USSD request and MO Release during transaction */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3289 | friend function f_tc_lu_and_mo_ussd_mo_release(charstring id, BSC_ConnHdlrPars pars) |
Vadim Yanitskiy | 2daf52d | 2018-06-21 04:19:58 +0700 | [diff] [blame] | 3290 | runs on BSC_ConnHdlr { |
| 3291 | f_init_handler(pars); |
| 3292 | |
| 3293 | /* Perform location update */ |
| 3294 | f_perform_lu(); |
| 3295 | |
| 3296 | /* Send CM Service Request for SS/USSD */ |
| 3297 | f_establish_fully(EST_TYPE_SS_ACT); |
| 3298 | |
| 3299 | /* We need to inspect GSUP activity */ |
| 3300 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3301 | |
| 3302 | var template OCTN facility_ms_req := f_USSD_FACILITY_IE_INVOKE( |
| 3303 | invoke_id := 1, /* Initial request */ |
| 3304 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3305 | ussd_string := "*6766*266#" |
| 3306 | ); |
| 3307 | |
| 3308 | var template OCTN facility_net_req := f_USSD_FACILITY_IE_INVOKE( |
| 3309 | invoke_id := 2, /* Counter request */ |
| 3310 | op_code := SS_OP_CODE_USS_REQUEST, |
| 3311 | ussd_string := "Password?!?" |
| 3312 | ) |
| 3313 | |
| 3314 | /* Compose MO SS/REGISTER message with request */ |
| 3315 | var template (value) PDU_ML3_MS_NW ussd_ms_req := ts_ML3_MO_SS_REGISTER( |
| 3316 | tid := 1, /* We just need a single transaction */ |
| 3317 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3318 | facility := valueof(facility_ms_req) |
| 3319 | ); |
| 3320 | |
| 3321 | /* Compose expected MSC -> HLR message */ |
| 3322 | var template GSUP_PDU gsup_ms_req := tr_GSUP_PROC_SS_REQ( |
| 3323 | imsi := g_pars.imsi, |
| 3324 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3325 | ss := valueof(facility_ms_req) |
| 3326 | ); |
| 3327 | |
| 3328 | /* To be used for sending response with correct session ID */ |
| 3329 | var GSUP_PDU gsup_ms_req_complete; |
| 3330 | |
| 3331 | /* Initiate a new transaction */ |
| 3332 | BSSAP.send(ts_PDU_DTAP_MO(ussd_ms_req)); |
| 3333 | /* Expect GSUP request with original Facility IE */ |
| 3334 | gsup_ms_req_complete := f_expect_gsup_msg(gsup_ms_req); |
| 3335 | |
| 3336 | /* Compose the response from HLR using received session ID */ |
| 3337 | var template (value) GSUP_PDU gsup_net_req := ts_GSUP_PROC_SS_REQ( |
| 3338 | imsi := g_pars.imsi, |
| 3339 | sid := gsup_ms_req_complete.ies[1].val.session_id, |
| 3340 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 3341 | ss := valueof(facility_net_req) |
| 3342 | ); |
| 3343 | |
| 3344 | /* Compose expected MT SS/FACILITY template with counter request */ |
| 3345 | var template PDU_ML3_NW_MS ussd_net_req := tr_ML3_MT_SS_FACILITY( |
| 3346 | tid := 1, /* Response should arrive within the same transaction */ |
| 3347 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3348 | facility := valueof(facility_net_req) |
| 3349 | ); |
| 3350 | |
| 3351 | /* Send response over GSUP */ |
| 3352 | GSUP.send(gsup_net_req); |
| 3353 | /* Expect MT SS/FACILITY message with counter request */ |
| 3354 | f_expect_mt_dtap_msg(ussd_net_req); |
| 3355 | |
| 3356 | /* Compose MO SS/RELEASE COMPLETE */ |
| 3357 | var template (value) PDU_ML3_MS_NW ussd_abort := ts_ML3_MO_SS_RELEASE_COMPLETE( |
| 3358 | tid := 1, /* Response should arrive within the same transaction */ |
| 3359 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3360 | facility := omit |
| 3361 | /* TODO: cause? */ |
| 3362 | ); |
| 3363 | |
| 3364 | /* Compose expected HLR -> MSC abort message */ |
| 3365 | var template GSUP_PDU gsup_abort := tr_GSUP_PROC_SS_REQ( |
| 3366 | imsi := g_pars.imsi, |
| 3367 | sid := gsup_ms_req_complete.ies[1].val.session_id, |
| 3368 | state := OSMO_GSUP_SESSION_STATE_END |
| 3369 | ); |
| 3370 | |
| 3371 | /* Abort transaction */ |
| 3372 | BSSAP.send(ts_PDU_DTAP_MO(ussd_abort)); |
| 3373 | /* Expect GSUP message indicating abort */ |
| 3374 | f_expect_gsup_msg(gsup_abort); |
| 3375 | |
| 3376 | f_expect_clear(); |
| 3377 | } |
| 3378 | testcase TC_lu_and_mo_ussd_mo_release() runs on MTC_CT { |
| 3379 | var BSC_ConnHdlr vc_conn; |
| 3380 | f_init(); |
| 3381 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_ussd_mo_release), 50); |
| 3382 | vc_conn.done; |
| 3383 | } |
| 3384 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3385 | |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 3386 | /* LU followed by MO USSD request and MT Release due to timeout */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3387 | friend function f_tc_lu_and_ss_session_timeout(charstring id, BSC_ConnHdlrPars pars) |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 3388 | runs on BSC_ConnHdlr { |
| 3389 | f_init_handler(pars); |
| 3390 | |
| 3391 | /* Perform location update */ |
| 3392 | f_perform_lu(); |
| 3393 | |
| 3394 | /* Send CM Service Request for SS/USSD */ |
| 3395 | f_establish_fully(EST_TYPE_SS_ACT); |
| 3396 | |
| 3397 | /* We need to inspect GSUP activity */ |
| 3398 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3399 | |
| 3400 | var template OCTN facility_ms_req := f_USSD_FACILITY_IE_INVOKE( |
| 3401 | invoke_id := 1, |
| 3402 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3403 | ussd_string := "#release_me"); |
| 3404 | |
| 3405 | /* Compose MO SS/REGISTER message with request */ |
| 3406 | var template (value) PDU_ML3_MS_NW ussd_ms_req := ts_ML3_MO_SS_REGISTER( |
| 3407 | tid := 1, /* An arbitrary transaction identifier */ |
| 3408 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3409 | facility := valueof(facility_ms_req)); |
| 3410 | |
| 3411 | /* Compose expected MSC -> HLR message */ |
| 3412 | var template GSUP_PDU gsup_ms_req := tr_GSUP_PROC_SS_REQ( |
| 3413 | imsi := g_pars.imsi, |
| 3414 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3415 | ss := valueof(facility_ms_req)); |
| 3416 | |
| 3417 | /* To be used for sending response with correct session ID */ |
| 3418 | var GSUP_PDU gsup_ms_req_complete; |
| 3419 | |
| 3420 | /* Initiate a new SS transaction */ |
| 3421 | BSSAP.send(ts_PDU_DTAP_MO(ussd_ms_req)); |
| 3422 | /* Expect GSUP request with original Facility IE */ |
| 3423 | gsup_ms_req_complete := f_expect_gsup_msg(gsup_ms_req); |
| 3424 | |
| 3425 | /* Don't respond, wait for timeout */ |
| 3426 | f_sleep(3.0); |
| 3427 | |
| 3428 | var template PDU_ML3_NW_MS dtap_rel := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3429 | tid := 1, /* Should match the request's tid */ |
| 3430 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3431 | cause := *, /* TODO: expect some specific value */ |
| 3432 | facility := omit); |
| 3433 | |
| 3434 | var template GSUP_PDU gsup_rel := tr_GSUP_PROC_SS_ERR( |
| 3435 | imsi := g_pars.imsi, |
| 3436 | sid := gsup_ms_req_complete.ies[1].val.session_id, |
| 3437 | state := OSMO_GSUP_SESSION_STATE_END, |
| 3438 | cause := ?); /* TODO: expect some specific value */ |
| 3439 | |
| 3440 | /* Expect release on both interfaces */ |
| 3441 | interleave { |
| 3442 | [] BSSAP.receive(tr_PDU_DTAP_MT(dtap_rel)) { }; |
| 3443 | [] GSUP.receive(gsup_rel) { }; |
| 3444 | } |
| 3445 | |
| 3446 | f_expect_clear(); |
| 3447 | setverdict(pass); |
| 3448 | } |
| 3449 | testcase TC_lu_and_ss_session_timeout() runs on MTC_CT { |
| 3450 | var BSC_ConnHdlr vc_conn; |
| 3451 | f_init(); |
Vadim Yanitskiy | 36d28dd | 2018-12-03 02:45:45 +0700 | [diff] [blame] | 3452 | f_vty_config(MSCVTY, "msc", "ncss guard-timeout 3"); |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 3453 | vc_conn := f_start_handler(refers(f_tc_lu_and_ss_session_timeout), 51); |
| 3454 | vc_conn.done; |
Vadim Yanitskiy | 36d28dd | 2018-12-03 02:45:45 +0700 | [diff] [blame] | 3455 | f_vty_config(MSCVTY, "msc", "ncss guard-timeout 0"); |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 3456 | } |
| 3457 | |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 3458 | /* MT (network-originated) USSD for unknown subscriber */ |
| 3459 | friend function f_tc_mt_ussd_for_unknown_subscr(charstring id, BSC_ConnHdlrPars pars) |
| 3460 | runs on BSC_ConnHdlr { |
| 3461 | var hexstring imsi := '000000000000000'H; /* Some unknown IMSI */ |
| 3462 | var OCT4 sid := '20000222'O; |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 3463 | |
| 3464 | f_init_handler(pars); |
| 3465 | f_ran_register_imsi(imsi, 'FFFFFFFF'O); |
| 3466 | f_create_gsup_expect(hex2str(imsi)); |
| 3467 | |
| 3468 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 3469 | imsi := imsi, |
| 3470 | sid := sid, |
| 3471 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3472 | ss := f_rnd_octstring(23) |
| 3473 | ); |
| 3474 | |
| 3475 | /* Error with cause GMM_CAUSE_IMSI_UNKNOWN */ |
| 3476 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_ERR( |
| 3477 | imsi := imsi, |
| 3478 | sid := sid, |
| 3479 | state := OSMO_GSUP_SESSION_STATE_END, |
| 3480 | cause := 2 /* FIXME: introduce an enumerated type! */ |
| 3481 | ); |
| 3482 | |
| 3483 | /* Initiate a MT USSD notification */ |
| 3484 | GSUP.send(gsup_req); |
| 3485 | |
| 3486 | /* Expect GSUP PROC_SS_ERROR message */ |
Vadim Yanitskiy | 851798c | 2019-06-15 14:22:28 +0700 | [diff] [blame] | 3487 | f_expect_gsup_msg(gsup_rsp); |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 3488 | } |
| 3489 | testcase TC_mt_ussd_for_unknown_subscr() runs on MTC_CT { |
| 3490 | var BSC_ConnHdlr vc_conn; |
| 3491 | f_init(); |
| 3492 | vc_conn := f_start_handler(refers(f_tc_mt_ussd_for_unknown_subscr), 0); |
| 3493 | vc_conn.done; |
| 3494 | } |
| 3495 | |
Vadim Yanitskiy | c3c07d4 | 2019-06-17 23:00:44 +0700 | [diff] [blame] | 3496 | /* MO (mobile-originated) SS/USSD for unknown transaction */ |
| 3497 | friend function f_tc_mo_ussd_for_unknown_trans(charstring id, BSC_ConnHdlrPars pars) |
| 3498 | runs on BSC_ConnHdlr { |
| 3499 | f_init_handler(pars); |
| 3500 | |
Vadim Yanitskiy | 70d15bf | 2020-01-09 22:51:01 +0100 | [diff] [blame] | 3501 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | c3c07d4 | 2019-06-17 23:00:44 +0700 | [diff] [blame] | 3502 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3503 | |
| 3504 | /* Perform location update */ |
| 3505 | f_perform_lu(); |
| 3506 | |
| 3507 | /* Send CM Service Request for SS/USSD */ |
| 3508 | f_establish_fully(EST_TYPE_SS_ACT); |
| 3509 | |
| 3510 | /* GSM 04.80 FACILITY message for a non-existing transaction */ |
| 3511 | var template (value) PDU_ML3_MS_NW mo_ss_fac := ts_ML3_MO_SS_FACILITY( |
| 3512 | tid := 1, /* An arbitrary transaction identifier */ |
| 3513 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3514 | facility := f_rnd_octstring(23) /* We don't care about the Facility IE */ |
| 3515 | ); |
| 3516 | |
| 3517 | /* GSM 04.80 RELEASE COMPLETE message for a non-existing transaction */ |
| 3518 | var template (value) PDU_ML3_MS_NW mo_ss_rel := ts_ML3_MO_SS_RELEASE_COMPLETE( |
| 3519 | tid := 1, /* An arbitrary transaction identifier */ |
| 3520 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3521 | facility := f_rnd_octstring(23) /* We don't care about the Facility IE */ |
| 3522 | ); |
| 3523 | |
| 3524 | /* Expected response from the network */ |
| 3525 | var template PDU_ML3_NW_MS mt_ss_rel := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3526 | tid := 1, /* Same as in the FACILITY message */ |
| 3527 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3528 | facility := omit |
| 3529 | ); |
| 3530 | |
| 3531 | /* Send GSM 04.80 FACILITY for non-existing transaction */ |
| 3532 | BSSAP.send(ts_PDU_DTAP_MO(mo_ss_fac)); |
| 3533 | |
| 3534 | /* Expect GSM 04.80 RELEASE COMPLETE message */ |
| 3535 | f_expect_mt_dtap_msg(mt_ss_rel); |
| 3536 | f_expect_clear(); |
| 3537 | |
| 3538 | /* Send another CM Service Request for SS/USSD */ |
| 3539 | f_establish_fully(EST_TYPE_SS_ACT); |
| 3540 | |
| 3541 | /* Send GSM 04.80 RELEASE COMPLETE for non-existing transaction */ |
| 3542 | BSSAP.send(ts_PDU_DTAP_MO(mo_ss_rel)); |
| 3543 | |
| 3544 | /* Expect GSM 04.80 RELEASE COMPLETE message */ |
| 3545 | f_expect_mt_dtap_msg(mt_ss_rel); |
| 3546 | f_expect_clear(); |
| 3547 | } |
| 3548 | testcase TC_mo_ussd_for_unknown_trans() runs on MTC_CT { |
| 3549 | var BSC_ConnHdlr vc_conn; |
| 3550 | f_init(); |
| 3551 | vc_conn := f_start_handler(refers(f_tc_mo_ussd_for_unknown_trans), 111); |
| 3552 | vc_conn.done; |
| 3553 | } |
| 3554 | |
Vadim Yanitskiy | d612d28 | 2019-06-15 14:46:03 +0700 | [diff] [blame] | 3555 | /* MT (network-originated) USSD for unknown session */ |
| 3556 | friend function f_tc_proc_ss_for_unknown_session(charstring id, BSC_ConnHdlrPars pars) |
| 3557 | runs on BSC_ConnHdlr { |
| 3558 | var OCT4 sid := '20000333'O; |
| 3559 | |
| 3560 | f_init_handler(pars); |
| 3561 | |
| 3562 | /* Perform location update */ |
| 3563 | f_perform_lu(); |
| 3564 | |
Vadim Yanitskiy | 70d15bf | 2020-01-09 22:51:01 +0100 | [diff] [blame] | 3565 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | d612d28 | 2019-06-15 14:46:03 +0700 | [diff] [blame] | 3566 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3567 | |
| 3568 | /* Request referencing a non-existing SS session */ |
| 3569 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 3570 | imsi := g_pars.imsi, |
| 3571 | sid := sid, |
| 3572 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 3573 | ss := f_rnd_octstring(23) |
| 3574 | ); |
| 3575 | |
| 3576 | /* Error with some cause value */ |
| 3577 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_ERR( |
| 3578 | imsi := g_pars.imsi, |
| 3579 | sid := sid, |
| 3580 | state := OSMO_GSUP_SESSION_STATE_END, |
| 3581 | cause := ? /* FIXME: introduce an enumerated type! */ |
| 3582 | ); |
| 3583 | |
| 3584 | /* Initiate a MT USSD notification */ |
| 3585 | GSUP.send(gsup_req); |
| 3586 | |
| 3587 | /* Expect GSUP PROC_SS_ERROR message */ |
| 3588 | f_expect_gsup_msg(gsup_rsp); |
| 3589 | } |
| 3590 | testcase TC_proc_ss_for_unknown_session() runs on MTC_CT { |
| 3591 | var BSC_ConnHdlr vc_conn; |
| 3592 | f_init(); |
| 3593 | vc_conn := f_start_handler(refers(f_tc_proc_ss_for_unknown_session), 110); |
| 3594 | vc_conn.done; |
| 3595 | } |
| 3596 | |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 3597 | /* MT (network-originated) USSD and no response to Paging Request */ |
| 3598 | friend function f_tc_proc_ss_paging_fail(charstring id, BSC_ConnHdlrPars pars) |
| 3599 | runs on BSC_ConnHdlr { |
| 3600 | timer TP := 2.0; /* Paging timer */ |
| 3601 | |
| 3602 | f_init_handler(pars); |
| 3603 | |
| 3604 | /* Perform location update */ |
| 3605 | f_perform_lu(); |
| 3606 | |
Vadim Yanitskiy | 70d15bf | 2020-01-09 22:51:01 +0100 | [diff] [blame] | 3607 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 3608 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3609 | |
| 3610 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 3611 | imsi := g_pars.imsi, |
| 3612 | sid := '20000444'O, |
| 3613 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3614 | ss := f_rnd_octstring(23) |
| 3615 | ); |
| 3616 | |
| 3617 | /* Error with some cause value */ |
| 3618 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_ERR( |
| 3619 | imsi := g_pars.imsi, |
| 3620 | sid := '20000444'O, |
| 3621 | state := OSMO_GSUP_SESSION_STATE_END, |
| 3622 | cause := ? /* FIXME: introduce an enumerated type! */ |
| 3623 | ); |
| 3624 | |
| 3625 | /* Initiate a MT USSD notification */ |
| 3626 | GSUP.send(gsup_req); |
| 3627 | |
| 3628 | /* Send it to MSC and expect Paging Request */ |
| 3629 | TP.start; |
| 3630 | alt { |
| 3631 | [pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 3632 | setverdict(pass); |
| 3633 | } |
| 3634 | [not pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) { |
| 3635 | setverdict(pass); |
| 3636 | } |
| 3637 | /* We don't expect anything else */ |
| 3638 | [] as_unexp_gsup_or_bssap_msg(); |
| 3639 | [] TP.timeout { |
| 3640 | setverdict(fail, "Timeout waiting for Paging Request"); |
| 3641 | } |
| 3642 | } |
| 3643 | |
Vadim Yanitskiy | d24b525 | 2019-10-02 00:04:51 +0700 | [diff] [blame] | 3644 | /* Wait up to 20 seconds for GSUP PROC_SS_ERROR message. |
| 3645 | * OsmoMSC waits for Paging Response 10 seconds by default. */ |
| 3646 | f_expect_gsup_msg(gsup_rsp, T_val := 20.0); |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 3647 | } |
| 3648 | testcase TC_proc_ss_paging_fail() runs on MTC_CT { |
| 3649 | var BSC_ConnHdlr vc_conn; |
| 3650 | f_init(); |
| 3651 | vc_conn := f_start_handler(refers(f_tc_proc_ss_paging_fail), 101); |
| 3652 | vc_conn.done; |
| 3653 | } |
| 3654 | |
Vadim Yanitskiy | 29ba8d6 | 2019-06-16 15:19:41 +0700 | [diff] [blame] | 3655 | /* MT (network-originated) USSD followed by immediate abort */ |
| 3656 | friend function f_tc_proc_ss_abort(charstring id, BSC_ConnHdlrPars pars) |
| 3657 | runs on BSC_ConnHdlr { |
| 3658 | var octetstring facility := f_rnd_octstring(23); |
| 3659 | var OCT4 sid := '20000555'O; |
| 3660 | timer TP := 2.0; |
| 3661 | |
| 3662 | f_init_handler(pars); |
| 3663 | |
| 3664 | /* Perform location update */ |
| 3665 | f_perform_lu(); |
| 3666 | |
Vadim Yanitskiy | 70d15bf | 2020-01-09 22:51:01 +0100 | [diff] [blame] | 3667 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 29ba8d6 | 2019-06-16 15:19:41 +0700 | [diff] [blame] | 3668 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3669 | |
| 3670 | /* PROC_SS_REQ initiates a mobile-originated SS/USSD session */ |
| 3671 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 3672 | imsi := g_pars.imsi, sid := sid, |
| 3673 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3674 | ss := facility |
| 3675 | ); |
| 3676 | |
| 3677 | /* On the MS side, we expect GSM 04.80 REGISTER message */ |
| 3678 | var template PDU_ML3_NW_MS dtap_reg := tr_ML3_MT_SS_REGISTER( |
| 3679 | tid := 0, /* Most likely, it should be 0 */ |
| 3680 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3681 | facility := facility |
| 3682 | ); |
| 3683 | |
| 3684 | /* PROC_SS_ERR with SESSION_STATE_END terminates the SS/USSD session */ |
| 3685 | var template (value) GSUP_PDU gsup_abort := ts_GSUP_PROC_SS_ERR( |
| 3686 | imsi := g_pars.imsi, sid := sid, |
| 3687 | state := OSMO_GSUP_SESSION_STATE_END, |
| 3688 | cause := 0 /* FIXME: introduce an enumerated type! */ |
| 3689 | ); |
| 3690 | |
| 3691 | /* On the MS side, we expect GSM 04.80 REGISTER message */ |
| 3692 | var template PDU_ML3_NW_MS dtap_rel := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3693 | tid := 0, /* Most likely, it should be 0 */ |
| 3694 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3695 | cause := *, /* FIXME: expect some specific cause value */ |
| 3696 | facility := omit |
| 3697 | ); |
| 3698 | |
| 3699 | /* Initiate a MT USSD with random payload */ |
| 3700 | GSUP.send(gsup_req); |
| 3701 | |
| 3702 | /* Expect Paging Request */ |
| 3703 | TP.start; |
| 3704 | alt { |
| 3705 | [pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 3706 | setverdict(pass); |
| 3707 | } |
| 3708 | [not pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) { |
| 3709 | setverdict(pass); |
| 3710 | } |
| 3711 | /* We don't expect anything else */ |
| 3712 | [] as_unexp_gsup_or_bssap_msg(); |
| 3713 | [] TP.timeout { |
| 3714 | setverdict(fail, "Timeout waiting for Paging Request"); |
| 3715 | } |
| 3716 | } |
| 3717 | |
| 3718 | /* Send Paging Response and establish connection */ |
| 3719 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 3720 | /* Expect MT REGISTER message with random facility */ |
| 3721 | f_expect_mt_dtap_msg(dtap_reg); |
| 3722 | |
| 3723 | /* HLR/EUSE decides to abort the session even |
| 3724 | * before getting any response from the MS */ |
| 3725 | /* Initiate a MT USSD with random payload */ |
| 3726 | GSUP.send(gsup_abort); |
| 3727 | |
| 3728 | /* Expect RELEASE COMPLETE on ths MS side */ |
| 3729 | f_expect_mt_dtap_msg(dtap_rel); |
| 3730 | |
| 3731 | f_expect_clear(); |
| 3732 | } |
| 3733 | testcase TC_proc_ss_abort() runs on MTC_CT { |
| 3734 | var BSC_ConnHdlr vc_conn; |
| 3735 | f_init(); |
| 3736 | vc_conn := f_start_handler(refers(f_tc_proc_ss_abort), 102); |
| 3737 | vc_conn.done; |
| 3738 | } |
| 3739 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3740 | |
Vadim Yanitskiy | 1c9754d | 2020-01-07 21:56:55 +0100 | [diff] [blame] | 3741 | /* Verify multiple concurrent MO SS/USSD transactions |
| 3742 | * (one subscriber - one transaction) */ |
| 3743 | testcase TC_multi_lu_and_mo_ussd() runs on MTC_CT { |
| 3744 | var BSC_ConnHdlr vc_conn[16]; |
| 3745 | var integer i; |
| 3746 | |
| 3747 | f_init(); |
| 3748 | |
| 3749 | for (i := 0; i < sizeof(vc_conn); i := i + 1) { |
| 3750 | vc_conn[i] := f_start_handler(refers(f_tc_lu_and_mo_ussd_single_request), 210 + i); |
| 3751 | } |
| 3752 | |
| 3753 | for (i := 0; i < sizeof(vc_conn); i := i + 1) { |
| 3754 | vc_conn[i].done; |
| 3755 | } |
| 3756 | } |
| 3757 | |
| 3758 | /* Verify multiple concurrent MT SS/USSD transactions |
| 3759 | * (one subscriber - one transaction) */ |
| 3760 | testcase TC_multi_lu_and_mt_ussd() runs on MTC_CT { |
| 3761 | var BSC_ConnHdlr vc_conn[16]; |
| 3762 | var integer i; |
| 3763 | var OCT4 sid; |
| 3764 | |
| 3765 | f_init(); |
| 3766 | |
| 3767 | for (i := 0; i < sizeof(vc_conn); i := i + 1) { |
| 3768 | sid := '200001'O & int2oct(i, 1); /* All transactions must use different session ID */ |
| 3769 | vc_conn[i] := f_start_handler_with_pars(refers(f_tc_lu_and_mt_ussd_notification), |
| 3770 | f_init_pars(226 + i, gsup_sid := sid)); |
| 3771 | } |
| 3772 | |
| 3773 | for (i := 0; i < sizeof(vc_conn); i := i + 1) { |
| 3774 | vc_conn[i].done; |
| 3775 | } |
| 3776 | } |
| 3777 | |
| 3778 | |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 3779 | /* A5/1 only permitted on network side; attempt an invalid CIPHER MODE COMPLETE with A5/3 which MSC should reject. */ |
| 3780 | private function f_tc_cipher_complete_with_invalid_cipher(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 3781 | pars.net.expect_auth := true; |
| 3782 | pars.net.expect_ciph := true; |
| 3783 | pars.net.kc_support := '02'O; /* A5/1 only */ |
| 3784 | f_init_handler(pars); |
| 3785 | |
| 3786 | g_pars.vec := f_gen_auth_vec_2g(); |
| 3787 | |
| 3788 | /* Can't use f_perform_lu() directly. Code below is based on it. */ |
| 3789 | |
| 3790 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 3791 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3792 | |
| 3793 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 3794 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 3795 | f_cl3_or_initial_ue(l3_lu); |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 3796 | |
| 3797 | f_mm_auth(); |
| 3798 | |
| 3799 | var OCT1 a5_net := f_alg_mask_from_cm(g_pars.cm2); |
| 3800 | var OCT1 a5_intersect := g_pars.net.kc_support and4b a5_net; |
| 3801 | alt { |
| 3802 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(a5_intersect, g_pars.vec.kc)) { |
| 3803 | BSSAP.send(ts_BSSMAP_CipherModeCompl(int2oct(4 /* "accept" A5/3 */, 1))); |
| 3804 | } |
| 3805 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?, g_pars.vec.kc)) { |
| 3806 | setverdict(fail, "Wrong ciphering algorithm mask in CiphModCmd"); |
| 3807 | mtc.stop; |
| 3808 | } |
| 3809 | [] BSSAP.receive { |
| 3810 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 3811 | mtc.stop; |
| 3812 | } |
| 3813 | } |
| 3814 | |
| 3815 | /* Expect LU reject from MSC. */ |
| 3816 | alt { |
| 3817 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 3818 | setverdict(pass); |
| 3819 | } |
| 3820 | [] BSSAP.receive { |
| 3821 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 3822 | mtc.stop; |
| 3823 | } |
| 3824 | } |
Stefan Sperling | c620b35 | 2018-12-18 17:23:36 +0100 | [diff] [blame] | 3825 | f_expect_clear(); |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 3826 | } |
| 3827 | |
| 3828 | testcase TC_cipher_complete_with_invalid_cipher() runs on MTC_CT { |
| 3829 | var BSC_ConnHdlr vc_conn; |
| 3830 | f_init(); |
| 3831 | f_vty_config(MSCVTY, "network", "encryption a5 1"); |
| 3832 | |
| 3833 | vc_conn := f_start_handler(refers(f_tc_cipher_complete_with_invalid_cipher), 52); |
| 3834 | vc_conn.done; |
| 3835 | } |
| 3836 | |
Harald Welte | b2284bd | 2019-05-10 11:30:43 +0200 | [diff] [blame] | 3837 | /* Location Update with invalid (non-matching) MCC/MNC reported on BSSMAP level from BSC */ |
| 3838 | friend function f_tc_lu_with_invalid_mcc_mnc(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 3839 | f_init_handler(pars); |
| 3840 | |
| 3841 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 3842 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3843 | |
| 3844 | /* modify the cell ID which will be used to construct the COMPLELTE L3 or InitialUE */ |
| 3845 | g_pars.cell_id := valueof(ts_CellId_CGI('333'H, '22'H, 23, 42)); |
| 3846 | |
| 3847 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 3848 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 3849 | f_cl3_or_initial_ue(l3_lu); |
| 3850 | |
| 3851 | /* Expect LU reject from MSC. */ |
| 3852 | alt { |
| 3853 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 3854 | setverdict(pass); |
| 3855 | } |
| 3856 | [] BSSAP.receive { |
| 3857 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 3858 | mtc.stop; |
| 3859 | } |
| 3860 | } |
| 3861 | f_expect_clear(); |
| 3862 | } |
| 3863 | testcase TC_lu_with_invalid_mcc_mnc() runs on MTC_CT { |
| 3864 | var BSC_ConnHdlr vc_conn; |
| 3865 | f_init(); |
| 3866 | vc_conn := f_start_handler(refers(f_tc_lu_with_invalid_mcc_mnc), 54); |
| 3867 | vc_conn.done; |
| 3868 | } |
| 3869 | |
Stefan Sperling | a2d59c6 | 2018-12-18 16:32:44 +0100 | [diff] [blame] | 3870 | private function f_tc_cipher_complete_without_alg(charstring id, BSC_ConnHdlrPars pars, octetstring kc_support) runs on BSC_ConnHdlr { |
| 3871 | pars.net.expect_auth := true; |
| 3872 | pars.net.expect_ciph := true; |
| 3873 | pars.net.kc_support := kc_support; |
| 3874 | f_init_handler(pars); |
| 3875 | |
| 3876 | g_pars.vec := f_gen_auth_vec_2g(); |
| 3877 | |
| 3878 | /* Can't use f_perform_lu() directly. Code below is based on it. */ |
| 3879 | |
| 3880 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 3881 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3882 | |
| 3883 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 3884 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 3885 | f_cl3_or_initial_ue(l3_lu); |
| 3886 | |
| 3887 | f_mm_auth(); |
| 3888 | |
| 3889 | var OCT1 a5_net := f_alg_mask_from_cm(g_pars.cm2); |
| 3890 | var OCT1 a5_intersect := g_pars.net.kc_support and4b a5_net; |
| 3891 | alt { |
| 3892 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(a5_intersect, g_pars.vec.kc)) { |
| 3893 | BSSAP.send(ts_BSSMAP_CipherModeComplAlg(omit)); |
| 3894 | } |
| 3895 | [] BSSAP.receive(tr_BSSMAP_ClassmarkReq) { |
| 3896 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 3897 | repeat; |
| 3898 | } |
| 3899 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?, g_pars.vec.kc)) { |
| 3900 | setverdict(fail, "Wrong ciphering algorithm mask in CiphModCmd"); |
| 3901 | mtc.stop; |
| 3902 | } |
| 3903 | [] BSSAP.receive { |
| 3904 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 3905 | mtc.stop; |
| 3906 | } |
| 3907 | } |
| 3908 | |
| 3909 | /* TODO: Verify MSC is using the best cipher available! How? */ |
| 3910 | |
| 3911 | f_msc_lu_hlr(); |
| 3912 | f_accept_reject_lu(); |
| 3913 | f_expect_clear(); |
| 3914 | setverdict(pass); |
| 3915 | } |
| 3916 | |
| 3917 | /* A5/1 only permitted on network side; attempt CIPHER MODE COMPLETE without specifying the accepted algorithm. */ |
| 3918 | private function f_tc_cipher_complete_1_without_cipher(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 3919 | f_tc_cipher_complete_without_alg(id, pars, '02'O /* A5/1 only */); |
| 3920 | } |
| 3921 | |
| 3922 | /* A5/3 only permitted on network side; attempt CIPHER MODE COMPLETE without specifying the accepted algorithm. */ |
| 3923 | private function f_tc_cipher_complete_3_without_cipher(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 3924 | f_tc_cipher_complete_without_alg(id, pars, '08'O /* A5/3 only */); |
| 3925 | } |
| 3926 | |
| 3927 | /* A5/1 + A5/3 permitted on network side; attempt CIPHER MODE COMPLETE without specifying the accepted algorithm. */ |
| 3928 | private function f_tc_cipher_complete_13_without_cipher(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 3929 | f_tc_cipher_complete_without_alg(id, pars, '0A'O /* A5/1 and A5/3 enabled */); |
| 3930 | } |
| 3931 | |
| 3932 | testcase TC_cipher_complete_1_without_cipher() runs on MTC_CT { |
| 3933 | var BSC_ConnHdlr vc_conn; |
| 3934 | f_init(); |
| 3935 | f_vty_config(MSCVTY, "network", "encryption a5 1"); |
| 3936 | |
| 3937 | vc_conn := f_start_handler(refers(f_tc_cipher_complete_1_without_cipher), 53); |
| 3938 | vc_conn.done; |
| 3939 | } |
| 3940 | |
| 3941 | testcase TC_cipher_complete_3_without_cipher() runs on MTC_CT { |
| 3942 | var BSC_ConnHdlr vc_conn; |
| 3943 | f_init(); |
| 3944 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 3945 | |
| 3946 | vc_conn := f_start_handler(refers(f_tc_cipher_complete_3_without_cipher), 54); |
| 3947 | vc_conn.done; |
| 3948 | } |
| 3949 | |
| 3950 | testcase TC_cipher_complete_13_without_cipher() runs on MTC_CT { |
| 3951 | var BSC_ConnHdlr vc_conn; |
| 3952 | f_init(); |
| 3953 | f_vty_config(MSCVTY, "network", "encryption a5 1 3"); |
| 3954 | |
| 3955 | vc_conn := f_start_handler(refers(f_tc_cipher_complete_13_without_cipher), 55); |
| 3956 | vc_conn.done; |
| 3957 | } |
Harald Welte | b2284bd | 2019-05-10 11:30:43 +0200 | [diff] [blame] | 3958 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 3959 | /* TODO (SMS): |
| 3960 | * different user data lengths |
| 3961 | * SMPP transaction mode with unsuccessful delivery |
| 3962 | * queued MT-SMS with no paging response + later delivery |
| 3963 | * different data coding schemes |
| 3964 | * multi-part SMS |
| 3965 | * user-data headers |
| 3966 | * TP-PID for SMS to SIM |
| 3967 | * behavior if SMS memory is full + RP-SMMA |
| 3968 | * delivery reports |
| 3969 | * SMPP osmocom extensions |
| 3970 | * more-messages-to-send |
| 3971 | * SMS during ongoing call (SACCH/SAPI3) |
| 3972 | */ |
| 3973 | |
| 3974 | /* TODO (General): |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 3975 | * continue to send repeated MO signalling messages to keep channel open: does MSC tmeout? |
| 3976 | * malformed messages (missing IE, invalid message type): properly rejected? |
| 3977 | * MT call while LU or is ongoing: Do we use existing lchan or page while lchan active? |
| 3978 | * 3G/2G auth permutations |
| 3979 | * encryption algorithms vs. classmark vs. vty config |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 3980 | * send new transaction after/during clear (like SMS, ...) |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 3981 | * too long L3 INFO in DTAP |
| 3982 | * too long / padded BSSAP |
| 3983 | * too long / short TLV values |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 3984 | */ |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 3985 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3986 | /*********************************************************************** |
| 3987 | * SGsAP Testing |
| 3988 | ***********************************************************************/ |
| 3989 | |
Philipp Maier | 948747b | 2019-04-02 15:22:33 +0200 | [diff] [blame] | 3990 | /* Check if a subscriber exists in the VLR */ |
| 3991 | private function f_ctrl_subscr_in_vlr(charstring imsi_or_msisdn) runs on BSC_ConnHdlr return boolean { |
| 3992 | |
| 3993 | var CtrlValue active_subsribers; |
| 3994 | var integer rc; |
| 3995 | active_subsribers := f_ctrl_get(IPA_CTRL, "subscriber-list-active-v1"); |
| 3996 | |
| 3997 | rc := f_strstr(active_subsribers, imsi_or_msisdn); |
| 3998 | if (rc < 0) { |
| 3999 | return false; |
| 4000 | } |
| 4001 | |
| 4002 | return true; |
| 4003 | } |
| 4004 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4005 | /* Perform a location updatye at the A-Interface and run some checks to confirm |
| 4006 | * that everything is back to normal. */ |
| 4007 | private function f_sgsap_bssmap_screening() runs on BSC_ConnHdlr { |
| 4008 | var SmsParameters spars := valueof(t_SmsPars); |
| 4009 | |
| 4010 | /* Perform a location update, the SGs association is expected to fall |
| 4011 | * back to NULL */ |
| 4012 | f_perform_lu(); |
| 4013 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4014 | |
| 4015 | /* Trigger a paging request and expect the paging on BSSMAP, this is |
| 4016 | * to make sure that pagings are sent throught the A-Interface again |
| 4017 | * and not throught the SGs interface.*/ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 4018 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4019 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 4020 | |
| 4021 | alt { |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 4022 | [g_pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)); { |
| 4023 | setverdict(pass); |
| 4024 | } |
Harald Welte | 62113fc | 2019-05-09 13:04:02 +0200 | [diff] [blame] | 4025 | [not g_pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) { |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4026 | setverdict(pass); |
| 4027 | } |
| 4028 | [] SGsAP.receive { |
| 4029 | setverdict(fail, "Received unexpected message on SGs"); |
| 4030 | } |
| 4031 | } |
| 4032 | |
| 4033 | /* Send an SMS to make sure that also payload messages are routed |
| 4034 | * throught the A-Interface again */ |
| 4035 | f_establish_fully(EST_TYPE_MO_SMS); |
| 4036 | f_mo_sms(spars); |
| 4037 | f_expect_clear(); |
| 4038 | } |
| 4039 | |
| 4040 | private function f_tc_sgsap_reset(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4041 | var charstring vlr_name; |
| 4042 | f_init_handler(pars); |
| 4043 | |
| 4044 | vlr_name := f_sgsap_reset_mme(mp_mme_name); |
| 4045 | log("VLR name: ", vlr_name); |
| 4046 | setverdict(pass); |
Neels Hofmeyr | c0b520d | 2019-03-06 15:35:50 +0100 | [diff] [blame] | 4047 | f_sleep(1.0); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4048 | } |
| 4049 | |
| 4050 | testcase TC_sgsap_reset() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4051 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4052 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4053 | f_init(1, true); |
| 4054 | pars := f_init_pars(11810, true); |
| 4055 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_reset), pars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4056 | vc_conn.done; |
| 4057 | } |
| 4058 | |
| 4059 | /* like f_mm_auth() but for SGs */ |
| 4060 | function f_mm_auth_sgs() runs on BSC_ConnHdlr { |
| 4061 | if (g_pars.net.expect_auth) { |
| 4062 | g_pars.vec := f_gen_auth_vec_3g(); |
| 4063 | var GSUP_IE auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G3G(g_pars.vec.rand, |
| 4064 | g_pars.vec.sres, |
| 4065 | g_pars.vec.kc, |
| 4066 | g_pars.vec.ik, |
| 4067 | g_pars.vec.ck, |
| 4068 | g_pars.vec.autn, |
| 4069 | g_pars.vec.res)); |
| 4070 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 4071 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
| 4072 | SGsAP.receive(tr_ML3_MT_MM_AUTH_REQ_3G(g_pars.vec.rand, g_pars.vec.autn)); |
| 4073 | SGsAP.send(ts_ML3_MT_MM_AUTH_RESP_3G(g_pars.vec.sres, g_pars.vec.res)); |
| 4074 | } |
| 4075 | } |
| 4076 | |
| 4077 | /* like f_perform_lu(), but on SGs rather than BSSAP */ |
| 4078 | function f_sgs_perform_lu() runs on BSC_ConnHdlr { |
| 4079 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4080 | var PDU_SGsAP lur; |
| 4081 | var PDU_SGsAP lua; |
| 4082 | var PDU_SGsAP mm_info; |
| 4083 | var octetstring mm_info_dtap; |
| 4084 | |
| 4085 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 4086 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4087 | |
| 4088 | lur := valueof(ts_SGsAP_LU_REQ(g_pars.imsi, mme_name, IMSI_attach, |
| 4089 | ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4090 | /* Old LAI, if MS sends it */ |
| 4091 | /* TMSI status, if MS has no valid TMSI */ |
| 4092 | /* IMEISV, if it supports "automatic device detection" */ |
| 4093 | /* TAI, if available in MME */ |
| 4094 | /* E-CGI, if available in MME */ |
| 4095 | SGsAP.send(lur); |
| 4096 | |
| 4097 | /* FIXME: is this really done over SGs? The Ue is already authenticated |
| 4098 | * via the MME ... */ |
| 4099 | f_mm_auth_sgs(); |
| 4100 | |
| 4101 | /* Expect MSC to perform LU with HLR */ |
| 4102 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 4103 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 4104 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 4105 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 4106 | |
| 4107 | alt { |
| 4108 | [] SGsAP.receive(tr_SGsAP_LU_ACCEPT(g_pars.imsi, ?)) -> value lua { |
| 4109 | if (isvalue(lua.sGsAP_LOCATION_UPDATE_ACCEPT.newTMSIorIMSI.iD.iD.tmsi_ptmsi.octets)) { |
| 4110 | g_pars.tmsi :=lua.sGsAP_LOCATION_UPDATE_ACCEPT.newTMSIorIMSI.iD.iD.tmsi_ptmsi.octets |
| 4111 | SGsAP.send(ts_SGsAP_TMSI_REALL_CMPL(g_pars.imsi)); |
| 4112 | } |
| 4113 | setverdict(pass); |
| 4114 | } |
| 4115 | [] SGsAP.receive(tr_SGsAP_LU_REJECT(g_pars.imsi, ?, ?)) { |
| 4116 | setverdict(fail, "Received LU-REJECT instead of ACCEPT"); |
| 4117 | } |
| 4118 | [] SGsAP.receive { |
| 4119 | setverdict(fail, "Received unexpected message on SGs"); |
| 4120 | } |
| 4121 | } |
| 4122 | |
| 4123 | /* Check MM information */ |
| 4124 | if (mp_mm_info == true) { |
| 4125 | SGsAP.receive(tr_SGsAP_MM_INFO_REQ(g_pars.imsi, ?)) -> value mm_info; |
| 4126 | mm_info_dtap := '0532'O & mm_info.sGsAP_MM_INFORMATION_REQUEST.mM_Information.information; |
| 4127 | if (not match(dec_PDU_ML3_NW_MS(mm_info_dtap), tr_ML3_MT_MM_Info)) { |
| 4128 | setverdict(fail, "Unexpected MM Information"); |
| 4129 | } |
| 4130 | } |
| 4131 | |
| 4132 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4133 | } |
| 4134 | |
| 4135 | private function f_tc_sgsap_lu(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4136 | f_init_handler(pars); |
| 4137 | f_sgs_perform_lu(); |
| 4138 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4139 | |
| 4140 | f_sgsap_bssmap_screening(); |
| 4141 | |
| 4142 | setverdict(pass); |
| 4143 | } |
| 4144 | testcase TC_sgsap_lu() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4145 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4146 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4147 | f_init(1, true); |
| 4148 | pars := f_init_pars(11811, true); |
| 4149 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_lu), pars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4150 | vc_conn.done; |
| 4151 | } |
| 4152 | |
| 4153 | /* Do LU by IMSI, refuse it on GSUP and expect LU REJ back to MS */ |
| 4154 | private function f_tc_sgsap_lu_imsi_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4155 | f_init_handler(pars); |
| 4156 | var PDU_SGsAP lur; |
| 4157 | |
| 4158 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4159 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4160 | lur := valueof(ts_SGsAP_LU_REQ(g_pars.imsi, mme_name, IMSI_attach, |
| 4161 | ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4162 | SGsAP.send(lur); |
| 4163 | |
| 4164 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 4165 | GSUP.send(ts_GSUP_UL_ERR(g_pars.imsi, 23)); |
| 4166 | alt { |
| 4167 | [] SGsAP.receive(tr_SGsAP_LU_REJECT(g_pars.imsi, ?, ?)) { |
| 4168 | setverdict(pass); |
| 4169 | } |
| 4170 | [] SGsAP.receive(tr_SGsAP_LU_ACCEPT(g_pars.imsi, ?)) { |
| 4171 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
| 4172 | mtc.stop; |
| 4173 | } |
| 4174 | [] SGsAP.receive { |
| 4175 | setverdict(fail, "Received unexpected message on SGs"); |
| 4176 | } |
| 4177 | } |
| 4178 | |
| 4179 | f_sgsap_bssmap_screening(); |
| 4180 | |
| 4181 | setverdict(pass); |
| 4182 | } |
| 4183 | testcase TC_sgsap_lu_imsi_reject() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4184 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4185 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4186 | f_init(1, true); |
| 4187 | pars := f_init_pars(11812, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4188 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4189 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_lu_imsi_reject), pars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4190 | vc_conn.done; |
| 4191 | } |
| 4192 | |
| 4193 | /* Do LU by IMSI, but then remain silent so that Ts6-1 times out */ |
| 4194 | private function f_tc_sgsap_lu_and_nothing(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4195 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4196 | var PDU_SGsAP lur; |
| 4197 | |
| 4198 | f_init_handler(pars); |
| 4199 | |
| 4200 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 4201 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4202 | |
| 4203 | lur := valueof(ts_SGsAP_LU_REQ(g_pars.imsi, mme_name, IMSI_attach, |
| 4204 | ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4205 | /* Old LAI, if MS sends it */ |
| 4206 | /* TMSI status, if MS has no valid TMSI */ |
| 4207 | /* IMEISV, if it supports "automatic device detection" */ |
| 4208 | /* TAI, if available in MME */ |
| 4209 | /* E-CGI, if available in MME */ |
| 4210 | SGsAP.send(lur); |
| 4211 | |
| 4212 | /* FIXME: is this really done over SGs? The Ue is already authenticated |
| 4213 | * via the MME ... */ |
| 4214 | f_mm_auth_sgs(); |
| 4215 | |
| 4216 | /* Expect MSC to perform LU with HLR */ |
| 4217 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 4218 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 4219 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 4220 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 4221 | |
| 4222 | alt { |
| 4223 | [] SGsAP.receive(tr_SGsAP_LU_ACCEPT(g_pars.imsi, ?)) { |
| 4224 | setverdict(pass); |
| 4225 | } |
| 4226 | [] SGsAP.receive(tr_SGsAP_LU_REJECT(g_pars.imsi, ?, ?)) { |
| 4227 | setverdict(fail, "Received LU-REJECT instead of ACCEPT"); |
| 4228 | } |
| 4229 | [] SGsAP.receive { |
| 4230 | setverdict(fail, "Received unexpected message on SGs"); |
| 4231 | } |
| 4232 | } |
| 4233 | |
| 4234 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4235 | |
| 4236 | /* Wait until the VLR has abort the TMSI reallocation procedure */ |
| 4237 | f_sleep(45.0); |
| 4238 | |
| 4239 | /* The outcome does not change the SGs state, see also 5.2.3.4 */ |
| 4240 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4241 | |
| 4242 | f_sgsap_bssmap_screening(); |
| 4243 | |
| 4244 | setverdict(pass); |
| 4245 | } |
| 4246 | testcase TC_sgsap_lu_and_nothing() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4247 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4248 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4249 | f_init(1, true); |
| 4250 | pars := f_init_pars(11813, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4251 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4252 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_lu_and_nothing), pars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4253 | vc_conn.done; |
| 4254 | } |
| 4255 | |
| 4256 | private function f_tc_sgsap_expl_imsi_det_eps(charstring id, BSC_ConnHdlrPars pars) |
| 4257 | runs on BSC_ConnHdlr { |
| 4258 | f_init_handler(pars); |
| 4259 | f_sgs_perform_lu(); |
| 4260 | f_sleep(3.0); |
| 4261 | |
| 4262 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4263 | SGsAP.send(ts_SGsAP_EPS_DETACH_IND(g_pars.imsi, mme_name, UE_initiated)); |
| 4264 | SGsAP.receive(tr_SGsAP_EPS_DETACH_ACK(g_pars.imsi)); |
| 4265 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4266 | |
| 4267 | f_sgsap_bssmap_screening(); |
| 4268 | |
| 4269 | setverdict(pass); |
| 4270 | } |
| 4271 | testcase TC_sgsap_expl_imsi_det_eps() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4272 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4273 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4274 | f_init(1, true); |
| 4275 | pars := f_init_pars(11814, true); |
| 4276 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_expl_imsi_det_eps), pars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4277 | vc_conn.done; |
| 4278 | } |
| 4279 | |
Philipp Maier | fc19f17 | 2019-03-21 11:17:54 +0100 | [diff] [blame] | 4280 | private function f_tc_sgsap_impl_imsi_det_eps(charstring id, BSC_ConnHdlrPars pars) |
| 4281 | runs on BSC_ConnHdlr { |
| 4282 | f_init_handler(pars); |
| 4283 | f_sgs_perform_lu(); |
| 4284 | f_sleep(3.0); |
| 4285 | |
| 4286 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4287 | SGsAP.send(ts_SGsAP_EPS_DETACH_IND(g_pars.imsi, mme_name, network_initiated)); |
| 4288 | SGsAP.receive(tr_SGsAP_EPS_DETACH_ACK(g_pars.imsi)); |
| 4289 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4290 | |
| 4291 | f_sgsap_bssmap_screening(); |
| 4292 | |
| 4293 | setverdict(pass); |
| 4294 | } |
| 4295 | testcase TC_sgsap_impl_imsi_det_eps() runs on MTC_CT { |
| 4296 | var BSC_ConnHdlrPars pars; |
| 4297 | var BSC_ConnHdlr vc_conn; |
| 4298 | f_init(1, true); |
| 4299 | pars := f_init_pars(11814, true); |
| 4300 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_impl_imsi_det_eps), pars); |
| 4301 | vc_conn.done; |
| 4302 | } |
| 4303 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4304 | private function f_tc_sgsap_expl_imsi_det_noneps(charstring id, BSC_ConnHdlrPars pars) |
| 4305 | runs on BSC_ConnHdlr { |
| 4306 | f_init_handler(pars); |
| 4307 | f_sgs_perform_lu(); |
| 4308 | f_sleep(3.0); |
| 4309 | |
| 4310 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4311 | SGsAP.send(ts_SGsAP_IMSI_DETACH_IND(g_pars.imsi, mme_name, combined_UE_initiated)); |
| 4312 | SGsAP.receive(tr_SGsAP_IMSI_DETACH_ACK(g_pars.imsi)); |
Philipp Maier | d08e7e7 | 2019-04-02 15:27:10 +0200 | [diff] [blame] | 4313 | |
| 4314 | if (f_ctrl_subscr_in_vlr(hex2str(g_pars.imsi))) { |
| 4315 | setverdict(fail, "subscriber not removed from VLR"); |
| 4316 | } |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4317 | |
| 4318 | f_sgsap_bssmap_screening(); |
| 4319 | |
| 4320 | setverdict(pass); |
| 4321 | } |
| 4322 | testcase TC_sgsap_expl_imsi_det_noneps() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4323 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4324 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4325 | f_init(1, true); |
| 4326 | pars := f_init_pars(11815, true); |
| 4327 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_expl_imsi_det_noneps), pars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4328 | vc_conn.done; |
| 4329 | } |
| 4330 | |
Philipp Maier | 5d81270 | 2019-03-21 10:51:26 +0100 | [diff] [blame] | 4331 | private function f_tc_sgsap_impl_imsi_det_noneps(charstring id, BSC_ConnHdlrPars pars) |
| 4332 | runs on BSC_ConnHdlr { |
| 4333 | f_init_handler(pars); |
| 4334 | f_sgs_perform_lu(); |
| 4335 | f_sleep(3.0); |
| 4336 | |
| 4337 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4338 | SGsAP.send(ts_SGsAP_IMSI_DETACH_IND(g_pars.imsi, mme_name, implicit_network_initiated)); |
| 4339 | SGsAP.receive(tr_SGsAP_IMSI_DETACH_ACK(g_pars.imsi)); |
| 4340 | |
| 4341 | if (f_ctrl_subscr_in_vlr(hex2str(g_pars.imsi))) { |
| 4342 | setverdict(fail, "subscriber not removed from VLR"); |
| 4343 | } |
| 4344 | |
| 4345 | f_sgsap_bssmap_screening(); |
| 4346 | |
| 4347 | setverdict(pass); |
| 4348 | } |
| 4349 | testcase TC_sgsap_impl_imsi_det_noneps() runs on MTC_CT { |
| 4350 | var BSC_ConnHdlrPars pars; |
| 4351 | var BSC_ConnHdlr vc_conn; |
| 4352 | f_init(1, true); |
| 4353 | pars := f_init_pars(11815, true); |
| 4354 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_impl_imsi_det_noneps), pars); |
| 4355 | vc_conn.done; |
| 4356 | } |
| 4357 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4358 | /* Trigger a paging request via VTY and send a paging reject in response */ |
| 4359 | private function f_tc_sgsap_paging_rej(charstring id, BSC_ConnHdlrPars pars) |
| 4360 | runs on BSC_ConnHdlr { |
| 4361 | f_init_handler(pars); |
| 4362 | f_sgs_perform_lu(); |
| 4363 | f_sleep(1.0); |
| 4364 | |
| 4365 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4366 | var template PDU_SGsAP exp_resp := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, CS_call_indicator, omit); |
| 4367 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4368 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 4369 | |
| 4370 | /* Initiate paging via VTY */ |
| 4371 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 4372 | alt { |
| 4373 | [] SGsAP.receive(exp_resp) { |
| 4374 | setverdict(pass); |
| 4375 | } |
| 4376 | [] SGsAP.receive { |
| 4377 | setverdict(fail, "Received unexpected message on SGs"); |
| 4378 | } |
| 4379 | } |
| 4380 | |
| 4381 | /* Now reject the paging */ |
| 4382 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, IMSI_unknown)); |
| 4383 | |
| 4384 | /* Wait for the states inside the MSC to settle and check the state |
| 4385 | * of the SGs Association */ |
| 4386 | f_sleep(1.0); |
| 4387 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4388 | |
| 4389 | /* FIXME: At the moment we send an IMSI_unknown as cause code, which is fine, |
| 4390 | * but we also need to cover tha case where the cause code indicates an |
| 4391 | * "IMSI detached for EPS services". In those cases the VLR is expected to |
| 4392 | * try paging on tha A/Iu interface. This will be another testcase similar to |
| 4393 | * this one, but extended with checks for the presence of the A/Iu paging |
| 4394 | * messages. */ |
| 4395 | |
| 4396 | f_sgsap_bssmap_screening(); |
| 4397 | |
| 4398 | setverdict(pass); |
| 4399 | } |
| 4400 | testcase TC_sgsap_paging_rej() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4401 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4402 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4403 | f_init(1, true); |
| 4404 | pars := f_init_pars(11816, true); |
| 4405 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_paging_rej), pars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4406 | vc_conn.done; |
| 4407 | } |
| 4408 | |
| 4409 | /* Trigger a paging request via VTY and send a paging reject that indicates |
| 4410 | * that the subscriber intentionally rejected the call. */ |
| 4411 | private function f_tc_sgsap_paging_subscr_rej(charstring id, BSC_ConnHdlrPars pars) |
| 4412 | runs on BSC_ConnHdlr { |
| 4413 | f_init_handler(pars); |
| 4414 | f_sgs_perform_lu(); |
| 4415 | f_sleep(1.0); |
| 4416 | |
| 4417 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4418 | var template PDU_SGsAP exp_resp := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, CS_call_indicator, omit); |
| 4419 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4420 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 4421 | |
| 4422 | /* Initiate paging via VTY */ |
| 4423 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 4424 | alt { |
| 4425 | [] SGsAP.receive(exp_resp) { |
| 4426 | setverdict(pass); |
| 4427 | } |
| 4428 | [] SGsAP.receive { |
| 4429 | setverdict(fail, "Received unexpected message on SGs"); |
| 4430 | } |
| 4431 | } |
| 4432 | |
| 4433 | /* Now reject the paging */ |
| 4434 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, user_rejected_mobile_terminating_CS_fallback_call)); |
| 4435 | |
| 4436 | /* Wait for the states inside the MSC to settle and check the state |
| 4437 | * of the SGs Association */ |
| 4438 | f_sleep(1.0); |
| 4439 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4440 | |
| 4441 | /* FIXME: The VLR is supposed to trigger an User Determined User Busy (UDUB) as specified |
| 4442 | * in 3GPP TS 24.082, this is not yet implemented in the MSC or in this tests, we need |
| 4443 | * to check back how this works and how it can be tested */ |
| 4444 | |
| 4445 | f_sgsap_bssmap_screening(); |
| 4446 | |
| 4447 | setverdict(pass); |
| 4448 | } |
| 4449 | testcase TC_sgsap_paging_subscr_rej() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4450 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4451 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4452 | f_init(1, true); |
| 4453 | pars := f_init_pars(11817, true); |
| 4454 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_paging_subscr_rej), pars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4455 | vc_conn.done; |
| 4456 | } |
| 4457 | |
| 4458 | /* Trigger a paging request via VTY and send an UE unreacable messge in response */ |
| 4459 | private function f_tc_sgsap_paging_ue_unr(charstring id, BSC_ConnHdlrPars pars) |
| 4460 | runs on BSC_ConnHdlr { |
| 4461 | f_init_handler(pars); |
| 4462 | f_sgs_perform_lu(); |
| 4463 | f_sleep(1.0); |
| 4464 | |
| 4465 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4466 | var template PDU_SGsAP exp_resp := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, CS_call_indicator, omit); |
| 4467 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4468 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 4469 | |
| 4470 | /* Initiate paging via VTY */ |
| 4471 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 4472 | alt { |
| 4473 | [] SGsAP.receive(exp_resp) { |
| 4474 | setverdict(pass); |
| 4475 | } |
| 4476 | [] SGsAP.receive { |
| 4477 | setverdict(fail, "Received unexpected message on SGs"); |
| 4478 | } |
| 4479 | } |
| 4480 | |
| 4481 | /* Now pretend that the UE is unreachable */ |
| 4482 | SGsAP.send(ts_SGsAP_UE_UNREACHABLE(g_pars.imsi, UE_unreachable)); |
| 4483 | |
| 4484 | /* Wait for the states inside the MSC to settle and check the state |
| 4485 | * of the SGs Association. */ |
| 4486 | f_sleep(1.0); |
| 4487 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4488 | |
| 4489 | f_sgsap_bssmap_screening(); |
| 4490 | |
| 4491 | setverdict(pass); |
| 4492 | } |
| 4493 | testcase TC_sgsap_paging_ue_unr() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4494 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4495 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4496 | f_init(1, true); |
| 4497 | pars := f_init_pars(11818, true); |
| 4498 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_paging_ue_unr), pars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4499 | vc_conn.done; |
| 4500 | } |
| 4501 | |
| 4502 | /* Trigger a paging request via VTY but don't respond to it */ |
| 4503 | private function f_tc_sgsap_paging_and_nothing(charstring id, BSC_ConnHdlrPars pars) |
| 4504 | runs on BSC_ConnHdlr { |
| 4505 | f_init_handler(pars); |
| 4506 | f_sgs_perform_lu(); |
| 4507 | f_sleep(1.0); |
| 4508 | |
| 4509 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4510 | var template PDU_SGsAP exp_resp := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, CS_call_indicator, omit); |
Philipp Maier | 3421810 | 2019-09-24 09:15:49 +0200 | [diff] [blame] | 4511 | var template PDU_SGsAP exp_serv_abrt := ts_SGsAP_SERVICE_ABORT_REQ(g_pars.imsi); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4512 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4513 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 4514 | |
| 4515 | /* Initiate paging via VTY */ |
| 4516 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 4517 | alt { |
| 4518 | [] SGsAP.receive(exp_resp) { |
| 4519 | setverdict(pass); |
| 4520 | } |
| 4521 | [] SGsAP.receive { |
| 4522 | setverdict(fail, "Received unexpected message on SGs"); |
| 4523 | } |
| 4524 | } |
| 4525 | |
Philipp Maier | 3421810 | 2019-09-24 09:15:49 +0200 | [diff] [blame] | 4526 | /* While we are doing nothing, expect an SGsAP-SERVICE-ABORT-REQUEST |
| 4527 | * after some time */ |
| 4528 | timer T := 10.0; |
| 4529 | T.start |
| 4530 | alt { |
| 4531 | [] SGsAP.receive(exp_serv_abrt) |
| 4532 | { |
| 4533 | setverdict(pass); |
| 4534 | } |
| 4535 | [] SGsAP.receive { |
| 4536 | setverdict(fail, "unexpected SGsAP message received"); |
| 4537 | self.stop; |
| 4538 | } |
| 4539 | [] T.timeout { |
| 4540 | setverdict(fail, "MSC did not send SGsAP-SERVICE-ABORT-REQUEST"); |
| 4541 | self.stop; |
| 4542 | } |
| 4543 | } |
| 4544 | |
| 4545 | /* The SGs association must remain unchanged. */ |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4546 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4547 | |
| 4548 | f_sgsap_bssmap_screening(); |
| 4549 | |
| 4550 | setverdict(pass); |
| 4551 | } |
| 4552 | testcase TC_sgsap_paging_and_nothing() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4553 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4554 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4555 | f_init(1, true); |
| 4556 | pars := f_init_pars(11819, true); |
| 4557 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_paging_and_nothing), pars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4558 | vc_conn.done; |
| 4559 | } |
| 4560 | |
| 4561 | /* Trigger a paging request via VTY and slip in an LU */ |
| 4562 | private function f_tc_sgsap_paging_and_lu(charstring id, BSC_ConnHdlrPars pars) |
| 4563 | runs on BSC_ConnHdlr { |
| 4564 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4565 | f_init_handler(pars); |
| 4566 | |
| 4567 | /* First we prepar the situation, where the SGs association is in state |
| 4568 | * NULL and the confirmed by radio contact indicator is set to false |
| 4569 | * as well. This can be archived by performing an SGs LU and then |
| 4570 | * resetting the VLR */ |
| 4571 | f_sgs_perform_lu(); |
| 4572 | f_sgsap_reset_mme(mp_mme_name); |
| 4573 | f_sleep(1.0); |
| 4574 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4575 | |
| 4576 | /* Perform a paging, expect the paging messages on the SGs interface */ |
| 4577 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 4578 | alt { |
| 4579 | [] SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)) { |
| 4580 | setverdict(pass); |
| 4581 | } |
| 4582 | [] SGsAP.receive { |
| 4583 | setverdict(fail, "Received unexpected message on SGs"); |
| 4584 | } |
| 4585 | } |
| 4586 | |
| 4587 | /* Perform the LU as normal */ |
| 4588 | f_sgs_perform_lu(); |
| 4589 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4590 | |
| 4591 | /* Expect a new paging request right after the LU */ |
| 4592 | alt { |
| 4593 | [] SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)) { |
| 4594 | setverdict(pass); |
| 4595 | } |
| 4596 | [] SGsAP.receive { |
| 4597 | setverdict(fail, "Received unexpected message on SGs"); |
| 4598 | } |
| 4599 | } |
| 4600 | |
| 4601 | /* Test is done now, lets round everything up by rejecting the paging |
| 4602 | * cleanly. */ |
| 4603 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, user_rejected_mobile_terminating_CS_fallback_call)); |
| 4604 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4605 | |
| 4606 | f_sgsap_bssmap_screening(); |
| 4607 | |
| 4608 | setverdict(pass); |
| 4609 | } |
| 4610 | testcase TC_sgsap_paging_and_lu() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4611 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4612 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4613 | f_init(1, true); |
| 4614 | pars := f_init_pars(11820, true); |
| 4615 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_paging_and_lu), pars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4616 | vc_conn.done; |
| 4617 | } |
| 4618 | |
| 4619 | /* Send unexpected unit-data through the SGs interface */ |
| 4620 | private function f_tc_sgsap_unexp_ud(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4621 | f_init_handler(pars); |
| 4622 | f_sleep(1.0); |
| 4623 | |
| 4624 | /* This simulates what happens when a subscriber without SGs |
| 4625 | * association gets unitdata via the SGs interface. */ |
| 4626 | |
| 4627 | /* Make sure the subscriber exists and the SGs association |
| 4628 | * is in NULL state */ |
| 4629 | f_perform_lu(); |
| 4630 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4631 | |
| 4632 | /* Send some random unit data, the MSC/VLR should send a release |
| 4633 | * immediately. */ |
| 4634 | SGsAP.send(ts_SGsAP_UL_UD(pars.imsi,'1234'O)); |
| 4635 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, IMSI_detached_for_EPS_nonEPS_services)); |
| 4636 | |
| 4637 | f_sgsap_bssmap_screening(); |
| 4638 | |
| 4639 | setverdict(pass); |
| 4640 | } |
| 4641 | testcase TC_sgsap_unexp_ud() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4642 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4643 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4644 | f_init(1, true); |
| 4645 | pars := f_init_pars(11821, true); |
| 4646 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_unexp_ud), pars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4647 | vc_conn.done; |
| 4648 | } |
| 4649 | |
| 4650 | /* Send unsolicited unit-data through the SGs interface */ |
| 4651 | private function f_tc_sgsap_unsol_ud(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4652 | f_init_handler(pars); |
| 4653 | f_sleep(1.0); |
| 4654 | |
| 4655 | /* This simulates what happens when the MME attempts to send unitdata |
| 4656 | * to a subscriber that is completely unknown to the VLR */ |
| 4657 | |
| 4658 | /* Send some random unit data, the MSC/VLR should send a release |
| 4659 | * immediately. */ |
| 4660 | SGsAP.send(ts_SGsAP_UL_UD(pars.imsi,'1234'O)); |
| 4661 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, IMSI_unknown)); |
| 4662 | |
| 4663 | f_sgsap_bssmap_screening(); |
| 4664 | |
| 4665 | setverdict(pass); |
| 4666 | } |
| 4667 | testcase TC_sgsap_unsol_ud() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4668 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4669 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4670 | f_init(1, true); |
| 4671 | pars := f_init_pars(11822, true); |
| 4672 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_unsol_ud), pars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4673 | vc_conn.done; |
| 4674 | } |
| 4675 | |
| 4676 | private altstep as_other_sms_sgs() runs on BSC_ConnHdlr { |
| 4677 | /* FIXME: Match an actual payload (second questionmark), the type is |
| 4678 | * octetstring, how do we use a tr_PDU_DTAP_MT here? */ |
| 4679 | [] SGsAP.receive(tr_SGsAP_DL_UD(?,?)) { |
| 4680 | setverdict(fail, "Unexpected SMS related PDU from MSC"); |
| 4681 | mtc.stop; |
| 4682 | } |
| 4683 | } |
| 4684 | |
| 4685 | /* receive a MT-SMS delivered from the MSC/SMSC over an already existing SGsAP connection */ |
| 4686 | function f_mt_sms_sgs(inout SmsParameters spars) |
| 4687 | runs on BSC_ConnHdlr { |
| 4688 | var template (value) TPDU_RP_DATA_MS_SGSN tp_mo; |
| 4689 | var template (value) RPDU_MS_SGSN rp_mo; |
| 4690 | var template (value) PDU_ML3_MS_NW l3_mo; |
| 4691 | |
| 4692 | var template TPDU_RP_DATA_SGSN_MS tp_mt; |
| 4693 | var template RPDU_SGSN_MS rp_mt; |
| 4694 | var template PDU_ML3_NW_MS l3_mt; |
| 4695 | |
| 4696 | var PDU_ML3_NW_MS sgsap_l3_mt; |
| 4697 | |
| 4698 | var default d := activate(as_other_sms_sgs()); |
| 4699 | |
| 4700 | /* Expect CP-DATA(RP-DATA(SMS-DELIVER)) */ |
| 4701 | tp_mt := tr_SMS_DELIVER(?, spars.tp.ud, spars.tp.pid, spars.tp.dcs, ?); |
Vadim Yanitskiy | 04dd5f7 | 2019-12-13 15:45:44 +0900 | [diff] [blame] | 4702 | rp_mt := tr_RP_DATA_MT(?, spars.rp.smsc_addr, omit, tp_mt); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4703 | l3_mt := tr_ML3_MT_SMS(?, c_TIF_ORIG, tr_CP_DATA_MT(rp_mt)); |
| 4704 | |
| 4705 | SGsAP.receive(l3_mt) -> value sgsap_l3_mt; |
| 4706 | |
| 4707 | /* Extract relevant identifiers */ |
| 4708 | spars.tid := bit2int(sgsap_l3_mt.tiOrSkip.transactionId.tio); |
| 4709 | spars.rp.msg_ref := sgsap_l3_mt.msgs.sms.cP_DATA.cP_User_Data.cP_RPDU.rP_DATA_SGSN_MS.rP_MessageReference; |
| 4710 | |
| 4711 | /* send CP-ACK for CP-DATA just received */ |
| 4712 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_REPL, ts_CP_ACK_MO); |
| 4713 | |
| 4714 | SGsAP.send(l3_mo); |
| 4715 | |
| 4716 | /* send RP-ACK for RP-DATA */ |
| 4717 | rp_mo := ts_RP_ACK_MO(spars.rp.msg_ref); |
| 4718 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_REPL, ts_CP_DATA_MO(rp_mo)); |
| 4719 | |
| 4720 | SGsAP.send(l3_mo); |
| 4721 | |
| 4722 | /* expect CP-ACK for CP-DATA(RP-ACK) just sent */ |
| 4723 | l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_ORIG, tr_CP_ACK_MT); |
| 4724 | |
| 4725 | SGsAP.receive(l3_mt); |
| 4726 | |
| 4727 | deactivate(d); |
| 4728 | |
| 4729 | setverdict(pass); |
| 4730 | } |
| 4731 | |
| 4732 | /* submit a MO-SMS to MSC/SMSC over an already existing SGsAP connection */ |
| 4733 | function f_mo_sms_sgs(inout SmsParameters spars) |
| 4734 | runs on BSC_ConnHdlr { |
| 4735 | var template (value) TPDU_RP_DATA_MS_SGSN tp_mo; |
| 4736 | var template (value) RPDU_MS_SGSN rp_mo; |
| 4737 | var template (value) PDU_ML3_MS_NW l3_mo; |
| 4738 | |
| 4739 | var template TPDU_RP_DATA_SGSN_MS tp_mt; |
| 4740 | var template RPDU_SGSN_MS rp_mt; |
| 4741 | var template PDU_ML3_NW_MS l3_mt; |
| 4742 | |
| 4743 | var default d := activate(as_other_sms_sgs()); |
| 4744 | |
| 4745 | /* just in case this is routed to SMPP.. */ |
| 4746 | f_create_smpp_expect(hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue)); |
| 4747 | |
| 4748 | tp_mo := ts_SMS_SUBMIT(spars.tp.msg_ref, spars.tp.da, spars.tp.pid, spars.tp.dcs, |
| 4749 | spars.tp.udl, spars.tp.ud); |
Vadim Yanitskiy | 437b5a6 | 2019-12-15 14:13:39 +0900 | [diff] [blame] | 4750 | rp_mo := ts_RP_DATA_MO(spars.rp.msg_ref, omit, spars.rp.smsc_addr, tp_mo); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4751 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_DATA_MO(rp_mo)); |
| 4752 | |
| 4753 | SGsAP.send(l3_mo); |
| 4754 | |
| 4755 | /* receive CP-ACK for CP-DATA above */ |
| 4756 | SGsAP.receive(tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_ACK_MT)); |
| 4757 | |
| 4758 | if (ispresent(spars.exp_rp_err)) { |
| 4759 | /* expect an RP-ERROR message from MSC with given cause */ |
| 4760 | rp_mt := tr_RP_ERROR_MT(spars.rp.msg_ref, spars.exp_rp_err); |
| 4761 | l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_DATA_MT(rp_mt)); |
| 4762 | SGsAP.receive(l3_mt); |
| 4763 | /* send CP-ACK for CP-DATA just received */ |
| 4764 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_ACK_MO); |
| 4765 | SGsAP.send(l3_mo); |
| 4766 | } else { |
| 4767 | /* expect RP-ACK for RP-DATA */ |
| 4768 | rp_mt := tr_RP_ACK_MT(spars.rp.msg_ref); |
| 4769 | l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_DATA_MT(rp_mt)); |
| 4770 | SGsAP.receive(l3_mt); |
| 4771 | /* send CP-ACO for CP-DATA just received */ |
| 4772 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_ACK_MO); |
| 4773 | SGsAP.send(l3_mo); |
| 4774 | } |
| 4775 | |
| 4776 | deactivate(d); |
| 4777 | |
| 4778 | setverdict(pass); |
| 4779 | } |
| 4780 | |
| 4781 | private function f_vty_sms_send_conn_hdlr(charstring imsi, charstring msisdn, charstring text) |
| 4782 | runs on BSC_ConnHdlr { |
| 4783 | f_vty_transceive(MSCVTY, "subscriber imsi "&imsi&" sms sender msisdn "&msisdn&" send "&text); |
| 4784 | } |
| 4785 | |
| 4786 | /* Send a MT SMS via SGs interface */ |
| 4787 | private function f_tc_sgsap_mt_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4788 | f_init_handler(pars); |
| 4789 | f_sgs_perform_lu(); |
| 4790 | f_sleep(1.0); |
| 4791 | var SmsParameters spars := valueof(t_SmsPars); |
| 4792 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 4793 | |
| 4794 | /* Trigger SMS via VTY */ |
| 4795 | f_vty_sms_send_conn_hdlr(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 4796 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4797 | |
| 4798 | /* Expect a paging request and respond accordingly with a service request */ |
| 4799 | SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, SMS_indicator, omit)); |
| 4800 | SGsAP.send(ts_SGsAP_SERVICE_REQ(pars.imsi, SMS_indicator, EMM_CONNECTED)); |
| 4801 | |
| 4802 | /* Connection is now live, receive the MT-SMS */ |
| 4803 | f_mt_sms_sgs(spars); |
| 4804 | |
| 4805 | /* Expect a concluding release from the MSC */ |
| 4806 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, omit)); |
| 4807 | |
| 4808 | /* Make sure that subscriber is still present and the SGs association is in tact (ref-counting) */ |
| 4809 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4810 | |
| 4811 | f_sgsap_bssmap_screening(); |
| 4812 | |
| 4813 | setverdict(pass); |
| 4814 | } |
| 4815 | testcase TC_sgsap_mt_sms() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4816 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4817 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4818 | f_init(1, true); |
| 4819 | pars := f_init_pars(11823, true); |
| 4820 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_mt_sms), pars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4821 | vc_conn.done; |
| 4822 | } |
| 4823 | |
| 4824 | /* Send a MO SMS via SGs interface */ |
| 4825 | private function f_tc_sgsap_mo_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4826 | f_init_handler(pars); |
| 4827 | f_sgs_perform_lu(); |
| 4828 | f_sleep(1.0); |
| 4829 | var SmsParameters spars := valueof(t_SmsPars); |
| 4830 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 4831 | |
| 4832 | /* Send the MO-SMS */ |
| 4833 | f_mo_sms_sgs(spars); |
| 4834 | |
| 4835 | /* Expect a concluding release from the MSC/VLR */ |
| 4836 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, omit)); |
| 4837 | |
| 4838 | /* Make sure that subscriber is still present and the SGs association is in tact (ref-counting) */ |
| 4839 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4840 | |
| 4841 | setverdict(pass); |
| 4842 | |
| 4843 | f_sgsap_bssmap_screening() |
| 4844 | } |
| 4845 | testcase TC_sgsap_mo_sms() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4846 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4847 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4848 | f_init(1, true); |
| 4849 | pars := f_init_pars(11824, true); |
| 4850 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_mo_sms), pars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4851 | vc_conn.done; |
| 4852 | } |
| 4853 | |
| 4854 | /* Trigger sending of an MT sms via VTY but never respond to anything */ |
| 4855 | private function f_tc_sgsap_mt_sms_and_nothing(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4856 | f_init_handler(pars, 170.0); |
| 4857 | f_sgs_perform_lu(); |
| 4858 | f_sleep(1.0); |
| 4859 | |
| 4860 | var SmsParameters spars := valueof(t_SmsPars); |
| 4861 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 4862 | var integer page_count := 0; |
| 4863 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4864 | var template PDU_SGsAP exp_pag_req := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, SMS_indicator, omit); |
| 4865 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4866 | exp_pag_req.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 4867 | |
| 4868 | /* Trigger SMS via VTY */ |
| 4869 | f_vty_sms_send_conn_hdlr(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 4870 | |
Neels Hofmeyr | 1623774 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 4871 | /* Expect the MSC/VLR to page exactly once */ |
| 4872 | SGsAP.receive(exp_pag_req); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4873 | |
| 4874 | /* Wait some time to make sure the MSC is not delivering any further |
| 4875 | * paging messages or anything else that could be unexpected. */ |
| 4876 | timer T := 20.0; |
| 4877 | T.start |
| 4878 | alt { |
| 4879 | [] SGsAP.receive(exp_pag_req) |
| 4880 | { |
| 4881 | setverdict(fail, "paging seems not to stop!"); |
| 4882 | mtc.stop; |
| 4883 | } |
| 4884 | [] SGsAP.receive { |
| 4885 | setverdict(fail, "unexpected SGsAP message received"); |
| 4886 | self.stop; |
| 4887 | } |
| 4888 | [] T.timeout { |
| 4889 | setverdict(pass); |
| 4890 | } |
| 4891 | } |
| 4892 | |
| 4893 | /* Even on a failed paging the SGs Association should stay intact */ |
| 4894 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4895 | |
Philipp Maier | 26bdb8c | 2019-09-24 09:21:12 +0200 | [diff] [blame] | 4896 | /* Make sure that the SMS we just inserted is cleared and the |
| 4897 | * subscriber is expired. This is necessary because otherwise the MSC |
| 4898 | * might re-try the SMS delivery and disturb the following tests. */ |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4899 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 4900 | f_vty_sms_clear(hex2str(g_pars.imsi)); |
| 4901 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4902 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " expire"); |
| 4903 | |
| 4904 | setverdict(pass); |
Neels Hofmeyr | b0f8234 | 2019-03-06 15:36:51 +0100 | [diff] [blame] | 4905 | |
| 4906 | f_sgsap_bssmap_screening(); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4907 | } |
| 4908 | testcase TC_sgsap_mt_sms_and_nothing() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4909 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4910 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4911 | f_init(1, true); |
| 4912 | pars := f_init_pars(11825, true); |
| 4913 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_mt_sms_and_nothing), pars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4914 | vc_conn.done; |
| 4915 | } |
| 4916 | |
| 4917 | /* Trigger sending of an MT sms via VTY but reject the paging immediately */ |
| 4918 | private function f_tc_sgsap_mt_sms_and_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4919 | f_init_handler(pars, 150.0); |
| 4920 | f_sgs_perform_lu(); |
| 4921 | f_sleep(1.0); |
| 4922 | |
| 4923 | var SmsParameters spars := valueof(t_SmsPars); |
| 4924 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 4925 | var integer page_count := 0; |
| 4926 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4927 | var template PDU_SGsAP exp_pag_req := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, SMS_indicator, omit); |
| 4928 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4929 | exp_pag_req.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 4930 | |
| 4931 | /* Trigger SMS via VTY */ |
| 4932 | f_vty_sms_send_conn_hdlr(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 4933 | |
| 4934 | /* Expect a paging request and reject it immediately */ |
| 4935 | SGsAP.receive(exp_pag_req); |
| 4936 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, IMSI_unknown)); |
| 4937 | |
| 4938 | /* The MSC/VLR should no longer try to page once the paging has been |
| 4939 | * rejected. Wait some time and check if there are no unexpected |
| 4940 | * messages on the SGs interface. */ |
| 4941 | timer T := 20.0; |
| 4942 | T.start |
| 4943 | alt { |
| 4944 | [] SGsAP.receive(exp_pag_req) |
| 4945 | { |
| 4946 | setverdict(fail, "paging seems not to stop!"); |
| 4947 | mtc.stop; |
| 4948 | } |
| 4949 | [] SGsAP.receive { |
| 4950 | setverdict(fail, "unexpected SGsAP message received"); |
| 4951 | self.stop; |
| 4952 | } |
| 4953 | [] T.timeout { |
| 4954 | setverdict(pass); |
| 4955 | } |
| 4956 | } |
| 4957 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 4958 | f_vty_sms_clear(hex2str(g_pars.imsi)); |
| 4959 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4960 | /* A rejected paging with IMSI_unknown (see above) should always send |
| 4961 | * the SGs association to NULL. */ |
| 4962 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4963 | |
| 4964 | f_sgsap_bssmap_screening(); |
| 4965 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4966 | setverdict(pass); |
| 4967 | } |
| 4968 | testcase TC_sgsap_mt_sms_and_reject() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4969 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4970 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4971 | f_init(1, true); |
| 4972 | pars := f_init_pars(11826, true); |
| 4973 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_mt_sms_and_reject), pars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4974 | vc_conn.done; |
| 4975 | } |
| 4976 | |
| 4977 | /* Perform an MT CSDB call including LU */ |
| 4978 | private function f_mt_lu_and_csfb_call(charstring id, BSC_ConnHdlrPars pars, boolean bssmap_lu) runs on BSC_ConnHdlr { |
| 4979 | f_init_handler(pars); |
| 4980 | |
| 4981 | /* Be sure that the BSSMAP reset is done before we begin. */ |
| 4982 | f_sleep(2.0); |
| 4983 | |
| 4984 | /* Testcase variation: See what happens when we do a regular BSSMAP |
| 4985 | * LU first (this should not hurt in any way!) */ |
| 4986 | if (bssmap_lu) { |
| 4987 | f_perform_lu(); |
| 4988 | } |
| 4989 | |
| 4990 | f_sgs_perform_lu(); |
| 4991 | f_sleep(1.0); |
| 4992 | |
| 4993 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4994 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4995 | |
| 4996 | /* Initiate a call via MNCC interface */ |
| 4997 | f_mt_call_initate(cpars); |
| 4998 | |
| 4999 | /* Expect a paging request and respond accordingly with a service request */ |
| 5000 | SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)); |
| 5001 | SGsAP.send(ts_SGsAP_SERVICE_REQ(pars.imsi, CS_call_indicator, EMM_CONNECTED)); |
| 5002 | |
| 5003 | /* Complete the call, hold it for some time and then tear it down */ |
| 5004 | f_mt_call_complete(cpars); |
| 5005 | f_sleep(3.0); |
Harald Welte | 4c422b7 | 2019-02-17 16:27:10 +0100 | [diff] [blame] | 5006 | f_call_hangup(cpars, true, is_csfb := true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5007 | |
| 5008 | /* Make sure that subscriber is still present and the SGs association is in tact (ref-counting) */ |
| 5009 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5010 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5011 | /* Test for successful return by triggering a paging, when the paging |
| 5012 | * request is received via SGs, we can be sure that the MSC/VLR has |
| 5013 | * recognized that the UE is now back on 4G */ |
| 5014 | f_sleep(1.0); |
| 5015 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 5016 | alt { |
| 5017 | [] SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)) { |
| 5018 | setverdict(pass); |
| 5019 | } |
| 5020 | [] SGsAP.receive { |
| 5021 | setverdict(fail, "Received unexpected message on SGs"); |
| 5022 | } |
| 5023 | } |
| 5024 | |
| 5025 | f_sgsap_bssmap_screening(); |
| 5026 | |
| 5027 | setverdict(pass); |
| 5028 | } |
| 5029 | |
| 5030 | /* Perform a regular BSSAP LU first, do a SGSAP LU and then make a CSFB call */ |
| 5031 | private function f_tc_bssap_lu_sgsap_lu_and_mt_call(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5032 | f_mt_lu_and_csfb_call(id, pars, true); |
| 5033 | } |
| 5034 | testcase TC_bssap_lu_sgsap_lu_and_mt_call() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5035 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5036 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5037 | f_init(1, true); |
| 5038 | pars := f_init_pars(118139, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5039 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5040 | vc_conn := f_start_handler_with_pars(refers(f_tc_bssap_lu_sgsap_lu_and_mt_call), pars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5041 | vc_conn.done; |
| 5042 | } |
| 5043 | |
| 5044 | |
| 5045 | /* Perform a SGSAP LU and then make a CSFB call */ |
| 5046 | private function f_tc_sgsap_lu_and_mt_call(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5047 | f_mt_lu_and_csfb_call(id, pars, false); |
| 5048 | } |
| 5049 | testcase TC_sgsap_lu_and_mt_call() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5050 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5051 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5052 | f_init(1, true); |
| 5053 | pars := f_init_pars(11827, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5054 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5055 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_lu_and_mt_call), pars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5056 | vc_conn.done; |
| 5057 | } |
| 5058 | |
Philipp Maier | 628c005 | 2019-04-09 17:36:57 +0200 | [diff] [blame] | 5059 | /* Simulate an HLR/VLR failure */ |
| 5060 | private function f_tc_sgsap_vlr_failure(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5061 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 5062 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5063 | |
| 5064 | var PDU_SGsAP lur; |
| 5065 | |
| 5066 | f_init_handler(pars); |
| 5067 | |
| 5068 | /* Attempt location update (which is expected to fail) */ |
| 5069 | lur := valueof(ts_SGsAP_LU_REQ(g_pars.imsi, mme_name, IMSI_attach, |
| 5070 | ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5071 | SGsAP.send(lur); |
| 5072 | |
| 5073 | /* Respond to SGsAP-RESET-INDICATION from VLR */ |
| 5074 | alt { |
| 5075 | [] SGsAP.receive(tr_SGsAP_RESET_IND_VLR(vlr_name)); { |
| 5076 | SGsAP.send(valueof(ts_SGsAP_RESET_ACK_MME(mme_name))); |
| 5077 | setverdict(pass); |
| 5078 | } |
| 5079 | [] SGsAP.receive { |
| 5080 | setverdict(fail, "Received unexpected message on SGs"); |
| 5081 | } |
| 5082 | } |
| 5083 | |
| 5084 | f_sleep(1.0); |
| 5085 | setverdict(pass); |
| 5086 | } |
| 5087 | testcase TC_sgsap_vlr_failure() runs on MTC_CT { |
| 5088 | var BSC_ConnHdlrPars pars; |
| 5089 | var BSC_ConnHdlr vc_conn; |
| 5090 | f_init(1, true, false); |
| 5091 | pars := f_init_pars(11811, true, false); |
| 5092 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_vlr_failure), pars); |
| 5093 | vc_conn.done; |
| 5094 | } |
| 5095 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5096 | /* SGs TODO: |
| 5097 | * LU attempt for IMSI without NAM_PS in HLR |
| 5098 | * LU attempt with AUTH FAIL due to invalid RES/SRES |
| 5099 | * LU attempt with no response from HLR (VLR should timeout + LU REJ) |
| 5100 | * LU attempt with new TMSI but without TMSI REALL CMPL baco to VLR |
| 5101 | * implicit IMSI detach from EPS |
| 5102 | * implicit IMSI detach from non-EPS |
| 5103 | * MM INFO |
| 5104 | * |
| 5105 | */ |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 5106 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5107 | private function f_tc_ho_inter_bsc_unknown_cell(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5108 | f_init_handler(pars); |
| 5109 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5110 | |
| 5111 | f_perform_lu(); |
| 5112 | f_mo_call_establish(cpars); |
| 5113 | |
| 5114 | f_sleep(1.0); |
| 5115 | |
| 5116 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_BETTER_CELL; |
| 5117 | var BssmapCause cause := enum2int(cause_val); |
| 5118 | |
| 5119 | var template BSSMAP_FIELD_CellIdentificationList cil; |
| 5120 | cil := { cIl_LAI := { ts_BSSMAP_CI_LAI('023'H, '42'H, 999) } }; |
| 5121 | |
| 5122 | BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 5123 | BSSAP.receive(tr_BSSMAP_HandoverRequiredReject); |
| 5124 | |
| 5125 | f_call_hangup(cpars, true); |
| 5126 | } |
| 5127 | testcase TC_ho_inter_bsc_unknown_cell() runs on MTC_CT { |
| 5128 | var BSC_ConnHdlr vc_conn; |
| 5129 | f_init(); |
| 5130 | |
| 5131 | vc_conn := f_start_handler(refers(f_tc_ho_inter_bsc_unknown_cell), 53); |
| 5132 | vc_conn.done; |
| 5133 | } |
| 5134 | |
| 5135 | private altstep as_mgcp_ack_all_mdcx(CallParameters cpars) runs on BSC_ConnHdlr { |
| 5136 | var MgcpCommand mgcp_cmd; |
| 5137 | [] MGCP.receive(tr_MDCX) -> value mgcp_cmd { |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 5138 | var SDP_Message sdp := valueof(ts_SDP(cpars.mgw_conn_2.mgw_rtp_ip, cpars.mgw_conn_2.mgw_rtp_ip, |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5139 | hex2str(cpars.mgcp_call_id), "42", |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 5140 | cpars.mgw_conn_2.mgw_rtp_port, |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5141 | { int2str(cpars.rtp_payload_type) }, |
| 5142 | { valueof(ts_SDP_rtpmap(cpars.rtp_payload_type, |
| 5143 | cpars.rtp_sdp_format)), |
| 5144 | valueof(ts_SDP_ptime(20)) })); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 5145 | MGCP.send(ts_MDCX_ACK(mgcp_cmd.line.trans_id, cpars.mgw_conn_2.mgcp_connection_id, sdp)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5146 | repeat; |
| 5147 | } |
| 5148 | } |
| 5149 | |
| 5150 | private function f_tc_ho_inter_bsc0(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5151 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5152 | |
| 5153 | f_init_handler(pars); |
| 5154 | |
| 5155 | f_vty_transceive(MSCVTY, "configure terminal"); |
| 5156 | f_vty_transceive(MSCVTY, "msc"); |
| 5157 | f_vty_transceive(MSCVTY, "neighbor a cgi 262 42 23 42 ran-pc 0.24.1"); |
| 5158 | f_vty_transceive(MSCVTY, "neighbor a lac 5 ran-pc 0.24.2"); |
| 5159 | f_vty_transceive(MSCVTY, "exit"); |
| 5160 | f_vty_transceive(MSCVTY, "exit"); |
| 5161 | |
| 5162 | f_perform_lu(); |
| 5163 | f_mo_call_establish(cpars); |
| 5164 | |
| 5165 | f_sleep(1.0); |
| 5166 | |
| 5167 | var default ack_mdcx := activate(as_mgcp_ack_all_mdcx(cpars)); |
| 5168 | |
| 5169 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_BETTER_CELL; |
| 5170 | var BssmapCause cause := enum2int(cause_val); |
| 5171 | |
| 5172 | var template BSSMAP_FIELD_CellIdentificationList cil; |
| 5173 | cil := { cIl_LAI := { ts_BSSMAP_CI_LAI('023'H, '42'H, 5) } }; |
| 5174 | |
| 5175 | /* old BSS sends Handover Required */ |
| 5176 | BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 5177 | |
| 5178 | /* Now the action goes on in f_tc_ho_inter_bsc1() */ |
| 5179 | |
| 5180 | /* MSC forwards the RR Handover Command to old BSS */ |
| 5181 | var PDU_BSSAP ho_command; |
| 5182 | BSSAP.receive(tr_BSSMAP_HandoverCommand) -> value ho_command; |
| 5183 | |
| 5184 | log("GOT HandoverCommand", ho_command); |
| 5185 | |
| 5186 | BSSAP.receive(tr_BSSMAP_HandoverSucceeded); |
| 5187 | |
| 5188 | /* f_tc_ho_inter_bsc1() completes Handover, then expecting a Clear here. */ |
| 5189 | f_expect_clear(); |
| 5190 | |
| 5191 | log("FIRST inter-BSC Handover done"); |
| 5192 | |
| 5193 | |
| 5194 | /* ------------------------ */ |
| 5195 | |
| 5196 | /* Ok, that went well, now the other BSC is handovering back here -- |
| 5197 | * from now on this here is the new BSS. */ |
| 5198 | f_create_bssmap_exp_handoverRequest(193); |
| 5199 | |
| 5200 | var PDU_BSSAP ho_request; |
| 5201 | BSSAP.receive(tr_BSSMAP_HandoverRequest) -> value ho_request; |
| 5202 | |
| 5203 | /* new BSS composes a RR Handover Command */ |
| 5204 | var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 5205 | var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd); |
| 5206 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 5207 | BSSAP.send(ts_BSSMAP_HandoverRequestAcknowledge(rr_ho_cmd_enc, lengthof(rr_ho_cmd_enc), |
| 5208 | tla, ts_BSSMAP_IE_SpeechCodec({ts_CodecFR}))); |
| 5209 | |
| 5210 | /* Now f_tc_ho_inter_bsc1() expects HandoverCommand */ |
| 5211 | |
| 5212 | f_sleep(0.5); |
| 5213 | |
| 5214 | /* Notify that the MS is now over here */ |
| 5215 | |
| 5216 | BSSAP.send(ts_BSSMAP_HandoverDetect); |
| 5217 | f_sleep(0.1); |
| 5218 | BSSAP.send(ts_BSSMAP_HandoverComplete); |
| 5219 | |
| 5220 | f_sleep(3.0); |
| 5221 | |
| 5222 | deactivate(ack_mdcx); |
| 5223 | |
| 5224 | var default ccrel := activate(as_optional_cc_rel(cpars, true)); |
| 5225 | |
| 5226 | /* blatant cheating */ |
| 5227 | var N_Sd_Array last_n_sd := f_bssmap_last_n_sd(); |
| 5228 | last_n_sd[0] := 3; |
| 5229 | f_bssmap_continue_after_n_sd(last_n_sd); |
| 5230 | |
| 5231 | f_call_hangup(cpars, true); |
| 5232 | f_sleep(1.0); |
| 5233 | deactivate(ccrel); |
| 5234 | |
| 5235 | setverdict(pass); |
| 5236 | } |
| 5237 | private function f_tc_ho_inter_bsc1(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5238 | f_init_handler(pars); |
| 5239 | f_create_bssmap_exp_handoverRequest(194); |
| 5240 | |
| 5241 | var PDU_BSSAP ho_request; |
| 5242 | BSSAP.receive(tr_BSSMAP_HandoverRequest) -> value ho_request; |
| 5243 | |
| 5244 | /* new BSS composes a RR Handover Command */ |
| 5245 | var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 5246 | var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd); |
| 5247 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 5248 | BSSAP.send(ts_BSSMAP_HandoverRequestAcknowledge(rr_ho_cmd_enc, lengthof(rr_ho_cmd_enc), |
| 5249 | tla, ts_BSSMAP_IE_SpeechCodec({ts_CodecFR}))); |
| 5250 | |
| 5251 | /* Now f_tc_ho_inter_bsc0() expects HandoverCommand */ |
| 5252 | |
| 5253 | f_sleep(0.5); |
| 5254 | |
| 5255 | /* Notify that the MS is now over here */ |
| 5256 | |
| 5257 | BSSAP.send(ts_BSSMAP_HandoverDetect); |
| 5258 | f_sleep(0.1); |
| 5259 | BSSAP.send(ts_BSSMAP_HandoverComplete); |
| 5260 | |
| 5261 | f_sleep(3.0); |
| 5262 | |
| 5263 | /* Now I'd like to f_call_hangup() but we don't know any cpars here. So |
| 5264 | * ... handover back to the first BSC :P */ |
| 5265 | |
| 5266 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_BETTER_CELL; |
| 5267 | var BssmapCause cause := enum2int(cause_val); |
| 5268 | |
| 5269 | var template BSSMAP_FIELD_CellIdentificationList cil; |
| 5270 | cil := { cIl_LAI := { ts_BSSMAP_CI_LAI('262'H, '42'H, 23) } }; |
| 5271 | |
| 5272 | /* old BSS sends Handover Required */ |
| 5273 | BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 5274 | |
| 5275 | /* Now the action goes on in f_tc_ho_inter_bsc0() */ |
| 5276 | |
| 5277 | /* MSC forwards the RR Handover Command to old BSS */ |
| 5278 | var PDU_BSSAP ho_command; |
| 5279 | BSSAP.receive(tr_BSSMAP_HandoverCommand) -> value ho_command; |
| 5280 | |
| 5281 | log("GOT HandoverCommand", ho_command); |
| 5282 | |
| 5283 | BSSAP.receive(tr_BSSMAP_HandoverSucceeded); |
| 5284 | |
| 5285 | /* f_tc_ho_inter_bsc1() completes Handover, then expecting a Clear here. */ |
| 5286 | f_expect_clear(); |
| 5287 | setverdict(pass); |
| 5288 | } |
| 5289 | testcase TC_ho_inter_bsc() runs on MTC_CT { |
| 5290 | var BSC_ConnHdlr vc_conn0; |
| 5291 | var BSC_ConnHdlr vc_conn1; |
| 5292 | f_init(2); |
| 5293 | |
| 5294 | var BSC_ConnHdlrPars pars0 := f_init_pars(53); |
| 5295 | var BSC_ConnHdlrPars pars1 := f_init_pars(53); |
| 5296 | |
| 5297 | vc_conn0 := f_start_handler_with_pars(refers(f_tc_ho_inter_bsc0), pars0, 0); |
| 5298 | vc_conn1 := f_start_handler_with_pars(refers(f_tc_ho_inter_bsc1), pars1, 1); |
| 5299 | vc_conn0.done; |
| 5300 | vc_conn1.done; |
| 5301 | } |
| 5302 | |
| 5303 | function f_ML3_patch_seq_nr_MS_NW(in uint2_t seq_nr, inout octetstring enc_l3) { |
| 5304 | log("MS_NW patching N(SD)=", seq_nr, " into dtap ", enc_l3); |
| 5305 | enc_l3[2] := (enc_l3[2] and4b '3f'O) or4b bit2oct(int2bit(seq_nr, 8) << 6); |
| 5306 | log("MS_NW patched enc_l3: ", enc_l3); |
| 5307 | } |
| 5308 | |
| 5309 | private function f_tc_ho_inter_msc_out(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5310 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5311 | var hexstring ho_number := f_gen_msisdn(99999); |
| 5312 | |
| 5313 | f_init_handler(pars); |
| 5314 | |
| 5315 | f_create_mncc_expect(hex2str(ho_number)); |
| 5316 | |
| 5317 | f_vty_transceive(MSCVTY, "configure terminal"); |
| 5318 | f_vty_transceive(MSCVTY, "msc"); |
| 5319 | f_vty_transceive(MSCVTY, "neighbor a cgi 017 017 1 1 msc-ipa-name msc-017-017-1"); |
| 5320 | f_vty_transceive(MSCVTY, "exit"); |
| 5321 | f_vty_transceive(MSCVTY, "exit"); |
| 5322 | |
| 5323 | f_perform_lu(); |
| 5324 | f_mo_call_establish(cpars); |
| 5325 | |
| 5326 | f_sleep(1.0); |
| 5327 | |
| 5328 | var default ack_mdcx := activate(as_mgcp_ack_all_mdcx(cpars)); |
| 5329 | |
| 5330 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_BETTER_CELL; |
| 5331 | var BssmapCause cause := enum2int(cause_val); |
| 5332 | |
| 5333 | var template BSSMAP_FIELD_CellIdentificationList cil; |
| 5334 | cil := { cIl_LAI := { ts_BSSMAP_CI_LAI('017'H, '017'H, 1) } }; |
| 5335 | |
| 5336 | /* old BSS sends Handover Required */ |
| 5337 | BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 5338 | |
| 5339 | /* The target cell 017-017 LAC 1 is configured to be a remote MSC of name "msc-017-017-1". |
| 5340 | * This MSC tries to reach the other MSC via GSUP. */ |
| 5341 | |
| 5342 | var octetstring remote_msc_name := '6D73632D3031372D3031372D3100'O; /* "msc-017-017-1\0" as octetstring */ |
| 5343 | var GSUP_PDU prep_ho_req; |
| 5344 | GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST, |
| 5345 | pars.imsi, destination_name := remote_msc_name)) -> value prep_ho_req; |
| 5346 | |
| 5347 | var GSUP_IeValue source_name_ie; |
| 5348 | f_gsup_find_ie(prep_ho_req, OSMO_GSUP_SOURCE_NAME_IE, source_name_ie); |
| 5349 | var octetstring local_msc_name := source_name_ie.source_name; |
| 5350 | |
| 5351 | /* Remote MSC has figured out its BSC and signals success */ |
| 5352 | var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 5353 | var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd); |
| 5354 | var PDU_BSSAP ho_req_ack := valueof(ts_BSSMAP_HandoverRequestAcknowledge(rr_ho_cmd_enc, lengthof(rr_ho_cmd_enc), |
| 5355 | aoIPTransportLayer := omit, |
| 5356 | speechCodec := ts_BSSMAP_IE_SpeechCodec({ts_CodecFR}))); |
| 5357 | GSUP.send(ts_GSUP_E_PrepareHandoverResult( |
| 5358 | pars.imsi, |
| 5359 | ho_number, |
| 5360 | remote_msc_name, local_msc_name, |
| 5361 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, enc_PDU_BSSAP(ho_req_ack))))); |
| 5362 | |
| 5363 | /* MSC forwards the RR Handover Command to old BSS */ |
| 5364 | BSSAP.receive(tr_BSSMAP_HandoverCommand); |
| 5365 | |
| 5366 | /* The MS shows up at remote new BSS */ |
| 5367 | |
| 5368 | GSUP.send(ts_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PROCESS_ACCESS_SIGNALLING_REQUEST, |
| 5369 | pars.imsi, remote_msc_name, local_msc_name, |
| 5370 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, |
| 5371 | enc_PDU_BSSAP(valueof(ts_BSSMAP_HandoverDetect)))))); |
| 5372 | BSSAP.receive(tr_BSSMAP_HandoverSucceeded); |
| 5373 | f_sleep(0.1); |
| 5374 | |
| 5375 | /* Save the MS sequence counters for use on the other connection */ |
| 5376 | var N_Sd_Array last_n_sd := f_bssmap_last_n_sd(); |
| 5377 | |
| 5378 | GSUP.send(ts_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_SEND_END_SIGNAL_REQUEST, |
| 5379 | pars.imsi, remote_msc_name, local_msc_name, |
| 5380 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, |
| 5381 | enc_PDU_BSSAP(valueof(ts_BSSMAP_HandoverComplete)))))); |
| 5382 | |
| 5383 | /* The local BSS conn clears, all communication goes via remote MSC now */ |
| 5384 | f_expect_clear(); |
| 5385 | |
| 5386 | /**********************************/ |
| 5387 | /* Play through some signalling across the inter-MSC link. |
| 5388 | * This is a copy of f_tc_lu_and_mo_ussd_single_request() translated into GSUP AN-APDUs. */ |
| 5389 | |
| 5390 | if (false) { |
| 5391 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 5392 | invoke_id := 5, /* Phone may not start from 0 or 1 */ |
| 5393 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 5394 | ussd_string := "*#100#" |
| 5395 | ); |
| 5396 | |
| 5397 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 5398 | invoke_id := 5, /* InvokeID shall be the same for both REQ and RSP */ |
| 5399 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 5400 | ussd_string := "Your extension is " & hex2str(g_pars.msisdn) & "\r" |
| 5401 | ) |
| 5402 | |
| 5403 | /* Compose a new SS/REGISTER message with request */ |
| 5404 | var template (value) PDU_ML3_MS_NW ussd_req := ts_ML3_MO_SS_REGISTER( |
| 5405 | tid := 1, /* We just need a single transaction */ |
| 5406 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 5407 | facility := valueof(facility_req) |
| 5408 | ); |
| 5409 | var PDU_ML3_MS_NW ussd_req_v := valueof(ussd_req); |
| 5410 | |
| 5411 | /* Compose SS/RELEASE_COMPLETE template with expected response */ |
| 5412 | var template PDU_ML3_NW_MS ussd_rsp := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 5413 | tid := 1, /* Response should arrive within the same transaction */ |
| 5414 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 5415 | facility := valueof(facility_rsp) |
| 5416 | ); |
| 5417 | |
| 5418 | /* Compose expected MSC -> HLR message */ |
| 5419 | var template GSUP_PDU gsup_req := tr_GSUP_PROC_SS_REQ( |
| 5420 | imsi := g_pars.imsi, |
| 5421 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 5422 | ss := valueof(facility_req) |
| 5423 | ); |
| 5424 | |
| 5425 | /* To be used for sending response with correct session ID */ |
| 5426 | var GSUP_PDU gsup_req_complete; |
| 5427 | |
| 5428 | /* Request own number */ |
| 5429 | /* From remote MSC instead of BSSAP directly */ |
| 5430 | /* Patch the correct N_SD value into the message. */ |
| 5431 | var octetstring l3_enc := enc_PDU_ML3_MS_NW(ussd_req_v); |
| 5432 | var RAN_Emulation.ConnectionData cd; |
| 5433 | f_ML3_patch_seq_nr_MS_NW(f_next_n_sd(last_n_sd, f_ML3_n_sd_idx(ussd_req_v)), l3_enc); |
| 5434 | GSUP.send(ts_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PROCESS_ACCESS_SIGNALLING_REQUEST, |
| 5435 | pars.imsi, remote_msc_name, local_msc_name, |
| 5436 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, |
| 5437 | enc_PDU_BSSAP(valueof(ts_BSSAP_DTAP(l3_enc))) |
| 5438 | )) |
| 5439 | )); |
| 5440 | |
| 5441 | /* Expect GSUP message containing the SS payload */ |
| 5442 | gsup_req_complete := f_expect_gsup_msg(gsup_req); |
| 5443 | |
| 5444 | /* Compose the response from HLR using received session ID */ |
| 5445 | var template GSUP_PDU gsup_rsp := ts_GSUP_PROC_SS_REQ( |
| 5446 | imsi := g_pars.imsi, |
| 5447 | sid := gsup_req_complete.ies[1].val.session_id, |
| 5448 | state := OSMO_GSUP_SESSION_STATE_END, |
| 5449 | ss := valueof(facility_rsp) |
| 5450 | ); |
| 5451 | |
| 5452 | /* Finally, HLR terminates the session */ |
| 5453 | GSUP.send(gsup_rsp); |
| 5454 | |
| 5455 | /* The USSD response goes out to remote MSC, on GSUP E instead of BSSAP */ |
| 5456 | var GSUP_PDU gsup_ussd_rsp; |
| 5457 | GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_FORWARD_ACCESS_SIGNALLING_REQUEST, |
| 5458 | pars.imsi, destination_name := remote_msc_name)) -> value gsup_ussd_rsp; |
| 5459 | |
| 5460 | var GSUP_IeValue an_apdu; |
| 5461 | if (not f_gsup_find_ie(gsup_ussd_rsp, OSMO_GSUP_AN_APDU_IE, an_apdu)) { |
| 5462 | setverdict(fail, "No AN-APDU in received GSUP message. Expected USSD response in DTAP, got", gsup_ussd_rsp); |
| 5463 | mtc.stop; |
| 5464 | } |
| 5465 | var PDU_BSSAP bssap_dtap_mt := dec_PDU_BSSAP(an_apdu.an_apdu.pdu); |
| 5466 | var PDU_ML3_NW_MS dtap_mt := dec_PDU_ML3_NW_MS(bssap_dtap_mt.pdu.dtap); |
| 5467 | log("Expecting", ussd_rsp); |
| 5468 | log("Got", dtap_mt); |
| 5469 | if (not match(dtap_mt, ussd_rsp)) { |
| 5470 | setverdict(fail, "Unexpected GSUP message. Expected USSD response in DTAP, got", gsup_ussd_rsp); |
| 5471 | mtc.stop; |
| 5472 | } |
| 5473 | } |
| 5474 | /**********************************/ |
| 5475 | |
| 5476 | |
| 5477 | /* inter-MSC handover back to the first MSC */ |
| 5478 | f_create_bssmap_exp_handoverRequest(193); |
| 5479 | cil := { cIl_CGI := { ts_BSSMAP_CI_CGI('262'H, '42'H, 23, 42) } }; |
| 5480 | |
| 5481 | /* old BSS sends Handover Required, via inter-MSC E link: like |
| 5482 | * BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 5483 | * but via GSUP */ |
| 5484 | GSUP.send(ts_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_REQUEST, |
| 5485 | pars.imsi, remote_msc_name, local_msc_name, |
| 5486 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, |
| 5487 | enc_PDU_BSSAP(valueof(ts_BSSMAP_HandoverRequired(cause, cil))) |
| 5488 | )) |
| 5489 | )); |
| 5490 | |
| 5491 | /* MSC asks local BSS to prepare Handover to it */ |
| 5492 | BSSAP.receive(tr_BSSMAP_HandoverRequest); |
| 5493 | |
| 5494 | /* Make sure the new BSSAP conn continues with the correct N_SD sequence numbers */ |
| 5495 | f_bssmap_continue_after_n_sd(last_n_sd); |
| 5496 | |
| 5497 | /* new BSS composes a RR Handover Command */ |
| 5498 | rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 5499 | rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd); |
| 5500 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342)); |
| 5501 | BSSAP.send(ts_BSSMAP_HandoverRequestAcknowledge(rr_ho_cmd_enc, lengthof(rr_ho_cmd_enc), |
| 5502 | tla, ts_BSSMAP_IE_SpeechCodec({ts_CodecFR}))); |
| 5503 | |
| 5504 | /* HandoverCommand goes out via remote MSC-I */ |
| 5505 | var GSUP_PDU prep_subsq_ho_res; |
| 5506 | GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_RESULT, |
| 5507 | pars.imsi, destination_name := remote_msc_name)) -> value prep_subsq_ho_res; |
| 5508 | |
| 5509 | /* MS shows up at the local BSS */ |
| 5510 | BSSAP.send(ts_BSSMAP_HandoverDetect); |
| 5511 | f_sleep(0.1); |
| 5512 | BSSAP.send(ts_BSSMAP_HandoverComplete); |
| 5513 | |
| 5514 | /* Handover Succeeded message */ |
| 5515 | GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_FORWARD_ACCESS_SIGNALLING_REQUEST, |
| 5516 | pars.imsi, destination_name := remote_msc_name)); |
| 5517 | |
| 5518 | /* MS has handovered to here, Clear Command goes out via remote MSC-I -- in form of a GSUP Close. */ |
| 5519 | GSUP.receive(tr_GSUP_E_NO_PDU(OSMO_GSUP_MSGT_E_CLOSE, |
| 5520 | pars.imsi, destination_name := remote_msc_name)); |
| 5521 | |
| 5522 | /* Handover ends successfully. Call goes on for a little longer and then we hang up. */ |
| 5523 | |
| 5524 | f_sleep(1.0); |
| 5525 | deactivate(ack_mdcx); |
| 5526 | |
| 5527 | /* FIXME: the inter-MSC call has put a number of MNCC messages in the queue, which above code should expect and |
| 5528 | * clear out. The f_call_hangup() expects an MNCC_REL_IND, so, for the time being, just clear the MNCC messages |
| 5529 | * before starting the call hangup. Instead of this, the individual messages should be tested for above. */ |
| 5530 | MNCC.clear; |
| 5531 | |
| 5532 | var default ccrel := activate(as_optional_cc_rel(cpars, true)); |
| 5533 | f_call_hangup(cpars, true); |
| 5534 | f_sleep(1.0); |
| 5535 | deactivate(ccrel); |
| 5536 | |
| 5537 | setverdict(pass); |
| 5538 | } |
| 5539 | testcase TC_ho_inter_msc_out() runs on MTC_CT { |
| 5540 | var BSC_ConnHdlr vc_conn; |
| 5541 | f_init(1); |
| 5542 | |
| 5543 | var BSC_ConnHdlrPars pars := f_init_pars(54); |
| 5544 | |
| 5545 | vc_conn := f_start_handler_with_pars(refers(f_tc_ho_inter_msc_out), pars, 0); |
| 5546 | vc_conn.done; |
| 5547 | } |
| 5548 | |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 5549 | private function f_tc_lu_imsi_auth_tmsi_check_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5550 | pars.net.expect_auth := true; |
| 5551 | pars.net.expect_imei := true; |
| 5552 | f_init_handler(pars); |
| 5553 | f_perform_lu(); |
| 5554 | } |
| 5555 | testcase TC_lu_imsi_auth_tmsi_check_imei() runs on MTC_CT { |
| 5556 | var BSC_ConnHdlr vc_conn; |
| 5557 | f_init(); |
| 5558 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 5559 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 5560 | |
| 5561 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei), 5); |
| 5562 | vc_conn.done; |
| 5563 | } |
| 5564 | |
| 5565 | private function f_tc_lu_imsi_auth3g_tmsi_check_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5566 | pars.net.expect_auth := true; |
| 5567 | pars.use_umts_aka := true; |
| 5568 | pars.net.expect_imei := true; |
| 5569 | f_init_handler(pars); |
| 5570 | f_perform_lu(); |
| 5571 | } |
| 5572 | testcase TC_lu_imsi_auth3g_tmsi_check_imei() runs on MTC_CT { |
| 5573 | var BSC_ConnHdlr vc_conn; |
| 5574 | f_init(); |
| 5575 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 5576 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 5577 | |
| 5578 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth3g_tmsi_check_imei), 5); |
| 5579 | vc_conn.done; |
| 5580 | } |
| 5581 | |
| 5582 | private function f_tc_lu_imsi_noauth_tmsi_check_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5583 | pars.net.expect_imei := true; |
| 5584 | f_init_handler(pars); |
| 5585 | f_perform_lu(); |
| 5586 | } |
| 5587 | testcase TC_lu_imsi_noauth_tmsi_check_imei() runs on MTC_CT { |
| 5588 | var BSC_ConnHdlr vc_conn; |
| 5589 | f_init(); |
| 5590 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 5591 | |
| 5592 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_tmsi_check_imei), 5); |
| 5593 | vc_conn.done; |
| 5594 | } |
| 5595 | |
| 5596 | private function f_tc_lu_imsi_noauth_notmsi_check_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5597 | pars.net.expect_tmsi := false; |
| 5598 | pars.net.expect_imei := true; |
| 5599 | f_init_handler(pars); |
| 5600 | f_perform_lu(); |
| 5601 | } |
| 5602 | testcase TC_lu_imsi_noauth_notmsi_check_imei() runs on MTC_CT { |
| 5603 | var BSC_ConnHdlr vc_conn; |
| 5604 | f_init(); |
| 5605 | f_vty_config(MSCVTY, "msc", "no assign-tmsi"); |
| 5606 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 5607 | |
| 5608 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_notmsi_check_imei), 5); |
| 5609 | vc_conn.done; |
| 5610 | } |
| 5611 | |
| 5612 | private function f_tc_lu_imsi_auth_tmsi_check_imei_nack(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5613 | var PDU_ML3_MS_NW l3_lu; |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 5614 | |
| 5615 | pars.net.expect_auth := true; |
| 5616 | pars.net.expect_imei := true; |
| 5617 | pars.net.check_imei_result := OSMO_GSUP_IMEI_RESULT_NACK; |
| 5618 | f_init_handler(pars); |
| 5619 | |
| 5620 | /* Cannot use f_perform_lu() as we expect a reject */ |
| 5621 | l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 5622 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 5623 | f_bssap_compl_l3(l3_lu); |
| 5624 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 5625 | |
| 5626 | f_mm_common(); |
| 5627 | f_msc_lu_hlr(); |
| 5628 | f_mm_imei(); |
Oliver Smith | 91bfa1c | 2019-07-19 15:01:15 +0200 | [diff] [blame] | 5629 | f_expect_lu_reject(); |
Oliver Smith | 690d60f | 2019-07-23 13:09:08 +0200 | [diff] [blame] | 5630 | f_expect_clear(); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 5631 | } |
| 5632 | testcase TC_lu_imsi_auth_tmsi_check_imei_nack() runs on MTC_CT { |
| 5633 | var BSC_ConnHdlr vc_conn; |
| 5634 | f_init(); |
| 5635 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 5636 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 5637 | |
| 5638 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_nack), 5); |
| 5639 | vc_conn.done; |
| 5640 | } |
| 5641 | |
| 5642 | private function f_tc_lu_imsi_auth_tmsi_check_imei_err(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5643 | var PDU_ML3_MS_NW l3_lu; |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 5644 | |
| 5645 | pars.net.expect_auth := true; |
| 5646 | pars.net.expect_imei := true; |
| 5647 | pars.net.check_imei_error := true; |
| 5648 | f_init_handler(pars); |
| 5649 | |
| 5650 | /* Cannot use f_perform_lu() as we expect a reject */ |
| 5651 | l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 5652 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 5653 | f_bssap_compl_l3(l3_lu); |
| 5654 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 5655 | |
| 5656 | f_mm_common(); |
| 5657 | f_msc_lu_hlr(); |
| 5658 | f_mm_imei(); |
Oliver Smith | 91bfa1c | 2019-07-19 15:01:15 +0200 | [diff] [blame] | 5659 | f_expect_lu_reject(); |
Oliver Smith | 690d60f | 2019-07-23 13:09:08 +0200 | [diff] [blame] | 5660 | f_expect_clear(); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 5661 | } |
| 5662 | testcase TC_lu_imsi_auth_tmsi_check_imei_err() runs on MTC_CT { |
| 5663 | var BSC_ConnHdlr vc_conn; |
| 5664 | f_init(); |
| 5665 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 5666 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 5667 | |
| 5668 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_err), 5); |
| 5669 | vc_conn.done; |
| 5670 | } |
| 5671 | |
| 5672 | private function f_tc_lu_imsi_auth_tmsi_check_imei_early(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5673 | pars.net.expect_auth := true; |
| 5674 | pars.net.expect_imei_early := true; |
| 5675 | f_init_handler(pars); |
| 5676 | f_perform_lu(); |
| 5677 | } |
| 5678 | testcase TC_lu_imsi_auth_tmsi_check_imei_early() runs on MTC_CT { |
| 5679 | var BSC_ConnHdlr vc_conn; |
| 5680 | f_init(); |
| 5681 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 5682 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 5683 | |
| 5684 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_early), 5); |
| 5685 | vc_conn.done; |
| 5686 | } |
| 5687 | |
| 5688 | private function f_tc_lu_imsi_auth3g_tmsi_check_imei_early(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5689 | pars.net.expect_auth := true; |
| 5690 | pars.use_umts_aka := true; |
| 5691 | pars.net.expect_imei_early := true; |
| 5692 | f_init_handler(pars); |
| 5693 | f_perform_lu(); |
| 5694 | } |
| 5695 | testcase TC_lu_imsi_auth3g_tmsi_check_imei_early() runs on MTC_CT { |
| 5696 | var BSC_ConnHdlr vc_conn; |
| 5697 | f_init(); |
| 5698 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 5699 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 5700 | |
| 5701 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth3g_tmsi_check_imei_early), 5); |
| 5702 | vc_conn.done; |
| 5703 | } |
| 5704 | |
| 5705 | private function f_tc_lu_imsi_noauth_tmsi_check_imei_early(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5706 | pars.net.expect_imei_early := true; |
| 5707 | f_init_handler(pars); |
| 5708 | f_perform_lu(); |
| 5709 | } |
| 5710 | testcase TC_lu_imsi_noauth_tmsi_check_imei_early() runs on MTC_CT { |
| 5711 | var BSC_ConnHdlr vc_conn; |
| 5712 | f_init(); |
| 5713 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 5714 | |
| 5715 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_tmsi_check_imei_early), 5); |
| 5716 | vc_conn.done; |
| 5717 | } |
| 5718 | |
| 5719 | private function f_tc_lu_imsi_noauth_notmsi_check_imei_early(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5720 | pars.net.expect_tmsi := false; |
| 5721 | pars.net.expect_imei_early := true; |
| 5722 | f_init_handler(pars); |
| 5723 | f_perform_lu(); |
| 5724 | } |
| 5725 | testcase TC_lu_imsi_noauth_notmsi_check_imei_early() runs on MTC_CT { |
| 5726 | var BSC_ConnHdlr vc_conn; |
| 5727 | f_init(); |
| 5728 | f_vty_config(MSCVTY, "msc", "no assign-tmsi"); |
| 5729 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 5730 | |
| 5731 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_notmsi_check_imei_early), 5); |
| 5732 | vc_conn.done; |
| 5733 | } |
| 5734 | |
| 5735 | private function f_tc_lu_imsi_auth_tmsi_check_imei_early_nack(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5736 | var PDU_ML3_MS_NW l3_lu; |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 5737 | |
| 5738 | pars.net.expect_auth := true; |
| 5739 | pars.net.expect_imei_early := true; |
| 5740 | pars.net.check_imei_result := OSMO_GSUP_IMEI_RESULT_NACK; |
| 5741 | f_init_handler(pars); |
| 5742 | |
| 5743 | /* Cannot use f_perform_lu() as we expect a reject */ |
| 5744 | l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 5745 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 5746 | f_bssap_compl_l3(l3_lu); |
| 5747 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 5748 | |
| 5749 | f_mm_imei_early(); |
Oliver Smith | 91bfa1c | 2019-07-19 15:01:15 +0200 | [diff] [blame] | 5750 | f_expect_lu_reject(); |
Oliver Smith | 690d60f | 2019-07-23 13:09:08 +0200 | [diff] [blame] | 5751 | f_expect_clear(); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 5752 | } |
| 5753 | testcase TC_lu_imsi_auth_tmsi_check_imei_early_nack() runs on MTC_CT { |
| 5754 | var BSC_ConnHdlr vc_conn; |
| 5755 | f_init(); |
| 5756 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 5757 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 5758 | |
| 5759 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_early_nack), 5); |
| 5760 | vc_conn.done; |
| 5761 | } |
| 5762 | |
| 5763 | private function f_tc_lu_imsi_auth_tmsi_check_imei_early_err(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5764 | var PDU_ML3_MS_NW l3_lu; |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 5765 | |
| 5766 | pars.net.expect_auth := true; |
| 5767 | pars.net.expect_imei_early := true; |
| 5768 | pars.net.check_imei_error := true; |
| 5769 | f_init_handler(pars); |
| 5770 | |
| 5771 | /* Cannot use f_perform_lu() as we expect a reject */ |
| 5772 | l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 5773 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 5774 | f_bssap_compl_l3(l3_lu); |
| 5775 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 5776 | |
| 5777 | f_mm_imei_early(); |
Oliver Smith | 91bfa1c | 2019-07-19 15:01:15 +0200 | [diff] [blame] | 5778 | f_expect_lu_reject(); |
Oliver Smith | 690d60f | 2019-07-23 13:09:08 +0200 | [diff] [blame] | 5779 | f_expect_clear(); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 5780 | } |
| 5781 | testcase TC_lu_imsi_auth_tmsi_check_imei_early_err() runs on MTC_CT { |
| 5782 | var BSC_ConnHdlr vc_conn; |
| 5783 | f_init(); |
| 5784 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 5785 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 5786 | |
| 5787 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_early_err), 5); |
| 5788 | vc_conn.done; |
| 5789 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5790 | |
Neels Hofmeyr | 8df6962 | 2019-11-02 19:16:03 +0100 | [diff] [blame] | 5791 | friend function f_tc_invalid_mgcp_crash(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5792 | f_init_handler(pars); |
| 5793 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 5794 | |
| 5795 | /* Set invalid IP address so that osmo-msc discards the rtp_stream and MGCP endpoint FSM instances in the middle |
| 5796 | * of successful MGCP response dispatch. If things aren't safeguarded, the on_success() in osmo_mgcpc_ep_fsm |
| 5797 | * will cause a use-after-free after that event dispatch. */ |
| 5798 | cpars.mgw_conn_1.mgw_rtp_ip := "0.0.0.0"; |
| 5799 | cpars.mgw_conn_2.mgw_rtp_ip := "0.0.0.0"; |
| 5800 | cpars.rtp_sdp_format := "FOO/8000"; |
| 5801 | cpars.expect_release := true; |
| 5802 | |
| 5803 | f_perform_lu(); |
| 5804 | f_mo_call_establish(cpars); |
| 5805 | } |
| 5806 | testcase TC_invalid_mgcp_crash() runs on MTC_CT { |
| 5807 | var BSC_ConnHdlr vc_conn; |
| 5808 | f_init(); |
| 5809 | |
| 5810 | vc_conn := f_start_handler(refers(f_tc_invalid_mgcp_crash), 7); |
| 5811 | vc_conn.done; |
| 5812 | } |
| 5813 | |
Vadim Yanitskiy | eddebaa | 2019-12-28 17:45:34 +0100 | [diff] [blame] | 5814 | friend function f_tc_mm_id_resp_no_identity(charstring id, BSC_ConnHdlrPars pars) |
| 5815 | runs on BSC_ConnHdlr { |
| 5816 | pars.tmsi := 'FFFFFFFF'O; |
| 5817 | f_init_handler(pars); |
| 5818 | |
| 5819 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 5820 | |
| 5821 | /* Initiate Location Updating using an unknown TMSI */ |
| 5822 | f_bssap_compl_l3(f_build_lu_tmsi(pars.tmsi)); |
| 5823 | |
| 5824 | /* Expect an Identity Request, send response with no identity */ |
| 5825 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req(CM_ID_TYPE_IMSI))); |
| 5826 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp({ |
| 5827 | lengthIndicator := 1, |
| 5828 | mobileIdentityV := { |
| 5829 | typeOfIdentity := '000'B, |
| 5830 | oddEvenInd_identity := { |
| 5831 | no_identity := { |
| 5832 | oddevenIndicator := '0'B, |
| 5833 | fillerDigits := '00000'H |
| 5834 | } |
| 5835 | } |
| 5836 | } |
| 5837 | }))); |
| 5838 | |
| 5839 | f_expect_lu_reject(); |
| 5840 | f_expect_clear(); |
| 5841 | } |
| 5842 | testcase TC_mm_id_resp_no_identity() runs on MTC_CT { |
| 5843 | var BSC_ConnHdlr vc_conn; |
| 5844 | |
| 5845 | f_init(); |
| 5846 | |
| 5847 | vc_conn := f_start_handler(refers(f_tc_mm_id_resp_no_identity), 7); |
| 5848 | vc_conn.done; |
| 5849 | } |
| 5850 | |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 5851 | control { |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 5852 | execute( TC_cr_before_reset() ); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 5853 | execute( TC_lu_imsi_noauth_tmsi() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 5854 | execute( TC_lu_imsi_noauth_notmsi() ); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 5855 | execute( TC_lu_imsi_reject() ); |
| 5856 | execute( TC_lu_imsi_timeout_gsup() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 5857 | execute( TC_lu_imsi_auth_tmsi() ); |
Harald Welte | 8a397ae | 2019-04-21 22:03:37 +0200 | [diff] [blame] | 5858 | execute( TC_lu_imsi_auth3g_tmsi() ); |
Pau Espin Pedrol | d3d54a9 | 2019-12-17 17:02:54 +0100 | [diff] [blame] | 5859 | execute( TC_lu_imsi_timeout_tmsi_realloc() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 5860 | execute( TC_cmserv_imsi_unknown() ); |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 5861 | execute( TC_lu_and_mo_call() ); |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 5862 | execute( TC_lu_and_mo_call_sccp_tiar_timeout() ); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 5863 | execute( TC_lu_auth_sai_timeout() ); |
| 5864 | execute( TC_lu_auth_sai_err() ); |
Harald Welte | e1a2f3c | 2018-01-24 17:28:48 +0100 | [diff] [blame] | 5865 | execute( TC_lu_clear_request() ); |
| 5866 | execute( TC_lu_disconnect() ); |
| 5867 | execute( TC_lu_by_imei() ); |
| 5868 | execute( TC_lu_by_tmsi_noauth_unknown() ); |
| 5869 | execute( TC_imsi_detach_by_imsi() ); |
| 5870 | execute( TC_imsi_detach_by_tmsi() ); |
| 5871 | execute( TC_imsi_detach_by_imei() ); |
| 5872 | execute( TC_emerg_call_imei_reject() ); |
| 5873 | execute( TC_emerg_call_imsi() ); |
| 5874 | execute( TC_cm_serv_req_vgcs_reject() ); |
| 5875 | execute( TC_cm_serv_req_vbs_reject() ); |
| 5876 | execute( TC_cm_serv_req_lcs_reject() ); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 5877 | execute( TC_cm_reest_req_reject() ); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 5878 | execute( TC_lu_auth_2G_fail() ); |
| 5879 | execute( TC_lu_imsi_auth_tmsi_encr_13_13() ); |
| 5880 | execute( TC_cl3_no_payload() ); |
| 5881 | execute( TC_cl3_rnd_payload() ); |
Harald Welte | 1852a84 | 2018-01-26 22:53:36 +0100 | [diff] [blame] | 5882 | execute( TC_establish_and_nothing() ); |
| 5883 | execute( TC_mo_setup_and_nothing() ); |
| 5884 | execute( TC_mo_crcx_ran_timeout() ); |
| 5885 | execute( TC_mo_crcx_ran_reject() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 5886 | execute( TC_mt_crcx_ran_reject() ); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 5887 | execute( TC_mo_setup_and_dtmf_dup() ); |
Harald Welte | aa54cf8 | 2018-01-30 08:15:32 +0100 | [diff] [blame] | 5888 | //execute( TC_mt_t310() ); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 5889 | execute( TC_gsup_cancel() ); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 5890 | execute( TC_lu_imsi_auth_tmsi_encr_1_13() ); |
| 5891 | execute( TC_lu_imsi_auth_tmsi_encr_3_13() ); |
| 5892 | execute( TC_lu_imsi_auth_tmsi_encr_3_1() ); |
Neels Hofmeyr | 29b8da0 | 2018-03-01 18:09:45 +0100 | [diff] [blame] | 5893 | execute( TC_lu_imsi_auth_tmsi_encr_3_1_no_cm() ); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 5894 | execute( TC_lu_imsi_auth_tmsi_encr_13_2() ); |
| 5895 | execute( TC_lu_imsi_auth_tmsi_encr_013_2() ); |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 5896 | execute( TC_mo_release_timeout() ); |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 5897 | execute( TC_lu_and_mt_call_no_dlcx_resp() ); |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 5898 | execute( TC_reset_two() ); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 5899 | |
| 5900 | execute( TC_lu_and_mt_call() ); |
| 5901 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 5902 | execute( TC_lu_and_mo_sms() ); |
| 5903 | execute( TC_lu_and_mt_sms() ); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 5904 | execute( TC_lu_and_mt_sms_paging_and_nothing() ); |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 5905 | execute( TC_lu_and_mt_sms_paging_repeated() ); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 5906 | execute( TC_smpp_mo_sms() ); |
| 5907 | execute( TC_smpp_mt_sms() ); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 5908 | |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 5909 | execute( TC_gsup_mo_sms() ); |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 5910 | execute( TC_gsup_mo_smma() ); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 5911 | execute( TC_gsup_mt_sms_ack() ); |
| 5912 | execute( TC_gsup_mt_sms_err() ); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 5913 | execute( TC_gsup_mt_sms_rp_mr() ); |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 5914 | execute( TC_gsup_mo_mt_sms_rp_mr() ); |
Vadim Yanitskiy | a2a8a11 | 2019-07-08 20:04:32 +0700 | [diff] [blame] | 5915 | execute( TC_gsup_mt_multi_part_sms() ); |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 5916 | |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 5917 | execute( TC_lu_and_mo_ussd_single_request() ); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 5918 | execute( TC_lu_and_mt_ussd_notification() ); |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 5919 | execute( TC_lu_and_mo_ussd_during_mt_call() ); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 5920 | execute( TC_lu_and_mt_ussd_during_mt_call() ); |
Vadim Yanitskiy | 2daf52d | 2018-06-21 04:19:58 +0700 | [diff] [blame] | 5921 | execute( TC_lu_and_mo_ussd_mo_release() ); |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 5922 | execute( TC_lu_and_ss_session_timeout() ); |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 5923 | |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 5924 | execute( TC_mt_ussd_for_unknown_subscr() ); |
Vadim Yanitskiy | c3c07d4 | 2019-06-17 23:00:44 +0700 | [diff] [blame] | 5925 | execute( TC_mo_ussd_for_unknown_trans() ); |
Vadim Yanitskiy | d612d28 | 2019-06-15 14:46:03 +0700 | [diff] [blame] | 5926 | execute( TC_proc_ss_for_unknown_session() ); |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 5927 | execute( TC_proc_ss_paging_fail() ); |
Vadim Yanitskiy | 29ba8d6 | 2019-06-16 15:19:41 +0700 | [diff] [blame] | 5928 | execute( TC_proc_ss_abort() ); |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 5929 | |
Vadim Yanitskiy | 1c9754d | 2020-01-07 21:56:55 +0100 | [diff] [blame] | 5930 | execute( TC_multi_lu_and_mo_ussd() ); |
| 5931 | execute( TC_multi_lu_and_mt_ussd() ); |
| 5932 | |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 5933 | execute( TC_cipher_complete_with_invalid_cipher() ); |
Stefan Sperling | a2d59c6 | 2018-12-18 16:32:44 +0100 | [diff] [blame] | 5934 | execute( TC_cipher_complete_1_without_cipher() ); |
| 5935 | execute( TC_cipher_complete_3_without_cipher() ); |
| 5936 | execute( TC_cipher_complete_13_without_cipher() ); |
Harald Welte | b2284bd | 2019-05-10 11:30:43 +0200 | [diff] [blame] | 5937 | execute( TC_lu_with_invalid_mcc_mnc() ); |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 5938 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5939 | execute( TC_sgsap_reset() ); |
| 5940 | execute( TC_sgsap_lu() ); |
| 5941 | execute( TC_sgsap_lu_imsi_reject() ); |
| 5942 | execute( TC_sgsap_lu_and_nothing() ); |
| 5943 | execute( TC_sgsap_expl_imsi_det_eps() ); |
Philipp Maier | fc19f17 | 2019-03-21 11:17:54 +0100 | [diff] [blame] | 5944 | execute( TC_sgsap_impl_imsi_det_eps() ); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5945 | execute( TC_sgsap_expl_imsi_det_noneps() ); |
Philipp Maier | 5d81270 | 2019-03-21 10:51:26 +0100 | [diff] [blame] | 5946 | execute( TC_sgsap_impl_imsi_det_noneps() ); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5947 | execute( TC_sgsap_paging_rej() ); |
| 5948 | execute( TC_sgsap_paging_subscr_rej() ); |
| 5949 | execute( TC_sgsap_paging_ue_unr() ); |
| 5950 | execute( TC_sgsap_paging_and_nothing() ); |
| 5951 | execute( TC_sgsap_paging_and_lu() ); |
| 5952 | execute( TC_sgsap_mt_sms() ); |
| 5953 | execute( TC_sgsap_mo_sms() ); |
| 5954 | execute( TC_sgsap_mt_sms_and_nothing() ); |
| 5955 | execute( TC_sgsap_mt_sms_and_reject() ); |
| 5956 | execute( TC_sgsap_unexp_ud() ); |
| 5957 | execute( TC_sgsap_unsol_ud() ); |
| 5958 | execute( TC_bssap_lu_sgsap_lu_and_mt_call() ); |
| 5959 | execute( TC_sgsap_lu_and_mt_call() ); |
Philipp Maier | 628c005 | 2019-04-09 17:36:57 +0200 | [diff] [blame] | 5960 | execute( TC_sgsap_vlr_failure() ); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5961 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5962 | execute( TC_ho_inter_bsc_unknown_cell() ); |
| 5963 | execute( TC_ho_inter_bsc() ); |
| 5964 | |
| 5965 | execute( TC_ho_inter_msc_out() ); |
| 5966 | |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 5967 | execute( TC_lu_imsi_auth_tmsi_check_imei() ); |
| 5968 | execute( TC_lu_imsi_auth3g_tmsi_check_imei() ); |
| 5969 | execute( TC_lu_imsi_noauth_tmsi_check_imei() ); |
| 5970 | execute( TC_lu_imsi_noauth_notmsi_check_imei() ); |
| 5971 | execute( TC_lu_imsi_auth_tmsi_check_imei_nack() ); |
| 5972 | execute( TC_lu_imsi_auth_tmsi_check_imei_err() ); |
| 5973 | execute( TC_lu_imsi_auth_tmsi_check_imei_early() ); |
| 5974 | execute( TC_lu_imsi_auth3g_tmsi_check_imei_early() ); |
| 5975 | execute( TC_lu_imsi_noauth_tmsi_check_imei_early() ); |
| 5976 | execute( TC_lu_imsi_noauth_notmsi_check_imei_early() ); |
| 5977 | execute( TC_lu_imsi_auth_tmsi_check_imei_early_nack() ); |
| 5978 | execute( TC_lu_imsi_auth_tmsi_check_imei_early_err() ); |
| 5979 | |
Neels Hofmeyr | 1b3c6e3 | 2018-03-01 17:52:21 +0100 | [diff] [blame] | 5980 | /* Run this last: at the time of writing this test crashes the MSC */ |
| 5981 | execute( TC_lu_imsi_auth_tmsi_encr_3_1_log_msc_debug() ); |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 5982 | execute( TC_mo_cc_bssmap_clear() ); |
Pau Espin Pedrol | 690d659 | 2019-05-31 17:56:32 +0200 | [diff] [blame] | 5983 | if (mp_enable_osmux_test) { |
| 5984 | execute( TC_lu_and_mt_call_osmux() ); |
| 5985 | } |
Neels Hofmeyr | 8df6962 | 2019-11-02 19:16:03 +0100 | [diff] [blame] | 5986 | execute( TC_invalid_mgcp_crash() ); |
Vadim Yanitskiy | eddebaa | 2019-12-28 17:45:34 +0100 | [diff] [blame] | 5987 | execute( TC_mm_id_resp_no_identity() ); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 5988 | } |
| 5989 | |
| 5990 | |
| 5991 | } |