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; |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 19 | import from GSM_Types all; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 20 | |
| 21 | import from M3UA_Types all; |
| 22 | import from M3UA_Emulation all; |
| 23 | |
| 24 | import from MTP3asp_Types all; |
| 25 | import from MTP3asp_PortType all; |
| 26 | |
| 27 | import from SCCPasp_Types all; |
| 28 | import from SCCP_Types all; |
| 29 | import from SCCP_Emulation all; |
| 30 | |
| 31 | import from SCTPasp_Types all; |
| 32 | import from SCTPasp_PortType all; |
| 33 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 34 | import from Osmocom_CTRL_Functions all; |
| 35 | import from Osmocom_CTRL_Types all; |
| 36 | import from Osmocom_CTRL_Adapter all; |
| 37 | |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 38 | import from TELNETasp_PortType all; |
| 39 | import from Osmocom_VTY_Functions all; |
| 40 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 41 | import from MNCC_Emulation all; |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 42 | import from MNCC_Types all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 43 | |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 44 | import from MGCP_Emulation all; |
| 45 | import from MGCP_Types all; |
| 46 | import from MGCP_Templates all; |
| 47 | import from SDP_Types all; |
| 48 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 49 | import from GSUP_Emulation all; |
| 50 | import from GSUP_Types all; |
| 51 | import from IPA_Emulation all; |
| 52 | |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 53 | import from BSSAP_Types all; |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 54 | import from RAN_Adapter all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 55 | import from BSSAP_CodecPort all; |
| 56 | import from BSSMAP_Templates all; |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 57 | import from RAN_Emulation all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 58 | import from BSC_ConnectionHandler all; |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 59 | import from RANAP_Templates all; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 60 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 61 | import from SGsAP_Templates all; |
| 62 | import from SGsAP_Types all; |
| 63 | import from SGsAP_Emulation all; |
| 64 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 65 | import from MobileL3_Types all; |
| 66 | import from MobileL3_CommonIE_Types all; |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 67 | import from MobileL3_SMS_Types all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 68 | import from L3_Templates all; |
Harald Welte | 158a7ca | 2018-02-16 18:11:31 +0100 | [diff] [blame] | 69 | import from L3_Common all; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 70 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 71 | import from SMPP_Types all; |
| 72 | import from SMPP_Templates all; |
| 73 | import from SMPP_Emulation all; |
| 74 | |
Stefan Sperling | c307e68 | 2018-06-14 15:15:46 +0200 | [diff] [blame] | 75 | import from SCCP_Templates all; |
| 76 | |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 77 | import from SS_Types all; |
| 78 | import from SS_Templates all; |
| 79 | import from USSD_Helpers all; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 80 | import from DNS_Helpers all; |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 81 | |
Philipp Maier | 948747b | 2019-04-02 15:22:33 +0200 | [diff] [blame] | 82 | import from TCCConversion_Functions all; |
| 83 | |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 84 | const integer NUM_BSC := 3; |
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"; |
Eric Wild | 49888a6 | 2022-03-30 03:16:11 +0200 | [diff] [blame] | 143 | integer mp_bssap_reset_retries := 1; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 144 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 145 | RAN_Configurations mp_bssap_cfg := { |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 146 | { |
| 147 | sccp_service_type := "mtp3_itu", |
| 148 | sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" }, |
| 149 | own_pc := 185, |
| 150 | own_ssn := 254, |
| 151 | peer_pc := 187, |
| 152 | peer_ssn := 254, |
| 153 | sio := '83'O, |
| 154 | rctx := 0 |
| 155 | }, |
| 156 | { |
| 157 | sccp_service_type := "mtp3_itu", |
| 158 | sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" }, |
| 159 | own_pc := 186, |
| 160 | own_ssn := 254, |
| 161 | peer_pc := 187, |
| 162 | peer_ssn := 254, |
| 163 | sio := '83'O, |
| 164 | rctx := 1 |
| 165 | } |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 166 | }; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 167 | } |
| 168 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 169 | /* altstep for the global guard timer (only used when BSSAP_DIRECT |
| 170 | * is used for communication */ |
| 171 | private altstep as_Tguard_direct() runs on MTC_CT { |
| 172 | [] Tguard_direct.timeout { |
| 173 | setverdict(fail, "Tguard timeout"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 174 | mtc.stop; |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 175 | } |
| 176 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 177 | |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 178 | private altstep as_optional_cc_rel(CallParameters cpars, boolean respond := false) runs on BSC_ConnHdlr { |
| 179 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))) { |
| 180 | if (respond) { |
| 181 | var BIT1 tid_remote := '1'B; |
| 182 | if (cpars.mo_call) { |
| 183 | tid_remote := '0'B; |
| 184 | } |
| 185 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_REL_COMPL(cpars.transaction_id, tid_remote))); |
| 186 | } |
| 187 | } |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 188 | } |
| 189 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 190 | function f_init_smpp(charstring id) runs on MTC_CT { |
| 191 | id := id & "-SMPP"; |
| 192 | var EsmePars pars := { |
| 193 | mode := MODE_TRANSCEIVER, |
| 194 | bind := { |
| 195 | system_id := mp_smpp_system_id, |
| 196 | password := mp_smpp_password, |
| 197 | system_type := "MSC_Tests", |
| 198 | interface_version := hex2int('34'H), |
| 199 | addr_ton := unknown, |
| 200 | addr_npi := unknown, |
| 201 | address_range := "" |
| 202 | }, |
| 203 | esme_role := true |
| 204 | } |
| 205 | |
| 206 | vc_SMPP := SMPP_Emulation_CT.create(id); |
| 207 | map(vc_SMPP:SMPP_PORT, system:SMPP_PORT); |
Harald Welte | 4698a4c | 2020-08-18 22:57:52 +0200 | [diff] [blame] | 208 | vc_SMPP.start(SMPP_Emulation.main_client(pars, mp_msc_ip, mp_msc_smpp_port, "", 0)); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 212 | function f_init_mncc(charstring id) runs on MTC_CT { |
| 213 | id := id & "-MNCC"; |
| 214 | var MnccOps ops := { |
| 215 | create_cb := refers(MNCC_Emulation.ExpectedCreateCallback), |
| 216 | unitdata_cb := refers(MNCC_Emulation.DummyUnitdataCallback) |
| 217 | } |
| 218 | |
| 219 | vc_MNCC := MNCC_Emulation_CT.create(id); |
| 220 | map(vc_MNCC:MNCC, system:MNCC_CODEC_PT); |
| 221 | vc_MNCC.start(MNCC_Emulation.main(ops, id, mp_msc_mncc)); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 222 | } |
| 223 | |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 224 | function f_init_mgcp(charstring id) runs on MTC_CT { |
| 225 | id := id & "-MGCP"; |
| 226 | var MGCPOps ops := { |
| 227 | create_cb := refers(MGCP_Emulation.ExpectedCreateCallback), |
| 228 | unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback) |
| 229 | } |
| 230 | var MGCP_conn_parameters pars := { |
Harald Welte | 6126fb0 | 2018-01-27 20:08:24 +0100 | [diff] [blame] | 231 | callagent_ip := mp_msc_ip, |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 232 | callagent_udp_port := -1, |
Harald Welte | 6126fb0 | 2018-01-27 20:08:24 +0100 | [diff] [blame] | 233 | mgw_ip := mp_mgw_ip, |
Pau Espin Pedrol | 1a026a5 | 2019-06-18 17:21:52 +0200 | [diff] [blame] | 234 | mgw_udp_port := mp_mgw_port, |
| 235 | multi_conn_mode := false |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | vc_MGCP := MGCP_Emulation_CT.create(id); |
| 239 | map(vc_MGCP:MGCP, system:MGCP_CODEC_PT); |
| 240 | vc_MGCP.start(MGCP_Emulation.main(ops, pars, id)); |
| 241 | } |
| 242 | |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 243 | function ForwardUnitdataCallback(PDU_SGsAP msg) |
| 244 | runs on SGsAP_Emulation_CT return template PDU_SGsAP { |
| 245 | SGsAP_CLIENT.send(msg); |
| 246 | return omit; |
| 247 | } |
| 248 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 249 | function f_init_sgsap(charstring id) runs on MTC_CT { |
| 250 | id := id & "-SGsAP"; |
| 251 | var SGsAPOps ops := { |
| 252 | create_cb := refers(SGsAP_Emulation.ExpectedCreateCallback), |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 253 | unitdata_cb := refers(ForwardUnitdataCallback) |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 254 | } |
| 255 | var SGsAP_conn_parameters pars := { |
| 256 | remote_ip := mp_msc_ip, |
| 257 | remote_sctp_port := 29118, |
| 258 | local_ip := "", |
| 259 | local_sctp_port := -1 |
| 260 | } |
| 261 | |
| 262 | vc_SGsAP := SGsAP_Emulation_CT.create(id); |
| 263 | map(vc_SGsAP:SGsAP, system:SGsAP_CODEC_PT); |
| 264 | vc_SGsAP.start(SGsAP_Emulation.main(ops, pars, id)); |
| 265 | } |
| 266 | |
| 267 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 268 | function f_init_gsup(charstring id) runs on MTC_CT { |
| 269 | id := id & "-GSUP"; |
| 270 | var GsupOps ops := { |
| 271 | create_cb := refers(GSUP_Emulation.ExpectedCreateCallback) |
| 272 | } |
| 273 | |
| 274 | vc_GSUP_IPA := IPA_Emulation_CT.create(id & "-IPA"); |
| 275 | vc_GSUP := GSUP_Emulation_CT.create(id); |
| 276 | |
| 277 | map(vc_GSUP_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 278 | connect(vc_GSUP:GSUP, vc_GSUP_IPA:IPA_GSUP_PORT); |
| 279 | /* we use this hack to get events like ASP_IPA_EVENT_UP */ |
| 280 | connect(vc_GSUP_IPA:IPA_CTRL_PORT, self:GSUP_IPA_EVENT); |
| 281 | |
| 282 | vc_GSUP.start(GSUP_Emulation.main(ops, id)); |
| 283 | vc_GSUP_IPA.start(IPA_Emulation.main_server(mp_hlr_ip, mp_hlr_port)); |
| 284 | |
| 285 | /* wait for incoming connection to GSUP port before proceeding */ |
| 286 | timer T := 10.0; |
| 287 | T.start; |
| 288 | alt { |
Vadim Yanitskiy | 61564be | 2020-05-18 20:44:14 +0700 | [diff] [blame] | 289 | [] GSUP_IPA_EVENT.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_UP)) { } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 290 | [] T.timeout { |
Harald Welte | 458fd37 | 2018-03-21 11:26:23 +0100 | [diff] [blame] | 291 | setverdict(fail, "No connection to GSUP Port"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 292 | mtc.stop |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 293 | } |
| 294 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 295 | } |
| 296 | |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 297 | 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] | 298 | |
| 299 | if (g_initialized == true) { |
| 300 | return; |
| 301 | } |
| 302 | g_initialized := true; |
| 303 | |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 304 | if (num_bsc > NUM_BSC) { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 305 | testcase.stop("excess number of BSC instances requested"); |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 306 | } |
| 307 | |
Pau Espin Pedrol | 9a5b8ff | 2021-01-04 19:01:31 +0100 | [diff] [blame] | 308 | f_ipa_ctrl_start_client(mp_msc_ip, mp_msc_ctrl_port); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 309 | |
| 310 | map(self:MSCVTY, system:MSCVTY); |
| 311 | f_vty_set_prompts(MSCVTY); |
| 312 | f_vty_transceive(MSCVTY, "enable"); |
Harald Welte | b14c77a | 2018-01-25 17:25:44 +0100 | [diff] [blame] | 313 | |
| 314 | /* set some defaults */ |
| 315 | f_vty_config(MSCVTY, "network", "authentication optional"); |
| 316 | f_vty_config(MSCVTY, "msc", "assign-tmsi"); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 317 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 0"); |
Harald Welte | b14c77a | 2018-01-25 17:25:44 +0100 | [diff] [blame] | 318 | f_vty_config(MSCVTY, "network", "encryption a5 0"); |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 319 | f_vty_config(MSCVTY, "cs7 instance 0", "sccp-timer ias " & int2str(g_msc_sccp_timer_ias)); |
| 320 | f_vty_config(MSCVTY, "cs7 instance 0", "sccp-timer iar " & int2str(g_msc_sccp_timer_iar)); |
Pau Espin Pedrol | 9a732a4 | 2020-09-15 15:56:33 +0200 | [diff] [blame] | 321 | if (osmux) { |
| 322 | f_vty_config(MSCVTY, "msc", "osmux on"); |
| 323 | } else { |
| 324 | f_vty_config(MSCVTY, "msc", "osmux off"); |
Pau Espin Pedrol | 3dd33bc | 2019-05-31 17:51:20 +0200 | [diff] [blame] | 325 | } |
Daniel Willmann | 0886215 | 2022-02-22 13:21:49 +0100 | [diff] [blame] | 326 | |
Neels Hofmeyr | c47ce85 | 2023-03-06 17:16:50 +0100 | [diff] [blame] | 327 | /* Configure the MGCP timeout so that a failure to set up all RTP streams triggers within the time that we keep |
| 328 | * an otherwise established call open. */ |
| 329 | f_vty_config(MSCVTY, "msc", "timer mgw X2 3"); |
| 330 | |
Daniel Willmann | 0886215 | 2022-02-22 13:21:49 +0100 | [diff] [blame] | 331 | for (var integer i := 0; i < num_bsc; i := i + 1) { |
| 332 | if (isbound(mp_bssap_cfg[i])) { |
| 333 | var RanOps ranops := BSC_RanOps; |
| 334 | ranops.use_osmux := osmux; |
Eric Wild | 49888a6 | 2022-03-30 03:16:11 +0200 | [diff] [blame] | 335 | ranops.bssap_reset_retries := mp_bssap_reset_retries; |
Daniel Willmann | 0886215 | 2022-02-22 13:21:49 +0100 | [diff] [blame] | 336 | f_ran_adapter_init(g_bssap[i], mp_bssap_cfg[i], "MSC_Test_" & int2str(i), ranops); |
| 337 | f_ran_adapter_start(g_bssap[i]); |
| 338 | } else { |
| 339 | testcase.stop("missing BSSAP configuration"); |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | f_init_mncc("MSC_Test"); |
| 344 | f_init_mgcp("MSC_Test"); |
| 345 | |
| 346 | if (gsup == true) { |
| 347 | f_init_gsup("MSC_Test"); |
| 348 | } |
| 349 | f_init_smpp("MSC_Test"); |
| 350 | |
| 351 | if (sgsap == true) { |
| 352 | f_init_sgsap("MSC_Test"); |
| 353 | } |
| 354 | |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 355 | } |
| 356 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 357 | /* Initialize for a direct connection to BSSAP. This function is an alternative |
| 358 | * to f_init() when the high level functions of the BSC_ConnectionHandler are |
| 359 | * not needed. */ |
| 360 | function f_init_bssap_direct() runs on MTC_CT { |
Harald Welte | 3ca0ce1 | 2019-04-23 17:18:48 +0200 | [diff] [blame] | 361 | 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] | 362 | connect(g_bssap[0].vc_SCCP:SCCP_SP_PORT, self:BSSAP_DIRECT); |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 363 | |
| 364 | /* Start guard timer and activate it as default */ |
| 365 | Tguard_direct.start |
| 366 | activate(as_Tguard_direct()); |
| 367 | } |
| 368 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 369 | 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] | 370 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 371 | /* FIXME: move into BSC_ConnectionHandler? */ |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 372 | function f_init_pars(integer imsi_suffix, boolean sgsap := false, boolean gsup := true, integer ran_idx := 0, |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 373 | boolean ran_is_geran := true, boolean use_osmux := false, OCT4 gsup_sid := '20000101'O, |
| 374 | boolean verify_cell_id := true) |
Harald Welte | f9abf8d | 2019-04-21 13:07:17 +0200 | [diff] [blame] | 375 | runs on MTC_CT return BSC_ConnHdlrPars { |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 376 | var BSC_ConnHdlrNetworkPars net_pars := { |
| 377 | kc_support := '0A'O, /* A5/1 and A5/3 enabled */ |
Neels Hofmeyr | e860fc4 | 2022-10-05 01:15:54 +0200 | [diff] [blame] | 378 | net_config := { "authentication optional", "encryption a5 0" }, |
| 379 | expect_attach_success := true, |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 380 | expect_tmsi := true, |
Neels Hofmeyr | e860fc4 | 2022-10-05 01:15:54 +0200 | [diff] [blame] | 381 | expect_auth_attempt := false, |
| 382 | hlr_has_auth_info := true, |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 383 | expect_auth := false, |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 384 | expect_ciph := false, |
| 385 | expect_imei := false, |
| 386 | expect_imei_early := false, |
| 387 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 388 | check_imei_error := false |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 389 | }; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 390 | var BSC_ConnHdlrPars pars := { |
Harald Welte | f9abf8d | 2019-04-21 13:07:17 +0200 | [diff] [blame] | 391 | sccp_addr_own := g_bssap[ran_idx].sccp_addr_own, |
| 392 | sccp_addr_peer := g_bssap[ran_idx].sccp_addr_peer, |
Harald Welte | edbab81 | 2018-03-18 16:02:25 +0100 | [diff] [blame] | 393 | cell_id := valueof(ts_CellId_CGI('262'H, '42'H, 23, 42)), |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 394 | imei := f_gen_imei(imsi_suffix), |
| 395 | imsi := f_gen_imsi(imsi_suffix), |
| 396 | msisdn := f_gen_msisdn(imsi_suffix), |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 397 | tmsi := omit, |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 398 | cm1 := valueof(ts_CM1), |
Harald Welte | 8260057 | 2018-01-21 20:54:08 +0100 | [diff] [blame] | 399 | cm2 := valueof(ts_CM2_default), |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 400 | cm3 := omit, |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 401 | vec := omit, |
Neels Hofmeyr | b00c5b0 | 2021-06-23 20:05:25 +0200 | [diff] [blame] | 402 | vec_keep := false, |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 403 | net := net_pars, |
Philipp Maier | aeb29a8 | 2018-11-08 17:40:53 +0100 | [diff] [blame] | 404 | send_early_cm := true, |
| 405 | ipa_ctrl_ip := mp_msc_ip, |
| 406 | ipa_ctrl_port := mp_msc_ctrl_port, |
Philipp Maier | 9b690e4 | 2018-12-21 11:50:03 +0100 | [diff] [blame] | 407 | ipa_ctrl_enable := true, |
Philipp Maier | 5786548 | 2019-01-07 18:33:13 +0100 | [diff] [blame] | 408 | mm_info := mp_mm_info, |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 409 | sgsap_enable := sgsap, |
Harald Welte | f9abf8d | 2019-04-21 13:07:17 +0200 | [diff] [blame] | 410 | gsup_enable := gsup, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 411 | gsup_sid := gsup_sid, |
Harald Welte | c1f937a | 2019-04-21 21:19:23 +0200 | [diff] [blame] | 412 | ran_idx := ran_idx, |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 413 | use_umts_aka := false, |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 414 | ran_is_geran := ran_is_geran, |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 415 | use_osmux := use_osmux, |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 416 | use_ipv6 := false, |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 417 | verify_cell_id := verify_cell_id, |
| 418 | common_id_last_eutran_plmn := omit |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 419 | }; |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 420 | if (not ran_is_geran) { |
| 421 | pars.use_umts_aka := true; |
| 422 | pars.net.expect_auth := true; |
| 423 | } |
Neels Hofmeyr | 9adaa70 | 2018-03-01 20:23:19 +0100 | [diff] [blame] | 424 | return pars; |
| 425 | } |
| 426 | |
Neels Hofmeyr | e1a1b63 | 2021-07-28 18:05:43 +0200 | [diff] [blame] | 427 | function f_start_handler_create(BSC_ConnHdlrPars pars) runs on MTC_CT return BSC_ConnHdlr { |
Neels Hofmeyr | 9adaa70 | 2018-03-01 20:23:19 +0100 | [diff] [blame] | 428 | var BSC_ConnHdlr vc_conn; |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 429 | var charstring id := testcasename() & int2str(pars.ran_idx); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 430 | |
| 431 | vc_conn := BSC_ConnHdlr.create(id); |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 432 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 433 | /* BSSMAP part / A interface */ |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 434 | connect(vc_conn:BSSAP, g_bssap[pars.ran_idx].vc_RAN:CLIENT); |
| 435 | connect(vc_conn:BSSAP_PROC, g_bssap[pars.ran_idx].vc_RAN:PROC); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 436 | /* MNCC part */ |
| 437 | connect(vc_conn:MNCC, vc_MNCC:MNCC_CLIENT); |
| 438 | connect(vc_conn:MNCC_PROC, vc_MNCC:MNCC_PROC); |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 439 | /* MGCP part */ |
| 440 | connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT); |
| 441 | connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 442 | /* GSUP part */ |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 443 | if (pars.gsup_enable == true) { |
| 444 | connect(vc_conn:GSUP, vc_GSUP:GSUP_CLIENT); |
| 445 | connect(vc_conn:GSUP_PROC, vc_GSUP:GSUP_PROC); |
| 446 | } |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 447 | /* SMPP part */ |
| 448 | connect(vc_conn:SMPP, vc_SMPP:SMPP_CLIENT); |
| 449 | connect(vc_conn:SMPP_PROC, vc_SMPP:SMPP_PROC); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 450 | /* SGs part */ |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 451 | if (pars.sgsap_enable == true) { |
Philipp Maier | 5786548 | 2019-01-07 18:33:13 +0100 | [diff] [blame] | 452 | connect(vc_conn:SGsAP, vc_SGsAP:SGsAP_CLIENT); |
| 453 | connect(vc_conn:SGsAP_PROC, vc_SGsAP:SGsAP_PROC); |
| 454 | } |
Neels Hofmeyr | e1a1b63 | 2021-07-28 18:05:43 +0200 | [diff] [blame] | 455 | return vc_conn; |
| 456 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 457 | |
Neels Hofmeyr | e1a1b63 | 2021-07-28 18:05:43 +0200 | [diff] [blame] | 458 | function f_start_handler_run(BSC_ConnHdlr vc_conn, void_fn fn, BSC_ConnHdlrPars pars) runs on MTC_CT { |
| 459 | var charstring id := testcasename() & int2str(pars.ran_idx); |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 460 | /* We cannot use vc_conn.start(f_init_handler(fn, id, pars)); as we cannot have |
| 461 | * 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] | 462 | vc_conn.start(derefers(fn)(id, pars)); |
Neels Hofmeyr | e1a1b63 | 2021-07-28 18:05:43 +0200 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | function f_start_handler_with_pars(void_fn fn, BSC_ConnHdlrPars pars) runs on MTC_CT return BSC_ConnHdlr { |
| 466 | var BSC_ConnHdlr vc_conn; |
| 467 | vc_conn := f_start_handler_create(pars); |
| 468 | f_start_handler_run(vc_conn, fn, pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 469 | return vc_conn; |
| 470 | } |
| 471 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 472 | function f_start_handler(void_fn fn, integer imsi_suffix, integer ran_idx := 0, boolean ran_is_geran := true, boolean use_osmux := false, |
| 473 | boolean verify_cell_id := true) |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 474 | runs on MTC_CT return BSC_ConnHdlr { |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 475 | 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, verify_cell_id := verify_cell_id)); |
Neels Hofmeyr | 9adaa70 | 2018-03-01 20:23:19 +0100 | [diff] [blame] | 476 | } |
| 477 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 478 | 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] | 479 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 480 | f_perform_lu(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 481 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 482 | testcase TC_lu_imsi_noauth_tmsi() runs on MTC_CT { |
| 483 | var BSC_ConnHdlr vc_conn; |
| 484 | f_init(); |
| 485 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 486 | 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] | 487 | vc_conn.done; |
| 488 | } |
| 489 | |
| 490 | 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] | 491 | pars.net.expect_tmsi := false; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 492 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 493 | f_perform_lu(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 494 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 495 | testcase TC_lu_imsi_noauth_notmsi() runs on MTC_CT { |
| 496 | var BSC_ConnHdlr vc_conn; |
| 497 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 498 | f_vty_config(MSCVTY, "msc", "no assign-tmsi"); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 499 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 500 | 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] | 501 | vc_conn.done; |
| 502 | } |
| 503 | |
| 504 | /* 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] | 505 | 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] | 506 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 507 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 508 | |
| 509 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 510 | f_cl3_or_initial_ue(l3_lu); |
Neels Hofmeyr | d076c52 | 2019-11-28 01:00:52 +0100 | [diff] [blame] | 511 | f_mm_common(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 512 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 513 | GSUP.send(ts_GSUP_UL_ERR(g_pars.imsi, 23)); |
| 514 | alt { |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 515 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej(int2oct(23,1)))) { |
| 516 | f_expect_clear(); |
| 517 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 518 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 519 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 520 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 521 | } |
| 522 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 523 | } |
| 524 | testcase TC_lu_imsi_reject() runs on MTC_CT { |
| 525 | var BSC_ConnHdlr vc_conn; |
| 526 | f_init(); |
| 527 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 528 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_reject), 3, verify_cell_id := false); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 529 | vc_conn.done; |
| 530 | } |
| 531 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 532 | |
| 533 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 534 | /* Do LU by IMSI, timeout on GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 535 | 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] | 536 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 537 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 538 | |
| 539 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 540 | f_cl3_or_initial_ue(l3_lu); |
Neels Hofmeyr | d076c52 | 2019-11-28 01:00:52 +0100 | [diff] [blame] | 541 | f_mm_common(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 542 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 543 | /* Normally the HLR would need to respond here, but we decide to force a timeout here */ |
| 544 | alt { |
| 545 | /* FIXME: Expect specific reject cause */ |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 546 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 547 | f_expect_clear(); |
| 548 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 549 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 550 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 551 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 552 | } |
| 553 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 554 | } |
| 555 | testcase TC_lu_imsi_timeout_gsup() runs on MTC_CT { |
| 556 | var BSC_ConnHdlr vc_conn; |
| 557 | f_init(); |
| 558 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 559 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_timeout_gsup), 4, verify_cell_id := false); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 560 | vc_conn.done; |
| 561 | } |
| 562 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 563 | |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 564 | 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] | 565 | pars.net.expect_auth := true; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 566 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 567 | f_perform_lu(); |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 568 | } |
| 569 | testcase TC_lu_imsi_auth_tmsi() runs on MTC_CT { |
| 570 | var BSC_ConnHdlr vc_conn; |
| 571 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 572 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 573 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 574 | 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] | 575 | vc_conn.done; |
| 576 | } |
| 577 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 578 | |
| 579 | 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] | 580 | pars.net.expect_auth := true; |
| 581 | pars.use_umts_aka := true; |
| 582 | f_init_handler(pars); |
| 583 | f_perform_lu(); |
| 584 | } |
| 585 | testcase TC_lu_imsi_auth3g_tmsi() runs on MTC_CT { |
| 586 | var BSC_ConnHdlr vc_conn; |
| 587 | f_init(); |
| 588 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 589 | |
| 590 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth3g_tmsi), 1005); |
| 591 | vc_conn.done; |
| 592 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 593 | |
Pau Espin Pedrol | d3d54a9 | 2019-12-17 17:02:54 +0100 | [diff] [blame] | 594 | /* Proceed with LU but never receive an TMSI Realloc from MS after LU Accept (OS#4337). |
| 595 | * TS 24.008 sec 4.3.1.5 states MSC should simply release all MM connections. |
| 596 | */ |
| 597 | friend function f_tc_lu_imsi_timeout_tmsi_realloc(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 598 | |
| 599 | f_init_handler(pars); |
| 600 | |
| 601 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 602 | var PDU_DTAP_MT dtap_mt; |
| 603 | |
| 604 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 605 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 606 | |
| 607 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 608 | if (g_pars.ran_is_geran) { |
| 609 | f_bssap_compl_l3(l3_lu); |
| 610 | if (g_pars.send_early_cm) { |
| 611 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 612 | } |
| 613 | } else { |
| 614 | f_ranap_initial_ue(l3_lu); |
| 615 | } |
| 616 | |
| 617 | f_mm_imei_early(); |
| 618 | f_mm_common(); |
| 619 | f_msc_lu_hlr(); |
| 620 | f_mm_imei(); |
| 621 | |
| 622 | alt { |
| 623 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) -> value dtap_mt {} |
| 624 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 625 | setverdict(fail, "Expected LU ACK, but received LU REJ"); |
| 626 | mtc.stop; |
| 627 | } |
| 628 | } |
| 629 | |
| 630 | /* currently (due to bug OS#4337), an extra LU reject is received before |
| 631 | terminating the connection. Enabling following line makes the test |
| 632 | pass: */ |
| 633 | //f_expect_lu_reject('16'O); /* Cause: congestion */ |
| 634 | |
| 635 | /* f_expect_lu_reject() already waits for T"-1" (X1, 5 seconds), but give some |
| 636 | extra time to avoid race conditons... */ |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 637 | f_expect_clear(7.0, verify_vlr_cell_id := false); |
Pau Espin Pedrol | d3d54a9 | 2019-12-17 17:02:54 +0100 | [diff] [blame] | 638 | |
| 639 | setverdict(pass); |
| 640 | } |
| 641 | testcase TC_lu_imsi_timeout_tmsi_realloc() runs on MTC_CT { |
| 642 | var BSC_ConnHdlr vc_conn; |
| 643 | f_init(); |
| 644 | |
| 645 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_timeout_tmsi_realloc), 5); |
| 646 | vc_conn.done; |
| 647 | } |
| 648 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 649 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 650 | /* Send CM SERVICE REQ for IMSI that has never performed LU before */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 651 | friend function f_tc_cmserv_imsi_unknown(charstring id, BSC_ConnHdlrPars pars) |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 652 | runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 653 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 654 | |
| 655 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | edbab81 | 2018-03-18 16:02:25 +0100 | [diff] [blame] | 656 | 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] | 657 | 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] | 658 | |
| 659 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 660 | |
| 661 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 662 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | b781799 | 2019-05-09 13:15:39 +0200 | [diff] [blame] | 663 | f_mm_auth(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 664 | |
| 665 | timer T := 10.0; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 666 | T.start; |
| 667 | alt { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 668 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)) { } |
| 669 | //[] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_ACC)) { } |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 670 | [] BSSAP.receive { |
| 671 | setverdict(fail, "Received unexpected BSSAP"); |
| 672 | mtc.stop; |
| 673 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 674 | [] GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)) { |
| 675 | setverdict(fail, "Unexpected GSUP UL REQ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 676 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 677 | } |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 678 | [] T.timeout { |
Neels Hofmeyr | f1c3c21 | 2020-08-19 13:15:32 +0000 | [diff] [blame] | 679 | setverdict(fail, "Timeout waiting for CM SERV REJ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 680 | mtc.stop; |
| 681 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 682 | } |
| 683 | |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 684 | f_expect_clear(); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 685 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 686 | testcase TC_cmserv_imsi_unknown() runs on MTC_CT { |
| 687 | var BSC_ConnHdlr vc_conn; |
| 688 | f_init(); |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 689 | vc_conn := f_start_handler(refers(f_tc_cmserv_imsi_unknown), 6, verify_cell_id := false); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 690 | vc_conn.done; |
| 691 | } |
| 692 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 693 | |
Neels Hofmeyr | 13737fb | 2020-08-19 13:16:14 +0000 | [diff] [blame] | 694 | /* Send CM SERVICE REQ for TMSI that has never performed LU before */ |
| 695 | friend function f_tc_cmserv_tmsi_unknown(charstring id, BSC_ConnHdlrPars pars) |
| 696 | runs on BSC_ConnHdlr { |
| 697 | f_init_handler(pars); |
| 698 | |
| 699 | var MobileIdentityLV mi := valueof(ts_MI_TMSI_LV('57111111'O)); |
| 700 | var BSSMAP_IE_CellIdentifier cell_id := valueof(ts_CellId_CGI('262'H, '42'H, 23, 42)); |
| 701 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi)); |
| 702 | |
| 703 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 704 | f_cl3_or_initial_ue(l3_info); |
| 705 | f_mm_auth(); |
| 706 | |
| 707 | timer T := 10.0; |
| 708 | T.start; |
| 709 | alt { |
| 710 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)) { } |
| 711 | [] BSSAP.receive { |
| 712 | setverdict(fail, "Received unexpected BSSAP"); |
| 713 | mtc.stop; |
| 714 | } |
| 715 | [] T.timeout { |
| 716 | setverdict(fail, "Timeout waiting for CM SERV REJ"); |
| 717 | mtc.stop; |
| 718 | } |
| 719 | } |
| 720 | |
| 721 | f_expect_clear(); |
| 722 | } |
| 723 | testcase TC_cmserv_tmsi_unknown() runs on MTC_CT { |
| 724 | var BSC_ConnHdlr vc_conn; |
| 725 | f_init(); |
| 726 | vc_conn := f_start_handler(refers(f_tc_cmserv_tmsi_unknown), 57, verify_cell_id := false); |
| 727 | vc_conn.done; |
| 728 | } |
| 729 | |
Neels Hofmeyr | 14d0b13 | 2020-08-19 13:49:05 +0000 | [diff] [blame] | 730 | /* Send Paging Response for IMSI that has never performed LU before */ |
| 731 | friend function f_tc_paging_response_imsi_unknown(charstring id, BSC_ConnHdlrPars pars) |
| 732 | runs on BSC_ConnHdlr { |
| 733 | f_init_handler(pars); |
| 734 | |
| 735 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 736 | var BSSMAP_IE_CellIdentifier cell_id := valueof(ts_CellId_CGI('262'H, '42'H, 23, 42)); |
| 737 | var PDU_ML3_MS_NW l3_info := valueof(ts_PAG_RESP(mi)); |
| 738 | |
| 739 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 740 | f_cl3_or_initial_ue(l3_info); |
| 741 | |
| 742 | /* The Paging Response gets rejected by a direct Clear Command */ |
| 743 | f_expect_clear(); |
| 744 | } |
| 745 | testcase TC_paging_response_imsi_unknown() runs on MTC_CT { |
| 746 | var BSC_ConnHdlr vc_conn; |
| 747 | f_init(); |
| 748 | vc_conn := f_start_handler(refers(f_tc_paging_response_imsi_unknown), 58, verify_cell_id := false); |
| 749 | vc_conn.done; |
| 750 | } |
| 751 | |
| 752 | /* Send Paging Response for TMSI that has never performed LU before */ |
| 753 | friend function f_tc_paging_response_tmsi_unknown(charstring id, BSC_ConnHdlrPars pars) |
| 754 | runs on BSC_ConnHdlr { |
| 755 | f_init_handler(pars); |
| 756 | |
| 757 | var MobileIdentityLV mi := valueof(ts_MI_TMSI_LV('59111111'O)); |
| 758 | var BSSMAP_IE_CellIdentifier cell_id := valueof(ts_CellId_CGI('262'H, '42'H, 23, 42)); |
| 759 | var PDU_ML3_MS_NW l3_info := valueof(ts_PAG_RESP(mi)); |
| 760 | |
| 761 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 762 | f_cl3_or_initial_ue(l3_info); |
| 763 | |
| 764 | /* The Paging Response gets rejected by a direct Clear Command */ |
| 765 | f_expect_clear(); |
| 766 | } |
| 767 | testcase TC_paging_response_tmsi_unknown() runs on MTC_CT { |
| 768 | var BSC_ConnHdlr vc_conn; |
| 769 | f_init(); |
| 770 | vc_conn := f_start_handler(refers(f_tc_paging_response_tmsi_unknown), 59, verify_cell_id := false); |
| 771 | vc_conn.done; |
| 772 | } |
| 773 | |
Neels Hofmeyr | 13737fb | 2020-08-19 13:16:14 +0000 | [diff] [blame] | 774 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 775 | 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] | 776 | f_init_handler(pars); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 777 | var CallParameters cpars := valueof(t_CallParams); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 778 | f_perform_lu(); |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 779 | f_mo_call(cpars); |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 780 | } |
| 781 | testcase TC_lu_and_mo_call() runs on MTC_CT { |
| 782 | var BSC_ConnHdlr vc_conn; |
| 783 | f_init(); |
| 784 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 785 | 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] | 786 | vc_conn.done; |
| 787 | } |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 788 | friend function f_tc_lu_and_mo_call_ipv6(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 789 | f_init_handler(pars); |
| 790 | var CallParameters cpars := valueof(t_CallParams); |
| 791 | cpars.mgw_conn_1.mgw_rtp_ip := "::1"; |
| 792 | cpars.mgw_conn_2.mgw_rtp_ip := "::2"; |
| 793 | cpars.bss_rtp_ip := "::3"; |
| 794 | f_perform_lu(); |
| 795 | f_mo_call(cpars); |
| 796 | } |
| 797 | testcase TC_lu_and_mo_call_ipv6() runs on MTC_CT { |
| 798 | var BSC_ConnHdlr vc_conn; |
| 799 | f_init(); |
| 800 | |
| 801 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_call_ipv6), 7); |
| 802 | vc_conn.done; |
| 803 | } |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 804 | |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 805 | /* Verify T(iar) triggers and releases the channel */ |
| 806 | friend function f_lu_and_mo_call_sccp_tiar_timeout(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 807 | timer T_wait_iar := int2float(5 + 1); /* g_msc_sccp_timer_iar + Give extra time (+1 sec) */ |
| 808 | f_init_handler(pars); |
| 809 | var CallParameters cpars := valueof(t_CallParams); |
| 810 | f_perform_lu(); |
| 811 | f_mo_call_establish(cpars); |
| 812 | |
| 813 | /* Expect the channel cleared upon T(iar) triggered: */ |
| 814 | T_wait_iar.start; |
| 815 | alt { |
| 816 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) { |
| 817 | T_wait_iar.stop |
| 818 | setverdict(pass); |
| 819 | } |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 820 | [] T_wait_iar.timeout { |
| 821 | setverdict(fail, "Timeout waiting for T(iar) triggered SCCP RSLD"); |
| 822 | mtc.stop; |
| 823 | } |
| 824 | } |
Harald Welte | 4a3fa71 | 2020-08-19 08:57:33 +0200 | [diff] [blame] | 825 | /* DLCX for both directions; if we don't do this, we might receive either of the two during |
| 826 | * shutdown causing race conditions */ |
| 827 | MGCP.receive(tr_DLCX(?)); |
| 828 | MGCP.receive(tr_DLCX(?)); |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 829 | |
| 830 | setverdict(pass); |
| 831 | } |
| 832 | testcase TC_lu_and_mo_call_sccp_tiar_timeout() runs on MTC_CT { |
| 833 | var BSC_ConnHdlr vc_conn; |
| 834 | |
| 835 | /* Set T(iar) in MSC low enough that it will trigger before other side |
| 836 | has time to keep alive with a T(ias). Keep recommended ratio of |
| 837 | T(iar) >= T(ias)*2 */ |
| 838 | g_msc_sccp_timer_ias := 2; |
| 839 | g_msc_sccp_timer_iar := 5; |
| 840 | |
| 841 | f_init(); |
| 842 | |
| 843 | vc_conn := f_start_handler(refers(f_lu_and_mo_call_sccp_tiar_timeout), 89); |
| 844 | vc_conn.done; |
| 845 | } |
| 846 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 847 | |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 848 | /* Test LU (with authentication enabled), where HLR times out sending SAI response */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 849 | 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] | 850 | f_init_handler(pars); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 851 | |
| 852 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 853 | var PDU_DTAP_MT dtap_mt; |
| 854 | |
| 855 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 856 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 857 | |
| 858 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 859 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 860 | |
| 861 | /* Send Early Classmark, just for the fun of it */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 862 | if (pars.ran_is_geran) { |
| 863 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 864 | } |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 865 | |
| 866 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 867 | /* The HLR would normally return an auth vector here, but we fail to do so. */ |
| 868 | |
| 869 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 870 | f_expect_clear(); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 871 | } |
| 872 | testcase TC_lu_auth_sai_timeout() runs on MTC_CT { |
| 873 | var BSC_ConnHdlr vc_conn; |
| 874 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 875 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 876 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 877 | vc_conn := f_start_handler(refers(f_tc_lu_auth_sai_timeout), 8, verify_cell_id := false); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 878 | vc_conn.done; |
| 879 | } |
| 880 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 881 | |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 882 | /* Test LU (with authentication enabled), where HLR rejects sending SAI error */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 883 | 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] | 884 | f_init_handler(pars); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 885 | |
| 886 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 887 | var PDU_DTAP_MT dtap_mt; |
| 888 | |
| 889 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 890 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 891 | |
| 892 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 893 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 894 | |
| 895 | /* Send Early Classmark, just for the fun of it */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 896 | if (pars.ran_is_geran) { |
| 897 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 898 | } |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 899 | |
| 900 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 901 | GSUP.send(ts_GSUP_SAI_ERR(g_pars.imsi, 13)); |
| 902 | |
| 903 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 904 | f_expect_clear(); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 905 | } |
| 906 | testcase TC_lu_auth_sai_err() runs on MTC_CT { |
| 907 | var BSC_ConnHdlr vc_conn; |
| 908 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 909 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 910 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 911 | vc_conn := f_start_handler(refers(f_tc_lu_auth_sai_err), 9, verify_cell_id := false); |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 912 | vc_conn.done; |
| 913 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 914 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 915 | |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 916 | /* Test LU but BSC will send a clear request in the middle */ |
| 917 | 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] | 918 | f_init_handler(pars); |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 919 | |
| 920 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 921 | var PDU_DTAP_MT dtap_mt; |
| 922 | |
| 923 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 924 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 925 | |
| 926 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 927 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 79f1e45 | 2020-08-18 22:55:02 +0200 | [diff] [blame] | 928 | f_expect_common_id(); |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 929 | |
| 930 | /* Send Early Classmark, just for the fun of it */ |
| 931 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 932 | |
| 933 | f_sleep(1.0); |
| 934 | /* send clear request in the middle of the LU */ |
| 935 | BSSAP.send(ts_BSSMAP_ClearRequest(0)); |
Neels Hofmeyr | 2b326fa | 2018-04-06 00:59:36 +0200 | [diff] [blame] | 936 | alt { |
| 937 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { repeat; } |
| 938 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) {} |
| 939 | } |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 940 | BSSAP.send(ts_BSSMAP_ClearComplete); |
Harald Welte | 89a3249 | 2018-01-27 19:07:28 +0100 | [diff] [blame] | 941 | alt { |
| 942 | /* See https://osmocom.org/issues/2862 */ |
Neels Hofmeyr | 2b326fa | 2018-04-06 00:59:36 +0200 | [diff] [blame] | 943 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 944 | setverdict(fail, "Got a second Clear Command, only one expected"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 945 | mtc.stop; |
Neels Hofmeyr | 2b326fa | 2018-04-06 00:59:36 +0200 | [diff] [blame] | 946 | repeat; |
| 947 | } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 948 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
Harald Welte | 89a3249 | 2018-01-27 19:07:28 +0100 | [diff] [blame] | 949 | } |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 950 | setverdict(pass); |
| 951 | } |
| 952 | testcase TC_lu_clear_request() runs on MTC_CT { |
| 953 | var BSC_ConnHdlr vc_conn; |
| 954 | f_init(); |
| 955 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 956 | vc_conn := f_start_handler(refers(f_tc_lu_clear_request), 10); |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 957 | vc_conn.done; |
| 958 | } |
| 959 | |
Vadim Yanitskiy | 109e755 | 2021-02-05 05:36:02 +0100 | [diff] [blame] | 960 | /* Test reaction on Clear Request during a MO Call */ |
| 961 | friend function f_TC_mo_mt_call_clear_request(charstring id, BSC_ConnHdlrPars pars) |
| 962 | runs on BSC_ConnHdlr { |
| 963 | var CallParameters cpars := valueof(t_CallParams); |
| 964 | var MNCC_PDU mncc_pdu; |
| 965 | timer T := 2.0; |
| 966 | |
| 967 | f_init_handler(pars); |
| 968 | |
| 969 | f_perform_lu(); |
| 970 | |
| 971 | /* HACK: reducing code duplication ('66'H - MO, '68'H - MT) */ |
| 972 | if (pars.imsi == '262420002532766'H) |
| 973 | { f_mo_call_establish(cpars); } |
| 974 | else |
| 975 | { f_mt_call_establish(cpars); } |
| 976 | |
| 977 | /* Hold the line for a while... */ |
| 978 | f_sleep(2.0); |
| 979 | |
| 980 | /* BSC sends BSSMAP Clear Request (e.g. due to RR failure) */ |
| 981 | BSSAP.send(ts_BSSMAP_ClearRequest(1)); |
| 982 | |
| 983 | /* Expect (optional) CC RELEASE and Clear Command */ |
| 984 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
| 985 | f_expect_clear(); |
| 986 | deactivate(ccrel); |
| 987 | |
| 988 | /* Expect RELease indication on the MNCC socket */ |
| 989 | T.start; |
| 990 | alt { |
| 991 | [] MNCC.receive(tr_MNCC_REL_ind(cpars.mncc_callref)) -> value mncc_pdu { |
| 992 | log("Rx MNCC REL.ind, cause := ", mncc_pdu.u.signal.cause); |
| 993 | setverdict(pass); |
| 994 | } |
| 995 | [] MNCC.receive(MNCC_PDU:?) -> value mncc_pdu { |
| 996 | setverdict(fail, "Rx unexpected MNCC PDU: ", mncc_pdu); |
| 997 | } |
| 998 | [] T.timeout { |
| 999 | setverdict(fail, "Timeout waiting for MNCC REL.ind"); |
| 1000 | } |
| 1001 | } |
| 1002 | } |
| 1003 | testcase TC_mo_call_clear_request() runs on MTC_CT { |
| 1004 | var BSC_ConnHdlr vc_conn; |
| 1005 | |
| 1006 | f_init(); |
| 1007 | |
| 1008 | vc_conn := f_start_handler(refers(f_TC_mo_mt_call_clear_request), 2532766); // '66'H - MO |
| 1009 | vc_conn.done; |
| 1010 | } |
| 1011 | testcase TC_mt_call_clear_request() runs on MTC_CT { |
| 1012 | var BSC_ConnHdlr vc_conn; |
| 1013 | |
| 1014 | f_init(); |
| 1015 | |
| 1016 | vc_conn := f_start_handler(refers(f_TC_mo_mt_call_clear_request), 2532768); // '68'H - MT |
| 1017 | vc_conn.done; |
| 1018 | } |
| 1019 | |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1020 | /* Test LU but BSC will send a clear request in the middle */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1021 | 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] | 1022 | f_init_handler(pars); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1023 | |
| 1024 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 1025 | var PDU_DTAP_MT dtap_mt; |
| 1026 | |
| 1027 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1028 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1029 | |
| 1030 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1031 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1032 | |
| 1033 | /* Send Early Classmark, just for the fun of it */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1034 | if (pars.ran_is_geran) { |
| 1035 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1036 | } |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1037 | |
| 1038 | f_sleep(1.0); |
| 1039 | /* send clear request in the middle of the LU */ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1040 | BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1041 | setverdict(pass); |
Neels Hofmeyr | bb825c9 | 2019-03-06 15:35:50 +0100 | [diff] [blame] | 1042 | f_sleep(1.0); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1043 | } |
| 1044 | testcase TC_lu_disconnect() runs on MTC_CT { |
| 1045 | var BSC_ConnHdlr vc_conn; |
| 1046 | f_init(); |
| 1047 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1048 | vc_conn := f_start_handler(refers(f_tc_lu_disconnect), 11); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1049 | vc_conn.done; |
| 1050 | } |
| 1051 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1052 | /* Test LU but with illegal mobile identity type = IMEI */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1053 | 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] | 1054 | f_init_handler(pars); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1055 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 1056 | 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] | 1057 | var PDU_DTAP_MT dtap_mt; |
| 1058 | |
| 1059 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1060 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1061 | |
| 1062 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1063 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1064 | |
| 1065 | /* Send Early Classmark, just for the fun of it */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1066 | if (pars.ran_is_geran) { |
| 1067 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1068 | } |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1069 | /* wait for LU reject, ignore any ID REQ */ |
| 1070 | alt { |
| 1071 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { } |
| 1072 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req)) { repeat; } |
| 1073 | } |
| 1074 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1075 | f_expect_clear(); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1076 | } |
| 1077 | testcase TC_lu_by_imei() runs on MTC_CT { |
| 1078 | var BSC_ConnHdlr vc_conn; |
| 1079 | f_init(); |
| 1080 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1081 | vc_conn := f_start_handler(refers(f_tc_lu_by_imei), 12, verify_cell_id := false); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1082 | vc_conn.done; |
| 1083 | } |
| 1084 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1085 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1086 | /* Test LU by TMSI with unknown TMSI, expect (and answer) ID REQ. */ |
| 1087 | 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] | 1088 | /* We piggyback a test for an MSC crash on overlong IMSI (OS#2864) onto this test. */ |
| 1089 | var hexstring overlong_imsi := '012345789ABCDEF0123456789ABCDEF'H; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1090 | f_init_handler(pars); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1091 | |
| 1092 | var PDU_ML3_MS_NW l3_lu := f_build_lu_tmsi('01020304'O); /* FIXME: Random */ |
| 1093 | var PDU_DTAP_MT dtap_mt; |
| 1094 | |
| 1095 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1096 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1097 | |
| 1098 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1099 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1100 | |
| 1101 | /* Send Early Classmark, just for the fun of it */ |
| 1102 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1103 | |
| 1104 | /* Wait for + respond to ID REQ (IMSI) */ |
Oliver Smith | 3289845 | 2019-07-09 12:32:35 +0200 | [diff] [blame] | 1105 | 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] | 1106 | 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] | 1107 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp_IMSI(g_pars.imsi))); |
Harald Welte | 79f1e45 | 2020-08-18 22:55:02 +0200 | [diff] [blame] | 1108 | f_expect_common_id(); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1109 | |
| 1110 | /* Expect MSC to do UpdateLocation to HLR; respond to it */ |
| 1111 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 1112 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 1113 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 1114 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 1115 | |
| 1116 | alt { |
Harald Welte | 7ec4fa8 | 2018-01-27 10:57:40 +0100 | [diff] [blame] | 1117 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 1118 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_TmsiRealloc_Cmpl)); |
| 1119 | } |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1120 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 1121 | setverdict(fail, "Expected LU ACK, but received REJ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1122 | mtc.stop; |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1123 | } |
| 1124 | } |
| 1125 | |
Philipp Maier | 9b690e4 | 2018-12-21 11:50:03 +0100 | [diff] [blame] | 1126 | /* Wait for MM-Information (if enabled) */ |
| 1127 | f_expect_mm_info(); |
| 1128 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1129 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1130 | f_expect_clear(); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1131 | } |
| 1132 | testcase TC_lu_by_tmsi_noauth_unknown() runs on MTC_CT { |
| 1133 | var BSC_ConnHdlr vc_conn; |
| 1134 | f_init(); |
| 1135 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1136 | vc_conn := f_start_handler(refers(f_tc_lu_tmsi_noauth_unknown), 13); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1137 | vc_conn.done; |
| 1138 | } |
| 1139 | |
Neels Hofmeyr | fc06c73 | 2020-08-19 12:52:28 +0000 | [diff] [blame] | 1140 | /* Test LU by unknown TMSI, while the IMSI is already attached: osmo-msc should switch to the attached vlr_subscr. */ |
| 1141 | private function f_tc_attached_imsi_lu_unknown_tmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1142 | f_init_handler(pars); |
| 1143 | |
| 1144 | var PDU_ML3_MS_NW l3_lu := f_build_lu_tmsi('56111111'O); |
| 1145 | var PDU_DTAP_MT dtap_mt; |
| 1146 | |
| 1147 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1148 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1149 | |
| 1150 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 1151 | f_cl3_or_initial_ue(l3_lu); |
| 1152 | |
| 1153 | /* Send Early Classmark, just for the fun of it */ |
| 1154 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1155 | |
| 1156 | /* Wait for + respond to ID REQ (IMSI) */ |
| 1157 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req(CM_ID_TYPE_IMSI))); |
| 1158 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp_IMSI(g_pars.imsi))); |
| 1159 | f_expect_common_id(); |
| 1160 | |
| 1161 | /* Expect MSC to do UpdateLocation to HLR; respond to it */ |
| 1162 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 1163 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 1164 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 1165 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 1166 | |
| 1167 | alt { |
| 1168 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 1169 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_TmsiRealloc_Cmpl)); |
| 1170 | } |
| 1171 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 1172 | setverdict(fail, "Expected LU ACK, but received REJ"); |
| 1173 | mtc.stop; |
| 1174 | } |
| 1175 | } |
| 1176 | |
| 1177 | /* Wait for MM-Information (if enabled) */ |
| 1178 | f_expect_mm_info(); |
| 1179 | |
| 1180 | /* wait for normal teardown */ |
Eric Wild | 85cc161 | 2022-03-30 01:44:29 +0200 | [diff] [blame] | 1181 | f_expect_clear(verify_vlr_cell_id := false); |
Neels Hofmeyr | fc06c73 | 2020-08-19 12:52:28 +0000 | [diff] [blame] | 1182 | |
| 1183 | /* Now the same IMSI is still attached in the VLR, and a LU with an unknown TMSI reveals the same IMSI only |
| 1184 | * later during ID Response. osmo-msc first creates a new vlr_subscr for the unknown TMSI, and as soon as the |
| 1185 | * IMSI becomes known, must notice that this IMSI is still regarded as attached, and must not create evil twins. |
| 1186 | */ |
| 1187 | |
| 1188 | /* (since the TMSI Reallocation happened, we could do this with exactly the same TMSI as above, but for test |
| 1189 | * readability just use a different one.) */ |
| 1190 | l3_lu := f_build_lu_tmsi('56222222'O); |
| 1191 | f_cl3_or_initial_ue(l3_lu); |
| 1192 | |
| 1193 | /* Wait for + respond to ID REQ (IMSI) */ |
| 1194 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req(CM_ID_TYPE_IMSI))); |
| 1195 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp_IMSI(g_pars.imsi))); |
| 1196 | f_expect_common_id(); |
| 1197 | |
| 1198 | /* Expect MSC to do UpdateLocation to HLR; respond to it */ |
| 1199 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 1200 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 1201 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 1202 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 1203 | |
| 1204 | alt { |
| 1205 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 1206 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_TmsiRealloc_Cmpl)); |
| 1207 | } |
| 1208 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 1209 | setverdict(fail, "Expected LU ACK, but received REJ"); |
| 1210 | mtc.stop; |
| 1211 | } |
| 1212 | } |
| 1213 | |
| 1214 | /* Wait for MM-Information (if enabled) */ |
| 1215 | f_expect_mm_info(); |
| 1216 | |
| 1217 | /* wait for normal teardown */ |
Eric Wild | 85cc161 | 2022-03-30 01:44:29 +0200 | [diff] [blame] | 1218 | f_expect_clear(verify_vlr_cell_id := false); |
Neels Hofmeyr | fc06c73 | 2020-08-19 12:52:28 +0000 | [diff] [blame] | 1219 | } |
| 1220 | testcase TC_attached_imsi_lu_unknown_tmsi() runs on MTC_CT { |
| 1221 | var BSC_ConnHdlr vc_conn; |
| 1222 | f_init(); |
| 1223 | |
| 1224 | vc_conn := f_start_handler(refers(f_tc_attached_imsi_lu_unknown_tmsi), 56); |
| 1225 | vc_conn.done; |
| 1226 | } |
| 1227 | |
Harald Welte | 4d15fa7 | 2020-08-19 08:58:28 +0200 | [diff] [blame] | 1228 | friend function f_imsi_detach_by_imsi() runs on BSC_ConnHdlr { |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1229 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 1230 | |
| 1231 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1232 | 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] | 1233 | |
| 1234 | /* Send Early Classmark, just for the fun of it? */ |
Harald Welte | 4d15fa7 | 2020-08-19 08:58:28 +0200 | [diff] [blame] | 1235 | if (g_pars.ran_is_geran) { |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1236 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1237 | } |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1238 | |
| 1239 | /* wait for normal teardown */ |
Harald Welte | 4d15fa7 | 2020-08-19 08:58:28 +0200 | [diff] [blame] | 1240 | f_expect_clear(verify_vlr_cell_id := false); |
| 1241 | } |
| 1242 | |
| 1243 | |
| 1244 | /* Test IMSI DETACH (MI=IMSI) */ |
| 1245 | friend function f_tc_imsi_detach_by_imsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1246 | f_init_handler(pars); |
| 1247 | |
| 1248 | f_imsi_detach_by_imsi(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1249 | } |
| 1250 | testcase TC_imsi_detach_by_imsi() runs on MTC_CT { |
| 1251 | var BSC_ConnHdlr vc_conn; |
| 1252 | f_init(); |
| 1253 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1254 | vc_conn := f_start_handler(refers(f_tc_imsi_detach_by_imsi), 14, verify_cell_id := false); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1255 | vc_conn.done; |
| 1256 | } |
| 1257 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1258 | |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1259 | /* Test IMSI DETACH (MI=TMSI) */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1260 | 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] | 1261 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1262 | |
| 1263 | var MobileIdentityLV mi := valueof(ts_MI_TMSI_LV('01020304'O)); |
| 1264 | |
| 1265 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1266 | 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] | 1267 | |
| 1268 | /* Send Early Classmark, just for the fun of it? */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1269 | if (pars.ran_is_geran) { |
| 1270 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1271 | } |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1272 | |
| 1273 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1274 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1275 | } |
| 1276 | testcase TC_imsi_detach_by_tmsi() runs on MTC_CT { |
| 1277 | var BSC_ConnHdlr vc_conn; |
| 1278 | f_init(); |
| 1279 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1280 | vc_conn := f_start_handler(refers(f_tc_imsi_detach_by_tmsi), 15, verify_cell_id := false); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1281 | vc_conn.done; |
| 1282 | } |
| 1283 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1284 | |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1285 | /* Test IMSI DETACH (MI=IMEI), which is illegal */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1286 | 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] | 1287 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1288 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 1289 | var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1290 | |
| 1291 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1292 | 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] | 1293 | |
| 1294 | /* Send Early Classmark, just for the fun of it? */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1295 | if (pars.ran_is_geran) { |
| 1296 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1297 | } |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1298 | |
| 1299 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1300 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1301 | } |
| 1302 | testcase TC_imsi_detach_by_imei() runs on MTC_CT { |
| 1303 | var BSC_ConnHdlr vc_conn; |
| 1304 | f_init(); |
| 1305 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1306 | vc_conn := f_start_handler(refers(f_tc_imsi_detach_by_imei), 16, verify_cell_id := false); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1307 | vc_conn.done; |
| 1308 | } |
| 1309 | |
| 1310 | |
| 1311 | /* helper function for an emergency call. caller passes in mobile identity to use */ |
| 1312 | private function f_emerg_call(MobileIdentityLV mi) runs on BSC_ConnHdlr { |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 1313 | var CallParameters cpars := valueof(t_CallParams('112'H, 0)); |
| 1314 | cpars.emergency := true; |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1315 | |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 1316 | f_mo_call(cpars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1317 | } |
| 1318 | |
| 1319 | /* 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] | 1320 | 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] | 1321 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1322 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 1323 | var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1324 | 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] | 1325 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1326 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ('05'O))); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1327 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1328 | } |
| 1329 | testcase TC_emerg_call_imei_reject() runs on MTC_CT { |
| 1330 | var BSC_ConnHdlr vc_conn; |
| 1331 | f_init(); |
| 1332 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1333 | vc_conn := f_start_handler(refers(f_tc_emerg_call_imei_reject), 17, verify_cell_id := false); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1334 | vc_conn.done; |
| 1335 | } |
| 1336 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1337 | |
Harald Welte | d5b9140 | 2018-01-24 18:48:16 +0100 | [diff] [blame] | 1338 | /* establish an emergency call by IMSI, SIM inserted (and hence IMSI) */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1339 | 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] | 1340 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1341 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1342 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1343 | /* Then issue emergency call identified by IMSI */ |
| 1344 | f_emerg_call(valueof(ts_MI_IMSI_LV(g_pars.imsi))); |
| 1345 | } |
| 1346 | testcase TC_emerg_call_imsi() runs on MTC_CT { |
| 1347 | var BSC_ConnHdlr vc_conn; |
| 1348 | f_init(); |
| 1349 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1350 | vc_conn := f_start_handler(refers(f_tc_emerg_call_imsi), 18); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1351 | vc_conn.done; |
| 1352 | } |
| 1353 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1354 | |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1355 | /* CM Service Request for VGCS -> reject */ |
| 1356 | 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] | 1357 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1358 | |
| 1359 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1360 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1361 | |
| 1362 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1363 | 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] | 1364 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1365 | 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] | 1366 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1367 | } |
| 1368 | testcase TC_cm_serv_req_vgcs_reject() runs on MTC_CT { |
| 1369 | var BSC_ConnHdlr vc_conn; |
| 1370 | f_init(); |
| 1371 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1372 | 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] | 1373 | vc_conn.done; |
| 1374 | } |
| 1375 | |
| 1376 | /* CM Service Request for VBS -> reject */ |
| 1377 | 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] | 1378 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1379 | |
| 1380 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1381 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1382 | |
| 1383 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1384 | 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] | 1385 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1386 | 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] | 1387 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1388 | } |
| 1389 | testcase TC_cm_serv_req_vbs_reject() runs on MTC_CT { |
| 1390 | var BSC_ConnHdlr vc_conn; |
| 1391 | f_init(); |
| 1392 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1393 | 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] | 1394 | vc_conn.done; |
| 1395 | } |
| 1396 | |
| 1397 | /* CM Service Request for LCS -> reject */ |
| 1398 | 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] | 1399 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1400 | |
| 1401 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1402 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1403 | |
| 1404 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1405 | 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] | 1406 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1407 | 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] | 1408 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1409 | } |
| 1410 | testcase TC_cm_serv_req_lcs_reject() runs on MTC_CT { |
| 1411 | var BSC_ConnHdlr vc_conn; |
| 1412 | f_init(); |
| 1413 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1414 | 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] | 1415 | vc_conn.done; |
| 1416 | } |
| 1417 | |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1418 | /* CM Re-Establishment Request */ |
| 1419 | 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] | 1420 | f_init_handler(pars); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1421 | |
| 1422 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1423 | f_perform_lu(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1424 | |
| 1425 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 1426 | 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] | 1427 | f_cl3_or_initial_ue(l3_info); |
Neels Hofmeyr | 49bbb51 | 2021-07-29 22:51:08 +0200 | [diff] [blame] | 1428 | /* Older osmo-msc returns: GSM48_REJECT_SRV_OPT_NOT_SUPPORTED = 32, |
| 1429 | * newer osmo-msc with CM Re-Establish support returns: GSM48_REJECT_CALL_CAN_NOT_BE_IDENTIFIED = 38 */ |
| 1430 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ( (int2oct(32,1), int2oct(38,1)) ))); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1431 | f_expect_clear(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1432 | } |
| 1433 | testcase TC_cm_reest_req_reject() runs on MTC_CT { |
| 1434 | var BSC_ConnHdlr vc_conn; |
| 1435 | f_init(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1436 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1437 | 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] | 1438 | vc_conn.done; |
| 1439 | } |
| 1440 | |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1441 | /* Test LU (with authentication enabled), with wrong response from MS */ |
| 1442 | 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] | 1443 | f_init_handler(pars); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1444 | |
| 1445 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 1446 | |
| 1447 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1448 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1449 | |
| 1450 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1451 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1452 | |
| 1453 | /* Send Early Classmark, just for the fun of it */ |
| 1454 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1455 | |
| 1456 | var AuthVector vec := f_gen_auth_vec_2g(); |
| 1457 | var GSUP_IE auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G(vec.rand, vec.sres, vec.kc)); |
| 1458 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 1459 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
| 1460 | |
| 1461 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_AUTH_REQ(vec.rand))); |
| 1462 | /* Send back wrong auth response */ |
| 1463 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MT_MM_AUTH_RESP_2G('00000000'O))); |
| 1464 | |
| 1465 | /* Expect GSUP AUTH FAIL REP to HLR */ |
| 1466 | GSUP.receive(tr_GSUP_AUTH_FAIL_IND(g_pars.imsi)); |
| 1467 | |
| 1468 | /* Expect LU REJECT with Cause == Illegal MS */ |
| 1469 | 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] | 1470 | f_expect_clear(); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1471 | } |
| 1472 | testcase TC_lu_auth_2G_fail() runs on MTC_CT { |
| 1473 | var BSC_ConnHdlr vc_conn; |
| 1474 | f_init(); |
| 1475 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1476 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1477 | vc_conn := f_start_handler(refers(f_tc_lu_auth_2G_fail), 23, verify_cell_id := false); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1478 | vc_conn.done; |
| 1479 | } |
| 1480 | |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 1481 | /* 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] | 1482 | 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] | 1483 | pars.net.expect_auth := true; |
| 1484 | pars.net.expect_ciph := true; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1485 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1486 | f_perform_lu(); |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 1487 | } |
| 1488 | testcase TC_lu_imsi_auth_tmsi_encr_13_13() runs on MTC_CT { |
| 1489 | var BSC_ConnHdlr vc_conn; |
| 1490 | f_init(); |
| 1491 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 1492 | f_vty_config(MSCVTY, "network", "encryption a5 1 3"); |
| 1493 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1494 | 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] | 1495 | vc_conn.done; |
| 1496 | } |
| 1497 | |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1498 | /* Test Complete L3 without payload */ |
| 1499 | 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] | 1500 | f_init_handler(pars); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1501 | |
| 1502 | /* Send Complete L3 Info with empty L3 frame */ |
| 1503 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own, |
| 1504 | valueof(ts_BSSMAP_ComplL3(g_pars.cell_id, ''O)))); |
| 1505 | |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1506 | timer T := 5.0; |
| 1507 | T.start; |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1508 | alt { |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1509 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1510 | /* Expect LU REJECT with Cause == Illegal MS */ |
Harald Welte | bdb3c45 | 2018-03-18 22:43:06 +0100 | [diff] [blame] | 1511 | [] BSSAP.receive(tr_PDU_DTAP_MT(?)) { repeat; } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1512 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND) { repeat; } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1513 | [] as_clear_cmd_compl_disc(); |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1514 | [] T.timeout { |
Daniel Willmann | 90829d6 | 2018-02-15 17:45:14 +0100 | [diff] [blame] | 1515 | setverdict(fail, "Timeout waiting for ClearCommand or SCCP Release"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1516 | mtc.stop; |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1517 | } |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1518 | } |
| 1519 | setverdict(pass); |
| 1520 | } |
| 1521 | testcase TC_cl3_no_payload() runs on MTC_CT { |
| 1522 | var BSC_ConnHdlr vc_conn; |
| 1523 | f_init(); |
| 1524 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1525 | vc_conn := f_start_handler(refers(f_tc_cl3_no_payload), 25); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1526 | vc_conn.done; |
| 1527 | } |
| 1528 | |
| 1529 | /* Test Complete L3 with random payload */ |
| 1530 | 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] | 1531 | f_init_handler(pars); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1532 | |
Daniel Willmann | aa14a38 | 2018-07-26 08:29:45 +0200 | [diff] [blame] | 1533 | /* length is limited by PDU_BSSAP length field which includes some |
| 1534 | * other fields beside l3info payload. So payl can only be 240 bytes |
| 1535 | * Since rnd() returns values < 1 multiply with 241 |
| 1536 | */ |
| 1537 | var integer len := float2int(rnd() * 241.0); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1538 | var octetstring payl := f_rnd_octstring(len); |
| 1539 | |
| 1540 | /* Send Complete L3 Info with empty L3 frame */ |
| 1541 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own, |
| 1542 | valueof(ts_BSSMAP_ComplL3(g_pars.cell_id, payl)))); |
| 1543 | |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1544 | timer T := 5.0; |
| 1545 | T.start; |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1546 | alt { |
| 1547 | /* Immediate disconnect */ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1548 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1549 | [] BSSAP.receive(tr_PDU_DTAP_MT(?)) { repeat; } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1550 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND) { repeat; } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1551 | [] as_clear_cmd_compl_disc(); |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1552 | [] T.timeout { |
Daniel Willmann | 90829d6 | 2018-02-15 17:45:14 +0100 | [diff] [blame] | 1553 | setverdict(fail, "Timeout waiting for ClearCommand or SCCP Release"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1554 | mtc.stop; |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1555 | } |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1556 | } |
| 1557 | setverdict(pass); |
| 1558 | } |
| 1559 | testcase TC_cl3_rnd_payload() runs on MTC_CT { |
| 1560 | var BSC_ConnHdlr vc_conn; |
| 1561 | f_init(); |
| 1562 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1563 | vc_conn := f_start_handler(refers(f_tc_cl3_rnd_payload), 26); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1564 | vc_conn.done; |
| 1565 | } |
| 1566 | |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1567 | /* Test Complete L3 with random payload */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1568 | 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] | 1569 | f_init_handler(pars); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1570 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1571 | f_perform_lu(); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1572 | |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1573 | f_establish_fully(); |
Daniel Willmann | 898a7e0 | 2018-05-17 12:16:16 +0200 | [diff] [blame] | 1574 | f_expect_clear(10.0); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1575 | } |
| 1576 | testcase TC_establish_and_nothing() runs on MTC_CT { |
| 1577 | var BSC_ConnHdlr vc_conn; |
| 1578 | f_init(); |
| 1579 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1580 | vc_conn := f_start_handler(refers(f_tc_establish_and_nothing), 27); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1581 | vc_conn.done; |
| 1582 | } |
| 1583 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1584 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1585 | /* Test MO Call SETUP with no response from MNCC */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1586 | 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] | 1587 | f_init_handler(pars, 190.0); |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1588 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1589 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1590 | cpars.mgw_conn_2.resp := 0; |
| 1591 | cpars.stop_after_cc_setup := true; |
| 1592 | |
| 1593 | f_vty_config(MSCVTY, "msc", "mncc guard-timeout 20"); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1594 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1595 | f_perform_lu(); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1596 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1597 | f_mo_call_establish(cpars); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1598 | |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 1599 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
| 1600 | |
Philipp Maier | 109e6aa | 2018-10-17 10:53:32 +0200 | [diff] [blame] | 1601 | f_expect_clear(185.0); |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 1602 | |
| 1603 | deactivate(ccrel); |
| 1604 | |
| 1605 | f_sleep(1.0); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1606 | } |
| 1607 | testcase TC_mo_setup_and_nothing() runs on MTC_CT { |
| 1608 | var BSC_ConnHdlr vc_conn; |
| 1609 | f_init(); |
| 1610 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1611 | 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] | 1612 | vc_conn.done; |
| 1613 | } |
| 1614 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1615 | |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1616 | /* Test MO Call with no response to RAN-side CRCX */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1617 | 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] | 1618 | f_init_handler(pars); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1619 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1620 | var MNCC_PDU mncc; |
| 1621 | var MgcpCommand mgcp_cmd; |
| 1622 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1623 | f_perform_lu(); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1624 | /* Do not respond to the second CRCX */ |
| 1625 | cpars.mgw_conn_2.resp := 0; |
| 1626 | f_mo_call_establish(cpars); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1627 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1628 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1629 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1630 | f_expect_clear(60.0); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1631 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1632 | deactivate(ccrel); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1633 | } |
| 1634 | testcase TC_mo_crcx_ran_timeout() runs on MTC_CT { |
| 1635 | var BSC_ConnHdlr vc_conn; |
| 1636 | f_init(); |
| 1637 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1638 | 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] | 1639 | vc_conn.done; |
| 1640 | } |
| 1641 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1642 | |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1643 | /* Test MO Call with reject to RAN-side CRCX */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1644 | 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] | 1645 | f_init_handler(pars); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1646 | |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1647 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1648 | |
| 1649 | /* Respond with error for the first CRCX */ |
| 1650 | cpars.mgw_conn_1.resp := -1; |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1651 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1652 | f_perform_lu(); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1653 | f_mo_call_establish(cpars); |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1654 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1655 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
| 1656 | f_expect_clear(60.0); |
| 1657 | deactivate(ccrel); |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1658 | } |
| 1659 | testcase TC_mo_crcx_ran_reject() runs on MTC_CT { |
| 1660 | var BSC_ConnHdlr vc_conn; |
| 1661 | f_init(); |
| 1662 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1663 | 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] | 1664 | vc_conn.done; |
| 1665 | } |
| 1666 | |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1667 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1668 | /* helper function to start a MT call: MNCC SETUP; Paging; DChan est.; DTAP SETUP */ |
| 1669 | private function f_mt_call_start(inout CallParameters cpars) runs on BSC_ConnHdlr { |
| 1670 | var MNCC_PDU mncc; |
| 1671 | var MgcpCommand mgcp_cmd; |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1672 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1673 | f_perform_lu(); |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 1674 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1675 | |
| 1676 | /* Allocate call reference and send SETUP via MNCC to MSC */ |
| 1677 | cpars.mncc_callref := f_rnd_int(2147483648); |
| 1678 | MNCC.send(ts_MNCC_SETUP_req(cpars.mncc_callref, hex2str(g_pars.msisdn), |
| 1679 | hex2str(cpars.called_party), hex2str(g_pars.imsi))); |
| 1680 | |
| 1681 | /* MSC->BSC: expect PAGING from MSC */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 1682 | f_expect_paging(); |
| 1683 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1684 | /* MS -> MSC: PAGING RESPONSE */ |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1685 | f_establish_fully(EST_TYPE_PAG_RESP); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1686 | |
| 1687 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1688 | |
| 1689 | /* MSC->MS: SETUP */ |
| 1690 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_SETUP(cpars.transaction_id, *, cpars.called_party))); |
| 1691 | } |
| 1692 | |
| 1693 | /* Test MT Call */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1694 | 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] | 1695 | f_init_handler(pars); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1696 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
| 1697 | var MNCC_PDU mncc; |
| 1698 | var MgcpCommand mgcp_cmd; |
| 1699 | |
| 1700 | f_mt_call_start(cpars); |
| 1701 | |
| 1702 | /* MS->MSC: CALL CONFIRMED */ |
| 1703 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CALL_CONF(cpars.transaction_id))); |
| 1704 | |
| 1705 | MNCC.receive(tr_MNCC_CALL_CONF_ind(cpars.mncc_callref)); |
| 1706 | |
| 1707 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
| 1708 | cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 1709 | |
| 1710 | /* Detect if the received CRCX is a wildcarded CRCX request. If yes, |
| 1711 | * set an endpoint name that fits the pattern. If not, just use the |
| 1712 | * endpoint name from the request */ |
| 1713 | if (match(mgcp_cmd.line.ep, t_MGCP_EP_wildcard)) { |
| 1714 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
| 1715 | } else { |
| 1716 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
| 1717 | } |
| 1718 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1719 | /* Respond to CRCX with error */ |
| 1720 | var MgcpResponse mgcp_rsp := { |
| 1721 | line := { |
| 1722 | code := "542", |
| 1723 | trans_id := mgcp_cmd.line.trans_id, |
| 1724 | string := "FORCED_FAIL" |
| 1725 | }, |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1726 | sdp := omit |
| 1727 | } |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 1728 | var MgcpParameter mgcp_rsp_param := { |
| 1729 | code := "Z", |
| 1730 | val := cpars.mgcp_ep |
| 1731 | }; |
| 1732 | mgcp_rsp.params[0] := mgcp_rsp_param; |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1733 | MGCP.send(mgcp_rsp); |
| 1734 | |
| 1735 | timer T := 30.0; |
| 1736 | T.start; |
| 1737 | alt { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1738 | [] T.timeout { |
| 1739 | setverdict(fail, "Timeout waiting for channel release"); |
| 1740 | mtc.stop; |
| 1741 | } |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1742 | [] MNCC.receive { repeat; } |
| 1743 | [] GSUP.receive { repeat; } |
| 1744 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 1745 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
| 1746 | f_create_mgcp_delete_ep(cpars.mgcp_ep); |
| 1747 | repeat; |
| 1748 | } |
| 1749 | [] MGCP.receive { repeat; } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1750 | [] as_clear_cmd_compl_disc(); |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 1751 | [] as_optional_cc_rel(cpars); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1752 | } |
| 1753 | } |
| 1754 | testcase TC_mt_crcx_ran_reject() runs on MTC_CT { |
| 1755 | var BSC_ConnHdlr vc_conn; |
| 1756 | f_init(); |
| 1757 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1758 | 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] | 1759 | vc_conn.done; |
| 1760 | } |
| 1761 | |
| 1762 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1763 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1764 | /* Test MT Call T310 timer */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1765 | friend function f_tc_mt_t310(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1766 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1767 | var MgcpCommand mgcp_cmd; |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1768 | var PDU_BSSAP bssap; |
| 1769 | timer T310; |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1770 | |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1771 | f_init_handler(pars); |
| 1772 | |
Neels Hofmeyr | 0560615 | 2023-03-06 22:42:27 +0100 | [diff] [blame] | 1773 | /* Make sure X2 does not fire in this test. This test does not send a CN RTP port to osmo-msc, which will |
| 1774 | * trigger X2 timeout. We want to test T310, so make X2 significantly longer than T310=30s. */ |
| 1775 | f_vty_config(MSCVTY, "msc", "timer mgw X2 40"); |
| 1776 | |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1777 | /* Initiate a MT call, establish connection */ |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1778 | f_mt_call_start(cpars); |
| 1779 | |
| 1780 | /* MS->MSC: CALL CONFIRMED */ |
| 1781 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CALL_CONF(cpars.transaction_id))); |
| 1782 | MNCC.receive(tr_MNCC_CALL_CONF_ind(cpars.mncc_callref)); |
| 1783 | |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1784 | /* NOTE: MSC is expected to start T310 here */ |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1785 | |
Neels Hofmeyr | d8a4aee | 2022-07-25 22:07:24 +0200 | [diff] [blame] | 1786 | interleave { |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1787 | /* MSC->MGW: CRCX (first) */ |
Neels Hofmeyr | d8a4aee | 2022-07-25 22:07:24 +0200 | [diff] [blame] | 1788 | [] MGCP.receive(tr_CRCX) -> value mgcp_cmd { |
| 1789 | f_handle_crcx(cpars, mgcp_cmd); /* MSC<-MGW: OK */ |
| 1790 | } |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1791 | |
| 1792 | /* BSC->BSC: BSSMAP ASSIGNMENT REQ */ |
Neels Hofmeyr | d8a4aee | 2022-07-25 22:07:24 +0200 | [diff] [blame] | 1793 | [] BSSAP.receive(tr_BSSMAP_AssignmentReq(omit, ?)) -> value bssap { |
| 1794 | BSSAP.send(ts_BSSMAP_AssignmentComplete(omit, |
| 1795 | aoip := f_ts_BSSMAP_IE_AoIP_TLA(cpars.bss_rtp_ip, cpars.bss_rtp_port), |
| 1796 | speechCodec := ts_BSSMAP_IE_SpeechCodec({ ts_CodecFR }))); |
| 1797 | } |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1798 | |
| 1799 | /* MSC->MGW: MDCX */ |
Neels Hofmeyr | d8a4aee | 2022-07-25 22:07:24 +0200 | [diff] [blame] | 1800 | [] MGCP.receive(tr_MDCX) -> value mgcp_cmd { |
| 1801 | MGCP.send(ts_MDCX_ACK(mgcp_cmd.line.trans_id, cpars.mgw_conn_1.mgcp_connection_id, |
| 1802 | sdp := omit)); |
| 1803 | } |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1804 | |
| 1805 | /* MSC->MGW: CRCX (second) */ |
Neels Hofmeyr | d8a4aee | 2022-07-25 22:07:24 +0200 | [diff] [blame] | 1806 | [] MGCP.receive(tr_CRCX) -> value mgcp_cmd { |
| 1807 | f_handle_crcx(cpars, mgcp_cmd); /* MSC<-MGW: OK */ |
Neels Hofmeyr | d8a4aee | 2022-07-25 22:07:24 +0200 | [diff] [blame] | 1808 | } |
Neels Hofmeyr | c29e6dc | 2022-08-09 02:38:10 +0200 | [diff] [blame] | 1809 | |
| 1810 | [] MNCC.receive(tr_MNCC_RTP_CREATE(cpars.mncc_callref)); |
Neels Hofmeyr | d8a4aee | 2022-07-25 22:07:24 +0200 | [diff] [blame] | 1811 | } |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1812 | |
| 1813 | /* Reschedule the guard timeout */ |
| 1814 | g_Tguard.start(30.0 + 10.0); |
| 1815 | |
| 1816 | /* NOTE: the BSC is expected to respond with CC ALERTING at this state, so |
| 1817 | * the MSC would stop T310. However, the idea is to verify T310 expiration |
| 1818 | * here, so grab some popcorn and wait for MNCC DISC.ind. */ |
| 1819 | T310.start(30.0 + 2.0); |
Neels Hofmeyr | e81ef42 | 2022-08-07 14:33:06 +0200 | [diff] [blame] | 1820 | var MNCC_PDU mncc_rx; |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1821 | alt { |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1822 | [] T310.timeout { |
| 1823 | setverdict(fail, "Timeout waiting for MNCC DISC.ind due to T310"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1824 | mtc.stop; |
| 1825 | } |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1826 | [] MNCC.receive(tr_MNCC_DISC_ind(cpars.mncc_callref)) { |
| 1827 | MNCC.send(ts_MNCC_REL_req(cpars.mncc_callref, valueof(ts_MNCC_cause(23)))); |
Neels Hofmeyr | 13eeb55 | 2022-08-07 14:33:37 +0200 | [diff] [blame] | 1828 | log("Rx MNCC DISC.ind, T310.read yields ", T310.read); |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1829 | setverdict(pass); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1830 | } |
Neels Hofmeyr | e81ef42 | 2022-08-07 14:33:06 +0200 | [diff] [blame] | 1831 | [] MNCC.receive(MNCC_PDU:?) -> value mncc_rx { |
| 1832 | log("Rx ", mncc_rx); |
| 1833 | setverdict(fail, "Expected MNCC DISC.ind, got some other MNCC message instead"); |
| 1834 | mtc.stop; |
| 1835 | } |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1836 | } |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1837 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1838 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_DISC(cpars.transaction_id))); |
| 1839 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))); |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1840 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_REL_COMPL(cpars.transaction_id, '1'B))); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1841 | |
| 1842 | alt { |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1843 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 1844 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1845 | // FIXME: f_create_mgcp_delete_ep(cpars.mgcp_ep); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1846 | repeat; |
| 1847 | } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1848 | [] as_clear_cmd_compl_disc(); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1849 | } |
| 1850 | } |
| 1851 | testcase TC_mt_t310() runs on MTC_CT { |
| 1852 | var BSC_ConnHdlr vc_conn; |
| 1853 | f_init(); |
| 1854 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1855 | vc_conn := f_start_handler(refers(f_tc_mt_t310), 32); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1856 | vc_conn.done; |
| 1857 | } |
| 1858 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1859 | |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1860 | /* 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] | 1861 | 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] | 1862 | f_init_handler(pars); |
| 1863 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1864 | |
| 1865 | /* Location Update to make subscriber known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1866 | f_perform_lu(); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1867 | |
| 1868 | /* First MO call should succeed */ |
| 1869 | f_mo_call(cpars); |
| 1870 | |
| 1871 | /* Cancel the subscriber in the VLR */ |
| 1872 | GSUP.send(ts_GSUP_CL_REQ(g_pars.imsi, OSMO_GSUP_CANCEL_TYPE_WITHDRAW)); |
| 1873 | alt { |
| 1874 | [] GSUP.receive(tr_GSUP_CL_RES(g_pars.imsi)) { } |
| 1875 | [] GSUP.receive(tr_GSUP_CL_ERR(g_pars.imsi)) { |
| 1876 | setverdict(fail, "Received GSUP Location Cancel Error"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1877 | mtc.stop; |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1878 | } |
| 1879 | } |
| 1880 | |
| 1881 | /* Follow-up transactions should fail */ |
| 1882 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 1883 | 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] | 1884 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1885 | alt { |
| 1886 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)) { } |
| 1887 | [] BSSAP.receive { |
| 1888 | setverdict(fail, "Received unexpected BSSAP instead of CM SERV REJ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1889 | mtc.stop; |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1890 | } |
| 1891 | } |
Neels Hofmeyr | 0f7429a | 2019-03-07 22:28:41 +0100 | [diff] [blame] | 1892 | |
| 1893 | f_expect_clear(); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1894 | setverdict(pass); |
| 1895 | } |
| 1896 | testcase TC_gsup_cancel() runs on MTC_CT { |
| 1897 | var BSC_ConnHdlr vc_conn; |
| 1898 | f_init(); |
| 1899 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1900 | vc_conn := f_start_handler(refers(f_tc_gsup_cancel), 33, verify_cell_id := false); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1901 | vc_conn.done; |
| 1902 | } |
| 1903 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1904 | |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1905 | /* A5/1 only permitted on network side, and MS capable to do it */ |
| 1906 | private function f_tc_lu_imsi_auth_tmsi_encr_1_13(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1907 | pars.net.expect_auth := true; |
| 1908 | pars.net.expect_ciph := true; |
| 1909 | pars.net.kc_support := '02'O; /* A5/1 only */ |
| 1910 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1911 | f_perform_lu(); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1912 | } |
| 1913 | testcase TC_lu_imsi_auth_tmsi_encr_1_13() runs on MTC_CT { |
| 1914 | var BSC_ConnHdlr vc_conn; |
| 1915 | f_init(); |
| 1916 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1917 | f_vty_config(MSCVTY, "network", "encryption a5 1"); |
| 1918 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1919 | 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] | 1920 | vc_conn.done; |
| 1921 | } |
| 1922 | |
| 1923 | /* A5/3 only permitted on network side, and MS capable to do it */ |
| 1924 | private function f_tc_lu_imsi_auth_tmsi_encr_3_13(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1925 | pars.net.expect_auth := true; |
| 1926 | pars.net.expect_ciph := true; |
| 1927 | pars.net.kc_support := '08'O; /* A5/3 only */ |
| 1928 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1929 | f_perform_lu(); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1930 | } |
| 1931 | testcase TC_lu_imsi_auth_tmsi_encr_3_13() runs on MTC_CT { |
| 1932 | var BSC_ConnHdlr vc_conn; |
| 1933 | f_init(); |
| 1934 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1935 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1936 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1937 | 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] | 1938 | vc_conn.done; |
| 1939 | } |
| 1940 | |
| 1941 | /* A5/3 only permitted on network side, and MS with only A5/1 support */ |
| 1942 | private function f_tc_lu_imsi_auth_tmsi_encr_3_1(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1943 | pars.net.expect_auth := true; |
| 1944 | pars.net.expect_ciph := true; |
| 1945 | pars.net.kc_support := '08'O; /* A5/3 only */ |
| 1946 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 1947 | f_init_handler(pars, 15.0); |
| 1948 | |
| 1949 | /* cannot use f_perform_lu() as we expect a reject */ |
| 1950 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 1951 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1952 | f_cl3_or_initial_ue(l3_lu); |
Neels Hofmeyr | 29b8da0 | 2018-03-01 18:09:45 +0100 | [diff] [blame] | 1953 | if (pars.send_early_cm) { |
| 1954 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1955 | } else { |
| 1956 | pars.cm1.esind := '0'B; |
| 1957 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1958 | f_mm_auth(); |
| 1959 | alt { |
Daniel Willmann | 52918e5 | 2018-09-20 14:39:09 +0200 | [diff] [blame] | 1960 | [] BSSAP.receive(tr_BSSMAP_ClassmarkReq) { |
| 1961 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1962 | repeat; |
| 1963 | } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1964 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 1965 | f_expect_clear(); |
| 1966 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1967 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?,?)) { |
| 1968 | setverdict(fail, "CipherModeCommand despite no A5 intersection"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1969 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1970 | } |
| 1971 | [] BSSAP.receive { |
Harald Welte | 458fd37 | 2018-03-21 11:26:23 +0100 | [diff] [blame] | 1972 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1973 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1974 | } |
| 1975 | } |
| 1976 | setverdict(pass); |
| 1977 | } |
| 1978 | testcase TC_lu_imsi_auth_tmsi_encr_3_1() runs on MTC_CT { |
| 1979 | var BSC_ConnHdlr vc_conn; |
| 1980 | f_init(); |
| 1981 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1982 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1983 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1984 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_3_1), 360, verify_cell_id := false); |
Neels Hofmeyr | 29b8da0 | 2018-03-01 18:09:45 +0100 | [diff] [blame] | 1985 | vc_conn.done; |
| 1986 | } |
| 1987 | testcase TC_lu_imsi_auth_tmsi_encr_3_1_no_cm() runs on MTC_CT { |
| 1988 | var BSC_ConnHdlrPars pars; |
| 1989 | var BSC_ConnHdlr vc_conn; |
| 1990 | f_init(); |
| 1991 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1992 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1993 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1994 | pars := f_init_pars(361, verify_cell_id := false); |
Neels Hofmeyr | 29b8da0 | 2018-03-01 18:09:45 +0100 | [diff] [blame] | 1995 | pars.send_early_cm := false; |
| 1996 | 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] | 1997 | vc_conn.done; |
| 1998 | } |
Neels Hofmeyr | 1b3c6e3 | 2018-03-01 17:52:21 +0100 | [diff] [blame] | 1999 | testcase TC_lu_imsi_auth_tmsi_encr_3_1_log_msc_debug() runs on MTC_CT { |
| 2000 | var BSC_ConnHdlr vc_conn; |
| 2001 | f_init(); |
| 2002 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 2003 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 2004 | |
| 2005 | /* Make sure the MSC category is on DEBUG level to trigger the log |
| 2006 | * message that is reported in OS#2947 to trigger the segfault */ |
| 2007 | f_vty_config(MSCVTY, "log stderr", "logging level msc debug"); |
| 2008 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 2009 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_3_1), 362, verify_cell_id := false); |
Neels Hofmeyr | 1b3c6e3 | 2018-03-01 17:52:21 +0100 | [diff] [blame] | 2010 | vc_conn.done; |
| 2011 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2012 | |
| 2013 | /* A5/1 + A5/3 only permitted on network side, and MS with only A5/2 support */ |
| 2014 | private function f_tc_lu_imsi_auth_tmsi_encr_13_2(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2015 | pars.net.expect_auth := true; |
| 2016 | pars.net.expect_ciph := true; |
| 2017 | pars.net.kc_support := '0A'O; /* A5/1 + A5/3 */ |
| 2018 | pars.cm1.a5_1 := '1'B; |
| 2019 | pars.cm2.a5_1 := '1'B; |
| 2020 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 2021 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '1'B; |
| 2022 | f_init_handler(pars, 15.0); |
| 2023 | |
| 2024 | /* cannot use f_perform_lu() as we expect a reject */ |
| 2025 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 2026 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 2027 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2028 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 2029 | f_mm_auth(); |
| 2030 | alt { |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 2031 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 2032 | f_expect_clear(); |
| 2033 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2034 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?,?)) { |
| 2035 | setverdict(fail, "CipherModeCommand despite no A5 intersection"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2036 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2037 | } |
| 2038 | [] BSSAP.receive { |
Harald Welte | 458fd37 | 2018-03-21 11:26:23 +0100 | [diff] [blame] | 2039 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2040 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2041 | } |
| 2042 | } |
| 2043 | setverdict(pass); |
| 2044 | } |
| 2045 | testcase TC_lu_imsi_auth_tmsi_encr_13_2() runs on MTC_CT { |
| 2046 | var BSC_ConnHdlr vc_conn; |
| 2047 | f_init(); |
| 2048 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 2049 | f_vty_config(MSCVTY, "network", "encryption a5 1 3"); |
| 2050 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 2051 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_13_2), 37, verify_cell_id := false); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2052 | vc_conn.done; |
| 2053 | } |
| 2054 | |
Eric Wild | 26f4a62 | 2021-05-17 15:27:05 +0200 | [diff] [blame] | 2055 | /* A5/0 + A5/1 + A5/3 + a5/4 only permitted on network side, and MS with only A5/1 support */ |
| 2056 | private function f_tc_lu_imsi_auth_tmsi_encr_0134_1(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2057 | pars.net.expect_auth := true; |
| 2058 | pars.net.expect_ciph := true; |
| 2059 | pars.net.kc_support := '03'O; /* A5/0 + A5/1 */ |
| 2060 | pars.cm1.a5_1 := '0'B; |
| 2061 | pars.cm2.a5_1 := '0'B; |
| 2062 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 2063 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '0'B; |
| 2064 | pars.cm2.classmarkInformationType2_oct5.cm3 := '0'B; |
| 2065 | pars.cm3 := omit; |
| 2066 | pars.use_umts_aka := true; |
| 2067 | |
| 2068 | f_init_handler(pars, 15.0); |
| 2069 | f_perform_lu(); |
| 2070 | } |
| 2071 | testcase TC_lu_imsi_auth_tmsi_encr_0134_1() runs on MTC_CT { |
| 2072 | var BSC_ConnHdlr vc_conn; |
| 2073 | f_init(); |
| 2074 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 2075 | f_vty_config(MSCVTY, "network", "encryption a5 0 1 3 4"); |
| 2076 | |
| 2077 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_0134_1), 39); |
| 2078 | vc_conn.done; |
| 2079 | } |
| 2080 | |
| 2081 | /* A5/0 + A5/1 + A5/3 + a5/4 only permitted on network side, and MS with A5/3 + A5/4 support */ |
| 2082 | private function f_tc_lu_imsi_auth_tmsi_encr_0134_34(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2083 | pars.net.expect_auth := true; |
| 2084 | pars.net.expect_ciph := true; |
| 2085 | pars.net.kc_support := '19'O; /* A5/3 + A5/4 */ |
| 2086 | pars.cm1.a5_1 := '1'B; |
| 2087 | pars.cm2.a5_1 := '1'B; |
| 2088 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '1'B; |
| 2089 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '0'B; |
| 2090 | pars.cm2.classmarkInformationType2_oct5.cm3 := '1'B; |
| 2091 | pars.cm3 := valueof(ts_CM3_default); |
| 2092 | pars.use_umts_aka := true; |
| 2093 | |
| 2094 | f_init_handler(pars, 15.0); |
| 2095 | f_perform_lu(); |
| 2096 | } |
| 2097 | testcase TC_lu_imsi_auth_tmsi_encr_0134_34() runs on MTC_CT { |
| 2098 | var BSC_ConnHdlr vc_conn; |
| 2099 | f_init(); |
| 2100 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 2101 | f_vty_config(MSCVTY, "network", "encryption a5 0 1 3 4"); |
| 2102 | |
| 2103 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_0134_34), 40); |
| 2104 | vc_conn.done; |
| 2105 | } |
| 2106 | |
| 2107 | /* A5/0 + A5/1 + A5/3 + a5/4 only permitted on network side, and MS with A5/3 support but no CM3 */ |
| 2108 | private function f_tc_lu_imsi_auth_tmsi_encr_0134_34_no_cm3(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2109 | pars.net.expect_auth := true; |
| 2110 | pars.net.expect_ciph := true; |
| 2111 | pars.net.kc_support := '19'O; /* A5/3 + A5/4 */ |
| 2112 | pars.cm1.a5_1 := '1'B; |
| 2113 | pars.cm2.a5_1 := '1'B; |
| 2114 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '1'B; |
| 2115 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '0'B; |
| 2116 | pars.cm2.classmarkInformationType2_oct5.cm3 := '0'B; |
| 2117 | pars.cm3 := omit; |
| 2118 | pars.use_umts_aka := true; |
| 2119 | |
| 2120 | f_init_handler(pars, 15.0); |
| 2121 | f_perform_lu(); |
| 2122 | } |
| 2123 | testcase TC_lu_imsi_auth_tmsi_encr_0134_34_no_cm3() runs on MTC_CT { |
| 2124 | var BSC_ConnHdlr vc_conn; |
| 2125 | f_init(); |
| 2126 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 2127 | f_vty_config(MSCVTY, "network", "encryption a5 0 1 3 4"); |
| 2128 | |
| 2129 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_0134_34_no_cm3), 41); |
| 2130 | vc_conn.done; |
| 2131 | } |
| 2132 | |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2133 | /* A5/0 + A5/1 + A5/3 only permitted on network side, and MS with only A5/2 support */ |
| 2134 | private function f_tc_lu_imsi_auth_tmsi_encr_013_2(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2135 | pars.net.expect_auth := true; |
| 2136 | pars.net.expect_ciph := true; |
| 2137 | pars.net.kc_support := '0B'O; /* A5/1 + A5/3 */ |
| 2138 | pars.cm1.a5_1 := '1'B; |
| 2139 | pars.cm2.a5_1 := '1'B; |
| 2140 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 2141 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '1'B; |
| 2142 | f_init_handler(pars, 15.0); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 2143 | f_perform_lu(); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2144 | } |
| 2145 | testcase TC_lu_imsi_auth_tmsi_encr_013_2() runs on MTC_CT { |
| 2146 | var BSC_ConnHdlr vc_conn; |
| 2147 | f_init(); |
| 2148 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 2149 | f_vty_config(MSCVTY, "network", "encryption a5 0 1 3"); |
| 2150 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 2151 | 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] | 2152 | vc_conn.done; |
| 2153 | } |
| 2154 | |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 2155 | /* LU followed by MT call (including paging) */ |
Neels Hofmeyr | 8fe8a90 | 2019-11-03 05:51:03 +0100 | [diff] [blame] | 2156 | 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] | 2157 | f_init_handler(pars); |
Stefan Sperling | 26d57be | 2018-11-12 17:03:26 +0100 | [diff] [blame] | 2158 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 2159 | cpars.use_osmux := pars.use_osmux; |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 2160 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 2161 | f_perform_lu(); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 2162 | f_mt_call(cpars); |
| 2163 | } |
| 2164 | testcase TC_lu_and_mt_call() runs on MTC_CT { |
| 2165 | var BSC_ConnHdlr vc_conn; |
| 2166 | f_init(); |
| 2167 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 2168 | 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] | 2169 | vc_conn.done; |
| 2170 | } |
| 2171 | |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 2172 | testcase TC_lu_and_mt_call_osmux() runs on MTC_CT { |
| 2173 | var BSC_ConnHdlr vc_conn; |
| 2174 | f_init(1, false, true, true); |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 2175 | |
| 2176 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_call), 39, 0, true, true); |
| 2177 | vc_conn.done; |
| 2178 | } |
| 2179 | |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 2180 | /* LU followed by MT call (including paging) */ |
| 2181 | friend function f_tc_lu_and_mt_call_ipv6(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2182 | f_init_handler(pars); |
| 2183 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 2184 | cpars.mgw_conn_1.mgw_rtp_ip := "::1"; |
| 2185 | cpars.mgw_conn_2.mgw_rtp_ip := "::2"; |
| 2186 | cpars.bss_rtp_ip := "::3"; |
Pau Espin Pedrol | 563b3d0 | 2020-09-09 20:19:52 +0200 | [diff] [blame] | 2187 | cpars.mncc_rtp_ip := "::9"; |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 2188 | f_perform_lu(); |
| 2189 | f_mt_call(cpars); |
| 2190 | } |
| 2191 | testcase TC_lu_and_mt_call_ipv6() runs on MTC_CT { |
| 2192 | var BSC_ConnHdlr vc_conn; |
| 2193 | f_init(); |
| 2194 | |
| 2195 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_call_ipv6), 39); |
| 2196 | vc_conn.done; |
| 2197 | } |
| 2198 | |
Neels Hofmeyr | b58d974 | 2019-11-27 18:44:54 +0100 | [diff] [blame] | 2199 | /* MT call while already Paging */ |
| 2200 | friend function f_tc_lu_and_mt_call_already_paging(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2201 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
| 2202 | var SmsParameters spars := valueof(t_SmsPars); |
| 2203 | var OCT4 tmsi; |
| 2204 | |
| 2205 | f_init_handler(pars); |
| 2206 | |
| 2207 | /* Perform location update */ |
| 2208 | f_perform_lu(); |
| 2209 | |
| 2210 | /* register an 'expect' for given IMSI (+TMSI) */ |
| 2211 | if (isvalue(g_pars.tmsi)) { |
| 2212 | tmsi := g_pars.tmsi; |
| 2213 | } else { |
| 2214 | tmsi := 'FFFFFFFF'O; |
| 2215 | } |
| 2216 | f_ran_register_imsi(g_pars.imsi, tmsi); |
| 2217 | |
| 2218 | log("start Paging by an SMS"); |
| 2219 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 2220 | |
| 2221 | /* MSC->BSC: expect PAGING from MSC */ |
| 2222 | f_expect_paging(); |
| 2223 | |
| 2224 | log("MNCC signals MT call, before Paging Response"); |
Oliver Smith | 97dc91f | 2023-05-31 13:53:21 +0200 | [diff] [blame] | 2225 | f_mt_call_initiate(cpars); |
Neels Hofmeyr | b58d974 | 2019-11-27 18:44:54 +0100 | [diff] [blame] | 2226 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
| 2227 | |
| 2228 | f_sleep(0.5); |
| 2229 | log("phone answers Paging, expecting both SMS and MT call to be established"); |
| 2230 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2231 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 2232 | interleave { |
| 2233 | [] BSSAP.receive(f_mt_sms_deliver_pdu(spars)) { |
| 2234 | log("Got SMS-DELIVER"); |
| 2235 | }; |
| 2236 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_SETUP(cpars.transaction_id, *, cpars.called_party))) { |
| 2237 | log("Got CC Setup"); |
| 2238 | }; |
| 2239 | } |
| 2240 | setverdict(pass); |
| 2241 | log("success, tear down"); |
| 2242 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
| 2243 | if (g_pars.ran_is_geran) { |
| 2244 | BSSAP.send(ts_BSSMAP_ClearRequest(0)); |
| 2245 | } else { |
| 2246 | BSSAP.send(ts_RANAP_IuReleaseRequest(ts_RanapCause_om_intervention)); |
| 2247 | } |
| 2248 | f_expect_clear(); |
| 2249 | deactivate(ccrel); |
| 2250 | f_vty_sms_clear(hex2str(g_pars.imsi)); |
| 2251 | } |
| 2252 | testcase TC_lu_and_mt_call_already_paging() runs on MTC_CT { |
| 2253 | var BSC_ConnHdlrPars pars; |
| 2254 | var BSC_ConnHdlr vc_conn; |
| 2255 | f_init(); |
| 2256 | pars := f_init_pars(391); |
| 2257 | vc_conn := f_start_handler_with_pars(refers(f_tc_lu_and_mt_call_already_paging), pars); |
| 2258 | vc_conn.done; |
| 2259 | } |
| 2260 | |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 2261 | /* Test MO Call SETUP with DTMF */ |
| 2262 | private function f_tc_mo_setup_dtmf_dup(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2263 | f_init_handler(pars); |
| 2264 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 2265 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 2266 | f_perform_lu(); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 2267 | f_mo_seq_dtmf_dup(cpars); |
| 2268 | } |
| 2269 | testcase TC_mo_setup_and_dtmf_dup() runs on MTC_CT { |
| 2270 | var BSC_ConnHdlr vc_conn; |
| 2271 | f_init(); |
| 2272 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 2273 | 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] | 2274 | vc_conn.done; |
| 2275 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2276 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 2277 | testcase TC_cr_before_reset() runs on MTC_CT { |
| 2278 | timer T := 4.0; |
| 2279 | var boolean reset_ack_seen := false; |
| 2280 | f_init_bssap_direct(); |
| 2281 | |
Harald Welte | 3ca0ce1 | 2019-04-23 17:18:48 +0200 | [diff] [blame] | 2282 | f_ran_adapter_start(g_bssap[0]); |
Daniel Willmann | 42d1d5b | 2018-08-07 15:18:41 +0200 | [diff] [blame] | 2283 | |
Daniel Willmann | e801896 | 2018-08-21 14:18:00 +0200 | [diff] [blame] | 2284 | f_sleep(3.0); |
| 2285 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 2286 | /* Make a blind connection attemt, to trigger the deadlock condition */ |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 2287 | 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] | 2288 | |
| 2289 | /* Send a BSSMAP reset */ |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 2290 | 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] | 2291 | T.start |
| 2292 | alt { |
| 2293 | [] BSSAP_DIRECT.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_ResetAck)) { |
| 2294 | reset_ack_seen := true; |
| 2295 | repeat; |
| 2296 | } |
| 2297 | |
| 2298 | /* Acknowledge MSC sided reset requests */ |
| 2299 | [] BSSAP_DIRECT.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) { |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 2300 | 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] | 2301 | repeat; |
| 2302 | } |
| 2303 | |
| 2304 | /* Ignore all other messages (e.g CR from the connection request) */ |
| 2305 | [] BSSAP_DIRECT.receive { repeat } |
| 2306 | |
| 2307 | /* If we got no BSSMAP RESET ACK back, then the MSC entered the |
| 2308 | * deadlock situation. The MSC is then unable to respond to any |
| 2309 | * further BSSMAP RESET or any other sort of traffic. */ |
| 2310 | [reset_ack_seen == true] T.timeout { setverdict(pass) } |
| 2311 | [reset_ack_seen == false] T.timeout { |
| 2312 | setverdict(fail, "no BSSMAP RESET ACK seen!"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2313 | mtc.stop; |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 2314 | } |
Pau Espin Pedrol | 7e9178d | 2019-12-17 17:52:17 +0100 | [diff] [blame] | 2315 | } |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 2316 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2317 | |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 2318 | /* 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] | 2319 | 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] | 2320 | f_init_handler(pars); |
| 2321 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 2322 | var MNCC_PDU mncc; |
| 2323 | var MgcpCommand mgcp_cmd; |
| 2324 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 2325 | /* Do not respond to the second CRCX */ |
| 2326 | cpars.mgw_conn_2.resp := 0; |
| 2327 | |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 2328 | f_perform_lu(); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 2329 | f_mo_call_establish(cpars); |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 2330 | |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 2331 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 2332 | |
| 2333 | f_expect_clear(60.0); |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 2334 | |
| 2335 | deactivate(ccrel); |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 2336 | } |
| 2337 | testcase TC_mo_release_timeout() runs on MTC_CT { |
| 2338 | var BSC_ConnHdlr vc_conn; |
| 2339 | f_init(); |
| 2340 | |
| 2341 | vc_conn := f_start_handler(refers(f_tc_mo_release_timeout), 40); |
| 2342 | vc_conn.done; |
| 2343 | } |
| 2344 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 2345 | |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 2346 | /* LU followed by MT call (including paging) */ |
| 2347 | private function f_tc_lu_and_mt_call_no_dlcx_resp(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2348 | f_init_handler(pars); |
Stefan Sperling | 26d57be | 2018-11-12 17:03:26 +0100 | [diff] [blame] | 2349 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 2350 | |
| 2351 | /* Intentionally disable the CRCX response */ |
| 2352 | cpars.mgw_drop_dlcx := true; |
| 2353 | |
| 2354 | /* Perform location update and call */ |
| 2355 | f_perform_lu(); |
| 2356 | f_mt_call(cpars); |
| 2357 | } |
| 2358 | testcase TC_lu_and_mt_call_no_dlcx_resp() runs on MTC_CT { |
| 2359 | var BSC_ConnHdlr vc_conn; |
| 2360 | f_init(); |
| 2361 | |
| 2362 | /* Perform an almost normal looking locationupdate + mt-call, but do |
| 2363 | * not respond to the DLCX at the end of the call */ |
| 2364 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_call_no_dlcx_resp), 41); |
| 2365 | vc_conn.done; |
| 2366 | |
| 2367 | /* Wait a guard period until the MGCP layer in the MSC times out, |
| 2368 | * if the MSC is vulnerable to the use-after-free situation that is |
| 2369 | * fixed by I78f1b6a9149488a4ad3f120c1e190a83c07d4b89 then it should |
| 2370 | * segfault now */ |
| 2371 | f_sleep(6.0); |
| 2372 | |
| 2373 | /* Run the init procedures once more. If the MSC has crashed, this |
| 2374 | * this will fail */ |
| 2375 | f_init(); |
| 2376 | } |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 2377 | |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 2378 | /* Two BSSMAP resets from two different BSCs */ |
| 2379 | testcase TC_reset_two() runs on MTC_CT { |
| 2380 | var BSC_ConnHdlr vc_conn; |
| 2381 | f_init(2); |
| 2382 | f_sleep(2.0); |
| 2383 | setverdict(pass); |
| 2384 | } |
| 2385 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2386 | /* Two BSSMAP resets from two different BSCs plus one IuCS RANAP Reset */ |
| 2387 | testcase TC_reset_two_1iu() runs on MTC_CT { |
| 2388 | var BSC_ConnHdlr vc_conn; |
| 2389 | f_init(3); |
| 2390 | f_sleep(2.0); |
| 2391 | setverdict(pass); |
| 2392 | } |
| 2393 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2394 | /*********************************************************************** |
| 2395 | * SMS Testing |
| 2396 | ***********************************************************************/ |
| 2397 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2398 | /* LU followed by MO SMS */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2399 | 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] | 2400 | var SmsParameters spars := valueof(t_SmsPars); |
| 2401 | |
| 2402 | f_init_handler(pars); |
| 2403 | |
| 2404 | /* Perform location update and call */ |
| 2405 | f_perform_lu(); |
| 2406 | |
| 2407 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2408 | |
| 2409 | //spars.exp_rp_err := 96; /* invalid mandatory information */ |
| 2410 | f_mo_sms(spars); |
| 2411 | |
| 2412 | f_expect_clear(); |
| 2413 | } |
| 2414 | testcase TC_lu_and_mo_sms() runs on MTC_CT { |
| 2415 | var BSC_ConnHdlr vc_conn; |
| 2416 | f_init(); |
| 2417 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_sms), 42); |
| 2418 | vc_conn.done; |
| 2419 | } |
| 2420 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2421 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2422 | private function f_vty_sms_send(charstring imsi, charstring msisdn, charstring text) |
Neels Hofmeyr | 6aaeccf | 2019-03-06 15:32:26 +0100 | [diff] [blame] | 2423 | runs on BSC_ConnHdlr { |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2424 | f_vty_transceive(MSCVTY, "subscriber imsi "&imsi&" sms sender msisdn "&msisdn&" send "&text); |
| 2425 | } |
| 2426 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 2427 | /* Remove still pending SMS */ |
| 2428 | private function f_vty_sms_clear(charstring imsi) |
| 2429 | runs on BSC_ConnHdlr { |
| 2430 | f_vty_transceive(MSCVTY, "subscriber imsi " & imsi & " sms delete-all"); |
| 2431 | f_vty_transceive(MSCVTY, "sms-queue clear"); |
| 2432 | } |
| 2433 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2434 | /* LU followed by MT SMS */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2435 | 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] | 2436 | var SmsParameters spars := valueof(t_SmsPars); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2437 | |
| 2438 | f_init_handler(pars); |
| 2439 | |
| 2440 | /* Perform location update and call */ |
| 2441 | f_perform_lu(); |
| 2442 | |
| 2443 | /* register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2444 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2445 | |
Neels Hofmeyr | 6aaeccf | 2019-03-06 15:32:26 +0100 | [diff] [blame] | 2446 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2447 | |
| 2448 | /* MSC->BSC: expect PAGING from MSC */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 2449 | f_expect_paging(); |
| 2450 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2451 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 2452 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2453 | |
| 2454 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 2455 | f_mt_sms(spars); |
| 2456 | |
| 2457 | f_expect_clear(); |
| 2458 | } |
| 2459 | testcase TC_lu_and_mt_sms() runs on MTC_CT { |
| 2460 | var BSC_ConnHdlrPars pars; |
| 2461 | var BSC_ConnHdlr vc_conn; |
| 2462 | f_init(); |
| 2463 | pars := f_init_pars(43); |
| 2464 | 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] | 2465 | vc_conn.done; |
| 2466 | } |
| 2467 | |
Neels Hofmeyr | b58d974 | 2019-11-27 18:44:54 +0100 | [diff] [blame] | 2468 | /* SMS added while already Paging */ |
| 2469 | friend function f_tc_lu_and_mt_sms_already_paging(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2470 | var SmsParameters spars := valueof(t_SmsPars); |
| 2471 | var OCT4 tmsi; |
| 2472 | |
| 2473 | f_init_handler(pars); |
| 2474 | |
| 2475 | f_perform_lu(); |
| 2476 | |
| 2477 | /* register an 'expect' for given IMSI (+TMSI) */ |
| 2478 | if (isvalue(g_pars.tmsi)) { |
| 2479 | tmsi := g_pars.tmsi; |
| 2480 | } else { |
| 2481 | tmsi := 'FFFFFFFF'O; |
| 2482 | } |
| 2483 | f_ran_register_imsi(g_pars.imsi, tmsi); |
| 2484 | |
| 2485 | log("first SMS"); |
| 2486 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 2487 | |
| 2488 | /* MSC->BSC: expect PAGING from MSC */ |
| 2489 | f_expect_paging(); |
| 2490 | |
| 2491 | log("second SMS"); |
| 2492 | /* Now osmo-msc is in state "Paging pending", make sure that another SMS to be sent at this time just joins in |
| 2493 | * with the pending paging. Another SMS: */ |
| 2494 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Another SMS"); |
| 2495 | |
| 2496 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 2497 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2498 | |
| 2499 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 2500 | f_mt_sms(spars); |
| 2501 | |
| 2502 | spars.tp.ud := '41F79B8E2ECB41D3E614'O; |
| 2503 | f_mt_sms(spars); |
| 2504 | |
| 2505 | f_expect_clear(); |
| 2506 | } |
| 2507 | testcase TC_lu_and_mt_sms_already_paging() runs on MTC_CT { |
| 2508 | var BSC_ConnHdlrPars pars; |
| 2509 | var BSC_ConnHdlr vc_conn; |
| 2510 | f_init(); |
| 2511 | pars := f_init_pars(44); |
| 2512 | vc_conn := f_start_handler_with_pars(refers(f_tc_lu_and_mt_sms_already_paging), pars); |
| 2513 | vc_conn.done; |
| 2514 | } |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2515 | |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2516 | /* Paging for MT SMS but no response */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2517 | 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] | 2518 | var SmsParameters spars := valueof(t_SmsPars); |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2519 | |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2520 | f_init_handler(pars, 150.0); |
| 2521 | |
| 2522 | /* Perform location update */ |
| 2523 | f_perform_lu(); |
| 2524 | |
| 2525 | /* register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2526 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2527 | |
Neels Hofmeyr | 6aaeccf | 2019-03-06 15:32:26 +0100 | [diff] [blame] | 2528 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 2529 | |
Neels Hofmeyr | 1623774 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 2530 | /* Expect the MSC to page exactly once */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2531 | f_expect_paging(); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2532 | |
| 2533 | /* Wait some time to make sure the MSC is not delivering any further |
| 2534 | * paging messages or anything else that could be unexpected. */ |
| 2535 | timer T := 20.0; |
| 2536 | T.start |
| 2537 | alt { |
Vadim Yanitskiy | da77459 | 2020-01-15 10:33:47 +0700 | [diff] [blame] | 2538 | [pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 2539 | setverdict(fail, "paging seems not to stop!"); |
| 2540 | mtc.stop; |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2541 | } |
Vadim Yanitskiy | da77459 | 2020-01-15 10:33:47 +0700 | [diff] [blame] | 2542 | [not pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) { |
| 2543 | setverdict(fail, "paging seems not to stop!"); |
| 2544 | mtc.stop; |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2545 | } |
Vadim Yanitskiy | da77459 | 2020-01-15 10:33:47 +0700 | [diff] [blame] | 2546 | [] BSSAP.receive { |
| 2547 | setverdict(fail, "unexpected BSSAP message received"); |
| 2548 | self.stop; |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2549 | } |
Vadim Yanitskiy | da77459 | 2020-01-15 10:33:47 +0700 | [diff] [blame] | 2550 | [] T.timeout { |
| 2551 | setverdict(pass); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2552 | } |
| 2553 | } |
| 2554 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 2555 | f_vty_sms_clear(hex2str(g_pars.imsi)); |
| 2556 | |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2557 | setverdict(pass); |
| 2558 | } |
| 2559 | testcase TC_lu_and_mt_sms_paging_and_nothing() runs on MTC_CT { |
| 2560 | var BSC_ConnHdlrPars pars; |
| 2561 | var BSC_ConnHdlr vc_conn; |
| 2562 | f_init(); |
Philipp Maier | a99ad26 | 2019-01-22 15:35:42 +0100 | [diff] [blame] | 2563 | pars := f_init_pars(1843); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2564 | 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] | 2565 | vc_conn.done; |
| 2566 | } |
| 2567 | |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2568 | /* LU followed by MT SMS with repeated paging */ |
| 2569 | friend function f_tc_lu_and_mt_sms_paging_repeated(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2570 | var SmsParameters spars := valueof(t_SmsPars); |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2571 | |
| 2572 | f_init_handler(pars); |
| 2573 | |
| 2574 | /* Perform location update and call */ |
| 2575 | f_perform_lu(); |
| 2576 | |
| 2577 | /* register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2578 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2579 | |
| 2580 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 2581 | |
Neels Hofmeyr | c3accec | 2019-11-28 01:09:47 +0100 | [diff] [blame] | 2582 | log("Expecting first Paging"); |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2583 | /* MSC->BSC: expect PAGING from MSC */ |
| 2584 | f_expect_paging(); |
| 2585 | |
Neels Hofmeyr | c3accec | 2019-11-28 01:09:47 +0100 | [diff] [blame] | 2586 | if (g_pars.ran_is_geran) { |
| 2587 | log("GERAN: expect no further Paging"); |
| 2588 | } else { |
| 2589 | log("UTRAN: expect more Paging"); |
| 2590 | } |
| 2591 | |
| 2592 | timer T := 5.0; |
| 2593 | T.start; |
| 2594 | alt { |
| 2595 | [g_pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 2596 | setverdict(fail, "GERAN should not repeat Paging, but received a second Paging"); |
| 2597 | mtc.stop; |
| 2598 | } |
| 2599 | [not g_pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) { |
| 2600 | log("UTRAN: second Paging received, as expected"); |
| 2601 | setverdict(pass); |
| 2602 | } |
| 2603 | [] T.timeout { |
| 2604 | if (g_pars.ran_is_geran) { |
| 2605 | log("GERAN: No further Paging received, as expected"); |
| 2606 | setverdict(pass); |
| 2607 | } else { |
| 2608 | setverdict(fail, "UTRAN: Expected a second Paging"); |
| 2609 | mtc.stop; |
| 2610 | } |
| 2611 | } |
| 2612 | } |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2613 | |
| 2614 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 2615 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2616 | |
| 2617 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 2618 | f_mt_sms(spars); |
| 2619 | |
| 2620 | f_expect_clear(); |
| 2621 | } |
| 2622 | testcase TC_lu_and_mt_sms_paging_repeated() runs on MTC_CT { |
| 2623 | var BSC_ConnHdlrPars pars; |
| 2624 | var BSC_ConnHdlr vc_conn; |
| 2625 | f_init(); |
| 2626 | pars := f_init_pars(1844); |
| 2627 | vc_conn := f_start_handler_with_pars(refers(f_tc_lu_and_mt_sms_paging_repeated), pars); |
| 2628 | vc_conn.done; |
| 2629 | } |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2630 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2631 | /* mobile originated SMS from MS/BTS/BSC side to SMPP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2632 | 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] | 2633 | var SmsParameters spars := valueof(t_SmsPars); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2634 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2635 | f_init_handler(pars); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2636 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2637 | /* Perform location update so IMSI is known + registered in MSC/VLR */ |
| 2638 | f_perform_lu(); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2639 | |
Vadim Yanitskiy | 2d3f846 | 2020-01-15 11:44:12 +0700 | [diff] [blame] | 2640 | /* MS/UE submits a MO SMS */ |
| 2641 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2642 | f_mo_sms_submit(spars); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2643 | |
| 2644 | var SMPP_PDU smpp; |
| 2645 | var template SMPP_PDU tr_smpp := tr_SMPP(c_SMPP_command_id_deliver_sm, ESME_ROK); |
| 2646 | tr_smpp.body.deliver_sm := { |
| 2647 | service_type := "CMT", |
| 2648 | source_addr_ton := network_specific, |
| 2649 | source_addr_npi := isdn, |
| 2650 | source_addr := hex2str(pars.msisdn), |
| 2651 | dest_addr_ton := f_sm_ton_from_gsm(spars.tp.da.tP_DA_NoPad.tP_TypeOfNumber), |
| 2652 | dest_addr_npi := f_sm_npi_from_gsm(spars.tp.da.tP_DA_NoPad.tP_NumberingPlanID), |
| 2653 | destination_addr := hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue), |
| 2654 | esm_class := '00000001'B, |
| 2655 | protocol_id := 0, |
| 2656 | priority_flag := 0, |
| 2657 | schedule_delivery_time := "", |
| 2658 | replace_if_present := 0, |
| 2659 | data_coding := '00000001'B, |
| 2660 | sm_default_msg_id := 0, |
| 2661 | sm_length := ?, |
| 2662 | short_message := spars.tp.ud, |
| 2663 | opt_pars := { |
| 2664 | { |
| 2665 | tag := user_message_reference, |
| 2666 | len := 2, |
| 2667 | opt_value := { |
| 2668 | int2_val := oct2int(spars.tp.msg_ref) |
| 2669 | } |
| 2670 | } |
| 2671 | } |
| 2672 | }; |
| 2673 | alt { |
| 2674 | [] SMPP.receive(tr_smpp) -> value smpp { |
| 2675 | SMPP.send(ts_SMPP_DELIVER_SM_resp(ESME_ROK, smpp.header.seq_num)); |
| 2676 | } |
| 2677 | [] SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)) { repeat; } |
| 2678 | } |
| 2679 | |
Vadim Yanitskiy | 2d3f846 | 2020-01-15 11:44:12 +0700 | [diff] [blame] | 2680 | /* MSC terminates the SMS transaction with RP-ACK */ |
| 2681 | f_mo_sms_wait_rp_ack(spars); |
| 2682 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2683 | f_expect_clear(); |
| 2684 | } |
| 2685 | testcase TC_smpp_mo_sms() runs on MTC_CT { |
| 2686 | var BSC_ConnHdlr vc_conn; |
| 2687 | f_init(); |
| 2688 | f_vty_config2(MSCVTY, { "smpp", "esme msc_tester"}, "default-route"); |
| 2689 | vc_conn := f_start_handler(refers(f_tc_smpp_mo_sms), 44); |
| 2690 | vc_conn.done; |
| 2691 | f_vty_config2(MSCVTY, { "smpp", "esme msc_tester"}, "no default-route"); |
| 2692 | } |
| 2693 | |
Vadim Yanitskiy | 3382076 | 2020-01-15 11:26:07 +0700 | [diff] [blame] | 2694 | /* Test case for OS#4351: make sure that RP-ERROR from ESME is properly sent to the MS/UE */ |
| 2695 | friend function f_tc_smpp_mo_sms_rp_error(charstring id, BSC_ConnHdlrPars pars) |
| 2696 | runs on BSC_ConnHdlr { |
| 2697 | var SmsParameters spars := valueof(t_SmsPars); |
| 2698 | var SMPP_PDU smpp_pdu; |
| 2699 | timer T := 3.0; |
| 2700 | |
| 2701 | f_init_handler(pars); |
| 2702 | |
| 2703 | /* Perform location update */ |
| 2704 | f_perform_lu(); |
| 2705 | |
| 2706 | /* MS/UE submits a MO SMS */ |
| 2707 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2708 | f_mo_sms_submit(spars); |
| 2709 | |
| 2710 | /* ESME responds with an error (Invalid Destination Address) */ |
| 2711 | T.start; |
| 2712 | alt { |
| 2713 | [] SMPP.receive(tr_SMPP(c_SMPP_command_id_deliver_sm, ESME_ROK, body := ?)) -> value smpp_pdu { |
| 2714 | SMPP.send(ts_SMPP_DELIVER_SM_resp(ESME_RINVDSTADR, smpp_pdu.header.seq_num)); |
| 2715 | } |
| 2716 | [] SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)) { repeat; } |
| 2717 | [] T.timeout { |
| 2718 | setverdict(fail, "Timeout waiting for SMPP DELIVER-SM"); |
| 2719 | mtc.stop; |
| 2720 | } |
| 2721 | } |
| 2722 | |
| 2723 | /* Expect RP-ERROR on BSSAP interface */ |
| 2724 | spars.exp_rp_err := 1; /* FIXME: GSM411_RP_CAUSE_MO_NUM_UNASSIGNED */ |
| 2725 | f_mo_sms_wait_rp_ack(spars); |
| 2726 | |
| 2727 | f_expect_clear(); |
| 2728 | } |
| 2729 | testcase TC_smpp_mo_sms_rp_error() runs on MTC_CT { |
| 2730 | var BSC_ConnHdlr vc_conn; |
| 2731 | f_init(); |
| 2732 | f_vty_config2(MSCVTY, { "smpp", "esme msc_tester"}, "default-route"); |
| 2733 | vc_conn := f_start_handler(refers(f_tc_smpp_mo_sms_rp_error), 45); |
| 2734 | vc_conn.done; |
| 2735 | f_vty_config2(MSCVTY, { "smpp", "esme msc_tester"}, "no default-route"); |
| 2736 | } |
| 2737 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2738 | |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 2739 | /* Test MO-SMS from MS/BTS/BSC towards HLR (via GSUP) */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2740 | friend function f_tc_gsup_mo_sms(charstring id, BSC_ConnHdlrPars pars) |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 2741 | runs on BSC_ConnHdlr { |
| 2742 | var SmsParameters spars := valueof(t_SmsPars); |
| 2743 | var GSUP_PDU gsup_msg_rx; |
| 2744 | var octetstring sm_tpdu; |
| 2745 | |
| 2746 | f_init_handler(pars); |
| 2747 | |
| 2748 | /* We need to inspect GSUP activity */ |
| 2749 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2750 | |
| 2751 | /* Perform location update */ |
| 2752 | f_perform_lu(); |
| 2753 | |
| 2754 | /* Send CM Service Request for SMS */ |
| 2755 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2756 | |
| 2757 | /* Prepare expected SM-RP-UI (SM TPDU) */ |
| 2758 | enc_TPDU_RP_DATA_MS_SGSN_fast( |
| 2759 | valueof(ts_SMS_SUBMIT(spars.tp.msg_ref, |
| 2760 | spars.tp.da, spars.tp.pid, spars.tp.dcs, |
| 2761 | spars.tp.udl, spars.tp.ud)), |
| 2762 | sm_tpdu); |
| 2763 | |
| 2764 | var template GSUP_PDU mo_forwardSM := tr_GSUP_MO_FORWARD_SM_REQ( |
| 2765 | imsi := g_pars.imsi, |
| 2766 | sm_rp_mr := spars.rp.msg_ref, |
Vadim Yanitskiy | 04dd5f7 | 2019-12-13 15:45:44 +0900 | [diff] [blame] | 2767 | /* SM-RP-DA: SMSC address */ |
| 2768 | sm_rp_da := tr_GSUP_SM_RP_DA_SMSC_ADDR(t_GSUP_SM_RP_Addr( |
| 2769 | number := spars.rp.smsc_addr.rP_NumberDigits, |
| 2770 | npi := spars.rp.smsc_addr.rP_NumberingPlanIdentification, |
| 2771 | ton := spars.rp.smsc_addr.rP_TypeOfNumber, |
| 2772 | ext := spars.rp.smsc_addr.rP_Ext)), |
| 2773 | /* SM-RP-OA: subscriber's MSISDN (filled in by MSC) */ |
| 2774 | sm_rp_oa := tr_GSUP_SM_RP_OA_MSISDN(t_GSUP_SM_RP_Addr( |
| 2775 | number := g_pars.msisdn, |
| 2776 | /* NOTE: MSISDN in g_pars lacks this info, assuming defaults */ |
| 2777 | npi := '0001'B, ton := '001'B, ext := '1'B)), |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 2778 | /* TODO: can we use decmatch here? */ |
| 2779 | sm_rp_ui := sm_tpdu |
| 2780 | ); |
| 2781 | |
| 2782 | /* Submit an SMS on DTAP and expect MO-forwardSM-Req on GSUP */ |
| 2783 | f_mo_sms_submit(spars); |
| 2784 | alt { |
| 2785 | [] GSUP.receive(mo_forwardSM) -> value gsup_msg_rx { |
Vadim Yanitskiy | a358dd4 | 2020-01-15 10:42:47 +0700 | [diff] [blame] | 2786 | log("RX MO-forwardSM-Req: ", gsup_msg_rx); |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 2787 | setverdict(pass); |
| 2788 | } |
| 2789 | [] GSUP.receive { |
| 2790 | log("RX unexpected GSUP message"); |
| 2791 | setverdict(fail); |
| 2792 | mtc.stop; |
| 2793 | } |
| 2794 | } |
| 2795 | |
| 2796 | /* Trigger RP-ACK by sending MO-forwardSM-Res */ |
| 2797 | GSUP.send(valueof(ts_GSUP_MO_FORWARD_SM_RES( |
| 2798 | imsi := g_pars.imsi, |
| 2799 | sm_rp_mr := spars.rp.msg_ref))); |
| 2800 | /* Expect RP-ACK on DTAP */ |
| 2801 | f_mo_sms_wait_rp_ack(spars); |
| 2802 | |
| 2803 | f_expect_clear(); |
| 2804 | } |
| 2805 | testcase TC_gsup_mo_sms() runs on MTC_CT { |
| 2806 | var BSC_ConnHdlr vc_conn; |
| 2807 | f_init(); |
| 2808 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2809 | vc_conn := f_start_handler(refers(f_tc_gsup_mo_sms), 88); |
| 2810 | vc_conn.done; |
| 2811 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2812 | } |
| 2813 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2814 | |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 2815 | /* Test MO-SMMA from MS/BTS/BSC towards HLR (via GSUP) */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2816 | friend function f_tc_gsup_mo_smma(charstring id, BSC_ConnHdlrPars pars) |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 2817 | runs on BSC_ConnHdlr { |
| 2818 | var SmsParameters spars := valueof(t_SmsPars); |
| 2819 | var GSUP_PDU gsup_msg_rx; |
| 2820 | |
| 2821 | f_init_handler(pars); |
| 2822 | |
| 2823 | /* We need to inspect GSUP activity */ |
| 2824 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2825 | |
| 2826 | /* Perform location update */ |
| 2827 | f_perform_lu(); |
| 2828 | |
| 2829 | /* Send CM Service Request for SMS */ |
| 2830 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2831 | |
| 2832 | var template GSUP_PDU mo_ReadyForSM := tr_GSUP_MO_READY_FOR_SM_REQ( |
| 2833 | imsi := g_pars.imsi, |
| 2834 | sm_rp_mr := spars.rp.msg_ref, |
| 2835 | sm_alert_rsn := GSUP_SM_ALERT_RSN_TYPE_MEM_AVAIL |
| 2836 | ); |
| 2837 | |
| 2838 | /* Submit an SMS on DTAP and expect MO-forwardSM-Req on GSUP */ |
| 2839 | f_mo_smma(spars); |
| 2840 | alt { |
| 2841 | [] GSUP.receive(mo_ReadyForSM) -> value gsup_msg_rx { |
Vadim Yanitskiy | a358dd4 | 2020-01-15 10:42:47 +0700 | [diff] [blame] | 2842 | log("RX MO-ReadyForSM-Req: ", gsup_msg_rx); |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 2843 | setverdict(pass); |
| 2844 | } |
| 2845 | [] GSUP.receive { |
| 2846 | log("RX unexpected GSUP message"); |
| 2847 | setverdict(fail); |
| 2848 | mtc.stop; |
| 2849 | } |
| 2850 | } |
| 2851 | |
| 2852 | /* Trigger RP-ACK by sending MO-forwardSM-Res */ |
| 2853 | GSUP.send(valueof(ts_GSUP_MO_READY_FOR_SM_RES( |
| 2854 | imsi := g_pars.imsi, |
| 2855 | sm_rp_mr := spars.rp.msg_ref))); |
| 2856 | /* Expect RP-ACK on DTAP */ |
| 2857 | f_mo_sms_wait_rp_ack(spars); |
| 2858 | |
| 2859 | f_expect_clear(); |
| 2860 | } |
| 2861 | testcase TC_gsup_mo_smma() runs on MTC_CT { |
| 2862 | var BSC_ConnHdlr vc_conn; |
| 2863 | f_init(); |
| 2864 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2865 | vc_conn := f_start_handler(refers(f_tc_gsup_mo_smma), 89); |
| 2866 | vc_conn.done; |
| 2867 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2868 | } |
| 2869 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2870 | |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2871 | /* Helper for sending MT SMS over GSUP */ |
| 2872 | private function f_gsup_forwardSM_req(SmsParameters spars, OCT1 mms := '00'O) |
| 2873 | runs on BSC_ConnHdlr { |
Vadim Yanitskiy | a52347c | 2019-12-12 17:32:33 +0900 | [diff] [blame] | 2874 | 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] | 2875 | var GSUP_SM_RP_Addr smsc := valueof(t_GSUP_SM_RP_Addr( |
| 2876 | number := spars.rp.smsc_addr.rP_NumberDigits, |
| 2877 | npi := spars.rp.smsc_addr.rP_NumberingPlanIdentification, |
| 2878 | ton := spars.rp.smsc_addr.rP_TypeOfNumber, |
| 2879 | ext := spars.rp.smsc_addr.rP_Ext)); |
Vadim Yanitskiy | a52347c | 2019-12-12 17:32:33 +0900 | [diff] [blame] | 2880 | |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2881 | GSUP.send(ts_GSUP_MT_FORWARD_SM_REQ( |
| 2882 | imsi := g_pars.imsi, |
| 2883 | /* NOTE: MSC should assign RP-MR itself */ |
| 2884 | sm_rp_mr := 'FF'O, |
Vadim Yanitskiy | a52347c | 2019-12-12 17:32:33 +0900 | [diff] [blame] | 2885 | sm_rp_da := valueof(ts_GSUP_SM_RP_DA_MSISDN(msisdn)), |
Vadim Yanitskiy | 04dd5f7 | 2019-12-13 15:45:44 +0900 | [diff] [blame] | 2886 | sm_rp_oa := valueof(ts_GSUP_SM_RP_OA_SMSC_ADDR(smsc)), |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2887 | /* Encoded SMS TPDU (taken from Wireshark) |
| 2888 | * FIXME: we should encode spars somehow */ |
| 2889 | sm_rp_ui := '00068021436500008111328130858200'O, |
| 2890 | sm_rp_mms := mms |
| 2891 | )); |
| 2892 | } |
| 2893 | |
| 2894 | /* Test successful MT-SMS (RP-ACK) over GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2895 | 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] | 2896 | runs on BSC_ConnHdlr { |
| 2897 | var SmsParameters spars := valueof(t_SmsPars); |
| 2898 | |
| 2899 | f_init_handler(pars); |
| 2900 | |
| 2901 | /* We need to inspect GSUP activity */ |
| 2902 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2903 | |
| 2904 | /* Perform location update */ |
| 2905 | f_perform_lu(); |
| 2906 | |
| 2907 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2908 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2909 | |
| 2910 | var template GSUP_PDU mt_forwardSM_res := tr_GSUP_MT_FORWARD_SM_RES( |
| 2911 | imsi := g_pars.imsi, |
| 2912 | /* NOTE: MSC should assign RP-MR itself */ |
| 2913 | sm_rp_mr := ? |
| 2914 | ); |
| 2915 | |
| 2916 | /* Submit a MT SMS on GSUP */ |
| 2917 | f_gsup_forwardSM_req(spars); |
| 2918 | |
| 2919 | /* Expect Paging Request and Establish DTAP / BSSAP / SCCP connection */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 2920 | f_expect_paging(); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2921 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2922 | |
| 2923 | /* Wait for MT SMS on DTAP */ |
| 2924 | f_mt_sms_expect(spars); |
| 2925 | |
| 2926 | /* Send RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 2927 | f_mt_sms_send_rp_ack(spars); |
| 2928 | alt { |
| 2929 | [] GSUP.receive(mt_forwardSM_res) { |
| 2930 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 2931 | setverdict(pass); |
| 2932 | } |
| 2933 | [] GSUP.receive { |
| 2934 | log("RX unexpected GSUP message"); |
| 2935 | setverdict(fail); |
| 2936 | mtc.stop; |
| 2937 | } |
| 2938 | } |
| 2939 | |
| 2940 | f_expect_clear(); |
| 2941 | } |
| 2942 | testcase TC_gsup_mt_sms_ack() runs on MTC_CT { |
| 2943 | var BSC_ConnHdlrPars pars; |
| 2944 | var BSC_ConnHdlr vc_conn; |
| 2945 | f_init(); |
| 2946 | pars := f_init_pars(90); |
| 2947 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2948 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_sms_ack), pars); |
| 2949 | vc_conn.done; |
| 2950 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2951 | } |
| 2952 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2953 | |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2954 | /* Test rejected MT-SMS (RP-ERROR) over GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2955 | 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] | 2956 | runs on BSC_ConnHdlr { |
| 2957 | var SmsParameters spars := valueof(t_SmsPars); |
| 2958 | var OCT1 sm_rp_cause := '78'O; /* dummy RP-Cause value */ |
| 2959 | |
| 2960 | f_init_handler(pars); |
| 2961 | |
| 2962 | /* We need to inspect GSUP activity */ |
| 2963 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2964 | |
| 2965 | /* Perform location update */ |
| 2966 | f_perform_lu(); |
| 2967 | |
| 2968 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2969 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2970 | |
| 2971 | var template GSUP_PDU mt_forwardSM_err := tr_GSUP_MT_FORWARD_SM_ERR( |
| 2972 | imsi := g_pars.imsi, |
| 2973 | /* NOTE: MSC should assign RP-MR itself */ |
| 2974 | sm_rp_mr := ?, |
| 2975 | sm_rp_cause := sm_rp_cause |
| 2976 | ); |
| 2977 | |
| 2978 | /* Submit a MT SMS on GSUP */ |
| 2979 | f_gsup_forwardSM_req(spars); |
| 2980 | |
| 2981 | /* Expect Paging Request and Establish DTAP / BSSAP / SCCP connection */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 2982 | f_expect_paging(); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2983 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2984 | |
| 2985 | /* Wait for MT SMS on DTAP */ |
| 2986 | f_mt_sms_expect(spars); |
| 2987 | |
| 2988 | /* Send RP-ERROR and expect MT-forwardSM-Err on GSUP */ |
| 2989 | f_mt_sms_send_rp_error(spars, oct2int(sm_rp_cause)); |
| 2990 | alt { |
| 2991 | [] GSUP.receive(mt_forwardSM_err) { |
| 2992 | log("RX MT-forwardSM-Err (RP-ERROR)"); |
| 2993 | setverdict(pass); |
| 2994 | mtc.stop; |
| 2995 | } |
| 2996 | [] GSUP.receive { |
| 2997 | log("RX unexpected GSUP message"); |
| 2998 | setverdict(fail); |
| 2999 | mtc.stop; |
| 3000 | } |
| 3001 | } |
| 3002 | |
| 3003 | f_expect_clear(); |
| 3004 | } |
| 3005 | testcase TC_gsup_mt_sms_err() runs on MTC_CT { |
| 3006 | var BSC_ConnHdlrPars pars; |
| 3007 | var BSC_ConnHdlr vc_conn; |
| 3008 | f_init(); |
| 3009 | pars := f_init_pars(91); |
| 3010 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 3011 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_sms_err), pars); |
| 3012 | vc_conn.done; |
| 3013 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 3014 | } |
| 3015 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3016 | |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 3017 | /* Test SM-RP-MR assignment for MT-SMS over GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3018 | 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] | 3019 | runs on BSC_ConnHdlr { |
| 3020 | var SmsParameters spars1 := valueof(t_SmsPars); /* 1st SMS */ |
| 3021 | var SmsParameters spars2 := valueof(t_SmsPars); /* 2nd SMS */ |
| 3022 | |
| 3023 | f_init_handler(pars); |
| 3024 | |
| 3025 | /* We need to inspect GSUP activity */ |
| 3026 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3027 | |
| 3028 | /* Perform location update */ |
| 3029 | f_perform_lu(); |
| 3030 | |
| 3031 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 3032 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 3033 | |
| 3034 | /* Submit the 1st MT SMS on GSUP */ |
| 3035 | log("TX MT-forwardSM-Req for the 1st SMS"); |
| 3036 | f_gsup_forwardSM_req(spars1); |
| 3037 | |
| 3038 | /* Expect Paging Request and Establish DTAP / BSSAP / SCCP connection */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 3039 | f_expect_paging(); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 3040 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 3041 | |
| 3042 | /* Wait for 1st MT SMS on DTAP */ |
| 3043 | f_mt_sms_expect(spars1); |
| 3044 | log("RX the 1st SMS on DTAP, DTAP TID is ", spars1.tid, |
| 3045 | ", SM-RP-MR is ", spars1.rp.msg_ref); |
| 3046 | |
| 3047 | /* Submit the 2nd MT SMS on GSUP */ |
| 3048 | log("TX MT-forwardSM-Req for the 2nd SMS"); |
| 3049 | f_gsup_forwardSM_req(spars2); |
| 3050 | |
| 3051 | /* Wait for 2nd MT SMS on DTAP */ |
| 3052 | f_mt_sms_expect(spars2); |
| 3053 | log("RX the 2nd SMS on DTAP, DTAP TID is ", spars2.tid, |
| 3054 | ", SM-RP-MR is ", spars2.rp.msg_ref); |
| 3055 | |
| 3056 | /* Both transaction IDs shall be different */ |
| 3057 | if (spars1.tid == spars2.tid) { |
| 3058 | log("Both DTAP transaction IDs shall be different"); |
| 3059 | setverdict(fail); |
| 3060 | } |
| 3061 | |
| 3062 | /* Both SM-RP-MR values shall be different */ |
| 3063 | if (spars1.rp.msg_ref == spars2.rp.msg_ref) { |
| 3064 | log("Both SM-RP-MR values shall be different"); |
| 3065 | setverdict(fail); |
| 3066 | } |
| 3067 | |
| 3068 | /* Both SM-RP-MR values shall be assigned */ |
| 3069 | if (spars1.rp.msg_ref == 'FF'O) { |
| 3070 | log("Unassigned SM-RP-MR value for the 1st SMS"); |
| 3071 | setverdict(fail); |
| 3072 | } |
| 3073 | if (spars2.rp.msg_ref == 'FF'O) { |
| 3074 | log("Unassigned SM-RP-MR value for the 2nd SMS"); |
| 3075 | setverdict(fail); |
| 3076 | } |
| 3077 | |
| 3078 | /* Send the 1st RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 3079 | f_mt_sms_send_rp_ack(spars1); |
| 3080 | alt { |
| 3081 | [] GSUP.receive(tr_GSUP_MT_FORWARD_SM_RES( |
| 3082 | imsi := g_pars.imsi, |
| 3083 | sm_rp_mr := spars1.rp.msg_ref |
| 3084 | )) { |
| 3085 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 3086 | setverdict(pass); |
| 3087 | } |
| 3088 | [] GSUP.receive { |
| 3089 | log("RX unexpected GSUP message"); |
| 3090 | setverdict(fail); |
| 3091 | mtc.stop; |
| 3092 | } |
| 3093 | } |
| 3094 | |
| 3095 | /* Send the 2nd RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 3096 | f_mt_sms_send_rp_ack(spars2); |
| 3097 | alt { |
| 3098 | [] GSUP.receive(tr_GSUP_MT_FORWARD_SM_RES( |
| 3099 | imsi := g_pars.imsi, |
| 3100 | sm_rp_mr := spars2.rp.msg_ref |
| 3101 | )) { |
| 3102 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 3103 | setverdict(pass); |
| 3104 | } |
| 3105 | [] GSUP.receive { |
| 3106 | log("RX unexpected GSUP message"); |
| 3107 | setverdict(fail); |
| 3108 | mtc.stop; |
| 3109 | } |
| 3110 | } |
| 3111 | |
| 3112 | f_expect_clear(); |
| 3113 | } |
| 3114 | testcase TC_gsup_mt_sms_rp_mr() runs on MTC_CT { |
| 3115 | var BSC_ConnHdlrPars pars; |
| 3116 | var BSC_ConnHdlr vc_conn; |
| 3117 | f_init(); |
| 3118 | pars := f_init_pars(92); |
| 3119 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 3120 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_sms_rp_mr), pars); |
| 3121 | vc_conn.done; |
| 3122 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 3123 | } |
| 3124 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3125 | |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 3126 | /* Test SM-RP-MR assignment for MT-SMS over GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3127 | 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] | 3128 | runs on BSC_ConnHdlr { |
| 3129 | var SmsParameters spars_mo := valueof(t_SmsPars); /* MO SMMA */ |
| 3130 | var SmsParameters spars_mt := valueof(t_SmsPars); /* MT SMS */ |
| 3131 | |
| 3132 | f_init_handler(pars); |
| 3133 | |
| 3134 | /* We need to inspect GSUP activity */ |
| 3135 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3136 | |
| 3137 | /* Perform location update */ |
| 3138 | f_perform_lu(); |
| 3139 | |
| 3140 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 3141 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 3142 | |
| 3143 | /* Send CM Service Request for MO SMMA */ |
| 3144 | f_establish_fully(EST_TYPE_MO_SMS); |
| 3145 | |
| 3146 | /* Submit MO SMMA on DTAP */ |
| 3147 | log("Submit MO SMMA on DTAP, SM-RP-MR is '00'O"); |
| 3148 | spars_mo.rp.msg_ref := '00'O; |
| 3149 | f_mo_smma(spars_mo); |
| 3150 | |
| 3151 | /* Expect MO-forwardSM-Req for MO SMMA on GSUP */ |
| 3152 | alt { |
| 3153 | [] GSUP.receive(tr_GSUP_MO_READY_FOR_SM_REQ( |
| 3154 | imsi := g_pars.imsi, |
| 3155 | sm_rp_mr := spars_mo.rp.msg_ref, |
| 3156 | sm_alert_rsn := GSUP_SM_ALERT_RSN_TYPE_MEM_AVAIL |
| 3157 | )) { |
| 3158 | log("RX MO-ReadyForSM-Req, SM-RP-MR is '00'O"); |
| 3159 | setverdict(pass); |
| 3160 | } |
| 3161 | [] GSUP.receive { |
| 3162 | log("RX unexpected GSUP message"); |
| 3163 | setverdict(fail); |
| 3164 | mtc.stop; |
| 3165 | } |
| 3166 | } |
| 3167 | |
| 3168 | /* Submit MT SMS on GSUP */ |
| 3169 | log("TX MT-forwardSM-Req for the MT SMS"); |
| 3170 | f_gsup_forwardSM_req(spars_mt); |
| 3171 | |
| 3172 | /* Wait for MT SMS on DTAP */ |
| 3173 | f_mt_sms_expect(spars_mt); |
| 3174 | log("RX MT SMS on DTAP, DTAP TID is ", spars_mt.tid, |
| 3175 | ", SM-RP-MR is ", spars_mt.rp.msg_ref); |
| 3176 | |
| 3177 | /* Both SM-RP-MR values shall be different */ |
| 3178 | if (spars_mo.rp.msg_ref == spars_mt.rp.msg_ref) { |
| 3179 | log("Both SM-RP-MR values shall be different"); |
| 3180 | setverdict(fail); |
| 3181 | } |
| 3182 | |
| 3183 | /* SM-RP-MR value for MT SMS shall be assigned */ |
| 3184 | if (spars_mt.rp.msg_ref == 'FF'O) { |
| 3185 | log("Unassigned SM-RP-MR value for the MT SMS"); |
| 3186 | setverdict(fail); |
| 3187 | } |
| 3188 | |
| 3189 | /* Trigger RP-ACK for MO SMMA by sending MO-forwardSM-Res */ |
| 3190 | GSUP.send(valueof(ts_GSUP_MO_READY_FOR_SM_RES( |
| 3191 | imsi := g_pars.imsi, |
| 3192 | sm_rp_mr := spars_mo.rp.msg_ref))); |
| 3193 | /* Expect RP-ACK for MO SMMA on DTAP */ |
| 3194 | f_mo_sms_wait_rp_ack(spars_mo); |
| 3195 | |
| 3196 | /* Send RP-ACK for MT SMS and expect MT-forwardSM-Res on GSUP */ |
| 3197 | f_mt_sms_send_rp_ack(spars_mt); |
| 3198 | alt { |
| 3199 | [] GSUP.receive(tr_GSUP_MT_FORWARD_SM_RES( |
| 3200 | imsi := g_pars.imsi, |
| 3201 | sm_rp_mr := spars_mt.rp.msg_ref |
| 3202 | )) { |
| 3203 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 3204 | setverdict(pass); |
| 3205 | } |
| 3206 | [] GSUP.receive { |
| 3207 | log("RX unexpected GSUP message"); |
| 3208 | setverdict(fail); |
| 3209 | mtc.stop; |
| 3210 | } |
| 3211 | } |
| 3212 | |
| 3213 | f_expect_clear(); |
| 3214 | } |
| 3215 | testcase TC_gsup_mo_mt_sms_rp_mr() runs on MTC_CT { |
| 3216 | var BSC_ConnHdlrPars pars; |
| 3217 | var BSC_ConnHdlr vc_conn; |
| 3218 | f_init(); |
| 3219 | pars := f_init_pars(93); |
| 3220 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 3221 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mo_mt_sms_rp_mr), pars); |
| 3222 | vc_conn.done; |
| 3223 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 3224 | } |
| 3225 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3226 | |
Vadim Yanitskiy | 1cd11a0 | 2018-12-03 02:43:35 +0700 | [diff] [blame] | 3227 | /* Test multi-part MT-SMS over GSUP */ |
| 3228 | private function f_tc_gsup_mt_multi_part_sms(charstring id, BSC_ConnHdlrPars pars) |
| 3229 | runs on BSC_ConnHdlr { |
| 3230 | var SmsParameters spars := valueof(t_SmsPars); |
| 3231 | |
| 3232 | f_init_handler(pars); |
| 3233 | |
| 3234 | /* We need to inspect GSUP activity */ |
| 3235 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3236 | |
| 3237 | /* Perform location update */ |
| 3238 | f_perform_lu(); |
| 3239 | |
| 3240 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 3241 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 1cd11a0 | 2018-12-03 02:43:35 +0700 | [diff] [blame] | 3242 | |
| 3243 | var template GSUP_PDU mt_forwardSM_res := tr_GSUP_MT_FORWARD_SM_RES( |
| 3244 | imsi := g_pars.imsi, |
| 3245 | /* NOTE: MSC should assign RP-MR itself */ |
| 3246 | sm_rp_mr := ? |
| 3247 | ); |
| 3248 | |
| 3249 | /* Send 4 messages (NOTE: SM-RP-UI remains unchanged) */ |
| 3250 | for (var integer i := 3; i >= 0; i := i-1) { |
| 3251 | /* Submit a MT SMS on GSUP (MMS is decremented) */ |
| 3252 | f_gsup_forwardSM_req(spars, int2oct(i, 1)); |
| 3253 | |
| 3254 | /* Expect Paging Request and Establish connection */ |
| 3255 | if (i == 3) { /* ... only once! */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3256 | f_expect_paging(); |
Vadim Yanitskiy | 1cd11a0 | 2018-12-03 02:43:35 +0700 | [diff] [blame] | 3257 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 3258 | } |
| 3259 | |
| 3260 | /* Wait for MT SMS on DTAP */ |
| 3261 | f_mt_sms_expect(spars); |
| 3262 | |
| 3263 | /* Send RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 3264 | f_mt_sms_send_rp_ack(spars); |
| 3265 | alt { |
| 3266 | [] GSUP.receive(mt_forwardSM_res) { |
| 3267 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 3268 | setverdict(pass); |
| 3269 | } |
| 3270 | [] GSUP.receive { |
| 3271 | log("RX unexpected GSUP message"); |
| 3272 | setverdict(fail); |
| 3273 | mtc.stop; |
| 3274 | } |
| 3275 | } |
| 3276 | |
| 3277 | /* Keep some 'distance' between transmissions */ |
| 3278 | f_sleep(1.5); |
| 3279 | } |
| 3280 | |
| 3281 | f_expect_clear(); |
| 3282 | } |
| 3283 | testcase TC_gsup_mt_multi_part_sms() runs on MTC_CT { |
| 3284 | var BSC_ConnHdlrPars pars; |
| 3285 | var BSC_ConnHdlr vc_conn; |
| 3286 | f_init(); |
| 3287 | pars := f_init_pars(91); |
| 3288 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 3289 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_multi_part_sms), pars); |
| 3290 | vc_conn.done; |
| 3291 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 3292 | } |
| 3293 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 3294 | /* convert GSM L3 TON to SMPP_TON enum */ |
| 3295 | function f_sm_ton_from_gsm(BIT3 ton) return SMPP_TON { |
| 3296 | select (ton) { |
| 3297 | case ('000'B) { return unknown; } |
| 3298 | case ('001'B) { return international; } |
| 3299 | case ('010'B) { return national; } |
| 3300 | case ('011'B) { return network_specific; } |
| 3301 | case ('100'B) { return subscriber_number; } |
| 3302 | case ('101'B) { return alphanumeric; } |
| 3303 | case ('110'B) { return abbreviated; } |
| 3304 | } |
| 3305 | setverdict(fail, "Unknown TON ", ton); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 3306 | mtc.stop; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 3307 | } |
| 3308 | /* convert GSM L3 NPI to SMPP_NPI enum */ |
| 3309 | function f_sm_npi_from_gsm(BIT4 npi) return SMPP_NPI { |
| 3310 | select (npi) { |
| 3311 | case ('0000'B) { return unknown; } |
| 3312 | case ('0001'B) { return isdn; } |
| 3313 | case ('0011'B) { return data; } |
| 3314 | case ('0100'B) { return telex; } |
| 3315 | case ('0110'B) { return land_mobile; } |
| 3316 | case ('1000'B) { return national; } |
| 3317 | case ('1001'B) { return private_; } |
| 3318 | case ('1010'B) { return ermes; } |
| 3319 | } |
| 3320 | setverdict(fail, "Unknown NPI ", npi); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 3321 | mtc.stop; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 3322 | } |
| 3323 | |
| 3324 | /* build a SMPP_SM from SmsParameters */ |
| 3325 | function f_mt_sm_from_spars(SmsParameters spars) |
| 3326 | runs on BSC_ConnHdlr return SMPP_SM { |
| 3327 | var SMPP_SM sm := { |
| 3328 | service_type := "CMT", |
| 3329 | source_addr_ton := f_sm_ton_from_gsm(spars.tp.da.tP_DA_NoPad.tP_TypeOfNumber), |
| 3330 | source_addr_npi := f_sm_npi_from_gsm(spars.tp.da.tP_DA_NoPad.tP_NumberingPlanID), |
| 3331 | source_addr := hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue), |
| 3332 | dest_addr_ton := international, |
| 3333 | dest_addr_npi := isdn, |
| 3334 | destination_addr := hex2str(g_pars.msisdn), |
| 3335 | esm_class := '00000001'B, |
| 3336 | protocol_id := 0, |
| 3337 | priority_flag := 0, |
| 3338 | schedule_delivery_time := "", |
| 3339 | validity_period := "", |
| 3340 | registered_delivery := '00000000'B, |
| 3341 | replace_if_present := 0, |
| 3342 | data_coding := '00000001'B, |
| 3343 | sm_default_msg_id := 0, |
| 3344 | sm_length := spars.tp.udl, |
| 3345 | short_message := spars.tp.ud, |
| 3346 | opt_pars := {} |
| 3347 | }; |
| 3348 | return sm; |
| 3349 | } |
| 3350 | |
| 3351 | /* helper function to encode SMS from 'spars', send it via SMPP to MSC; receive it on MS side */ |
| 3352 | private function f_smpp_mt_sms(SmsParameters spars, boolean trans_mode) runs on BSC_ConnHdlr { |
| 3353 | var SMPP_SM sm := f_mt_sm_from_spars(spars); |
| 3354 | if (trans_mode) { |
| 3355 | sm.esm_class := '00000010'B; |
| 3356 | } |
| 3357 | |
| 3358 | /* actually cause MSC to send a SMS via SUBMIT-SM from SMPP side */ |
| 3359 | SMPP.send(ts_SMPP_SUBMIT_SM(sm)); |
| 3360 | if (not match(sm.esm_class, tr_ESM_CLASS_TRANSACTION)) { |
| 3361 | /* if we're not in SMPP transaction mode, we expect the SMPP-level ACK |
| 3362 | * before we expect the SMS delivery on the BSC/radio side */ |
| 3363 | SMPP.receive(tr_SMPP(c_SMPP_command_id_submit_sm_resp, ESME_ROK)); |
| 3364 | } |
| 3365 | |
| 3366 | /* MSC->BSC: expect PAGING from MSC */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 3367 | f_expect_paging(); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 3368 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 3369 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 3370 | SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)); |
| 3371 | |
| 3372 | f_mt_sms(spars); |
| 3373 | |
| 3374 | if (match(sm.esm_class, tr_ESM_CLASS_TRANSACTION)) { |
| 3375 | SMPP.receive(tr_SMPP(c_SMPP_command_id_submit_sm_resp, ESME_ROK)); |
| 3376 | } |
| 3377 | f_expect_clear(); |
| 3378 | } |
| 3379 | |
| 3380 | /* mobile terminated SMS, from SMPP to BSC/BTS/MS */ |
| 3381 | private function f_tc_smpp_mt_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 3382 | f_init_handler(pars); |
| 3383 | |
| 3384 | /* Perform location update so IMSI is known + registered in MSC/VLR */ |
| 3385 | f_perform_lu(); |
| 3386 | SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)); |
| 3387 | |
| 3388 | /* register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 3389 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 3390 | |
| 3391 | var SmsParameters spars := valueof(t_SmsPars); |
| 3392 | /* TODO: test with more intelligent user data; test different coding schemes */ |
| 3393 | spars.tp.ud := '00'O; |
| 3394 | spars.tp.udl := 1; |
| 3395 | |
| 3396 | /* first test the non-transaction store+forward mode */ |
| 3397 | f_smpp_mt_sms(spars, false); |
| 3398 | |
| 3399 | /* then test the transaction mode */ |
| 3400 | f_smpp_mt_sms(spars, true); |
| 3401 | } |
| 3402 | testcase TC_smpp_mt_sms() runs on MTC_CT { |
| 3403 | var BSC_ConnHdlr vc_conn; |
| 3404 | f_init(); |
| 3405 | vc_conn := f_start_handler(refers(f_tc_smpp_mt_sms), 45); |
| 3406 | vc_conn.done; |
| 3407 | } |
| 3408 | |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3409 | /*********************************************************************** |
| 3410 | * USSD Testing |
| 3411 | ***********************************************************************/ |
| 3412 | |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3413 | private altstep as_unexp_gsup_or_bssap_msg() |
| 3414 | runs on BSC_ConnHdlr { |
| 3415 | [] GSUP.receive { |
| 3416 | setverdict(fail, "Unknown/unexpected GSUP received"); |
| 3417 | self.stop; |
| 3418 | } |
| 3419 | [] BSSAP.receive { |
| 3420 | setverdict(fail, "Unknown/unexpected BSSAP message received"); |
| 3421 | self.stop; |
| 3422 | } |
| 3423 | } |
| 3424 | |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 3425 | private function f_expect_gsup_msg(template GSUP_PDU msg, |
| 3426 | float T_val := 2.0) |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3427 | runs on BSC_ConnHdlr return GSUP_PDU { |
| 3428 | var GSUP_PDU gsup_msg_complete; |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 3429 | timer T := T_val; |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3430 | |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3431 | T.start; |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3432 | alt { |
| 3433 | [] GSUP.receive(msg) -> value gsup_msg_complete { |
| 3434 | setverdict(pass); |
| 3435 | } |
| 3436 | /* We don't expect anything else */ |
| 3437 | [] as_unexp_gsup_or_bssap_msg(); |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3438 | [] T.timeout { |
| 3439 | setverdict(fail, "Timeout waiting for GSUP message: ", msg); |
| 3440 | } |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3441 | } |
| 3442 | |
| 3443 | return gsup_msg_complete; |
| 3444 | } |
| 3445 | |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 3446 | private function f_expect_mt_dtap_msg(template PDU_ML3_NW_MS msg, |
| 3447 | float T_val := 2.0) |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3448 | runs on BSC_ConnHdlr return PDU_ML3_NW_MS { |
| 3449 | var PDU_DTAP_MT bssap_msg_complete; |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 3450 | timer T := T_val; |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3451 | |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3452 | T.start; |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3453 | alt { |
| 3454 | [] BSSAP.receive(tr_PDU_DTAP_MT(msg)) -> value bssap_msg_complete { |
| 3455 | setverdict(pass); |
| 3456 | } |
| 3457 | /* We don't expect anything else */ |
| 3458 | [] as_unexp_gsup_or_bssap_msg(); |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3459 | [] T.timeout { |
| 3460 | setverdict(fail, "Timeout waiting for BSSAP message: ", msg); |
| 3461 | } |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3462 | } |
| 3463 | |
| 3464 | return bssap_msg_complete.dtap; |
| 3465 | } |
| 3466 | |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3467 | /* LU followed by MO USSD request */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3468 | 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] | 3469 | runs on BSC_ConnHdlr { |
| 3470 | f_init_handler(pars); |
| 3471 | |
| 3472 | /* Perform location update */ |
| 3473 | f_perform_lu(); |
| 3474 | |
| 3475 | /* Send CM Service Request for SS/USSD */ |
| 3476 | f_establish_fully(EST_TYPE_SS_ACT); |
| 3477 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3478 | /* We need to inspect GSUP activity */ |
| 3479 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3480 | |
| 3481 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 3482 | invoke_id := 5, /* Phone may not start from 0 or 1 */ |
| 3483 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3484 | ussd_string := "*#100#" |
| 3485 | ); |
| 3486 | |
| 3487 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 3488 | invoke_id := 5, /* InvokeID shall be the same for both REQ and RSP */ |
| 3489 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3490 | ussd_string := "Your extension is " & hex2str(g_pars.msisdn) & "\r" |
| 3491 | ) |
| 3492 | |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3493 | /* Compose a new SS/REGISTER message with request */ |
| 3494 | var template (value) PDU_ML3_MS_NW ussd_req := ts_ML3_MO_SS_REGISTER( |
| 3495 | tid := 1, /* We just need a single transaction */ |
| 3496 | 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] | 3497 | facility := valueof(facility_req) |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3498 | ); |
| 3499 | |
| 3500 | /* Compose SS/RELEASE_COMPLETE template with expected response */ |
| 3501 | var template PDU_ML3_NW_MS ussd_rsp := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3502 | tid := 1, /* Response should arrive within the same transaction */ |
| 3503 | 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] | 3504 | facility := valueof(facility_rsp) |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3505 | ); |
| 3506 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3507 | /* Compose expected MSC -> HLR message */ |
| 3508 | var template GSUP_PDU gsup_req := tr_GSUP_PROC_SS_REQ( |
| 3509 | imsi := g_pars.imsi, |
| 3510 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3511 | ss := valueof(facility_req) |
| 3512 | ); |
| 3513 | |
| 3514 | /* To be used for sending response with correct session ID */ |
| 3515 | var GSUP_PDU gsup_req_complete; |
| 3516 | |
| 3517 | /* Request own number */ |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3518 | BSSAP.send(ts_PDU_DTAP_MO(ussd_req)); |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3519 | /* Expect GSUP message containing the SS payload */ |
| 3520 | gsup_req_complete := f_expect_gsup_msg(gsup_req); |
| 3521 | |
| 3522 | /* Compose the response from HLR using received session ID */ |
| 3523 | var template GSUP_PDU gsup_rsp := ts_GSUP_PROC_SS_REQ( |
| 3524 | imsi := g_pars.imsi, |
| 3525 | sid := gsup_req_complete.ies[1].val.session_id, |
| 3526 | state := OSMO_GSUP_SESSION_STATE_END, |
| 3527 | ss := valueof(facility_rsp) |
| 3528 | ); |
| 3529 | |
| 3530 | /* Finally, HLR terminates the session */ |
| 3531 | GSUP.send(gsup_rsp); |
| 3532 | /* Expect RELEASE_COMPLETE message with the response */ |
| 3533 | f_expect_mt_dtap_msg(ussd_rsp); |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3534 | |
| 3535 | f_expect_clear(); |
| 3536 | } |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3537 | testcase TC_lu_and_mo_ussd_single_request() runs on MTC_CT { |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3538 | var BSC_ConnHdlr vc_conn; |
| 3539 | f_init(); |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3540 | 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] | 3541 | vc_conn.done; |
| 3542 | } |
| 3543 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3544 | |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3545 | /* LU followed by MT USSD notification */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3546 | 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] | 3547 | runs on BSC_ConnHdlr { |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3548 | timer T := 5.0; |
| 3549 | |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3550 | f_init_handler(pars); |
| 3551 | |
| 3552 | /* Perform location update */ |
| 3553 | f_perform_lu(); |
| 3554 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 3555 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3556 | |
| 3557 | /* We need to inspect GSUP activity */ |
| 3558 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3559 | |
| 3560 | /* Facility IE with network-originated USSD notification */ |
| 3561 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 3562 | op_code := SS_OP_CODE_USS_NOTIFY, |
| 3563 | ussd_string := "Mahlzeit!" |
| 3564 | ); |
| 3565 | |
| 3566 | /* Facility IE with acknowledgment to the USSD notification */ |
| 3567 | var template OCTN facility_rsp := enc_SS_FacilityInformation( |
| 3568 | /* In case of USSD notification, Return Result is empty */ |
| 3569 | valueof(ts_SS_USSD_FACILITY_RETURN_RESULT_EMPTY()) |
| 3570 | ); |
| 3571 | |
| 3572 | /* Compose a new MT SS/REGISTER message with USSD notification */ |
| 3573 | var template PDU_ML3_NW_MS ussd_ntf := tr_ML3_MT_SS_REGISTER( |
| 3574 | tid := 0, /* FIXME: most likely, it should be 0 */ |
| 3575 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3576 | facility := valueof(facility_req) |
| 3577 | ); |
| 3578 | |
| 3579 | /* Compose HLR -> MSC GSUP message */ |
| 3580 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 3581 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3582 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3583 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3584 | ss := valueof(facility_req) |
| 3585 | ); |
| 3586 | |
| 3587 | /* Send it to MSC and expect Paging Request */ |
| 3588 | GSUP.send(gsup_req); |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3589 | T.start; |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3590 | alt { |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3591 | [pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 3592 | setverdict(pass); |
| 3593 | } |
Harald Welte | 62113fc | 2019-05-09 13:04:02 +0200 | [diff] [blame] | 3594 | [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] | 3595 | setverdict(pass); |
| 3596 | } |
| 3597 | /* We don't expect anything else */ |
| 3598 | [] as_unexp_gsup_or_bssap_msg(); |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3599 | [] T.timeout { |
| 3600 | setverdict(fail, "Timeout waiting for Paging Request"); |
| 3601 | } |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3602 | } |
| 3603 | |
| 3604 | /* Send Paging Response and expect USSD notification */ |
| 3605 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 3606 | /* Expect MT REGISTER message with USSD notification */ |
| 3607 | f_expect_mt_dtap_msg(ussd_ntf); |
| 3608 | |
| 3609 | /* Compose a new MO SS/FACILITY message with empty response */ |
| 3610 | var template (value) PDU_ML3_MS_NW ussd_rsp := ts_ML3_MO_SS_FACILITY( |
| 3611 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3612 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3613 | facility := valueof(facility_rsp) |
| 3614 | ); |
| 3615 | |
| 3616 | /* Compose expected MSC -> HLR GSUP message */ |
| 3617 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_REQ( |
| 3618 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3619 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3620 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 3621 | ss := valueof(facility_rsp) |
| 3622 | ); |
| 3623 | |
| 3624 | /* MS sends response to the notification */ |
| 3625 | BSSAP.send(ts_PDU_DTAP_MO(ussd_rsp)); |
| 3626 | /* Expect GSUP message containing the SS payload */ |
| 3627 | f_expect_gsup_msg(gsup_rsp); |
| 3628 | |
| 3629 | /* Compose expected MT SS/RELEASE COMPLETE message */ |
| 3630 | var template PDU_ML3_NW_MS ussd_term := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3631 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3632 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3633 | facility := omit |
| 3634 | ); |
| 3635 | |
| 3636 | /* Compose MSC -> HLR GSUP message */ |
| 3637 | var template GSUP_PDU gsup_term := ts_GSUP_PROC_SS_REQ( |
| 3638 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3639 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3640 | state := OSMO_GSUP_SESSION_STATE_END |
| 3641 | ); |
| 3642 | |
| 3643 | /* Finally, HLR terminates the session */ |
| 3644 | GSUP.send(gsup_term) |
| 3645 | /* Expect MT RELEASE COMPLETE without Facility IE */ |
| 3646 | f_expect_mt_dtap_msg(ussd_term); |
| 3647 | |
| 3648 | f_expect_clear(); |
| 3649 | } |
| 3650 | testcase TC_lu_and_mt_ussd_notification() runs on MTC_CT { |
| 3651 | var BSC_ConnHdlr vc_conn; |
| 3652 | f_init(); |
| 3653 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_ussd_notification), 47); |
| 3654 | vc_conn.done; |
| 3655 | } |
| 3656 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3657 | |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3658 | /* LU followed by MT call and MO USSD request during this call */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3659 | 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] | 3660 | runs on BSC_ConnHdlr { |
| 3661 | f_init_handler(pars); |
| 3662 | |
| 3663 | /* Call parameters taken from f_tc_lu_and_mt_call */ |
| 3664 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3665 | |
| 3666 | /* Perform location update */ |
| 3667 | f_perform_lu(); |
| 3668 | |
| 3669 | /* Establish a MT call */ |
| 3670 | f_mt_call_establish(cpars); |
| 3671 | |
| 3672 | /* Hold the call for some time */ |
| 3673 | f_sleep(1.0); |
| 3674 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3675 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 3676 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3677 | ussd_string := "*#100#" |
| 3678 | ); |
| 3679 | |
| 3680 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 3681 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3682 | ussd_string := "Your extension is " & hex2str(g_pars.msisdn) & "\r" |
| 3683 | ) |
| 3684 | |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3685 | /* Compose a new SS/REGISTER message with request */ |
| 3686 | var template (value) PDU_ML3_MS_NW ussd_req := ts_ML3_MO_SS_REGISTER( |
| 3687 | tid := 1, /* We just need a single transaction */ |
| 3688 | 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] | 3689 | facility := valueof(facility_req) |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3690 | ); |
| 3691 | |
| 3692 | /* Compose SS/RELEASE_COMPLETE template with expected response */ |
| 3693 | var template PDU_ML3_NW_MS ussd_rsp := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3694 | tid := 1, /* Response should arrive within the same transaction */ |
| 3695 | 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] | 3696 | facility := valueof(facility_rsp) |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3697 | ); |
| 3698 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3699 | /* Compose expected MSC -> HLR message */ |
| 3700 | var template GSUP_PDU gsup_req := tr_GSUP_PROC_SS_REQ( |
| 3701 | imsi := g_pars.imsi, |
| 3702 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3703 | ss := valueof(facility_req) |
| 3704 | ); |
| 3705 | |
| 3706 | /* To be used for sending response with correct session ID */ |
| 3707 | var GSUP_PDU gsup_req_complete; |
| 3708 | |
| 3709 | /* Request own number */ |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3710 | BSSAP.send(ts_PDU_DTAP_MO(ussd_req)); |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3711 | /* Expect GSUP message containing the SS payload */ |
| 3712 | gsup_req_complete := f_expect_gsup_msg(gsup_req); |
| 3713 | |
| 3714 | /* Compose the response from HLR using received session ID */ |
| 3715 | var template GSUP_PDU gsup_rsp := ts_GSUP_PROC_SS_REQ( |
| 3716 | imsi := g_pars.imsi, |
| 3717 | sid := gsup_req_complete.ies[1].val.session_id, |
| 3718 | state := OSMO_GSUP_SESSION_STATE_END, |
| 3719 | ss := valueof(facility_rsp) |
| 3720 | ); |
| 3721 | |
| 3722 | /* Finally, HLR terminates the session */ |
| 3723 | GSUP.send(gsup_rsp); |
| 3724 | /* Expect RELEASE_COMPLETE message with the response */ |
| 3725 | f_expect_mt_dtap_msg(ussd_rsp); |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3726 | |
| 3727 | /* Hold the call for some time */ |
| 3728 | f_sleep(1.0); |
| 3729 | |
| 3730 | /* Release the call (does Clear Complete itself) */ |
| 3731 | f_call_hangup(cpars, true); |
| 3732 | } |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3733 | 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] | 3734 | var BSC_ConnHdlr vc_conn; |
| 3735 | f_init(); |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3736 | 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] | 3737 | vc_conn.done; |
| 3738 | } |
| 3739 | |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 3740 | /* BSSMAP Clear Request in the middle of a call, see OS#3062 */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3741 | 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] | 3742 | f_init_handler(pars); |
| 3743 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 3744 | cpars.ran_clear_when_alerting := true; |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 3745 | |
| 3746 | f_perform_lu(); |
| 3747 | |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 3748 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 3749 | f_mo_call_establish(cpars); |
| 3750 | f_expect_clear() |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 3751 | deactivate(ccrel); |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 3752 | |
| 3753 | f_sleep(1.0); |
| 3754 | } |
| 3755 | testcase TC_mo_cc_bssmap_clear() runs on MTC_CT { |
| 3756 | var BSC_ConnHdlr vc_conn; |
| 3757 | f_init(); |
| 3758 | |
| 3759 | vc_conn := f_start_handler(refers(f_tc_mo_cc_bssmap_clear), 43); |
| 3760 | vc_conn.done; |
| 3761 | } |
| 3762 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3763 | |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3764 | /* LU followed by MT call and MT USSD request during this call */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3765 | 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] | 3766 | runs on BSC_ConnHdlr { |
| 3767 | f_init_handler(pars); |
| 3768 | |
| 3769 | /* Call parameters taken from f_tc_lu_and_mt_call */ |
| 3770 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3771 | |
| 3772 | /* Perform location update */ |
| 3773 | f_perform_lu(); |
| 3774 | |
| 3775 | /* Establish a MT call */ |
| 3776 | f_mt_call_establish(cpars); |
| 3777 | |
| 3778 | /* Hold the call for some time */ |
| 3779 | f_sleep(1.0); |
| 3780 | |
| 3781 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 3782 | op_code := SS_OP_CODE_USS_REQUEST, |
| 3783 | ussd_string := "Please type anything..." |
| 3784 | ); |
| 3785 | |
| 3786 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 3787 | op_code := SS_OP_CODE_USS_REQUEST, |
| 3788 | ussd_string := "Nope." |
| 3789 | ) |
| 3790 | |
| 3791 | /* Compose MT SS/REGISTER message with network-originated request */ |
| 3792 | var template (value) PDU_ML3_NW_MS ussd_req := ts_ML3_MT_SS_REGISTER( |
| 3793 | tid := 0, /* FIXME: most likely, it should be 0 */ |
| 3794 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3795 | facility := valueof(facility_req) |
| 3796 | ); |
| 3797 | |
| 3798 | /* Compose HLR -> MSC GSUP message */ |
| 3799 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 3800 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3801 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3802 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3803 | ss := valueof(facility_req) |
| 3804 | ); |
| 3805 | |
| 3806 | /* Send it to MSC */ |
| 3807 | GSUP.send(gsup_req); |
| 3808 | /* Expect MT REGISTER message with USSD request */ |
| 3809 | f_expect_mt_dtap_msg(ussd_req); |
| 3810 | |
| 3811 | /* Compose a new MO SS/FACILITY message with response */ |
| 3812 | var template (value) PDU_ML3_MS_NW ussd_rsp := ts_ML3_MO_SS_FACILITY( |
| 3813 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3814 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3815 | facility := valueof(facility_rsp) |
| 3816 | ); |
| 3817 | |
| 3818 | /* Compose expected MSC -> HLR GSUP message */ |
| 3819 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_REQ( |
| 3820 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3821 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3822 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 3823 | ss := valueof(facility_rsp) |
| 3824 | ); |
| 3825 | |
| 3826 | /* MS sends response */ |
| 3827 | BSSAP.send(ts_PDU_DTAP_MO(ussd_rsp)); |
| 3828 | f_expect_gsup_msg(gsup_rsp); |
| 3829 | |
| 3830 | /* Compose expected MT SS/RELEASE COMPLETE message */ |
| 3831 | var template PDU_ML3_NW_MS ussd_term := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3832 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3833 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3834 | facility := omit |
| 3835 | ); |
| 3836 | |
| 3837 | /* Compose MSC -> HLR GSUP message */ |
| 3838 | var template GSUP_PDU gsup_term := ts_GSUP_PROC_SS_REQ( |
| 3839 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3840 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3841 | state := OSMO_GSUP_SESSION_STATE_END |
| 3842 | ); |
| 3843 | |
| 3844 | /* Finally, HLR terminates the session */ |
| 3845 | GSUP.send(gsup_term); |
| 3846 | /* Expect MT RELEASE COMPLETE without Facility IE */ |
| 3847 | f_expect_mt_dtap_msg(ussd_term); |
| 3848 | |
| 3849 | /* Hold the call for some time */ |
| 3850 | f_sleep(1.0); |
| 3851 | |
| 3852 | /* Release the call (does Clear Complete itself) */ |
| 3853 | f_call_hangup(cpars, true); |
| 3854 | } |
| 3855 | testcase TC_lu_and_mt_ussd_during_mt_call() runs on MTC_CT { |
| 3856 | var BSC_ConnHdlr vc_conn; |
| 3857 | f_init(); |
| 3858 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_ussd_during_mt_call), 49); |
| 3859 | vc_conn.done; |
| 3860 | } |
| 3861 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3862 | |
Vadim Yanitskiy | 2daf52d | 2018-06-21 04:19:58 +0700 | [diff] [blame] | 3863 | /* LU followed by MO USSD request and MO Release during transaction */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3864 | 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] | 3865 | runs on BSC_ConnHdlr { |
| 3866 | f_init_handler(pars); |
| 3867 | |
| 3868 | /* Perform location update */ |
| 3869 | f_perform_lu(); |
| 3870 | |
| 3871 | /* Send CM Service Request for SS/USSD */ |
| 3872 | f_establish_fully(EST_TYPE_SS_ACT); |
| 3873 | |
| 3874 | /* We need to inspect GSUP activity */ |
| 3875 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3876 | |
| 3877 | var template OCTN facility_ms_req := f_USSD_FACILITY_IE_INVOKE( |
| 3878 | invoke_id := 1, /* Initial request */ |
| 3879 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3880 | ussd_string := "*6766*266#" |
| 3881 | ); |
| 3882 | |
| 3883 | var template OCTN facility_net_req := f_USSD_FACILITY_IE_INVOKE( |
| 3884 | invoke_id := 2, /* Counter request */ |
| 3885 | op_code := SS_OP_CODE_USS_REQUEST, |
| 3886 | ussd_string := "Password?!?" |
| 3887 | ) |
| 3888 | |
| 3889 | /* Compose MO SS/REGISTER message with request */ |
| 3890 | var template (value) PDU_ML3_MS_NW ussd_ms_req := ts_ML3_MO_SS_REGISTER( |
| 3891 | tid := 1, /* We just need a single transaction */ |
| 3892 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3893 | facility := valueof(facility_ms_req) |
| 3894 | ); |
| 3895 | |
| 3896 | /* Compose expected MSC -> HLR message */ |
| 3897 | var template GSUP_PDU gsup_ms_req := tr_GSUP_PROC_SS_REQ( |
| 3898 | imsi := g_pars.imsi, |
| 3899 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3900 | ss := valueof(facility_ms_req) |
| 3901 | ); |
| 3902 | |
| 3903 | /* To be used for sending response with correct session ID */ |
| 3904 | var GSUP_PDU gsup_ms_req_complete; |
| 3905 | |
| 3906 | /* Initiate a new transaction */ |
| 3907 | BSSAP.send(ts_PDU_DTAP_MO(ussd_ms_req)); |
| 3908 | /* Expect GSUP request with original Facility IE */ |
| 3909 | gsup_ms_req_complete := f_expect_gsup_msg(gsup_ms_req); |
| 3910 | |
| 3911 | /* Compose the response from HLR using received session ID */ |
| 3912 | var template (value) GSUP_PDU gsup_net_req := ts_GSUP_PROC_SS_REQ( |
| 3913 | imsi := g_pars.imsi, |
| 3914 | sid := gsup_ms_req_complete.ies[1].val.session_id, |
| 3915 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 3916 | ss := valueof(facility_net_req) |
| 3917 | ); |
| 3918 | |
| 3919 | /* Compose expected MT SS/FACILITY template with counter request */ |
| 3920 | var template PDU_ML3_NW_MS ussd_net_req := tr_ML3_MT_SS_FACILITY( |
| 3921 | tid := 1, /* Response should arrive within the same transaction */ |
| 3922 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3923 | facility := valueof(facility_net_req) |
| 3924 | ); |
| 3925 | |
| 3926 | /* Send response over GSUP */ |
| 3927 | GSUP.send(gsup_net_req); |
| 3928 | /* Expect MT SS/FACILITY message with counter request */ |
| 3929 | f_expect_mt_dtap_msg(ussd_net_req); |
| 3930 | |
| 3931 | /* Compose MO SS/RELEASE COMPLETE */ |
| 3932 | var template (value) PDU_ML3_MS_NW ussd_abort := ts_ML3_MO_SS_RELEASE_COMPLETE( |
| 3933 | tid := 1, /* Response should arrive within the same transaction */ |
| 3934 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3935 | facility := omit |
| 3936 | /* TODO: cause? */ |
| 3937 | ); |
| 3938 | |
| 3939 | /* Compose expected HLR -> MSC abort message */ |
| 3940 | var template GSUP_PDU gsup_abort := tr_GSUP_PROC_SS_REQ( |
| 3941 | imsi := g_pars.imsi, |
| 3942 | sid := gsup_ms_req_complete.ies[1].val.session_id, |
| 3943 | state := OSMO_GSUP_SESSION_STATE_END |
| 3944 | ); |
| 3945 | |
| 3946 | /* Abort transaction */ |
| 3947 | BSSAP.send(ts_PDU_DTAP_MO(ussd_abort)); |
| 3948 | /* Expect GSUP message indicating abort */ |
| 3949 | f_expect_gsup_msg(gsup_abort); |
| 3950 | |
| 3951 | f_expect_clear(); |
| 3952 | } |
| 3953 | testcase TC_lu_and_mo_ussd_mo_release() runs on MTC_CT { |
| 3954 | var BSC_ConnHdlr vc_conn; |
| 3955 | f_init(); |
| 3956 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_ussd_mo_release), 50); |
| 3957 | vc_conn.done; |
| 3958 | } |
| 3959 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3960 | |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 3961 | /* LU followed by MO USSD request and MT Release due to timeout */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3962 | 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] | 3963 | runs on BSC_ConnHdlr { |
| 3964 | f_init_handler(pars); |
| 3965 | |
| 3966 | /* Perform location update */ |
| 3967 | f_perform_lu(); |
| 3968 | |
| 3969 | /* Send CM Service Request for SS/USSD */ |
| 3970 | f_establish_fully(EST_TYPE_SS_ACT); |
| 3971 | |
| 3972 | /* We need to inspect GSUP activity */ |
| 3973 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3974 | |
| 3975 | var template OCTN facility_ms_req := f_USSD_FACILITY_IE_INVOKE( |
| 3976 | invoke_id := 1, |
| 3977 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3978 | ussd_string := "#release_me"); |
| 3979 | |
| 3980 | /* Compose MO SS/REGISTER message with request */ |
| 3981 | var template (value) PDU_ML3_MS_NW ussd_ms_req := ts_ML3_MO_SS_REGISTER( |
| 3982 | tid := 1, /* An arbitrary transaction identifier */ |
| 3983 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3984 | facility := valueof(facility_ms_req)); |
| 3985 | |
| 3986 | /* Compose expected MSC -> HLR message */ |
| 3987 | var template GSUP_PDU gsup_ms_req := tr_GSUP_PROC_SS_REQ( |
| 3988 | imsi := g_pars.imsi, |
| 3989 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3990 | ss := valueof(facility_ms_req)); |
| 3991 | |
| 3992 | /* To be used for sending response with correct session ID */ |
| 3993 | var GSUP_PDU gsup_ms_req_complete; |
| 3994 | |
| 3995 | /* Initiate a new SS transaction */ |
| 3996 | BSSAP.send(ts_PDU_DTAP_MO(ussd_ms_req)); |
| 3997 | /* Expect GSUP request with original Facility IE */ |
| 3998 | gsup_ms_req_complete := f_expect_gsup_msg(gsup_ms_req); |
| 3999 | |
| 4000 | /* Don't respond, wait for timeout */ |
| 4001 | f_sleep(3.0); |
| 4002 | |
| 4003 | var template PDU_ML3_NW_MS dtap_rel := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 4004 | tid := 1, /* Should match the request's tid */ |
| 4005 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 4006 | cause := *, /* TODO: expect some specific value */ |
| 4007 | facility := omit); |
| 4008 | |
| 4009 | var template GSUP_PDU gsup_rel := tr_GSUP_PROC_SS_ERR( |
| 4010 | imsi := g_pars.imsi, |
| 4011 | sid := gsup_ms_req_complete.ies[1].val.session_id, |
| 4012 | state := OSMO_GSUP_SESSION_STATE_END, |
| 4013 | cause := ?); /* TODO: expect some specific value */ |
| 4014 | |
| 4015 | /* Expect release on both interfaces */ |
| 4016 | interleave { |
| 4017 | [] BSSAP.receive(tr_PDU_DTAP_MT(dtap_rel)) { }; |
| 4018 | [] GSUP.receive(gsup_rel) { }; |
| 4019 | } |
| 4020 | |
| 4021 | f_expect_clear(); |
| 4022 | setverdict(pass); |
| 4023 | } |
| 4024 | testcase TC_lu_and_ss_session_timeout() runs on MTC_CT { |
| 4025 | var BSC_ConnHdlr vc_conn; |
| 4026 | f_init(); |
Vadim Yanitskiy | 36d28dd | 2018-12-03 02:45:45 +0700 | [diff] [blame] | 4027 | f_vty_config(MSCVTY, "msc", "ncss guard-timeout 3"); |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 4028 | vc_conn := f_start_handler(refers(f_tc_lu_and_ss_session_timeout), 51); |
| 4029 | vc_conn.done; |
Vadim Yanitskiy | 36d28dd | 2018-12-03 02:45:45 +0700 | [diff] [blame] | 4030 | f_vty_config(MSCVTY, "msc", "ncss guard-timeout 0"); |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 4031 | } |
| 4032 | |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 4033 | /* MT (network-originated) USSD for unknown subscriber */ |
| 4034 | friend function f_tc_mt_ussd_for_unknown_subscr(charstring id, BSC_ConnHdlrPars pars) |
| 4035 | runs on BSC_ConnHdlr { |
| 4036 | var hexstring imsi := '000000000000000'H; /* Some unknown IMSI */ |
| 4037 | var OCT4 sid := '20000222'O; |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 4038 | |
| 4039 | f_init_handler(pars); |
| 4040 | f_ran_register_imsi(imsi, 'FFFFFFFF'O); |
| 4041 | f_create_gsup_expect(hex2str(imsi)); |
| 4042 | |
| 4043 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 4044 | imsi := imsi, |
| 4045 | sid := sid, |
| 4046 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 4047 | ss := f_rnd_octstring(23) |
| 4048 | ); |
| 4049 | |
| 4050 | /* Error with cause GMM_CAUSE_IMSI_UNKNOWN */ |
| 4051 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_ERR( |
| 4052 | imsi := imsi, |
| 4053 | sid := sid, |
| 4054 | state := OSMO_GSUP_SESSION_STATE_END, |
| 4055 | cause := 2 /* FIXME: introduce an enumerated type! */ |
| 4056 | ); |
| 4057 | |
| 4058 | /* Initiate a MT USSD notification */ |
| 4059 | GSUP.send(gsup_req); |
| 4060 | |
| 4061 | /* Expect GSUP PROC_SS_ERROR message */ |
Vadim Yanitskiy | 851798c | 2019-06-15 14:22:28 +0700 | [diff] [blame] | 4062 | f_expect_gsup_msg(gsup_rsp); |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 4063 | } |
| 4064 | testcase TC_mt_ussd_for_unknown_subscr() runs on MTC_CT { |
| 4065 | var BSC_ConnHdlr vc_conn; |
| 4066 | f_init(); |
| 4067 | vc_conn := f_start_handler(refers(f_tc_mt_ussd_for_unknown_subscr), 0); |
| 4068 | vc_conn.done; |
| 4069 | } |
| 4070 | |
Vadim Yanitskiy | c3c07d4 | 2019-06-17 23:00:44 +0700 | [diff] [blame] | 4071 | /* MO (mobile-originated) SS/USSD for unknown transaction */ |
| 4072 | friend function f_tc_mo_ussd_for_unknown_trans(charstring id, BSC_ConnHdlrPars pars) |
| 4073 | runs on BSC_ConnHdlr { |
| 4074 | f_init_handler(pars); |
| 4075 | |
Vadim Yanitskiy | 70d15bf | 2020-01-09 22:51:01 +0100 | [diff] [blame] | 4076 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | c3c07d4 | 2019-06-17 23:00:44 +0700 | [diff] [blame] | 4077 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4078 | |
| 4079 | /* Perform location update */ |
| 4080 | f_perform_lu(); |
| 4081 | |
| 4082 | /* Send CM Service Request for SS/USSD */ |
| 4083 | f_establish_fully(EST_TYPE_SS_ACT); |
| 4084 | |
| 4085 | /* GSM 04.80 FACILITY message for a non-existing transaction */ |
| 4086 | var template (value) PDU_ML3_MS_NW mo_ss_fac := ts_ML3_MO_SS_FACILITY( |
| 4087 | tid := 1, /* An arbitrary transaction identifier */ |
| 4088 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 4089 | facility := f_rnd_octstring(23) /* We don't care about the Facility IE */ |
| 4090 | ); |
| 4091 | |
| 4092 | /* GSM 04.80 RELEASE COMPLETE message for a non-existing transaction */ |
| 4093 | var template (value) PDU_ML3_MS_NW mo_ss_rel := ts_ML3_MO_SS_RELEASE_COMPLETE( |
| 4094 | tid := 1, /* An arbitrary transaction identifier */ |
| 4095 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 4096 | facility := f_rnd_octstring(23) /* We don't care about the Facility IE */ |
| 4097 | ); |
| 4098 | |
| 4099 | /* Expected response from the network */ |
| 4100 | var template PDU_ML3_NW_MS mt_ss_rel := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 4101 | tid := 1, /* Same as in the FACILITY message */ |
| 4102 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 4103 | facility := omit |
| 4104 | ); |
| 4105 | |
| 4106 | /* Send GSM 04.80 FACILITY for non-existing transaction */ |
| 4107 | BSSAP.send(ts_PDU_DTAP_MO(mo_ss_fac)); |
| 4108 | |
| 4109 | /* Expect GSM 04.80 RELEASE COMPLETE message */ |
| 4110 | f_expect_mt_dtap_msg(mt_ss_rel); |
| 4111 | f_expect_clear(); |
| 4112 | |
| 4113 | /* Send another CM Service Request for SS/USSD */ |
| 4114 | f_establish_fully(EST_TYPE_SS_ACT); |
| 4115 | |
| 4116 | /* Send GSM 04.80 RELEASE COMPLETE for non-existing transaction */ |
| 4117 | BSSAP.send(ts_PDU_DTAP_MO(mo_ss_rel)); |
| 4118 | |
| 4119 | /* Expect GSM 04.80 RELEASE COMPLETE message */ |
| 4120 | f_expect_mt_dtap_msg(mt_ss_rel); |
| 4121 | f_expect_clear(); |
| 4122 | } |
| 4123 | testcase TC_mo_ussd_for_unknown_trans() runs on MTC_CT { |
| 4124 | var BSC_ConnHdlr vc_conn; |
| 4125 | f_init(); |
| 4126 | vc_conn := f_start_handler(refers(f_tc_mo_ussd_for_unknown_trans), 111); |
| 4127 | vc_conn.done; |
| 4128 | } |
| 4129 | |
Vadim Yanitskiy | d612d28 | 2019-06-15 14:46:03 +0700 | [diff] [blame] | 4130 | /* MT (network-originated) USSD for unknown session */ |
| 4131 | friend function f_tc_proc_ss_for_unknown_session(charstring id, BSC_ConnHdlrPars pars) |
| 4132 | runs on BSC_ConnHdlr { |
| 4133 | var OCT4 sid := '20000333'O; |
| 4134 | |
| 4135 | f_init_handler(pars); |
| 4136 | |
| 4137 | /* Perform location update */ |
| 4138 | f_perform_lu(); |
| 4139 | |
Vadim Yanitskiy | 70d15bf | 2020-01-09 22:51:01 +0100 | [diff] [blame] | 4140 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | d612d28 | 2019-06-15 14:46:03 +0700 | [diff] [blame] | 4141 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4142 | |
| 4143 | /* Request referencing a non-existing SS session */ |
| 4144 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 4145 | imsi := g_pars.imsi, |
| 4146 | sid := sid, |
| 4147 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 4148 | ss := f_rnd_octstring(23) |
| 4149 | ); |
| 4150 | |
| 4151 | /* Error with some cause value */ |
| 4152 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_ERR( |
| 4153 | imsi := g_pars.imsi, |
| 4154 | sid := sid, |
| 4155 | state := OSMO_GSUP_SESSION_STATE_END, |
| 4156 | cause := ? /* FIXME: introduce an enumerated type! */ |
| 4157 | ); |
| 4158 | |
| 4159 | /* Initiate a MT USSD notification */ |
| 4160 | GSUP.send(gsup_req); |
| 4161 | |
| 4162 | /* Expect GSUP PROC_SS_ERROR message */ |
| 4163 | f_expect_gsup_msg(gsup_rsp); |
| 4164 | } |
| 4165 | testcase TC_proc_ss_for_unknown_session() runs on MTC_CT { |
| 4166 | var BSC_ConnHdlr vc_conn; |
| 4167 | f_init(); |
| 4168 | vc_conn := f_start_handler(refers(f_tc_proc_ss_for_unknown_session), 110); |
| 4169 | vc_conn.done; |
| 4170 | } |
| 4171 | |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 4172 | /* MT (network-originated) USSD and no response to Paging Request */ |
| 4173 | friend function f_tc_proc_ss_paging_fail(charstring id, BSC_ConnHdlrPars pars) |
| 4174 | runs on BSC_ConnHdlr { |
| 4175 | timer TP := 2.0; /* Paging timer */ |
| 4176 | |
| 4177 | f_init_handler(pars); |
| 4178 | |
| 4179 | /* Perform location update */ |
| 4180 | f_perform_lu(); |
| 4181 | |
Vadim Yanitskiy | 70d15bf | 2020-01-09 22:51:01 +0100 | [diff] [blame] | 4182 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 4183 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4184 | |
| 4185 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 4186 | imsi := g_pars.imsi, |
| 4187 | sid := '20000444'O, |
| 4188 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 4189 | ss := f_rnd_octstring(23) |
| 4190 | ); |
| 4191 | |
| 4192 | /* Error with some cause value */ |
| 4193 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_ERR( |
| 4194 | imsi := g_pars.imsi, |
| 4195 | sid := '20000444'O, |
| 4196 | state := OSMO_GSUP_SESSION_STATE_END, |
| 4197 | cause := ? /* FIXME: introduce an enumerated type! */ |
| 4198 | ); |
| 4199 | |
| 4200 | /* Initiate a MT USSD notification */ |
| 4201 | GSUP.send(gsup_req); |
| 4202 | |
| 4203 | /* Send it to MSC and expect Paging Request */ |
| 4204 | TP.start; |
| 4205 | alt { |
| 4206 | [pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 4207 | setverdict(pass); |
| 4208 | } |
| 4209 | [not pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) { |
| 4210 | setverdict(pass); |
| 4211 | } |
| 4212 | /* We don't expect anything else */ |
| 4213 | [] as_unexp_gsup_or_bssap_msg(); |
| 4214 | [] TP.timeout { |
| 4215 | setverdict(fail, "Timeout waiting for Paging Request"); |
| 4216 | } |
| 4217 | } |
| 4218 | |
Vadim Yanitskiy | d24b525 | 2019-10-02 00:04:51 +0700 | [diff] [blame] | 4219 | /* Wait up to 20 seconds for GSUP PROC_SS_ERROR message. |
| 4220 | * OsmoMSC waits for Paging Response 10 seconds by default. */ |
| 4221 | f_expect_gsup_msg(gsup_rsp, T_val := 20.0); |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 4222 | } |
| 4223 | testcase TC_proc_ss_paging_fail() runs on MTC_CT { |
| 4224 | var BSC_ConnHdlr vc_conn; |
| 4225 | f_init(); |
| 4226 | vc_conn := f_start_handler(refers(f_tc_proc_ss_paging_fail), 101); |
| 4227 | vc_conn.done; |
| 4228 | } |
| 4229 | |
Vadim Yanitskiy | 29ba8d6 | 2019-06-16 15:19:41 +0700 | [diff] [blame] | 4230 | /* MT (network-originated) USSD followed by immediate abort */ |
| 4231 | friend function f_tc_proc_ss_abort(charstring id, BSC_ConnHdlrPars pars) |
| 4232 | runs on BSC_ConnHdlr { |
| 4233 | var octetstring facility := f_rnd_octstring(23); |
| 4234 | var OCT4 sid := '20000555'O; |
| 4235 | timer TP := 2.0; |
| 4236 | |
| 4237 | f_init_handler(pars); |
| 4238 | |
| 4239 | /* Perform location update */ |
| 4240 | f_perform_lu(); |
| 4241 | |
Vadim Yanitskiy | 70d15bf | 2020-01-09 22:51:01 +0100 | [diff] [blame] | 4242 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 29ba8d6 | 2019-06-16 15:19:41 +0700 | [diff] [blame] | 4243 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4244 | |
| 4245 | /* PROC_SS_REQ initiates a mobile-originated SS/USSD session */ |
| 4246 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 4247 | imsi := g_pars.imsi, sid := sid, |
| 4248 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 4249 | ss := facility |
| 4250 | ); |
| 4251 | |
| 4252 | /* On the MS side, we expect GSM 04.80 REGISTER message */ |
| 4253 | var template PDU_ML3_NW_MS dtap_reg := tr_ML3_MT_SS_REGISTER( |
| 4254 | tid := 0, /* Most likely, it should be 0 */ |
| 4255 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 4256 | facility := facility |
| 4257 | ); |
| 4258 | |
| 4259 | /* PROC_SS_ERR with SESSION_STATE_END terminates the SS/USSD session */ |
| 4260 | var template (value) GSUP_PDU gsup_abort := ts_GSUP_PROC_SS_ERR( |
| 4261 | imsi := g_pars.imsi, sid := sid, |
| 4262 | state := OSMO_GSUP_SESSION_STATE_END, |
| 4263 | cause := 0 /* FIXME: introduce an enumerated type! */ |
| 4264 | ); |
| 4265 | |
| 4266 | /* On the MS side, we expect GSM 04.80 REGISTER message */ |
| 4267 | var template PDU_ML3_NW_MS dtap_rel := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 4268 | tid := 0, /* Most likely, it should be 0 */ |
| 4269 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 4270 | cause := *, /* FIXME: expect some specific cause value */ |
| 4271 | facility := omit |
| 4272 | ); |
| 4273 | |
| 4274 | /* Initiate a MT USSD with random payload */ |
| 4275 | GSUP.send(gsup_req); |
| 4276 | |
| 4277 | /* Expect Paging Request */ |
| 4278 | TP.start; |
| 4279 | alt { |
| 4280 | [pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 4281 | setverdict(pass); |
| 4282 | } |
| 4283 | [not pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) { |
| 4284 | setverdict(pass); |
| 4285 | } |
| 4286 | /* We don't expect anything else */ |
| 4287 | [] as_unexp_gsup_or_bssap_msg(); |
| 4288 | [] TP.timeout { |
| 4289 | setverdict(fail, "Timeout waiting for Paging Request"); |
| 4290 | } |
| 4291 | } |
| 4292 | |
| 4293 | /* Send Paging Response and establish connection */ |
| 4294 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 4295 | /* Expect MT REGISTER message with random facility */ |
| 4296 | f_expect_mt_dtap_msg(dtap_reg); |
| 4297 | |
| 4298 | /* HLR/EUSE decides to abort the session even |
| 4299 | * before getting any response from the MS */ |
| 4300 | /* Initiate a MT USSD with random payload */ |
| 4301 | GSUP.send(gsup_abort); |
| 4302 | |
| 4303 | /* Expect RELEASE COMPLETE on ths MS side */ |
| 4304 | f_expect_mt_dtap_msg(dtap_rel); |
| 4305 | |
| 4306 | f_expect_clear(); |
| 4307 | } |
| 4308 | testcase TC_proc_ss_abort() runs on MTC_CT { |
| 4309 | var BSC_ConnHdlr vc_conn; |
| 4310 | f_init(); |
| 4311 | vc_conn := f_start_handler(refers(f_tc_proc_ss_abort), 102); |
| 4312 | vc_conn.done; |
| 4313 | } |
| 4314 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 4315 | |
Vadim Yanitskiy | 1c9754d | 2020-01-07 21:56:55 +0100 | [diff] [blame] | 4316 | /* Verify multiple concurrent MO SS/USSD transactions |
| 4317 | * (one subscriber - one transaction) */ |
| 4318 | testcase TC_multi_lu_and_mo_ussd() runs on MTC_CT { |
| 4319 | var BSC_ConnHdlr vc_conn[16]; |
| 4320 | var integer i; |
| 4321 | |
| 4322 | f_init(); |
| 4323 | |
| 4324 | for (i := 0; i < sizeof(vc_conn); i := i + 1) { |
| 4325 | vc_conn[i] := f_start_handler(refers(f_tc_lu_and_mo_ussd_single_request), 210 + i); |
| 4326 | } |
| 4327 | |
| 4328 | for (i := 0; i < sizeof(vc_conn); i := i + 1) { |
| 4329 | vc_conn[i].done; |
| 4330 | } |
| 4331 | } |
| 4332 | |
| 4333 | /* Verify multiple concurrent MT SS/USSD transactions |
| 4334 | * (one subscriber - one transaction) */ |
| 4335 | testcase TC_multi_lu_and_mt_ussd() runs on MTC_CT { |
| 4336 | var BSC_ConnHdlr vc_conn[16]; |
| 4337 | var integer i; |
| 4338 | var OCT4 sid; |
| 4339 | |
| 4340 | f_init(); |
| 4341 | |
| 4342 | for (i := 0; i < sizeof(vc_conn); i := i + 1) { |
| 4343 | sid := '200001'O & int2oct(i, 1); /* All transactions must use different session ID */ |
| 4344 | vc_conn[i] := f_start_handler_with_pars(refers(f_tc_lu_and_mt_ussd_notification), |
| 4345 | f_init_pars(226 + i, gsup_sid := sid)); |
| 4346 | } |
| 4347 | |
| 4348 | for (i := 0; i < sizeof(vc_conn); i := i + 1) { |
| 4349 | vc_conn[i].done; |
| 4350 | } |
| 4351 | } |
| 4352 | |
| 4353 | |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 4354 | /* A5/1 only permitted on network side; attempt an invalid CIPHER MODE COMPLETE with A5/3 which MSC should reject. */ |
| 4355 | private function f_tc_cipher_complete_with_invalid_cipher(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4356 | pars.net.expect_auth := true; |
| 4357 | pars.net.expect_ciph := true; |
| 4358 | pars.net.kc_support := '02'O; /* A5/1 only */ |
| 4359 | f_init_handler(pars); |
| 4360 | |
| 4361 | g_pars.vec := f_gen_auth_vec_2g(); |
| 4362 | |
| 4363 | /* Can't use f_perform_lu() directly. Code below is based on it. */ |
| 4364 | |
| 4365 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 4366 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4367 | |
| 4368 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 4369 | 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] | 4370 | f_cl3_or_initial_ue(l3_lu); |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 4371 | |
| 4372 | f_mm_auth(); |
| 4373 | |
| 4374 | var OCT1 a5_net := f_alg_mask_from_cm(g_pars.cm2); |
| 4375 | var OCT1 a5_intersect := g_pars.net.kc_support and4b a5_net; |
| 4376 | alt { |
| 4377 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(a5_intersect, g_pars.vec.kc)) { |
| 4378 | BSSAP.send(ts_BSSMAP_CipherModeCompl(int2oct(4 /* "accept" A5/3 */, 1))); |
| 4379 | } |
| 4380 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?, g_pars.vec.kc)) { |
| 4381 | setverdict(fail, "Wrong ciphering algorithm mask in CiphModCmd"); |
| 4382 | mtc.stop; |
| 4383 | } |
| 4384 | [] BSSAP.receive { |
| 4385 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 4386 | mtc.stop; |
| 4387 | } |
| 4388 | } |
Harald Welte | 79f1e45 | 2020-08-18 22:55:02 +0200 | [diff] [blame] | 4389 | f_expect_common_id(); |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 4390 | |
| 4391 | /* Expect LU reject from MSC. */ |
| 4392 | alt { |
| 4393 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 4394 | setverdict(pass); |
| 4395 | } |
| 4396 | [] BSSAP.receive { |
| 4397 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 4398 | mtc.stop; |
| 4399 | } |
| 4400 | } |
Stefan Sperling | c620b35 | 2018-12-18 17:23:36 +0100 | [diff] [blame] | 4401 | f_expect_clear(); |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 4402 | } |
| 4403 | |
| 4404 | testcase TC_cipher_complete_with_invalid_cipher() runs on MTC_CT { |
| 4405 | var BSC_ConnHdlr vc_conn; |
| 4406 | f_init(); |
| 4407 | f_vty_config(MSCVTY, "network", "encryption a5 1"); |
| 4408 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 4409 | vc_conn := f_start_handler(refers(f_tc_cipher_complete_with_invalid_cipher), 52, verify_cell_id := false); |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 4410 | vc_conn.done; |
| 4411 | } |
| 4412 | |
Harald Welte | b2284bd | 2019-05-10 11:30:43 +0200 | [diff] [blame] | 4413 | /* Location Update with invalid (non-matching) MCC/MNC reported on BSSMAP level from BSC */ |
| 4414 | friend function f_tc_lu_with_invalid_mcc_mnc(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4415 | f_init_handler(pars); |
| 4416 | |
| 4417 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 4418 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4419 | |
| 4420 | /* modify the cell ID which will be used to construct the COMPLELTE L3 or InitialUE */ |
| 4421 | g_pars.cell_id := valueof(ts_CellId_CGI('333'H, '22'H, 23, 42)); |
| 4422 | |
| 4423 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 4424 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 4425 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 79f1e45 | 2020-08-18 22:55:02 +0200 | [diff] [blame] | 4426 | f_expect_common_id(); |
Harald Welte | b2284bd | 2019-05-10 11:30:43 +0200 | [diff] [blame] | 4427 | |
| 4428 | /* Expect LU reject from MSC. */ |
| 4429 | alt { |
| 4430 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 4431 | setverdict(pass); |
| 4432 | } |
| 4433 | [] BSSAP.receive { |
| 4434 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 4435 | mtc.stop; |
| 4436 | } |
| 4437 | } |
Eric Wild | 85cc161 | 2022-03-30 01:44:29 +0200 | [diff] [blame] | 4438 | f_expect_clear(verify_vlr_cell_id:=false); |
Harald Welte | b2284bd | 2019-05-10 11:30:43 +0200 | [diff] [blame] | 4439 | } |
| 4440 | testcase TC_lu_with_invalid_mcc_mnc() runs on MTC_CT { |
| 4441 | var BSC_ConnHdlr vc_conn; |
| 4442 | f_init(); |
| 4443 | vc_conn := f_start_handler(refers(f_tc_lu_with_invalid_mcc_mnc), 54); |
| 4444 | vc_conn.done; |
| 4445 | } |
| 4446 | |
Stefan Sperling | a2d59c6 | 2018-12-18 16:32:44 +0100 | [diff] [blame] | 4447 | private function f_tc_cipher_complete_without_alg(charstring id, BSC_ConnHdlrPars pars, octetstring kc_support) runs on BSC_ConnHdlr { |
| 4448 | pars.net.expect_auth := true; |
| 4449 | pars.net.expect_ciph := true; |
| 4450 | pars.net.kc_support := kc_support; |
| 4451 | f_init_handler(pars); |
| 4452 | |
| 4453 | g_pars.vec := f_gen_auth_vec_2g(); |
| 4454 | |
| 4455 | /* Can't use f_perform_lu() directly. Code below is based on it. */ |
| 4456 | |
| 4457 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 4458 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4459 | |
| 4460 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 4461 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 4462 | f_cl3_or_initial_ue(l3_lu); |
| 4463 | |
| 4464 | f_mm_auth(); |
| 4465 | |
| 4466 | var OCT1 a5_net := f_alg_mask_from_cm(g_pars.cm2); |
| 4467 | var OCT1 a5_intersect := g_pars.net.kc_support and4b a5_net; |
| 4468 | alt { |
| 4469 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(a5_intersect, g_pars.vec.kc)) { |
| 4470 | BSSAP.send(ts_BSSMAP_CipherModeComplAlg(omit)); |
| 4471 | } |
| 4472 | [] BSSAP.receive(tr_BSSMAP_ClassmarkReq) { |
| 4473 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 4474 | repeat; |
| 4475 | } |
| 4476 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?, g_pars.vec.kc)) { |
| 4477 | setverdict(fail, "Wrong ciphering algorithm mask in CiphModCmd"); |
| 4478 | mtc.stop; |
| 4479 | } |
| 4480 | [] BSSAP.receive { |
| 4481 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 4482 | mtc.stop; |
| 4483 | } |
| 4484 | } |
Harald Welte | 79f1e45 | 2020-08-18 22:55:02 +0200 | [diff] [blame] | 4485 | f_expect_common_id(); |
Stefan Sperling | a2d59c6 | 2018-12-18 16:32:44 +0100 | [diff] [blame] | 4486 | |
| 4487 | /* TODO: Verify MSC is using the best cipher available! How? */ |
| 4488 | |
| 4489 | f_msc_lu_hlr(); |
Neels Hofmeyr | e860fc4 | 2022-10-05 01:15:54 +0200 | [diff] [blame] | 4490 | as_accept_reject_lu(); |
Stefan Sperling | a2d59c6 | 2018-12-18 16:32:44 +0100 | [diff] [blame] | 4491 | f_expect_clear(); |
| 4492 | setverdict(pass); |
| 4493 | } |
| 4494 | |
| 4495 | /* A5/1 only permitted on network side; attempt CIPHER MODE COMPLETE without specifying the accepted algorithm. */ |
| 4496 | private function f_tc_cipher_complete_1_without_cipher(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4497 | f_tc_cipher_complete_without_alg(id, pars, '02'O /* A5/1 only */); |
| 4498 | } |
| 4499 | |
| 4500 | /* A5/3 only permitted on network side; attempt CIPHER MODE COMPLETE without specifying the accepted algorithm. */ |
| 4501 | private function f_tc_cipher_complete_3_without_cipher(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4502 | f_tc_cipher_complete_without_alg(id, pars, '08'O /* A5/3 only */); |
| 4503 | } |
| 4504 | |
| 4505 | /* A5/1 + A5/3 permitted on network side; attempt CIPHER MODE COMPLETE without specifying the accepted algorithm. */ |
| 4506 | private function f_tc_cipher_complete_13_without_cipher(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4507 | f_tc_cipher_complete_without_alg(id, pars, '0A'O /* A5/1 and A5/3 enabled */); |
| 4508 | } |
| 4509 | |
| 4510 | testcase TC_cipher_complete_1_without_cipher() runs on MTC_CT { |
| 4511 | var BSC_ConnHdlr vc_conn; |
| 4512 | f_init(); |
| 4513 | f_vty_config(MSCVTY, "network", "encryption a5 1"); |
| 4514 | |
| 4515 | vc_conn := f_start_handler(refers(f_tc_cipher_complete_1_without_cipher), 53); |
| 4516 | vc_conn.done; |
| 4517 | } |
| 4518 | |
| 4519 | testcase TC_cipher_complete_3_without_cipher() runs on MTC_CT { |
| 4520 | var BSC_ConnHdlr vc_conn; |
| 4521 | f_init(); |
| 4522 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 4523 | |
| 4524 | vc_conn := f_start_handler(refers(f_tc_cipher_complete_3_without_cipher), 54); |
| 4525 | vc_conn.done; |
| 4526 | } |
| 4527 | |
| 4528 | testcase TC_cipher_complete_13_without_cipher() runs on MTC_CT { |
| 4529 | var BSC_ConnHdlr vc_conn; |
| 4530 | f_init(); |
| 4531 | f_vty_config(MSCVTY, "network", "encryption a5 1 3"); |
| 4532 | |
| 4533 | vc_conn := f_start_handler(refers(f_tc_cipher_complete_13_without_cipher), 55); |
| 4534 | vc_conn.done; |
| 4535 | } |
Harald Welte | b2284bd | 2019-05-10 11:30:43 +0200 | [diff] [blame] | 4536 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 4537 | /* TODO (SMS): |
| 4538 | * different user data lengths |
| 4539 | * SMPP transaction mode with unsuccessful delivery |
| 4540 | * queued MT-SMS with no paging response + later delivery |
| 4541 | * different data coding schemes |
| 4542 | * multi-part SMS |
| 4543 | * user-data headers |
| 4544 | * TP-PID for SMS to SIM |
| 4545 | * behavior if SMS memory is full + RP-SMMA |
| 4546 | * delivery reports |
| 4547 | * SMPP osmocom extensions |
| 4548 | * more-messages-to-send |
| 4549 | * SMS during ongoing call (SACCH/SAPI3) |
| 4550 | */ |
| 4551 | |
| 4552 | /* TODO (General): |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 4553 | * continue to send repeated MO signalling messages to keep channel open: does MSC tmeout? |
| 4554 | * malformed messages (missing IE, invalid message type): properly rejected? |
| 4555 | * MT call while LU or is ongoing: Do we use existing lchan or page while lchan active? |
| 4556 | * 3G/2G auth permutations |
| 4557 | * encryption algorithms vs. classmark vs. vty config |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 4558 | * send new transaction after/during clear (like SMS, ...) |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 4559 | * too long L3 INFO in DTAP |
| 4560 | * too long / padded BSSAP |
| 4561 | * too long / short TLV values |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 4562 | */ |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 4563 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 4564 | /*********************************************************************** |
| 4565 | * SGsAP Testing |
| 4566 | ***********************************************************************/ |
| 4567 | |
Philipp Maier | 948747b | 2019-04-02 15:22:33 +0200 | [diff] [blame] | 4568 | /* Check if a subscriber exists in the VLR */ |
| 4569 | private function f_ctrl_subscr_in_vlr(charstring imsi_or_msisdn) runs on BSC_ConnHdlr return boolean { |
| 4570 | |
| 4571 | var CtrlValue active_subsribers; |
| 4572 | var integer rc; |
| 4573 | active_subsribers := f_ctrl_get(IPA_CTRL, "subscriber-list-active-v1"); |
| 4574 | |
| 4575 | rc := f_strstr(active_subsribers, imsi_or_msisdn); |
| 4576 | if (rc < 0) { |
| 4577 | return false; |
| 4578 | } |
| 4579 | |
| 4580 | return true; |
| 4581 | } |
| 4582 | |
Pau Espin Pedrol | cefe9da | 2021-07-02 18:38:27 +0200 | [diff] [blame] | 4583 | /* Perform a Location Update at the A-Interface and run some checks to confirm |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4584 | * that everything is back to normal. */ |
| 4585 | private function f_sgsap_bssmap_screening() runs on BSC_ConnHdlr { |
| 4586 | var SmsParameters spars := valueof(t_SmsPars); |
| 4587 | |
Pau Espin Pedrol | 7593a8a | 2021-07-02 18:55:16 +0200 | [diff] [blame] | 4588 | /* From now on, since we initiated LU from A-Interface, we expect no |
| 4589 | * LastEutranPLMNId on Common Id, since the SGs interface should be gone |
| 4590 | */ |
| 4591 | g_pars.common_id_last_eutran_plmn := omit; |
| 4592 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4593 | /* Perform a location update, the SGs association is expected to fall |
| 4594 | * back to NULL */ |
| 4595 | f_perform_lu(); |
| 4596 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4597 | |
| 4598 | /* Trigger a paging request and expect the paging on BSSMAP, this is |
| 4599 | * to make sure that pagings are sent throught the A-Interface again |
| 4600 | * and not throught the SGs interface.*/ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 4601 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4602 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 4603 | |
| 4604 | alt { |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 4605 | [g_pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)); { |
| 4606 | setverdict(pass); |
| 4607 | } |
Harald Welte | 62113fc | 2019-05-09 13:04:02 +0200 | [diff] [blame] | 4608 | [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] | 4609 | setverdict(pass); |
| 4610 | } |
| 4611 | [] SGsAP.receive { |
| 4612 | setverdict(fail, "Received unexpected message on SGs"); |
| 4613 | } |
| 4614 | } |
| 4615 | |
| 4616 | /* Send an SMS to make sure that also payload messages are routed |
| 4617 | * throught the A-Interface again */ |
| 4618 | f_establish_fully(EST_TYPE_MO_SMS); |
| 4619 | f_mo_sms(spars); |
| 4620 | f_expect_clear(); |
| 4621 | } |
| 4622 | |
| 4623 | private function f_tc_sgsap_reset(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4624 | var charstring vlr_name; |
| 4625 | f_init_handler(pars); |
| 4626 | |
| 4627 | vlr_name := f_sgsap_reset_mme(mp_mme_name); |
| 4628 | log("VLR name: ", vlr_name); |
| 4629 | setverdict(pass); |
Neels Hofmeyr | c0b520d | 2019-03-06 15:35:50 +0100 | [diff] [blame] | 4630 | f_sleep(1.0); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4631 | } |
| 4632 | |
| 4633 | testcase TC_sgsap_reset() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4634 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4635 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4636 | f_init(1, true); |
| 4637 | pars := f_init_pars(11810, true); |
| 4638 | 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] | 4639 | vc_conn.done; |
| 4640 | } |
| 4641 | |
| 4642 | /* like f_mm_auth() but for SGs */ |
| 4643 | function f_mm_auth_sgs() runs on BSC_ConnHdlr { |
| 4644 | if (g_pars.net.expect_auth) { |
| 4645 | g_pars.vec := f_gen_auth_vec_3g(); |
| 4646 | var GSUP_IE auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G3G(g_pars.vec.rand, |
| 4647 | g_pars.vec.sres, |
| 4648 | g_pars.vec.kc, |
| 4649 | g_pars.vec.ik, |
| 4650 | g_pars.vec.ck, |
| 4651 | g_pars.vec.autn, |
| 4652 | g_pars.vec.res)); |
| 4653 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 4654 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
| 4655 | SGsAP.receive(tr_ML3_MT_MM_AUTH_REQ_3G(g_pars.vec.rand, g_pars.vec.autn)); |
| 4656 | SGsAP.send(ts_ML3_MT_MM_AUTH_RESP_3G(g_pars.vec.sres, g_pars.vec.res)); |
| 4657 | } |
| 4658 | } |
| 4659 | |
| 4660 | /* like f_perform_lu(), but on SGs rather than BSSAP */ |
| 4661 | function f_sgs_perform_lu() runs on BSC_ConnHdlr { |
| 4662 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4663 | var PDU_SGsAP lur; |
| 4664 | var PDU_SGsAP lua; |
| 4665 | var PDU_SGsAP mm_info; |
| 4666 | var octetstring mm_info_dtap; |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4667 | var GsmMcc mcc; |
| 4668 | var GsmMnc mnc; |
| 4669 | var template (omit) TrackingAreaIdentityValue tai := omit; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4670 | |
| 4671 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 4672 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4673 | if (g_pars.common_id_last_eutran_plmn != omit) { |
| 4674 | f_dec_mcc_mnc(g_pars.common_id_last_eutran_plmn, mcc, mnc); |
| 4675 | tai := ts_SGsAP_TAI(mcc, mnc, 555); |
| 4676 | } |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4677 | lur := valueof(ts_SGsAP_LU_REQ(g_pars.imsi, mme_name, IMSI_attach, |
Pau Espin Pedrol | 3768a6f | 2021-04-28 14:24:23 +0200 | [diff] [blame] | 4678 | ts_SGsAP_LAI('901'H, '70'H, 2342), |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4679 | tai)); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4680 | /* Old LAI, if MS sends it */ |
| 4681 | /* TMSI status, if MS has no valid TMSI */ |
| 4682 | /* IMEISV, if it supports "automatic device detection" */ |
| 4683 | /* TAI, if available in MME */ |
| 4684 | /* E-CGI, if available in MME */ |
| 4685 | SGsAP.send(lur); |
| 4686 | |
| 4687 | /* FIXME: is this really done over SGs? The Ue is already authenticated |
| 4688 | * via the MME ... */ |
| 4689 | f_mm_auth_sgs(); |
| 4690 | |
| 4691 | /* Expect MSC to perform LU with HLR */ |
| 4692 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 4693 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 4694 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 4695 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 4696 | |
| 4697 | alt { |
| 4698 | [] SGsAP.receive(tr_SGsAP_LU_ACCEPT(g_pars.imsi, ?)) -> value lua { |
| 4699 | if (isvalue(lua.sGsAP_LOCATION_UPDATE_ACCEPT.newTMSIorIMSI.iD.iD.tmsi_ptmsi.octets)) { |
| 4700 | g_pars.tmsi :=lua.sGsAP_LOCATION_UPDATE_ACCEPT.newTMSIorIMSI.iD.iD.tmsi_ptmsi.octets |
| 4701 | SGsAP.send(ts_SGsAP_TMSI_REALL_CMPL(g_pars.imsi)); |
| 4702 | } |
| 4703 | setverdict(pass); |
| 4704 | } |
| 4705 | [] SGsAP.receive(tr_SGsAP_LU_REJECT(g_pars.imsi, ?, ?)) { |
| 4706 | setverdict(fail, "Received LU-REJECT instead of ACCEPT"); |
| 4707 | } |
| 4708 | [] SGsAP.receive { |
| 4709 | setverdict(fail, "Received unexpected message on SGs"); |
| 4710 | } |
| 4711 | } |
| 4712 | |
| 4713 | /* Check MM information */ |
| 4714 | if (mp_mm_info == true) { |
| 4715 | SGsAP.receive(tr_SGsAP_MM_INFO_REQ(g_pars.imsi, ?)) -> value mm_info; |
| 4716 | mm_info_dtap := '0532'O & mm_info.sGsAP_MM_INFORMATION_REQUEST.mM_Information.information; |
| 4717 | if (not match(dec_PDU_ML3_NW_MS(mm_info_dtap), tr_ML3_MT_MM_Info)) { |
| 4718 | setverdict(fail, "Unexpected MM Information"); |
| 4719 | } |
| 4720 | } |
| 4721 | |
| 4722 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4723 | } |
| 4724 | |
| 4725 | private function f_tc_sgsap_lu(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4726 | f_init_handler(pars); |
| 4727 | f_sgs_perform_lu(); |
| 4728 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4729 | |
| 4730 | f_sgsap_bssmap_screening(); |
| 4731 | |
| 4732 | setverdict(pass); |
| 4733 | } |
| 4734 | testcase TC_sgsap_lu() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4735 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4736 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4737 | f_init(1, true); |
| 4738 | pars := f_init_pars(11811, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4739 | pars.common_id_last_eutran_plmn := f_enc_mcc_mnc('901'H, '70'H); |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4740 | 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] | 4741 | vc_conn.done; |
| 4742 | } |
| 4743 | |
| 4744 | /* Do LU by IMSI, refuse it on GSUP and expect LU REJ back to MS */ |
| 4745 | private function f_tc_sgsap_lu_imsi_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4746 | f_init_handler(pars); |
| 4747 | var PDU_SGsAP lur; |
| 4748 | |
| 4749 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4750 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4751 | lur := valueof(ts_SGsAP_LU_REQ(g_pars.imsi, mme_name, IMSI_attach, |
| 4752 | ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4753 | SGsAP.send(lur); |
| 4754 | |
| 4755 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 4756 | GSUP.send(ts_GSUP_UL_ERR(g_pars.imsi, 23)); |
| 4757 | alt { |
| 4758 | [] SGsAP.receive(tr_SGsAP_LU_REJECT(g_pars.imsi, ?, ?)) { |
| 4759 | setverdict(pass); |
| 4760 | } |
| 4761 | [] SGsAP.receive(tr_SGsAP_LU_ACCEPT(g_pars.imsi, ?)) { |
| 4762 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
| 4763 | mtc.stop; |
| 4764 | } |
| 4765 | [] SGsAP.receive { |
| 4766 | setverdict(fail, "Received unexpected message on SGs"); |
| 4767 | } |
| 4768 | } |
| 4769 | |
| 4770 | f_sgsap_bssmap_screening(); |
| 4771 | |
| 4772 | setverdict(pass); |
| 4773 | } |
| 4774 | testcase TC_sgsap_lu_imsi_reject() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4775 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4776 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4777 | f_init(1, true); |
| 4778 | pars := f_init_pars(11812, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4779 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4780 | 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] | 4781 | vc_conn.done; |
| 4782 | } |
| 4783 | |
| 4784 | /* Do LU by IMSI, but then remain silent so that Ts6-1 times out */ |
| 4785 | private function f_tc_sgsap_lu_and_nothing(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4786 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4787 | var PDU_SGsAP lur; |
| 4788 | |
| 4789 | f_init_handler(pars); |
| 4790 | |
| 4791 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 4792 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4793 | |
| 4794 | lur := valueof(ts_SGsAP_LU_REQ(g_pars.imsi, mme_name, IMSI_attach, |
| 4795 | ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4796 | /* Old LAI, if MS sends it */ |
| 4797 | /* TMSI status, if MS has no valid TMSI */ |
| 4798 | /* IMEISV, if it supports "automatic device detection" */ |
| 4799 | /* TAI, if available in MME */ |
| 4800 | /* E-CGI, if available in MME */ |
| 4801 | SGsAP.send(lur); |
| 4802 | |
| 4803 | /* FIXME: is this really done over SGs? The Ue is already authenticated |
| 4804 | * via the MME ... */ |
| 4805 | f_mm_auth_sgs(); |
| 4806 | |
| 4807 | /* Expect MSC to perform LU with HLR */ |
| 4808 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 4809 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 4810 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 4811 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 4812 | |
| 4813 | alt { |
| 4814 | [] SGsAP.receive(tr_SGsAP_LU_ACCEPT(g_pars.imsi, ?)) { |
| 4815 | setverdict(pass); |
| 4816 | } |
| 4817 | [] SGsAP.receive(tr_SGsAP_LU_REJECT(g_pars.imsi, ?, ?)) { |
| 4818 | setverdict(fail, "Received LU-REJECT instead of ACCEPT"); |
| 4819 | } |
| 4820 | [] SGsAP.receive { |
| 4821 | setverdict(fail, "Received unexpected message on SGs"); |
| 4822 | } |
| 4823 | } |
| 4824 | |
| 4825 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4826 | |
| 4827 | /* Wait until the VLR has abort the TMSI reallocation procedure */ |
| 4828 | f_sleep(45.0); |
| 4829 | |
| 4830 | /* The outcome does not change the SGs state, see also 5.2.3.4 */ |
| 4831 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4832 | |
| 4833 | f_sgsap_bssmap_screening(); |
| 4834 | |
| 4835 | setverdict(pass); |
| 4836 | } |
| 4837 | testcase TC_sgsap_lu_and_nothing() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4838 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4839 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4840 | f_init(1, true); |
| 4841 | pars := f_init_pars(11813, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4842 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4843 | 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] | 4844 | vc_conn.done; |
| 4845 | } |
| 4846 | |
| 4847 | private function f_tc_sgsap_expl_imsi_det_eps(charstring id, BSC_ConnHdlrPars pars) |
| 4848 | runs on BSC_ConnHdlr { |
| 4849 | f_init_handler(pars); |
| 4850 | f_sgs_perform_lu(); |
| 4851 | f_sleep(3.0); |
| 4852 | |
| 4853 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4854 | SGsAP.send(ts_SGsAP_EPS_DETACH_IND(g_pars.imsi, mme_name, UE_initiated)); |
| 4855 | SGsAP.receive(tr_SGsAP_EPS_DETACH_ACK(g_pars.imsi)); |
| 4856 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4857 | |
| 4858 | f_sgsap_bssmap_screening(); |
| 4859 | |
| 4860 | setverdict(pass); |
| 4861 | } |
| 4862 | testcase TC_sgsap_expl_imsi_det_eps() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4863 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4864 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4865 | f_init(1, true); |
| 4866 | pars := f_init_pars(11814, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4867 | pars.common_id_last_eutran_plmn := f_enc_mcc_mnc('901'H, '70'H); |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4868 | 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] | 4869 | vc_conn.done; |
| 4870 | } |
| 4871 | |
Philipp Maier | fc19f17 | 2019-03-21 11:17:54 +0100 | [diff] [blame] | 4872 | private function f_tc_sgsap_impl_imsi_det_eps(charstring id, BSC_ConnHdlrPars pars) |
| 4873 | runs on BSC_ConnHdlr { |
| 4874 | f_init_handler(pars); |
| 4875 | f_sgs_perform_lu(); |
| 4876 | f_sleep(3.0); |
| 4877 | |
| 4878 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4879 | SGsAP.send(ts_SGsAP_EPS_DETACH_IND(g_pars.imsi, mme_name, network_initiated)); |
| 4880 | SGsAP.receive(tr_SGsAP_EPS_DETACH_ACK(g_pars.imsi)); |
| 4881 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4882 | |
| 4883 | f_sgsap_bssmap_screening(); |
| 4884 | |
| 4885 | setverdict(pass); |
| 4886 | } |
| 4887 | testcase TC_sgsap_impl_imsi_det_eps() runs on MTC_CT { |
| 4888 | var BSC_ConnHdlrPars pars; |
| 4889 | var BSC_ConnHdlr vc_conn; |
| 4890 | f_init(1, true); |
| 4891 | pars := f_init_pars(11814, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4892 | pars.common_id_last_eutran_plmn := f_enc_mcc_mnc('901'H, '70'H); |
Philipp Maier | fc19f17 | 2019-03-21 11:17:54 +0100 | [diff] [blame] | 4893 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_impl_imsi_det_eps), pars); |
| 4894 | vc_conn.done; |
| 4895 | } |
| 4896 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4897 | private function f_tc_sgsap_expl_imsi_det_noneps(charstring id, BSC_ConnHdlrPars pars) |
| 4898 | runs on BSC_ConnHdlr { |
| 4899 | f_init_handler(pars); |
| 4900 | f_sgs_perform_lu(); |
| 4901 | f_sleep(3.0); |
| 4902 | |
| 4903 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4904 | SGsAP.send(ts_SGsAP_IMSI_DETACH_IND(g_pars.imsi, mme_name, combined_UE_initiated)); |
| 4905 | SGsAP.receive(tr_SGsAP_IMSI_DETACH_ACK(g_pars.imsi)); |
Philipp Maier | d08e7e7 | 2019-04-02 15:27:10 +0200 | [diff] [blame] | 4906 | |
| 4907 | if (f_ctrl_subscr_in_vlr(hex2str(g_pars.imsi))) { |
| 4908 | setverdict(fail, "subscriber not removed from VLR"); |
| 4909 | } |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4910 | |
| 4911 | f_sgsap_bssmap_screening(); |
| 4912 | |
| 4913 | setverdict(pass); |
| 4914 | } |
| 4915 | testcase TC_sgsap_expl_imsi_det_noneps() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4916 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4917 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4918 | f_init(1, true); |
| 4919 | pars := f_init_pars(11815, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4920 | pars.common_id_last_eutran_plmn := f_enc_mcc_mnc('901'H, '70'H); |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4921 | 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] | 4922 | vc_conn.done; |
| 4923 | } |
| 4924 | |
Philipp Maier | 5d81270 | 2019-03-21 10:51:26 +0100 | [diff] [blame] | 4925 | private function f_tc_sgsap_impl_imsi_det_noneps(charstring id, BSC_ConnHdlrPars pars) |
| 4926 | runs on BSC_ConnHdlr { |
| 4927 | f_init_handler(pars); |
| 4928 | f_sgs_perform_lu(); |
| 4929 | f_sleep(3.0); |
| 4930 | |
| 4931 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4932 | SGsAP.send(ts_SGsAP_IMSI_DETACH_IND(g_pars.imsi, mme_name, implicit_network_initiated)); |
| 4933 | SGsAP.receive(tr_SGsAP_IMSI_DETACH_ACK(g_pars.imsi)); |
| 4934 | |
| 4935 | if (f_ctrl_subscr_in_vlr(hex2str(g_pars.imsi))) { |
| 4936 | setverdict(fail, "subscriber not removed from VLR"); |
| 4937 | } |
| 4938 | |
| 4939 | f_sgsap_bssmap_screening(); |
| 4940 | |
| 4941 | setverdict(pass); |
| 4942 | } |
| 4943 | testcase TC_sgsap_impl_imsi_det_noneps() runs on MTC_CT { |
| 4944 | var BSC_ConnHdlrPars pars; |
| 4945 | var BSC_ConnHdlr vc_conn; |
| 4946 | f_init(1, true); |
| 4947 | pars := f_init_pars(11815, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4948 | pars.common_id_last_eutran_plmn := f_enc_mcc_mnc('901'H, '70'H); |
Philipp Maier | 5d81270 | 2019-03-21 10:51:26 +0100 | [diff] [blame] | 4949 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_impl_imsi_det_noneps), pars); |
| 4950 | vc_conn.done; |
| 4951 | } |
| 4952 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4953 | /* Trigger a paging request via VTY and send a paging reject in response */ |
| 4954 | private function f_tc_sgsap_paging_rej(charstring id, BSC_ConnHdlrPars pars) |
| 4955 | runs on BSC_ConnHdlr { |
| 4956 | f_init_handler(pars); |
| 4957 | f_sgs_perform_lu(); |
| 4958 | f_sleep(1.0); |
| 4959 | |
| 4960 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4961 | var template PDU_SGsAP exp_resp := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, CS_call_indicator, omit); |
| 4962 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4963 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 4964 | |
| 4965 | /* Initiate paging via VTY */ |
| 4966 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 4967 | alt { |
| 4968 | [] SGsAP.receive(exp_resp) { |
| 4969 | setverdict(pass); |
| 4970 | } |
| 4971 | [] SGsAP.receive { |
| 4972 | setverdict(fail, "Received unexpected message on SGs"); |
| 4973 | } |
| 4974 | } |
| 4975 | |
| 4976 | /* Now reject the paging */ |
| 4977 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, IMSI_unknown)); |
| 4978 | |
| 4979 | /* Wait for the states inside the MSC to settle and check the state |
| 4980 | * of the SGs Association */ |
| 4981 | f_sleep(1.0); |
| 4982 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4983 | |
| 4984 | /* FIXME: At the moment we send an IMSI_unknown as cause code, which is fine, |
| 4985 | * but we also need to cover tha case where the cause code indicates an |
| 4986 | * "IMSI detached for EPS services". In those cases the VLR is expected to |
| 4987 | * try paging on tha A/Iu interface. This will be another testcase similar to |
| 4988 | * this one, but extended with checks for the presence of the A/Iu paging |
| 4989 | * messages. */ |
| 4990 | |
| 4991 | f_sgsap_bssmap_screening(); |
| 4992 | |
| 4993 | setverdict(pass); |
| 4994 | } |
| 4995 | testcase TC_sgsap_paging_rej() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4996 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4997 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4998 | f_init(1, true); |
| 4999 | pars := f_init_pars(11816, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5000 | pars.common_id_last_eutran_plmn := f_enc_mcc_mnc('901'H, '70'H); |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5001 | 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] | 5002 | vc_conn.done; |
| 5003 | } |
| 5004 | |
| 5005 | /* Trigger a paging request via VTY and send a paging reject that indicates |
| 5006 | * that the subscriber intentionally rejected the call. */ |
| 5007 | private function f_tc_sgsap_paging_subscr_rej(charstring id, BSC_ConnHdlrPars pars) |
| 5008 | runs on BSC_ConnHdlr { |
| 5009 | f_init_handler(pars); |
| 5010 | f_sgs_perform_lu(); |
| 5011 | f_sleep(1.0); |
| 5012 | |
| 5013 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5014 | var template PDU_SGsAP exp_resp := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, CS_call_indicator, omit); |
| 5015 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5016 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 5017 | |
| 5018 | /* Initiate paging via VTY */ |
| 5019 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 5020 | alt { |
| 5021 | [] SGsAP.receive(exp_resp) { |
| 5022 | setverdict(pass); |
| 5023 | } |
| 5024 | [] SGsAP.receive { |
| 5025 | setverdict(fail, "Received unexpected message on SGs"); |
| 5026 | } |
| 5027 | } |
| 5028 | |
| 5029 | /* Now reject the paging */ |
| 5030 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, user_rejected_mobile_terminating_CS_fallback_call)); |
| 5031 | |
| 5032 | /* Wait for the states inside the MSC to settle and check the state |
| 5033 | * of the SGs Association */ |
| 5034 | f_sleep(1.0); |
| 5035 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5036 | |
| 5037 | /* FIXME: The VLR is supposed to trigger an User Determined User Busy (UDUB) as specified |
| 5038 | * in 3GPP TS 24.082, this is not yet implemented in the MSC or in this tests, we need |
| 5039 | * to check back how this works and how it can be tested */ |
| 5040 | |
| 5041 | f_sgsap_bssmap_screening(); |
| 5042 | |
| 5043 | setverdict(pass); |
| 5044 | } |
| 5045 | testcase TC_sgsap_paging_subscr_rej() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5046 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5047 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5048 | f_init(1, true); |
| 5049 | pars := f_init_pars(11817, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5050 | pars.common_id_last_eutran_plmn := f_enc_mcc_mnc('901'H, '70'H); |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5051 | 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] | 5052 | vc_conn.done; |
| 5053 | } |
| 5054 | |
| 5055 | /* Trigger a paging request via VTY and send an UE unreacable messge in response */ |
| 5056 | private function f_tc_sgsap_paging_ue_unr(charstring id, BSC_ConnHdlrPars pars) |
| 5057 | runs on BSC_ConnHdlr { |
| 5058 | f_init_handler(pars); |
| 5059 | f_sgs_perform_lu(); |
| 5060 | f_sleep(1.0); |
| 5061 | |
| 5062 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5063 | var template PDU_SGsAP exp_resp := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, CS_call_indicator, omit); |
| 5064 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5065 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 5066 | |
| 5067 | /* Initiate paging via VTY */ |
| 5068 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 5069 | alt { |
| 5070 | [] SGsAP.receive(exp_resp) { |
| 5071 | setverdict(pass); |
| 5072 | } |
| 5073 | [] SGsAP.receive { |
| 5074 | setverdict(fail, "Received unexpected message on SGs"); |
| 5075 | } |
| 5076 | } |
| 5077 | |
| 5078 | /* Now pretend that the UE is unreachable */ |
| 5079 | SGsAP.send(ts_SGsAP_UE_UNREACHABLE(g_pars.imsi, UE_unreachable)); |
| 5080 | |
| 5081 | /* Wait for the states inside the MSC to settle and check the state |
| 5082 | * of the SGs Association. */ |
| 5083 | f_sleep(1.0); |
| 5084 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5085 | |
| 5086 | f_sgsap_bssmap_screening(); |
| 5087 | |
| 5088 | setverdict(pass); |
| 5089 | } |
| 5090 | testcase TC_sgsap_paging_ue_unr() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5091 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5092 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5093 | f_init(1, true); |
| 5094 | pars := f_init_pars(11818, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5095 | pars.common_id_last_eutran_plmn := f_enc_mcc_mnc('901'H, '70'H); |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5096 | 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] | 5097 | vc_conn.done; |
| 5098 | } |
| 5099 | |
| 5100 | /* Trigger a paging request via VTY but don't respond to it */ |
| 5101 | private function f_tc_sgsap_paging_and_nothing(charstring id, BSC_ConnHdlrPars pars) |
| 5102 | runs on BSC_ConnHdlr { |
| 5103 | f_init_handler(pars); |
| 5104 | f_sgs_perform_lu(); |
| 5105 | f_sleep(1.0); |
| 5106 | |
| 5107 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5108 | 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] | 5109 | 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] | 5110 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5111 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 5112 | |
| 5113 | /* Initiate paging via VTY */ |
| 5114 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 5115 | alt { |
| 5116 | [] SGsAP.receive(exp_resp) { |
| 5117 | setverdict(pass); |
| 5118 | } |
| 5119 | [] SGsAP.receive { |
| 5120 | setverdict(fail, "Received unexpected message on SGs"); |
| 5121 | } |
| 5122 | } |
| 5123 | |
Philipp Maier | 3421810 | 2019-09-24 09:15:49 +0200 | [diff] [blame] | 5124 | /* While we are doing nothing, expect an SGsAP-SERVICE-ABORT-REQUEST |
| 5125 | * after some time */ |
| 5126 | timer T := 10.0; |
| 5127 | T.start |
| 5128 | alt { |
| 5129 | [] SGsAP.receive(exp_serv_abrt) |
| 5130 | { |
| 5131 | setverdict(pass); |
| 5132 | } |
| 5133 | [] SGsAP.receive { |
| 5134 | setverdict(fail, "unexpected SGsAP message received"); |
| 5135 | self.stop; |
| 5136 | } |
| 5137 | [] T.timeout { |
| 5138 | setverdict(fail, "MSC did not send SGsAP-SERVICE-ABORT-REQUEST"); |
| 5139 | self.stop; |
| 5140 | } |
| 5141 | } |
| 5142 | |
| 5143 | /* The SGs association must remain unchanged. */ |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5144 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5145 | |
| 5146 | f_sgsap_bssmap_screening(); |
| 5147 | |
| 5148 | setverdict(pass); |
| 5149 | } |
| 5150 | testcase TC_sgsap_paging_and_nothing() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5151 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5152 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5153 | f_init(1, true); |
| 5154 | pars := f_init_pars(11819, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5155 | pars.common_id_last_eutran_plmn := f_enc_mcc_mnc('901'H, '70'H); |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5156 | 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] | 5157 | vc_conn.done; |
| 5158 | } |
| 5159 | |
| 5160 | /* Trigger a paging request via VTY and slip in an LU */ |
| 5161 | private function f_tc_sgsap_paging_and_lu(charstring id, BSC_ConnHdlrPars pars) |
| 5162 | runs on BSC_ConnHdlr { |
| 5163 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5164 | f_init_handler(pars); |
| 5165 | |
| 5166 | /* First we prepar the situation, where the SGs association is in state |
| 5167 | * NULL and the confirmed by radio contact indicator is set to false |
| 5168 | * as well. This can be archived by performing an SGs LU and then |
| 5169 | * resetting the VLR */ |
| 5170 | f_sgs_perform_lu(); |
| 5171 | f_sgsap_reset_mme(mp_mme_name); |
| 5172 | f_sleep(1.0); |
| 5173 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 5174 | |
| 5175 | /* Perform a paging, expect the paging messages on the SGs interface */ |
| 5176 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 5177 | alt { |
| 5178 | [] SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)) { |
| 5179 | setverdict(pass); |
| 5180 | } |
| 5181 | [] SGsAP.receive { |
| 5182 | setverdict(fail, "Received unexpected message on SGs"); |
| 5183 | } |
| 5184 | } |
| 5185 | |
| 5186 | /* Perform the LU as normal */ |
| 5187 | f_sgs_perform_lu(); |
| 5188 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5189 | |
| 5190 | /* Expect a new paging request right after the LU */ |
| 5191 | alt { |
| 5192 | [] SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)) { |
| 5193 | setverdict(pass); |
| 5194 | } |
| 5195 | [] SGsAP.receive { |
| 5196 | setverdict(fail, "Received unexpected message on SGs"); |
| 5197 | } |
| 5198 | } |
| 5199 | |
| 5200 | /* Test is done now, lets round everything up by rejecting the paging |
| 5201 | * cleanly. */ |
| 5202 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, user_rejected_mobile_terminating_CS_fallback_call)); |
| 5203 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5204 | |
| 5205 | f_sgsap_bssmap_screening(); |
| 5206 | |
| 5207 | setverdict(pass); |
| 5208 | } |
| 5209 | testcase TC_sgsap_paging_and_lu() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5210 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5211 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5212 | f_init(1, true); |
| 5213 | pars := f_init_pars(11820, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5214 | pars.common_id_last_eutran_plmn := f_enc_mcc_mnc('901'H, '70'H); |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5215 | 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] | 5216 | vc_conn.done; |
| 5217 | } |
| 5218 | |
| 5219 | /* Send unexpected unit-data through the SGs interface */ |
| 5220 | private function f_tc_sgsap_unexp_ud(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5221 | f_init_handler(pars); |
| 5222 | f_sleep(1.0); |
| 5223 | |
| 5224 | /* This simulates what happens when a subscriber without SGs |
| 5225 | * association gets unitdata via the SGs interface. */ |
| 5226 | |
| 5227 | /* Make sure the subscriber exists and the SGs association |
| 5228 | * is in NULL state */ |
| 5229 | f_perform_lu(); |
| 5230 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 5231 | |
| 5232 | /* Send some random unit data, the MSC/VLR should send a release |
| 5233 | * immediately. */ |
| 5234 | SGsAP.send(ts_SGsAP_UL_UD(pars.imsi,'1234'O)); |
| 5235 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, IMSI_detached_for_EPS_nonEPS_services)); |
| 5236 | |
| 5237 | f_sgsap_bssmap_screening(); |
| 5238 | |
| 5239 | setverdict(pass); |
| 5240 | } |
| 5241 | testcase TC_sgsap_unexp_ud() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5242 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5243 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5244 | f_init(1, true); |
| 5245 | pars := f_init_pars(11821, true); |
| 5246 | 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] | 5247 | vc_conn.done; |
| 5248 | } |
| 5249 | |
| 5250 | /* Send unsolicited unit-data through the SGs interface */ |
| 5251 | private function f_tc_sgsap_unsol_ud(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5252 | f_init_handler(pars); |
| 5253 | f_sleep(1.0); |
| 5254 | |
| 5255 | /* This simulates what happens when the MME attempts to send unitdata |
| 5256 | * to a subscriber that is completely unknown to the VLR */ |
| 5257 | |
| 5258 | /* Send some random unit data, the MSC/VLR should send a release |
| 5259 | * immediately. */ |
| 5260 | SGsAP.send(ts_SGsAP_UL_UD(pars.imsi,'1234'O)); |
| 5261 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, IMSI_unknown)); |
| 5262 | |
| 5263 | f_sgsap_bssmap_screening(); |
| 5264 | |
Harald Welte | 4d15fa7 | 2020-08-19 08:58:28 +0200 | [diff] [blame] | 5265 | /* clean-up VLR state about this subscriber */ |
| 5266 | f_imsi_detach_by_imsi(); |
| 5267 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5268 | setverdict(pass); |
| 5269 | } |
| 5270 | testcase TC_sgsap_unsol_ud() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5271 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5272 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5273 | f_init(1, true); |
| 5274 | pars := f_init_pars(11822, true); |
| 5275 | 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] | 5276 | vc_conn.done; |
| 5277 | } |
| 5278 | |
| 5279 | private altstep as_other_sms_sgs() runs on BSC_ConnHdlr { |
| 5280 | /* FIXME: Match an actual payload (second questionmark), the type is |
| 5281 | * octetstring, how do we use a tr_PDU_DTAP_MT here? */ |
| 5282 | [] SGsAP.receive(tr_SGsAP_DL_UD(?,?)) { |
| 5283 | setverdict(fail, "Unexpected SMS related PDU from MSC"); |
| 5284 | mtc.stop; |
| 5285 | } |
| 5286 | } |
| 5287 | |
| 5288 | /* receive a MT-SMS delivered from the MSC/SMSC over an already existing SGsAP connection */ |
| 5289 | function f_mt_sms_sgs(inout SmsParameters spars) |
| 5290 | runs on BSC_ConnHdlr { |
| 5291 | var template (value) TPDU_RP_DATA_MS_SGSN tp_mo; |
| 5292 | var template (value) RPDU_MS_SGSN rp_mo; |
| 5293 | var template (value) PDU_ML3_MS_NW l3_mo; |
| 5294 | |
| 5295 | var template TPDU_RP_DATA_SGSN_MS tp_mt; |
| 5296 | var template RPDU_SGSN_MS rp_mt; |
| 5297 | var template PDU_ML3_NW_MS l3_mt; |
| 5298 | |
| 5299 | var PDU_ML3_NW_MS sgsap_l3_mt; |
| 5300 | |
| 5301 | var default d := activate(as_other_sms_sgs()); |
| 5302 | |
| 5303 | /* Expect CP-DATA(RP-DATA(SMS-DELIVER)) */ |
| 5304 | 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] | 5305 | 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] | 5306 | l3_mt := tr_ML3_MT_SMS(?, c_TIF_ORIG, tr_CP_DATA_MT(rp_mt)); |
| 5307 | |
| 5308 | SGsAP.receive(l3_mt) -> value sgsap_l3_mt; |
| 5309 | |
| 5310 | /* Extract relevant identifiers */ |
| 5311 | spars.tid := bit2int(sgsap_l3_mt.tiOrSkip.transactionId.tio); |
| 5312 | spars.rp.msg_ref := sgsap_l3_mt.msgs.sms.cP_DATA.cP_User_Data.cP_RPDU.rP_DATA_SGSN_MS.rP_MessageReference; |
| 5313 | |
| 5314 | /* send CP-ACK for CP-DATA just received */ |
| 5315 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_REPL, ts_CP_ACK_MO); |
| 5316 | |
| 5317 | SGsAP.send(l3_mo); |
| 5318 | |
| 5319 | /* send RP-ACK for RP-DATA */ |
| 5320 | rp_mo := ts_RP_ACK_MO(spars.rp.msg_ref); |
| 5321 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_REPL, ts_CP_DATA_MO(rp_mo)); |
| 5322 | |
| 5323 | SGsAP.send(l3_mo); |
| 5324 | |
| 5325 | /* expect CP-ACK for CP-DATA(RP-ACK) just sent */ |
| 5326 | l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_ORIG, tr_CP_ACK_MT); |
| 5327 | |
| 5328 | SGsAP.receive(l3_mt); |
| 5329 | |
| 5330 | deactivate(d); |
| 5331 | |
| 5332 | setverdict(pass); |
| 5333 | } |
| 5334 | |
| 5335 | /* submit a MO-SMS to MSC/SMSC over an already existing SGsAP connection */ |
| 5336 | function f_mo_sms_sgs(inout SmsParameters spars) |
| 5337 | runs on BSC_ConnHdlr { |
| 5338 | var template (value) TPDU_RP_DATA_MS_SGSN tp_mo; |
| 5339 | var template (value) RPDU_MS_SGSN rp_mo; |
| 5340 | var template (value) PDU_ML3_MS_NW l3_mo; |
| 5341 | |
| 5342 | var template TPDU_RP_DATA_SGSN_MS tp_mt; |
| 5343 | var template RPDU_SGSN_MS rp_mt; |
| 5344 | var template PDU_ML3_NW_MS l3_mt; |
| 5345 | |
| 5346 | var default d := activate(as_other_sms_sgs()); |
| 5347 | |
| 5348 | /* just in case this is routed to SMPP.. */ |
| 5349 | f_create_smpp_expect(hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue)); |
| 5350 | |
| 5351 | tp_mo := ts_SMS_SUBMIT(spars.tp.msg_ref, spars.tp.da, spars.tp.pid, spars.tp.dcs, |
| 5352 | spars.tp.udl, spars.tp.ud); |
Vadim Yanitskiy | 437b5a6 | 2019-12-15 14:13:39 +0900 | [diff] [blame] | 5353 | 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] | 5354 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_DATA_MO(rp_mo)); |
| 5355 | |
| 5356 | SGsAP.send(l3_mo); |
| 5357 | |
| 5358 | /* receive CP-ACK for CP-DATA above */ |
| 5359 | SGsAP.receive(tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_ACK_MT)); |
| 5360 | |
| 5361 | if (ispresent(spars.exp_rp_err)) { |
| 5362 | /* expect an RP-ERROR message from MSC with given cause */ |
| 5363 | rp_mt := tr_RP_ERROR_MT(spars.rp.msg_ref, spars.exp_rp_err); |
| 5364 | l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_DATA_MT(rp_mt)); |
| 5365 | SGsAP.receive(l3_mt); |
| 5366 | /* send CP-ACK for CP-DATA just received */ |
| 5367 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_ACK_MO); |
| 5368 | SGsAP.send(l3_mo); |
| 5369 | } else { |
| 5370 | /* expect RP-ACK for RP-DATA */ |
| 5371 | rp_mt := tr_RP_ACK_MT(spars.rp.msg_ref); |
| 5372 | l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_DATA_MT(rp_mt)); |
| 5373 | SGsAP.receive(l3_mt); |
| 5374 | /* send CP-ACO for CP-DATA just received */ |
| 5375 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_ACK_MO); |
| 5376 | SGsAP.send(l3_mo); |
| 5377 | } |
| 5378 | |
| 5379 | deactivate(d); |
| 5380 | |
| 5381 | setverdict(pass); |
| 5382 | } |
| 5383 | |
| 5384 | private function f_vty_sms_send_conn_hdlr(charstring imsi, charstring msisdn, charstring text) |
| 5385 | runs on BSC_ConnHdlr { |
| 5386 | f_vty_transceive(MSCVTY, "subscriber imsi "&imsi&" sms sender msisdn "&msisdn&" send "&text); |
| 5387 | } |
| 5388 | |
| 5389 | /* Send a MT SMS via SGs interface */ |
| 5390 | private function f_tc_sgsap_mt_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5391 | f_init_handler(pars); |
| 5392 | f_sgs_perform_lu(); |
| 5393 | f_sleep(1.0); |
| 5394 | var SmsParameters spars := valueof(t_SmsPars); |
| 5395 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 5396 | |
| 5397 | /* Trigger SMS via VTY */ |
| 5398 | f_vty_sms_send_conn_hdlr(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 5399 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5400 | |
| 5401 | /* Expect a paging request and respond accordingly with a service request */ |
| 5402 | SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, SMS_indicator, omit)); |
| 5403 | SGsAP.send(ts_SGsAP_SERVICE_REQ(pars.imsi, SMS_indicator, EMM_CONNECTED)); |
| 5404 | |
| 5405 | /* Connection is now live, receive the MT-SMS */ |
| 5406 | f_mt_sms_sgs(spars); |
| 5407 | |
| 5408 | /* Expect a concluding release from the MSC */ |
| 5409 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, omit)); |
| 5410 | |
| 5411 | /* Make sure that subscriber is still present and the SGs association is in tact (ref-counting) */ |
| 5412 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5413 | |
| 5414 | f_sgsap_bssmap_screening(); |
| 5415 | |
| 5416 | setverdict(pass); |
| 5417 | } |
| 5418 | testcase TC_sgsap_mt_sms() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5419 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5420 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5421 | f_init(1, true); |
| 5422 | pars := f_init_pars(11823, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5423 | pars.common_id_last_eutran_plmn := f_enc_mcc_mnc('901'H, '70'H); |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5424 | 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] | 5425 | vc_conn.done; |
| 5426 | } |
| 5427 | |
| 5428 | /* Send a MO SMS via SGs interface */ |
| 5429 | private function f_tc_sgsap_mo_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5430 | f_init_handler(pars); |
| 5431 | f_sgs_perform_lu(); |
| 5432 | f_sleep(1.0); |
| 5433 | var SmsParameters spars := valueof(t_SmsPars); |
| 5434 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 5435 | |
| 5436 | /* Send the MO-SMS */ |
| 5437 | f_mo_sms_sgs(spars); |
| 5438 | |
| 5439 | /* Expect a concluding release from the MSC/VLR */ |
| 5440 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, omit)); |
| 5441 | |
| 5442 | /* Make sure that subscriber is still present and the SGs association is in tact (ref-counting) */ |
| 5443 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5444 | |
| 5445 | setverdict(pass); |
| 5446 | |
| 5447 | f_sgsap_bssmap_screening() |
| 5448 | } |
| 5449 | testcase TC_sgsap_mo_sms() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5450 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5451 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5452 | f_init(1, true); |
| 5453 | pars := f_init_pars(11824, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5454 | pars.common_id_last_eutran_plmn := f_enc_mcc_mnc('901'H, '70'H); |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5455 | 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] | 5456 | vc_conn.done; |
| 5457 | } |
| 5458 | |
| 5459 | /* Trigger sending of an MT sms via VTY but never respond to anything */ |
| 5460 | private function f_tc_sgsap_mt_sms_and_nothing(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5461 | f_init_handler(pars, 170.0); |
| 5462 | f_sgs_perform_lu(); |
| 5463 | f_sleep(1.0); |
| 5464 | |
| 5465 | var SmsParameters spars := valueof(t_SmsPars); |
| 5466 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 5467 | var integer page_count := 0; |
| 5468 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5469 | var template PDU_SGsAP exp_pag_req := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, SMS_indicator, omit); |
| 5470 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5471 | exp_pag_req.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 5472 | |
| 5473 | /* Trigger SMS via VTY */ |
| 5474 | f_vty_sms_send_conn_hdlr(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 5475 | |
Neels Hofmeyr | 1623774 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 5476 | /* Expect the MSC/VLR to page exactly once */ |
| 5477 | SGsAP.receive(exp_pag_req); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5478 | |
| 5479 | /* Wait some time to make sure the MSC is not delivering any further |
| 5480 | * paging messages or anything else that could be unexpected. */ |
| 5481 | timer T := 20.0; |
| 5482 | T.start |
| 5483 | alt { |
| 5484 | [] SGsAP.receive(exp_pag_req) |
| 5485 | { |
| 5486 | setverdict(fail, "paging seems not to stop!"); |
| 5487 | mtc.stop; |
| 5488 | } |
| 5489 | [] SGsAP.receive { |
| 5490 | setverdict(fail, "unexpected SGsAP message received"); |
| 5491 | self.stop; |
| 5492 | } |
| 5493 | [] T.timeout { |
| 5494 | setverdict(pass); |
| 5495 | } |
| 5496 | } |
| 5497 | |
| 5498 | /* Even on a failed paging the SGs Association should stay intact */ |
| 5499 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5500 | |
Philipp Maier | 26bdb8c | 2019-09-24 09:21:12 +0200 | [diff] [blame] | 5501 | /* Make sure that the SMS we just inserted is cleared and the |
| 5502 | * subscriber is expired. This is necessary because otherwise the MSC |
| 5503 | * might re-try the SMS delivery and disturb the following tests. */ |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5504 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 5505 | f_vty_sms_clear(hex2str(g_pars.imsi)); |
| 5506 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5507 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " expire"); |
| 5508 | |
| 5509 | setverdict(pass); |
Neels Hofmeyr | b0f8234 | 2019-03-06 15:36:51 +0100 | [diff] [blame] | 5510 | |
| 5511 | f_sgsap_bssmap_screening(); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5512 | } |
| 5513 | testcase TC_sgsap_mt_sms_and_nothing() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5514 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5515 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5516 | f_init(1, true); |
| 5517 | pars := f_init_pars(11825, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5518 | pars.common_id_last_eutran_plmn := f_enc_mcc_mnc('901'H, '70'H); |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5519 | 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] | 5520 | vc_conn.done; |
| 5521 | } |
| 5522 | |
| 5523 | /* Trigger sending of an MT sms via VTY but reject the paging immediately */ |
| 5524 | private function f_tc_sgsap_mt_sms_and_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5525 | f_init_handler(pars, 150.0); |
| 5526 | f_sgs_perform_lu(); |
| 5527 | f_sleep(1.0); |
| 5528 | |
| 5529 | var SmsParameters spars := valueof(t_SmsPars); |
| 5530 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 5531 | var integer page_count := 0; |
| 5532 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5533 | var template PDU_SGsAP exp_pag_req := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, SMS_indicator, omit); |
| 5534 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5535 | exp_pag_req.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 5536 | |
| 5537 | /* Trigger SMS via VTY */ |
| 5538 | f_vty_sms_send_conn_hdlr(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 5539 | |
| 5540 | /* Expect a paging request and reject it immediately */ |
| 5541 | SGsAP.receive(exp_pag_req); |
| 5542 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, IMSI_unknown)); |
| 5543 | |
| 5544 | /* The MSC/VLR should no longer try to page once the paging has been |
| 5545 | * rejected. Wait some time and check if there are no unexpected |
| 5546 | * messages on the SGs interface. */ |
| 5547 | timer T := 20.0; |
| 5548 | T.start |
| 5549 | alt { |
| 5550 | [] SGsAP.receive(exp_pag_req) |
| 5551 | { |
| 5552 | setverdict(fail, "paging seems not to stop!"); |
| 5553 | mtc.stop; |
| 5554 | } |
| 5555 | [] SGsAP.receive { |
| 5556 | setverdict(fail, "unexpected SGsAP message received"); |
| 5557 | self.stop; |
| 5558 | } |
| 5559 | [] T.timeout { |
| 5560 | setverdict(pass); |
| 5561 | } |
| 5562 | } |
| 5563 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 5564 | f_vty_sms_clear(hex2str(g_pars.imsi)); |
| 5565 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5566 | /* A rejected paging with IMSI_unknown (see above) should always send |
| 5567 | * the SGs association to NULL. */ |
| 5568 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 5569 | |
| 5570 | f_sgsap_bssmap_screening(); |
| 5571 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5572 | setverdict(pass); |
| 5573 | } |
| 5574 | testcase TC_sgsap_mt_sms_and_reject() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5575 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5576 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5577 | f_init(1, true); |
| 5578 | pars := f_init_pars(11826, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5579 | pars.common_id_last_eutran_plmn := f_enc_mcc_mnc('901'H, '70'H); |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5580 | 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] | 5581 | vc_conn.done; |
| 5582 | } |
| 5583 | |
Pau Espin Pedrol | 3acd19e | 2021-04-28 12:59:52 +0200 | [diff] [blame] | 5584 | /* Perform an MT CSFB call including LU */ |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5585 | private function f_mt_lu_and_csfb_call(charstring id, BSC_ConnHdlrPars pars, boolean bssmap_lu) runs on BSC_ConnHdlr { |
| 5586 | f_init_handler(pars); |
| 5587 | |
| 5588 | /* Be sure that the BSSMAP reset is done before we begin. */ |
| 5589 | f_sleep(2.0); |
| 5590 | |
| 5591 | /* Testcase variation: See what happens when we do a regular BSSMAP |
| 5592 | * LU first (this should not hurt in any way!) */ |
| 5593 | if (bssmap_lu) { |
| 5594 | f_perform_lu(); |
| 5595 | } |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5596 | pars.common_id_last_eutran_plmn := f_enc_mcc_mnc('901'H, '70'H); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5597 | |
| 5598 | f_sgs_perform_lu(); |
| 5599 | f_sleep(1.0); |
| 5600 | |
| 5601 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5602 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5603 | |
| 5604 | /* Initiate a call via MNCC interface */ |
Oliver Smith | 97dc91f | 2023-05-31 13:53:21 +0200 | [diff] [blame] | 5605 | f_mt_call_initiate(cpars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5606 | |
| 5607 | /* Expect a paging request and respond accordingly with a service request */ |
| 5608 | SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)); |
| 5609 | SGsAP.send(ts_SGsAP_SERVICE_REQ(pars.imsi, CS_call_indicator, EMM_CONNECTED)); |
| 5610 | |
| 5611 | /* Complete the call, hold it for some time and then tear it down */ |
| 5612 | f_mt_call_complete(cpars); |
| 5613 | f_sleep(3.0); |
Harald Welte | 4c422b7 | 2019-02-17 16:27:10 +0100 | [diff] [blame] | 5614 | f_call_hangup(cpars, true, is_csfb := true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5615 | |
| 5616 | /* Make sure that subscriber is still present and the SGs association is in tact (ref-counting) */ |
| 5617 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5618 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5619 | /* Test for successful return by triggering a paging, when the paging |
| 5620 | * request is received via SGs, we can be sure that the MSC/VLR has |
| 5621 | * recognized that the UE is now back on 4G */ |
| 5622 | f_sleep(1.0); |
| 5623 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 5624 | alt { |
| 5625 | [] SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)) { |
| 5626 | setverdict(pass); |
| 5627 | } |
| 5628 | [] SGsAP.receive { |
| 5629 | setverdict(fail, "Received unexpected message on SGs"); |
| 5630 | } |
| 5631 | } |
| 5632 | |
| 5633 | f_sgsap_bssmap_screening(); |
| 5634 | |
| 5635 | setverdict(pass); |
| 5636 | } |
| 5637 | |
| 5638 | /* Perform a regular BSSAP LU first, do a SGSAP LU and then make a CSFB call */ |
| 5639 | private function f_tc_bssap_lu_sgsap_lu_and_mt_call(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5640 | f_mt_lu_and_csfb_call(id, pars, true); |
| 5641 | } |
| 5642 | 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] | 5643 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5644 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5645 | f_init(1, true); |
| 5646 | pars := f_init_pars(118139, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5647 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5648 | 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] | 5649 | vc_conn.done; |
| 5650 | } |
| 5651 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5652 | /* Perform a SGSAP LU and then make a CSFB call */ |
| 5653 | private function f_tc_sgsap_lu_and_mt_call(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5654 | f_mt_lu_and_csfb_call(id, pars, false); |
| 5655 | } |
| 5656 | testcase TC_sgsap_lu_and_mt_call() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5657 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5658 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5659 | f_init(1, true); |
| 5660 | pars := f_init_pars(11827, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5661 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5662 | 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] | 5663 | vc_conn.done; |
| 5664 | } |
| 5665 | |
Philipp Maier | 628c005 | 2019-04-09 17:36:57 +0200 | [diff] [blame] | 5666 | /* Simulate an HLR/VLR failure */ |
| 5667 | private function f_tc_sgsap_vlr_failure(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5668 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 5669 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5670 | |
| 5671 | var PDU_SGsAP lur; |
| 5672 | |
| 5673 | f_init_handler(pars); |
| 5674 | |
| 5675 | /* Attempt location update (which is expected to fail) */ |
| 5676 | lur := valueof(ts_SGsAP_LU_REQ(g_pars.imsi, mme_name, IMSI_attach, |
| 5677 | ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5678 | SGsAP.send(lur); |
| 5679 | |
| 5680 | /* Respond to SGsAP-RESET-INDICATION from VLR */ |
| 5681 | alt { |
| 5682 | [] SGsAP.receive(tr_SGsAP_RESET_IND_VLR(vlr_name)); { |
| 5683 | SGsAP.send(valueof(ts_SGsAP_RESET_ACK_MME(mme_name))); |
| 5684 | setverdict(pass); |
| 5685 | } |
| 5686 | [] SGsAP.receive { |
| 5687 | setverdict(fail, "Received unexpected message on SGs"); |
| 5688 | } |
| 5689 | } |
| 5690 | |
| 5691 | f_sleep(1.0); |
| 5692 | setverdict(pass); |
| 5693 | } |
| 5694 | testcase TC_sgsap_vlr_failure() runs on MTC_CT { |
| 5695 | var BSC_ConnHdlrPars pars; |
| 5696 | var BSC_ConnHdlr vc_conn; |
| 5697 | f_init(1, true, false); |
| 5698 | pars := f_init_pars(11811, true, false); |
| 5699 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_vlr_failure), pars); |
| 5700 | vc_conn.done; |
| 5701 | } |
| 5702 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5703 | /* SGs TODO: |
| 5704 | * LU attempt for IMSI without NAM_PS in HLR |
| 5705 | * LU attempt with AUTH FAIL due to invalid RES/SRES |
| 5706 | * LU attempt with no response from HLR (VLR should timeout + LU REJ) |
| 5707 | * LU attempt with new TMSI but without TMSI REALL CMPL baco to VLR |
| 5708 | * implicit IMSI detach from EPS |
| 5709 | * implicit IMSI detach from non-EPS |
| 5710 | * MM INFO |
| 5711 | * |
| 5712 | */ |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 5713 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5714 | private function f_tc_ho_inter_bsc_unknown_cell(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5715 | f_init_handler(pars); |
| 5716 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5717 | |
| 5718 | f_perform_lu(); |
| 5719 | f_mo_call_establish(cpars); |
| 5720 | |
| 5721 | f_sleep(1.0); |
| 5722 | |
| 5723 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_BETTER_CELL; |
| 5724 | var BssmapCause cause := enum2int(cause_val); |
| 5725 | |
| 5726 | var template BSSMAP_FIELD_CellIdentificationList cil; |
| 5727 | cil := { cIl_LAI := { ts_BSSMAP_CI_LAI('023'H, '42'H, 999) } }; |
| 5728 | |
| 5729 | BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 5730 | BSSAP.receive(tr_BSSMAP_HandoverRequiredReject); |
| 5731 | |
| 5732 | f_call_hangup(cpars, true); |
| 5733 | } |
| 5734 | testcase TC_ho_inter_bsc_unknown_cell() runs on MTC_CT { |
| 5735 | var BSC_ConnHdlr vc_conn; |
| 5736 | f_init(); |
| 5737 | |
| 5738 | vc_conn := f_start_handler(refers(f_tc_ho_inter_bsc_unknown_cell), 53); |
| 5739 | vc_conn.done; |
| 5740 | } |
| 5741 | |
| 5742 | private altstep as_mgcp_ack_all_mdcx(CallParameters cpars) runs on BSC_ConnHdlr { |
| 5743 | var MgcpCommand mgcp_cmd; |
| 5744 | [] MGCP.receive(tr_MDCX) -> value mgcp_cmd { |
Neels Hofmeyr | 8913b9e | 2021-07-27 22:33:45 +0200 | [diff] [blame] | 5745 | var charstring conn_id; |
| 5746 | f_mgcp_find_param_entry(mgcp_cmd.params, "I", conn_id); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 5747 | 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] | 5748 | hex2str(cpars.mgcp_call_id), "42", |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 5749 | cpars.mgw_conn_2.mgw_rtp_port, |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5750 | { int2str(cpars.rtp_payload_type) }, |
| 5751 | { valueof(ts_SDP_rtpmap(cpars.rtp_payload_type, |
| 5752 | cpars.rtp_sdp_format)), |
| 5753 | valueof(ts_SDP_ptime(20)) })); |
Neels Hofmeyr | 8913b9e | 2021-07-27 22:33:45 +0200 | [diff] [blame] | 5754 | MGCP.send(ts_MDCX_ACK(mgcp_cmd.line.trans_id, str2hex(conn_id), sdp)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5755 | repeat; |
| 5756 | } |
| 5757 | } |
| 5758 | |
Neels Hofmeyr | 8853afb | 2021-07-27 22:34:15 +0200 | [diff] [blame] | 5759 | private altstep as_mgcp_ack_all_dlcx(CallParameters cpars) runs on BSC_ConnHdlr { |
| 5760 | var MgcpCommand mgcp_cmd; |
| 5761 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 5762 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
| 5763 | repeat; |
| 5764 | } |
| 5765 | } |
| 5766 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5767 | private function f_tc_ho_inter_bsc0(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 5768 | var CallParameters cpars; |
| 5769 | |
| 5770 | cpars := valueof(t_CallParams('12345'H, 0)); |
| 5771 | if (pars.use_ipv6) { |
| 5772 | cpars.mgw_conn_1.mgw_rtp_ip := "::1"; |
| 5773 | cpars.mgw_conn_2.mgw_rtp_ip := "::2"; |
| 5774 | cpars.bss_rtp_ip := "::3"; |
| 5775 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5776 | |
| 5777 | f_init_handler(pars); |
| 5778 | |
| 5779 | f_vty_transceive(MSCVTY, "configure terminal"); |
| 5780 | f_vty_transceive(MSCVTY, "msc"); |
| 5781 | f_vty_transceive(MSCVTY, "neighbor a cgi 262 42 23 42 ran-pc 0.24.1"); |
Neels Hofmeyr | 2822d07 | 2021-06-23 03:20:32 +0200 | [diff] [blame] | 5782 | f_vty_transceive(MSCVTY, "neighbor a cgi 023 42 5 6 ran-pc 0.24.2"); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5783 | f_vty_transceive(MSCVTY, "exit"); |
| 5784 | f_vty_transceive(MSCVTY, "exit"); |
| 5785 | |
| 5786 | f_perform_lu(); |
| 5787 | f_mo_call_establish(cpars); |
| 5788 | |
| 5789 | f_sleep(1.0); |
| 5790 | |
| 5791 | var default ack_mdcx := activate(as_mgcp_ack_all_mdcx(cpars)); |
| 5792 | |
| 5793 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_BETTER_CELL; |
| 5794 | var BssmapCause cause := enum2int(cause_val); |
| 5795 | |
| 5796 | var template BSSMAP_FIELD_CellIdentificationList cil; |
Neels Hofmeyr | 2822d07 | 2021-06-23 03:20:32 +0200 | [diff] [blame] | 5797 | cil := { cIl_CGI := { ts_BSSMAP_CI_CGI('023'H, '42'H, 5, 6) } }; |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5798 | |
| 5799 | /* old BSS sends Handover Required */ |
| 5800 | BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 5801 | |
| 5802 | /* Now the action goes on in f_tc_ho_inter_bsc1() */ |
| 5803 | |
| 5804 | /* MSC forwards the RR Handover Command to old BSS */ |
| 5805 | var PDU_BSSAP ho_command; |
| 5806 | BSSAP.receive(tr_BSSMAP_HandoverCommand) -> value ho_command; |
| 5807 | |
| 5808 | log("GOT HandoverCommand", ho_command); |
| 5809 | |
| 5810 | BSSAP.receive(tr_BSSMAP_HandoverSucceeded); |
| 5811 | |
| 5812 | /* f_tc_ho_inter_bsc1() completes Handover, then expecting a Clear here. */ |
| 5813 | f_expect_clear(); |
| 5814 | |
| 5815 | log("FIRST inter-BSC Handover done"); |
| 5816 | |
| 5817 | |
| 5818 | /* ------------------------ */ |
| 5819 | |
| 5820 | /* Ok, that went well, now the other BSC is handovering back here -- |
| 5821 | * from now on this here is the new BSS. */ |
| 5822 | f_create_bssmap_exp_handoverRequest(193); |
| 5823 | |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5824 | var template BSSMAP_IE_EncryptionInformation encryptionInformation; |
| 5825 | var template BSSMAP_IE_ChosenEncryptionAlgorithm chosenEncryptionAlgorithm; |
| 5826 | var template BSSMAP_IE_KC128 kC128; |
| 5827 | var OCT1 a5_perm_alg; |
| 5828 | f_get_expected_encryption(encryptionInformation, chosenEncryptionAlgorithm, kC128, a5_perm_alg); |
Vadim Yanitskiy | c5fcb89 | 2022-08-04 04:06:07 +0700 | [diff] [blame] | 5829 | var template PDU_BSSAP expect_ho_request := tr_BSSMAP_HandoverRequest(encryptionInformation, |
| 5830 | chosenEncryptionAlgorithm, |
| 5831 | kC128, codecList := ?); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5832 | var PDU_BSSAP ho_request; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5833 | alt { |
| 5834 | [] BSSAP.receive(expect_ho_request); |
| 5835 | [] BSSAP.receive(tr_BSSMAP_HandoverRequest) -> value ho_request { |
| 5836 | log("Error: Wrong handoverRequest received. Expected: ", expect_ho_request, |
| 5837 | " got ", ho_request); |
| 5838 | setverdict(fail, "Wrong handoverRequest received"); |
| 5839 | mtc.stop; |
| 5840 | } |
| 5841 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5842 | |
| 5843 | /* new BSS composes a RR Handover Command */ |
| 5844 | var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 5845 | var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 5846 | var BSSMAP_IE_AoIP_TransportLayerAddress tla tla := |
| 5847 | valueof(f_ts_BSSMAP_IE_AoIP_TLA(cpars.bss_rtp_ip, cpars.bss_rtp_port)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5848 | BSSAP.send(ts_BSSMAP_HandoverRequestAcknowledge(rr_ho_cmd_enc, lengthof(rr_ho_cmd_enc), |
| 5849 | tla, ts_BSSMAP_IE_SpeechCodec({ts_CodecFR}))); |
| 5850 | |
| 5851 | /* Now f_tc_ho_inter_bsc1() expects HandoverCommand */ |
| 5852 | |
| 5853 | f_sleep(0.5); |
| 5854 | |
| 5855 | /* Notify that the MS is now over here */ |
| 5856 | |
| 5857 | BSSAP.send(ts_BSSMAP_HandoverDetect); |
| 5858 | f_sleep(0.1); |
| 5859 | BSSAP.send(ts_BSSMAP_HandoverComplete); |
| 5860 | |
| 5861 | f_sleep(3.0); |
| 5862 | |
| 5863 | deactivate(ack_mdcx); |
| 5864 | |
| 5865 | var default ccrel := activate(as_optional_cc_rel(cpars, true)); |
| 5866 | |
| 5867 | /* blatant cheating */ |
| 5868 | var N_Sd_Array last_n_sd := f_bssmap_last_n_sd(); |
| 5869 | last_n_sd[0] := 3; |
| 5870 | f_bssmap_continue_after_n_sd(last_n_sd); |
| 5871 | |
| 5872 | f_call_hangup(cpars, true); |
| 5873 | f_sleep(1.0); |
| 5874 | deactivate(ccrel); |
| 5875 | |
| 5876 | setverdict(pass); |
| 5877 | } |
| 5878 | private function f_tc_ho_inter_bsc1(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 5879 | var charstring bss_rtp_ip; |
| 5880 | if (pars.use_ipv6) { |
| 5881 | bss_rtp_ip := "::8"; |
| 5882 | } else { |
| 5883 | bss_rtp_ip := "1.2.3.4"; |
| 5884 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5885 | f_init_handler(pars); |
| 5886 | f_create_bssmap_exp_handoverRequest(194); |
| 5887 | |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5888 | var template BSSMAP_IE_EncryptionInformation encryptionInformation; |
| 5889 | var template BSSMAP_IE_ChosenEncryptionAlgorithm chosenEncryptionAlgorithm; |
| 5890 | var template BSSMAP_IE_KC128 kC128; |
| 5891 | var OCT1 a5_perm_alg; |
| 5892 | f_get_expected_encryption(encryptionInformation, chosenEncryptionAlgorithm, kC128, a5_perm_alg); |
Vadim Yanitskiy | c5fcb89 | 2022-08-04 04:06:07 +0700 | [diff] [blame] | 5893 | var template PDU_BSSAP expect_ho_request := tr_BSSMAP_HandoverRequest(encryptionInformation, |
| 5894 | chosenEncryptionAlgorithm, |
| 5895 | kC128, codecList := ?); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5896 | var PDU_BSSAP ho_request; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5897 | alt { |
| 5898 | [] BSSAP.receive(expect_ho_request); |
| 5899 | [] BSSAP.receive(tr_BSSMAP_HandoverRequest) -> value ho_request { |
| 5900 | log("Error: Wrong handoverRequest received. Expected: ", expect_ho_request, |
| 5901 | " got ", ho_request); |
| 5902 | setverdict(fail, "Wrong handoverRequest received"); |
| 5903 | mtc.stop; |
| 5904 | } |
| 5905 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5906 | /* new BSS composes a RR Handover Command */ |
| 5907 | var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 5908 | var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 5909 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := |
| 5910 | valueof(f_ts_BSSMAP_IE_AoIP_TLA(bss_rtp_ip, 2342)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5911 | BSSAP.send(ts_BSSMAP_HandoverRequestAcknowledge(rr_ho_cmd_enc, lengthof(rr_ho_cmd_enc), |
| 5912 | tla, ts_BSSMAP_IE_SpeechCodec({ts_CodecFR}))); |
| 5913 | |
| 5914 | /* Now f_tc_ho_inter_bsc0() expects HandoverCommand */ |
| 5915 | |
| 5916 | f_sleep(0.5); |
| 5917 | |
| 5918 | /* Notify that the MS is now over here */ |
| 5919 | |
| 5920 | BSSAP.send(ts_BSSMAP_HandoverDetect); |
| 5921 | f_sleep(0.1); |
| 5922 | BSSAP.send(ts_BSSMAP_HandoverComplete); |
| 5923 | |
| 5924 | f_sleep(3.0); |
| 5925 | |
| 5926 | /* Now I'd like to f_call_hangup() but we don't know any cpars here. So |
| 5927 | * ... handover back to the first BSC :P */ |
| 5928 | |
| 5929 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_BETTER_CELL; |
| 5930 | var BssmapCause cause := enum2int(cause_val); |
| 5931 | |
| 5932 | var template BSSMAP_FIELD_CellIdentificationList cil; |
Neels Hofmeyr | 2822d07 | 2021-06-23 03:20:32 +0200 | [diff] [blame] | 5933 | cil := { cIl_CGI := { ts_BSSMAP_CI_CGI('262'H, '42'H, 23, 42) } }; |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5934 | |
| 5935 | /* old BSS sends Handover Required */ |
| 5936 | BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 5937 | |
| 5938 | /* Now the action goes on in f_tc_ho_inter_bsc0() */ |
| 5939 | |
| 5940 | /* MSC forwards the RR Handover Command to old BSS */ |
| 5941 | var PDU_BSSAP ho_command; |
| 5942 | BSSAP.receive(tr_BSSMAP_HandoverCommand) -> value ho_command; |
| 5943 | |
| 5944 | log("GOT HandoverCommand", ho_command); |
| 5945 | |
| 5946 | BSSAP.receive(tr_BSSMAP_HandoverSucceeded); |
| 5947 | |
| 5948 | /* f_tc_ho_inter_bsc1() completes Handover, then expecting a Clear here. */ |
| 5949 | f_expect_clear(); |
| 5950 | setverdict(pass); |
| 5951 | } |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5952 | function f_tc_ho_inter_bsc_main(boolean use_ipv6 := false, integer a5_n := 0) runs on MTC_CT { |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5953 | var BSC_ConnHdlr vc_conn0; |
| 5954 | var BSC_ConnHdlr vc_conn1; |
| 5955 | f_init(2); |
| 5956 | |
| 5957 | var BSC_ConnHdlrPars pars0 := f_init_pars(53); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 5958 | pars0.use_ipv6 := use_ipv6; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5959 | pars0.net.expect_ciph := a5_n > 0; |
| 5960 | pars0.net.expect_auth := pars0.net.expect_ciph; |
| 5961 | pars0.net.kc_support := bit2oct('00000001'B << a5_n); |
| 5962 | pars0.cm2.classmarkInformationType2_oct5.a5_3 := '1'B; |
| 5963 | pars0.cm2.classmarkInformationType2_oct5.a5_2 := '0'B; |
| 5964 | pars0.cm2.classmarkInformationType2_oct5.cm3 := '1'B; |
| 5965 | pars0.cm3 := valueof(ts_CM3_default); |
| 5966 | pars0.use_umts_aka := true; |
| 5967 | pars0.vec := f_gen_auth_vec_3g(); |
| 5968 | pars0.vec_keep := true; |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 5969 | pars0.ran_idx := 0; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5970 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5971 | var BSC_ConnHdlrPars pars1 := f_init_pars(53); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 5972 | pars1.use_ipv6 := use_ipv6; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5973 | pars1.net.expect_ciph := pars0.net.expect_ciph; |
| 5974 | pars1.net.expect_auth := pars0.net.expect_ciph; |
| 5975 | pars1.net.kc_support := bit2oct('00000001'B << a5_n); |
| 5976 | pars1.cm2 := pars0.cm2; |
| 5977 | pars1.cm3 := pars0.cm3; |
| 5978 | pars1.use_umts_aka := true; |
| 5979 | /* Both components need the same auth vector info because we expect f_tc_ho_inter_bsc0's ciphering key to be |
| 5980 | * identical to the one that shows up in f_tc_ho_inter_bsc1. Can only do that by feeding in a vector to both |
| 5981 | * components and then not overwriting it in BSC_ConnectionHandler. */ |
| 5982 | pars1.vec := pars0.vec; |
| 5983 | pars1.vec_keep := true; |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 5984 | pars1.ran_idx := 1; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5985 | |
| 5986 | if (a5_n > 0) { |
| 5987 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 5988 | } |
| 5989 | f_vty_config(MSCVTY, "network", "encryption a5 " & int2str(a5_n)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5990 | |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 5991 | vc_conn0 := f_start_handler_with_pars(refers(f_tc_ho_inter_bsc0), pars0); |
| 5992 | vc_conn1 := f_start_handler_with_pars(refers(f_tc_ho_inter_bsc1), pars1); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5993 | vc_conn0.done; |
| 5994 | vc_conn1.done; |
| 5995 | } |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 5996 | testcase TC_ho_inter_bsc() runs on MTC_CT { |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5997 | f_tc_ho_inter_bsc_main(false, a5_n := 0); |
| 5998 | } |
| 5999 | testcase TC_ho_inter_bsc_a5_1() runs on MTC_CT { |
| 6000 | f_tc_ho_inter_bsc_main(false, a5_n := 1); |
| 6001 | } |
| 6002 | testcase TC_ho_inter_bsc_a5_3() runs on MTC_CT { |
| 6003 | f_tc_ho_inter_bsc_main(false, a5_n := 3); |
| 6004 | } |
| 6005 | testcase TC_ho_inter_bsc_a5_4() runs on MTC_CT { |
| 6006 | f_tc_ho_inter_bsc_main(false, a5_n := 4); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 6007 | } |
| 6008 | testcase TC_ho_inter_bsc_ipv6() runs on MTC_CT { |
| 6009 | f_tc_ho_inter_bsc_main(true); |
| 6010 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6011 | |
| 6012 | function f_ML3_patch_seq_nr_MS_NW(in uint2_t seq_nr, inout octetstring enc_l3) { |
| 6013 | log("MS_NW patching N(SD)=", seq_nr, " into dtap ", enc_l3); |
| 6014 | enc_l3[2] := (enc_l3[2] and4b '3f'O) or4b bit2oct(int2bit(seq_nr, 8) << 6); |
| 6015 | log("MS_NW patched enc_l3: ", enc_l3); |
| 6016 | } |
| 6017 | |
| 6018 | private function f_tc_ho_inter_msc_out(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 6019 | var CallParameters cpars; |
Neels Hofmeyr | 906af10 | 2021-07-01 12:08:35 +0200 | [diff] [blame] | 6020 | var PDU_BSSAP ho_request; |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 6021 | |
| 6022 | cpars := valueof(t_CallParams('12345'H, 0)); |
| 6023 | if (pars.use_ipv6) { |
| 6024 | cpars.mgw_conn_1.mgw_rtp_ip := "::1"; |
| 6025 | cpars.mgw_conn_2.mgw_rtp_ip := "::2"; |
| 6026 | cpars.bss_rtp_ip := "::3"; |
| 6027 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6028 | var hexstring ho_number := f_gen_msisdn(99999); |
| 6029 | |
| 6030 | f_init_handler(pars); |
| 6031 | |
| 6032 | f_create_mncc_expect(hex2str(ho_number)); |
| 6033 | |
| 6034 | f_vty_transceive(MSCVTY, "configure terminal"); |
| 6035 | f_vty_transceive(MSCVTY, "msc"); |
| 6036 | f_vty_transceive(MSCVTY, "neighbor a cgi 017 017 1 1 msc-ipa-name msc-017-017-1"); |
| 6037 | f_vty_transceive(MSCVTY, "exit"); |
| 6038 | f_vty_transceive(MSCVTY, "exit"); |
| 6039 | |
| 6040 | f_perform_lu(); |
| 6041 | f_mo_call_establish(cpars); |
| 6042 | |
| 6043 | f_sleep(1.0); |
| 6044 | |
| 6045 | var default ack_mdcx := activate(as_mgcp_ack_all_mdcx(cpars)); |
| 6046 | |
| 6047 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_BETTER_CELL; |
| 6048 | var BssmapCause cause := enum2int(cause_val); |
| 6049 | |
| 6050 | var template BSSMAP_FIELD_CellIdentificationList cil; |
Neels Hofmeyr | 36ebc33 | 2021-06-23 03:20:32 +0200 | [diff] [blame] | 6051 | cil := { cIl_CGI := { ts_BSSMAP_CI_CGI('017'H, '017'H, 1, 1) } }; |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6052 | |
| 6053 | /* old BSS sends Handover Required */ |
| 6054 | BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 6055 | |
| 6056 | /* The target cell 017-017 LAC 1 is configured to be a remote MSC of name "msc-017-017-1". |
| 6057 | * This MSC tries to reach the other MSC via GSUP. */ |
| 6058 | |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6059 | var template BSSMAP_IE_EncryptionInformation encryptionInformation; |
| 6060 | var template BSSMAP_IE_ChosenEncryptionAlgorithm chosenEncryptionAlgorithm; |
| 6061 | var template BSSMAP_IE_KC128 kC128; |
| 6062 | var OCT1 a5_perm_alg; |
| 6063 | f_get_expected_encryption(encryptionInformation, chosenEncryptionAlgorithm, kC128, a5_perm_alg); |
Vadim Yanitskiy | c5fcb89 | 2022-08-04 04:06:07 +0700 | [diff] [blame] | 6064 | var template PDU_BSSAP expect_ho_request := tr_BSSMAP_HandoverRequest(encryptionInformation, |
| 6065 | chosenEncryptionAlgorithm, |
| 6066 | kC128, codecList := ?); |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6067 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6068 | var octetstring remote_msc_name := '6D73632D3031372D3031372D3100'O; /* "msc-017-017-1\0" as octetstring */ |
| 6069 | var GSUP_PDU prep_ho_req; |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6070 | alt { |
| 6071 | [] GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST, |
| 6072 | pars.imsi, destination_name := remote_msc_name, |
Neels Hofmeyr | ec2e1f7 | 2021-07-02 02:08:32 +0200 | [diff] [blame] | 6073 | an_apdu := t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, pdu := ?))) -> value prep_ho_req; |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6074 | [] GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST)) { |
| 6075 | setverdict(fail, "Wrong OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST message received"); |
| 6076 | mtc.stop; |
| 6077 | } |
| 6078 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6079 | |
| 6080 | var GSUP_IeValue source_name_ie; |
| 6081 | f_gsup_find_ie(prep_ho_req, OSMO_GSUP_SOURCE_NAME_IE, source_name_ie); |
| 6082 | var octetstring local_msc_name := source_name_ie.source_name; |
| 6083 | |
Neels Hofmeyr | ec2e1f7 | 2021-07-02 02:08:32 +0200 | [diff] [blame] | 6084 | /* Decode PDU to 1) match with expect_ho_request and 2) to forward the actual chosen encryption algorithm. */ |
Neels Hofmeyr | 906af10 | 2021-07-01 12:08:35 +0200 | [diff] [blame] | 6085 | var GSUP_IeValue an_apdu_ie; |
| 6086 | f_gsup_find_ie(prep_ho_req, OSMO_GSUP_AN_APDU_IE, an_apdu_ie); |
| 6087 | ho_request := dec_PDU_BSSAP(an_apdu_ie.an_apdu.pdu); |
Neels Hofmeyr | ec2e1f7 | 2021-07-02 02:08:32 +0200 | [diff] [blame] | 6088 | if (not match(ho_request, expect_ho_request)) { |
| 6089 | setverdict(fail, "Wrong PDU in OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST message received"); |
| 6090 | mtc.stop; |
| 6091 | } |
Neels Hofmeyr | 906af10 | 2021-07-01 12:08:35 +0200 | [diff] [blame] | 6092 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6093 | /* Remote MSC has figured out its BSC and signals success */ |
| 6094 | var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 6095 | var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd); |
| 6096 | var PDU_BSSAP ho_req_ack := valueof(ts_BSSMAP_HandoverRequestAcknowledge(rr_ho_cmd_enc, lengthof(rr_ho_cmd_enc), |
Neels Hofmeyr | 906af10 | 2021-07-01 12:08:35 +0200 | [diff] [blame] | 6097 | aoIPTransportLayer := omit, |
| 6098 | speechCodec := ts_BSSMAP_IE_SpeechCodec({ts_CodecFR}), |
| 6099 | chosenEncryptionAlgorithm := ho_request.pdu.bssmap.handoverRequest.chosenEncryptionAlgorithm)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6100 | GSUP.send(ts_GSUP_E_PrepareHandoverResult( |
| 6101 | pars.imsi, |
| 6102 | ho_number, |
| 6103 | remote_msc_name, local_msc_name, |
| 6104 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, enc_PDU_BSSAP(ho_req_ack))))); |
| 6105 | |
| 6106 | /* MSC forwards the RR Handover Command to old BSS */ |
| 6107 | BSSAP.receive(tr_BSSMAP_HandoverCommand); |
| 6108 | |
| 6109 | /* The MS shows up at remote new BSS */ |
| 6110 | |
| 6111 | GSUP.send(ts_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PROCESS_ACCESS_SIGNALLING_REQUEST, |
| 6112 | pars.imsi, remote_msc_name, local_msc_name, |
| 6113 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, |
| 6114 | enc_PDU_BSSAP(valueof(ts_BSSMAP_HandoverDetect)))))); |
| 6115 | BSSAP.receive(tr_BSSMAP_HandoverSucceeded); |
| 6116 | f_sleep(0.1); |
| 6117 | |
| 6118 | /* Save the MS sequence counters for use on the other connection */ |
| 6119 | var N_Sd_Array last_n_sd := f_bssmap_last_n_sd(); |
| 6120 | |
| 6121 | GSUP.send(ts_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_SEND_END_SIGNAL_REQUEST, |
| 6122 | pars.imsi, remote_msc_name, local_msc_name, |
| 6123 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, |
| 6124 | enc_PDU_BSSAP(valueof(ts_BSSMAP_HandoverComplete)))))); |
| 6125 | |
| 6126 | /* The local BSS conn clears, all communication goes via remote MSC now */ |
| 6127 | f_expect_clear(); |
| 6128 | |
| 6129 | /**********************************/ |
| 6130 | /* Play through some signalling across the inter-MSC link. |
| 6131 | * This is a copy of f_tc_lu_and_mo_ussd_single_request() translated into GSUP AN-APDUs. */ |
| 6132 | |
| 6133 | if (false) { |
| 6134 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 6135 | invoke_id := 5, /* Phone may not start from 0 or 1 */ |
| 6136 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 6137 | ussd_string := "*#100#" |
| 6138 | ); |
| 6139 | |
| 6140 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 6141 | invoke_id := 5, /* InvokeID shall be the same for both REQ and RSP */ |
| 6142 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 6143 | ussd_string := "Your extension is " & hex2str(g_pars.msisdn) & "\r" |
| 6144 | ) |
| 6145 | |
| 6146 | /* Compose a new SS/REGISTER message with request */ |
| 6147 | var template (value) PDU_ML3_MS_NW ussd_req := ts_ML3_MO_SS_REGISTER( |
| 6148 | tid := 1, /* We just need a single transaction */ |
| 6149 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 6150 | facility := valueof(facility_req) |
| 6151 | ); |
| 6152 | var PDU_ML3_MS_NW ussd_req_v := valueof(ussd_req); |
| 6153 | |
| 6154 | /* Compose SS/RELEASE_COMPLETE template with expected response */ |
| 6155 | var template PDU_ML3_NW_MS ussd_rsp := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 6156 | tid := 1, /* Response should arrive within the same transaction */ |
| 6157 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 6158 | facility := valueof(facility_rsp) |
| 6159 | ); |
| 6160 | |
| 6161 | /* Compose expected MSC -> HLR message */ |
| 6162 | var template GSUP_PDU gsup_req := tr_GSUP_PROC_SS_REQ( |
| 6163 | imsi := g_pars.imsi, |
| 6164 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 6165 | ss := valueof(facility_req) |
| 6166 | ); |
| 6167 | |
| 6168 | /* To be used for sending response with correct session ID */ |
| 6169 | var GSUP_PDU gsup_req_complete; |
| 6170 | |
| 6171 | /* Request own number */ |
| 6172 | /* From remote MSC instead of BSSAP directly */ |
| 6173 | /* Patch the correct N_SD value into the message. */ |
| 6174 | var octetstring l3_enc := enc_PDU_ML3_MS_NW(ussd_req_v); |
| 6175 | var RAN_Emulation.ConnectionData cd; |
| 6176 | f_ML3_patch_seq_nr_MS_NW(f_next_n_sd(last_n_sd, f_ML3_n_sd_idx(ussd_req_v)), l3_enc); |
| 6177 | GSUP.send(ts_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PROCESS_ACCESS_SIGNALLING_REQUEST, |
| 6178 | pars.imsi, remote_msc_name, local_msc_name, |
| 6179 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, |
| 6180 | enc_PDU_BSSAP(valueof(ts_BSSAP_DTAP(l3_enc))) |
| 6181 | )) |
| 6182 | )); |
| 6183 | |
| 6184 | /* Expect GSUP message containing the SS payload */ |
| 6185 | gsup_req_complete := f_expect_gsup_msg(gsup_req); |
| 6186 | |
| 6187 | /* Compose the response from HLR using received session ID */ |
| 6188 | var template GSUP_PDU gsup_rsp := ts_GSUP_PROC_SS_REQ( |
| 6189 | imsi := g_pars.imsi, |
| 6190 | sid := gsup_req_complete.ies[1].val.session_id, |
| 6191 | state := OSMO_GSUP_SESSION_STATE_END, |
| 6192 | ss := valueof(facility_rsp) |
| 6193 | ); |
| 6194 | |
| 6195 | /* Finally, HLR terminates the session */ |
| 6196 | GSUP.send(gsup_rsp); |
| 6197 | |
| 6198 | /* The USSD response goes out to remote MSC, on GSUP E instead of BSSAP */ |
| 6199 | var GSUP_PDU gsup_ussd_rsp; |
| 6200 | GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_FORWARD_ACCESS_SIGNALLING_REQUEST, |
| 6201 | pars.imsi, destination_name := remote_msc_name)) -> value gsup_ussd_rsp; |
| 6202 | |
| 6203 | var GSUP_IeValue an_apdu; |
| 6204 | if (not f_gsup_find_ie(gsup_ussd_rsp, OSMO_GSUP_AN_APDU_IE, an_apdu)) { |
| 6205 | setverdict(fail, "No AN-APDU in received GSUP message. Expected USSD response in DTAP, got", gsup_ussd_rsp); |
| 6206 | mtc.stop; |
| 6207 | } |
| 6208 | var PDU_BSSAP bssap_dtap_mt := dec_PDU_BSSAP(an_apdu.an_apdu.pdu); |
| 6209 | var PDU_ML3_NW_MS dtap_mt := dec_PDU_ML3_NW_MS(bssap_dtap_mt.pdu.dtap); |
| 6210 | log("Expecting", ussd_rsp); |
| 6211 | log("Got", dtap_mt); |
| 6212 | if (not match(dtap_mt, ussd_rsp)) { |
| 6213 | setverdict(fail, "Unexpected GSUP message. Expected USSD response in DTAP, got", gsup_ussd_rsp); |
| 6214 | mtc.stop; |
| 6215 | } |
| 6216 | } |
| 6217 | /**********************************/ |
| 6218 | |
| 6219 | |
| 6220 | /* inter-MSC handover back to the first MSC */ |
| 6221 | f_create_bssmap_exp_handoverRequest(193); |
| 6222 | cil := { cIl_CGI := { ts_BSSMAP_CI_CGI('262'H, '42'H, 23, 42) } }; |
| 6223 | |
| 6224 | /* old BSS sends Handover Required, via inter-MSC E link: like |
| 6225 | * BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 6226 | * but via GSUP */ |
| 6227 | GSUP.send(ts_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_REQUEST, |
| 6228 | pars.imsi, remote_msc_name, local_msc_name, |
| 6229 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, |
| 6230 | enc_PDU_BSSAP(valueof(ts_BSSMAP_HandoverRequired(cause, cil))) |
| 6231 | )) |
| 6232 | )); |
| 6233 | |
| 6234 | /* MSC asks local BSS to prepare Handover to it */ |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6235 | f_get_expected_encryption(encryptionInformation, chosenEncryptionAlgorithm, kC128, a5_perm_alg); |
Vadim Yanitskiy | c5fcb89 | 2022-08-04 04:06:07 +0700 | [diff] [blame] | 6236 | expect_ho_request := tr_BSSMAP_HandoverRequest(encryptionInformation, |
| 6237 | chosenEncryptionAlgorithm, |
| 6238 | kC128, codecList := ?); |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6239 | alt { |
Neels Hofmeyr | 906af10 | 2021-07-01 12:08:35 +0200 | [diff] [blame] | 6240 | [] BSSAP.receive(expect_ho_request) -> value ho_request; |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6241 | [] BSSAP.receive(tr_BSSMAP_HandoverRequest) -> value ho_request { |
| 6242 | log("Error: Wrong handoverRequest received. Expected: ", expect_ho_request, |
| 6243 | " got ", ho_request); |
| 6244 | setverdict(fail, "Wrong handoverRequest received"); |
| 6245 | mtc.stop; |
| 6246 | } |
| 6247 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6248 | |
| 6249 | /* Make sure the new BSSAP conn continues with the correct N_SD sequence numbers */ |
| 6250 | f_bssmap_continue_after_n_sd(last_n_sd); |
| 6251 | |
| 6252 | /* new BSS composes a RR Handover Command */ |
| 6253 | rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 6254 | rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 6255 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := |
| 6256 | valueof(f_ts_BSSMAP_IE_AoIP_TLA(cpars.bss_rtp_ip, cpars.bss_rtp_port)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6257 | BSSAP.send(ts_BSSMAP_HandoverRequestAcknowledge(rr_ho_cmd_enc, lengthof(rr_ho_cmd_enc), |
Neels Hofmeyr | 906af10 | 2021-07-01 12:08:35 +0200 | [diff] [blame] | 6258 | tla, ts_BSSMAP_IE_SpeechCodec({ts_CodecFR}), |
| 6259 | chosenEncryptionAlgorithm := ho_request.pdu.bssmap.handoverRequest.chosenEncryptionAlgorithm)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6260 | |
| 6261 | /* HandoverCommand goes out via remote MSC-I */ |
| 6262 | var GSUP_PDU prep_subsq_ho_res; |
| 6263 | GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_RESULT, |
| 6264 | pars.imsi, destination_name := remote_msc_name)) -> value prep_subsq_ho_res; |
| 6265 | |
| 6266 | /* MS shows up at the local BSS */ |
| 6267 | BSSAP.send(ts_BSSMAP_HandoverDetect); |
| 6268 | f_sleep(0.1); |
| 6269 | BSSAP.send(ts_BSSMAP_HandoverComplete); |
| 6270 | |
| 6271 | /* Handover Succeeded message */ |
| 6272 | GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_FORWARD_ACCESS_SIGNALLING_REQUEST, |
| 6273 | pars.imsi, destination_name := remote_msc_name)); |
| 6274 | |
| 6275 | /* MS has handovered to here, Clear Command goes out via remote MSC-I -- in form of a GSUP Close. */ |
| 6276 | GSUP.receive(tr_GSUP_E_NO_PDU(OSMO_GSUP_MSGT_E_CLOSE, |
| 6277 | pars.imsi, destination_name := remote_msc_name)); |
| 6278 | |
| 6279 | /* Handover ends successfully. Call goes on for a little longer and then we hang up. */ |
| 6280 | |
| 6281 | f_sleep(1.0); |
| 6282 | deactivate(ack_mdcx); |
| 6283 | |
| 6284 | /* FIXME: the inter-MSC call has put a number of MNCC messages in the queue, which above code should expect and |
| 6285 | * clear out. The f_call_hangup() expects an MNCC_REL_IND, so, for the time being, just clear the MNCC messages |
| 6286 | * before starting the call hangup. Instead of this, the individual messages should be tested for above. */ |
| 6287 | MNCC.clear; |
| 6288 | |
| 6289 | var default ccrel := activate(as_optional_cc_rel(cpars, true)); |
| 6290 | f_call_hangup(cpars, true); |
| 6291 | f_sleep(1.0); |
| 6292 | deactivate(ccrel); |
| 6293 | |
| 6294 | setverdict(pass); |
| 6295 | } |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6296 | function f_tc_ho_inter_msc_out_a5(integer a5_n) runs on MTC_CT { |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6297 | var BSC_ConnHdlr vc_conn; |
| 6298 | f_init(1); |
| 6299 | |
| 6300 | var BSC_ConnHdlrPars pars := f_init_pars(54); |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6301 | pars.net.expect_ciph := a5_n > 0; |
| 6302 | pars.net.expect_auth := pars.net.expect_ciph; |
| 6303 | pars.net.kc_support := bit2oct('00000001'B << a5_n); |
| 6304 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '1'B; |
| 6305 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '0'B; |
| 6306 | pars.cm2.classmarkInformationType2_oct5.cm3 := '1'B; |
| 6307 | pars.cm3 := valueof(ts_CM3_default); |
| 6308 | pars.use_umts_aka := true; |
| 6309 | |
| 6310 | if (a5_n > 0) { |
| 6311 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6312 | } |
| 6313 | f_vty_config(MSCVTY, "network", "encryption a5 " & int2str(a5_n)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6314 | |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 6315 | vc_conn := f_start_handler_with_pars(refers(f_tc_ho_inter_msc_out), pars); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6316 | vc_conn.done; |
| 6317 | } |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6318 | testcase TC_ho_inter_msc_out() runs on MTC_CT { |
| 6319 | f_tc_ho_inter_msc_out_a5(0); |
| 6320 | } |
| 6321 | testcase TC_ho_inter_msc_out_a5_1() runs on MTC_CT { |
| 6322 | f_tc_ho_inter_msc_out_a5(1); |
| 6323 | } |
| 6324 | testcase TC_ho_inter_msc_out_a5_3() runs on MTC_CT { |
| 6325 | f_tc_ho_inter_msc_out_a5(3); |
| 6326 | } |
| 6327 | testcase TC_ho_inter_msc_out_a5_4() runs on MTC_CT { |
| 6328 | f_tc_ho_inter_msc_out_a5(4); |
| 6329 | } |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 6330 | testcase TC_ho_inter_msc_out_ipv6() runs on MTC_CT { |
| 6331 | var BSC_ConnHdlr vc_conn; |
| 6332 | f_init(1); |
| 6333 | |
| 6334 | var BSC_ConnHdlrPars pars := f_init_pars(54); |
| 6335 | pars.use_ipv6 := true; |
| 6336 | |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 6337 | vc_conn := f_start_handler_with_pars(refers(f_tc_ho_inter_msc_out), pars); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 6338 | vc_conn.done; |
| 6339 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6340 | |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6341 | private function f_tc_lu_imsi_auth_tmsi_check_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6342 | pars.net.expect_auth := true; |
| 6343 | pars.net.expect_imei := true; |
| 6344 | f_init_handler(pars); |
| 6345 | f_perform_lu(); |
| 6346 | } |
| 6347 | testcase TC_lu_imsi_auth_tmsi_check_imei() runs on MTC_CT { |
| 6348 | var BSC_ConnHdlr vc_conn; |
| 6349 | f_init(); |
| 6350 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6351 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6352 | |
| 6353 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei), 5); |
| 6354 | vc_conn.done; |
| 6355 | } |
| 6356 | |
| 6357 | private function f_tc_lu_imsi_auth3g_tmsi_check_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6358 | pars.net.expect_auth := true; |
| 6359 | pars.use_umts_aka := true; |
| 6360 | pars.net.expect_imei := true; |
| 6361 | f_init_handler(pars); |
| 6362 | f_perform_lu(); |
| 6363 | } |
| 6364 | testcase TC_lu_imsi_auth3g_tmsi_check_imei() runs on MTC_CT { |
| 6365 | var BSC_ConnHdlr vc_conn; |
| 6366 | f_init(); |
| 6367 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6368 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6369 | |
| 6370 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth3g_tmsi_check_imei), 5); |
| 6371 | vc_conn.done; |
| 6372 | } |
| 6373 | |
| 6374 | private function f_tc_lu_imsi_noauth_tmsi_check_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6375 | pars.net.expect_imei := true; |
| 6376 | f_init_handler(pars); |
| 6377 | f_perform_lu(); |
| 6378 | } |
| 6379 | testcase TC_lu_imsi_noauth_tmsi_check_imei() runs on MTC_CT { |
| 6380 | var BSC_ConnHdlr vc_conn; |
| 6381 | f_init(); |
| 6382 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6383 | |
| 6384 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_tmsi_check_imei), 5); |
| 6385 | vc_conn.done; |
| 6386 | } |
| 6387 | |
| 6388 | private function f_tc_lu_imsi_noauth_notmsi_check_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6389 | pars.net.expect_tmsi := false; |
| 6390 | pars.net.expect_imei := true; |
| 6391 | f_init_handler(pars); |
| 6392 | f_perform_lu(); |
| 6393 | } |
| 6394 | testcase TC_lu_imsi_noauth_notmsi_check_imei() runs on MTC_CT { |
| 6395 | var BSC_ConnHdlr vc_conn; |
| 6396 | f_init(); |
| 6397 | f_vty_config(MSCVTY, "msc", "no assign-tmsi"); |
| 6398 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6399 | |
| 6400 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_notmsi_check_imei), 5); |
| 6401 | vc_conn.done; |
| 6402 | } |
| 6403 | |
| 6404 | private function f_tc_lu_imsi_auth_tmsi_check_imei_nack(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6405 | var PDU_ML3_MS_NW l3_lu; |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6406 | |
| 6407 | pars.net.expect_auth := true; |
| 6408 | pars.net.expect_imei := true; |
| 6409 | pars.net.check_imei_result := OSMO_GSUP_IMEI_RESULT_NACK; |
| 6410 | f_init_handler(pars); |
| 6411 | |
| 6412 | /* Cannot use f_perform_lu() as we expect a reject */ |
| 6413 | l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 6414 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6415 | f_bssap_compl_l3(l3_lu); |
| 6416 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 6417 | |
| 6418 | f_mm_common(); |
| 6419 | f_msc_lu_hlr(); |
| 6420 | f_mm_imei(); |
Oliver Smith | 91bfa1c | 2019-07-19 15:01:15 +0200 | [diff] [blame] | 6421 | f_expect_lu_reject(); |
Eric Wild | 85cc161 | 2022-03-30 01:44:29 +0200 | [diff] [blame] | 6422 | f_expect_clear(verify_vlr_cell_id:=false); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6423 | } |
| 6424 | testcase TC_lu_imsi_auth_tmsi_check_imei_nack() runs on MTC_CT { |
| 6425 | var BSC_ConnHdlr vc_conn; |
| 6426 | f_init(); |
| 6427 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6428 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6429 | |
| 6430 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_nack), 5); |
| 6431 | vc_conn.done; |
| 6432 | } |
| 6433 | |
| 6434 | private function f_tc_lu_imsi_auth_tmsi_check_imei_err(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6435 | var PDU_ML3_MS_NW l3_lu; |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6436 | |
| 6437 | pars.net.expect_auth := true; |
| 6438 | pars.net.expect_imei := true; |
| 6439 | pars.net.check_imei_error := true; |
| 6440 | f_init_handler(pars); |
| 6441 | |
| 6442 | /* Cannot use f_perform_lu() as we expect a reject */ |
| 6443 | l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 6444 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6445 | f_bssap_compl_l3(l3_lu); |
| 6446 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 6447 | |
| 6448 | f_mm_common(); |
| 6449 | f_msc_lu_hlr(); |
| 6450 | f_mm_imei(); |
Oliver Smith | 91bfa1c | 2019-07-19 15:01:15 +0200 | [diff] [blame] | 6451 | f_expect_lu_reject(); |
Eric Wild | 85cc161 | 2022-03-30 01:44:29 +0200 | [diff] [blame] | 6452 | f_expect_clear(verify_vlr_cell_id:=false); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6453 | } |
| 6454 | testcase TC_lu_imsi_auth_tmsi_check_imei_err() runs on MTC_CT { |
| 6455 | var BSC_ConnHdlr vc_conn; |
| 6456 | f_init(); |
| 6457 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6458 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6459 | |
| 6460 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_err), 5); |
| 6461 | vc_conn.done; |
| 6462 | } |
| 6463 | |
| 6464 | private function f_tc_lu_imsi_auth_tmsi_check_imei_early(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6465 | pars.net.expect_auth := true; |
| 6466 | pars.net.expect_imei_early := true; |
| 6467 | f_init_handler(pars); |
| 6468 | f_perform_lu(); |
| 6469 | } |
| 6470 | testcase TC_lu_imsi_auth_tmsi_check_imei_early() runs on MTC_CT { |
| 6471 | var BSC_ConnHdlr vc_conn; |
| 6472 | f_init(); |
| 6473 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6474 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6475 | |
| 6476 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_early), 5); |
| 6477 | vc_conn.done; |
| 6478 | } |
| 6479 | |
| 6480 | private function f_tc_lu_imsi_auth3g_tmsi_check_imei_early(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6481 | pars.net.expect_auth := true; |
| 6482 | pars.use_umts_aka := true; |
| 6483 | pars.net.expect_imei_early := true; |
| 6484 | f_init_handler(pars); |
| 6485 | f_perform_lu(); |
| 6486 | } |
| 6487 | testcase TC_lu_imsi_auth3g_tmsi_check_imei_early() runs on MTC_CT { |
| 6488 | var BSC_ConnHdlr vc_conn; |
| 6489 | f_init(); |
| 6490 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6491 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6492 | |
| 6493 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth3g_tmsi_check_imei_early), 5); |
| 6494 | vc_conn.done; |
| 6495 | } |
| 6496 | |
| 6497 | private function f_tc_lu_imsi_noauth_tmsi_check_imei_early(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6498 | pars.net.expect_imei_early := true; |
| 6499 | f_init_handler(pars); |
| 6500 | f_perform_lu(); |
| 6501 | } |
| 6502 | testcase TC_lu_imsi_noauth_tmsi_check_imei_early() runs on MTC_CT { |
| 6503 | var BSC_ConnHdlr vc_conn; |
| 6504 | f_init(); |
| 6505 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6506 | |
| 6507 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_tmsi_check_imei_early), 5); |
| 6508 | vc_conn.done; |
| 6509 | } |
| 6510 | |
| 6511 | private function f_tc_lu_imsi_noauth_notmsi_check_imei_early(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6512 | pars.net.expect_tmsi := false; |
| 6513 | pars.net.expect_imei_early := true; |
| 6514 | f_init_handler(pars); |
| 6515 | f_perform_lu(); |
| 6516 | } |
| 6517 | testcase TC_lu_imsi_noauth_notmsi_check_imei_early() runs on MTC_CT { |
| 6518 | var BSC_ConnHdlr vc_conn; |
| 6519 | f_init(); |
| 6520 | f_vty_config(MSCVTY, "msc", "no assign-tmsi"); |
| 6521 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6522 | |
| 6523 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_notmsi_check_imei_early), 5); |
| 6524 | vc_conn.done; |
| 6525 | } |
| 6526 | |
| 6527 | private function f_tc_lu_imsi_auth_tmsi_check_imei_early_nack(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6528 | var PDU_ML3_MS_NW l3_lu; |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6529 | |
| 6530 | pars.net.expect_auth := true; |
| 6531 | pars.net.expect_imei_early := true; |
| 6532 | pars.net.check_imei_result := OSMO_GSUP_IMEI_RESULT_NACK; |
| 6533 | f_init_handler(pars); |
| 6534 | |
| 6535 | /* Cannot use f_perform_lu() as we expect a reject */ |
| 6536 | l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 6537 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6538 | f_bssap_compl_l3(l3_lu); |
| 6539 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 6540 | |
| 6541 | f_mm_imei_early(); |
Oliver Smith | 91bfa1c | 2019-07-19 15:01:15 +0200 | [diff] [blame] | 6542 | f_expect_lu_reject(); |
Eric Wild | 85cc161 | 2022-03-30 01:44:29 +0200 | [diff] [blame] | 6543 | f_expect_clear(verify_vlr_cell_id:=false); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6544 | } |
| 6545 | testcase TC_lu_imsi_auth_tmsi_check_imei_early_nack() runs on MTC_CT { |
| 6546 | var BSC_ConnHdlr vc_conn; |
| 6547 | f_init(); |
| 6548 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6549 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6550 | |
| 6551 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_early_nack), 5); |
| 6552 | vc_conn.done; |
| 6553 | } |
| 6554 | |
| 6555 | private function f_tc_lu_imsi_auth_tmsi_check_imei_early_err(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6556 | var PDU_ML3_MS_NW l3_lu; |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6557 | |
| 6558 | pars.net.expect_auth := true; |
| 6559 | pars.net.expect_imei_early := true; |
| 6560 | pars.net.check_imei_error := true; |
| 6561 | f_init_handler(pars); |
| 6562 | |
| 6563 | /* Cannot use f_perform_lu() as we expect a reject */ |
| 6564 | l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 6565 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6566 | f_bssap_compl_l3(l3_lu); |
| 6567 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 6568 | |
| 6569 | f_mm_imei_early(); |
Oliver Smith | 91bfa1c | 2019-07-19 15:01:15 +0200 | [diff] [blame] | 6570 | f_expect_lu_reject(); |
Eric Wild | 85cc161 | 2022-03-30 01:44:29 +0200 | [diff] [blame] | 6571 | f_expect_clear(verify_vlr_cell_id:=false); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6572 | } |
| 6573 | testcase TC_lu_imsi_auth_tmsi_check_imei_early_err() runs on MTC_CT { |
| 6574 | var BSC_ConnHdlr vc_conn; |
| 6575 | f_init(); |
| 6576 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6577 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6578 | |
| 6579 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_early_err), 5); |
| 6580 | vc_conn.done; |
| 6581 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6582 | |
Neels Hofmeyr | 8df6962 | 2019-11-02 19:16:03 +0100 | [diff] [blame] | 6583 | friend function f_tc_invalid_mgcp_crash(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6584 | f_init_handler(pars); |
| 6585 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 6586 | |
| 6587 | /* Set invalid IP address so that osmo-msc discards the rtp_stream and MGCP endpoint FSM instances in the middle |
| 6588 | * of successful MGCP response dispatch. If things aren't safeguarded, the on_success() in osmo_mgcpc_ep_fsm |
| 6589 | * will cause a use-after-free after that event dispatch. */ |
| 6590 | cpars.mgw_conn_1.mgw_rtp_ip := "0.0.0.0"; |
| 6591 | cpars.mgw_conn_2.mgw_rtp_ip := "0.0.0.0"; |
| 6592 | cpars.rtp_sdp_format := "FOO/8000"; |
| 6593 | cpars.expect_release := true; |
| 6594 | |
| 6595 | f_perform_lu(); |
| 6596 | f_mo_call_establish(cpars); |
| 6597 | } |
| 6598 | testcase TC_invalid_mgcp_crash() runs on MTC_CT { |
| 6599 | var BSC_ConnHdlr vc_conn; |
| 6600 | f_init(); |
| 6601 | |
| 6602 | vc_conn := f_start_handler(refers(f_tc_invalid_mgcp_crash), 7); |
| 6603 | vc_conn.done; |
| 6604 | } |
| 6605 | |
Vadim Yanitskiy | eddebaa | 2019-12-28 17:45:34 +0100 | [diff] [blame] | 6606 | friend function f_tc_mm_id_resp_no_identity(charstring id, BSC_ConnHdlrPars pars) |
| 6607 | runs on BSC_ConnHdlr { |
| 6608 | pars.tmsi := 'FFFFFFFF'O; |
| 6609 | f_init_handler(pars); |
| 6610 | |
| 6611 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6612 | |
| 6613 | /* Initiate Location Updating using an unknown TMSI */ |
| 6614 | f_bssap_compl_l3(f_build_lu_tmsi(pars.tmsi)); |
| 6615 | |
| 6616 | /* Expect an Identity Request, send response with no identity */ |
| 6617 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req(CM_ID_TYPE_IMSI))); |
| 6618 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp({ |
| 6619 | lengthIndicator := 1, |
| 6620 | mobileIdentityV := { |
| 6621 | typeOfIdentity := '000'B, |
| 6622 | oddEvenInd_identity := { |
| 6623 | no_identity := { |
| 6624 | oddevenIndicator := '0'B, |
| 6625 | fillerDigits := '00000'H |
| 6626 | } |
| 6627 | } |
| 6628 | } |
| 6629 | }))); |
| 6630 | |
| 6631 | f_expect_lu_reject(); |
| 6632 | f_expect_clear(); |
| 6633 | } |
| 6634 | testcase TC_mm_id_resp_no_identity() runs on MTC_CT { |
| 6635 | var BSC_ConnHdlr vc_conn; |
| 6636 | |
| 6637 | f_init(); |
| 6638 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 6639 | vc_conn := f_start_handler(refers(f_tc_mm_id_resp_no_identity), 7, verify_cell_id := false); |
Vadim Yanitskiy | eddebaa | 2019-12-28 17:45:34 +0100 | [diff] [blame] | 6640 | vc_conn.done; |
| 6641 | } |
| 6642 | |
Vadim Yanitskiy | 2521906 | 2020-01-21 01:41:33 +0700 | [diff] [blame] | 6643 | /* Verify the case when T3212 expires during Paging procedure, just before the receipt |
| 6644 | * of Paging Response. This used to provoke a NULL-pointer dereference in old versions |
| 6645 | * of OsmoMSC, but apparently the bug has been fixed, and we're safe now. */ |
| 6646 | friend function f_tc_lu_and_expire_while_paging(charstring id, BSC_ConnHdlrPars pars) |
| 6647 | runs on BSC_ConnHdlr { |
| 6648 | var charstring imsi := hex2str(pars.imsi); |
| 6649 | |
| 6650 | f_init_handler(pars); |
| 6651 | |
| 6652 | /* Perform location update */ |
| 6653 | f_perform_lu(); |
| 6654 | |
| 6655 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
| 6656 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6657 | |
| 6658 | /* Initiate paging procedure from the VTY */ |
| 6659 | f_vty_transceive(MSCVTY, "subscriber imsi " & imsi & " paging"); |
| 6660 | f_expect_paging(); |
| 6661 | |
| 6662 | /* Emulate T3212 expiration during paging (we don't want to wait, right?) */ |
| 6663 | f_vty_transceive(MSCVTY, "subscriber imsi " & imsi & " expire"); |
| 6664 | |
| 6665 | /* MS sends PAGING RESPONSE, *old* OsmoMSC crashes here... */ |
| 6666 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 6667 | |
| 6668 | /* The recent OsmoMSC keeps subscriber in its VLR unless the Paging is completed. |
| 6669 | * In this case we do not send anything and just wait for a Clear Command. */ |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 6670 | f_expect_clear(verify_vlr_cell_id := false); |
Vadim Yanitskiy | 2521906 | 2020-01-21 01:41:33 +0700 | [diff] [blame] | 6671 | } |
| 6672 | testcase TC_lu_and_expire_while_paging() runs on MTC_CT { |
| 6673 | var BSC_ConnHdlr vc_conn; |
| 6674 | |
| 6675 | f_init(); |
| 6676 | |
| 6677 | vc_conn := f_start_handler(refers(f_tc_lu_and_expire_while_paging), 7); |
| 6678 | vc_conn.done; |
| 6679 | } |
| 6680 | |
Neels Hofmeyr | 3ad76a4 | 2022-08-09 02:57:49 +0200 | [diff] [blame] | 6681 | private altstep as_mncc_rx_rtp_create(CallParameters cpars) runs on BSC_ConnHdlr { |
| 6682 | [] MNCC.receive(tr_MNCC_RTP_CREATE(cpars.mncc_callref)); |
| 6683 | } |
| 6684 | |
Neels Hofmeyr | 4f099b4 | 2021-07-27 03:45:26 +0200 | [diff] [blame] | 6685 | const charstring REEST_LOST_CONNECTION := "REEST_LOST_CONNECTION"; |
| 6686 | const charstring REEST_CLEARED := "REEST_CLEARED"; |
| 6687 | |
| 6688 | friend function f_tc_call_re_establishment_1(charstring id, BSC_ConnHdlrPars pars) |
| 6689 | runs on BSC_ConnHdlr { |
| 6690 | f_init_handler(pars, t_guard := 30.0); |
| 6691 | |
| 6692 | f_perform_lu(); |
| 6693 | |
| 6694 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 6695 | f_mo_call_establish(cpars); |
| 6696 | f_sleep(3.0); |
| 6697 | COORD.send(REEST_LOST_CONNECTION); |
| 6698 | COORD.send(cpars); |
| 6699 | f_expect_clear(verify_vlr_cell_id := false); |
| 6700 | COORD.send(REEST_CLEARED); |
| 6701 | } |
| 6702 | |
| 6703 | friend function f_tc_call_re_establishment_2(charstring id, BSC_ConnHdlrPars pars) |
| 6704 | runs on BSC_ConnHdlr { |
| 6705 | f_init_handler(pars, t_guard := 30.0); |
| 6706 | var CallParameters cpars; |
| 6707 | |
| 6708 | COORD.receive(REEST_LOST_CONNECTION); |
| 6709 | COORD.receive(tr_CallParams) -> value cpars; |
| 6710 | |
| 6711 | f_gsup_change_connhdlr(hex2str(g_pars.imsi)); |
| 6712 | f_create_smpp_expect(hex2str(pars.msisdn)); |
| 6713 | |
| 6714 | /* The MS has lost the first channel and decides to show up on a new conn (on a nearby neighbor cell) to ask for |
| 6715 | * CM Re-Establishment. Send a Complete Layer 3 to osmo-msc with a CM Re-Establishment Request. */ |
| 6716 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 6717 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_REESTABL_REQ(mi)); |
| 6718 | f_cl3_or_initial_ue(l3_info); |
| 6719 | |
| 6720 | /* At this point the other test component should receive the Clear Command for the first A connection. */ |
| 6721 | |
| 6722 | /* This new connection continues with Authentication... */ |
| 6723 | f_mm_common(); |
| 6724 | |
| 6725 | /* ...and with Assignment of a voice channel. */ |
| 6726 | var template BSSMAP_IE_AoIP_TransportLayerAddress tla_ass := |
Neels Hofmeyr | 02d513e | 2022-07-25 22:07:24 +0200 | [diff] [blame] | 6727 | (f_tr_BSSMAP_IE_AoIP_TLA(cpars.mgw_conn_1.mgw_rtp_ip, ?), |
| 6728 | f_tr_BSSMAP_IE_AoIP_TLA(cpars.mgw_conn_2.mgw_rtp_ip, ?)); |
Neels Hofmeyr | 4f099b4 | 2021-07-27 03:45:26 +0200 | [diff] [blame] | 6729 | BSSAP.receive(tr_BSSMAP_AssignmentReq(omit, tla_ass)); |
| 6730 | /* By this Assignment Request, the CM Re-Establishment Request is implicitly accepted. */ |
| 6731 | |
| 6732 | /* Send Assignment Complete from BSC */ |
| 6733 | var template BSSMAP_IE_AoIP_TransportLayerAddress tla; |
| 6734 | tla := f_ts_BSSMAP_IE_AoIP_TLA(cpars.bss_rtp_ip, cpars.bss_rtp_port); |
| 6735 | var BSSMAP_IE_SpeechCodec codec; |
| 6736 | codec := valueof(ts_BSSMAP_IE_SpeechCodec({ts_CodecFR})); |
| 6737 | |
| 6738 | /* Make really sure the other component is done with its MGCP */ |
| 6739 | COORD.receive(REEST_CLEARED); |
| 6740 | |
| 6741 | /* Transfer state for this call over to this test component so we can resolve MNCC and MGCP in this function. */ |
| 6742 | f_mncc_change_connhdlr(cpars.mncc_callref); |
| 6743 | f_mgcp_change_connhdlr(cpars.mgcp_ep); |
| 6744 | |
| 6745 | /* osmo-msc may redirect the MGW endpoint to the newly allocated channel. |
| 6746 | * Apparently osmo-msc currently also sends an MDCX to the CN side, just repeating the same configuration that |
| 6747 | * is already in use. This test accepts any number of or even lack of MDCX. */ |
| 6748 | var default ack_mdcx := activate(as_mgcp_ack_all_mdcx(cpars)); |
Neels Hofmeyr | 3ad76a4 | 2022-08-09 02:57:49 +0200 | [diff] [blame] | 6749 | var default optional_rtp_create := activate(as_mncc_rx_rtp_create(cpars)); |
Neels Hofmeyr | 4f099b4 | 2021-07-27 03:45:26 +0200 | [diff] [blame] | 6750 | |
| 6751 | BSSAP.send(ts_BSSMAP_AssignmentComplete(omit, tla, codec)); |
Neels Hofmeyr | 3ad76a4 | 2022-08-09 02:57:49 +0200 | [diff] [blame] | 6752 | |
Neels Hofmeyr | 4f099b4 | 2021-07-27 03:45:26 +0200 | [diff] [blame] | 6753 | /* The call has been fully re-established. |
| 6754 | * Let a bit of time pass before hanging up, for everything to settle. */ |
| 6755 | f_sleep(3.0); |
| 6756 | |
Neels Hofmeyr | 3ad76a4 | 2022-08-09 02:57:49 +0200 | [diff] [blame] | 6757 | deactivate(optional_rtp_create); |
Neels Hofmeyr | 4f099b4 | 2021-07-27 03:45:26 +0200 | [diff] [blame] | 6758 | deactivate(ack_mdcx); |
| 6759 | |
| 6760 | /* Hang up the call and clear the new, second A connection */ |
| 6761 | var default ack_dlcx := activate(as_mgcp_ack_all_dlcx(cpars)); |
| 6762 | |
| 6763 | /* CC release. This is the proper MS initiated release sequence as shown by |
| 6764 | * https://git.osmocom.org/osmo-msc/tree/doc/sequence_charts/voice_call_full.msc?id=e53ecde83e4fb2470209e818e9ad76a2d6a19190 |
| 6765 | * f_call_hangup() seems a bit mixed up, so here a "proper" sequence. Fix of f_call_hangup() pending. */ |
| 6766 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_DISC(cpars.transaction_id, '0'B, '0000000'B))); |
| 6767 | MNCC.receive(tr_MNCC_DISC_ind(cpars.mncc_callref)); |
| 6768 | MNCC.send(ts_MNCC_REL_req(cpars.mncc_callref, valueof(ts_MNCC_cause(23)))); |
| 6769 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))); |
| 6770 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_REL_COMPL(cpars.transaction_id, '0'B))); |
| 6771 | MNCC.receive(tr_MNCC_REL_cnf(cpars.mncc_callref, cause := *)); |
| 6772 | |
| 6773 | /* BSSAP clear */ |
| 6774 | interleave { |
| 6775 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 6776 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 6777 | } |
| 6778 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 6779 | } |
| 6780 | |
| 6781 | f_sleep(1.0); |
| 6782 | deactivate(ack_dlcx); |
| 6783 | } |
| 6784 | |
| 6785 | testcase TC_call_re_establishment() runs on MTC_CT { |
| 6786 | var BSC_ConnHdlr vc_conn1; |
| 6787 | var BSC_ConnHdlr vc_conn2; |
| 6788 | f_init(); |
| 6789 | |
| 6790 | var BSC_ConnHdlrPars pars1 := f_init_pars(91); |
| 6791 | var BSC_ConnHdlrPars pars2 := pars1; |
| 6792 | |
| 6793 | vc_conn1 := f_start_handler_create(pars1); |
| 6794 | vc_conn2 := f_start_handler_create(pars2); |
| 6795 | connect(vc_conn1:COORD, vc_conn2:COORD); |
| 6796 | f_start_handler_run(vc_conn1, refers(f_tc_call_re_establishment_1), pars1); |
| 6797 | f_start_handler_run(vc_conn2, refers(f_tc_call_re_establishment_2), pars2); |
| 6798 | vc_conn1.done; |
| 6799 | vc_conn2.done; |
| 6800 | } |
| 6801 | |
Neels Hofmeyr | a9b2dcf | 2021-07-28 00:57:58 +0200 | [diff] [blame] | 6802 | testcase TC_call_re_establishment_auth() runs on MTC_CT { |
| 6803 | var BSC_ConnHdlr vc_conn1; |
| 6804 | var BSC_ConnHdlr vc_conn2; |
| 6805 | f_init(); |
| 6806 | |
| 6807 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6808 | |
| 6809 | var BSC_ConnHdlrPars pars1 := f_init_pars(92); |
| 6810 | pars1.net.expect_auth := true; |
| 6811 | var BSC_ConnHdlrPars pars2 := pars1; |
| 6812 | |
| 6813 | vc_conn1 := f_start_handler_create(pars1); |
| 6814 | vc_conn2 := f_start_handler_create(pars2); |
| 6815 | connect(vc_conn1:COORD, vc_conn2:COORD); |
| 6816 | f_start_handler_run(vc_conn1, refers(f_tc_call_re_establishment_1), pars1); |
| 6817 | f_start_handler_run(vc_conn2, refers(f_tc_call_re_establishment_2), pars2); |
| 6818 | vc_conn1.done; |
| 6819 | vc_conn2.done; |
| 6820 | } |
| 6821 | |
Neels Hofmeyr | 48e4d7d | 2021-07-28 00:57:58 +0200 | [diff] [blame] | 6822 | testcase TC_call_re_establishment_ciph() runs on MTC_CT { |
| 6823 | var BSC_ConnHdlr vc_conn1; |
| 6824 | var BSC_ConnHdlr vc_conn2; |
| 6825 | f_init(); |
| 6826 | |
| 6827 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6828 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 6829 | |
| 6830 | var BSC_ConnHdlrPars pars1 := f_init_pars(92); |
| 6831 | pars1.net.expect_auth := true; |
| 6832 | pars1.net.expect_ciph := true; |
| 6833 | pars1.net.kc_support := '08'O; /* A5/3 only */ |
| 6834 | var BSC_ConnHdlrPars pars2 := pars1; |
| 6835 | |
| 6836 | vc_conn1 := f_start_handler_create(pars1); |
| 6837 | vc_conn2 := f_start_handler_create(pars2); |
| 6838 | connect(vc_conn1:COORD, vc_conn2:COORD); |
| 6839 | f_start_handler_run(vc_conn1, refers(f_tc_call_re_establishment_1), pars1); |
| 6840 | f_start_handler_run(vc_conn2, refers(f_tc_call_re_establishment_2), pars2); |
| 6841 | vc_conn1.done; |
| 6842 | vc_conn2.done; |
| 6843 | } |
| 6844 | |
Neels Hofmeyr | 07ea7f2 | 2022-05-05 01:39:26 +0200 | [diff] [blame] | 6845 | /* Establish a conn with a valid Mobile Identity. Then send a CM Service Request containing a mismatching Mobile |
| 6846 | * Identity on the same conn. Caused a crash, see OS#5532. */ |
| 6847 | friend function f_tc_cm_serv_wrong_mi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6848 | f_init_handler(pars); |
| 6849 | |
| 6850 | /* Set up a fully identified conn */ |
| 6851 | f_perform_lu(); |
| 6852 | f_establish_fully(); |
| 6853 | |
| 6854 | /* CM Serv Req with mismatching Mobile Identity */ |
| 6855 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(99999))); /* ensure it is different from below*/ |
| 6856 | BSSAP.send(ts_PDU_DTAP_MO(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, mi))); |
| 6857 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)); |
| 6858 | |
| 6859 | /* Cancel the first CM Service from f_establish_fully() */ |
| 6860 | BSSAP.send(ts_BSSMAP_ClearRequest(0)); |
| 6861 | |
| 6862 | f_expect_clear(); |
| 6863 | } |
| 6864 | testcase TC_cm_serv_wrong_mi() runs on MTC_CT { |
| 6865 | var BSC_ConnHdlr vc_conn; |
| 6866 | f_init(); |
| 6867 | vc_conn := f_start_handler(refers(f_tc_cm_serv_wrong_mi), 94); |
| 6868 | vc_conn.done; |
| 6869 | } |
| 6870 | |
Neels Hofmeyr | e860fc4 | 2022-10-05 01:15:54 +0200 | [diff] [blame] | 6871 | /* a5 0 a5 0 a5 0 3 a5 0 3 a5 3 a5 3 |
| 6872 | * HLR has auth info no yes no yes no yes |
| 6873 | * |
| 6874 | * test case index [0] [1] [2] [3] [4] [5] |
| 6875 | * authentication optional No auth No auth attempt auth, auth reject auth |
| 6876 | * (%) fall back to +ciph +ciph |
| 6877 | * no-auth |
| 6878 | * |
| 6879 | * [6] [7] [8] [9] [10] [11] |
| 6880 | * authentication mandatory reject auth reject auth reject auth |
| 6881 | * only +ciph +ciph |
| 6882 | * |
| 6883 | * (%): Arguably, when HLR has auth info, the MSC should use it. Current behavior of osmo-msc is to not attempt auth at |
| 6884 | * all. Related: OS#4830. |
| 6885 | */ |
| 6886 | type record of BSC_ConnHdlrNetworkPars rof_netpars; |
| 6887 | |
| 6888 | const rof_netpars auth_options_testcases := { |
| 6889 | { |
| 6890 | /* [0] auth optional, encr a5 0: no-auth" */ |
| 6891 | kc_support := '01'O, |
| 6892 | net_config := { "authentication optional", |
| 6893 | "encryption a5 0" }, |
| 6894 | expect_attach_success := true, |
| 6895 | expect_tmsi := true, |
| 6896 | expect_auth_attempt := false, |
| 6897 | hlr_has_auth_info := false, |
| 6898 | expect_auth := false, |
| 6899 | expect_ciph := false, |
| 6900 | expect_imei := false, |
| 6901 | expect_imei_early := false, |
| 6902 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 6903 | check_imei_error := false |
| 6904 | }, |
| 6905 | { |
| 6906 | /* [1] auth optional, encr a5 0, HLR HAS auth info: no-auth */ |
| 6907 | kc_support := '01'O, |
| 6908 | net_config := { "authentication optional", |
| 6909 | "encryption a5 0" }, |
| 6910 | expect_attach_success := true, |
| 6911 | expect_tmsi := true, |
| 6912 | expect_auth_attempt := false, |
| 6913 | hlr_has_auth_info := true, |
| 6914 | expect_auth := false, |
| 6915 | expect_ciph := false, |
| 6916 | expect_imei := false, |
| 6917 | expect_imei_early := false, |
| 6918 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 6919 | check_imei_error := false |
| 6920 | }, |
| 6921 | { |
| 6922 | /* [2] auth optional, encr a5 0 3, HLR has NO Auth Info: Fall back to no-auth" */ |
| 6923 | kc_support := '09'O, |
| 6924 | net_config := { "authentication optional", |
| 6925 | "encryption a5 0 3" }, |
| 6926 | expect_attach_success := true, |
| 6927 | expect_tmsi := true, |
| 6928 | expect_auth_attempt := true, |
| 6929 | hlr_has_auth_info := false, |
| 6930 | expect_auth := false, |
| 6931 | expect_ciph := false, |
| 6932 | expect_imei := false, |
| 6933 | expect_imei_early := false, |
| 6934 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 6935 | check_imei_error := false |
| 6936 | }, |
| 6937 | { |
| 6938 | /* [3] auth optional, encr a5 0 3, HLR HAS Auth Info: Use A5/3 */ |
| 6939 | kc_support := '09'O, |
| 6940 | net_config := { "authentication optional", |
| 6941 | "encryption a5 0 3" }, |
| 6942 | expect_attach_success := true, |
| 6943 | expect_tmsi := true, |
| 6944 | expect_auth_attempt := true, |
| 6945 | hlr_has_auth_info := true, |
| 6946 | expect_auth := true, |
| 6947 | expect_ciph := true, |
| 6948 | expect_imei := false, |
| 6949 | expect_imei_early := false, |
| 6950 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 6951 | check_imei_error := false |
| 6952 | }, |
| 6953 | { |
| 6954 | /* [4] auth optional, encr a5 3, HLR has NO Auth Info: reject. |
| 6955 | * Auth is required implicitly because ciph is required. */ |
| 6956 | kc_support := '08'O, |
| 6957 | net_config := { "authentication optional", |
| 6958 | "encryption a5 3" }, |
| 6959 | expect_attach_success := false, |
| 6960 | expect_tmsi := true, |
| 6961 | expect_auth_attempt := true, |
| 6962 | hlr_has_auth_info := false, |
| 6963 | expect_auth := false, |
| 6964 | expect_ciph := false, |
| 6965 | expect_imei := false, |
| 6966 | expect_imei_early := false, |
| 6967 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 6968 | check_imei_error := false |
| 6969 | }, |
| 6970 | { |
| 6971 | /* [5] auth optional, encr a5 3, HLR HAS Auth Info: auth + ciph. |
| 6972 | * Auth is required implicitly because ciph is required. */ |
| 6973 | kc_support := '08'O, |
| 6974 | net_config := { "authentication optional", |
| 6975 | "encryption a5 3" }, |
| 6976 | expect_attach_success := true, |
| 6977 | expect_tmsi := true, |
| 6978 | expect_auth_attempt := true, |
| 6979 | hlr_has_auth_info := true, |
| 6980 | expect_auth := true, |
| 6981 | expect_ciph := true, |
| 6982 | expect_imei := false, |
| 6983 | expect_imei_early := false, |
| 6984 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 6985 | check_imei_error := false |
| 6986 | }, |
| 6987 | |
| 6988 | /* Same as above, but with 'authentication required' */ |
| 6989 | |
| 6990 | { |
| 6991 | /* [6] auth required, encr a5 0, HLR has NO auth info: reject */ |
| 6992 | kc_support := '01'O, |
| 6993 | net_config := { "authentication required", |
| 6994 | "encryption a5 0" }, |
| 6995 | expect_attach_success := false, |
| 6996 | expect_tmsi := true, |
| 6997 | expect_auth_attempt := true, |
| 6998 | hlr_has_auth_info := false, |
| 6999 | expect_auth := false, |
| 7000 | expect_ciph := false, |
| 7001 | expect_imei := false, |
| 7002 | expect_imei_early := false, |
| 7003 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 7004 | check_imei_error := false |
| 7005 | }, |
| 7006 | { |
| 7007 | /* [7] auth required, encr a5 0, HLR HAS auth info: do auth, no ciph" */ |
| 7008 | kc_support := '01'O, |
| 7009 | net_config := { "authentication required", |
| 7010 | "encryption a5 0" }, |
| 7011 | expect_attach_success := true, |
| 7012 | expect_tmsi := true, |
| 7013 | expect_auth_attempt := true, |
| 7014 | hlr_has_auth_info := true, |
| 7015 | expect_auth := true, |
| 7016 | expect_ciph := false, |
| 7017 | expect_imei := false, |
| 7018 | expect_imei_early := false, |
| 7019 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 7020 | check_imei_error := false |
| 7021 | }, |
| 7022 | { |
| 7023 | /* [8] auth required, encr a5 0 3, HLR has NO Auth Info: reject */ |
| 7024 | kc_support := '09'O, |
| 7025 | net_config := { "authentication required", |
| 7026 | "encryption a5 0 3" }, |
| 7027 | expect_attach_success := false, |
| 7028 | expect_tmsi := true, |
| 7029 | expect_auth_attempt := true, |
| 7030 | hlr_has_auth_info := false, |
| 7031 | expect_auth := false, |
| 7032 | expect_ciph := false, |
| 7033 | expect_imei := false, |
| 7034 | expect_imei_early := false, |
| 7035 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 7036 | check_imei_error := false |
| 7037 | }, |
| 7038 | { |
| 7039 | /* [9] auth required, encr a5 0 3, HLR HAS Auth Info: Use A5/3 */ |
| 7040 | kc_support := '09'O, |
| 7041 | net_config := { "authentication required", |
| 7042 | "encryption a5 0 3" }, |
| 7043 | expect_attach_success := true, |
| 7044 | expect_tmsi := true, |
| 7045 | expect_auth_attempt := true, |
| 7046 | hlr_has_auth_info := true, |
| 7047 | expect_auth := true, |
| 7048 | expect_ciph := true, |
| 7049 | expect_imei := false, |
| 7050 | expect_imei_early := false, |
| 7051 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 7052 | check_imei_error := false |
| 7053 | }, |
| 7054 | { |
| 7055 | /* [10] auth required, encr a5 3, HLR has NO Auth Info: reject. */ |
| 7056 | kc_support := '08'O, |
| 7057 | net_config := { "authentication required", |
| 7058 | "encryption a5 3" }, |
| 7059 | expect_attach_success := false, |
| 7060 | expect_tmsi := true, |
| 7061 | expect_auth_attempt := true, |
| 7062 | hlr_has_auth_info := false, |
| 7063 | expect_auth := false, |
| 7064 | expect_ciph := false, |
| 7065 | expect_imei := false, |
| 7066 | expect_imei_early := false, |
| 7067 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 7068 | check_imei_error := false |
| 7069 | }, |
| 7070 | { |
| 7071 | /* [11] auth required, encr a5 3, HLR HAS Auth Info: auth + ciph. */ |
| 7072 | kc_support := '08'O, |
| 7073 | net_config := { "authentication required", |
| 7074 | "encryption a5 3" }, |
| 7075 | expect_attach_success := true, |
| 7076 | expect_tmsi := true, |
| 7077 | expect_auth_attempt := true, |
| 7078 | hlr_has_auth_info := true, |
| 7079 | expect_auth := true, |
| 7080 | expect_ciph := true, |
| 7081 | expect_imei := false, |
| 7082 | expect_imei_early := false, |
| 7083 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 7084 | check_imei_error := false |
| 7085 | } |
| 7086 | }; |
| 7087 | |
| 7088 | private function f_tc_auth_options(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 7089 | f_init_handler(pars); |
| 7090 | |
| 7091 | /* Location Updating */ |
| 7092 | log(MSCVTY, "f_perform_lu() starting"); |
| 7093 | f_perform_lu(); |
| 7094 | log(MSCVTY, "f_perform_lu() done"); |
| 7095 | |
| 7096 | f_sleep(1.0); |
| 7097 | |
| 7098 | if (not pars.net.expect_attach_success) { |
| 7099 | /* Expected above LU to fail. In order to test CM Service Request below, a LU has to succeed first. So |
| 7100 | * run another LU that will be successful. Careful not to load auth tokens into the VLR that may taint |
| 7101 | * the test for CM Service Request below. */ |
| 7102 | |
| 7103 | log(MSCVTY, "Running a successful LU so that CM Service Request can be tested"); |
| 7104 | var BSC_ConnHdlrNetworkPars saved_net := g_pars.net; |
| 7105 | g_pars.net.kc_support := '01'O; |
| 7106 | g_pars.net.expect_attach_success := true; |
| 7107 | g_pars.net.expect_auth_attempt := false; |
| 7108 | g_pars.net.expect_auth := false; |
| 7109 | g_pars.net.expect_ciph := false; |
| 7110 | f_vty_config3(MSCVTY, {"network"}, {"authentication optional", "encryption a5 0"}); |
| 7111 | f_perform_lu(); |
| 7112 | |
| 7113 | /* Reconfigure like it was before */ |
| 7114 | g_pars.net := saved_net; |
| 7115 | f_vty_config3(MSCVTY, {"network"}, g_pars.net.net_config); |
| 7116 | log(MSCVTY, "Running a successful LU done"); |
| 7117 | } |
| 7118 | |
| 7119 | /* CM Service Request */ |
| 7120 | log(MSCVTY, "f_establish_fully() starting"); |
| 7121 | f_establish_fully(); |
| 7122 | log(MSCVTY, "f_establish_fully() done"); |
| 7123 | BSSAP.send(ts_BSSMAP_ClearRequest(0)); |
| 7124 | f_expect_clear(); |
| 7125 | } |
| 7126 | |
| 7127 | function f_TC_auth_options(integer tc_i) runs on MTC_CT { |
| 7128 | f_init(); |
| 7129 | |
| 7130 | var BSC_ConnHdlrNetworkPars tc := auth_options_testcases[tc_i]; |
| 7131 | |
| 7132 | f_vty_config3(MSCVTY, {"network"}, tc.net_config); |
| 7133 | |
| 7134 | var BSC_ConnHdlrPars pars := f_init_pars(42300 + tc_i); |
| 7135 | pars.net := tc; |
| 7136 | |
| 7137 | var BSC_ConnHdlr vc_conn; |
| 7138 | vc_conn := f_start_handler_with_pars(refers(f_tc_auth_options), pars); |
| 7139 | vc_conn.done; |
| 7140 | } |
| 7141 | |
| 7142 | testcase TC_auth_options_0() runs on MTC_CT { |
| 7143 | f_TC_auth_options(0); |
| 7144 | } |
| 7145 | |
| 7146 | testcase TC_auth_options_1() runs on MTC_CT { |
| 7147 | f_TC_auth_options(1); |
| 7148 | } |
| 7149 | |
| 7150 | testcase TC_auth_options_2() runs on MTC_CT { |
| 7151 | f_TC_auth_options(2); |
| 7152 | } |
| 7153 | |
| 7154 | testcase TC_auth_options_3() runs on MTC_CT { |
| 7155 | f_TC_auth_options(3); |
| 7156 | } |
| 7157 | |
| 7158 | testcase TC_auth_options_4() runs on MTC_CT { |
| 7159 | f_TC_auth_options(4); |
| 7160 | } |
| 7161 | |
| 7162 | testcase TC_auth_options_5() runs on MTC_CT { |
| 7163 | f_TC_auth_options(5); |
| 7164 | } |
| 7165 | |
| 7166 | testcase TC_auth_options_6() runs on MTC_CT { |
| 7167 | f_TC_auth_options(6); |
| 7168 | } |
| 7169 | |
| 7170 | testcase TC_auth_options_7() runs on MTC_CT { |
| 7171 | f_TC_auth_options(7); |
| 7172 | } |
| 7173 | |
| 7174 | testcase TC_auth_options_8() runs on MTC_CT { |
| 7175 | f_TC_auth_options(8); |
| 7176 | } |
| 7177 | |
| 7178 | testcase TC_auth_options_9() runs on MTC_CT { |
| 7179 | f_TC_auth_options(9); |
| 7180 | } |
| 7181 | |
| 7182 | testcase TC_auth_options_10() runs on MTC_CT { |
| 7183 | f_TC_auth_options(10); |
| 7184 | } |
| 7185 | |
| 7186 | testcase TC_auth_options_11() runs on MTC_CT { |
| 7187 | f_TC_auth_options(11); |
| 7188 | } |
| 7189 | |
Oliver Smith | 92b280c | 2023-04-20 13:13:23 +0200 | [diff] [blame] | 7190 | friend function f_tc_lu_and_mo_csd(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 7191 | f_init_handler(pars); |
| 7192 | var CallParameters cpars := valueof(t_CallParams); |
| 7193 | cpars.csd := true; |
| 7194 | f_perform_lu(); |
| 7195 | f_mo_call(cpars); |
| 7196 | } |
| 7197 | testcase TC_lu_and_mo_csd() runs on MTC_CT { |
| 7198 | var BSC_ConnHdlr vc_conn; |
| 7199 | f_init(); |
| 7200 | |
| 7201 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_csd), 7); |
| 7202 | vc_conn.done; |
| 7203 | } |
| 7204 | |
Oliver Smith | c1dd36a | 2023-05-31 13:52:24 +0200 | [diff] [blame] | 7205 | friend function f_tc_lu_and_mt_csd(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 7206 | f_init_handler(pars); |
| 7207 | var CallParameters cpars := valueof(t_CallParams); |
| 7208 | cpars.csd := true; |
| 7209 | f_perform_lu(); |
| 7210 | f_mt_call(cpars); |
| 7211 | } |
| 7212 | testcase TC_lu_and_mt_csd() runs on MTC_CT { |
| 7213 | var BSC_ConnHdlr vc_conn; |
| 7214 | f_init(); |
| 7215 | |
| 7216 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_csd), 7); |
| 7217 | vc_conn.done; |
| 7218 | } |
| 7219 | |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 7220 | control { |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 7221 | execute( TC_cr_before_reset() ); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 7222 | execute( TC_lu_imsi_noauth_tmsi() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 7223 | execute( TC_lu_imsi_noauth_notmsi() ); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 7224 | execute( TC_lu_imsi_reject() ); |
| 7225 | execute( TC_lu_imsi_timeout_gsup() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 7226 | execute( TC_lu_imsi_auth_tmsi() ); |
Harald Welte | 8a397ae | 2019-04-21 22:03:37 +0200 | [diff] [blame] | 7227 | execute( TC_lu_imsi_auth3g_tmsi() ); |
Pau Espin Pedrol | d3d54a9 | 2019-12-17 17:02:54 +0100 | [diff] [blame] | 7228 | execute( TC_lu_imsi_timeout_tmsi_realloc() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 7229 | execute( TC_cmserv_imsi_unknown() ); |
Neels Hofmeyr | 13737fb | 2020-08-19 13:16:14 +0000 | [diff] [blame] | 7230 | execute( TC_cmserv_tmsi_unknown() ); |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 7231 | execute( TC_lu_and_mo_call() ); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 7232 | execute( TC_lu_and_mo_call_ipv6() ); |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 7233 | execute( TC_lu_and_mo_call_sccp_tiar_timeout() ); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 7234 | execute( TC_lu_auth_sai_timeout() ); |
| 7235 | execute( TC_lu_auth_sai_err() ); |
Harald Welte | e1a2f3c | 2018-01-24 17:28:48 +0100 | [diff] [blame] | 7236 | execute( TC_lu_clear_request() ); |
Vadim Yanitskiy | 109e755 | 2021-02-05 05:36:02 +0100 | [diff] [blame] | 7237 | execute( TC_mo_call_clear_request() ); |
| 7238 | execute( TC_mt_call_clear_request() ); |
Harald Welte | e1a2f3c | 2018-01-24 17:28:48 +0100 | [diff] [blame] | 7239 | execute( TC_lu_disconnect() ); |
| 7240 | execute( TC_lu_by_imei() ); |
| 7241 | execute( TC_lu_by_tmsi_noauth_unknown() ); |
Neels Hofmeyr | fc06c73 | 2020-08-19 12:52:28 +0000 | [diff] [blame] | 7242 | execute( TC_attached_imsi_lu_unknown_tmsi() ); |
Harald Welte | e1a2f3c | 2018-01-24 17:28:48 +0100 | [diff] [blame] | 7243 | execute( TC_imsi_detach_by_imsi() ); |
| 7244 | execute( TC_imsi_detach_by_tmsi() ); |
| 7245 | execute( TC_imsi_detach_by_imei() ); |
| 7246 | execute( TC_emerg_call_imei_reject() ); |
| 7247 | execute( TC_emerg_call_imsi() ); |
| 7248 | execute( TC_cm_serv_req_vgcs_reject() ); |
| 7249 | execute( TC_cm_serv_req_vbs_reject() ); |
| 7250 | execute( TC_cm_serv_req_lcs_reject() ); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 7251 | execute( TC_cm_reest_req_reject() ); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 7252 | execute( TC_lu_auth_2G_fail() ); |
| 7253 | execute( TC_lu_imsi_auth_tmsi_encr_13_13() ); |
| 7254 | execute( TC_cl3_no_payload() ); |
| 7255 | execute( TC_cl3_rnd_payload() ); |
Harald Welte | 1852a84 | 2018-01-26 22:53:36 +0100 | [diff] [blame] | 7256 | execute( TC_establish_and_nothing() ); |
| 7257 | execute( TC_mo_setup_and_nothing() ); |
| 7258 | execute( TC_mo_crcx_ran_timeout() ); |
| 7259 | execute( TC_mo_crcx_ran_reject() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 7260 | execute( TC_mt_crcx_ran_reject() ); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 7261 | execute( TC_mo_setup_and_dtmf_dup() ); |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 7262 | execute( TC_mt_t310() ); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 7263 | execute( TC_gsup_cancel() ); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 7264 | execute( TC_lu_imsi_auth_tmsi_encr_1_13() ); |
| 7265 | execute( TC_lu_imsi_auth_tmsi_encr_3_13() ); |
| 7266 | execute( TC_lu_imsi_auth_tmsi_encr_3_1() ); |
Neels Hofmeyr | 29b8da0 | 2018-03-01 18:09:45 +0100 | [diff] [blame] | 7267 | execute( TC_lu_imsi_auth_tmsi_encr_3_1_no_cm() ); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 7268 | execute( TC_lu_imsi_auth_tmsi_encr_13_2() ); |
| 7269 | execute( TC_lu_imsi_auth_tmsi_encr_013_2() ); |
Eric Wild | 26f4a62 | 2021-05-17 15:27:05 +0200 | [diff] [blame] | 7270 | execute( TC_lu_imsi_auth_tmsi_encr_0134_1() ); |
| 7271 | execute( TC_lu_imsi_auth_tmsi_encr_0134_34() ); |
| 7272 | execute( TC_lu_imsi_auth_tmsi_encr_0134_34_no_cm3() ); |
| 7273 | |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 7274 | execute( TC_mo_release_timeout() ); |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 7275 | execute( TC_lu_and_mt_call_no_dlcx_resp() ); |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 7276 | execute( TC_reset_two() ); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 7277 | |
| 7278 | execute( TC_lu_and_mt_call() ); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 7279 | execute( TC_lu_and_mt_call_ipv6() ); |
Neels Hofmeyr | b58d974 | 2019-11-27 18:44:54 +0100 | [diff] [blame] | 7280 | execute( TC_lu_and_mt_call_already_paging() ); |
Pau Espin Pedrol | 9a732a4 | 2020-09-15 15:56:33 +0200 | [diff] [blame] | 7281 | execute( TC_lu_and_mt_call_osmux() ); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 7282 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 7283 | execute( TC_lu_and_mo_sms() ); |
| 7284 | execute( TC_lu_and_mt_sms() ); |
Neels Hofmeyr | b58d974 | 2019-11-27 18:44:54 +0100 | [diff] [blame] | 7285 | execute( TC_lu_and_mt_sms_already_paging() ); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 7286 | execute( TC_lu_and_mt_sms_paging_and_nothing() ); |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 7287 | execute( TC_lu_and_mt_sms_paging_repeated() ); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 7288 | execute( TC_smpp_mo_sms() ); |
Vadim Yanitskiy | 3382076 | 2020-01-15 11:26:07 +0700 | [diff] [blame] | 7289 | execute( TC_smpp_mo_sms_rp_error() ); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 7290 | execute( TC_smpp_mt_sms() ); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 7291 | |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 7292 | execute( TC_gsup_mo_sms() ); |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 7293 | execute( TC_gsup_mo_smma() ); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 7294 | execute( TC_gsup_mt_sms_ack() ); |
| 7295 | execute( TC_gsup_mt_sms_err() ); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 7296 | execute( TC_gsup_mt_sms_rp_mr() ); |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 7297 | execute( TC_gsup_mo_mt_sms_rp_mr() ); |
Vadim Yanitskiy | a2a8a11 | 2019-07-08 20:04:32 +0700 | [diff] [blame] | 7298 | execute( TC_gsup_mt_multi_part_sms() ); |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 7299 | |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 7300 | execute( TC_lu_and_mo_ussd_single_request() ); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 7301 | execute( TC_lu_and_mt_ussd_notification() ); |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 7302 | execute( TC_lu_and_mo_ussd_during_mt_call() ); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 7303 | execute( TC_lu_and_mt_ussd_during_mt_call() ); |
Vadim Yanitskiy | 2daf52d | 2018-06-21 04:19:58 +0700 | [diff] [blame] | 7304 | execute( TC_lu_and_mo_ussd_mo_release() ); |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 7305 | execute( TC_lu_and_ss_session_timeout() ); |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 7306 | |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 7307 | execute( TC_mt_ussd_for_unknown_subscr() ); |
Vadim Yanitskiy | c3c07d4 | 2019-06-17 23:00:44 +0700 | [diff] [blame] | 7308 | execute( TC_mo_ussd_for_unknown_trans() ); |
Vadim Yanitskiy | d612d28 | 2019-06-15 14:46:03 +0700 | [diff] [blame] | 7309 | execute( TC_proc_ss_for_unknown_session() ); |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 7310 | execute( TC_proc_ss_paging_fail() ); |
Vadim Yanitskiy | 29ba8d6 | 2019-06-16 15:19:41 +0700 | [diff] [blame] | 7311 | execute( TC_proc_ss_abort() ); |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 7312 | |
Vadim Yanitskiy | 1c9754d | 2020-01-07 21:56:55 +0100 | [diff] [blame] | 7313 | execute( TC_multi_lu_and_mo_ussd() ); |
| 7314 | execute( TC_multi_lu_and_mt_ussd() ); |
| 7315 | |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 7316 | execute( TC_cipher_complete_with_invalid_cipher() ); |
Stefan Sperling | a2d59c6 | 2018-12-18 16:32:44 +0100 | [diff] [blame] | 7317 | execute( TC_cipher_complete_1_without_cipher() ); |
| 7318 | execute( TC_cipher_complete_3_without_cipher() ); |
| 7319 | execute( TC_cipher_complete_13_without_cipher() ); |
Harald Welte | b2284bd | 2019-05-10 11:30:43 +0200 | [diff] [blame] | 7320 | execute( TC_lu_with_invalid_mcc_mnc() ); |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 7321 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 7322 | execute( TC_sgsap_reset() ); |
| 7323 | execute( TC_sgsap_lu() ); |
| 7324 | execute( TC_sgsap_lu_imsi_reject() ); |
| 7325 | execute( TC_sgsap_lu_and_nothing() ); |
| 7326 | execute( TC_sgsap_expl_imsi_det_eps() ); |
Philipp Maier | fc19f17 | 2019-03-21 11:17:54 +0100 | [diff] [blame] | 7327 | execute( TC_sgsap_impl_imsi_det_eps() ); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 7328 | execute( TC_sgsap_expl_imsi_det_noneps() ); |
Philipp Maier | 5d81270 | 2019-03-21 10:51:26 +0100 | [diff] [blame] | 7329 | execute( TC_sgsap_impl_imsi_det_noneps() ); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 7330 | execute( TC_sgsap_paging_rej() ); |
| 7331 | execute( TC_sgsap_paging_subscr_rej() ); |
| 7332 | execute( TC_sgsap_paging_ue_unr() ); |
| 7333 | execute( TC_sgsap_paging_and_nothing() ); |
| 7334 | execute( TC_sgsap_paging_and_lu() ); |
| 7335 | execute( TC_sgsap_mt_sms() ); |
| 7336 | execute( TC_sgsap_mo_sms() ); |
| 7337 | execute( TC_sgsap_mt_sms_and_nothing() ); |
| 7338 | execute( TC_sgsap_mt_sms_and_reject() ); |
| 7339 | execute( TC_sgsap_unexp_ud() ); |
| 7340 | execute( TC_sgsap_unsol_ud() ); |
| 7341 | execute( TC_bssap_lu_sgsap_lu_and_mt_call() ); |
| 7342 | execute( TC_sgsap_lu_and_mt_call() ); |
Philipp Maier | 628c005 | 2019-04-09 17:36:57 +0200 | [diff] [blame] | 7343 | execute( TC_sgsap_vlr_failure() ); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 7344 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 7345 | execute( TC_ho_inter_bsc_unknown_cell() ); |
| 7346 | execute( TC_ho_inter_bsc() ); |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 7347 | execute( TC_ho_inter_bsc_a5_1() ); |
| 7348 | execute( TC_ho_inter_bsc_a5_3() ); |
| 7349 | execute( TC_ho_inter_bsc_a5_4() ); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 7350 | execute( TC_ho_inter_bsc_ipv6() ); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 7351 | |
| 7352 | execute( TC_ho_inter_msc_out() ); |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 7353 | execute( TC_ho_inter_msc_out_a5_1() ); |
| 7354 | execute( TC_ho_inter_msc_out_a5_3() ); |
| 7355 | execute( TC_ho_inter_msc_out_a5_4() ); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 7356 | execute( TC_ho_inter_msc_out_ipv6() ); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 7357 | |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 7358 | execute( TC_lu_imsi_auth_tmsi_check_imei() ); |
| 7359 | execute( TC_lu_imsi_auth3g_tmsi_check_imei() ); |
| 7360 | execute( TC_lu_imsi_noauth_tmsi_check_imei() ); |
| 7361 | execute( TC_lu_imsi_noauth_notmsi_check_imei() ); |
| 7362 | execute( TC_lu_imsi_auth_tmsi_check_imei_nack() ); |
| 7363 | execute( TC_lu_imsi_auth_tmsi_check_imei_err() ); |
| 7364 | execute( TC_lu_imsi_auth_tmsi_check_imei_early() ); |
| 7365 | execute( TC_lu_imsi_auth3g_tmsi_check_imei_early() ); |
| 7366 | execute( TC_lu_imsi_noauth_tmsi_check_imei_early() ); |
| 7367 | execute( TC_lu_imsi_noauth_notmsi_check_imei_early() ); |
| 7368 | execute( TC_lu_imsi_auth_tmsi_check_imei_early_nack() ); |
| 7369 | execute( TC_lu_imsi_auth_tmsi_check_imei_early_err() ); |
Neels Hofmeyr | 1b3c6e3 | 2018-03-01 17:52:21 +0100 | [diff] [blame] | 7370 | execute( TC_lu_imsi_auth_tmsi_encr_3_1_log_msc_debug() ); |
Pau Espin Pedrol | 609f1d6 | 2020-09-15 16:01:55 +0200 | [diff] [blame] | 7371 | |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 7372 | execute( TC_mo_cc_bssmap_clear() ); |
Neels Hofmeyr | 8df6962 | 2019-11-02 19:16:03 +0100 | [diff] [blame] | 7373 | execute( TC_invalid_mgcp_crash() ); |
Vadim Yanitskiy | eddebaa | 2019-12-28 17:45:34 +0100 | [diff] [blame] | 7374 | execute( TC_mm_id_resp_no_identity() ); |
Vadim Yanitskiy | 2521906 | 2020-01-21 01:41:33 +0700 | [diff] [blame] | 7375 | execute( TC_lu_and_expire_while_paging() ); |
Pau Espin Pedrol | 174fac2 | 2021-02-26 13:20:10 +0100 | [diff] [blame] | 7376 | execute( TC_paging_response_imsi_unknown() ); |
| 7377 | execute( TC_paging_response_tmsi_unknown() ); |
Neels Hofmeyr | 4f099b4 | 2021-07-27 03:45:26 +0200 | [diff] [blame] | 7378 | |
| 7379 | execute( TC_call_re_establishment() ); |
Neels Hofmeyr | a9b2dcf | 2021-07-28 00:57:58 +0200 | [diff] [blame] | 7380 | execute( TC_call_re_establishment_auth() ); |
Neels Hofmeyr | 48e4d7d | 2021-07-28 00:57:58 +0200 | [diff] [blame] | 7381 | execute( TC_call_re_establishment_ciph() ); |
Neels Hofmeyr | 07ea7f2 | 2022-05-05 01:39:26 +0200 | [diff] [blame] | 7382 | |
| 7383 | execute( TC_cm_serv_wrong_mi() ); |
Neels Hofmeyr | e860fc4 | 2022-10-05 01:15:54 +0200 | [diff] [blame] | 7384 | |
| 7385 | execute( TC_auth_options_0() ); |
| 7386 | execute( TC_auth_options_1() ); |
| 7387 | execute( TC_auth_options_2() ); |
| 7388 | execute( TC_auth_options_3() ); |
| 7389 | execute( TC_auth_options_4() ); |
| 7390 | execute( TC_auth_options_5() ); |
| 7391 | execute( TC_auth_options_6() ); |
| 7392 | execute( TC_auth_options_7() ); |
| 7393 | execute( TC_auth_options_8() ); |
| 7394 | execute( TC_auth_options_9() ); |
| 7395 | execute( TC_auth_options_10() ); |
| 7396 | execute( TC_auth_options_11() ); |
Oliver Smith | 92b280c | 2023-04-20 13:13:23 +0200 | [diff] [blame] | 7397 | |
| 7398 | execute( TC_lu_and_mo_csd() ); |
Oliver Smith | c1dd36a | 2023-05-31 13:52:24 +0200 | [diff] [blame] | 7399 | execute( TC_lu_and_mt_csd() ); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 7400 | } |
| 7401 | |
| 7402 | |
| 7403 | } |