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 | |
| 327 | for (var integer i := 0; i < num_bsc; i := i + 1) { |
| 328 | if (isbound(mp_bssap_cfg[i])) { |
| 329 | var RanOps ranops := BSC_RanOps; |
| 330 | ranops.use_osmux := osmux; |
Eric Wild | 49888a6 | 2022-03-30 03:16:11 +0200 | [diff] [blame] | 331 | ranops.bssap_reset_retries := mp_bssap_reset_retries; |
Daniel Willmann | 0886215 | 2022-02-22 13:21:49 +0100 | [diff] [blame] | 332 | f_ran_adapter_init(g_bssap[i], mp_bssap_cfg[i], "MSC_Test_" & int2str(i), ranops); |
| 333 | f_ran_adapter_start(g_bssap[i]); |
| 334 | } else { |
| 335 | testcase.stop("missing BSSAP configuration"); |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | f_init_mncc("MSC_Test"); |
| 340 | f_init_mgcp("MSC_Test"); |
| 341 | |
| 342 | if (gsup == true) { |
| 343 | f_init_gsup("MSC_Test"); |
| 344 | } |
| 345 | f_init_smpp("MSC_Test"); |
| 346 | |
| 347 | if (sgsap == true) { |
| 348 | f_init_sgsap("MSC_Test"); |
| 349 | } |
| 350 | |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 351 | } |
| 352 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 353 | /* Initialize for a direct connection to BSSAP. This function is an alternative |
| 354 | * to f_init() when the high level functions of the BSC_ConnectionHandler are |
| 355 | * not needed. */ |
| 356 | function f_init_bssap_direct() runs on MTC_CT { |
Harald Welte | 3ca0ce1 | 2019-04-23 17:18:48 +0200 | [diff] [blame] | 357 | 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] | 358 | connect(g_bssap[0].vc_SCCP:SCCP_SP_PORT, self:BSSAP_DIRECT); |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 359 | |
| 360 | /* Start guard timer and activate it as default */ |
| 361 | Tguard_direct.start |
| 362 | activate(as_Tguard_direct()); |
| 363 | } |
| 364 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 365 | 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] | 366 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 367 | /* FIXME: move into BSC_ConnectionHandler? */ |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 368 | 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] | 369 | boolean ran_is_geran := true, boolean use_osmux := false, OCT4 gsup_sid := '20000101'O, |
| 370 | boolean verify_cell_id := true) |
Harald Welte | f9abf8d | 2019-04-21 13:07:17 +0200 | [diff] [blame] | 371 | runs on MTC_CT return BSC_ConnHdlrPars { |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 372 | var BSC_ConnHdlrNetworkPars net_pars := { |
| 373 | kc_support := '0A'O, /* A5/1 and A5/3 enabled */ |
| 374 | expect_tmsi := true, |
| 375 | expect_auth := false, |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 376 | expect_ciph := false, |
| 377 | expect_imei := false, |
| 378 | expect_imei_early := false, |
| 379 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 380 | check_imei_error := false |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 381 | }; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 382 | var BSC_ConnHdlrPars pars := { |
Harald Welte | f9abf8d | 2019-04-21 13:07:17 +0200 | [diff] [blame] | 383 | sccp_addr_own := g_bssap[ran_idx].sccp_addr_own, |
| 384 | sccp_addr_peer := g_bssap[ran_idx].sccp_addr_peer, |
Harald Welte | edbab81 | 2018-03-18 16:02:25 +0100 | [diff] [blame] | 385 | cell_id := valueof(ts_CellId_CGI('262'H, '42'H, 23, 42)), |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 386 | imei := f_gen_imei(imsi_suffix), |
| 387 | imsi := f_gen_imsi(imsi_suffix), |
| 388 | msisdn := f_gen_msisdn(imsi_suffix), |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 389 | tmsi := omit, |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 390 | cm1 := valueof(ts_CM1), |
Harald Welte | 8260057 | 2018-01-21 20:54:08 +0100 | [diff] [blame] | 391 | cm2 := valueof(ts_CM2_default), |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 392 | cm3 := omit, |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 393 | vec := omit, |
Neels Hofmeyr | b00c5b0 | 2021-06-23 20:05:25 +0200 | [diff] [blame] | 394 | vec_keep := false, |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 395 | net := net_pars, |
Philipp Maier | aeb29a8 | 2018-11-08 17:40:53 +0100 | [diff] [blame] | 396 | send_early_cm := true, |
| 397 | ipa_ctrl_ip := mp_msc_ip, |
| 398 | ipa_ctrl_port := mp_msc_ctrl_port, |
Philipp Maier | 9b690e4 | 2018-12-21 11:50:03 +0100 | [diff] [blame] | 399 | ipa_ctrl_enable := true, |
Philipp Maier | 5786548 | 2019-01-07 18:33:13 +0100 | [diff] [blame] | 400 | mm_info := mp_mm_info, |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 401 | sgsap_enable := sgsap, |
Harald Welte | f9abf8d | 2019-04-21 13:07:17 +0200 | [diff] [blame] | 402 | gsup_enable := gsup, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 403 | gsup_sid := gsup_sid, |
Harald Welte | c1f937a | 2019-04-21 21:19:23 +0200 | [diff] [blame] | 404 | ran_idx := ran_idx, |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 405 | use_umts_aka := false, |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 406 | ran_is_geran := ran_is_geran, |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 407 | use_osmux := use_osmux, |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 408 | use_ipv6 := false, |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 409 | verify_cell_id := verify_cell_id, |
| 410 | common_id_last_eutran_plmn := omit |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 411 | }; |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 412 | if (not ran_is_geran) { |
| 413 | pars.use_umts_aka := true; |
| 414 | pars.net.expect_auth := true; |
| 415 | } |
Neels Hofmeyr | 9adaa70 | 2018-03-01 20:23:19 +0100 | [diff] [blame] | 416 | return pars; |
| 417 | } |
| 418 | |
Neels Hofmeyr | e1a1b63 | 2021-07-28 18:05:43 +0200 | [diff] [blame] | 419 | 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] | 420 | var BSC_ConnHdlr vc_conn; |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 421 | var charstring id := testcasename() & int2str(pars.ran_idx); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 422 | |
| 423 | vc_conn := BSC_ConnHdlr.create(id); |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 424 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 425 | /* BSSMAP part / A interface */ |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 426 | connect(vc_conn:BSSAP, g_bssap[pars.ran_idx].vc_RAN:CLIENT); |
| 427 | 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] | 428 | /* MNCC part */ |
| 429 | connect(vc_conn:MNCC, vc_MNCC:MNCC_CLIENT); |
| 430 | connect(vc_conn:MNCC_PROC, vc_MNCC:MNCC_PROC); |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 431 | /* MGCP part */ |
| 432 | connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT); |
| 433 | connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 434 | /* GSUP part */ |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 435 | if (pars.gsup_enable == true) { |
| 436 | connect(vc_conn:GSUP, vc_GSUP:GSUP_CLIENT); |
| 437 | connect(vc_conn:GSUP_PROC, vc_GSUP:GSUP_PROC); |
| 438 | } |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 439 | /* SMPP part */ |
| 440 | connect(vc_conn:SMPP, vc_SMPP:SMPP_CLIENT); |
| 441 | connect(vc_conn:SMPP_PROC, vc_SMPP:SMPP_PROC); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 442 | /* SGs part */ |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 443 | if (pars.sgsap_enable == true) { |
Philipp Maier | 5786548 | 2019-01-07 18:33:13 +0100 | [diff] [blame] | 444 | connect(vc_conn:SGsAP, vc_SGsAP:SGsAP_CLIENT); |
| 445 | connect(vc_conn:SGsAP_PROC, vc_SGsAP:SGsAP_PROC); |
| 446 | } |
Neels Hofmeyr | e1a1b63 | 2021-07-28 18:05:43 +0200 | [diff] [blame] | 447 | return vc_conn; |
| 448 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 449 | |
Neels Hofmeyr | e1a1b63 | 2021-07-28 18:05:43 +0200 | [diff] [blame] | 450 | function f_start_handler_run(BSC_ConnHdlr vc_conn, void_fn fn, BSC_ConnHdlrPars pars) runs on MTC_CT { |
| 451 | var charstring id := testcasename() & int2str(pars.ran_idx); |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 452 | /* We cannot use vc_conn.start(f_init_handler(fn, id, pars)); as we cannot have |
| 453 | * 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] | 454 | vc_conn.start(derefers(fn)(id, pars)); |
Neels Hofmeyr | e1a1b63 | 2021-07-28 18:05:43 +0200 | [diff] [blame] | 455 | } |
| 456 | |
| 457 | function f_start_handler_with_pars(void_fn fn, BSC_ConnHdlrPars pars) runs on MTC_CT return BSC_ConnHdlr { |
| 458 | var BSC_ConnHdlr vc_conn; |
| 459 | vc_conn := f_start_handler_create(pars); |
| 460 | f_start_handler_run(vc_conn, fn, pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 461 | return vc_conn; |
| 462 | } |
| 463 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 464 | function f_start_handler(void_fn fn, integer imsi_suffix, integer ran_idx := 0, boolean ran_is_geran := true, boolean use_osmux := false, |
| 465 | boolean verify_cell_id := true) |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 466 | runs on MTC_CT return BSC_ConnHdlr { |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 467 | 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] | 468 | } |
| 469 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 470 | 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] | 471 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 472 | f_perform_lu(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 473 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 474 | testcase TC_lu_imsi_noauth_tmsi() runs on MTC_CT { |
| 475 | var BSC_ConnHdlr vc_conn; |
| 476 | f_init(); |
| 477 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 478 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_tmsi), 1); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 479 | vc_conn.done; |
| 480 | } |
| 481 | |
| 482 | 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] | 483 | pars.net.expect_tmsi := false; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 484 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 485 | f_perform_lu(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 486 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 487 | testcase TC_lu_imsi_noauth_notmsi() runs on MTC_CT { |
| 488 | var BSC_ConnHdlr vc_conn; |
| 489 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 490 | f_vty_config(MSCVTY, "msc", "no assign-tmsi"); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 491 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 492 | 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] | 493 | vc_conn.done; |
| 494 | } |
| 495 | |
| 496 | /* 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] | 497 | 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] | 498 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 499 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 500 | |
| 501 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 502 | f_cl3_or_initial_ue(l3_lu); |
Neels Hofmeyr | d076c52 | 2019-11-28 01:00:52 +0100 | [diff] [blame] | 503 | f_mm_common(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 504 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 505 | GSUP.send(ts_GSUP_UL_ERR(g_pars.imsi, 23)); |
| 506 | alt { |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 507 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej(int2oct(23,1)))) { |
| 508 | f_expect_clear(); |
| 509 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 510 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 511 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 512 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 513 | } |
| 514 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 515 | } |
| 516 | testcase TC_lu_imsi_reject() runs on MTC_CT { |
| 517 | var BSC_ConnHdlr vc_conn; |
| 518 | f_init(); |
| 519 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 520 | 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] | 521 | vc_conn.done; |
| 522 | } |
| 523 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 524 | |
| 525 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 526 | /* Do LU by IMSI, timeout on GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 527 | 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] | 528 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 529 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 530 | |
| 531 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 532 | f_cl3_or_initial_ue(l3_lu); |
Neels Hofmeyr | d076c52 | 2019-11-28 01:00:52 +0100 | [diff] [blame] | 533 | f_mm_common(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 534 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 535 | /* Normally the HLR would need to respond here, but we decide to force a timeout here */ |
| 536 | alt { |
| 537 | /* FIXME: Expect specific reject cause */ |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 538 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 539 | f_expect_clear(); |
| 540 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 541 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 542 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 543 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 544 | } |
| 545 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 546 | } |
| 547 | testcase TC_lu_imsi_timeout_gsup() runs on MTC_CT { |
| 548 | var BSC_ConnHdlr vc_conn; |
| 549 | f_init(); |
| 550 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 551 | 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] | 552 | vc_conn.done; |
| 553 | } |
| 554 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 555 | |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 556 | 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] | 557 | pars.net.expect_auth := true; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 558 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 559 | f_perform_lu(); |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 560 | } |
| 561 | testcase TC_lu_imsi_auth_tmsi() runs on MTC_CT { |
| 562 | var BSC_ConnHdlr vc_conn; |
| 563 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 564 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 565 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 566 | 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] | 567 | vc_conn.done; |
| 568 | } |
| 569 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 570 | |
| 571 | 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] | 572 | pars.net.expect_auth := true; |
| 573 | pars.use_umts_aka := true; |
| 574 | f_init_handler(pars); |
| 575 | f_perform_lu(); |
| 576 | } |
| 577 | testcase TC_lu_imsi_auth3g_tmsi() runs on MTC_CT { |
| 578 | var BSC_ConnHdlr vc_conn; |
| 579 | f_init(); |
| 580 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 581 | |
| 582 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth3g_tmsi), 1005); |
| 583 | vc_conn.done; |
| 584 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 585 | |
Pau Espin Pedrol | d3d54a9 | 2019-12-17 17:02:54 +0100 | [diff] [blame] | 586 | /* Proceed with LU but never receive an TMSI Realloc from MS after LU Accept (OS#4337). |
| 587 | * TS 24.008 sec 4.3.1.5 states MSC should simply release all MM connections. |
| 588 | */ |
| 589 | friend function f_tc_lu_imsi_timeout_tmsi_realloc(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 590 | |
| 591 | f_init_handler(pars); |
| 592 | |
| 593 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 594 | var PDU_DTAP_MT dtap_mt; |
| 595 | |
| 596 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 597 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 598 | |
| 599 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 600 | if (g_pars.ran_is_geran) { |
| 601 | f_bssap_compl_l3(l3_lu); |
| 602 | if (g_pars.send_early_cm) { |
| 603 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 604 | } |
| 605 | } else { |
| 606 | f_ranap_initial_ue(l3_lu); |
| 607 | } |
| 608 | |
| 609 | f_mm_imei_early(); |
| 610 | f_mm_common(); |
| 611 | f_msc_lu_hlr(); |
| 612 | f_mm_imei(); |
| 613 | |
| 614 | alt { |
| 615 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) -> value dtap_mt {} |
| 616 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 617 | setverdict(fail, "Expected LU ACK, but received LU REJ"); |
| 618 | mtc.stop; |
| 619 | } |
| 620 | } |
| 621 | |
| 622 | /* currently (due to bug OS#4337), an extra LU reject is received before |
| 623 | terminating the connection. Enabling following line makes the test |
| 624 | pass: */ |
| 625 | //f_expect_lu_reject('16'O); /* Cause: congestion */ |
| 626 | |
| 627 | /* f_expect_lu_reject() already waits for T"-1" (X1, 5 seconds), but give some |
| 628 | extra time to avoid race conditons... */ |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 629 | f_expect_clear(7.0, verify_vlr_cell_id := false); |
Pau Espin Pedrol | d3d54a9 | 2019-12-17 17:02:54 +0100 | [diff] [blame] | 630 | |
| 631 | setverdict(pass); |
| 632 | } |
| 633 | testcase TC_lu_imsi_timeout_tmsi_realloc() runs on MTC_CT { |
| 634 | var BSC_ConnHdlr vc_conn; |
| 635 | f_init(); |
| 636 | |
| 637 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_timeout_tmsi_realloc), 5); |
| 638 | vc_conn.done; |
| 639 | } |
| 640 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 641 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 642 | /* Send CM SERVICE REQ for IMSI that has never performed LU before */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 643 | friend function f_tc_cmserv_imsi_unknown(charstring id, BSC_ConnHdlrPars pars) |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 644 | runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 645 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 646 | |
| 647 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | edbab81 | 2018-03-18 16:02:25 +0100 | [diff] [blame] | 648 | 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] | 649 | 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] | 650 | |
| 651 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 652 | |
| 653 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 654 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | b781799 | 2019-05-09 13:15:39 +0200 | [diff] [blame] | 655 | f_mm_auth(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 656 | |
| 657 | timer T := 10.0; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 658 | T.start; |
| 659 | alt { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 660 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)) { } |
| 661 | //[] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_ACC)) { } |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 662 | [] BSSAP.receive { |
| 663 | setverdict(fail, "Received unexpected BSSAP"); |
| 664 | mtc.stop; |
| 665 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 666 | [] GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)) { |
| 667 | setverdict(fail, "Unexpected GSUP UL REQ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 668 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 669 | } |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 670 | [] T.timeout { |
Neels Hofmeyr | f1c3c21 | 2020-08-19 13:15:32 +0000 | [diff] [blame] | 671 | setverdict(fail, "Timeout waiting for CM SERV REJ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 672 | mtc.stop; |
| 673 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 674 | } |
| 675 | |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 676 | f_expect_clear(); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 677 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 678 | testcase TC_cmserv_imsi_unknown() runs on MTC_CT { |
| 679 | var BSC_ConnHdlr vc_conn; |
| 680 | f_init(); |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 681 | 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] | 682 | vc_conn.done; |
| 683 | } |
| 684 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 685 | |
Neels Hofmeyr | 13737fb | 2020-08-19 13:16:14 +0000 | [diff] [blame] | 686 | /* Send CM SERVICE REQ for TMSI that has never performed LU before */ |
| 687 | friend function f_tc_cmserv_tmsi_unknown(charstring id, BSC_ConnHdlrPars pars) |
| 688 | runs on BSC_ConnHdlr { |
| 689 | f_init_handler(pars); |
| 690 | |
| 691 | var MobileIdentityLV mi := valueof(ts_MI_TMSI_LV('57111111'O)); |
| 692 | var BSSMAP_IE_CellIdentifier cell_id := valueof(ts_CellId_CGI('262'H, '42'H, 23, 42)); |
| 693 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi)); |
| 694 | |
| 695 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 696 | f_cl3_or_initial_ue(l3_info); |
| 697 | f_mm_auth(); |
| 698 | |
| 699 | timer T := 10.0; |
| 700 | T.start; |
| 701 | alt { |
| 702 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)) { } |
| 703 | [] BSSAP.receive { |
| 704 | setverdict(fail, "Received unexpected BSSAP"); |
| 705 | mtc.stop; |
| 706 | } |
| 707 | [] T.timeout { |
| 708 | setverdict(fail, "Timeout waiting for CM SERV REJ"); |
| 709 | mtc.stop; |
| 710 | } |
| 711 | } |
| 712 | |
| 713 | f_expect_clear(); |
| 714 | } |
| 715 | testcase TC_cmserv_tmsi_unknown() runs on MTC_CT { |
| 716 | var BSC_ConnHdlr vc_conn; |
| 717 | f_init(); |
| 718 | vc_conn := f_start_handler(refers(f_tc_cmserv_tmsi_unknown), 57, verify_cell_id := false); |
| 719 | vc_conn.done; |
| 720 | } |
| 721 | |
Neels Hofmeyr | 14d0b13 | 2020-08-19 13:49:05 +0000 | [diff] [blame] | 722 | /* Send Paging Response for IMSI that has never performed LU before */ |
| 723 | friend function f_tc_paging_response_imsi_unknown(charstring id, BSC_ConnHdlrPars pars) |
| 724 | runs on BSC_ConnHdlr { |
| 725 | f_init_handler(pars); |
| 726 | |
| 727 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 728 | var BSSMAP_IE_CellIdentifier cell_id := valueof(ts_CellId_CGI('262'H, '42'H, 23, 42)); |
| 729 | var PDU_ML3_MS_NW l3_info := valueof(ts_PAG_RESP(mi)); |
| 730 | |
| 731 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 732 | f_cl3_or_initial_ue(l3_info); |
| 733 | |
| 734 | /* The Paging Response gets rejected by a direct Clear Command */ |
| 735 | f_expect_clear(); |
| 736 | } |
| 737 | testcase TC_paging_response_imsi_unknown() runs on MTC_CT { |
| 738 | var BSC_ConnHdlr vc_conn; |
| 739 | f_init(); |
| 740 | vc_conn := f_start_handler(refers(f_tc_paging_response_imsi_unknown), 58, verify_cell_id := false); |
| 741 | vc_conn.done; |
| 742 | } |
| 743 | |
| 744 | /* Send Paging Response for TMSI that has never performed LU before */ |
| 745 | friend function f_tc_paging_response_tmsi_unknown(charstring id, BSC_ConnHdlrPars pars) |
| 746 | runs on BSC_ConnHdlr { |
| 747 | f_init_handler(pars); |
| 748 | |
| 749 | var MobileIdentityLV mi := valueof(ts_MI_TMSI_LV('59111111'O)); |
| 750 | var BSSMAP_IE_CellIdentifier cell_id := valueof(ts_CellId_CGI('262'H, '42'H, 23, 42)); |
| 751 | var PDU_ML3_MS_NW l3_info := valueof(ts_PAG_RESP(mi)); |
| 752 | |
| 753 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 754 | f_cl3_or_initial_ue(l3_info); |
| 755 | |
| 756 | /* The Paging Response gets rejected by a direct Clear Command */ |
| 757 | f_expect_clear(); |
| 758 | } |
| 759 | testcase TC_paging_response_tmsi_unknown() runs on MTC_CT { |
| 760 | var BSC_ConnHdlr vc_conn; |
| 761 | f_init(); |
| 762 | vc_conn := f_start_handler(refers(f_tc_paging_response_tmsi_unknown), 59, verify_cell_id := false); |
| 763 | vc_conn.done; |
| 764 | } |
| 765 | |
Neels Hofmeyr | 13737fb | 2020-08-19 13:16:14 +0000 | [diff] [blame] | 766 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 767 | 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] | 768 | f_init_handler(pars); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 769 | var CallParameters cpars := valueof(t_CallParams); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 770 | f_perform_lu(); |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 771 | f_mo_call(cpars); |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 772 | } |
| 773 | testcase TC_lu_and_mo_call() runs on MTC_CT { |
| 774 | var BSC_ConnHdlr vc_conn; |
| 775 | f_init(); |
| 776 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 777 | 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] | 778 | vc_conn.done; |
| 779 | } |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 780 | friend function f_tc_lu_and_mo_call_ipv6(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 781 | f_init_handler(pars); |
| 782 | var CallParameters cpars := valueof(t_CallParams); |
| 783 | cpars.mgw_conn_1.mgw_rtp_ip := "::1"; |
| 784 | cpars.mgw_conn_2.mgw_rtp_ip := "::2"; |
| 785 | cpars.bss_rtp_ip := "::3"; |
| 786 | f_perform_lu(); |
| 787 | f_mo_call(cpars); |
| 788 | } |
| 789 | testcase TC_lu_and_mo_call_ipv6() runs on MTC_CT { |
| 790 | var BSC_ConnHdlr vc_conn; |
| 791 | f_init(); |
| 792 | |
| 793 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_call_ipv6), 7); |
| 794 | vc_conn.done; |
| 795 | } |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 796 | |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 797 | /* Verify T(iar) triggers and releases the channel */ |
| 798 | friend function f_lu_and_mo_call_sccp_tiar_timeout(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 799 | timer T_wait_iar := int2float(5 + 1); /* g_msc_sccp_timer_iar + Give extra time (+1 sec) */ |
| 800 | f_init_handler(pars); |
| 801 | var CallParameters cpars := valueof(t_CallParams); |
| 802 | f_perform_lu(); |
| 803 | f_mo_call_establish(cpars); |
| 804 | |
| 805 | /* Expect the channel cleared upon T(iar) triggered: */ |
| 806 | T_wait_iar.start; |
| 807 | alt { |
| 808 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) { |
| 809 | T_wait_iar.stop |
| 810 | setverdict(pass); |
| 811 | } |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 812 | [] T_wait_iar.timeout { |
| 813 | setverdict(fail, "Timeout waiting for T(iar) triggered SCCP RSLD"); |
| 814 | mtc.stop; |
| 815 | } |
| 816 | } |
Harald Welte | 4a3fa71 | 2020-08-19 08:57:33 +0200 | [diff] [blame] | 817 | /* DLCX for both directions; if we don't do this, we might receive either of the two during |
| 818 | * shutdown causing race conditions */ |
| 819 | MGCP.receive(tr_DLCX(?)); |
| 820 | MGCP.receive(tr_DLCX(?)); |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 821 | |
| 822 | setverdict(pass); |
| 823 | } |
| 824 | testcase TC_lu_and_mo_call_sccp_tiar_timeout() runs on MTC_CT { |
| 825 | var BSC_ConnHdlr vc_conn; |
| 826 | |
| 827 | /* Set T(iar) in MSC low enough that it will trigger before other side |
| 828 | has time to keep alive with a T(ias). Keep recommended ratio of |
| 829 | T(iar) >= T(ias)*2 */ |
| 830 | g_msc_sccp_timer_ias := 2; |
| 831 | g_msc_sccp_timer_iar := 5; |
| 832 | |
| 833 | f_init(); |
| 834 | |
| 835 | vc_conn := f_start_handler(refers(f_lu_and_mo_call_sccp_tiar_timeout), 89); |
| 836 | vc_conn.done; |
| 837 | } |
| 838 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 839 | |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 840 | /* Test LU (with authentication enabled), where HLR times out sending SAI response */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 841 | 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] | 842 | f_init_handler(pars); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 843 | |
| 844 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 845 | var PDU_DTAP_MT dtap_mt; |
| 846 | |
| 847 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 848 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 849 | |
| 850 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 851 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 852 | |
| 853 | /* Send Early Classmark, just for the fun of it */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 854 | if (pars.ran_is_geran) { |
| 855 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 856 | } |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 857 | |
| 858 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 859 | /* The HLR would normally return an auth vector here, but we fail to do so. */ |
| 860 | |
| 861 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 862 | f_expect_clear(); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 863 | } |
| 864 | testcase TC_lu_auth_sai_timeout() runs on MTC_CT { |
| 865 | var BSC_ConnHdlr vc_conn; |
| 866 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 867 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 868 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 869 | 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] | 870 | vc_conn.done; |
| 871 | } |
| 872 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 873 | |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 874 | /* Test LU (with authentication enabled), where HLR rejects sending SAI error */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 875 | 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] | 876 | f_init_handler(pars); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 877 | |
| 878 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 879 | var PDU_DTAP_MT dtap_mt; |
| 880 | |
| 881 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 882 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 883 | |
| 884 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 885 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 886 | |
| 887 | /* Send Early Classmark, just for the fun of it */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 888 | if (pars.ran_is_geran) { |
| 889 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 890 | } |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 891 | |
| 892 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 893 | GSUP.send(ts_GSUP_SAI_ERR(g_pars.imsi, 13)); |
| 894 | |
| 895 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 896 | f_expect_clear(); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 897 | } |
| 898 | testcase TC_lu_auth_sai_err() runs on MTC_CT { |
| 899 | var BSC_ConnHdlr vc_conn; |
| 900 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 901 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 902 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 903 | 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] | 904 | vc_conn.done; |
| 905 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 906 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 907 | |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 908 | /* Test LU but BSC will send a clear request in the middle */ |
| 909 | 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] | 910 | f_init_handler(pars); |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 911 | |
| 912 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 913 | var PDU_DTAP_MT dtap_mt; |
| 914 | |
| 915 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 916 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 917 | |
| 918 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 919 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 79f1e45 | 2020-08-18 22:55:02 +0200 | [diff] [blame] | 920 | f_expect_common_id(); |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 921 | |
| 922 | /* Send Early Classmark, just for the fun of it */ |
| 923 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 924 | |
| 925 | f_sleep(1.0); |
| 926 | /* send clear request in the middle of the LU */ |
| 927 | BSSAP.send(ts_BSSMAP_ClearRequest(0)); |
Neels Hofmeyr | 2b326fa | 2018-04-06 00:59:36 +0200 | [diff] [blame] | 928 | alt { |
| 929 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { repeat; } |
| 930 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) {} |
| 931 | } |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 932 | BSSAP.send(ts_BSSMAP_ClearComplete); |
Harald Welte | 89a3249 | 2018-01-27 19:07:28 +0100 | [diff] [blame] | 933 | alt { |
| 934 | /* See https://osmocom.org/issues/2862 */ |
Neels Hofmeyr | 2b326fa | 2018-04-06 00:59:36 +0200 | [diff] [blame] | 935 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 936 | setverdict(fail, "Got a second Clear Command, only one expected"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 937 | mtc.stop; |
Neels Hofmeyr | 2b326fa | 2018-04-06 00:59:36 +0200 | [diff] [blame] | 938 | repeat; |
| 939 | } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 940 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
Harald Welte | 89a3249 | 2018-01-27 19:07:28 +0100 | [diff] [blame] | 941 | } |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 942 | setverdict(pass); |
| 943 | } |
| 944 | testcase TC_lu_clear_request() runs on MTC_CT { |
| 945 | var BSC_ConnHdlr vc_conn; |
| 946 | f_init(); |
| 947 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 948 | vc_conn := f_start_handler(refers(f_tc_lu_clear_request), 10); |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 949 | vc_conn.done; |
| 950 | } |
| 951 | |
Vadim Yanitskiy | 109e755 | 2021-02-05 05:36:02 +0100 | [diff] [blame] | 952 | /* Test reaction on Clear Request during a MO Call */ |
| 953 | friend function f_TC_mo_mt_call_clear_request(charstring id, BSC_ConnHdlrPars pars) |
| 954 | runs on BSC_ConnHdlr { |
| 955 | var CallParameters cpars := valueof(t_CallParams); |
| 956 | var MNCC_PDU mncc_pdu; |
| 957 | timer T := 2.0; |
| 958 | |
| 959 | f_init_handler(pars); |
| 960 | |
| 961 | f_perform_lu(); |
| 962 | |
| 963 | /* HACK: reducing code duplication ('66'H - MO, '68'H - MT) */ |
| 964 | if (pars.imsi == '262420002532766'H) |
| 965 | { f_mo_call_establish(cpars); } |
| 966 | else |
| 967 | { f_mt_call_establish(cpars); } |
| 968 | |
| 969 | /* Hold the line for a while... */ |
| 970 | f_sleep(2.0); |
| 971 | |
| 972 | /* BSC sends BSSMAP Clear Request (e.g. due to RR failure) */ |
| 973 | BSSAP.send(ts_BSSMAP_ClearRequest(1)); |
| 974 | |
| 975 | /* Expect (optional) CC RELEASE and Clear Command */ |
| 976 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
| 977 | f_expect_clear(); |
| 978 | deactivate(ccrel); |
| 979 | |
| 980 | /* Expect RELease indication on the MNCC socket */ |
| 981 | T.start; |
| 982 | alt { |
| 983 | [] MNCC.receive(tr_MNCC_REL_ind(cpars.mncc_callref)) -> value mncc_pdu { |
| 984 | log("Rx MNCC REL.ind, cause := ", mncc_pdu.u.signal.cause); |
| 985 | setverdict(pass); |
| 986 | } |
| 987 | [] MNCC.receive(MNCC_PDU:?) -> value mncc_pdu { |
| 988 | setverdict(fail, "Rx unexpected MNCC PDU: ", mncc_pdu); |
| 989 | } |
| 990 | [] T.timeout { |
| 991 | setverdict(fail, "Timeout waiting for MNCC REL.ind"); |
| 992 | } |
| 993 | } |
| 994 | } |
| 995 | testcase TC_mo_call_clear_request() runs on MTC_CT { |
| 996 | var BSC_ConnHdlr vc_conn; |
| 997 | |
| 998 | f_init(); |
| 999 | |
| 1000 | vc_conn := f_start_handler(refers(f_TC_mo_mt_call_clear_request), 2532766); // '66'H - MO |
| 1001 | vc_conn.done; |
| 1002 | } |
| 1003 | testcase TC_mt_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), 2532768); // '68'H - MT |
| 1009 | vc_conn.done; |
| 1010 | } |
| 1011 | |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1012 | /* Test LU but BSC will send a clear request in the middle */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1013 | 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] | 1014 | f_init_handler(pars); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1015 | |
| 1016 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 1017 | var PDU_DTAP_MT dtap_mt; |
| 1018 | |
| 1019 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1020 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1021 | |
| 1022 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1023 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1024 | |
| 1025 | /* Send Early Classmark, just for the fun of it */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1026 | if (pars.ran_is_geran) { |
| 1027 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1028 | } |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1029 | |
| 1030 | f_sleep(1.0); |
| 1031 | /* send clear request in the middle of the LU */ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1032 | BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1033 | setverdict(pass); |
Neels Hofmeyr | bb825c9 | 2019-03-06 15:35:50 +0100 | [diff] [blame] | 1034 | f_sleep(1.0); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1035 | } |
| 1036 | testcase TC_lu_disconnect() runs on MTC_CT { |
| 1037 | var BSC_ConnHdlr vc_conn; |
| 1038 | f_init(); |
| 1039 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1040 | vc_conn := f_start_handler(refers(f_tc_lu_disconnect), 11); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1041 | vc_conn.done; |
| 1042 | } |
| 1043 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1044 | /* Test LU but with illegal mobile identity type = IMEI */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1045 | 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] | 1046 | f_init_handler(pars); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1047 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 1048 | 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] | 1049 | var PDU_DTAP_MT dtap_mt; |
| 1050 | |
| 1051 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1052 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1053 | |
| 1054 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1055 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1056 | |
| 1057 | /* Send Early Classmark, just for the fun of it */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1058 | if (pars.ran_is_geran) { |
| 1059 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1060 | } |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1061 | /* wait for LU reject, ignore any ID REQ */ |
| 1062 | alt { |
| 1063 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { } |
| 1064 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req)) { repeat; } |
| 1065 | } |
| 1066 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1067 | f_expect_clear(); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1068 | } |
| 1069 | testcase TC_lu_by_imei() runs on MTC_CT { |
| 1070 | var BSC_ConnHdlr vc_conn; |
| 1071 | f_init(); |
| 1072 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1073 | 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] | 1074 | vc_conn.done; |
| 1075 | } |
| 1076 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1077 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1078 | /* Test LU by TMSI with unknown TMSI, expect (and answer) ID REQ. */ |
| 1079 | 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] | 1080 | /* We piggyback a test for an MSC crash on overlong IMSI (OS#2864) onto this test. */ |
| 1081 | var hexstring overlong_imsi := '012345789ABCDEF0123456789ABCDEF'H; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1082 | f_init_handler(pars); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1083 | |
| 1084 | var PDU_ML3_MS_NW l3_lu := f_build_lu_tmsi('01020304'O); /* FIXME: Random */ |
| 1085 | var PDU_DTAP_MT dtap_mt; |
| 1086 | |
| 1087 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1088 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1089 | |
| 1090 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1091 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1092 | |
| 1093 | /* Send Early Classmark, just for the fun of it */ |
| 1094 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1095 | |
| 1096 | /* Wait for + respond to ID REQ (IMSI) */ |
Oliver Smith | 3289845 | 2019-07-09 12:32:35 +0200 | [diff] [blame] | 1097 | 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] | 1098 | 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] | 1099 | 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] | 1100 | f_expect_common_id(); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1101 | |
| 1102 | /* Expect MSC to do UpdateLocation to HLR; respond to it */ |
| 1103 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 1104 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 1105 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 1106 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 1107 | |
| 1108 | alt { |
Harald Welte | 7ec4fa8 | 2018-01-27 10:57:40 +0100 | [diff] [blame] | 1109 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 1110 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_TmsiRealloc_Cmpl)); |
| 1111 | } |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1112 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 1113 | setverdict(fail, "Expected LU ACK, but received REJ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1114 | mtc.stop; |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1115 | } |
| 1116 | } |
| 1117 | |
Philipp Maier | 9b690e4 | 2018-12-21 11:50:03 +0100 | [diff] [blame] | 1118 | /* Wait for MM-Information (if enabled) */ |
| 1119 | f_expect_mm_info(); |
| 1120 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1121 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1122 | f_expect_clear(); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1123 | } |
| 1124 | testcase TC_lu_by_tmsi_noauth_unknown() runs on MTC_CT { |
| 1125 | var BSC_ConnHdlr vc_conn; |
| 1126 | f_init(); |
| 1127 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1128 | 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] | 1129 | vc_conn.done; |
| 1130 | } |
| 1131 | |
Neels Hofmeyr | fc06c73 | 2020-08-19 12:52:28 +0000 | [diff] [blame] | 1132 | /* Test LU by unknown TMSI, while the IMSI is already attached: osmo-msc should switch to the attached vlr_subscr. */ |
| 1133 | private function f_tc_attached_imsi_lu_unknown_tmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1134 | f_init_handler(pars); |
| 1135 | |
| 1136 | var PDU_ML3_MS_NW l3_lu := f_build_lu_tmsi('56111111'O); |
| 1137 | var PDU_DTAP_MT dtap_mt; |
| 1138 | |
| 1139 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1140 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1141 | |
| 1142 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 1143 | f_cl3_or_initial_ue(l3_lu); |
| 1144 | |
| 1145 | /* Send Early Classmark, just for the fun of it */ |
| 1146 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1147 | |
| 1148 | /* Wait for + respond to ID REQ (IMSI) */ |
| 1149 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req(CM_ID_TYPE_IMSI))); |
| 1150 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp_IMSI(g_pars.imsi))); |
| 1151 | f_expect_common_id(); |
| 1152 | |
| 1153 | /* Expect MSC to do UpdateLocation to HLR; respond to it */ |
| 1154 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 1155 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 1156 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 1157 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 1158 | |
| 1159 | alt { |
| 1160 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 1161 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_TmsiRealloc_Cmpl)); |
| 1162 | } |
| 1163 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 1164 | setverdict(fail, "Expected LU ACK, but received REJ"); |
| 1165 | mtc.stop; |
| 1166 | } |
| 1167 | } |
| 1168 | |
| 1169 | /* Wait for MM-Information (if enabled) */ |
| 1170 | f_expect_mm_info(); |
| 1171 | |
| 1172 | /* wait for normal teardown */ |
| 1173 | f_expect_clear(); |
| 1174 | |
| 1175 | /* Now the same IMSI is still attached in the VLR, and a LU with an unknown TMSI reveals the same IMSI only |
| 1176 | * later during ID Response. osmo-msc first creates a new vlr_subscr for the unknown TMSI, and as soon as the |
| 1177 | * IMSI becomes known, must notice that this IMSI is still regarded as attached, and must not create evil twins. |
| 1178 | */ |
| 1179 | |
| 1180 | /* (since the TMSI Reallocation happened, we could do this with exactly the same TMSI as above, but for test |
| 1181 | * readability just use a different one.) */ |
| 1182 | l3_lu := f_build_lu_tmsi('56222222'O); |
| 1183 | f_cl3_or_initial_ue(l3_lu); |
| 1184 | |
| 1185 | /* Wait for + respond to ID REQ (IMSI) */ |
| 1186 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req(CM_ID_TYPE_IMSI))); |
| 1187 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp_IMSI(g_pars.imsi))); |
| 1188 | f_expect_common_id(); |
| 1189 | |
| 1190 | /* Expect MSC to do UpdateLocation to HLR; respond to it */ |
| 1191 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 1192 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 1193 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 1194 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 1195 | |
| 1196 | alt { |
| 1197 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 1198 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_TmsiRealloc_Cmpl)); |
| 1199 | } |
| 1200 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 1201 | setverdict(fail, "Expected LU ACK, but received REJ"); |
| 1202 | mtc.stop; |
| 1203 | } |
| 1204 | } |
| 1205 | |
| 1206 | /* Wait for MM-Information (if enabled) */ |
| 1207 | f_expect_mm_info(); |
| 1208 | |
| 1209 | /* wait for normal teardown */ |
| 1210 | f_expect_clear(); |
| 1211 | } |
| 1212 | testcase TC_attached_imsi_lu_unknown_tmsi() runs on MTC_CT { |
| 1213 | var BSC_ConnHdlr vc_conn; |
| 1214 | f_init(); |
| 1215 | |
| 1216 | vc_conn := f_start_handler(refers(f_tc_attached_imsi_lu_unknown_tmsi), 56); |
| 1217 | vc_conn.done; |
| 1218 | } |
| 1219 | |
Harald Welte | 4d15fa7 | 2020-08-19 08:58:28 +0200 | [diff] [blame] | 1220 | friend function f_imsi_detach_by_imsi() runs on BSC_ConnHdlr { |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1221 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 1222 | |
| 1223 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1224 | 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] | 1225 | |
| 1226 | /* Send Early Classmark, just for the fun of it? */ |
Harald Welte | 4d15fa7 | 2020-08-19 08:58:28 +0200 | [diff] [blame] | 1227 | if (g_pars.ran_is_geran) { |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1228 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1229 | } |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1230 | |
| 1231 | /* wait for normal teardown */ |
Harald Welte | 4d15fa7 | 2020-08-19 08:58:28 +0200 | [diff] [blame] | 1232 | f_expect_clear(verify_vlr_cell_id := false); |
| 1233 | } |
| 1234 | |
| 1235 | |
| 1236 | /* Test IMSI DETACH (MI=IMSI) */ |
| 1237 | friend function f_tc_imsi_detach_by_imsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1238 | f_init_handler(pars); |
| 1239 | |
| 1240 | f_imsi_detach_by_imsi(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1241 | } |
| 1242 | testcase TC_imsi_detach_by_imsi() runs on MTC_CT { |
| 1243 | var BSC_ConnHdlr vc_conn; |
| 1244 | f_init(); |
| 1245 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1246 | 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] | 1247 | vc_conn.done; |
| 1248 | } |
| 1249 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1250 | |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1251 | /* Test IMSI DETACH (MI=TMSI) */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1252 | 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] | 1253 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1254 | |
| 1255 | var MobileIdentityLV mi := valueof(ts_MI_TMSI_LV('01020304'O)); |
| 1256 | |
| 1257 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1258 | 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] | 1259 | |
| 1260 | /* Send Early Classmark, just for the fun of it? */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1261 | if (pars.ran_is_geran) { |
| 1262 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1263 | } |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1264 | |
| 1265 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1266 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1267 | } |
| 1268 | testcase TC_imsi_detach_by_tmsi() runs on MTC_CT { |
| 1269 | var BSC_ConnHdlr vc_conn; |
| 1270 | f_init(); |
| 1271 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1272 | 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] | 1273 | vc_conn.done; |
| 1274 | } |
| 1275 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1276 | |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1277 | /* Test IMSI DETACH (MI=IMEI), which is illegal */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1278 | 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] | 1279 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1280 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 1281 | var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1282 | |
| 1283 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1284 | 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] | 1285 | |
| 1286 | /* Send Early Classmark, just for the fun of it? */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1287 | if (pars.ran_is_geran) { |
| 1288 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1289 | } |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1290 | |
| 1291 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1292 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1293 | } |
| 1294 | testcase TC_imsi_detach_by_imei() runs on MTC_CT { |
| 1295 | var BSC_ConnHdlr vc_conn; |
| 1296 | f_init(); |
| 1297 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1298 | 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] | 1299 | vc_conn.done; |
| 1300 | } |
| 1301 | |
| 1302 | |
| 1303 | /* helper function for an emergency call. caller passes in mobile identity to use */ |
| 1304 | private function f_emerg_call(MobileIdentityLV mi) runs on BSC_ConnHdlr { |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 1305 | var CallParameters cpars := valueof(t_CallParams('112'H, 0)); |
| 1306 | cpars.emergency := true; |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1307 | |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 1308 | f_mo_call(cpars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1309 | } |
| 1310 | |
| 1311 | /* 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] | 1312 | 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] | 1313 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1314 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 1315 | var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1316 | 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] | 1317 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1318 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ('05'O))); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1319 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1320 | } |
| 1321 | testcase TC_emerg_call_imei_reject() runs on MTC_CT { |
| 1322 | var BSC_ConnHdlr vc_conn; |
| 1323 | f_init(); |
| 1324 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1325 | 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] | 1326 | vc_conn.done; |
| 1327 | } |
| 1328 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1329 | |
Harald Welte | d5b9140 | 2018-01-24 18:48:16 +0100 | [diff] [blame] | 1330 | /* establish an emergency call by IMSI, SIM inserted (and hence IMSI) */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1331 | 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] | 1332 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1333 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1334 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1335 | /* Then issue emergency call identified by IMSI */ |
| 1336 | f_emerg_call(valueof(ts_MI_IMSI_LV(g_pars.imsi))); |
| 1337 | } |
| 1338 | testcase TC_emerg_call_imsi() runs on MTC_CT { |
| 1339 | var BSC_ConnHdlr vc_conn; |
| 1340 | f_init(); |
| 1341 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1342 | vc_conn := f_start_handler(refers(f_tc_emerg_call_imsi), 18); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1343 | vc_conn.done; |
| 1344 | } |
| 1345 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1346 | |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1347 | /* CM Service Request for VGCS -> reject */ |
| 1348 | 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] | 1349 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1350 | |
| 1351 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1352 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1353 | |
| 1354 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1355 | 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] | 1356 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1357 | 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] | 1358 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1359 | } |
| 1360 | testcase TC_cm_serv_req_vgcs_reject() runs on MTC_CT { |
| 1361 | var BSC_ConnHdlr vc_conn; |
| 1362 | f_init(); |
| 1363 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1364 | 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] | 1365 | vc_conn.done; |
| 1366 | } |
| 1367 | |
| 1368 | /* CM Service Request for VBS -> reject */ |
| 1369 | 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] | 1370 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1371 | |
| 1372 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1373 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1374 | |
| 1375 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1376 | 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] | 1377 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1378 | 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] | 1379 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1380 | } |
| 1381 | testcase TC_cm_serv_req_vbs_reject() runs on MTC_CT { |
| 1382 | var BSC_ConnHdlr vc_conn; |
| 1383 | f_init(); |
| 1384 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1385 | vc_conn := f_start_handler(refers(f_tc_cm_serv_req_vbs_reject), 20); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1386 | vc_conn.done; |
| 1387 | } |
| 1388 | |
| 1389 | /* CM Service Request for LCS -> reject */ |
| 1390 | 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] | 1391 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1392 | |
| 1393 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1394 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1395 | |
| 1396 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1397 | 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] | 1398 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1399 | 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] | 1400 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1401 | } |
| 1402 | testcase TC_cm_serv_req_lcs_reject() runs on MTC_CT { |
| 1403 | var BSC_ConnHdlr vc_conn; |
| 1404 | f_init(); |
| 1405 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1406 | 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] | 1407 | vc_conn.done; |
| 1408 | } |
| 1409 | |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1410 | /* CM Re-Establishment Request */ |
| 1411 | 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] | 1412 | f_init_handler(pars); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1413 | |
| 1414 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1415 | f_perform_lu(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1416 | |
| 1417 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 1418 | 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] | 1419 | f_cl3_or_initial_ue(l3_info); |
Neels Hofmeyr | 49bbb51 | 2021-07-29 22:51:08 +0200 | [diff] [blame] | 1420 | /* Older osmo-msc returns: GSM48_REJECT_SRV_OPT_NOT_SUPPORTED = 32, |
| 1421 | * newer osmo-msc with CM Re-Establish support returns: GSM48_REJECT_CALL_CAN_NOT_BE_IDENTIFIED = 38 */ |
| 1422 | 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] | 1423 | f_expect_clear(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1424 | } |
| 1425 | testcase TC_cm_reest_req_reject() runs on MTC_CT { |
| 1426 | var BSC_ConnHdlr vc_conn; |
| 1427 | f_init(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1428 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1429 | 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] | 1430 | vc_conn.done; |
| 1431 | } |
| 1432 | |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1433 | /* Test LU (with authentication enabled), with wrong response from MS */ |
| 1434 | 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] | 1435 | f_init_handler(pars); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1436 | |
| 1437 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 1438 | |
| 1439 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1440 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1441 | |
| 1442 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1443 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1444 | |
| 1445 | /* Send Early Classmark, just for the fun of it */ |
| 1446 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1447 | |
| 1448 | var AuthVector vec := f_gen_auth_vec_2g(); |
| 1449 | var GSUP_IE auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G(vec.rand, vec.sres, vec.kc)); |
| 1450 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 1451 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
| 1452 | |
| 1453 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_AUTH_REQ(vec.rand))); |
| 1454 | /* Send back wrong auth response */ |
| 1455 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MT_MM_AUTH_RESP_2G('00000000'O))); |
| 1456 | |
| 1457 | /* Expect GSUP AUTH FAIL REP to HLR */ |
| 1458 | GSUP.receive(tr_GSUP_AUTH_FAIL_IND(g_pars.imsi)); |
| 1459 | |
| 1460 | /* Expect LU REJECT with Cause == Illegal MS */ |
| 1461 | 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] | 1462 | f_expect_clear(); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1463 | } |
| 1464 | testcase TC_lu_auth_2G_fail() runs on MTC_CT { |
| 1465 | var BSC_ConnHdlr vc_conn; |
| 1466 | f_init(); |
| 1467 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1468 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1469 | 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] | 1470 | vc_conn.done; |
| 1471 | } |
| 1472 | |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 1473 | /* 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] | 1474 | 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] | 1475 | pars.net.expect_auth := true; |
| 1476 | pars.net.expect_ciph := true; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1477 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1478 | f_perform_lu(); |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 1479 | } |
| 1480 | testcase TC_lu_imsi_auth_tmsi_encr_13_13() runs on MTC_CT { |
| 1481 | var BSC_ConnHdlr vc_conn; |
| 1482 | f_init(); |
| 1483 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 1484 | f_vty_config(MSCVTY, "network", "encryption a5 1 3"); |
| 1485 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1486 | 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] | 1487 | vc_conn.done; |
| 1488 | } |
| 1489 | |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1490 | /* Test Complete L3 without payload */ |
| 1491 | 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] | 1492 | f_init_handler(pars); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1493 | |
| 1494 | /* Send Complete L3 Info with empty L3 frame */ |
| 1495 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own, |
| 1496 | valueof(ts_BSSMAP_ComplL3(g_pars.cell_id, ''O)))); |
| 1497 | |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1498 | timer T := 5.0; |
| 1499 | T.start; |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1500 | alt { |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1501 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1502 | /* Expect LU REJECT with Cause == Illegal MS */ |
Harald Welte | bdb3c45 | 2018-03-18 22:43:06 +0100 | [diff] [blame] | 1503 | [] BSSAP.receive(tr_PDU_DTAP_MT(?)) { repeat; } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1504 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND) { repeat; } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1505 | [] as_clear_cmd_compl_disc(); |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1506 | [] T.timeout { |
Daniel Willmann | 90829d6 | 2018-02-15 17:45:14 +0100 | [diff] [blame] | 1507 | setverdict(fail, "Timeout waiting for ClearCommand or SCCP Release"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1508 | mtc.stop; |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1509 | } |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1510 | } |
| 1511 | setverdict(pass); |
| 1512 | } |
| 1513 | testcase TC_cl3_no_payload() runs on MTC_CT { |
| 1514 | var BSC_ConnHdlr vc_conn; |
| 1515 | f_init(); |
| 1516 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1517 | vc_conn := f_start_handler(refers(f_tc_cl3_no_payload), 25); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1518 | vc_conn.done; |
| 1519 | } |
| 1520 | |
| 1521 | /* Test Complete L3 with random payload */ |
| 1522 | 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] | 1523 | f_init_handler(pars); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1524 | |
Daniel Willmann | aa14a38 | 2018-07-26 08:29:45 +0200 | [diff] [blame] | 1525 | /* length is limited by PDU_BSSAP length field which includes some |
| 1526 | * other fields beside l3info payload. So payl can only be 240 bytes |
| 1527 | * Since rnd() returns values < 1 multiply with 241 |
| 1528 | */ |
| 1529 | var integer len := float2int(rnd() * 241.0); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1530 | var octetstring payl := f_rnd_octstring(len); |
| 1531 | |
| 1532 | /* Send Complete L3 Info with empty L3 frame */ |
| 1533 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own, |
| 1534 | valueof(ts_BSSMAP_ComplL3(g_pars.cell_id, payl)))); |
| 1535 | |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1536 | timer T := 5.0; |
| 1537 | T.start; |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1538 | alt { |
| 1539 | /* Immediate disconnect */ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1540 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1541 | [] BSSAP.receive(tr_PDU_DTAP_MT(?)) { repeat; } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1542 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND) { repeat; } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1543 | [] as_clear_cmd_compl_disc(); |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1544 | [] T.timeout { |
Daniel Willmann | 90829d6 | 2018-02-15 17:45:14 +0100 | [diff] [blame] | 1545 | setverdict(fail, "Timeout waiting for ClearCommand or SCCP Release"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1546 | mtc.stop; |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1547 | } |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1548 | } |
| 1549 | setverdict(pass); |
| 1550 | } |
| 1551 | testcase TC_cl3_rnd_payload() runs on MTC_CT { |
| 1552 | var BSC_ConnHdlr vc_conn; |
| 1553 | f_init(); |
| 1554 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1555 | vc_conn := f_start_handler(refers(f_tc_cl3_rnd_payload), 26); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1556 | vc_conn.done; |
| 1557 | } |
| 1558 | |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1559 | /* Test Complete L3 with random payload */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1560 | 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] | 1561 | f_init_handler(pars); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1562 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1563 | f_perform_lu(); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1564 | |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1565 | f_establish_fully(); |
Daniel Willmann | 898a7e0 | 2018-05-17 12:16:16 +0200 | [diff] [blame] | 1566 | f_expect_clear(10.0); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1567 | } |
| 1568 | testcase TC_establish_and_nothing() runs on MTC_CT { |
| 1569 | var BSC_ConnHdlr vc_conn; |
| 1570 | f_init(); |
| 1571 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1572 | vc_conn := f_start_handler(refers(f_tc_establish_and_nothing), 27); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1573 | vc_conn.done; |
| 1574 | } |
| 1575 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1576 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1577 | /* Test MO Call SETUP with no response from MNCC */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1578 | 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] | 1579 | f_init_handler(pars, 190.0); |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1580 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1581 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1582 | cpars.mgw_conn_2.resp := 0; |
| 1583 | cpars.stop_after_cc_setup := true; |
| 1584 | |
| 1585 | f_vty_config(MSCVTY, "msc", "mncc guard-timeout 20"); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1586 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1587 | f_perform_lu(); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1588 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1589 | f_mo_call_establish(cpars); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1590 | |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 1591 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
| 1592 | |
Philipp Maier | 109e6aa | 2018-10-17 10:53:32 +0200 | [diff] [blame] | 1593 | f_expect_clear(185.0); |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 1594 | |
| 1595 | deactivate(ccrel); |
| 1596 | |
| 1597 | f_sleep(1.0); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1598 | } |
| 1599 | testcase TC_mo_setup_and_nothing() runs on MTC_CT { |
| 1600 | var BSC_ConnHdlr vc_conn; |
| 1601 | f_init(); |
| 1602 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1603 | 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] | 1604 | vc_conn.done; |
| 1605 | } |
| 1606 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1607 | |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1608 | /* Test MO Call with no response to RAN-side CRCX */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1609 | 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] | 1610 | f_init_handler(pars); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1611 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1612 | var MNCC_PDU mncc; |
| 1613 | var MgcpCommand mgcp_cmd; |
| 1614 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1615 | f_perform_lu(); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1616 | /* Do not respond to the second CRCX */ |
| 1617 | cpars.mgw_conn_2.resp := 0; |
| 1618 | f_mo_call_establish(cpars); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1619 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1620 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1621 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1622 | f_expect_clear(60.0); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1623 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1624 | deactivate(ccrel); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1625 | } |
| 1626 | testcase TC_mo_crcx_ran_timeout() runs on MTC_CT { |
| 1627 | var BSC_ConnHdlr vc_conn; |
| 1628 | f_init(); |
| 1629 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1630 | 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] | 1631 | vc_conn.done; |
| 1632 | } |
| 1633 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1634 | |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1635 | /* Test MO Call with reject to RAN-side CRCX */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1636 | 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] | 1637 | f_init_handler(pars); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1638 | |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1639 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1640 | |
| 1641 | /* Respond with error for the first CRCX */ |
| 1642 | cpars.mgw_conn_1.resp := -1; |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1643 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1644 | f_perform_lu(); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1645 | f_mo_call_establish(cpars); |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1646 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1647 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
| 1648 | f_expect_clear(60.0); |
| 1649 | deactivate(ccrel); |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1650 | } |
| 1651 | testcase TC_mo_crcx_ran_reject() runs on MTC_CT { |
| 1652 | var BSC_ConnHdlr vc_conn; |
| 1653 | f_init(); |
| 1654 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1655 | 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] | 1656 | vc_conn.done; |
| 1657 | } |
| 1658 | |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1659 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1660 | /* helper function to start a MT call: MNCC SETUP; Paging; DChan est.; DTAP SETUP */ |
| 1661 | private function f_mt_call_start(inout CallParameters cpars) runs on BSC_ConnHdlr { |
| 1662 | var MNCC_PDU mncc; |
| 1663 | var MgcpCommand mgcp_cmd; |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1664 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1665 | f_perform_lu(); |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 1666 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1667 | |
| 1668 | /* Allocate call reference and send SETUP via MNCC to MSC */ |
| 1669 | cpars.mncc_callref := f_rnd_int(2147483648); |
| 1670 | MNCC.send(ts_MNCC_SETUP_req(cpars.mncc_callref, hex2str(g_pars.msisdn), |
| 1671 | hex2str(cpars.called_party), hex2str(g_pars.imsi))); |
| 1672 | |
| 1673 | /* MSC->BSC: expect PAGING from MSC */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 1674 | f_expect_paging(); |
| 1675 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1676 | /* MS -> MSC: PAGING RESPONSE */ |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1677 | f_establish_fully(EST_TYPE_PAG_RESP); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1678 | |
| 1679 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1680 | |
| 1681 | /* MSC->MS: SETUP */ |
| 1682 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_SETUP(cpars.transaction_id, *, cpars.called_party))); |
| 1683 | } |
| 1684 | |
| 1685 | /* Test MT Call */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1686 | 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] | 1687 | f_init_handler(pars); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1688 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
| 1689 | var MNCC_PDU mncc; |
| 1690 | var MgcpCommand mgcp_cmd; |
| 1691 | |
| 1692 | f_mt_call_start(cpars); |
| 1693 | |
| 1694 | /* MS->MSC: CALL CONFIRMED */ |
| 1695 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CALL_CONF(cpars.transaction_id))); |
| 1696 | |
| 1697 | MNCC.receive(tr_MNCC_CALL_CONF_ind(cpars.mncc_callref)); |
| 1698 | |
| 1699 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
| 1700 | cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 1701 | |
| 1702 | /* Detect if the received CRCX is a wildcarded CRCX request. If yes, |
| 1703 | * set an endpoint name that fits the pattern. If not, just use the |
| 1704 | * endpoint name from the request */ |
| 1705 | if (match(mgcp_cmd.line.ep, t_MGCP_EP_wildcard)) { |
| 1706 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
| 1707 | } else { |
| 1708 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
| 1709 | } |
| 1710 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1711 | /* Respond to CRCX with error */ |
| 1712 | var MgcpResponse mgcp_rsp := { |
| 1713 | line := { |
| 1714 | code := "542", |
| 1715 | trans_id := mgcp_cmd.line.trans_id, |
| 1716 | string := "FORCED_FAIL" |
| 1717 | }, |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1718 | sdp := omit |
| 1719 | } |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 1720 | var MgcpParameter mgcp_rsp_param := { |
| 1721 | code := "Z", |
| 1722 | val := cpars.mgcp_ep |
| 1723 | }; |
| 1724 | mgcp_rsp.params[0] := mgcp_rsp_param; |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1725 | MGCP.send(mgcp_rsp); |
| 1726 | |
| 1727 | timer T := 30.0; |
| 1728 | T.start; |
| 1729 | alt { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1730 | [] T.timeout { |
| 1731 | setverdict(fail, "Timeout waiting for channel release"); |
| 1732 | mtc.stop; |
| 1733 | } |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1734 | [] MNCC.receive { repeat; } |
| 1735 | [] GSUP.receive { repeat; } |
| 1736 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 1737 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
| 1738 | f_create_mgcp_delete_ep(cpars.mgcp_ep); |
| 1739 | repeat; |
| 1740 | } |
| 1741 | [] MGCP.receive { repeat; } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1742 | [] as_clear_cmd_compl_disc(); |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 1743 | [] as_optional_cc_rel(cpars); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1744 | } |
| 1745 | } |
| 1746 | testcase TC_mt_crcx_ran_reject() runs on MTC_CT { |
| 1747 | var BSC_ConnHdlr vc_conn; |
| 1748 | f_init(); |
| 1749 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1750 | 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] | 1751 | vc_conn.done; |
| 1752 | } |
| 1753 | |
| 1754 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1755 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1756 | /* Test MT Call T310 timer */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1757 | 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] | 1758 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1759 | var MgcpCommand mgcp_cmd; |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1760 | var PDU_BSSAP bssap; |
| 1761 | timer T310; |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1762 | |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1763 | f_init_handler(pars); |
| 1764 | |
| 1765 | /* Initiate a MT call, establish connection */ |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1766 | f_mt_call_start(cpars); |
| 1767 | |
| 1768 | /* MS->MSC: CALL CONFIRMED */ |
| 1769 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CALL_CONF(cpars.transaction_id))); |
| 1770 | MNCC.receive(tr_MNCC_CALL_CONF_ind(cpars.mncc_callref)); |
| 1771 | |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1772 | /* NOTE: MSC is expected to start T310 here */ |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1773 | |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1774 | /* MSC->MGW: CRCX (first) */ |
| 1775 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
| 1776 | f_handle_crcx(cpars, mgcp_cmd); /* MSC<-MGW: OK */ |
| 1777 | |
| 1778 | /* BSC->BSC: BSSMAP ASSIGNMENT REQ */ |
| 1779 | BSSAP.receive(tr_BSSMAP_AssignmentReq(omit, ?)) -> value bssap; |
| 1780 | BSSAP.send(ts_BSSMAP_AssignmentComplete(omit, |
| 1781 | aoip := f_ts_BSSMAP_IE_AoIP_TLA(cpars.bss_rtp_ip, cpars.bss_rtp_port), |
| 1782 | speechCodec := ts_BSSMAP_IE_SpeechCodec({ ts_CodecFR }))); |
| 1783 | |
| 1784 | /* MSC->MGW: MDCX */ |
| 1785 | MGCP.receive(tr_MDCX) -> value mgcp_cmd; |
| 1786 | MGCP.send(ts_MDCX_ACK(mgcp_cmd.line.trans_id, cpars.mgw_conn_1.mgcp_connection_id, |
| 1787 | sdp := omit)); |
| 1788 | |
| 1789 | /* MSC->MGW: CRCX (second) */ |
| 1790 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
| 1791 | f_handle_crcx(cpars, mgcp_cmd); /* MSC<-MGW: OK */ |
| 1792 | MNCC.receive(tr_MNCC_RTP_CREATE(cpars.mncc_callref)); |
| 1793 | |
| 1794 | /* Reschedule the guard timeout */ |
| 1795 | g_Tguard.start(30.0 + 10.0); |
| 1796 | |
| 1797 | /* NOTE: the BSC is expected to respond with CC ALERTING at this state, so |
| 1798 | * the MSC would stop T310. However, the idea is to verify T310 expiration |
| 1799 | * here, so grab some popcorn and wait for MNCC DISC.ind. */ |
| 1800 | T310.start(30.0 + 2.0); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1801 | alt { |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1802 | [] T310.timeout { |
| 1803 | setverdict(fail, "Timeout waiting for MNCC DISC.ind due to T310"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1804 | mtc.stop; |
| 1805 | } |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1806 | [] MNCC.receive(tr_MNCC_DISC_ind(cpars.mncc_callref)) { |
| 1807 | MNCC.send(ts_MNCC_REL_req(cpars.mncc_callref, valueof(ts_MNCC_cause(23)))); |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1808 | log("Rx MNCC DISC.ind, T310.read yelds ", T310.read); |
| 1809 | setverdict(pass); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1810 | } |
| 1811 | } |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1812 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1813 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_DISC(cpars.transaction_id))); |
| 1814 | 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] | 1815 | 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] | 1816 | |
| 1817 | alt { |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1818 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 1819 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1820 | // FIXME: f_create_mgcp_delete_ep(cpars.mgcp_ep); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1821 | repeat; |
| 1822 | } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1823 | [] as_clear_cmd_compl_disc(); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1824 | } |
| 1825 | } |
| 1826 | testcase TC_mt_t310() runs on MTC_CT { |
| 1827 | var BSC_ConnHdlr vc_conn; |
| 1828 | f_init(); |
| 1829 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1830 | vc_conn := f_start_handler(refers(f_tc_mt_t310), 32); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1831 | vc_conn.done; |
| 1832 | } |
| 1833 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1834 | |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1835 | /* 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] | 1836 | 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] | 1837 | f_init_handler(pars); |
| 1838 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1839 | |
| 1840 | /* Location Update to make subscriber known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1841 | f_perform_lu(); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1842 | |
| 1843 | /* First MO call should succeed */ |
| 1844 | f_mo_call(cpars); |
| 1845 | |
| 1846 | /* Cancel the subscriber in the VLR */ |
| 1847 | GSUP.send(ts_GSUP_CL_REQ(g_pars.imsi, OSMO_GSUP_CANCEL_TYPE_WITHDRAW)); |
| 1848 | alt { |
| 1849 | [] GSUP.receive(tr_GSUP_CL_RES(g_pars.imsi)) { } |
| 1850 | [] GSUP.receive(tr_GSUP_CL_ERR(g_pars.imsi)) { |
| 1851 | setverdict(fail, "Received GSUP Location Cancel Error"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1852 | mtc.stop; |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1853 | } |
| 1854 | } |
| 1855 | |
| 1856 | /* Follow-up transactions should fail */ |
| 1857 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 1858 | 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] | 1859 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1860 | alt { |
| 1861 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)) { } |
| 1862 | [] BSSAP.receive { |
| 1863 | setverdict(fail, "Received unexpected BSSAP instead of CM SERV REJ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1864 | mtc.stop; |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1865 | } |
| 1866 | } |
Neels Hofmeyr | 0f7429a | 2019-03-07 22:28:41 +0100 | [diff] [blame] | 1867 | |
| 1868 | f_expect_clear(); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1869 | setverdict(pass); |
| 1870 | } |
| 1871 | testcase TC_gsup_cancel() runs on MTC_CT { |
| 1872 | var BSC_ConnHdlr vc_conn; |
| 1873 | f_init(); |
| 1874 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1875 | 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] | 1876 | vc_conn.done; |
| 1877 | } |
| 1878 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1879 | |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1880 | /* A5/1 only permitted on network side, and MS capable to do it */ |
| 1881 | private function f_tc_lu_imsi_auth_tmsi_encr_1_13(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1882 | pars.net.expect_auth := true; |
| 1883 | pars.net.expect_ciph := true; |
| 1884 | pars.net.kc_support := '02'O; /* A5/1 only */ |
| 1885 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1886 | f_perform_lu(); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1887 | } |
| 1888 | testcase TC_lu_imsi_auth_tmsi_encr_1_13() runs on MTC_CT { |
| 1889 | var BSC_ConnHdlr vc_conn; |
| 1890 | f_init(); |
| 1891 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1892 | f_vty_config(MSCVTY, "network", "encryption a5 1"); |
| 1893 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1894 | 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] | 1895 | vc_conn.done; |
| 1896 | } |
| 1897 | |
| 1898 | /* A5/3 only permitted on network side, and MS capable to do it */ |
| 1899 | private function f_tc_lu_imsi_auth_tmsi_encr_3_13(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1900 | pars.net.expect_auth := true; |
| 1901 | pars.net.expect_ciph := true; |
| 1902 | pars.net.kc_support := '08'O; /* A5/3 only */ |
| 1903 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1904 | f_perform_lu(); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1905 | } |
| 1906 | testcase TC_lu_imsi_auth_tmsi_encr_3_13() runs on MTC_CT { |
| 1907 | var BSC_ConnHdlr vc_conn; |
| 1908 | f_init(); |
| 1909 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1910 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1911 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1912 | 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] | 1913 | vc_conn.done; |
| 1914 | } |
| 1915 | |
| 1916 | /* A5/3 only permitted on network side, and MS with only A5/1 support */ |
| 1917 | private function f_tc_lu_imsi_auth_tmsi_encr_3_1(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1918 | pars.net.expect_auth := true; |
| 1919 | pars.net.expect_ciph := true; |
| 1920 | pars.net.kc_support := '08'O; /* A5/3 only */ |
| 1921 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 1922 | f_init_handler(pars, 15.0); |
| 1923 | |
| 1924 | /* cannot use f_perform_lu() as we expect a reject */ |
| 1925 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 1926 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1927 | f_cl3_or_initial_ue(l3_lu); |
Neels Hofmeyr | 29b8da0 | 2018-03-01 18:09:45 +0100 | [diff] [blame] | 1928 | if (pars.send_early_cm) { |
| 1929 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1930 | } else { |
| 1931 | pars.cm1.esind := '0'B; |
| 1932 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1933 | f_mm_auth(); |
| 1934 | alt { |
Daniel Willmann | 52918e5 | 2018-09-20 14:39:09 +0200 | [diff] [blame] | 1935 | [] BSSAP.receive(tr_BSSMAP_ClassmarkReq) { |
| 1936 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1937 | repeat; |
| 1938 | } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1939 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 1940 | f_expect_clear(); |
| 1941 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1942 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?,?)) { |
| 1943 | setverdict(fail, "CipherModeCommand despite no A5 intersection"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1944 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1945 | } |
| 1946 | [] BSSAP.receive { |
Harald Welte | 458fd37 | 2018-03-21 11:26:23 +0100 | [diff] [blame] | 1947 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1948 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1949 | } |
| 1950 | } |
| 1951 | setverdict(pass); |
| 1952 | } |
| 1953 | testcase TC_lu_imsi_auth_tmsi_encr_3_1() runs on MTC_CT { |
| 1954 | var BSC_ConnHdlr vc_conn; |
| 1955 | f_init(); |
| 1956 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1957 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1958 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1959 | 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] | 1960 | vc_conn.done; |
| 1961 | } |
| 1962 | testcase TC_lu_imsi_auth_tmsi_encr_3_1_no_cm() runs on MTC_CT { |
| 1963 | var BSC_ConnHdlrPars pars; |
| 1964 | var BSC_ConnHdlr vc_conn; |
| 1965 | f_init(); |
| 1966 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1967 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1968 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1969 | pars := f_init_pars(361, verify_cell_id := false); |
Neels Hofmeyr | 29b8da0 | 2018-03-01 18:09:45 +0100 | [diff] [blame] | 1970 | pars.send_early_cm := false; |
| 1971 | 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] | 1972 | vc_conn.done; |
| 1973 | } |
Neels Hofmeyr | 1b3c6e3 | 2018-03-01 17:52:21 +0100 | [diff] [blame] | 1974 | testcase TC_lu_imsi_auth_tmsi_encr_3_1_log_msc_debug() runs on MTC_CT { |
| 1975 | var BSC_ConnHdlr vc_conn; |
| 1976 | f_init(); |
| 1977 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1978 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1979 | |
| 1980 | /* Make sure the MSC category is on DEBUG level to trigger the log |
| 1981 | * message that is reported in OS#2947 to trigger the segfault */ |
| 1982 | f_vty_config(MSCVTY, "log stderr", "logging level msc debug"); |
| 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), 362, verify_cell_id := false); |
Neels Hofmeyr | 1b3c6e3 | 2018-03-01 17:52:21 +0100 | [diff] [blame] | 1985 | vc_conn.done; |
| 1986 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1987 | |
| 1988 | /* A5/1 + A5/3 only permitted on network side, and MS with only A5/2 support */ |
| 1989 | private function f_tc_lu_imsi_auth_tmsi_encr_13_2(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1990 | pars.net.expect_auth := true; |
| 1991 | pars.net.expect_ciph := true; |
| 1992 | pars.net.kc_support := '0A'O; /* A5/1 + A5/3 */ |
| 1993 | pars.cm1.a5_1 := '1'B; |
| 1994 | pars.cm2.a5_1 := '1'B; |
| 1995 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 1996 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '1'B; |
| 1997 | f_init_handler(pars, 15.0); |
| 1998 | |
| 1999 | /* cannot use f_perform_lu() as we expect a reject */ |
| 2000 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 2001 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 2002 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2003 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 2004 | f_mm_auth(); |
| 2005 | alt { |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 2006 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 2007 | f_expect_clear(); |
| 2008 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2009 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?,?)) { |
| 2010 | setverdict(fail, "CipherModeCommand despite no A5 intersection"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2011 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2012 | } |
| 2013 | [] BSSAP.receive { |
Harald Welte | 458fd37 | 2018-03-21 11:26:23 +0100 | [diff] [blame] | 2014 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2015 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2016 | } |
| 2017 | } |
| 2018 | setverdict(pass); |
| 2019 | } |
| 2020 | testcase TC_lu_imsi_auth_tmsi_encr_13_2() runs on MTC_CT { |
| 2021 | var BSC_ConnHdlr vc_conn; |
| 2022 | f_init(); |
| 2023 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 2024 | f_vty_config(MSCVTY, "network", "encryption a5 1 3"); |
| 2025 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 2026 | 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] | 2027 | vc_conn.done; |
| 2028 | } |
| 2029 | |
Eric Wild | 26f4a62 | 2021-05-17 15:27:05 +0200 | [diff] [blame] | 2030 | /* A5/0 + A5/1 + A5/3 + a5/4 only permitted on network side, and MS with only A5/1 support */ |
| 2031 | private function f_tc_lu_imsi_auth_tmsi_encr_0134_1(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2032 | pars.net.expect_auth := true; |
| 2033 | pars.net.expect_ciph := true; |
| 2034 | pars.net.kc_support := '03'O; /* A5/0 + A5/1 */ |
| 2035 | pars.cm1.a5_1 := '0'B; |
| 2036 | pars.cm2.a5_1 := '0'B; |
| 2037 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 2038 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '0'B; |
| 2039 | pars.cm2.classmarkInformationType2_oct5.cm3 := '0'B; |
| 2040 | pars.cm3 := omit; |
| 2041 | pars.use_umts_aka := true; |
| 2042 | |
| 2043 | f_init_handler(pars, 15.0); |
| 2044 | f_perform_lu(); |
| 2045 | } |
| 2046 | testcase TC_lu_imsi_auth_tmsi_encr_0134_1() runs on MTC_CT { |
| 2047 | var BSC_ConnHdlr vc_conn; |
| 2048 | f_init(); |
| 2049 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 2050 | f_vty_config(MSCVTY, "network", "encryption a5 0 1 3 4"); |
| 2051 | |
| 2052 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_0134_1), 39); |
| 2053 | vc_conn.done; |
| 2054 | } |
| 2055 | |
| 2056 | /* A5/0 + A5/1 + A5/3 + a5/4 only permitted on network side, and MS with A5/3 + A5/4 support */ |
| 2057 | private function f_tc_lu_imsi_auth_tmsi_encr_0134_34(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2058 | pars.net.expect_auth := true; |
| 2059 | pars.net.expect_ciph := true; |
| 2060 | pars.net.kc_support := '19'O; /* A5/3 + A5/4 */ |
| 2061 | pars.cm1.a5_1 := '1'B; |
| 2062 | pars.cm2.a5_1 := '1'B; |
| 2063 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '1'B; |
| 2064 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '0'B; |
| 2065 | pars.cm2.classmarkInformationType2_oct5.cm3 := '1'B; |
| 2066 | pars.cm3 := valueof(ts_CM3_default); |
| 2067 | pars.use_umts_aka := true; |
| 2068 | |
| 2069 | f_init_handler(pars, 15.0); |
| 2070 | f_perform_lu(); |
| 2071 | } |
| 2072 | testcase TC_lu_imsi_auth_tmsi_encr_0134_34() runs on MTC_CT { |
| 2073 | var BSC_ConnHdlr vc_conn; |
| 2074 | f_init(); |
| 2075 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 2076 | f_vty_config(MSCVTY, "network", "encryption a5 0 1 3 4"); |
| 2077 | |
| 2078 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_0134_34), 40); |
| 2079 | vc_conn.done; |
| 2080 | } |
| 2081 | |
| 2082 | /* A5/0 + A5/1 + A5/3 + a5/4 only permitted on network side, and MS with A5/3 support but no CM3 */ |
| 2083 | private function f_tc_lu_imsi_auth_tmsi_encr_0134_34_no_cm3(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2084 | pars.net.expect_auth := true; |
| 2085 | pars.net.expect_ciph := true; |
| 2086 | pars.net.kc_support := '19'O; /* A5/3 + A5/4 */ |
| 2087 | pars.cm1.a5_1 := '1'B; |
| 2088 | pars.cm2.a5_1 := '1'B; |
| 2089 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '1'B; |
| 2090 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '0'B; |
| 2091 | pars.cm2.classmarkInformationType2_oct5.cm3 := '0'B; |
| 2092 | pars.cm3 := omit; |
| 2093 | pars.use_umts_aka := true; |
| 2094 | |
| 2095 | f_init_handler(pars, 15.0); |
| 2096 | f_perform_lu(); |
| 2097 | } |
| 2098 | testcase TC_lu_imsi_auth_tmsi_encr_0134_34_no_cm3() runs on MTC_CT { |
| 2099 | var BSC_ConnHdlr vc_conn; |
| 2100 | f_init(); |
| 2101 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 2102 | f_vty_config(MSCVTY, "network", "encryption a5 0 1 3 4"); |
| 2103 | |
| 2104 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_0134_34_no_cm3), 41); |
| 2105 | vc_conn.done; |
| 2106 | } |
| 2107 | |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2108 | /* A5/0 + A5/1 + A5/3 only permitted on network side, and MS with only A5/2 support */ |
| 2109 | private function f_tc_lu_imsi_auth_tmsi_encr_013_2(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2110 | pars.net.expect_auth := true; |
| 2111 | pars.net.expect_ciph := true; |
| 2112 | pars.net.kc_support := '0B'O; /* A5/1 + A5/3 */ |
| 2113 | pars.cm1.a5_1 := '1'B; |
| 2114 | pars.cm2.a5_1 := '1'B; |
| 2115 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 2116 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '1'B; |
| 2117 | f_init_handler(pars, 15.0); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 2118 | f_perform_lu(); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2119 | } |
| 2120 | testcase TC_lu_imsi_auth_tmsi_encr_013_2() runs on MTC_CT { |
| 2121 | var BSC_ConnHdlr vc_conn; |
| 2122 | f_init(); |
| 2123 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 2124 | f_vty_config(MSCVTY, "network", "encryption a5 0 1 3"); |
| 2125 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 2126 | 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] | 2127 | vc_conn.done; |
| 2128 | } |
| 2129 | |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 2130 | /* LU followed by MT call (including paging) */ |
Neels Hofmeyr | 8fe8a90 | 2019-11-03 05:51:03 +0100 | [diff] [blame] | 2131 | 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] | 2132 | f_init_handler(pars); |
Stefan Sperling | 26d57be | 2018-11-12 17:03:26 +0100 | [diff] [blame] | 2133 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 2134 | cpars.use_osmux := pars.use_osmux; |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 2135 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 2136 | f_perform_lu(); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 2137 | f_mt_call(cpars); |
| 2138 | } |
| 2139 | testcase TC_lu_and_mt_call() runs on MTC_CT { |
| 2140 | var BSC_ConnHdlr vc_conn; |
| 2141 | f_init(); |
| 2142 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 2143 | 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] | 2144 | vc_conn.done; |
| 2145 | } |
| 2146 | |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 2147 | testcase TC_lu_and_mt_call_osmux() runs on MTC_CT { |
| 2148 | var BSC_ConnHdlr vc_conn; |
| 2149 | f_init(1, false, true, true); |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 2150 | |
| 2151 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_call), 39, 0, true, true); |
| 2152 | vc_conn.done; |
| 2153 | } |
| 2154 | |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 2155 | /* LU followed by MT call (including paging) */ |
| 2156 | friend function f_tc_lu_and_mt_call_ipv6(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2157 | f_init_handler(pars); |
| 2158 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 2159 | cpars.mgw_conn_1.mgw_rtp_ip := "::1"; |
| 2160 | cpars.mgw_conn_2.mgw_rtp_ip := "::2"; |
| 2161 | cpars.bss_rtp_ip := "::3"; |
Pau Espin Pedrol | 563b3d0 | 2020-09-09 20:19:52 +0200 | [diff] [blame] | 2162 | cpars.mncc_rtp_ip := "::9"; |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 2163 | f_perform_lu(); |
| 2164 | f_mt_call(cpars); |
| 2165 | } |
| 2166 | testcase TC_lu_and_mt_call_ipv6() runs on MTC_CT { |
| 2167 | var BSC_ConnHdlr vc_conn; |
| 2168 | f_init(); |
| 2169 | |
| 2170 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_call_ipv6), 39); |
| 2171 | vc_conn.done; |
| 2172 | } |
| 2173 | |
Neels Hofmeyr | b58d974 | 2019-11-27 18:44:54 +0100 | [diff] [blame] | 2174 | /* MT call while already Paging */ |
| 2175 | friend function f_tc_lu_and_mt_call_already_paging(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2176 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
| 2177 | var SmsParameters spars := valueof(t_SmsPars); |
| 2178 | var OCT4 tmsi; |
| 2179 | |
| 2180 | f_init_handler(pars); |
| 2181 | |
| 2182 | /* Perform location update */ |
| 2183 | f_perform_lu(); |
| 2184 | |
| 2185 | /* register an 'expect' for given IMSI (+TMSI) */ |
| 2186 | if (isvalue(g_pars.tmsi)) { |
| 2187 | tmsi := g_pars.tmsi; |
| 2188 | } else { |
| 2189 | tmsi := 'FFFFFFFF'O; |
| 2190 | } |
| 2191 | f_ran_register_imsi(g_pars.imsi, tmsi); |
| 2192 | |
| 2193 | log("start Paging by an SMS"); |
| 2194 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 2195 | |
| 2196 | /* MSC->BSC: expect PAGING from MSC */ |
| 2197 | f_expect_paging(); |
| 2198 | |
| 2199 | log("MNCC signals MT call, before Paging Response"); |
| 2200 | f_mt_call_initate(cpars); |
| 2201 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
| 2202 | |
| 2203 | f_sleep(0.5); |
| 2204 | log("phone answers Paging, expecting both SMS and MT call to be established"); |
| 2205 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2206 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 2207 | interleave { |
| 2208 | [] BSSAP.receive(f_mt_sms_deliver_pdu(spars)) { |
| 2209 | log("Got SMS-DELIVER"); |
| 2210 | }; |
| 2211 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_SETUP(cpars.transaction_id, *, cpars.called_party))) { |
| 2212 | log("Got CC Setup"); |
| 2213 | }; |
| 2214 | } |
| 2215 | setverdict(pass); |
| 2216 | log("success, tear down"); |
| 2217 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
| 2218 | if (g_pars.ran_is_geran) { |
| 2219 | BSSAP.send(ts_BSSMAP_ClearRequest(0)); |
| 2220 | } else { |
| 2221 | BSSAP.send(ts_RANAP_IuReleaseRequest(ts_RanapCause_om_intervention)); |
| 2222 | } |
| 2223 | f_expect_clear(); |
| 2224 | deactivate(ccrel); |
| 2225 | f_vty_sms_clear(hex2str(g_pars.imsi)); |
| 2226 | } |
| 2227 | testcase TC_lu_and_mt_call_already_paging() runs on MTC_CT { |
| 2228 | var BSC_ConnHdlrPars pars; |
| 2229 | var BSC_ConnHdlr vc_conn; |
| 2230 | f_init(); |
| 2231 | pars := f_init_pars(391); |
| 2232 | vc_conn := f_start_handler_with_pars(refers(f_tc_lu_and_mt_call_already_paging), pars); |
| 2233 | vc_conn.done; |
| 2234 | } |
| 2235 | |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 2236 | /* Test MO Call SETUP with DTMF */ |
| 2237 | private function f_tc_mo_setup_dtmf_dup(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2238 | f_init_handler(pars); |
| 2239 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 2240 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 2241 | f_perform_lu(); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 2242 | f_mo_seq_dtmf_dup(cpars); |
| 2243 | } |
| 2244 | testcase TC_mo_setup_and_dtmf_dup() runs on MTC_CT { |
| 2245 | var BSC_ConnHdlr vc_conn; |
| 2246 | f_init(); |
| 2247 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 2248 | 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] | 2249 | vc_conn.done; |
| 2250 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2251 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 2252 | testcase TC_cr_before_reset() runs on MTC_CT { |
| 2253 | timer T := 4.0; |
| 2254 | var boolean reset_ack_seen := false; |
| 2255 | f_init_bssap_direct(); |
| 2256 | |
Harald Welte | 3ca0ce1 | 2019-04-23 17:18:48 +0200 | [diff] [blame] | 2257 | f_ran_adapter_start(g_bssap[0]); |
Daniel Willmann | 42d1d5b | 2018-08-07 15:18:41 +0200 | [diff] [blame] | 2258 | |
Daniel Willmann | e801896 | 2018-08-21 14:18:00 +0200 | [diff] [blame] | 2259 | f_sleep(3.0); |
| 2260 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 2261 | /* Make a blind connection attemt, to trigger the deadlock condition */ |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 2262 | 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] | 2263 | |
| 2264 | /* Send a BSSMAP reset */ |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 2265 | 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] | 2266 | T.start |
| 2267 | alt { |
| 2268 | [] BSSAP_DIRECT.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_ResetAck)) { |
| 2269 | reset_ack_seen := true; |
| 2270 | repeat; |
| 2271 | } |
| 2272 | |
| 2273 | /* Acknowledge MSC sided reset requests */ |
| 2274 | [] BSSAP_DIRECT.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) { |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 2275 | 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] | 2276 | repeat; |
| 2277 | } |
| 2278 | |
| 2279 | /* Ignore all other messages (e.g CR from the connection request) */ |
| 2280 | [] BSSAP_DIRECT.receive { repeat } |
| 2281 | |
| 2282 | /* If we got no BSSMAP RESET ACK back, then the MSC entered the |
| 2283 | * deadlock situation. The MSC is then unable to respond to any |
| 2284 | * further BSSMAP RESET or any other sort of traffic. */ |
| 2285 | [reset_ack_seen == true] T.timeout { setverdict(pass) } |
| 2286 | [reset_ack_seen == false] T.timeout { |
| 2287 | setverdict(fail, "no BSSMAP RESET ACK seen!"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2288 | mtc.stop; |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 2289 | } |
Pau Espin Pedrol | 7e9178d | 2019-12-17 17:52:17 +0100 | [diff] [blame] | 2290 | } |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 2291 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2292 | |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 2293 | /* 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] | 2294 | 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] | 2295 | f_init_handler(pars); |
| 2296 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 2297 | var MNCC_PDU mncc; |
| 2298 | var MgcpCommand mgcp_cmd; |
| 2299 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 2300 | /* Do not respond to the second CRCX */ |
| 2301 | cpars.mgw_conn_2.resp := 0; |
| 2302 | |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 2303 | f_perform_lu(); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 2304 | f_mo_call_establish(cpars); |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 2305 | |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 2306 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 2307 | |
| 2308 | f_expect_clear(60.0); |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 2309 | |
| 2310 | deactivate(ccrel); |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 2311 | } |
| 2312 | testcase TC_mo_release_timeout() runs on MTC_CT { |
| 2313 | var BSC_ConnHdlr vc_conn; |
| 2314 | f_init(); |
| 2315 | |
| 2316 | vc_conn := f_start_handler(refers(f_tc_mo_release_timeout), 40); |
| 2317 | vc_conn.done; |
| 2318 | } |
| 2319 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 2320 | |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 2321 | /* LU followed by MT call (including paging) */ |
| 2322 | private function f_tc_lu_and_mt_call_no_dlcx_resp(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2323 | f_init_handler(pars); |
Stefan Sperling | 26d57be | 2018-11-12 17:03:26 +0100 | [diff] [blame] | 2324 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 2325 | |
| 2326 | /* Intentionally disable the CRCX response */ |
| 2327 | cpars.mgw_drop_dlcx := true; |
| 2328 | |
| 2329 | /* Perform location update and call */ |
| 2330 | f_perform_lu(); |
| 2331 | f_mt_call(cpars); |
| 2332 | } |
| 2333 | testcase TC_lu_and_mt_call_no_dlcx_resp() runs on MTC_CT { |
| 2334 | var BSC_ConnHdlr vc_conn; |
| 2335 | f_init(); |
| 2336 | |
| 2337 | /* Perform an almost normal looking locationupdate + mt-call, but do |
| 2338 | * not respond to the DLCX at the end of the call */ |
| 2339 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_call_no_dlcx_resp), 41); |
| 2340 | vc_conn.done; |
| 2341 | |
| 2342 | /* Wait a guard period until the MGCP layer in the MSC times out, |
| 2343 | * if the MSC is vulnerable to the use-after-free situation that is |
| 2344 | * fixed by I78f1b6a9149488a4ad3f120c1e190a83c07d4b89 then it should |
| 2345 | * segfault now */ |
| 2346 | f_sleep(6.0); |
| 2347 | |
| 2348 | /* Run the init procedures once more. If the MSC has crashed, this |
| 2349 | * this will fail */ |
| 2350 | f_init(); |
| 2351 | } |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 2352 | |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 2353 | /* Two BSSMAP resets from two different BSCs */ |
| 2354 | testcase TC_reset_two() runs on MTC_CT { |
| 2355 | var BSC_ConnHdlr vc_conn; |
| 2356 | f_init(2); |
| 2357 | f_sleep(2.0); |
| 2358 | setverdict(pass); |
| 2359 | } |
| 2360 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2361 | /* Two BSSMAP resets from two different BSCs plus one IuCS RANAP Reset */ |
| 2362 | testcase TC_reset_two_1iu() runs on MTC_CT { |
| 2363 | var BSC_ConnHdlr vc_conn; |
| 2364 | f_init(3); |
| 2365 | f_sleep(2.0); |
| 2366 | setverdict(pass); |
| 2367 | } |
| 2368 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2369 | /*********************************************************************** |
| 2370 | * SMS Testing |
| 2371 | ***********************************************************************/ |
| 2372 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2373 | /* LU followed by MO SMS */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2374 | 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] | 2375 | var SmsParameters spars := valueof(t_SmsPars); |
| 2376 | |
| 2377 | f_init_handler(pars); |
| 2378 | |
| 2379 | /* Perform location update and call */ |
| 2380 | f_perform_lu(); |
| 2381 | |
| 2382 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2383 | |
| 2384 | //spars.exp_rp_err := 96; /* invalid mandatory information */ |
| 2385 | f_mo_sms(spars); |
| 2386 | |
| 2387 | f_expect_clear(); |
| 2388 | } |
| 2389 | testcase TC_lu_and_mo_sms() runs on MTC_CT { |
| 2390 | var BSC_ConnHdlr vc_conn; |
| 2391 | f_init(); |
| 2392 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_sms), 42); |
| 2393 | vc_conn.done; |
| 2394 | } |
| 2395 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2396 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2397 | private function f_vty_sms_send(charstring imsi, charstring msisdn, charstring text) |
Neels Hofmeyr | 6aaeccf | 2019-03-06 15:32:26 +0100 | [diff] [blame] | 2398 | runs on BSC_ConnHdlr { |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2399 | f_vty_transceive(MSCVTY, "subscriber imsi "&imsi&" sms sender msisdn "&msisdn&" send "&text); |
| 2400 | } |
| 2401 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 2402 | /* Remove still pending SMS */ |
| 2403 | private function f_vty_sms_clear(charstring imsi) |
| 2404 | runs on BSC_ConnHdlr { |
| 2405 | f_vty_transceive(MSCVTY, "subscriber imsi " & imsi & " sms delete-all"); |
| 2406 | f_vty_transceive(MSCVTY, "sms-queue clear"); |
| 2407 | } |
| 2408 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2409 | /* LU followed by MT SMS */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2410 | 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] | 2411 | var SmsParameters spars := valueof(t_SmsPars); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2412 | |
| 2413 | f_init_handler(pars); |
| 2414 | |
| 2415 | /* Perform location update and call */ |
| 2416 | f_perform_lu(); |
| 2417 | |
| 2418 | /* register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2419 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2420 | |
Neels Hofmeyr | 6aaeccf | 2019-03-06 15:32:26 +0100 | [diff] [blame] | 2421 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2422 | |
| 2423 | /* MSC->BSC: expect PAGING from MSC */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 2424 | f_expect_paging(); |
| 2425 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2426 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 2427 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2428 | |
| 2429 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 2430 | f_mt_sms(spars); |
| 2431 | |
| 2432 | f_expect_clear(); |
| 2433 | } |
| 2434 | testcase TC_lu_and_mt_sms() runs on MTC_CT { |
| 2435 | var BSC_ConnHdlrPars pars; |
| 2436 | var BSC_ConnHdlr vc_conn; |
| 2437 | f_init(); |
| 2438 | pars := f_init_pars(43); |
| 2439 | 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] | 2440 | vc_conn.done; |
| 2441 | } |
| 2442 | |
Neels Hofmeyr | b58d974 | 2019-11-27 18:44:54 +0100 | [diff] [blame] | 2443 | /* SMS added while already Paging */ |
| 2444 | friend function f_tc_lu_and_mt_sms_already_paging(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2445 | var SmsParameters spars := valueof(t_SmsPars); |
| 2446 | var OCT4 tmsi; |
| 2447 | |
| 2448 | f_init_handler(pars); |
| 2449 | |
| 2450 | f_perform_lu(); |
| 2451 | |
| 2452 | /* register an 'expect' for given IMSI (+TMSI) */ |
| 2453 | if (isvalue(g_pars.tmsi)) { |
| 2454 | tmsi := g_pars.tmsi; |
| 2455 | } else { |
| 2456 | tmsi := 'FFFFFFFF'O; |
| 2457 | } |
| 2458 | f_ran_register_imsi(g_pars.imsi, tmsi); |
| 2459 | |
| 2460 | log("first SMS"); |
| 2461 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 2462 | |
| 2463 | /* MSC->BSC: expect PAGING from MSC */ |
| 2464 | f_expect_paging(); |
| 2465 | |
| 2466 | log("second SMS"); |
| 2467 | /* Now osmo-msc is in state "Paging pending", make sure that another SMS to be sent at this time just joins in |
| 2468 | * with the pending paging. Another SMS: */ |
| 2469 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Another SMS"); |
| 2470 | |
| 2471 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 2472 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2473 | |
| 2474 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 2475 | f_mt_sms(spars); |
| 2476 | |
| 2477 | spars.tp.ud := '41F79B8E2ECB41D3E614'O; |
| 2478 | f_mt_sms(spars); |
| 2479 | |
| 2480 | f_expect_clear(); |
| 2481 | } |
| 2482 | testcase TC_lu_and_mt_sms_already_paging() runs on MTC_CT { |
| 2483 | var BSC_ConnHdlrPars pars; |
| 2484 | var BSC_ConnHdlr vc_conn; |
| 2485 | f_init(); |
| 2486 | pars := f_init_pars(44); |
| 2487 | vc_conn := f_start_handler_with_pars(refers(f_tc_lu_and_mt_sms_already_paging), pars); |
| 2488 | vc_conn.done; |
| 2489 | } |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2490 | |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2491 | /* Paging for MT SMS but no response */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2492 | 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] | 2493 | var SmsParameters spars := valueof(t_SmsPars); |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2494 | |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2495 | f_init_handler(pars, 150.0); |
| 2496 | |
| 2497 | /* Perform location update */ |
| 2498 | f_perform_lu(); |
| 2499 | |
| 2500 | /* register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2501 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2502 | |
Neels Hofmeyr | 6aaeccf | 2019-03-06 15:32:26 +0100 | [diff] [blame] | 2503 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 2504 | |
Neels Hofmeyr | 1623774 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 2505 | /* Expect the MSC to page exactly once */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2506 | f_expect_paging(); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2507 | |
| 2508 | /* Wait some time to make sure the MSC is not delivering any further |
| 2509 | * paging messages or anything else that could be unexpected. */ |
| 2510 | timer T := 20.0; |
| 2511 | T.start |
| 2512 | alt { |
Vadim Yanitskiy | da77459 | 2020-01-15 10:33:47 +0700 | [diff] [blame] | 2513 | [pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 2514 | setverdict(fail, "paging seems not to stop!"); |
| 2515 | mtc.stop; |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2516 | } |
Vadim Yanitskiy | da77459 | 2020-01-15 10:33:47 +0700 | [diff] [blame] | 2517 | [not pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) { |
| 2518 | setverdict(fail, "paging seems not to stop!"); |
| 2519 | mtc.stop; |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2520 | } |
Vadim Yanitskiy | da77459 | 2020-01-15 10:33:47 +0700 | [diff] [blame] | 2521 | [] BSSAP.receive { |
| 2522 | setverdict(fail, "unexpected BSSAP message received"); |
| 2523 | self.stop; |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2524 | } |
Vadim Yanitskiy | da77459 | 2020-01-15 10:33:47 +0700 | [diff] [blame] | 2525 | [] T.timeout { |
| 2526 | setverdict(pass); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2527 | } |
| 2528 | } |
| 2529 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 2530 | f_vty_sms_clear(hex2str(g_pars.imsi)); |
| 2531 | |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2532 | setverdict(pass); |
| 2533 | } |
| 2534 | testcase TC_lu_and_mt_sms_paging_and_nothing() runs on MTC_CT { |
| 2535 | var BSC_ConnHdlrPars pars; |
| 2536 | var BSC_ConnHdlr vc_conn; |
| 2537 | f_init(); |
Philipp Maier | a99ad26 | 2019-01-22 15:35:42 +0100 | [diff] [blame] | 2538 | pars := f_init_pars(1843); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2539 | 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] | 2540 | vc_conn.done; |
| 2541 | } |
| 2542 | |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2543 | /* LU followed by MT SMS with repeated paging */ |
| 2544 | friend function f_tc_lu_and_mt_sms_paging_repeated(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2545 | var SmsParameters spars := valueof(t_SmsPars); |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2546 | |
| 2547 | f_init_handler(pars); |
| 2548 | |
| 2549 | /* Perform location update and call */ |
| 2550 | f_perform_lu(); |
| 2551 | |
| 2552 | /* register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2553 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2554 | |
| 2555 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 2556 | |
Neels Hofmeyr | c3accec | 2019-11-28 01:09:47 +0100 | [diff] [blame] | 2557 | log("Expecting first Paging"); |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2558 | /* MSC->BSC: expect PAGING from MSC */ |
| 2559 | f_expect_paging(); |
| 2560 | |
Neels Hofmeyr | c3accec | 2019-11-28 01:09:47 +0100 | [diff] [blame] | 2561 | if (g_pars.ran_is_geran) { |
| 2562 | log("GERAN: expect no further Paging"); |
| 2563 | } else { |
| 2564 | log("UTRAN: expect more Paging"); |
| 2565 | } |
| 2566 | |
| 2567 | timer T := 5.0; |
| 2568 | T.start; |
| 2569 | alt { |
| 2570 | [g_pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 2571 | setverdict(fail, "GERAN should not repeat Paging, but received a second Paging"); |
| 2572 | mtc.stop; |
| 2573 | } |
| 2574 | [not g_pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) { |
| 2575 | log("UTRAN: second Paging received, as expected"); |
| 2576 | setverdict(pass); |
| 2577 | } |
| 2578 | [] T.timeout { |
| 2579 | if (g_pars.ran_is_geran) { |
| 2580 | log("GERAN: No further Paging received, as expected"); |
| 2581 | setverdict(pass); |
| 2582 | } else { |
| 2583 | setverdict(fail, "UTRAN: Expected a second Paging"); |
| 2584 | mtc.stop; |
| 2585 | } |
| 2586 | } |
| 2587 | } |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2588 | |
| 2589 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 2590 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2591 | |
| 2592 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 2593 | f_mt_sms(spars); |
| 2594 | |
| 2595 | f_expect_clear(); |
| 2596 | } |
| 2597 | testcase TC_lu_and_mt_sms_paging_repeated() runs on MTC_CT { |
| 2598 | var BSC_ConnHdlrPars pars; |
| 2599 | var BSC_ConnHdlr vc_conn; |
| 2600 | f_init(); |
| 2601 | pars := f_init_pars(1844); |
| 2602 | vc_conn := f_start_handler_with_pars(refers(f_tc_lu_and_mt_sms_paging_repeated), pars); |
| 2603 | vc_conn.done; |
| 2604 | } |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2605 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2606 | /* mobile originated SMS from MS/BTS/BSC side to SMPP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2607 | 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] | 2608 | var SmsParameters spars := valueof(t_SmsPars); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2609 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2610 | f_init_handler(pars); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2611 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2612 | /* Perform location update so IMSI is known + registered in MSC/VLR */ |
| 2613 | f_perform_lu(); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2614 | |
Vadim Yanitskiy | 2d3f846 | 2020-01-15 11:44:12 +0700 | [diff] [blame] | 2615 | /* MS/UE submits a MO SMS */ |
| 2616 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2617 | f_mo_sms_submit(spars); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2618 | |
| 2619 | var SMPP_PDU smpp; |
| 2620 | var template SMPP_PDU tr_smpp := tr_SMPP(c_SMPP_command_id_deliver_sm, ESME_ROK); |
| 2621 | tr_smpp.body.deliver_sm := { |
| 2622 | service_type := "CMT", |
| 2623 | source_addr_ton := network_specific, |
| 2624 | source_addr_npi := isdn, |
| 2625 | source_addr := hex2str(pars.msisdn), |
| 2626 | dest_addr_ton := f_sm_ton_from_gsm(spars.tp.da.tP_DA_NoPad.tP_TypeOfNumber), |
| 2627 | dest_addr_npi := f_sm_npi_from_gsm(spars.tp.da.tP_DA_NoPad.tP_NumberingPlanID), |
| 2628 | destination_addr := hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue), |
| 2629 | esm_class := '00000001'B, |
| 2630 | protocol_id := 0, |
| 2631 | priority_flag := 0, |
| 2632 | schedule_delivery_time := "", |
| 2633 | replace_if_present := 0, |
| 2634 | data_coding := '00000001'B, |
| 2635 | sm_default_msg_id := 0, |
| 2636 | sm_length := ?, |
| 2637 | short_message := spars.tp.ud, |
| 2638 | opt_pars := { |
| 2639 | { |
| 2640 | tag := user_message_reference, |
| 2641 | len := 2, |
| 2642 | opt_value := { |
| 2643 | int2_val := oct2int(spars.tp.msg_ref) |
| 2644 | } |
| 2645 | } |
| 2646 | } |
| 2647 | }; |
| 2648 | alt { |
| 2649 | [] SMPP.receive(tr_smpp) -> value smpp { |
| 2650 | SMPP.send(ts_SMPP_DELIVER_SM_resp(ESME_ROK, smpp.header.seq_num)); |
| 2651 | } |
| 2652 | [] SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)) { repeat; } |
| 2653 | } |
| 2654 | |
Vadim Yanitskiy | 2d3f846 | 2020-01-15 11:44:12 +0700 | [diff] [blame] | 2655 | /* MSC terminates the SMS transaction with RP-ACK */ |
| 2656 | f_mo_sms_wait_rp_ack(spars); |
| 2657 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2658 | f_expect_clear(); |
| 2659 | } |
| 2660 | testcase TC_smpp_mo_sms() runs on MTC_CT { |
| 2661 | var BSC_ConnHdlr vc_conn; |
| 2662 | f_init(); |
| 2663 | f_vty_config2(MSCVTY, { "smpp", "esme msc_tester"}, "default-route"); |
| 2664 | vc_conn := f_start_handler(refers(f_tc_smpp_mo_sms), 44); |
| 2665 | vc_conn.done; |
| 2666 | f_vty_config2(MSCVTY, { "smpp", "esme msc_tester"}, "no default-route"); |
| 2667 | } |
| 2668 | |
Vadim Yanitskiy | 3382076 | 2020-01-15 11:26:07 +0700 | [diff] [blame] | 2669 | /* Test case for OS#4351: make sure that RP-ERROR from ESME is properly sent to the MS/UE */ |
| 2670 | friend function f_tc_smpp_mo_sms_rp_error(charstring id, BSC_ConnHdlrPars pars) |
| 2671 | runs on BSC_ConnHdlr { |
| 2672 | var SmsParameters spars := valueof(t_SmsPars); |
| 2673 | var SMPP_PDU smpp_pdu; |
| 2674 | timer T := 3.0; |
| 2675 | |
| 2676 | f_init_handler(pars); |
| 2677 | |
| 2678 | /* Perform location update */ |
| 2679 | f_perform_lu(); |
| 2680 | |
| 2681 | /* MS/UE submits a MO SMS */ |
| 2682 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2683 | f_mo_sms_submit(spars); |
| 2684 | |
| 2685 | /* ESME responds with an error (Invalid Destination Address) */ |
| 2686 | T.start; |
| 2687 | alt { |
| 2688 | [] SMPP.receive(tr_SMPP(c_SMPP_command_id_deliver_sm, ESME_ROK, body := ?)) -> value smpp_pdu { |
| 2689 | SMPP.send(ts_SMPP_DELIVER_SM_resp(ESME_RINVDSTADR, smpp_pdu.header.seq_num)); |
| 2690 | } |
| 2691 | [] SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)) { repeat; } |
| 2692 | [] T.timeout { |
| 2693 | setverdict(fail, "Timeout waiting for SMPP DELIVER-SM"); |
| 2694 | mtc.stop; |
| 2695 | } |
| 2696 | } |
| 2697 | |
| 2698 | /* Expect RP-ERROR on BSSAP interface */ |
| 2699 | spars.exp_rp_err := 1; /* FIXME: GSM411_RP_CAUSE_MO_NUM_UNASSIGNED */ |
| 2700 | f_mo_sms_wait_rp_ack(spars); |
| 2701 | |
| 2702 | f_expect_clear(); |
| 2703 | } |
| 2704 | testcase TC_smpp_mo_sms_rp_error() runs on MTC_CT { |
| 2705 | var BSC_ConnHdlr vc_conn; |
| 2706 | f_init(); |
| 2707 | f_vty_config2(MSCVTY, { "smpp", "esme msc_tester"}, "default-route"); |
| 2708 | vc_conn := f_start_handler(refers(f_tc_smpp_mo_sms_rp_error), 45); |
| 2709 | vc_conn.done; |
| 2710 | f_vty_config2(MSCVTY, { "smpp", "esme msc_tester"}, "no default-route"); |
| 2711 | } |
| 2712 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2713 | |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 2714 | /* Test MO-SMS from MS/BTS/BSC towards HLR (via GSUP) */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2715 | friend function f_tc_gsup_mo_sms(charstring id, BSC_ConnHdlrPars pars) |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 2716 | runs on BSC_ConnHdlr { |
| 2717 | var SmsParameters spars := valueof(t_SmsPars); |
| 2718 | var GSUP_PDU gsup_msg_rx; |
| 2719 | var octetstring sm_tpdu; |
| 2720 | |
| 2721 | f_init_handler(pars); |
| 2722 | |
| 2723 | /* We need to inspect GSUP activity */ |
| 2724 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2725 | |
| 2726 | /* Perform location update */ |
| 2727 | f_perform_lu(); |
| 2728 | |
| 2729 | /* Send CM Service Request for SMS */ |
| 2730 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2731 | |
| 2732 | /* Prepare expected SM-RP-UI (SM TPDU) */ |
| 2733 | enc_TPDU_RP_DATA_MS_SGSN_fast( |
| 2734 | valueof(ts_SMS_SUBMIT(spars.tp.msg_ref, |
| 2735 | spars.tp.da, spars.tp.pid, spars.tp.dcs, |
| 2736 | spars.tp.udl, spars.tp.ud)), |
| 2737 | sm_tpdu); |
| 2738 | |
| 2739 | var template GSUP_PDU mo_forwardSM := tr_GSUP_MO_FORWARD_SM_REQ( |
| 2740 | imsi := g_pars.imsi, |
| 2741 | sm_rp_mr := spars.rp.msg_ref, |
Vadim Yanitskiy | 04dd5f7 | 2019-12-13 15:45:44 +0900 | [diff] [blame] | 2742 | /* SM-RP-DA: SMSC address */ |
| 2743 | sm_rp_da := tr_GSUP_SM_RP_DA_SMSC_ADDR(t_GSUP_SM_RP_Addr( |
| 2744 | number := spars.rp.smsc_addr.rP_NumberDigits, |
| 2745 | npi := spars.rp.smsc_addr.rP_NumberingPlanIdentification, |
| 2746 | ton := spars.rp.smsc_addr.rP_TypeOfNumber, |
| 2747 | ext := spars.rp.smsc_addr.rP_Ext)), |
| 2748 | /* SM-RP-OA: subscriber's MSISDN (filled in by MSC) */ |
| 2749 | sm_rp_oa := tr_GSUP_SM_RP_OA_MSISDN(t_GSUP_SM_RP_Addr( |
| 2750 | number := g_pars.msisdn, |
| 2751 | /* NOTE: MSISDN in g_pars lacks this info, assuming defaults */ |
| 2752 | npi := '0001'B, ton := '001'B, ext := '1'B)), |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 2753 | /* TODO: can we use decmatch here? */ |
| 2754 | sm_rp_ui := sm_tpdu |
| 2755 | ); |
| 2756 | |
| 2757 | /* Submit an SMS on DTAP and expect MO-forwardSM-Req on GSUP */ |
| 2758 | f_mo_sms_submit(spars); |
| 2759 | alt { |
| 2760 | [] GSUP.receive(mo_forwardSM) -> value gsup_msg_rx { |
Vadim Yanitskiy | a358dd4 | 2020-01-15 10:42:47 +0700 | [diff] [blame] | 2761 | log("RX MO-forwardSM-Req: ", gsup_msg_rx); |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 2762 | setverdict(pass); |
| 2763 | } |
| 2764 | [] GSUP.receive { |
| 2765 | log("RX unexpected GSUP message"); |
| 2766 | setverdict(fail); |
| 2767 | mtc.stop; |
| 2768 | } |
| 2769 | } |
| 2770 | |
| 2771 | /* Trigger RP-ACK by sending MO-forwardSM-Res */ |
| 2772 | GSUP.send(valueof(ts_GSUP_MO_FORWARD_SM_RES( |
| 2773 | imsi := g_pars.imsi, |
| 2774 | sm_rp_mr := spars.rp.msg_ref))); |
| 2775 | /* Expect RP-ACK on DTAP */ |
| 2776 | f_mo_sms_wait_rp_ack(spars); |
| 2777 | |
| 2778 | f_expect_clear(); |
| 2779 | } |
| 2780 | testcase TC_gsup_mo_sms() runs on MTC_CT { |
| 2781 | var BSC_ConnHdlr vc_conn; |
| 2782 | f_init(); |
| 2783 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2784 | vc_conn := f_start_handler(refers(f_tc_gsup_mo_sms), 88); |
| 2785 | vc_conn.done; |
| 2786 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2787 | } |
| 2788 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2789 | |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 2790 | /* Test MO-SMMA from MS/BTS/BSC towards HLR (via GSUP) */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2791 | friend function f_tc_gsup_mo_smma(charstring id, BSC_ConnHdlrPars pars) |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 2792 | runs on BSC_ConnHdlr { |
| 2793 | var SmsParameters spars := valueof(t_SmsPars); |
| 2794 | var GSUP_PDU gsup_msg_rx; |
| 2795 | |
| 2796 | f_init_handler(pars); |
| 2797 | |
| 2798 | /* We need to inspect GSUP activity */ |
| 2799 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2800 | |
| 2801 | /* Perform location update */ |
| 2802 | f_perform_lu(); |
| 2803 | |
| 2804 | /* Send CM Service Request for SMS */ |
| 2805 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2806 | |
| 2807 | var template GSUP_PDU mo_ReadyForSM := tr_GSUP_MO_READY_FOR_SM_REQ( |
| 2808 | imsi := g_pars.imsi, |
| 2809 | sm_rp_mr := spars.rp.msg_ref, |
| 2810 | sm_alert_rsn := GSUP_SM_ALERT_RSN_TYPE_MEM_AVAIL |
| 2811 | ); |
| 2812 | |
| 2813 | /* Submit an SMS on DTAP and expect MO-forwardSM-Req on GSUP */ |
| 2814 | f_mo_smma(spars); |
| 2815 | alt { |
| 2816 | [] GSUP.receive(mo_ReadyForSM) -> value gsup_msg_rx { |
Vadim Yanitskiy | a358dd4 | 2020-01-15 10:42:47 +0700 | [diff] [blame] | 2817 | log("RX MO-ReadyForSM-Req: ", gsup_msg_rx); |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 2818 | setverdict(pass); |
| 2819 | } |
| 2820 | [] GSUP.receive { |
| 2821 | log("RX unexpected GSUP message"); |
| 2822 | setverdict(fail); |
| 2823 | mtc.stop; |
| 2824 | } |
| 2825 | } |
| 2826 | |
| 2827 | /* Trigger RP-ACK by sending MO-forwardSM-Res */ |
| 2828 | GSUP.send(valueof(ts_GSUP_MO_READY_FOR_SM_RES( |
| 2829 | imsi := g_pars.imsi, |
| 2830 | sm_rp_mr := spars.rp.msg_ref))); |
| 2831 | /* Expect RP-ACK on DTAP */ |
| 2832 | f_mo_sms_wait_rp_ack(spars); |
| 2833 | |
| 2834 | f_expect_clear(); |
| 2835 | } |
| 2836 | testcase TC_gsup_mo_smma() runs on MTC_CT { |
| 2837 | var BSC_ConnHdlr vc_conn; |
| 2838 | f_init(); |
| 2839 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2840 | vc_conn := f_start_handler(refers(f_tc_gsup_mo_smma), 89); |
| 2841 | vc_conn.done; |
| 2842 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2843 | } |
| 2844 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2845 | |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2846 | /* Helper for sending MT SMS over GSUP */ |
| 2847 | private function f_gsup_forwardSM_req(SmsParameters spars, OCT1 mms := '00'O) |
| 2848 | runs on BSC_ConnHdlr { |
Vadim Yanitskiy | a52347c | 2019-12-12 17:32:33 +0900 | [diff] [blame] | 2849 | 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] | 2850 | var GSUP_SM_RP_Addr smsc := valueof(t_GSUP_SM_RP_Addr( |
| 2851 | number := spars.rp.smsc_addr.rP_NumberDigits, |
| 2852 | npi := spars.rp.smsc_addr.rP_NumberingPlanIdentification, |
| 2853 | ton := spars.rp.smsc_addr.rP_TypeOfNumber, |
| 2854 | ext := spars.rp.smsc_addr.rP_Ext)); |
Vadim Yanitskiy | a52347c | 2019-12-12 17:32:33 +0900 | [diff] [blame] | 2855 | |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2856 | GSUP.send(ts_GSUP_MT_FORWARD_SM_REQ( |
| 2857 | imsi := g_pars.imsi, |
| 2858 | /* NOTE: MSC should assign RP-MR itself */ |
| 2859 | sm_rp_mr := 'FF'O, |
Vadim Yanitskiy | a52347c | 2019-12-12 17:32:33 +0900 | [diff] [blame] | 2860 | sm_rp_da := valueof(ts_GSUP_SM_RP_DA_MSISDN(msisdn)), |
Vadim Yanitskiy | 04dd5f7 | 2019-12-13 15:45:44 +0900 | [diff] [blame] | 2861 | sm_rp_oa := valueof(ts_GSUP_SM_RP_OA_SMSC_ADDR(smsc)), |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2862 | /* Encoded SMS TPDU (taken from Wireshark) |
| 2863 | * FIXME: we should encode spars somehow */ |
| 2864 | sm_rp_ui := '00068021436500008111328130858200'O, |
| 2865 | sm_rp_mms := mms |
| 2866 | )); |
| 2867 | } |
| 2868 | |
| 2869 | /* Test successful MT-SMS (RP-ACK) over GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2870 | 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] | 2871 | runs on BSC_ConnHdlr { |
| 2872 | var SmsParameters spars := valueof(t_SmsPars); |
| 2873 | |
| 2874 | f_init_handler(pars); |
| 2875 | |
| 2876 | /* We need to inspect GSUP activity */ |
| 2877 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2878 | |
| 2879 | /* Perform location update */ |
| 2880 | f_perform_lu(); |
| 2881 | |
| 2882 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2883 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2884 | |
| 2885 | var template GSUP_PDU mt_forwardSM_res := tr_GSUP_MT_FORWARD_SM_RES( |
| 2886 | imsi := g_pars.imsi, |
| 2887 | /* NOTE: MSC should assign RP-MR itself */ |
| 2888 | sm_rp_mr := ? |
| 2889 | ); |
| 2890 | |
| 2891 | /* Submit a MT SMS on GSUP */ |
| 2892 | f_gsup_forwardSM_req(spars); |
| 2893 | |
| 2894 | /* Expect Paging Request and Establish DTAP / BSSAP / SCCP connection */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 2895 | f_expect_paging(); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2896 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2897 | |
| 2898 | /* Wait for MT SMS on DTAP */ |
| 2899 | f_mt_sms_expect(spars); |
| 2900 | |
| 2901 | /* Send RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 2902 | f_mt_sms_send_rp_ack(spars); |
| 2903 | alt { |
| 2904 | [] GSUP.receive(mt_forwardSM_res) { |
| 2905 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 2906 | setverdict(pass); |
| 2907 | } |
| 2908 | [] GSUP.receive { |
| 2909 | log("RX unexpected GSUP message"); |
| 2910 | setverdict(fail); |
| 2911 | mtc.stop; |
| 2912 | } |
| 2913 | } |
| 2914 | |
| 2915 | f_expect_clear(); |
| 2916 | } |
| 2917 | testcase TC_gsup_mt_sms_ack() runs on MTC_CT { |
| 2918 | var BSC_ConnHdlrPars pars; |
| 2919 | var BSC_ConnHdlr vc_conn; |
| 2920 | f_init(); |
| 2921 | pars := f_init_pars(90); |
| 2922 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2923 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_sms_ack), pars); |
| 2924 | vc_conn.done; |
| 2925 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2926 | } |
| 2927 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2928 | |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2929 | /* Test rejected MT-SMS (RP-ERROR) over GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2930 | 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] | 2931 | runs on BSC_ConnHdlr { |
| 2932 | var SmsParameters spars := valueof(t_SmsPars); |
| 2933 | var OCT1 sm_rp_cause := '78'O; /* dummy RP-Cause value */ |
| 2934 | |
| 2935 | f_init_handler(pars); |
| 2936 | |
| 2937 | /* We need to inspect GSUP activity */ |
| 2938 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2939 | |
| 2940 | /* Perform location update */ |
| 2941 | f_perform_lu(); |
| 2942 | |
| 2943 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2944 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2945 | |
| 2946 | var template GSUP_PDU mt_forwardSM_err := tr_GSUP_MT_FORWARD_SM_ERR( |
| 2947 | imsi := g_pars.imsi, |
| 2948 | /* NOTE: MSC should assign RP-MR itself */ |
| 2949 | sm_rp_mr := ?, |
| 2950 | sm_rp_cause := sm_rp_cause |
| 2951 | ); |
| 2952 | |
| 2953 | /* Submit a MT SMS on GSUP */ |
| 2954 | f_gsup_forwardSM_req(spars); |
| 2955 | |
| 2956 | /* Expect Paging Request and Establish DTAP / BSSAP / SCCP connection */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 2957 | f_expect_paging(); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2958 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2959 | |
| 2960 | /* Wait for MT SMS on DTAP */ |
| 2961 | f_mt_sms_expect(spars); |
| 2962 | |
| 2963 | /* Send RP-ERROR and expect MT-forwardSM-Err on GSUP */ |
| 2964 | f_mt_sms_send_rp_error(spars, oct2int(sm_rp_cause)); |
| 2965 | alt { |
| 2966 | [] GSUP.receive(mt_forwardSM_err) { |
| 2967 | log("RX MT-forwardSM-Err (RP-ERROR)"); |
| 2968 | setverdict(pass); |
| 2969 | mtc.stop; |
| 2970 | } |
| 2971 | [] GSUP.receive { |
| 2972 | log("RX unexpected GSUP message"); |
| 2973 | setverdict(fail); |
| 2974 | mtc.stop; |
| 2975 | } |
| 2976 | } |
| 2977 | |
| 2978 | f_expect_clear(); |
| 2979 | } |
| 2980 | testcase TC_gsup_mt_sms_err() runs on MTC_CT { |
| 2981 | var BSC_ConnHdlrPars pars; |
| 2982 | var BSC_ConnHdlr vc_conn; |
| 2983 | f_init(); |
| 2984 | pars := f_init_pars(91); |
| 2985 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2986 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_sms_err), pars); |
| 2987 | vc_conn.done; |
| 2988 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2989 | } |
| 2990 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2991 | |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 2992 | /* Test SM-RP-MR assignment for MT-SMS over GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2993 | 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] | 2994 | runs on BSC_ConnHdlr { |
| 2995 | var SmsParameters spars1 := valueof(t_SmsPars); /* 1st SMS */ |
| 2996 | var SmsParameters spars2 := valueof(t_SmsPars); /* 2nd SMS */ |
| 2997 | |
| 2998 | f_init_handler(pars); |
| 2999 | |
| 3000 | /* We need to inspect GSUP activity */ |
| 3001 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3002 | |
| 3003 | /* Perform location update */ |
| 3004 | f_perform_lu(); |
| 3005 | |
| 3006 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 3007 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 3008 | |
| 3009 | /* Submit the 1st MT SMS on GSUP */ |
| 3010 | log("TX MT-forwardSM-Req for the 1st SMS"); |
| 3011 | f_gsup_forwardSM_req(spars1); |
| 3012 | |
| 3013 | /* Expect Paging Request and Establish DTAP / BSSAP / SCCP connection */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 3014 | f_expect_paging(); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 3015 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 3016 | |
| 3017 | /* Wait for 1st MT SMS on DTAP */ |
| 3018 | f_mt_sms_expect(spars1); |
| 3019 | log("RX the 1st SMS on DTAP, DTAP TID is ", spars1.tid, |
| 3020 | ", SM-RP-MR is ", spars1.rp.msg_ref); |
| 3021 | |
| 3022 | /* Submit the 2nd MT SMS on GSUP */ |
| 3023 | log("TX MT-forwardSM-Req for the 2nd SMS"); |
| 3024 | f_gsup_forwardSM_req(spars2); |
| 3025 | |
| 3026 | /* Wait for 2nd MT SMS on DTAP */ |
| 3027 | f_mt_sms_expect(spars2); |
| 3028 | log("RX the 2nd SMS on DTAP, DTAP TID is ", spars2.tid, |
| 3029 | ", SM-RP-MR is ", spars2.rp.msg_ref); |
| 3030 | |
| 3031 | /* Both transaction IDs shall be different */ |
| 3032 | if (spars1.tid == spars2.tid) { |
| 3033 | log("Both DTAP transaction IDs shall be different"); |
| 3034 | setverdict(fail); |
| 3035 | } |
| 3036 | |
| 3037 | /* Both SM-RP-MR values shall be different */ |
| 3038 | if (spars1.rp.msg_ref == spars2.rp.msg_ref) { |
| 3039 | log("Both SM-RP-MR values shall be different"); |
| 3040 | setverdict(fail); |
| 3041 | } |
| 3042 | |
| 3043 | /* Both SM-RP-MR values shall be assigned */ |
| 3044 | if (spars1.rp.msg_ref == 'FF'O) { |
| 3045 | log("Unassigned SM-RP-MR value for the 1st SMS"); |
| 3046 | setverdict(fail); |
| 3047 | } |
| 3048 | if (spars2.rp.msg_ref == 'FF'O) { |
| 3049 | log("Unassigned SM-RP-MR value for the 2nd SMS"); |
| 3050 | setverdict(fail); |
| 3051 | } |
| 3052 | |
| 3053 | /* Send the 1st RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 3054 | f_mt_sms_send_rp_ack(spars1); |
| 3055 | alt { |
| 3056 | [] GSUP.receive(tr_GSUP_MT_FORWARD_SM_RES( |
| 3057 | imsi := g_pars.imsi, |
| 3058 | sm_rp_mr := spars1.rp.msg_ref |
| 3059 | )) { |
| 3060 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 3061 | setverdict(pass); |
| 3062 | } |
| 3063 | [] GSUP.receive { |
| 3064 | log("RX unexpected GSUP message"); |
| 3065 | setverdict(fail); |
| 3066 | mtc.stop; |
| 3067 | } |
| 3068 | } |
| 3069 | |
| 3070 | /* Send the 2nd RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 3071 | f_mt_sms_send_rp_ack(spars2); |
| 3072 | alt { |
| 3073 | [] GSUP.receive(tr_GSUP_MT_FORWARD_SM_RES( |
| 3074 | imsi := g_pars.imsi, |
| 3075 | sm_rp_mr := spars2.rp.msg_ref |
| 3076 | )) { |
| 3077 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 3078 | setverdict(pass); |
| 3079 | } |
| 3080 | [] GSUP.receive { |
| 3081 | log("RX unexpected GSUP message"); |
| 3082 | setverdict(fail); |
| 3083 | mtc.stop; |
| 3084 | } |
| 3085 | } |
| 3086 | |
| 3087 | f_expect_clear(); |
| 3088 | } |
| 3089 | testcase TC_gsup_mt_sms_rp_mr() runs on MTC_CT { |
| 3090 | var BSC_ConnHdlrPars pars; |
| 3091 | var BSC_ConnHdlr vc_conn; |
| 3092 | f_init(); |
| 3093 | pars := f_init_pars(92); |
| 3094 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 3095 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_sms_rp_mr), pars); |
| 3096 | vc_conn.done; |
| 3097 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 3098 | } |
| 3099 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3100 | |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 3101 | /* Test SM-RP-MR assignment for MT-SMS over GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3102 | 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] | 3103 | runs on BSC_ConnHdlr { |
| 3104 | var SmsParameters spars_mo := valueof(t_SmsPars); /* MO SMMA */ |
| 3105 | var SmsParameters spars_mt := valueof(t_SmsPars); /* MT SMS */ |
| 3106 | |
| 3107 | f_init_handler(pars); |
| 3108 | |
| 3109 | /* We need to inspect GSUP activity */ |
| 3110 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3111 | |
| 3112 | /* Perform location update */ |
| 3113 | f_perform_lu(); |
| 3114 | |
| 3115 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 3116 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 3117 | |
| 3118 | /* Send CM Service Request for MO SMMA */ |
| 3119 | f_establish_fully(EST_TYPE_MO_SMS); |
| 3120 | |
| 3121 | /* Submit MO SMMA on DTAP */ |
| 3122 | log("Submit MO SMMA on DTAP, SM-RP-MR is '00'O"); |
| 3123 | spars_mo.rp.msg_ref := '00'O; |
| 3124 | f_mo_smma(spars_mo); |
| 3125 | |
| 3126 | /* Expect MO-forwardSM-Req for MO SMMA on GSUP */ |
| 3127 | alt { |
| 3128 | [] GSUP.receive(tr_GSUP_MO_READY_FOR_SM_REQ( |
| 3129 | imsi := g_pars.imsi, |
| 3130 | sm_rp_mr := spars_mo.rp.msg_ref, |
| 3131 | sm_alert_rsn := GSUP_SM_ALERT_RSN_TYPE_MEM_AVAIL |
| 3132 | )) { |
| 3133 | log("RX MO-ReadyForSM-Req, SM-RP-MR is '00'O"); |
| 3134 | setverdict(pass); |
| 3135 | } |
| 3136 | [] GSUP.receive { |
| 3137 | log("RX unexpected GSUP message"); |
| 3138 | setverdict(fail); |
| 3139 | mtc.stop; |
| 3140 | } |
| 3141 | } |
| 3142 | |
| 3143 | /* Submit MT SMS on GSUP */ |
| 3144 | log("TX MT-forwardSM-Req for the MT SMS"); |
| 3145 | f_gsup_forwardSM_req(spars_mt); |
| 3146 | |
| 3147 | /* Wait for MT SMS on DTAP */ |
| 3148 | f_mt_sms_expect(spars_mt); |
| 3149 | log("RX MT SMS on DTAP, DTAP TID is ", spars_mt.tid, |
| 3150 | ", SM-RP-MR is ", spars_mt.rp.msg_ref); |
| 3151 | |
| 3152 | /* Both SM-RP-MR values shall be different */ |
| 3153 | if (spars_mo.rp.msg_ref == spars_mt.rp.msg_ref) { |
| 3154 | log("Both SM-RP-MR values shall be different"); |
| 3155 | setverdict(fail); |
| 3156 | } |
| 3157 | |
| 3158 | /* SM-RP-MR value for MT SMS shall be assigned */ |
| 3159 | if (spars_mt.rp.msg_ref == 'FF'O) { |
| 3160 | log("Unassigned SM-RP-MR value for the MT SMS"); |
| 3161 | setverdict(fail); |
| 3162 | } |
| 3163 | |
| 3164 | /* Trigger RP-ACK for MO SMMA by sending MO-forwardSM-Res */ |
| 3165 | GSUP.send(valueof(ts_GSUP_MO_READY_FOR_SM_RES( |
| 3166 | imsi := g_pars.imsi, |
| 3167 | sm_rp_mr := spars_mo.rp.msg_ref))); |
| 3168 | /* Expect RP-ACK for MO SMMA on DTAP */ |
| 3169 | f_mo_sms_wait_rp_ack(spars_mo); |
| 3170 | |
| 3171 | /* Send RP-ACK for MT SMS and expect MT-forwardSM-Res on GSUP */ |
| 3172 | f_mt_sms_send_rp_ack(spars_mt); |
| 3173 | alt { |
| 3174 | [] GSUP.receive(tr_GSUP_MT_FORWARD_SM_RES( |
| 3175 | imsi := g_pars.imsi, |
| 3176 | sm_rp_mr := spars_mt.rp.msg_ref |
| 3177 | )) { |
| 3178 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 3179 | setverdict(pass); |
| 3180 | } |
| 3181 | [] GSUP.receive { |
| 3182 | log("RX unexpected GSUP message"); |
| 3183 | setverdict(fail); |
| 3184 | mtc.stop; |
| 3185 | } |
| 3186 | } |
| 3187 | |
| 3188 | f_expect_clear(); |
| 3189 | } |
| 3190 | testcase TC_gsup_mo_mt_sms_rp_mr() runs on MTC_CT { |
| 3191 | var BSC_ConnHdlrPars pars; |
| 3192 | var BSC_ConnHdlr vc_conn; |
| 3193 | f_init(); |
| 3194 | pars := f_init_pars(93); |
| 3195 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 3196 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mo_mt_sms_rp_mr), pars); |
| 3197 | vc_conn.done; |
| 3198 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 3199 | } |
| 3200 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3201 | |
Vadim Yanitskiy | 1cd11a0 | 2018-12-03 02:43:35 +0700 | [diff] [blame] | 3202 | /* Test multi-part MT-SMS over GSUP */ |
| 3203 | private function f_tc_gsup_mt_multi_part_sms(charstring id, BSC_ConnHdlrPars pars) |
| 3204 | runs on BSC_ConnHdlr { |
| 3205 | var SmsParameters spars := valueof(t_SmsPars); |
| 3206 | |
| 3207 | f_init_handler(pars); |
| 3208 | |
| 3209 | /* We need to inspect GSUP activity */ |
| 3210 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3211 | |
| 3212 | /* Perform location update */ |
| 3213 | f_perform_lu(); |
| 3214 | |
| 3215 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 3216 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 1cd11a0 | 2018-12-03 02:43:35 +0700 | [diff] [blame] | 3217 | |
| 3218 | var template GSUP_PDU mt_forwardSM_res := tr_GSUP_MT_FORWARD_SM_RES( |
| 3219 | imsi := g_pars.imsi, |
| 3220 | /* NOTE: MSC should assign RP-MR itself */ |
| 3221 | sm_rp_mr := ? |
| 3222 | ); |
| 3223 | |
| 3224 | /* Send 4 messages (NOTE: SM-RP-UI remains unchanged) */ |
| 3225 | for (var integer i := 3; i >= 0; i := i-1) { |
| 3226 | /* Submit a MT SMS on GSUP (MMS is decremented) */ |
| 3227 | f_gsup_forwardSM_req(spars, int2oct(i, 1)); |
| 3228 | |
| 3229 | /* Expect Paging Request and Establish connection */ |
| 3230 | if (i == 3) { /* ... only once! */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3231 | f_expect_paging(); |
Vadim Yanitskiy | 1cd11a0 | 2018-12-03 02:43:35 +0700 | [diff] [blame] | 3232 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 3233 | } |
| 3234 | |
| 3235 | /* Wait for MT SMS on DTAP */ |
| 3236 | f_mt_sms_expect(spars); |
| 3237 | |
| 3238 | /* Send RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 3239 | f_mt_sms_send_rp_ack(spars); |
| 3240 | alt { |
| 3241 | [] GSUP.receive(mt_forwardSM_res) { |
| 3242 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 3243 | setverdict(pass); |
| 3244 | } |
| 3245 | [] GSUP.receive { |
| 3246 | log("RX unexpected GSUP message"); |
| 3247 | setverdict(fail); |
| 3248 | mtc.stop; |
| 3249 | } |
| 3250 | } |
| 3251 | |
| 3252 | /* Keep some 'distance' between transmissions */ |
| 3253 | f_sleep(1.5); |
| 3254 | } |
| 3255 | |
| 3256 | f_expect_clear(); |
| 3257 | } |
| 3258 | testcase TC_gsup_mt_multi_part_sms() runs on MTC_CT { |
| 3259 | var BSC_ConnHdlrPars pars; |
| 3260 | var BSC_ConnHdlr vc_conn; |
| 3261 | f_init(); |
| 3262 | pars := f_init_pars(91); |
| 3263 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 3264 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_multi_part_sms), pars); |
| 3265 | vc_conn.done; |
| 3266 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 3267 | } |
| 3268 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 3269 | /* convert GSM L3 TON to SMPP_TON enum */ |
| 3270 | function f_sm_ton_from_gsm(BIT3 ton) return SMPP_TON { |
| 3271 | select (ton) { |
| 3272 | case ('000'B) { return unknown; } |
| 3273 | case ('001'B) { return international; } |
| 3274 | case ('010'B) { return national; } |
| 3275 | case ('011'B) { return network_specific; } |
| 3276 | case ('100'B) { return subscriber_number; } |
| 3277 | case ('101'B) { return alphanumeric; } |
| 3278 | case ('110'B) { return abbreviated; } |
| 3279 | } |
| 3280 | setverdict(fail, "Unknown TON ", ton); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 3281 | mtc.stop; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 3282 | } |
| 3283 | /* convert GSM L3 NPI to SMPP_NPI enum */ |
| 3284 | function f_sm_npi_from_gsm(BIT4 npi) return SMPP_NPI { |
| 3285 | select (npi) { |
| 3286 | case ('0000'B) { return unknown; } |
| 3287 | case ('0001'B) { return isdn; } |
| 3288 | case ('0011'B) { return data; } |
| 3289 | case ('0100'B) { return telex; } |
| 3290 | case ('0110'B) { return land_mobile; } |
| 3291 | case ('1000'B) { return national; } |
| 3292 | case ('1001'B) { return private_; } |
| 3293 | case ('1010'B) { return ermes; } |
| 3294 | } |
| 3295 | setverdict(fail, "Unknown NPI ", npi); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 3296 | mtc.stop; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 3297 | } |
| 3298 | |
| 3299 | /* build a SMPP_SM from SmsParameters */ |
| 3300 | function f_mt_sm_from_spars(SmsParameters spars) |
| 3301 | runs on BSC_ConnHdlr return SMPP_SM { |
| 3302 | var SMPP_SM sm := { |
| 3303 | service_type := "CMT", |
| 3304 | source_addr_ton := f_sm_ton_from_gsm(spars.tp.da.tP_DA_NoPad.tP_TypeOfNumber), |
| 3305 | source_addr_npi := f_sm_npi_from_gsm(spars.tp.da.tP_DA_NoPad.tP_NumberingPlanID), |
| 3306 | source_addr := hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue), |
| 3307 | dest_addr_ton := international, |
| 3308 | dest_addr_npi := isdn, |
| 3309 | destination_addr := hex2str(g_pars.msisdn), |
| 3310 | esm_class := '00000001'B, |
| 3311 | protocol_id := 0, |
| 3312 | priority_flag := 0, |
| 3313 | schedule_delivery_time := "", |
| 3314 | validity_period := "", |
| 3315 | registered_delivery := '00000000'B, |
| 3316 | replace_if_present := 0, |
| 3317 | data_coding := '00000001'B, |
| 3318 | sm_default_msg_id := 0, |
| 3319 | sm_length := spars.tp.udl, |
| 3320 | short_message := spars.tp.ud, |
| 3321 | opt_pars := {} |
| 3322 | }; |
| 3323 | return sm; |
| 3324 | } |
| 3325 | |
| 3326 | /* helper function to encode SMS from 'spars', send it via SMPP to MSC; receive it on MS side */ |
| 3327 | private function f_smpp_mt_sms(SmsParameters spars, boolean trans_mode) runs on BSC_ConnHdlr { |
| 3328 | var SMPP_SM sm := f_mt_sm_from_spars(spars); |
| 3329 | if (trans_mode) { |
| 3330 | sm.esm_class := '00000010'B; |
| 3331 | } |
| 3332 | |
| 3333 | /* actually cause MSC to send a SMS via SUBMIT-SM from SMPP side */ |
| 3334 | SMPP.send(ts_SMPP_SUBMIT_SM(sm)); |
| 3335 | if (not match(sm.esm_class, tr_ESM_CLASS_TRANSACTION)) { |
| 3336 | /* if we're not in SMPP transaction mode, we expect the SMPP-level ACK |
| 3337 | * before we expect the SMS delivery on the BSC/radio side */ |
| 3338 | SMPP.receive(tr_SMPP(c_SMPP_command_id_submit_sm_resp, ESME_ROK)); |
| 3339 | } |
| 3340 | |
| 3341 | /* MSC->BSC: expect PAGING from MSC */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 3342 | f_expect_paging(); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 3343 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 3344 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 3345 | SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)); |
| 3346 | |
| 3347 | f_mt_sms(spars); |
| 3348 | |
| 3349 | if (match(sm.esm_class, tr_ESM_CLASS_TRANSACTION)) { |
| 3350 | SMPP.receive(tr_SMPP(c_SMPP_command_id_submit_sm_resp, ESME_ROK)); |
| 3351 | } |
| 3352 | f_expect_clear(); |
| 3353 | } |
| 3354 | |
| 3355 | /* mobile terminated SMS, from SMPP to BSC/BTS/MS */ |
| 3356 | private function f_tc_smpp_mt_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 3357 | f_init_handler(pars); |
| 3358 | |
| 3359 | /* Perform location update so IMSI is known + registered in MSC/VLR */ |
| 3360 | f_perform_lu(); |
| 3361 | SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)); |
| 3362 | |
| 3363 | /* register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 3364 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 3365 | |
| 3366 | var SmsParameters spars := valueof(t_SmsPars); |
| 3367 | /* TODO: test with more intelligent user data; test different coding schemes */ |
| 3368 | spars.tp.ud := '00'O; |
| 3369 | spars.tp.udl := 1; |
| 3370 | |
| 3371 | /* first test the non-transaction store+forward mode */ |
| 3372 | f_smpp_mt_sms(spars, false); |
| 3373 | |
| 3374 | /* then test the transaction mode */ |
| 3375 | f_smpp_mt_sms(spars, true); |
| 3376 | } |
| 3377 | testcase TC_smpp_mt_sms() runs on MTC_CT { |
| 3378 | var BSC_ConnHdlr vc_conn; |
| 3379 | f_init(); |
| 3380 | vc_conn := f_start_handler(refers(f_tc_smpp_mt_sms), 45); |
| 3381 | vc_conn.done; |
| 3382 | } |
| 3383 | |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3384 | /*********************************************************************** |
| 3385 | * USSD Testing |
| 3386 | ***********************************************************************/ |
| 3387 | |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3388 | private altstep as_unexp_gsup_or_bssap_msg() |
| 3389 | runs on BSC_ConnHdlr { |
| 3390 | [] GSUP.receive { |
| 3391 | setverdict(fail, "Unknown/unexpected GSUP received"); |
| 3392 | self.stop; |
| 3393 | } |
| 3394 | [] BSSAP.receive { |
| 3395 | setverdict(fail, "Unknown/unexpected BSSAP message received"); |
| 3396 | self.stop; |
| 3397 | } |
| 3398 | } |
| 3399 | |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 3400 | private function f_expect_gsup_msg(template GSUP_PDU msg, |
| 3401 | float T_val := 2.0) |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3402 | runs on BSC_ConnHdlr return GSUP_PDU { |
| 3403 | var GSUP_PDU gsup_msg_complete; |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 3404 | timer T := T_val; |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3405 | |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3406 | T.start; |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3407 | alt { |
| 3408 | [] GSUP.receive(msg) -> value gsup_msg_complete { |
| 3409 | setverdict(pass); |
| 3410 | } |
| 3411 | /* We don't expect anything else */ |
| 3412 | [] as_unexp_gsup_or_bssap_msg(); |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3413 | [] T.timeout { |
| 3414 | setverdict(fail, "Timeout waiting for GSUP message: ", msg); |
| 3415 | } |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3416 | } |
| 3417 | |
| 3418 | return gsup_msg_complete; |
| 3419 | } |
| 3420 | |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 3421 | private function f_expect_mt_dtap_msg(template PDU_ML3_NW_MS msg, |
| 3422 | float T_val := 2.0) |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3423 | runs on BSC_ConnHdlr return PDU_ML3_NW_MS { |
| 3424 | var PDU_DTAP_MT bssap_msg_complete; |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 3425 | timer T := T_val; |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3426 | |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3427 | T.start; |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3428 | alt { |
| 3429 | [] BSSAP.receive(tr_PDU_DTAP_MT(msg)) -> value bssap_msg_complete { |
| 3430 | setverdict(pass); |
| 3431 | } |
| 3432 | /* We don't expect anything else */ |
| 3433 | [] as_unexp_gsup_or_bssap_msg(); |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3434 | [] T.timeout { |
| 3435 | setverdict(fail, "Timeout waiting for BSSAP message: ", msg); |
| 3436 | } |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3437 | } |
| 3438 | |
| 3439 | return bssap_msg_complete.dtap; |
| 3440 | } |
| 3441 | |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3442 | /* LU followed by MO USSD request */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3443 | 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] | 3444 | runs on BSC_ConnHdlr { |
| 3445 | f_init_handler(pars); |
| 3446 | |
| 3447 | /* Perform location update */ |
| 3448 | f_perform_lu(); |
| 3449 | |
| 3450 | /* Send CM Service Request for SS/USSD */ |
| 3451 | f_establish_fully(EST_TYPE_SS_ACT); |
| 3452 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3453 | /* We need to inspect GSUP activity */ |
| 3454 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3455 | |
| 3456 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 3457 | invoke_id := 5, /* Phone may not start from 0 or 1 */ |
| 3458 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3459 | ussd_string := "*#100#" |
| 3460 | ); |
| 3461 | |
| 3462 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 3463 | invoke_id := 5, /* InvokeID shall be the same for both REQ and RSP */ |
| 3464 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3465 | ussd_string := "Your extension is " & hex2str(g_pars.msisdn) & "\r" |
| 3466 | ) |
| 3467 | |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3468 | /* Compose a new SS/REGISTER message with request */ |
| 3469 | var template (value) PDU_ML3_MS_NW ussd_req := ts_ML3_MO_SS_REGISTER( |
| 3470 | tid := 1, /* We just need a single transaction */ |
| 3471 | 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] | 3472 | facility := valueof(facility_req) |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3473 | ); |
| 3474 | |
| 3475 | /* Compose SS/RELEASE_COMPLETE template with expected response */ |
| 3476 | var template PDU_ML3_NW_MS ussd_rsp := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3477 | tid := 1, /* Response should arrive within the same transaction */ |
| 3478 | 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] | 3479 | facility := valueof(facility_rsp) |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3480 | ); |
| 3481 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3482 | /* Compose expected MSC -> HLR message */ |
| 3483 | var template GSUP_PDU gsup_req := tr_GSUP_PROC_SS_REQ( |
| 3484 | imsi := g_pars.imsi, |
| 3485 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3486 | ss := valueof(facility_req) |
| 3487 | ); |
| 3488 | |
| 3489 | /* To be used for sending response with correct session ID */ |
| 3490 | var GSUP_PDU gsup_req_complete; |
| 3491 | |
| 3492 | /* Request own number */ |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3493 | BSSAP.send(ts_PDU_DTAP_MO(ussd_req)); |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3494 | /* Expect GSUP message containing the SS payload */ |
| 3495 | gsup_req_complete := f_expect_gsup_msg(gsup_req); |
| 3496 | |
| 3497 | /* Compose the response from HLR using received session ID */ |
| 3498 | var template GSUP_PDU gsup_rsp := ts_GSUP_PROC_SS_REQ( |
| 3499 | imsi := g_pars.imsi, |
| 3500 | sid := gsup_req_complete.ies[1].val.session_id, |
| 3501 | state := OSMO_GSUP_SESSION_STATE_END, |
| 3502 | ss := valueof(facility_rsp) |
| 3503 | ); |
| 3504 | |
| 3505 | /* Finally, HLR terminates the session */ |
| 3506 | GSUP.send(gsup_rsp); |
| 3507 | /* Expect RELEASE_COMPLETE message with the response */ |
| 3508 | f_expect_mt_dtap_msg(ussd_rsp); |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3509 | |
| 3510 | f_expect_clear(); |
| 3511 | } |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3512 | testcase TC_lu_and_mo_ussd_single_request() runs on MTC_CT { |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3513 | var BSC_ConnHdlr vc_conn; |
| 3514 | f_init(); |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3515 | 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] | 3516 | vc_conn.done; |
| 3517 | } |
| 3518 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3519 | |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3520 | /* LU followed by MT USSD notification */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3521 | 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] | 3522 | runs on BSC_ConnHdlr { |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3523 | timer T := 5.0; |
| 3524 | |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3525 | f_init_handler(pars); |
| 3526 | |
| 3527 | /* Perform location update */ |
| 3528 | f_perform_lu(); |
| 3529 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 3530 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3531 | |
| 3532 | /* We need to inspect GSUP activity */ |
| 3533 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3534 | |
| 3535 | /* Facility IE with network-originated USSD notification */ |
| 3536 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 3537 | op_code := SS_OP_CODE_USS_NOTIFY, |
| 3538 | ussd_string := "Mahlzeit!" |
| 3539 | ); |
| 3540 | |
| 3541 | /* Facility IE with acknowledgment to the USSD notification */ |
| 3542 | var template OCTN facility_rsp := enc_SS_FacilityInformation( |
| 3543 | /* In case of USSD notification, Return Result is empty */ |
| 3544 | valueof(ts_SS_USSD_FACILITY_RETURN_RESULT_EMPTY()) |
| 3545 | ); |
| 3546 | |
| 3547 | /* Compose a new MT SS/REGISTER message with USSD notification */ |
| 3548 | var template PDU_ML3_NW_MS ussd_ntf := tr_ML3_MT_SS_REGISTER( |
| 3549 | tid := 0, /* FIXME: most likely, it should be 0 */ |
| 3550 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3551 | facility := valueof(facility_req) |
| 3552 | ); |
| 3553 | |
| 3554 | /* Compose HLR -> MSC GSUP message */ |
| 3555 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 3556 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3557 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3558 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3559 | ss := valueof(facility_req) |
| 3560 | ); |
| 3561 | |
| 3562 | /* Send it to MSC and expect Paging Request */ |
| 3563 | GSUP.send(gsup_req); |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3564 | T.start; |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3565 | alt { |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3566 | [pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 3567 | setverdict(pass); |
| 3568 | } |
Harald Welte | 62113fc | 2019-05-09 13:04:02 +0200 | [diff] [blame] | 3569 | [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] | 3570 | setverdict(pass); |
| 3571 | } |
| 3572 | /* We don't expect anything else */ |
| 3573 | [] as_unexp_gsup_or_bssap_msg(); |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3574 | [] T.timeout { |
| 3575 | setverdict(fail, "Timeout waiting for Paging Request"); |
| 3576 | } |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3577 | } |
| 3578 | |
| 3579 | /* Send Paging Response and expect USSD notification */ |
| 3580 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 3581 | /* Expect MT REGISTER message with USSD notification */ |
| 3582 | f_expect_mt_dtap_msg(ussd_ntf); |
| 3583 | |
| 3584 | /* Compose a new MO SS/FACILITY message with empty response */ |
| 3585 | var template (value) PDU_ML3_MS_NW ussd_rsp := ts_ML3_MO_SS_FACILITY( |
| 3586 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3587 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3588 | facility := valueof(facility_rsp) |
| 3589 | ); |
| 3590 | |
| 3591 | /* Compose expected MSC -> HLR GSUP message */ |
| 3592 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_REQ( |
| 3593 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3594 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3595 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 3596 | ss := valueof(facility_rsp) |
| 3597 | ); |
| 3598 | |
| 3599 | /* MS sends response to the notification */ |
| 3600 | BSSAP.send(ts_PDU_DTAP_MO(ussd_rsp)); |
| 3601 | /* Expect GSUP message containing the SS payload */ |
| 3602 | f_expect_gsup_msg(gsup_rsp); |
| 3603 | |
| 3604 | /* Compose expected MT SS/RELEASE COMPLETE message */ |
| 3605 | var template PDU_ML3_NW_MS ussd_term := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3606 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3607 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3608 | facility := omit |
| 3609 | ); |
| 3610 | |
| 3611 | /* Compose MSC -> HLR GSUP message */ |
| 3612 | var template GSUP_PDU gsup_term := ts_GSUP_PROC_SS_REQ( |
| 3613 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3614 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3615 | state := OSMO_GSUP_SESSION_STATE_END |
| 3616 | ); |
| 3617 | |
| 3618 | /* Finally, HLR terminates the session */ |
| 3619 | GSUP.send(gsup_term) |
| 3620 | /* Expect MT RELEASE COMPLETE without Facility IE */ |
| 3621 | f_expect_mt_dtap_msg(ussd_term); |
| 3622 | |
| 3623 | f_expect_clear(); |
| 3624 | } |
| 3625 | testcase TC_lu_and_mt_ussd_notification() runs on MTC_CT { |
| 3626 | var BSC_ConnHdlr vc_conn; |
| 3627 | f_init(); |
| 3628 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_ussd_notification), 47); |
| 3629 | vc_conn.done; |
| 3630 | } |
| 3631 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3632 | |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3633 | /* LU followed by MT call and MO USSD request during this call */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3634 | 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] | 3635 | runs on BSC_ConnHdlr { |
| 3636 | f_init_handler(pars); |
| 3637 | |
| 3638 | /* Call parameters taken from f_tc_lu_and_mt_call */ |
| 3639 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3640 | |
| 3641 | /* Perform location update */ |
| 3642 | f_perform_lu(); |
| 3643 | |
| 3644 | /* Establish a MT call */ |
| 3645 | f_mt_call_establish(cpars); |
| 3646 | |
| 3647 | /* Hold the call for some time */ |
| 3648 | f_sleep(1.0); |
| 3649 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3650 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 3651 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3652 | ussd_string := "*#100#" |
| 3653 | ); |
| 3654 | |
| 3655 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 3656 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3657 | ussd_string := "Your extension is " & hex2str(g_pars.msisdn) & "\r" |
| 3658 | ) |
| 3659 | |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3660 | /* Compose a new SS/REGISTER message with request */ |
| 3661 | var template (value) PDU_ML3_MS_NW ussd_req := ts_ML3_MO_SS_REGISTER( |
| 3662 | tid := 1, /* We just need a single transaction */ |
| 3663 | 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] | 3664 | facility := valueof(facility_req) |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3665 | ); |
| 3666 | |
| 3667 | /* Compose SS/RELEASE_COMPLETE template with expected response */ |
| 3668 | var template PDU_ML3_NW_MS ussd_rsp := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3669 | tid := 1, /* Response should arrive within the same transaction */ |
| 3670 | 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] | 3671 | facility := valueof(facility_rsp) |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3672 | ); |
| 3673 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3674 | /* Compose expected MSC -> HLR message */ |
| 3675 | var template GSUP_PDU gsup_req := tr_GSUP_PROC_SS_REQ( |
| 3676 | imsi := g_pars.imsi, |
| 3677 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3678 | ss := valueof(facility_req) |
| 3679 | ); |
| 3680 | |
| 3681 | /* To be used for sending response with correct session ID */ |
| 3682 | var GSUP_PDU gsup_req_complete; |
| 3683 | |
| 3684 | /* Request own number */ |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3685 | BSSAP.send(ts_PDU_DTAP_MO(ussd_req)); |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3686 | /* Expect GSUP message containing the SS payload */ |
| 3687 | gsup_req_complete := f_expect_gsup_msg(gsup_req); |
| 3688 | |
| 3689 | /* Compose the response from HLR using received session ID */ |
| 3690 | var template GSUP_PDU gsup_rsp := ts_GSUP_PROC_SS_REQ( |
| 3691 | imsi := g_pars.imsi, |
| 3692 | sid := gsup_req_complete.ies[1].val.session_id, |
| 3693 | state := OSMO_GSUP_SESSION_STATE_END, |
| 3694 | ss := valueof(facility_rsp) |
| 3695 | ); |
| 3696 | |
| 3697 | /* Finally, HLR terminates the session */ |
| 3698 | GSUP.send(gsup_rsp); |
| 3699 | /* Expect RELEASE_COMPLETE message with the response */ |
| 3700 | f_expect_mt_dtap_msg(ussd_rsp); |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3701 | |
| 3702 | /* Hold the call for some time */ |
| 3703 | f_sleep(1.0); |
| 3704 | |
| 3705 | /* Release the call (does Clear Complete itself) */ |
| 3706 | f_call_hangup(cpars, true); |
| 3707 | } |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3708 | 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] | 3709 | var BSC_ConnHdlr vc_conn; |
| 3710 | f_init(); |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3711 | 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] | 3712 | vc_conn.done; |
| 3713 | } |
| 3714 | |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 3715 | /* BSSMAP Clear Request in the middle of a call, see OS#3062 */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3716 | 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] | 3717 | f_init_handler(pars); |
| 3718 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 3719 | cpars.ran_clear_when_alerting := true; |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 3720 | |
| 3721 | f_perform_lu(); |
| 3722 | |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 3723 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 3724 | f_mo_call_establish(cpars); |
| 3725 | f_expect_clear() |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 3726 | deactivate(ccrel); |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 3727 | |
| 3728 | f_sleep(1.0); |
| 3729 | } |
| 3730 | testcase TC_mo_cc_bssmap_clear() runs on MTC_CT { |
| 3731 | var BSC_ConnHdlr vc_conn; |
| 3732 | f_init(); |
| 3733 | |
| 3734 | vc_conn := f_start_handler(refers(f_tc_mo_cc_bssmap_clear), 43); |
| 3735 | vc_conn.done; |
| 3736 | } |
| 3737 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3738 | |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3739 | /* LU followed by MT call and MT USSD request during this call */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3740 | 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] | 3741 | runs on BSC_ConnHdlr { |
| 3742 | f_init_handler(pars); |
| 3743 | |
| 3744 | /* Call parameters taken from f_tc_lu_and_mt_call */ |
| 3745 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3746 | |
| 3747 | /* Perform location update */ |
| 3748 | f_perform_lu(); |
| 3749 | |
| 3750 | /* Establish a MT call */ |
| 3751 | f_mt_call_establish(cpars); |
| 3752 | |
| 3753 | /* Hold the call for some time */ |
| 3754 | f_sleep(1.0); |
| 3755 | |
| 3756 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 3757 | op_code := SS_OP_CODE_USS_REQUEST, |
| 3758 | ussd_string := "Please type anything..." |
| 3759 | ); |
| 3760 | |
| 3761 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 3762 | op_code := SS_OP_CODE_USS_REQUEST, |
| 3763 | ussd_string := "Nope." |
| 3764 | ) |
| 3765 | |
| 3766 | /* Compose MT SS/REGISTER message with network-originated request */ |
| 3767 | var template (value) PDU_ML3_NW_MS ussd_req := ts_ML3_MT_SS_REGISTER( |
| 3768 | tid := 0, /* FIXME: most likely, it should be 0 */ |
| 3769 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3770 | facility := valueof(facility_req) |
| 3771 | ); |
| 3772 | |
| 3773 | /* Compose HLR -> MSC GSUP message */ |
| 3774 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 3775 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3776 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3777 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3778 | ss := valueof(facility_req) |
| 3779 | ); |
| 3780 | |
| 3781 | /* Send it to MSC */ |
| 3782 | GSUP.send(gsup_req); |
| 3783 | /* Expect MT REGISTER message with USSD request */ |
| 3784 | f_expect_mt_dtap_msg(ussd_req); |
| 3785 | |
| 3786 | /* Compose a new MO SS/FACILITY message with response */ |
| 3787 | var template (value) PDU_ML3_MS_NW ussd_rsp := ts_ML3_MO_SS_FACILITY( |
| 3788 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3789 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3790 | facility := valueof(facility_rsp) |
| 3791 | ); |
| 3792 | |
| 3793 | /* Compose expected MSC -> HLR GSUP message */ |
| 3794 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_REQ( |
| 3795 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3796 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3797 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 3798 | ss := valueof(facility_rsp) |
| 3799 | ); |
| 3800 | |
| 3801 | /* MS sends response */ |
| 3802 | BSSAP.send(ts_PDU_DTAP_MO(ussd_rsp)); |
| 3803 | f_expect_gsup_msg(gsup_rsp); |
| 3804 | |
| 3805 | /* Compose expected MT SS/RELEASE COMPLETE message */ |
| 3806 | var template PDU_ML3_NW_MS ussd_term := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3807 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3808 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3809 | facility := omit |
| 3810 | ); |
| 3811 | |
| 3812 | /* Compose MSC -> HLR GSUP message */ |
| 3813 | var template GSUP_PDU gsup_term := ts_GSUP_PROC_SS_REQ( |
| 3814 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3815 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3816 | state := OSMO_GSUP_SESSION_STATE_END |
| 3817 | ); |
| 3818 | |
| 3819 | /* Finally, HLR terminates the session */ |
| 3820 | GSUP.send(gsup_term); |
| 3821 | /* Expect MT RELEASE COMPLETE without Facility IE */ |
| 3822 | f_expect_mt_dtap_msg(ussd_term); |
| 3823 | |
| 3824 | /* Hold the call for some time */ |
| 3825 | f_sleep(1.0); |
| 3826 | |
| 3827 | /* Release the call (does Clear Complete itself) */ |
| 3828 | f_call_hangup(cpars, true); |
| 3829 | } |
| 3830 | testcase TC_lu_and_mt_ussd_during_mt_call() runs on MTC_CT { |
| 3831 | var BSC_ConnHdlr vc_conn; |
| 3832 | f_init(); |
| 3833 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_ussd_during_mt_call), 49); |
| 3834 | vc_conn.done; |
| 3835 | } |
| 3836 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3837 | |
Vadim Yanitskiy | 2daf52d | 2018-06-21 04:19:58 +0700 | [diff] [blame] | 3838 | /* LU followed by MO USSD request and MO Release during transaction */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3839 | 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] | 3840 | runs on BSC_ConnHdlr { |
| 3841 | f_init_handler(pars); |
| 3842 | |
| 3843 | /* Perform location update */ |
| 3844 | f_perform_lu(); |
| 3845 | |
| 3846 | /* Send CM Service Request for SS/USSD */ |
| 3847 | f_establish_fully(EST_TYPE_SS_ACT); |
| 3848 | |
| 3849 | /* We need to inspect GSUP activity */ |
| 3850 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3851 | |
| 3852 | var template OCTN facility_ms_req := f_USSD_FACILITY_IE_INVOKE( |
| 3853 | invoke_id := 1, /* Initial request */ |
| 3854 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3855 | ussd_string := "*6766*266#" |
| 3856 | ); |
| 3857 | |
| 3858 | var template OCTN facility_net_req := f_USSD_FACILITY_IE_INVOKE( |
| 3859 | invoke_id := 2, /* Counter request */ |
| 3860 | op_code := SS_OP_CODE_USS_REQUEST, |
| 3861 | ussd_string := "Password?!?" |
| 3862 | ) |
| 3863 | |
| 3864 | /* Compose MO SS/REGISTER message with request */ |
| 3865 | var template (value) PDU_ML3_MS_NW ussd_ms_req := ts_ML3_MO_SS_REGISTER( |
| 3866 | tid := 1, /* We just need a single transaction */ |
| 3867 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3868 | facility := valueof(facility_ms_req) |
| 3869 | ); |
| 3870 | |
| 3871 | /* Compose expected MSC -> HLR message */ |
| 3872 | var template GSUP_PDU gsup_ms_req := tr_GSUP_PROC_SS_REQ( |
| 3873 | imsi := g_pars.imsi, |
| 3874 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3875 | ss := valueof(facility_ms_req) |
| 3876 | ); |
| 3877 | |
| 3878 | /* To be used for sending response with correct session ID */ |
| 3879 | var GSUP_PDU gsup_ms_req_complete; |
| 3880 | |
| 3881 | /* Initiate a new transaction */ |
| 3882 | BSSAP.send(ts_PDU_DTAP_MO(ussd_ms_req)); |
| 3883 | /* Expect GSUP request with original Facility IE */ |
| 3884 | gsup_ms_req_complete := f_expect_gsup_msg(gsup_ms_req); |
| 3885 | |
| 3886 | /* Compose the response from HLR using received session ID */ |
| 3887 | var template (value) GSUP_PDU gsup_net_req := ts_GSUP_PROC_SS_REQ( |
| 3888 | imsi := g_pars.imsi, |
| 3889 | sid := gsup_ms_req_complete.ies[1].val.session_id, |
| 3890 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 3891 | ss := valueof(facility_net_req) |
| 3892 | ); |
| 3893 | |
| 3894 | /* Compose expected MT SS/FACILITY template with counter request */ |
| 3895 | var template PDU_ML3_NW_MS ussd_net_req := tr_ML3_MT_SS_FACILITY( |
| 3896 | tid := 1, /* Response should arrive within the same transaction */ |
| 3897 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3898 | facility := valueof(facility_net_req) |
| 3899 | ); |
| 3900 | |
| 3901 | /* Send response over GSUP */ |
| 3902 | GSUP.send(gsup_net_req); |
| 3903 | /* Expect MT SS/FACILITY message with counter request */ |
| 3904 | f_expect_mt_dtap_msg(ussd_net_req); |
| 3905 | |
| 3906 | /* Compose MO SS/RELEASE COMPLETE */ |
| 3907 | var template (value) PDU_ML3_MS_NW ussd_abort := ts_ML3_MO_SS_RELEASE_COMPLETE( |
| 3908 | tid := 1, /* Response should arrive within the same transaction */ |
| 3909 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3910 | facility := omit |
| 3911 | /* TODO: cause? */ |
| 3912 | ); |
| 3913 | |
| 3914 | /* Compose expected HLR -> MSC abort message */ |
| 3915 | var template GSUP_PDU gsup_abort := tr_GSUP_PROC_SS_REQ( |
| 3916 | imsi := g_pars.imsi, |
| 3917 | sid := gsup_ms_req_complete.ies[1].val.session_id, |
| 3918 | state := OSMO_GSUP_SESSION_STATE_END |
| 3919 | ); |
| 3920 | |
| 3921 | /* Abort transaction */ |
| 3922 | BSSAP.send(ts_PDU_DTAP_MO(ussd_abort)); |
| 3923 | /* Expect GSUP message indicating abort */ |
| 3924 | f_expect_gsup_msg(gsup_abort); |
| 3925 | |
| 3926 | f_expect_clear(); |
| 3927 | } |
| 3928 | testcase TC_lu_and_mo_ussd_mo_release() runs on MTC_CT { |
| 3929 | var BSC_ConnHdlr vc_conn; |
| 3930 | f_init(); |
| 3931 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_ussd_mo_release), 50); |
| 3932 | vc_conn.done; |
| 3933 | } |
| 3934 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3935 | |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 3936 | /* LU followed by MO USSD request and MT Release due to timeout */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3937 | 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] | 3938 | runs on BSC_ConnHdlr { |
| 3939 | f_init_handler(pars); |
| 3940 | |
| 3941 | /* Perform location update */ |
| 3942 | f_perform_lu(); |
| 3943 | |
| 3944 | /* Send CM Service Request for SS/USSD */ |
| 3945 | f_establish_fully(EST_TYPE_SS_ACT); |
| 3946 | |
| 3947 | /* We need to inspect GSUP activity */ |
| 3948 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3949 | |
| 3950 | var template OCTN facility_ms_req := f_USSD_FACILITY_IE_INVOKE( |
| 3951 | invoke_id := 1, |
| 3952 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3953 | ussd_string := "#release_me"); |
| 3954 | |
| 3955 | /* Compose MO SS/REGISTER message with request */ |
| 3956 | var template (value) PDU_ML3_MS_NW ussd_ms_req := ts_ML3_MO_SS_REGISTER( |
| 3957 | tid := 1, /* An arbitrary transaction identifier */ |
| 3958 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3959 | facility := valueof(facility_ms_req)); |
| 3960 | |
| 3961 | /* Compose expected MSC -> HLR message */ |
| 3962 | var template GSUP_PDU gsup_ms_req := tr_GSUP_PROC_SS_REQ( |
| 3963 | imsi := g_pars.imsi, |
| 3964 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3965 | ss := valueof(facility_ms_req)); |
| 3966 | |
| 3967 | /* To be used for sending response with correct session ID */ |
| 3968 | var GSUP_PDU gsup_ms_req_complete; |
| 3969 | |
| 3970 | /* Initiate a new SS transaction */ |
| 3971 | BSSAP.send(ts_PDU_DTAP_MO(ussd_ms_req)); |
| 3972 | /* Expect GSUP request with original Facility IE */ |
| 3973 | gsup_ms_req_complete := f_expect_gsup_msg(gsup_ms_req); |
| 3974 | |
| 3975 | /* Don't respond, wait for timeout */ |
| 3976 | f_sleep(3.0); |
| 3977 | |
| 3978 | var template PDU_ML3_NW_MS dtap_rel := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3979 | tid := 1, /* Should match the request's tid */ |
| 3980 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3981 | cause := *, /* TODO: expect some specific value */ |
| 3982 | facility := omit); |
| 3983 | |
| 3984 | var template GSUP_PDU gsup_rel := tr_GSUP_PROC_SS_ERR( |
| 3985 | imsi := g_pars.imsi, |
| 3986 | sid := gsup_ms_req_complete.ies[1].val.session_id, |
| 3987 | state := OSMO_GSUP_SESSION_STATE_END, |
| 3988 | cause := ?); /* TODO: expect some specific value */ |
| 3989 | |
| 3990 | /* Expect release on both interfaces */ |
| 3991 | interleave { |
| 3992 | [] BSSAP.receive(tr_PDU_DTAP_MT(dtap_rel)) { }; |
| 3993 | [] GSUP.receive(gsup_rel) { }; |
| 3994 | } |
| 3995 | |
| 3996 | f_expect_clear(); |
| 3997 | setverdict(pass); |
| 3998 | } |
| 3999 | testcase TC_lu_and_ss_session_timeout() runs on MTC_CT { |
| 4000 | var BSC_ConnHdlr vc_conn; |
| 4001 | f_init(); |
Vadim Yanitskiy | 36d28dd | 2018-12-03 02:45:45 +0700 | [diff] [blame] | 4002 | f_vty_config(MSCVTY, "msc", "ncss guard-timeout 3"); |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 4003 | vc_conn := f_start_handler(refers(f_tc_lu_and_ss_session_timeout), 51); |
| 4004 | vc_conn.done; |
Vadim Yanitskiy | 36d28dd | 2018-12-03 02:45:45 +0700 | [diff] [blame] | 4005 | f_vty_config(MSCVTY, "msc", "ncss guard-timeout 0"); |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 4006 | } |
| 4007 | |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 4008 | /* MT (network-originated) USSD for unknown subscriber */ |
| 4009 | friend function f_tc_mt_ussd_for_unknown_subscr(charstring id, BSC_ConnHdlrPars pars) |
| 4010 | runs on BSC_ConnHdlr { |
| 4011 | var hexstring imsi := '000000000000000'H; /* Some unknown IMSI */ |
| 4012 | var OCT4 sid := '20000222'O; |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 4013 | |
| 4014 | f_init_handler(pars); |
| 4015 | f_ran_register_imsi(imsi, 'FFFFFFFF'O); |
| 4016 | f_create_gsup_expect(hex2str(imsi)); |
| 4017 | |
| 4018 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 4019 | imsi := imsi, |
| 4020 | sid := sid, |
| 4021 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 4022 | ss := f_rnd_octstring(23) |
| 4023 | ); |
| 4024 | |
| 4025 | /* Error with cause GMM_CAUSE_IMSI_UNKNOWN */ |
| 4026 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_ERR( |
| 4027 | imsi := imsi, |
| 4028 | sid := sid, |
| 4029 | state := OSMO_GSUP_SESSION_STATE_END, |
| 4030 | cause := 2 /* FIXME: introduce an enumerated type! */ |
| 4031 | ); |
| 4032 | |
| 4033 | /* Initiate a MT USSD notification */ |
| 4034 | GSUP.send(gsup_req); |
| 4035 | |
| 4036 | /* Expect GSUP PROC_SS_ERROR message */ |
Vadim Yanitskiy | 851798c | 2019-06-15 14:22:28 +0700 | [diff] [blame] | 4037 | f_expect_gsup_msg(gsup_rsp); |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 4038 | } |
| 4039 | testcase TC_mt_ussd_for_unknown_subscr() runs on MTC_CT { |
| 4040 | var BSC_ConnHdlr vc_conn; |
| 4041 | f_init(); |
| 4042 | vc_conn := f_start_handler(refers(f_tc_mt_ussd_for_unknown_subscr), 0); |
| 4043 | vc_conn.done; |
| 4044 | } |
| 4045 | |
Vadim Yanitskiy | c3c07d4 | 2019-06-17 23:00:44 +0700 | [diff] [blame] | 4046 | /* MO (mobile-originated) SS/USSD for unknown transaction */ |
| 4047 | friend function f_tc_mo_ussd_for_unknown_trans(charstring id, BSC_ConnHdlrPars pars) |
| 4048 | runs on BSC_ConnHdlr { |
| 4049 | f_init_handler(pars); |
| 4050 | |
Vadim Yanitskiy | 70d15bf | 2020-01-09 22:51:01 +0100 | [diff] [blame] | 4051 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | c3c07d4 | 2019-06-17 23:00:44 +0700 | [diff] [blame] | 4052 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4053 | |
| 4054 | /* Perform location update */ |
| 4055 | f_perform_lu(); |
| 4056 | |
| 4057 | /* Send CM Service Request for SS/USSD */ |
| 4058 | f_establish_fully(EST_TYPE_SS_ACT); |
| 4059 | |
| 4060 | /* GSM 04.80 FACILITY message for a non-existing transaction */ |
| 4061 | var template (value) PDU_ML3_MS_NW mo_ss_fac := ts_ML3_MO_SS_FACILITY( |
| 4062 | tid := 1, /* An arbitrary transaction identifier */ |
| 4063 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 4064 | facility := f_rnd_octstring(23) /* We don't care about the Facility IE */ |
| 4065 | ); |
| 4066 | |
| 4067 | /* GSM 04.80 RELEASE COMPLETE message for a non-existing transaction */ |
| 4068 | var template (value) PDU_ML3_MS_NW mo_ss_rel := ts_ML3_MO_SS_RELEASE_COMPLETE( |
| 4069 | tid := 1, /* An arbitrary transaction identifier */ |
| 4070 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 4071 | facility := f_rnd_octstring(23) /* We don't care about the Facility IE */ |
| 4072 | ); |
| 4073 | |
| 4074 | /* Expected response from the network */ |
| 4075 | var template PDU_ML3_NW_MS mt_ss_rel := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 4076 | tid := 1, /* Same as in the FACILITY message */ |
| 4077 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 4078 | facility := omit |
| 4079 | ); |
| 4080 | |
| 4081 | /* Send GSM 04.80 FACILITY for non-existing transaction */ |
| 4082 | BSSAP.send(ts_PDU_DTAP_MO(mo_ss_fac)); |
| 4083 | |
| 4084 | /* Expect GSM 04.80 RELEASE COMPLETE message */ |
| 4085 | f_expect_mt_dtap_msg(mt_ss_rel); |
| 4086 | f_expect_clear(); |
| 4087 | |
| 4088 | /* Send another CM Service Request for SS/USSD */ |
| 4089 | f_establish_fully(EST_TYPE_SS_ACT); |
| 4090 | |
| 4091 | /* Send GSM 04.80 RELEASE COMPLETE for non-existing transaction */ |
| 4092 | BSSAP.send(ts_PDU_DTAP_MO(mo_ss_rel)); |
| 4093 | |
| 4094 | /* Expect GSM 04.80 RELEASE COMPLETE message */ |
| 4095 | f_expect_mt_dtap_msg(mt_ss_rel); |
| 4096 | f_expect_clear(); |
| 4097 | } |
| 4098 | testcase TC_mo_ussd_for_unknown_trans() runs on MTC_CT { |
| 4099 | var BSC_ConnHdlr vc_conn; |
| 4100 | f_init(); |
| 4101 | vc_conn := f_start_handler(refers(f_tc_mo_ussd_for_unknown_trans), 111); |
| 4102 | vc_conn.done; |
| 4103 | } |
| 4104 | |
Vadim Yanitskiy | d612d28 | 2019-06-15 14:46:03 +0700 | [diff] [blame] | 4105 | /* MT (network-originated) USSD for unknown session */ |
| 4106 | friend function f_tc_proc_ss_for_unknown_session(charstring id, BSC_ConnHdlrPars pars) |
| 4107 | runs on BSC_ConnHdlr { |
| 4108 | var OCT4 sid := '20000333'O; |
| 4109 | |
| 4110 | f_init_handler(pars); |
| 4111 | |
| 4112 | /* Perform location update */ |
| 4113 | f_perform_lu(); |
| 4114 | |
Vadim Yanitskiy | 70d15bf | 2020-01-09 22:51:01 +0100 | [diff] [blame] | 4115 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | d612d28 | 2019-06-15 14:46:03 +0700 | [diff] [blame] | 4116 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4117 | |
| 4118 | /* Request referencing a non-existing SS session */ |
| 4119 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 4120 | imsi := g_pars.imsi, |
| 4121 | sid := sid, |
| 4122 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 4123 | ss := f_rnd_octstring(23) |
| 4124 | ); |
| 4125 | |
| 4126 | /* Error with some cause value */ |
| 4127 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_ERR( |
| 4128 | imsi := g_pars.imsi, |
| 4129 | sid := sid, |
| 4130 | state := OSMO_GSUP_SESSION_STATE_END, |
| 4131 | cause := ? /* FIXME: introduce an enumerated type! */ |
| 4132 | ); |
| 4133 | |
| 4134 | /* Initiate a MT USSD notification */ |
| 4135 | GSUP.send(gsup_req); |
| 4136 | |
| 4137 | /* Expect GSUP PROC_SS_ERROR message */ |
| 4138 | f_expect_gsup_msg(gsup_rsp); |
| 4139 | } |
| 4140 | testcase TC_proc_ss_for_unknown_session() runs on MTC_CT { |
| 4141 | var BSC_ConnHdlr vc_conn; |
| 4142 | f_init(); |
| 4143 | vc_conn := f_start_handler(refers(f_tc_proc_ss_for_unknown_session), 110); |
| 4144 | vc_conn.done; |
| 4145 | } |
| 4146 | |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 4147 | /* MT (network-originated) USSD and no response to Paging Request */ |
| 4148 | friend function f_tc_proc_ss_paging_fail(charstring id, BSC_ConnHdlrPars pars) |
| 4149 | runs on BSC_ConnHdlr { |
| 4150 | timer TP := 2.0; /* Paging timer */ |
| 4151 | |
| 4152 | f_init_handler(pars); |
| 4153 | |
| 4154 | /* Perform location update */ |
| 4155 | f_perform_lu(); |
| 4156 | |
Vadim Yanitskiy | 70d15bf | 2020-01-09 22:51:01 +0100 | [diff] [blame] | 4157 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 4158 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4159 | |
| 4160 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 4161 | imsi := g_pars.imsi, |
| 4162 | sid := '20000444'O, |
| 4163 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 4164 | ss := f_rnd_octstring(23) |
| 4165 | ); |
| 4166 | |
| 4167 | /* Error with some cause value */ |
| 4168 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_ERR( |
| 4169 | imsi := g_pars.imsi, |
| 4170 | sid := '20000444'O, |
| 4171 | state := OSMO_GSUP_SESSION_STATE_END, |
| 4172 | cause := ? /* FIXME: introduce an enumerated type! */ |
| 4173 | ); |
| 4174 | |
| 4175 | /* Initiate a MT USSD notification */ |
| 4176 | GSUP.send(gsup_req); |
| 4177 | |
| 4178 | /* Send it to MSC and expect Paging Request */ |
| 4179 | TP.start; |
| 4180 | alt { |
| 4181 | [pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 4182 | setverdict(pass); |
| 4183 | } |
| 4184 | [not pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) { |
| 4185 | setverdict(pass); |
| 4186 | } |
| 4187 | /* We don't expect anything else */ |
| 4188 | [] as_unexp_gsup_or_bssap_msg(); |
| 4189 | [] TP.timeout { |
| 4190 | setverdict(fail, "Timeout waiting for Paging Request"); |
| 4191 | } |
| 4192 | } |
| 4193 | |
Vadim Yanitskiy | d24b525 | 2019-10-02 00:04:51 +0700 | [diff] [blame] | 4194 | /* Wait up to 20 seconds for GSUP PROC_SS_ERROR message. |
| 4195 | * OsmoMSC waits for Paging Response 10 seconds by default. */ |
| 4196 | f_expect_gsup_msg(gsup_rsp, T_val := 20.0); |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 4197 | } |
| 4198 | testcase TC_proc_ss_paging_fail() runs on MTC_CT { |
| 4199 | var BSC_ConnHdlr vc_conn; |
| 4200 | f_init(); |
| 4201 | vc_conn := f_start_handler(refers(f_tc_proc_ss_paging_fail), 101); |
| 4202 | vc_conn.done; |
| 4203 | } |
| 4204 | |
Vadim Yanitskiy | 29ba8d6 | 2019-06-16 15:19:41 +0700 | [diff] [blame] | 4205 | /* MT (network-originated) USSD followed by immediate abort */ |
| 4206 | friend function f_tc_proc_ss_abort(charstring id, BSC_ConnHdlrPars pars) |
| 4207 | runs on BSC_ConnHdlr { |
| 4208 | var octetstring facility := f_rnd_octstring(23); |
| 4209 | var OCT4 sid := '20000555'O; |
| 4210 | timer TP := 2.0; |
| 4211 | |
| 4212 | f_init_handler(pars); |
| 4213 | |
| 4214 | /* Perform location update */ |
| 4215 | f_perform_lu(); |
| 4216 | |
Vadim Yanitskiy | 70d15bf | 2020-01-09 22:51:01 +0100 | [diff] [blame] | 4217 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 29ba8d6 | 2019-06-16 15:19:41 +0700 | [diff] [blame] | 4218 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4219 | |
| 4220 | /* PROC_SS_REQ initiates a mobile-originated SS/USSD session */ |
| 4221 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 4222 | imsi := g_pars.imsi, sid := sid, |
| 4223 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 4224 | ss := facility |
| 4225 | ); |
| 4226 | |
| 4227 | /* On the MS side, we expect GSM 04.80 REGISTER message */ |
| 4228 | var template PDU_ML3_NW_MS dtap_reg := tr_ML3_MT_SS_REGISTER( |
| 4229 | tid := 0, /* Most likely, it should be 0 */ |
| 4230 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 4231 | facility := facility |
| 4232 | ); |
| 4233 | |
| 4234 | /* PROC_SS_ERR with SESSION_STATE_END terminates the SS/USSD session */ |
| 4235 | var template (value) GSUP_PDU gsup_abort := ts_GSUP_PROC_SS_ERR( |
| 4236 | imsi := g_pars.imsi, sid := sid, |
| 4237 | state := OSMO_GSUP_SESSION_STATE_END, |
| 4238 | cause := 0 /* FIXME: introduce an enumerated type! */ |
| 4239 | ); |
| 4240 | |
| 4241 | /* On the MS side, we expect GSM 04.80 REGISTER message */ |
| 4242 | var template PDU_ML3_NW_MS dtap_rel := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 4243 | tid := 0, /* Most likely, it should be 0 */ |
| 4244 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 4245 | cause := *, /* FIXME: expect some specific cause value */ |
| 4246 | facility := omit |
| 4247 | ); |
| 4248 | |
| 4249 | /* Initiate a MT USSD with random payload */ |
| 4250 | GSUP.send(gsup_req); |
| 4251 | |
| 4252 | /* Expect Paging Request */ |
| 4253 | TP.start; |
| 4254 | alt { |
| 4255 | [pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 4256 | setverdict(pass); |
| 4257 | } |
| 4258 | [not pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) { |
| 4259 | setverdict(pass); |
| 4260 | } |
| 4261 | /* We don't expect anything else */ |
| 4262 | [] as_unexp_gsup_or_bssap_msg(); |
| 4263 | [] TP.timeout { |
| 4264 | setverdict(fail, "Timeout waiting for Paging Request"); |
| 4265 | } |
| 4266 | } |
| 4267 | |
| 4268 | /* Send Paging Response and establish connection */ |
| 4269 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 4270 | /* Expect MT REGISTER message with random facility */ |
| 4271 | f_expect_mt_dtap_msg(dtap_reg); |
| 4272 | |
| 4273 | /* HLR/EUSE decides to abort the session even |
| 4274 | * before getting any response from the MS */ |
| 4275 | /* Initiate a MT USSD with random payload */ |
| 4276 | GSUP.send(gsup_abort); |
| 4277 | |
| 4278 | /* Expect RELEASE COMPLETE on ths MS side */ |
| 4279 | f_expect_mt_dtap_msg(dtap_rel); |
| 4280 | |
| 4281 | f_expect_clear(); |
| 4282 | } |
| 4283 | testcase TC_proc_ss_abort() runs on MTC_CT { |
| 4284 | var BSC_ConnHdlr vc_conn; |
| 4285 | f_init(); |
| 4286 | vc_conn := f_start_handler(refers(f_tc_proc_ss_abort), 102); |
| 4287 | vc_conn.done; |
| 4288 | } |
| 4289 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 4290 | |
Vadim Yanitskiy | 1c9754d | 2020-01-07 21:56:55 +0100 | [diff] [blame] | 4291 | /* Verify multiple concurrent MO SS/USSD transactions |
| 4292 | * (one subscriber - one transaction) */ |
| 4293 | testcase TC_multi_lu_and_mo_ussd() runs on MTC_CT { |
| 4294 | var BSC_ConnHdlr vc_conn[16]; |
| 4295 | var integer i; |
| 4296 | |
| 4297 | f_init(); |
| 4298 | |
| 4299 | for (i := 0; i < sizeof(vc_conn); i := i + 1) { |
| 4300 | vc_conn[i] := f_start_handler(refers(f_tc_lu_and_mo_ussd_single_request), 210 + i); |
| 4301 | } |
| 4302 | |
| 4303 | for (i := 0; i < sizeof(vc_conn); i := i + 1) { |
| 4304 | vc_conn[i].done; |
| 4305 | } |
| 4306 | } |
| 4307 | |
| 4308 | /* Verify multiple concurrent MT SS/USSD transactions |
| 4309 | * (one subscriber - one transaction) */ |
| 4310 | testcase TC_multi_lu_and_mt_ussd() runs on MTC_CT { |
| 4311 | var BSC_ConnHdlr vc_conn[16]; |
| 4312 | var integer i; |
| 4313 | var OCT4 sid; |
| 4314 | |
| 4315 | f_init(); |
| 4316 | |
| 4317 | for (i := 0; i < sizeof(vc_conn); i := i + 1) { |
| 4318 | sid := '200001'O & int2oct(i, 1); /* All transactions must use different session ID */ |
| 4319 | vc_conn[i] := f_start_handler_with_pars(refers(f_tc_lu_and_mt_ussd_notification), |
| 4320 | f_init_pars(226 + i, gsup_sid := sid)); |
| 4321 | } |
| 4322 | |
| 4323 | for (i := 0; i < sizeof(vc_conn); i := i + 1) { |
| 4324 | vc_conn[i].done; |
| 4325 | } |
| 4326 | } |
| 4327 | |
| 4328 | |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 4329 | /* A5/1 only permitted on network side; attempt an invalid CIPHER MODE COMPLETE with A5/3 which MSC should reject. */ |
| 4330 | private function f_tc_cipher_complete_with_invalid_cipher(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4331 | pars.net.expect_auth := true; |
| 4332 | pars.net.expect_ciph := true; |
| 4333 | pars.net.kc_support := '02'O; /* A5/1 only */ |
| 4334 | f_init_handler(pars); |
| 4335 | |
| 4336 | g_pars.vec := f_gen_auth_vec_2g(); |
| 4337 | |
| 4338 | /* Can't use f_perform_lu() directly. Code below is based on it. */ |
| 4339 | |
| 4340 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 4341 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4342 | |
| 4343 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 4344 | 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] | 4345 | f_cl3_or_initial_ue(l3_lu); |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 4346 | |
| 4347 | f_mm_auth(); |
| 4348 | |
| 4349 | var OCT1 a5_net := f_alg_mask_from_cm(g_pars.cm2); |
| 4350 | var OCT1 a5_intersect := g_pars.net.kc_support and4b a5_net; |
| 4351 | alt { |
| 4352 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(a5_intersect, g_pars.vec.kc)) { |
| 4353 | BSSAP.send(ts_BSSMAP_CipherModeCompl(int2oct(4 /* "accept" A5/3 */, 1))); |
| 4354 | } |
| 4355 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?, g_pars.vec.kc)) { |
| 4356 | setverdict(fail, "Wrong ciphering algorithm mask in CiphModCmd"); |
| 4357 | mtc.stop; |
| 4358 | } |
| 4359 | [] BSSAP.receive { |
| 4360 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 4361 | mtc.stop; |
| 4362 | } |
| 4363 | } |
Harald Welte | 79f1e45 | 2020-08-18 22:55:02 +0200 | [diff] [blame] | 4364 | f_expect_common_id(); |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 4365 | |
| 4366 | /* Expect LU reject from MSC. */ |
| 4367 | alt { |
| 4368 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 4369 | setverdict(pass); |
| 4370 | } |
| 4371 | [] BSSAP.receive { |
| 4372 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 4373 | mtc.stop; |
| 4374 | } |
| 4375 | } |
Stefan Sperling | c620b35 | 2018-12-18 17:23:36 +0100 | [diff] [blame] | 4376 | f_expect_clear(); |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 4377 | } |
| 4378 | |
| 4379 | testcase TC_cipher_complete_with_invalid_cipher() runs on MTC_CT { |
| 4380 | var BSC_ConnHdlr vc_conn; |
| 4381 | f_init(); |
| 4382 | f_vty_config(MSCVTY, "network", "encryption a5 1"); |
| 4383 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 4384 | 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] | 4385 | vc_conn.done; |
| 4386 | } |
| 4387 | |
Harald Welte | b2284bd | 2019-05-10 11:30:43 +0200 | [diff] [blame] | 4388 | /* Location Update with invalid (non-matching) MCC/MNC reported on BSSMAP level from BSC */ |
| 4389 | friend function f_tc_lu_with_invalid_mcc_mnc(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4390 | f_init_handler(pars); |
| 4391 | |
| 4392 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 4393 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4394 | |
| 4395 | /* modify the cell ID which will be used to construct the COMPLELTE L3 or InitialUE */ |
| 4396 | g_pars.cell_id := valueof(ts_CellId_CGI('333'H, '22'H, 23, 42)); |
| 4397 | |
| 4398 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 4399 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 4400 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 79f1e45 | 2020-08-18 22:55:02 +0200 | [diff] [blame] | 4401 | f_expect_common_id(); |
Harald Welte | b2284bd | 2019-05-10 11:30:43 +0200 | [diff] [blame] | 4402 | |
| 4403 | /* Expect LU reject from MSC. */ |
| 4404 | alt { |
| 4405 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 4406 | setverdict(pass); |
| 4407 | } |
| 4408 | [] BSSAP.receive { |
| 4409 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 4410 | mtc.stop; |
| 4411 | } |
| 4412 | } |
| 4413 | f_expect_clear(); |
| 4414 | } |
| 4415 | testcase TC_lu_with_invalid_mcc_mnc() runs on MTC_CT { |
| 4416 | var BSC_ConnHdlr vc_conn; |
| 4417 | f_init(); |
| 4418 | vc_conn := f_start_handler(refers(f_tc_lu_with_invalid_mcc_mnc), 54); |
| 4419 | vc_conn.done; |
| 4420 | } |
| 4421 | |
Stefan Sperling | a2d59c6 | 2018-12-18 16:32:44 +0100 | [diff] [blame] | 4422 | private function f_tc_cipher_complete_without_alg(charstring id, BSC_ConnHdlrPars pars, octetstring kc_support) runs on BSC_ConnHdlr { |
| 4423 | pars.net.expect_auth := true; |
| 4424 | pars.net.expect_ciph := true; |
| 4425 | pars.net.kc_support := kc_support; |
| 4426 | f_init_handler(pars); |
| 4427 | |
| 4428 | g_pars.vec := f_gen_auth_vec_2g(); |
| 4429 | |
| 4430 | /* Can't use f_perform_lu() directly. Code below is based on it. */ |
| 4431 | |
| 4432 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 4433 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4434 | |
| 4435 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 4436 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 4437 | f_cl3_or_initial_ue(l3_lu); |
| 4438 | |
| 4439 | f_mm_auth(); |
| 4440 | |
| 4441 | var OCT1 a5_net := f_alg_mask_from_cm(g_pars.cm2); |
| 4442 | var OCT1 a5_intersect := g_pars.net.kc_support and4b a5_net; |
| 4443 | alt { |
| 4444 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(a5_intersect, g_pars.vec.kc)) { |
| 4445 | BSSAP.send(ts_BSSMAP_CipherModeComplAlg(omit)); |
| 4446 | } |
| 4447 | [] BSSAP.receive(tr_BSSMAP_ClassmarkReq) { |
| 4448 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 4449 | repeat; |
| 4450 | } |
| 4451 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?, g_pars.vec.kc)) { |
| 4452 | setverdict(fail, "Wrong ciphering algorithm mask in CiphModCmd"); |
| 4453 | mtc.stop; |
| 4454 | } |
| 4455 | [] BSSAP.receive { |
| 4456 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 4457 | mtc.stop; |
| 4458 | } |
| 4459 | } |
Harald Welte | 79f1e45 | 2020-08-18 22:55:02 +0200 | [diff] [blame] | 4460 | f_expect_common_id(); |
Stefan Sperling | a2d59c6 | 2018-12-18 16:32:44 +0100 | [diff] [blame] | 4461 | |
| 4462 | /* TODO: Verify MSC is using the best cipher available! How? */ |
| 4463 | |
| 4464 | f_msc_lu_hlr(); |
| 4465 | f_accept_reject_lu(); |
| 4466 | f_expect_clear(); |
| 4467 | setverdict(pass); |
| 4468 | } |
| 4469 | |
| 4470 | /* A5/1 only permitted on network side; attempt CIPHER MODE COMPLETE without specifying the accepted algorithm. */ |
| 4471 | private function f_tc_cipher_complete_1_without_cipher(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4472 | f_tc_cipher_complete_without_alg(id, pars, '02'O /* A5/1 only */); |
| 4473 | } |
| 4474 | |
| 4475 | /* A5/3 only permitted on network side; attempt CIPHER MODE COMPLETE without specifying the accepted algorithm. */ |
| 4476 | private function f_tc_cipher_complete_3_without_cipher(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4477 | f_tc_cipher_complete_without_alg(id, pars, '08'O /* A5/3 only */); |
| 4478 | } |
| 4479 | |
| 4480 | /* A5/1 + A5/3 permitted on network side; attempt CIPHER MODE COMPLETE without specifying the accepted algorithm. */ |
| 4481 | private function f_tc_cipher_complete_13_without_cipher(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4482 | f_tc_cipher_complete_without_alg(id, pars, '0A'O /* A5/1 and A5/3 enabled */); |
| 4483 | } |
| 4484 | |
| 4485 | testcase TC_cipher_complete_1_without_cipher() runs on MTC_CT { |
| 4486 | var BSC_ConnHdlr vc_conn; |
| 4487 | f_init(); |
| 4488 | f_vty_config(MSCVTY, "network", "encryption a5 1"); |
| 4489 | |
| 4490 | vc_conn := f_start_handler(refers(f_tc_cipher_complete_1_without_cipher), 53); |
| 4491 | vc_conn.done; |
| 4492 | } |
| 4493 | |
| 4494 | testcase TC_cipher_complete_3_without_cipher() runs on MTC_CT { |
| 4495 | var BSC_ConnHdlr vc_conn; |
| 4496 | f_init(); |
| 4497 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 4498 | |
| 4499 | vc_conn := f_start_handler(refers(f_tc_cipher_complete_3_without_cipher), 54); |
| 4500 | vc_conn.done; |
| 4501 | } |
| 4502 | |
| 4503 | testcase TC_cipher_complete_13_without_cipher() runs on MTC_CT { |
| 4504 | var BSC_ConnHdlr vc_conn; |
| 4505 | f_init(); |
| 4506 | f_vty_config(MSCVTY, "network", "encryption a5 1 3"); |
| 4507 | |
| 4508 | vc_conn := f_start_handler(refers(f_tc_cipher_complete_13_without_cipher), 55); |
| 4509 | vc_conn.done; |
| 4510 | } |
Harald Welte | b2284bd | 2019-05-10 11:30:43 +0200 | [diff] [blame] | 4511 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 4512 | /* TODO (SMS): |
| 4513 | * different user data lengths |
| 4514 | * SMPP transaction mode with unsuccessful delivery |
| 4515 | * queued MT-SMS with no paging response + later delivery |
| 4516 | * different data coding schemes |
| 4517 | * multi-part SMS |
| 4518 | * user-data headers |
| 4519 | * TP-PID for SMS to SIM |
| 4520 | * behavior if SMS memory is full + RP-SMMA |
| 4521 | * delivery reports |
| 4522 | * SMPP osmocom extensions |
| 4523 | * more-messages-to-send |
| 4524 | * SMS during ongoing call (SACCH/SAPI3) |
| 4525 | */ |
| 4526 | |
| 4527 | /* TODO (General): |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 4528 | * continue to send repeated MO signalling messages to keep channel open: does MSC tmeout? |
| 4529 | * malformed messages (missing IE, invalid message type): properly rejected? |
| 4530 | * MT call while LU or is ongoing: Do we use existing lchan or page while lchan active? |
| 4531 | * 3G/2G auth permutations |
| 4532 | * encryption algorithms vs. classmark vs. vty config |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 4533 | * send new transaction after/during clear (like SMS, ...) |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 4534 | * too long L3 INFO in DTAP |
| 4535 | * too long / padded BSSAP |
| 4536 | * too long / short TLV values |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 4537 | */ |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 4538 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 4539 | /*********************************************************************** |
| 4540 | * SGsAP Testing |
| 4541 | ***********************************************************************/ |
| 4542 | |
Philipp Maier | 948747b | 2019-04-02 15:22:33 +0200 | [diff] [blame] | 4543 | /* Check if a subscriber exists in the VLR */ |
| 4544 | private function f_ctrl_subscr_in_vlr(charstring imsi_or_msisdn) runs on BSC_ConnHdlr return boolean { |
| 4545 | |
| 4546 | var CtrlValue active_subsribers; |
| 4547 | var integer rc; |
| 4548 | active_subsribers := f_ctrl_get(IPA_CTRL, "subscriber-list-active-v1"); |
| 4549 | |
| 4550 | rc := f_strstr(active_subsribers, imsi_or_msisdn); |
| 4551 | if (rc < 0) { |
| 4552 | return false; |
| 4553 | } |
| 4554 | |
| 4555 | return true; |
| 4556 | } |
| 4557 | |
Pau Espin Pedrol | cefe9da | 2021-07-02 18:38:27 +0200 | [diff] [blame] | 4558 | /* 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] | 4559 | * that everything is back to normal. */ |
| 4560 | private function f_sgsap_bssmap_screening() runs on BSC_ConnHdlr { |
| 4561 | var SmsParameters spars := valueof(t_SmsPars); |
| 4562 | |
Pau Espin Pedrol | 7593a8a | 2021-07-02 18:55:16 +0200 | [diff] [blame] | 4563 | /* From now on, since we initiated LU from A-Interface, we expect no |
| 4564 | * LastEutranPLMNId on Common Id, since the SGs interface should be gone |
| 4565 | */ |
| 4566 | g_pars.common_id_last_eutran_plmn := omit; |
| 4567 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4568 | /* Perform a location update, the SGs association is expected to fall |
| 4569 | * back to NULL */ |
| 4570 | f_perform_lu(); |
| 4571 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4572 | |
| 4573 | /* Trigger a paging request and expect the paging on BSSMAP, this is |
| 4574 | * to make sure that pagings are sent throught the A-Interface again |
| 4575 | * and not throught the SGs interface.*/ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 4576 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4577 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 4578 | |
| 4579 | alt { |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 4580 | [g_pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)); { |
| 4581 | setverdict(pass); |
| 4582 | } |
Harald Welte | 62113fc | 2019-05-09 13:04:02 +0200 | [diff] [blame] | 4583 | [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] | 4584 | setverdict(pass); |
| 4585 | } |
| 4586 | [] SGsAP.receive { |
| 4587 | setverdict(fail, "Received unexpected message on SGs"); |
| 4588 | } |
| 4589 | } |
| 4590 | |
| 4591 | /* Send an SMS to make sure that also payload messages are routed |
| 4592 | * throught the A-Interface again */ |
| 4593 | f_establish_fully(EST_TYPE_MO_SMS); |
| 4594 | f_mo_sms(spars); |
| 4595 | f_expect_clear(); |
| 4596 | } |
| 4597 | |
| 4598 | private function f_tc_sgsap_reset(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4599 | var charstring vlr_name; |
| 4600 | f_init_handler(pars); |
| 4601 | |
| 4602 | vlr_name := f_sgsap_reset_mme(mp_mme_name); |
| 4603 | log("VLR name: ", vlr_name); |
| 4604 | setverdict(pass); |
Neels Hofmeyr | c0b520d | 2019-03-06 15:35:50 +0100 | [diff] [blame] | 4605 | f_sleep(1.0); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4606 | } |
| 4607 | |
| 4608 | testcase TC_sgsap_reset() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4609 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4610 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4611 | f_init(1, true); |
| 4612 | pars := f_init_pars(11810, true); |
| 4613 | 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] | 4614 | vc_conn.done; |
| 4615 | } |
| 4616 | |
| 4617 | /* like f_mm_auth() but for SGs */ |
| 4618 | function f_mm_auth_sgs() runs on BSC_ConnHdlr { |
| 4619 | if (g_pars.net.expect_auth) { |
| 4620 | g_pars.vec := f_gen_auth_vec_3g(); |
| 4621 | var GSUP_IE auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G3G(g_pars.vec.rand, |
| 4622 | g_pars.vec.sres, |
| 4623 | g_pars.vec.kc, |
| 4624 | g_pars.vec.ik, |
| 4625 | g_pars.vec.ck, |
| 4626 | g_pars.vec.autn, |
| 4627 | g_pars.vec.res)); |
| 4628 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 4629 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
| 4630 | SGsAP.receive(tr_ML3_MT_MM_AUTH_REQ_3G(g_pars.vec.rand, g_pars.vec.autn)); |
| 4631 | SGsAP.send(ts_ML3_MT_MM_AUTH_RESP_3G(g_pars.vec.sres, g_pars.vec.res)); |
| 4632 | } |
| 4633 | } |
| 4634 | |
| 4635 | /* like f_perform_lu(), but on SGs rather than BSSAP */ |
| 4636 | function f_sgs_perform_lu() runs on BSC_ConnHdlr { |
| 4637 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4638 | var PDU_SGsAP lur; |
| 4639 | var PDU_SGsAP lua; |
| 4640 | var PDU_SGsAP mm_info; |
| 4641 | var octetstring mm_info_dtap; |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4642 | var GsmMcc mcc; |
| 4643 | var GsmMnc mnc; |
| 4644 | var template (omit) TrackingAreaIdentityValue tai := omit; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4645 | |
| 4646 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 4647 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4648 | if (g_pars.common_id_last_eutran_plmn != omit) { |
| 4649 | f_dec_mcc_mnc(g_pars.common_id_last_eutran_plmn, mcc, mnc); |
| 4650 | tai := ts_SGsAP_TAI(mcc, mnc, 555); |
| 4651 | } |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4652 | 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] | 4653 | ts_SGsAP_LAI('901'H, '70'H, 2342), |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4654 | tai)); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4655 | /* Old LAI, if MS sends it */ |
| 4656 | /* TMSI status, if MS has no valid TMSI */ |
| 4657 | /* IMEISV, if it supports "automatic device detection" */ |
| 4658 | /* TAI, if available in MME */ |
| 4659 | /* E-CGI, if available in MME */ |
| 4660 | SGsAP.send(lur); |
| 4661 | |
| 4662 | /* FIXME: is this really done over SGs? The Ue is already authenticated |
| 4663 | * via the MME ... */ |
| 4664 | f_mm_auth_sgs(); |
| 4665 | |
| 4666 | /* Expect MSC to perform LU with HLR */ |
| 4667 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 4668 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 4669 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 4670 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 4671 | |
| 4672 | alt { |
| 4673 | [] SGsAP.receive(tr_SGsAP_LU_ACCEPT(g_pars.imsi, ?)) -> value lua { |
| 4674 | if (isvalue(lua.sGsAP_LOCATION_UPDATE_ACCEPT.newTMSIorIMSI.iD.iD.tmsi_ptmsi.octets)) { |
| 4675 | g_pars.tmsi :=lua.sGsAP_LOCATION_UPDATE_ACCEPT.newTMSIorIMSI.iD.iD.tmsi_ptmsi.octets |
| 4676 | SGsAP.send(ts_SGsAP_TMSI_REALL_CMPL(g_pars.imsi)); |
| 4677 | } |
| 4678 | setverdict(pass); |
| 4679 | } |
| 4680 | [] SGsAP.receive(tr_SGsAP_LU_REJECT(g_pars.imsi, ?, ?)) { |
| 4681 | setverdict(fail, "Received LU-REJECT instead of ACCEPT"); |
| 4682 | } |
| 4683 | [] SGsAP.receive { |
| 4684 | setverdict(fail, "Received unexpected message on SGs"); |
| 4685 | } |
| 4686 | } |
| 4687 | |
| 4688 | /* Check MM information */ |
| 4689 | if (mp_mm_info == true) { |
| 4690 | SGsAP.receive(tr_SGsAP_MM_INFO_REQ(g_pars.imsi, ?)) -> value mm_info; |
| 4691 | mm_info_dtap := '0532'O & mm_info.sGsAP_MM_INFORMATION_REQUEST.mM_Information.information; |
| 4692 | if (not match(dec_PDU_ML3_NW_MS(mm_info_dtap), tr_ML3_MT_MM_Info)) { |
| 4693 | setverdict(fail, "Unexpected MM Information"); |
| 4694 | } |
| 4695 | } |
| 4696 | |
| 4697 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4698 | } |
| 4699 | |
| 4700 | private function f_tc_sgsap_lu(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4701 | f_init_handler(pars); |
| 4702 | f_sgs_perform_lu(); |
| 4703 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4704 | |
| 4705 | f_sgsap_bssmap_screening(); |
| 4706 | |
| 4707 | setverdict(pass); |
| 4708 | } |
| 4709 | testcase TC_sgsap_lu() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4710 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4711 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4712 | f_init(1, true); |
| 4713 | pars := f_init_pars(11811, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4714 | 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] | 4715 | 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] | 4716 | vc_conn.done; |
| 4717 | } |
| 4718 | |
| 4719 | /* Do LU by IMSI, refuse it on GSUP and expect LU REJ back to MS */ |
| 4720 | private function f_tc_sgsap_lu_imsi_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4721 | f_init_handler(pars); |
| 4722 | var PDU_SGsAP lur; |
| 4723 | |
| 4724 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4725 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4726 | lur := valueof(ts_SGsAP_LU_REQ(g_pars.imsi, mme_name, IMSI_attach, |
| 4727 | ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4728 | SGsAP.send(lur); |
| 4729 | |
| 4730 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 4731 | GSUP.send(ts_GSUP_UL_ERR(g_pars.imsi, 23)); |
| 4732 | alt { |
| 4733 | [] SGsAP.receive(tr_SGsAP_LU_REJECT(g_pars.imsi, ?, ?)) { |
| 4734 | setverdict(pass); |
| 4735 | } |
| 4736 | [] SGsAP.receive(tr_SGsAP_LU_ACCEPT(g_pars.imsi, ?)) { |
| 4737 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
| 4738 | mtc.stop; |
| 4739 | } |
| 4740 | [] SGsAP.receive { |
| 4741 | setverdict(fail, "Received unexpected message on SGs"); |
| 4742 | } |
| 4743 | } |
| 4744 | |
| 4745 | f_sgsap_bssmap_screening(); |
| 4746 | |
| 4747 | setverdict(pass); |
| 4748 | } |
| 4749 | testcase TC_sgsap_lu_imsi_reject() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4750 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4751 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4752 | f_init(1, true); |
| 4753 | pars := f_init_pars(11812, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4754 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4755 | 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] | 4756 | vc_conn.done; |
| 4757 | } |
| 4758 | |
| 4759 | /* Do LU by IMSI, but then remain silent so that Ts6-1 times out */ |
| 4760 | private function f_tc_sgsap_lu_and_nothing(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4761 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4762 | var PDU_SGsAP lur; |
| 4763 | |
| 4764 | f_init_handler(pars); |
| 4765 | |
| 4766 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 4767 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4768 | |
| 4769 | lur := valueof(ts_SGsAP_LU_REQ(g_pars.imsi, mme_name, IMSI_attach, |
| 4770 | ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4771 | /* Old LAI, if MS sends it */ |
| 4772 | /* TMSI status, if MS has no valid TMSI */ |
| 4773 | /* IMEISV, if it supports "automatic device detection" */ |
| 4774 | /* TAI, if available in MME */ |
| 4775 | /* E-CGI, if available in MME */ |
| 4776 | SGsAP.send(lur); |
| 4777 | |
| 4778 | /* FIXME: is this really done over SGs? The Ue is already authenticated |
| 4779 | * via the MME ... */ |
| 4780 | f_mm_auth_sgs(); |
| 4781 | |
| 4782 | /* Expect MSC to perform LU with HLR */ |
| 4783 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 4784 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 4785 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 4786 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 4787 | |
| 4788 | alt { |
| 4789 | [] SGsAP.receive(tr_SGsAP_LU_ACCEPT(g_pars.imsi, ?)) { |
| 4790 | setverdict(pass); |
| 4791 | } |
| 4792 | [] SGsAP.receive(tr_SGsAP_LU_REJECT(g_pars.imsi, ?, ?)) { |
| 4793 | setverdict(fail, "Received LU-REJECT instead of ACCEPT"); |
| 4794 | } |
| 4795 | [] SGsAP.receive { |
| 4796 | setverdict(fail, "Received unexpected message on SGs"); |
| 4797 | } |
| 4798 | } |
| 4799 | |
| 4800 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4801 | |
| 4802 | /* Wait until the VLR has abort the TMSI reallocation procedure */ |
| 4803 | f_sleep(45.0); |
| 4804 | |
| 4805 | /* The outcome does not change the SGs state, see also 5.2.3.4 */ |
| 4806 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4807 | |
| 4808 | f_sgsap_bssmap_screening(); |
| 4809 | |
| 4810 | setverdict(pass); |
| 4811 | } |
| 4812 | testcase TC_sgsap_lu_and_nothing() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4813 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4814 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4815 | f_init(1, true); |
| 4816 | pars := f_init_pars(11813, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4817 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4818 | 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] | 4819 | vc_conn.done; |
| 4820 | } |
| 4821 | |
| 4822 | private function f_tc_sgsap_expl_imsi_det_eps(charstring id, BSC_ConnHdlrPars pars) |
| 4823 | runs on BSC_ConnHdlr { |
| 4824 | f_init_handler(pars); |
| 4825 | f_sgs_perform_lu(); |
| 4826 | f_sleep(3.0); |
| 4827 | |
| 4828 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4829 | SGsAP.send(ts_SGsAP_EPS_DETACH_IND(g_pars.imsi, mme_name, UE_initiated)); |
| 4830 | SGsAP.receive(tr_SGsAP_EPS_DETACH_ACK(g_pars.imsi)); |
| 4831 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4832 | |
| 4833 | f_sgsap_bssmap_screening(); |
| 4834 | |
| 4835 | setverdict(pass); |
| 4836 | } |
| 4837 | testcase TC_sgsap_expl_imsi_det_eps() 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(11814, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4842 | 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] | 4843 | 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] | 4844 | vc_conn.done; |
| 4845 | } |
| 4846 | |
Philipp Maier | fc19f17 | 2019-03-21 11:17:54 +0100 | [diff] [blame] | 4847 | private function f_tc_sgsap_impl_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, network_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_impl_imsi_det_eps() runs on MTC_CT { |
| 4863 | var BSC_ConnHdlrPars pars; |
| 4864 | var BSC_ConnHdlr vc_conn; |
| 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 | fc19f17 | 2019-03-21 11:17:54 +0100 | [diff] [blame] | 4868 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_impl_imsi_det_eps), pars); |
| 4869 | vc_conn.done; |
| 4870 | } |
| 4871 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4872 | private function f_tc_sgsap_expl_imsi_det_noneps(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_IMSI_DETACH_IND(g_pars.imsi, mme_name, combined_UE_initiated)); |
| 4880 | SGsAP.receive(tr_SGsAP_IMSI_DETACH_ACK(g_pars.imsi)); |
Philipp Maier | d08e7e7 | 2019-04-02 15:27:10 +0200 | [diff] [blame] | 4881 | |
| 4882 | if (f_ctrl_subscr_in_vlr(hex2str(g_pars.imsi))) { |
| 4883 | setverdict(fail, "subscriber not removed from VLR"); |
| 4884 | } |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4885 | |
| 4886 | f_sgsap_bssmap_screening(); |
| 4887 | |
| 4888 | setverdict(pass); |
| 4889 | } |
| 4890 | testcase TC_sgsap_expl_imsi_det_noneps() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4891 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4892 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4893 | f_init(1, true); |
| 4894 | pars := f_init_pars(11815, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4895 | 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] | 4896 | 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] | 4897 | vc_conn.done; |
| 4898 | } |
| 4899 | |
Philipp Maier | 5d81270 | 2019-03-21 10:51:26 +0100 | [diff] [blame] | 4900 | private function f_tc_sgsap_impl_imsi_det_noneps(charstring id, BSC_ConnHdlrPars pars) |
| 4901 | runs on BSC_ConnHdlr { |
| 4902 | f_init_handler(pars); |
| 4903 | f_sgs_perform_lu(); |
| 4904 | f_sleep(3.0); |
| 4905 | |
| 4906 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4907 | SGsAP.send(ts_SGsAP_IMSI_DETACH_IND(g_pars.imsi, mme_name, implicit_network_initiated)); |
| 4908 | SGsAP.receive(tr_SGsAP_IMSI_DETACH_ACK(g_pars.imsi)); |
| 4909 | |
| 4910 | if (f_ctrl_subscr_in_vlr(hex2str(g_pars.imsi))) { |
| 4911 | setverdict(fail, "subscriber not removed from VLR"); |
| 4912 | } |
| 4913 | |
| 4914 | f_sgsap_bssmap_screening(); |
| 4915 | |
| 4916 | setverdict(pass); |
| 4917 | } |
| 4918 | testcase TC_sgsap_impl_imsi_det_noneps() runs on MTC_CT { |
| 4919 | var BSC_ConnHdlrPars pars; |
| 4920 | var BSC_ConnHdlr vc_conn; |
| 4921 | f_init(1, true); |
| 4922 | pars := f_init_pars(11815, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4923 | 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] | 4924 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_impl_imsi_det_noneps), pars); |
| 4925 | vc_conn.done; |
| 4926 | } |
| 4927 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4928 | /* Trigger a paging request via VTY and send a paging reject in response */ |
| 4929 | private function f_tc_sgsap_paging_rej(charstring id, BSC_ConnHdlrPars pars) |
| 4930 | runs on BSC_ConnHdlr { |
| 4931 | f_init_handler(pars); |
| 4932 | f_sgs_perform_lu(); |
| 4933 | f_sleep(1.0); |
| 4934 | |
| 4935 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4936 | var template PDU_SGsAP exp_resp := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, CS_call_indicator, omit); |
| 4937 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4938 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 4939 | |
| 4940 | /* Initiate paging via VTY */ |
| 4941 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 4942 | alt { |
| 4943 | [] SGsAP.receive(exp_resp) { |
| 4944 | setverdict(pass); |
| 4945 | } |
| 4946 | [] SGsAP.receive { |
| 4947 | setverdict(fail, "Received unexpected message on SGs"); |
| 4948 | } |
| 4949 | } |
| 4950 | |
| 4951 | /* Now reject the paging */ |
| 4952 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, IMSI_unknown)); |
| 4953 | |
| 4954 | /* Wait for the states inside the MSC to settle and check the state |
| 4955 | * of the SGs Association */ |
| 4956 | f_sleep(1.0); |
| 4957 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4958 | |
| 4959 | /* FIXME: At the moment we send an IMSI_unknown as cause code, which is fine, |
| 4960 | * but we also need to cover tha case where the cause code indicates an |
| 4961 | * "IMSI detached for EPS services". In those cases the VLR is expected to |
| 4962 | * try paging on tha A/Iu interface. This will be another testcase similar to |
| 4963 | * this one, but extended with checks for the presence of the A/Iu paging |
| 4964 | * messages. */ |
| 4965 | |
| 4966 | f_sgsap_bssmap_screening(); |
| 4967 | |
| 4968 | setverdict(pass); |
| 4969 | } |
| 4970 | testcase TC_sgsap_paging_rej() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4971 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4972 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4973 | f_init(1, true); |
| 4974 | pars := f_init_pars(11816, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4975 | 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] | 4976 | 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] | 4977 | vc_conn.done; |
| 4978 | } |
| 4979 | |
| 4980 | /* Trigger a paging request via VTY and send a paging reject that indicates |
| 4981 | * that the subscriber intentionally rejected the call. */ |
| 4982 | private function f_tc_sgsap_paging_subscr_rej(charstring id, BSC_ConnHdlrPars pars) |
| 4983 | runs on BSC_ConnHdlr { |
| 4984 | f_init_handler(pars); |
| 4985 | f_sgs_perform_lu(); |
| 4986 | f_sleep(1.0); |
| 4987 | |
| 4988 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4989 | var template PDU_SGsAP exp_resp := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, CS_call_indicator, omit); |
| 4990 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4991 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 4992 | |
| 4993 | /* Initiate paging via VTY */ |
| 4994 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 4995 | alt { |
| 4996 | [] SGsAP.receive(exp_resp) { |
| 4997 | setverdict(pass); |
| 4998 | } |
| 4999 | [] SGsAP.receive { |
| 5000 | setverdict(fail, "Received unexpected message on SGs"); |
| 5001 | } |
| 5002 | } |
| 5003 | |
| 5004 | /* Now reject the paging */ |
| 5005 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, user_rejected_mobile_terminating_CS_fallback_call)); |
| 5006 | |
| 5007 | /* Wait for the states inside the MSC to settle and check the state |
| 5008 | * of the SGs Association */ |
| 5009 | f_sleep(1.0); |
| 5010 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5011 | |
| 5012 | /* FIXME: The VLR is supposed to trigger an User Determined User Busy (UDUB) as specified |
| 5013 | * in 3GPP TS 24.082, this is not yet implemented in the MSC or in this tests, we need |
| 5014 | * to check back how this works and how it can be tested */ |
| 5015 | |
| 5016 | f_sgsap_bssmap_screening(); |
| 5017 | |
| 5018 | setverdict(pass); |
| 5019 | } |
| 5020 | testcase TC_sgsap_paging_subscr_rej() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5021 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5022 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5023 | f_init(1, true); |
| 5024 | pars := f_init_pars(11817, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5025 | 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] | 5026 | 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] | 5027 | vc_conn.done; |
| 5028 | } |
| 5029 | |
| 5030 | /* Trigger a paging request via VTY and send an UE unreacable messge in response */ |
| 5031 | private function f_tc_sgsap_paging_ue_unr(charstring id, BSC_ConnHdlrPars pars) |
| 5032 | runs on BSC_ConnHdlr { |
| 5033 | f_init_handler(pars); |
| 5034 | f_sgs_perform_lu(); |
| 5035 | f_sleep(1.0); |
| 5036 | |
| 5037 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5038 | var template PDU_SGsAP exp_resp := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, CS_call_indicator, omit); |
| 5039 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5040 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 5041 | |
| 5042 | /* Initiate paging via VTY */ |
| 5043 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 5044 | alt { |
| 5045 | [] SGsAP.receive(exp_resp) { |
| 5046 | setverdict(pass); |
| 5047 | } |
| 5048 | [] SGsAP.receive { |
| 5049 | setverdict(fail, "Received unexpected message on SGs"); |
| 5050 | } |
| 5051 | } |
| 5052 | |
| 5053 | /* Now pretend that the UE is unreachable */ |
| 5054 | SGsAP.send(ts_SGsAP_UE_UNREACHABLE(g_pars.imsi, UE_unreachable)); |
| 5055 | |
| 5056 | /* Wait for the states inside the MSC to settle and check the state |
| 5057 | * of the SGs Association. */ |
| 5058 | f_sleep(1.0); |
| 5059 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5060 | |
| 5061 | f_sgsap_bssmap_screening(); |
| 5062 | |
| 5063 | setverdict(pass); |
| 5064 | } |
| 5065 | testcase TC_sgsap_paging_ue_unr() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5066 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5067 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5068 | f_init(1, true); |
| 5069 | pars := f_init_pars(11818, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5070 | 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] | 5071 | 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] | 5072 | vc_conn.done; |
| 5073 | } |
| 5074 | |
| 5075 | /* Trigger a paging request via VTY but don't respond to it */ |
| 5076 | private function f_tc_sgsap_paging_and_nothing(charstring id, BSC_ConnHdlrPars pars) |
| 5077 | runs on BSC_ConnHdlr { |
| 5078 | f_init_handler(pars); |
| 5079 | f_sgs_perform_lu(); |
| 5080 | f_sleep(1.0); |
| 5081 | |
| 5082 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5083 | 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] | 5084 | 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] | 5085 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5086 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 5087 | |
| 5088 | /* Initiate paging via VTY */ |
| 5089 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 5090 | alt { |
| 5091 | [] SGsAP.receive(exp_resp) { |
| 5092 | setverdict(pass); |
| 5093 | } |
| 5094 | [] SGsAP.receive { |
| 5095 | setverdict(fail, "Received unexpected message on SGs"); |
| 5096 | } |
| 5097 | } |
| 5098 | |
Philipp Maier | 3421810 | 2019-09-24 09:15:49 +0200 | [diff] [blame] | 5099 | /* While we are doing nothing, expect an SGsAP-SERVICE-ABORT-REQUEST |
| 5100 | * after some time */ |
| 5101 | timer T := 10.0; |
| 5102 | T.start |
| 5103 | alt { |
| 5104 | [] SGsAP.receive(exp_serv_abrt) |
| 5105 | { |
| 5106 | setverdict(pass); |
| 5107 | } |
| 5108 | [] SGsAP.receive { |
| 5109 | setverdict(fail, "unexpected SGsAP message received"); |
| 5110 | self.stop; |
| 5111 | } |
| 5112 | [] T.timeout { |
| 5113 | setverdict(fail, "MSC did not send SGsAP-SERVICE-ABORT-REQUEST"); |
| 5114 | self.stop; |
| 5115 | } |
| 5116 | } |
| 5117 | |
| 5118 | /* The SGs association must remain unchanged. */ |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5119 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5120 | |
| 5121 | f_sgsap_bssmap_screening(); |
| 5122 | |
| 5123 | setverdict(pass); |
| 5124 | } |
| 5125 | testcase TC_sgsap_paging_and_nothing() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5126 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5127 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5128 | f_init(1, true); |
| 5129 | pars := f_init_pars(11819, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5130 | 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] | 5131 | 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] | 5132 | vc_conn.done; |
| 5133 | } |
| 5134 | |
| 5135 | /* Trigger a paging request via VTY and slip in an LU */ |
| 5136 | private function f_tc_sgsap_paging_and_lu(charstring id, BSC_ConnHdlrPars pars) |
| 5137 | runs on BSC_ConnHdlr { |
| 5138 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5139 | f_init_handler(pars); |
| 5140 | |
| 5141 | /* First we prepar the situation, where the SGs association is in state |
| 5142 | * NULL and the confirmed by radio contact indicator is set to false |
| 5143 | * as well. This can be archived by performing an SGs LU and then |
| 5144 | * resetting the VLR */ |
| 5145 | f_sgs_perform_lu(); |
| 5146 | f_sgsap_reset_mme(mp_mme_name); |
| 5147 | f_sleep(1.0); |
| 5148 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 5149 | |
| 5150 | /* Perform a paging, expect the paging messages on the SGs interface */ |
| 5151 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 5152 | alt { |
| 5153 | [] SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)) { |
| 5154 | setverdict(pass); |
| 5155 | } |
| 5156 | [] SGsAP.receive { |
| 5157 | setverdict(fail, "Received unexpected message on SGs"); |
| 5158 | } |
| 5159 | } |
| 5160 | |
| 5161 | /* Perform the LU as normal */ |
| 5162 | f_sgs_perform_lu(); |
| 5163 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5164 | |
| 5165 | /* Expect a new paging request right after the LU */ |
| 5166 | alt { |
| 5167 | [] SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)) { |
| 5168 | setverdict(pass); |
| 5169 | } |
| 5170 | [] SGsAP.receive { |
| 5171 | setverdict(fail, "Received unexpected message on SGs"); |
| 5172 | } |
| 5173 | } |
| 5174 | |
| 5175 | /* Test is done now, lets round everything up by rejecting the paging |
| 5176 | * cleanly. */ |
| 5177 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, user_rejected_mobile_terminating_CS_fallback_call)); |
| 5178 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5179 | |
| 5180 | f_sgsap_bssmap_screening(); |
| 5181 | |
| 5182 | setverdict(pass); |
| 5183 | } |
| 5184 | testcase TC_sgsap_paging_and_lu() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5185 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5186 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5187 | f_init(1, true); |
| 5188 | pars := f_init_pars(11820, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5189 | 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] | 5190 | 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] | 5191 | vc_conn.done; |
| 5192 | } |
| 5193 | |
| 5194 | /* Send unexpected unit-data through the SGs interface */ |
| 5195 | private function f_tc_sgsap_unexp_ud(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5196 | f_init_handler(pars); |
| 5197 | f_sleep(1.0); |
| 5198 | |
| 5199 | /* This simulates what happens when a subscriber without SGs |
| 5200 | * association gets unitdata via the SGs interface. */ |
| 5201 | |
| 5202 | /* Make sure the subscriber exists and the SGs association |
| 5203 | * is in NULL state */ |
| 5204 | f_perform_lu(); |
| 5205 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 5206 | |
| 5207 | /* Send some random unit data, the MSC/VLR should send a release |
| 5208 | * immediately. */ |
| 5209 | SGsAP.send(ts_SGsAP_UL_UD(pars.imsi,'1234'O)); |
| 5210 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, IMSI_detached_for_EPS_nonEPS_services)); |
| 5211 | |
| 5212 | f_sgsap_bssmap_screening(); |
| 5213 | |
| 5214 | setverdict(pass); |
| 5215 | } |
| 5216 | testcase TC_sgsap_unexp_ud() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5217 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5218 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5219 | f_init(1, true); |
| 5220 | pars := f_init_pars(11821, true); |
| 5221 | 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] | 5222 | vc_conn.done; |
| 5223 | } |
| 5224 | |
| 5225 | /* Send unsolicited unit-data through the SGs interface */ |
| 5226 | private function f_tc_sgsap_unsol_ud(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5227 | f_init_handler(pars); |
| 5228 | f_sleep(1.0); |
| 5229 | |
| 5230 | /* This simulates what happens when the MME attempts to send unitdata |
| 5231 | * to a subscriber that is completely unknown to the VLR */ |
| 5232 | |
| 5233 | /* Send some random unit data, the MSC/VLR should send a release |
| 5234 | * immediately. */ |
| 5235 | SGsAP.send(ts_SGsAP_UL_UD(pars.imsi,'1234'O)); |
| 5236 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, IMSI_unknown)); |
| 5237 | |
| 5238 | f_sgsap_bssmap_screening(); |
| 5239 | |
Harald Welte | 4d15fa7 | 2020-08-19 08:58:28 +0200 | [diff] [blame] | 5240 | /* clean-up VLR state about this subscriber */ |
| 5241 | f_imsi_detach_by_imsi(); |
| 5242 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5243 | setverdict(pass); |
| 5244 | } |
| 5245 | testcase TC_sgsap_unsol_ud() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5246 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5247 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5248 | f_init(1, true); |
| 5249 | pars := f_init_pars(11822, true); |
| 5250 | 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] | 5251 | vc_conn.done; |
| 5252 | } |
| 5253 | |
| 5254 | private altstep as_other_sms_sgs() runs on BSC_ConnHdlr { |
| 5255 | /* FIXME: Match an actual payload (second questionmark), the type is |
| 5256 | * octetstring, how do we use a tr_PDU_DTAP_MT here? */ |
| 5257 | [] SGsAP.receive(tr_SGsAP_DL_UD(?,?)) { |
| 5258 | setverdict(fail, "Unexpected SMS related PDU from MSC"); |
| 5259 | mtc.stop; |
| 5260 | } |
| 5261 | } |
| 5262 | |
| 5263 | /* receive a MT-SMS delivered from the MSC/SMSC over an already existing SGsAP connection */ |
| 5264 | function f_mt_sms_sgs(inout SmsParameters spars) |
| 5265 | runs on BSC_ConnHdlr { |
| 5266 | var template (value) TPDU_RP_DATA_MS_SGSN tp_mo; |
| 5267 | var template (value) RPDU_MS_SGSN rp_mo; |
| 5268 | var template (value) PDU_ML3_MS_NW l3_mo; |
| 5269 | |
| 5270 | var template TPDU_RP_DATA_SGSN_MS tp_mt; |
| 5271 | var template RPDU_SGSN_MS rp_mt; |
| 5272 | var template PDU_ML3_NW_MS l3_mt; |
| 5273 | |
| 5274 | var PDU_ML3_NW_MS sgsap_l3_mt; |
| 5275 | |
| 5276 | var default d := activate(as_other_sms_sgs()); |
| 5277 | |
| 5278 | /* Expect CP-DATA(RP-DATA(SMS-DELIVER)) */ |
| 5279 | 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] | 5280 | 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] | 5281 | l3_mt := tr_ML3_MT_SMS(?, c_TIF_ORIG, tr_CP_DATA_MT(rp_mt)); |
| 5282 | |
| 5283 | SGsAP.receive(l3_mt) -> value sgsap_l3_mt; |
| 5284 | |
| 5285 | /* Extract relevant identifiers */ |
| 5286 | spars.tid := bit2int(sgsap_l3_mt.tiOrSkip.transactionId.tio); |
| 5287 | spars.rp.msg_ref := sgsap_l3_mt.msgs.sms.cP_DATA.cP_User_Data.cP_RPDU.rP_DATA_SGSN_MS.rP_MessageReference; |
| 5288 | |
| 5289 | /* send CP-ACK for CP-DATA just received */ |
| 5290 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_REPL, ts_CP_ACK_MO); |
| 5291 | |
| 5292 | SGsAP.send(l3_mo); |
| 5293 | |
| 5294 | /* send RP-ACK for RP-DATA */ |
| 5295 | rp_mo := ts_RP_ACK_MO(spars.rp.msg_ref); |
| 5296 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_REPL, ts_CP_DATA_MO(rp_mo)); |
| 5297 | |
| 5298 | SGsAP.send(l3_mo); |
| 5299 | |
| 5300 | /* expect CP-ACK for CP-DATA(RP-ACK) just sent */ |
| 5301 | l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_ORIG, tr_CP_ACK_MT); |
| 5302 | |
| 5303 | SGsAP.receive(l3_mt); |
| 5304 | |
| 5305 | deactivate(d); |
| 5306 | |
| 5307 | setverdict(pass); |
| 5308 | } |
| 5309 | |
| 5310 | /* submit a MO-SMS to MSC/SMSC over an already existing SGsAP connection */ |
| 5311 | function f_mo_sms_sgs(inout SmsParameters spars) |
| 5312 | runs on BSC_ConnHdlr { |
| 5313 | var template (value) TPDU_RP_DATA_MS_SGSN tp_mo; |
| 5314 | var template (value) RPDU_MS_SGSN rp_mo; |
| 5315 | var template (value) PDU_ML3_MS_NW l3_mo; |
| 5316 | |
| 5317 | var template TPDU_RP_DATA_SGSN_MS tp_mt; |
| 5318 | var template RPDU_SGSN_MS rp_mt; |
| 5319 | var template PDU_ML3_NW_MS l3_mt; |
| 5320 | |
| 5321 | var default d := activate(as_other_sms_sgs()); |
| 5322 | |
| 5323 | /* just in case this is routed to SMPP.. */ |
| 5324 | f_create_smpp_expect(hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue)); |
| 5325 | |
| 5326 | tp_mo := ts_SMS_SUBMIT(spars.tp.msg_ref, spars.tp.da, spars.tp.pid, spars.tp.dcs, |
| 5327 | spars.tp.udl, spars.tp.ud); |
Vadim Yanitskiy | 437b5a6 | 2019-12-15 14:13:39 +0900 | [diff] [blame] | 5328 | 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] | 5329 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_DATA_MO(rp_mo)); |
| 5330 | |
| 5331 | SGsAP.send(l3_mo); |
| 5332 | |
| 5333 | /* receive CP-ACK for CP-DATA above */ |
| 5334 | SGsAP.receive(tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_ACK_MT)); |
| 5335 | |
| 5336 | if (ispresent(spars.exp_rp_err)) { |
| 5337 | /* expect an RP-ERROR message from MSC with given cause */ |
| 5338 | rp_mt := tr_RP_ERROR_MT(spars.rp.msg_ref, spars.exp_rp_err); |
| 5339 | l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_DATA_MT(rp_mt)); |
| 5340 | SGsAP.receive(l3_mt); |
| 5341 | /* send CP-ACK for CP-DATA just received */ |
| 5342 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_ACK_MO); |
| 5343 | SGsAP.send(l3_mo); |
| 5344 | } else { |
| 5345 | /* expect RP-ACK for RP-DATA */ |
| 5346 | rp_mt := tr_RP_ACK_MT(spars.rp.msg_ref); |
| 5347 | l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_DATA_MT(rp_mt)); |
| 5348 | SGsAP.receive(l3_mt); |
| 5349 | /* send CP-ACO for CP-DATA just received */ |
| 5350 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_ACK_MO); |
| 5351 | SGsAP.send(l3_mo); |
| 5352 | } |
| 5353 | |
| 5354 | deactivate(d); |
| 5355 | |
| 5356 | setverdict(pass); |
| 5357 | } |
| 5358 | |
| 5359 | private function f_vty_sms_send_conn_hdlr(charstring imsi, charstring msisdn, charstring text) |
| 5360 | runs on BSC_ConnHdlr { |
| 5361 | f_vty_transceive(MSCVTY, "subscriber imsi "&imsi&" sms sender msisdn "&msisdn&" send "&text); |
| 5362 | } |
| 5363 | |
| 5364 | /* Send a MT SMS via SGs interface */ |
| 5365 | private function f_tc_sgsap_mt_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5366 | f_init_handler(pars); |
| 5367 | f_sgs_perform_lu(); |
| 5368 | f_sleep(1.0); |
| 5369 | var SmsParameters spars := valueof(t_SmsPars); |
| 5370 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 5371 | |
| 5372 | /* Trigger SMS via VTY */ |
| 5373 | f_vty_sms_send_conn_hdlr(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 5374 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5375 | |
| 5376 | /* Expect a paging request and respond accordingly with a service request */ |
| 5377 | SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, SMS_indicator, omit)); |
| 5378 | SGsAP.send(ts_SGsAP_SERVICE_REQ(pars.imsi, SMS_indicator, EMM_CONNECTED)); |
| 5379 | |
| 5380 | /* Connection is now live, receive the MT-SMS */ |
| 5381 | f_mt_sms_sgs(spars); |
| 5382 | |
| 5383 | /* Expect a concluding release from the MSC */ |
| 5384 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, omit)); |
| 5385 | |
| 5386 | /* Make sure that subscriber is still present and the SGs association is in tact (ref-counting) */ |
| 5387 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5388 | |
| 5389 | f_sgsap_bssmap_screening(); |
| 5390 | |
| 5391 | setverdict(pass); |
| 5392 | } |
| 5393 | testcase TC_sgsap_mt_sms() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5394 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5395 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5396 | f_init(1, true); |
| 5397 | pars := f_init_pars(11823, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5398 | 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] | 5399 | 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] | 5400 | vc_conn.done; |
| 5401 | } |
| 5402 | |
| 5403 | /* Send a MO SMS via SGs interface */ |
| 5404 | private function f_tc_sgsap_mo_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5405 | f_init_handler(pars); |
| 5406 | f_sgs_perform_lu(); |
| 5407 | f_sleep(1.0); |
| 5408 | var SmsParameters spars := valueof(t_SmsPars); |
| 5409 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 5410 | |
| 5411 | /* Send the MO-SMS */ |
| 5412 | f_mo_sms_sgs(spars); |
| 5413 | |
| 5414 | /* Expect a concluding release from the MSC/VLR */ |
| 5415 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, omit)); |
| 5416 | |
| 5417 | /* Make sure that subscriber is still present and the SGs association is in tact (ref-counting) */ |
| 5418 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5419 | |
| 5420 | setverdict(pass); |
| 5421 | |
| 5422 | f_sgsap_bssmap_screening() |
| 5423 | } |
| 5424 | testcase TC_sgsap_mo_sms() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5425 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5426 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5427 | f_init(1, true); |
| 5428 | pars := f_init_pars(11824, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5429 | 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] | 5430 | 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] | 5431 | vc_conn.done; |
| 5432 | } |
| 5433 | |
| 5434 | /* Trigger sending of an MT sms via VTY but never respond to anything */ |
| 5435 | private function f_tc_sgsap_mt_sms_and_nothing(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5436 | f_init_handler(pars, 170.0); |
| 5437 | f_sgs_perform_lu(); |
| 5438 | f_sleep(1.0); |
| 5439 | |
| 5440 | var SmsParameters spars := valueof(t_SmsPars); |
| 5441 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 5442 | var integer page_count := 0; |
| 5443 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5444 | var template PDU_SGsAP exp_pag_req := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, SMS_indicator, omit); |
| 5445 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5446 | exp_pag_req.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 5447 | |
| 5448 | /* Trigger SMS via VTY */ |
| 5449 | f_vty_sms_send_conn_hdlr(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 5450 | |
Neels Hofmeyr | 1623774 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 5451 | /* Expect the MSC/VLR to page exactly once */ |
| 5452 | SGsAP.receive(exp_pag_req); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5453 | |
| 5454 | /* Wait some time to make sure the MSC is not delivering any further |
| 5455 | * paging messages or anything else that could be unexpected. */ |
| 5456 | timer T := 20.0; |
| 5457 | T.start |
| 5458 | alt { |
| 5459 | [] SGsAP.receive(exp_pag_req) |
| 5460 | { |
| 5461 | setverdict(fail, "paging seems not to stop!"); |
| 5462 | mtc.stop; |
| 5463 | } |
| 5464 | [] SGsAP.receive { |
| 5465 | setverdict(fail, "unexpected SGsAP message received"); |
| 5466 | self.stop; |
| 5467 | } |
| 5468 | [] T.timeout { |
| 5469 | setverdict(pass); |
| 5470 | } |
| 5471 | } |
| 5472 | |
| 5473 | /* Even on a failed paging the SGs Association should stay intact */ |
| 5474 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5475 | |
Philipp Maier | 26bdb8c | 2019-09-24 09:21:12 +0200 | [diff] [blame] | 5476 | /* Make sure that the SMS we just inserted is cleared and the |
| 5477 | * subscriber is expired. This is necessary because otherwise the MSC |
| 5478 | * might re-try the SMS delivery and disturb the following tests. */ |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5479 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 5480 | f_vty_sms_clear(hex2str(g_pars.imsi)); |
| 5481 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5482 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " expire"); |
| 5483 | |
| 5484 | setverdict(pass); |
Neels Hofmeyr | b0f8234 | 2019-03-06 15:36:51 +0100 | [diff] [blame] | 5485 | |
| 5486 | f_sgsap_bssmap_screening(); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5487 | } |
| 5488 | testcase TC_sgsap_mt_sms_and_nothing() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5489 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5490 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5491 | f_init(1, true); |
| 5492 | pars := f_init_pars(11825, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5493 | 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] | 5494 | 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] | 5495 | vc_conn.done; |
| 5496 | } |
| 5497 | |
| 5498 | /* Trigger sending of an MT sms via VTY but reject the paging immediately */ |
| 5499 | private function f_tc_sgsap_mt_sms_and_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5500 | f_init_handler(pars, 150.0); |
| 5501 | f_sgs_perform_lu(); |
| 5502 | f_sleep(1.0); |
| 5503 | |
| 5504 | var SmsParameters spars := valueof(t_SmsPars); |
| 5505 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 5506 | var integer page_count := 0; |
| 5507 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5508 | var template PDU_SGsAP exp_pag_req := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, SMS_indicator, omit); |
| 5509 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5510 | exp_pag_req.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 5511 | |
| 5512 | /* Trigger SMS via VTY */ |
| 5513 | f_vty_sms_send_conn_hdlr(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 5514 | |
| 5515 | /* Expect a paging request and reject it immediately */ |
| 5516 | SGsAP.receive(exp_pag_req); |
| 5517 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, IMSI_unknown)); |
| 5518 | |
| 5519 | /* The MSC/VLR should no longer try to page once the paging has been |
| 5520 | * rejected. Wait some time and check if there are no unexpected |
| 5521 | * messages on the SGs interface. */ |
| 5522 | timer T := 20.0; |
| 5523 | T.start |
| 5524 | alt { |
| 5525 | [] SGsAP.receive(exp_pag_req) |
| 5526 | { |
| 5527 | setverdict(fail, "paging seems not to stop!"); |
| 5528 | mtc.stop; |
| 5529 | } |
| 5530 | [] SGsAP.receive { |
| 5531 | setverdict(fail, "unexpected SGsAP message received"); |
| 5532 | self.stop; |
| 5533 | } |
| 5534 | [] T.timeout { |
| 5535 | setverdict(pass); |
| 5536 | } |
| 5537 | } |
| 5538 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 5539 | f_vty_sms_clear(hex2str(g_pars.imsi)); |
| 5540 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5541 | /* A rejected paging with IMSI_unknown (see above) should always send |
| 5542 | * the SGs association to NULL. */ |
| 5543 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 5544 | |
| 5545 | f_sgsap_bssmap_screening(); |
| 5546 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5547 | setverdict(pass); |
| 5548 | } |
| 5549 | testcase TC_sgsap_mt_sms_and_reject() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5550 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5551 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5552 | f_init(1, true); |
| 5553 | pars := f_init_pars(11826, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5554 | 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] | 5555 | 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] | 5556 | vc_conn.done; |
| 5557 | } |
| 5558 | |
Pau Espin Pedrol | 3acd19e | 2021-04-28 12:59:52 +0200 | [diff] [blame] | 5559 | /* Perform an MT CSFB call including LU */ |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5560 | private function f_mt_lu_and_csfb_call(charstring id, BSC_ConnHdlrPars pars, boolean bssmap_lu) runs on BSC_ConnHdlr { |
| 5561 | f_init_handler(pars); |
| 5562 | |
| 5563 | /* Be sure that the BSSMAP reset is done before we begin. */ |
| 5564 | f_sleep(2.0); |
| 5565 | |
| 5566 | /* Testcase variation: See what happens when we do a regular BSSMAP |
| 5567 | * LU first (this should not hurt in any way!) */ |
| 5568 | if (bssmap_lu) { |
| 5569 | f_perform_lu(); |
| 5570 | } |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5571 | 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] | 5572 | |
| 5573 | f_sgs_perform_lu(); |
| 5574 | f_sleep(1.0); |
| 5575 | |
| 5576 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5577 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5578 | |
| 5579 | /* Initiate a call via MNCC interface */ |
| 5580 | f_mt_call_initate(cpars); |
| 5581 | |
| 5582 | /* Expect a paging request and respond accordingly with a service request */ |
| 5583 | SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)); |
| 5584 | SGsAP.send(ts_SGsAP_SERVICE_REQ(pars.imsi, CS_call_indicator, EMM_CONNECTED)); |
| 5585 | |
| 5586 | /* Complete the call, hold it for some time and then tear it down */ |
| 5587 | f_mt_call_complete(cpars); |
| 5588 | f_sleep(3.0); |
Harald Welte | 4c422b7 | 2019-02-17 16:27:10 +0100 | [diff] [blame] | 5589 | f_call_hangup(cpars, true, is_csfb := true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5590 | |
| 5591 | /* Make sure that subscriber is still present and the SGs association is in tact (ref-counting) */ |
| 5592 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5593 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5594 | /* Test for successful return by triggering a paging, when the paging |
| 5595 | * request is received via SGs, we can be sure that the MSC/VLR has |
| 5596 | * recognized that the UE is now back on 4G */ |
| 5597 | f_sleep(1.0); |
| 5598 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 5599 | alt { |
| 5600 | [] SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)) { |
| 5601 | setverdict(pass); |
| 5602 | } |
| 5603 | [] SGsAP.receive { |
| 5604 | setverdict(fail, "Received unexpected message on SGs"); |
| 5605 | } |
| 5606 | } |
| 5607 | |
| 5608 | f_sgsap_bssmap_screening(); |
| 5609 | |
| 5610 | setverdict(pass); |
| 5611 | } |
| 5612 | |
| 5613 | /* Perform a regular BSSAP LU first, do a SGSAP LU and then make a CSFB call */ |
| 5614 | private function f_tc_bssap_lu_sgsap_lu_and_mt_call(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5615 | f_mt_lu_and_csfb_call(id, pars, true); |
| 5616 | } |
| 5617 | 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] | 5618 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5619 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5620 | f_init(1, true); |
| 5621 | pars := f_init_pars(118139, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5622 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5623 | 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] | 5624 | vc_conn.done; |
| 5625 | } |
| 5626 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5627 | /* Perform a SGSAP LU and then make a CSFB call */ |
| 5628 | private function f_tc_sgsap_lu_and_mt_call(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5629 | f_mt_lu_and_csfb_call(id, pars, false); |
| 5630 | } |
| 5631 | testcase TC_sgsap_lu_and_mt_call() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5632 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5633 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5634 | f_init(1, true); |
| 5635 | pars := f_init_pars(11827, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5636 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5637 | 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] | 5638 | vc_conn.done; |
| 5639 | } |
| 5640 | |
Philipp Maier | 628c005 | 2019-04-09 17:36:57 +0200 | [diff] [blame] | 5641 | /* Simulate an HLR/VLR failure */ |
| 5642 | private function f_tc_sgsap_vlr_failure(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5643 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 5644 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5645 | |
| 5646 | var PDU_SGsAP lur; |
| 5647 | |
| 5648 | f_init_handler(pars); |
| 5649 | |
| 5650 | /* Attempt location update (which is expected to fail) */ |
| 5651 | lur := valueof(ts_SGsAP_LU_REQ(g_pars.imsi, mme_name, IMSI_attach, |
| 5652 | ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5653 | SGsAP.send(lur); |
| 5654 | |
| 5655 | /* Respond to SGsAP-RESET-INDICATION from VLR */ |
| 5656 | alt { |
| 5657 | [] SGsAP.receive(tr_SGsAP_RESET_IND_VLR(vlr_name)); { |
| 5658 | SGsAP.send(valueof(ts_SGsAP_RESET_ACK_MME(mme_name))); |
| 5659 | setverdict(pass); |
| 5660 | } |
| 5661 | [] SGsAP.receive { |
| 5662 | setverdict(fail, "Received unexpected message on SGs"); |
| 5663 | } |
| 5664 | } |
| 5665 | |
| 5666 | f_sleep(1.0); |
| 5667 | setverdict(pass); |
| 5668 | } |
| 5669 | testcase TC_sgsap_vlr_failure() runs on MTC_CT { |
| 5670 | var BSC_ConnHdlrPars pars; |
| 5671 | var BSC_ConnHdlr vc_conn; |
| 5672 | f_init(1, true, false); |
| 5673 | pars := f_init_pars(11811, true, false); |
| 5674 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_vlr_failure), pars); |
| 5675 | vc_conn.done; |
| 5676 | } |
| 5677 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5678 | /* SGs TODO: |
| 5679 | * LU attempt for IMSI without NAM_PS in HLR |
| 5680 | * LU attempt with AUTH FAIL due to invalid RES/SRES |
| 5681 | * LU attempt with no response from HLR (VLR should timeout + LU REJ) |
| 5682 | * LU attempt with new TMSI but without TMSI REALL CMPL baco to VLR |
| 5683 | * implicit IMSI detach from EPS |
| 5684 | * implicit IMSI detach from non-EPS |
| 5685 | * MM INFO |
| 5686 | * |
| 5687 | */ |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 5688 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5689 | private function f_tc_ho_inter_bsc_unknown_cell(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5690 | f_init_handler(pars); |
| 5691 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5692 | |
| 5693 | f_perform_lu(); |
| 5694 | f_mo_call_establish(cpars); |
| 5695 | |
| 5696 | f_sleep(1.0); |
| 5697 | |
| 5698 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_BETTER_CELL; |
| 5699 | var BssmapCause cause := enum2int(cause_val); |
| 5700 | |
| 5701 | var template BSSMAP_FIELD_CellIdentificationList cil; |
| 5702 | cil := { cIl_LAI := { ts_BSSMAP_CI_LAI('023'H, '42'H, 999) } }; |
| 5703 | |
| 5704 | BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 5705 | BSSAP.receive(tr_BSSMAP_HandoverRequiredReject); |
| 5706 | |
| 5707 | f_call_hangup(cpars, true); |
| 5708 | } |
| 5709 | testcase TC_ho_inter_bsc_unknown_cell() runs on MTC_CT { |
| 5710 | var BSC_ConnHdlr vc_conn; |
| 5711 | f_init(); |
| 5712 | |
| 5713 | vc_conn := f_start_handler(refers(f_tc_ho_inter_bsc_unknown_cell), 53); |
| 5714 | vc_conn.done; |
| 5715 | } |
| 5716 | |
| 5717 | private altstep as_mgcp_ack_all_mdcx(CallParameters cpars) runs on BSC_ConnHdlr { |
| 5718 | var MgcpCommand mgcp_cmd; |
| 5719 | [] MGCP.receive(tr_MDCX) -> value mgcp_cmd { |
Neels Hofmeyr | 8913b9e | 2021-07-27 22:33:45 +0200 | [diff] [blame] | 5720 | var charstring conn_id; |
| 5721 | f_mgcp_find_param_entry(mgcp_cmd.params, "I", conn_id); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 5722 | 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] | 5723 | hex2str(cpars.mgcp_call_id), "42", |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 5724 | cpars.mgw_conn_2.mgw_rtp_port, |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5725 | { int2str(cpars.rtp_payload_type) }, |
| 5726 | { valueof(ts_SDP_rtpmap(cpars.rtp_payload_type, |
| 5727 | cpars.rtp_sdp_format)), |
| 5728 | valueof(ts_SDP_ptime(20)) })); |
Neels Hofmeyr | 8913b9e | 2021-07-27 22:33:45 +0200 | [diff] [blame] | 5729 | 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] | 5730 | repeat; |
| 5731 | } |
| 5732 | } |
| 5733 | |
Neels Hofmeyr | 8853afb | 2021-07-27 22:34:15 +0200 | [diff] [blame] | 5734 | private altstep as_mgcp_ack_all_dlcx(CallParameters cpars) runs on BSC_ConnHdlr { |
| 5735 | var MgcpCommand mgcp_cmd; |
| 5736 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 5737 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
| 5738 | repeat; |
| 5739 | } |
| 5740 | } |
| 5741 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5742 | 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] | 5743 | var CallParameters cpars; |
| 5744 | |
| 5745 | cpars := valueof(t_CallParams('12345'H, 0)); |
| 5746 | if (pars.use_ipv6) { |
| 5747 | cpars.mgw_conn_1.mgw_rtp_ip := "::1"; |
| 5748 | cpars.mgw_conn_2.mgw_rtp_ip := "::2"; |
| 5749 | cpars.bss_rtp_ip := "::3"; |
| 5750 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5751 | |
| 5752 | f_init_handler(pars); |
| 5753 | |
| 5754 | f_vty_transceive(MSCVTY, "configure terminal"); |
| 5755 | f_vty_transceive(MSCVTY, "msc"); |
| 5756 | 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] | 5757 | 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] | 5758 | f_vty_transceive(MSCVTY, "exit"); |
| 5759 | f_vty_transceive(MSCVTY, "exit"); |
| 5760 | |
| 5761 | f_perform_lu(); |
| 5762 | f_mo_call_establish(cpars); |
| 5763 | |
| 5764 | f_sleep(1.0); |
| 5765 | |
| 5766 | var default ack_mdcx := activate(as_mgcp_ack_all_mdcx(cpars)); |
| 5767 | |
| 5768 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_BETTER_CELL; |
| 5769 | var BssmapCause cause := enum2int(cause_val); |
| 5770 | |
| 5771 | var template BSSMAP_FIELD_CellIdentificationList cil; |
Neels Hofmeyr | 2822d07 | 2021-06-23 03:20:32 +0200 | [diff] [blame] | 5772 | 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] | 5773 | |
| 5774 | /* old BSS sends Handover Required */ |
| 5775 | BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 5776 | |
| 5777 | /* Now the action goes on in f_tc_ho_inter_bsc1() */ |
| 5778 | |
| 5779 | /* MSC forwards the RR Handover Command to old BSS */ |
| 5780 | var PDU_BSSAP ho_command; |
| 5781 | BSSAP.receive(tr_BSSMAP_HandoverCommand) -> value ho_command; |
| 5782 | |
| 5783 | log("GOT HandoverCommand", ho_command); |
| 5784 | |
| 5785 | BSSAP.receive(tr_BSSMAP_HandoverSucceeded); |
| 5786 | |
| 5787 | /* f_tc_ho_inter_bsc1() completes Handover, then expecting a Clear here. */ |
| 5788 | f_expect_clear(); |
| 5789 | |
| 5790 | log("FIRST inter-BSC Handover done"); |
| 5791 | |
| 5792 | |
| 5793 | /* ------------------------ */ |
| 5794 | |
| 5795 | /* Ok, that went well, now the other BSC is handovering back here -- |
| 5796 | * from now on this here is the new BSS. */ |
| 5797 | f_create_bssmap_exp_handoverRequest(193); |
| 5798 | |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5799 | var template BSSMAP_IE_EncryptionInformation encryptionInformation; |
| 5800 | var template BSSMAP_IE_ChosenEncryptionAlgorithm chosenEncryptionAlgorithm; |
| 5801 | var template BSSMAP_IE_KC128 kC128; |
| 5802 | var OCT1 a5_perm_alg; |
| 5803 | f_get_expected_encryption(encryptionInformation, chosenEncryptionAlgorithm, kC128, a5_perm_alg); |
| 5804 | var template PDU_BSSAP expect_ho_request := tr_BSSMAP_HandoverRequest(encryptionInformation, chosenEncryptionAlgorithm, kC128); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5805 | var PDU_BSSAP ho_request; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5806 | alt { |
| 5807 | [] BSSAP.receive(expect_ho_request); |
| 5808 | [] BSSAP.receive(tr_BSSMAP_HandoverRequest) -> value ho_request { |
| 5809 | log("Error: Wrong handoverRequest received. Expected: ", expect_ho_request, |
| 5810 | " got ", ho_request); |
| 5811 | setverdict(fail, "Wrong handoverRequest received"); |
| 5812 | mtc.stop; |
| 5813 | } |
| 5814 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5815 | |
| 5816 | /* new BSS composes a RR Handover Command */ |
| 5817 | var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 5818 | 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] | 5819 | var BSSMAP_IE_AoIP_TransportLayerAddress tla tla := |
| 5820 | 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] | 5821 | BSSAP.send(ts_BSSMAP_HandoverRequestAcknowledge(rr_ho_cmd_enc, lengthof(rr_ho_cmd_enc), |
| 5822 | tla, ts_BSSMAP_IE_SpeechCodec({ts_CodecFR}))); |
| 5823 | |
| 5824 | /* Now f_tc_ho_inter_bsc1() expects HandoverCommand */ |
| 5825 | |
| 5826 | f_sleep(0.5); |
| 5827 | |
| 5828 | /* Notify that the MS is now over here */ |
| 5829 | |
| 5830 | BSSAP.send(ts_BSSMAP_HandoverDetect); |
| 5831 | f_sleep(0.1); |
| 5832 | BSSAP.send(ts_BSSMAP_HandoverComplete); |
| 5833 | |
| 5834 | f_sleep(3.0); |
| 5835 | |
| 5836 | deactivate(ack_mdcx); |
| 5837 | |
| 5838 | var default ccrel := activate(as_optional_cc_rel(cpars, true)); |
| 5839 | |
| 5840 | /* blatant cheating */ |
| 5841 | var N_Sd_Array last_n_sd := f_bssmap_last_n_sd(); |
| 5842 | last_n_sd[0] := 3; |
| 5843 | f_bssmap_continue_after_n_sd(last_n_sd); |
| 5844 | |
| 5845 | f_call_hangup(cpars, true); |
| 5846 | f_sleep(1.0); |
| 5847 | deactivate(ccrel); |
| 5848 | |
| 5849 | setverdict(pass); |
| 5850 | } |
| 5851 | 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] | 5852 | var charstring bss_rtp_ip; |
| 5853 | if (pars.use_ipv6) { |
| 5854 | bss_rtp_ip := "::8"; |
| 5855 | } else { |
| 5856 | bss_rtp_ip := "1.2.3.4"; |
| 5857 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5858 | f_init_handler(pars); |
| 5859 | f_create_bssmap_exp_handoverRequest(194); |
| 5860 | |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5861 | var template BSSMAP_IE_EncryptionInformation encryptionInformation; |
| 5862 | var template BSSMAP_IE_ChosenEncryptionAlgorithm chosenEncryptionAlgorithm; |
| 5863 | var template BSSMAP_IE_KC128 kC128; |
| 5864 | var OCT1 a5_perm_alg; |
| 5865 | f_get_expected_encryption(encryptionInformation, chosenEncryptionAlgorithm, kC128, a5_perm_alg); |
| 5866 | var template PDU_BSSAP expect_ho_request := tr_BSSMAP_HandoverRequest(encryptionInformation, chosenEncryptionAlgorithm, kC128); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5867 | var PDU_BSSAP ho_request; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5868 | alt { |
| 5869 | [] BSSAP.receive(expect_ho_request); |
| 5870 | [] BSSAP.receive(tr_BSSMAP_HandoverRequest) -> value ho_request { |
| 5871 | log("Error: Wrong handoverRequest received. Expected: ", expect_ho_request, |
| 5872 | " got ", ho_request); |
| 5873 | setverdict(fail, "Wrong handoverRequest received"); |
| 5874 | mtc.stop; |
| 5875 | } |
| 5876 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5877 | /* new BSS composes a RR Handover Command */ |
| 5878 | var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 5879 | 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] | 5880 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := |
| 5881 | valueof(f_ts_BSSMAP_IE_AoIP_TLA(bss_rtp_ip, 2342)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5882 | BSSAP.send(ts_BSSMAP_HandoverRequestAcknowledge(rr_ho_cmd_enc, lengthof(rr_ho_cmd_enc), |
| 5883 | tla, ts_BSSMAP_IE_SpeechCodec({ts_CodecFR}))); |
| 5884 | |
| 5885 | /* Now f_tc_ho_inter_bsc0() expects HandoverCommand */ |
| 5886 | |
| 5887 | f_sleep(0.5); |
| 5888 | |
| 5889 | /* Notify that the MS is now over here */ |
| 5890 | |
| 5891 | BSSAP.send(ts_BSSMAP_HandoverDetect); |
| 5892 | f_sleep(0.1); |
| 5893 | BSSAP.send(ts_BSSMAP_HandoverComplete); |
| 5894 | |
| 5895 | f_sleep(3.0); |
| 5896 | |
| 5897 | /* Now I'd like to f_call_hangup() but we don't know any cpars here. So |
| 5898 | * ... handover back to the first BSC :P */ |
| 5899 | |
| 5900 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_BETTER_CELL; |
| 5901 | var BssmapCause cause := enum2int(cause_val); |
| 5902 | |
| 5903 | var template BSSMAP_FIELD_CellIdentificationList cil; |
Neels Hofmeyr | 2822d07 | 2021-06-23 03:20:32 +0200 | [diff] [blame] | 5904 | 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] | 5905 | |
| 5906 | /* old BSS sends Handover Required */ |
| 5907 | BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 5908 | |
| 5909 | /* Now the action goes on in f_tc_ho_inter_bsc0() */ |
| 5910 | |
| 5911 | /* MSC forwards the RR Handover Command to old BSS */ |
| 5912 | var PDU_BSSAP ho_command; |
| 5913 | BSSAP.receive(tr_BSSMAP_HandoverCommand) -> value ho_command; |
| 5914 | |
| 5915 | log("GOT HandoverCommand", ho_command); |
| 5916 | |
| 5917 | BSSAP.receive(tr_BSSMAP_HandoverSucceeded); |
| 5918 | |
| 5919 | /* f_tc_ho_inter_bsc1() completes Handover, then expecting a Clear here. */ |
| 5920 | f_expect_clear(); |
| 5921 | setverdict(pass); |
| 5922 | } |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5923 | 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] | 5924 | var BSC_ConnHdlr vc_conn0; |
| 5925 | var BSC_ConnHdlr vc_conn1; |
| 5926 | f_init(2); |
| 5927 | |
| 5928 | var BSC_ConnHdlrPars pars0 := f_init_pars(53); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 5929 | pars0.use_ipv6 := use_ipv6; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5930 | pars0.net.expect_ciph := a5_n > 0; |
| 5931 | pars0.net.expect_auth := pars0.net.expect_ciph; |
| 5932 | pars0.net.kc_support := bit2oct('00000001'B << a5_n); |
| 5933 | pars0.cm2.classmarkInformationType2_oct5.a5_3 := '1'B; |
| 5934 | pars0.cm2.classmarkInformationType2_oct5.a5_2 := '0'B; |
| 5935 | pars0.cm2.classmarkInformationType2_oct5.cm3 := '1'B; |
| 5936 | pars0.cm3 := valueof(ts_CM3_default); |
| 5937 | pars0.use_umts_aka := true; |
| 5938 | pars0.vec := f_gen_auth_vec_3g(); |
| 5939 | pars0.vec_keep := true; |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 5940 | pars0.ran_idx := 0; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5941 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5942 | var BSC_ConnHdlrPars pars1 := f_init_pars(53); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 5943 | pars1.use_ipv6 := use_ipv6; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5944 | pars1.net.expect_ciph := pars0.net.expect_ciph; |
| 5945 | pars1.net.expect_auth := pars0.net.expect_ciph; |
| 5946 | pars1.net.kc_support := bit2oct('00000001'B << a5_n); |
| 5947 | pars1.cm2 := pars0.cm2; |
| 5948 | pars1.cm3 := pars0.cm3; |
| 5949 | pars1.use_umts_aka := true; |
| 5950 | /* Both components need the same auth vector info because we expect f_tc_ho_inter_bsc0's ciphering key to be |
| 5951 | * identical to the one that shows up in f_tc_ho_inter_bsc1. Can only do that by feeding in a vector to both |
| 5952 | * components and then not overwriting it in BSC_ConnectionHandler. */ |
| 5953 | pars1.vec := pars0.vec; |
| 5954 | pars1.vec_keep := true; |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 5955 | pars1.ran_idx := 1; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5956 | |
| 5957 | if (a5_n > 0) { |
| 5958 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 5959 | } |
| 5960 | f_vty_config(MSCVTY, "network", "encryption a5 " & int2str(a5_n)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5961 | |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 5962 | vc_conn0 := f_start_handler_with_pars(refers(f_tc_ho_inter_bsc0), pars0); |
| 5963 | 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] | 5964 | vc_conn0.done; |
| 5965 | vc_conn1.done; |
| 5966 | } |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 5967 | testcase TC_ho_inter_bsc() runs on MTC_CT { |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5968 | f_tc_ho_inter_bsc_main(false, a5_n := 0); |
| 5969 | } |
| 5970 | testcase TC_ho_inter_bsc_a5_1() runs on MTC_CT { |
| 5971 | f_tc_ho_inter_bsc_main(false, a5_n := 1); |
| 5972 | } |
| 5973 | testcase TC_ho_inter_bsc_a5_3() runs on MTC_CT { |
| 5974 | f_tc_ho_inter_bsc_main(false, a5_n := 3); |
| 5975 | } |
| 5976 | testcase TC_ho_inter_bsc_a5_4() runs on MTC_CT { |
| 5977 | f_tc_ho_inter_bsc_main(false, a5_n := 4); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 5978 | } |
| 5979 | testcase TC_ho_inter_bsc_ipv6() runs on MTC_CT { |
| 5980 | f_tc_ho_inter_bsc_main(true); |
| 5981 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5982 | |
| 5983 | function f_ML3_patch_seq_nr_MS_NW(in uint2_t seq_nr, inout octetstring enc_l3) { |
| 5984 | log("MS_NW patching N(SD)=", seq_nr, " into dtap ", enc_l3); |
| 5985 | enc_l3[2] := (enc_l3[2] and4b '3f'O) or4b bit2oct(int2bit(seq_nr, 8) << 6); |
| 5986 | log("MS_NW patched enc_l3: ", enc_l3); |
| 5987 | } |
| 5988 | |
| 5989 | 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] | 5990 | var CallParameters cpars; |
Neels Hofmeyr | 906af10 | 2021-07-01 12:08:35 +0200 | [diff] [blame] | 5991 | var PDU_BSSAP ho_request; |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 5992 | |
| 5993 | cpars := valueof(t_CallParams('12345'H, 0)); |
| 5994 | if (pars.use_ipv6) { |
| 5995 | cpars.mgw_conn_1.mgw_rtp_ip := "::1"; |
| 5996 | cpars.mgw_conn_2.mgw_rtp_ip := "::2"; |
| 5997 | cpars.bss_rtp_ip := "::3"; |
| 5998 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5999 | var hexstring ho_number := f_gen_msisdn(99999); |
| 6000 | |
| 6001 | f_init_handler(pars); |
| 6002 | |
| 6003 | f_create_mncc_expect(hex2str(ho_number)); |
| 6004 | |
| 6005 | f_vty_transceive(MSCVTY, "configure terminal"); |
| 6006 | f_vty_transceive(MSCVTY, "msc"); |
| 6007 | f_vty_transceive(MSCVTY, "neighbor a cgi 017 017 1 1 msc-ipa-name msc-017-017-1"); |
| 6008 | f_vty_transceive(MSCVTY, "exit"); |
| 6009 | f_vty_transceive(MSCVTY, "exit"); |
| 6010 | |
| 6011 | f_perform_lu(); |
| 6012 | f_mo_call_establish(cpars); |
| 6013 | |
| 6014 | f_sleep(1.0); |
| 6015 | |
| 6016 | var default ack_mdcx := activate(as_mgcp_ack_all_mdcx(cpars)); |
| 6017 | |
| 6018 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_BETTER_CELL; |
| 6019 | var BssmapCause cause := enum2int(cause_val); |
| 6020 | |
| 6021 | var template BSSMAP_FIELD_CellIdentificationList cil; |
Neels Hofmeyr | 36ebc33 | 2021-06-23 03:20:32 +0200 | [diff] [blame] | 6022 | 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] | 6023 | |
| 6024 | /* old BSS sends Handover Required */ |
| 6025 | BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 6026 | |
| 6027 | /* The target cell 017-017 LAC 1 is configured to be a remote MSC of name "msc-017-017-1". |
| 6028 | * This MSC tries to reach the other MSC via GSUP. */ |
| 6029 | |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6030 | var template BSSMAP_IE_EncryptionInformation encryptionInformation; |
| 6031 | var template BSSMAP_IE_ChosenEncryptionAlgorithm chosenEncryptionAlgorithm; |
| 6032 | var template BSSMAP_IE_KC128 kC128; |
| 6033 | var OCT1 a5_perm_alg; |
| 6034 | f_get_expected_encryption(encryptionInformation, chosenEncryptionAlgorithm, kC128, a5_perm_alg); |
| 6035 | var template PDU_BSSAP expect_ho_request := tr_BSSMAP_HandoverRequest(encryptionInformation, chosenEncryptionAlgorithm, kC128); |
| 6036 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6037 | var octetstring remote_msc_name := '6D73632D3031372D3031372D3100'O; /* "msc-017-017-1\0" as octetstring */ |
| 6038 | var GSUP_PDU prep_ho_req; |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6039 | alt { |
| 6040 | [] GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST, |
| 6041 | pars.imsi, destination_name := remote_msc_name, |
Neels Hofmeyr | ec2e1f7 | 2021-07-02 02:08:32 +0200 | [diff] [blame] | 6042 | 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] | 6043 | [] GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST)) { |
| 6044 | setverdict(fail, "Wrong OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST message received"); |
| 6045 | mtc.stop; |
| 6046 | } |
| 6047 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6048 | |
| 6049 | var GSUP_IeValue source_name_ie; |
| 6050 | f_gsup_find_ie(prep_ho_req, OSMO_GSUP_SOURCE_NAME_IE, source_name_ie); |
| 6051 | var octetstring local_msc_name := source_name_ie.source_name; |
| 6052 | |
Neels Hofmeyr | ec2e1f7 | 2021-07-02 02:08:32 +0200 | [diff] [blame] | 6053 | /* 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] | 6054 | var GSUP_IeValue an_apdu_ie; |
| 6055 | f_gsup_find_ie(prep_ho_req, OSMO_GSUP_AN_APDU_IE, an_apdu_ie); |
| 6056 | ho_request := dec_PDU_BSSAP(an_apdu_ie.an_apdu.pdu); |
Neels Hofmeyr | ec2e1f7 | 2021-07-02 02:08:32 +0200 | [diff] [blame] | 6057 | if (not match(ho_request, expect_ho_request)) { |
| 6058 | setverdict(fail, "Wrong PDU in OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST message received"); |
| 6059 | mtc.stop; |
| 6060 | } |
Neels Hofmeyr | 906af10 | 2021-07-01 12:08:35 +0200 | [diff] [blame] | 6061 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6062 | /* Remote MSC has figured out its BSC and signals success */ |
| 6063 | var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 6064 | var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd); |
| 6065 | 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] | 6066 | aoIPTransportLayer := omit, |
| 6067 | speechCodec := ts_BSSMAP_IE_SpeechCodec({ts_CodecFR}), |
| 6068 | chosenEncryptionAlgorithm := ho_request.pdu.bssmap.handoverRequest.chosenEncryptionAlgorithm)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6069 | GSUP.send(ts_GSUP_E_PrepareHandoverResult( |
| 6070 | pars.imsi, |
| 6071 | ho_number, |
| 6072 | remote_msc_name, local_msc_name, |
| 6073 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, enc_PDU_BSSAP(ho_req_ack))))); |
| 6074 | |
| 6075 | /* MSC forwards the RR Handover Command to old BSS */ |
| 6076 | BSSAP.receive(tr_BSSMAP_HandoverCommand); |
| 6077 | |
| 6078 | /* The MS shows up at remote new BSS */ |
| 6079 | |
| 6080 | GSUP.send(ts_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PROCESS_ACCESS_SIGNALLING_REQUEST, |
| 6081 | pars.imsi, remote_msc_name, local_msc_name, |
| 6082 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, |
| 6083 | enc_PDU_BSSAP(valueof(ts_BSSMAP_HandoverDetect)))))); |
| 6084 | BSSAP.receive(tr_BSSMAP_HandoverSucceeded); |
| 6085 | f_sleep(0.1); |
| 6086 | |
| 6087 | /* Save the MS sequence counters for use on the other connection */ |
| 6088 | var N_Sd_Array last_n_sd := f_bssmap_last_n_sd(); |
| 6089 | |
| 6090 | GSUP.send(ts_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_SEND_END_SIGNAL_REQUEST, |
| 6091 | pars.imsi, remote_msc_name, local_msc_name, |
| 6092 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, |
| 6093 | enc_PDU_BSSAP(valueof(ts_BSSMAP_HandoverComplete)))))); |
| 6094 | |
| 6095 | /* The local BSS conn clears, all communication goes via remote MSC now */ |
| 6096 | f_expect_clear(); |
| 6097 | |
| 6098 | /**********************************/ |
| 6099 | /* Play through some signalling across the inter-MSC link. |
| 6100 | * This is a copy of f_tc_lu_and_mo_ussd_single_request() translated into GSUP AN-APDUs. */ |
| 6101 | |
| 6102 | if (false) { |
| 6103 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 6104 | invoke_id := 5, /* Phone may not start from 0 or 1 */ |
| 6105 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 6106 | ussd_string := "*#100#" |
| 6107 | ); |
| 6108 | |
| 6109 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 6110 | invoke_id := 5, /* InvokeID shall be the same for both REQ and RSP */ |
| 6111 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 6112 | ussd_string := "Your extension is " & hex2str(g_pars.msisdn) & "\r" |
| 6113 | ) |
| 6114 | |
| 6115 | /* Compose a new SS/REGISTER message with request */ |
| 6116 | var template (value) PDU_ML3_MS_NW ussd_req := ts_ML3_MO_SS_REGISTER( |
| 6117 | tid := 1, /* We just need a single transaction */ |
| 6118 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 6119 | facility := valueof(facility_req) |
| 6120 | ); |
| 6121 | var PDU_ML3_MS_NW ussd_req_v := valueof(ussd_req); |
| 6122 | |
| 6123 | /* Compose SS/RELEASE_COMPLETE template with expected response */ |
| 6124 | var template PDU_ML3_NW_MS ussd_rsp := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 6125 | tid := 1, /* Response should arrive within the same transaction */ |
| 6126 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 6127 | facility := valueof(facility_rsp) |
| 6128 | ); |
| 6129 | |
| 6130 | /* Compose expected MSC -> HLR message */ |
| 6131 | var template GSUP_PDU gsup_req := tr_GSUP_PROC_SS_REQ( |
| 6132 | imsi := g_pars.imsi, |
| 6133 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 6134 | ss := valueof(facility_req) |
| 6135 | ); |
| 6136 | |
| 6137 | /* To be used for sending response with correct session ID */ |
| 6138 | var GSUP_PDU gsup_req_complete; |
| 6139 | |
| 6140 | /* Request own number */ |
| 6141 | /* From remote MSC instead of BSSAP directly */ |
| 6142 | /* Patch the correct N_SD value into the message. */ |
| 6143 | var octetstring l3_enc := enc_PDU_ML3_MS_NW(ussd_req_v); |
| 6144 | var RAN_Emulation.ConnectionData cd; |
| 6145 | f_ML3_patch_seq_nr_MS_NW(f_next_n_sd(last_n_sd, f_ML3_n_sd_idx(ussd_req_v)), l3_enc); |
| 6146 | GSUP.send(ts_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PROCESS_ACCESS_SIGNALLING_REQUEST, |
| 6147 | pars.imsi, remote_msc_name, local_msc_name, |
| 6148 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, |
| 6149 | enc_PDU_BSSAP(valueof(ts_BSSAP_DTAP(l3_enc))) |
| 6150 | )) |
| 6151 | )); |
| 6152 | |
| 6153 | /* Expect GSUP message containing the SS payload */ |
| 6154 | gsup_req_complete := f_expect_gsup_msg(gsup_req); |
| 6155 | |
| 6156 | /* Compose the response from HLR using received session ID */ |
| 6157 | var template GSUP_PDU gsup_rsp := ts_GSUP_PROC_SS_REQ( |
| 6158 | imsi := g_pars.imsi, |
| 6159 | sid := gsup_req_complete.ies[1].val.session_id, |
| 6160 | state := OSMO_GSUP_SESSION_STATE_END, |
| 6161 | ss := valueof(facility_rsp) |
| 6162 | ); |
| 6163 | |
| 6164 | /* Finally, HLR terminates the session */ |
| 6165 | GSUP.send(gsup_rsp); |
| 6166 | |
| 6167 | /* The USSD response goes out to remote MSC, on GSUP E instead of BSSAP */ |
| 6168 | var GSUP_PDU gsup_ussd_rsp; |
| 6169 | GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_FORWARD_ACCESS_SIGNALLING_REQUEST, |
| 6170 | pars.imsi, destination_name := remote_msc_name)) -> value gsup_ussd_rsp; |
| 6171 | |
| 6172 | var GSUP_IeValue an_apdu; |
| 6173 | if (not f_gsup_find_ie(gsup_ussd_rsp, OSMO_GSUP_AN_APDU_IE, an_apdu)) { |
| 6174 | setverdict(fail, "No AN-APDU in received GSUP message. Expected USSD response in DTAP, got", gsup_ussd_rsp); |
| 6175 | mtc.stop; |
| 6176 | } |
| 6177 | var PDU_BSSAP bssap_dtap_mt := dec_PDU_BSSAP(an_apdu.an_apdu.pdu); |
| 6178 | var PDU_ML3_NW_MS dtap_mt := dec_PDU_ML3_NW_MS(bssap_dtap_mt.pdu.dtap); |
| 6179 | log("Expecting", ussd_rsp); |
| 6180 | log("Got", dtap_mt); |
| 6181 | if (not match(dtap_mt, ussd_rsp)) { |
| 6182 | setverdict(fail, "Unexpected GSUP message. Expected USSD response in DTAP, got", gsup_ussd_rsp); |
| 6183 | mtc.stop; |
| 6184 | } |
| 6185 | } |
| 6186 | /**********************************/ |
| 6187 | |
| 6188 | |
| 6189 | /* inter-MSC handover back to the first MSC */ |
| 6190 | f_create_bssmap_exp_handoverRequest(193); |
| 6191 | cil := { cIl_CGI := { ts_BSSMAP_CI_CGI('262'H, '42'H, 23, 42) } }; |
| 6192 | |
| 6193 | /* old BSS sends Handover Required, via inter-MSC E link: like |
| 6194 | * BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 6195 | * but via GSUP */ |
| 6196 | GSUP.send(ts_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_REQUEST, |
| 6197 | pars.imsi, remote_msc_name, local_msc_name, |
| 6198 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, |
| 6199 | enc_PDU_BSSAP(valueof(ts_BSSMAP_HandoverRequired(cause, cil))) |
| 6200 | )) |
| 6201 | )); |
| 6202 | |
| 6203 | /* MSC asks local BSS to prepare Handover to it */ |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6204 | f_get_expected_encryption(encryptionInformation, chosenEncryptionAlgorithm, kC128, a5_perm_alg); |
| 6205 | expect_ho_request := tr_BSSMAP_HandoverRequest(encryptionInformation, chosenEncryptionAlgorithm, kC128); |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6206 | alt { |
Neels Hofmeyr | 906af10 | 2021-07-01 12:08:35 +0200 | [diff] [blame] | 6207 | [] BSSAP.receive(expect_ho_request) -> value ho_request; |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6208 | [] BSSAP.receive(tr_BSSMAP_HandoverRequest) -> value ho_request { |
| 6209 | log("Error: Wrong handoverRequest received. Expected: ", expect_ho_request, |
| 6210 | " got ", ho_request); |
| 6211 | setverdict(fail, "Wrong handoverRequest received"); |
| 6212 | mtc.stop; |
| 6213 | } |
| 6214 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6215 | |
| 6216 | /* Make sure the new BSSAP conn continues with the correct N_SD sequence numbers */ |
| 6217 | f_bssmap_continue_after_n_sd(last_n_sd); |
| 6218 | |
| 6219 | /* new BSS composes a RR Handover Command */ |
| 6220 | rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 6221 | 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] | 6222 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := |
| 6223 | 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] | 6224 | 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] | 6225 | tla, ts_BSSMAP_IE_SpeechCodec({ts_CodecFR}), |
| 6226 | chosenEncryptionAlgorithm := ho_request.pdu.bssmap.handoverRequest.chosenEncryptionAlgorithm)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6227 | |
| 6228 | /* HandoverCommand goes out via remote MSC-I */ |
| 6229 | var GSUP_PDU prep_subsq_ho_res; |
| 6230 | GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_RESULT, |
| 6231 | pars.imsi, destination_name := remote_msc_name)) -> value prep_subsq_ho_res; |
| 6232 | |
| 6233 | /* MS shows up at the local BSS */ |
| 6234 | BSSAP.send(ts_BSSMAP_HandoverDetect); |
| 6235 | f_sleep(0.1); |
| 6236 | BSSAP.send(ts_BSSMAP_HandoverComplete); |
| 6237 | |
| 6238 | /* Handover Succeeded message */ |
| 6239 | GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_FORWARD_ACCESS_SIGNALLING_REQUEST, |
| 6240 | pars.imsi, destination_name := remote_msc_name)); |
| 6241 | |
| 6242 | /* MS has handovered to here, Clear Command goes out via remote MSC-I -- in form of a GSUP Close. */ |
| 6243 | GSUP.receive(tr_GSUP_E_NO_PDU(OSMO_GSUP_MSGT_E_CLOSE, |
| 6244 | pars.imsi, destination_name := remote_msc_name)); |
| 6245 | |
| 6246 | /* Handover ends successfully. Call goes on for a little longer and then we hang up. */ |
| 6247 | |
| 6248 | f_sleep(1.0); |
| 6249 | deactivate(ack_mdcx); |
| 6250 | |
| 6251 | /* FIXME: the inter-MSC call has put a number of MNCC messages in the queue, which above code should expect and |
| 6252 | * clear out. The f_call_hangup() expects an MNCC_REL_IND, so, for the time being, just clear the MNCC messages |
| 6253 | * before starting the call hangup. Instead of this, the individual messages should be tested for above. */ |
| 6254 | MNCC.clear; |
| 6255 | |
| 6256 | var default ccrel := activate(as_optional_cc_rel(cpars, true)); |
| 6257 | f_call_hangup(cpars, true); |
| 6258 | f_sleep(1.0); |
| 6259 | deactivate(ccrel); |
| 6260 | |
| 6261 | setverdict(pass); |
| 6262 | } |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6263 | 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] | 6264 | var BSC_ConnHdlr vc_conn; |
| 6265 | f_init(1); |
| 6266 | |
| 6267 | var BSC_ConnHdlrPars pars := f_init_pars(54); |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6268 | pars.net.expect_ciph := a5_n > 0; |
| 6269 | pars.net.expect_auth := pars.net.expect_ciph; |
| 6270 | pars.net.kc_support := bit2oct('00000001'B << a5_n); |
| 6271 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '1'B; |
| 6272 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '0'B; |
| 6273 | pars.cm2.classmarkInformationType2_oct5.cm3 := '1'B; |
| 6274 | pars.cm3 := valueof(ts_CM3_default); |
| 6275 | pars.use_umts_aka := true; |
| 6276 | |
| 6277 | if (a5_n > 0) { |
| 6278 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6279 | } |
| 6280 | f_vty_config(MSCVTY, "network", "encryption a5 " & int2str(a5_n)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6281 | |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 6282 | 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] | 6283 | vc_conn.done; |
| 6284 | } |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6285 | testcase TC_ho_inter_msc_out() runs on MTC_CT { |
| 6286 | f_tc_ho_inter_msc_out_a5(0); |
| 6287 | } |
| 6288 | testcase TC_ho_inter_msc_out_a5_1() runs on MTC_CT { |
| 6289 | f_tc_ho_inter_msc_out_a5(1); |
| 6290 | } |
| 6291 | testcase TC_ho_inter_msc_out_a5_3() runs on MTC_CT { |
| 6292 | f_tc_ho_inter_msc_out_a5(3); |
| 6293 | } |
| 6294 | testcase TC_ho_inter_msc_out_a5_4() runs on MTC_CT { |
| 6295 | f_tc_ho_inter_msc_out_a5(4); |
| 6296 | } |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 6297 | testcase TC_ho_inter_msc_out_ipv6() runs on MTC_CT { |
| 6298 | var BSC_ConnHdlr vc_conn; |
| 6299 | f_init(1); |
| 6300 | |
| 6301 | var BSC_ConnHdlrPars pars := f_init_pars(54); |
| 6302 | pars.use_ipv6 := true; |
| 6303 | |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 6304 | 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] | 6305 | vc_conn.done; |
| 6306 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6307 | |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6308 | private function f_tc_lu_imsi_auth_tmsi_check_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6309 | pars.net.expect_auth := true; |
| 6310 | pars.net.expect_imei := true; |
| 6311 | f_init_handler(pars); |
| 6312 | f_perform_lu(); |
| 6313 | } |
| 6314 | testcase TC_lu_imsi_auth_tmsi_check_imei() runs on MTC_CT { |
| 6315 | var BSC_ConnHdlr vc_conn; |
| 6316 | f_init(); |
| 6317 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6318 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6319 | |
| 6320 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei), 5); |
| 6321 | vc_conn.done; |
| 6322 | } |
| 6323 | |
| 6324 | private function f_tc_lu_imsi_auth3g_tmsi_check_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6325 | pars.net.expect_auth := true; |
| 6326 | pars.use_umts_aka := true; |
| 6327 | pars.net.expect_imei := true; |
| 6328 | f_init_handler(pars); |
| 6329 | f_perform_lu(); |
| 6330 | } |
| 6331 | testcase TC_lu_imsi_auth3g_tmsi_check_imei() runs on MTC_CT { |
| 6332 | var BSC_ConnHdlr vc_conn; |
| 6333 | f_init(); |
| 6334 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6335 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6336 | |
| 6337 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth3g_tmsi_check_imei), 5); |
| 6338 | vc_conn.done; |
| 6339 | } |
| 6340 | |
| 6341 | private function f_tc_lu_imsi_noauth_tmsi_check_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6342 | pars.net.expect_imei := true; |
| 6343 | f_init_handler(pars); |
| 6344 | f_perform_lu(); |
| 6345 | } |
| 6346 | testcase TC_lu_imsi_noauth_tmsi_check_imei() runs on MTC_CT { |
| 6347 | var BSC_ConnHdlr vc_conn; |
| 6348 | f_init(); |
| 6349 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6350 | |
| 6351 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_tmsi_check_imei), 5); |
| 6352 | vc_conn.done; |
| 6353 | } |
| 6354 | |
| 6355 | private function f_tc_lu_imsi_noauth_notmsi_check_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6356 | pars.net.expect_tmsi := false; |
| 6357 | pars.net.expect_imei := true; |
| 6358 | f_init_handler(pars); |
| 6359 | f_perform_lu(); |
| 6360 | } |
| 6361 | testcase TC_lu_imsi_noauth_notmsi_check_imei() runs on MTC_CT { |
| 6362 | var BSC_ConnHdlr vc_conn; |
| 6363 | f_init(); |
| 6364 | f_vty_config(MSCVTY, "msc", "no assign-tmsi"); |
| 6365 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6366 | |
| 6367 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_notmsi_check_imei), 5); |
| 6368 | vc_conn.done; |
| 6369 | } |
| 6370 | |
| 6371 | private function f_tc_lu_imsi_auth_tmsi_check_imei_nack(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6372 | var PDU_ML3_MS_NW l3_lu; |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6373 | |
| 6374 | pars.net.expect_auth := true; |
| 6375 | pars.net.expect_imei := true; |
| 6376 | pars.net.check_imei_result := OSMO_GSUP_IMEI_RESULT_NACK; |
| 6377 | f_init_handler(pars); |
| 6378 | |
| 6379 | /* Cannot use f_perform_lu() as we expect a reject */ |
| 6380 | l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 6381 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6382 | f_bssap_compl_l3(l3_lu); |
| 6383 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 6384 | |
| 6385 | f_mm_common(); |
| 6386 | f_msc_lu_hlr(); |
| 6387 | f_mm_imei(); |
Oliver Smith | 91bfa1c | 2019-07-19 15:01:15 +0200 | [diff] [blame] | 6388 | f_expect_lu_reject(); |
Oliver Smith | 690d60f | 2019-07-23 13:09:08 +0200 | [diff] [blame] | 6389 | f_expect_clear(); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6390 | } |
| 6391 | testcase TC_lu_imsi_auth_tmsi_check_imei_nack() runs on MTC_CT { |
| 6392 | var BSC_ConnHdlr vc_conn; |
| 6393 | f_init(); |
| 6394 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6395 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6396 | |
| 6397 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_nack), 5); |
| 6398 | vc_conn.done; |
| 6399 | } |
| 6400 | |
| 6401 | private function f_tc_lu_imsi_auth_tmsi_check_imei_err(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6402 | var PDU_ML3_MS_NW l3_lu; |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6403 | |
| 6404 | pars.net.expect_auth := true; |
| 6405 | pars.net.expect_imei := true; |
| 6406 | pars.net.check_imei_error := true; |
| 6407 | f_init_handler(pars); |
| 6408 | |
| 6409 | /* Cannot use f_perform_lu() as we expect a reject */ |
| 6410 | l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 6411 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6412 | f_bssap_compl_l3(l3_lu); |
| 6413 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 6414 | |
| 6415 | f_mm_common(); |
| 6416 | f_msc_lu_hlr(); |
| 6417 | f_mm_imei(); |
Oliver Smith | 91bfa1c | 2019-07-19 15:01:15 +0200 | [diff] [blame] | 6418 | f_expect_lu_reject(); |
Oliver Smith | 690d60f | 2019-07-23 13:09:08 +0200 | [diff] [blame] | 6419 | f_expect_clear(); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6420 | } |
| 6421 | testcase TC_lu_imsi_auth_tmsi_check_imei_err() runs on MTC_CT { |
| 6422 | var BSC_ConnHdlr vc_conn; |
| 6423 | f_init(); |
| 6424 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6425 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6426 | |
| 6427 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_err), 5); |
| 6428 | vc_conn.done; |
| 6429 | } |
| 6430 | |
| 6431 | private function f_tc_lu_imsi_auth_tmsi_check_imei_early(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6432 | pars.net.expect_auth := true; |
| 6433 | pars.net.expect_imei_early := true; |
| 6434 | f_init_handler(pars); |
| 6435 | f_perform_lu(); |
| 6436 | } |
| 6437 | testcase TC_lu_imsi_auth_tmsi_check_imei_early() runs on MTC_CT { |
| 6438 | var BSC_ConnHdlr vc_conn; |
| 6439 | f_init(); |
| 6440 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6441 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6442 | |
| 6443 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_early), 5); |
| 6444 | vc_conn.done; |
| 6445 | } |
| 6446 | |
| 6447 | private function f_tc_lu_imsi_auth3g_tmsi_check_imei_early(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6448 | pars.net.expect_auth := true; |
| 6449 | pars.use_umts_aka := true; |
| 6450 | pars.net.expect_imei_early := true; |
| 6451 | f_init_handler(pars); |
| 6452 | f_perform_lu(); |
| 6453 | } |
| 6454 | testcase TC_lu_imsi_auth3g_tmsi_check_imei_early() 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 early"); |
| 6459 | |
| 6460 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth3g_tmsi_check_imei_early), 5); |
| 6461 | vc_conn.done; |
| 6462 | } |
| 6463 | |
| 6464 | private function f_tc_lu_imsi_noauth_tmsi_check_imei_early(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6465 | pars.net.expect_imei_early := true; |
| 6466 | f_init_handler(pars); |
| 6467 | f_perform_lu(); |
| 6468 | } |
| 6469 | testcase TC_lu_imsi_noauth_tmsi_check_imei_early() runs on MTC_CT { |
| 6470 | var BSC_ConnHdlr vc_conn; |
| 6471 | f_init(); |
| 6472 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6473 | |
| 6474 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_tmsi_check_imei_early), 5); |
| 6475 | vc_conn.done; |
| 6476 | } |
| 6477 | |
| 6478 | private function f_tc_lu_imsi_noauth_notmsi_check_imei_early(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6479 | pars.net.expect_tmsi := false; |
| 6480 | pars.net.expect_imei_early := true; |
| 6481 | f_init_handler(pars); |
| 6482 | f_perform_lu(); |
| 6483 | } |
| 6484 | testcase TC_lu_imsi_noauth_notmsi_check_imei_early() runs on MTC_CT { |
| 6485 | var BSC_ConnHdlr vc_conn; |
| 6486 | f_init(); |
| 6487 | f_vty_config(MSCVTY, "msc", "no assign-tmsi"); |
| 6488 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6489 | |
| 6490 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_notmsi_check_imei_early), 5); |
| 6491 | vc_conn.done; |
| 6492 | } |
| 6493 | |
| 6494 | private function f_tc_lu_imsi_auth_tmsi_check_imei_early_nack(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6495 | var PDU_ML3_MS_NW l3_lu; |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6496 | |
| 6497 | pars.net.expect_auth := true; |
| 6498 | pars.net.expect_imei_early := true; |
| 6499 | pars.net.check_imei_result := OSMO_GSUP_IMEI_RESULT_NACK; |
| 6500 | f_init_handler(pars); |
| 6501 | |
| 6502 | /* Cannot use f_perform_lu() as we expect a reject */ |
| 6503 | l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 6504 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6505 | f_bssap_compl_l3(l3_lu); |
| 6506 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 6507 | |
| 6508 | f_mm_imei_early(); |
Oliver Smith | 91bfa1c | 2019-07-19 15:01:15 +0200 | [diff] [blame] | 6509 | f_expect_lu_reject(); |
Oliver Smith | 690d60f | 2019-07-23 13:09:08 +0200 | [diff] [blame] | 6510 | f_expect_clear(); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6511 | } |
| 6512 | testcase TC_lu_imsi_auth_tmsi_check_imei_early_nack() runs on MTC_CT { |
| 6513 | var BSC_ConnHdlr vc_conn; |
| 6514 | f_init(); |
| 6515 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6516 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6517 | |
| 6518 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_early_nack), 5); |
| 6519 | vc_conn.done; |
| 6520 | } |
| 6521 | |
| 6522 | private function f_tc_lu_imsi_auth_tmsi_check_imei_early_err(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6523 | var PDU_ML3_MS_NW l3_lu; |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6524 | |
| 6525 | pars.net.expect_auth := true; |
| 6526 | pars.net.expect_imei_early := true; |
| 6527 | pars.net.check_imei_error := true; |
| 6528 | f_init_handler(pars); |
| 6529 | |
| 6530 | /* Cannot use f_perform_lu() as we expect a reject */ |
| 6531 | l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 6532 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6533 | f_bssap_compl_l3(l3_lu); |
| 6534 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 6535 | |
| 6536 | f_mm_imei_early(); |
Oliver Smith | 91bfa1c | 2019-07-19 15:01:15 +0200 | [diff] [blame] | 6537 | f_expect_lu_reject(); |
Oliver Smith | 690d60f | 2019-07-23 13:09:08 +0200 | [diff] [blame] | 6538 | f_expect_clear(); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6539 | } |
| 6540 | testcase TC_lu_imsi_auth_tmsi_check_imei_early_err() runs on MTC_CT { |
| 6541 | var BSC_ConnHdlr vc_conn; |
| 6542 | f_init(); |
| 6543 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6544 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6545 | |
| 6546 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_early_err), 5); |
| 6547 | vc_conn.done; |
| 6548 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6549 | |
Neels Hofmeyr | 8df6962 | 2019-11-02 19:16:03 +0100 | [diff] [blame] | 6550 | friend function f_tc_invalid_mgcp_crash(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6551 | f_init_handler(pars); |
| 6552 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 6553 | |
| 6554 | /* Set invalid IP address so that osmo-msc discards the rtp_stream and MGCP endpoint FSM instances in the middle |
| 6555 | * of successful MGCP response dispatch. If things aren't safeguarded, the on_success() in osmo_mgcpc_ep_fsm |
| 6556 | * will cause a use-after-free after that event dispatch. */ |
| 6557 | cpars.mgw_conn_1.mgw_rtp_ip := "0.0.0.0"; |
| 6558 | cpars.mgw_conn_2.mgw_rtp_ip := "0.0.0.0"; |
| 6559 | cpars.rtp_sdp_format := "FOO/8000"; |
| 6560 | cpars.expect_release := true; |
| 6561 | |
| 6562 | f_perform_lu(); |
| 6563 | f_mo_call_establish(cpars); |
| 6564 | } |
| 6565 | testcase TC_invalid_mgcp_crash() runs on MTC_CT { |
| 6566 | var BSC_ConnHdlr vc_conn; |
| 6567 | f_init(); |
| 6568 | |
| 6569 | vc_conn := f_start_handler(refers(f_tc_invalid_mgcp_crash), 7); |
| 6570 | vc_conn.done; |
| 6571 | } |
| 6572 | |
Vadim Yanitskiy | eddebaa | 2019-12-28 17:45:34 +0100 | [diff] [blame] | 6573 | friend function f_tc_mm_id_resp_no_identity(charstring id, BSC_ConnHdlrPars pars) |
| 6574 | runs on BSC_ConnHdlr { |
| 6575 | pars.tmsi := 'FFFFFFFF'O; |
| 6576 | f_init_handler(pars); |
| 6577 | |
| 6578 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6579 | |
| 6580 | /* Initiate Location Updating using an unknown TMSI */ |
| 6581 | f_bssap_compl_l3(f_build_lu_tmsi(pars.tmsi)); |
| 6582 | |
| 6583 | /* Expect an Identity Request, send response with no identity */ |
| 6584 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req(CM_ID_TYPE_IMSI))); |
| 6585 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp({ |
| 6586 | lengthIndicator := 1, |
| 6587 | mobileIdentityV := { |
| 6588 | typeOfIdentity := '000'B, |
| 6589 | oddEvenInd_identity := { |
| 6590 | no_identity := { |
| 6591 | oddevenIndicator := '0'B, |
| 6592 | fillerDigits := '00000'H |
| 6593 | } |
| 6594 | } |
| 6595 | } |
| 6596 | }))); |
| 6597 | |
| 6598 | f_expect_lu_reject(); |
| 6599 | f_expect_clear(); |
| 6600 | } |
| 6601 | testcase TC_mm_id_resp_no_identity() runs on MTC_CT { |
| 6602 | var BSC_ConnHdlr vc_conn; |
| 6603 | |
| 6604 | f_init(); |
| 6605 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 6606 | 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] | 6607 | vc_conn.done; |
| 6608 | } |
| 6609 | |
Vadim Yanitskiy | 2521906 | 2020-01-21 01:41:33 +0700 | [diff] [blame] | 6610 | /* Verify the case when T3212 expires during Paging procedure, just before the receipt |
| 6611 | * of Paging Response. This used to provoke a NULL-pointer dereference in old versions |
| 6612 | * of OsmoMSC, but apparently the bug has been fixed, and we're safe now. */ |
| 6613 | friend function f_tc_lu_and_expire_while_paging(charstring id, BSC_ConnHdlrPars pars) |
| 6614 | runs on BSC_ConnHdlr { |
| 6615 | var charstring imsi := hex2str(pars.imsi); |
| 6616 | |
| 6617 | f_init_handler(pars); |
| 6618 | |
| 6619 | /* Perform location update */ |
| 6620 | f_perform_lu(); |
| 6621 | |
| 6622 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
| 6623 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6624 | |
| 6625 | /* Initiate paging procedure from the VTY */ |
| 6626 | f_vty_transceive(MSCVTY, "subscriber imsi " & imsi & " paging"); |
| 6627 | f_expect_paging(); |
| 6628 | |
| 6629 | /* Emulate T3212 expiration during paging (we don't want to wait, right?) */ |
| 6630 | f_vty_transceive(MSCVTY, "subscriber imsi " & imsi & " expire"); |
| 6631 | |
| 6632 | /* MS sends PAGING RESPONSE, *old* OsmoMSC crashes here... */ |
| 6633 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 6634 | |
| 6635 | /* The recent OsmoMSC keeps subscriber in its VLR unless the Paging is completed. |
| 6636 | * 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] | 6637 | f_expect_clear(verify_vlr_cell_id := false); |
Vadim Yanitskiy | 2521906 | 2020-01-21 01:41:33 +0700 | [diff] [blame] | 6638 | } |
| 6639 | testcase TC_lu_and_expire_while_paging() runs on MTC_CT { |
| 6640 | var BSC_ConnHdlr vc_conn; |
| 6641 | |
| 6642 | f_init(); |
| 6643 | |
| 6644 | vc_conn := f_start_handler(refers(f_tc_lu_and_expire_while_paging), 7); |
| 6645 | vc_conn.done; |
| 6646 | } |
| 6647 | |
Neels Hofmeyr | 4f099b4 | 2021-07-27 03:45:26 +0200 | [diff] [blame] | 6648 | const charstring REEST_LOST_CONNECTION := "REEST_LOST_CONNECTION"; |
| 6649 | const charstring REEST_CLEARED := "REEST_CLEARED"; |
| 6650 | |
| 6651 | friend function f_tc_call_re_establishment_1(charstring id, BSC_ConnHdlrPars pars) |
| 6652 | runs on BSC_ConnHdlr { |
| 6653 | f_init_handler(pars, t_guard := 30.0); |
| 6654 | |
| 6655 | f_perform_lu(); |
| 6656 | |
| 6657 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 6658 | f_mo_call_establish(cpars); |
| 6659 | f_sleep(3.0); |
| 6660 | COORD.send(REEST_LOST_CONNECTION); |
| 6661 | COORD.send(cpars); |
| 6662 | f_expect_clear(verify_vlr_cell_id := false); |
| 6663 | COORD.send(REEST_CLEARED); |
| 6664 | } |
| 6665 | |
| 6666 | friend function f_tc_call_re_establishment_2(charstring id, BSC_ConnHdlrPars pars) |
| 6667 | runs on BSC_ConnHdlr { |
| 6668 | f_init_handler(pars, t_guard := 30.0); |
| 6669 | var CallParameters cpars; |
| 6670 | |
| 6671 | COORD.receive(REEST_LOST_CONNECTION); |
| 6672 | COORD.receive(tr_CallParams) -> value cpars; |
| 6673 | |
| 6674 | f_gsup_change_connhdlr(hex2str(g_pars.imsi)); |
| 6675 | f_create_smpp_expect(hex2str(pars.msisdn)); |
| 6676 | |
| 6677 | /* The MS has lost the first channel and decides to show up on a new conn (on a nearby neighbor cell) to ask for |
| 6678 | * CM Re-Establishment. Send a Complete Layer 3 to osmo-msc with a CM Re-Establishment Request. */ |
| 6679 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 6680 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_REESTABL_REQ(mi)); |
| 6681 | f_cl3_or_initial_ue(l3_info); |
| 6682 | |
| 6683 | /* At this point the other test component should receive the Clear Command for the first A connection. */ |
| 6684 | |
| 6685 | /* This new connection continues with Authentication... */ |
| 6686 | f_mm_common(); |
| 6687 | |
| 6688 | /* ...and with Assignment of a voice channel. */ |
| 6689 | var template BSSMAP_IE_AoIP_TransportLayerAddress tla_ass := |
| 6690 | f_tr_BSSMAP_IE_AoIP_TLA(cpars.mgw_conn_1.mgw_rtp_ip, ?); |
| 6691 | BSSAP.receive(tr_BSSMAP_AssignmentReq(omit, tla_ass)); |
| 6692 | /* By this Assignment Request, the CM Re-Establishment Request is implicitly accepted. */ |
| 6693 | |
| 6694 | /* Send Assignment Complete from BSC */ |
| 6695 | var template BSSMAP_IE_AoIP_TransportLayerAddress tla; |
| 6696 | tla := f_ts_BSSMAP_IE_AoIP_TLA(cpars.bss_rtp_ip, cpars.bss_rtp_port); |
| 6697 | var BSSMAP_IE_SpeechCodec codec; |
| 6698 | codec := valueof(ts_BSSMAP_IE_SpeechCodec({ts_CodecFR})); |
| 6699 | |
| 6700 | /* Make really sure the other component is done with its MGCP */ |
| 6701 | COORD.receive(REEST_CLEARED); |
| 6702 | |
| 6703 | /* Transfer state for this call over to this test component so we can resolve MNCC and MGCP in this function. */ |
| 6704 | f_mncc_change_connhdlr(cpars.mncc_callref); |
| 6705 | f_mgcp_change_connhdlr(cpars.mgcp_ep); |
| 6706 | |
| 6707 | /* osmo-msc may redirect the MGW endpoint to the newly allocated channel. |
| 6708 | * Apparently osmo-msc currently also sends an MDCX to the CN side, just repeating the same configuration that |
| 6709 | * is already in use. This test accepts any number of or even lack of MDCX. */ |
| 6710 | var default ack_mdcx := activate(as_mgcp_ack_all_mdcx(cpars)); |
| 6711 | |
| 6712 | BSSAP.send(ts_BSSMAP_AssignmentComplete(omit, tla, codec)); |
| 6713 | /* The call has been fully re-established. |
| 6714 | * Let a bit of time pass before hanging up, for everything to settle. */ |
| 6715 | f_sleep(3.0); |
| 6716 | |
| 6717 | deactivate(ack_mdcx); |
| 6718 | |
| 6719 | /* Hang up the call and clear the new, second A connection */ |
| 6720 | var default ack_dlcx := activate(as_mgcp_ack_all_dlcx(cpars)); |
| 6721 | |
| 6722 | /* CC release. This is the proper MS initiated release sequence as shown by |
| 6723 | * https://git.osmocom.org/osmo-msc/tree/doc/sequence_charts/voice_call_full.msc?id=e53ecde83e4fb2470209e818e9ad76a2d6a19190 |
| 6724 | * f_call_hangup() seems a bit mixed up, so here a "proper" sequence. Fix of f_call_hangup() pending. */ |
| 6725 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_DISC(cpars.transaction_id, '0'B, '0000000'B))); |
| 6726 | MNCC.receive(tr_MNCC_DISC_ind(cpars.mncc_callref)); |
| 6727 | MNCC.send(ts_MNCC_REL_req(cpars.mncc_callref, valueof(ts_MNCC_cause(23)))); |
| 6728 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))); |
| 6729 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_REL_COMPL(cpars.transaction_id, '0'B))); |
| 6730 | MNCC.receive(tr_MNCC_REL_cnf(cpars.mncc_callref, cause := *)); |
| 6731 | |
| 6732 | /* BSSAP clear */ |
| 6733 | interleave { |
| 6734 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 6735 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 6736 | } |
| 6737 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 6738 | } |
| 6739 | |
| 6740 | f_sleep(1.0); |
| 6741 | deactivate(ack_dlcx); |
| 6742 | } |
| 6743 | |
| 6744 | testcase TC_call_re_establishment() runs on MTC_CT { |
| 6745 | var BSC_ConnHdlr vc_conn1; |
| 6746 | var BSC_ConnHdlr vc_conn2; |
| 6747 | f_init(); |
| 6748 | |
| 6749 | var BSC_ConnHdlrPars pars1 := f_init_pars(91); |
| 6750 | var BSC_ConnHdlrPars pars2 := pars1; |
| 6751 | |
| 6752 | vc_conn1 := f_start_handler_create(pars1); |
| 6753 | vc_conn2 := f_start_handler_create(pars2); |
| 6754 | connect(vc_conn1:COORD, vc_conn2:COORD); |
| 6755 | f_start_handler_run(vc_conn1, refers(f_tc_call_re_establishment_1), pars1); |
| 6756 | f_start_handler_run(vc_conn2, refers(f_tc_call_re_establishment_2), pars2); |
| 6757 | vc_conn1.done; |
| 6758 | vc_conn2.done; |
| 6759 | } |
| 6760 | |
Neels Hofmeyr | a9b2dcf | 2021-07-28 00:57:58 +0200 | [diff] [blame] | 6761 | testcase TC_call_re_establishment_auth() runs on MTC_CT { |
| 6762 | var BSC_ConnHdlr vc_conn1; |
| 6763 | var BSC_ConnHdlr vc_conn2; |
| 6764 | f_init(); |
| 6765 | |
| 6766 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6767 | |
| 6768 | var BSC_ConnHdlrPars pars1 := f_init_pars(92); |
| 6769 | pars1.net.expect_auth := true; |
| 6770 | var BSC_ConnHdlrPars pars2 := pars1; |
| 6771 | |
| 6772 | vc_conn1 := f_start_handler_create(pars1); |
| 6773 | vc_conn2 := f_start_handler_create(pars2); |
| 6774 | connect(vc_conn1:COORD, vc_conn2:COORD); |
| 6775 | f_start_handler_run(vc_conn1, refers(f_tc_call_re_establishment_1), pars1); |
| 6776 | f_start_handler_run(vc_conn2, refers(f_tc_call_re_establishment_2), pars2); |
| 6777 | vc_conn1.done; |
| 6778 | vc_conn2.done; |
| 6779 | } |
| 6780 | |
Neels Hofmeyr | 48e4d7d | 2021-07-28 00:57:58 +0200 | [diff] [blame] | 6781 | testcase TC_call_re_establishment_ciph() runs on MTC_CT { |
| 6782 | var BSC_ConnHdlr vc_conn1; |
| 6783 | var BSC_ConnHdlr vc_conn2; |
| 6784 | f_init(); |
| 6785 | |
| 6786 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6787 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 6788 | |
| 6789 | var BSC_ConnHdlrPars pars1 := f_init_pars(92); |
| 6790 | pars1.net.expect_auth := true; |
| 6791 | pars1.net.expect_ciph := true; |
| 6792 | pars1.net.kc_support := '08'O; /* A5/3 only */ |
| 6793 | var BSC_ConnHdlrPars pars2 := pars1; |
| 6794 | |
| 6795 | vc_conn1 := f_start_handler_create(pars1); |
| 6796 | vc_conn2 := f_start_handler_create(pars2); |
| 6797 | connect(vc_conn1:COORD, vc_conn2:COORD); |
| 6798 | f_start_handler_run(vc_conn1, refers(f_tc_call_re_establishment_1), pars1); |
| 6799 | f_start_handler_run(vc_conn2, refers(f_tc_call_re_establishment_2), pars2); |
| 6800 | vc_conn1.done; |
| 6801 | vc_conn2.done; |
| 6802 | } |
| 6803 | |
Neels Hofmeyr | 07ea7f2 | 2022-05-05 01:39:26 +0200 | [diff] [blame] | 6804 | /* Establish a conn with a valid Mobile Identity. Then send a CM Service Request containing a mismatching Mobile |
| 6805 | * Identity on the same conn. Caused a crash, see OS#5532. */ |
| 6806 | friend function f_tc_cm_serv_wrong_mi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6807 | f_init_handler(pars); |
| 6808 | |
| 6809 | /* Set up a fully identified conn */ |
| 6810 | f_perform_lu(); |
| 6811 | f_establish_fully(); |
| 6812 | |
| 6813 | /* CM Serv Req with mismatching Mobile Identity */ |
| 6814 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(99999))); /* ensure it is different from below*/ |
| 6815 | BSSAP.send(ts_PDU_DTAP_MO(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, mi))); |
| 6816 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)); |
| 6817 | |
| 6818 | /* Cancel the first CM Service from f_establish_fully() */ |
| 6819 | BSSAP.send(ts_BSSMAP_ClearRequest(0)); |
| 6820 | |
| 6821 | f_expect_clear(); |
| 6822 | } |
| 6823 | testcase TC_cm_serv_wrong_mi() runs on MTC_CT { |
| 6824 | var BSC_ConnHdlr vc_conn; |
| 6825 | f_init(); |
| 6826 | vc_conn := f_start_handler(refers(f_tc_cm_serv_wrong_mi), 94); |
| 6827 | vc_conn.done; |
| 6828 | } |
| 6829 | |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 6830 | control { |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 6831 | execute( TC_cr_before_reset() ); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 6832 | execute( TC_lu_imsi_noauth_tmsi() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 6833 | execute( TC_lu_imsi_noauth_notmsi() ); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 6834 | execute( TC_lu_imsi_reject() ); |
| 6835 | execute( TC_lu_imsi_timeout_gsup() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 6836 | execute( TC_lu_imsi_auth_tmsi() ); |
Harald Welte | 8a397ae | 2019-04-21 22:03:37 +0200 | [diff] [blame] | 6837 | execute( TC_lu_imsi_auth3g_tmsi() ); |
Pau Espin Pedrol | d3d54a9 | 2019-12-17 17:02:54 +0100 | [diff] [blame] | 6838 | execute( TC_lu_imsi_timeout_tmsi_realloc() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 6839 | execute( TC_cmserv_imsi_unknown() ); |
Neels Hofmeyr | 13737fb | 2020-08-19 13:16:14 +0000 | [diff] [blame] | 6840 | execute( TC_cmserv_tmsi_unknown() ); |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 6841 | execute( TC_lu_and_mo_call() ); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 6842 | execute( TC_lu_and_mo_call_ipv6() ); |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 6843 | execute( TC_lu_and_mo_call_sccp_tiar_timeout() ); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 6844 | execute( TC_lu_auth_sai_timeout() ); |
| 6845 | execute( TC_lu_auth_sai_err() ); |
Harald Welte | e1a2f3c | 2018-01-24 17:28:48 +0100 | [diff] [blame] | 6846 | execute( TC_lu_clear_request() ); |
Vadim Yanitskiy | 109e755 | 2021-02-05 05:36:02 +0100 | [diff] [blame] | 6847 | execute( TC_mo_call_clear_request() ); |
| 6848 | execute( TC_mt_call_clear_request() ); |
Harald Welte | e1a2f3c | 2018-01-24 17:28:48 +0100 | [diff] [blame] | 6849 | execute( TC_lu_disconnect() ); |
| 6850 | execute( TC_lu_by_imei() ); |
| 6851 | execute( TC_lu_by_tmsi_noauth_unknown() ); |
Neels Hofmeyr | fc06c73 | 2020-08-19 12:52:28 +0000 | [diff] [blame] | 6852 | execute( TC_attached_imsi_lu_unknown_tmsi() ); |
Harald Welte | e1a2f3c | 2018-01-24 17:28:48 +0100 | [diff] [blame] | 6853 | execute( TC_imsi_detach_by_imsi() ); |
| 6854 | execute( TC_imsi_detach_by_tmsi() ); |
| 6855 | execute( TC_imsi_detach_by_imei() ); |
| 6856 | execute( TC_emerg_call_imei_reject() ); |
| 6857 | execute( TC_emerg_call_imsi() ); |
| 6858 | execute( TC_cm_serv_req_vgcs_reject() ); |
| 6859 | execute( TC_cm_serv_req_vbs_reject() ); |
| 6860 | execute( TC_cm_serv_req_lcs_reject() ); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 6861 | execute( TC_cm_reest_req_reject() ); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 6862 | execute( TC_lu_auth_2G_fail() ); |
| 6863 | execute( TC_lu_imsi_auth_tmsi_encr_13_13() ); |
| 6864 | execute( TC_cl3_no_payload() ); |
| 6865 | execute( TC_cl3_rnd_payload() ); |
Harald Welte | 1852a84 | 2018-01-26 22:53:36 +0100 | [diff] [blame] | 6866 | execute( TC_establish_and_nothing() ); |
| 6867 | execute( TC_mo_setup_and_nothing() ); |
| 6868 | execute( TC_mo_crcx_ran_timeout() ); |
| 6869 | execute( TC_mo_crcx_ran_reject() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 6870 | execute( TC_mt_crcx_ran_reject() ); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 6871 | execute( TC_mo_setup_and_dtmf_dup() ); |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 6872 | execute( TC_mt_t310() ); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 6873 | execute( TC_gsup_cancel() ); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 6874 | execute( TC_lu_imsi_auth_tmsi_encr_1_13() ); |
| 6875 | execute( TC_lu_imsi_auth_tmsi_encr_3_13() ); |
| 6876 | execute( TC_lu_imsi_auth_tmsi_encr_3_1() ); |
Neels Hofmeyr | 29b8da0 | 2018-03-01 18:09:45 +0100 | [diff] [blame] | 6877 | execute( TC_lu_imsi_auth_tmsi_encr_3_1_no_cm() ); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 6878 | execute( TC_lu_imsi_auth_tmsi_encr_13_2() ); |
| 6879 | execute( TC_lu_imsi_auth_tmsi_encr_013_2() ); |
Eric Wild | 26f4a62 | 2021-05-17 15:27:05 +0200 | [diff] [blame] | 6880 | execute( TC_lu_imsi_auth_tmsi_encr_0134_1() ); |
| 6881 | execute( TC_lu_imsi_auth_tmsi_encr_0134_34() ); |
| 6882 | execute( TC_lu_imsi_auth_tmsi_encr_0134_34_no_cm3() ); |
| 6883 | |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 6884 | execute( TC_mo_release_timeout() ); |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 6885 | execute( TC_lu_and_mt_call_no_dlcx_resp() ); |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 6886 | execute( TC_reset_two() ); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 6887 | |
| 6888 | execute( TC_lu_and_mt_call() ); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 6889 | execute( TC_lu_and_mt_call_ipv6() ); |
Neels Hofmeyr | b58d974 | 2019-11-27 18:44:54 +0100 | [diff] [blame] | 6890 | execute( TC_lu_and_mt_call_already_paging() ); |
Pau Espin Pedrol | 9a732a4 | 2020-09-15 15:56:33 +0200 | [diff] [blame] | 6891 | execute( TC_lu_and_mt_call_osmux() ); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 6892 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 6893 | execute( TC_lu_and_mo_sms() ); |
| 6894 | execute( TC_lu_and_mt_sms() ); |
Neels Hofmeyr | b58d974 | 2019-11-27 18:44:54 +0100 | [diff] [blame] | 6895 | execute( TC_lu_and_mt_sms_already_paging() ); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 6896 | execute( TC_lu_and_mt_sms_paging_and_nothing() ); |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 6897 | execute( TC_lu_and_mt_sms_paging_repeated() ); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 6898 | execute( TC_smpp_mo_sms() ); |
Vadim Yanitskiy | 3382076 | 2020-01-15 11:26:07 +0700 | [diff] [blame] | 6899 | execute( TC_smpp_mo_sms_rp_error() ); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 6900 | execute( TC_smpp_mt_sms() ); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 6901 | |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 6902 | execute( TC_gsup_mo_sms() ); |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 6903 | execute( TC_gsup_mo_smma() ); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 6904 | execute( TC_gsup_mt_sms_ack() ); |
| 6905 | execute( TC_gsup_mt_sms_err() ); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 6906 | execute( TC_gsup_mt_sms_rp_mr() ); |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 6907 | execute( TC_gsup_mo_mt_sms_rp_mr() ); |
Vadim Yanitskiy | a2a8a11 | 2019-07-08 20:04:32 +0700 | [diff] [blame] | 6908 | execute( TC_gsup_mt_multi_part_sms() ); |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 6909 | |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 6910 | execute( TC_lu_and_mo_ussd_single_request() ); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 6911 | execute( TC_lu_and_mt_ussd_notification() ); |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 6912 | execute( TC_lu_and_mo_ussd_during_mt_call() ); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 6913 | execute( TC_lu_and_mt_ussd_during_mt_call() ); |
Vadim Yanitskiy | 2daf52d | 2018-06-21 04:19:58 +0700 | [diff] [blame] | 6914 | execute( TC_lu_and_mo_ussd_mo_release() ); |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 6915 | execute( TC_lu_and_ss_session_timeout() ); |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 6916 | |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 6917 | execute( TC_mt_ussd_for_unknown_subscr() ); |
Vadim Yanitskiy | c3c07d4 | 2019-06-17 23:00:44 +0700 | [diff] [blame] | 6918 | execute( TC_mo_ussd_for_unknown_trans() ); |
Vadim Yanitskiy | d612d28 | 2019-06-15 14:46:03 +0700 | [diff] [blame] | 6919 | execute( TC_proc_ss_for_unknown_session() ); |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 6920 | execute( TC_proc_ss_paging_fail() ); |
Vadim Yanitskiy | 29ba8d6 | 2019-06-16 15:19:41 +0700 | [diff] [blame] | 6921 | execute( TC_proc_ss_abort() ); |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 6922 | |
Vadim Yanitskiy | 1c9754d | 2020-01-07 21:56:55 +0100 | [diff] [blame] | 6923 | execute( TC_multi_lu_and_mo_ussd() ); |
| 6924 | execute( TC_multi_lu_and_mt_ussd() ); |
| 6925 | |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 6926 | execute( TC_cipher_complete_with_invalid_cipher() ); |
Stefan Sperling | a2d59c6 | 2018-12-18 16:32:44 +0100 | [diff] [blame] | 6927 | execute( TC_cipher_complete_1_without_cipher() ); |
| 6928 | execute( TC_cipher_complete_3_without_cipher() ); |
| 6929 | execute( TC_cipher_complete_13_without_cipher() ); |
Harald Welte | b2284bd | 2019-05-10 11:30:43 +0200 | [diff] [blame] | 6930 | execute( TC_lu_with_invalid_mcc_mnc() ); |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 6931 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 6932 | execute( TC_sgsap_reset() ); |
| 6933 | execute( TC_sgsap_lu() ); |
| 6934 | execute( TC_sgsap_lu_imsi_reject() ); |
| 6935 | execute( TC_sgsap_lu_and_nothing() ); |
| 6936 | execute( TC_sgsap_expl_imsi_det_eps() ); |
Philipp Maier | fc19f17 | 2019-03-21 11:17:54 +0100 | [diff] [blame] | 6937 | execute( TC_sgsap_impl_imsi_det_eps() ); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 6938 | execute( TC_sgsap_expl_imsi_det_noneps() ); |
Philipp Maier | 5d81270 | 2019-03-21 10:51:26 +0100 | [diff] [blame] | 6939 | execute( TC_sgsap_impl_imsi_det_noneps() ); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 6940 | execute( TC_sgsap_paging_rej() ); |
| 6941 | execute( TC_sgsap_paging_subscr_rej() ); |
| 6942 | execute( TC_sgsap_paging_ue_unr() ); |
| 6943 | execute( TC_sgsap_paging_and_nothing() ); |
| 6944 | execute( TC_sgsap_paging_and_lu() ); |
| 6945 | execute( TC_sgsap_mt_sms() ); |
| 6946 | execute( TC_sgsap_mo_sms() ); |
| 6947 | execute( TC_sgsap_mt_sms_and_nothing() ); |
| 6948 | execute( TC_sgsap_mt_sms_and_reject() ); |
| 6949 | execute( TC_sgsap_unexp_ud() ); |
| 6950 | execute( TC_sgsap_unsol_ud() ); |
| 6951 | execute( TC_bssap_lu_sgsap_lu_and_mt_call() ); |
| 6952 | execute( TC_sgsap_lu_and_mt_call() ); |
Philipp Maier | 628c005 | 2019-04-09 17:36:57 +0200 | [diff] [blame] | 6953 | execute( TC_sgsap_vlr_failure() ); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 6954 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6955 | execute( TC_ho_inter_bsc_unknown_cell() ); |
| 6956 | execute( TC_ho_inter_bsc() ); |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6957 | execute( TC_ho_inter_bsc_a5_1() ); |
| 6958 | execute( TC_ho_inter_bsc_a5_3() ); |
| 6959 | execute( TC_ho_inter_bsc_a5_4() ); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 6960 | execute( TC_ho_inter_bsc_ipv6() ); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6961 | |
| 6962 | execute( TC_ho_inter_msc_out() ); |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6963 | execute( TC_ho_inter_msc_out_a5_1() ); |
| 6964 | execute( TC_ho_inter_msc_out_a5_3() ); |
| 6965 | execute( TC_ho_inter_msc_out_a5_4() ); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 6966 | execute( TC_ho_inter_msc_out_ipv6() ); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6967 | |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6968 | execute( TC_lu_imsi_auth_tmsi_check_imei() ); |
| 6969 | execute( TC_lu_imsi_auth3g_tmsi_check_imei() ); |
| 6970 | execute( TC_lu_imsi_noauth_tmsi_check_imei() ); |
| 6971 | execute( TC_lu_imsi_noauth_notmsi_check_imei() ); |
| 6972 | execute( TC_lu_imsi_auth_tmsi_check_imei_nack() ); |
| 6973 | execute( TC_lu_imsi_auth_tmsi_check_imei_err() ); |
| 6974 | execute( TC_lu_imsi_auth_tmsi_check_imei_early() ); |
| 6975 | execute( TC_lu_imsi_auth3g_tmsi_check_imei_early() ); |
| 6976 | execute( TC_lu_imsi_noauth_tmsi_check_imei_early() ); |
| 6977 | execute( TC_lu_imsi_noauth_notmsi_check_imei_early() ); |
| 6978 | execute( TC_lu_imsi_auth_tmsi_check_imei_early_nack() ); |
| 6979 | execute( TC_lu_imsi_auth_tmsi_check_imei_early_err() ); |
Neels Hofmeyr | 1b3c6e3 | 2018-03-01 17:52:21 +0100 | [diff] [blame] | 6980 | 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] | 6981 | |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 6982 | execute( TC_mo_cc_bssmap_clear() ); |
Neels Hofmeyr | 8df6962 | 2019-11-02 19:16:03 +0100 | [diff] [blame] | 6983 | execute( TC_invalid_mgcp_crash() ); |
Vadim Yanitskiy | eddebaa | 2019-12-28 17:45:34 +0100 | [diff] [blame] | 6984 | execute( TC_mm_id_resp_no_identity() ); |
Vadim Yanitskiy | 2521906 | 2020-01-21 01:41:33 +0700 | [diff] [blame] | 6985 | execute( TC_lu_and_expire_while_paging() ); |
Pau Espin Pedrol | 174fac2 | 2021-02-26 13:20:10 +0100 | [diff] [blame] | 6986 | execute( TC_paging_response_imsi_unknown() ); |
| 6987 | execute( TC_paging_response_tmsi_unknown() ); |
Neels Hofmeyr | 4f099b4 | 2021-07-27 03:45:26 +0200 | [diff] [blame] | 6988 | |
| 6989 | execute( TC_call_re_establishment() ); |
Neels Hofmeyr | a9b2dcf | 2021-07-28 00:57:58 +0200 | [diff] [blame] | 6990 | execute( TC_call_re_establishment_auth() ); |
Neels Hofmeyr | 48e4d7d | 2021-07-28 00:57:58 +0200 | [diff] [blame] | 6991 | execute( TC_call_re_establishment_ciph() ); |
Neels Hofmeyr | 07ea7f2 | 2022-05-05 01:39:26 +0200 | [diff] [blame] | 6992 | |
| 6993 | execute( TC_cm_serv_wrong_mi() ); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 6994 | } |
| 6995 | |
| 6996 | |
| 6997 | } |