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"; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 143 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 144 | RAN_Configurations mp_bssap_cfg := { |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 145 | { |
| 146 | sccp_service_type := "mtp3_itu", |
| 147 | sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" }, |
| 148 | own_pc := 185, |
| 149 | own_ssn := 254, |
| 150 | peer_pc := 187, |
| 151 | peer_ssn := 254, |
| 152 | sio := '83'O, |
| 153 | rctx := 0 |
| 154 | }, |
| 155 | { |
| 156 | sccp_service_type := "mtp3_itu", |
| 157 | sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" }, |
| 158 | own_pc := 186, |
| 159 | own_ssn := 254, |
| 160 | peer_pc := 187, |
| 161 | peer_ssn := 254, |
| 162 | sio := '83'O, |
| 163 | rctx := 1 |
| 164 | } |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 165 | }; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 166 | } |
| 167 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 168 | /* altstep for the global guard timer (only used when BSSAP_DIRECT |
| 169 | * is used for communication */ |
| 170 | private altstep as_Tguard_direct() runs on MTC_CT { |
| 171 | [] Tguard_direct.timeout { |
| 172 | setverdict(fail, "Tguard timeout"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 173 | mtc.stop; |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 174 | } |
| 175 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 176 | |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 177 | private altstep as_optional_cc_rel(CallParameters cpars, boolean respond := false) runs on BSC_ConnHdlr { |
| 178 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))) { |
| 179 | if (respond) { |
| 180 | var BIT1 tid_remote := '1'B; |
| 181 | if (cpars.mo_call) { |
| 182 | tid_remote := '0'B; |
| 183 | } |
| 184 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_REL_COMPL(cpars.transaction_id, tid_remote))); |
| 185 | } |
| 186 | } |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 187 | } |
| 188 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 189 | function f_init_smpp(charstring id) runs on MTC_CT { |
| 190 | id := id & "-SMPP"; |
| 191 | var EsmePars pars := { |
| 192 | mode := MODE_TRANSCEIVER, |
| 193 | bind := { |
| 194 | system_id := mp_smpp_system_id, |
| 195 | password := mp_smpp_password, |
| 196 | system_type := "MSC_Tests", |
| 197 | interface_version := hex2int('34'H), |
| 198 | addr_ton := unknown, |
| 199 | addr_npi := unknown, |
| 200 | address_range := "" |
| 201 | }, |
| 202 | esme_role := true |
| 203 | } |
| 204 | |
| 205 | vc_SMPP := SMPP_Emulation_CT.create(id); |
| 206 | map(vc_SMPP:SMPP_PORT, system:SMPP_PORT); |
Harald Welte | 4698a4c | 2020-08-18 22:57:52 +0200 | [diff] [blame] | 207 | 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] | 208 | } |
| 209 | |
| 210 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 211 | function f_init_mncc(charstring id) runs on MTC_CT { |
| 212 | id := id & "-MNCC"; |
| 213 | var MnccOps ops := { |
| 214 | create_cb := refers(MNCC_Emulation.ExpectedCreateCallback), |
| 215 | unitdata_cb := refers(MNCC_Emulation.DummyUnitdataCallback) |
| 216 | } |
| 217 | |
| 218 | vc_MNCC := MNCC_Emulation_CT.create(id); |
| 219 | map(vc_MNCC:MNCC, system:MNCC_CODEC_PT); |
| 220 | vc_MNCC.start(MNCC_Emulation.main(ops, id, mp_msc_mncc)); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 221 | } |
| 222 | |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 223 | function f_init_mgcp(charstring id) runs on MTC_CT { |
| 224 | id := id & "-MGCP"; |
| 225 | var MGCPOps ops := { |
| 226 | create_cb := refers(MGCP_Emulation.ExpectedCreateCallback), |
| 227 | unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback) |
| 228 | } |
| 229 | var MGCP_conn_parameters pars := { |
Harald Welte | 6126fb0 | 2018-01-27 20:08:24 +0100 | [diff] [blame] | 230 | callagent_ip := mp_msc_ip, |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 231 | callagent_udp_port := -1, |
Harald Welte | 6126fb0 | 2018-01-27 20:08:24 +0100 | [diff] [blame] | 232 | mgw_ip := mp_mgw_ip, |
Pau Espin Pedrol | 1a026a5 | 2019-06-18 17:21:52 +0200 | [diff] [blame] | 233 | mgw_udp_port := mp_mgw_port, |
| 234 | multi_conn_mode := false |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | vc_MGCP := MGCP_Emulation_CT.create(id); |
| 238 | map(vc_MGCP:MGCP, system:MGCP_CODEC_PT); |
| 239 | vc_MGCP.start(MGCP_Emulation.main(ops, pars, id)); |
| 240 | } |
| 241 | |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 242 | function ForwardUnitdataCallback(PDU_SGsAP msg) |
| 243 | runs on SGsAP_Emulation_CT return template PDU_SGsAP { |
| 244 | SGsAP_CLIENT.send(msg); |
| 245 | return omit; |
| 246 | } |
| 247 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 248 | function f_init_sgsap(charstring id) runs on MTC_CT { |
| 249 | id := id & "-SGsAP"; |
| 250 | var SGsAPOps ops := { |
| 251 | create_cb := refers(SGsAP_Emulation.ExpectedCreateCallback), |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 252 | unitdata_cb := refers(ForwardUnitdataCallback) |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 253 | } |
| 254 | var SGsAP_conn_parameters pars := { |
| 255 | remote_ip := mp_msc_ip, |
| 256 | remote_sctp_port := 29118, |
| 257 | local_ip := "", |
| 258 | local_sctp_port := -1 |
| 259 | } |
| 260 | |
| 261 | vc_SGsAP := SGsAP_Emulation_CT.create(id); |
| 262 | map(vc_SGsAP:SGsAP, system:SGsAP_CODEC_PT); |
| 263 | vc_SGsAP.start(SGsAP_Emulation.main(ops, pars, id)); |
| 264 | } |
| 265 | |
| 266 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 267 | function f_init_gsup(charstring id) runs on MTC_CT { |
| 268 | id := id & "-GSUP"; |
| 269 | var GsupOps ops := { |
| 270 | create_cb := refers(GSUP_Emulation.ExpectedCreateCallback) |
| 271 | } |
| 272 | |
| 273 | vc_GSUP_IPA := IPA_Emulation_CT.create(id & "-IPA"); |
| 274 | vc_GSUP := GSUP_Emulation_CT.create(id); |
| 275 | |
| 276 | map(vc_GSUP_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 277 | connect(vc_GSUP:GSUP, vc_GSUP_IPA:IPA_GSUP_PORT); |
| 278 | /* we use this hack to get events like ASP_IPA_EVENT_UP */ |
| 279 | connect(vc_GSUP_IPA:IPA_CTRL_PORT, self:GSUP_IPA_EVENT); |
| 280 | |
| 281 | vc_GSUP.start(GSUP_Emulation.main(ops, id)); |
| 282 | vc_GSUP_IPA.start(IPA_Emulation.main_server(mp_hlr_ip, mp_hlr_port)); |
| 283 | |
| 284 | /* wait for incoming connection to GSUP port before proceeding */ |
| 285 | timer T := 10.0; |
| 286 | T.start; |
| 287 | alt { |
Vadim Yanitskiy | 61564be | 2020-05-18 20:44:14 +0700 | [diff] [blame] | 288 | [] GSUP_IPA_EVENT.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_UP)) { } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 289 | [] T.timeout { |
Harald Welte | 458fd37 | 2018-03-21 11:26:23 +0100 | [diff] [blame] | 290 | setverdict(fail, "No connection to GSUP Port"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 291 | mtc.stop |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 292 | } |
| 293 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 294 | } |
| 295 | |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 296 | 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] | 297 | |
| 298 | if (g_initialized == true) { |
| 299 | return; |
| 300 | } |
| 301 | g_initialized := true; |
| 302 | |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 303 | if (num_bsc > NUM_BSC) { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 304 | testcase.stop("excess number of BSC instances requested"); |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | for (var integer i := 0; i < num_bsc; i := i + 1) { |
| 308 | if (isbound(mp_bssap_cfg[i])) { |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 309 | var RanOps ranops := BSC_RanOps; |
| 310 | ranops.use_osmux := osmux; |
| 311 | f_ran_adapter_init(g_bssap[i], mp_bssap_cfg[i], "MSC_Test_" & int2str(i), ranops); |
Harald Welte | 3ca0ce1 | 2019-04-23 17:18:48 +0200 | [diff] [blame] | 312 | f_ran_adapter_start(g_bssap[i]); |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 313 | } else { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 314 | testcase.stop("missing BSSAP configuration"); |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 315 | } |
| 316 | } |
| 317 | |
Pau Espin Pedrol | 9a5b8ff | 2021-01-04 19:01:31 +0100 | [diff] [blame] | 318 | f_ipa_ctrl_start_client(mp_msc_ip, mp_msc_ctrl_port); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 319 | f_init_mncc("MSC_Test"); |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 320 | f_init_mgcp("MSC_Test"); |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 321 | |
| 322 | if (gsup == true) { |
| 323 | f_init_gsup("MSC_Test"); |
| 324 | } |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 325 | f_init_smpp("MSC_Test"); |
Philipp Maier | 5786548 | 2019-01-07 18:33:13 +0100 | [diff] [blame] | 326 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 327 | if (sgsap == true) { |
Philipp Maier | 5786548 | 2019-01-07 18:33:13 +0100 | [diff] [blame] | 328 | f_init_sgsap("MSC_Test"); |
| 329 | } |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 330 | |
| 331 | map(self:MSCVTY, system:MSCVTY); |
| 332 | f_vty_set_prompts(MSCVTY); |
| 333 | f_vty_transceive(MSCVTY, "enable"); |
Harald Welte | b14c77a | 2018-01-25 17:25:44 +0100 | [diff] [blame] | 334 | |
| 335 | /* set some defaults */ |
| 336 | f_vty_config(MSCVTY, "network", "authentication optional"); |
| 337 | f_vty_config(MSCVTY, "msc", "assign-tmsi"); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 338 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 0"); |
Harald Welte | b14c77a | 2018-01-25 17:25:44 +0100 | [diff] [blame] | 339 | f_vty_config(MSCVTY, "network", "encryption a5 0"); |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 340 | f_vty_config(MSCVTY, "cs7 instance 0", "sccp-timer ias " & int2str(g_msc_sccp_timer_ias)); |
| 341 | 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] | 342 | if (osmux) { |
| 343 | f_vty_config(MSCVTY, "msc", "osmux on"); |
| 344 | } else { |
| 345 | f_vty_config(MSCVTY, "msc", "osmux off"); |
Pau Espin Pedrol | 3dd33bc | 2019-05-31 17:51:20 +0200 | [diff] [blame] | 346 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 347 | } |
| 348 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 349 | /* Initialize for a direct connection to BSSAP. This function is an alternative |
| 350 | * to f_init() when the high level functions of the BSC_ConnectionHandler are |
| 351 | * not needed. */ |
| 352 | function f_init_bssap_direct() runs on MTC_CT { |
Harald Welte | 3ca0ce1 | 2019-04-23 17:18:48 +0200 | [diff] [blame] | 353 | 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] | 354 | connect(g_bssap[0].vc_SCCP:SCCP_SP_PORT, self:BSSAP_DIRECT); |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 355 | |
| 356 | /* Start guard timer and activate it as default */ |
| 357 | Tguard_direct.start |
| 358 | activate(as_Tguard_direct()); |
| 359 | } |
| 360 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 361 | 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] | 362 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 363 | /* FIXME: move into BSC_ConnectionHandler? */ |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 364 | 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] | 365 | boolean ran_is_geran := true, boolean use_osmux := false, OCT4 gsup_sid := '20000101'O, |
| 366 | boolean verify_cell_id := true) |
Harald Welte | f9abf8d | 2019-04-21 13:07:17 +0200 | [diff] [blame] | 367 | runs on MTC_CT return BSC_ConnHdlrPars { |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 368 | var BSC_ConnHdlrNetworkPars net_pars := { |
| 369 | kc_support := '0A'O, /* A5/1 and A5/3 enabled */ |
| 370 | expect_tmsi := true, |
| 371 | expect_auth := false, |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 372 | expect_ciph := false, |
| 373 | expect_imei := false, |
| 374 | expect_imei_early := false, |
| 375 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 376 | check_imei_error := false |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 377 | }; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 378 | var BSC_ConnHdlrPars pars := { |
Harald Welte | f9abf8d | 2019-04-21 13:07:17 +0200 | [diff] [blame] | 379 | sccp_addr_own := g_bssap[ran_idx].sccp_addr_own, |
| 380 | sccp_addr_peer := g_bssap[ran_idx].sccp_addr_peer, |
Harald Welte | edbab81 | 2018-03-18 16:02:25 +0100 | [diff] [blame] | 381 | cell_id := valueof(ts_CellId_CGI('262'H, '42'H, 23, 42)), |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 382 | imei := f_gen_imei(imsi_suffix), |
| 383 | imsi := f_gen_imsi(imsi_suffix), |
| 384 | msisdn := f_gen_msisdn(imsi_suffix), |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 385 | tmsi := omit, |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 386 | cm1 := valueof(ts_CM1), |
Harald Welte | 8260057 | 2018-01-21 20:54:08 +0100 | [diff] [blame] | 387 | cm2 := valueof(ts_CM2_default), |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 388 | cm3 := omit, |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 389 | vec := omit, |
Neels Hofmeyr | b00c5b0 | 2021-06-23 20:05:25 +0200 | [diff] [blame] | 390 | vec_keep := false, |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 391 | net := net_pars, |
Philipp Maier | aeb29a8 | 2018-11-08 17:40:53 +0100 | [diff] [blame] | 392 | send_early_cm := true, |
| 393 | ipa_ctrl_ip := mp_msc_ip, |
| 394 | ipa_ctrl_port := mp_msc_ctrl_port, |
Philipp Maier | 9b690e4 | 2018-12-21 11:50:03 +0100 | [diff] [blame] | 395 | ipa_ctrl_enable := true, |
Philipp Maier | 5786548 | 2019-01-07 18:33:13 +0100 | [diff] [blame] | 396 | mm_info := mp_mm_info, |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 397 | sgsap_enable := sgsap, |
Harald Welte | f9abf8d | 2019-04-21 13:07:17 +0200 | [diff] [blame] | 398 | gsup_enable := gsup, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 399 | gsup_sid := gsup_sid, |
Harald Welte | c1f937a | 2019-04-21 21:19:23 +0200 | [diff] [blame] | 400 | ran_idx := ran_idx, |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 401 | use_umts_aka := false, |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 402 | ran_is_geran := ran_is_geran, |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 403 | use_osmux := use_osmux, |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 404 | use_ipv6 := false, |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 405 | verify_cell_id := verify_cell_id, |
| 406 | common_id_last_eutran_plmn := omit |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 407 | }; |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 408 | if (not ran_is_geran) { |
| 409 | pars.use_umts_aka := true; |
| 410 | pars.net.expect_auth := true; |
| 411 | } |
Neels Hofmeyr | 9adaa70 | 2018-03-01 20:23:19 +0100 | [diff] [blame] | 412 | return pars; |
| 413 | } |
| 414 | |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 415 | function f_start_handler_with_pars(void_fn fn, BSC_ConnHdlrPars pars) runs on MTC_CT return BSC_ConnHdlr { |
Neels Hofmeyr | 9adaa70 | 2018-03-01 20:23:19 +0100 | [diff] [blame] | 416 | var BSC_ConnHdlr vc_conn; |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 417 | var charstring id := testcasename() & int2str(pars.ran_idx); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 418 | |
| 419 | vc_conn := BSC_ConnHdlr.create(id); |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 420 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 421 | /* BSSMAP part / A interface */ |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 422 | connect(vc_conn:BSSAP, g_bssap[pars.ran_idx].vc_RAN:CLIENT); |
| 423 | 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] | 424 | /* MNCC part */ |
| 425 | connect(vc_conn:MNCC, vc_MNCC:MNCC_CLIENT); |
| 426 | connect(vc_conn:MNCC_PROC, vc_MNCC:MNCC_PROC); |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 427 | /* MGCP part */ |
| 428 | connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT); |
| 429 | connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 430 | /* GSUP part */ |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 431 | if (pars.gsup_enable == true) { |
| 432 | connect(vc_conn:GSUP, vc_GSUP:GSUP_CLIENT); |
| 433 | connect(vc_conn:GSUP_PROC, vc_GSUP:GSUP_PROC); |
| 434 | } |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 435 | /* SMPP part */ |
| 436 | connect(vc_conn:SMPP, vc_SMPP:SMPP_CLIENT); |
| 437 | connect(vc_conn:SMPP_PROC, vc_SMPP:SMPP_PROC); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 438 | /* SGs part */ |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 439 | if (pars.sgsap_enable == true) { |
Philipp Maier | 5786548 | 2019-01-07 18:33:13 +0100 | [diff] [blame] | 440 | connect(vc_conn:SGsAP, vc_SGsAP:SGsAP_CLIENT); |
| 441 | connect(vc_conn:SGsAP_PROC, vc_SGsAP:SGsAP_PROC); |
| 442 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 443 | |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 444 | /* We cannot use vc_conn.start(f_init_handler(fn, id, pars)); as we cannot have |
| 445 | * 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] | 446 | vc_conn.start(derefers(fn)(id, pars)); |
| 447 | return vc_conn; |
| 448 | } |
| 449 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 450 | function f_start_handler(void_fn fn, integer imsi_suffix, integer ran_idx := 0, boolean ran_is_geran := true, boolean use_osmux := false, |
| 451 | boolean verify_cell_id := true) |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 452 | runs on MTC_CT return BSC_ConnHdlr { |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 453 | return f_start_handler_with_pars(fn, f_init_pars(imsi_suffix, ran_idx := ran_idx, ran_is_geran := ran_is_geran, use_osmux := use_osmux, verify_cell_id := verify_cell_id)); |
Neels Hofmeyr | 9adaa70 | 2018-03-01 20:23:19 +0100 | [diff] [blame] | 454 | } |
| 455 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 456 | private function f_tc_lu_imsi_noauth_tmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 457 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 458 | f_perform_lu(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 459 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 460 | testcase TC_lu_imsi_noauth_tmsi() runs on MTC_CT { |
| 461 | var BSC_ConnHdlr vc_conn; |
| 462 | f_init(); |
| 463 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 464 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_tmsi), 1); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 465 | vc_conn.done; |
| 466 | } |
| 467 | |
| 468 | private function f_tc_lu_imsi_noauth_notmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 469 | pars.net.expect_tmsi := false; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 470 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 471 | f_perform_lu(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 472 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 473 | testcase TC_lu_imsi_noauth_notmsi() runs on MTC_CT { |
| 474 | var BSC_ConnHdlr vc_conn; |
| 475 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 476 | f_vty_config(MSCVTY, "msc", "no assign-tmsi"); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 477 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 478 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_notmsi), 2); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 479 | vc_conn.done; |
| 480 | } |
| 481 | |
| 482 | /* Do LU by IMSI, refuse it on GSUP and expect LU REJ back to MS */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 483 | friend function f_tc_lu_imsi_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 484 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 485 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 486 | |
| 487 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 488 | f_cl3_or_initial_ue(l3_lu); |
Neels Hofmeyr | d076c52 | 2019-11-28 01:00:52 +0100 | [diff] [blame] | 489 | f_mm_common(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 490 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 491 | GSUP.send(ts_GSUP_UL_ERR(g_pars.imsi, 23)); |
| 492 | alt { |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 493 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej(int2oct(23,1)))) { |
| 494 | f_expect_clear(); |
| 495 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 496 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 497 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 498 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 499 | } |
| 500 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 501 | } |
| 502 | testcase TC_lu_imsi_reject() runs on MTC_CT { |
| 503 | var BSC_ConnHdlr vc_conn; |
| 504 | f_init(); |
| 505 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 506 | 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] | 507 | vc_conn.done; |
| 508 | } |
| 509 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 510 | |
| 511 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 512 | /* Do LU by IMSI, timeout on GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 513 | friend function f_tc_lu_imsi_timeout_gsup(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 514 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 515 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 516 | |
| 517 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 518 | f_cl3_or_initial_ue(l3_lu); |
Neels Hofmeyr | d076c52 | 2019-11-28 01:00:52 +0100 | [diff] [blame] | 519 | f_mm_common(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 520 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 521 | /* Normally the HLR would need to respond here, but we decide to force a timeout here */ |
| 522 | alt { |
| 523 | /* FIXME: Expect specific reject cause */ |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 524 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 525 | f_expect_clear(); |
| 526 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 527 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 528 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 529 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 530 | } |
| 531 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 532 | } |
| 533 | testcase TC_lu_imsi_timeout_gsup() runs on MTC_CT { |
| 534 | var BSC_ConnHdlr vc_conn; |
| 535 | f_init(); |
| 536 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 537 | 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] | 538 | vc_conn.done; |
| 539 | } |
| 540 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 541 | |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 542 | private function f_tc_lu_imsi_auth_tmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 543 | pars.net.expect_auth := true; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 544 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 545 | f_perform_lu(); |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 546 | } |
| 547 | testcase TC_lu_imsi_auth_tmsi() runs on MTC_CT { |
| 548 | var BSC_ConnHdlr vc_conn; |
| 549 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 550 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 551 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 552 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi), 5); |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 553 | vc_conn.done; |
| 554 | } |
| 555 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 556 | |
| 557 | friend function f_tc_lu_imsi_auth3g_tmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
Harald Welte | 8a397ae | 2019-04-21 22:03:37 +0200 | [diff] [blame] | 558 | pars.net.expect_auth := true; |
| 559 | pars.use_umts_aka := true; |
| 560 | f_init_handler(pars); |
| 561 | f_perform_lu(); |
| 562 | } |
| 563 | testcase TC_lu_imsi_auth3g_tmsi() runs on MTC_CT { |
| 564 | var BSC_ConnHdlr vc_conn; |
| 565 | f_init(); |
| 566 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 567 | |
| 568 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth3g_tmsi), 1005); |
| 569 | vc_conn.done; |
| 570 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 571 | |
Pau Espin Pedrol | d3d54a9 | 2019-12-17 17:02:54 +0100 | [diff] [blame] | 572 | /* Proceed with LU but never receive an TMSI Realloc from MS after LU Accept (OS#4337). |
| 573 | * TS 24.008 sec 4.3.1.5 states MSC should simply release all MM connections. |
| 574 | */ |
| 575 | friend function f_tc_lu_imsi_timeout_tmsi_realloc(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 576 | |
| 577 | f_init_handler(pars); |
| 578 | |
| 579 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 580 | var PDU_DTAP_MT dtap_mt; |
| 581 | |
| 582 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 583 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 584 | |
| 585 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 586 | if (g_pars.ran_is_geran) { |
| 587 | f_bssap_compl_l3(l3_lu); |
| 588 | if (g_pars.send_early_cm) { |
| 589 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 590 | } |
| 591 | } else { |
| 592 | f_ranap_initial_ue(l3_lu); |
| 593 | } |
| 594 | |
| 595 | f_mm_imei_early(); |
| 596 | f_mm_common(); |
| 597 | f_msc_lu_hlr(); |
| 598 | f_mm_imei(); |
| 599 | |
| 600 | alt { |
| 601 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) -> value dtap_mt {} |
| 602 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 603 | setverdict(fail, "Expected LU ACK, but received LU REJ"); |
| 604 | mtc.stop; |
| 605 | } |
| 606 | } |
| 607 | |
| 608 | /* currently (due to bug OS#4337), an extra LU reject is received before |
| 609 | terminating the connection. Enabling following line makes the test |
| 610 | pass: */ |
| 611 | //f_expect_lu_reject('16'O); /* Cause: congestion */ |
| 612 | |
| 613 | /* f_expect_lu_reject() already waits for T"-1" (X1, 5 seconds), but give some |
| 614 | extra time to avoid race conditons... */ |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 615 | f_expect_clear(7.0, verify_vlr_cell_id := false); |
Pau Espin Pedrol | d3d54a9 | 2019-12-17 17:02:54 +0100 | [diff] [blame] | 616 | |
| 617 | setverdict(pass); |
| 618 | } |
| 619 | testcase TC_lu_imsi_timeout_tmsi_realloc() runs on MTC_CT { |
| 620 | var BSC_ConnHdlr vc_conn; |
| 621 | f_init(); |
| 622 | |
| 623 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_timeout_tmsi_realloc), 5); |
| 624 | vc_conn.done; |
| 625 | } |
| 626 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 627 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 628 | /* Send CM SERVICE REQ for IMSI that has never performed LU before */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 629 | friend function f_tc_cmserv_imsi_unknown(charstring id, BSC_ConnHdlrPars pars) |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 630 | runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 631 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 632 | |
| 633 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | edbab81 | 2018-03-18 16:02:25 +0100 | [diff] [blame] | 634 | var BSSMAP_IE_CellIdentifier cell_id := valueof(ts_CellId_CGI('262'H, '42'H, 23, 42)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 635 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi)); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 636 | |
| 637 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 638 | |
| 639 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 640 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | b781799 | 2019-05-09 13:15:39 +0200 | [diff] [blame] | 641 | f_mm_auth(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 642 | |
| 643 | timer T := 10.0; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 644 | T.start; |
| 645 | alt { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 646 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)) { } |
| 647 | //[] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_ACC)) { } |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 648 | [] BSSAP.receive { |
| 649 | setverdict(fail, "Received unexpected BSSAP"); |
| 650 | mtc.stop; |
| 651 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 652 | [] GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)) { |
| 653 | setverdict(fail, "Unexpected GSUP UL REQ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 654 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 655 | } |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 656 | [] T.timeout { |
Neels Hofmeyr | f1c3c21 | 2020-08-19 13:15:32 +0000 | [diff] [blame] | 657 | setverdict(fail, "Timeout waiting for CM SERV REJ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 658 | mtc.stop; |
| 659 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 660 | } |
| 661 | |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 662 | f_expect_clear(); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 663 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 664 | testcase TC_cmserv_imsi_unknown() runs on MTC_CT { |
| 665 | var BSC_ConnHdlr vc_conn; |
| 666 | f_init(); |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 667 | 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] | 668 | vc_conn.done; |
| 669 | } |
| 670 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 671 | |
Neels Hofmeyr | 13737fb | 2020-08-19 13:16:14 +0000 | [diff] [blame] | 672 | /* Send CM SERVICE REQ for TMSI that has never performed LU before */ |
| 673 | friend function f_tc_cmserv_tmsi_unknown(charstring id, BSC_ConnHdlrPars pars) |
| 674 | runs on BSC_ConnHdlr { |
| 675 | f_init_handler(pars); |
| 676 | |
| 677 | var MobileIdentityLV mi := valueof(ts_MI_TMSI_LV('57111111'O)); |
| 678 | var BSSMAP_IE_CellIdentifier cell_id := valueof(ts_CellId_CGI('262'H, '42'H, 23, 42)); |
| 679 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi)); |
| 680 | |
| 681 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 682 | f_cl3_or_initial_ue(l3_info); |
| 683 | f_mm_auth(); |
| 684 | |
| 685 | timer T := 10.0; |
| 686 | T.start; |
| 687 | alt { |
| 688 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)) { } |
| 689 | [] BSSAP.receive { |
| 690 | setverdict(fail, "Received unexpected BSSAP"); |
| 691 | mtc.stop; |
| 692 | } |
| 693 | [] T.timeout { |
| 694 | setverdict(fail, "Timeout waiting for CM SERV REJ"); |
| 695 | mtc.stop; |
| 696 | } |
| 697 | } |
| 698 | |
| 699 | f_expect_clear(); |
| 700 | } |
| 701 | testcase TC_cmserv_tmsi_unknown() runs on MTC_CT { |
| 702 | var BSC_ConnHdlr vc_conn; |
| 703 | f_init(); |
| 704 | vc_conn := f_start_handler(refers(f_tc_cmserv_tmsi_unknown), 57, verify_cell_id := false); |
| 705 | vc_conn.done; |
| 706 | } |
| 707 | |
Neels Hofmeyr | 14d0b13 | 2020-08-19 13:49:05 +0000 | [diff] [blame] | 708 | /* Send Paging Response for IMSI that has never performed LU before */ |
| 709 | friend function f_tc_paging_response_imsi_unknown(charstring id, BSC_ConnHdlrPars pars) |
| 710 | runs on BSC_ConnHdlr { |
| 711 | f_init_handler(pars); |
| 712 | |
| 713 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 714 | var BSSMAP_IE_CellIdentifier cell_id := valueof(ts_CellId_CGI('262'H, '42'H, 23, 42)); |
| 715 | var PDU_ML3_MS_NW l3_info := valueof(ts_PAG_RESP(mi)); |
| 716 | |
| 717 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 718 | f_cl3_or_initial_ue(l3_info); |
| 719 | |
| 720 | /* The Paging Response gets rejected by a direct Clear Command */ |
| 721 | f_expect_clear(); |
| 722 | } |
| 723 | testcase TC_paging_response_imsi_unknown() runs on MTC_CT { |
| 724 | var BSC_ConnHdlr vc_conn; |
| 725 | f_init(); |
| 726 | vc_conn := f_start_handler(refers(f_tc_paging_response_imsi_unknown), 58, verify_cell_id := false); |
| 727 | vc_conn.done; |
| 728 | } |
| 729 | |
| 730 | /* Send Paging Response for TMSI that has never performed LU before */ |
| 731 | friend function f_tc_paging_response_tmsi_unknown(charstring id, BSC_ConnHdlrPars pars) |
| 732 | runs on BSC_ConnHdlr { |
| 733 | f_init_handler(pars); |
| 734 | |
| 735 | var MobileIdentityLV mi := valueof(ts_MI_TMSI_LV('59111111'O)); |
| 736 | var BSSMAP_IE_CellIdentifier cell_id := valueof(ts_CellId_CGI('262'H, '42'H, 23, 42)); |
| 737 | var PDU_ML3_MS_NW l3_info := valueof(ts_PAG_RESP(mi)); |
| 738 | |
| 739 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 740 | f_cl3_or_initial_ue(l3_info); |
| 741 | |
| 742 | /* The Paging Response gets rejected by a direct Clear Command */ |
| 743 | f_expect_clear(); |
| 744 | } |
| 745 | testcase TC_paging_response_tmsi_unknown() runs on MTC_CT { |
| 746 | var BSC_ConnHdlr vc_conn; |
| 747 | f_init(); |
| 748 | vc_conn := f_start_handler(refers(f_tc_paging_response_tmsi_unknown), 59, verify_cell_id := false); |
| 749 | vc_conn.done; |
| 750 | } |
| 751 | |
Neels Hofmeyr | 13737fb | 2020-08-19 13:16:14 +0000 | [diff] [blame] | 752 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 753 | 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] | 754 | f_init_handler(pars); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 755 | var CallParameters cpars := valueof(t_CallParams); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 756 | f_perform_lu(); |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 757 | f_mo_call(cpars); |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 758 | } |
| 759 | testcase TC_lu_and_mo_call() runs on MTC_CT { |
| 760 | var BSC_ConnHdlr vc_conn; |
| 761 | f_init(); |
| 762 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 763 | 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] | 764 | vc_conn.done; |
| 765 | } |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 766 | friend function f_tc_lu_and_mo_call_ipv6(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 767 | f_init_handler(pars); |
| 768 | var CallParameters cpars := valueof(t_CallParams); |
| 769 | cpars.mgw_conn_1.mgw_rtp_ip := "::1"; |
| 770 | cpars.mgw_conn_2.mgw_rtp_ip := "::2"; |
| 771 | cpars.bss_rtp_ip := "::3"; |
| 772 | f_perform_lu(); |
| 773 | f_mo_call(cpars); |
| 774 | } |
| 775 | testcase TC_lu_and_mo_call_ipv6() runs on MTC_CT { |
| 776 | var BSC_ConnHdlr vc_conn; |
| 777 | f_init(); |
| 778 | |
| 779 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_call_ipv6), 7); |
| 780 | vc_conn.done; |
| 781 | } |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 782 | |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 783 | /* Verify T(iar) triggers and releases the channel */ |
| 784 | friend function f_lu_and_mo_call_sccp_tiar_timeout(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 785 | timer T_wait_iar := int2float(5 + 1); /* g_msc_sccp_timer_iar + Give extra time (+1 sec) */ |
| 786 | f_init_handler(pars); |
| 787 | var CallParameters cpars := valueof(t_CallParams); |
| 788 | f_perform_lu(); |
| 789 | f_mo_call_establish(cpars); |
| 790 | |
| 791 | /* Expect the channel cleared upon T(iar) triggered: */ |
| 792 | T_wait_iar.start; |
| 793 | alt { |
| 794 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) { |
| 795 | T_wait_iar.stop |
| 796 | setverdict(pass); |
| 797 | } |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 798 | [] T_wait_iar.timeout { |
| 799 | setverdict(fail, "Timeout waiting for T(iar) triggered SCCP RSLD"); |
| 800 | mtc.stop; |
| 801 | } |
| 802 | } |
Harald Welte | 4a3fa71 | 2020-08-19 08:57:33 +0200 | [diff] [blame] | 803 | /* DLCX for both directions; if we don't do this, we might receive either of the two during |
| 804 | * shutdown causing race conditions */ |
| 805 | MGCP.receive(tr_DLCX(?)); |
| 806 | MGCP.receive(tr_DLCX(?)); |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 807 | |
| 808 | setverdict(pass); |
| 809 | } |
| 810 | testcase TC_lu_and_mo_call_sccp_tiar_timeout() runs on MTC_CT { |
| 811 | var BSC_ConnHdlr vc_conn; |
| 812 | |
| 813 | /* Set T(iar) in MSC low enough that it will trigger before other side |
| 814 | has time to keep alive with a T(ias). Keep recommended ratio of |
| 815 | T(iar) >= T(ias)*2 */ |
| 816 | g_msc_sccp_timer_ias := 2; |
| 817 | g_msc_sccp_timer_iar := 5; |
| 818 | |
| 819 | f_init(); |
| 820 | |
| 821 | vc_conn := f_start_handler(refers(f_lu_and_mo_call_sccp_tiar_timeout), 89); |
| 822 | vc_conn.done; |
| 823 | } |
| 824 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 825 | |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 826 | /* Test LU (with authentication enabled), where HLR times out sending SAI response */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 827 | 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] | 828 | f_init_handler(pars); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 829 | |
| 830 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 831 | var PDU_DTAP_MT dtap_mt; |
| 832 | |
| 833 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 834 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 835 | |
| 836 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 837 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 838 | |
| 839 | /* Send Early Classmark, just for the fun of it */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 840 | if (pars.ran_is_geran) { |
| 841 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 842 | } |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 843 | |
| 844 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 845 | /* The HLR would normally return an auth vector here, but we fail to do so. */ |
| 846 | |
| 847 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 848 | f_expect_clear(); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 849 | } |
| 850 | testcase TC_lu_auth_sai_timeout() runs on MTC_CT { |
| 851 | var BSC_ConnHdlr vc_conn; |
| 852 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 853 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 854 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 855 | 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] | 856 | vc_conn.done; |
| 857 | } |
| 858 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 859 | |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 860 | /* Test LU (with authentication enabled), where HLR rejects sending SAI error */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 861 | 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] | 862 | f_init_handler(pars); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 863 | |
| 864 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 865 | var PDU_DTAP_MT dtap_mt; |
| 866 | |
| 867 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 868 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 869 | |
| 870 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 871 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 872 | |
| 873 | /* Send Early Classmark, just for the fun of it */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 874 | if (pars.ran_is_geran) { |
| 875 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 876 | } |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 877 | |
| 878 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 879 | GSUP.send(ts_GSUP_SAI_ERR(g_pars.imsi, 13)); |
| 880 | |
| 881 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 882 | f_expect_clear(); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 883 | } |
| 884 | testcase TC_lu_auth_sai_err() runs on MTC_CT { |
| 885 | var BSC_ConnHdlr vc_conn; |
| 886 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 887 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 888 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 889 | 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] | 890 | vc_conn.done; |
| 891 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 892 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 893 | |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 894 | /* Test LU but BSC will send a clear request in the middle */ |
| 895 | 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] | 896 | f_init_handler(pars); |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 897 | |
| 898 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 899 | var PDU_DTAP_MT dtap_mt; |
| 900 | |
| 901 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 902 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 903 | |
| 904 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 905 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 79f1e45 | 2020-08-18 22:55:02 +0200 | [diff] [blame] | 906 | f_expect_common_id(); |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 907 | |
| 908 | /* Send Early Classmark, just for the fun of it */ |
| 909 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 910 | |
| 911 | f_sleep(1.0); |
| 912 | /* send clear request in the middle of the LU */ |
| 913 | BSSAP.send(ts_BSSMAP_ClearRequest(0)); |
Neels Hofmeyr | 2b326fa | 2018-04-06 00:59:36 +0200 | [diff] [blame] | 914 | alt { |
| 915 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { repeat; } |
| 916 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) {} |
| 917 | } |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 918 | BSSAP.send(ts_BSSMAP_ClearComplete); |
Harald Welte | 89a3249 | 2018-01-27 19:07:28 +0100 | [diff] [blame] | 919 | alt { |
| 920 | /* See https://osmocom.org/issues/2862 */ |
Neels Hofmeyr | 2b326fa | 2018-04-06 00:59:36 +0200 | [diff] [blame] | 921 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 922 | setverdict(fail, "Got a second Clear Command, only one expected"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 923 | mtc.stop; |
Neels Hofmeyr | 2b326fa | 2018-04-06 00:59:36 +0200 | [diff] [blame] | 924 | repeat; |
| 925 | } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 926 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
Harald Welte | 89a3249 | 2018-01-27 19:07:28 +0100 | [diff] [blame] | 927 | } |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 928 | setverdict(pass); |
| 929 | } |
| 930 | testcase TC_lu_clear_request() runs on MTC_CT { |
| 931 | var BSC_ConnHdlr vc_conn; |
| 932 | f_init(); |
| 933 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 934 | vc_conn := f_start_handler(refers(f_tc_lu_clear_request), 10); |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 935 | vc_conn.done; |
| 936 | } |
| 937 | |
Vadim Yanitskiy | 109e755 | 2021-02-05 05:36:02 +0100 | [diff] [blame] | 938 | /* Test reaction on Clear Request during a MO Call */ |
| 939 | friend function f_TC_mo_mt_call_clear_request(charstring id, BSC_ConnHdlrPars pars) |
| 940 | runs on BSC_ConnHdlr { |
| 941 | var CallParameters cpars := valueof(t_CallParams); |
| 942 | var MNCC_PDU mncc_pdu; |
| 943 | timer T := 2.0; |
| 944 | |
| 945 | f_init_handler(pars); |
| 946 | |
| 947 | f_perform_lu(); |
| 948 | |
| 949 | /* HACK: reducing code duplication ('66'H - MO, '68'H - MT) */ |
| 950 | if (pars.imsi == '262420002532766'H) |
| 951 | { f_mo_call_establish(cpars); } |
| 952 | else |
| 953 | { f_mt_call_establish(cpars); } |
| 954 | |
| 955 | /* Hold the line for a while... */ |
| 956 | f_sleep(2.0); |
| 957 | |
| 958 | /* BSC sends BSSMAP Clear Request (e.g. due to RR failure) */ |
| 959 | BSSAP.send(ts_BSSMAP_ClearRequest(1)); |
| 960 | |
| 961 | /* Expect (optional) CC RELEASE and Clear Command */ |
| 962 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
| 963 | f_expect_clear(); |
| 964 | deactivate(ccrel); |
| 965 | |
| 966 | /* Expect RELease indication on the MNCC socket */ |
| 967 | T.start; |
| 968 | alt { |
| 969 | [] MNCC.receive(tr_MNCC_REL_ind(cpars.mncc_callref)) -> value mncc_pdu { |
| 970 | log("Rx MNCC REL.ind, cause := ", mncc_pdu.u.signal.cause); |
| 971 | setverdict(pass); |
| 972 | } |
| 973 | [] MNCC.receive(MNCC_PDU:?) -> value mncc_pdu { |
| 974 | setverdict(fail, "Rx unexpected MNCC PDU: ", mncc_pdu); |
| 975 | } |
| 976 | [] T.timeout { |
| 977 | setverdict(fail, "Timeout waiting for MNCC REL.ind"); |
| 978 | } |
| 979 | } |
| 980 | } |
| 981 | testcase TC_mo_call_clear_request() runs on MTC_CT { |
| 982 | var BSC_ConnHdlr vc_conn; |
| 983 | |
| 984 | f_init(); |
| 985 | |
| 986 | vc_conn := f_start_handler(refers(f_TC_mo_mt_call_clear_request), 2532766); // '66'H - MO |
| 987 | vc_conn.done; |
| 988 | } |
| 989 | testcase TC_mt_call_clear_request() runs on MTC_CT { |
| 990 | var BSC_ConnHdlr vc_conn; |
| 991 | |
| 992 | f_init(); |
| 993 | |
| 994 | vc_conn := f_start_handler(refers(f_TC_mo_mt_call_clear_request), 2532768); // '68'H - MT |
| 995 | vc_conn.done; |
| 996 | } |
| 997 | |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 998 | /* Test LU but BSC will send a clear request in the middle */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 999 | 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] | 1000 | f_init_handler(pars); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1001 | |
| 1002 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 1003 | var PDU_DTAP_MT dtap_mt; |
| 1004 | |
| 1005 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1006 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1007 | |
| 1008 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1009 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1010 | |
| 1011 | /* Send Early Classmark, just for the fun of it */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1012 | if (pars.ran_is_geran) { |
| 1013 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1014 | } |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1015 | |
| 1016 | f_sleep(1.0); |
| 1017 | /* send clear request in the middle of the LU */ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1018 | BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1019 | setverdict(pass); |
Neels Hofmeyr | bb825c9 | 2019-03-06 15:35:50 +0100 | [diff] [blame] | 1020 | f_sleep(1.0); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1021 | } |
| 1022 | testcase TC_lu_disconnect() runs on MTC_CT { |
| 1023 | var BSC_ConnHdlr vc_conn; |
| 1024 | f_init(); |
| 1025 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1026 | vc_conn := f_start_handler(refers(f_tc_lu_disconnect), 11); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1027 | vc_conn.done; |
| 1028 | } |
| 1029 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1030 | /* Test LU but with illegal mobile identity type = IMEI */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1031 | 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] | 1032 | f_init_handler(pars); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1033 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 1034 | 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] | 1035 | var PDU_DTAP_MT dtap_mt; |
| 1036 | |
| 1037 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1038 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1039 | |
| 1040 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1041 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1042 | |
| 1043 | /* Send Early Classmark, just for the fun of it */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1044 | if (pars.ran_is_geran) { |
| 1045 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1046 | } |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1047 | /* wait for LU reject, ignore any ID REQ */ |
| 1048 | alt { |
| 1049 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { } |
| 1050 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req)) { repeat; } |
| 1051 | } |
| 1052 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1053 | f_expect_clear(); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1054 | } |
| 1055 | testcase TC_lu_by_imei() runs on MTC_CT { |
| 1056 | var BSC_ConnHdlr vc_conn; |
| 1057 | f_init(); |
| 1058 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1059 | 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] | 1060 | vc_conn.done; |
| 1061 | } |
| 1062 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1063 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1064 | /* Test LU by TMSI with unknown TMSI, expect (and answer) ID REQ. */ |
| 1065 | 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] | 1066 | /* We piggyback a test for an MSC crash on overlong IMSI (OS#2864) onto this test. */ |
| 1067 | var hexstring overlong_imsi := '012345789ABCDEF0123456789ABCDEF'H; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1068 | f_init_handler(pars); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1069 | |
| 1070 | var PDU_ML3_MS_NW l3_lu := f_build_lu_tmsi('01020304'O); /* FIXME: Random */ |
| 1071 | var PDU_DTAP_MT dtap_mt; |
| 1072 | |
| 1073 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1074 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1075 | |
| 1076 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1077 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1078 | |
| 1079 | /* Send Early Classmark, just for the fun of it */ |
| 1080 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1081 | |
| 1082 | /* Wait for + respond to ID REQ (IMSI) */ |
Oliver Smith | 3289845 | 2019-07-09 12:32:35 +0200 | [diff] [blame] | 1083 | 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] | 1084 | 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] | 1085 | 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] | 1086 | f_expect_common_id(); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1087 | |
| 1088 | /* Expect MSC to do UpdateLocation to HLR; respond to it */ |
| 1089 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 1090 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 1091 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 1092 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 1093 | |
| 1094 | alt { |
Harald Welte | 7ec4fa8 | 2018-01-27 10:57:40 +0100 | [diff] [blame] | 1095 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 1096 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_TmsiRealloc_Cmpl)); |
| 1097 | } |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1098 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 1099 | setverdict(fail, "Expected LU ACK, but received REJ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1100 | mtc.stop; |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1101 | } |
| 1102 | } |
| 1103 | |
Philipp Maier | 9b690e4 | 2018-12-21 11:50:03 +0100 | [diff] [blame] | 1104 | /* Wait for MM-Information (if enabled) */ |
| 1105 | f_expect_mm_info(); |
| 1106 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1107 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1108 | f_expect_clear(); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1109 | } |
| 1110 | testcase TC_lu_by_tmsi_noauth_unknown() runs on MTC_CT { |
| 1111 | var BSC_ConnHdlr vc_conn; |
| 1112 | f_init(); |
| 1113 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1114 | 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] | 1115 | vc_conn.done; |
| 1116 | } |
| 1117 | |
Neels Hofmeyr | fc06c73 | 2020-08-19 12:52:28 +0000 | [diff] [blame] | 1118 | /* Test LU by unknown TMSI, while the IMSI is already attached: osmo-msc should switch to the attached vlr_subscr. */ |
| 1119 | private function f_tc_attached_imsi_lu_unknown_tmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1120 | f_init_handler(pars); |
| 1121 | |
| 1122 | var PDU_ML3_MS_NW l3_lu := f_build_lu_tmsi('56111111'O); |
| 1123 | var PDU_DTAP_MT dtap_mt; |
| 1124 | |
| 1125 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1126 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1127 | |
| 1128 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 1129 | f_cl3_or_initial_ue(l3_lu); |
| 1130 | |
| 1131 | /* Send Early Classmark, just for the fun of it */ |
| 1132 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1133 | |
| 1134 | /* Wait for + respond to ID REQ (IMSI) */ |
| 1135 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req(CM_ID_TYPE_IMSI))); |
| 1136 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp_IMSI(g_pars.imsi))); |
| 1137 | f_expect_common_id(); |
| 1138 | |
| 1139 | /* Expect MSC to do UpdateLocation to HLR; respond to it */ |
| 1140 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 1141 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 1142 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 1143 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 1144 | |
| 1145 | alt { |
| 1146 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 1147 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_TmsiRealloc_Cmpl)); |
| 1148 | } |
| 1149 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 1150 | setverdict(fail, "Expected LU ACK, but received REJ"); |
| 1151 | mtc.stop; |
| 1152 | } |
| 1153 | } |
| 1154 | |
| 1155 | /* Wait for MM-Information (if enabled) */ |
| 1156 | f_expect_mm_info(); |
| 1157 | |
| 1158 | /* wait for normal teardown */ |
| 1159 | f_expect_clear(); |
| 1160 | |
| 1161 | /* Now the same IMSI is still attached in the VLR, and a LU with an unknown TMSI reveals the same IMSI only |
| 1162 | * later during ID Response. osmo-msc first creates a new vlr_subscr for the unknown TMSI, and as soon as the |
| 1163 | * IMSI becomes known, must notice that this IMSI is still regarded as attached, and must not create evil twins. |
| 1164 | */ |
| 1165 | |
| 1166 | /* (since the TMSI Reallocation happened, we could do this with exactly the same TMSI as above, but for test |
| 1167 | * readability just use a different one.) */ |
| 1168 | l3_lu := f_build_lu_tmsi('56222222'O); |
| 1169 | f_cl3_or_initial_ue(l3_lu); |
| 1170 | |
| 1171 | /* Wait for + respond to ID REQ (IMSI) */ |
| 1172 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req(CM_ID_TYPE_IMSI))); |
| 1173 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp_IMSI(g_pars.imsi))); |
| 1174 | f_expect_common_id(); |
| 1175 | |
| 1176 | /* Expect MSC to do UpdateLocation to HLR; respond to it */ |
| 1177 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 1178 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 1179 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 1180 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 1181 | |
| 1182 | alt { |
| 1183 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 1184 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_TmsiRealloc_Cmpl)); |
| 1185 | } |
| 1186 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 1187 | setverdict(fail, "Expected LU ACK, but received REJ"); |
| 1188 | mtc.stop; |
| 1189 | } |
| 1190 | } |
| 1191 | |
| 1192 | /* Wait for MM-Information (if enabled) */ |
| 1193 | f_expect_mm_info(); |
| 1194 | |
| 1195 | /* wait for normal teardown */ |
| 1196 | f_expect_clear(); |
| 1197 | } |
| 1198 | testcase TC_attached_imsi_lu_unknown_tmsi() runs on MTC_CT { |
| 1199 | var BSC_ConnHdlr vc_conn; |
| 1200 | f_init(); |
| 1201 | |
| 1202 | vc_conn := f_start_handler(refers(f_tc_attached_imsi_lu_unknown_tmsi), 56); |
| 1203 | vc_conn.done; |
| 1204 | } |
| 1205 | |
Harald Welte | 4d15fa7 | 2020-08-19 08:58:28 +0200 | [diff] [blame] | 1206 | friend function f_imsi_detach_by_imsi() runs on BSC_ConnHdlr { |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1207 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 1208 | |
| 1209 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1210 | 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] | 1211 | |
| 1212 | /* Send Early Classmark, just for the fun of it? */ |
Harald Welte | 4d15fa7 | 2020-08-19 08:58:28 +0200 | [diff] [blame] | 1213 | if (g_pars.ran_is_geran) { |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1214 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1215 | } |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1216 | |
| 1217 | /* wait for normal teardown */ |
Harald Welte | 4d15fa7 | 2020-08-19 08:58:28 +0200 | [diff] [blame] | 1218 | f_expect_clear(verify_vlr_cell_id := false); |
| 1219 | } |
| 1220 | |
| 1221 | |
| 1222 | /* Test IMSI DETACH (MI=IMSI) */ |
| 1223 | friend function f_tc_imsi_detach_by_imsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1224 | f_init_handler(pars); |
| 1225 | |
| 1226 | f_imsi_detach_by_imsi(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1227 | } |
| 1228 | testcase TC_imsi_detach_by_imsi() runs on MTC_CT { |
| 1229 | var BSC_ConnHdlr vc_conn; |
| 1230 | f_init(); |
| 1231 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1232 | 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] | 1233 | vc_conn.done; |
| 1234 | } |
| 1235 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1236 | |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1237 | /* Test IMSI DETACH (MI=TMSI) */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1238 | 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] | 1239 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1240 | |
| 1241 | var MobileIdentityLV mi := valueof(ts_MI_TMSI_LV('01020304'O)); |
| 1242 | |
| 1243 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1244 | 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] | 1245 | |
| 1246 | /* Send Early Classmark, just for the fun of it? */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1247 | if (pars.ran_is_geran) { |
| 1248 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1249 | } |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1250 | |
| 1251 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1252 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1253 | } |
| 1254 | testcase TC_imsi_detach_by_tmsi() runs on MTC_CT { |
| 1255 | var BSC_ConnHdlr vc_conn; |
| 1256 | f_init(); |
| 1257 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1258 | 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] | 1259 | vc_conn.done; |
| 1260 | } |
| 1261 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1262 | |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1263 | /* Test IMSI DETACH (MI=IMEI), which is illegal */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1264 | 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] | 1265 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1266 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 1267 | var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1268 | |
| 1269 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1270 | 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] | 1271 | |
| 1272 | /* Send Early Classmark, just for the fun of it? */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1273 | if (pars.ran_is_geran) { |
| 1274 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1275 | } |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1276 | |
| 1277 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1278 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1279 | } |
| 1280 | testcase TC_imsi_detach_by_imei() runs on MTC_CT { |
| 1281 | var BSC_ConnHdlr vc_conn; |
| 1282 | f_init(); |
| 1283 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1284 | 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] | 1285 | vc_conn.done; |
| 1286 | } |
| 1287 | |
| 1288 | |
| 1289 | /* helper function for an emergency call. caller passes in mobile identity to use */ |
| 1290 | private function f_emerg_call(MobileIdentityLV mi) runs on BSC_ConnHdlr { |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 1291 | var CallParameters cpars := valueof(t_CallParams('112'H, 0)); |
| 1292 | cpars.emergency := true; |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1293 | |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 1294 | f_mo_call(cpars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1295 | } |
| 1296 | |
| 1297 | /* 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] | 1298 | 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] | 1299 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1300 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 1301 | var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1302 | 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] | 1303 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1304 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ('05'O))); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1305 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1306 | } |
| 1307 | testcase TC_emerg_call_imei_reject() runs on MTC_CT { |
| 1308 | var BSC_ConnHdlr vc_conn; |
| 1309 | f_init(); |
| 1310 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1311 | 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] | 1312 | vc_conn.done; |
| 1313 | } |
| 1314 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1315 | |
Harald Welte | d5b9140 | 2018-01-24 18:48:16 +0100 | [diff] [blame] | 1316 | /* establish an emergency call by IMSI, SIM inserted (and hence IMSI) */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1317 | 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] | 1318 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1319 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1320 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1321 | /* Then issue emergency call identified by IMSI */ |
| 1322 | f_emerg_call(valueof(ts_MI_IMSI_LV(g_pars.imsi))); |
| 1323 | } |
| 1324 | testcase TC_emerg_call_imsi() runs on MTC_CT { |
| 1325 | var BSC_ConnHdlr vc_conn; |
| 1326 | f_init(); |
| 1327 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1328 | vc_conn := f_start_handler(refers(f_tc_emerg_call_imsi), 18); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1329 | vc_conn.done; |
| 1330 | } |
| 1331 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1332 | |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1333 | /* CM Service Request for VGCS -> reject */ |
| 1334 | 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] | 1335 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1336 | |
| 1337 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1338 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1339 | |
| 1340 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1341 | 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] | 1342 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1343 | 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] | 1344 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1345 | } |
| 1346 | testcase TC_cm_serv_req_vgcs_reject() runs on MTC_CT { |
| 1347 | var BSC_ConnHdlr vc_conn; |
| 1348 | f_init(); |
| 1349 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1350 | vc_conn := f_start_handler(refers(f_tc_cm_serv_req_vgcs_reject), 19); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1351 | vc_conn.done; |
| 1352 | } |
| 1353 | |
| 1354 | /* CM Service Request for VBS -> reject */ |
| 1355 | 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] | 1356 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1357 | |
| 1358 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1359 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1360 | |
| 1361 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1362 | 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] | 1363 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1364 | 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] | 1365 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1366 | } |
| 1367 | testcase TC_cm_serv_req_vbs_reject() runs on MTC_CT { |
| 1368 | var BSC_ConnHdlr vc_conn; |
| 1369 | f_init(); |
| 1370 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1371 | 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] | 1372 | vc_conn.done; |
| 1373 | } |
| 1374 | |
| 1375 | /* CM Service Request for LCS -> reject */ |
| 1376 | 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] | 1377 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1378 | |
| 1379 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1380 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1381 | |
| 1382 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1383 | 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] | 1384 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1385 | 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] | 1386 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1387 | } |
| 1388 | testcase TC_cm_serv_req_lcs_reject() runs on MTC_CT { |
| 1389 | var BSC_ConnHdlr vc_conn; |
| 1390 | f_init(); |
| 1391 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1392 | 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] | 1393 | vc_conn.done; |
| 1394 | } |
| 1395 | |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1396 | /* CM Re-Establishment Request */ |
| 1397 | 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] | 1398 | f_init_handler(pars); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1399 | |
| 1400 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1401 | f_perform_lu(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1402 | |
| 1403 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 1404 | 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] | 1405 | f_cl3_or_initial_ue(l3_info); |
Neels Hofmeyr | 49bbb51 | 2021-07-29 22:51:08 +0200 | [diff] [blame] | 1406 | /* Older osmo-msc returns: GSM48_REJECT_SRV_OPT_NOT_SUPPORTED = 32, |
| 1407 | * newer osmo-msc with CM Re-Establish support returns: GSM48_REJECT_CALL_CAN_NOT_BE_IDENTIFIED = 38 */ |
| 1408 | 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] | 1409 | f_expect_clear(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1410 | } |
| 1411 | testcase TC_cm_reest_req_reject() runs on MTC_CT { |
| 1412 | var BSC_ConnHdlr vc_conn; |
| 1413 | f_init(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1414 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1415 | 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] | 1416 | vc_conn.done; |
| 1417 | } |
| 1418 | |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1419 | /* Test LU (with authentication enabled), with wrong response from MS */ |
| 1420 | 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] | 1421 | f_init_handler(pars); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1422 | |
| 1423 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 1424 | |
| 1425 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1426 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1427 | |
| 1428 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1429 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1430 | |
| 1431 | /* Send Early Classmark, just for the fun of it */ |
| 1432 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1433 | |
| 1434 | var AuthVector vec := f_gen_auth_vec_2g(); |
| 1435 | var GSUP_IE auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G(vec.rand, vec.sres, vec.kc)); |
| 1436 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 1437 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
| 1438 | |
| 1439 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_AUTH_REQ(vec.rand))); |
| 1440 | /* Send back wrong auth response */ |
| 1441 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MT_MM_AUTH_RESP_2G('00000000'O))); |
| 1442 | |
| 1443 | /* Expect GSUP AUTH FAIL REP to HLR */ |
| 1444 | GSUP.receive(tr_GSUP_AUTH_FAIL_IND(g_pars.imsi)); |
| 1445 | |
| 1446 | /* Expect LU REJECT with Cause == Illegal MS */ |
| 1447 | 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] | 1448 | f_expect_clear(); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1449 | } |
| 1450 | testcase TC_lu_auth_2G_fail() runs on MTC_CT { |
| 1451 | var BSC_ConnHdlr vc_conn; |
| 1452 | f_init(); |
| 1453 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1454 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1455 | 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] | 1456 | vc_conn.done; |
| 1457 | } |
| 1458 | |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 1459 | /* 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] | 1460 | 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] | 1461 | pars.net.expect_auth := true; |
| 1462 | pars.net.expect_ciph := true; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1463 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1464 | f_perform_lu(); |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 1465 | } |
| 1466 | testcase TC_lu_imsi_auth_tmsi_encr_13_13() runs on MTC_CT { |
| 1467 | var BSC_ConnHdlr vc_conn; |
| 1468 | f_init(); |
| 1469 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 1470 | f_vty_config(MSCVTY, "network", "encryption a5 1 3"); |
| 1471 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1472 | 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] | 1473 | vc_conn.done; |
| 1474 | } |
| 1475 | |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1476 | /* Test Complete L3 without payload */ |
| 1477 | 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] | 1478 | f_init_handler(pars); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1479 | |
| 1480 | /* Send Complete L3 Info with empty L3 frame */ |
| 1481 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own, |
| 1482 | valueof(ts_BSSMAP_ComplL3(g_pars.cell_id, ''O)))); |
| 1483 | |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1484 | timer T := 5.0; |
| 1485 | T.start; |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1486 | alt { |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1487 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1488 | /* Expect LU REJECT with Cause == Illegal MS */ |
Harald Welte | bdb3c45 | 2018-03-18 22:43:06 +0100 | [diff] [blame] | 1489 | [] BSSAP.receive(tr_PDU_DTAP_MT(?)) { repeat; } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1490 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND) { repeat; } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1491 | [] as_clear_cmd_compl_disc(); |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1492 | [] T.timeout { |
Daniel Willmann | 90829d6 | 2018-02-15 17:45:14 +0100 | [diff] [blame] | 1493 | setverdict(fail, "Timeout waiting for ClearCommand or SCCP Release"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1494 | mtc.stop; |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1495 | } |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1496 | } |
| 1497 | setverdict(pass); |
| 1498 | } |
| 1499 | testcase TC_cl3_no_payload() runs on MTC_CT { |
| 1500 | var BSC_ConnHdlr vc_conn; |
| 1501 | f_init(); |
| 1502 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1503 | vc_conn := f_start_handler(refers(f_tc_cl3_no_payload), 25); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1504 | vc_conn.done; |
| 1505 | } |
| 1506 | |
| 1507 | /* Test Complete L3 with random payload */ |
| 1508 | 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] | 1509 | f_init_handler(pars); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1510 | |
Daniel Willmann | aa14a38 | 2018-07-26 08:29:45 +0200 | [diff] [blame] | 1511 | /* length is limited by PDU_BSSAP length field which includes some |
| 1512 | * other fields beside l3info payload. So payl can only be 240 bytes |
| 1513 | * Since rnd() returns values < 1 multiply with 241 |
| 1514 | */ |
| 1515 | var integer len := float2int(rnd() * 241.0); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1516 | var octetstring payl := f_rnd_octstring(len); |
| 1517 | |
| 1518 | /* Send Complete L3 Info with empty L3 frame */ |
| 1519 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own, |
| 1520 | valueof(ts_BSSMAP_ComplL3(g_pars.cell_id, payl)))); |
| 1521 | |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1522 | timer T := 5.0; |
| 1523 | T.start; |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1524 | alt { |
| 1525 | /* Immediate disconnect */ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1526 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1527 | [] BSSAP.receive(tr_PDU_DTAP_MT(?)) { repeat; } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1528 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND) { repeat; } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1529 | [] as_clear_cmd_compl_disc(); |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1530 | [] T.timeout { |
Daniel Willmann | 90829d6 | 2018-02-15 17:45:14 +0100 | [diff] [blame] | 1531 | setverdict(fail, "Timeout waiting for ClearCommand or SCCP Release"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1532 | mtc.stop; |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1533 | } |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1534 | } |
| 1535 | setverdict(pass); |
| 1536 | } |
| 1537 | testcase TC_cl3_rnd_payload() runs on MTC_CT { |
| 1538 | var BSC_ConnHdlr vc_conn; |
| 1539 | f_init(); |
| 1540 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1541 | vc_conn := f_start_handler(refers(f_tc_cl3_rnd_payload), 26); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1542 | vc_conn.done; |
| 1543 | } |
| 1544 | |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1545 | /* Test Complete L3 with random payload */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1546 | 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] | 1547 | f_init_handler(pars); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1548 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1549 | f_perform_lu(); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1550 | |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1551 | f_establish_fully(); |
Daniel Willmann | 898a7e0 | 2018-05-17 12:16:16 +0200 | [diff] [blame] | 1552 | f_expect_clear(10.0); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1553 | } |
| 1554 | testcase TC_establish_and_nothing() runs on MTC_CT { |
| 1555 | var BSC_ConnHdlr vc_conn; |
| 1556 | f_init(); |
| 1557 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1558 | vc_conn := f_start_handler(refers(f_tc_establish_and_nothing), 27); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1559 | vc_conn.done; |
| 1560 | } |
| 1561 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1562 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1563 | /* Test MO Call SETUP with no response from MNCC */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1564 | 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] | 1565 | f_init_handler(pars, 190.0); |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1566 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1567 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1568 | cpars.mgw_conn_2.resp := 0; |
| 1569 | cpars.stop_after_cc_setup := true; |
| 1570 | |
| 1571 | f_vty_config(MSCVTY, "msc", "mncc guard-timeout 20"); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1572 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1573 | f_perform_lu(); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1574 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1575 | f_mo_call_establish(cpars); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1576 | |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 1577 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
| 1578 | |
Philipp Maier | 109e6aa | 2018-10-17 10:53:32 +0200 | [diff] [blame] | 1579 | f_expect_clear(185.0); |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 1580 | |
| 1581 | deactivate(ccrel); |
| 1582 | |
| 1583 | f_sleep(1.0); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1584 | } |
| 1585 | testcase TC_mo_setup_and_nothing() runs on MTC_CT { |
| 1586 | var BSC_ConnHdlr vc_conn; |
| 1587 | f_init(); |
| 1588 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1589 | 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] | 1590 | vc_conn.done; |
| 1591 | } |
| 1592 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1593 | |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1594 | /* Test MO Call with no response to RAN-side CRCX */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1595 | 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] | 1596 | f_init_handler(pars); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1597 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1598 | var MNCC_PDU mncc; |
| 1599 | var MgcpCommand mgcp_cmd; |
| 1600 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1601 | f_perform_lu(); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1602 | /* Do not respond to the second CRCX */ |
| 1603 | cpars.mgw_conn_2.resp := 0; |
| 1604 | f_mo_call_establish(cpars); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1605 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1606 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1607 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1608 | f_expect_clear(60.0); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1609 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1610 | deactivate(ccrel); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1611 | } |
| 1612 | testcase TC_mo_crcx_ran_timeout() runs on MTC_CT { |
| 1613 | var BSC_ConnHdlr vc_conn; |
| 1614 | f_init(); |
| 1615 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1616 | 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] | 1617 | vc_conn.done; |
| 1618 | } |
| 1619 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1620 | |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1621 | /* Test MO Call with reject to RAN-side CRCX */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1622 | 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] | 1623 | f_init_handler(pars); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1624 | |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1625 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1626 | |
| 1627 | /* Respond with error for the first CRCX */ |
| 1628 | cpars.mgw_conn_1.resp := -1; |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1629 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1630 | f_perform_lu(); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1631 | f_mo_call_establish(cpars); |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1632 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1633 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
| 1634 | f_expect_clear(60.0); |
| 1635 | deactivate(ccrel); |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1636 | } |
| 1637 | testcase TC_mo_crcx_ran_reject() runs on MTC_CT { |
| 1638 | var BSC_ConnHdlr vc_conn; |
| 1639 | f_init(); |
| 1640 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1641 | 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] | 1642 | vc_conn.done; |
| 1643 | } |
| 1644 | |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1645 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1646 | /* helper function to start a MT call: MNCC SETUP; Paging; DChan est.; DTAP SETUP */ |
| 1647 | private function f_mt_call_start(inout CallParameters cpars) runs on BSC_ConnHdlr { |
| 1648 | var MNCC_PDU mncc; |
| 1649 | var MgcpCommand mgcp_cmd; |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1650 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1651 | f_perform_lu(); |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 1652 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1653 | |
| 1654 | /* Allocate call reference and send SETUP via MNCC to MSC */ |
| 1655 | cpars.mncc_callref := f_rnd_int(2147483648); |
| 1656 | MNCC.send(ts_MNCC_SETUP_req(cpars.mncc_callref, hex2str(g_pars.msisdn), |
| 1657 | hex2str(cpars.called_party), hex2str(g_pars.imsi))); |
| 1658 | |
| 1659 | /* MSC->BSC: expect PAGING from MSC */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 1660 | f_expect_paging(); |
| 1661 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1662 | /* MS -> MSC: PAGING RESPONSE */ |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1663 | f_establish_fully(EST_TYPE_PAG_RESP); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1664 | |
| 1665 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1666 | |
| 1667 | /* MSC->MS: SETUP */ |
| 1668 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_SETUP(cpars.transaction_id, *, cpars.called_party))); |
| 1669 | } |
| 1670 | |
| 1671 | /* Test MT Call */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1672 | 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] | 1673 | f_init_handler(pars); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1674 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
| 1675 | var MNCC_PDU mncc; |
| 1676 | var MgcpCommand mgcp_cmd; |
| 1677 | |
| 1678 | f_mt_call_start(cpars); |
| 1679 | |
| 1680 | /* MS->MSC: CALL CONFIRMED */ |
| 1681 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CALL_CONF(cpars.transaction_id))); |
| 1682 | |
| 1683 | MNCC.receive(tr_MNCC_CALL_CONF_ind(cpars.mncc_callref)); |
| 1684 | |
| 1685 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
| 1686 | cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 1687 | |
| 1688 | /* Detect if the received CRCX is a wildcarded CRCX request. If yes, |
| 1689 | * set an endpoint name that fits the pattern. If not, just use the |
| 1690 | * endpoint name from the request */ |
| 1691 | if (match(mgcp_cmd.line.ep, t_MGCP_EP_wildcard)) { |
| 1692 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
| 1693 | } else { |
| 1694 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
| 1695 | } |
| 1696 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1697 | /* Respond to CRCX with error */ |
| 1698 | var MgcpResponse mgcp_rsp := { |
| 1699 | line := { |
| 1700 | code := "542", |
| 1701 | trans_id := mgcp_cmd.line.trans_id, |
| 1702 | string := "FORCED_FAIL" |
| 1703 | }, |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1704 | sdp := omit |
| 1705 | } |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 1706 | var MgcpParameter mgcp_rsp_param := { |
| 1707 | code := "Z", |
| 1708 | val := cpars.mgcp_ep |
| 1709 | }; |
| 1710 | mgcp_rsp.params[0] := mgcp_rsp_param; |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1711 | MGCP.send(mgcp_rsp); |
| 1712 | |
| 1713 | timer T := 30.0; |
| 1714 | T.start; |
| 1715 | alt { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1716 | [] T.timeout { |
| 1717 | setverdict(fail, "Timeout waiting for channel release"); |
| 1718 | mtc.stop; |
| 1719 | } |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1720 | [] MNCC.receive { repeat; } |
| 1721 | [] GSUP.receive { repeat; } |
| 1722 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 1723 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
| 1724 | f_create_mgcp_delete_ep(cpars.mgcp_ep); |
| 1725 | repeat; |
| 1726 | } |
| 1727 | [] MGCP.receive { repeat; } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1728 | [] as_clear_cmd_compl_disc(); |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 1729 | [] as_optional_cc_rel(cpars); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1730 | } |
| 1731 | } |
| 1732 | testcase TC_mt_crcx_ran_reject() runs on MTC_CT { |
| 1733 | var BSC_ConnHdlr vc_conn; |
| 1734 | f_init(); |
| 1735 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1736 | 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] | 1737 | vc_conn.done; |
| 1738 | } |
| 1739 | |
| 1740 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1741 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1742 | /* Test MT Call T310 timer */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1743 | 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] | 1744 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1745 | var MgcpCommand mgcp_cmd; |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1746 | var PDU_BSSAP bssap; |
| 1747 | timer T310; |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1748 | |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1749 | f_init_handler(pars); |
| 1750 | |
| 1751 | /* Initiate a MT call, establish connection */ |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1752 | f_mt_call_start(cpars); |
| 1753 | |
| 1754 | /* MS->MSC: CALL CONFIRMED */ |
| 1755 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CALL_CONF(cpars.transaction_id))); |
| 1756 | MNCC.receive(tr_MNCC_CALL_CONF_ind(cpars.mncc_callref)); |
| 1757 | |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1758 | /* NOTE: MSC is expected to start T310 here */ |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1759 | |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1760 | /* MSC->MGW: CRCX (first) */ |
| 1761 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
| 1762 | f_handle_crcx(cpars, mgcp_cmd); /* MSC<-MGW: OK */ |
| 1763 | |
| 1764 | /* BSC->BSC: BSSMAP ASSIGNMENT REQ */ |
| 1765 | BSSAP.receive(tr_BSSMAP_AssignmentReq(omit, ?)) -> value bssap; |
| 1766 | BSSAP.send(ts_BSSMAP_AssignmentComplete(omit, |
| 1767 | aoip := f_ts_BSSMAP_IE_AoIP_TLA(cpars.bss_rtp_ip, cpars.bss_rtp_port), |
| 1768 | speechCodec := ts_BSSMAP_IE_SpeechCodec({ ts_CodecFR }))); |
| 1769 | |
| 1770 | /* MSC->MGW: MDCX */ |
| 1771 | MGCP.receive(tr_MDCX) -> value mgcp_cmd; |
| 1772 | MGCP.send(ts_MDCX_ACK(mgcp_cmd.line.trans_id, cpars.mgw_conn_1.mgcp_connection_id, |
| 1773 | sdp := omit)); |
| 1774 | |
| 1775 | /* MSC->MGW: CRCX (second) */ |
| 1776 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
| 1777 | f_handle_crcx(cpars, mgcp_cmd); /* MSC<-MGW: OK */ |
| 1778 | MNCC.receive(tr_MNCC_RTP_CREATE(cpars.mncc_callref)); |
| 1779 | |
| 1780 | /* Reschedule the guard timeout */ |
| 1781 | g_Tguard.start(30.0 + 10.0); |
| 1782 | |
| 1783 | /* NOTE: the BSC is expected to respond with CC ALERTING at this state, so |
| 1784 | * the MSC would stop T310. However, the idea is to verify T310 expiration |
| 1785 | * here, so grab some popcorn and wait for MNCC DISC.ind. */ |
| 1786 | T310.start(30.0 + 2.0); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1787 | alt { |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1788 | [] T310.timeout { |
| 1789 | setverdict(fail, "Timeout waiting for MNCC DISC.ind due to T310"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1790 | mtc.stop; |
| 1791 | } |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1792 | [] MNCC.receive(tr_MNCC_DISC_ind(cpars.mncc_callref)) { |
| 1793 | 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] | 1794 | log("Rx MNCC DISC.ind, T310.read yelds ", T310.read); |
| 1795 | setverdict(pass); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1796 | } |
| 1797 | } |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1798 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1799 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_DISC(cpars.transaction_id))); |
| 1800 | 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] | 1801 | 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] | 1802 | |
| 1803 | alt { |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1804 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 1805 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1806 | // FIXME: f_create_mgcp_delete_ep(cpars.mgcp_ep); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1807 | repeat; |
| 1808 | } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1809 | [] as_clear_cmd_compl_disc(); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1810 | } |
| 1811 | } |
| 1812 | testcase TC_mt_t310() runs on MTC_CT { |
| 1813 | var BSC_ConnHdlr vc_conn; |
| 1814 | f_init(); |
| 1815 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1816 | vc_conn := f_start_handler(refers(f_tc_mt_t310), 32); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1817 | vc_conn.done; |
| 1818 | } |
| 1819 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1820 | |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1821 | /* 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] | 1822 | 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] | 1823 | f_init_handler(pars); |
| 1824 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1825 | |
| 1826 | /* Location Update to make subscriber known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1827 | f_perform_lu(); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1828 | |
| 1829 | /* First MO call should succeed */ |
| 1830 | f_mo_call(cpars); |
| 1831 | |
| 1832 | /* Cancel the subscriber in the VLR */ |
| 1833 | GSUP.send(ts_GSUP_CL_REQ(g_pars.imsi, OSMO_GSUP_CANCEL_TYPE_WITHDRAW)); |
| 1834 | alt { |
| 1835 | [] GSUP.receive(tr_GSUP_CL_RES(g_pars.imsi)) { } |
| 1836 | [] GSUP.receive(tr_GSUP_CL_ERR(g_pars.imsi)) { |
| 1837 | setverdict(fail, "Received GSUP Location Cancel Error"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1838 | mtc.stop; |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1839 | } |
| 1840 | } |
| 1841 | |
| 1842 | /* Follow-up transactions should fail */ |
| 1843 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 1844 | 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] | 1845 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1846 | alt { |
| 1847 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)) { } |
| 1848 | [] BSSAP.receive { |
| 1849 | setverdict(fail, "Received unexpected BSSAP instead of CM SERV REJ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1850 | mtc.stop; |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1851 | } |
| 1852 | } |
Neels Hofmeyr | 0f7429a | 2019-03-07 22:28:41 +0100 | [diff] [blame] | 1853 | |
| 1854 | f_expect_clear(); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1855 | setverdict(pass); |
| 1856 | } |
| 1857 | testcase TC_gsup_cancel() runs on MTC_CT { |
| 1858 | var BSC_ConnHdlr vc_conn; |
| 1859 | f_init(); |
| 1860 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1861 | 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] | 1862 | vc_conn.done; |
| 1863 | } |
| 1864 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1865 | |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1866 | /* A5/1 only permitted on network side, and MS capable to do it */ |
| 1867 | private function f_tc_lu_imsi_auth_tmsi_encr_1_13(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1868 | pars.net.expect_auth := true; |
| 1869 | pars.net.expect_ciph := true; |
| 1870 | pars.net.kc_support := '02'O; /* A5/1 only */ |
| 1871 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1872 | f_perform_lu(); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1873 | } |
| 1874 | testcase TC_lu_imsi_auth_tmsi_encr_1_13() runs on MTC_CT { |
| 1875 | var BSC_ConnHdlr vc_conn; |
| 1876 | f_init(); |
| 1877 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1878 | f_vty_config(MSCVTY, "network", "encryption a5 1"); |
| 1879 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1880 | 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] | 1881 | vc_conn.done; |
| 1882 | } |
| 1883 | |
| 1884 | /* A5/3 only permitted on network side, and MS capable to do it */ |
| 1885 | private function f_tc_lu_imsi_auth_tmsi_encr_3_13(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1886 | pars.net.expect_auth := true; |
| 1887 | pars.net.expect_ciph := true; |
| 1888 | pars.net.kc_support := '08'O; /* A5/3 only */ |
| 1889 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1890 | f_perform_lu(); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1891 | } |
| 1892 | testcase TC_lu_imsi_auth_tmsi_encr_3_13() runs on MTC_CT { |
| 1893 | var BSC_ConnHdlr vc_conn; |
| 1894 | f_init(); |
| 1895 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1896 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1897 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1898 | 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] | 1899 | vc_conn.done; |
| 1900 | } |
| 1901 | |
| 1902 | /* A5/3 only permitted on network side, and MS with only A5/1 support */ |
| 1903 | private function f_tc_lu_imsi_auth_tmsi_encr_3_1(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1904 | pars.net.expect_auth := true; |
| 1905 | pars.net.expect_ciph := true; |
| 1906 | pars.net.kc_support := '08'O; /* A5/3 only */ |
| 1907 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 1908 | f_init_handler(pars, 15.0); |
| 1909 | |
| 1910 | /* cannot use f_perform_lu() as we expect a reject */ |
| 1911 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 1912 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1913 | f_cl3_or_initial_ue(l3_lu); |
Neels Hofmeyr | 29b8da0 | 2018-03-01 18:09:45 +0100 | [diff] [blame] | 1914 | if (pars.send_early_cm) { |
| 1915 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1916 | } else { |
| 1917 | pars.cm1.esind := '0'B; |
| 1918 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1919 | f_mm_auth(); |
| 1920 | alt { |
Daniel Willmann | 52918e5 | 2018-09-20 14:39:09 +0200 | [diff] [blame] | 1921 | [] BSSAP.receive(tr_BSSMAP_ClassmarkReq) { |
| 1922 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1923 | repeat; |
| 1924 | } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1925 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 1926 | f_expect_clear(); |
| 1927 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1928 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?,?)) { |
| 1929 | setverdict(fail, "CipherModeCommand despite no A5 intersection"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1930 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1931 | } |
| 1932 | [] BSSAP.receive { |
Harald Welte | 458fd37 | 2018-03-21 11:26:23 +0100 | [diff] [blame] | 1933 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1934 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1935 | } |
| 1936 | } |
| 1937 | setverdict(pass); |
| 1938 | } |
| 1939 | testcase TC_lu_imsi_auth_tmsi_encr_3_1() runs on MTC_CT { |
| 1940 | var BSC_ConnHdlr vc_conn; |
| 1941 | f_init(); |
| 1942 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1943 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1944 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1945 | 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] | 1946 | vc_conn.done; |
| 1947 | } |
| 1948 | testcase TC_lu_imsi_auth_tmsi_encr_3_1_no_cm() runs on MTC_CT { |
| 1949 | var BSC_ConnHdlrPars pars; |
| 1950 | var BSC_ConnHdlr vc_conn; |
| 1951 | f_init(); |
| 1952 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1953 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1954 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1955 | pars := f_init_pars(361, verify_cell_id := false); |
Neels Hofmeyr | 29b8da0 | 2018-03-01 18:09:45 +0100 | [diff] [blame] | 1956 | pars.send_early_cm := false; |
| 1957 | 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] | 1958 | vc_conn.done; |
| 1959 | } |
Neels Hofmeyr | 1b3c6e3 | 2018-03-01 17:52:21 +0100 | [diff] [blame] | 1960 | testcase TC_lu_imsi_auth_tmsi_encr_3_1_log_msc_debug() runs on MTC_CT { |
| 1961 | var BSC_ConnHdlr vc_conn; |
| 1962 | f_init(); |
| 1963 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1964 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1965 | |
| 1966 | /* Make sure the MSC category is on DEBUG level to trigger the log |
| 1967 | * message that is reported in OS#2947 to trigger the segfault */ |
| 1968 | f_vty_config(MSCVTY, "log stderr", "logging level msc debug"); |
| 1969 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1970 | 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] | 1971 | vc_conn.done; |
| 1972 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1973 | |
| 1974 | /* A5/1 + A5/3 only permitted on network side, and MS with only A5/2 support */ |
| 1975 | private function f_tc_lu_imsi_auth_tmsi_encr_13_2(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1976 | pars.net.expect_auth := true; |
| 1977 | pars.net.expect_ciph := true; |
| 1978 | pars.net.kc_support := '0A'O; /* A5/1 + A5/3 */ |
| 1979 | pars.cm1.a5_1 := '1'B; |
| 1980 | pars.cm2.a5_1 := '1'B; |
| 1981 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 1982 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '1'B; |
| 1983 | f_init_handler(pars, 15.0); |
| 1984 | |
| 1985 | /* cannot use f_perform_lu() as we expect a reject */ |
| 1986 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 1987 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1988 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1989 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1990 | f_mm_auth(); |
| 1991 | alt { |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1992 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 1993 | f_expect_clear(); |
| 1994 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1995 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?,?)) { |
| 1996 | setverdict(fail, "CipherModeCommand despite no A5 intersection"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1997 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1998 | } |
| 1999 | [] BSSAP.receive { |
Harald Welte | 458fd37 | 2018-03-21 11:26:23 +0100 | [diff] [blame] | 2000 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2001 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2002 | } |
| 2003 | } |
| 2004 | setverdict(pass); |
| 2005 | } |
| 2006 | testcase TC_lu_imsi_auth_tmsi_encr_13_2() runs on MTC_CT { |
| 2007 | var BSC_ConnHdlr vc_conn; |
| 2008 | f_init(); |
| 2009 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 2010 | f_vty_config(MSCVTY, "network", "encryption a5 1 3"); |
| 2011 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 2012 | 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] | 2013 | vc_conn.done; |
| 2014 | } |
| 2015 | |
Eric Wild | 26f4a62 | 2021-05-17 15:27:05 +0200 | [diff] [blame] | 2016 | /* A5/0 + A5/1 + A5/3 + a5/4 only permitted on network side, and MS with only A5/1 support */ |
| 2017 | private function f_tc_lu_imsi_auth_tmsi_encr_0134_1(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2018 | pars.net.expect_auth := true; |
| 2019 | pars.net.expect_ciph := true; |
| 2020 | pars.net.kc_support := '03'O; /* A5/0 + A5/1 */ |
| 2021 | pars.cm1.a5_1 := '0'B; |
| 2022 | pars.cm2.a5_1 := '0'B; |
| 2023 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 2024 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '0'B; |
| 2025 | pars.cm2.classmarkInformationType2_oct5.cm3 := '0'B; |
| 2026 | pars.cm3 := omit; |
| 2027 | pars.use_umts_aka := true; |
| 2028 | |
| 2029 | f_init_handler(pars, 15.0); |
| 2030 | f_perform_lu(); |
| 2031 | } |
| 2032 | testcase TC_lu_imsi_auth_tmsi_encr_0134_1() runs on MTC_CT { |
| 2033 | var BSC_ConnHdlr vc_conn; |
| 2034 | f_init(); |
| 2035 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 2036 | f_vty_config(MSCVTY, "network", "encryption a5 0 1 3 4"); |
| 2037 | |
| 2038 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_0134_1), 39); |
| 2039 | vc_conn.done; |
| 2040 | } |
| 2041 | |
| 2042 | /* A5/0 + A5/1 + A5/3 + a5/4 only permitted on network side, and MS with A5/3 + A5/4 support */ |
| 2043 | private function f_tc_lu_imsi_auth_tmsi_encr_0134_34(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2044 | pars.net.expect_auth := true; |
| 2045 | pars.net.expect_ciph := true; |
| 2046 | pars.net.kc_support := '19'O; /* A5/3 + A5/4 */ |
| 2047 | pars.cm1.a5_1 := '1'B; |
| 2048 | pars.cm2.a5_1 := '1'B; |
| 2049 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '1'B; |
| 2050 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '0'B; |
| 2051 | pars.cm2.classmarkInformationType2_oct5.cm3 := '1'B; |
| 2052 | pars.cm3 := valueof(ts_CM3_default); |
| 2053 | pars.use_umts_aka := true; |
| 2054 | |
| 2055 | f_init_handler(pars, 15.0); |
| 2056 | f_perform_lu(); |
| 2057 | } |
| 2058 | testcase TC_lu_imsi_auth_tmsi_encr_0134_34() runs on MTC_CT { |
| 2059 | var BSC_ConnHdlr vc_conn; |
| 2060 | f_init(); |
| 2061 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 2062 | f_vty_config(MSCVTY, "network", "encryption a5 0 1 3 4"); |
| 2063 | |
| 2064 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_0134_34), 40); |
| 2065 | vc_conn.done; |
| 2066 | } |
| 2067 | |
| 2068 | /* A5/0 + A5/1 + A5/3 + a5/4 only permitted on network side, and MS with A5/3 support but no CM3 */ |
| 2069 | private function f_tc_lu_imsi_auth_tmsi_encr_0134_34_no_cm3(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2070 | pars.net.expect_auth := true; |
| 2071 | pars.net.expect_ciph := true; |
| 2072 | pars.net.kc_support := '19'O; /* A5/3 + A5/4 */ |
| 2073 | pars.cm1.a5_1 := '1'B; |
| 2074 | pars.cm2.a5_1 := '1'B; |
| 2075 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '1'B; |
| 2076 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '0'B; |
| 2077 | pars.cm2.classmarkInformationType2_oct5.cm3 := '0'B; |
| 2078 | pars.cm3 := omit; |
| 2079 | pars.use_umts_aka := true; |
| 2080 | |
| 2081 | f_init_handler(pars, 15.0); |
| 2082 | f_perform_lu(); |
| 2083 | } |
| 2084 | testcase TC_lu_imsi_auth_tmsi_encr_0134_34_no_cm3() runs on MTC_CT { |
| 2085 | var BSC_ConnHdlr vc_conn; |
| 2086 | f_init(); |
| 2087 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 2088 | f_vty_config(MSCVTY, "network", "encryption a5 0 1 3 4"); |
| 2089 | |
| 2090 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_0134_34_no_cm3), 41); |
| 2091 | vc_conn.done; |
| 2092 | } |
| 2093 | |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2094 | /* A5/0 + A5/1 + A5/3 only permitted on network side, and MS with only A5/2 support */ |
| 2095 | private function f_tc_lu_imsi_auth_tmsi_encr_013_2(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2096 | pars.net.expect_auth := true; |
| 2097 | pars.net.expect_ciph := true; |
| 2098 | pars.net.kc_support := '0B'O; /* A5/1 + A5/3 */ |
| 2099 | pars.cm1.a5_1 := '1'B; |
| 2100 | pars.cm2.a5_1 := '1'B; |
| 2101 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 2102 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '1'B; |
| 2103 | f_init_handler(pars, 15.0); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 2104 | f_perform_lu(); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2105 | } |
| 2106 | testcase TC_lu_imsi_auth_tmsi_encr_013_2() runs on MTC_CT { |
| 2107 | var BSC_ConnHdlr vc_conn; |
| 2108 | f_init(); |
| 2109 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 2110 | f_vty_config(MSCVTY, "network", "encryption a5 0 1 3"); |
| 2111 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 2112 | 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] | 2113 | vc_conn.done; |
| 2114 | } |
| 2115 | |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 2116 | /* LU followed by MT call (including paging) */ |
Neels Hofmeyr | 8fe8a90 | 2019-11-03 05:51:03 +0100 | [diff] [blame] | 2117 | 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] | 2118 | f_init_handler(pars); |
Stefan Sperling | 26d57be | 2018-11-12 17:03:26 +0100 | [diff] [blame] | 2119 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 2120 | cpars.use_osmux := pars.use_osmux; |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 2121 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 2122 | f_perform_lu(); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 2123 | f_mt_call(cpars); |
| 2124 | } |
| 2125 | testcase TC_lu_and_mt_call() runs on MTC_CT { |
| 2126 | var BSC_ConnHdlr vc_conn; |
| 2127 | f_init(); |
| 2128 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 2129 | 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] | 2130 | vc_conn.done; |
| 2131 | } |
| 2132 | |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 2133 | testcase TC_lu_and_mt_call_osmux() runs on MTC_CT { |
| 2134 | var BSC_ConnHdlr vc_conn; |
| 2135 | f_init(1, false, true, true); |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 2136 | |
| 2137 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_call), 39, 0, true, true); |
| 2138 | vc_conn.done; |
| 2139 | } |
| 2140 | |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 2141 | /* LU followed by MT call (including paging) */ |
| 2142 | friend function f_tc_lu_and_mt_call_ipv6(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2143 | f_init_handler(pars); |
| 2144 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 2145 | cpars.mgw_conn_1.mgw_rtp_ip := "::1"; |
| 2146 | cpars.mgw_conn_2.mgw_rtp_ip := "::2"; |
| 2147 | cpars.bss_rtp_ip := "::3"; |
Pau Espin Pedrol | 563b3d0 | 2020-09-09 20:19:52 +0200 | [diff] [blame] | 2148 | cpars.mncc_rtp_ip := "::9"; |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 2149 | f_perform_lu(); |
| 2150 | f_mt_call(cpars); |
| 2151 | } |
| 2152 | testcase TC_lu_and_mt_call_ipv6() runs on MTC_CT { |
| 2153 | var BSC_ConnHdlr vc_conn; |
| 2154 | f_init(); |
| 2155 | |
| 2156 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_call_ipv6), 39); |
| 2157 | vc_conn.done; |
| 2158 | } |
| 2159 | |
Neels Hofmeyr | b58d974 | 2019-11-27 18:44:54 +0100 | [diff] [blame] | 2160 | /* MT call while already Paging */ |
| 2161 | friend function f_tc_lu_and_mt_call_already_paging(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2162 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
| 2163 | var SmsParameters spars := valueof(t_SmsPars); |
| 2164 | var OCT4 tmsi; |
| 2165 | |
| 2166 | f_init_handler(pars); |
| 2167 | |
| 2168 | /* Perform location update */ |
| 2169 | f_perform_lu(); |
| 2170 | |
| 2171 | /* register an 'expect' for given IMSI (+TMSI) */ |
| 2172 | if (isvalue(g_pars.tmsi)) { |
| 2173 | tmsi := g_pars.tmsi; |
| 2174 | } else { |
| 2175 | tmsi := 'FFFFFFFF'O; |
| 2176 | } |
| 2177 | f_ran_register_imsi(g_pars.imsi, tmsi); |
| 2178 | |
| 2179 | log("start Paging by an SMS"); |
| 2180 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 2181 | |
| 2182 | /* MSC->BSC: expect PAGING from MSC */ |
| 2183 | f_expect_paging(); |
| 2184 | |
| 2185 | log("MNCC signals MT call, before Paging Response"); |
| 2186 | f_mt_call_initate(cpars); |
| 2187 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
| 2188 | |
| 2189 | f_sleep(0.5); |
| 2190 | log("phone answers Paging, expecting both SMS and MT call to be established"); |
| 2191 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2192 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 2193 | interleave { |
| 2194 | [] BSSAP.receive(f_mt_sms_deliver_pdu(spars)) { |
| 2195 | log("Got SMS-DELIVER"); |
| 2196 | }; |
| 2197 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_SETUP(cpars.transaction_id, *, cpars.called_party))) { |
| 2198 | log("Got CC Setup"); |
| 2199 | }; |
| 2200 | } |
| 2201 | setverdict(pass); |
| 2202 | log("success, tear down"); |
| 2203 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
| 2204 | if (g_pars.ran_is_geran) { |
| 2205 | BSSAP.send(ts_BSSMAP_ClearRequest(0)); |
| 2206 | } else { |
| 2207 | BSSAP.send(ts_RANAP_IuReleaseRequest(ts_RanapCause_om_intervention)); |
| 2208 | } |
| 2209 | f_expect_clear(); |
| 2210 | deactivate(ccrel); |
| 2211 | f_vty_sms_clear(hex2str(g_pars.imsi)); |
| 2212 | } |
| 2213 | testcase TC_lu_and_mt_call_already_paging() runs on MTC_CT { |
| 2214 | var BSC_ConnHdlrPars pars; |
| 2215 | var BSC_ConnHdlr vc_conn; |
| 2216 | f_init(); |
| 2217 | pars := f_init_pars(391); |
| 2218 | vc_conn := f_start_handler_with_pars(refers(f_tc_lu_and_mt_call_already_paging), pars); |
| 2219 | vc_conn.done; |
| 2220 | } |
| 2221 | |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 2222 | /* Test MO Call SETUP with DTMF */ |
| 2223 | private function f_tc_mo_setup_dtmf_dup(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2224 | f_init_handler(pars); |
| 2225 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 2226 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 2227 | f_perform_lu(); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 2228 | f_mo_seq_dtmf_dup(cpars); |
| 2229 | } |
| 2230 | testcase TC_mo_setup_and_dtmf_dup() runs on MTC_CT { |
| 2231 | var BSC_ConnHdlr vc_conn; |
| 2232 | f_init(); |
| 2233 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 2234 | 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] | 2235 | vc_conn.done; |
| 2236 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2237 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 2238 | testcase TC_cr_before_reset() runs on MTC_CT { |
| 2239 | timer T := 4.0; |
| 2240 | var boolean reset_ack_seen := false; |
| 2241 | f_init_bssap_direct(); |
| 2242 | |
Harald Welte | 3ca0ce1 | 2019-04-23 17:18:48 +0200 | [diff] [blame] | 2243 | f_ran_adapter_start(g_bssap[0]); |
Daniel Willmann | 42d1d5b | 2018-08-07 15:18:41 +0200 | [diff] [blame] | 2244 | |
Daniel Willmann | e801896 | 2018-08-21 14:18:00 +0200 | [diff] [blame] | 2245 | f_sleep(3.0); |
| 2246 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 2247 | /* Make a blind connection attemt, to trigger the deadlock condition */ |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 2248 | 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] | 2249 | |
| 2250 | /* Send a BSSMAP reset */ |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 2251 | 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] | 2252 | T.start |
| 2253 | alt { |
| 2254 | [] BSSAP_DIRECT.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_ResetAck)) { |
| 2255 | reset_ack_seen := true; |
| 2256 | repeat; |
| 2257 | } |
| 2258 | |
| 2259 | /* Acknowledge MSC sided reset requests */ |
| 2260 | [] BSSAP_DIRECT.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) { |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 2261 | 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] | 2262 | repeat; |
| 2263 | } |
| 2264 | |
| 2265 | /* Ignore all other messages (e.g CR from the connection request) */ |
| 2266 | [] BSSAP_DIRECT.receive { repeat } |
| 2267 | |
| 2268 | /* If we got no BSSMAP RESET ACK back, then the MSC entered the |
| 2269 | * deadlock situation. The MSC is then unable to respond to any |
| 2270 | * further BSSMAP RESET or any other sort of traffic. */ |
| 2271 | [reset_ack_seen == true] T.timeout { setverdict(pass) } |
| 2272 | [reset_ack_seen == false] T.timeout { |
| 2273 | setverdict(fail, "no BSSMAP RESET ACK seen!"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2274 | mtc.stop; |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 2275 | } |
Pau Espin Pedrol | 7e9178d | 2019-12-17 17:52:17 +0100 | [diff] [blame] | 2276 | } |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 2277 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2278 | |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 2279 | /* 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] | 2280 | 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] | 2281 | f_init_handler(pars); |
| 2282 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 2283 | var MNCC_PDU mncc; |
| 2284 | var MgcpCommand mgcp_cmd; |
| 2285 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 2286 | /* Do not respond to the second CRCX */ |
| 2287 | cpars.mgw_conn_2.resp := 0; |
| 2288 | |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 2289 | f_perform_lu(); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 2290 | f_mo_call_establish(cpars); |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 2291 | |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 2292 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 2293 | |
| 2294 | f_expect_clear(60.0); |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 2295 | |
| 2296 | deactivate(ccrel); |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 2297 | } |
| 2298 | testcase TC_mo_release_timeout() runs on MTC_CT { |
| 2299 | var BSC_ConnHdlr vc_conn; |
| 2300 | f_init(); |
| 2301 | |
| 2302 | vc_conn := f_start_handler(refers(f_tc_mo_release_timeout), 40); |
| 2303 | vc_conn.done; |
| 2304 | } |
| 2305 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 2306 | |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 2307 | /* LU followed by MT call (including paging) */ |
| 2308 | private function f_tc_lu_and_mt_call_no_dlcx_resp(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2309 | f_init_handler(pars); |
Stefan Sperling | 26d57be | 2018-11-12 17:03:26 +0100 | [diff] [blame] | 2310 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 2311 | |
| 2312 | /* Intentionally disable the CRCX response */ |
| 2313 | cpars.mgw_drop_dlcx := true; |
| 2314 | |
| 2315 | /* Perform location update and call */ |
| 2316 | f_perform_lu(); |
| 2317 | f_mt_call(cpars); |
| 2318 | } |
| 2319 | testcase TC_lu_and_mt_call_no_dlcx_resp() runs on MTC_CT { |
| 2320 | var BSC_ConnHdlr vc_conn; |
| 2321 | f_init(); |
| 2322 | |
| 2323 | /* Perform an almost normal looking locationupdate + mt-call, but do |
| 2324 | * not respond to the DLCX at the end of the call */ |
| 2325 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_call_no_dlcx_resp), 41); |
| 2326 | vc_conn.done; |
| 2327 | |
| 2328 | /* Wait a guard period until the MGCP layer in the MSC times out, |
| 2329 | * if the MSC is vulnerable to the use-after-free situation that is |
| 2330 | * fixed by I78f1b6a9149488a4ad3f120c1e190a83c07d4b89 then it should |
| 2331 | * segfault now */ |
| 2332 | f_sleep(6.0); |
| 2333 | |
| 2334 | /* Run the init procedures once more. If the MSC has crashed, this |
| 2335 | * this will fail */ |
| 2336 | f_init(); |
| 2337 | } |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 2338 | |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 2339 | /* Two BSSMAP resets from two different BSCs */ |
| 2340 | testcase TC_reset_two() runs on MTC_CT { |
| 2341 | var BSC_ConnHdlr vc_conn; |
| 2342 | f_init(2); |
| 2343 | f_sleep(2.0); |
| 2344 | setverdict(pass); |
| 2345 | } |
| 2346 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2347 | /* Two BSSMAP resets from two different BSCs plus one IuCS RANAP Reset */ |
| 2348 | testcase TC_reset_two_1iu() runs on MTC_CT { |
| 2349 | var BSC_ConnHdlr vc_conn; |
| 2350 | f_init(3); |
| 2351 | f_sleep(2.0); |
| 2352 | setverdict(pass); |
| 2353 | } |
| 2354 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2355 | /*********************************************************************** |
| 2356 | * SMS Testing |
| 2357 | ***********************************************************************/ |
| 2358 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2359 | /* LU followed by MO SMS */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2360 | 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] | 2361 | var SmsParameters spars := valueof(t_SmsPars); |
| 2362 | |
| 2363 | f_init_handler(pars); |
| 2364 | |
| 2365 | /* Perform location update and call */ |
| 2366 | f_perform_lu(); |
| 2367 | |
| 2368 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2369 | |
| 2370 | //spars.exp_rp_err := 96; /* invalid mandatory information */ |
| 2371 | f_mo_sms(spars); |
| 2372 | |
| 2373 | f_expect_clear(); |
| 2374 | } |
| 2375 | testcase TC_lu_and_mo_sms() runs on MTC_CT { |
| 2376 | var BSC_ConnHdlr vc_conn; |
| 2377 | f_init(); |
| 2378 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_sms), 42); |
| 2379 | vc_conn.done; |
| 2380 | } |
| 2381 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2382 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2383 | private function f_vty_sms_send(charstring imsi, charstring msisdn, charstring text) |
Neels Hofmeyr | 6aaeccf | 2019-03-06 15:32:26 +0100 | [diff] [blame] | 2384 | runs on BSC_ConnHdlr { |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2385 | f_vty_transceive(MSCVTY, "subscriber imsi "&imsi&" sms sender msisdn "&msisdn&" send "&text); |
| 2386 | } |
| 2387 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 2388 | /* Remove still pending SMS */ |
| 2389 | private function f_vty_sms_clear(charstring imsi) |
| 2390 | runs on BSC_ConnHdlr { |
| 2391 | f_vty_transceive(MSCVTY, "subscriber imsi " & imsi & " sms delete-all"); |
| 2392 | f_vty_transceive(MSCVTY, "sms-queue clear"); |
| 2393 | } |
| 2394 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2395 | /* LU followed by MT SMS */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2396 | 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] | 2397 | var SmsParameters spars := valueof(t_SmsPars); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2398 | |
| 2399 | f_init_handler(pars); |
| 2400 | |
| 2401 | /* Perform location update and call */ |
| 2402 | f_perform_lu(); |
| 2403 | |
| 2404 | /* register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2405 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2406 | |
Neels Hofmeyr | 6aaeccf | 2019-03-06 15:32:26 +0100 | [diff] [blame] | 2407 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2408 | |
| 2409 | /* MSC->BSC: expect PAGING from MSC */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 2410 | f_expect_paging(); |
| 2411 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2412 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 2413 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2414 | |
| 2415 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 2416 | f_mt_sms(spars); |
| 2417 | |
| 2418 | f_expect_clear(); |
| 2419 | } |
| 2420 | testcase TC_lu_and_mt_sms() runs on MTC_CT { |
| 2421 | var BSC_ConnHdlrPars pars; |
| 2422 | var BSC_ConnHdlr vc_conn; |
| 2423 | f_init(); |
| 2424 | pars := f_init_pars(43); |
| 2425 | 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] | 2426 | vc_conn.done; |
| 2427 | } |
| 2428 | |
Neels Hofmeyr | b58d974 | 2019-11-27 18:44:54 +0100 | [diff] [blame] | 2429 | /* SMS added while already Paging */ |
| 2430 | friend function f_tc_lu_and_mt_sms_already_paging(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2431 | var SmsParameters spars := valueof(t_SmsPars); |
| 2432 | var OCT4 tmsi; |
| 2433 | |
| 2434 | f_init_handler(pars); |
| 2435 | |
| 2436 | f_perform_lu(); |
| 2437 | |
| 2438 | /* register an 'expect' for given IMSI (+TMSI) */ |
| 2439 | if (isvalue(g_pars.tmsi)) { |
| 2440 | tmsi := g_pars.tmsi; |
| 2441 | } else { |
| 2442 | tmsi := 'FFFFFFFF'O; |
| 2443 | } |
| 2444 | f_ran_register_imsi(g_pars.imsi, tmsi); |
| 2445 | |
| 2446 | log("first SMS"); |
| 2447 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 2448 | |
| 2449 | /* MSC->BSC: expect PAGING from MSC */ |
| 2450 | f_expect_paging(); |
| 2451 | |
| 2452 | log("second SMS"); |
| 2453 | /* Now osmo-msc is in state "Paging pending", make sure that another SMS to be sent at this time just joins in |
| 2454 | * with the pending paging. Another SMS: */ |
| 2455 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Another SMS"); |
| 2456 | |
| 2457 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 2458 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2459 | |
| 2460 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 2461 | f_mt_sms(spars); |
| 2462 | |
| 2463 | spars.tp.ud := '41F79B8E2ECB41D3E614'O; |
| 2464 | f_mt_sms(spars); |
| 2465 | |
| 2466 | f_expect_clear(); |
| 2467 | } |
| 2468 | testcase TC_lu_and_mt_sms_already_paging() runs on MTC_CT { |
| 2469 | var BSC_ConnHdlrPars pars; |
| 2470 | var BSC_ConnHdlr vc_conn; |
| 2471 | f_init(); |
| 2472 | pars := f_init_pars(44); |
| 2473 | vc_conn := f_start_handler_with_pars(refers(f_tc_lu_and_mt_sms_already_paging), pars); |
| 2474 | vc_conn.done; |
| 2475 | } |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2476 | |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2477 | /* Paging for MT SMS but no response */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2478 | 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] | 2479 | var SmsParameters spars := valueof(t_SmsPars); |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2480 | |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2481 | f_init_handler(pars, 150.0); |
| 2482 | |
| 2483 | /* Perform location update */ |
| 2484 | f_perform_lu(); |
| 2485 | |
| 2486 | /* register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2487 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2488 | |
Neels Hofmeyr | 6aaeccf | 2019-03-06 15:32:26 +0100 | [diff] [blame] | 2489 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 2490 | |
Neels Hofmeyr | 1623774 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 2491 | /* Expect the MSC to page exactly once */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2492 | f_expect_paging(); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2493 | |
| 2494 | /* Wait some time to make sure the MSC is not delivering any further |
| 2495 | * paging messages or anything else that could be unexpected. */ |
| 2496 | timer T := 20.0; |
| 2497 | T.start |
| 2498 | alt { |
Vadim Yanitskiy | da77459 | 2020-01-15 10:33:47 +0700 | [diff] [blame] | 2499 | [pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 2500 | setverdict(fail, "paging seems not to stop!"); |
| 2501 | mtc.stop; |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2502 | } |
Vadim Yanitskiy | da77459 | 2020-01-15 10:33:47 +0700 | [diff] [blame] | 2503 | [not pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) { |
| 2504 | setverdict(fail, "paging seems not to stop!"); |
| 2505 | mtc.stop; |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2506 | } |
Vadim Yanitskiy | da77459 | 2020-01-15 10:33:47 +0700 | [diff] [blame] | 2507 | [] BSSAP.receive { |
| 2508 | setverdict(fail, "unexpected BSSAP message received"); |
| 2509 | self.stop; |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2510 | } |
Vadim Yanitskiy | da77459 | 2020-01-15 10:33:47 +0700 | [diff] [blame] | 2511 | [] T.timeout { |
| 2512 | setverdict(pass); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2513 | } |
| 2514 | } |
| 2515 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 2516 | f_vty_sms_clear(hex2str(g_pars.imsi)); |
| 2517 | |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2518 | setverdict(pass); |
| 2519 | } |
| 2520 | testcase TC_lu_and_mt_sms_paging_and_nothing() runs on MTC_CT { |
| 2521 | var BSC_ConnHdlrPars pars; |
| 2522 | var BSC_ConnHdlr vc_conn; |
| 2523 | f_init(); |
Philipp Maier | a99ad26 | 2019-01-22 15:35:42 +0100 | [diff] [blame] | 2524 | pars := f_init_pars(1843); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2525 | 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] | 2526 | vc_conn.done; |
| 2527 | } |
| 2528 | |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2529 | /* LU followed by MT SMS with repeated paging */ |
| 2530 | friend function f_tc_lu_and_mt_sms_paging_repeated(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2531 | var SmsParameters spars := valueof(t_SmsPars); |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2532 | |
| 2533 | f_init_handler(pars); |
| 2534 | |
| 2535 | /* Perform location update and call */ |
| 2536 | f_perform_lu(); |
| 2537 | |
| 2538 | /* register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2539 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2540 | |
| 2541 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 2542 | |
Neels Hofmeyr | c3accec | 2019-11-28 01:09:47 +0100 | [diff] [blame] | 2543 | log("Expecting first Paging"); |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2544 | /* MSC->BSC: expect PAGING from MSC */ |
| 2545 | f_expect_paging(); |
| 2546 | |
Neels Hofmeyr | c3accec | 2019-11-28 01:09:47 +0100 | [diff] [blame] | 2547 | if (g_pars.ran_is_geran) { |
| 2548 | log("GERAN: expect no further Paging"); |
| 2549 | } else { |
| 2550 | log("UTRAN: expect more Paging"); |
| 2551 | } |
| 2552 | |
| 2553 | timer T := 5.0; |
| 2554 | T.start; |
| 2555 | alt { |
| 2556 | [g_pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 2557 | setverdict(fail, "GERAN should not repeat Paging, but received a second Paging"); |
| 2558 | mtc.stop; |
| 2559 | } |
| 2560 | [not g_pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) { |
| 2561 | log("UTRAN: second Paging received, as expected"); |
| 2562 | setverdict(pass); |
| 2563 | } |
| 2564 | [] T.timeout { |
| 2565 | if (g_pars.ran_is_geran) { |
| 2566 | log("GERAN: No further Paging received, as expected"); |
| 2567 | setverdict(pass); |
| 2568 | } else { |
| 2569 | setverdict(fail, "UTRAN: Expected a second Paging"); |
| 2570 | mtc.stop; |
| 2571 | } |
| 2572 | } |
| 2573 | } |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2574 | |
| 2575 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 2576 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2577 | |
| 2578 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 2579 | f_mt_sms(spars); |
| 2580 | |
| 2581 | f_expect_clear(); |
| 2582 | } |
| 2583 | testcase TC_lu_and_mt_sms_paging_repeated() runs on MTC_CT { |
| 2584 | var BSC_ConnHdlrPars pars; |
| 2585 | var BSC_ConnHdlr vc_conn; |
| 2586 | f_init(); |
| 2587 | pars := f_init_pars(1844); |
| 2588 | vc_conn := f_start_handler_with_pars(refers(f_tc_lu_and_mt_sms_paging_repeated), pars); |
| 2589 | vc_conn.done; |
| 2590 | } |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2591 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2592 | /* mobile originated SMS from MS/BTS/BSC side to SMPP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2593 | 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] | 2594 | var SmsParameters spars := valueof(t_SmsPars); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2595 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2596 | f_init_handler(pars); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2597 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2598 | /* Perform location update so IMSI is known + registered in MSC/VLR */ |
| 2599 | f_perform_lu(); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2600 | |
Vadim Yanitskiy | 2d3f846 | 2020-01-15 11:44:12 +0700 | [diff] [blame] | 2601 | /* MS/UE submits a MO SMS */ |
| 2602 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2603 | f_mo_sms_submit(spars); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2604 | |
| 2605 | var SMPP_PDU smpp; |
| 2606 | var template SMPP_PDU tr_smpp := tr_SMPP(c_SMPP_command_id_deliver_sm, ESME_ROK); |
| 2607 | tr_smpp.body.deliver_sm := { |
| 2608 | service_type := "CMT", |
| 2609 | source_addr_ton := network_specific, |
| 2610 | source_addr_npi := isdn, |
| 2611 | source_addr := hex2str(pars.msisdn), |
| 2612 | dest_addr_ton := f_sm_ton_from_gsm(spars.tp.da.tP_DA_NoPad.tP_TypeOfNumber), |
| 2613 | dest_addr_npi := f_sm_npi_from_gsm(spars.tp.da.tP_DA_NoPad.tP_NumberingPlanID), |
| 2614 | destination_addr := hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue), |
| 2615 | esm_class := '00000001'B, |
| 2616 | protocol_id := 0, |
| 2617 | priority_flag := 0, |
| 2618 | schedule_delivery_time := "", |
| 2619 | replace_if_present := 0, |
| 2620 | data_coding := '00000001'B, |
| 2621 | sm_default_msg_id := 0, |
| 2622 | sm_length := ?, |
| 2623 | short_message := spars.tp.ud, |
| 2624 | opt_pars := { |
| 2625 | { |
| 2626 | tag := user_message_reference, |
| 2627 | len := 2, |
| 2628 | opt_value := { |
| 2629 | int2_val := oct2int(spars.tp.msg_ref) |
| 2630 | } |
| 2631 | } |
| 2632 | } |
| 2633 | }; |
| 2634 | alt { |
| 2635 | [] SMPP.receive(tr_smpp) -> value smpp { |
| 2636 | SMPP.send(ts_SMPP_DELIVER_SM_resp(ESME_ROK, smpp.header.seq_num)); |
| 2637 | } |
| 2638 | [] SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)) { repeat; } |
| 2639 | } |
| 2640 | |
Vadim Yanitskiy | 2d3f846 | 2020-01-15 11:44:12 +0700 | [diff] [blame] | 2641 | /* MSC terminates the SMS transaction with RP-ACK */ |
| 2642 | f_mo_sms_wait_rp_ack(spars); |
| 2643 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2644 | f_expect_clear(); |
| 2645 | } |
| 2646 | testcase TC_smpp_mo_sms() runs on MTC_CT { |
| 2647 | var BSC_ConnHdlr vc_conn; |
| 2648 | f_init(); |
| 2649 | f_vty_config2(MSCVTY, { "smpp", "esme msc_tester"}, "default-route"); |
| 2650 | vc_conn := f_start_handler(refers(f_tc_smpp_mo_sms), 44); |
| 2651 | vc_conn.done; |
| 2652 | f_vty_config2(MSCVTY, { "smpp", "esme msc_tester"}, "no default-route"); |
| 2653 | } |
| 2654 | |
Vadim Yanitskiy | 3382076 | 2020-01-15 11:26:07 +0700 | [diff] [blame] | 2655 | /* Test case for OS#4351: make sure that RP-ERROR from ESME is properly sent to the MS/UE */ |
| 2656 | friend function f_tc_smpp_mo_sms_rp_error(charstring id, BSC_ConnHdlrPars pars) |
| 2657 | runs on BSC_ConnHdlr { |
| 2658 | var SmsParameters spars := valueof(t_SmsPars); |
| 2659 | var SMPP_PDU smpp_pdu; |
| 2660 | timer T := 3.0; |
| 2661 | |
| 2662 | f_init_handler(pars); |
| 2663 | |
| 2664 | /* Perform location update */ |
| 2665 | f_perform_lu(); |
| 2666 | |
| 2667 | /* MS/UE submits a MO SMS */ |
| 2668 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2669 | f_mo_sms_submit(spars); |
| 2670 | |
| 2671 | /* ESME responds with an error (Invalid Destination Address) */ |
| 2672 | T.start; |
| 2673 | alt { |
| 2674 | [] SMPP.receive(tr_SMPP(c_SMPP_command_id_deliver_sm, ESME_ROK, body := ?)) -> value smpp_pdu { |
| 2675 | SMPP.send(ts_SMPP_DELIVER_SM_resp(ESME_RINVDSTADR, smpp_pdu.header.seq_num)); |
| 2676 | } |
| 2677 | [] SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)) { repeat; } |
| 2678 | [] T.timeout { |
| 2679 | setverdict(fail, "Timeout waiting for SMPP DELIVER-SM"); |
| 2680 | mtc.stop; |
| 2681 | } |
| 2682 | } |
| 2683 | |
| 2684 | /* Expect RP-ERROR on BSSAP interface */ |
| 2685 | spars.exp_rp_err := 1; /* FIXME: GSM411_RP_CAUSE_MO_NUM_UNASSIGNED */ |
| 2686 | f_mo_sms_wait_rp_ack(spars); |
| 2687 | |
| 2688 | f_expect_clear(); |
| 2689 | } |
| 2690 | testcase TC_smpp_mo_sms_rp_error() runs on MTC_CT { |
| 2691 | var BSC_ConnHdlr vc_conn; |
| 2692 | f_init(); |
| 2693 | f_vty_config2(MSCVTY, { "smpp", "esme msc_tester"}, "default-route"); |
| 2694 | vc_conn := f_start_handler(refers(f_tc_smpp_mo_sms_rp_error), 45); |
| 2695 | vc_conn.done; |
| 2696 | f_vty_config2(MSCVTY, { "smpp", "esme msc_tester"}, "no default-route"); |
| 2697 | } |
| 2698 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2699 | |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 2700 | /* Test MO-SMS from MS/BTS/BSC towards HLR (via GSUP) */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2701 | friend function f_tc_gsup_mo_sms(charstring id, BSC_ConnHdlrPars pars) |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 2702 | runs on BSC_ConnHdlr { |
| 2703 | var SmsParameters spars := valueof(t_SmsPars); |
| 2704 | var GSUP_PDU gsup_msg_rx; |
| 2705 | var octetstring sm_tpdu; |
| 2706 | |
| 2707 | f_init_handler(pars); |
| 2708 | |
| 2709 | /* We need to inspect GSUP activity */ |
| 2710 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2711 | |
| 2712 | /* Perform location update */ |
| 2713 | f_perform_lu(); |
| 2714 | |
| 2715 | /* Send CM Service Request for SMS */ |
| 2716 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2717 | |
| 2718 | /* Prepare expected SM-RP-UI (SM TPDU) */ |
| 2719 | enc_TPDU_RP_DATA_MS_SGSN_fast( |
| 2720 | valueof(ts_SMS_SUBMIT(spars.tp.msg_ref, |
| 2721 | spars.tp.da, spars.tp.pid, spars.tp.dcs, |
| 2722 | spars.tp.udl, spars.tp.ud)), |
| 2723 | sm_tpdu); |
| 2724 | |
| 2725 | var template GSUP_PDU mo_forwardSM := tr_GSUP_MO_FORWARD_SM_REQ( |
| 2726 | imsi := g_pars.imsi, |
| 2727 | sm_rp_mr := spars.rp.msg_ref, |
Vadim Yanitskiy | 04dd5f7 | 2019-12-13 15:45:44 +0900 | [diff] [blame] | 2728 | /* SM-RP-DA: SMSC address */ |
| 2729 | sm_rp_da := tr_GSUP_SM_RP_DA_SMSC_ADDR(t_GSUP_SM_RP_Addr( |
| 2730 | number := spars.rp.smsc_addr.rP_NumberDigits, |
| 2731 | npi := spars.rp.smsc_addr.rP_NumberingPlanIdentification, |
| 2732 | ton := spars.rp.smsc_addr.rP_TypeOfNumber, |
| 2733 | ext := spars.rp.smsc_addr.rP_Ext)), |
| 2734 | /* SM-RP-OA: subscriber's MSISDN (filled in by MSC) */ |
| 2735 | sm_rp_oa := tr_GSUP_SM_RP_OA_MSISDN(t_GSUP_SM_RP_Addr( |
| 2736 | number := g_pars.msisdn, |
| 2737 | /* NOTE: MSISDN in g_pars lacks this info, assuming defaults */ |
| 2738 | npi := '0001'B, ton := '001'B, ext := '1'B)), |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 2739 | /* TODO: can we use decmatch here? */ |
| 2740 | sm_rp_ui := sm_tpdu |
| 2741 | ); |
| 2742 | |
| 2743 | /* Submit an SMS on DTAP and expect MO-forwardSM-Req on GSUP */ |
| 2744 | f_mo_sms_submit(spars); |
| 2745 | alt { |
| 2746 | [] GSUP.receive(mo_forwardSM) -> value gsup_msg_rx { |
Vadim Yanitskiy | a358dd4 | 2020-01-15 10:42:47 +0700 | [diff] [blame] | 2747 | log("RX MO-forwardSM-Req: ", gsup_msg_rx); |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 2748 | setverdict(pass); |
| 2749 | } |
| 2750 | [] GSUP.receive { |
| 2751 | log("RX unexpected GSUP message"); |
| 2752 | setverdict(fail); |
| 2753 | mtc.stop; |
| 2754 | } |
| 2755 | } |
| 2756 | |
| 2757 | /* Trigger RP-ACK by sending MO-forwardSM-Res */ |
| 2758 | GSUP.send(valueof(ts_GSUP_MO_FORWARD_SM_RES( |
| 2759 | imsi := g_pars.imsi, |
| 2760 | sm_rp_mr := spars.rp.msg_ref))); |
| 2761 | /* Expect RP-ACK on DTAP */ |
| 2762 | f_mo_sms_wait_rp_ack(spars); |
| 2763 | |
| 2764 | f_expect_clear(); |
| 2765 | } |
| 2766 | testcase TC_gsup_mo_sms() runs on MTC_CT { |
| 2767 | var BSC_ConnHdlr vc_conn; |
| 2768 | f_init(); |
| 2769 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2770 | vc_conn := f_start_handler(refers(f_tc_gsup_mo_sms), 88); |
| 2771 | vc_conn.done; |
| 2772 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2773 | } |
| 2774 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2775 | |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 2776 | /* Test MO-SMMA from MS/BTS/BSC towards HLR (via GSUP) */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2777 | friend function f_tc_gsup_mo_smma(charstring id, BSC_ConnHdlrPars pars) |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 2778 | runs on BSC_ConnHdlr { |
| 2779 | var SmsParameters spars := valueof(t_SmsPars); |
| 2780 | var GSUP_PDU gsup_msg_rx; |
| 2781 | |
| 2782 | f_init_handler(pars); |
| 2783 | |
| 2784 | /* We need to inspect GSUP activity */ |
| 2785 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2786 | |
| 2787 | /* Perform location update */ |
| 2788 | f_perform_lu(); |
| 2789 | |
| 2790 | /* Send CM Service Request for SMS */ |
| 2791 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2792 | |
| 2793 | var template GSUP_PDU mo_ReadyForSM := tr_GSUP_MO_READY_FOR_SM_REQ( |
| 2794 | imsi := g_pars.imsi, |
| 2795 | sm_rp_mr := spars.rp.msg_ref, |
| 2796 | sm_alert_rsn := GSUP_SM_ALERT_RSN_TYPE_MEM_AVAIL |
| 2797 | ); |
| 2798 | |
| 2799 | /* Submit an SMS on DTAP and expect MO-forwardSM-Req on GSUP */ |
| 2800 | f_mo_smma(spars); |
| 2801 | alt { |
| 2802 | [] GSUP.receive(mo_ReadyForSM) -> value gsup_msg_rx { |
Vadim Yanitskiy | a358dd4 | 2020-01-15 10:42:47 +0700 | [diff] [blame] | 2803 | log("RX MO-ReadyForSM-Req: ", gsup_msg_rx); |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 2804 | setverdict(pass); |
| 2805 | } |
| 2806 | [] GSUP.receive { |
| 2807 | log("RX unexpected GSUP message"); |
| 2808 | setverdict(fail); |
| 2809 | mtc.stop; |
| 2810 | } |
| 2811 | } |
| 2812 | |
| 2813 | /* Trigger RP-ACK by sending MO-forwardSM-Res */ |
| 2814 | GSUP.send(valueof(ts_GSUP_MO_READY_FOR_SM_RES( |
| 2815 | imsi := g_pars.imsi, |
| 2816 | sm_rp_mr := spars.rp.msg_ref))); |
| 2817 | /* Expect RP-ACK on DTAP */ |
| 2818 | f_mo_sms_wait_rp_ack(spars); |
| 2819 | |
| 2820 | f_expect_clear(); |
| 2821 | } |
| 2822 | testcase TC_gsup_mo_smma() runs on MTC_CT { |
| 2823 | var BSC_ConnHdlr vc_conn; |
| 2824 | f_init(); |
| 2825 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2826 | vc_conn := f_start_handler(refers(f_tc_gsup_mo_smma), 89); |
| 2827 | vc_conn.done; |
| 2828 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2829 | } |
| 2830 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2831 | |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2832 | /* Helper for sending MT SMS over GSUP */ |
| 2833 | private function f_gsup_forwardSM_req(SmsParameters spars, OCT1 mms := '00'O) |
| 2834 | runs on BSC_ConnHdlr { |
Vadim Yanitskiy | a52347c | 2019-12-12 17:32:33 +0900 | [diff] [blame] | 2835 | 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] | 2836 | var GSUP_SM_RP_Addr smsc := valueof(t_GSUP_SM_RP_Addr( |
| 2837 | number := spars.rp.smsc_addr.rP_NumberDigits, |
| 2838 | npi := spars.rp.smsc_addr.rP_NumberingPlanIdentification, |
| 2839 | ton := spars.rp.smsc_addr.rP_TypeOfNumber, |
| 2840 | ext := spars.rp.smsc_addr.rP_Ext)); |
Vadim Yanitskiy | a52347c | 2019-12-12 17:32:33 +0900 | [diff] [blame] | 2841 | |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2842 | GSUP.send(ts_GSUP_MT_FORWARD_SM_REQ( |
| 2843 | imsi := g_pars.imsi, |
| 2844 | /* NOTE: MSC should assign RP-MR itself */ |
| 2845 | sm_rp_mr := 'FF'O, |
Vadim Yanitskiy | a52347c | 2019-12-12 17:32:33 +0900 | [diff] [blame] | 2846 | sm_rp_da := valueof(ts_GSUP_SM_RP_DA_MSISDN(msisdn)), |
Vadim Yanitskiy | 04dd5f7 | 2019-12-13 15:45:44 +0900 | [diff] [blame] | 2847 | sm_rp_oa := valueof(ts_GSUP_SM_RP_OA_SMSC_ADDR(smsc)), |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2848 | /* Encoded SMS TPDU (taken from Wireshark) |
| 2849 | * FIXME: we should encode spars somehow */ |
| 2850 | sm_rp_ui := '00068021436500008111328130858200'O, |
| 2851 | sm_rp_mms := mms |
| 2852 | )); |
| 2853 | } |
| 2854 | |
| 2855 | /* Test successful MT-SMS (RP-ACK) over GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2856 | 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] | 2857 | runs on BSC_ConnHdlr { |
| 2858 | var SmsParameters spars := valueof(t_SmsPars); |
| 2859 | |
| 2860 | f_init_handler(pars); |
| 2861 | |
| 2862 | /* We need to inspect GSUP activity */ |
| 2863 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2864 | |
| 2865 | /* Perform location update */ |
| 2866 | f_perform_lu(); |
| 2867 | |
| 2868 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2869 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2870 | |
| 2871 | var template GSUP_PDU mt_forwardSM_res := tr_GSUP_MT_FORWARD_SM_RES( |
| 2872 | imsi := g_pars.imsi, |
| 2873 | /* NOTE: MSC should assign RP-MR itself */ |
| 2874 | sm_rp_mr := ? |
| 2875 | ); |
| 2876 | |
| 2877 | /* Submit a MT SMS on GSUP */ |
| 2878 | f_gsup_forwardSM_req(spars); |
| 2879 | |
| 2880 | /* Expect Paging Request and Establish DTAP / BSSAP / SCCP connection */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 2881 | f_expect_paging(); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2882 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2883 | |
| 2884 | /* Wait for MT SMS on DTAP */ |
| 2885 | f_mt_sms_expect(spars); |
| 2886 | |
| 2887 | /* Send RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 2888 | f_mt_sms_send_rp_ack(spars); |
| 2889 | alt { |
| 2890 | [] GSUP.receive(mt_forwardSM_res) { |
| 2891 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 2892 | setverdict(pass); |
| 2893 | } |
| 2894 | [] GSUP.receive { |
| 2895 | log("RX unexpected GSUP message"); |
| 2896 | setverdict(fail); |
| 2897 | mtc.stop; |
| 2898 | } |
| 2899 | } |
| 2900 | |
| 2901 | f_expect_clear(); |
| 2902 | } |
| 2903 | testcase TC_gsup_mt_sms_ack() runs on MTC_CT { |
| 2904 | var BSC_ConnHdlrPars pars; |
| 2905 | var BSC_ConnHdlr vc_conn; |
| 2906 | f_init(); |
| 2907 | pars := f_init_pars(90); |
| 2908 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2909 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_sms_ack), pars); |
| 2910 | vc_conn.done; |
| 2911 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2912 | } |
| 2913 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2914 | |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2915 | /* Test rejected MT-SMS (RP-ERROR) over GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2916 | 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] | 2917 | runs on BSC_ConnHdlr { |
| 2918 | var SmsParameters spars := valueof(t_SmsPars); |
| 2919 | var OCT1 sm_rp_cause := '78'O; /* dummy RP-Cause value */ |
| 2920 | |
| 2921 | f_init_handler(pars); |
| 2922 | |
| 2923 | /* We need to inspect GSUP activity */ |
| 2924 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2925 | |
| 2926 | /* Perform location update */ |
| 2927 | f_perform_lu(); |
| 2928 | |
| 2929 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2930 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2931 | |
| 2932 | var template GSUP_PDU mt_forwardSM_err := tr_GSUP_MT_FORWARD_SM_ERR( |
| 2933 | imsi := g_pars.imsi, |
| 2934 | /* NOTE: MSC should assign RP-MR itself */ |
| 2935 | sm_rp_mr := ?, |
| 2936 | sm_rp_cause := sm_rp_cause |
| 2937 | ); |
| 2938 | |
| 2939 | /* Submit a MT SMS on GSUP */ |
| 2940 | f_gsup_forwardSM_req(spars); |
| 2941 | |
| 2942 | /* Expect Paging Request and Establish DTAP / BSSAP / SCCP connection */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 2943 | f_expect_paging(); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2944 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2945 | |
| 2946 | /* Wait for MT SMS on DTAP */ |
| 2947 | f_mt_sms_expect(spars); |
| 2948 | |
| 2949 | /* Send RP-ERROR and expect MT-forwardSM-Err on GSUP */ |
| 2950 | f_mt_sms_send_rp_error(spars, oct2int(sm_rp_cause)); |
| 2951 | alt { |
| 2952 | [] GSUP.receive(mt_forwardSM_err) { |
| 2953 | log("RX MT-forwardSM-Err (RP-ERROR)"); |
| 2954 | setverdict(pass); |
| 2955 | mtc.stop; |
| 2956 | } |
| 2957 | [] GSUP.receive { |
| 2958 | log("RX unexpected GSUP message"); |
| 2959 | setverdict(fail); |
| 2960 | mtc.stop; |
| 2961 | } |
| 2962 | } |
| 2963 | |
| 2964 | f_expect_clear(); |
| 2965 | } |
| 2966 | testcase TC_gsup_mt_sms_err() runs on MTC_CT { |
| 2967 | var BSC_ConnHdlrPars pars; |
| 2968 | var BSC_ConnHdlr vc_conn; |
| 2969 | f_init(); |
| 2970 | pars := f_init_pars(91); |
| 2971 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2972 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_sms_err), pars); |
| 2973 | vc_conn.done; |
| 2974 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2975 | } |
| 2976 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2977 | |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 2978 | /* Test SM-RP-MR assignment for MT-SMS over GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2979 | 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] | 2980 | runs on BSC_ConnHdlr { |
| 2981 | var SmsParameters spars1 := valueof(t_SmsPars); /* 1st SMS */ |
| 2982 | var SmsParameters spars2 := valueof(t_SmsPars); /* 2nd SMS */ |
| 2983 | |
| 2984 | f_init_handler(pars); |
| 2985 | |
| 2986 | /* We need to inspect GSUP activity */ |
| 2987 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2988 | |
| 2989 | /* Perform location update */ |
| 2990 | f_perform_lu(); |
| 2991 | |
| 2992 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2993 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 2994 | |
| 2995 | /* Submit the 1st MT SMS on GSUP */ |
| 2996 | log("TX MT-forwardSM-Req for the 1st SMS"); |
| 2997 | f_gsup_forwardSM_req(spars1); |
| 2998 | |
| 2999 | /* Expect Paging Request and Establish DTAP / BSSAP / SCCP connection */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 3000 | f_expect_paging(); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 3001 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 3002 | |
| 3003 | /* Wait for 1st MT SMS on DTAP */ |
| 3004 | f_mt_sms_expect(spars1); |
| 3005 | log("RX the 1st SMS on DTAP, DTAP TID is ", spars1.tid, |
| 3006 | ", SM-RP-MR is ", spars1.rp.msg_ref); |
| 3007 | |
| 3008 | /* Submit the 2nd MT SMS on GSUP */ |
| 3009 | log("TX MT-forwardSM-Req for the 2nd SMS"); |
| 3010 | f_gsup_forwardSM_req(spars2); |
| 3011 | |
| 3012 | /* Wait for 2nd MT SMS on DTAP */ |
| 3013 | f_mt_sms_expect(spars2); |
| 3014 | log("RX the 2nd SMS on DTAP, DTAP TID is ", spars2.tid, |
| 3015 | ", SM-RP-MR is ", spars2.rp.msg_ref); |
| 3016 | |
| 3017 | /* Both transaction IDs shall be different */ |
| 3018 | if (spars1.tid == spars2.tid) { |
| 3019 | log("Both DTAP transaction IDs shall be different"); |
| 3020 | setverdict(fail); |
| 3021 | } |
| 3022 | |
| 3023 | /* Both SM-RP-MR values shall be different */ |
| 3024 | if (spars1.rp.msg_ref == spars2.rp.msg_ref) { |
| 3025 | log("Both SM-RP-MR values shall be different"); |
| 3026 | setverdict(fail); |
| 3027 | } |
| 3028 | |
| 3029 | /* Both SM-RP-MR values shall be assigned */ |
| 3030 | if (spars1.rp.msg_ref == 'FF'O) { |
| 3031 | log("Unassigned SM-RP-MR value for the 1st SMS"); |
| 3032 | setverdict(fail); |
| 3033 | } |
| 3034 | if (spars2.rp.msg_ref == 'FF'O) { |
| 3035 | log("Unassigned SM-RP-MR value for the 2nd SMS"); |
| 3036 | setverdict(fail); |
| 3037 | } |
| 3038 | |
| 3039 | /* Send the 1st RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 3040 | f_mt_sms_send_rp_ack(spars1); |
| 3041 | alt { |
| 3042 | [] GSUP.receive(tr_GSUP_MT_FORWARD_SM_RES( |
| 3043 | imsi := g_pars.imsi, |
| 3044 | sm_rp_mr := spars1.rp.msg_ref |
| 3045 | )) { |
| 3046 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 3047 | setverdict(pass); |
| 3048 | } |
| 3049 | [] GSUP.receive { |
| 3050 | log("RX unexpected GSUP message"); |
| 3051 | setverdict(fail); |
| 3052 | mtc.stop; |
| 3053 | } |
| 3054 | } |
| 3055 | |
| 3056 | /* Send the 2nd RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 3057 | f_mt_sms_send_rp_ack(spars2); |
| 3058 | alt { |
| 3059 | [] GSUP.receive(tr_GSUP_MT_FORWARD_SM_RES( |
| 3060 | imsi := g_pars.imsi, |
| 3061 | sm_rp_mr := spars2.rp.msg_ref |
| 3062 | )) { |
| 3063 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 3064 | setverdict(pass); |
| 3065 | } |
| 3066 | [] GSUP.receive { |
| 3067 | log("RX unexpected GSUP message"); |
| 3068 | setverdict(fail); |
| 3069 | mtc.stop; |
| 3070 | } |
| 3071 | } |
| 3072 | |
| 3073 | f_expect_clear(); |
| 3074 | } |
| 3075 | testcase TC_gsup_mt_sms_rp_mr() runs on MTC_CT { |
| 3076 | var BSC_ConnHdlrPars pars; |
| 3077 | var BSC_ConnHdlr vc_conn; |
| 3078 | f_init(); |
| 3079 | pars := f_init_pars(92); |
| 3080 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 3081 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_sms_rp_mr), pars); |
| 3082 | vc_conn.done; |
| 3083 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 3084 | } |
| 3085 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3086 | |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 3087 | /* Test SM-RP-MR assignment for MT-SMS over GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3088 | 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] | 3089 | runs on BSC_ConnHdlr { |
| 3090 | var SmsParameters spars_mo := valueof(t_SmsPars); /* MO SMMA */ |
| 3091 | var SmsParameters spars_mt := valueof(t_SmsPars); /* MT SMS */ |
| 3092 | |
| 3093 | f_init_handler(pars); |
| 3094 | |
| 3095 | /* We need to inspect GSUP activity */ |
| 3096 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3097 | |
| 3098 | /* Perform location update */ |
| 3099 | f_perform_lu(); |
| 3100 | |
| 3101 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 3102 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 3103 | |
| 3104 | /* Send CM Service Request for MO SMMA */ |
| 3105 | f_establish_fully(EST_TYPE_MO_SMS); |
| 3106 | |
| 3107 | /* Submit MO SMMA on DTAP */ |
| 3108 | log("Submit MO SMMA on DTAP, SM-RP-MR is '00'O"); |
| 3109 | spars_mo.rp.msg_ref := '00'O; |
| 3110 | f_mo_smma(spars_mo); |
| 3111 | |
| 3112 | /* Expect MO-forwardSM-Req for MO SMMA on GSUP */ |
| 3113 | alt { |
| 3114 | [] GSUP.receive(tr_GSUP_MO_READY_FOR_SM_REQ( |
| 3115 | imsi := g_pars.imsi, |
| 3116 | sm_rp_mr := spars_mo.rp.msg_ref, |
| 3117 | sm_alert_rsn := GSUP_SM_ALERT_RSN_TYPE_MEM_AVAIL |
| 3118 | )) { |
| 3119 | log("RX MO-ReadyForSM-Req, SM-RP-MR is '00'O"); |
| 3120 | setverdict(pass); |
| 3121 | } |
| 3122 | [] GSUP.receive { |
| 3123 | log("RX unexpected GSUP message"); |
| 3124 | setverdict(fail); |
| 3125 | mtc.stop; |
| 3126 | } |
| 3127 | } |
| 3128 | |
| 3129 | /* Submit MT SMS on GSUP */ |
| 3130 | log("TX MT-forwardSM-Req for the MT SMS"); |
| 3131 | f_gsup_forwardSM_req(spars_mt); |
| 3132 | |
| 3133 | /* Wait for MT SMS on DTAP */ |
| 3134 | f_mt_sms_expect(spars_mt); |
| 3135 | log("RX MT SMS on DTAP, DTAP TID is ", spars_mt.tid, |
| 3136 | ", SM-RP-MR is ", spars_mt.rp.msg_ref); |
| 3137 | |
| 3138 | /* Both SM-RP-MR values shall be different */ |
| 3139 | if (spars_mo.rp.msg_ref == spars_mt.rp.msg_ref) { |
| 3140 | log("Both SM-RP-MR values shall be different"); |
| 3141 | setverdict(fail); |
| 3142 | } |
| 3143 | |
| 3144 | /* SM-RP-MR value for MT SMS shall be assigned */ |
| 3145 | if (spars_mt.rp.msg_ref == 'FF'O) { |
| 3146 | log("Unassigned SM-RP-MR value for the MT SMS"); |
| 3147 | setverdict(fail); |
| 3148 | } |
| 3149 | |
| 3150 | /* Trigger RP-ACK for MO SMMA by sending MO-forwardSM-Res */ |
| 3151 | GSUP.send(valueof(ts_GSUP_MO_READY_FOR_SM_RES( |
| 3152 | imsi := g_pars.imsi, |
| 3153 | sm_rp_mr := spars_mo.rp.msg_ref))); |
| 3154 | /* Expect RP-ACK for MO SMMA on DTAP */ |
| 3155 | f_mo_sms_wait_rp_ack(spars_mo); |
| 3156 | |
| 3157 | /* Send RP-ACK for MT SMS and expect MT-forwardSM-Res on GSUP */ |
| 3158 | f_mt_sms_send_rp_ack(spars_mt); |
| 3159 | alt { |
| 3160 | [] GSUP.receive(tr_GSUP_MT_FORWARD_SM_RES( |
| 3161 | imsi := g_pars.imsi, |
| 3162 | sm_rp_mr := spars_mt.rp.msg_ref |
| 3163 | )) { |
| 3164 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 3165 | setverdict(pass); |
| 3166 | } |
| 3167 | [] GSUP.receive { |
| 3168 | log("RX unexpected GSUP message"); |
| 3169 | setverdict(fail); |
| 3170 | mtc.stop; |
| 3171 | } |
| 3172 | } |
| 3173 | |
| 3174 | f_expect_clear(); |
| 3175 | } |
| 3176 | testcase TC_gsup_mo_mt_sms_rp_mr() runs on MTC_CT { |
| 3177 | var BSC_ConnHdlrPars pars; |
| 3178 | var BSC_ConnHdlr vc_conn; |
| 3179 | f_init(); |
| 3180 | pars := f_init_pars(93); |
| 3181 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 3182 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mo_mt_sms_rp_mr), pars); |
| 3183 | vc_conn.done; |
| 3184 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 3185 | } |
| 3186 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3187 | |
Vadim Yanitskiy | 1cd11a0 | 2018-12-03 02:43:35 +0700 | [diff] [blame] | 3188 | /* Test multi-part MT-SMS over GSUP */ |
| 3189 | private function f_tc_gsup_mt_multi_part_sms(charstring id, BSC_ConnHdlrPars pars) |
| 3190 | runs on BSC_ConnHdlr { |
| 3191 | var SmsParameters spars := valueof(t_SmsPars); |
| 3192 | |
| 3193 | f_init_handler(pars); |
| 3194 | |
| 3195 | /* We need to inspect GSUP activity */ |
| 3196 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3197 | |
| 3198 | /* Perform location update */ |
| 3199 | f_perform_lu(); |
| 3200 | |
| 3201 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 3202 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 1cd11a0 | 2018-12-03 02:43:35 +0700 | [diff] [blame] | 3203 | |
| 3204 | var template GSUP_PDU mt_forwardSM_res := tr_GSUP_MT_FORWARD_SM_RES( |
| 3205 | imsi := g_pars.imsi, |
| 3206 | /* NOTE: MSC should assign RP-MR itself */ |
| 3207 | sm_rp_mr := ? |
| 3208 | ); |
| 3209 | |
| 3210 | /* Send 4 messages (NOTE: SM-RP-UI remains unchanged) */ |
| 3211 | for (var integer i := 3; i >= 0; i := i-1) { |
| 3212 | /* Submit a MT SMS on GSUP (MMS is decremented) */ |
| 3213 | f_gsup_forwardSM_req(spars, int2oct(i, 1)); |
| 3214 | |
| 3215 | /* Expect Paging Request and Establish connection */ |
| 3216 | if (i == 3) { /* ... only once! */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3217 | f_expect_paging(); |
Vadim Yanitskiy | 1cd11a0 | 2018-12-03 02:43:35 +0700 | [diff] [blame] | 3218 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 3219 | } |
| 3220 | |
| 3221 | /* Wait for MT SMS on DTAP */ |
| 3222 | f_mt_sms_expect(spars); |
| 3223 | |
| 3224 | /* Send RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 3225 | f_mt_sms_send_rp_ack(spars); |
| 3226 | alt { |
| 3227 | [] GSUP.receive(mt_forwardSM_res) { |
| 3228 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 3229 | setverdict(pass); |
| 3230 | } |
| 3231 | [] GSUP.receive { |
| 3232 | log("RX unexpected GSUP message"); |
| 3233 | setverdict(fail); |
| 3234 | mtc.stop; |
| 3235 | } |
| 3236 | } |
| 3237 | |
| 3238 | /* Keep some 'distance' between transmissions */ |
| 3239 | f_sleep(1.5); |
| 3240 | } |
| 3241 | |
| 3242 | f_expect_clear(); |
| 3243 | } |
| 3244 | testcase TC_gsup_mt_multi_part_sms() runs on MTC_CT { |
| 3245 | var BSC_ConnHdlrPars pars; |
| 3246 | var BSC_ConnHdlr vc_conn; |
| 3247 | f_init(); |
| 3248 | pars := f_init_pars(91); |
| 3249 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 3250 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_multi_part_sms), pars); |
| 3251 | vc_conn.done; |
| 3252 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 3253 | } |
| 3254 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 3255 | /* convert GSM L3 TON to SMPP_TON enum */ |
| 3256 | function f_sm_ton_from_gsm(BIT3 ton) return SMPP_TON { |
| 3257 | select (ton) { |
| 3258 | case ('000'B) { return unknown; } |
| 3259 | case ('001'B) { return international; } |
| 3260 | case ('010'B) { return national; } |
| 3261 | case ('011'B) { return network_specific; } |
| 3262 | case ('100'B) { return subscriber_number; } |
| 3263 | case ('101'B) { return alphanumeric; } |
| 3264 | case ('110'B) { return abbreviated; } |
| 3265 | } |
| 3266 | setverdict(fail, "Unknown TON ", ton); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 3267 | mtc.stop; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 3268 | } |
| 3269 | /* convert GSM L3 NPI to SMPP_NPI enum */ |
| 3270 | function f_sm_npi_from_gsm(BIT4 npi) return SMPP_NPI { |
| 3271 | select (npi) { |
| 3272 | case ('0000'B) { return unknown; } |
| 3273 | case ('0001'B) { return isdn; } |
| 3274 | case ('0011'B) { return data; } |
| 3275 | case ('0100'B) { return telex; } |
| 3276 | case ('0110'B) { return land_mobile; } |
| 3277 | case ('1000'B) { return national; } |
| 3278 | case ('1001'B) { return private_; } |
| 3279 | case ('1010'B) { return ermes; } |
| 3280 | } |
| 3281 | setverdict(fail, "Unknown NPI ", npi); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 3282 | mtc.stop; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 3283 | } |
| 3284 | |
| 3285 | /* build a SMPP_SM from SmsParameters */ |
| 3286 | function f_mt_sm_from_spars(SmsParameters spars) |
| 3287 | runs on BSC_ConnHdlr return SMPP_SM { |
| 3288 | var SMPP_SM sm := { |
| 3289 | service_type := "CMT", |
| 3290 | source_addr_ton := f_sm_ton_from_gsm(spars.tp.da.tP_DA_NoPad.tP_TypeOfNumber), |
| 3291 | source_addr_npi := f_sm_npi_from_gsm(spars.tp.da.tP_DA_NoPad.tP_NumberingPlanID), |
| 3292 | source_addr := hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue), |
| 3293 | dest_addr_ton := international, |
| 3294 | dest_addr_npi := isdn, |
| 3295 | destination_addr := hex2str(g_pars.msisdn), |
| 3296 | esm_class := '00000001'B, |
| 3297 | protocol_id := 0, |
| 3298 | priority_flag := 0, |
| 3299 | schedule_delivery_time := "", |
| 3300 | validity_period := "", |
| 3301 | registered_delivery := '00000000'B, |
| 3302 | replace_if_present := 0, |
| 3303 | data_coding := '00000001'B, |
| 3304 | sm_default_msg_id := 0, |
| 3305 | sm_length := spars.tp.udl, |
| 3306 | short_message := spars.tp.ud, |
| 3307 | opt_pars := {} |
| 3308 | }; |
| 3309 | return sm; |
| 3310 | } |
| 3311 | |
| 3312 | /* helper function to encode SMS from 'spars', send it via SMPP to MSC; receive it on MS side */ |
| 3313 | private function f_smpp_mt_sms(SmsParameters spars, boolean trans_mode) runs on BSC_ConnHdlr { |
| 3314 | var SMPP_SM sm := f_mt_sm_from_spars(spars); |
| 3315 | if (trans_mode) { |
| 3316 | sm.esm_class := '00000010'B; |
| 3317 | } |
| 3318 | |
| 3319 | /* actually cause MSC to send a SMS via SUBMIT-SM from SMPP side */ |
| 3320 | SMPP.send(ts_SMPP_SUBMIT_SM(sm)); |
| 3321 | if (not match(sm.esm_class, tr_ESM_CLASS_TRANSACTION)) { |
| 3322 | /* if we're not in SMPP transaction mode, we expect the SMPP-level ACK |
| 3323 | * before we expect the SMS delivery on the BSC/radio side */ |
| 3324 | SMPP.receive(tr_SMPP(c_SMPP_command_id_submit_sm_resp, ESME_ROK)); |
| 3325 | } |
| 3326 | |
| 3327 | /* MSC->BSC: expect PAGING from MSC */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 3328 | f_expect_paging(); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 3329 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 3330 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 3331 | SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)); |
| 3332 | |
| 3333 | f_mt_sms(spars); |
| 3334 | |
| 3335 | if (match(sm.esm_class, tr_ESM_CLASS_TRANSACTION)) { |
| 3336 | SMPP.receive(tr_SMPP(c_SMPP_command_id_submit_sm_resp, ESME_ROK)); |
| 3337 | } |
| 3338 | f_expect_clear(); |
| 3339 | } |
| 3340 | |
| 3341 | /* mobile terminated SMS, from SMPP to BSC/BTS/MS */ |
| 3342 | private function f_tc_smpp_mt_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 3343 | f_init_handler(pars); |
| 3344 | |
| 3345 | /* Perform location update so IMSI is known + registered in MSC/VLR */ |
| 3346 | f_perform_lu(); |
| 3347 | SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)); |
| 3348 | |
| 3349 | /* register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 3350 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 3351 | |
| 3352 | var SmsParameters spars := valueof(t_SmsPars); |
| 3353 | /* TODO: test with more intelligent user data; test different coding schemes */ |
| 3354 | spars.tp.ud := '00'O; |
| 3355 | spars.tp.udl := 1; |
| 3356 | |
| 3357 | /* first test the non-transaction store+forward mode */ |
| 3358 | f_smpp_mt_sms(spars, false); |
| 3359 | |
| 3360 | /* then test the transaction mode */ |
| 3361 | f_smpp_mt_sms(spars, true); |
| 3362 | } |
| 3363 | testcase TC_smpp_mt_sms() runs on MTC_CT { |
| 3364 | var BSC_ConnHdlr vc_conn; |
| 3365 | f_init(); |
| 3366 | vc_conn := f_start_handler(refers(f_tc_smpp_mt_sms), 45); |
| 3367 | vc_conn.done; |
| 3368 | } |
| 3369 | |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3370 | /*********************************************************************** |
| 3371 | * USSD Testing |
| 3372 | ***********************************************************************/ |
| 3373 | |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3374 | private altstep as_unexp_gsup_or_bssap_msg() |
| 3375 | runs on BSC_ConnHdlr { |
| 3376 | [] GSUP.receive { |
| 3377 | setverdict(fail, "Unknown/unexpected GSUP received"); |
| 3378 | self.stop; |
| 3379 | } |
| 3380 | [] BSSAP.receive { |
| 3381 | setverdict(fail, "Unknown/unexpected BSSAP message received"); |
| 3382 | self.stop; |
| 3383 | } |
| 3384 | } |
| 3385 | |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 3386 | private function f_expect_gsup_msg(template GSUP_PDU msg, |
| 3387 | float T_val := 2.0) |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3388 | runs on BSC_ConnHdlr return GSUP_PDU { |
| 3389 | var GSUP_PDU gsup_msg_complete; |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 3390 | timer T := T_val; |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3391 | |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3392 | T.start; |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3393 | alt { |
| 3394 | [] GSUP.receive(msg) -> value gsup_msg_complete { |
| 3395 | setverdict(pass); |
| 3396 | } |
| 3397 | /* We don't expect anything else */ |
| 3398 | [] as_unexp_gsup_or_bssap_msg(); |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3399 | [] T.timeout { |
| 3400 | setverdict(fail, "Timeout waiting for GSUP message: ", msg); |
| 3401 | } |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3402 | } |
| 3403 | |
| 3404 | return gsup_msg_complete; |
| 3405 | } |
| 3406 | |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 3407 | private function f_expect_mt_dtap_msg(template PDU_ML3_NW_MS msg, |
| 3408 | float T_val := 2.0) |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3409 | runs on BSC_ConnHdlr return PDU_ML3_NW_MS { |
| 3410 | var PDU_DTAP_MT bssap_msg_complete; |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 3411 | timer T := T_val; |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3412 | |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3413 | T.start; |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3414 | alt { |
| 3415 | [] BSSAP.receive(tr_PDU_DTAP_MT(msg)) -> value bssap_msg_complete { |
| 3416 | setverdict(pass); |
| 3417 | } |
| 3418 | /* We don't expect anything else */ |
| 3419 | [] as_unexp_gsup_or_bssap_msg(); |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3420 | [] T.timeout { |
| 3421 | setverdict(fail, "Timeout waiting for BSSAP message: ", msg); |
| 3422 | } |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3423 | } |
| 3424 | |
| 3425 | return bssap_msg_complete.dtap; |
| 3426 | } |
| 3427 | |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3428 | /* LU followed by MO USSD request */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3429 | 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] | 3430 | runs on BSC_ConnHdlr { |
| 3431 | f_init_handler(pars); |
| 3432 | |
| 3433 | /* Perform location update */ |
| 3434 | f_perform_lu(); |
| 3435 | |
| 3436 | /* Send CM Service Request for SS/USSD */ |
| 3437 | f_establish_fully(EST_TYPE_SS_ACT); |
| 3438 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3439 | /* We need to inspect GSUP activity */ |
| 3440 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3441 | |
| 3442 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 3443 | invoke_id := 5, /* Phone may not start from 0 or 1 */ |
| 3444 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3445 | ussd_string := "*#100#" |
| 3446 | ); |
| 3447 | |
| 3448 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 3449 | invoke_id := 5, /* InvokeID shall be the same for both REQ and RSP */ |
| 3450 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3451 | ussd_string := "Your extension is " & hex2str(g_pars.msisdn) & "\r" |
| 3452 | ) |
| 3453 | |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3454 | /* Compose a new SS/REGISTER message with request */ |
| 3455 | var template (value) PDU_ML3_MS_NW ussd_req := ts_ML3_MO_SS_REGISTER( |
| 3456 | tid := 1, /* We just need a single transaction */ |
| 3457 | 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] | 3458 | facility := valueof(facility_req) |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3459 | ); |
| 3460 | |
| 3461 | /* Compose SS/RELEASE_COMPLETE template with expected response */ |
| 3462 | var template PDU_ML3_NW_MS ussd_rsp := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3463 | tid := 1, /* Response should arrive within the same transaction */ |
| 3464 | 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] | 3465 | facility := valueof(facility_rsp) |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3466 | ); |
| 3467 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3468 | /* Compose expected MSC -> HLR message */ |
| 3469 | var template GSUP_PDU gsup_req := tr_GSUP_PROC_SS_REQ( |
| 3470 | imsi := g_pars.imsi, |
| 3471 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3472 | ss := valueof(facility_req) |
| 3473 | ); |
| 3474 | |
| 3475 | /* To be used for sending response with correct session ID */ |
| 3476 | var GSUP_PDU gsup_req_complete; |
| 3477 | |
| 3478 | /* Request own number */ |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3479 | BSSAP.send(ts_PDU_DTAP_MO(ussd_req)); |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3480 | /* Expect GSUP message containing the SS payload */ |
| 3481 | gsup_req_complete := f_expect_gsup_msg(gsup_req); |
| 3482 | |
| 3483 | /* Compose the response from HLR using received session ID */ |
| 3484 | var template GSUP_PDU gsup_rsp := ts_GSUP_PROC_SS_REQ( |
| 3485 | imsi := g_pars.imsi, |
| 3486 | sid := gsup_req_complete.ies[1].val.session_id, |
| 3487 | state := OSMO_GSUP_SESSION_STATE_END, |
| 3488 | ss := valueof(facility_rsp) |
| 3489 | ); |
| 3490 | |
| 3491 | /* Finally, HLR terminates the session */ |
| 3492 | GSUP.send(gsup_rsp); |
| 3493 | /* Expect RELEASE_COMPLETE message with the response */ |
| 3494 | f_expect_mt_dtap_msg(ussd_rsp); |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3495 | |
| 3496 | f_expect_clear(); |
| 3497 | } |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3498 | testcase TC_lu_and_mo_ussd_single_request() runs on MTC_CT { |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3499 | var BSC_ConnHdlr vc_conn; |
| 3500 | f_init(); |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3501 | 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] | 3502 | vc_conn.done; |
| 3503 | } |
| 3504 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3505 | |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3506 | /* LU followed by MT USSD notification */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3507 | 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] | 3508 | runs on BSC_ConnHdlr { |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3509 | timer T := 5.0; |
| 3510 | |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3511 | f_init_handler(pars); |
| 3512 | |
| 3513 | /* Perform location update */ |
| 3514 | f_perform_lu(); |
| 3515 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 3516 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3517 | |
| 3518 | /* We need to inspect GSUP activity */ |
| 3519 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3520 | |
| 3521 | /* Facility IE with network-originated USSD notification */ |
| 3522 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 3523 | op_code := SS_OP_CODE_USS_NOTIFY, |
| 3524 | ussd_string := "Mahlzeit!" |
| 3525 | ); |
| 3526 | |
| 3527 | /* Facility IE with acknowledgment to the USSD notification */ |
| 3528 | var template OCTN facility_rsp := enc_SS_FacilityInformation( |
| 3529 | /* In case of USSD notification, Return Result is empty */ |
| 3530 | valueof(ts_SS_USSD_FACILITY_RETURN_RESULT_EMPTY()) |
| 3531 | ); |
| 3532 | |
| 3533 | /* Compose a new MT SS/REGISTER message with USSD notification */ |
| 3534 | var template PDU_ML3_NW_MS ussd_ntf := tr_ML3_MT_SS_REGISTER( |
| 3535 | tid := 0, /* FIXME: most likely, it should be 0 */ |
| 3536 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3537 | facility := valueof(facility_req) |
| 3538 | ); |
| 3539 | |
| 3540 | /* Compose HLR -> MSC GSUP message */ |
| 3541 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 3542 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3543 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3544 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3545 | ss := valueof(facility_req) |
| 3546 | ); |
| 3547 | |
| 3548 | /* Send it to MSC and expect Paging Request */ |
| 3549 | GSUP.send(gsup_req); |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3550 | T.start; |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3551 | alt { |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3552 | [pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 3553 | setverdict(pass); |
| 3554 | } |
Harald Welte | 62113fc | 2019-05-09 13:04:02 +0200 | [diff] [blame] | 3555 | [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] | 3556 | setverdict(pass); |
| 3557 | } |
| 3558 | /* We don't expect anything else */ |
| 3559 | [] as_unexp_gsup_or_bssap_msg(); |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3560 | [] T.timeout { |
| 3561 | setverdict(fail, "Timeout waiting for Paging Request"); |
| 3562 | } |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3563 | } |
| 3564 | |
| 3565 | /* Send Paging Response and expect USSD notification */ |
| 3566 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 3567 | /* Expect MT REGISTER message with USSD notification */ |
| 3568 | f_expect_mt_dtap_msg(ussd_ntf); |
| 3569 | |
| 3570 | /* Compose a new MO SS/FACILITY message with empty response */ |
| 3571 | var template (value) PDU_ML3_MS_NW ussd_rsp := ts_ML3_MO_SS_FACILITY( |
| 3572 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3573 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3574 | facility := valueof(facility_rsp) |
| 3575 | ); |
| 3576 | |
| 3577 | /* Compose expected MSC -> HLR GSUP message */ |
| 3578 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_REQ( |
| 3579 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3580 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3581 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 3582 | ss := valueof(facility_rsp) |
| 3583 | ); |
| 3584 | |
| 3585 | /* MS sends response to the notification */ |
| 3586 | BSSAP.send(ts_PDU_DTAP_MO(ussd_rsp)); |
| 3587 | /* Expect GSUP message containing the SS payload */ |
| 3588 | f_expect_gsup_msg(gsup_rsp); |
| 3589 | |
| 3590 | /* Compose expected MT SS/RELEASE COMPLETE message */ |
| 3591 | var template PDU_ML3_NW_MS ussd_term := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3592 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3593 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3594 | facility := omit |
| 3595 | ); |
| 3596 | |
| 3597 | /* Compose MSC -> HLR GSUP message */ |
| 3598 | var template GSUP_PDU gsup_term := ts_GSUP_PROC_SS_REQ( |
| 3599 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3600 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3601 | state := OSMO_GSUP_SESSION_STATE_END |
| 3602 | ); |
| 3603 | |
| 3604 | /* Finally, HLR terminates the session */ |
| 3605 | GSUP.send(gsup_term) |
| 3606 | /* Expect MT RELEASE COMPLETE without Facility IE */ |
| 3607 | f_expect_mt_dtap_msg(ussd_term); |
| 3608 | |
| 3609 | f_expect_clear(); |
| 3610 | } |
| 3611 | testcase TC_lu_and_mt_ussd_notification() runs on MTC_CT { |
| 3612 | var BSC_ConnHdlr vc_conn; |
| 3613 | f_init(); |
| 3614 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_ussd_notification), 47); |
| 3615 | vc_conn.done; |
| 3616 | } |
| 3617 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3618 | |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3619 | /* LU followed by MT call and MO USSD request during this call */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3620 | 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] | 3621 | runs on BSC_ConnHdlr { |
| 3622 | f_init_handler(pars); |
| 3623 | |
| 3624 | /* Call parameters taken from f_tc_lu_and_mt_call */ |
| 3625 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3626 | |
| 3627 | /* Perform location update */ |
| 3628 | f_perform_lu(); |
| 3629 | |
| 3630 | /* Establish a MT call */ |
| 3631 | f_mt_call_establish(cpars); |
| 3632 | |
| 3633 | /* Hold the call for some time */ |
| 3634 | f_sleep(1.0); |
| 3635 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3636 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 3637 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3638 | ussd_string := "*#100#" |
| 3639 | ); |
| 3640 | |
| 3641 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 3642 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3643 | ussd_string := "Your extension is " & hex2str(g_pars.msisdn) & "\r" |
| 3644 | ) |
| 3645 | |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3646 | /* Compose a new SS/REGISTER message with request */ |
| 3647 | var template (value) PDU_ML3_MS_NW ussd_req := ts_ML3_MO_SS_REGISTER( |
| 3648 | tid := 1, /* We just need a single transaction */ |
| 3649 | 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] | 3650 | facility := valueof(facility_req) |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3651 | ); |
| 3652 | |
| 3653 | /* Compose SS/RELEASE_COMPLETE template with expected response */ |
| 3654 | var template PDU_ML3_NW_MS ussd_rsp := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3655 | tid := 1, /* Response should arrive within the same transaction */ |
| 3656 | 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] | 3657 | facility := valueof(facility_rsp) |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3658 | ); |
| 3659 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3660 | /* Compose expected MSC -> HLR message */ |
| 3661 | var template GSUP_PDU gsup_req := tr_GSUP_PROC_SS_REQ( |
| 3662 | imsi := g_pars.imsi, |
| 3663 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3664 | ss := valueof(facility_req) |
| 3665 | ); |
| 3666 | |
| 3667 | /* To be used for sending response with correct session ID */ |
| 3668 | var GSUP_PDU gsup_req_complete; |
| 3669 | |
| 3670 | /* Request own number */ |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3671 | BSSAP.send(ts_PDU_DTAP_MO(ussd_req)); |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3672 | /* Expect GSUP message containing the SS payload */ |
| 3673 | gsup_req_complete := f_expect_gsup_msg(gsup_req); |
| 3674 | |
| 3675 | /* Compose the response from HLR using received session ID */ |
| 3676 | var template GSUP_PDU gsup_rsp := ts_GSUP_PROC_SS_REQ( |
| 3677 | imsi := g_pars.imsi, |
| 3678 | sid := gsup_req_complete.ies[1].val.session_id, |
| 3679 | state := OSMO_GSUP_SESSION_STATE_END, |
| 3680 | ss := valueof(facility_rsp) |
| 3681 | ); |
| 3682 | |
| 3683 | /* Finally, HLR terminates the session */ |
| 3684 | GSUP.send(gsup_rsp); |
| 3685 | /* Expect RELEASE_COMPLETE message with the response */ |
| 3686 | f_expect_mt_dtap_msg(ussd_rsp); |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3687 | |
| 3688 | /* Hold the call for some time */ |
| 3689 | f_sleep(1.0); |
| 3690 | |
| 3691 | /* Release the call (does Clear Complete itself) */ |
| 3692 | f_call_hangup(cpars, true); |
| 3693 | } |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3694 | 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] | 3695 | var BSC_ConnHdlr vc_conn; |
| 3696 | f_init(); |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3697 | 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] | 3698 | vc_conn.done; |
| 3699 | } |
| 3700 | |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 3701 | /* BSSMAP Clear Request in the middle of a call, see OS#3062 */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3702 | 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] | 3703 | f_init_handler(pars); |
| 3704 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 3705 | cpars.ran_clear_when_alerting := true; |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 3706 | |
| 3707 | f_perform_lu(); |
| 3708 | |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 3709 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 3710 | f_mo_call_establish(cpars); |
| 3711 | f_expect_clear() |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 3712 | deactivate(ccrel); |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 3713 | |
| 3714 | f_sleep(1.0); |
| 3715 | } |
| 3716 | testcase TC_mo_cc_bssmap_clear() runs on MTC_CT { |
| 3717 | var BSC_ConnHdlr vc_conn; |
| 3718 | f_init(); |
| 3719 | |
| 3720 | vc_conn := f_start_handler(refers(f_tc_mo_cc_bssmap_clear), 43); |
| 3721 | vc_conn.done; |
| 3722 | } |
| 3723 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3724 | |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3725 | /* LU followed by MT call and MT USSD request during this call */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3726 | 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] | 3727 | runs on BSC_ConnHdlr { |
| 3728 | f_init_handler(pars); |
| 3729 | |
| 3730 | /* Call parameters taken from f_tc_lu_and_mt_call */ |
| 3731 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3732 | |
| 3733 | /* Perform location update */ |
| 3734 | f_perform_lu(); |
| 3735 | |
| 3736 | /* Establish a MT call */ |
| 3737 | f_mt_call_establish(cpars); |
| 3738 | |
| 3739 | /* Hold the call for some time */ |
| 3740 | f_sleep(1.0); |
| 3741 | |
| 3742 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 3743 | op_code := SS_OP_CODE_USS_REQUEST, |
| 3744 | ussd_string := "Please type anything..." |
| 3745 | ); |
| 3746 | |
| 3747 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 3748 | op_code := SS_OP_CODE_USS_REQUEST, |
| 3749 | ussd_string := "Nope." |
| 3750 | ) |
| 3751 | |
| 3752 | /* Compose MT SS/REGISTER message with network-originated request */ |
| 3753 | var template (value) PDU_ML3_NW_MS ussd_req := ts_ML3_MT_SS_REGISTER( |
| 3754 | tid := 0, /* FIXME: most likely, it should be 0 */ |
| 3755 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3756 | facility := valueof(facility_req) |
| 3757 | ); |
| 3758 | |
| 3759 | /* Compose HLR -> MSC GSUP message */ |
| 3760 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 3761 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3762 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3763 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3764 | ss := valueof(facility_req) |
| 3765 | ); |
| 3766 | |
| 3767 | /* Send it to MSC */ |
| 3768 | GSUP.send(gsup_req); |
| 3769 | /* Expect MT REGISTER message with USSD request */ |
| 3770 | f_expect_mt_dtap_msg(ussd_req); |
| 3771 | |
| 3772 | /* Compose a new MO SS/FACILITY message with response */ |
| 3773 | var template (value) PDU_ML3_MS_NW ussd_rsp := ts_ML3_MO_SS_FACILITY( |
| 3774 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3775 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3776 | facility := valueof(facility_rsp) |
| 3777 | ); |
| 3778 | |
| 3779 | /* Compose expected MSC -> HLR GSUP message */ |
| 3780 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_REQ( |
| 3781 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3782 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3783 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 3784 | ss := valueof(facility_rsp) |
| 3785 | ); |
| 3786 | |
| 3787 | /* MS sends response */ |
| 3788 | BSSAP.send(ts_PDU_DTAP_MO(ussd_rsp)); |
| 3789 | f_expect_gsup_msg(gsup_rsp); |
| 3790 | |
| 3791 | /* Compose expected MT SS/RELEASE COMPLETE message */ |
| 3792 | var template PDU_ML3_NW_MS ussd_term := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3793 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3794 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3795 | facility := omit |
| 3796 | ); |
| 3797 | |
| 3798 | /* Compose MSC -> HLR GSUP message */ |
| 3799 | var template GSUP_PDU gsup_term := ts_GSUP_PROC_SS_REQ( |
| 3800 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3801 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3802 | state := OSMO_GSUP_SESSION_STATE_END |
| 3803 | ); |
| 3804 | |
| 3805 | /* Finally, HLR terminates the session */ |
| 3806 | GSUP.send(gsup_term); |
| 3807 | /* Expect MT RELEASE COMPLETE without Facility IE */ |
| 3808 | f_expect_mt_dtap_msg(ussd_term); |
| 3809 | |
| 3810 | /* Hold the call for some time */ |
| 3811 | f_sleep(1.0); |
| 3812 | |
| 3813 | /* Release the call (does Clear Complete itself) */ |
| 3814 | f_call_hangup(cpars, true); |
| 3815 | } |
| 3816 | testcase TC_lu_and_mt_ussd_during_mt_call() runs on MTC_CT { |
| 3817 | var BSC_ConnHdlr vc_conn; |
| 3818 | f_init(); |
| 3819 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_ussd_during_mt_call), 49); |
| 3820 | vc_conn.done; |
| 3821 | } |
| 3822 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3823 | |
Vadim Yanitskiy | 2daf52d | 2018-06-21 04:19:58 +0700 | [diff] [blame] | 3824 | /* LU followed by MO USSD request and MO Release during transaction */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3825 | 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] | 3826 | runs on BSC_ConnHdlr { |
| 3827 | f_init_handler(pars); |
| 3828 | |
| 3829 | /* Perform location update */ |
| 3830 | f_perform_lu(); |
| 3831 | |
| 3832 | /* Send CM Service Request for SS/USSD */ |
| 3833 | f_establish_fully(EST_TYPE_SS_ACT); |
| 3834 | |
| 3835 | /* We need to inspect GSUP activity */ |
| 3836 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3837 | |
| 3838 | var template OCTN facility_ms_req := f_USSD_FACILITY_IE_INVOKE( |
| 3839 | invoke_id := 1, /* Initial request */ |
| 3840 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3841 | ussd_string := "*6766*266#" |
| 3842 | ); |
| 3843 | |
| 3844 | var template OCTN facility_net_req := f_USSD_FACILITY_IE_INVOKE( |
| 3845 | invoke_id := 2, /* Counter request */ |
| 3846 | op_code := SS_OP_CODE_USS_REQUEST, |
| 3847 | ussd_string := "Password?!?" |
| 3848 | ) |
| 3849 | |
| 3850 | /* Compose MO SS/REGISTER message with request */ |
| 3851 | var template (value) PDU_ML3_MS_NW ussd_ms_req := ts_ML3_MO_SS_REGISTER( |
| 3852 | tid := 1, /* We just need a single transaction */ |
| 3853 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3854 | facility := valueof(facility_ms_req) |
| 3855 | ); |
| 3856 | |
| 3857 | /* Compose expected MSC -> HLR message */ |
| 3858 | var template GSUP_PDU gsup_ms_req := tr_GSUP_PROC_SS_REQ( |
| 3859 | imsi := g_pars.imsi, |
| 3860 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3861 | ss := valueof(facility_ms_req) |
| 3862 | ); |
| 3863 | |
| 3864 | /* To be used for sending response with correct session ID */ |
| 3865 | var GSUP_PDU gsup_ms_req_complete; |
| 3866 | |
| 3867 | /* Initiate a new transaction */ |
| 3868 | BSSAP.send(ts_PDU_DTAP_MO(ussd_ms_req)); |
| 3869 | /* Expect GSUP request with original Facility IE */ |
| 3870 | gsup_ms_req_complete := f_expect_gsup_msg(gsup_ms_req); |
| 3871 | |
| 3872 | /* Compose the response from HLR using received session ID */ |
| 3873 | var template (value) GSUP_PDU gsup_net_req := ts_GSUP_PROC_SS_REQ( |
| 3874 | imsi := g_pars.imsi, |
| 3875 | sid := gsup_ms_req_complete.ies[1].val.session_id, |
| 3876 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 3877 | ss := valueof(facility_net_req) |
| 3878 | ); |
| 3879 | |
| 3880 | /* Compose expected MT SS/FACILITY template with counter request */ |
| 3881 | var template PDU_ML3_NW_MS ussd_net_req := tr_ML3_MT_SS_FACILITY( |
| 3882 | tid := 1, /* Response should arrive within the same transaction */ |
| 3883 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3884 | facility := valueof(facility_net_req) |
| 3885 | ); |
| 3886 | |
| 3887 | /* Send response over GSUP */ |
| 3888 | GSUP.send(gsup_net_req); |
| 3889 | /* Expect MT SS/FACILITY message with counter request */ |
| 3890 | f_expect_mt_dtap_msg(ussd_net_req); |
| 3891 | |
| 3892 | /* Compose MO SS/RELEASE COMPLETE */ |
| 3893 | var template (value) PDU_ML3_MS_NW ussd_abort := ts_ML3_MO_SS_RELEASE_COMPLETE( |
| 3894 | tid := 1, /* Response should arrive within the same transaction */ |
| 3895 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3896 | facility := omit |
| 3897 | /* TODO: cause? */ |
| 3898 | ); |
| 3899 | |
| 3900 | /* Compose expected HLR -> MSC abort message */ |
| 3901 | var template GSUP_PDU gsup_abort := tr_GSUP_PROC_SS_REQ( |
| 3902 | imsi := g_pars.imsi, |
| 3903 | sid := gsup_ms_req_complete.ies[1].val.session_id, |
| 3904 | state := OSMO_GSUP_SESSION_STATE_END |
| 3905 | ); |
| 3906 | |
| 3907 | /* Abort transaction */ |
| 3908 | BSSAP.send(ts_PDU_DTAP_MO(ussd_abort)); |
| 3909 | /* Expect GSUP message indicating abort */ |
| 3910 | f_expect_gsup_msg(gsup_abort); |
| 3911 | |
| 3912 | f_expect_clear(); |
| 3913 | } |
| 3914 | testcase TC_lu_and_mo_ussd_mo_release() runs on MTC_CT { |
| 3915 | var BSC_ConnHdlr vc_conn; |
| 3916 | f_init(); |
| 3917 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_ussd_mo_release), 50); |
| 3918 | vc_conn.done; |
| 3919 | } |
| 3920 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3921 | |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 3922 | /* LU followed by MO USSD request and MT Release due to timeout */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3923 | 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] | 3924 | runs on BSC_ConnHdlr { |
| 3925 | f_init_handler(pars); |
| 3926 | |
| 3927 | /* Perform location update */ |
| 3928 | f_perform_lu(); |
| 3929 | |
| 3930 | /* Send CM Service Request for SS/USSD */ |
| 3931 | f_establish_fully(EST_TYPE_SS_ACT); |
| 3932 | |
| 3933 | /* We need to inspect GSUP activity */ |
| 3934 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3935 | |
| 3936 | var template OCTN facility_ms_req := f_USSD_FACILITY_IE_INVOKE( |
| 3937 | invoke_id := 1, |
| 3938 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3939 | ussd_string := "#release_me"); |
| 3940 | |
| 3941 | /* Compose MO SS/REGISTER message with request */ |
| 3942 | var template (value) PDU_ML3_MS_NW ussd_ms_req := ts_ML3_MO_SS_REGISTER( |
| 3943 | tid := 1, /* An arbitrary transaction identifier */ |
| 3944 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3945 | facility := valueof(facility_ms_req)); |
| 3946 | |
| 3947 | /* Compose expected MSC -> HLR message */ |
| 3948 | var template GSUP_PDU gsup_ms_req := tr_GSUP_PROC_SS_REQ( |
| 3949 | imsi := g_pars.imsi, |
| 3950 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3951 | ss := valueof(facility_ms_req)); |
| 3952 | |
| 3953 | /* To be used for sending response with correct session ID */ |
| 3954 | var GSUP_PDU gsup_ms_req_complete; |
| 3955 | |
| 3956 | /* Initiate a new SS transaction */ |
| 3957 | BSSAP.send(ts_PDU_DTAP_MO(ussd_ms_req)); |
| 3958 | /* Expect GSUP request with original Facility IE */ |
| 3959 | gsup_ms_req_complete := f_expect_gsup_msg(gsup_ms_req); |
| 3960 | |
| 3961 | /* Don't respond, wait for timeout */ |
| 3962 | f_sleep(3.0); |
| 3963 | |
| 3964 | var template PDU_ML3_NW_MS dtap_rel := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3965 | tid := 1, /* Should match the request's tid */ |
| 3966 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3967 | cause := *, /* TODO: expect some specific value */ |
| 3968 | facility := omit); |
| 3969 | |
| 3970 | var template GSUP_PDU gsup_rel := tr_GSUP_PROC_SS_ERR( |
| 3971 | imsi := g_pars.imsi, |
| 3972 | sid := gsup_ms_req_complete.ies[1].val.session_id, |
| 3973 | state := OSMO_GSUP_SESSION_STATE_END, |
| 3974 | cause := ?); /* TODO: expect some specific value */ |
| 3975 | |
| 3976 | /* Expect release on both interfaces */ |
| 3977 | interleave { |
| 3978 | [] BSSAP.receive(tr_PDU_DTAP_MT(dtap_rel)) { }; |
| 3979 | [] GSUP.receive(gsup_rel) { }; |
| 3980 | } |
| 3981 | |
| 3982 | f_expect_clear(); |
| 3983 | setverdict(pass); |
| 3984 | } |
| 3985 | testcase TC_lu_and_ss_session_timeout() runs on MTC_CT { |
| 3986 | var BSC_ConnHdlr vc_conn; |
| 3987 | f_init(); |
Vadim Yanitskiy | 36d28dd | 2018-12-03 02:45:45 +0700 | [diff] [blame] | 3988 | f_vty_config(MSCVTY, "msc", "ncss guard-timeout 3"); |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 3989 | vc_conn := f_start_handler(refers(f_tc_lu_and_ss_session_timeout), 51); |
| 3990 | vc_conn.done; |
Vadim Yanitskiy | 36d28dd | 2018-12-03 02:45:45 +0700 | [diff] [blame] | 3991 | f_vty_config(MSCVTY, "msc", "ncss guard-timeout 0"); |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 3992 | } |
| 3993 | |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 3994 | /* MT (network-originated) USSD for unknown subscriber */ |
| 3995 | friend function f_tc_mt_ussd_for_unknown_subscr(charstring id, BSC_ConnHdlrPars pars) |
| 3996 | runs on BSC_ConnHdlr { |
| 3997 | var hexstring imsi := '000000000000000'H; /* Some unknown IMSI */ |
| 3998 | var OCT4 sid := '20000222'O; |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 3999 | |
| 4000 | f_init_handler(pars); |
| 4001 | f_ran_register_imsi(imsi, 'FFFFFFFF'O); |
| 4002 | f_create_gsup_expect(hex2str(imsi)); |
| 4003 | |
| 4004 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 4005 | imsi := imsi, |
| 4006 | sid := sid, |
| 4007 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 4008 | ss := f_rnd_octstring(23) |
| 4009 | ); |
| 4010 | |
| 4011 | /* Error with cause GMM_CAUSE_IMSI_UNKNOWN */ |
| 4012 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_ERR( |
| 4013 | imsi := imsi, |
| 4014 | sid := sid, |
| 4015 | state := OSMO_GSUP_SESSION_STATE_END, |
| 4016 | cause := 2 /* FIXME: introduce an enumerated type! */ |
| 4017 | ); |
| 4018 | |
| 4019 | /* Initiate a MT USSD notification */ |
| 4020 | GSUP.send(gsup_req); |
| 4021 | |
| 4022 | /* Expect GSUP PROC_SS_ERROR message */ |
Vadim Yanitskiy | 851798c | 2019-06-15 14:22:28 +0700 | [diff] [blame] | 4023 | f_expect_gsup_msg(gsup_rsp); |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 4024 | } |
| 4025 | testcase TC_mt_ussd_for_unknown_subscr() runs on MTC_CT { |
| 4026 | var BSC_ConnHdlr vc_conn; |
| 4027 | f_init(); |
| 4028 | vc_conn := f_start_handler(refers(f_tc_mt_ussd_for_unknown_subscr), 0); |
| 4029 | vc_conn.done; |
| 4030 | } |
| 4031 | |
Vadim Yanitskiy | c3c07d4 | 2019-06-17 23:00:44 +0700 | [diff] [blame] | 4032 | /* MO (mobile-originated) SS/USSD for unknown transaction */ |
| 4033 | friend function f_tc_mo_ussd_for_unknown_trans(charstring id, BSC_ConnHdlrPars pars) |
| 4034 | runs on BSC_ConnHdlr { |
| 4035 | f_init_handler(pars); |
| 4036 | |
Vadim Yanitskiy | 70d15bf | 2020-01-09 22:51:01 +0100 | [diff] [blame] | 4037 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | c3c07d4 | 2019-06-17 23:00:44 +0700 | [diff] [blame] | 4038 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4039 | |
| 4040 | /* Perform location update */ |
| 4041 | f_perform_lu(); |
| 4042 | |
| 4043 | /* Send CM Service Request for SS/USSD */ |
| 4044 | f_establish_fully(EST_TYPE_SS_ACT); |
| 4045 | |
| 4046 | /* GSM 04.80 FACILITY message for a non-existing transaction */ |
| 4047 | var template (value) PDU_ML3_MS_NW mo_ss_fac := ts_ML3_MO_SS_FACILITY( |
| 4048 | tid := 1, /* An arbitrary transaction identifier */ |
| 4049 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 4050 | facility := f_rnd_octstring(23) /* We don't care about the Facility IE */ |
| 4051 | ); |
| 4052 | |
| 4053 | /* GSM 04.80 RELEASE COMPLETE message for a non-existing transaction */ |
| 4054 | var template (value) PDU_ML3_MS_NW mo_ss_rel := ts_ML3_MO_SS_RELEASE_COMPLETE( |
| 4055 | tid := 1, /* An arbitrary transaction identifier */ |
| 4056 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 4057 | facility := f_rnd_octstring(23) /* We don't care about the Facility IE */ |
| 4058 | ); |
| 4059 | |
| 4060 | /* Expected response from the network */ |
| 4061 | var template PDU_ML3_NW_MS mt_ss_rel := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 4062 | tid := 1, /* Same as in the FACILITY message */ |
| 4063 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 4064 | facility := omit |
| 4065 | ); |
| 4066 | |
| 4067 | /* Send GSM 04.80 FACILITY for non-existing transaction */ |
| 4068 | BSSAP.send(ts_PDU_DTAP_MO(mo_ss_fac)); |
| 4069 | |
| 4070 | /* Expect GSM 04.80 RELEASE COMPLETE message */ |
| 4071 | f_expect_mt_dtap_msg(mt_ss_rel); |
| 4072 | f_expect_clear(); |
| 4073 | |
| 4074 | /* Send another CM Service Request for SS/USSD */ |
| 4075 | f_establish_fully(EST_TYPE_SS_ACT); |
| 4076 | |
| 4077 | /* Send GSM 04.80 RELEASE COMPLETE for non-existing transaction */ |
| 4078 | BSSAP.send(ts_PDU_DTAP_MO(mo_ss_rel)); |
| 4079 | |
| 4080 | /* Expect GSM 04.80 RELEASE COMPLETE message */ |
| 4081 | f_expect_mt_dtap_msg(mt_ss_rel); |
| 4082 | f_expect_clear(); |
| 4083 | } |
| 4084 | testcase TC_mo_ussd_for_unknown_trans() runs on MTC_CT { |
| 4085 | var BSC_ConnHdlr vc_conn; |
| 4086 | f_init(); |
| 4087 | vc_conn := f_start_handler(refers(f_tc_mo_ussd_for_unknown_trans), 111); |
| 4088 | vc_conn.done; |
| 4089 | } |
| 4090 | |
Vadim Yanitskiy | d612d28 | 2019-06-15 14:46:03 +0700 | [diff] [blame] | 4091 | /* MT (network-originated) USSD for unknown session */ |
| 4092 | friend function f_tc_proc_ss_for_unknown_session(charstring id, BSC_ConnHdlrPars pars) |
| 4093 | runs on BSC_ConnHdlr { |
| 4094 | var OCT4 sid := '20000333'O; |
| 4095 | |
| 4096 | f_init_handler(pars); |
| 4097 | |
| 4098 | /* Perform location update */ |
| 4099 | f_perform_lu(); |
| 4100 | |
Vadim Yanitskiy | 70d15bf | 2020-01-09 22:51:01 +0100 | [diff] [blame] | 4101 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | d612d28 | 2019-06-15 14:46:03 +0700 | [diff] [blame] | 4102 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4103 | |
| 4104 | /* Request referencing a non-existing SS session */ |
| 4105 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 4106 | imsi := g_pars.imsi, |
| 4107 | sid := sid, |
| 4108 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 4109 | ss := f_rnd_octstring(23) |
| 4110 | ); |
| 4111 | |
| 4112 | /* Error with some cause value */ |
| 4113 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_ERR( |
| 4114 | imsi := g_pars.imsi, |
| 4115 | sid := sid, |
| 4116 | state := OSMO_GSUP_SESSION_STATE_END, |
| 4117 | cause := ? /* FIXME: introduce an enumerated type! */ |
| 4118 | ); |
| 4119 | |
| 4120 | /* Initiate a MT USSD notification */ |
| 4121 | GSUP.send(gsup_req); |
| 4122 | |
| 4123 | /* Expect GSUP PROC_SS_ERROR message */ |
| 4124 | f_expect_gsup_msg(gsup_rsp); |
| 4125 | } |
| 4126 | testcase TC_proc_ss_for_unknown_session() runs on MTC_CT { |
| 4127 | var BSC_ConnHdlr vc_conn; |
| 4128 | f_init(); |
| 4129 | vc_conn := f_start_handler(refers(f_tc_proc_ss_for_unknown_session), 110); |
| 4130 | vc_conn.done; |
| 4131 | } |
| 4132 | |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 4133 | /* MT (network-originated) USSD and no response to Paging Request */ |
| 4134 | friend function f_tc_proc_ss_paging_fail(charstring id, BSC_ConnHdlrPars pars) |
| 4135 | runs on BSC_ConnHdlr { |
| 4136 | timer TP := 2.0; /* Paging timer */ |
| 4137 | |
| 4138 | f_init_handler(pars); |
| 4139 | |
| 4140 | /* Perform location update */ |
| 4141 | f_perform_lu(); |
| 4142 | |
Vadim Yanitskiy | 70d15bf | 2020-01-09 22:51:01 +0100 | [diff] [blame] | 4143 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 4144 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4145 | |
| 4146 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 4147 | imsi := g_pars.imsi, |
| 4148 | sid := '20000444'O, |
| 4149 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 4150 | ss := f_rnd_octstring(23) |
| 4151 | ); |
| 4152 | |
| 4153 | /* Error with some cause value */ |
| 4154 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_ERR( |
| 4155 | imsi := g_pars.imsi, |
| 4156 | sid := '20000444'O, |
| 4157 | state := OSMO_GSUP_SESSION_STATE_END, |
| 4158 | cause := ? /* FIXME: introduce an enumerated type! */ |
| 4159 | ); |
| 4160 | |
| 4161 | /* Initiate a MT USSD notification */ |
| 4162 | GSUP.send(gsup_req); |
| 4163 | |
| 4164 | /* Send it to MSC and expect Paging Request */ |
| 4165 | TP.start; |
| 4166 | alt { |
| 4167 | [pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 4168 | setverdict(pass); |
| 4169 | } |
| 4170 | [not pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) { |
| 4171 | setverdict(pass); |
| 4172 | } |
| 4173 | /* We don't expect anything else */ |
| 4174 | [] as_unexp_gsup_or_bssap_msg(); |
| 4175 | [] TP.timeout { |
| 4176 | setverdict(fail, "Timeout waiting for Paging Request"); |
| 4177 | } |
| 4178 | } |
| 4179 | |
Vadim Yanitskiy | d24b525 | 2019-10-02 00:04:51 +0700 | [diff] [blame] | 4180 | /* Wait up to 20 seconds for GSUP PROC_SS_ERROR message. |
| 4181 | * OsmoMSC waits for Paging Response 10 seconds by default. */ |
| 4182 | f_expect_gsup_msg(gsup_rsp, T_val := 20.0); |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 4183 | } |
| 4184 | testcase TC_proc_ss_paging_fail() runs on MTC_CT { |
| 4185 | var BSC_ConnHdlr vc_conn; |
| 4186 | f_init(); |
| 4187 | vc_conn := f_start_handler(refers(f_tc_proc_ss_paging_fail), 101); |
| 4188 | vc_conn.done; |
| 4189 | } |
| 4190 | |
Vadim Yanitskiy | 29ba8d6 | 2019-06-16 15:19:41 +0700 | [diff] [blame] | 4191 | /* MT (network-originated) USSD followed by immediate abort */ |
| 4192 | friend function f_tc_proc_ss_abort(charstring id, BSC_ConnHdlrPars pars) |
| 4193 | runs on BSC_ConnHdlr { |
| 4194 | var octetstring facility := f_rnd_octstring(23); |
| 4195 | var OCT4 sid := '20000555'O; |
| 4196 | timer TP := 2.0; |
| 4197 | |
| 4198 | f_init_handler(pars); |
| 4199 | |
| 4200 | /* Perform location update */ |
| 4201 | f_perform_lu(); |
| 4202 | |
Vadim Yanitskiy | 70d15bf | 2020-01-09 22:51:01 +0100 | [diff] [blame] | 4203 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 29ba8d6 | 2019-06-16 15:19:41 +0700 | [diff] [blame] | 4204 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4205 | |
| 4206 | /* PROC_SS_REQ initiates a mobile-originated SS/USSD session */ |
| 4207 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 4208 | imsi := g_pars.imsi, sid := sid, |
| 4209 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 4210 | ss := facility |
| 4211 | ); |
| 4212 | |
| 4213 | /* On the MS side, we expect GSM 04.80 REGISTER message */ |
| 4214 | var template PDU_ML3_NW_MS dtap_reg := tr_ML3_MT_SS_REGISTER( |
| 4215 | tid := 0, /* Most likely, it should be 0 */ |
| 4216 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 4217 | facility := facility |
| 4218 | ); |
| 4219 | |
| 4220 | /* PROC_SS_ERR with SESSION_STATE_END terminates the SS/USSD session */ |
| 4221 | var template (value) GSUP_PDU gsup_abort := ts_GSUP_PROC_SS_ERR( |
| 4222 | imsi := g_pars.imsi, sid := sid, |
| 4223 | state := OSMO_GSUP_SESSION_STATE_END, |
| 4224 | cause := 0 /* FIXME: introduce an enumerated type! */ |
| 4225 | ); |
| 4226 | |
| 4227 | /* On the MS side, we expect GSM 04.80 REGISTER message */ |
| 4228 | var template PDU_ML3_NW_MS dtap_rel := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 4229 | tid := 0, /* Most likely, it should be 0 */ |
| 4230 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 4231 | cause := *, /* FIXME: expect some specific cause value */ |
| 4232 | facility := omit |
| 4233 | ); |
| 4234 | |
| 4235 | /* Initiate a MT USSD with random payload */ |
| 4236 | GSUP.send(gsup_req); |
| 4237 | |
| 4238 | /* Expect Paging Request */ |
| 4239 | TP.start; |
| 4240 | alt { |
| 4241 | [pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 4242 | setverdict(pass); |
| 4243 | } |
| 4244 | [not pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) { |
| 4245 | setverdict(pass); |
| 4246 | } |
| 4247 | /* We don't expect anything else */ |
| 4248 | [] as_unexp_gsup_or_bssap_msg(); |
| 4249 | [] TP.timeout { |
| 4250 | setverdict(fail, "Timeout waiting for Paging Request"); |
| 4251 | } |
| 4252 | } |
| 4253 | |
| 4254 | /* Send Paging Response and establish connection */ |
| 4255 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 4256 | /* Expect MT REGISTER message with random facility */ |
| 4257 | f_expect_mt_dtap_msg(dtap_reg); |
| 4258 | |
| 4259 | /* HLR/EUSE decides to abort the session even |
| 4260 | * before getting any response from the MS */ |
| 4261 | /* Initiate a MT USSD with random payload */ |
| 4262 | GSUP.send(gsup_abort); |
| 4263 | |
| 4264 | /* Expect RELEASE COMPLETE on ths MS side */ |
| 4265 | f_expect_mt_dtap_msg(dtap_rel); |
| 4266 | |
| 4267 | f_expect_clear(); |
| 4268 | } |
| 4269 | testcase TC_proc_ss_abort() runs on MTC_CT { |
| 4270 | var BSC_ConnHdlr vc_conn; |
| 4271 | f_init(); |
| 4272 | vc_conn := f_start_handler(refers(f_tc_proc_ss_abort), 102); |
| 4273 | vc_conn.done; |
| 4274 | } |
| 4275 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 4276 | |
Vadim Yanitskiy | 1c9754d | 2020-01-07 21:56:55 +0100 | [diff] [blame] | 4277 | /* Verify multiple concurrent MO SS/USSD transactions |
| 4278 | * (one subscriber - one transaction) */ |
| 4279 | testcase TC_multi_lu_and_mo_ussd() runs on MTC_CT { |
| 4280 | var BSC_ConnHdlr vc_conn[16]; |
| 4281 | var integer i; |
| 4282 | |
| 4283 | f_init(); |
| 4284 | |
| 4285 | for (i := 0; i < sizeof(vc_conn); i := i + 1) { |
| 4286 | vc_conn[i] := f_start_handler(refers(f_tc_lu_and_mo_ussd_single_request), 210 + i); |
| 4287 | } |
| 4288 | |
| 4289 | for (i := 0; i < sizeof(vc_conn); i := i + 1) { |
| 4290 | vc_conn[i].done; |
| 4291 | } |
| 4292 | } |
| 4293 | |
| 4294 | /* Verify multiple concurrent MT SS/USSD transactions |
| 4295 | * (one subscriber - one transaction) */ |
| 4296 | testcase TC_multi_lu_and_mt_ussd() runs on MTC_CT { |
| 4297 | var BSC_ConnHdlr vc_conn[16]; |
| 4298 | var integer i; |
| 4299 | var OCT4 sid; |
| 4300 | |
| 4301 | f_init(); |
| 4302 | |
| 4303 | for (i := 0; i < sizeof(vc_conn); i := i + 1) { |
| 4304 | sid := '200001'O & int2oct(i, 1); /* All transactions must use different session ID */ |
| 4305 | vc_conn[i] := f_start_handler_with_pars(refers(f_tc_lu_and_mt_ussd_notification), |
| 4306 | f_init_pars(226 + i, gsup_sid := sid)); |
| 4307 | } |
| 4308 | |
| 4309 | for (i := 0; i < sizeof(vc_conn); i := i + 1) { |
| 4310 | vc_conn[i].done; |
| 4311 | } |
| 4312 | } |
| 4313 | |
| 4314 | |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 4315 | /* A5/1 only permitted on network side; attempt an invalid CIPHER MODE COMPLETE with A5/3 which MSC should reject. */ |
| 4316 | private function f_tc_cipher_complete_with_invalid_cipher(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4317 | pars.net.expect_auth := true; |
| 4318 | pars.net.expect_ciph := true; |
| 4319 | pars.net.kc_support := '02'O; /* A5/1 only */ |
| 4320 | f_init_handler(pars); |
| 4321 | |
| 4322 | g_pars.vec := f_gen_auth_vec_2g(); |
| 4323 | |
| 4324 | /* Can't use f_perform_lu() directly. Code below is based on it. */ |
| 4325 | |
| 4326 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 4327 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4328 | |
| 4329 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 4330 | 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] | 4331 | f_cl3_or_initial_ue(l3_lu); |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 4332 | |
| 4333 | f_mm_auth(); |
| 4334 | |
| 4335 | var OCT1 a5_net := f_alg_mask_from_cm(g_pars.cm2); |
| 4336 | var OCT1 a5_intersect := g_pars.net.kc_support and4b a5_net; |
| 4337 | alt { |
| 4338 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(a5_intersect, g_pars.vec.kc)) { |
| 4339 | BSSAP.send(ts_BSSMAP_CipherModeCompl(int2oct(4 /* "accept" A5/3 */, 1))); |
| 4340 | } |
| 4341 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?, g_pars.vec.kc)) { |
| 4342 | setverdict(fail, "Wrong ciphering algorithm mask in CiphModCmd"); |
| 4343 | mtc.stop; |
| 4344 | } |
| 4345 | [] BSSAP.receive { |
| 4346 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 4347 | mtc.stop; |
| 4348 | } |
| 4349 | } |
Harald Welte | 79f1e45 | 2020-08-18 22:55:02 +0200 | [diff] [blame] | 4350 | f_expect_common_id(); |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 4351 | |
| 4352 | /* Expect LU reject from MSC. */ |
| 4353 | alt { |
| 4354 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 4355 | setverdict(pass); |
| 4356 | } |
| 4357 | [] BSSAP.receive { |
| 4358 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 4359 | mtc.stop; |
| 4360 | } |
| 4361 | } |
Stefan Sperling | c620b35 | 2018-12-18 17:23:36 +0100 | [diff] [blame] | 4362 | f_expect_clear(); |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 4363 | } |
| 4364 | |
| 4365 | testcase TC_cipher_complete_with_invalid_cipher() runs on MTC_CT { |
| 4366 | var BSC_ConnHdlr vc_conn; |
| 4367 | f_init(); |
| 4368 | f_vty_config(MSCVTY, "network", "encryption a5 1"); |
| 4369 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 4370 | 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] | 4371 | vc_conn.done; |
| 4372 | } |
| 4373 | |
Harald Welte | b2284bd | 2019-05-10 11:30:43 +0200 | [diff] [blame] | 4374 | /* Location Update with invalid (non-matching) MCC/MNC reported on BSSMAP level from BSC */ |
| 4375 | friend function f_tc_lu_with_invalid_mcc_mnc(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4376 | f_init_handler(pars); |
| 4377 | |
| 4378 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 4379 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4380 | |
| 4381 | /* modify the cell ID which will be used to construct the COMPLELTE L3 or InitialUE */ |
| 4382 | g_pars.cell_id := valueof(ts_CellId_CGI('333'H, '22'H, 23, 42)); |
| 4383 | |
| 4384 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 4385 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 4386 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 79f1e45 | 2020-08-18 22:55:02 +0200 | [diff] [blame] | 4387 | f_expect_common_id(); |
Harald Welte | b2284bd | 2019-05-10 11:30:43 +0200 | [diff] [blame] | 4388 | |
| 4389 | /* Expect LU reject from MSC. */ |
| 4390 | alt { |
| 4391 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 4392 | setverdict(pass); |
| 4393 | } |
| 4394 | [] BSSAP.receive { |
| 4395 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 4396 | mtc.stop; |
| 4397 | } |
| 4398 | } |
| 4399 | f_expect_clear(); |
| 4400 | } |
| 4401 | testcase TC_lu_with_invalid_mcc_mnc() runs on MTC_CT { |
| 4402 | var BSC_ConnHdlr vc_conn; |
| 4403 | f_init(); |
| 4404 | vc_conn := f_start_handler(refers(f_tc_lu_with_invalid_mcc_mnc), 54); |
| 4405 | vc_conn.done; |
| 4406 | } |
| 4407 | |
Stefan Sperling | a2d59c6 | 2018-12-18 16:32:44 +0100 | [diff] [blame] | 4408 | private function f_tc_cipher_complete_without_alg(charstring id, BSC_ConnHdlrPars pars, octetstring kc_support) runs on BSC_ConnHdlr { |
| 4409 | pars.net.expect_auth := true; |
| 4410 | pars.net.expect_ciph := true; |
| 4411 | pars.net.kc_support := kc_support; |
| 4412 | f_init_handler(pars); |
| 4413 | |
| 4414 | g_pars.vec := f_gen_auth_vec_2g(); |
| 4415 | |
| 4416 | /* Can't use f_perform_lu() directly. Code below is based on it. */ |
| 4417 | |
| 4418 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 4419 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4420 | |
| 4421 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 4422 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 4423 | f_cl3_or_initial_ue(l3_lu); |
| 4424 | |
| 4425 | f_mm_auth(); |
| 4426 | |
| 4427 | var OCT1 a5_net := f_alg_mask_from_cm(g_pars.cm2); |
| 4428 | var OCT1 a5_intersect := g_pars.net.kc_support and4b a5_net; |
| 4429 | alt { |
| 4430 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(a5_intersect, g_pars.vec.kc)) { |
| 4431 | BSSAP.send(ts_BSSMAP_CipherModeComplAlg(omit)); |
| 4432 | } |
| 4433 | [] BSSAP.receive(tr_BSSMAP_ClassmarkReq) { |
| 4434 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 4435 | repeat; |
| 4436 | } |
| 4437 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?, g_pars.vec.kc)) { |
| 4438 | setverdict(fail, "Wrong ciphering algorithm mask in CiphModCmd"); |
| 4439 | mtc.stop; |
| 4440 | } |
| 4441 | [] BSSAP.receive { |
| 4442 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 4443 | mtc.stop; |
| 4444 | } |
| 4445 | } |
Harald Welte | 79f1e45 | 2020-08-18 22:55:02 +0200 | [diff] [blame] | 4446 | f_expect_common_id(); |
Stefan Sperling | a2d59c6 | 2018-12-18 16:32:44 +0100 | [diff] [blame] | 4447 | |
| 4448 | /* TODO: Verify MSC is using the best cipher available! How? */ |
| 4449 | |
| 4450 | f_msc_lu_hlr(); |
| 4451 | f_accept_reject_lu(); |
| 4452 | f_expect_clear(); |
| 4453 | setverdict(pass); |
| 4454 | } |
| 4455 | |
| 4456 | /* A5/1 only permitted on network side; attempt CIPHER MODE COMPLETE without specifying the accepted algorithm. */ |
| 4457 | private function f_tc_cipher_complete_1_without_cipher(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4458 | f_tc_cipher_complete_without_alg(id, pars, '02'O /* A5/1 only */); |
| 4459 | } |
| 4460 | |
| 4461 | /* A5/3 only permitted on network side; attempt CIPHER MODE COMPLETE without specifying the accepted algorithm. */ |
| 4462 | private function f_tc_cipher_complete_3_without_cipher(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4463 | f_tc_cipher_complete_without_alg(id, pars, '08'O /* A5/3 only */); |
| 4464 | } |
| 4465 | |
| 4466 | /* A5/1 + A5/3 permitted on network side; attempt CIPHER MODE COMPLETE without specifying the accepted algorithm. */ |
| 4467 | private function f_tc_cipher_complete_13_without_cipher(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4468 | f_tc_cipher_complete_without_alg(id, pars, '0A'O /* A5/1 and A5/3 enabled */); |
| 4469 | } |
| 4470 | |
| 4471 | testcase TC_cipher_complete_1_without_cipher() runs on MTC_CT { |
| 4472 | var BSC_ConnHdlr vc_conn; |
| 4473 | f_init(); |
| 4474 | f_vty_config(MSCVTY, "network", "encryption a5 1"); |
| 4475 | |
| 4476 | vc_conn := f_start_handler(refers(f_tc_cipher_complete_1_without_cipher), 53); |
| 4477 | vc_conn.done; |
| 4478 | } |
| 4479 | |
| 4480 | testcase TC_cipher_complete_3_without_cipher() runs on MTC_CT { |
| 4481 | var BSC_ConnHdlr vc_conn; |
| 4482 | f_init(); |
| 4483 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 4484 | |
| 4485 | vc_conn := f_start_handler(refers(f_tc_cipher_complete_3_without_cipher), 54); |
| 4486 | vc_conn.done; |
| 4487 | } |
| 4488 | |
| 4489 | testcase TC_cipher_complete_13_without_cipher() runs on MTC_CT { |
| 4490 | var BSC_ConnHdlr vc_conn; |
| 4491 | f_init(); |
| 4492 | f_vty_config(MSCVTY, "network", "encryption a5 1 3"); |
| 4493 | |
| 4494 | vc_conn := f_start_handler(refers(f_tc_cipher_complete_13_without_cipher), 55); |
| 4495 | vc_conn.done; |
| 4496 | } |
Harald Welte | b2284bd | 2019-05-10 11:30:43 +0200 | [diff] [blame] | 4497 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 4498 | /* TODO (SMS): |
| 4499 | * different user data lengths |
| 4500 | * SMPP transaction mode with unsuccessful delivery |
| 4501 | * queued MT-SMS with no paging response + later delivery |
| 4502 | * different data coding schemes |
| 4503 | * multi-part SMS |
| 4504 | * user-data headers |
| 4505 | * TP-PID for SMS to SIM |
| 4506 | * behavior if SMS memory is full + RP-SMMA |
| 4507 | * delivery reports |
| 4508 | * SMPP osmocom extensions |
| 4509 | * more-messages-to-send |
| 4510 | * SMS during ongoing call (SACCH/SAPI3) |
| 4511 | */ |
| 4512 | |
| 4513 | /* TODO (General): |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 4514 | * continue to send repeated MO signalling messages to keep channel open: does MSC tmeout? |
| 4515 | * malformed messages (missing IE, invalid message type): properly rejected? |
| 4516 | * MT call while LU or is ongoing: Do we use existing lchan or page while lchan active? |
| 4517 | * 3G/2G auth permutations |
| 4518 | * encryption algorithms vs. classmark vs. vty config |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 4519 | * send new transaction after/during clear (like SMS, ...) |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 4520 | * too long L3 INFO in DTAP |
| 4521 | * too long / padded BSSAP |
| 4522 | * too long / short TLV values |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 4523 | */ |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 4524 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 4525 | /*********************************************************************** |
| 4526 | * SGsAP Testing |
| 4527 | ***********************************************************************/ |
| 4528 | |
Philipp Maier | 948747b | 2019-04-02 15:22:33 +0200 | [diff] [blame] | 4529 | /* Check if a subscriber exists in the VLR */ |
| 4530 | private function f_ctrl_subscr_in_vlr(charstring imsi_or_msisdn) runs on BSC_ConnHdlr return boolean { |
| 4531 | |
| 4532 | var CtrlValue active_subsribers; |
| 4533 | var integer rc; |
| 4534 | active_subsribers := f_ctrl_get(IPA_CTRL, "subscriber-list-active-v1"); |
| 4535 | |
| 4536 | rc := f_strstr(active_subsribers, imsi_or_msisdn); |
| 4537 | if (rc < 0) { |
| 4538 | return false; |
| 4539 | } |
| 4540 | |
| 4541 | return true; |
| 4542 | } |
| 4543 | |
Pau Espin Pedrol | cefe9da | 2021-07-02 18:38:27 +0200 | [diff] [blame] | 4544 | /* 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] | 4545 | * that everything is back to normal. */ |
| 4546 | private function f_sgsap_bssmap_screening() runs on BSC_ConnHdlr { |
| 4547 | var SmsParameters spars := valueof(t_SmsPars); |
| 4548 | |
Pau Espin Pedrol | 7593a8a | 2021-07-02 18:55:16 +0200 | [diff] [blame] | 4549 | /* From now on, since we initiated LU from A-Interface, we expect no |
| 4550 | * LastEutranPLMNId on Common Id, since the SGs interface should be gone |
| 4551 | */ |
| 4552 | g_pars.common_id_last_eutran_plmn := omit; |
| 4553 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4554 | /* Perform a location update, the SGs association is expected to fall |
| 4555 | * back to NULL */ |
| 4556 | f_perform_lu(); |
| 4557 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4558 | |
| 4559 | /* Trigger a paging request and expect the paging on BSSMAP, this is |
| 4560 | * to make sure that pagings are sent throught the A-Interface again |
| 4561 | * and not throught the SGs interface.*/ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 4562 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4563 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 4564 | |
| 4565 | alt { |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 4566 | [g_pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)); { |
| 4567 | setverdict(pass); |
| 4568 | } |
Harald Welte | 62113fc | 2019-05-09 13:04:02 +0200 | [diff] [blame] | 4569 | [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] | 4570 | setverdict(pass); |
| 4571 | } |
| 4572 | [] SGsAP.receive { |
| 4573 | setverdict(fail, "Received unexpected message on SGs"); |
| 4574 | } |
| 4575 | } |
| 4576 | |
| 4577 | /* Send an SMS to make sure that also payload messages are routed |
| 4578 | * throught the A-Interface again */ |
| 4579 | f_establish_fully(EST_TYPE_MO_SMS); |
| 4580 | f_mo_sms(spars); |
| 4581 | f_expect_clear(); |
| 4582 | } |
| 4583 | |
| 4584 | private function f_tc_sgsap_reset(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4585 | var charstring vlr_name; |
| 4586 | f_init_handler(pars); |
| 4587 | |
| 4588 | vlr_name := f_sgsap_reset_mme(mp_mme_name); |
| 4589 | log("VLR name: ", vlr_name); |
| 4590 | setverdict(pass); |
Neels Hofmeyr | c0b520d | 2019-03-06 15:35:50 +0100 | [diff] [blame] | 4591 | f_sleep(1.0); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4592 | } |
| 4593 | |
| 4594 | testcase TC_sgsap_reset() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4595 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4596 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4597 | f_init(1, true); |
| 4598 | pars := f_init_pars(11810, true); |
| 4599 | 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] | 4600 | vc_conn.done; |
| 4601 | } |
| 4602 | |
| 4603 | /* like f_mm_auth() but for SGs */ |
| 4604 | function f_mm_auth_sgs() runs on BSC_ConnHdlr { |
| 4605 | if (g_pars.net.expect_auth) { |
| 4606 | g_pars.vec := f_gen_auth_vec_3g(); |
| 4607 | var GSUP_IE auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G3G(g_pars.vec.rand, |
| 4608 | g_pars.vec.sres, |
| 4609 | g_pars.vec.kc, |
| 4610 | g_pars.vec.ik, |
| 4611 | g_pars.vec.ck, |
| 4612 | g_pars.vec.autn, |
| 4613 | g_pars.vec.res)); |
| 4614 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 4615 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
| 4616 | SGsAP.receive(tr_ML3_MT_MM_AUTH_REQ_3G(g_pars.vec.rand, g_pars.vec.autn)); |
| 4617 | SGsAP.send(ts_ML3_MT_MM_AUTH_RESP_3G(g_pars.vec.sres, g_pars.vec.res)); |
| 4618 | } |
| 4619 | } |
| 4620 | |
| 4621 | /* like f_perform_lu(), but on SGs rather than BSSAP */ |
| 4622 | function f_sgs_perform_lu() runs on BSC_ConnHdlr { |
| 4623 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4624 | var PDU_SGsAP lur; |
| 4625 | var PDU_SGsAP lua; |
| 4626 | var PDU_SGsAP mm_info; |
| 4627 | var octetstring mm_info_dtap; |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4628 | var GsmMcc mcc; |
| 4629 | var GsmMnc mnc; |
| 4630 | var template (omit) TrackingAreaIdentityValue tai := omit; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4631 | |
| 4632 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 4633 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4634 | if (g_pars.common_id_last_eutran_plmn != omit) { |
| 4635 | f_dec_mcc_mnc(g_pars.common_id_last_eutran_plmn, mcc, mnc); |
| 4636 | tai := ts_SGsAP_TAI(mcc, mnc, 555); |
| 4637 | } |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4638 | 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] | 4639 | ts_SGsAP_LAI('901'H, '70'H, 2342), |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4640 | tai)); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4641 | /* Old LAI, if MS sends it */ |
| 4642 | /* TMSI status, if MS has no valid TMSI */ |
| 4643 | /* IMEISV, if it supports "automatic device detection" */ |
| 4644 | /* TAI, if available in MME */ |
| 4645 | /* E-CGI, if available in MME */ |
| 4646 | SGsAP.send(lur); |
| 4647 | |
| 4648 | /* FIXME: is this really done over SGs? The Ue is already authenticated |
| 4649 | * via the MME ... */ |
| 4650 | f_mm_auth_sgs(); |
| 4651 | |
| 4652 | /* Expect MSC to perform LU with HLR */ |
| 4653 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 4654 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 4655 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 4656 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 4657 | |
| 4658 | alt { |
| 4659 | [] SGsAP.receive(tr_SGsAP_LU_ACCEPT(g_pars.imsi, ?)) -> value lua { |
| 4660 | if (isvalue(lua.sGsAP_LOCATION_UPDATE_ACCEPT.newTMSIorIMSI.iD.iD.tmsi_ptmsi.octets)) { |
| 4661 | g_pars.tmsi :=lua.sGsAP_LOCATION_UPDATE_ACCEPT.newTMSIorIMSI.iD.iD.tmsi_ptmsi.octets |
| 4662 | SGsAP.send(ts_SGsAP_TMSI_REALL_CMPL(g_pars.imsi)); |
| 4663 | } |
| 4664 | setverdict(pass); |
| 4665 | } |
| 4666 | [] SGsAP.receive(tr_SGsAP_LU_REJECT(g_pars.imsi, ?, ?)) { |
| 4667 | setverdict(fail, "Received LU-REJECT instead of ACCEPT"); |
| 4668 | } |
| 4669 | [] SGsAP.receive { |
| 4670 | setverdict(fail, "Received unexpected message on SGs"); |
| 4671 | } |
| 4672 | } |
| 4673 | |
| 4674 | /* Check MM information */ |
| 4675 | if (mp_mm_info == true) { |
| 4676 | SGsAP.receive(tr_SGsAP_MM_INFO_REQ(g_pars.imsi, ?)) -> value mm_info; |
| 4677 | mm_info_dtap := '0532'O & mm_info.sGsAP_MM_INFORMATION_REQUEST.mM_Information.information; |
| 4678 | if (not match(dec_PDU_ML3_NW_MS(mm_info_dtap), tr_ML3_MT_MM_Info)) { |
| 4679 | setverdict(fail, "Unexpected MM Information"); |
| 4680 | } |
| 4681 | } |
| 4682 | |
| 4683 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4684 | } |
| 4685 | |
| 4686 | private function f_tc_sgsap_lu(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4687 | f_init_handler(pars); |
| 4688 | f_sgs_perform_lu(); |
| 4689 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4690 | |
| 4691 | f_sgsap_bssmap_screening(); |
| 4692 | |
| 4693 | setverdict(pass); |
| 4694 | } |
| 4695 | testcase TC_sgsap_lu() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4696 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4697 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4698 | f_init(1, true); |
| 4699 | pars := f_init_pars(11811, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4700 | 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] | 4701 | 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] | 4702 | vc_conn.done; |
| 4703 | } |
| 4704 | |
| 4705 | /* Do LU by IMSI, refuse it on GSUP and expect LU REJ back to MS */ |
| 4706 | private function f_tc_sgsap_lu_imsi_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4707 | f_init_handler(pars); |
| 4708 | var PDU_SGsAP lur; |
| 4709 | |
| 4710 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4711 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4712 | lur := valueof(ts_SGsAP_LU_REQ(g_pars.imsi, mme_name, IMSI_attach, |
| 4713 | ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4714 | SGsAP.send(lur); |
| 4715 | |
| 4716 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 4717 | GSUP.send(ts_GSUP_UL_ERR(g_pars.imsi, 23)); |
| 4718 | alt { |
| 4719 | [] SGsAP.receive(tr_SGsAP_LU_REJECT(g_pars.imsi, ?, ?)) { |
| 4720 | setverdict(pass); |
| 4721 | } |
| 4722 | [] SGsAP.receive(tr_SGsAP_LU_ACCEPT(g_pars.imsi, ?)) { |
| 4723 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
| 4724 | mtc.stop; |
| 4725 | } |
| 4726 | [] SGsAP.receive { |
| 4727 | setverdict(fail, "Received unexpected message on SGs"); |
| 4728 | } |
| 4729 | } |
| 4730 | |
| 4731 | f_sgsap_bssmap_screening(); |
| 4732 | |
| 4733 | setverdict(pass); |
| 4734 | } |
| 4735 | testcase TC_sgsap_lu_imsi_reject() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4736 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4737 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4738 | f_init(1, true); |
| 4739 | pars := f_init_pars(11812, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4740 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4741 | 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] | 4742 | vc_conn.done; |
| 4743 | } |
| 4744 | |
| 4745 | /* Do LU by IMSI, but then remain silent so that Ts6-1 times out */ |
| 4746 | private function f_tc_sgsap_lu_and_nothing(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4747 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4748 | var PDU_SGsAP lur; |
| 4749 | |
| 4750 | f_init_handler(pars); |
| 4751 | |
| 4752 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 4753 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4754 | |
| 4755 | lur := valueof(ts_SGsAP_LU_REQ(g_pars.imsi, mme_name, IMSI_attach, |
| 4756 | ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4757 | /* Old LAI, if MS sends it */ |
| 4758 | /* TMSI status, if MS has no valid TMSI */ |
| 4759 | /* IMEISV, if it supports "automatic device detection" */ |
| 4760 | /* TAI, if available in MME */ |
| 4761 | /* E-CGI, if available in MME */ |
| 4762 | SGsAP.send(lur); |
| 4763 | |
| 4764 | /* FIXME: is this really done over SGs? The Ue is already authenticated |
| 4765 | * via the MME ... */ |
| 4766 | f_mm_auth_sgs(); |
| 4767 | |
| 4768 | /* Expect MSC to perform LU with HLR */ |
| 4769 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 4770 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 4771 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 4772 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 4773 | |
| 4774 | alt { |
| 4775 | [] SGsAP.receive(tr_SGsAP_LU_ACCEPT(g_pars.imsi, ?)) { |
| 4776 | setverdict(pass); |
| 4777 | } |
| 4778 | [] SGsAP.receive(tr_SGsAP_LU_REJECT(g_pars.imsi, ?, ?)) { |
| 4779 | setverdict(fail, "Received LU-REJECT instead of ACCEPT"); |
| 4780 | } |
| 4781 | [] SGsAP.receive { |
| 4782 | setverdict(fail, "Received unexpected message on SGs"); |
| 4783 | } |
| 4784 | } |
| 4785 | |
| 4786 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4787 | |
| 4788 | /* Wait until the VLR has abort the TMSI reallocation procedure */ |
| 4789 | f_sleep(45.0); |
| 4790 | |
| 4791 | /* The outcome does not change the SGs state, see also 5.2.3.4 */ |
| 4792 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4793 | |
| 4794 | f_sgsap_bssmap_screening(); |
| 4795 | |
| 4796 | setverdict(pass); |
| 4797 | } |
| 4798 | testcase TC_sgsap_lu_and_nothing() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4799 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4800 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4801 | f_init(1, true); |
| 4802 | pars := f_init_pars(11813, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4803 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4804 | 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] | 4805 | vc_conn.done; |
| 4806 | } |
| 4807 | |
| 4808 | private function f_tc_sgsap_expl_imsi_det_eps(charstring id, BSC_ConnHdlrPars pars) |
| 4809 | runs on BSC_ConnHdlr { |
| 4810 | f_init_handler(pars); |
| 4811 | f_sgs_perform_lu(); |
| 4812 | f_sleep(3.0); |
| 4813 | |
| 4814 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4815 | SGsAP.send(ts_SGsAP_EPS_DETACH_IND(g_pars.imsi, mme_name, UE_initiated)); |
| 4816 | SGsAP.receive(tr_SGsAP_EPS_DETACH_ACK(g_pars.imsi)); |
| 4817 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4818 | |
| 4819 | f_sgsap_bssmap_screening(); |
| 4820 | |
| 4821 | setverdict(pass); |
| 4822 | } |
| 4823 | testcase TC_sgsap_expl_imsi_det_eps() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4824 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4825 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4826 | f_init(1, true); |
| 4827 | pars := f_init_pars(11814, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4828 | 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] | 4829 | 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] | 4830 | vc_conn.done; |
| 4831 | } |
| 4832 | |
Philipp Maier | fc19f17 | 2019-03-21 11:17:54 +0100 | [diff] [blame] | 4833 | private function f_tc_sgsap_impl_imsi_det_eps(charstring id, BSC_ConnHdlrPars pars) |
| 4834 | runs on BSC_ConnHdlr { |
| 4835 | f_init_handler(pars); |
| 4836 | f_sgs_perform_lu(); |
| 4837 | f_sleep(3.0); |
| 4838 | |
| 4839 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4840 | SGsAP.send(ts_SGsAP_EPS_DETACH_IND(g_pars.imsi, mme_name, network_initiated)); |
| 4841 | SGsAP.receive(tr_SGsAP_EPS_DETACH_ACK(g_pars.imsi)); |
| 4842 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4843 | |
| 4844 | f_sgsap_bssmap_screening(); |
| 4845 | |
| 4846 | setverdict(pass); |
| 4847 | } |
| 4848 | testcase TC_sgsap_impl_imsi_det_eps() runs on MTC_CT { |
| 4849 | var BSC_ConnHdlrPars pars; |
| 4850 | var BSC_ConnHdlr vc_conn; |
| 4851 | f_init(1, true); |
| 4852 | pars := f_init_pars(11814, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4853 | 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] | 4854 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_impl_imsi_det_eps), pars); |
| 4855 | vc_conn.done; |
| 4856 | } |
| 4857 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4858 | private function f_tc_sgsap_expl_imsi_det_noneps(charstring id, BSC_ConnHdlrPars pars) |
| 4859 | runs on BSC_ConnHdlr { |
| 4860 | f_init_handler(pars); |
| 4861 | f_sgs_perform_lu(); |
| 4862 | f_sleep(3.0); |
| 4863 | |
| 4864 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4865 | SGsAP.send(ts_SGsAP_IMSI_DETACH_IND(g_pars.imsi, mme_name, combined_UE_initiated)); |
| 4866 | SGsAP.receive(tr_SGsAP_IMSI_DETACH_ACK(g_pars.imsi)); |
Philipp Maier | d08e7e7 | 2019-04-02 15:27:10 +0200 | [diff] [blame] | 4867 | |
| 4868 | if (f_ctrl_subscr_in_vlr(hex2str(g_pars.imsi))) { |
| 4869 | setverdict(fail, "subscriber not removed from VLR"); |
| 4870 | } |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4871 | |
| 4872 | f_sgsap_bssmap_screening(); |
| 4873 | |
| 4874 | setverdict(pass); |
| 4875 | } |
| 4876 | testcase TC_sgsap_expl_imsi_det_noneps() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4877 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4878 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4879 | f_init(1, true); |
| 4880 | pars := f_init_pars(11815, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4881 | 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] | 4882 | 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] | 4883 | vc_conn.done; |
| 4884 | } |
| 4885 | |
Philipp Maier | 5d81270 | 2019-03-21 10:51:26 +0100 | [diff] [blame] | 4886 | private function f_tc_sgsap_impl_imsi_det_noneps(charstring id, BSC_ConnHdlrPars pars) |
| 4887 | runs on BSC_ConnHdlr { |
| 4888 | f_init_handler(pars); |
| 4889 | f_sgs_perform_lu(); |
| 4890 | f_sleep(3.0); |
| 4891 | |
| 4892 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4893 | SGsAP.send(ts_SGsAP_IMSI_DETACH_IND(g_pars.imsi, mme_name, implicit_network_initiated)); |
| 4894 | SGsAP.receive(tr_SGsAP_IMSI_DETACH_ACK(g_pars.imsi)); |
| 4895 | |
| 4896 | if (f_ctrl_subscr_in_vlr(hex2str(g_pars.imsi))) { |
| 4897 | setverdict(fail, "subscriber not removed from VLR"); |
| 4898 | } |
| 4899 | |
| 4900 | f_sgsap_bssmap_screening(); |
| 4901 | |
| 4902 | setverdict(pass); |
| 4903 | } |
| 4904 | testcase TC_sgsap_impl_imsi_det_noneps() runs on MTC_CT { |
| 4905 | var BSC_ConnHdlrPars pars; |
| 4906 | var BSC_ConnHdlr vc_conn; |
| 4907 | f_init(1, true); |
| 4908 | pars := f_init_pars(11815, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4909 | 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] | 4910 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_impl_imsi_det_noneps), pars); |
| 4911 | vc_conn.done; |
| 4912 | } |
| 4913 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4914 | /* Trigger a paging request via VTY and send a paging reject in response */ |
| 4915 | private function f_tc_sgsap_paging_rej(charstring id, BSC_ConnHdlrPars pars) |
| 4916 | runs on BSC_ConnHdlr { |
| 4917 | f_init_handler(pars); |
| 4918 | f_sgs_perform_lu(); |
| 4919 | f_sleep(1.0); |
| 4920 | |
| 4921 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4922 | var template PDU_SGsAP exp_resp := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, CS_call_indicator, omit); |
| 4923 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4924 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 4925 | |
| 4926 | /* Initiate paging via VTY */ |
| 4927 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 4928 | alt { |
| 4929 | [] SGsAP.receive(exp_resp) { |
| 4930 | setverdict(pass); |
| 4931 | } |
| 4932 | [] SGsAP.receive { |
| 4933 | setverdict(fail, "Received unexpected message on SGs"); |
| 4934 | } |
| 4935 | } |
| 4936 | |
| 4937 | /* Now reject the paging */ |
| 4938 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, IMSI_unknown)); |
| 4939 | |
| 4940 | /* Wait for the states inside the MSC to settle and check the state |
| 4941 | * of the SGs Association */ |
| 4942 | f_sleep(1.0); |
| 4943 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4944 | |
| 4945 | /* FIXME: At the moment we send an IMSI_unknown as cause code, which is fine, |
| 4946 | * but we also need to cover tha case where the cause code indicates an |
| 4947 | * "IMSI detached for EPS services". In those cases the VLR is expected to |
| 4948 | * try paging on tha A/Iu interface. This will be another testcase similar to |
| 4949 | * this one, but extended with checks for the presence of the A/Iu paging |
| 4950 | * messages. */ |
| 4951 | |
| 4952 | f_sgsap_bssmap_screening(); |
| 4953 | |
| 4954 | setverdict(pass); |
| 4955 | } |
| 4956 | testcase TC_sgsap_paging_rej() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4957 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4958 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4959 | f_init(1, true); |
| 4960 | pars := f_init_pars(11816, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4961 | 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] | 4962 | 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] | 4963 | vc_conn.done; |
| 4964 | } |
| 4965 | |
| 4966 | /* Trigger a paging request via VTY and send a paging reject that indicates |
| 4967 | * that the subscriber intentionally rejected the call. */ |
| 4968 | private function f_tc_sgsap_paging_subscr_rej(charstring id, BSC_ConnHdlrPars pars) |
| 4969 | runs on BSC_ConnHdlr { |
| 4970 | f_init_handler(pars); |
| 4971 | f_sgs_perform_lu(); |
| 4972 | f_sleep(1.0); |
| 4973 | |
| 4974 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4975 | var template PDU_SGsAP exp_resp := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, CS_call_indicator, omit); |
| 4976 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4977 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 4978 | |
| 4979 | /* Initiate paging via VTY */ |
| 4980 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 4981 | alt { |
| 4982 | [] SGsAP.receive(exp_resp) { |
| 4983 | setverdict(pass); |
| 4984 | } |
| 4985 | [] SGsAP.receive { |
| 4986 | setverdict(fail, "Received unexpected message on SGs"); |
| 4987 | } |
| 4988 | } |
| 4989 | |
| 4990 | /* Now reject the paging */ |
| 4991 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, user_rejected_mobile_terminating_CS_fallback_call)); |
| 4992 | |
| 4993 | /* Wait for the states inside the MSC to settle and check the state |
| 4994 | * of the SGs Association */ |
| 4995 | f_sleep(1.0); |
| 4996 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4997 | |
| 4998 | /* FIXME: The VLR is supposed to trigger an User Determined User Busy (UDUB) as specified |
| 4999 | * in 3GPP TS 24.082, this is not yet implemented in the MSC or in this tests, we need |
| 5000 | * to check back how this works and how it can be tested */ |
| 5001 | |
| 5002 | f_sgsap_bssmap_screening(); |
| 5003 | |
| 5004 | setverdict(pass); |
| 5005 | } |
| 5006 | testcase TC_sgsap_paging_subscr_rej() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5007 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5008 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5009 | f_init(1, true); |
| 5010 | pars := f_init_pars(11817, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5011 | 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] | 5012 | 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] | 5013 | vc_conn.done; |
| 5014 | } |
| 5015 | |
| 5016 | /* Trigger a paging request via VTY and send an UE unreacable messge in response */ |
| 5017 | private function f_tc_sgsap_paging_ue_unr(charstring id, BSC_ConnHdlrPars pars) |
| 5018 | runs on BSC_ConnHdlr { |
| 5019 | f_init_handler(pars); |
| 5020 | f_sgs_perform_lu(); |
| 5021 | f_sleep(1.0); |
| 5022 | |
| 5023 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5024 | var template PDU_SGsAP exp_resp := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, CS_call_indicator, omit); |
| 5025 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5026 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 5027 | |
| 5028 | /* Initiate paging via VTY */ |
| 5029 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 5030 | alt { |
| 5031 | [] SGsAP.receive(exp_resp) { |
| 5032 | setverdict(pass); |
| 5033 | } |
| 5034 | [] SGsAP.receive { |
| 5035 | setverdict(fail, "Received unexpected message on SGs"); |
| 5036 | } |
| 5037 | } |
| 5038 | |
| 5039 | /* Now pretend that the UE is unreachable */ |
| 5040 | SGsAP.send(ts_SGsAP_UE_UNREACHABLE(g_pars.imsi, UE_unreachable)); |
| 5041 | |
| 5042 | /* Wait for the states inside the MSC to settle and check the state |
| 5043 | * of the SGs Association. */ |
| 5044 | f_sleep(1.0); |
| 5045 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5046 | |
| 5047 | f_sgsap_bssmap_screening(); |
| 5048 | |
| 5049 | setverdict(pass); |
| 5050 | } |
| 5051 | testcase TC_sgsap_paging_ue_unr() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5052 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5053 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5054 | f_init(1, true); |
| 5055 | pars := f_init_pars(11818, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5056 | 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] | 5057 | 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] | 5058 | vc_conn.done; |
| 5059 | } |
| 5060 | |
| 5061 | /* Trigger a paging request via VTY but don't respond to it */ |
| 5062 | private function f_tc_sgsap_paging_and_nothing(charstring id, BSC_ConnHdlrPars pars) |
| 5063 | runs on BSC_ConnHdlr { |
| 5064 | f_init_handler(pars); |
| 5065 | f_sgs_perform_lu(); |
| 5066 | f_sleep(1.0); |
| 5067 | |
| 5068 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5069 | 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] | 5070 | 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] | 5071 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5072 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 5073 | |
| 5074 | /* Initiate paging via VTY */ |
| 5075 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 5076 | alt { |
| 5077 | [] SGsAP.receive(exp_resp) { |
| 5078 | setverdict(pass); |
| 5079 | } |
| 5080 | [] SGsAP.receive { |
| 5081 | setverdict(fail, "Received unexpected message on SGs"); |
| 5082 | } |
| 5083 | } |
| 5084 | |
Philipp Maier | 3421810 | 2019-09-24 09:15:49 +0200 | [diff] [blame] | 5085 | /* While we are doing nothing, expect an SGsAP-SERVICE-ABORT-REQUEST |
| 5086 | * after some time */ |
| 5087 | timer T := 10.0; |
| 5088 | T.start |
| 5089 | alt { |
| 5090 | [] SGsAP.receive(exp_serv_abrt) |
| 5091 | { |
| 5092 | setverdict(pass); |
| 5093 | } |
| 5094 | [] SGsAP.receive { |
| 5095 | setverdict(fail, "unexpected SGsAP message received"); |
| 5096 | self.stop; |
| 5097 | } |
| 5098 | [] T.timeout { |
| 5099 | setverdict(fail, "MSC did not send SGsAP-SERVICE-ABORT-REQUEST"); |
| 5100 | self.stop; |
| 5101 | } |
| 5102 | } |
| 5103 | |
| 5104 | /* The SGs association must remain unchanged. */ |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5105 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5106 | |
| 5107 | f_sgsap_bssmap_screening(); |
| 5108 | |
| 5109 | setverdict(pass); |
| 5110 | } |
| 5111 | testcase TC_sgsap_paging_and_nothing() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5112 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5113 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5114 | f_init(1, true); |
| 5115 | pars := f_init_pars(11819, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5116 | 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] | 5117 | 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] | 5118 | vc_conn.done; |
| 5119 | } |
| 5120 | |
| 5121 | /* Trigger a paging request via VTY and slip in an LU */ |
| 5122 | private function f_tc_sgsap_paging_and_lu(charstring id, BSC_ConnHdlrPars pars) |
| 5123 | runs on BSC_ConnHdlr { |
| 5124 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5125 | f_init_handler(pars); |
| 5126 | |
| 5127 | /* First we prepar the situation, where the SGs association is in state |
| 5128 | * NULL and the confirmed by radio contact indicator is set to false |
| 5129 | * as well. This can be archived by performing an SGs LU and then |
| 5130 | * resetting the VLR */ |
| 5131 | f_sgs_perform_lu(); |
| 5132 | f_sgsap_reset_mme(mp_mme_name); |
| 5133 | f_sleep(1.0); |
| 5134 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 5135 | |
| 5136 | /* Perform a paging, expect the paging messages on the SGs interface */ |
| 5137 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 5138 | alt { |
| 5139 | [] SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)) { |
| 5140 | setverdict(pass); |
| 5141 | } |
| 5142 | [] SGsAP.receive { |
| 5143 | setverdict(fail, "Received unexpected message on SGs"); |
| 5144 | } |
| 5145 | } |
| 5146 | |
| 5147 | /* Perform the LU as normal */ |
| 5148 | f_sgs_perform_lu(); |
| 5149 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5150 | |
| 5151 | /* Expect a new paging request right after the LU */ |
| 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 | /* Test is done now, lets round everything up by rejecting the paging |
| 5162 | * cleanly. */ |
| 5163 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, user_rejected_mobile_terminating_CS_fallback_call)); |
| 5164 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5165 | |
| 5166 | f_sgsap_bssmap_screening(); |
| 5167 | |
| 5168 | setverdict(pass); |
| 5169 | } |
| 5170 | testcase TC_sgsap_paging_and_lu() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5171 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5172 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5173 | f_init(1, true); |
| 5174 | pars := f_init_pars(11820, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5175 | 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] | 5176 | 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] | 5177 | vc_conn.done; |
| 5178 | } |
| 5179 | |
| 5180 | /* Send unexpected unit-data through the SGs interface */ |
| 5181 | private function f_tc_sgsap_unexp_ud(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5182 | f_init_handler(pars); |
| 5183 | f_sleep(1.0); |
| 5184 | |
| 5185 | /* This simulates what happens when a subscriber without SGs |
| 5186 | * association gets unitdata via the SGs interface. */ |
| 5187 | |
| 5188 | /* Make sure the subscriber exists and the SGs association |
| 5189 | * is in NULL state */ |
| 5190 | f_perform_lu(); |
| 5191 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 5192 | |
| 5193 | /* Send some random unit data, the MSC/VLR should send a release |
| 5194 | * immediately. */ |
| 5195 | SGsAP.send(ts_SGsAP_UL_UD(pars.imsi,'1234'O)); |
| 5196 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, IMSI_detached_for_EPS_nonEPS_services)); |
| 5197 | |
| 5198 | f_sgsap_bssmap_screening(); |
| 5199 | |
| 5200 | setverdict(pass); |
| 5201 | } |
| 5202 | testcase TC_sgsap_unexp_ud() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5203 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5204 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5205 | f_init(1, true); |
| 5206 | pars := f_init_pars(11821, true); |
| 5207 | 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] | 5208 | vc_conn.done; |
| 5209 | } |
| 5210 | |
| 5211 | /* Send unsolicited unit-data through the SGs interface */ |
| 5212 | private function f_tc_sgsap_unsol_ud(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5213 | f_init_handler(pars); |
| 5214 | f_sleep(1.0); |
| 5215 | |
| 5216 | /* This simulates what happens when the MME attempts to send unitdata |
| 5217 | * to a subscriber that is completely unknown to the VLR */ |
| 5218 | |
| 5219 | /* Send some random unit data, the MSC/VLR should send a release |
| 5220 | * immediately. */ |
| 5221 | SGsAP.send(ts_SGsAP_UL_UD(pars.imsi,'1234'O)); |
| 5222 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, IMSI_unknown)); |
| 5223 | |
| 5224 | f_sgsap_bssmap_screening(); |
| 5225 | |
Harald Welte | 4d15fa7 | 2020-08-19 08:58:28 +0200 | [diff] [blame] | 5226 | /* clean-up VLR state about this subscriber */ |
| 5227 | f_imsi_detach_by_imsi(); |
| 5228 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5229 | setverdict(pass); |
| 5230 | } |
| 5231 | testcase TC_sgsap_unsol_ud() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5232 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5233 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5234 | f_init(1, true); |
| 5235 | pars := f_init_pars(11822, true); |
| 5236 | 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] | 5237 | vc_conn.done; |
| 5238 | } |
| 5239 | |
| 5240 | private altstep as_other_sms_sgs() runs on BSC_ConnHdlr { |
| 5241 | /* FIXME: Match an actual payload (second questionmark), the type is |
| 5242 | * octetstring, how do we use a tr_PDU_DTAP_MT here? */ |
| 5243 | [] SGsAP.receive(tr_SGsAP_DL_UD(?,?)) { |
| 5244 | setverdict(fail, "Unexpected SMS related PDU from MSC"); |
| 5245 | mtc.stop; |
| 5246 | } |
| 5247 | } |
| 5248 | |
| 5249 | /* receive a MT-SMS delivered from the MSC/SMSC over an already existing SGsAP connection */ |
| 5250 | function f_mt_sms_sgs(inout SmsParameters spars) |
| 5251 | runs on BSC_ConnHdlr { |
| 5252 | var template (value) TPDU_RP_DATA_MS_SGSN tp_mo; |
| 5253 | var template (value) RPDU_MS_SGSN rp_mo; |
| 5254 | var template (value) PDU_ML3_MS_NW l3_mo; |
| 5255 | |
| 5256 | var template TPDU_RP_DATA_SGSN_MS tp_mt; |
| 5257 | var template RPDU_SGSN_MS rp_mt; |
| 5258 | var template PDU_ML3_NW_MS l3_mt; |
| 5259 | |
| 5260 | var PDU_ML3_NW_MS sgsap_l3_mt; |
| 5261 | |
| 5262 | var default d := activate(as_other_sms_sgs()); |
| 5263 | |
| 5264 | /* Expect CP-DATA(RP-DATA(SMS-DELIVER)) */ |
| 5265 | 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] | 5266 | 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] | 5267 | l3_mt := tr_ML3_MT_SMS(?, c_TIF_ORIG, tr_CP_DATA_MT(rp_mt)); |
| 5268 | |
| 5269 | SGsAP.receive(l3_mt) -> value sgsap_l3_mt; |
| 5270 | |
| 5271 | /* Extract relevant identifiers */ |
| 5272 | spars.tid := bit2int(sgsap_l3_mt.tiOrSkip.transactionId.tio); |
| 5273 | spars.rp.msg_ref := sgsap_l3_mt.msgs.sms.cP_DATA.cP_User_Data.cP_RPDU.rP_DATA_SGSN_MS.rP_MessageReference; |
| 5274 | |
| 5275 | /* send CP-ACK for CP-DATA just received */ |
| 5276 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_REPL, ts_CP_ACK_MO); |
| 5277 | |
| 5278 | SGsAP.send(l3_mo); |
| 5279 | |
| 5280 | /* send RP-ACK for RP-DATA */ |
| 5281 | rp_mo := ts_RP_ACK_MO(spars.rp.msg_ref); |
| 5282 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_REPL, ts_CP_DATA_MO(rp_mo)); |
| 5283 | |
| 5284 | SGsAP.send(l3_mo); |
| 5285 | |
| 5286 | /* expect CP-ACK for CP-DATA(RP-ACK) just sent */ |
| 5287 | l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_ORIG, tr_CP_ACK_MT); |
| 5288 | |
| 5289 | SGsAP.receive(l3_mt); |
| 5290 | |
| 5291 | deactivate(d); |
| 5292 | |
| 5293 | setverdict(pass); |
| 5294 | } |
| 5295 | |
| 5296 | /* submit a MO-SMS to MSC/SMSC over an already existing SGsAP connection */ |
| 5297 | function f_mo_sms_sgs(inout SmsParameters spars) |
| 5298 | runs on BSC_ConnHdlr { |
| 5299 | var template (value) TPDU_RP_DATA_MS_SGSN tp_mo; |
| 5300 | var template (value) RPDU_MS_SGSN rp_mo; |
| 5301 | var template (value) PDU_ML3_MS_NW l3_mo; |
| 5302 | |
| 5303 | var template TPDU_RP_DATA_SGSN_MS tp_mt; |
| 5304 | var template RPDU_SGSN_MS rp_mt; |
| 5305 | var template PDU_ML3_NW_MS l3_mt; |
| 5306 | |
| 5307 | var default d := activate(as_other_sms_sgs()); |
| 5308 | |
| 5309 | /* just in case this is routed to SMPP.. */ |
| 5310 | f_create_smpp_expect(hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue)); |
| 5311 | |
| 5312 | tp_mo := ts_SMS_SUBMIT(spars.tp.msg_ref, spars.tp.da, spars.tp.pid, spars.tp.dcs, |
| 5313 | spars.tp.udl, spars.tp.ud); |
Vadim Yanitskiy | 437b5a6 | 2019-12-15 14:13:39 +0900 | [diff] [blame] | 5314 | 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] | 5315 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_DATA_MO(rp_mo)); |
| 5316 | |
| 5317 | SGsAP.send(l3_mo); |
| 5318 | |
| 5319 | /* receive CP-ACK for CP-DATA above */ |
| 5320 | SGsAP.receive(tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_ACK_MT)); |
| 5321 | |
| 5322 | if (ispresent(spars.exp_rp_err)) { |
| 5323 | /* expect an RP-ERROR message from MSC with given cause */ |
| 5324 | rp_mt := tr_RP_ERROR_MT(spars.rp.msg_ref, spars.exp_rp_err); |
| 5325 | l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_DATA_MT(rp_mt)); |
| 5326 | SGsAP.receive(l3_mt); |
| 5327 | /* send CP-ACK for CP-DATA just received */ |
| 5328 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_ACK_MO); |
| 5329 | SGsAP.send(l3_mo); |
| 5330 | } else { |
| 5331 | /* expect RP-ACK for RP-DATA */ |
| 5332 | rp_mt := tr_RP_ACK_MT(spars.rp.msg_ref); |
| 5333 | l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_DATA_MT(rp_mt)); |
| 5334 | SGsAP.receive(l3_mt); |
| 5335 | /* send CP-ACO for CP-DATA just received */ |
| 5336 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_ACK_MO); |
| 5337 | SGsAP.send(l3_mo); |
| 5338 | } |
| 5339 | |
| 5340 | deactivate(d); |
| 5341 | |
| 5342 | setverdict(pass); |
| 5343 | } |
| 5344 | |
| 5345 | private function f_vty_sms_send_conn_hdlr(charstring imsi, charstring msisdn, charstring text) |
| 5346 | runs on BSC_ConnHdlr { |
| 5347 | f_vty_transceive(MSCVTY, "subscriber imsi "&imsi&" sms sender msisdn "&msisdn&" send "&text); |
| 5348 | } |
| 5349 | |
| 5350 | /* Send a MT SMS via SGs interface */ |
| 5351 | private function f_tc_sgsap_mt_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5352 | f_init_handler(pars); |
| 5353 | f_sgs_perform_lu(); |
| 5354 | f_sleep(1.0); |
| 5355 | var SmsParameters spars := valueof(t_SmsPars); |
| 5356 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 5357 | |
| 5358 | /* Trigger SMS via VTY */ |
| 5359 | f_vty_sms_send_conn_hdlr(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 5360 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5361 | |
| 5362 | /* Expect a paging request and respond accordingly with a service request */ |
| 5363 | SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, SMS_indicator, omit)); |
| 5364 | SGsAP.send(ts_SGsAP_SERVICE_REQ(pars.imsi, SMS_indicator, EMM_CONNECTED)); |
| 5365 | |
| 5366 | /* Connection is now live, receive the MT-SMS */ |
| 5367 | f_mt_sms_sgs(spars); |
| 5368 | |
| 5369 | /* Expect a concluding release from the MSC */ |
| 5370 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, omit)); |
| 5371 | |
| 5372 | /* Make sure that subscriber is still present and the SGs association is in tact (ref-counting) */ |
| 5373 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5374 | |
| 5375 | f_sgsap_bssmap_screening(); |
| 5376 | |
| 5377 | setverdict(pass); |
| 5378 | } |
| 5379 | testcase TC_sgsap_mt_sms() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5380 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5381 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5382 | f_init(1, true); |
| 5383 | pars := f_init_pars(11823, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5384 | 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] | 5385 | 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] | 5386 | vc_conn.done; |
| 5387 | } |
| 5388 | |
| 5389 | /* Send a MO SMS via SGs interface */ |
| 5390 | private function f_tc_sgsap_mo_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5391 | f_init_handler(pars); |
| 5392 | f_sgs_perform_lu(); |
| 5393 | f_sleep(1.0); |
| 5394 | var SmsParameters spars := valueof(t_SmsPars); |
| 5395 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 5396 | |
| 5397 | /* Send the MO-SMS */ |
| 5398 | f_mo_sms_sgs(spars); |
| 5399 | |
| 5400 | /* Expect a concluding release from the MSC/VLR */ |
| 5401 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, omit)); |
| 5402 | |
| 5403 | /* Make sure that subscriber is still present and the SGs association is in tact (ref-counting) */ |
| 5404 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5405 | |
| 5406 | setverdict(pass); |
| 5407 | |
| 5408 | f_sgsap_bssmap_screening() |
| 5409 | } |
| 5410 | testcase TC_sgsap_mo_sms() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5411 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5412 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5413 | f_init(1, true); |
| 5414 | pars := f_init_pars(11824, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5415 | 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] | 5416 | 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] | 5417 | vc_conn.done; |
| 5418 | } |
| 5419 | |
| 5420 | /* Trigger sending of an MT sms via VTY but never respond to anything */ |
| 5421 | private function f_tc_sgsap_mt_sms_and_nothing(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5422 | f_init_handler(pars, 170.0); |
| 5423 | f_sgs_perform_lu(); |
| 5424 | f_sleep(1.0); |
| 5425 | |
| 5426 | var SmsParameters spars := valueof(t_SmsPars); |
| 5427 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 5428 | var integer page_count := 0; |
| 5429 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5430 | var template PDU_SGsAP exp_pag_req := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, SMS_indicator, omit); |
| 5431 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5432 | exp_pag_req.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 5433 | |
| 5434 | /* Trigger SMS via VTY */ |
| 5435 | f_vty_sms_send_conn_hdlr(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 5436 | |
Neels Hofmeyr | 1623774 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 5437 | /* Expect the MSC/VLR to page exactly once */ |
| 5438 | SGsAP.receive(exp_pag_req); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5439 | |
| 5440 | /* Wait some time to make sure the MSC is not delivering any further |
| 5441 | * paging messages or anything else that could be unexpected. */ |
| 5442 | timer T := 20.0; |
| 5443 | T.start |
| 5444 | alt { |
| 5445 | [] SGsAP.receive(exp_pag_req) |
| 5446 | { |
| 5447 | setverdict(fail, "paging seems not to stop!"); |
| 5448 | mtc.stop; |
| 5449 | } |
| 5450 | [] SGsAP.receive { |
| 5451 | setverdict(fail, "unexpected SGsAP message received"); |
| 5452 | self.stop; |
| 5453 | } |
| 5454 | [] T.timeout { |
| 5455 | setverdict(pass); |
| 5456 | } |
| 5457 | } |
| 5458 | |
| 5459 | /* Even on a failed paging the SGs Association should stay intact */ |
| 5460 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5461 | |
Philipp Maier | 26bdb8c | 2019-09-24 09:21:12 +0200 | [diff] [blame] | 5462 | /* Make sure that the SMS we just inserted is cleared and the |
| 5463 | * subscriber is expired. This is necessary because otherwise the MSC |
| 5464 | * might re-try the SMS delivery and disturb the following tests. */ |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5465 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 5466 | f_vty_sms_clear(hex2str(g_pars.imsi)); |
| 5467 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5468 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " expire"); |
| 5469 | |
| 5470 | setverdict(pass); |
Neels Hofmeyr | b0f8234 | 2019-03-06 15:36:51 +0100 | [diff] [blame] | 5471 | |
| 5472 | f_sgsap_bssmap_screening(); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5473 | } |
| 5474 | testcase TC_sgsap_mt_sms_and_nothing() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5475 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5476 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5477 | f_init(1, true); |
| 5478 | pars := f_init_pars(11825, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5479 | 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] | 5480 | 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] | 5481 | vc_conn.done; |
| 5482 | } |
| 5483 | |
| 5484 | /* Trigger sending of an MT sms via VTY but reject the paging immediately */ |
| 5485 | private function f_tc_sgsap_mt_sms_and_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5486 | f_init_handler(pars, 150.0); |
| 5487 | f_sgs_perform_lu(); |
| 5488 | f_sleep(1.0); |
| 5489 | |
| 5490 | var SmsParameters spars := valueof(t_SmsPars); |
| 5491 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 5492 | var integer page_count := 0; |
| 5493 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5494 | var template PDU_SGsAP exp_pag_req := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, SMS_indicator, omit); |
| 5495 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5496 | exp_pag_req.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 5497 | |
| 5498 | /* Trigger SMS via VTY */ |
| 5499 | f_vty_sms_send_conn_hdlr(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 5500 | |
| 5501 | /* Expect a paging request and reject it immediately */ |
| 5502 | SGsAP.receive(exp_pag_req); |
| 5503 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, IMSI_unknown)); |
| 5504 | |
| 5505 | /* The MSC/VLR should no longer try to page once the paging has been |
| 5506 | * rejected. Wait some time and check if there are no unexpected |
| 5507 | * messages on the SGs interface. */ |
| 5508 | timer T := 20.0; |
| 5509 | T.start |
| 5510 | alt { |
| 5511 | [] SGsAP.receive(exp_pag_req) |
| 5512 | { |
| 5513 | setverdict(fail, "paging seems not to stop!"); |
| 5514 | mtc.stop; |
| 5515 | } |
| 5516 | [] SGsAP.receive { |
| 5517 | setverdict(fail, "unexpected SGsAP message received"); |
| 5518 | self.stop; |
| 5519 | } |
| 5520 | [] T.timeout { |
| 5521 | setverdict(pass); |
| 5522 | } |
| 5523 | } |
| 5524 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 5525 | f_vty_sms_clear(hex2str(g_pars.imsi)); |
| 5526 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5527 | /* A rejected paging with IMSI_unknown (see above) should always send |
| 5528 | * the SGs association to NULL. */ |
| 5529 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 5530 | |
| 5531 | f_sgsap_bssmap_screening(); |
| 5532 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5533 | setverdict(pass); |
| 5534 | } |
| 5535 | testcase TC_sgsap_mt_sms_and_reject() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5536 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5537 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5538 | f_init(1, true); |
| 5539 | pars := f_init_pars(11826, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5540 | 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] | 5541 | 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] | 5542 | vc_conn.done; |
| 5543 | } |
| 5544 | |
Pau Espin Pedrol | 3acd19e | 2021-04-28 12:59:52 +0200 | [diff] [blame] | 5545 | /* Perform an MT CSFB call including LU */ |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5546 | private function f_mt_lu_and_csfb_call(charstring id, BSC_ConnHdlrPars pars, boolean bssmap_lu) runs on BSC_ConnHdlr { |
| 5547 | f_init_handler(pars); |
| 5548 | |
| 5549 | /* Be sure that the BSSMAP reset is done before we begin. */ |
| 5550 | f_sleep(2.0); |
| 5551 | |
| 5552 | /* Testcase variation: See what happens when we do a regular BSSMAP |
| 5553 | * LU first (this should not hurt in any way!) */ |
| 5554 | if (bssmap_lu) { |
| 5555 | f_perform_lu(); |
| 5556 | } |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5557 | 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] | 5558 | |
| 5559 | f_sgs_perform_lu(); |
| 5560 | f_sleep(1.0); |
| 5561 | |
| 5562 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5563 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5564 | |
| 5565 | /* Initiate a call via MNCC interface */ |
| 5566 | f_mt_call_initate(cpars); |
| 5567 | |
| 5568 | /* Expect a paging request and respond accordingly with a service request */ |
| 5569 | SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)); |
| 5570 | SGsAP.send(ts_SGsAP_SERVICE_REQ(pars.imsi, CS_call_indicator, EMM_CONNECTED)); |
| 5571 | |
| 5572 | /* Complete the call, hold it for some time and then tear it down */ |
| 5573 | f_mt_call_complete(cpars); |
| 5574 | f_sleep(3.0); |
Harald Welte | 4c422b7 | 2019-02-17 16:27:10 +0100 | [diff] [blame] | 5575 | f_call_hangup(cpars, true, is_csfb := true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5576 | |
| 5577 | /* Make sure that subscriber is still present and the SGs association is in tact (ref-counting) */ |
| 5578 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5579 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5580 | /* Test for successful return by triggering a paging, when the paging |
| 5581 | * request is received via SGs, we can be sure that the MSC/VLR has |
| 5582 | * recognized that the UE is now back on 4G */ |
| 5583 | f_sleep(1.0); |
| 5584 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 5585 | alt { |
| 5586 | [] SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)) { |
| 5587 | setverdict(pass); |
| 5588 | } |
| 5589 | [] SGsAP.receive { |
| 5590 | setverdict(fail, "Received unexpected message on SGs"); |
| 5591 | } |
| 5592 | } |
| 5593 | |
| 5594 | f_sgsap_bssmap_screening(); |
| 5595 | |
| 5596 | setverdict(pass); |
| 5597 | } |
| 5598 | |
| 5599 | /* Perform a regular BSSAP LU first, do a SGSAP LU and then make a CSFB call */ |
| 5600 | private function f_tc_bssap_lu_sgsap_lu_and_mt_call(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5601 | f_mt_lu_and_csfb_call(id, pars, true); |
| 5602 | } |
| 5603 | 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] | 5604 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5605 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5606 | f_init(1, true); |
| 5607 | pars := f_init_pars(118139, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5608 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5609 | 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] | 5610 | vc_conn.done; |
| 5611 | } |
| 5612 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5613 | /* Perform a SGSAP LU and then make a CSFB call */ |
| 5614 | private function f_tc_sgsap_lu_and_mt_call(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5615 | f_mt_lu_and_csfb_call(id, pars, false); |
| 5616 | } |
| 5617 | testcase TC_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(11827, 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_sgsap_lu_and_mt_call), pars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5624 | vc_conn.done; |
| 5625 | } |
| 5626 | |
Philipp Maier | 628c005 | 2019-04-09 17:36:57 +0200 | [diff] [blame] | 5627 | /* Simulate an HLR/VLR failure */ |
| 5628 | private function f_tc_sgsap_vlr_failure(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5629 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 5630 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5631 | |
| 5632 | var PDU_SGsAP lur; |
| 5633 | |
| 5634 | f_init_handler(pars); |
| 5635 | |
| 5636 | /* Attempt location update (which is expected to fail) */ |
| 5637 | lur := valueof(ts_SGsAP_LU_REQ(g_pars.imsi, mme_name, IMSI_attach, |
| 5638 | ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5639 | SGsAP.send(lur); |
| 5640 | |
| 5641 | /* Respond to SGsAP-RESET-INDICATION from VLR */ |
| 5642 | alt { |
| 5643 | [] SGsAP.receive(tr_SGsAP_RESET_IND_VLR(vlr_name)); { |
| 5644 | SGsAP.send(valueof(ts_SGsAP_RESET_ACK_MME(mme_name))); |
| 5645 | setverdict(pass); |
| 5646 | } |
| 5647 | [] SGsAP.receive { |
| 5648 | setverdict(fail, "Received unexpected message on SGs"); |
| 5649 | } |
| 5650 | } |
| 5651 | |
| 5652 | f_sleep(1.0); |
| 5653 | setverdict(pass); |
| 5654 | } |
| 5655 | testcase TC_sgsap_vlr_failure() runs on MTC_CT { |
| 5656 | var BSC_ConnHdlrPars pars; |
| 5657 | var BSC_ConnHdlr vc_conn; |
| 5658 | f_init(1, true, false); |
| 5659 | pars := f_init_pars(11811, true, false); |
| 5660 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_vlr_failure), pars); |
| 5661 | vc_conn.done; |
| 5662 | } |
| 5663 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5664 | /* SGs TODO: |
| 5665 | * LU attempt for IMSI without NAM_PS in HLR |
| 5666 | * LU attempt with AUTH FAIL due to invalid RES/SRES |
| 5667 | * LU attempt with no response from HLR (VLR should timeout + LU REJ) |
| 5668 | * LU attempt with new TMSI but without TMSI REALL CMPL baco to VLR |
| 5669 | * implicit IMSI detach from EPS |
| 5670 | * implicit IMSI detach from non-EPS |
| 5671 | * MM INFO |
| 5672 | * |
| 5673 | */ |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 5674 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5675 | private function f_tc_ho_inter_bsc_unknown_cell(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5676 | f_init_handler(pars); |
| 5677 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5678 | |
| 5679 | f_perform_lu(); |
| 5680 | f_mo_call_establish(cpars); |
| 5681 | |
| 5682 | f_sleep(1.0); |
| 5683 | |
| 5684 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_BETTER_CELL; |
| 5685 | var BssmapCause cause := enum2int(cause_val); |
| 5686 | |
| 5687 | var template BSSMAP_FIELD_CellIdentificationList cil; |
| 5688 | cil := { cIl_LAI := { ts_BSSMAP_CI_LAI('023'H, '42'H, 999) } }; |
| 5689 | |
| 5690 | BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 5691 | BSSAP.receive(tr_BSSMAP_HandoverRequiredReject); |
| 5692 | |
| 5693 | f_call_hangup(cpars, true); |
| 5694 | } |
| 5695 | testcase TC_ho_inter_bsc_unknown_cell() runs on MTC_CT { |
| 5696 | var BSC_ConnHdlr vc_conn; |
| 5697 | f_init(); |
| 5698 | |
| 5699 | vc_conn := f_start_handler(refers(f_tc_ho_inter_bsc_unknown_cell), 53); |
| 5700 | vc_conn.done; |
| 5701 | } |
| 5702 | |
| 5703 | private altstep as_mgcp_ack_all_mdcx(CallParameters cpars) runs on BSC_ConnHdlr { |
| 5704 | var MgcpCommand mgcp_cmd; |
| 5705 | [] MGCP.receive(tr_MDCX) -> value mgcp_cmd { |
Neels Hofmeyr | 8913b9e | 2021-07-27 22:33:45 +0200 | [diff] [blame] | 5706 | var charstring conn_id; |
| 5707 | f_mgcp_find_param_entry(mgcp_cmd.params, "I", conn_id); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 5708 | 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] | 5709 | hex2str(cpars.mgcp_call_id), "42", |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 5710 | cpars.mgw_conn_2.mgw_rtp_port, |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5711 | { int2str(cpars.rtp_payload_type) }, |
| 5712 | { valueof(ts_SDP_rtpmap(cpars.rtp_payload_type, |
| 5713 | cpars.rtp_sdp_format)), |
| 5714 | valueof(ts_SDP_ptime(20)) })); |
Neels Hofmeyr | 8913b9e | 2021-07-27 22:33:45 +0200 | [diff] [blame] | 5715 | 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] | 5716 | repeat; |
| 5717 | } |
| 5718 | } |
| 5719 | |
Neels Hofmeyr | 8853afb | 2021-07-27 22:34:15 +0200 | [diff] [blame] | 5720 | private altstep as_mgcp_ack_all_dlcx(CallParameters cpars) runs on BSC_ConnHdlr { |
| 5721 | var MgcpCommand mgcp_cmd; |
| 5722 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 5723 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
| 5724 | repeat; |
| 5725 | } |
| 5726 | } |
| 5727 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5728 | 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] | 5729 | var CallParameters cpars; |
| 5730 | |
| 5731 | cpars := valueof(t_CallParams('12345'H, 0)); |
| 5732 | if (pars.use_ipv6) { |
| 5733 | cpars.mgw_conn_1.mgw_rtp_ip := "::1"; |
| 5734 | cpars.mgw_conn_2.mgw_rtp_ip := "::2"; |
| 5735 | cpars.bss_rtp_ip := "::3"; |
| 5736 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5737 | |
| 5738 | f_init_handler(pars); |
| 5739 | |
| 5740 | f_vty_transceive(MSCVTY, "configure terminal"); |
| 5741 | f_vty_transceive(MSCVTY, "msc"); |
| 5742 | 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] | 5743 | 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] | 5744 | f_vty_transceive(MSCVTY, "exit"); |
| 5745 | f_vty_transceive(MSCVTY, "exit"); |
| 5746 | |
| 5747 | f_perform_lu(); |
| 5748 | f_mo_call_establish(cpars); |
| 5749 | |
| 5750 | f_sleep(1.0); |
| 5751 | |
| 5752 | var default ack_mdcx := activate(as_mgcp_ack_all_mdcx(cpars)); |
| 5753 | |
| 5754 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_BETTER_CELL; |
| 5755 | var BssmapCause cause := enum2int(cause_val); |
| 5756 | |
| 5757 | var template BSSMAP_FIELD_CellIdentificationList cil; |
Neels Hofmeyr | 2822d07 | 2021-06-23 03:20:32 +0200 | [diff] [blame] | 5758 | 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] | 5759 | |
| 5760 | /* old BSS sends Handover Required */ |
| 5761 | BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 5762 | |
| 5763 | /* Now the action goes on in f_tc_ho_inter_bsc1() */ |
| 5764 | |
| 5765 | /* MSC forwards the RR Handover Command to old BSS */ |
| 5766 | var PDU_BSSAP ho_command; |
| 5767 | BSSAP.receive(tr_BSSMAP_HandoverCommand) -> value ho_command; |
| 5768 | |
| 5769 | log("GOT HandoverCommand", ho_command); |
| 5770 | |
| 5771 | BSSAP.receive(tr_BSSMAP_HandoverSucceeded); |
| 5772 | |
| 5773 | /* f_tc_ho_inter_bsc1() completes Handover, then expecting a Clear here. */ |
| 5774 | f_expect_clear(); |
| 5775 | |
| 5776 | log("FIRST inter-BSC Handover done"); |
| 5777 | |
| 5778 | |
| 5779 | /* ------------------------ */ |
| 5780 | |
| 5781 | /* Ok, that went well, now the other BSC is handovering back here -- |
| 5782 | * from now on this here is the new BSS. */ |
| 5783 | f_create_bssmap_exp_handoverRequest(193); |
| 5784 | |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5785 | var template BSSMAP_IE_EncryptionInformation encryptionInformation; |
| 5786 | var template BSSMAP_IE_ChosenEncryptionAlgorithm chosenEncryptionAlgorithm; |
| 5787 | var template BSSMAP_IE_KC128 kC128; |
| 5788 | var OCT1 a5_perm_alg; |
| 5789 | f_get_expected_encryption(encryptionInformation, chosenEncryptionAlgorithm, kC128, a5_perm_alg); |
| 5790 | 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] | 5791 | var PDU_BSSAP ho_request; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5792 | alt { |
| 5793 | [] BSSAP.receive(expect_ho_request); |
| 5794 | [] BSSAP.receive(tr_BSSMAP_HandoverRequest) -> value ho_request { |
| 5795 | log("Error: Wrong handoverRequest received. Expected: ", expect_ho_request, |
| 5796 | " got ", ho_request); |
| 5797 | setverdict(fail, "Wrong handoverRequest received"); |
| 5798 | mtc.stop; |
| 5799 | } |
| 5800 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5801 | |
| 5802 | /* new BSS composes a RR Handover Command */ |
| 5803 | var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 5804 | 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] | 5805 | var BSSMAP_IE_AoIP_TransportLayerAddress tla tla := |
| 5806 | 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] | 5807 | BSSAP.send(ts_BSSMAP_HandoverRequestAcknowledge(rr_ho_cmd_enc, lengthof(rr_ho_cmd_enc), |
| 5808 | tla, ts_BSSMAP_IE_SpeechCodec({ts_CodecFR}))); |
| 5809 | |
| 5810 | /* Now f_tc_ho_inter_bsc1() expects HandoverCommand */ |
| 5811 | |
| 5812 | f_sleep(0.5); |
| 5813 | |
| 5814 | /* Notify that the MS is now over here */ |
| 5815 | |
| 5816 | BSSAP.send(ts_BSSMAP_HandoverDetect); |
| 5817 | f_sleep(0.1); |
| 5818 | BSSAP.send(ts_BSSMAP_HandoverComplete); |
| 5819 | |
| 5820 | f_sleep(3.0); |
| 5821 | |
| 5822 | deactivate(ack_mdcx); |
| 5823 | |
| 5824 | var default ccrel := activate(as_optional_cc_rel(cpars, true)); |
| 5825 | |
| 5826 | /* blatant cheating */ |
| 5827 | var N_Sd_Array last_n_sd := f_bssmap_last_n_sd(); |
| 5828 | last_n_sd[0] := 3; |
| 5829 | f_bssmap_continue_after_n_sd(last_n_sd); |
| 5830 | |
| 5831 | f_call_hangup(cpars, true); |
| 5832 | f_sleep(1.0); |
| 5833 | deactivate(ccrel); |
| 5834 | |
| 5835 | setverdict(pass); |
| 5836 | } |
| 5837 | 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] | 5838 | var charstring bss_rtp_ip; |
| 5839 | if (pars.use_ipv6) { |
| 5840 | bss_rtp_ip := "::8"; |
| 5841 | } else { |
| 5842 | bss_rtp_ip := "1.2.3.4"; |
| 5843 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5844 | f_init_handler(pars); |
| 5845 | f_create_bssmap_exp_handoverRequest(194); |
| 5846 | |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5847 | var template BSSMAP_IE_EncryptionInformation encryptionInformation; |
| 5848 | var template BSSMAP_IE_ChosenEncryptionAlgorithm chosenEncryptionAlgorithm; |
| 5849 | var template BSSMAP_IE_KC128 kC128; |
| 5850 | var OCT1 a5_perm_alg; |
| 5851 | f_get_expected_encryption(encryptionInformation, chosenEncryptionAlgorithm, kC128, a5_perm_alg); |
| 5852 | 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] | 5853 | var PDU_BSSAP ho_request; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5854 | alt { |
| 5855 | [] BSSAP.receive(expect_ho_request); |
| 5856 | [] BSSAP.receive(tr_BSSMAP_HandoverRequest) -> value ho_request { |
| 5857 | log("Error: Wrong handoverRequest received. Expected: ", expect_ho_request, |
| 5858 | " got ", ho_request); |
| 5859 | setverdict(fail, "Wrong handoverRequest received"); |
| 5860 | mtc.stop; |
| 5861 | } |
| 5862 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5863 | /* new BSS composes a RR Handover Command */ |
| 5864 | var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 5865 | 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] | 5866 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := |
| 5867 | valueof(f_ts_BSSMAP_IE_AoIP_TLA(bss_rtp_ip, 2342)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5868 | BSSAP.send(ts_BSSMAP_HandoverRequestAcknowledge(rr_ho_cmd_enc, lengthof(rr_ho_cmd_enc), |
| 5869 | tla, ts_BSSMAP_IE_SpeechCodec({ts_CodecFR}))); |
| 5870 | |
| 5871 | /* Now f_tc_ho_inter_bsc0() expects HandoverCommand */ |
| 5872 | |
| 5873 | f_sleep(0.5); |
| 5874 | |
| 5875 | /* Notify that the MS is now over here */ |
| 5876 | |
| 5877 | BSSAP.send(ts_BSSMAP_HandoverDetect); |
| 5878 | f_sleep(0.1); |
| 5879 | BSSAP.send(ts_BSSMAP_HandoverComplete); |
| 5880 | |
| 5881 | f_sleep(3.0); |
| 5882 | |
| 5883 | /* Now I'd like to f_call_hangup() but we don't know any cpars here. So |
| 5884 | * ... handover back to the first BSC :P */ |
| 5885 | |
| 5886 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_BETTER_CELL; |
| 5887 | var BssmapCause cause := enum2int(cause_val); |
| 5888 | |
| 5889 | var template BSSMAP_FIELD_CellIdentificationList cil; |
Neels Hofmeyr | 2822d07 | 2021-06-23 03:20:32 +0200 | [diff] [blame] | 5890 | 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] | 5891 | |
| 5892 | /* old BSS sends Handover Required */ |
| 5893 | BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 5894 | |
| 5895 | /* Now the action goes on in f_tc_ho_inter_bsc0() */ |
| 5896 | |
| 5897 | /* MSC forwards the RR Handover Command to old BSS */ |
| 5898 | var PDU_BSSAP ho_command; |
| 5899 | BSSAP.receive(tr_BSSMAP_HandoverCommand) -> value ho_command; |
| 5900 | |
| 5901 | log("GOT HandoverCommand", ho_command); |
| 5902 | |
| 5903 | BSSAP.receive(tr_BSSMAP_HandoverSucceeded); |
| 5904 | |
| 5905 | /* f_tc_ho_inter_bsc1() completes Handover, then expecting a Clear here. */ |
| 5906 | f_expect_clear(); |
| 5907 | setverdict(pass); |
| 5908 | } |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5909 | 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] | 5910 | var BSC_ConnHdlr vc_conn0; |
| 5911 | var BSC_ConnHdlr vc_conn1; |
| 5912 | f_init(2); |
| 5913 | |
| 5914 | var BSC_ConnHdlrPars pars0 := f_init_pars(53); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 5915 | pars0.use_ipv6 := use_ipv6; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5916 | pars0.net.expect_ciph := a5_n > 0; |
| 5917 | pars0.net.expect_auth := pars0.net.expect_ciph; |
| 5918 | pars0.net.kc_support := bit2oct('00000001'B << a5_n); |
| 5919 | pars0.cm2.classmarkInformationType2_oct5.a5_3 := '1'B; |
| 5920 | pars0.cm2.classmarkInformationType2_oct5.a5_2 := '0'B; |
| 5921 | pars0.cm2.classmarkInformationType2_oct5.cm3 := '1'B; |
| 5922 | pars0.cm3 := valueof(ts_CM3_default); |
| 5923 | pars0.use_umts_aka := true; |
| 5924 | pars0.vec := f_gen_auth_vec_3g(); |
| 5925 | pars0.vec_keep := true; |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 5926 | pars0.ran_idx := 0; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5927 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5928 | var BSC_ConnHdlrPars pars1 := f_init_pars(53); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 5929 | pars1.use_ipv6 := use_ipv6; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5930 | pars1.net.expect_ciph := pars0.net.expect_ciph; |
| 5931 | pars1.net.expect_auth := pars0.net.expect_ciph; |
| 5932 | pars1.net.kc_support := bit2oct('00000001'B << a5_n); |
| 5933 | pars1.cm2 := pars0.cm2; |
| 5934 | pars1.cm3 := pars0.cm3; |
| 5935 | pars1.use_umts_aka := true; |
| 5936 | /* Both components need the same auth vector info because we expect f_tc_ho_inter_bsc0's ciphering key to be |
| 5937 | * identical to the one that shows up in f_tc_ho_inter_bsc1. Can only do that by feeding in a vector to both |
| 5938 | * components and then not overwriting it in BSC_ConnectionHandler. */ |
| 5939 | pars1.vec := pars0.vec; |
| 5940 | pars1.vec_keep := true; |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 5941 | pars1.ran_idx := 1; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5942 | |
| 5943 | if (a5_n > 0) { |
| 5944 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 5945 | } |
| 5946 | f_vty_config(MSCVTY, "network", "encryption a5 " & int2str(a5_n)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5947 | |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 5948 | vc_conn0 := f_start_handler_with_pars(refers(f_tc_ho_inter_bsc0), pars0); |
| 5949 | 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] | 5950 | vc_conn0.done; |
| 5951 | vc_conn1.done; |
| 5952 | } |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 5953 | testcase TC_ho_inter_bsc() runs on MTC_CT { |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5954 | f_tc_ho_inter_bsc_main(false, a5_n := 0); |
| 5955 | } |
| 5956 | testcase TC_ho_inter_bsc_a5_1() runs on MTC_CT { |
| 5957 | f_tc_ho_inter_bsc_main(false, a5_n := 1); |
| 5958 | } |
| 5959 | testcase TC_ho_inter_bsc_a5_3() runs on MTC_CT { |
| 5960 | f_tc_ho_inter_bsc_main(false, a5_n := 3); |
| 5961 | } |
| 5962 | testcase TC_ho_inter_bsc_a5_4() runs on MTC_CT { |
| 5963 | f_tc_ho_inter_bsc_main(false, a5_n := 4); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 5964 | } |
| 5965 | testcase TC_ho_inter_bsc_ipv6() runs on MTC_CT { |
| 5966 | f_tc_ho_inter_bsc_main(true); |
| 5967 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5968 | |
| 5969 | function f_ML3_patch_seq_nr_MS_NW(in uint2_t seq_nr, inout octetstring enc_l3) { |
| 5970 | log("MS_NW patching N(SD)=", seq_nr, " into dtap ", enc_l3); |
| 5971 | enc_l3[2] := (enc_l3[2] and4b '3f'O) or4b bit2oct(int2bit(seq_nr, 8) << 6); |
| 5972 | log("MS_NW patched enc_l3: ", enc_l3); |
| 5973 | } |
| 5974 | |
| 5975 | 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] | 5976 | var CallParameters cpars; |
Neels Hofmeyr | 906af10 | 2021-07-01 12:08:35 +0200 | [diff] [blame] | 5977 | var PDU_BSSAP ho_request; |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 5978 | |
| 5979 | cpars := valueof(t_CallParams('12345'H, 0)); |
| 5980 | if (pars.use_ipv6) { |
| 5981 | cpars.mgw_conn_1.mgw_rtp_ip := "::1"; |
| 5982 | cpars.mgw_conn_2.mgw_rtp_ip := "::2"; |
| 5983 | cpars.bss_rtp_ip := "::3"; |
| 5984 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5985 | var hexstring ho_number := f_gen_msisdn(99999); |
| 5986 | |
| 5987 | f_init_handler(pars); |
| 5988 | |
| 5989 | f_create_mncc_expect(hex2str(ho_number)); |
| 5990 | |
| 5991 | f_vty_transceive(MSCVTY, "configure terminal"); |
| 5992 | f_vty_transceive(MSCVTY, "msc"); |
| 5993 | f_vty_transceive(MSCVTY, "neighbor a cgi 017 017 1 1 msc-ipa-name msc-017-017-1"); |
| 5994 | f_vty_transceive(MSCVTY, "exit"); |
| 5995 | f_vty_transceive(MSCVTY, "exit"); |
| 5996 | |
| 5997 | f_perform_lu(); |
| 5998 | f_mo_call_establish(cpars); |
| 5999 | |
| 6000 | f_sleep(1.0); |
| 6001 | |
| 6002 | var default ack_mdcx := activate(as_mgcp_ack_all_mdcx(cpars)); |
| 6003 | |
| 6004 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_BETTER_CELL; |
| 6005 | var BssmapCause cause := enum2int(cause_val); |
| 6006 | |
| 6007 | var template BSSMAP_FIELD_CellIdentificationList cil; |
Neels Hofmeyr | 36ebc33 | 2021-06-23 03:20:32 +0200 | [diff] [blame] | 6008 | 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] | 6009 | |
| 6010 | /* old BSS sends Handover Required */ |
| 6011 | BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 6012 | |
| 6013 | /* The target cell 017-017 LAC 1 is configured to be a remote MSC of name "msc-017-017-1". |
| 6014 | * This MSC tries to reach the other MSC via GSUP. */ |
| 6015 | |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6016 | var template BSSMAP_IE_EncryptionInformation encryptionInformation; |
| 6017 | var template BSSMAP_IE_ChosenEncryptionAlgorithm chosenEncryptionAlgorithm; |
| 6018 | var template BSSMAP_IE_KC128 kC128; |
| 6019 | var OCT1 a5_perm_alg; |
| 6020 | f_get_expected_encryption(encryptionInformation, chosenEncryptionAlgorithm, kC128, a5_perm_alg); |
| 6021 | var template PDU_BSSAP expect_ho_request := tr_BSSMAP_HandoverRequest(encryptionInformation, chosenEncryptionAlgorithm, kC128); |
| 6022 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6023 | var octetstring remote_msc_name := '6D73632D3031372D3031372D3100'O; /* "msc-017-017-1\0" as octetstring */ |
| 6024 | var GSUP_PDU prep_ho_req; |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6025 | alt { |
| 6026 | [] GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST, |
| 6027 | pars.imsi, destination_name := remote_msc_name, |
Neels Hofmeyr | ec2e1f7 | 2021-07-02 02:08:32 +0200 | [diff] [blame] | 6028 | 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] | 6029 | [] GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST)) { |
| 6030 | setverdict(fail, "Wrong OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST message received"); |
| 6031 | mtc.stop; |
| 6032 | } |
| 6033 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6034 | |
| 6035 | var GSUP_IeValue source_name_ie; |
| 6036 | f_gsup_find_ie(prep_ho_req, OSMO_GSUP_SOURCE_NAME_IE, source_name_ie); |
| 6037 | var octetstring local_msc_name := source_name_ie.source_name; |
| 6038 | |
Neels Hofmeyr | ec2e1f7 | 2021-07-02 02:08:32 +0200 | [diff] [blame] | 6039 | /* 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] | 6040 | var GSUP_IeValue an_apdu_ie; |
| 6041 | f_gsup_find_ie(prep_ho_req, OSMO_GSUP_AN_APDU_IE, an_apdu_ie); |
| 6042 | ho_request := dec_PDU_BSSAP(an_apdu_ie.an_apdu.pdu); |
Neels Hofmeyr | ec2e1f7 | 2021-07-02 02:08:32 +0200 | [diff] [blame] | 6043 | if (not match(ho_request, expect_ho_request)) { |
| 6044 | setverdict(fail, "Wrong PDU in OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST message received"); |
| 6045 | mtc.stop; |
| 6046 | } |
Neels Hofmeyr | 906af10 | 2021-07-01 12:08:35 +0200 | [diff] [blame] | 6047 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6048 | /* Remote MSC has figured out its BSC and signals success */ |
| 6049 | var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 6050 | var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd); |
| 6051 | 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] | 6052 | aoIPTransportLayer := omit, |
| 6053 | speechCodec := ts_BSSMAP_IE_SpeechCodec({ts_CodecFR}), |
| 6054 | chosenEncryptionAlgorithm := ho_request.pdu.bssmap.handoverRequest.chosenEncryptionAlgorithm)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6055 | GSUP.send(ts_GSUP_E_PrepareHandoverResult( |
| 6056 | pars.imsi, |
| 6057 | ho_number, |
| 6058 | remote_msc_name, local_msc_name, |
| 6059 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, enc_PDU_BSSAP(ho_req_ack))))); |
| 6060 | |
| 6061 | /* MSC forwards the RR Handover Command to old BSS */ |
| 6062 | BSSAP.receive(tr_BSSMAP_HandoverCommand); |
| 6063 | |
| 6064 | /* The MS shows up at remote new BSS */ |
| 6065 | |
| 6066 | GSUP.send(ts_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PROCESS_ACCESS_SIGNALLING_REQUEST, |
| 6067 | pars.imsi, remote_msc_name, local_msc_name, |
| 6068 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, |
| 6069 | enc_PDU_BSSAP(valueof(ts_BSSMAP_HandoverDetect)))))); |
| 6070 | BSSAP.receive(tr_BSSMAP_HandoverSucceeded); |
| 6071 | f_sleep(0.1); |
| 6072 | |
| 6073 | /* Save the MS sequence counters for use on the other connection */ |
| 6074 | var N_Sd_Array last_n_sd := f_bssmap_last_n_sd(); |
| 6075 | |
| 6076 | GSUP.send(ts_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_SEND_END_SIGNAL_REQUEST, |
| 6077 | pars.imsi, remote_msc_name, local_msc_name, |
| 6078 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, |
| 6079 | enc_PDU_BSSAP(valueof(ts_BSSMAP_HandoverComplete)))))); |
| 6080 | |
| 6081 | /* The local BSS conn clears, all communication goes via remote MSC now */ |
| 6082 | f_expect_clear(); |
| 6083 | |
| 6084 | /**********************************/ |
| 6085 | /* Play through some signalling across the inter-MSC link. |
| 6086 | * This is a copy of f_tc_lu_and_mo_ussd_single_request() translated into GSUP AN-APDUs. */ |
| 6087 | |
| 6088 | if (false) { |
| 6089 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 6090 | invoke_id := 5, /* Phone may not start from 0 or 1 */ |
| 6091 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 6092 | ussd_string := "*#100#" |
| 6093 | ); |
| 6094 | |
| 6095 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 6096 | invoke_id := 5, /* InvokeID shall be the same for both REQ and RSP */ |
| 6097 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 6098 | ussd_string := "Your extension is " & hex2str(g_pars.msisdn) & "\r" |
| 6099 | ) |
| 6100 | |
| 6101 | /* Compose a new SS/REGISTER message with request */ |
| 6102 | var template (value) PDU_ML3_MS_NW ussd_req := ts_ML3_MO_SS_REGISTER( |
| 6103 | tid := 1, /* We just need a single transaction */ |
| 6104 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 6105 | facility := valueof(facility_req) |
| 6106 | ); |
| 6107 | var PDU_ML3_MS_NW ussd_req_v := valueof(ussd_req); |
| 6108 | |
| 6109 | /* Compose SS/RELEASE_COMPLETE template with expected response */ |
| 6110 | var template PDU_ML3_NW_MS ussd_rsp := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 6111 | tid := 1, /* Response should arrive within the same transaction */ |
| 6112 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 6113 | facility := valueof(facility_rsp) |
| 6114 | ); |
| 6115 | |
| 6116 | /* Compose expected MSC -> HLR message */ |
| 6117 | var template GSUP_PDU gsup_req := tr_GSUP_PROC_SS_REQ( |
| 6118 | imsi := g_pars.imsi, |
| 6119 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 6120 | ss := valueof(facility_req) |
| 6121 | ); |
| 6122 | |
| 6123 | /* To be used for sending response with correct session ID */ |
| 6124 | var GSUP_PDU gsup_req_complete; |
| 6125 | |
| 6126 | /* Request own number */ |
| 6127 | /* From remote MSC instead of BSSAP directly */ |
| 6128 | /* Patch the correct N_SD value into the message. */ |
| 6129 | var octetstring l3_enc := enc_PDU_ML3_MS_NW(ussd_req_v); |
| 6130 | var RAN_Emulation.ConnectionData cd; |
| 6131 | f_ML3_patch_seq_nr_MS_NW(f_next_n_sd(last_n_sd, f_ML3_n_sd_idx(ussd_req_v)), l3_enc); |
| 6132 | GSUP.send(ts_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PROCESS_ACCESS_SIGNALLING_REQUEST, |
| 6133 | pars.imsi, remote_msc_name, local_msc_name, |
| 6134 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, |
| 6135 | enc_PDU_BSSAP(valueof(ts_BSSAP_DTAP(l3_enc))) |
| 6136 | )) |
| 6137 | )); |
| 6138 | |
| 6139 | /* Expect GSUP message containing the SS payload */ |
| 6140 | gsup_req_complete := f_expect_gsup_msg(gsup_req); |
| 6141 | |
| 6142 | /* Compose the response from HLR using received session ID */ |
| 6143 | var template GSUP_PDU gsup_rsp := ts_GSUP_PROC_SS_REQ( |
| 6144 | imsi := g_pars.imsi, |
| 6145 | sid := gsup_req_complete.ies[1].val.session_id, |
| 6146 | state := OSMO_GSUP_SESSION_STATE_END, |
| 6147 | ss := valueof(facility_rsp) |
| 6148 | ); |
| 6149 | |
| 6150 | /* Finally, HLR terminates the session */ |
| 6151 | GSUP.send(gsup_rsp); |
| 6152 | |
| 6153 | /* The USSD response goes out to remote MSC, on GSUP E instead of BSSAP */ |
| 6154 | var GSUP_PDU gsup_ussd_rsp; |
| 6155 | GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_FORWARD_ACCESS_SIGNALLING_REQUEST, |
| 6156 | pars.imsi, destination_name := remote_msc_name)) -> value gsup_ussd_rsp; |
| 6157 | |
| 6158 | var GSUP_IeValue an_apdu; |
| 6159 | if (not f_gsup_find_ie(gsup_ussd_rsp, OSMO_GSUP_AN_APDU_IE, an_apdu)) { |
| 6160 | setverdict(fail, "No AN-APDU in received GSUP message. Expected USSD response in DTAP, got", gsup_ussd_rsp); |
| 6161 | mtc.stop; |
| 6162 | } |
| 6163 | var PDU_BSSAP bssap_dtap_mt := dec_PDU_BSSAP(an_apdu.an_apdu.pdu); |
| 6164 | var PDU_ML3_NW_MS dtap_mt := dec_PDU_ML3_NW_MS(bssap_dtap_mt.pdu.dtap); |
| 6165 | log("Expecting", ussd_rsp); |
| 6166 | log("Got", dtap_mt); |
| 6167 | if (not match(dtap_mt, ussd_rsp)) { |
| 6168 | setverdict(fail, "Unexpected GSUP message. Expected USSD response in DTAP, got", gsup_ussd_rsp); |
| 6169 | mtc.stop; |
| 6170 | } |
| 6171 | } |
| 6172 | /**********************************/ |
| 6173 | |
| 6174 | |
| 6175 | /* inter-MSC handover back to the first MSC */ |
| 6176 | f_create_bssmap_exp_handoverRequest(193); |
| 6177 | cil := { cIl_CGI := { ts_BSSMAP_CI_CGI('262'H, '42'H, 23, 42) } }; |
| 6178 | |
| 6179 | /* old BSS sends Handover Required, via inter-MSC E link: like |
| 6180 | * BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 6181 | * but via GSUP */ |
| 6182 | GSUP.send(ts_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_REQUEST, |
| 6183 | pars.imsi, remote_msc_name, local_msc_name, |
| 6184 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, |
| 6185 | enc_PDU_BSSAP(valueof(ts_BSSMAP_HandoverRequired(cause, cil))) |
| 6186 | )) |
| 6187 | )); |
| 6188 | |
| 6189 | /* MSC asks local BSS to prepare Handover to it */ |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6190 | f_get_expected_encryption(encryptionInformation, chosenEncryptionAlgorithm, kC128, a5_perm_alg); |
| 6191 | expect_ho_request := tr_BSSMAP_HandoverRequest(encryptionInformation, chosenEncryptionAlgorithm, kC128); |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6192 | alt { |
Neels Hofmeyr | 906af10 | 2021-07-01 12:08:35 +0200 | [diff] [blame] | 6193 | [] BSSAP.receive(expect_ho_request) -> value ho_request; |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6194 | [] BSSAP.receive(tr_BSSMAP_HandoverRequest) -> value ho_request { |
| 6195 | log("Error: Wrong handoverRequest received. Expected: ", expect_ho_request, |
| 6196 | " got ", ho_request); |
| 6197 | setverdict(fail, "Wrong handoverRequest received"); |
| 6198 | mtc.stop; |
| 6199 | } |
| 6200 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6201 | |
| 6202 | /* Make sure the new BSSAP conn continues with the correct N_SD sequence numbers */ |
| 6203 | f_bssmap_continue_after_n_sd(last_n_sd); |
| 6204 | |
| 6205 | /* new BSS composes a RR Handover Command */ |
| 6206 | rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 6207 | 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] | 6208 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := |
| 6209 | 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] | 6210 | 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] | 6211 | tla, ts_BSSMAP_IE_SpeechCodec({ts_CodecFR}), |
| 6212 | chosenEncryptionAlgorithm := ho_request.pdu.bssmap.handoverRequest.chosenEncryptionAlgorithm)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6213 | |
| 6214 | /* HandoverCommand goes out via remote MSC-I */ |
| 6215 | var GSUP_PDU prep_subsq_ho_res; |
| 6216 | GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_RESULT, |
| 6217 | pars.imsi, destination_name := remote_msc_name)) -> value prep_subsq_ho_res; |
| 6218 | |
| 6219 | /* MS shows up at the local BSS */ |
| 6220 | BSSAP.send(ts_BSSMAP_HandoverDetect); |
| 6221 | f_sleep(0.1); |
| 6222 | BSSAP.send(ts_BSSMAP_HandoverComplete); |
| 6223 | |
| 6224 | /* Handover Succeeded message */ |
| 6225 | GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_FORWARD_ACCESS_SIGNALLING_REQUEST, |
| 6226 | pars.imsi, destination_name := remote_msc_name)); |
| 6227 | |
| 6228 | /* MS has handovered to here, Clear Command goes out via remote MSC-I -- in form of a GSUP Close. */ |
| 6229 | GSUP.receive(tr_GSUP_E_NO_PDU(OSMO_GSUP_MSGT_E_CLOSE, |
| 6230 | pars.imsi, destination_name := remote_msc_name)); |
| 6231 | |
| 6232 | /* Handover ends successfully. Call goes on for a little longer and then we hang up. */ |
| 6233 | |
| 6234 | f_sleep(1.0); |
| 6235 | deactivate(ack_mdcx); |
| 6236 | |
| 6237 | /* FIXME: the inter-MSC call has put a number of MNCC messages in the queue, which above code should expect and |
| 6238 | * clear out. The f_call_hangup() expects an MNCC_REL_IND, so, for the time being, just clear the MNCC messages |
| 6239 | * before starting the call hangup. Instead of this, the individual messages should be tested for above. */ |
| 6240 | MNCC.clear; |
| 6241 | |
| 6242 | var default ccrel := activate(as_optional_cc_rel(cpars, true)); |
| 6243 | f_call_hangup(cpars, true); |
| 6244 | f_sleep(1.0); |
| 6245 | deactivate(ccrel); |
| 6246 | |
| 6247 | setverdict(pass); |
| 6248 | } |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6249 | 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] | 6250 | var BSC_ConnHdlr vc_conn; |
| 6251 | f_init(1); |
| 6252 | |
| 6253 | var BSC_ConnHdlrPars pars := f_init_pars(54); |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6254 | pars.net.expect_ciph := a5_n > 0; |
| 6255 | pars.net.expect_auth := pars.net.expect_ciph; |
| 6256 | pars.net.kc_support := bit2oct('00000001'B << a5_n); |
| 6257 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '1'B; |
| 6258 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '0'B; |
| 6259 | pars.cm2.classmarkInformationType2_oct5.cm3 := '1'B; |
| 6260 | pars.cm3 := valueof(ts_CM3_default); |
| 6261 | pars.use_umts_aka := true; |
| 6262 | |
| 6263 | if (a5_n > 0) { |
| 6264 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6265 | } |
| 6266 | f_vty_config(MSCVTY, "network", "encryption a5 " & int2str(a5_n)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6267 | |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 6268 | 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] | 6269 | vc_conn.done; |
| 6270 | } |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6271 | testcase TC_ho_inter_msc_out() runs on MTC_CT { |
| 6272 | f_tc_ho_inter_msc_out_a5(0); |
| 6273 | } |
| 6274 | testcase TC_ho_inter_msc_out_a5_1() runs on MTC_CT { |
| 6275 | f_tc_ho_inter_msc_out_a5(1); |
| 6276 | } |
| 6277 | testcase TC_ho_inter_msc_out_a5_3() runs on MTC_CT { |
| 6278 | f_tc_ho_inter_msc_out_a5(3); |
| 6279 | } |
| 6280 | testcase TC_ho_inter_msc_out_a5_4() runs on MTC_CT { |
| 6281 | f_tc_ho_inter_msc_out_a5(4); |
| 6282 | } |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 6283 | testcase TC_ho_inter_msc_out_ipv6() runs on MTC_CT { |
| 6284 | var BSC_ConnHdlr vc_conn; |
| 6285 | f_init(1); |
| 6286 | |
| 6287 | var BSC_ConnHdlrPars pars := f_init_pars(54); |
| 6288 | pars.use_ipv6 := true; |
| 6289 | |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 6290 | 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] | 6291 | vc_conn.done; |
| 6292 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6293 | |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6294 | private function f_tc_lu_imsi_auth_tmsi_check_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6295 | pars.net.expect_auth := true; |
| 6296 | pars.net.expect_imei := true; |
| 6297 | f_init_handler(pars); |
| 6298 | f_perform_lu(); |
| 6299 | } |
| 6300 | testcase TC_lu_imsi_auth_tmsi_check_imei() runs on MTC_CT { |
| 6301 | var BSC_ConnHdlr vc_conn; |
| 6302 | f_init(); |
| 6303 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6304 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6305 | |
| 6306 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei), 5); |
| 6307 | vc_conn.done; |
| 6308 | } |
| 6309 | |
| 6310 | private function f_tc_lu_imsi_auth3g_tmsi_check_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6311 | pars.net.expect_auth := true; |
| 6312 | pars.use_umts_aka := true; |
| 6313 | pars.net.expect_imei := true; |
| 6314 | f_init_handler(pars); |
| 6315 | f_perform_lu(); |
| 6316 | } |
| 6317 | testcase TC_lu_imsi_auth3g_tmsi_check_imei() runs on MTC_CT { |
| 6318 | var BSC_ConnHdlr vc_conn; |
| 6319 | f_init(); |
| 6320 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6321 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6322 | |
| 6323 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth3g_tmsi_check_imei), 5); |
| 6324 | vc_conn.done; |
| 6325 | } |
| 6326 | |
| 6327 | private function f_tc_lu_imsi_noauth_tmsi_check_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6328 | pars.net.expect_imei := true; |
| 6329 | f_init_handler(pars); |
| 6330 | f_perform_lu(); |
| 6331 | } |
| 6332 | testcase TC_lu_imsi_noauth_tmsi_check_imei() runs on MTC_CT { |
| 6333 | var BSC_ConnHdlr vc_conn; |
| 6334 | f_init(); |
| 6335 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6336 | |
| 6337 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_tmsi_check_imei), 5); |
| 6338 | vc_conn.done; |
| 6339 | } |
| 6340 | |
| 6341 | private function f_tc_lu_imsi_noauth_notmsi_check_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6342 | pars.net.expect_tmsi := false; |
| 6343 | pars.net.expect_imei := true; |
| 6344 | f_init_handler(pars); |
| 6345 | f_perform_lu(); |
| 6346 | } |
| 6347 | testcase TC_lu_imsi_noauth_notmsi_check_imei() runs on MTC_CT { |
| 6348 | var BSC_ConnHdlr vc_conn; |
| 6349 | f_init(); |
| 6350 | f_vty_config(MSCVTY, "msc", "no assign-tmsi"); |
| 6351 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6352 | |
| 6353 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_notmsi_check_imei), 5); |
| 6354 | vc_conn.done; |
| 6355 | } |
| 6356 | |
| 6357 | private function f_tc_lu_imsi_auth_tmsi_check_imei_nack(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6358 | var PDU_ML3_MS_NW l3_lu; |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6359 | |
| 6360 | pars.net.expect_auth := true; |
| 6361 | pars.net.expect_imei := true; |
| 6362 | pars.net.check_imei_result := OSMO_GSUP_IMEI_RESULT_NACK; |
| 6363 | f_init_handler(pars); |
| 6364 | |
| 6365 | /* Cannot use f_perform_lu() as we expect a reject */ |
| 6366 | l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 6367 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6368 | f_bssap_compl_l3(l3_lu); |
| 6369 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 6370 | |
| 6371 | f_mm_common(); |
| 6372 | f_msc_lu_hlr(); |
| 6373 | f_mm_imei(); |
Oliver Smith | 91bfa1c | 2019-07-19 15:01:15 +0200 | [diff] [blame] | 6374 | f_expect_lu_reject(); |
Oliver Smith | 690d60f | 2019-07-23 13:09:08 +0200 | [diff] [blame] | 6375 | f_expect_clear(); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6376 | } |
| 6377 | testcase TC_lu_imsi_auth_tmsi_check_imei_nack() runs on MTC_CT { |
| 6378 | var BSC_ConnHdlr vc_conn; |
| 6379 | f_init(); |
| 6380 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6381 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6382 | |
| 6383 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_nack), 5); |
| 6384 | vc_conn.done; |
| 6385 | } |
| 6386 | |
| 6387 | private function f_tc_lu_imsi_auth_tmsi_check_imei_err(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6388 | var PDU_ML3_MS_NW l3_lu; |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6389 | |
| 6390 | pars.net.expect_auth := true; |
| 6391 | pars.net.expect_imei := true; |
| 6392 | pars.net.check_imei_error := true; |
| 6393 | f_init_handler(pars); |
| 6394 | |
| 6395 | /* Cannot use f_perform_lu() as we expect a reject */ |
| 6396 | l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 6397 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6398 | f_bssap_compl_l3(l3_lu); |
| 6399 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 6400 | |
| 6401 | f_mm_common(); |
| 6402 | f_msc_lu_hlr(); |
| 6403 | f_mm_imei(); |
Oliver Smith | 91bfa1c | 2019-07-19 15:01:15 +0200 | [diff] [blame] | 6404 | f_expect_lu_reject(); |
Oliver Smith | 690d60f | 2019-07-23 13:09:08 +0200 | [diff] [blame] | 6405 | f_expect_clear(); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6406 | } |
| 6407 | testcase TC_lu_imsi_auth_tmsi_check_imei_err() runs on MTC_CT { |
| 6408 | var BSC_ConnHdlr vc_conn; |
| 6409 | f_init(); |
| 6410 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6411 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6412 | |
| 6413 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_err), 5); |
| 6414 | vc_conn.done; |
| 6415 | } |
| 6416 | |
| 6417 | private function f_tc_lu_imsi_auth_tmsi_check_imei_early(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6418 | pars.net.expect_auth := true; |
| 6419 | pars.net.expect_imei_early := true; |
| 6420 | f_init_handler(pars); |
| 6421 | f_perform_lu(); |
| 6422 | } |
| 6423 | testcase TC_lu_imsi_auth_tmsi_check_imei_early() runs on MTC_CT { |
| 6424 | var BSC_ConnHdlr vc_conn; |
| 6425 | f_init(); |
| 6426 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6427 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6428 | |
| 6429 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_early), 5); |
| 6430 | vc_conn.done; |
| 6431 | } |
| 6432 | |
| 6433 | private function f_tc_lu_imsi_auth3g_tmsi_check_imei_early(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6434 | pars.net.expect_auth := true; |
| 6435 | pars.use_umts_aka := true; |
| 6436 | pars.net.expect_imei_early := true; |
| 6437 | f_init_handler(pars); |
| 6438 | f_perform_lu(); |
| 6439 | } |
| 6440 | testcase TC_lu_imsi_auth3g_tmsi_check_imei_early() runs on MTC_CT { |
| 6441 | var BSC_ConnHdlr vc_conn; |
| 6442 | f_init(); |
| 6443 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6444 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6445 | |
| 6446 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth3g_tmsi_check_imei_early), 5); |
| 6447 | vc_conn.done; |
| 6448 | } |
| 6449 | |
| 6450 | private function f_tc_lu_imsi_noauth_tmsi_check_imei_early(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6451 | pars.net.expect_imei_early := true; |
| 6452 | f_init_handler(pars); |
| 6453 | f_perform_lu(); |
| 6454 | } |
| 6455 | testcase TC_lu_imsi_noauth_tmsi_check_imei_early() runs on MTC_CT { |
| 6456 | var BSC_ConnHdlr vc_conn; |
| 6457 | f_init(); |
| 6458 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6459 | |
| 6460 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_tmsi_check_imei_early), 5); |
| 6461 | vc_conn.done; |
| 6462 | } |
| 6463 | |
| 6464 | private function f_tc_lu_imsi_noauth_notmsi_check_imei_early(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6465 | pars.net.expect_tmsi := false; |
| 6466 | pars.net.expect_imei_early := true; |
| 6467 | f_init_handler(pars); |
| 6468 | f_perform_lu(); |
| 6469 | } |
| 6470 | testcase TC_lu_imsi_noauth_notmsi_check_imei_early() runs on MTC_CT { |
| 6471 | var BSC_ConnHdlr vc_conn; |
| 6472 | f_init(); |
| 6473 | f_vty_config(MSCVTY, "msc", "no assign-tmsi"); |
| 6474 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6475 | |
| 6476 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_notmsi_check_imei_early), 5); |
| 6477 | vc_conn.done; |
| 6478 | } |
| 6479 | |
| 6480 | private function f_tc_lu_imsi_auth_tmsi_check_imei_early_nack(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6481 | var PDU_ML3_MS_NW l3_lu; |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6482 | |
| 6483 | pars.net.expect_auth := true; |
| 6484 | pars.net.expect_imei_early := true; |
| 6485 | pars.net.check_imei_result := OSMO_GSUP_IMEI_RESULT_NACK; |
| 6486 | f_init_handler(pars); |
| 6487 | |
| 6488 | /* Cannot use f_perform_lu() as we expect a reject */ |
| 6489 | l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 6490 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6491 | f_bssap_compl_l3(l3_lu); |
| 6492 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 6493 | |
| 6494 | f_mm_imei_early(); |
Oliver Smith | 91bfa1c | 2019-07-19 15:01:15 +0200 | [diff] [blame] | 6495 | f_expect_lu_reject(); |
Oliver Smith | 690d60f | 2019-07-23 13:09:08 +0200 | [diff] [blame] | 6496 | f_expect_clear(); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6497 | } |
| 6498 | testcase TC_lu_imsi_auth_tmsi_check_imei_early_nack() runs on MTC_CT { |
| 6499 | var BSC_ConnHdlr vc_conn; |
| 6500 | f_init(); |
| 6501 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6502 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6503 | |
| 6504 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_early_nack), 5); |
| 6505 | vc_conn.done; |
| 6506 | } |
| 6507 | |
| 6508 | private function f_tc_lu_imsi_auth_tmsi_check_imei_early_err(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6509 | var PDU_ML3_MS_NW l3_lu; |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6510 | |
| 6511 | pars.net.expect_auth := true; |
| 6512 | pars.net.expect_imei_early := true; |
| 6513 | pars.net.check_imei_error := true; |
| 6514 | f_init_handler(pars); |
| 6515 | |
| 6516 | /* Cannot use f_perform_lu() as we expect a reject */ |
| 6517 | l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 6518 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6519 | f_bssap_compl_l3(l3_lu); |
| 6520 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 6521 | |
| 6522 | f_mm_imei_early(); |
Oliver Smith | 91bfa1c | 2019-07-19 15:01:15 +0200 | [diff] [blame] | 6523 | f_expect_lu_reject(); |
Oliver Smith | 690d60f | 2019-07-23 13:09:08 +0200 | [diff] [blame] | 6524 | f_expect_clear(); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6525 | } |
| 6526 | testcase TC_lu_imsi_auth_tmsi_check_imei_early_err() runs on MTC_CT { |
| 6527 | var BSC_ConnHdlr vc_conn; |
| 6528 | f_init(); |
| 6529 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6530 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6531 | |
| 6532 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_early_err), 5); |
| 6533 | vc_conn.done; |
| 6534 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6535 | |
Neels Hofmeyr | 8df6962 | 2019-11-02 19:16:03 +0100 | [diff] [blame] | 6536 | friend function f_tc_invalid_mgcp_crash(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6537 | f_init_handler(pars); |
| 6538 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 6539 | |
| 6540 | /* Set invalid IP address so that osmo-msc discards the rtp_stream and MGCP endpoint FSM instances in the middle |
| 6541 | * of successful MGCP response dispatch. If things aren't safeguarded, the on_success() in osmo_mgcpc_ep_fsm |
| 6542 | * will cause a use-after-free after that event dispatch. */ |
| 6543 | cpars.mgw_conn_1.mgw_rtp_ip := "0.0.0.0"; |
| 6544 | cpars.mgw_conn_2.mgw_rtp_ip := "0.0.0.0"; |
| 6545 | cpars.rtp_sdp_format := "FOO/8000"; |
| 6546 | cpars.expect_release := true; |
| 6547 | |
| 6548 | f_perform_lu(); |
| 6549 | f_mo_call_establish(cpars); |
| 6550 | } |
| 6551 | testcase TC_invalid_mgcp_crash() runs on MTC_CT { |
| 6552 | var BSC_ConnHdlr vc_conn; |
| 6553 | f_init(); |
| 6554 | |
| 6555 | vc_conn := f_start_handler(refers(f_tc_invalid_mgcp_crash), 7); |
| 6556 | vc_conn.done; |
| 6557 | } |
| 6558 | |
Vadim Yanitskiy | eddebaa | 2019-12-28 17:45:34 +0100 | [diff] [blame] | 6559 | friend function f_tc_mm_id_resp_no_identity(charstring id, BSC_ConnHdlrPars pars) |
| 6560 | runs on BSC_ConnHdlr { |
| 6561 | pars.tmsi := 'FFFFFFFF'O; |
| 6562 | f_init_handler(pars); |
| 6563 | |
| 6564 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6565 | |
| 6566 | /* Initiate Location Updating using an unknown TMSI */ |
| 6567 | f_bssap_compl_l3(f_build_lu_tmsi(pars.tmsi)); |
| 6568 | |
| 6569 | /* Expect an Identity Request, send response with no identity */ |
| 6570 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req(CM_ID_TYPE_IMSI))); |
| 6571 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp({ |
| 6572 | lengthIndicator := 1, |
| 6573 | mobileIdentityV := { |
| 6574 | typeOfIdentity := '000'B, |
| 6575 | oddEvenInd_identity := { |
| 6576 | no_identity := { |
| 6577 | oddevenIndicator := '0'B, |
| 6578 | fillerDigits := '00000'H |
| 6579 | } |
| 6580 | } |
| 6581 | } |
| 6582 | }))); |
| 6583 | |
| 6584 | f_expect_lu_reject(); |
| 6585 | f_expect_clear(); |
| 6586 | } |
| 6587 | testcase TC_mm_id_resp_no_identity() runs on MTC_CT { |
| 6588 | var BSC_ConnHdlr vc_conn; |
| 6589 | |
| 6590 | f_init(); |
| 6591 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 6592 | 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] | 6593 | vc_conn.done; |
| 6594 | } |
| 6595 | |
Vadim Yanitskiy | 2521906 | 2020-01-21 01:41:33 +0700 | [diff] [blame] | 6596 | /* Verify the case when T3212 expires during Paging procedure, just before the receipt |
| 6597 | * of Paging Response. This used to provoke a NULL-pointer dereference in old versions |
| 6598 | * of OsmoMSC, but apparently the bug has been fixed, and we're safe now. */ |
| 6599 | friend function f_tc_lu_and_expire_while_paging(charstring id, BSC_ConnHdlrPars pars) |
| 6600 | runs on BSC_ConnHdlr { |
| 6601 | var charstring imsi := hex2str(pars.imsi); |
| 6602 | |
| 6603 | f_init_handler(pars); |
| 6604 | |
| 6605 | /* Perform location update */ |
| 6606 | f_perform_lu(); |
| 6607 | |
| 6608 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
| 6609 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6610 | |
| 6611 | /* Initiate paging procedure from the VTY */ |
| 6612 | f_vty_transceive(MSCVTY, "subscriber imsi " & imsi & " paging"); |
| 6613 | f_expect_paging(); |
| 6614 | |
| 6615 | /* Emulate T3212 expiration during paging (we don't want to wait, right?) */ |
| 6616 | f_vty_transceive(MSCVTY, "subscriber imsi " & imsi & " expire"); |
| 6617 | |
| 6618 | /* MS sends PAGING RESPONSE, *old* OsmoMSC crashes here... */ |
| 6619 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 6620 | |
| 6621 | /* The recent OsmoMSC keeps subscriber in its VLR unless the Paging is completed. |
| 6622 | * 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] | 6623 | f_expect_clear(verify_vlr_cell_id := false); |
Vadim Yanitskiy | 2521906 | 2020-01-21 01:41:33 +0700 | [diff] [blame] | 6624 | } |
| 6625 | testcase TC_lu_and_expire_while_paging() runs on MTC_CT { |
| 6626 | var BSC_ConnHdlr vc_conn; |
| 6627 | |
| 6628 | f_init(); |
| 6629 | |
| 6630 | vc_conn := f_start_handler(refers(f_tc_lu_and_expire_while_paging), 7); |
| 6631 | vc_conn.done; |
| 6632 | } |
| 6633 | |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 6634 | control { |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 6635 | execute( TC_cr_before_reset() ); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 6636 | execute( TC_lu_imsi_noauth_tmsi() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 6637 | execute( TC_lu_imsi_noauth_notmsi() ); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 6638 | execute( TC_lu_imsi_reject() ); |
| 6639 | execute( TC_lu_imsi_timeout_gsup() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 6640 | execute( TC_lu_imsi_auth_tmsi() ); |
Harald Welte | 8a397ae | 2019-04-21 22:03:37 +0200 | [diff] [blame] | 6641 | execute( TC_lu_imsi_auth3g_tmsi() ); |
Pau Espin Pedrol | d3d54a9 | 2019-12-17 17:02:54 +0100 | [diff] [blame] | 6642 | execute( TC_lu_imsi_timeout_tmsi_realloc() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 6643 | execute( TC_cmserv_imsi_unknown() ); |
Neels Hofmeyr | 13737fb | 2020-08-19 13:16:14 +0000 | [diff] [blame] | 6644 | execute( TC_cmserv_tmsi_unknown() ); |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 6645 | execute( TC_lu_and_mo_call() ); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 6646 | execute( TC_lu_and_mo_call_ipv6() ); |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 6647 | execute( TC_lu_and_mo_call_sccp_tiar_timeout() ); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 6648 | execute( TC_lu_auth_sai_timeout() ); |
| 6649 | execute( TC_lu_auth_sai_err() ); |
Harald Welte | e1a2f3c | 2018-01-24 17:28:48 +0100 | [diff] [blame] | 6650 | execute( TC_lu_clear_request() ); |
Vadim Yanitskiy | 109e755 | 2021-02-05 05:36:02 +0100 | [diff] [blame] | 6651 | execute( TC_mo_call_clear_request() ); |
| 6652 | execute( TC_mt_call_clear_request() ); |
Harald Welte | e1a2f3c | 2018-01-24 17:28:48 +0100 | [diff] [blame] | 6653 | execute( TC_lu_disconnect() ); |
| 6654 | execute( TC_lu_by_imei() ); |
| 6655 | execute( TC_lu_by_tmsi_noauth_unknown() ); |
Neels Hofmeyr | fc06c73 | 2020-08-19 12:52:28 +0000 | [diff] [blame] | 6656 | execute( TC_attached_imsi_lu_unknown_tmsi() ); |
Harald Welte | e1a2f3c | 2018-01-24 17:28:48 +0100 | [diff] [blame] | 6657 | execute( TC_imsi_detach_by_imsi() ); |
| 6658 | execute( TC_imsi_detach_by_tmsi() ); |
| 6659 | execute( TC_imsi_detach_by_imei() ); |
| 6660 | execute( TC_emerg_call_imei_reject() ); |
| 6661 | execute( TC_emerg_call_imsi() ); |
| 6662 | execute( TC_cm_serv_req_vgcs_reject() ); |
| 6663 | execute( TC_cm_serv_req_vbs_reject() ); |
| 6664 | execute( TC_cm_serv_req_lcs_reject() ); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 6665 | execute( TC_cm_reest_req_reject() ); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 6666 | execute( TC_lu_auth_2G_fail() ); |
| 6667 | execute( TC_lu_imsi_auth_tmsi_encr_13_13() ); |
| 6668 | execute( TC_cl3_no_payload() ); |
| 6669 | execute( TC_cl3_rnd_payload() ); |
Harald Welte | 1852a84 | 2018-01-26 22:53:36 +0100 | [diff] [blame] | 6670 | execute( TC_establish_and_nothing() ); |
| 6671 | execute( TC_mo_setup_and_nothing() ); |
| 6672 | execute( TC_mo_crcx_ran_timeout() ); |
| 6673 | execute( TC_mo_crcx_ran_reject() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 6674 | execute( TC_mt_crcx_ran_reject() ); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 6675 | execute( TC_mo_setup_and_dtmf_dup() ); |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 6676 | execute( TC_mt_t310() ); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 6677 | execute( TC_gsup_cancel() ); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 6678 | execute( TC_lu_imsi_auth_tmsi_encr_1_13() ); |
| 6679 | execute( TC_lu_imsi_auth_tmsi_encr_3_13() ); |
| 6680 | execute( TC_lu_imsi_auth_tmsi_encr_3_1() ); |
Neels Hofmeyr | 29b8da0 | 2018-03-01 18:09:45 +0100 | [diff] [blame] | 6681 | execute( TC_lu_imsi_auth_tmsi_encr_3_1_no_cm() ); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 6682 | execute( TC_lu_imsi_auth_tmsi_encr_13_2() ); |
| 6683 | execute( TC_lu_imsi_auth_tmsi_encr_013_2() ); |
Eric Wild | 26f4a62 | 2021-05-17 15:27:05 +0200 | [diff] [blame] | 6684 | execute( TC_lu_imsi_auth_tmsi_encr_0134_1() ); |
| 6685 | execute( TC_lu_imsi_auth_tmsi_encr_0134_34() ); |
| 6686 | execute( TC_lu_imsi_auth_tmsi_encr_0134_34_no_cm3() ); |
| 6687 | |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 6688 | execute( TC_mo_release_timeout() ); |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 6689 | execute( TC_lu_and_mt_call_no_dlcx_resp() ); |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 6690 | execute( TC_reset_two() ); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 6691 | |
| 6692 | execute( TC_lu_and_mt_call() ); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 6693 | execute( TC_lu_and_mt_call_ipv6() ); |
Neels Hofmeyr | b58d974 | 2019-11-27 18:44:54 +0100 | [diff] [blame] | 6694 | execute( TC_lu_and_mt_call_already_paging() ); |
Pau Espin Pedrol | 9a732a4 | 2020-09-15 15:56:33 +0200 | [diff] [blame] | 6695 | execute( TC_lu_and_mt_call_osmux() ); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 6696 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 6697 | execute( TC_lu_and_mo_sms() ); |
| 6698 | execute( TC_lu_and_mt_sms() ); |
Neels Hofmeyr | b58d974 | 2019-11-27 18:44:54 +0100 | [diff] [blame] | 6699 | execute( TC_lu_and_mt_sms_already_paging() ); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 6700 | execute( TC_lu_and_mt_sms_paging_and_nothing() ); |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 6701 | execute( TC_lu_and_mt_sms_paging_repeated() ); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 6702 | execute( TC_smpp_mo_sms() ); |
Vadim Yanitskiy | 3382076 | 2020-01-15 11:26:07 +0700 | [diff] [blame] | 6703 | execute( TC_smpp_mo_sms_rp_error() ); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 6704 | execute( TC_smpp_mt_sms() ); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 6705 | |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 6706 | execute( TC_gsup_mo_sms() ); |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 6707 | execute( TC_gsup_mo_smma() ); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 6708 | execute( TC_gsup_mt_sms_ack() ); |
| 6709 | execute( TC_gsup_mt_sms_err() ); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 6710 | execute( TC_gsup_mt_sms_rp_mr() ); |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 6711 | execute( TC_gsup_mo_mt_sms_rp_mr() ); |
Vadim Yanitskiy | a2a8a11 | 2019-07-08 20:04:32 +0700 | [diff] [blame] | 6712 | execute( TC_gsup_mt_multi_part_sms() ); |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 6713 | |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 6714 | execute( TC_lu_and_mo_ussd_single_request() ); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 6715 | execute( TC_lu_and_mt_ussd_notification() ); |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 6716 | execute( TC_lu_and_mo_ussd_during_mt_call() ); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 6717 | execute( TC_lu_and_mt_ussd_during_mt_call() ); |
Vadim Yanitskiy | 2daf52d | 2018-06-21 04:19:58 +0700 | [diff] [blame] | 6718 | execute( TC_lu_and_mo_ussd_mo_release() ); |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 6719 | execute( TC_lu_and_ss_session_timeout() ); |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 6720 | |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 6721 | execute( TC_mt_ussd_for_unknown_subscr() ); |
Vadim Yanitskiy | c3c07d4 | 2019-06-17 23:00:44 +0700 | [diff] [blame] | 6722 | execute( TC_mo_ussd_for_unknown_trans() ); |
Vadim Yanitskiy | d612d28 | 2019-06-15 14:46:03 +0700 | [diff] [blame] | 6723 | execute( TC_proc_ss_for_unknown_session() ); |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 6724 | execute( TC_proc_ss_paging_fail() ); |
Vadim Yanitskiy | 29ba8d6 | 2019-06-16 15:19:41 +0700 | [diff] [blame] | 6725 | execute( TC_proc_ss_abort() ); |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 6726 | |
Vadim Yanitskiy | 1c9754d | 2020-01-07 21:56:55 +0100 | [diff] [blame] | 6727 | execute( TC_multi_lu_and_mo_ussd() ); |
| 6728 | execute( TC_multi_lu_and_mt_ussd() ); |
| 6729 | |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 6730 | execute( TC_cipher_complete_with_invalid_cipher() ); |
Stefan Sperling | a2d59c6 | 2018-12-18 16:32:44 +0100 | [diff] [blame] | 6731 | execute( TC_cipher_complete_1_without_cipher() ); |
| 6732 | execute( TC_cipher_complete_3_without_cipher() ); |
| 6733 | execute( TC_cipher_complete_13_without_cipher() ); |
Harald Welte | b2284bd | 2019-05-10 11:30:43 +0200 | [diff] [blame] | 6734 | execute( TC_lu_with_invalid_mcc_mnc() ); |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 6735 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 6736 | execute( TC_sgsap_reset() ); |
| 6737 | execute( TC_sgsap_lu() ); |
| 6738 | execute( TC_sgsap_lu_imsi_reject() ); |
| 6739 | execute( TC_sgsap_lu_and_nothing() ); |
| 6740 | execute( TC_sgsap_expl_imsi_det_eps() ); |
Philipp Maier | fc19f17 | 2019-03-21 11:17:54 +0100 | [diff] [blame] | 6741 | execute( TC_sgsap_impl_imsi_det_eps() ); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 6742 | execute( TC_sgsap_expl_imsi_det_noneps() ); |
Philipp Maier | 5d81270 | 2019-03-21 10:51:26 +0100 | [diff] [blame] | 6743 | execute( TC_sgsap_impl_imsi_det_noneps() ); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 6744 | execute( TC_sgsap_paging_rej() ); |
| 6745 | execute( TC_sgsap_paging_subscr_rej() ); |
| 6746 | execute( TC_sgsap_paging_ue_unr() ); |
| 6747 | execute( TC_sgsap_paging_and_nothing() ); |
| 6748 | execute( TC_sgsap_paging_and_lu() ); |
| 6749 | execute( TC_sgsap_mt_sms() ); |
| 6750 | execute( TC_sgsap_mo_sms() ); |
| 6751 | execute( TC_sgsap_mt_sms_and_nothing() ); |
| 6752 | execute( TC_sgsap_mt_sms_and_reject() ); |
| 6753 | execute( TC_sgsap_unexp_ud() ); |
| 6754 | execute( TC_sgsap_unsol_ud() ); |
| 6755 | execute( TC_bssap_lu_sgsap_lu_and_mt_call() ); |
| 6756 | execute( TC_sgsap_lu_and_mt_call() ); |
Philipp Maier | 628c005 | 2019-04-09 17:36:57 +0200 | [diff] [blame] | 6757 | execute( TC_sgsap_vlr_failure() ); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 6758 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6759 | execute( TC_ho_inter_bsc_unknown_cell() ); |
| 6760 | execute( TC_ho_inter_bsc() ); |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6761 | execute( TC_ho_inter_bsc_a5_1() ); |
| 6762 | execute( TC_ho_inter_bsc_a5_3() ); |
| 6763 | execute( TC_ho_inter_bsc_a5_4() ); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 6764 | execute( TC_ho_inter_bsc_ipv6() ); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6765 | |
| 6766 | execute( TC_ho_inter_msc_out() ); |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6767 | execute( TC_ho_inter_msc_out_a5_1() ); |
| 6768 | execute( TC_ho_inter_msc_out_a5_3() ); |
| 6769 | execute( TC_ho_inter_msc_out_a5_4() ); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 6770 | execute( TC_ho_inter_msc_out_ipv6() ); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6771 | |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6772 | execute( TC_lu_imsi_auth_tmsi_check_imei() ); |
| 6773 | execute( TC_lu_imsi_auth3g_tmsi_check_imei() ); |
| 6774 | execute( TC_lu_imsi_noauth_tmsi_check_imei() ); |
| 6775 | execute( TC_lu_imsi_noauth_notmsi_check_imei() ); |
| 6776 | execute( TC_lu_imsi_auth_tmsi_check_imei_nack() ); |
| 6777 | execute( TC_lu_imsi_auth_tmsi_check_imei_err() ); |
| 6778 | execute( TC_lu_imsi_auth_tmsi_check_imei_early() ); |
| 6779 | execute( TC_lu_imsi_auth3g_tmsi_check_imei_early() ); |
| 6780 | execute( TC_lu_imsi_noauth_tmsi_check_imei_early() ); |
| 6781 | execute( TC_lu_imsi_noauth_notmsi_check_imei_early() ); |
| 6782 | execute( TC_lu_imsi_auth_tmsi_check_imei_early_nack() ); |
| 6783 | execute( TC_lu_imsi_auth_tmsi_check_imei_early_err() ); |
Neels Hofmeyr | 1b3c6e3 | 2018-03-01 17:52:21 +0100 | [diff] [blame] | 6784 | 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] | 6785 | |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 6786 | execute( TC_mo_cc_bssmap_clear() ); |
Neels Hofmeyr | 8df6962 | 2019-11-02 19:16:03 +0100 | [diff] [blame] | 6787 | execute( TC_invalid_mgcp_crash() ); |
Vadim Yanitskiy | eddebaa | 2019-12-28 17:45:34 +0100 | [diff] [blame] | 6788 | execute( TC_mm_id_resp_no_identity() ); |
Vadim Yanitskiy | 2521906 | 2020-01-21 01:41:33 +0700 | [diff] [blame] | 6789 | execute( TC_lu_and_expire_while_paging() ); |
Pau Espin Pedrol | 174fac2 | 2021-02-26 13:20:10 +0100 | [diff] [blame] | 6790 | execute( TC_paging_response_imsi_unknown() ); |
| 6791 | execute( TC_paging_response_tmsi_unknown() ); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 6792 | } |
| 6793 | |
| 6794 | |
| 6795 | } |