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; |
Andreas Eversberg | 1733de3 | 2023-07-27 16:27:05 +0200 | [diff] [blame] | 16 | friend module MSC_Tests_ASCI; |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 17 | |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 18 | import from General_Types all; |
| 19 | import from Osmocom_Types all; |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 20 | import from GSM_Types all; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 21 | |
| 22 | import from M3UA_Types all; |
| 23 | import from M3UA_Emulation all; |
| 24 | |
| 25 | import from MTP3asp_Types all; |
| 26 | import from MTP3asp_PortType all; |
| 27 | |
| 28 | import from SCCPasp_Types all; |
| 29 | import from SCCP_Types all; |
| 30 | import from SCCP_Emulation all; |
| 31 | |
| 32 | import from SCTPasp_Types all; |
| 33 | import from SCTPasp_PortType all; |
| 34 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 35 | import from Osmocom_CTRL_Functions all; |
| 36 | import from Osmocom_CTRL_Types all; |
| 37 | import from Osmocom_CTRL_Adapter all; |
| 38 | |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 39 | import from TELNETasp_PortType all; |
| 40 | import from Osmocom_VTY_Functions all; |
| 41 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 42 | import from MNCC_Emulation all; |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 43 | import from MNCC_Types all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 44 | |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 45 | import from MGCP_Emulation all; |
| 46 | import from MGCP_Types all; |
| 47 | import from MGCP_Templates all; |
| 48 | import from SDP_Types all; |
Pau Espin Pedrol | 1158cc6 | 2024-03-21 17:21:35 +0100 | [diff] [blame] | 49 | import from SDP_Templates all; |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 50 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 51 | import from GSUP_Types all; |
Pau Espin Pedrol | 8f1403a | 2024-01-18 20:08:43 +0100 | [diff] [blame] | 52 | import from GSUP_Templates all; |
| 53 | import from GSUP_Emulation all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 54 | import from IPA_Emulation all; |
| 55 | |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 56 | import from BSSAP_Types all; |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 57 | import from RAN_Adapter all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 58 | import from BSSAP_CodecPort all; |
| 59 | import from BSSMAP_Templates all; |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 60 | import from RAN_Emulation all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 61 | import from BSC_ConnectionHandler all; |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 62 | import from RANAP_Templates all; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 63 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 64 | import from SGsAP_Templates all; |
| 65 | import from SGsAP_Types all; |
| 66 | import from SGsAP_Emulation all; |
| 67 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 68 | import from MobileL3_Types all; |
| 69 | import from MobileL3_CommonIE_Types all; |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 70 | import from MobileL3_SMS_Types all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 71 | import from L3_Templates all; |
Harald Welte | 158a7ca | 2018-02-16 18:11:31 +0100 | [diff] [blame] | 72 | import from L3_Common all; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 73 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 74 | import from SMPP_Types all; |
| 75 | import from SMPP_Templates all; |
| 76 | import from SMPP_Emulation all; |
| 77 | |
Stefan Sperling | c307e68 | 2018-06-14 15:15:46 +0200 | [diff] [blame] | 78 | import from SCCP_Templates all; |
| 79 | |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 80 | import from SS_Types all; |
| 81 | import from SS_Templates all; |
| 82 | import from USSD_Helpers all; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 83 | import from DNS_Helpers all; |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 84 | |
Philipp Maier | 948747b | 2019-04-02 15:22:33 +0200 | [diff] [blame] | 85 | import from TCCConversion_Functions all; |
| 86 | |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 87 | const integer NUM_BSC := 3; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 88 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 89 | /* Needed for SGsAP SMS */ |
| 90 | import from MobileL3_SMS_Types all; |
| 91 | |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 92 | type component MTC_CT extends CTRL_Adapter_CT { |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 93 | var boolean g_initialized := false; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 94 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 95 | var RAN_Adapter g_bssap[NUM_BSC]; |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 96 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 97 | /* no 'adapter_CT' for MNCC or GSUP */ |
| 98 | var MNCC_Emulation_CT vc_MNCC; |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 99 | var MGCP_Emulation_CT vc_MGCP; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 100 | var GSUP_Emulation_CT vc_GSUP; |
| 101 | var IPA_Emulation_CT vc_GSUP_IPA; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 102 | var SMPP_Emulation_CT vc_SMPP; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 103 | var SGsAP_Emulation_CT vc_SGsAP; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 104 | |
| 105 | /* only to get events from IPA underneath GSUP */ |
| 106 | port IPA_CTRL_PT GSUP_IPA_EVENT; |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 107 | /* VTY to MSC */ |
| 108 | port TELNETasp_PT MSCVTY; |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 109 | |
| 110 | /* A port to directly send BSSAP messages. This port is used for |
| 111 | * tests that require low level access to sen arbitrary BSSAP |
| 112 | * messages. Run f_init_bssap_direct() to connect and initialize */ |
| 113 | port BSSAP_CODEC_PT BSSAP_DIRECT; |
| 114 | |
| 115 | /* When BSSAP messages are directly sent, then the connection |
| 116 | * handler is not active, which means that also no guard timer is |
| 117 | * set up. The following timer will serve as a replacement */ |
| 118 | timer Tguard_direct := 60.0; |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 119 | |
| 120 | /* Configure T(tias) over VTY, seconds */ |
| 121 | var integer g_msc_sccp_timer_ias := 7 * 60; |
| 122 | /* Configure T(tiar) over VTY, seconds */ |
| 123 | var integer g_msc_sccp_timer_iar := 15 * 60; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | modulepar { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 127 | /* remote parameters of IUT */ |
| 128 | charstring mp_msc_ip := "127.0.0.1"; |
| 129 | integer mp_msc_ctrl_port := 4255; |
| 130 | integer mp_msc_vty_port := 4254; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 131 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 132 | /* local parameters of emulated HLR */ |
Philipp Maier | 9b690e4 | 2018-12-21 11:50:03 +0100 | [diff] [blame] | 133 | boolean mp_mm_info := false; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 134 | charstring mp_hlr_ip := "127.0.0.1"; |
| 135 | integer mp_hlr_port := 4222; |
Harald Welte | 6126fb0 | 2018-01-27 20:08:24 +0100 | [diff] [blame] | 136 | charstring mp_mgw_ip := "127.0.0.1"; |
| 137 | integer mp_mgw_port := 2427; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 138 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 139 | charstring mp_msc_mncc := "/tmp/mncc"; |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 140 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 141 | integer mp_msc_smpp_port := 2775; |
| 142 | charstring mp_smpp_system_id := "msc_tester"; |
| 143 | charstring mp_smpp_password := "osmocom1"; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 144 | charstring mp_mme_name := "mmec01.mmegi0001.mme.epc.mnc070.mcc901.3gppnetwork.org"; |
| 145 | charstring mp_vlr_name := "vlr.example.net"; |
Eric Wild | 49888a6 | 2022-03-30 03:16:11 +0200 | [diff] [blame] | 146 | integer mp_bssap_reset_retries := 1; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 147 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 148 | RAN_Configurations mp_bssap_cfg := { |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 149 | { |
| 150 | sccp_service_type := "mtp3_itu", |
| 151 | sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" }, |
| 152 | own_pc := 185, |
| 153 | own_ssn := 254, |
| 154 | peer_pc := 187, |
| 155 | peer_ssn := 254, |
| 156 | sio := '83'O, |
| 157 | rctx := 0 |
| 158 | }, |
| 159 | { |
| 160 | sccp_service_type := "mtp3_itu", |
| 161 | sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" }, |
| 162 | own_pc := 186, |
| 163 | own_ssn := 254, |
| 164 | peer_pc := 187, |
| 165 | peer_ssn := 254, |
| 166 | sio := '83'O, |
| 167 | rctx := 1 |
| 168 | } |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 169 | }; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 170 | } |
| 171 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 172 | /* altstep for the global guard timer (only used when BSSAP_DIRECT |
| 173 | * is used for communication */ |
| 174 | private altstep as_Tguard_direct() runs on MTC_CT { |
| 175 | [] Tguard_direct.timeout { |
| 176 | setverdict(fail, "Tguard timeout"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 177 | mtc.stop; |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 178 | } |
| 179 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 180 | |
Neels Hofmeyr | 2ca1ab4 | 2019-03-08 03:45:43 +0100 | [diff] [blame] | 181 | private altstep as_optional_cc_rel(CallParameters cpars, boolean respond := false) runs on BSC_ConnHdlr { |
| 182 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))) { |
| 183 | if (respond) { |
| 184 | var BIT1 tid_remote := '1'B; |
| 185 | if (cpars.mo_call) { |
| 186 | tid_remote := '0'B; |
| 187 | } |
| 188 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_REL_COMPL(cpars.transaction_id, tid_remote))); |
| 189 | } |
| 190 | } |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 191 | } |
| 192 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 193 | function f_init_smpp(charstring id) runs on MTC_CT { |
| 194 | id := id & "-SMPP"; |
| 195 | var EsmePars pars := { |
| 196 | mode := MODE_TRANSCEIVER, |
| 197 | bind := { |
| 198 | system_id := mp_smpp_system_id, |
| 199 | password := mp_smpp_password, |
| 200 | system_type := "MSC_Tests", |
| 201 | interface_version := hex2int('34'H), |
| 202 | addr_ton := unknown, |
| 203 | addr_npi := unknown, |
| 204 | address_range := "" |
| 205 | }, |
| 206 | esme_role := true |
| 207 | } |
| 208 | |
| 209 | vc_SMPP := SMPP_Emulation_CT.create(id); |
| 210 | map(vc_SMPP:SMPP_PORT, system:SMPP_PORT); |
Harald Welte | 4698a4c | 2020-08-18 22:57:52 +0200 | [diff] [blame] | 211 | 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] | 212 | } |
| 213 | |
| 214 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 215 | function f_init_mncc(charstring id) runs on MTC_CT { |
| 216 | id := id & "-MNCC"; |
| 217 | var MnccOps ops := { |
| 218 | create_cb := refers(MNCC_Emulation.ExpectedCreateCallback), |
| 219 | unitdata_cb := refers(MNCC_Emulation.DummyUnitdataCallback) |
| 220 | } |
| 221 | |
| 222 | vc_MNCC := MNCC_Emulation_CT.create(id); |
| 223 | map(vc_MNCC:MNCC, system:MNCC_CODEC_PT); |
| 224 | vc_MNCC.start(MNCC_Emulation.main(ops, id, mp_msc_mncc)); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 225 | } |
| 226 | |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 227 | function f_init_mgcp(charstring id) runs on MTC_CT { |
| 228 | id := id & "-MGCP"; |
| 229 | var MGCPOps ops := { |
| 230 | create_cb := refers(MGCP_Emulation.ExpectedCreateCallback), |
| 231 | unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback) |
| 232 | } |
| 233 | var MGCP_conn_parameters pars := { |
Harald Welte | 6126fb0 | 2018-01-27 20:08:24 +0100 | [diff] [blame] | 234 | callagent_ip := mp_msc_ip, |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 235 | callagent_udp_port := -1, |
Harald Welte | 6126fb0 | 2018-01-27 20:08:24 +0100 | [diff] [blame] | 236 | mgw_ip := mp_mgw_ip, |
Pau Espin Pedrol | 1a026a5 | 2019-06-18 17:21:52 +0200 | [diff] [blame] | 237 | mgw_udp_port := mp_mgw_port, |
| 238 | multi_conn_mode := false |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | vc_MGCP := MGCP_Emulation_CT.create(id); |
| 242 | map(vc_MGCP:MGCP, system:MGCP_CODEC_PT); |
| 243 | vc_MGCP.start(MGCP_Emulation.main(ops, pars, id)); |
| 244 | } |
| 245 | |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 246 | function ForwardUnitdataCallback(PDU_SGsAP msg) |
| 247 | runs on SGsAP_Emulation_CT return template PDU_SGsAP { |
| 248 | SGsAP_CLIENT.send(msg); |
| 249 | return omit; |
| 250 | } |
| 251 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 252 | function f_init_sgsap(charstring id) runs on MTC_CT { |
| 253 | id := id & "-SGsAP"; |
| 254 | var SGsAPOps ops := { |
| 255 | create_cb := refers(SGsAP_Emulation.ExpectedCreateCallback), |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 256 | unitdata_cb := refers(ForwardUnitdataCallback) |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 257 | } |
| 258 | var SGsAP_conn_parameters pars := { |
| 259 | remote_ip := mp_msc_ip, |
| 260 | remote_sctp_port := 29118, |
| 261 | local_ip := "", |
| 262 | local_sctp_port := -1 |
| 263 | } |
| 264 | |
| 265 | vc_SGsAP := SGsAP_Emulation_CT.create(id); |
| 266 | map(vc_SGsAP:SGsAP, system:SGsAP_CODEC_PT); |
| 267 | vc_SGsAP.start(SGsAP_Emulation.main(ops, pars, id)); |
| 268 | } |
| 269 | |
| 270 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 271 | function f_init_gsup(charstring id) runs on MTC_CT { |
| 272 | id := id & "-GSUP"; |
| 273 | var GsupOps ops := { |
| 274 | create_cb := refers(GSUP_Emulation.ExpectedCreateCallback) |
| 275 | } |
| 276 | |
| 277 | vc_GSUP_IPA := IPA_Emulation_CT.create(id & "-IPA"); |
| 278 | vc_GSUP := GSUP_Emulation_CT.create(id); |
| 279 | |
| 280 | map(vc_GSUP_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 281 | connect(vc_GSUP:GSUP, vc_GSUP_IPA:IPA_GSUP_PORT); |
| 282 | /* we use this hack to get events like ASP_IPA_EVENT_UP */ |
| 283 | connect(vc_GSUP_IPA:IPA_CTRL_PORT, self:GSUP_IPA_EVENT); |
| 284 | |
| 285 | vc_GSUP.start(GSUP_Emulation.main(ops, id)); |
| 286 | vc_GSUP_IPA.start(IPA_Emulation.main_server(mp_hlr_ip, mp_hlr_port)); |
| 287 | |
| 288 | /* wait for incoming connection to GSUP port before proceeding */ |
| 289 | timer T := 10.0; |
| 290 | T.start; |
| 291 | alt { |
Vadim Yanitskiy | 61564be | 2020-05-18 20:44:14 +0700 | [diff] [blame] | 292 | [] GSUP_IPA_EVENT.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_UP)) { } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 293 | [] T.timeout { |
Harald Welte | 458fd37 | 2018-03-21 11:26:23 +0100 | [diff] [blame] | 294 | setverdict(fail, "No connection to GSUP Port"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 295 | mtc.stop |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 296 | } |
| 297 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 298 | } |
| 299 | |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 300 | 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] | 301 | |
| 302 | if (g_initialized == true) { |
| 303 | return; |
| 304 | } |
| 305 | g_initialized := true; |
| 306 | |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 307 | if (num_bsc > NUM_BSC) { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 308 | testcase.stop("excess number of BSC instances requested"); |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 309 | } |
| 310 | |
Pau Espin Pedrol | 9a5b8ff | 2021-01-04 19:01:31 +0100 | [diff] [blame] | 311 | f_ipa_ctrl_start_client(mp_msc_ip, mp_msc_ctrl_port); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 312 | |
| 313 | map(self:MSCVTY, system:MSCVTY); |
| 314 | f_vty_set_prompts(MSCVTY); |
| 315 | f_vty_transceive(MSCVTY, "enable"); |
Harald Welte | b14c77a | 2018-01-25 17:25:44 +0100 | [diff] [blame] | 316 | |
| 317 | /* set some defaults */ |
| 318 | f_vty_config(MSCVTY, "network", "authentication optional"); |
| 319 | f_vty_config(MSCVTY, "msc", "assign-tmsi"); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 320 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 0"); |
Harald Welte | b14c77a | 2018-01-25 17:25:44 +0100 | [diff] [blame] | 321 | f_vty_config(MSCVTY, "network", "encryption a5 0"); |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 322 | f_vty_config(MSCVTY, "cs7 instance 0", "sccp-timer ias " & int2str(g_msc_sccp_timer_ias)); |
| 323 | 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] | 324 | if (osmux) { |
| 325 | f_vty_config(MSCVTY, "msc", "osmux on"); |
| 326 | } else { |
| 327 | f_vty_config(MSCVTY, "msc", "osmux off"); |
Pau Espin Pedrol | 3dd33bc | 2019-05-31 17:51:20 +0200 | [diff] [blame] | 328 | } |
Daniel Willmann | 0886215 | 2022-02-22 13:21:49 +0100 | [diff] [blame] | 329 | |
Neels Hofmeyr | c47ce85 | 2023-03-06 17:16:50 +0100 | [diff] [blame] | 330 | /* Configure the MGCP timeout so that a failure to set up all RTP streams triggers within the time that we keep |
| 331 | * an otherwise established call open. */ |
| 332 | f_vty_config(MSCVTY, "msc", "timer mgw X2 3"); |
| 333 | |
Daniel Willmann | 0886215 | 2022-02-22 13:21:49 +0100 | [diff] [blame] | 334 | for (var integer i := 0; i < num_bsc; i := i + 1) { |
| 335 | if (isbound(mp_bssap_cfg[i])) { |
| 336 | var RanOps ranops := BSC_RanOps; |
| 337 | ranops.use_osmux := osmux; |
Eric Wild | 49888a6 | 2022-03-30 03:16:11 +0200 | [diff] [blame] | 338 | ranops.bssap_reset_retries := mp_bssap_reset_retries; |
Daniel Willmann | 0886215 | 2022-02-22 13:21:49 +0100 | [diff] [blame] | 339 | f_ran_adapter_init(g_bssap[i], mp_bssap_cfg[i], "MSC_Test_" & int2str(i), ranops); |
| 340 | f_ran_adapter_start(g_bssap[i]); |
| 341 | } else { |
| 342 | testcase.stop("missing BSSAP configuration"); |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | f_init_mncc("MSC_Test"); |
| 347 | f_init_mgcp("MSC_Test"); |
| 348 | |
| 349 | if (gsup == true) { |
| 350 | f_init_gsup("MSC_Test"); |
| 351 | } |
| 352 | f_init_smpp("MSC_Test"); |
| 353 | |
| 354 | if (sgsap == true) { |
| 355 | f_init_sgsap("MSC_Test"); |
| 356 | } |
| 357 | |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 358 | } |
| 359 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 360 | /* Initialize for a direct connection to BSSAP. This function is an alternative |
| 361 | * to f_init() when the high level functions of the BSC_ConnectionHandler are |
| 362 | * not needed. */ |
| 363 | function f_init_bssap_direct() runs on MTC_CT { |
Harald Welte | 3ca0ce1 | 2019-04-23 17:18:48 +0200 | [diff] [blame] | 364 | 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] | 365 | connect(g_bssap[0].vc_SCCP:SCCP_SP_PORT, self:BSSAP_DIRECT); |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 366 | |
| 367 | /* Start guard timer and activate it as default */ |
| 368 | Tguard_direct.start |
| 369 | activate(as_Tguard_direct()); |
| 370 | } |
| 371 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 372 | 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] | 373 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 374 | /* FIXME: move into BSC_ConnectionHandler? */ |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 375 | 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] | 376 | boolean ran_is_geran := true, boolean use_osmux := false, OCT4 gsup_sid := '20000101'O, |
| 377 | boolean verify_cell_id := true) |
Harald Welte | f9abf8d | 2019-04-21 13:07:17 +0200 | [diff] [blame] | 378 | runs on MTC_CT return BSC_ConnHdlrPars { |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 379 | var BSC_ConnHdlrNetworkPars net_pars := { |
| 380 | kc_support := '0A'O, /* A5/1 and A5/3 enabled */ |
Neels Hofmeyr | e860fc4 | 2022-10-05 01:15:54 +0200 | [diff] [blame] | 381 | net_config := { "authentication optional", "encryption a5 0" }, |
| 382 | expect_attach_success := true, |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 383 | expect_tmsi := true, |
Neels Hofmeyr | e860fc4 | 2022-10-05 01:15:54 +0200 | [diff] [blame] | 384 | expect_auth_attempt := false, |
| 385 | hlr_has_auth_info := true, |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 386 | expect_auth := false, |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 387 | expect_ciph := false, |
| 388 | expect_imei := false, |
| 389 | expect_imei_early := false, |
| 390 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 391 | check_imei_error := false |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 392 | }; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 393 | var BSC_ConnHdlrPars pars := { |
Harald Welte | f9abf8d | 2019-04-21 13:07:17 +0200 | [diff] [blame] | 394 | sccp_addr_own := g_bssap[ran_idx].sccp_addr_own, |
| 395 | sccp_addr_peer := g_bssap[ran_idx].sccp_addr_peer, |
Harald Welte | edbab81 | 2018-03-18 16:02:25 +0100 | [diff] [blame] | 396 | cell_id := valueof(ts_CellId_CGI('262'H, '42'H, 23, 42)), |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 397 | imei := f_gen_imei(imsi_suffix), |
| 398 | imsi := f_gen_imsi(imsi_suffix), |
| 399 | msisdn := f_gen_msisdn(imsi_suffix), |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 400 | tmsi := omit, |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 401 | cm1 := valueof(ts_CM1), |
Harald Welte | 8260057 | 2018-01-21 20:54:08 +0100 | [diff] [blame] | 402 | cm2 := valueof(ts_CM2_default), |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 403 | cm3 := omit, |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 404 | vec := omit, |
Neels Hofmeyr | b00c5b0 | 2021-06-23 20:05:25 +0200 | [diff] [blame] | 405 | vec_keep := false, |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 406 | net := net_pars, |
Philipp Maier | aeb29a8 | 2018-11-08 17:40:53 +0100 | [diff] [blame] | 407 | send_early_cm := true, |
| 408 | ipa_ctrl_ip := mp_msc_ip, |
| 409 | ipa_ctrl_port := mp_msc_ctrl_port, |
Philipp Maier | 9b690e4 | 2018-12-21 11:50:03 +0100 | [diff] [blame] | 410 | ipa_ctrl_enable := true, |
Philipp Maier | 5786548 | 2019-01-07 18:33:13 +0100 | [diff] [blame] | 411 | mm_info := mp_mm_info, |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 412 | sgsap_enable := sgsap, |
Harald Welte | f9abf8d | 2019-04-21 13:07:17 +0200 | [diff] [blame] | 413 | gsup_enable := gsup, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 414 | gsup_sid := gsup_sid, |
Harald Welte | c1f937a | 2019-04-21 21:19:23 +0200 | [diff] [blame] | 415 | ran_idx := ran_idx, |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 416 | use_umts_aka := false, |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 417 | ran_is_geran := ran_is_geran, |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 418 | use_osmux := use_osmux, |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 419 | use_ipv6 := false, |
Oliver Smith | 44424db | 2023-08-22 13:54:09 +0200 | [diff] [blame] | 420 | use_csd := false, |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 421 | verify_cell_id := verify_cell_id, |
| 422 | common_id_last_eutran_plmn := omit |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 423 | }; |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 424 | if (not ran_is_geran) { |
| 425 | pars.use_umts_aka := true; |
| 426 | pars.net.expect_auth := true; |
| 427 | } |
Neels Hofmeyr | 9adaa70 | 2018-03-01 20:23:19 +0100 | [diff] [blame] | 428 | return pars; |
| 429 | } |
| 430 | |
Neels Hofmeyr | e1a1b63 | 2021-07-28 18:05:43 +0200 | [diff] [blame] | 431 | function f_start_handler_create(BSC_ConnHdlrPars pars) runs on MTC_CT return BSC_ConnHdlr { |
Neels Hofmeyr | 9adaa70 | 2018-03-01 20:23:19 +0100 | [diff] [blame] | 432 | var BSC_ConnHdlr vc_conn; |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 433 | var charstring id := testcasename() & int2str(pars.ran_idx); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 434 | |
| 435 | vc_conn := BSC_ConnHdlr.create(id); |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 436 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 437 | /* BSSMAP part / A interface */ |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 438 | connect(vc_conn:BSSAP, g_bssap[pars.ran_idx].vc_RAN:CLIENT); |
| 439 | 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] | 440 | /* MNCC part */ |
| 441 | connect(vc_conn:MNCC, vc_MNCC:MNCC_CLIENT); |
| 442 | connect(vc_conn:MNCC_PROC, vc_MNCC:MNCC_PROC); |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 443 | /* MGCP part */ |
| 444 | connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT); |
| 445 | connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 446 | /* GSUP part */ |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 447 | if (pars.gsup_enable == true) { |
| 448 | connect(vc_conn:GSUP, vc_GSUP:GSUP_CLIENT); |
| 449 | connect(vc_conn:GSUP_PROC, vc_GSUP:GSUP_PROC); |
| 450 | } |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 451 | /* SMPP part */ |
| 452 | connect(vc_conn:SMPP, vc_SMPP:SMPP_CLIENT); |
| 453 | connect(vc_conn:SMPP_PROC, vc_SMPP:SMPP_PROC); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 454 | /* SGs part */ |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 455 | if (pars.sgsap_enable == true) { |
Philipp Maier | 5786548 | 2019-01-07 18:33:13 +0100 | [diff] [blame] | 456 | connect(vc_conn:SGsAP, vc_SGsAP:SGsAP_CLIENT); |
| 457 | connect(vc_conn:SGsAP_PROC, vc_SGsAP:SGsAP_PROC); |
| 458 | } |
Neels Hofmeyr | e1a1b63 | 2021-07-28 18:05:43 +0200 | [diff] [blame] | 459 | return vc_conn; |
| 460 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 461 | |
Neels Hofmeyr | e1a1b63 | 2021-07-28 18:05:43 +0200 | [diff] [blame] | 462 | function f_start_handler_run(BSC_ConnHdlr vc_conn, void_fn fn, BSC_ConnHdlrPars pars) runs on MTC_CT { |
| 463 | var charstring id := testcasename() & int2str(pars.ran_idx); |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 464 | /* We cannot use vc_conn.start(f_init_handler(fn, id, pars)); as we cannot have |
| 465 | * 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] | 466 | vc_conn.start(derefers(fn)(id, pars)); |
Neels Hofmeyr | e1a1b63 | 2021-07-28 18:05:43 +0200 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | function f_start_handler_with_pars(void_fn fn, BSC_ConnHdlrPars pars) runs on MTC_CT return BSC_ConnHdlr { |
| 470 | var BSC_ConnHdlr vc_conn; |
| 471 | vc_conn := f_start_handler_create(pars); |
| 472 | f_start_handler_run(vc_conn, fn, pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 473 | return vc_conn; |
| 474 | } |
| 475 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 476 | function f_start_handler(void_fn fn, integer imsi_suffix, integer ran_idx := 0, boolean ran_is_geran := true, boolean use_osmux := false, |
| 477 | boolean verify_cell_id := true) |
Harald Welte | 9b751a6 | 2019-04-14 17:39:29 +0200 | [diff] [blame] | 478 | runs on MTC_CT return BSC_ConnHdlr { |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 479 | 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] | 480 | } |
| 481 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 482 | 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] | 483 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 484 | f_perform_lu(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 485 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 486 | testcase TC_lu_imsi_noauth_tmsi() runs on MTC_CT { |
| 487 | var BSC_ConnHdlr vc_conn; |
| 488 | f_init(); |
| 489 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 490 | 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] | 491 | vc_conn.done; |
| 492 | } |
| 493 | |
| 494 | 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] | 495 | pars.net.expect_tmsi := false; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 496 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 497 | f_perform_lu(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 498 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 499 | testcase TC_lu_imsi_noauth_notmsi() runs on MTC_CT { |
| 500 | var BSC_ConnHdlr vc_conn; |
| 501 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 502 | f_vty_config(MSCVTY, "msc", "no assign-tmsi"); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 503 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 504 | 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] | 505 | vc_conn.done; |
| 506 | } |
| 507 | |
| 508 | /* 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] | 509 | 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] | 510 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 511 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 512 | |
| 513 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 514 | f_cl3_or_initial_ue(l3_lu); |
Neels Hofmeyr | d076c52 | 2019-11-28 01:00:52 +0100 | [diff] [blame] | 515 | f_mm_common(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 516 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 517 | GSUP.send(ts_GSUP_UL_ERR(g_pars.imsi, 23)); |
| 518 | alt { |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 519 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej(int2oct(23,1)))) { |
| 520 | f_expect_clear(); |
| 521 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 522 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 523 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 524 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 525 | } |
| 526 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 527 | } |
| 528 | testcase TC_lu_imsi_reject() runs on MTC_CT { |
| 529 | var BSC_ConnHdlr vc_conn; |
| 530 | f_init(); |
| 531 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 532 | 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] | 533 | vc_conn.done; |
| 534 | } |
| 535 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 536 | |
| 537 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 538 | /* Do LU by IMSI, timeout on GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 539 | 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] | 540 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 541 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 542 | |
| 543 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 544 | f_cl3_or_initial_ue(l3_lu); |
Neels Hofmeyr | d076c52 | 2019-11-28 01:00:52 +0100 | [diff] [blame] | 545 | f_mm_common(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 546 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 547 | /* Normally the HLR would need to respond here, but we decide to force a timeout here */ |
| 548 | alt { |
| 549 | /* FIXME: Expect specific reject cause */ |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 550 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 551 | f_expect_clear(); |
| 552 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 553 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 554 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 555 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 556 | } |
| 557 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 558 | } |
| 559 | testcase TC_lu_imsi_timeout_gsup() runs on MTC_CT { |
| 560 | var BSC_ConnHdlr vc_conn; |
| 561 | f_init(); |
| 562 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 563 | 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] | 564 | vc_conn.done; |
| 565 | } |
| 566 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 567 | |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 568 | 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] | 569 | pars.net.expect_auth := true; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 570 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 571 | f_perform_lu(); |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 572 | } |
| 573 | testcase TC_lu_imsi_auth_tmsi() runs on MTC_CT { |
| 574 | var BSC_ConnHdlr vc_conn; |
| 575 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 576 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 577 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 578 | 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] | 579 | vc_conn.done; |
| 580 | } |
| 581 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 582 | |
| 583 | 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] | 584 | pars.net.expect_auth := true; |
| 585 | pars.use_umts_aka := true; |
| 586 | f_init_handler(pars); |
| 587 | f_perform_lu(); |
| 588 | } |
| 589 | testcase TC_lu_imsi_auth3g_tmsi() runs on MTC_CT { |
| 590 | var BSC_ConnHdlr vc_conn; |
| 591 | f_init(); |
| 592 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 593 | |
| 594 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth3g_tmsi), 1005); |
| 595 | vc_conn.done; |
| 596 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 597 | |
Pau Espin Pedrol | d3d54a9 | 2019-12-17 17:02:54 +0100 | [diff] [blame] | 598 | /* Proceed with LU but never receive an TMSI Realloc from MS after LU Accept (OS#4337). |
| 599 | * TS 24.008 sec 4.3.1.5 states MSC should simply release all MM connections. |
| 600 | */ |
| 601 | friend function f_tc_lu_imsi_timeout_tmsi_realloc(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 602 | |
| 603 | f_init_handler(pars); |
| 604 | |
| 605 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 606 | var PDU_DTAP_MT dtap_mt; |
| 607 | |
| 608 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 609 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 610 | |
| 611 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 612 | if (g_pars.ran_is_geran) { |
| 613 | f_bssap_compl_l3(l3_lu); |
| 614 | if (g_pars.send_early_cm) { |
| 615 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 616 | } |
| 617 | } else { |
| 618 | f_ranap_initial_ue(l3_lu); |
| 619 | } |
| 620 | |
| 621 | f_mm_imei_early(); |
| 622 | f_mm_common(); |
| 623 | f_msc_lu_hlr(); |
| 624 | f_mm_imei(); |
| 625 | |
| 626 | alt { |
| 627 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) -> value dtap_mt {} |
| 628 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 629 | setverdict(fail, "Expected LU ACK, but received LU REJ"); |
| 630 | mtc.stop; |
| 631 | } |
| 632 | } |
| 633 | |
| 634 | /* currently (due to bug OS#4337), an extra LU reject is received before |
| 635 | terminating the connection. Enabling following line makes the test |
| 636 | pass: */ |
| 637 | //f_expect_lu_reject('16'O); /* Cause: congestion */ |
| 638 | |
| 639 | /* f_expect_lu_reject() already waits for T"-1" (X1, 5 seconds), but give some |
| 640 | extra time to avoid race conditons... */ |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 641 | f_expect_clear(7.0, verify_vlr_cell_id := false); |
Pau Espin Pedrol | d3d54a9 | 2019-12-17 17:02:54 +0100 | [diff] [blame] | 642 | |
| 643 | setverdict(pass); |
| 644 | } |
| 645 | testcase TC_lu_imsi_timeout_tmsi_realloc() runs on MTC_CT { |
| 646 | var BSC_ConnHdlr vc_conn; |
| 647 | f_init(); |
| 648 | |
| 649 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_timeout_tmsi_realloc), 5); |
| 650 | vc_conn.done; |
| 651 | } |
| 652 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 653 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 654 | /* Send CM SERVICE REQ for IMSI that has never performed LU before */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 655 | friend function f_tc_cmserv_imsi_unknown(charstring id, BSC_ConnHdlrPars pars) |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 656 | runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 657 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 658 | |
| 659 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | edbab81 | 2018-03-18 16:02:25 +0100 | [diff] [blame] | 660 | 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] | 661 | 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] | 662 | |
| 663 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 664 | |
| 665 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 666 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | b781799 | 2019-05-09 13:15:39 +0200 | [diff] [blame] | 667 | f_mm_auth(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 668 | |
| 669 | timer T := 10.0; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 670 | T.start; |
| 671 | alt { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 672 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)) { } |
| 673 | //[] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_ACC)) { } |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 674 | [] BSSAP.receive { |
| 675 | setverdict(fail, "Received unexpected BSSAP"); |
| 676 | mtc.stop; |
| 677 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 678 | [] GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)) { |
| 679 | setverdict(fail, "Unexpected GSUP UL REQ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 680 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 681 | } |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 682 | [] T.timeout { |
Neels Hofmeyr | f1c3c21 | 2020-08-19 13:15:32 +0000 | [diff] [blame] | 683 | setverdict(fail, "Timeout waiting for CM SERV REJ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 684 | mtc.stop; |
| 685 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 686 | } |
| 687 | |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 688 | f_expect_clear(); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 689 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 690 | testcase TC_cmserv_imsi_unknown() runs on MTC_CT { |
| 691 | var BSC_ConnHdlr vc_conn; |
| 692 | f_init(); |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 693 | 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] | 694 | vc_conn.done; |
| 695 | } |
| 696 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 697 | |
Neels Hofmeyr | 13737fb | 2020-08-19 13:16:14 +0000 | [diff] [blame] | 698 | /* Send CM SERVICE REQ for TMSI that has never performed LU before */ |
| 699 | friend function f_tc_cmserv_tmsi_unknown(charstring id, BSC_ConnHdlrPars pars) |
| 700 | runs on BSC_ConnHdlr { |
| 701 | f_init_handler(pars); |
| 702 | |
| 703 | var MobileIdentityLV mi := valueof(ts_MI_TMSI_LV('57111111'O)); |
| 704 | var BSSMAP_IE_CellIdentifier cell_id := valueof(ts_CellId_CGI('262'H, '42'H, 23, 42)); |
| 705 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi)); |
| 706 | |
| 707 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 708 | f_cl3_or_initial_ue(l3_info); |
| 709 | f_mm_auth(); |
| 710 | |
| 711 | timer T := 10.0; |
| 712 | T.start; |
| 713 | alt { |
| 714 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)) { } |
| 715 | [] BSSAP.receive { |
| 716 | setverdict(fail, "Received unexpected BSSAP"); |
| 717 | mtc.stop; |
| 718 | } |
| 719 | [] T.timeout { |
| 720 | setverdict(fail, "Timeout waiting for CM SERV REJ"); |
| 721 | mtc.stop; |
| 722 | } |
| 723 | } |
| 724 | |
| 725 | f_expect_clear(); |
| 726 | } |
| 727 | testcase TC_cmserv_tmsi_unknown() runs on MTC_CT { |
| 728 | var BSC_ConnHdlr vc_conn; |
| 729 | f_init(); |
| 730 | vc_conn := f_start_handler(refers(f_tc_cmserv_tmsi_unknown), 57, verify_cell_id := false); |
| 731 | vc_conn.done; |
| 732 | } |
| 733 | |
Neels Hofmeyr | 14d0b13 | 2020-08-19 13:49:05 +0000 | [diff] [blame] | 734 | /* Send Paging Response for IMSI that has never performed LU before */ |
| 735 | friend function f_tc_paging_response_imsi_unknown(charstring id, BSC_ConnHdlrPars pars) |
| 736 | runs on BSC_ConnHdlr { |
| 737 | f_init_handler(pars); |
| 738 | |
| 739 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 740 | var BSSMAP_IE_CellIdentifier cell_id := valueof(ts_CellId_CGI('262'H, '42'H, 23, 42)); |
| 741 | var PDU_ML3_MS_NW l3_info := valueof(ts_PAG_RESP(mi)); |
| 742 | |
| 743 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 744 | f_cl3_or_initial_ue(l3_info); |
| 745 | |
| 746 | /* The Paging Response gets rejected by a direct Clear Command */ |
| 747 | f_expect_clear(); |
| 748 | } |
| 749 | testcase TC_paging_response_imsi_unknown() runs on MTC_CT { |
| 750 | var BSC_ConnHdlr vc_conn; |
| 751 | f_init(); |
| 752 | vc_conn := f_start_handler(refers(f_tc_paging_response_imsi_unknown), 58, verify_cell_id := false); |
| 753 | vc_conn.done; |
| 754 | } |
| 755 | |
| 756 | /* Send Paging Response for TMSI that has never performed LU before */ |
| 757 | friend function f_tc_paging_response_tmsi_unknown(charstring id, BSC_ConnHdlrPars pars) |
| 758 | runs on BSC_ConnHdlr { |
| 759 | f_init_handler(pars); |
| 760 | |
| 761 | var MobileIdentityLV mi := valueof(ts_MI_TMSI_LV('59111111'O)); |
| 762 | var BSSMAP_IE_CellIdentifier cell_id := valueof(ts_CellId_CGI('262'H, '42'H, 23, 42)); |
| 763 | var PDU_ML3_MS_NW l3_info := valueof(ts_PAG_RESP(mi)); |
| 764 | |
| 765 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 766 | f_cl3_or_initial_ue(l3_info); |
| 767 | |
| 768 | /* The Paging Response gets rejected by a direct Clear Command */ |
| 769 | f_expect_clear(); |
| 770 | } |
| 771 | testcase TC_paging_response_tmsi_unknown() runs on MTC_CT { |
| 772 | var BSC_ConnHdlr vc_conn; |
| 773 | f_init(); |
| 774 | vc_conn := f_start_handler(refers(f_tc_paging_response_tmsi_unknown), 59, verify_cell_id := false); |
| 775 | vc_conn.done; |
| 776 | } |
| 777 | |
Neels Hofmeyr | 13737fb | 2020-08-19 13:16:14 +0000 | [diff] [blame] | 778 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 779 | 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] | 780 | f_init_handler(pars); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 781 | var CallParameters cpars := valueof(t_CallParams); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 782 | f_perform_lu(); |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 783 | f_mo_call(cpars); |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 784 | } |
| 785 | testcase TC_lu_and_mo_call() runs on MTC_CT { |
| 786 | var BSC_ConnHdlr vc_conn; |
| 787 | f_init(); |
| 788 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 789 | 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] | 790 | vc_conn.done; |
| 791 | } |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 792 | friend function f_tc_lu_and_mo_call_ipv6(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 793 | f_init_handler(pars); |
| 794 | var CallParameters cpars := valueof(t_CallParams); |
| 795 | cpars.mgw_conn_1.mgw_rtp_ip := "::1"; |
| 796 | cpars.mgw_conn_2.mgw_rtp_ip := "::2"; |
| 797 | cpars.bss_rtp_ip := "::3"; |
| 798 | f_perform_lu(); |
| 799 | f_mo_call(cpars); |
| 800 | } |
| 801 | testcase TC_lu_and_mo_call_ipv6() runs on MTC_CT { |
| 802 | var BSC_ConnHdlr vc_conn; |
| 803 | f_init(); |
| 804 | |
| 805 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_call_ipv6), 7); |
| 806 | vc_conn.done; |
| 807 | } |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 808 | |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 809 | /* Verify T(iar) triggers and releases the channel */ |
| 810 | friend function f_lu_and_mo_call_sccp_tiar_timeout(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 811 | timer T_wait_iar := int2float(5 + 1); /* g_msc_sccp_timer_iar + Give extra time (+1 sec) */ |
| 812 | f_init_handler(pars); |
| 813 | var CallParameters cpars := valueof(t_CallParams); |
| 814 | f_perform_lu(); |
| 815 | f_mo_call_establish(cpars); |
| 816 | |
| 817 | /* Expect the channel cleared upon T(iar) triggered: */ |
| 818 | T_wait_iar.start; |
| 819 | alt { |
| 820 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) { |
| 821 | T_wait_iar.stop |
| 822 | setverdict(pass); |
| 823 | } |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 824 | [] T_wait_iar.timeout { |
| 825 | setverdict(fail, "Timeout waiting for T(iar) triggered SCCP RSLD"); |
| 826 | mtc.stop; |
| 827 | } |
| 828 | } |
Harald Welte | 4a3fa71 | 2020-08-19 08:57:33 +0200 | [diff] [blame] | 829 | /* DLCX for both directions; if we don't do this, we might receive either of the two during |
| 830 | * shutdown causing race conditions */ |
| 831 | MGCP.receive(tr_DLCX(?)); |
| 832 | MGCP.receive(tr_DLCX(?)); |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 833 | |
| 834 | setverdict(pass); |
| 835 | } |
| 836 | testcase TC_lu_and_mo_call_sccp_tiar_timeout() runs on MTC_CT { |
| 837 | var BSC_ConnHdlr vc_conn; |
| 838 | |
| 839 | /* Set T(iar) in MSC low enough that it will trigger before other side |
| 840 | has time to keep alive with a T(ias). Keep recommended ratio of |
| 841 | T(iar) >= T(ias)*2 */ |
| 842 | g_msc_sccp_timer_ias := 2; |
| 843 | g_msc_sccp_timer_iar := 5; |
| 844 | |
| 845 | f_init(); |
| 846 | |
| 847 | vc_conn := f_start_handler(refers(f_lu_and_mo_call_sccp_tiar_timeout), 89); |
| 848 | vc_conn.done; |
| 849 | } |
| 850 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 851 | |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 852 | /* Test LU (with authentication enabled), where HLR times out sending SAI response */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 853 | 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] | 854 | f_init_handler(pars); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 855 | |
| 856 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 857 | var PDU_DTAP_MT dtap_mt; |
| 858 | |
| 859 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 860 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 861 | |
| 862 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 863 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 864 | |
| 865 | /* Send Early Classmark, just for the fun of it */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 866 | if (pars.ran_is_geran) { |
| 867 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 868 | } |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 869 | |
| 870 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 871 | /* The HLR would normally return an auth vector here, but we fail to do so. */ |
| 872 | |
| 873 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 874 | f_expect_clear(); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 875 | } |
| 876 | testcase TC_lu_auth_sai_timeout() runs on MTC_CT { |
| 877 | var BSC_ConnHdlr vc_conn; |
| 878 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 879 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 880 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 881 | 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] | 882 | vc_conn.done; |
| 883 | } |
| 884 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 885 | |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 886 | /* Test LU (with authentication enabled), where HLR rejects sending SAI error */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 887 | 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] | 888 | f_init_handler(pars); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 889 | |
| 890 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 891 | var PDU_DTAP_MT dtap_mt; |
| 892 | |
| 893 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 894 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 895 | |
| 896 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 897 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 898 | |
| 899 | /* Send Early Classmark, just for the fun of it */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 900 | if (pars.ran_is_geran) { |
| 901 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 902 | } |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 903 | |
| 904 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 905 | GSUP.send(ts_GSUP_SAI_ERR(g_pars.imsi, 13)); |
| 906 | |
| 907 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 908 | f_expect_clear(); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 909 | } |
| 910 | testcase TC_lu_auth_sai_err() runs on MTC_CT { |
| 911 | var BSC_ConnHdlr vc_conn; |
| 912 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 913 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 914 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 915 | 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] | 916 | vc_conn.done; |
| 917 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 918 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 919 | |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 920 | /* Test LU but BSC will send a clear request in the middle */ |
| 921 | 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] | 922 | f_init_handler(pars); |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 923 | |
| 924 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 925 | var PDU_DTAP_MT dtap_mt; |
| 926 | |
| 927 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 928 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 929 | |
| 930 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 931 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 79f1e45 | 2020-08-18 22:55:02 +0200 | [diff] [blame] | 932 | f_expect_common_id(); |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 933 | |
| 934 | /* Send Early Classmark, just for the fun of it */ |
| 935 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 936 | |
| 937 | f_sleep(1.0); |
| 938 | /* send clear request in the middle of the LU */ |
| 939 | BSSAP.send(ts_BSSMAP_ClearRequest(0)); |
Neels Hofmeyr | 2b326fa | 2018-04-06 00:59:36 +0200 | [diff] [blame] | 940 | alt { |
| 941 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { repeat; } |
| 942 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) {} |
| 943 | } |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 944 | BSSAP.send(ts_BSSMAP_ClearComplete); |
Harald Welte | 89a3249 | 2018-01-27 19:07:28 +0100 | [diff] [blame] | 945 | alt { |
| 946 | /* See https://osmocom.org/issues/2862 */ |
Neels Hofmeyr | 2b326fa | 2018-04-06 00:59:36 +0200 | [diff] [blame] | 947 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 948 | setverdict(fail, "Got a second Clear Command, only one expected"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 949 | mtc.stop; |
Neels Hofmeyr | 2b326fa | 2018-04-06 00:59:36 +0200 | [diff] [blame] | 950 | repeat; |
| 951 | } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 952 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
Harald Welte | 89a3249 | 2018-01-27 19:07:28 +0100 | [diff] [blame] | 953 | } |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 954 | setverdict(pass); |
| 955 | } |
| 956 | testcase TC_lu_clear_request() runs on MTC_CT { |
| 957 | var BSC_ConnHdlr vc_conn; |
| 958 | f_init(); |
| 959 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 960 | vc_conn := f_start_handler(refers(f_tc_lu_clear_request), 10); |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 961 | vc_conn.done; |
| 962 | } |
| 963 | |
Vadim Yanitskiy | 109e755 | 2021-02-05 05:36:02 +0100 | [diff] [blame] | 964 | /* Test reaction on Clear Request during a MO Call */ |
| 965 | friend function f_TC_mo_mt_call_clear_request(charstring id, BSC_ConnHdlrPars pars) |
| 966 | runs on BSC_ConnHdlr { |
| 967 | var CallParameters cpars := valueof(t_CallParams); |
| 968 | var MNCC_PDU mncc_pdu; |
| 969 | timer T := 2.0; |
| 970 | |
| 971 | f_init_handler(pars); |
| 972 | |
| 973 | f_perform_lu(); |
| 974 | |
| 975 | /* HACK: reducing code duplication ('66'H - MO, '68'H - MT) */ |
| 976 | if (pars.imsi == '262420002532766'H) |
| 977 | { f_mo_call_establish(cpars); } |
| 978 | else |
| 979 | { f_mt_call_establish(cpars); } |
| 980 | |
| 981 | /* Hold the line for a while... */ |
| 982 | f_sleep(2.0); |
| 983 | |
| 984 | /* BSC sends BSSMAP Clear Request (e.g. due to RR failure) */ |
| 985 | BSSAP.send(ts_BSSMAP_ClearRequest(1)); |
| 986 | |
| 987 | /* Expect (optional) CC RELEASE and Clear Command */ |
| 988 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
| 989 | f_expect_clear(); |
| 990 | deactivate(ccrel); |
| 991 | |
| 992 | /* Expect RELease indication on the MNCC socket */ |
| 993 | T.start; |
| 994 | alt { |
| 995 | [] MNCC.receive(tr_MNCC_REL_ind(cpars.mncc_callref)) -> value mncc_pdu { |
| 996 | log("Rx MNCC REL.ind, cause := ", mncc_pdu.u.signal.cause); |
| 997 | setverdict(pass); |
| 998 | } |
| 999 | [] MNCC.receive(MNCC_PDU:?) -> value mncc_pdu { |
| 1000 | setverdict(fail, "Rx unexpected MNCC PDU: ", mncc_pdu); |
| 1001 | } |
| 1002 | [] T.timeout { |
| 1003 | setverdict(fail, "Timeout waiting for MNCC REL.ind"); |
| 1004 | } |
| 1005 | } |
| 1006 | } |
| 1007 | testcase TC_mo_call_clear_request() runs on MTC_CT { |
| 1008 | var BSC_ConnHdlr vc_conn; |
| 1009 | |
| 1010 | f_init(); |
| 1011 | |
| 1012 | vc_conn := f_start_handler(refers(f_TC_mo_mt_call_clear_request), 2532766); // '66'H - MO |
| 1013 | vc_conn.done; |
| 1014 | } |
| 1015 | testcase TC_mt_call_clear_request() runs on MTC_CT { |
| 1016 | var BSC_ConnHdlr vc_conn; |
| 1017 | |
| 1018 | f_init(); |
| 1019 | |
| 1020 | vc_conn := f_start_handler(refers(f_TC_mo_mt_call_clear_request), 2532768); // '68'H - MT |
| 1021 | vc_conn.done; |
| 1022 | } |
| 1023 | |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1024 | /* Test LU but BSC will send a clear request in the middle */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1025 | 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] | 1026 | f_init_handler(pars); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1027 | |
| 1028 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 1029 | var PDU_DTAP_MT dtap_mt; |
| 1030 | |
| 1031 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1032 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1033 | |
| 1034 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1035 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1036 | |
| 1037 | /* Send Early Classmark, just for the fun of it */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1038 | if (pars.ran_is_geran) { |
| 1039 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1040 | } |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1041 | |
| 1042 | f_sleep(1.0); |
| 1043 | /* send clear request in the middle of the LU */ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1044 | BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1045 | setverdict(pass); |
Neels Hofmeyr | bb825c9 | 2019-03-06 15:35:50 +0100 | [diff] [blame] | 1046 | f_sleep(1.0); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1047 | } |
| 1048 | testcase TC_lu_disconnect() runs on MTC_CT { |
| 1049 | var BSC_ConnHdlr vc_conn; |
| 1050 | f_init(); |
| 1051 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1052 | vc_conn := f_start_handler(refers(f_tc_lu_disconnect), 11); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 1053 | vc_conn.done; |
| 1054 | } |
| 1055 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1056 | /* Test LU but with illegal mobile identity type = IMEI */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1057 | 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] | 1058 | f_init_handler(pars); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1059 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 1060 | 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] | 1061 | var PDU_DTAP_MT dtap_mt; |
| 1062 | |
| 1063 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1064 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1065 | |
| 1066 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1067 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1068 | |
| 1069 | /* Send Early Classmark, just for the fun of it */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1070 | if (pars.ran_is_geran) { |
| 1071 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1072 | } |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1073 | /* wait for LU reject, ignore any ID REQ */ |
| 1074 | alt { |
| 1075 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { } |
| 1076 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req)) { repeat; } |
| 1077 | } |
| 1078 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1079 | f_expect_clear(); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1080 | } |
| 1081 | testcase TC_lu_by_imei() runs on MTC_CT { |
| 1082 | var BSC_ConnHdlr vc_conn; |
| 1083 | f_init(); |
| 1084 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1085 | 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] | 1086 | vc_conn.done; |
| 1087 | } |
| 1088 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1089 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1090 | /* Test LU by TMSI with unknown TMSI, expect (and answer) ID REQ. */ |
| 1091 | 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] | 1092 | /* We piggyback a test for an MSC crash on overlong IMSI (OS#2864) onto this test. */ |
| 1093 | var hexstring overlong_imsi := '012345789ABCDEF0123456789ABCDEF'H; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1094 | f_init_handler(pars); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1095 | |
| 1096 | var PDU_ML3_MS_NW l3_lu := f_build_lu_tmsi('01020304'O); /* FIXME: Random */ |
| 1097 | var PDU_DTAP_MT dtap_mt; |
| 1098 | |
| 1099 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1100 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1101 | |
| 1102 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1103 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1104 | |
| 1105 | /* Send Early Classmark, just for the fun of it */ |
| 1106 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1107 | |
| 1108 | /* Wait for + respond to ID REQ (IMSI) */ |
Oliver Smith | 3289845 | 2019-07-09 12:32:35 +0200 | [diff] [blame] | 1109 | 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] | 1110 | 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] | 1111 | 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] | 1112 | f_expect_common_id(); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1113 | |
| 1114 | /* Expect MSC to do UpdateLocation to HLR; respond to it */ |
| 1115 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 1116 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 1117 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 1118 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 1119 | |
| 1120 | alt { |
Harald Welte | 7ec4fa8 | 2018-01-27 10:57:40 +0100 | [diff] [blame] | 1121 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 1122 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_TmsiRealloc_Cmpl)); |
| 1123 | } |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1124 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 1125 | setverdict(fail, "Expected LU ACK, but received REJ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1126 | mtc.stop; |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1127 | } |
| 1128 | } |
| 1129 | |
Philipp Maier | 9b690e4 | 2018-12-21 11:50:03 +0100 | [diff] [blame] | 1130 | /* Wait for MM-Information (if enabled) */ |
| 1131 | f_expect_mm_info(); |
| 1132 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1133 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1134 | f_expect_clear(); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 1135 | } |
| 1136 | testcase TC_lu_by_tmsi_noauth_unknown() runs on MTC_CT { |
| 1137 | var BSC_ConnHdlr vc_conn; |
| 1138 | f_init(); |
| 1139 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1140 | 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] | 1141 | vc_conn.done; |
| 1142 | } |
| 1143 | |
Neels Hofmeyr | fc06c73 | 2020-08-19 12:52:28 +0000 | [diff] [blame] | 1144 | /* Test LU by unknown TMSI, while the IMSI is already attached: osmo-msc should switch to the attached vlr_subscr. */ |
| 1145 | private function f_tc_attached_imsi_lu_unknown_tmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1146 | f_init_handler(pars); |
| 1147 | |
| 1148 | var PDU_ML3_MS_NW l3_lu := f_build_lu_tmsi('56111111'O); |
| 1149 | var PDU_DTAP_MT dtap_mt; |
| 1150 | |
| 1151 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1152 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1153 | |
| 1154 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 1155 | f_cl3_or_initial_ue(l3_lu); |
| 1156 | |
| 1157 | /* Send Early Classmark, just for the fun of it */ |
| 1158 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1159 | |
| 1160 | /* Wait for + respond to ID REQ (IMSI) */ |
| 1161 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req(CM_ID_TYPE_IMSI))); |
| 1162 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp_IMSI(g_pars.imsi))); |
| 1163 | f_expect_common_id(); |
| 1164 | |
| 1165 | /* Expect MSC to do UpdateLocation to HLR; respond to it */ |
| 1166 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 1167 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 1168 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 1169 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 1170 | |
| 1171 | alt { |
| 1172 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 1173 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_TmsiRealloc_Cmpl)); |
| 1174 | } |
| 1175 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 1176 | setverdict(fail, "Expected LU ACK, but received REJ"); |
| 1177 | mtc.stop; |
| 1178 | } |
| 1179 | } |
| 1180 | |
| 1181 | /* Wait for MM-Information (if enabled) */ |
| 1182 | f_expect_mm_info(); |
| 1183 | |
| 1184 | /* wait for normal teardown */ |
Eric Wild | 85cc161 | 2022-03-30 01:44:29 +0200 | [diff] [blame] | 1185 | f_expect_clear(verify_vlr_cell_id := false); |
Neels Hofmeyr | fc06c73 | 2020-08-19 12:52:28 +0000 | [diff] [blame] | 1186 | |
| 1187 | /* Now the same IMSI is still attached in the VLR, and a LU with an unknown TMSI reveals the same IMSI only |
| 1188 | * later during ID Response. osmo-msc first creates a new vlr_subscr for the unknown TMSI, and as soon as the |
| 1189 | * IMSI becomes known, must notice that this IMSI is still regarded as attached, and must not create evil twins. |
| 1190 | */ |
| 1191 | |
| 1192 | /* (since the TMSI Reallocation happened, we could do this with exactly the same TMSI as above, but for test |
| 1193 | * readability just use a different one.) */ |
| 1194 | l3_lu := f_build_lu_tmsi('56222222'O); |
| 1195 | f_cl3_or_initial_ue(l3_lu); |
| 1196 | |
| 1197 | /* Wait for + respond to ID REQ (IMSI) */ |
| 1198 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req(CM_ID_TYPE_IMSI))); |
| 1199 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp_IMSI(g_pars.imsi))); |
| 1200 | f_expect_common_id(); |
| 1201 | |
| 1202 | /* Expect MSC to do UpdateLocation to HLR; respond to it */ |
| 1203 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 1204 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 1205 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 1206 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 1207 | |
| 1208 | alt { |
| 1209 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 1210 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_TmsiRealloc_Cmpl)); |
| 1211 | } |
| 1212 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 1213 | setverdict(fail, "Expected LU ACK, but received REJ"); |
| 1214 | mtc.stop; |
| 1215 | } |
| 1216 | } |
| 1217 | |
| 1218 | /* Wait for MM-Information (if enabled) */ |
| 1219 | f_expect_mm_info(); |
| 1220 | |
| 1221 | /* wait for normal teardown */ |
Eric Wild | 85cc161 | 2022-03-30 01:44:29 +0200 | [diff] [blame] | 1222 | f_expect_clear(verify_vlr_cell_id := false); |
Neels Hofmeyr | fc06c73 | 2020-08-19 12:52:28 +0000 | [diff] [blame] | 1223 | } |
| 1224 | testcase TC_attached_imsi_lu_unknown_tmsi() runs on MTC_CT { |
| 1225 | var BSC_ConnHdlr vc_conn; |
| 1226 | f_init(); |
| 1227 | |
| 1228 | vc_conn := f_start_handler(refers(f_tc_attached_imsi_lu_unknown_tmsi), 56); |
| 1229 | vc_conn.done; |
| 1230 | } |
| 1231 | |
Harald Welte | 4d15fa7 | 2020-08-19 08:58:28 +0200 | [diff] [blame] | 1232 | friend function f_imsi_detach_by_imsi() runs on BSC_ConnHdlr { |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1233 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 1234 | |
| 1235 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1236 | 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] | 1237 | |
| 1238 | /* Send Early Classmark, just for the fun of it? */ |
Harald Welte | 4d15fa7 | 2020-08-19 08:58:28 +0200 | [diff] [blame] | 1239 | if (g_pars.ran_is_geran) { |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1240 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1241 | } |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1242 | |
| 1243 | /* wait for normal teardown */ |
Harald Welte | 4d15fa7 | 2020-08-19 08:58:28 +0200 | [diff] [blame] | 1244 | f_expect_clear(verify_vlr_cell_id := false); |
| 1245 | } |
| 1246 | |
| 1247 | |
| 1248 | /* Test IMSI DETACH (MI=IMSI) */ |
| 1249 | friend function f_tc_imsi_detach_by_imsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1250 | f_init_handler(pars); |
| 1251 | |
| 1252 | f_imsi_detach_by_imsi(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1253 | } |
| 1254 | testcase TC_imsi_detach_by_imsi() 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_imsi), 14, 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=TMSI) */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1264 | 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] | 1265 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1266 | |
| 1267 | var MobileIdentityLV mi := valueof(ts_MI_TMSI_LV('01020304'O)); |
| 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_tmsi() 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_tmsi), 15, verify_cell_id := false); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1285 | vc_conn.done; |
| 1286 | } |
| 1287 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1288 | |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1289 | /* Test IMSI DETACH (MI=IMEI), which is illegal */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1290 | 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] | 1291 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1292 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 1293 | var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1294 | |
| 1295 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1296 | 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] | 1297 | |
| 1298 | /* Send Early Classmark, just for the fun of it? */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1299 | if (pars.ran_is_geran) { |
| 1300 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1301 | } |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1302 | |
| 1303 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1304 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1305 | } |
| 1306 | testcase TC_imsi_detach_by_imei() runs on MTC_CT { |
| 1307 | var BSC_ConnHdlr vc_conn; |
| 1308 | f_init(); |
| 1309 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1310 | 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] | 1311 | vc_conn.done; |
| 1312 | } |
| 1313 | |
| 1314 | |
| 1315 | /* helper function for an emergency call. caller passes in mobile identity to use */ |
| 1316 | private function f_emerg_call(MobileIdentityLV mi) runs on BSC_ConnHdlr { |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 1317 | var CallParameters cpars := valueof(t_CallParams('112'H, 0)); |
| 1318 | cpars.emergency := true; |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1319 | |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 1320 | f_mo_call(cpars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1321 | } |
| 1322 | |
| 1323 | /* 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] | 1324 | 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] | 1325 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1326 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 1327 | var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1328 | 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] | 1329 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1330 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ('05'O))); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1331 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1332 | } |
| 1333 | testcase TC_emerg_call_imei_reject() runs on MTC_CT { |
| 1334 | var BSC_ConnHdlr vc_conn; |
| 1335 | f_init(); |
| 1336 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1337 | 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] | 1338 | vc_conn.done; |
| 1339 | } |
| 1340 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1341 | |
Harald Welte | d5b9140 | 2018-01-24 18:48:16 +0100 | [diff] [blame] | 1342 | /* establish an emergency call by IMSI, SIM inserted (and hence IMSI) */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1343 | 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] | 1344 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1345 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1346 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1347 | /* Then issue emergency call identified by IMSI */ |
| 1348 | f_emerg_call(valueof(ts_MI_IMSI_LV(g_pars.imsi))); |
| 1349 | } |
| 1350 | testcase TC_emerg_call_imsi() runs on MTC_CT { |
| 1351 | var BSC_ConnHdlr vc_conn; |
| 1352 | f_init(); |
| 1353 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1354 | vc_conn := f_start_handler(refers(f_tc_emerg_call_imsi), 18); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1355 | vc_conn.done; |
| 1356 | } |
| 1357 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1358 | |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1359 | /* CM Service Request for VGCS -> reject */ |
| 1360 | 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] | 1361 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1362 | |
| 1363 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1364 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1365 | |
| 1366 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1367 | 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] | 1368 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1369 | 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] | 1370 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1371 | } |
| 1372 | testcase TC_cm_serv_req_vgcs_reject() runs on MTC_CT { |
| 1373 | var BSC_ConnHdlr vc_conn; |
| 1374 | f_init(); |
| 1375 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1376 | 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] | 1377 | vc_conn.done; |
| 1378 | } |
| 1379 | |
| 1380 | /* CM Service Request for VBS -> reject */ |
| 1381 | 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] | 1382 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1383 | |
| 1384 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1385 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1386 | |
| 1387 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1388 | 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] | 1389 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1390 | 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] | 1391 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1392 | } |
| 1393 | testcase TC_cm_serv_req_vbs_reject() runs on MTC_CT { |
| 1394 | var BSC_ConnHdlr vc_conn; |
| 1395 | f_init(); |
| 1396 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1397 | 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] | 1398 | vc_conn.done; |
| 1399 | } |
| 1400 | |
| 1401 | /* CM Service Request for LCS -> reject */ |
| 1402 | 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] | 1403 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1404 | |
| 1405 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1406 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1407 | |
| 1408 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1409 | 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] | 1410 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1411 | 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] | 1412 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1413 | } |
| 1414 | testcase TC_cm_serv_req_lcs_reject() runs on MTC_CT { |
| 1415 | var BSC_ConnHdlr vc_conn; |
| 1416 | f_init(); |
| 1417 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1418 | 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] | 1419 | vc_conn.done; |
| 1420 | } |
| 1421 | |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1422 | /* CM Re-Establishment Request */ |
| 1423 | 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] | 1424 | f_init_handler(pars); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1425 | |
| 1426 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1427 | f_perform_lu(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1428 | |
| 1429 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 1430 | 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] | 1431 | f_cl3_or_initial_ue(l3_info); |
Neels Hofmeyr | 49bbb51 | 2021-07-29 22:51:08 +0200 | [diff] [blame] | 1432 | /* Older osmo-msc returns: GSM48_REJECT_SRV_OPT_NOT_SUPPORTED = 32, |
| 1433 | * newer osmo-msc with CM Re-Establish support returns: GSM48_REJECT_CALL_CAN_NOT_BE_IDENTIFIED = 38 */ |
| 1434 | 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] | 1435 | f_expect_clear(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1436 | } |
| 1437 | testcase TC_cm_reest_req_reject() runs on MTC_CT { |
| 1438 | var BSC_ConnHdlr vc_conn; |
| 1439 | f_init(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1440 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1441 | 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] | 1442 | vc_conn.done; |
| 1443 | } |
| 1444 | |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1445 | /* Test LU (with authentication enabled), with wrong response from MS */ |
| 1446 | 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] | 1447 | f_init_handler(pars); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1448 | |
| 1449 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 1450 | |
| 1451 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1452 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1453 | |
| 1454 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1455 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1456 | |
| 1457 | /* Send Early Classmark, just for the fun of it */ |
| 1458 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1459 | |
| 1460 | var AuthVector vec := f_gen_auth_vec_2g(); |
| 1461 | var GSUP_IE auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G(vec.rand, vec.sres, vec.kc)); |
| 1462 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 1463 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
| 1464 | |
| 1465 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_AUTH_REQ(vec.rand))); |
| 1466 | /* Send back wrong auth response */ |
| 1467 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MT_MM_AUTH_RESP_2G('00000000'O))); |
| 1468 | |
| 1469 | /* Expect GSUP AUTH FAIL REP to HLR */ |
| 1470 | GSUP.receive(tr_GSUP_AUTH_FAIL_IND(g_pars.imsi)); |
| 1471 | |
| 1472 | /* Expect LU REJECT with Cause == Illegal MS */ |
| 1473 | 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] | 1474 | f_expect_clear(); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1475 | } |
| 1476 | testcase TC_lu_auth_2G_fail() runs on MTC_CT { |
| 1477 | var BSC_ConnHdlr vc_conn; |
| 1478 | f_init(); |
| 1479 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1480 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1481 | 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] | 1482 | vc_conn.done; |
| 1483 | } |
| 1484 | |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 1485 | /* 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] | 1486 | 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] | 1487 | pars.net.expect_auth := true; |
| 1488 | pars.net.expect_ciph := true; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1489 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1490 | f_perform_lu(); |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 1491 | } |
| 1492 | testcase TC_lu_imsi_auth_tmsi_encr_13_13() runs on MTC_CT { |
| 1493 | var BSC_ConnHdlr vc_conn; |
| 1494 | f_init(); |
| 1495 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 1496 | f_vty_config(MSCVTY, "network", "encryption a5 1 3"); |
| 1497 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1498 | 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] | 1499 | vc_conn.done; |
| 1500 | } |
| 1501 | |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1502 | /* Test Complete L3 without payload */ |
| 1503 | 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] | 1504 | f_init_handler(pars); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1505 | |
| 1506 | /* Send Complete L3 Info with empty L3 frame */ |
| 1507 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own, |
| 1508 | valueof(ts_BSSMAP_ComplL3(g_pars.cell_id, ''O)))); |
| 1509 | |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1510 | timer T := 5.0; |
| 1511 | T.start; |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1512 | alt { |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1513 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1514 | /* Expect LU REJECT with Cause == Illegal MS */ |
Harald Welte | bdb3c45 | 2018-03-18 22:43:06 +0100 | [diff] [blame] | 1515 | [] BSSAP.receive(tr_PDU_DTAP_MT(?)) { repeat; } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1516 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND) { repeat; } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1517 | [] as_clear_cmd_compl_disc(); |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1518 | [] T.timeout { |
Daniel Willmann | 90829d6 | 2018-02-15 17:45:14 +0100 | [diff] [blame] | 1519 | setverdict(fail, "Timeout waiting for ClearCommand or SCCP Release"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1520 | mtc.stop; |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1521 | } |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1522 | } |
| 1523 | setverdict(pass); |
| 1524 | } |
| 1525 | testcase TC_cl3_no_payload() runs on MTC_CT { |
| 1526 | var BSC_ConnHdlr vc_conn; |
| 1527 | f_init(); |
| 1528 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1529 | vc_conn := f_start_handler(refers(f_tc_cl3_no_payload), 25); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1530 | vc_conn.done; |
| 1531 | } |
| 1532 | |
| 1533 | /* Test Complete L3 with random payload */ |
| 1534 | 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] | 1535 | f_init_handler(pars); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1536 | |
Daniel Willmann | aa14a38 | 2018-07-26 08:29:45 +0200 | [diff] [blame] | 1537 | /* length is limited by PDU_BSSAP length field which includes some |
| 1538 | * other fields beside l3info payload. So payl can only be 240 bytes |
| 1539 | * Since rnd() returns values < 1 multiply with 241 |
| 1540 | */ |
| 1541 | var integer len := float2int(rnd() * 241.0); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1542 | var octetstring payl := f_rnd_octstring(len); |
| 1543 | |
| 1544 | /* Send Complete L3 Info with empty L3 frame */ |
| 1545 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own, |
| 1546 | valueof(ts_BSSMAP_ComplL3(g_pars.cell_id, payl)))); |
| 1547 | |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1548 | timer T := 5.0; |
| 1549 | T.start; |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1550 | alt { |
| 1551 | /* Immediate disconnect */ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1552 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1553 | [] BSSAP.receive(tr_PDU_DTAP_MT(?)) { repeat; } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1554 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND) { repeat; } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1555 | [] as_clear_cmd_compl_disc(); |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1556 | [] T.timeout { |
Daniel Willmann | 90829d6 | 2018-02-15 17:45:14 +0100 | [diff] [blame] | 1557 | setverdict(fail, "Timeout waiting for ClearCommand or SCCP Release"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1558 | mtc.stop; |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1559 | } |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1560 | } |
| 1561 | setverdict(pass); |
| 1562 | } |
| 1563 | testcase TC_cl3_rnd_payload() runs on MTC_CT { |
| 1564 | var BSC_ConnHdlr vc_conn; |
| 1565 | f_init(); |
| 1566 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1567 | vc_conn := f_start_handler(refers(f_tc_cl3_rnd_payload), 26); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1568 | vc_conn.done; |
| 1569 | } |
| 1570 | |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1571 | /* Test Complete L3 with random payload */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1572 | 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] | 1573 | f_init_handler(pars); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1574 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1575 | f_perform_lu(); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1576 | |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1577 | f_establish_fully(); |
Daniel Willmann | 898a7e0 | 2018-05-17 12:16:16 +0200 | [diff] [blame] | 1578 | f_expect_clear(10.0); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1579 | } |
| 1580 | testcase TC_establish_and_nothing() runs on MTC_CT { |
| 1581 | var BSC_ConnHdlr vc_conn; |
| 1582 | f_init(); |
| 1583 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1584 | vc_conn := f_start_handler(refers(f_tc_establish_and_nothing), 27); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1585 | vc_conn.done; |
| 1586 | } |
| 1587 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1588 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1589 | /* Test MO Call SETUP with no response from MNCC */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1590 | 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] | 1591 | f_init_handler(pars, 190.0); |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1592 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1593 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1594 | cpars.mgw_conn_2.resp := 0; |
| 1595 | cpars.stop_after_cc_setup := true; |
| 1596 | |
| 1597 | f_vty_config(MSCVTY, "msc", "mncc guard-timeout 20"); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1598 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1599 | f_perform_lu(); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1600 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1601 | f_mo_call_establish(cpars); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1602 | |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 1603 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
| 1604 | |
Philipp Maier | 109e6aa | 2018-10-17 10:53:32 +0200 | [diff] [blame] | 1605 | f_expect_clear(185.0); |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 1606 | |
| 1607 | deactivate(ccrel); |
| 1608 | |
| 1609 | f_sleep(1.0); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1610 | } |
| 1611 | testcase TC_mo_setup_and_nothing() runs on MTC_CT { |
| 1612 | var BSC_ConnHdlr vc_conn; |
| 1613 | f_init(); |
| 1614 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1615 | 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] | 1616 | vc_conn.done; |
| 1617 | } |
| 1618 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1619 | |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1620 | /* Test MO Call with no response to RAN-side CRCX */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1621 | 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] | 1622 | f_init_handler(pars); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1623 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1624 | var MNCC_PDU mncc; |
| 1625 | var MgcpCommand mgcp_cmd; |
| 1626 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1627 | f_perform_lu(); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1628 | /* Do not respond to the second CRCX */ |
| 1629 | cpars.mgw_conn_2.resp := 0; |
| 1630 | f_mo_call_establish(cpars); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1631 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1632 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1633 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1634 | f_expect_clear(60.0); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1635 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1636 | deactivate(ccrel); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1637 | } |
| 1638 | testcase TC_mo_crcx_ran_timeout() runs on MTC_CT { |
| 1639 | var BSC_ConnHdlr vc_conn; |
| 1640 | f_init(); |
| 1641 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1642 | 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] | 1643 | vc_conn.done; |
| 1644 | } |
| 1645 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1646 | |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1647 | /* Test MO Call with reject to RAN-side CRCX */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1648 | 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] | 1649 | f_init_handler(pars); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1650 | |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1651 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1652 | |
| 1653 | /* Respond with error for the first CRCX */ |
| 1654 | cpars.mgw_conn_1.resp := -1; |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1655 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1656 | f_perform_lu(); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1657 | f_mo_call_establish(cpars); |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1658 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 1659 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
| 1660 | f_expect_clear(60.0); |
| 1661 | deactivate(ccrel); |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1662 | } |
| 1663 | testcase TC_mo_crcx_ran_reject() runs on MTC_CT { |
| 1664 | var BSC_ConnHdlr vc_conn; |
| 1665 | f_init(); |
| 1666 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1667 | 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] | 1668 | vc_conn.done; |
| 1669 | } |
| 1670 | |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1671 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1672 | /* helper function to start a MT call: MNCC SETUP; Paging; DChan est.; DTAP SETUP */ |
| 1673 | private function f_mt_call_start(inout CallParameters cpars) runs on BSC_ConnHdlr { |
| 1674 | var MNCC_PDU mncc; |
| 1675 | var MgcpCommand mgcp_cmd; |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1676 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1677 | f_perform_lu(); |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 1678 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1679 | |
| 1680 | /* Allocate call reference and send SETUP via MNCC to MSC */ |
| 1681 | cpars.mncc_callref := f_rnd_int(2147483648); |
| 1682 | MNCC.send(ts_MNCC_SETUP_req(cpars.mncc_callref, hex2str(g_pars.msisdn), |
| 1683 | hex2str(cpars.called_party), hex2str(g_pars.imsi))); |
| 1684 | |
| 1685 | /* MSC->BSC: expect PAGING from MSC */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 1686 | f_expect_paging(); |
| 1687 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1688 | /* MS -> MSC: PAGING RESPONSE */ |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1689 | f_establish_fully(EST_TYPE_PAG_RESP); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1690 | |
| 1691 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1692 | |
| 1693 | /* MSC->MS: SETUP */ |
| 1694 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_SETUP(cpars.transaction_id, *, cpars.called_party))); |
| 1695 | } |
| 1696 | |
| 1697 | /* Test MT Call */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1698 | 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] | 1699 | f_init_handler(pars); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1700 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
| 1701 | var MNCC_PDU mncc; |
| 1702 | var MgcpCommand mgcp_cmd; |
| 1703 | |
| 1704 | f_mt_call_start(cpars); |
| 1705 | |
| 1706 | /* MS->MSC: CALL CONFIRMED */ |
| 1707 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CALL_CONF(cpars.transaction_id))); |
| 1708 | |
| 1709 | MNCC.receive(tr_MNCC_CALL_CONF_ind(cpars.mncc_callref)); |
| 1710 | |
| 1711 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
| 1712 | cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 1713 | |
| 1714 | /* Detect if the received CRCX is a wildcarded CRCX request. If yes, |
| 1715 | * set an endpoint name that fits the pattern. If not, just use the |
| 1716 | * endpoint name from the request */ |
| 1717 | if (match(mgcp_cmd.line.ep, t_MGCP_EP_wildcard)) { |
| 1718 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
| 1719 | } else { |
| 1720 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
| 1721 | } |
| 1722 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1723 | /* Respond to CRCX with error */ |
| 1724 | var MgcpResponse mgcp_rsp := { |
| 1725 | line := { |
| 1726 | code := "542", |
| 1727 | trans_id := mgcp_cmd.line.trans_id, |
| 1728 | string := "FORCED_FAIL" |
| 1729 | }, |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1730 | sdp := omit |
| 1731 | } |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 1732 | var MgcpParameter mgcp_rsp_param := { |
| 1733 | code := "Z", |
| 1734 | val := cpars.mgcp_ep |
| 1735 | }; |
| 1736 | mgcp_rsp.params[0] := mgcp_rsp_param; |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1737 | MGCP.send(mgcp_rsp); |
| 1738 | |
| 1739 | timer T := 30.0; |
| 1740 | T.start; |
| 1741 | alt { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1742 | [] T.timeout { |
| 1743 | setverdict(fail, "Timeout waiting for channel release"); |
| 1744 | mtc.stop; |
| 1745 | } |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1746 | [] MNCC.receive { repeat; } |
| 1747 | [] GSUP.receive { repeat; } |
| 1748 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 1749 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
| 1750 | f_create_mgcp_delete_ep(cpars.mgcp_ep); |
| 1751 | repeat; |
| 1752 | } |
| 1753 | [] MGCP.receive { repeat; } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1754 | [] as_clear_cmd_compl_disc(); |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 1755 | [] as_optional_cc_rel(cpars); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1756 | } |
| 1757 | } |
| 1758 | testcase TC_mt_crcx_ran_reject() runs on MTC_CT { |
| 1759 | var BSC_ConnHdlr vc_conn; |
| 1760 | f_init(); |
| 1761 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1762 | 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] | 1763 | vc_conn.done; |
| 1764 | } |
| 1765 | |
| 1766 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1767 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1768 | /* Test MT Call T310 timer */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1769 | 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] | 1770 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1771 | var MgcpCommand mgcp_cmd; |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1772 | var PDU_BSSAP bssap; |
| 1773 | timer T310; |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1774 | |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1775 | f_init_handler(pars); |
| 1776 | |
Neels Hofmeyr | 0560615 | 2023-03-06 22:42:27 +0100 | [diff] [blame] | 1777 | /* Make sure X2 does not fire in this test. This test does not send a CN RTP port to osmo-msc, which will |
| 1778 | * trigger X2 timeout. We want to test T310, so make X2 significantly longer than T310=30s. */ |
| 1779 | f_vty_config(MSCVTY, "msc", "timer mgw X2 40"); |
| 1780 | |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1781 | /* Initiate a MT call, establish connection */ |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1782 | f_mt_call_start(cpars); |
| 1783 | |
| 1784 | /* MS->MSC: CALL CONFIRMED */ |
| 1785 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CALL_CONF(cpars.transaction_id))); |
| 1786 | MNCC.receive(tr_MNCC_CALL_CONF_ind(cpars.mncc_callref)); |
| 1787 | |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1788 | /* NOTE: MSC is expected to start T310 here */ |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1789 | |
Neels Hofmeyr | d8a4aee | 2022-07-25 22:07:24 +0200 | [diff] [blame] | 1790 | interleave { |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1791 | /* MSC->MGW: CRCX (first) */ |
Neels Hofmeyr | d8a4aee | 2022-07-25 22:07:24 +0200 | [diff] [blame] | 1792 | [] MGCP.receive(tr_CRCX) -> value mgcp_cmd { |
| 1793 | f_handle_crcx(cpars, mgcp_cmd); /* MSC<-MGW: OK */ |
| 1794 | } |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1795 | |
| 1796 | /* BSC->BSC: BSSMAP ASSIGNMENT REQ */ |
Neels Hofmeyr | d8a4aee | 2022-07-25 22:07:24 +0200 | [diff] [blame] | 1797 | [] BSSAP.receive(tr_BSSMAP_AssignmentReq(omit, ?)) -> value bssap { |
| 1798 | BSSAP.send(ts_BSSMAP_AssignmentComplete(omit, |
| 1799 | aoip := f_ts_BSSMAP_IE_AoIP_TLA(cpars.bss_rtp_ip, cpars.bss_rtp_port), |
| 1800 | speechCodec := ts_BSSMAP_IE_SpeechCodec({ ts_CodecFR }))); |
| 1801 | } |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1802 | |
| 1803 | /* MSC->MGW: MDCX */ |
Neels Hofmeyr | d8a4aee | 2022-07-25 22:07:24 +0200 | [diff] [blame] | 1804 | [] MGCP.receive(tr_MDCX) -> value mgcp_cmd { |
| 1805 | MGCP.send(ts_MDCX_ACK(mgcp_cmd.line.trans_id, cpars.mgw_conn_1.mgcp_connection_id, |
| 1806 | sdp := omit)); |
| 1807 | } |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1808 | |
| 1809 | /* MSC->MGW: CRCX (second) */ |
Neels Hofmeyr | d8a4aee | 2022-07-25 22:07:24 +0200 | [diff] [blame] | 1810 | [] MGCP.receive(tr_CRCX) -> value mgcp_cmd { |
| 1811 | f_handle_crcx(cpars, mgcp_cmd); /* MSC<-MGW: OK */ |
Neels Hofmeyr | d8a4aee | 2022-07-25 22:07:24 +0200 | [diff] [blame] | 1812 | } |
Neels Hofmeyr | c29e6dc | 2022-08-09 02:38:10 +0200 | [diff] [blame] | 1813 | |
| 1814 | [] MNCC.receive(tr_MNCC_RTP_CREATE(cpars.mncc_callref)); |
Neels Hofmeyr | d8a4aee | 2022-07-25 22:07:24 +0200 | [diff] [blame] | 1815 | } |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1816 | |
| 1817 | /* Reschedule the guard timeout */ |
| 1818 | g_Tguard.start(30.0 + 10.0); |
| 1819 | |
| 1820 | /* NOTE: the BSC is expected to respond with CC ALERTING at this state, so |
| 1821 | * the MSC would stop T310. However, the idea is to verify T310 expiration |
| 1822 | * here, so grab some popcorn and wait for MNCC DISC.ind. */ |
| 1823 | T310.start(30.0 + 2.0); |
Neels Hofmeyr | e81ef42 | 2022-08-07 14:33:06 +0200 | [diff] [blame] | 1824 | var MNCC_PDU mncc_rx; |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1825 | alt { |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1826 | [] T310.timeout { |
| 1827 | setverdict(fail, "Timeout waiting for MNCC DISC.ind due to T310"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1828 | mtc.stop; |
| 1829 | } |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1830 | [] MNCC.receive(tr_MNCC_DISC_ind(cpars.mncc_callref)) { |
| 1831 | MNCC.send(ts_MNCC_REL_req(cpars.mncc_callref, valueof(ts_MNCC_cause(23)))); |
Neels Hofmeyr | 13eeb55 | 2022-08-07 14:33:37 +0200 | [diff] [blame] | 1832 | log("Rx MNCC DISC.ind, T310.read yields ", T310.read); |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1833 | setverdict(pass); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1834 | } |
Neels Hofmeyr | e81ef42 | 2022-08-07 14:33:06 +0200 | [diff] [blame] | 1835 | [] MNCC.receive(MNCC_PDU:?) -> value mncc_rx { |
| 1836 | log("Rx ", mncc_rx); |
| 1837 | setverdict(fail, "Expected MNCC DISC.ind, got some other MNCC message instead"); |
| 1838 | mtc.stop; |
| 1839 | } |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1840 | } |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1841 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1842 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_DISC(cpars.transaction_id))); |
| 1843 | 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] | 1844 | 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] | 1845 | |
| 1846 | alt { |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1847 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 1848 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 1849 | // FIXME: f_create_mgcp_delete_ep(cpars.mgcp_ep); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1850 | repeat; |
| 1851 | } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1852 | [] as_clear_cmd_compl_disc(); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1853 | } |
| 1854 | } |
| 1855 | testcase TC_mt_t310() runs on MTC_CT { |
| 1856 | var BSC_ConnHdlr vc_conn; |
| 1857 | f_init(); |
| 1858 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1859 | vc_conn := f_start_handler(refers(f_tc_mt_t310), 32); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1860 | vc_conn.done; |
| 1861 | } |
| 1862 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1863 | |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1864 | /* 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] | 1865 | 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] | 1866 | f_init_handler(pars); |
| 1867 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1868 | |
| 1869 | /* Location Update to make subscriber known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1870 | f_perform_lu(); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1871 | |
| 1872 | /* First MO call should succeed */ |
| 1873 | f_mo_call(cpars); |
| 1874 | |
| 1875 | /* Cancel the subscriber in the VLR */ |
| 1876 | GSUP.send(ts_GSUP_CL_REQ(g_pars.imsi, OSMO_GSUP_CANCEL_TYPE_WITHDRAW)); |
| 1877 | alt { |
| 1878 | [] GSUP.receive(tr_GSUP_CL_RES(g_pars.imsi)) { } |
| 1879 | [] GSUP.receive(tr_GSUP_CL_ERR(g_pars.imsi)) { |
| 1880 | setverdict(fail, "Received GSUP Location Cancel Error"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1881 | mtc.stop; |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1882 | } |
| 1883 | } |
| 1884 | |
| 1885 | /* Follow-up transactions should fail */ |
| 1886 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 1887 | 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] | 1888 | f_cl3_or_initial_ue(l3_info); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1889 | alt { |
| 1890 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)) { } |
| 1891 | [] BSSAP.receive { |
| 1892 | setverdict(fail, "Received unexpected BSSAP instead of CM SERV REJ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1893 | mtc.stop; |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1894 | } |
| 1895 | } |
Neels Hofmeyr | 0f7429a | 2019-03-07 22:28:41 +0100 | [diff] [blame] | 1896 | |
| 1897 | f_expect_clear(); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1898 | setverdict(pass); |
| 1899 | } |
| 1900 | testcase TC_gsup_cancel() runs on MTC_CT { |
| 1901 | var BSC_ConnHdlr vc_conn; |
| 1902 | f_init(); |
| 1903 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1904 | 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] | 1905 | vc_conn.done; |
| 1906 | } |
| 1907 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 1908 | |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1909 | /* A5/1 only permitted on network side, and MS capable to do it */ |
| 1910 | private function f_tc_lu_imsi_auth_tmsi_encr_1_13(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1911 | pars.net.expect_auth := true; |
| 1912 | pars.net.expect_ciph := true; |
| 1913 | pars.net.kc_support := '02'O; /* A5/1 only */ |
| 1914 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1915 | f_perform_lu(); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1916 | } |
| 1917 | testcase TC_lu_imsi_auth_tmsi_encr_1_13() runs on MTC_CT { |
| 1918 | var BSC_ConnHdlr vc_conn; |
| 1919 | f_init(); |
| 1920 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1921 | f_vty_config(MSCVTY, "network", "encryption a5 1"); |
| 1922 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1923 | 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] | 1924 | vc_conn.done; |
| 1925 | } |
| 1926 | |
| 1927 | /* A5/3 only permitted on network side, and MS capable to do it */ |
| 1928 | private function f_tc_lu_imsi_auth_tmsi_encr_3_13(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1929 | pars.net.expect_auth := true; |
| 1930 | pars.net.expect_ciph := true; |
| 1931 | pars.net.kc_support := '08'O; /* A5/3 only */ |
| 1932 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1933 | f_perform_lu(); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1934 | } |
| 1935 | testcase TC_lu_imsi_auth_tmsi_encr_3_13() runs on MTC_CT { |
| 1936 | var BSC_ConnHdlr vc_conn; |
| 1937 | f_init(); |
| 1938 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1939 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1940 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1941 | 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] | 1942 | vc_conn.done; |
| 1943 | } |
| 1944 | |
| 1945 | /* A5/3 only permitted on network side, and MS with only A5/1 support */ |
| 1946 | private function f_tc_lu_imsi_auth_tmsi_encr_3_1(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1947 | pars.net.expect_auth := true; |
| 1948 | pars.net.expect_ciph := true; |
| 1949 | pars.net.kc_support := '08'O; /* A5/3 only */ |
| 1950 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 1951 | f_init_handler(pars, 15.0); |
| 1952 | |
| 1953 | /* cannot use f_perform_lu() as we expect a reject */ |
| 1954 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 1955 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 1956 | f_cl3_or_initial_ue(l3_lu); |
Neels Hofmeyr | 29b8da0 | 2018-03-01 18:09:45 +0100 | [diff] [blame] | 1957 | if (pars.send_early_cm) { |
| 1958 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1959 | } else { |
| 1960 | pars.cm1.esind := '0'B; |
| 1961 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1962 | f_mm_auth(); |
| 1963 | alt { |
Daniel Willmann | 52918e5 | 2018-09-20 14:39:09 +0200 | [diff] [blame] | 1964 | [] BSSAP.receive(tr_BSSMAP_ClassmarkReq) { |
| 1965 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1966 | repeat; |
| 1967 | } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1968 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 1969 | f_expect_clear(); |
| 1970 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1971 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?,?)) { |
| 1972 | setverdict(fail, "CipherModeCommand despite no A5 intersection"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1973 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1974 | } |
| 1975 | [] BSSAP.receive { |
Harald Welte | 458fd37 | 2018-03-21 11:26:23 +0100 | [diff] [blame] | 1976 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1977 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1978 | } |
| 1979 | } |
| 1980 | setverdict(pass); |
| 1981 | } |
| 1982 | testcase TC_lu_imsi_auth_tmsi_encr_3_1() runs on MTC_CT { |
| 1983 | var BSC_ConnHdlr vc_conn; |
| 1984 | f_init(); |
| 1985 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1986 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1987 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1988 | 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] | 1989 | vc_conn.done; |
| 1990 | } |
| 1991 | testcase TC_lu_imsi_auth_tmsi_encr_3_1_no_cm() runs on MTC_CT { |
| 1992 | var BSC_ConnHdlrPars pars; |
| 1993 | var BSC_ConnHdlr vc_conn; |
| 1994 | f_init(); |
| 1995 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1996 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1997 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 1998 | pars := f_init_pars(361, verify_cell_id := false); |
Neels Hofmeyr | 29b8da0 | 2018-03-01 18:09:45 +0100 | [diff] [blame] | 1999 | pars.send_early_cm := false; |
| 2000 | 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] | 2001 | vc_conn.done; |
| 2002 | } |
Neels Hofmeyr | 1b3c6e3 | 2018-03-01 17:52:21 +0100 | [diff] [blame] | 2003 | testcase TC_lu_imsi_auth_tmsi_encr_3_1_log_msc_debug() runs on MTC_CT { |
| 2004 | var BSC_ConnHdlr vc_conn; |
| 2005 | f_init(); |
| 2006 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 2007 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 2008 | |
| 2009 | /* Make sure the MSC category is on DEBUG level to trigger the log |
| 2010 | * message that is reported in OS#2947 to trigger the segfault */ |
| 2011 | f_vty_config(MSCVTY, "log stderr", "logging level msc debug"); |
| 2012 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 2013 | 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] | 2014 | vc_conn.done; |
| 2015 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2016 | |
| 2017 | /* A5/1 + A5/3 only permitted on network side, and MS with only A5/2 support */ |
| 2018 | private function f_tc_lu_imsi_auth_tmsi_encr_13_2(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2019 | pars.net.expect_auth := true; |
| 2020 | pars.net.expect_ciph := true; |
| 2021 | pars.net.kc_support := '0A'O; /* A5/1 + A5/3 */ |
| 2022 | pars.cm1.a5_1 := '1'B; |
| 2023 | pars.cm2.a5_1 := '1'B; |
| 2024 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 2025 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '1'B; |
| 2026 | f_init_handler(pars, 15.0); |
| 2027 | |
| 2028 | /* cannot use f_perform_lu() as we expect a reject */ |
| 2029 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 2030 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Harald Welte | dceacc7 | 2019-04-21 20:58:35 +0200 | [diff] [blame] | 2031 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2032 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 2033 | f_mm_auth(); |
| 2034 | alt { |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 2035 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 2036 | f_expect_clear(); |
| 2037 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2038 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?,?)) { |
| 2039 | setverdict(fail, "CipherModeCommand despite no A5 intersection"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2040 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2041 | } |
| 2042 | [] BSSAP.receive { |
Harald Welte | 458fd37 | 2018-03-21 11:26:23 +0100 | [diff] [blame] | 2043 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2044 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2045 | } |
| 2046 | } |
| 2047 | setverdict(pass); |
| 2048 | } |
| 2049 | testcase TC_lu_imsi_auth_tmsi_encr_13_2() runs on MTC_CT { |
| 2050 | var BSC_ConnHdlr vc_conn; |
| 2051 | f_init(); |
| 2052 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 2053 | f_vty_config(MSCVTY, "network", "encryption a5 1 3"); |
| 2054 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 2055 | 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] | 2056 | vc_conn.done; |
| 2057 | } |
| 2058 | |
Eric Wild | 26f4a62 | 2021-05-17 15:27:05 +0200 | [diff] [blame] | 2059 | /* A5/0 + A5/1 + A5/3 + a5/4 only permitted on network side, and MS with only A5/1 support */ |
| 2060 | private function f_tc_lu_imsi_auth_tmsi_encr_0134_1(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2061 | pars.net.expect_auth := true; |
| 2062 | pars.net.expect_ciph := true; |
| 2063 | pars.net.kc_support := '03'O; /* A5/0 + A5/1 */ |
| 2064 | pars.cm1.a5_1 := '0'B; |
| 2065 | pars.cm2.a5_1 := '0'B; |
| 2066 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 2067 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '0'B; |
| 2068 | pars.cm2.classmarkInformationType2_oct5.cm3 := '0'B; |
| 2069 | pars.cm3 := omit; |
| 2070 | pars.use_umts_aka := true; |
| 2071 | |
| 2072 | f_init_handler(pars, 15.0); |
| 2073 | f_perform_lu(); |
| 2074 | } |
| 2075 | testcase TC_lu_imsi_auth_tmsi_encr_0134_1() runs on MTC_CT { |
| 2076 | var BSC_ConnHdlr vc_conn; |
| 2077 | f_init(); |
| 2078 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 2079 | f_vty_config(MSCVTY, "network", "encryption a5 0 1 3 4"); |
| 2080 | |
| 2081 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_0134_1), 39); |
| 2082 | vc_conn.done; |
| 2083 | } |
| 2084 | |
| 2085 | /* A5/0 + A5/1 + A5/3 + a5/4 only permitted on network side, and MS with A5/3 + A5/4 support */ |
| 2086 | private function f_tc_lu_imsi_auth_tmsi_encr_0134_34(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2087 | pars.net.expect_auth := true; |
| 2088 | pars.net.expect_ciph := true; |
| 2089 | pars.net.kc_support := '19'O; /* A5/3 + A5/4 */ |
| 2090 | pars.cm1.a5_1 := '1'B; |
| 2091 | pars.cm2.a5_1 := '1'B; |
| 2092 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '1'B; |
| 2093 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '0'B; |
| 2094 | pars.cm2.classmarkInformationType2_oct5.cm3 := '1'B; |
| 2095 | pars.cm3 := valueof(ts_CM3_default); |
| 2096 | pars.use_umts_aka := true; |
| 2097 | |
| 2098 | f_init_handler(pars, 15.0); |
| 2099 | f_perform_lu(); |
| 2100 | } |
| 2101 | testcase TC_lu_imsi_auth_tmsi_encr_0134_34() runs on MTC_CT { |
| 2102 | var BSC_ConnHdlr vc_conn; |
| 2103 | f_init(); |
| 2104 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 2105 | f_vty_config(MSCVTY, "network", "encryption a5 0 1 3 4"); |
| 2106 | |
| 2107 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_0134_34), 40); |
| 2108 | vc_conn.done; |
| 2109 | } |
| 2110 | |
| 2111 | /* A5/0 + A5/1 + A5/3 + a5/4 only permitted on network side, and MS with A5/3 support but no CM3 */ |
| 2112 | private function f_tc_lu_imsi_auth_tmsi_encr_0134_34_no_cm3(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2113 | pars.net.expect_auth := true; |
| 2114 | pars.net.expect_ciph := true; |
| 2115 | pars.net.kc_support := '19'O; /* A5/3 + A5/4 */ |
| 2116 | pars.cm1.a5_1 := '1'B; |
| 2117 | pars.cm2.a5_1 := '1'B; |
| 2118 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '1'B; |
| 2119 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '0'B; |
| 2120 | pars.cm2.classmarkInformationType2_oct5.cm3 := '0'B; |
| 2121 | pars.cm3 := omit; |
| 2122 | pars.use_umts_aka := true; |
| 2123 | |
| 2124 | f_init_handler(pars, 15.0); |
| 2125 | f_perform_lu(); |
| 2126 | } |
| 2127 | testcase TC_lu_imsi_auth_tmsi_encr_0134_34_no_cm3() runs on MTC_CT { |
| 2128 | var BSC_ConnHdlr vc_conn; |
| 2129 | f_init(); |
| 2130 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 2131 | f_vty_config(MSCVTY, "network", "encryption a5 0 1 3 4"); |
| 2132 | |
| 2133 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_0134_34_no_cm3), 41); |
| 2134 | vc_conn.done; |
| 2135 | } |
| 2136 | |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2137 | /* A5/0 + A5/1 + A5/3 only permitted on network side, and MS with only A5/2 support */ |
| 2138 | private function f_tc_lu_imsi_auth_tmsi_encr_013_2(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2139 | pars.net.expect_auth := true; |
| 2140 | pars.net.expect_ciph := true; |
| 2141 | pars.net.kc_support := '0B'O; /* A5/1 + A5/3 */ |
| 2142 | pars.cm1.a5_1 := '1'B; |
| 2143 | pars.cm2.a5_1 := '1'B; |
| 2144 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 2145 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '1'B; |
| 2146 | f_init_handler(pars, 15.0); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 2147 | f_perform_lu(); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2148 | } |
| 2149 | testcase TC_lu_imsi_auth_tmsi_encr_013_2() runs on MTC_CT { |
| 2150 | var BSC_ConnHdlr vc_conn; |
| 2151 | f_init(); |
| 2152 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 2153 | f_vty_config(MSCVTY, "network", "encryption a5 0 1 3"); |
| 2154 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 2155 | 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] | 2156 | vc_conn.done; |
| 2157 | } |
| 2158 | |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 2159 | /* LU followed by MT call (including paging) */ |
Neels Hofmeyr | 8fe8a90 | 2019-11-03 05:51:03 +0100 | [diff] [blame] | 2160 | 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] | 2161 | f_init_handler(pars); |
Stefan Sperling | 26d57be | 2018-11-12 17:03:26 +0100 | [diff] [blame] | 2162 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 2163 | cpars.use_osmux := pars.use_osmux; |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 2164 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 2165 | f_perform_lu(); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 2166 | f_mt_call(cpars); |
| 2167 | } |
| 2168 | testcase TC_lu_and_mt_call() runs on MTC_CT { |
| 2169 | var BSC_ConnHdlr vc_conn; |
| 2170 | f_init(); |
| 2171 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 2172 | 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] | 2173 | vc_conn.done; |
| 2174 | } |
| 2175 | |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 2176 | testcase TC_lu_and_mt_call_osmux() runs on MTC_CT { |
| 2177 | var BSC_ConnHdlr vc_conn; |
| 2178 | f_init(1, false, true, true); |
Pau Espin Pedrol | a65697d | 2019-05-21 12:54:39 +0200 | [diff] [blame] | 2179 | |
| 2180 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_call), 39, 0, true, true); |
| 2181 | vc_conn.done; |
| 2182 | } |
| 2183 | |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 2184 | /* LU followed by MT call (including paging) */ |
| 2185 | friend function f_tc_lu_and_mt_call_ipv6(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2186 | f_init_handler(pars); |
| 2187 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 2188 | cpars.mgw_conn_1.mgw_rtp_ip := "::1"; |
| 2189 | cpars.mgw_conn_2.mgw_rtp_ip := "::2"; |
| 2190 | cpars.bss_rtp_ip := "::3"; |
Pau Espin Pedrol | 563b3d0 | 2020-09-09 20:19:52 +0200 | [diff] [blame] | 2191 | cpars.mncc_rtp_ip := "::9"; |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 2192 | f_perform_lu(); |
| 2193 | f_mt_call(cpars); |
| 2194 | } |
| 2195 | testcase TC_lu_and_mt_call_ipv6() runs on MTC_CT { |
| 2196 | var BSC_ConnHdlr vc_conn; |
| 2197 | f_init(); |
| 2198 | |
| 2199 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_call_ipv6), 39); |
| 2200 | vc_conn.done; |
| 2201 | } |
| 2202 | |
Neels Hofmeyr | b58d974 | 2019-11-27 18:44:54 +0100 | [diff] [blame] | 2203 | /* MT call while already Paging */ |
| 2204 | friend function f_tc_lu_and_mt_call_already_paging(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2205 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
| 2206 | var SmsParameters spars := valueof(t_SmsPars); |
| 2207 | var OCT4 tmsi; |
| 2208 | |
| 2209 | f_init_handler(pars); |
| 2210 | |
| 2211 | /* Perform location update */ |
| 2212 | f_perform_lu(); |
| 2213 | |
| 2214 | /* register an 'expect' for given IMSI (+TMSI) */ |
| 2215 | if (isvalue(g_pars.tmsi)) { |
| 2216 | tmsi := g_pars.tmsi; |
| 2217 | } else { |
| 2218 | tmsi := 'FFFFFFFF'O; |
| 2219 | } |
| 2220 | f_ran_register_imsi(g_pars.imsi, tmsi); |
| 2221 | |
| 2222 | log("start Paging by an SMS"); |
| 2223 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 2224 | |
| 2225 | /* MSC->BSC: expect PAGING from MSC */ |
| 2226 | f_expect_paging(); |
| 2227 | |
| 2228 | log("MNCC signals MT call, before Paging Response"); |
Oliver Smith | 97dc91f | 2023-05-31 13:53:21 +0200 | [diff] [blame] | 2229 | f_mt_call_initiate(cpars); |
Neels Hofmeyr | b58d974 | 2019-11-27 18:44:54 +0100 | [diff] [blame] | 2230 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
| 2231 | |
| 2232 | f_sleep(0.5); |
| 2233 | log("phone answers Paging, expecting both SMS and MT call to be established"); |
| 2234 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2235 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 2236 | interleave { |
| 2237 | [] BSSAP.receive(f_mt_sms_deliver_pdu(spars)) { |
| 2238 | log("Got SMS-DELIVER"); |
| 2239 | }; |
| 2240 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_SETUP(cpars.transaction_id, *, cpars.called_party))) { |
| 2241 | log("Got CC Setup"); |
| 2242 | }; |
| 2243 | } |
| 2244 | setverdict(pass); |
| 2245 | log("success, tear down"); |
| 2246 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
| 2247 | if (g_pars.ran_is_geran) { |
| 2248 | BSSAP.send(ts_BSSMAP_ClearRequest(0)); |
| 2249 | } else { |
| 2250 | BSSAP.send(ts_RANAP_IuReleaseRequest(ts_RanapCause_om_intervention)); |
| 2251 | } |
| 2252 | f_expect_clear(); |
| 2253 | deactivate(ccrel); |
| 2254 | f_vty_sms_clear(hex2str(g_pars.imsi)); |
| 2255 | } |
| 2256 | testcase TC_lu_and_mt_call_already_paging() runs on MTC_CT { |
| 2257 | var BSC_ConnHdlrPars pars; |
| 2258 | var BSC_ConnHdlr vc_conn; |
| 2259 | f_init(); |
| 2260 | pars := f_init_pars(391); |
| 2261 | vc_conn := f_start_handler_with_pars(refers(f_tc_lu_and_mt_call_already_paging), pars); |
| 2262 | vc_conn.done; |
| 2263 | } |
| 2264 | |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 2265 | /* Test MO Call SETUP with DTMF */ |
| 2266 | private function f_tc_mo_setup_dtmf_dup(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2267 | f_init_handler(pars); |
| 2268 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 2269 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 2270 | f_perform_lu(); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 2271 | f_mo_seq_dtmf_dup(cpars); |
| 2272 | } |
| 2273 | testcase TC_mo_setup_and_dtmf_dup() runs on MTC_CT { |
| 2274 | var BSC_ConnHdlr vc_conn; |
| 2275 | f_init(); |
| 2276 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 2277 | 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] | 2278 | vc_conn.done; |
| 2279 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2280 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 2281 | testcase TC_cr_before_reset() runs on MTC_CT { |
| 2282 | timer T := 4.0; |
| 2283 | var boolean reset_ack_seen := false; |
| 2284 | f_init_bssap_direct(); |
| 2285 | |
Harald Welte | 3ca0ce1 | 2019-04-23 17:18:48 +0200 | [diff] [blame] | 2286 | f_ran_adapter_start(g_bssap[0]); |
Daniel Willmann | 42d1d5b | 2018-08-07 15:18:41 +0200 | [diff] [blame] | 2287 | |
Daniel Willmann | e801896 | 2018-08-21 14:18:00 +0200 | [diff] [blame] | 2288 | f_sleep(3.0); |
| 2289 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 2290 | /* Make a blind connection attemt, to trigger the deadlock condition */ |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 2291 | 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] | 2292 | |
| 2293 | /* Send a BSSMAP reset */ |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 2294 | 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] | 2295 | T.start |
| 2296 | alt { |
| 2297 | [] BSSAP_DIRECT.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_ResetAck)) { |
| 2298 | reset_ack_seen := true; |
| 2299 | repeat; |
| 2300 | } |
| 2301 | |
| 2302 | /* Acknowledge MSC sided reset requests */ |
| 2303 | [] BSSAP_DIRECT.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) { |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 2304 | 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] | 2305 | repeat; |
| 2306 | } |
| 2307 | |
| 2308 | /* Ignore all other messages (e.g CR from the connection request) */ |
| 2309 | [] BSSAP_DIRECT.receive { repeat } |
| 2310 | |
| 2311 | /* If we got no BSSMAP RESET ACK back, then the MSC entered the |
| 2312 | * deadlock situation. The MSC is then unable to respond to any |
| 2313 | * further BSSMAP RESET or any other sort of traffic. */ |
| 2314 | [reset_ack_seen == true] T.timeout { setverdict(pass) } |
| 2315 | [reset_ack_seen == false] T.timeout { |
| 2316 | setverdict(fail, "no BSSMAP RESET ACK seen!"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2317 | mtc.stop; |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 2318 | } |
Pau Espin Pedrol | 7e9178d | 2019-12-17 17:52:17 +0100 | [diff] [blame] | 2319 | } |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 2320 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2321 | |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 2322 | /* 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] | 2323 | 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] | 2324 | f_init_handler(pars); |
| 2325 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 2326 | var MNCC_PDU mncc; |
| 2327 | var MgcpCommand mgcp_cmd; |
| 2328 | |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 2329 | /* Do not respond to the second CRCX */ |
| 2330 | cpars.mgw_conn_2.resp := 0; |
| 2331 | |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 2332 | f_perform_lu(); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 2333 | f_mo_call_establish(cpars); |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 2334 | |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 2335 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 2336 | |
| 2337 | f_expect_clear(60.0); |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 2338 | |
| 2339 | deactivate(ccrel); |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 2340 | } |
| 2341 | testcase TC_mo_release_timeout() runs on MTC_CT { |
| 2342 | var BSC_ConnHdlr vc_conn; |
| 2343 | f_init(); |
| 2344 | |
| 2345 | vc_conn := f_start_handler(refers(f_tc_mo_release_timeout), 40); |
| 2346 | vc_conn.done; |
| 2347 | } |
| 2348 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 2349 | |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 2350 | /* LU followed by MT call (including paging) */ |
| 2351 | private function f_tc_lu_and_mt_call_no_dlcx_resp(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2352 | f_init_handler(pars); |
Stefan Sperling | 26d57be | 2018-11-12 17:03:26 +0100 | [diff] [blame] | 2353 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 2354 | |
| 2355 | /* Intentionally disable the CRCX response */ |
| 2356 | cpars.mgw_drop_dlcx := true; |
| 2357 | |
| 2358 | /* Perform location update and call */ |
| 2359 | f_perform_lu(); |
| 2360 | f_mt_call(cpars); |
| 2361 | } |
| 2362 | testcase TC_lu_and_mt_call_no_dlcx_resp() runs on MTC_CT { |
| 2363 | var BSC_ConnHdlr vc_conn; |
| 2364 | f_init(); |
| 2365 | |
| 2366 | /* Perform an almost normal looking locationupdate + mt-call, but do |
| 2367 | * not respond to the DLCX at the end of the call */ |
| 2368 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_call_no_dlcx_resp), 41); |
| 2369 | vc_conn.done; |
| 2370 | |
| 2371 | /* Wait a guard period until the MGCP layer in the MSC times out, |
| 2372 | * if the MSC is vulnerable to the use-after-free situation that is |
| 2373 | * fixed by I78f1b6a9149488a4ad3f120c1e190a83c07d4b89 then it should |
| 2374 | * segfault now */ |
| 2375 | f_sleep(6.0); |
| 2376 | |
| 2377 | /* Run the init procedures once more. If the MSC has crashed, this |
| 2378 | * this will fail */ |
| 2379 | f_init(); |
| 2380 | } |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 2381 | |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 2382 | /* Two BSSMAP resets from two different BSCs */ |
| 2383 | testcase TC_reset_two() runs on MTC_CT { |
| 2384 | var BSC_ConnHdlr vc_conn; |
| 2385 | f_init(2); |
| 2386 | f_sleep(2.0); |
| 2387 | setverdict(pass); |
| 2388 | } |
| 2389 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2390 | /* Two BSSMAP resets from two different BSCs plus one IuCS RANAP Reset */ |
| 2391 | testcase TC_reset_two_1iu() runs on MTC_CT { |
| 2392 | var BSC_ConnHdlr vc_conn; |
| 2393 | f_init(3); |
| 2394 | f_sleep(2.0); |
| 2395 | setverdict(pass); |
| 2396 | } |
| 2397 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2398 | /*********************************************************************** |
| 2399 | * SMS Testing |
| 2400 | ***********************************************************************/ |
| 2401 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2402 | /* LU followed by MO SMS */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2403 | 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] | 2404 | var SmsParameters spars := valueof(t_SmsPars); |
| 2405 | |
| 2406 | f_init_handler(pars); |
| 2407 | |
| 2408 | /* Perform location update and call */ |
| 2409 | f_perform_lu(); |
| 2410 | |
| 2411 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2412 | |
| 2413 | //spars.exp_rp_err := 96; /* invalid mandatory information */ |
| 2414 | f_mo_sms(spars); |
| 2415 | |
| 2416 | f_expect_clear(); |
| 2417 | } |
| 2418 | testcase TC_lu_and_mo_sms() runs on MTC_CT { |
| 2419 | var BSC_ConnHdlr vc_conn; |
| 2420 | f_init(); |
| 2421 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_sms), 42); |
| 2422 | vc_conn.done; |
| 2423 | } |
| 2424 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2425 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2426 | private function f_vty_sms_send(charstring imsi, charstring msisdn, charstring text) |
Neels Hofmeyr | 6aaeccf | 2019-03-06 15:32:26 +0100 | [diff] [blame] | 2427 | runs on BSC_ConnHdlr { |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2428 | f_vty_transceive(MSCVTY, "subscriber imsi "&imsi&" sms sender msisdn "&msisdn&" send "&text); |
| 2429 | } |
| 2430 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 2431 | /* Remove still pending SMS */ |
| 2432 | private function f_vty_sms_clear(charstring imsi) |
| 2433 | runs on BSC_ConnHdlr { |
| 2434 | f_vty_transceive(MSCVTY, "subscriber imsi " & imsi & " sms delete-all"); |
| 2435 | f_vty_transceive(MSCVTY, "sms-queue clear"); |
| 2436 | } |
| 2437 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2438 | /* LU followed by MT SMS */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2439 | 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] | 2440 | var SmsParameters spars := valueof(t_SmsPars); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2441 | |
| 2442 | f_init_handler(pars); |
| 2443 | |
| 2444 | /* Perform location update and call */ |
| 2445 | f_perform_lu(); |
| 2446 | |
| 2447 | /* register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2448 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2449 | |
Neels Hofmeyr | 6aaeccf | 2019-03-06 15:32:26 +0100 | [diff] [blame] | 2450 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2451 | |
| 2452 | /* MSC->BSC: expect PAGING from MSC */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 2453 | f_expect_paging(); |
| 2454 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2455 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 2456 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2457 | |
| 2458 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 2459 | f_mt_sms(spars); |
| 2460 | |
| 2461 | f_expect_clear(); |
| 2462 | } |
| 2463 | testcase TC_lu_and_mt_sms() runs on MTC_CT { |
| 2464 | var BSC_ConnHdlrPars pars; |
| 2465 | var BSC_ConnHdlr vc_conn; |
| 2466 | f_init(); |
| 2467 | pars := f_init_pars(43); |
| 2468 | 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] | 2469 | vc_conn.done; |
| 2470 | } |
| 2471 | |
Neels Hofmeyr | b58d974 | 2019-11-27 18:44:54 +0100 | [diff] [blame] | 2472 | /* SMS added while already Paging */ |
| 2473 | friend function f_tc_lu_and_mt_sms_already_paging(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2474 | var SmsParameters spars := valueof(t_SmsPars); |
| 2475 | var OCT4 tmsi; |
| 2476 | |
| 2477 | f_init_handler(pars); |
| 2478 | |
| 2479 | f_perform_lu(); |
| 2480 | |
| 2481 | /* register an 'expect' for given IMSI (+TMSI) */ |
| 2482 | if (isvalue(g_pars.tmsi)) { |
| 2483 | tmsi := g_pars.tmsi; |
| 2484 | } else { |
| 2485 | tmsi := 'FFFFFFFF'O; |
| 2486 | } |
| 2487 | f_ran_register_imsi(g_pars.imsi, tmsi); |
| 2488 | |
| 2489 | log("first SMS"); |
| 2490 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 2491 | |
| 2492 | /* MSC->BSC: expect PAGING from MSC */ |
| 2493 | f_expect_paging(); |
| 2494 | |
| 2495 | log("second SMS"); |
| 2496 | /* Now osmo-msc is in state "Paging pending", make sure that another SMS to be sent at this time just joins in |
| 2497 | * with the pending paging. Another SMS: */ |
| 2498 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Another SMS"); |
| 2499 | |
| 2500 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 2501 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2502 | |
| 2503 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 2504 | f_mt_sms(spars); |
| 2505 | |
| 2506 | spars.tp.ud := '41F79B8E2ECB41D3E614'O; |
| 2507 | f_mt_sms(spars); |
| 2508 | |
| 2509 | f_expect_clear(); |
| 2510 | } |
| 2511 | testcase TC_lu_and_mt_sms_already_paging() runs on MTC_CT { |
| 2512 | var BSC_ConnHdlrPars pars; |
| 2513 | var BSC_ConnHdlr vc_conn; |
| 2514 | f_init(); |
| 2515 | pars := f_init_pars(44); |
| 2516 | vc_conn := f_start_handler_with_pars(refers(f_tc_lu_and_mt_sms_already_paging), pars); |
| 2517 | vc_conn.done; |
| 2518 | } |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2519 | |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2520 | /* Paging for MT SMS but no response */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2521 | 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] | 2522 | var SmsParameters spars := valueof(t_SmsPars); |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2523 | |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2524 | f_init_handler(pars, 150.0); |
| 2525 | |
| 2526 | /* Perform location update */ |
| 2527 | f_perform_lu(); |
| 2528 | |
| 2529 | /* register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2530 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2531 | |
Neels Hofmeyr | 6aaeccf | 2019-03-06 15:32:26 +0100 | [diff] [blame] | 2532 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 2533 | |
Neels Hofmeyr | 1623774 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 2534 | /* Expect the MSC to page exactly once */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2535 | f_expect_paging(); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2536 | |
| 2537 | /* Wait some time to make sure the MSC is not delivering any further |
| 2538 | * paging messages or anything else that could be unexpected. */ |
| 2539 | timer T := 20.0; |
| 2540 | T.start |
| 2541 | alt { |
Vadim Yanitskiy | da77459 | 2020-01-15 10:33:47 +0700 | [diff] [blame] | 2542 | [pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 2543 | setverdict(fail, "paging seems not to stop!"); |
| 2544 | mtc.stop; |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2545 | } |
Vadim Yanitskiy | da77459 | 2020-01-15 10:33:47 +0700 | [diff] [blame] | 2546 | [not pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) { |
| 2547 | setverdict(fail, "paging seems not to stop!"); |
| 2548 | mtc.stop; |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2549 | } |
Vadim Yanitskiy | da77459 | 2020-01-15 10:33:47 +0700 | [diff] [blame] | 2550 | [] BSSAP.receive { |
| 2551 | setverdict(fail, "unexpected BSSAP message received"); |
| 2552 | self.stop; |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2553 | } |
Vadim Yanitskiy | da77459 | 2020-01-15 10:33:47 +0700 | [diff] [blame] | 2554 | [] T.timeout { |
| 2555 | setverdict(pass); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2556 | } |
| 2557 | } |
| 2558 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 2559 | f_vty_sms_clear(hex2str(g_pars.imsi)); |
| 2560 | |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2561 | setverdict(pass); |
| 2562 | } |
| 2563 | testcase TC_lu_and_mt_sms_paging_and_nothing() runs on MTC_CT { |
| 2564 | var BSC_ConnHdlrPars pars; |
| 2565 | var BSC_ConnHdlr vc_conn; |
| 2566 | f_init(); |
Philipp Maier | a99ad26 | 2019-01-22 15:35:42 +0100 | [diff] [blame] | 2567 | pars := f_init_pars(1843); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2568 | 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] | 2569 | vc_conn.done; |
| 2570 | } |
| 2571 | |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2572 | /* LU followed by MT SMS with repeated paging */ |
| 2573 | friend function f_tc_lu_and_mt_sms_paging_repeated(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2574 | var SmsParameters spars := valueof(t_SmsPars); |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2575 | |
| 2576 | f_init_handler(pars); |
| 2577 | |
| 2578 | /* Perform location update and call */ |
| 2579 | f_perform_lu(); |
| 2580 | |
| 2581 | /* register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2582 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2583 | |
| 2584 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 2585 | |
Neels Hofmeyr | c3accec | 2019-11-28 01:09:47 +0100 | [diff] [blame] | 2586 | log("Expecting first Paging"); |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2587 | /* MSC->BSC: expect PAGING from MSC */ |
| 2588 | f_expect_paging(); |
| 2589 | |
Neels Hofmeyr | c3accec | 2019-11-28 01:09:47 +0100 | [diff] [blame] | 2590 | if (g_pars.ran_is_geran) { |
| 2591 | log("GERAN: expect no further Paging"); |
| 2592 | } else { |
| 2593 | log("UTRAN: expect more Paging"); |
| 2594 | } |
| 2595 | |
| 2596 | timer T := 5.0; |
| 2597 | T.start; |
| 2598 | alt { |
| 2599 | [g_pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 2600 | setverdict(fail, "GERAN should not repeat Paging, but received a second Paging"); |
| 2601 | mtc.stop; |
| 2602 | } |
| 2603 | [not g_pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) { |
| 2604 | log("UTRAN: second Paging received, as expected"); |
| 2605 | setverdict(pass); |
| 2606 | } |
| 2607 | [] T.timeout { |
| 2608 | if (g_pars.ran_is_geran) { |
| 2609 | log("GERAN: No further Paging received, as expected"); |
| 2610 | setverdict(pass); |
| 2611 | } else { |
| 2612 | setverdict(fail, "UTRAN: Expected a second Paging"); |
| 2613 | mtc.stop; |
| 2614 | } |
| 2615 | } |
| 2616 | } |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 2617 | |
| 2618 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 2619 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2620 | |
| 2621 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 2622 | f_mt_sms(spars); |
| 2623 | |
| 2624 | f_expect_clear(); |
| 2625 | } |
| 2626 | testcase TC_lu_and_mt_sms_paging_repeated() runs on MTC_CT { |
| 2627 | var BSC_ConnHdlrPars pars; |
| 2628 | var BSC_ConnHdlr vc_conn; |
| 2629 | f_init(); |
| 2630 | pars := f_init_pars(1844); |
| 2631 | vc_conn := f_start_handler_with_pars(refers(f_tc_lu_and_mt_sms_paging_repeated), pars); |
| 2632 | vc_conn.done; |
| 2633 | } |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2634 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2635 | /* mobile originated SMS from MS/BTS/BSC side to SMPP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2636 | 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] | 2637 | var SmsParameters spars := valueof(t_SmsPars); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2638 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2639 | f_init_handler(pars); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2640 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2641 | /* Perform location update so IMSI is known + registered in MSC/VLR */ |
| 2642 | f_perform_lu(); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2643 | |
Vadim Yanitskiy | 2d3f846 | 2020-01-15 11:44:12 +0700 | [diff] [blame] | 2644 | /* MS/UE submits a MO SMS */ |
| 2645 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2646 | f_mo_sms_submit(spars); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2647 | |
| 2648 | var SMPP_PDU smpp; |
| 2649 | var template SMPP_PDU tr_smpp := tr_SMPP(c_SMPP_command_id_deliver_sm, ESME_ROK); |
| 2650 | tr_smpp.body.deliver_sm := { |
| 2651 | service_type := "CMT", |
| 2652 | source_addr_ton := network_specific, |
| 2653 | source_addr_npi := isdn, |
| 2654 | source_addr := hex2str(pars.msisdn), |
| 2655 | dest_addr_ton := f_sm_ton_from_gsm(spars.tp.da.tP_DA_NoPad.tP_TypeOfNumber), |
| 2656 | dest_addr_npi := f_sm_npi_from_gsm(spars.tp.da.tP_DA_NoPad.tP_NumberingPlanID), |
| 2657 | destination_addr := hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue), |
| 2658 | esm_class := '00000001'B, |
| 2659 | protocol_id := 0, |
| 2660 | priority_flag := 0, |
| 2661 | schedule_delivery_time := "", |
| 2662 | replace_if_present := 0, |
| 2663 | data_coding := '00000001'B, |
| 2664 | sm_default_msg_id := 0, |
| 2665 | sm_length := ?, |
| 2666 | short_message := spars.tp.ud, |
| 2667 | opt_pars := { |
| 2668 | { |
| 2669 | tag := user_message_reference, |
| 2670 | len := 2, |
| 2671 | opt_value := { |
| 2672 | int2_val := oct2int(spars.tp.msg_ref) |
| 2673 | } |
| 2674 | } |
| 2675 | } |
| 2676 | }; |
| 2677 | alt { |
| 2678 | [] SMPP.receive(tr_smpp) -> value smpp { |
| 2679 | SMPP.send(ts_SMPP_DELIVER_SM_resp(ESME_ROK, smpp.header.seq_num)); |
| 2680 | } |
| 2681 | [] SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)) { repeat; } |
| 2682 | } |
| 2683 | |
Vadim Yanitskiy | 2d3f846 | 2020-01-15 11:44:12 +0700 | [diff] [blame] | 2684 | /* MSC terminates the SMS transaction with RP-ACK */ |
| 2685 | f_mo_sms_wait_rp_ack(spars); |
| 2686 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2687 | f_expect_clear(); |
| 2688 | } |
| 2689 | testcase TC_smpp_mo_sms() runs on MTC_CT { |
| 2690 | var BSC_ConnHdlr vc_conn; |
| 2691 | f_init(); |
| 2692 | f_vty_config2(MSCVTY, { "smpp", "esme msc_tester"}, "default-route"); |
| 2693 | vc_conn := f_start_handler(refers(f_tc_smpp_mo_sms), 44); |
| 2694 | vc_conn.done; |
| 2695 | f_vty_config2(MSCVTY, { "smpp", "esme msc_tester"}, "no default-route"); |
| 2696 | } |
| 2697 | |
Vadim Yanitskiy | 3382076 | 2020-01-15 11:26:07 +0700 | [diff] [blame] | 2698 | /* Test case for OS#4351: make sure that RP-ERROR from ESME is properly sent to the MS/UE */ |
| 2699 | friend function f_tc_smpp_mo_sms_rp_error(charstring id, BSC_ConnHdlrPars pars) |
| 2700 | runs on BSC_ConnHdlr { |
| 2701 | var SmsParameters spars := valueof(t_SmsPars); |
| 2702 | var SMPP_PDU smpp_pdu; |
| 2703 | timer T := 3.0; |
| 2704 | |
| 2705 | f_init_handler(pars); |
| 2706 | |
| 2707 | /* Perform location update */ |
| 2708 | f_perform_lu(); |
| 2709 | |
| 2710 | /* MS/UE submits a MO SMS */ |
| 2711 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2712 | f_mo_sms_submit(spars); |
| 2713 | |
| 2714 | /* ESME responds with an error (Invalid Destination Address) */ |
| 2715 | T.start; |
| 2716 | alt { |
| 2717 | [] SMPP.receive(tr_SMPP(c_SMPP_command_id_deliver_sm, ESME_ROK, body := ?)) -> value smpp_pdu { |
| 2718 | SMPP.send(ts_SMPP_DELIVER_SM_resp(ESME_RINVDSTADR, smpp_pdu.header.seq_num)); |
| 2719 | } |
| 2720 | [] SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)) { repeat; } |
| 2721 | [] T.timeout { |
| 2722 | setverdict(fail, "Timeout waiting for SMPP DELIVER-SM"); |
| 2723 | mtc.stop; |
| 2724 | } |
| 2725 | } |
| 2726 | |
| 2727 | /* Expect RP-ERROR on BSSAP interface */ |
| 2728 | spars.exp_rp_err := 1; /* FIXME: GSM411_RP_CAUSE_MO_NUM_UNASSIGNED */ |
| 2729 | f_mo_sms_wait_rp_ack(spars); |
| 2730 | |
| 2731 | f_expect_clear(); |
| 2732 | } |
| 2733 | testcase TC_smpp_mo_sms_rp_error() runs on MTC_CT { |
| 2734 | var BSC_ConnHdlr vc_conn; |
| 2735 | f_init(); |
| 2736 | f_vty_config2(MSCVTY, { "smpp", "esme msc_tester"}, "default-route"); |
| 2737 | vc_conn := f_start_handler(refers(f_tc_smpp_mo_sms_rp_error), 45); |
| 2738 | vc_conn.done; |
| 2739 | f_vty_config2(MSCVTY, { "smpp", "esme msc_tester"}, "no default-route"); |
| 2740 | } |
| 2741 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2742 | |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 2743 | /* Test MO-SMS from MS/BTS/BSC towards HLR (via GSUP) */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2744 | friend function f_tc_gsup_mo_sms(charstring id, BSC_ConnHdlrPars pars) |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 2745 | runs on BSC_ConnHdlr { |
| 2746 | var SmsParameters spars := valueof(t_SmsPars); |
| 2747 | var GSUP_PDU gsup_msg_rx; |
| 2748 | var octetstring sm_tpdu; |
| 2749 | |
| 2750 | f_init_handler(pars); |
| 2751 | |
| 2752 | /* We need to inspect GSUP activity */ |
| 2753 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2754 | |
| 2755 | /* Perform location update */ |
| 2756 | f_perform_lu(); |
| 2757 | |
| 2758 | /* Send CM Service Request for SMS */ |
| 2759 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2760 | |
| 2761 | /* Prepare expected SM-RP-UI (SM TPDU) */ |
| 2762 | enc_TPDU_RP_DATA_MS_SGSN_fast( |
| 2763 | valueof(ts_SMS_SUBMIT(spars.tp.msg_ref, |
| 2764 | spars.tp.da, spars.tp.pid, spars.tp.dcs, |
| 2765 | spars.tp.udl, spars.tp.ud)), |
| 2766 | sm_tpdu); |
| 2767 | |
| 2768 | var template GSUP_PDU mo_forwardSM := tr_GSUP_MO_FORWARD_SM_REQ( |
| 2769 | imsi := g_pars.imsi, |
| 2770 | sm_rp_mr := spars.rp.msg_ref, |
Vadim Yanitskiy | 04dd5f7 | 2019-12-13 15:45:44 +0900 | [diff] [blame] | 2771 | /* SM-RP-DA: SMSC address */ |
| 2772 | sm_rp_da := tr_GSUP_SM_RP_DA_SMSC_ADDR(t_GSUP_SM_RP_Addr( |
| 2773 | number := spars.rp.smsc_addr.rP_NumberDigits, |
| 2774 | npi := spars.rp.smsc_addr.rP_NumberingPlanIdentification, |
| 2775 | ton := spars.rp.smsc_addr.rP_TypeOfNumber, |
| 2776 | ext := spars.rp.smsc_addr.rP_Ext)), |
| 2777 | /* SM-RP-OA: subscriber's MSISDN (filled in by MSC) */ |
| 2778 | sm_rp_oa := tr_GSUP_SM_RP_OA_MSISDN(t_GSUP_SM_RP_Addr( |
| 2779 | number := g_pars.msisdn, |
| 2780 | /* NOTE: MSISDN in g_pars lacks this info, assuming defaults */ |
| 2781 | npi := '0001'B, ton := '001'B, ext := '1'B)), |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 2782 | /* TODO: can we use decmatch here? */ |
| 2783 | sm_rp_ui := sm_tpdu |
| 2784 | ); |
| 2785 | |
| 2786 | /* Submit an SMS on DTAP and expect MO-forwardSM-Req on GSUP */ |
| 2787 | f_mo_sms_submit(spars); |
| 2788 | alt { |
| 2789 | [] GSUP.receive(mo_forwardSM) -> value gsup_msg_rx { |
Vadim Yanitskiy | a358dd4 | 2020-01-15 10:42:47 +0700 | [diff] [blame] | 2790 | log("RX MO-forwardSM-Req: ", gsup_msg_rx); |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 2791 | setverdict(pass); |
| 2792 | } |
| 2793 | [] GSUP.receive { |
Vadim Yanitskiy | 286b042 | 2024-01-09 18:11:04 +0700 | [diff] [blame] | 2794 | setverdict(fail, "Rx unexpected GSUP message"); |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 2795 | mtc.stop; |
| 2796 | } |
| 2797 | } |
| 2798 | |
| 2799 | /* Trigger RP-ACK by sending MO-forwardSM-Res */ |
| 2800 | GSUP.send(valueof(ts_GSUP_MO_FORWARD_SM_RES( |
| 2801 | imsi := g_pars.imsi, |
| 2802 | sm_rp_mr := spars.rp.msg_ref))); |
| 2803 | /* Expect RP-ACK on DTAP */ |
| 2804 | f_mo_sms_wait_rp_ack(spars); |
| 2805 | |
| 2806 | f_expect_clear(); |
| 2807 | } |
| 2808 | testcase TC_gsup_mo_sms() runs on MTC_CT { |
| 2809 | var BSC_ConnHdlr vc_conn; |
| 2810 | f_init(); |
| 2811 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2812 | vc_conn := f_start_handler(refers(f_tc_gsup_mo_sms), 88); |
| 2813 | vc_conn.done; |
| 2814 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2815 | } |
| 2816 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2817 | |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 2818 | /* Test MO-SMMA from MS/BTS/BSC towards HLR (via GSUP) */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2819 | friend function f_tc_gsup_mo_smma(charstring id, BSC_ConnHdlrPars pars) |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 2820 | runs on BSC_ConnHdlr { |
| 2821 | var SmsParameters spars := valueof(t_SmsPars); |
| 2822 | var GSUP_PDU gsup_msg_rx; |
| 2823 | |
| 2824 | f_init_handler(pars); |
| 2825 | |
| 2826 | /* We need to inspect GSUP activity */ |
| 2827 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2828 | |
| 2829 | /* Perform location update */ |
| 2830 | f_perform_lu(); |
| 2831 | |
| 2832 | /* Send CM Service Request for SMS */ |
| 2833 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2834 | |
| 2835 | var template GSUP_PDU mo_ReadyForSM := tr_GSUP_MO_READY_FOR_SM_REQ( |
| 2836 | imsi := g_pars.imsi, |
| 2837 | sm_rp_mr := spars.rp.msg_ref, |
| 2838 | sm_alert_rsn := GSUP_SM_ALERT_RSN_TYPE_MEM_AVAIL |
| 2839 | ); |
| 2840 | |
| 2841 | /* Submit an SMS on DTAP and expect MO-forwardSM-Req on GSUP */ |
| 2842 | f_mo_smma(spars); |
| 2843 | alt { |
| 2844 | [] GSUP.receive(mo_ReadyForSM) -> value gsup_msg_rx { |
Vadim Yanitskiy | a358dd4 | 2020-01-15 10:42:47 +0700 | [diff] [blame] | 2845 | log("RX MO-ReadyForSM-Req: ", gsup_msg_rx); |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 2846 | setverdict(pass); |
| 2847 | } |
| 2848 | [] GSUP.receive { |
Vadim Yanitskiy | 286b042 | 2024-01-09 18:11:04 +0700 | [diff] [blame] | 2849 | setverdict(fail, "Rx unexpected GSUP message"); |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 2850 | mtc.stop; |
| 2851 | } |
| 2852 | } |
| 2853 | |
| 2854 | /* Trigger RP-ACK by sending MO-forwardSM-Res */ |
| 2855 | GSUP.send(valueof(ts_GSUP_MO_READY_FOR_SM_RES( |
| 2856 | imsi := g_pars.imsi, |
| 2857 | sm_rp_mr := spars.rp.msg_ref))); |
| 2858 | /* Expect RP-ACK on DTAP */ |
| 2859 | f_mo_sms_wait_rp_ack(spars); |
| 2860 | |
| 2861 | f_expect_clear(); |
| 2862 | } |
| 2863 | testcase TC_gsup_mo_smma() runs on MTC_CT { |
| 2864 | var BSC_ConnHdlr vc_conn; |
| 2865 | f_init(); |
| 2866 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2867 | vc_conn := f_start_handler(refers(f_tc_gsup_mo_smma), 89); |
| 2868 | vc_conn.done; |
| 2869 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2870 | } |
| 2871 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2872 | |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2873 | /* Helper for sending MT SMS over GSUP */ |
| 2874 | private function f_gsup_forwardSM_req(SmsParameters spars, OCT1 mms := '00'O) |
| 2875 | runs on BSC_ConnHdlr { |
Vadim Yanitskiy | a52347c | 2019-12-12 17:32:33 +0900 | [diff] [blame] | 2876 | 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] | 2877 | var GSUP_SM_RP_Addr smsc := valueof(t_GSUP_SM_RP_Addr( |
| 2878 | number := spars.rp.smsc_addr.rP_NumberDigits, |
| 2879 | npi := spars.rp.smsc_addr.rP_NumberingPlanIdentification, |
| 2880 | ton := spars.rp.smsc_addr.rP_TypeOfNumber, |
| 2881 | ext := spars.rp.smsc_addr.rP_Ext)); |
Vadim Yanitskiy | a52347c | 2019-12-12 17:32:33 +0900 | [diff] [blame] | 2882 | |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2883 | GSUP.send(ts_GSUP_MT_FORWARD_SM_REQ( |
| 2884 | imsi := g_pars.imsi, |
| 2885 | /* NOTE: MSC should assign RP-MR itself */ |
| 2886 | sm_rp_mr := 'FF'O, |
Vadim Yanitskiy | a52347c | 2019-12-12 17:32:33 +0900 | [diff] [blame] | 2887 | sm_rp_da := valueof(ts_GSUP_SM_RP_DA_MSISDN(msisdn)), |
Vadim Yanitskiy | 04dd5f7 | 2019-12-13 15:45:44 +0900 | [diff] [blame] | 2888 | sm_rp_oa := valueof(ts_GSUP_SM_RP_OA_SMSC_ADDR(smsc)), |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2889 | /* Encoded SMS TPDU (taken from Wireshark) |
| 2890 | * FIXME: we should encode spars somehow */ |
| 2891 | sm_rp_ui := '00068021436500008111328130858200'O, |
| 2892 | sm_rp_mms := mms |
| 2893 | )); |
| 2894 | } |
| 2895 | |
| 2896 | /* Test successful MT-SMS (RP-ACK) over GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2897 | 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] | 2898 | runs on BSC_ConnHdlr { |
| 2899 | var SmsParameters spars := valueof(t_SmsPars); |
| 2900 | |
| 2901 | f_init_handler(pars); |
| 2902 | |
| 2903 | /* We need to inspect GSUP activity */ |
| 2904 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2905 | |
| 2906 | /* Perform location update */ |
| 2907 | f_perform_lu(); |
| 2908 | |
| 2909 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2910 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2911 | |
| 2912 | var template GSUP_PDU mt_forwardSM_res := tr_GSUP_MT_FORWARD_SM_RES( |
| 2913 | imsi := g_pars.imsi, |
| 2914 | /* NOTE: MSC should assign RP-MR itself */ |
| 2915 | sm_rp_mr := ? |
| 2916 | ); |
| 2917 | |
| 2918 | /* Submit a MT SMS on GSUP */ |
| 2919 | f_gsup_forwardSM_req(spars); |
| 2920 | |
| 2921 | /* Expect Paging Request and Establish DTAP / BSSAP / SCCP connection */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 2922 | f_expect_paging(); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2923 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2924 | |
| 2925 | /* Wait for MT SMS on DTAP */ |
| 2926 | f_mt_sms_expect(spars); |
| 2927 | |
| 2928 | /* Send RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 2929 | f_mt_sms_send_rp_ack(spars); |
| 2930 | alt { |
| 2931 | [] GSUP.receive(mt_forwardSM_res) { |
| 2932 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 2933 | setverdict(pass); |
| 2934 | } |
| 2935 | [] GSUP.receive { |
Vadim Yanitskiy | 286b042 | 2024-01-09 18:11:04 +0700 | [diff] [blame] | 2936 | setverdict(fail, "Rx unexpected GSUP message"); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2937 | mtc.stop; |
| 2938 | } |
| 2939 | } |
| 2940 | |
| 2941 | f_expect_clear(); |
| 2942 | } |
| 2943 | testcase TC_gsup_mt_sms_ack() runs on MTC_CT { |
| 2944 | var BSC_ConnHdlrPars pars; |
| 2945 | var BSC_ConnHdlr vc_conn; |
| 2946 | f_init(); |
| 2947 | pars := f_init_pars(90); |
| 2948 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2949 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_sms_ack), pars); |
| 2950 | vc_conn.done; |
| 2951 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2952 | } |
| 2953 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2954 | |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2955 | /* Test rejected MT-SMS (RP-ERROR) over GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 2956 | 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] | 2957 | runs on BSC_ConnHdlr { |
| 2958 | var SmsParameters spars := valueof(t_SmsPars); |
| 2959 | var OCT1 sm_rp_cause := '78'O; /* dummy RP-Cause value */ |
| 2960 | |
| 2961 | f_init_handler(pars); |
| 2962 | |
| 2963 | /* We need to inspect GSUP activity */ |
| 2964 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2965 | |
| 2966 | /* Perform location update */ |
| 2967 | f_perform_lu(); |
| 2968 | |
| 2969 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 2970 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2971 | |
| 2972 | var template GSUP_PDU mt_forwardSM_err := tr_GSUP_MT_FORWARD_SM_ERR( |
| 2973 | imsi := g_pars.imsi, |
| 2974 | /* NOTE: MSC should assign RP-MR itself */ |
| 2975 | sm_rp_mr := ?, |
| 2976 | sm_rp_cause := sm_rp_cause |
| 2977 | ); |
| 2978 | |
| 2979 | /* Submit a MT SMS on GSUP */ |
| 2980 | f_gsup_forwardSM_req(spars); |
| 2981 | |
| 2982 | /* Expect Paging Request and Establish DTAP / BSSAP / SCCP connection */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 2983 | f_expect_paging(); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2984 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2985 | |
| 2986 | /* Wait for MT SMS on DTAP */ |
| 2987 | f_mt_sms_expect(spars); |
| 2988 | |
| 2989 | /* Send RP-ERROR and expect MT-forwardSM-Err on GSUP */ |
| 2990 | f_mt_sms_send_rp_error(spars, oct2int(sm_rp_cause)); |
| 2991 | alt { |
| 2992 | [] GSUP.receive(mt_forwardSM_err) { |
| 2993 | log("RX MT-forwardSM-Err (RP-ERROR)"); |
| 2994 | setverdict(pass); |
| 2995 | mtc.stop; |
| 2996 | } |
| 2997 | [] GSUP.receive { |
Vadim Yanitskiy | 286b042 | 2024-01-09 18:11:04 +0700 | [diff] [blame] | 2998 | setverdict(fail, "Rx unexpected GSUP message"); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2999 | mtc.stop; |
| 3000 | } |
| 3001 | } |
| 3002 | |
| 3003 | f_expect_clear(); |
| 3004 | } |
| 3005 | testcase TC_gsup_mt_sms_err() runs on MTC_CT { |
| 3006 | var BSC_ConnHdlrPars pars; |
| 3007 | var BSC_ConnHdlr vc_conn; |
| 3008 | f_init(); |
| 3009 | pars := f_init_pars(91); |
| 3010 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 3011 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_sms_err), pars); |
| 3012 | vc_conn.done; |
| 3013 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 3014 | } |
| 3015 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3016 | |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 3017 | /* Test SM-RP-MR assignment for MT-SMS over GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3018 | friend function f_tc_gsup_mt_sms_rp_mr(charstring id, BSC_ConnHdlrPars pars) |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 3019 | runs on BSC_ConnHdlr { |
| 3020 | var SmsParameters spars1 := valueof(t_SmsPars); /* 1st SMS */ |
| 3021 | var SmsParameters spars2 := valueof(t_SmsPars); /* 2nd SMS */ |
| 3022 | |
| 3023 | f_init_handler(pars); |
| 3024 | |
| 3025 | /* We need to inspect GSUP activity */ |
| 3026 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3027 | |
| 3028 | /* Perform location update */ |
| 3029 | f_perform_lu(); |
| 3030 | |
| 3031 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 3032 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 3033 | |
| 3034 | /* Submit the 1st MT SMS on GSUP */ |
| 3035 | log("TX MT-forwardSM-Req for the 1st SMS"); |
| 3036 | f_gsup_forwardSM_req(spars1); |
| 3037 | |
| 3038 | /* Expect Paging Request and Establish DTAP / BSSAP / SCCP connection */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 3039 | f_expect_paging(); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 3040 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 3041 | |
| 3042 | /* Wait for 1st MT SMS on DTAP */ |
| 3043 | f_mt_sms_expect(spars1); |
| 3044 | log("RX the 1st SMS on DTAP, DTAP TID is ", spars1.tid, |
| 3045 | ", SM-RP-MR is ", spars1.rp.msg_ref); |
| 3046 | |
| 3047 | /* Submit the 2nd MT SMS on GSUP */ |
| 3048 | log("TX MT-forwardSM-Req for the 2nd SMS"); |
| 3049 | f_gsup_forwardSM_req(spars2); |
| 3050 | |
| 3051 | /* Wait for 2nd MT SMS on DTAP */ |
| 3052 | f_mt_sms_expect(spars2); |
| 3053 | log("RX the 2nd SMS on DTAP, DTAP TID is ", spars2.tid, |
| 3054 | ", SM-RP-MR is ", spars2.rp.msg_ref); |
| 3055 | |
| 3056 | /* Both transaction IDs shall be different */ |
| 3057 | if (spars1.tid == spars2.tid) { |
Vadim Yanitskiy | 286b042 | 2024-01-09 18:11:04 +0700 | [diff] [blame] | 3058 | setverdict(fail, "Both DTAP transaction IDs shall be different"); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 3059 | } |
| 3060 | |
| 3061 | /* Both SM-RP-MR values shall be different */ |
| 3062 | if (spars1.rp.msg_ref == spars2.rp.msg_ref) { |
Vadim Yanitskiy | 286b042 | 2024-01-09 18:11:04 +0700 | [diff] [blame] | 3063 | setverdict(fail, "Both SM-RP-MR values shall be different"); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 3064 | } |
| 3065 | |
| 3066 | /* Both SM-RP-MR values shall be assigned */ |
| 3067 | if (spars1.rp.msg_ref == 'FF'O) { |
Vadim Yanitskiy | 286b042 | 2024-01-09 18:11:04 +0700 | [diff] [blame] | 3068 | setverdict(fail, "Unassigned SM-RP-MR value for the 1st SMS"); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 3069 | } |
| 3070 | if (spars2.rp.msg_ref == 'FF'O) { |
Vadim Yanitskiy | 286b042 | 2024-01-09 18:11:04 +0700 | [diff] [blame] | 3071 | setverdict(fail, "Unassigned SM-RP-MR value for the 2nd SMS"); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 3072 | } |
| 3073 | |
| 3074 | /* Send the 1st RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 3075 | f_mt_sms_send_rp_ack(spars1); |
| 3076 | alt { |
| 3077 | [] GSUP.receive(tr_GSUP_MT_FORWARD_SM_RES( |
| 3078 | imsi := g_pars.imsi, |
| 3079 | sm_rp_mr := spars1.rp.msg_ref |
| 3080 | )) { |
| 3081 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 3082 | setverdict(pass); |
| 3083 | } |
| 3084 | [] GSUP.receive { |
Vadim Yanitskiy | 286b042 | 2024-01-09 18:11:04 +0700 | [diff] [blame] | 3085 | setverdict(fail, "Rx unexpected GSUP message"); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 3086 | mtc.stop; |
| 3087 | } |
| 3088 | } |
| 3089 | |
| 3090 | /* Send the 2nd RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 3091 | f_mt_sms_send_rp_ack(spars2); |
| 3092 | alt { |
| 3093 | [] GSUP.receive(tr_GSUP_MT_FORWARD_SM_RES( |
| 3094 | imsi := g_pars.imsi, |
| 3095 | sm_rp_mr := spars2.rp.msg_ref |
| 3096 | )) { |
| 3097 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 3098 | setverdict(pass); |
| 3099 | } |
| 3100 | [] GSUP.receive { |
Vadim Yanitskiy | 286b042 | 2024-01-09 18:11:04 +0700 | [diff] [blame] | 3101 | setverdict(fail, "Rx unexpected GSUP message"); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 3102 | mtc.stop; |
| 3103 | } |
| 3104 | } |
| 3105 | |
| 3106 | f_expect_clear(); |
| 3107 | } |
| 3108 | testcase TC_gsup_mt_sms_rp_mr() runs on MTC_CT { |
| 3109 | var BSC_ConnHdlrPars pars; |
| 3110 | var BSC_ConnHdlr vc_conn; |
| 3111 | f_init(); |
| 3112 | pars := f_init_pars(92); |
| 3113 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 3114 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_sms_rp_mr), pars); |
| 3115 | vc_conn.done; |
| 3116 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 3117 | } |
| 3118 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3119 | |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 3120 | /* Test SM-RP-MR assignment for MT-SMS over GSUP */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3121 | 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] | 3122 | runs on BSC_ConnHdlr { |
| 3123 | var SmsParameters spars_mo := valueof(t_SmsPars); /* MO SMMA */ |
| 3124 | var SmsParameters spars_mt := valueof(t_SmsPars); /* MT SMS */ |
| 3125 | |
| 3126 | f_init_handler(pars); |
| 3127 | |
| 3128 | /* We need to inspect GSUP activity */ |
| 3129 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3130 | |
| 3131 | /* Perform location update */ |
| 3132 | f_perform_lu(); |
| 3133 | |
| 3134 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 3135 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 3136 | |
| 3137 | /* Send CM Service Request for MO SMMA */ |
| 3138 | f_establish_fully(EST_TYPE_MO_SMS); |
| 3139 | |
| 3140 | /* Submit MO SMMA on DTAP */ |
| 3141 | log("Submit MO SMMA on DTAP, SM-RP-MR is '00'O"); |
| 3142 | spars_mo.rp.msg_ref := '00'O; |
| 3143 | f_mo_smma(spars_mo); |
| 3144 | |
| 3145 | /* Expect MO-forwardSM-Req for MO SMMA on GSUP */ |
| 3146 | alt { |
| 3147 | [] GSUP.receive(tr_GSUP_MO_READY_FOR_SM_REQ( |
| 3148 | imsi := g_pars.imsi, |
| 3149 | sm_rp_mr := spars_mo.rp.msg_ref, |
| 3150 | sm_alert_rsn := GSUP_SM_ALERT_RSN_TYPE_MEM_AVAIL |
| 3151 | )) { |
| 3152 | log("RX MO-ReadyForSM-Req, SM-RP-MR is '00'O"); |
| 3153 | setverdict(pass); |
| 3154 | } |
| 3155 | [] GSUP.receive { |
Vadim Yanitskiy | 286b042 | 2024-01-09 18:11:04 +0700 | [diff] [blame] | 3156 | setverdict(fail, "Rx unexpected GSUP message"); |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 3157 | mtc.stop; |
| 3158 | } |
| 3159 | } |
| 3160 | |
| 3161 | /* Submit MT SMS on GSUP */ |
| 3162 | log("TX MT-forwardSM-Req for the MT SMS"); |
| 3163 | f_gsup_forwardSM_req(spars_mt); |
| 3164 | |
| 3165 | /* Wait for MT SMS on DTAP */ |
| 3166 | f_mt_sms_expect(spars_mt); |
| 3167 | log("RX MT SMS on DTAP, DTAP TID is ", spars_mt.tid, |
| 3168 | ", SM-RP-MR is ", spars_mt.rp.msg_ref); |
| 3169 | |
| 3170 | /* Both SM-RP-MR values shall be different */ |
| 3171 | if (spars_mo.rp.msg_ref == spars_mt.rp.msg_ref) { |
Vadim Yanitskiy | 286b042 | 2024-01-09 18:11:04 +0700 | [diff] [blame] | 3172 | setverdict(fail, "Both SM-RP-MR values shall be different"); |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 3173 | } |
| 3174 | |
| 3175 | /* SM-RP-MR value for MT SMS shall be assigned */ |
| 3176 | if (spars_mt.rp.msg_ref == 'FF'O) { |
Vadim Yanitskiy | 286b042 | 2024-01-09 18:11:04 +0700 | [diff] [blame] | 3177 | setverdict(fail, "Unassigned SM-RP-MR value for the MT SMS"); |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 3178 | } |
| 3179 | |
| 3180 | /* Trigger RP-ACK for MO SMMA by sending MO-forwardSM-Res */ |
| 3181 | GSUP.send(valueof(ts_GSUP_MO_READY_FOR_SM_RES( |
| 3182 | imsi := g_pars.imsi, |
| 3183 | sm_rp_mr := spars_mo.rp.msg_ref))); |
| 3184 | /* Expect RP-ACK for MO SMMA on DTAP */ |
| 3185 | f_mo_sms_wait_rp_ack(spars_mo); |
| 3186 | |
| 3187 | /* Send RP-ACK for MT SMS and expect MT-forwardSM-Res on GSUP */ |
| 3188 | f_mt_sms_send_rp_ack(spars_mt); |
| 3189 | alt { |
| 3190 | [] GSUP.receive(tr_GSUP_MT_FORWARD_SM_RES( |
| 3191 | imsi := g_pars.imsi, |
| 3192 | sm_rp_mr := spars_mt.rp.msg_ref |
| 3193 | )) { |
| 3194 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 3195 | setverdict(pass); |
| 3196 | } |
| 3197 | [] GSUP.receive { |
Vadim Yanitskiy | 286b042 | 2024-01-09 18:11:04 +0700 | [diff] [blame] | 3198 | setverdict(fail, "Rx unexpected GSUP message"); |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 3199 | mtc.stop; |
| 3200 | } |
| 3201 | } |
| 3202 | |
| 3203 | f_expect_clear(); |
| 3204 | } |
| 3205 | testcase TC_gsup_mo_mt_sms_rp_mr() runs on MTC_CT { |
| 3206 | var BSC_ConnHdlrPars pars; |
| 3207 | var BSC_ConnHdlr vc_conn; |
| 3208 | f_init(); |
| 3209 | pars := f_init_pars(93); |
| 3210 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 3211 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mo_mt_sms_rp_mr), pars); |
| 3212 | vc_conn.done; |
| 3213 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 3214 | } |
| 3215 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3216 | |
Vadim Yanitskiy | 1cd11a0 | 2018-12-03 02:43:35 +0700 | [diff] [blame] | 3217 | /* Test multi-part MT-SMS over GSUP */ |
| 3218 | private function f_tc_gsup_mt_multi_part_sms(charstring id, BSC_ConnHdlrPars pars) |
| 3219 | runs on BSC_ConnHdlr { |
| 3220 | var SmsParameters spars := valueof(t_SmsPars); |
| 3221 | |
| 3222 | f_init_handler(pars); |
| 3223 | |
| 3224 | /* We need to inspect GSUP activity */ |
| 3225 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3226 | |
| 3227 | /* Perform location update */ |
| 3228 | f_perform_lu(); |
| 3229 | |
| 3230 | /* Register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 3231 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 1cd11a0 | 2018-12-03 02:43:35 +0700 | [diff] [blame] | 3232 | |
| 3233 | var template GSUP_PDU mt_forwardSM_res := tr_GSUP_MT_FORWARD_SM_RES( |
| 3234 | imsi := g_pars.imsi, |
| 3235 | /* NOTE: MSC should assign RP-MR itself */ |
| 3236 | sm_rp_mr := ? |
| 3237 | ); |
| 3238 | |
| 3239 | /* Send 4 messages (NOTE: SM-RP-UI remains unchanged) */ |
| 3240 | for (var integer i := 3; i >= 0; i := i-1) { |
| 3241 | /* Submit a MT SMS on GSUP (MMS is decremented) */ |
| 3242 | f_gsup_forwardSM_req(spars, int2oct(i, 1)); |
| 3243 | |
| 3244 | /* Expect Paging Request and Establish connection */ |
| 3245 | if (i == 3) { /* ... only once! */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3246 | f_expect_paging(); |
Vadim Yanitskiy | 1cd11a0 | 2018-12-03 02:43:35 +0700 | [diff] [blame] | 3247 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 3248 | } |
| 3249 | |
| 3250 | /* Wait for MT SMS on DTAP */ |
| 3251 | f_mt_sms_expect(spars); |
| 3252 | |
| 3253 | /* Send RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 3254 | f_mt_sms_send_rp_ack(spars); |
| 3255 | alt { |
| 3256 | [] GSUP.receive(mt_forwardSM_res) { |
| 3257 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 3258 | setverdict(pass); |
| 3259 | } |
| 3260 | [] GSUP.receive { |
Vadim Yanitskiy | 286b042 | 2024-01-09 18:11:04 +0700 | [diff] [blame] | 3261 | setverdict(fail, "Rx unexpected GSUP message"); |
Vadim Yanitskiy | 1cd11a0 | 2018-12-03 02:43:35 +0700 | [diff] [blame] | 3262 | mtc.stop; |
| 3263 | } |
| 3264 | } |
| 3265 | |
| 3266 | /* Keep some 'distance' between transmissions */ |
| 3267 | f_sleep(1.5); |
| 3268 | } |
| 3269 | |
| 3270 | f_expect_clear(); |
| 3271 | } |
| 3272 | testcase TC_gsup_mt_multi_part_sms() runs on MTC_CT { |
| 3273 | var BSC_ConnHdlrPars pars; |
| 3274 | var BSC_ConnHdlr vc_conn; |
| 3275 | f_init(); |
| 3276 | pars := f_init_pars(91); |
| 3277 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 3278 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_multi_part_sms), pars); |
| 3279 | vc_conn.done; |
| 3280 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 3281 | } |
| 3282 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 3283 | /* convert GSM L3 TON to SMPP_TON enum */ |
| 3284 | function f_sm_ton_from_gsm(BIT3 ton) return SMPP_TON { |
| 3285 | select (ton) { |
| 3286 | case ('000'B) { return unknown; } |
| 3287 | case ('001'B) { return international; } |
| 3288 | case ('010'B) { return national; } |
| 3289 | case ('011'B) { return network_specific; } |
| 3290 | case ('100'B) { return subscriber_number; } |
| 3291 | case ('101'B) { return alphanumeric; } |
| 3292 | case ('110'B) { return abbreviated; } |
| 3293 | } |
| 3294 | setverdict(fail, "Unknown TON ", ton); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 3295 | mtc.stop; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 3296 | } |
| 3297 | /* convert GSM L3 NPI to SMPP_NPI enum */ |
| 3298 | function f_sm_npi_from_gsm(BIT4 npi) return SMPP_NPI { |
| 3299 | select (npi) { |
| 3300 | case ('0000'B) { return unknown; } |
| 3301 | case ('0001'B) { return isdn; } |
| 3302 | case ('0011'B) { return data; } |
| 3303 | case ('0100'B) { return telex; } |
| 3304 | case ('0110'B) { return land_mobile; } |
| 3305 | case ('1000'B) { return national; } |
| 3306 | case ('1001'B) { return private_; } |
| 3307 | case ('1010'B) { return ermes; } |
| 3308 | } |
| 3309 | setverdict(fail, "Unknown NPI ", npi); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 3310 | mtc.stop; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 3311 | } |
| 3312 | |
| 3313 | /* build a SMPP_SM from SmsParameters */ |
| 3314 | function f_mt_sm_from_spars(SmsParameters spars) |
| 3315 | runs on BSC_ConnHdlr return SMPP_SM { |
| 3316 | var SMPP_SM sm := { |
| 3317 | service_type := "CMT", |
| 3318 | source_addr_ton := f_sm_ton_from_gsm(spars.tp.da.tP_DA_NoPad.tP_TypeOfNumber), |
| 3319 | source_addr_npi := f_sm_npi_from_gsm(spars.tp.da.tP_DA_NoPad.tP_NumberingPlanID), |
| 3320 | source_addr := hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue), |
| 3321 | dest_addr_ton := international, |
| 3322 | dest_addr_npi := isdn, |
| 3323 | destination_addr := hex2str(g_pars.msisdn), |
| 3324 | esm_class := '00000001'B, |
| 3325 | protocol_id := 0, |
| 3326 | priority_flag := 0, |
| 3327 | schedule_delivery_time := "", |
| 3328 | validity_period := "", |
| 3329 | registered_delivery := '00000000'B, |
| 3330 | replace_if_present := 0, |
| 3331 | data_coding := '00000001'B, |
| 3332 | sm_default_msg_id := 0, |
| 3333 | sm_length := spars.tp.udl, |
| 3334 | short_message := spars.tp.ud, |
| 3335 | opt_pars := {} |
| 3336 | }; |
| 3337 | return sm; |
| 3338 | } |
| 3339 | |
| 3340 | /* helper function to encode SMS from 'spars', send it via SMPP to MSC; receive it on MS side */ |
| 3341 | private function f_smpp_mt_sms(SmsParameters spars, boolean trans_mode) runs on BSC_ConnHdlr { |
| 3342 | var SMPP_SM sm := f_mt_sm_from_spars(spars); |
| 3343 | if (trans_mode) { |
| 3344 | sm.esm_class := '00000010'B; |
| 3345 | } |
| 3346 | |
| 3347 | /* actually cause MSC to send a SMS via SUBMIT-SM from SMPP side */ |
| 3348 | SMPP.send(ts_SMPP_SUBMIT_SM(sm)); |
| 3349 | if (not match(sm.esm_class, tr_ESM_CLASS_TRANSACTION)) { |
| 3350 | /* if we're not in SMPP transaction mode, we expect the SMPP-level ACK |
| 3351 | * before we expect the SMS delivery on the BSC/radio side */ |
| 3352 | SMPP.receive(tr_SMPP(c_SMPP_command_id_submit_sm_resp, ESME_ROK)); |
| 3353 | } |
| 3354 | |
| 3355 | /* MSC->BSC: expect PAGING from MSC */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 3356 | f_expect_paging(); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 3357 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 3358 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 3359 | SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)); |
| 3360 | |
| 3361 | f_mt_sms(spars); |
| 3362 | |
| 3363 | if (match(sm.esm_class, tr_ESM_CLASS_TRANSACTION)) { |
| 3364 | SMPP.receive(tr_SMPP(c_SMPP_command_id_submit_sm_resp, ESME_ROK)); |
| 3365 | } |
| 3366 | f_expect_clear(); |
| 3367 | } |
| 3368 | |
| 3369 | /* mobile terminated SMS, from SMPP to BSC/BTS/MS */ |
| 3370 | private function f_tc_smpp_mt_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 3371 | f_init_handler(pars); |
| 3372 | |
| 3373 | /* Perform location update so IMSI is known + registered in MSC/VLR */ |
| 3374 | f_perform_lu(); |
| 3375 | SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)); |
| 3376 | |
| 3377 | /* register an 'expect' for given IMSI (+TMSI) */ |
Vadim Yanitskiy | ae74774 | 2020-01-10 00:23:10 +0100 | [diff] [blame] | 3378 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 3379 | |
| 3380 | var SmsParameters spars := valueof(t_SmsPars); |
| 3381 | /* TODO: test with more intelligent user data; test different coding schemes */ |
| 3382 | spars.tp.ud := '00'O; |
| 3383 | spars.tp.udl := 1; |
| 3384 | |
| 3385 | /* first test the non-transaction store+forward mode */ |
| 3386 | f_smpp_mt_sms(spars, false); |
| 3387 | |
| 3388 | /* then test the transaction mode */ |
| 3389 | f_smpp_mt_sms(spars, true); |
| 3390 | } |
| 3391 | testcase TC_smpp_mt_sms() runs on MTC_CT { |
| 3392 | var BSC_ConnHdlr vc_conn; |
| 3393 | f_init(); |
| 3394 | vc_conn := f_start_handler(refers(f_tc_smpp_mt_sms), 45); |
| 3395 | vc_conn.done; |
| 3396 | } |
| 3397 | |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3398 | /*********************************************************************** |
| 3399 | * USSD Testing |
| 3400 | ***********************************************************************/ |
| 3401 | |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3402 | private altstep as_unexp_gsup_or_bssap_msg() |
| 3403 | runs on BSC_ConnHdlr { |
| 3404 | [] GSUP.receive { |
| 3405 | setverdict(fail, "Unknown/unexpected GSUP received"); |
| 3406 | self.stop; |
| 3407 | } |
| 3408 | [] BSSAP.receive { |
| 3409 | setverdict(fail, "Unknown/unexpected BSSAP message received"); |
| 3410 | self.stop; |
| 3411 | } |
| 3412 | } |
| 3413 | |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 3414 | private function f_expect_gsup_msg(template GSUP_PDU msg, |
| 3415 | float T_val := 2.0) |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3416 | runs on BSC_ConnHdlr return GSUP_PDU { |
| 3417 | var GSUP_PDU gsup_msg_complete; |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 3418 | timer T := T_val; |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3419 | |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3420 | T.start; |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3421 | alt { |
| 3422 | [] GSUP.receive(msg) -> value gsup_msg_complete { |
| 3423 | setverdict(pass); |
| 3424 | } |
| 3425 | /* We don't expect anything else */ |
| 3426 | [] as_unexp_gsup_or_bssap_msg(); |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3427 | [] T.timeout { |
| 3428 | setverdict(fail, "Timeout waiting for GSUP message: ", msg); |
| 3429 | } |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3430 | } |
| 3431 | |
| 3432 | return gsup_msg_complete; |
| 3433 | } |
| 3434 | |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 3435 | private function f_expect_mt_dtap_msg(template PDU_ML3_NW_MS msg, |
| 3436 | float T_val := 2.0) |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3437 | runs on BSC_ConnHdlr return PDU_ML3_NW_MS { |
| 3438 | var PDU_DTAP_MT bssap_msg_complete; |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 3439 | timer T := T_val; |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3440 | |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3441 | T.start; |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3442 | alt { |
| 3443 | [] BSSAP.receive(tr_PDU_DTAP_MT(msg)) -> value bssap_msg_complete { |
| 3444 | setverdict(pass); |
| 3445 | } |
| 3446 | /* We don't expect anything else */ |
| 3447 | [] as_unexp_gsup_or_bssap_msg(); |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3448 | [] T.timeout { |
| 3449 | setverdict(fail, "Timeout waiting for BSSAP message: ", msg); |
| 3450 | } |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 3451 | } |
| 3452 | |
| 3453 | return bssap_msg_complete.dtap; |
| 3454 | } |
| 3455 | |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3456 | /* LU followed by MO USSD request */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3457 | 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] | 3458 | runs on BSC_ConnHdlr { |
| 3459 | f_init_handler(pars); |
| 3460 | |
| 3461 | /* Perform location update */ |
| 3462 | f_perform_lu(); |
| 3463 | |
| 3464 | /* Send CM Service Request for SS/USSD */ |
| 3465 | f_establish_fully(EST_TYPE_SS_ACT); |
| 3466 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3467 | /* We need to inspect GSUP activity */ |
| 3468 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3469 | |
| 3470 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 3471 | invoke_id := 5, /* Phone may not start from 0 or 1 */ |
| 3472 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3473 | ussd_string := "*#100#" |
| 3474 | ); |
| 3475 | |
| 3476 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 3477 | invoke_id := 5, /* InvokeID shall be the same for both REQ and RSP */ |
| 3478 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3479 | ussd_string := "Your extension is " & hex2str(g_pars.msisdn) & "\r" |
| 3480 | ) |
| 3481 | |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3482 | /* Compose a new SS/REGISTER message with request */ |
| 3483 | var template (value) PDU_ML3_MS_NW ussd_req := ts_ML3_MO_SS_REGISTER( |
| 3484 | tid := 1, /* We just need a single transaction */ |
| 3485 | 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] | 3486 | facility := valueof(facility_req) |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3487 | ); |
| 3488 | |
| 3489 | /* Compose SS/RELEASE_COMPLETE template with expected response */ |
| 3490 | var template PDU_ML3_NW_MS ussd_rsp := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3491 | tid := 1, /* Response should arrive within the same transaction */ |
| 3492 | 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] | 3493 | facility := valueof(facility_rsp) |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3494 | ); |
| 3495 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3496 | /* Compose expected MSC -> HLR message */ |
| 3497 | var template GSUP_PDU gsup_req := tr_GSUP_PROC_SS_REQ( |
| 3498 | imsi := g_pars.imsi, |
| 3499 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3500 | ss := valueof(facility_req) |
| 3501 | ); |
| 3502 | |
| 3503 | /* To be used for sending response with correct session ID */ |
| 3504 | var GSUP_PDU gsup_req_complete; |
| 3505 | |
| 3506 | /* Request own number */ |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3507 | BSSAP.send(ts_PDU_DTAP_MO(ussd_req)); |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3508 | /* Expect GSUP message containing the SS payload */ |
| 3509 | gsup_req_complete := f_expect_gsup_msg(gsup_req); |
| 3510 | |
| 3511 | /* Compose the response from HLR using received session ID */ |
| 3512 | var template GSUP_PDU gsup_rsp := ts_GSUP_PROC_SS_REQ( |
| 3513 | imsi := g_pars.imsi, |
| 3514 | sid := gsup_req_complete.ies[1].val.session_id, |
| 3515 | state := OSMO_GSUP_SESSION_STATE_END, |
| 3516 | ss := valueof(facility_rsp) |
| 3517 | ); |
| 3518 | |
| 3519 | /* Finally, HLR terminates the session */ |
| 3520 | GSUP.send(gsup_rsp); |
| 3521 | /* Expect RELEASE_COMPLETE message with the response */ |
| 3522 | f_expect_mt_dtap_msg(ussd_rsp); |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3523 | |
| 3524 | f_expect_clear(); |
| 3525 | } |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3526 | testcase TC_lu_and_mo_ussd_single_request() runs on MTC_CT { |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 3527 | var BSC_ConnHdlr vc_conn; |
| 3528 | f_init(); |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3529 | 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] | 3530 | vc_conn.done; |
| 3531 | } |
| 3532 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3533 | |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3534 | /* LU followed by MT USSD notification */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3535 | 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] | 3536 | runs on BSC_ConnHdlr { |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3537 | timer T := 5.0; |
| 3538 | |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3539 | f_init_handler(pars); |
| 3540 | |
| 3541 | /* Perform location update */ |
| 3542 | f_perform_lu(); |
| 3543 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 3544 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3545 | |
| 3546 | /* We need to inspect GSUP activity */ |
| 3547 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3548 | |
| 3549 | /* Facility IE with network-originated USSD notification */ |
| 3550 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 3551 | op_code := SS_OP_CODE_USS_NOTIFY, |
| 3552 | ussd_string := "Mahlzeit!" |
| 3553 | ); |
| 3554 | |
| 3555 | /* Facility IE with acknowledgment to the USSD notification */ |
| 3556 | var template OCTN facility_rsp := enc_SS_FacilityInformation( |
| 3557 | /* In case of USSD notification, Return Result is empty */ |
| 3558 | valueof(ts_SS_USSD_FACILITY_RETURN_RESULT_EMPTY()) |
| 3559 | ); |
| 3560 | |
| 3561 | /* Compose a new MT SS/REGISTER message with USSD notification */ |
| 3562 | var template PDU_ML3_NW_MS ussd_ntf := tr_ML3_MT_SS_REGISTER( |
| 3563 | tid := 0, /* FIXME: most likely, it should be 0 */ |
| 3564 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3565 | facility := valueof(facility_req) |
| 3566 | ); |
| 3567 | |
| 3568 | /* Compose HLR -> MSC GSUP message */ |
| 3569 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 3570 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3571 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3572 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3573 | ss := valueof(facility_req) |
| 3574 | ); |
| 3575 | |
| 3576 | /* Send it to MSC and expect Paging Request */ |
| 3577 | GSUP.send(gsup_req); |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3578 | T.start; |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3579 | alt { |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3580 | [pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 3581 | setverdict(pass); |
| 3582 | } |
Harald Welte | 62113fc | 2019-05-09 13:04:02 +0200 | [diff] [blame] | 3583 | [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] | 3584 | setverdict(pass); |
| 3585 | } |
| 3586 | /* We don't expect anything else */ |
| 3587 | [] as_unexp_gsup_or_bssap_msg(); |
Vadim Yanitskiy | d1e1ce5 | 2019-06-15 03:40:59 +0700 | [diff] [blame] | 3588 | [] T.timeout { |
| 3589 | setverdict(fail, "Timeout waiting for Paging Request"); |
| 3590 | } |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3591 | } |
| 3592 | |
| 3593 | /* Send Paging Response and expect USSD notification */ |
| 3594 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 3595 | /* Expect MT REGISTER message with USSD notification */ |
| 3596 | f_expect_mt_dtap_msg(ussd_ntf); |
| 3597 | |
| 3598 | /* Compose a new MO SS/FACILITY message with empty response */ |
| 3599 | var template (value) PDU_ML3_MS_NW ussd_rsp := ts_ML3_MO_SS_FACILITY( |
| 3600 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3601 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3602 | facility := valueof(facility_rsp) |
| 3603 | ); |
| 3604 | |
| 3605 | /* Compose expected MSC -> HLR GSUP message */ |
| 3606 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_REQ( |
| 3607 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3608 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3609 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 3610 | ss := valueof(facility_rsp) |
| 3611 | ); |
| 3612 | |
| 3613 | /* MS sends response to the notification */ |
| 3614 | BSSAP.send(ts_PDU_DTAP_MO(ussd_rsp)); |
| 3615 | /* Expect GSUP message containing the SS payload */ |
| 3616 | f_expect_gsup_msg(gsup_rsp); |
| 3617 | |
| 3618 | /* Compose expected MT SS/RELEASE COMPLETE message */ |
| 3619 | var template PDU_ML3_NW_MS ussd_term := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3620 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3621 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3622 | facility := omit |
| 3623 | ); |
| 3624 | |
| 3625 | /* Compose MSC -> HLR GSUP message */ |
| 3626 | var template GSUP_PDU gsup_term := ts_GSUP_PROC_SS_REQ( |
| 3627 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3628 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3629 | state := OSMO_GSUP_SESSION_STATE_END |
| 3630 | ); |
| 3631 | |
| 3632 | /* Finally, HLR terminates the session */ |
| 3633 | GSUP.send(gsup_term) |
| 3634 | /* Expect MT RELEASE COMPLETE without Facility IE */ |
| 3635 | f_expect_mt_dtap_msg(ussd_term); |
| 3636 | |
| 3637 | f_expect_clear(); |
| 3638 | } |
| 3639 | testcase TC_lu_and_mt_ussd_notification() runs on MTC_CT { |
| 3640 | var BSC_ConnHdlr vc_conn; |
| 3641 | f_init(); |
| 3642 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_ussd_notification), 47); |
| 3643 | vc_conn.done; |
| 3644 | } |
| 3645 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3646 | |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3647 | /* LU followed by MT call and MO USSD request during this call */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3648 | 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] | 3649 | runs on BSC_ConnHdlr { |
| 3650 | f_init_handler(pars); |
| 3651 | |
| 3652 | /* Call parameters taken from f_tc_lu_and_mt_call */ |
| 3653 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3654 | |
| 3655 | /* Perform location update */ |
| 3656 | f_perform_lu(); |
| 3657 | |
| 3658 | /* Establish a MT call */ |
| 3659 | f_mt_call_establish(cpars); |
| 3660 | |
| 3661 | /* Hold the call for some time */ |
| 3662 | f_sleep(1.0); |
| 3663 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3664 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 3665 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3666 | ussd_string := "*#100#" |
| 3667 | ); |
| 3668 | |
| 3669 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 3670 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3671 | ussd_string := "Your extension is " & hex2str(g_pars.msisdn) & "\r" |
| 3672 | ) |
| 3673 | |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3674 | /* Compose a new SS/REGISTER message with request */ |
| 3675 | var template (value) PDU_ML3_MS_NW ussd_req := ts_ML3_MO_SS_REGISTER( |
| 3676 | tid := 1, /* We just need a single transaction */ |
| 3677 | 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] | 3678 | facility := valueof(facility_req) |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3679 | ); |
| 3680 | |
| 3681 | /* Compose SS/RELEASE_COMPLETE template with expected response */ |
| 3682 | var template PDU_ML3_NW_MS ussd_rsp := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3683 | tid := 1, /* Response should arrive within the same transaction */ |
| 3684 | 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] | 3685 | facility := valueof(facility_rsp) |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3686 | ); |
| 3687 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3688 | /* Compose expected MSC -> HLR message */ |
| 3689 | var template GSUP_PDU gsup_req := tr_GSUP_PROC_SS_REQ( |
| 3690 | imsi := g_pars.imsi, |
| 3691 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3692 | ss := valueof(facility_req) |
| 3693 | ); |
| 3694 | |
| 3695 | /* To be used for sending response with correct session ID */ |
| 3696 | var GSUP_PDU gsup_req_complete; |
| 3697 | |
| 3698 | /* Request own number */ |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3699 | BSSAP.send(ts_PDU_DTAP_MO(ussd_req)); |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3700 | /* Expect GSUP message containing the SS payload */ |
| 3701 | gsup_req_complete := f_expect_gsup_msg(gsup_req); |
| 3702 | |
| 3703 | /* Compose the response from HLR using received session ID */ |
| 3704 | var template GSUP_PDU gsup_rsp := ts_GSUP_PROC_SS_REQ( |
| 3705 | imsi := g_pars.imsi, |
| 3706 | sid := gsup_req_complete.ies[1].val.session_id, |
| 3707 | state := OSMO_GSUP_SESSION_STATE_END, |
| 3708 | ss := valueof(facility_rsp) |
| 3709 | ); |
| 3710 | |
| 3711 | /* Finally, HLR terminates the session */ |
| 3712 | GSUP.send(gsup_rsp); |
| 3713 | /* Expect RELEASE_COMPLETE message with the response */ |
| 3714 | f_expect_mt_dtap_msg(ussd_rsp); |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3715 | |
| 3716 | /* Hold the call for some time */ |
| 3717 | f_sleep(1.0); |
| 3718 | |
| 3719 | /* Release the call (does Clear Complete itself) */ |
| 3720 | f_call_hangup(cpars, true); |
| 3721 | } |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3722 | 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] | 3723 | var BSC_ConnHdlr vc_conn; |
| 3724 | f_init(); |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3725 | 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] | 3726 | vc_conn.done; |
| 3727 | } |
| 3728 | |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 3729 | /* BSSMAP Clear Request in the middle of a call, see OS#3062 */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3730 | 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] | 3731 | f_init_handler(pars); |
| 3732 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 3733 | cpars.ran_clear_when_alerting := true; |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 3734 | |
| 3735 | f_perform_lu(); |
| 3736 | |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 3737 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 3738 | f_mo_call_establish(cpars); |
| 3739 | f_expect_clear() |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 3740 | deactivate(ccrel); |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 3741 | |
| 3742 | f_sleep(1.0); |
| 3743 | } |
| 3744 | testcase TC_mo_cc_bssmap_clear() runs on MTC_CT { |
| 3745 | var BSC_ConnHdlr vc_conn; |
| 3746 | f_init(); |
| 3747 | |
| 3748 | vc_conn := f_start_handler(refers(f_tc_mo_cc_bssmap_clear), 43); |
| 3749 | vc_conn.done; |
| 3750 | } |
| 3751 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3752 | |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3753 | /* LU followed by MT call and MT USSD request during this call */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3754 | 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] | 3755 | runs on BSC_ConnHdlr { |
| 3756 | f_init_handler(pars); |
| 3757 | |
| 3758 | /* Call parameters taken from f_tc_lu_and_mt_call */ |
| 3759 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3760 | |
| 3761 | /* Perform location update */ |
| 3762 | f_perform_lu(); |
| 3763 | |
| 3764 | /* Establish a MT call */ |
| 3765 | f_mt_call_establish(cpars); |
| 3766 | |
| 3767 | /* Hold the call for some time */ |
| 3768 | f_sleep(1.0); |
| 3769 | |
| 3770 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 3771 | op_code := SS_OP_CODE_USS_REQUEST, |
| 3772 | ussd_string := "Please type anything..." |
| 3773 | ); |
| 3774 | |
| 3775 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 3776 | op_code := SS_OP_CODE_USS_REQUEST, |
| 3777 | ussd_string := "Nope." |
| 3778 | ) |
| 3779 | |
| 3780 | /* Compose MT SS/REGISTER message with network-originated request */ |
| 3781 | var template (value) PDU_ML3_NW_MS ussd_req := ts_ML3_MT_SS_REGISTER( |
| 3782 | tid := 0, /* FIXME: most likely, it should be 0 */ |
| 3783 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3784 | facility := valueof(facility_req) |
| 3785 | ); |
| 3786 | |
| 3787 | /* Compose HLR -> MSC GSUP message */ |
| 3788 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 3789 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3790 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3791 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3792 | ss := valueof(facility_req) |
| 3793 | ); |
| 3794 | |
| 3795 | /* Send it to MSC */ |
| 3796 | GSUP.send(gsup_req); |
| 3797 | /* Expect MT REGISTER message with USSD request */ |
| 3798 | f_expect_mt_dtap_msg(ussd_req); |
| 3799 | |
| 3800 | /* Compose a new MO SS/FACILITY message with response */ |
| 3801 | var template (value) PDU_ML3_MS_NW ussd_rsp := ts_ML3_MO_SS_FACILITY( |
| 3802 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3803 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3804 | facility := valueof(facility_rsp) |
| 3805 | ); |
| 3806 | |
| 3807 | /* Compose expected MSC -> HLR GSUP message */ |
| 3808 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_REQ( |
| 3809 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3810 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3811 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 3812 | ss := valueof(facility_rsp) |
| 3813 | ); |
| 3814 | |
| 3815 | /* MS sends response */ |
| 3816 | BSSAP.send(ts_PDU_DTAP_MO(ussd_rsp)); |
| 3817 | f_expect_gsup_msg(gsup_rsp); |
| 3818 | |
| 3819 | /* Compose expected MT SS/RELEASE COMPLETE message */ |
| 3820 | var template PDU_ML3_NW_MS ussd_term := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3821 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3822 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3823 | facility := omit |
| 3824 | ); |
| 3825 | |
| 3826 | /* Compose MSC -> HLR GSUP message */ |
| 3827 | var template GSUP_PDU gsup_term := ts_GSUP_PROC_SS_REQ( |
| 3828 | imsi := g_pars.imsi, |
Vadim Yanitskiy | 2dd9661 | 2020-01-07 21:48:29 +0100 | [diff] [blame] | 3829 | sid := g_pars.gsup_sid, |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3830 | state := OSMO_GSUP_SESSION_STATE_END |
| 3831 | ); |
| 3832 | |
| 3833 | /* Finally, HLR terminates the session */ |
| 3834 | GSUP.send(gsup_term); |
| 3835 | /* Expect MT RELEASE COMPLETE without Facility IE */ |
| 3836 | f_expect_mt_dtap_msg(ussd_term); |
| 3837 | |
| 3838 | /* Hold the call for some time */ |
| 3839 | f_sleep(1.0); |
| 3840 | |
| 3841 | /* Release the call (does Clear Complete itself) */ |
| 3842 | f_call_hangup(cpars, true); |
| 3843 | } |
| 3844 | testcase TC_lu_and_mt_ussd_during_mt_call() runs on MTC_CT { |
| 3845 | var BSC_ConnHdlr vc_conn; |
| 3846 | f_init(); |
| 3847 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_ussd_during_mt_call), 49); |
| 3848 | vc_conn.done; |
| 3849 | } |
| 3850 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3851 | |
Vadim Yanitskiy | 2daf52d | 2018-06-21 04:19:58 +0700 | [diff] [blame] | 3852 | /* LU followed by MO USSD request and MO Release during transaction */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3853 | 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] | 3854 | runs on BSC_ConnHdlr { |
| 3855 | f_init_handler(pars); |
| 3856 | |
| 3857 | /* Perform location update */ |
| 3858 | f_perform_lu(); |
| 3859 | |
| 3860 | /* Send CM Service Request for SS/USSD */ |
| 3861 | f_establish_fully(EST_TYPE_SS_ACT); |
| 3862 | |
| 3863 | /* We need to inspect GSUP activity */ |
| 3864 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3865 | |
| 3866 | var template OCTN facility_ms_req := f_USSD_FACILITY_IE_INVOKE( |
| 3867 | invoke_id := 1, /* Initial request */ |
| 3868 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3869 | ussd_string := "*6766*266#" |
| 3870 | ); |
| 3871 | |
| 3872 | var template OCTN facility_net_req := f_USSD_FACILITY_IE_INVOKE( |
| 3873 | invoke_id := 2, /* Counter request */ |
| 3874 | op_code := SS_OP_CODE_USS_REQUEST, |
| 3875 | ussd_string := "Password?!?" |
| 3876 | ) |
| 3877 | |
| 3878 | /* Compose MO SS/REGISTER message with request */ |
| 3879 | var template (value) PDU_ML3_MS_NW ussd_ms_req := ts_ML3_MO_SS_REGISTER( |
| 3880 | tid := 1, /* We just need a single transaction */ |
| 3881 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3882 | facility := valueof(facility_ms_req) |
| 3883 | ); |
| 3884 | |
| 3885 | /* Compose expected MSC -> HLR message */ |
| 3886 | var template GSUP_PDU gsup_ms_req := tr_GSUP_PROC_SS_REQ( |
| 3887 | imsi := g_pars.imsi, |
| 3888 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3889 | ss := valueof(facility_ms_req) |
| 3890 | ); |
| 3891 | |
| 3892 | /* To be used for sending response with correct session ID */ |
| 3893 | var GSUP_PDU gsup_ms_req_complete; |
| 3894 | |
| 3895 | /* Initiate a new transaction */ |
| 3896 | BSSAP.send(ts_PDU_DTAP_MO(ussd_ms_req)); |
| 3897 | /* Expect GSUP request with original Facility IE */ |
| 3898 | gsup_ms_req_complete := f_expect_gsup_msg(gsup_ms_req); |
| 3899 | |
| 3900 | /* Compose the response from HLR using received session ID */ |
| 3901 | var template (value) GSUP_PDU gsup_net_req := ts_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_CONTINUE, |
| 3905 | ss := valueof(facility_net_req) |
| 3906 | ); |
| 3907 | |
| 3908 | /* Compose expected MT SS/FACILITY template with counter request */ |
| 3909 | var template PDU_ML3_NW_MS ussd_net_req := tr_ML3_MT_SS_FACILITY( |
| 3910 | tid := 1, /* Response should arrive within the same transaction */ |
| 3911 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3912 | facility := valueof(facility_net_req) |
| 3913 | ); |
| 3914 | |
| 3915 | /* Send response over GSUP */ |
| 3916 | GSUP.send(gsup_net_req); |
| 3917 | /* Expect MT SS/FACILITY message with counter request */ |
| 3918 | f_expect_mt_dtap_msg(ussd_net_req); |
| 3919 | |
| 3920 | /* Compose MO SS/RELEASE COMPLETE */ |
| 3921 | var template (value) PDU_ML3_MS_NW ussd_abort := ts_ML3_MO_SS_RELEASE_COMPLETE( |
| 3922 | tid := 1, /* Response should arrive within the same transaction */ |
| 3923 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3924 | facility := omit |
| 3925 | /* TODO: cause? */ |
| 3926 | ); |
| 3927 | |
| 3928 | /* Compose expected HLR -> MSC abort message */ |
| 3929 | var template GSUP_PDU gsup_abort := tr_GSUP_PROC_SS_REQ( |
| 3930 | imsi := g_pars.imsi, |
| 3931 | sid := gsup_ms_req_complete.ies[1].val.session_id, |
| 3932 | state := OSMO_GSUP_SESSION_STATE_END |
| 3933 | ); |
| 3934 | |
| 3935 | /* Abort transaction */ |
| 3936 | BSSAP.send(ts_PDU_DTAP_MO(ussd_abort)); |
| 3937 | /* Expect GSUP message indicating abort */ |
| 3938 | f_expect_gsup_msg(gsup_abort); |
| 3939 | |
| 3940 | f_expect_clear(); |
| 3941 | } |
| 3942 | testcase TC_lu_and_mo_ussd_mo_release() runs on MTC_CT { |
| 3943 | var BSC_ConnHdlr vc_conn; |
| 3944 | f_init(); |
| 3945 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_ussd_mo_release), 50); |
| 3946 | vc_conn.done; |
| 3947 | } |
| 3948 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3949 | |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 3950 | /* LU followed by MO USSD request and MT Release due to timeout */ |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 3951 | 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] | 3952 | runs on BSC_ConnHdlr { |
| 3953 | f_init_handler(pars); |
| 3954 | |
| 3955 | /* Perform location update */ |
| 3956 | f_perform_lu(); |
| 3957 | |
| 3958 | /* Send CM Service Request for SS/USSD */ |
| 3959 | f_establish_fully(EST_TYPE_SS_ACT); |
| 3960 | |
| 3961 | /* We need to inspect GSUP activity */ |
| 3962 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3963 | |
| 3964 | var template OCTN facility_ms_req := f_USSD_FACILITY_IE_INVOKE( |
| 3965 | invoke_id := 1, |
| 3966 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3967 | ussd_string := "#release_me"); |
| 3968 | |
| 3969 | /* Compose MO SS/REGISTER message with request */ |
| 3970 | var template (value) PDU_ML3_MS_NW ussd_ms_req := ts_ML3_MO_SS_REGISTER( |
| 3971 | tid := 1, /* An arbitrary transaction identifier */ |
| 3972 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3973 | facility := valueof(facility_ms_req)); |
| 3974 | |
| 3975 | /* Compose expected MSC -> HLR message */ |
| 3976 | var template GSUP_PDU gsup_ms_req := tr_GSUP_PROC_SS_REQ( |
| 3977 | imsi := g_pars.imsi, |
| 3978 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3979 | ss := valueof(facility_ms_req)); |
| 3980 | |
| 3981 | /* To be used for sending response with correct session ID */ |
| 3982 | var GSUP_PDU gsup_ms_req_complete; |
| 3983 | |
| 3984 | /* Initiate a new SS transaction */ |
| 3985 | BSSAP.send(ts_PDU_DTAP_MO(ussd_ms_req)); |
| 3986 | /* Expect GSUP request with original Facility IE */ |
| 3987 | gsup_ms_req_complete := f_expect_gsup_msg(gsup_ms_req); |
| 3988 | |
| 3989 | /* Don't respond, wait for timeout */ |
| 3990 | f_sleep(3.0); |
| 3991 | |
| 3992 | var template PDU_ML3_NW_MS dtap_rel := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3993 | tid := 1, /* Should match the request's tid */ |
| 3994 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3995 | cause := *, /* TODO: expect some specific value */ |
| 3996 | facility := omit); |
| 3997 | |
| 3998 | var template GSUP_PDU gsup_rel := tr_GSUP_PROC_SS_ERR( |
| 3999 | imsi := g_pars.imsi, |
| 4000 | sid := gsup_ms_req_complete.ies[1].val.session_id, |
| 4001 | state := OSMO_GSUP_SESSION_STATE_END, |
| 4002 | cause := ?); /* TODO: expect some specific value */ |
| 4003 | |
| 4004 | /* Expect release on both interfaces */ |
| 4005 | interleave { |
| 4006 | [] BSSAP.receive(tr_PDU_DTAP_MT(dtap_rel)) { }; |
| 4007 | [] GSUP.receive(gsup_rel) { }; |
| 4008 | } |
| 4009 | |
| 4010 | f_expect_clear(); |
| 4011 | setverdict(pass); |
| 4012 | } |
| 4013 | testcase TC_lu_and_ss_session_timeout() runs on MTC_CT { |
| 4014 | var BSC_ConnHdlr vc_conn; |
| 4015 | f_init(); |
Vadim Yanitskiy | 36d28dd | 2018-12-03 02:45:45 +0700 | [diff] [blame] | 4016 | f_vty_config(MSCVTY, "msc", "ncss guard-timeout 3"); |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 4017 | vc_conn := f_start_handler(refers(f_tc_lu_and_ss_session_timeout), 51); |
| 4018 | vc_conn.done; |
Vadim Yanitskiy | 36d28dd | 2018-12-03 02:45:45 +0700 | [diff] [blame] | 4019 | f_vty_config(MSCVTY, "msc", "ncss guard-timeout 0"); |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 4020 | } |
| 4021 | |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 4022 | /* MT (network-originated) USSD for unknown subscriber */ |
| 4023 | friend function f_tc_mt_ussd_for_unknown_subscr(charstring id, BSC_ConnHdlrPars pars) |
| 4024 | runs on BSC_ConnHdlr { |
| 4025 | var hexstring imsi := '000000000000000'H; /* Some unknown IMSI */ |
| 4026 | var OCT4 sid := '20000222'O; |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 4027 | |
| 4028 | f_init_handler(pars); |
| 4029 | f_ran_register_imsi(imsi, 'FFFFFFFF'O); |
| 4030 | f_create_gsup_expect(hex2str(imsi)); |
| 4031 | |
| 4032 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 4033 | imsi := imsi, |
| 4034 | sid := sid, |
| 4035 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 4036 | ss := f_rnd_octstring(23) |
| 4037 | ); |
| 4038 | |
| 4039 | /* Error with cause GMM_CAUSE_IMSI_UNKNOWN */ |
| 4040 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_ERR( |
| 4041 | imsi := imsi, |
| 4042 | sid := sid, |
| 4043 | state := OSMO_GSUP_SESSION_STATE_END, |
| 4044 | cause := 2 /* FIXME: introduce an enumerated type! */ |
| 4045 | ); |
| 4046 | |
| 4047 | /* Initiate a MT USSD notification */ |
| 4048 | GSUP.send(gsup_req); |
| 4049 | |
| 4050 | /* Expect GSUP PROC_SS_ERROR message */ |
Vadim Yanitskiy | 851798c | 2019-06-15 14:22:28 +0700 | [diff] [blame] | 4051 | f_expect_gsup_msg(gsup_rsp); |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 4052 | } |
| 4053 | testcase TC_mt_ussd_for_unknown_subscr() runs on MTC_CT { |
| 4054 | var BSC_ConnHdlr vc_conn; |
| 4055 | f_init(); |
| 4056 | vc_conn := f_start_handler(refers(f_tc_mt_ussd_for_unknown_subscr), 0); |
| 4057 | vc_conn.done; |
| 4058 | } |
| 4059 | |
Vadim Yanitskiy | c3c07d4 | 2019-06-17 23:00:44 +0700 | [diff] [blame] | 4060 | /* MO (mobile-originated) SS/USSD for unknown transaction */ |
| 4061 | friend function f_tc_mo_ussd_for_unknown_trans(charstring id, BSC_ConnHdlrPars pars) |
| 4062 | runs on BSC_ConnHdlr { |
| 4063 | f_init_handler(pars); |
| 4064 | |
Vadim Yanitskiy | 70d15bf | 2020-01-09 22:51:01 +0100 | [diff] [blame] | 4065 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | c3c07d4 | 2019-06-17 23:00:44 +0700 | [diff] [blame] | 4066 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4067 | |
| 4068 | /* Perform location update */ |
| 4069 | f_perform_lu(); |
| 4070 | |
| 4071 | /* Send CM Service Request for SS/USSD */ |
| 4072 | f_establish_fully(EST_TYPE_SS_ACT); |
| 4073 | |
| 4074 | /* GSM 04.80 FACILITY message for a non-existing transaction */ |
| 4075 | var template (value) PDU_ML3_MS_NW mo_ss_fac := ts_ML3_MO_SS_FACILITY( |
| 4076 | tid := 1, /* An arbitrary transaction identifier */ |
| 4077 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 4078 | facility := f_rnd_octstring(23) /* We don't care about the Facility IE */ |
| 4079 | ); |
| 4080 | |
| 4081 | /* GSM 04.80 RELEASE COMPLETE message for a non-existing transaction */ |
| 4082 | var template (value) PDU_ML3_MS_NW mo_ss_rel := ts_ML3_MO_SS_RELEASE_COMPLETE( |
| 4083 | tid := 1, /* An arbitrary transaction identifier */ |
| 4084 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 4085 | facility := f_rnd_octstring(23) /* We don't care about the Facility IE */ |
| 4086 | ); |
| 4087 | |
| 4088 | /* Expected response from the network */ |
| 4089 | var template PDU_ML3_NW_MS mt_ss_rel := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 4090 | tid := 1, /* Same as in the FACILITY message */ |
| 4091 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 4092 | facility := omit |
| 4093 | ); |
| 4094 | |
| 4095 | /* Send GSM 04.80 FACILITY for non-existing transaction */ |
| 4096 | BSSAP.send(ts_PDU_DTAP_MO(mo_ss_fac)); |
| 4097 | |
| 4098 | /* Expect GSM 04.80 RELEASE COMPLETE message */ |
| 4099 | f_expect_mt_dtap_msg(mt_ss_rel); |
| 4100 | f_expect_clear(); |
| 4101 | |
| 4102 | /* Send another CM Service Request for SS/USSD */ |
| 4103 | f_establish_fully(EST_TYPE_SS_ACT); |
| 4104 | |
| 4105 | /* Send GSM 04.80 RELEASE COMPLETE for non-existing transaction */ |
| 4106 | BSSAP.send(ts_PDU_DTAP_MO(mo_ss_rel)); |
| 4107 | |
| 4108 | /* Expect GSM 04.80 RELEASE COMPLETE message */ |
| 4109 | f_expect_mt_dtap_msg(mt_ss_rel); |
| 4110 | f_expect_clear(); |
| 4111 | } |
| 4112 | testcase TC_mo_ussd_for_unknown_trans() runs on MTC_CT { |
| 4113 | var BSC_ConnHdlr vc_conn; |
| 4114 | f_init(); |
| 4115 | vc_conn := f_start_handler(refers(f_tc_mo_ussd_for_unknown_trans), 111); |
| 4116 | vc_conn.done; |
| 4117 | } |
| 4118 | |
Vadim Yanitskiy | d612d28 | 2019-06-15 14:46:03 +0700 | [diff] [blame] | 4119 | /* MT (network-originated) USSD for unknown session */ |
| 4120 | friend function f_tc_proc_ss_for_unknown_session(charstring id, BSC_ConnHdlrPars pars) |
| 4121 | runs on BSC_ConnHdlr { |
| 4122 | var OCT4 sid := '20000333'O; |
| 4123 | |
| 4124 | f_init_handler(pars); |
| 4125 | |
| 4126 | /* Perform location update */ |
| 4127 | f_perform_lu(); |
| 4128 | |
Vadim Yanitskiy | 70d15bf | 2020-01-09 22:51:01 +0100 | [diff] [blame] | 4129 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | d612d28 | 2019-06-15 14:46:03 +0700 | [diff] [blame] | 4130 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4131 | |
| 4132 | /* Request referencing a non-existing SS session */ |
| 4133 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 4134 | imsi := g_pars.imsi, |
| 4135 | sid := sid, |
| 4136 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 4137 | ss := f_rnd_octstring(23) |
| 4138 | ); |
| 4139 | |
| 4140 | /* Error with some cause value */ |
| 4141 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_ERR( |
| 4142 | imsi := g_pars.imsi, |
| 4143 | sid := sid, |
| 4144 | state := OSMO_GSUP_SESSION_STATE_END, |
| 4145 | cause := ? /* FIXME: introduce an enumerated type! */ |
| 4146 | ); |
| 4147 | |
| 4148 | /* Initiate a MT USSD notification */ |
| 4149 | GSUP.send(gsup_req); |
| 4150 | |
| 4151 | /* Expect GSUP PROC_SS_ERROR message */ |
| 4152 | f_expect_gsup_msg(gsup_rsp); |
| 4153 | } |
| 4154 | testcase TC_proc_ss_for_unknown_session() runs on MTC_CT { |
| 4155 | var BSC_ConnHdlr vc_conn; |
| 4156 | f_init(); |
| 4157 | vc_conn := f_start_handler(refers(f_tc_proc_ss_for_unknown_session), 110); |
| 4158 | vc_conn.done; |
| 4159 | } |
| 4160 | |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 4161 | /* MT (network-originated) USSD and no response to Paging Request */ |
| 4162 | friend function f_tc_proc_ss_paging_fail(charstring id, BSC_ConnHdlrPars pars) |
| 4163 | runs on BSC_ConnHdlr { |
| 4164 | timer TP := 2.0; /* Paging timer */ |
| 4165 | |
| 4166 | f_init_handler(pars); |
| 4167 | |
| 4168 | /* Perform location update */ |
| 4169 | f_perform_lu(); |
| 4170 | |
Vadim Yanitskiy | 70d15bf | 2020-01-09 22:51:01 +0100 | [diff] [blame] | 4171 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 4172 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4173 | |
| 4174 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 4175 | imsi := g_pars.imsi, |
| 4176 | sid := '20000444'O, |
| 4177 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 4178 | ss := f_rnd_octstring(23) |
| 4179 | ); |
| 4180 | |
| 4181 | /* Error with some cause value */ |
| 4182 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_ERR( |
| 4183 | imsi := g_pars.imsi, |
| 4184 | sid := '20000444'O, |
| 4185 | state := OSMO_GSUP_SESSION_STATE_END, |
| 4186 | cause := ? /* FIXME: introduce an enumerated type! */ |
| 4187 | ); |
| 4188 | |
| 4189 | /* Initiate a MT USSD notification */ |
| 4190 | GSUP.send(gsup_req); |
| 4191 | |
| 4192 | /* Send it to MSC and expect Paging Request */ |
| 4193 | TP.start; |
| 4194 | alt { |
| 4195 | [pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 4196 | setverdict(pass); |
| 4197 | } |
| 4198 | [not pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) { |
| 4199 | setverdict(pass); |
| 4200 | } |
| 4201 | /* We don't expect anything else */ |
| 4202 | [] as_unexp_gsup_or_bssap_msg(); |
| 4203 | [] TP.timeout { |
| 4204 | setverdict(fail, "Timeout waiting for Paging Request"); |
| 4205 | } |
| 4206 | } |
| 4207 | |
Vadim Yanitskiy | d24b525 | 2019-10-02 00:04:51 +0700 | [diff] [blame] | 4208 | /* Wait up to 20 seconds for GSUP PROC_SS_ERROR message. |
| 4209 | * OsmoMSC waits for Paging Response 10 seconds by default. */ |
| 4210 | f_expect_gsup_msg(gsup_rsp, T_val := 20.0); |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 4211 | } |
| 4212 | testcase TC_proc_ss_paging_fail() runs on MTC_CT { |
| 4213 | var BSC_ConnHdlr vc_conn; |
| 4214 | f_init(); |
| 4215 | vc_conn := f_start_handler(refers(f_tc_proc_ss_paging_fail), 101); |
| 4216 | vc_conn.done; |
| 4217 | } |
| 4218 | |
Vadim Yanitskiy | 29ba8d6 | 2019-06-16 15:19:41 +0700 | [diff] [blame] | 4219 | /* MT (network-originated) USSD followed by immediate abort */ |
| 4220 | friend function f_tc_proc_ss_abort(charstring id, BSC_ConnHdlrPars pars) |
| 4221 | runs on BSC_ConnHdlr { |
| 4222 | var octetstring facility := f_rnd_octstring(23); |
| 4223 | var OCT4 sid := '20000555'O; |
| 4224 | timer TP := 2.0; |
| 4225 | |
| 4226 | f_init_handler(pars); |
| 4227 | |
| 4228 | /* Perform location update */ |
| 4229 | f_perform_lu(); |
| 4230 | |
Vadim Yanitskiy | 70d15bf | 2020-01-09 22:51:01 +0100 | [diff] [blame] | 4231 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 29ba8d6 | 2019-06-16 15:19:41 +0700 | [diff] [blame] | 4232 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4233 | |
| 4234 | /* PROC_SS_REQ initiates a mobile-originated SS/USSD session */ |
| 4235 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 4236 | imsi := g_pars.imsi, sid := sid, |
| 4237 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 4238 | ss := facility |
| 4239 | ); |
| 4240 | |
| 4241 | /* On the MS side, we expect GSM 04.80 REGISTER message */ |
| 4242 | var template PDU_ML3_NW_MS dtap_reg := tr_ML3_MT_SS_REGISTER( |
| 4243 | tid := 0, /* Most likely, it should be 0 */ |
| 4244 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 4245 | facility := facility |
| 4246 | ); |
| 4247 | |
| 4248 | /* PROC_SS_ERR with SESSION_STATE_END terminates the SS/USSD session */ |
| 4249 | var template (value) GSUP_PDU gsup_abort := ts_GSUP_PROC_SS_ERR( |
| 4250 | imsi := g_pars.imsi, sid := sid, |
| 4251 | state := OSMO_GSUP_SESSION_STATE_END, |
| 4252 | cause := 0 /* FIXME: introduce an enumerated type! */ |
| 4253 | ); |
| 4254 | |
| 4255 | /* On the MS side, we expect GSM 04.80 REGISTER message */ |
| 4256 | var template PDU_ML3_NW_MS dtap_rel := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 4257 | tid := 0, /* Most likely, it should be 0 */ |
| 4258 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 4259 | cause := *, /* FIXME: expect some specific cause value */ |
| 4260 | facility := omit |
| 4261 | ); |
| 4262 | |
| 4263 | /* Initiate a MT USSD with random payload */ |
| 4264 | GSUP.send(gsup_req); |
| 4265 | |
| 4266 | /* Expect Paging Request */ |
| 4267 | TP.start; |
| 4268 | alt { |
| 4269 | [pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 4270 | setverdict(pass); |
| 4271 | } |
| 4272 | [not pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) { |
| 4273 | setverdict(pass); |
| 4274 | } |
| 4275 | /* We don't expect anything else */ |
| 4276 | [] as_unexp_gsup_or_bssap_msg(); |
| 4277 | [] TP.timeout { |
| 4278 | setverdict(fail, "Timeout waiting for Paging Request"); |
| 4279 | } |
| 4280 | } |
| 4281 | |
| 4282 | /* Send Paging Response and establish connection */ |
| 4283 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 4284 | /* Expect MT REGISTER message with random facility */ |
| 4285 | f_expect_mt_dtap_msg(dtap_reg); |
| 4286 | |
| 4287 | /* HLR/EUSE decides to abort the session even |
| 4288 | * before getting any response from the MS */ |
| 4289 | /* Initiate a MT USSD with random payload */ |
| 4290 | GSUP.send(gsup_abort); |
| 4291 | |
| 4292 | /* Expect RELEASE COMPLETE on ths MS side */ |
| 4293 | f_expect_mt_dtap_msg(dtap_rel); |
| 4294 | |
| 4295 | f_expect_clear(); |
| 4296 | } |
| 4297 | testcase TC_proc_ss_abort() runs on MTC_CT { |
| 4298 | var BSC_ConnHdlr vc_conn; |
| 4299 | f_init(); |
| 4300 | vc_conn := f_start_handler(refers(f_tc_proc_ss_abort), 102); |
| 4301 | vc_conn.done; |
| 4302 | } |
| 4303 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 4304 | |
Vadim Yanitskiy | 1c9754d | 2020-01-07 21:56:55 +0100 | [diff] [blame] | 4305 | /* Verify multiple concurrent MO SS/USSD transactions |
| 4306 | * (one subscriber - one transaction) */ |
| 4307 | testcase TC_multi_lu_and_mo_ussd() runs on MTC_CT { |
| 4308 | var BSC_ConnHdlr vc_conn[16]; |
| 4309 | var integer i; |
| 4310 | |
| 4311 | f_init(); |
| 4312 | |
| 4313 | for (i := 0; i < sizeof(vc_conn); i := i + 1) { |
| 4314 | vc_conn[i] := f_start_handler(refers(f_tc_lu_and_mo_ussd_single_request), 210 + i); |
| 4315 | } |
| 4316 | |
| 4317 | for (i := 0; i < sizeof(vc_conn); i := i + 1) { |
| 4318 | vc_conn[i].done; |
| 4319 | } |
| 4320 | } |
| 4321 | |
| 4322 | /* Verify multiple concurrent MT SS/USSD transactions |
| 4323 | * (one subscriber - one transaction) */ |
| 4324 | testcase TC_multi_lu_and_mt_ussd() runs on MTC_CT { |
| 4325 | var BSC_ConnHdlr vc_conn[16]; |
| 4326 | var integer i; |
| 4327 | var OCT4 sid; |
| 4328 | |
| 4329 | f_init(); |
| 4330 | |
| 4331 | for (i := 0; i < sizeof(vc_conn); i := i + 1) { |
| 4332 | sid := '200001'O & int2oct(i, 1); /* All transactions must use different session ID */ |
| 4333 | vc_conn[i] := f_start_handler_with_pars(refers(f_tc_lu_and_mt_ussd_notification), |
| 4334 | f_init_pars(226 + i, gsup_sid := sid)); |
| 4335 | } |
| 4336 | |
| 4337 | for (i := 0; i < sizeof(vc_conn); i := i + 1) { |
| 4338 | vc_conn[i].done; |
| 4339 | } |
| 4340 | } |
| 4341 | |
| 4342 | |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 4343 | /* A5/1 only permitted on network side; attempt an invalid CIPHER MODE COMPLETE with A5/3 which MSC should reject. */ |
| 4344 | private function f_tc_cipher_complete_with_invalid_cipher(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4345 | pars.net.expect_auth := true; |
| 4346 | pars.net.expect_ciph := true; |
| 4347 | pars.net.kc_support := '02'O; /* A5/1 only */ |
| 4348 | f_init_handler(pars); |
| 4349 | |
| 4350 | g_pars.vec := f_gen_auth_vec_2g(); |
| 4351 | |
| 4352 | /* Can't use f_perform_lu() directly. Code below is based on it. */ |
| 4353 | |
| 4354 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 4355 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4356 | |
| 4357 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 4358 | 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] | 4359 | f_cl3_or_initial_ue(l3_lu); |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 4360 | |
| 4361 | f_mm_auth(); |
| 4362 | |
| 4363 | var OCT1 a5_net := f_alg_mask_from_cm(g_pars.cm2); |
| 4364 | var OCT1 a5_intersect := g_pars.net.kc_support and4b a5_net; |
| 4365 | alt { |
| 4366 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(a5_intersect, g_pars.vec.kc)) { |
| 4367 | BSSAP.send(ts_BSSMAP_CipherModeCompl(int2oct(4 /* "accept" A5/3 */, 1))); |
| 4368 | } |
| 4369 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?, g_pars.vec.kc)) { |
| 4370 | setverdict(fail, "Wrong ciphering algorithm mask in CiphModCmd"); |
| 4371 | mtc.stop; |
| 4372 | } |
| 4373 | [] BSSAP.receive { |
| 4374 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 4375 | mtc.stop; |
| 4376 | } |
| 4377 | } |
Harald Welte | 79f1e45 | 2020-08-18 22:55:02 +0200 | [diff] [blame] | 4378 | f_expect_common_id(); |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 4379 | |
| 4380 | /* Expect LU reject from MSC. */ |
| 4381 | alt { |
| 4382 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 4383 | setverdict(pass); |
| 4384 | } |
| 4385 | [] BSSAP.receive { |
| 4386 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 4387 | mtc.stop; |
| 4388 | } |
| 4389 | } |
Stefan Sperling | c620b35 | 2018-12-18 17:23:36 +0100 | [diff] [blame] | 4390 | f_expect_clear(); |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 4391 | } |
| 4392 | |
| 4393 | testcase TC_cipher_complete_with_invalid_cipher() runs on MTC_CT { |
| 4394 | var BSC_ConnHdlr vc_conn; |
| 4395 | f_init(); |
| 4396 | f_vty_config(MSCVTY, "network", "encryption a5 1"); |
| 4397 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 4398 | 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] | 4399 | vc_conn.done; |
| 4400 | } |
| 4401 | |
Harald Welte | b2284bd | 2019-05-10 11:30:43 +0200 | [diff] [blame] | 4402 | /* Location Update with invalid (non-matching) MCC/MNC reported on BSSMAP level from BSC */ |
| 4403 | friend function f_tc_lu_with_invalid_mcc_mnc(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4404 | f_init_handler(pars); |
| 4405 | |
| 4406 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 4407 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4408 | |
| 4409 | /* modify the cell ID which will be used to construct the COMPLELTE L3 or InitialUE */ |
| 4410 | g_pars.cell_id := valueof(ts_CellId_CGI('333'H, '22'H, 23, 42)); |
| 4411 | |
| 4412 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 4413 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 4414 | f_cl3_or_initial_ue(l3_lu); |
Harald Welte | 79f1e45 | 2020-08-18 22:55:02 +0200 | [diff] [blame] | 4415 | f_expect_common_id(); |
Harald Welte | b2284bd | 2019-05-10 11:30:43 +0200 | [diff] [blame] | 4416 | |
| 4417 | /* Expect LU reject from MSC. */ |
| 4418 | alt { |
| 4419 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 4420 | setverdict(pass); |
| 4421 | } |
| 4422 | [] BSSAP.receive { |
| 4423 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 4424 | mtc.stop; |
| 4425 | } |
| 4426 | } |
Eric Wild | 85cc161 | 2022-03-30 01:44:29 +0200 | [diff] [blame] | 4427 | f_expect_clear(verify_vlr_cell_id:=false); |
Harald Welte | b2284bd | 2019-05-10 11:30:43 +0200 | [diff] [blame] | 4428 | } |
| 4429 | testcase TC_lu_with_invalid_mcc_mnc() runs on MTC_CT { |
| 4430 | var BSC_ConnHdlr vc_conn; |
| 4431 | f_init(); |
| 4432 | vc_conn := f_start_handler(refers(f_tc_lu_with_invalid_mcc_mnc), 54); |
| 4433 | vc_conn.done; |
| 4434 | } |
| 4435 | |
Stefan Sperling | a2d59c6 | 2018-12-18 16:32:44 +0100 | [diff] [blame] | 4436 | private function f_tc_cipher_complete_without_alg(charstring id, BSC_ConnHdlrPars pars, octetstring kc_support) runs on BSC_ConnHdlr { |
| 4437 | pars.net.expect_auth := true; |
| 4438 | pars.net.expect_ciph := true; |
| 4439 | pars.net.kc_support := kc_support; |
| 4440 | f_init_handler(pars); |
| 4441 | |
| 4442 | g_pars.vec := f_gen_auth_vec_2g(); |
| 4443 | |
| 4444 | /* Can't use f_perform_lu() directly. Code below is based on it. */ |
| 4445 | |
| 4446 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 4447 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4448 | |
| 4449 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 4450 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 4451 | f_cl3_or_initial_ue(l3_lu); |
| 4452 | |
| 4453 | f_mm_auth(); |
| 4454 | |
| 4455 | var OCT1 a5_net := f_alg_mask_from_cm(g_pars.cm2); |
| 4456 | var OCT1 a5_intersect := g_pars.net.kc_support and4b a5_net; |
| 4457 | alt { |
| 4458 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(a5_intersect, g_pars.vec.kc)) { |
| 4459 | BSSAP.send(ts_BSSMAP_CipherModeComplAlg(omit)); |
| 4460 | } |
| 4461 | [] BSSAP.receive(tr_BSSMAP_ClassmarkReq) { |
| 4462 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 4463 | repeat; |
| 4464 | } |
| 4465 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?, g_pars.vec.kc)) { |
| 4466 | setverdict(fail, "Wrong ciphering algorithm mask in CiphModCmd"); |
| 4467 | mtc.stop; |
| 4468 | } |
| 4469 | [] BSSAP.receive { |
| 4470 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 4471 | mtc.stop; |
| 4472 | } |
| 4473 | } |
Harald Welte | 79f1e45 | 2020-08-18 22:55:02 +0200 | [diff] [blame] | 4474 | f_expect_common_id(); |
Stefan Sperling | a2d59c6 | 2018-12-18 16:32:44 +0100 | [diff] [blame] | 4475 | |
| 4476 | /* TODO: Verify MSC is using the best cipher available! How? */ |
| 4477 | |
| 4478 | f_msc_lu_hlr(); |
Neels Hofmeyr | e860fc4 | 2022-10-05 01:15:54 +0200 | [diff] [blame] | 4479 | as_accept_reject_lu(); |
Stefan Sperling | a2d59c6 | 2018-12-18 16:32:44 +0100 | [diff] [blame] | 4480 | f_expect_clear(); |
| 4481 | setverdict(pass); |
| 4482 | } |
| 4483 | |
| 4484 | /* A5/1 only permitted on network side; attempt CIPHER MODE COMPLETE without specifying the accepted algorithm. */ |
| 4485 | private function f_tc_cipher_complete_1_without_cipher(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4486 | f_tc_cipher_complete_without_alg(id, pars, '02'O /* A5/1 only */); |
| 4487 | } |
| 4488 | |
| 4489 | /* A5/3 only permitted on network side; attempt CIPHER MODE COMPLETE without specifying the accepted algorithm. */ |
| 4490 | private function f_tc_cipher_complete_3_without_cipher(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4491 | f_tc_cipher_complete_without_alg(id, pars, '08'O /* A5/3 only */); |
| 4492 | } |
| 4493 | |
| 4494 | /* A5/1 + A5/3 permitted on network side; attempt CIPHER MODE COMPLETE without specifying the accepted algorithm. */ |
| 4495 | private function f_tc_cipher_complete_13_without_cipher(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4496 | f_tc_cipher_complete_without_alg(id, pars, '0A'O /* A5/1 and A5/3 enabled */); |
| 4497 | } |
| 4498 | |
| 4499 | testcase TC_cipher_complete_1_without_cipher() runs on MTC_CT { |
| 4500 | var BSC_ConnHdlr vc_conn; |
| 4501 | f_init(); |
| 4502 | f_vty_config(MSCVTY, "network", "encryption a5 1"); |
| 4503 | |
| 4504 | vc_conn := f_start_handler(refers(f_tc_cipher_complete_1_without_cipher), 53); |
| 4505 | vc_conn.done; |
| 4506 | } |
| 4507 | |
| 4508 | testcase TC_cipher_complete_3_without_cipher() runs on MTC_CT { |
| 4509 | var BSC_ConnHdlr vc_conn; |
| 4510 | f_init(); |
| 4511 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 4512 | |
| 4513 | vc_conn := f_start_handler(refers(f_tc_cipher_complete_3_without_cipher), 54); |
| 4514 | vc_conn.done; |
| 4515 | } |
| 4516 | |
| 4517 | testcase TC_cipher_complete_13_without_cipher() runs on MTC_CT { |
| 4518 | var BSC_ConnHdlr vc_conn; |
| 4519 | f_init(); |
| 4520 | f_vty_config(MSCVTY, "network", "encryption a5 1 3"); |
| 4521 | |
| 4522 | vc_conn := f_start_handler(refers(f_tc_cipher_complete_13_without_cipher), 55); |
| 4523 | vc_conn.done; |
| 4524 | } |
Harald Welte | b2284bd | 2019-05-10 11:30:43 +0200 | [diff] [blame] | 4525 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 4526 | /* TODO (SMS): |
| 4527 | * different user data lengths |
| 4528 | * SMPP transaction mode with unsuccessful delivery |
| 4529 | * queued MT-SMS with no paging response + later delivery |
| 4530 | * different data coding schemes |
| 4531 | * multi-part SMS |
| 4532 | * user-data headers |
| 4533 | * TP-PID for SMS to SIM |
| 4534 | * behavior if SMS memory is full + RP-SMMA |
| 4535 | * delivery reports |
| 4536 | * SMPP osmocom extensions |
| 4537 | * more-messages-to-send |
| 4538 | * SMS during ongoing call (SACCH/SAPI3) |
| 4539 | */ |
| 4540 | |
| 4541 | /* TODO (General): |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 4542 | * continue to send repeated MO signalling messages to keep channel open: does MSC tmeout? |
| 4543 | * malformed messages (missing IE, invalid message type): properly rejected? |
| 4544 | * MT call while LU or is ongoing: Do we use existing lchan or page while lchan active? |
| 4545 | * 3G/2G auth permutations |
| 4546 | * encryption algorithms vs. classmark vs. vty config |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 4547 | * send new transaction after/during clear (like SMS, ...) |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 4548 | * too long L3 INFO in DTAP |
| 4549 | * too long / padded BSSAP |
| 4550 | * too long / short TLV values |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 4551 | */ |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 4552 | |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 4553 | /*********************************************************************** |
| 4554 | * SGsAP Testing |
| 4555 | ***********************************************************************/ |
| 4556 | |
Philipp Maier | 948747b | 2019-04-02 15:22:33 +0200 | [diff] [blame] | 4557 | /* Check if a subscriber exists in the VLR */ |
| 4558 | private function f_ctrl_subscr_in_vlr(charstring imsi_or_msisdn) runs on BSC_ConnHdlr return boolean { |
| 4559 | |
| 4560 | var CtrlValue active_subsribers; |
| 4561 | var integer rc; |
| 4562 | active_subsribers := f_ctrl_get(IPA_CTRL, "subscriber-list-active-v1"); |
| 4563 | |
| 4564 | rc := f_strstr(active_subsribers, imsi_or_msisdn); |
| 4565 | if (rc < 0) { |
| 4566 | return false; |
| 4567 | } |
| 4568 | |
| 4569 | return true; |
| 4570 | } |
| 4571 | |
Pau Espin Pedrol | cefe9da | 2021-07-02 18:38:27 +0200 | [diff] [blame] | 4572 | /* 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] | 4573 | * that everything is back to normal. */ |
| 4574 | private function f_sgsap_bssmap_screening() runs on BSC_ConnHdlr { |
| 4575 | var SmsParameters spars := valueof(t_SmsPars); |
| 4576 | |
Pau Espin Pedrol | 7593a8a | 2021-07-02 18:55:16 +0200 | [diff] [blame] | 4577 | /* From now on, since we initiated LU from A-Interface, we expect no |
| 4578 | * LastEutranPLMNId on Common Id, since the SGs interface should be gone |
| 4579 | */ |
| 4580 | g_pars.common_id_last_eutran_plmn := omit; |
| 4581 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4582 | /* Perform a location update, the SGs association is expected to fall |
| 4583 | * back to NULL */ |
| 4584 | f_perform_lu(); |
| 4585 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4586 | |
| 4587 | /* Trigger a paging request and expect the paging on BSSMAP, this is |
| 4588 | * to make sure that pagings are sent throught the A-Interface again |
| 4589 | * and not throught the SGs interface.*/ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 4590 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4591 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 4592 | |
| 4593 | alt { |
Harald Welte | e13cfb2 | 2019-04-23 16:52:02 +0200 | [diff] [blame] | 4594 | [g_pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)); { |
| 4595 | setverdict(pass); |
| 4596 | } |
Harald Welte | 62113fc | 2019-05-09 13:04:02 +0200 | [diff] [blame] | 4597 | [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] | 4598 | setverdict(pass); |
| 4599 | } |
| 4600 | [] SGsAP.receive { |
| 4601 | setverdict(fail, "Received unexpected message on SGs"); |
| 4602 | } |
| 4603 | } |
| 4604 | |
| 4605 | /* Send an SMS to make sure that also payload messages are routed |
| 4606 | * throught the A-Interface again */ |
| 4607 | f_establish_fully(EST_TYPE_MO_SMS); |
| 4608 | f_mo_sms(spars); |
| 4609 | f_expect_clear(); |
| 4610 | } |
| 4611 | |
| 4612 | private function f_tc_sgsap_reset(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4613 | var charstring vlr_name; |
| 4614 | f_init_handler(pars); |
| 4615 | |
| 4616 | vlr_name := f_sgsap_reset_mme(mp_mme_name); |
| 4617 | log("VLR name: ", vlr_name); |
| 4618 | setverdict(pass); |
Neels Hofmeyr | c0b520d | 2019-03-06 15:35:50 +0100 | [diff] [blame] | 4619 | f_sleep(1.0); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4620 | } |
| 4621 | |
| 4622 | testcase TC_sgsap_reset() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4623 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4624 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4625 | f_init(1, true); |
| 4626 | pars := f_init_pars(11810, true); |
| 4627 | 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] | 4628 | vc_conn.done; |
| 4629 | } |
| 4630 | |
| 4631 | /* like f_mm_auth() but for SGs */ |
| 4632 | function f_mm_auth_sgs() runs on BSC_ConnHdlr { |
| 4633 | if (g_pars.net.expect_auth) { |
| 4634 | g_pars.vec := f_gen_auth_vec_3g(); |
| 4635 | var GSUP_IE auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G3G(g_pars.vec.rand, |
| 4636 | g_pars.vec.sres, |
| 4637 | g_pars.vec.kc, |
| 4638 | g_pars.vec.ik, |
| 4639 | g_pars.vec.ck, |
| 4640 | g_pars.vec.autn, |
| 4641 | g_pars.vec.res)); |
| 4642 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 4643 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
| 4644 | SGsAP.receive(tr_ML3_MT_MM_AUTH_REQ_3G(g_pars.vec.rand, g_pars.vec.autn)); |
| 4645 | SGsAP.send(ts_ML3_MT_MM_AUTH_RESP_3G(g_pars.vec.sres, g_pars.vec.res)); |
| 4646 | } |
| 4647 | } |
| 4648 | |
| 4649 | /* like f_perform_lu(), but on SGs rather than BSSAP */ |
| 4650 | function f_sgs_perform_lu() runs on BSC_ConnHdlr { |
| 4651 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4652 | var PDU_SGsAP lur; |
| 4653 | var PDU_SGsAP lua; |
| 4654 | var PDU_SGsAP mm_info; |
| 4655 | var octetstring mm_info_dtap; |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4656 | var GsmMcc mcc; |
| 4657 | var GsmMnc mnc; |
| 4658 | var template (omit) TrackingAreaIdentityValue tai := omit; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4659 | |
| 4660 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 4661 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4662 | if (g_pars.common_id_last_eutran_plmn != omit) { |
| 4663 | f_dec_mcc_mnc(g_pars.common_id_last_eutran_plmn, mcc, mnc); |
| 4664 | tai := ts_SGsAP_TAI(mcc, mnc, 555); |
| 4665 | } |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4666 | 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] | 4667 | ts_SGsAP_LAI('901'H, '70'H, 2342), |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4668 | tai)); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4669 | /* Old LAI, if MS sends it */ |
| 4670 | /* TMSI status, if MS has no valid TMSI */ |
| 4671 | /* IMEISV, if it supports "automatic device detection" */ |
| 4672 | /* TAI, if available in MME */ |
| 4673 | /* E-CGI, if available in MME */ |
| 4674 | SGsAP.send(lur); |
| 4675 | |
| 4676 | /* FIXME: is this really done over SGs? The Ue is already authenticated |
| 4677 | * via the MME ... */ |
| 4678 | f_mm_auth_sgs(); |
| 4679 | |
| 4680 | /* Expect MSC to perform LU with HLR */ |
| 4681 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 4682 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 4683 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 4684 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 4685 | |
| 4686 | alt { |
| 4687 | [] SGsAP.receive(tr_SGsAP_LU_ACCEPT(g_pars.imsi, ?)) -> value lua { |
| 4688 | if (isvalue(lua.sGsAP_LOCATION_UPDATE_ACCEPT.newTMSIorIMSI.iD.iD.tmsi_ptmsi.octets)) { |
| 4689 | g_pars.tmsi :=lua.sGsAP_LOCATION_UPDATE_ACCEPT.newTMSIorIMSI.iD.iD.tmsi_ptmsi.octets |
| 4690 | SGsAP.send(ts_SGsAP_TMSI_REALL_CMPL(g_pars.imsi)); |
| 4691 | } |
| 4692 | setverdict(pass); |
| 4693 | } |
| 4694 | [] SGsAP.receive(tr_SGsAP_LU_REJECT(g_pars.imsi, ?, ?)) { |
| 4695 | setverdict(fail, "Received LU-REJECT instead of ACCEPT"); |
| 4696 | } |
| 4697 | [] SGsAP.receive { |
| 4698 | setverdict(fail, "Received unexpected message on SGs"); |
| 4699 | } |
| 4700 | } |
| 4701 | |
| 4702 | /* Check MM information */ |
| 4703 | if (mp_mm_info == true) { |
| 4704 | SGsAP.receive(tr_SGsAP_MM_INFO_REQ(g_pars.imsi, ?)) -> value mm_info; |
| 4705 | mm_info_dtap := '0532'O & mm_info.sGsAP_MM_INFORMATION_REQUEST.mM_Information.information; |
| 4706 | if (not match(dec_PDU_ML3_NW_MS(mm_info_dtap), tr_ML3_MT_MM_Info)) { |
| 4707 | setverdict(fail, "Unexpected MM Information"); |
| 4708 | } |
| 4709 | } |
| 4710 | |
| 4711 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4712 | } |
| 4713 | |
| 4714 | private function f_tc_sgsap_lu(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4715 | f_init_handler(pars); |
| 4716 | f_sgs_perform_lu(); |
| 4717 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4718 | |
| 4719 | f_sgsap_bssmap_screening(); |
| 4720 | |
| 4721 | setverdict(pass); |
| 4722 | } |
| 4723 | testcase TC_sgsap_lu() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4724 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4725 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4726 | f_init(1, true); |
| 4727 | pars := f_init_pars(11811, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4728 | 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] | 4729 | 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] | 4730 | vc_conn.done; |
| 4731 | } |
| 4732 | |
| 4733 | /* Do LU by IMSI, refuse it on GSUP and expect LU REJ back to MS */ |
| 4734 | private function f_tc_sgsap_lu_imsi_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4735 | f_init_handler(pars); |
| 4736 | var PDU_SGsAP lur; |
| 4737 | |
| 4738 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4739 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4740 | lur := valueof(ts_SGsAP_LU_REQ(g_pars.imsi, mme_name, IMSI_attach, |
| 4741 | ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4742 | SGsAP.send(lur); |
| 4743 | |
| 4744 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 4745 | GSUP.send(ts_GSUP_UL_ERR(g_pars.imsi, 23)); |
| 4746 | alt { |
| 4747 | [] SGsAP.receive(tr_SGsAP_LU_REJECT(g_pars.imsi, ?, ?)) { |
| 4748 | setverdict(pass); |
| 4749 | } |
| 4750 | [] SGsAP.receive(tr_SGsAP_LU_ACCEPT(g_pars.imsi, ?)) { |
| 4751 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
| 4752 | mtc.stop; |
| 4753 | } |
| 4754 | [] SGsAP.receive { |
| 4755 | setverdict(fail, "Received unexpected message on SGs"); |
| 4756 | } |
| 4757 | } |
| 4758 | |
| 4759 | f_sgsap_bssmap_screening(); |
| 4760 | |
| 4761 | setverdict(pass); |
| 4762 | } |
| 4763 | testcase TC_sgsap_lu_imsi_reject() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4764 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4765 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4766 | f_init(1, true); |
| 4767 | pars := f_init_pars(11812, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4768 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4769 | 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] | 4770 | vc_conn.done; |
| 4771 | } |
| 4772 | |
| 4773 | /* Do LU by IMSI, but then remain silent so that Ts6-1 times out */ |
| 4774 | private function f_tc_sgsap_lu_and_nothing(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4775 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4776 | var PDU_SGsAP lur; |
| 4777 | |
| 4778 | f_init_handler(pars); |
| 4779 | |
| 4780 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 4781 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 4782 | |
| 4783 | lur := valueof(ts_SGsAP_LU_REQ(g_pars.imsi, mme_name, IMSI_attach, |
| 4784 | ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4785 | /* Old LAI, if MS sends it */ |
| 4786 | /* TMSI status, if MS has no valid TMSI */ |
| 4787 | /* IMEISV, if it supports "automatic device detection" */ |
| 4788 | /* TAI, if available in MME */ |
| 4789 | /* E-CGI, if available in MME */ |
| 4790 | SGsAP.send(lur); |
| 4791 | |
| 4792 | /* FIXME: is this really done over SGs? The Ue is already authenticated |
| 4793 | * via the MME ... */ |
| 4794 | f_mm_auth_sgs(); |
| 4795 | |
| 4796 | /* Expect MSC to perform LU with HLR */ |
| 4797 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 4798 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 4799 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 4800 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 4801 | |
| 4802 | alt { |
| 4803 | [] SGsAP.receive(tr_SGsAP_LU_ACCEPT(g_pars.imsi, ?)) { |
| 4804 | setverdict(pass); |
| 4805 | } |
| 4806 | [] SGsAP.receive(tr_SGsAP_LU_REJECT(g_pars.imsi, ?, ?)) { |
| 4807 | setverdict(fail, "Received LU-REJECT instead of ACCEPT"); |
| 4808 | } |
| 4809 | [] SGsAP.receive { |
| 4810 | setverdict(fail, "Received unexpected message on SGs"); |
| 4811 | } |
| 4812 | } |
| 4813 | |
| 4814 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4815 | |
| 4816 | /* Wait until the VLR has abort the TMSI reallocation procedure */ |
| 4817 | f_sleep(45.0); |
| 4818 | |
| 4819 | /* The outcome does not change the SGs state, see also 5.2.3.4 */ |
| 4820 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4821 | |
| 4822 | f_sgsap_bssmap_screening(); |
| 4823 | |
| 4824 | setverdict(pass); |
| 4825 | } |
| 4826 | testcase TC_sgsap_lu_and_nothing() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4827 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4828 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4829 | f_init(1, true); |
| 4830 | pars := f_init_pars(11813, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4831 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4832 | 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] | 4833 | vc_conn.done; |
| 4834 | } |
| 4835 | |
| 4836 | private function f_tc_sgsap_expl_imsi_det_eps(charstring id, BSC_ConnHdlrPars pars) |
| 4837 | runs on BSC_ConnHdlr { |
| 4838 | f_init_handler(pars); |
| 4839 | f_sgs_perform_lu(); |
| 4840 | f_sleep(3.0); |
| 4841 | |
| 4842 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4843 | SGsAP.send(ts_SGsAP_EPS_DETACH_IND(g_pars.imsi, mme_name, UE_initiated)); |
| 4844 | SGsAP.receive(tr_SGsAP_EPS_DETACH_ACK(g_pars.imsi)); |
| 4845 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4846 | |
| 4847 | f_sgsap_bssmap_screening(); |
| 4848 | |
| 4849 | setverdict(pass); |
| 4850 | } |
| 4851 | testcase TC_sgsap_expl_imsi_det_eps() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4852 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4853 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4854 | f_init(1, true); |
| 4855 | pars := f_init_pars(11814, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4856 | 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] | 4857 | 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] | 4858 | vc_conn.done; |
| 4859 | } |
| 4860 | |
Philipp Maier | fc19f17 | 2019-03-21 11:17:54 +0100 | [diff] [blame] | 4861 | private function f_tc_sgsap_impl_imsi_det_eps(charstring id, BSC_ConnHdlrPars pars) |
| 4862 | runs on BSC_ConnHdlr { |
| 4863 | f_init_handler(pars); |
| 4864 | f_sgs_perform_lu(); |
| 4865 | f_sleep(3.0); |
| 4866 | |
| 4867 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4868 | SGsAP.send(ts_SGsAP_EPS_DETACH_IND(g_pars.imsi, mme_name, network_initiated)); |
| 4869 | SGsAP.receive(tr_SGsAP_EPS_DETACH_ACK(g_pars.imsi)); |
| 4870 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4871 | |
| 4872 | f_sgsap_bssmap_screening(); |
| 4873 | |
| 4874 | setverdict(pass); |
| 4875 | } |
| 4876 | testcase TC_sgsap_impl_imsi_det_eps() runs on MTC_CT { |
| 4877 | var BSC_ConnHdlrPars pars; |
| 4878 | var BSC_ConnHdlr vc_conn; |
| 4879 | f_init(1, true); |
| 4880 | pars := f_init_pars(11814, 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 | fc19f17 | 2019-03-21 11:17:54 +0100 | [diff] [blame] | 4882 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_impl_imsi_det_eps), pars); |
| 4883 | vc_conn.done; |
| 4884 | } |
| 4885 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4886 | private function f_tc_sgsap_expl_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, combined_UE_initiated)); |
| 4894 | SGsAP.receive(tr_SGsAP_IMSI_DETACH_ACK(g_pars.imsi)); |
Philipp Maier | d08e7e7 | 2019-04-02 15:27:10 +0200 | [diff] [blame] | 4895 | |
| 4896 | if (f_ctrl_subscr_in_vlr(hex2str(g_pars.imsi))) { |
| 4897 | setverdict(fail, "subscriber not removed from VLR"); |
| 4898 | } |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4899 | |
| 4900 | f_sgsap_bssmap_screening(); |
| 4901 | |
| 4902 | setverdict(pass); |
| 4903 | } |
| 4904 | testcase TC_sgsap_expl_imsi_det_noneps() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4905 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4906 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 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 | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4910 | 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] | 4911 | vc_conn.done; |
| 4912 | } |
| 4913 | |
Philipp Maier | 5d81270 | 2019-03-21 10:51:26 +0100 | [diff] [blame] | 4914 | private function f_tc_sgsap_impl_imsi_det_noneps(charstring id, BSC_ConnHdlrPars pars) |
| 4915 | runs on BSC_ConnHdlr { |
| 4916 | f_init_handler(pars); |
| 4917 | f_sgs_perform_lu(); |
| 4918 | f_sleep(3.0); |
| 4919 | |
| 4920 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4921 | SGsAP.send(ts_SGsAP_IMSI_DETACH_IND(g_pars.imsi, mme_name, implicit_network_initiated)); |
| 4922 | SGsAP.receive(tr_SGsAP_IMSI_DETACH_ACK(g_pars.imsi)); |
| 4923 | |
| 4924 | if (f_ctrl_subscr_in_vlr(hex2str(g_pars.imsi))) { |
| 4925 | setverdict(fail, "subscriber not removed from VLR"); |
| 4926 | } |
| 4927 | |
| 4928 | f_sgsap_bssmap_screening(); |
| 4929 | |
| 4930 | setverdict(pass); |
| 4931 | } |
| 4932 | testcase TC_sgsap_impl_imsi_det_noneps() runs on MTC_CT { |
| 4933 | var BSC_ConnHdlrPars pars; |
| 4934 | var BSC_ConnHdlr vc_conn; |
| 4935 | f_init(1, true); |
| 4936 | pars := f_init_pars(11815, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4937 | 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] | 4938 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_impl_imsi_det_noneps), pars); |
| 4939 | vc_conn.done; |
| 4940 | } |
| 4941 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4942 | /* Trigger a paging request via VTY and send a paging reject in response */ |
| 4943 | private function f_tc_sgsap_paging_rej(charstring id, BSC_ConnHdlrPars pars) |
| 4944 | runs on BSC_ConnHdlr { |
| 4945 | f_init_handler(pars); |
| 4946 | f_sgs_perform_lu(); |
| 4947 | f_sleep(1.0); |
| 4948 | |
| 4949 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4950 | var template PDU_SGsAP exp_resp := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, CS_call_indicator, omit); |
| 4951 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4952 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 4953 | |
| 4954 | /* Initiate paging via VTY */ |
| 4955 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 4956 | alt { |
| 4957 | [] SGsAP.receive(exp_resp) { |
| 4958 | setverdict(pass); |
| 4959 | } |
| 4960 | [] SGsAP.receive { |
| 4961 | setverdict(fail, "Received unexpected message on SGs"); |
| 4962 | } |
| 4963 | } |
| 4964 | |
| 4965 | /* Now reject the paging */ |
| 4966 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, IMSI_unknown)); |
| 4967 | |
| 4968 | /* Wait for the states inside the MSC to settle and check the state |
| 4969 | * of the SGs Association */ |
| 4970 | f_sleep(1.0); |
| 4971 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4972 | |
| 4973 | /* FIXME: At the moment we send an IMSI_unknown as cause code, which is fine, |
| 4974 | * but we also need to cover tha case where the cause code indicates an |
| 4975 | * "IMSI detached for EPS services". In those cases the VLR is expected to |
| 4976 | * try paging on tha A/Iu interface. This will be another testcase similar to |
| 4977 | * this one, but extended with checks for the presence of the A/Iu paging |
| 4978 | * messages. */ |
| 4979 | |
| 4980 | f_sgsap_bssmap_screening(); |
| 4981 | |
| 4982 | setverdict(pass); |
| 4983 | } |
| 4984 | testcase TC_sgsap_paging_rej() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4985 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4986 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4987 | f_init(1, true); |
| 4988 | pars := f_init_pars(11816, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 4989 | 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] | 4990 | 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] | 4991 | vc_conn.done; |
| 4992 | } |
| 4993 | |
| 4994 | /* Trigger a paging request via VTY and send a paging reject that indicates |
| 4995 | * that the subscriber intentionally rejected the call. */ |
| 4996 | private function f_tc_sgsap_paging_subscr_rej(charstring id, BSC_ConnHdlrPars pars) |
| 4997 | runs on BSC_ConnHdlr { |
| 4998 | f_init_handler(pars); |
| 4999 | f_sgs_perform_lu(); |
| 5000 | f_sleep(1.0); |
| 5001 | |
| 5002 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5003 | var template PDU_SGsAP exp_resp := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, CS_call_indicator, omit); |
| 5004 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5005 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 5006 | |
| 5007 | /* Initiate paging via VTY */ |
| 5008 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 5009 | alt { |
| 5010 | [] SGsAP.receive(exp_resp) { |
| 5011 | setverdict(pass); |
| 5012 | } |
| 5013 | [] SGsAP.receive { |
| 5014 | setverdict(fail, "Received unexpected message on SGs"); |
| 5015 | } |
| 5016 | } |
| 5017 | |
| 5018 | /* Now reject the paging */ |
| 5019 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, user_rejected_mobile_terminating_CS_fallback_call)); |
| 5020 | |
| 5021 | /* Wait for the states inside the MSC to settle and check the state |
| 5022 | * of the SGs Association */ |
| 5023 | f_sleep(1.0); |
| 5024 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5025 | |
| 5026 | /* FIXME: The VLR is supposed to trigger an User Determined User Busy (UDUB) as specified |
| 5027 | * in 3GPP TS 24.082, this is not yet implemented in the MSC or in this tests, we need |
| 5028 | * to check back how this works and how it can be tested */ |
| 5029 | |
| 5030 | f_sgsap_bssmap_screening(); |
| 5031 | |
| 5032 | setverdict(pass); |
| 5033 | } |
| 5034 | testcase TC_sgsap_paging_subscr_rej() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5035 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5036 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5037 | f_init(1, true); |
| 5038 | pars := f_init_pars(11817, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5039 | 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] | 5040 | 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] | 5041 | vc_conn.done; |
| 5042 | } |
| 5043 | |
| 5044 | /* Trigger a paging request via VTY and send an UE unreacable messge in response */ |
| 5045 | private function f_tc_sgsap_paging_ue_unr(charstring id, BSC_ConnHdlrPars pars) |
| 5046 | runs on BSC_ConnHdlr { |
| 5047 | f_init_handler(pars); |
| 5048 | f_sgs_perform_lu(); |
| 5049 | f_sleep(1.0); |
| 5050 | |
| 5051 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5052 | var template PDU_SGsAP exp_resp := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, CS_call_indicator, omit); |
| 5053 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5054 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 5055 | |
| 5056 | /* Initiate paging via VTY */ |
| 5057 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 5058 | alt { |
| 5059 | [] SGsAP.receive(exp_resp) { |
| 5060 | setverdict(pass); |
| 5061 | } |
| 5062 | [] SGsAP.receive { |
| 5063 | setverdict(fail, "Received unexpected message on SGs"); |
| 5064 | } |
| 5065 | } |
| 5066 | |
| 5067 | /* Now pretend that the UE is unreachable */ |
| 5068 | SGsAP.send(ts_SGsAP_UE_UNREACHABLE(g_pars.imsi, UE_unreachable)); |
| 5069 | |
| 5070 | /* Wait for the states inside the MSC to settle and check the state |
| 5071 | * of the SGs Association. */ |
| 5072 | f_sleep(1.0); |
| 5073 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5074 | |
| 5075 | f_sgsap_bssmap_screening(); |
| 5076 | |
| 5077 | setverdict(pass); |
| 5078 | } |
| 5079 | testcase TC_sgsap_paging_ue_unr() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5080 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5081 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5082 | f_init(1, true); |
| 5083 | pars := f_init_pars(11818, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5084 | 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] | 5085 | 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] | 5086 | vc_conn.done; |
| 5087 | } |
| 5088 | |
| 5089 | /* Trigger a paging request via VTY but don't respond to it */ |
| 5090 | private function f_tc_sgsap_paging_and_nothing(charstring id, BSC_ConnHdlrPars pars) |
| 5091 | runs on BSC_ConnHdlr { |
| 5092 | f_init_handler(pars); |
| 5093 | f_sgs_perform_lu(); |
| 5094 | f_sleep(1.0); |
| 5095 | |
| 5096 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5097 | 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] | 5098 | 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] | 5099 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5100 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 5101 | |
| 5102 | /* Initiate paging via VTY */ |
| 5103 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 5104 | alt { |
| 5105 | [] SGsAP.receive(exp_resp) { |
| 5106 | setverdict(pass); |
| 5107 | } |
| 5108 | [] SGsAP.receive { |
| 5109 | setverdict(fail, "Received unexpected message on SGs"); |
| 5110 | } |
| 5111 | } |
| 5112 | |
Philipp Maier | 3421810 | 2019-09-24 09:15:49 +0200 | [diff] [blame] | 5113 | /* While we are doing nothing, expect an SGsAP-SERVICE-ABORT-REQUEST |
| 5114 | * after some time */ |
| 5115 | timer T := 10.0; |
| 5116 | T.start |
| 5117 | alt { |
| 5118 | [] SGsAP.receive(exp_serv_abrt) |
| 5119 | { |
| 5120 | setverdict(pass); |
| 5121 | } |
| 5122 | [] SGsAP.receive { |
| 5123 | setverdict(fail, "unexpected SGsAP message received"); |
| 5124 | self.stop; |
| 5125 | } |
| 5126 | [] T.timeout { |
| 5127 | setverdict(fail, "MSC did not send SGsAP-SERVICE-ABORT-REQUEST"); |
| 5128 | self.stop; |
| 5129 | } |
| 5130 | } |
| 5131 | |
| 5132 | /* The SGs association must remain unchanged. */ |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5133 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5134 | |
| 5135 | f_sgsap_bssmap_screening(); |
| 5136 | |
| 5137 | setverdict(pass); |
| 5138 | } |
| 5139 | testcase TC_sgsap_paging_and_nothing() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5140 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5141 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5142 | f_init(1, true); |
| 5143 | pars := f_init_pars(11819, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5144 | 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] | 5145 | 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] | 5146 | vc_conn.done; |
| 5147 | } |
| 5148 | |
| 5149 | /* Trigger a paging request via VTY and slip in an LU */ |
| 5150 | private function f_tc_sgsap_paging_and_lu(charstring id, BSC_ConnHdlrPars pars) |
| 5151 | runs on BSC_ConnHdlr { |
| 5152 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5153 | f_init_handler(pars); |
| 5154 | |
| 5155 | /* First we prepar the situation, where the SGs association is in state |
| 5156 | * NULL and the confirmed by radio contact indicator is set to false |
| 5157 | * as well. This can be archived by performing an SGs LU and then |
| 5158 | * resetting the VLR */ |
| 5159 | f_sgs_perform_lu(); |
| 5160 | f_sgsap_reset_mme(mp_mme_name); |
| 5161 | f_sleep(1.0); |
| 5162 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 5163 | |
| 5164 | /* Perform a paging, expect the paging messages on the SGs interface */ |
| 5165 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 5166 | alt { |
| 5167 | [] SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)) { |
| 5168 | setverdict(pass); |
| 5169 | } |
| 5170 | [] SGsAP.receive { |
| 5171 | setverdict(fail, "Received unexpected message on SGs"); |
| 5172 | } |
| 5173 | } |
| 5174 | |
| 5175 | /* Perform the LU as normal */ |
| 5176 | f_sgs_perform_lu(); |
| 5177 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5178 | |
| 5179 | /* Expect a new paging request right after the LU */ |
| 5180 | alt { |
| 5181 | [] SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)) { |
| 5182 | setverdict(pass); |
| 5183 | } |
| 5184 | [] SGsAP.receive { |
| 5185 | setverdict(fail, "Received unexpected message on SGs"); |
| 5186 | } |
| 5187 | } |
| 5188 | |
| 5189 | /* Test is done now, lets round everything up by rejecting the paging |
| 5190 | * cleanly. */ |
| 5191 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, user_rejected_mobile_terminating_CS_fallback_call)); |
| 5192 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5193 | |
| 5194 | f_sgsap_bssmap_screening(); |
| 5195 | |
| 5196 | setverdict(pass); |
| 5197 | } |
| 5198 | testcase TC_sgsap_paging_and_lu() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5199 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5200 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5201 | f_init(1, true); |
| 5202 | pars := f_init_pars(11820, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5203 | 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] | 5204 | 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] | 5205 | vc_conn.done; |
| 5206 | } |
| 5207 | |
| 5208 | /* Send unexpected unit-data through the SGs interface */ |
| 5209 | private function f_tc_sgsap_unexp_ud(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5210 | f_init_handler(pars); |
| 5211 | f_sleep(1.0); |
| 5212 | |
| 5213 | /* This simulates what happens when a subscriber without SGs |
| 5214 | * association gets unitdata via the SGs interface. */ |
| 5215 | |
| 5216 | /* Make sure the subscriber exists and the SGs association |
| 5217 | * is in NULL state */ |
| 5218 | f_perform_lu(); |
| 5219 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 5220 | |
| 5221 | /* Send some random unit data, the MSC/VLR should send a release |
| 5222 | * immediately. */ |
| 5223 | SGsAP.send(ts_SGsAP_UL_UD(pars.imsi,'1234'O)); |
| 5224 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, IMSI_detached_for_EPS_nonEPS_services)); |
| 5225 | |
| 5226 | f_sgsap_bssmap_screening(); |
| 5227 | |
| 5228 | setverdict(pass); |
| 5229 | } |
| 5230 | testcase TC_sgsap_unexp_ud() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5231 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5232 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5233 | f_init(1, true); |
| 5234 | pars := f_init_pars(11821, true); |
| 5235 | 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] | 5236 | vc_conn.done; |
| 5237 | } |
| 5238 | |
| 5239 | /* Send unsolicited unit-data through the SGs interface */ |
| 5240 | private function f_tc_sgsap_unsol_ud(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5241 | f_init_handler(pars); |
| 5242 | f_sleep(1.0); |
| 5243 | |
| 5244 | /* This simulates what happens when the MME attempts to send unitdata |
| 5245 | * to a subscriber that is completely unknown to the VLR */ |
| 5246 | |
| 5247 | /* Send some random unit data, the MSC/VLR should send a release |
| 5248 | * immediately. */ |
| 5249 | SGsAP.send(ts_SGsAP_UL_UD(pars.imsi,'1234'O)); |
| 5250 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, IMSI_unknown)); |
| 5251 | |
| 5252 | f_sgsap_bssmap_screening(); |
| 5253 | |
Harald Welte | 4d15fa7 | 2020-08-19 08:58:28 +0200 | [diff] [blame] | 5254 | /* clean-up VLR state about this subscriber */ |
| 5255 | f_imsi_detach_by_imsi(); |
| 5256 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5257 | setverdict(pass); |
| 5258 | } |
| 5259 | testcase TC_sgsap_unsol_ud() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5260 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5261 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5262 | f_init(1, true); |
| 5263 | pars := f_init_pars(11822, true); |
| 5264 | 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] | 5265 | vc_conn.done; |
| 5266 | } |
| 5267 | |
| 5268 | private altstep as_other_sms_sgs() runs on BSC_ConnHdlr { |
| 5269 | /* FIXME: Match an actual payload (second questionmark), the type is |
| 5270 | * octetstring, how do we use a tr_PDU_DTAP_MT here? */ |
| 5271 | [] SGsAP.receive(tr_SGsAP_DL_UD(?,?)) { |
| 5272 | setverdict(fail, "Unexpected SMS related PDU from MSC"); |
| 5273 | mtc.stop; |
| 5274 | } |
| 5275 | } |
| 5276 | |
| 5277 | /* receive a MT-SMS delivered from the MSC/SMSC over an already existing SGsAP connection */ |
| 5278 | function f_mt_sms_sgs(inout SmsParameters spars) |
| 5279 | runs on BSC_ConnHdlr { |
| 5280 | var template (value) TPDU_RP_DATA_MS_SGSN tp_mo; |
| 5281 | var template (value) RPDU_MS_SGSN rp_mo; |
| 5282 | var template (value) PDU_ML3_MS_NW l3_mo; |
| 5283 | |
| 5284 | var template TPDU_RP_DATA_SGSN_MS tp_mt; |
| 5285 | var template RPDU_SGSN_MS rp_mt; |
| 5286 | var template PDU_ML3_NW_MS l3_mt; |
| 5287 | |
| 5288 | var PDU_ML3_NW_MS sgsap_l3_mt; |
| 5289 | |
| 5290 | var default d := activate(as_other_sms_sgs()); |
| 5291 | |
| 5292 | /* Expect CP-DATA(RP-DATA(SMS-DELIVER)) */ |
| 5293 | 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] | 5294 | 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] | 5295 | l3_mt := tr_ML3_MT_SMS(?, c_TIF_ORIG, tr_CP_DATA_MT(rp_mt)); |
| 5296 | |
| 5297 | SGsAP.receive(l3_mt) -> value sgsap_l3_mt; |
| 5298 | |
| 5299 | /* Extract relevant identifiers */ |
| 5300 | spars.tid := bit2int(sgsap_l3_mt.tiOrSkip.transactionId.tio); |
| 5301 | spars.rp.msg_ref := sgsap_l3_mt.msgs.sms.cP_DATA.cP_User_Data.cP_RPDU.rP_DATA_SGSN_MS.rP_MessageReference; |
| 5302 | |
| 5303 | /* send CP-ACK for CP-DATA just received */ |
| 5304 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_REPL, ts_CP_ACK_MO); |
| 5305 | |
| 5306 | SGsAP.send(l3_mo); |
| 5307 | |
| 5308 | /* send RP-ACK for RP-DATA */ |
| 5309 | rp_mo := ts_RP_ACK_MO(spars.rp.msg_ref); |
| 5310 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_REPL, ts_CP_DATA_MO(rp_mo)); |
| 5311 | |
| 5312 | SGsAP.send(l3_mo); |
| 5313 | |
| 5314 | /* expect CP-ACK for CP-DATA(RP-ACK) just sent */ |
| 5315 | l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_ORIG, tr_CP_ACK_MT); |
| 5316 | |
| 5317 | SGsAP.receive(l3_mt); |
| 5318 | |
| 5319 | deactivate(d); |
| 5320 | |
| 5321 | setverdict(pass); |
| 5322 | } |
| 5323 | |
| 5324 | /* submit a MO-SMS to MSC/SMSC over an already existing SGsAP connection */ |
| 5325 | function f_mo_sms_sgs(inout SmsParameters spars) |
| 5326 | runs on BSC_ConnHdlr { |
| 5327 | var template (value) TPDU_RP_DATA_MS_SGSN tp_mo; |
| 5328 | var template (value) RPDU_MS_SGSN rp_mo; |
| 5329 | var template (value) PDU_ML3_MS_NW l3_mo; |
| 5330 | |
| 5331 | var template TPDU_RP_DATA_SGSN_MS tp_mt; |
| 5332 | var template RPDU_SGSN_MS rp_mt; |
| 5333 | var template PDU_ML3_NW_MS l3_mt; |
| 5334 | |
| 5335 | var default d := activate(as_other_sms_sgs()); |
| 5336 | |
| 5337 | /* just in case this is routed to SMPP.. */ |
| 5338 | f_create_smpp_expect(hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue)); |
| 5339 | |
| 5340 | tp_mo := ts_SMS_SUBMIT(spars.tp.msg_ref, spars.tp.da, spars.tp.pid, spars.tp.dcs, |
| 5341 | spars.tp.udl, spars.tp.ud); |
Vadim Yanitskiy | 437b5a6 | 2019-12-15 14:13:39 +0900 | [diff] [blame] | 5342 | 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] | 5343 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_DATA_MO(rp_mo)); |
| 5344 | |
| 5345 | SGsAP.send(l3_mo); |
| 5346 | |
| 5347 | /* receive CP-ACK for CP-DATA above */ |
| 5348 | SGsAP.receive(tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_ACK_MT)); |
| 5349 | |
| 5350 | if (ispresent(spars.exp_rp_err)) { |
| 5351 | /* expect an RP-ERROR message from MSC with given cause */ |
| 5352 | rp_mt := tr_RP_ERROR_MT(spars.rp.msg_ref, spars.exp_rp_err); |
| 5353 | l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_DATA_MT(rp_mt)); |
| 5354 | SGsAP.receive(l3_mt); |
| 5355 | /* send CP-ACK for CP-DATA just received */ |
| 5356 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_ACK_MO); |
| 5357 | SGsAP.send(l3_mo); |
| 5358 | } else { |
| 5359 | /* expect RP-ACK for RP-DATA */ |
| 5360 | rp_mt := tr_RP_ACK_MT(spars.rp.msg_ref); |
| 5361 | l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_DATA_MT(rp_mt)); |
| 5362 | SGsAP.receive(l3_mt); |
| 5363 | /* send CP-ACO for CP-DATA just received */ |
| 5364 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_ACK_MO); |
| 5365 | SGsAP.send(l3_mo); |
| 5366 | } |
| 5367 | |
| 5368 | deactivate(d); |
| 5369 | |
| 5370 | setverdict(pass); |
| 5371 | } |
| 5372 | |
| 5373 | private function f_vty_sms_send_conn_hdlr(charstring imsi, charstring msisdn, charstring text) |
| 5374 | runs on BSC_ConnHdlr { |
| 5375 | f_vty_transceive(MSCVTY, "subscriber imsi "&imsi&" sms sender msisdn "&msisdn&" send "&text); |
| 5376 | } |
| 5377 | |
| 5378 | /* Send a MT SMS via SGs interface */ |
| 5379 | private function f_tc_sgsap_mt_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5380 | f_init_handler(pars); |
| 5381 | f_sgs_perform_lu(); |
| 5382 | f_sleep(1.0); |
| 5383 | var SmsParameters spars := valueof(t_SmsPars); |
| 5384 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 5385 | |
| 5386 | /* Trigger SMS via VTY */ |
| 5387 | f_vty_sms_send_conn_hdlr(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 5388 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5389 | |
| 5390 | /* Expect a paging request and respond accordingly with a service request */ |
| 5391 | SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, SMS_indicator, omit)); |
| 5392 | SGsAP.send(ts_SGsAP_SERVICE_REQ(pars.imsi, SMS_indicator, EMM_CONNECTED)); |
| 5393 | |
| 5394 | /* Connection is now live, receive the MT-SMS */ |
| 5395 | f_mt_sms_sgs(spars); |
| 5396 | |
| 5397 | /* Expect a concluding release from the MSC */ |
| 5398 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, omit)); |
| 5399 | |
| 5400 | /* Make sure that subscriber is still present and the SGs association is in tact (ref-counting) */ |
| 5401 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5402 | |
| 5403 | f_sgsap_bssmap_screening(); |
| 5404 | |
| 5405 | setverdict(pass); |
| 5406 | } |
| 5407 | testcase TC_sgsap_mt_sms() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5408 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5409 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5410 | f_init(1, true); |
| 5411 | pars := f_init_pars(11823, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5412 | 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] | 5413 | 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] | 5414 | vc_conn.done; |
| 5415 | } |
| 5416 | |
| 5417 | /* Send a MO SMS via SGs interface */ |
| 5418 | private function f_tc_sgsap_mo_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5419 | f_init_handler(pars); |
| 5420 | f_sgs_perform_lu(); |
| 5421 | f_sleep(1.0); |
| 5422 | var SmsParameters spars := valueof(t_SmsPars); |
| 5423 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 5424 | |
| 5425 | /* Send the MO-SMS */ |
| 5426 | f_mo_sms_sgs(spars); |
| 5427 | |
| 5428 | /* Expect a concluding release from the MSC/VLR */ |
| 5429 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, omit)); |
| 5430 | |
| 5431 | /* Make sure that subscriber is still present and the SGs association is in tact (ref-counting) */ |
| 5432 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5433 | |
| 5434 | setverdict(pass); |
| 5435 | |
| 5436 | f_sgsap_bssmap_screening() |
| 5437 | } |
| 5438 | testcase TC_sgsap_mo_sms() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5439 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5440 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5441 | f_init(1, true); |
| 5442 | pars := f_init_pars(11824, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5443 | 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] | 5444 | 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] | 5445 | vc_conn.done; |
| 5446 | } |
| 5447 | |
| 5448 | /* Trigger sending of an MT sms via VTY but never respond to anything */ |
| 5449 | private function f_tc_sgsap_mt_sms_and_nothing(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5450 | f_init_handler(pars, 170.0); |
| 5451 | f_sgs_perform_lu(); |
| 5452 | f_sleep(1.0); |
| 5453 | |
| 5454 | var SmsParameters spars := valueof(t_SmsPars); |
| 5455 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 5456 | var integer page_count := 0; |
| 5457 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5458 | var template PDU_SGsAP exp_pag_req := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, SMS_indicator, omit); |
| 5459 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5460 | exp_pag_req.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 5461 | |
| 5462 | /* Trigger SMS via VTY */ |
| 5463 | f_vty_sms_send_conn_hdlr(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 5464 | |
Neels Hofmeyr | 1623774 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 5465 | /* Expect the MSC/VLR to page exactly once */ |
| 5466 | SGsAP.receive(exp_pag_req); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5467 | |
| 5468 | /* Wait some time to make sure the MSC is not delivering any further |
| 5469 | * paging messages or anything else that could be unexpected. */ |
| 5470 | timer T := 20.0; |
| 5471 | T.start |
| 5472 | alt { |
| 5473 | [] SGsAP.receive(exp_pag_req) |
| 5474 | { |
| 5475 | setverdict(fail, "paging seems not to stop!"); |
| 5476 | mtc.stop; |
| 5477 | } |
| 5478 | [] SGsAP.receive { |
| 5479 | setverdict(fail, "unexpected SGsAP message received"); |
| 5480 | self.stop; |
| 5481 | } |
| 5482 | [] T.timeout { |
| 5483 | setverdict(pass); |
| 5484 | } |
| 5485 | } |
| 5486 | |
| 5487 | /* Even on a failed paging the SGs Association should stay intact */ |
| 5488 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5489 | |
Philipp Maier | 26bdb8c | 2019-09-24 09:21:12 +0200 | [diff] [blame] | 5490 | /* Make sure that the SMS we just inserted is cleared and the |
| 5491 | * subscriber is expired. This is necessary because otherwise the MSC |
| 5492 | * might re-try the SMS delivery and disturb the following tests. */ |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5493 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 5494 | f_vty_sms_clear(hex2str(g_pars.imsi)); |
| 5495 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5496 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " expire"); |
| 5497 | |
| 5498 | setverdict(pass); |
Neels Hofmeyr | b0f8234 | 2019-03-06 15:36:51 +0100 | [diff] [blame] | 5499 | |
| 5500 | f_sgsap_bssmap_screening(); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5501 | } |
| 5502 | testcase TC_sgsap_mt_sms_and_nothing() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5503 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5504 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5505 | f_init(1, true); |
| 5506 | pars := f_init_pars(11825, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5507 | 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] | 5508 | 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] | 5509 | vc_conn.done; |
| 5510 | } |
| 5511 | |
| 5512 | /* Trigger sending of an MT sms via VTY but reject the paging immediately */ |
| 5513 | private function f_tc_sgsap_mt_sms_and_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5514 | f_init_handler(pars, 150.0); |
| 5515 | f_sgs_perform_lu(); |
| 5516 | f_sleep(1.0); |
| 5517 | |
| 5518 | var SmsParameters spars := valueof(t_SmsPars); |
| 5519 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 5520 | var integer page_count := 0; |
| 5521 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5522 | var template PDU_SGsAP exp_pag_req := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, SMS_indicator, omit); |
| 5523 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5524 | exp_pag_req.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 5525 | |
| 5526 | /* Trigger SMS via VTY */ |
| 5527 | f_vty_sms_send_conn_hdlr(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 5528 | |
| 5529 | /* Expect a paging request and reject it immediately */ |
| 5530 | SGsAP.receive(exp_pag_req); |
| 5531 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, IMSI_unknown)); |
| 5532 | |
| 5533 | /* The MSC/VLR should no longer try to page once the paging has been |
| 5534 | * rejected. Wait some time and check if there are no unexpected |
| 5535 | * messages on the SGs interface. */ |
| 5536 | timer T := 20.0; |
| 5537 | T.start |
| 5538 | alt { |
| 5539 | [] SGsAP.receive(exp_pag_req) |
| 5540 | { |
| 5541 | setverdict(fail, "paging seems not to stop!"); |
| 5542 | mtc.stop; |
| 5543 | } |
| 5544 | [] SGsAP.receive { |
| 5545 | setverdict(fail, "unexpected SGsAP message received"); |
| 5546 | self.stop; |
| 5547 | } |
| 5548 | [] T.timeout { |
| 5549 | setverdict(pass); |
| 5550 | } |
| 5551 | } |
| 5552 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 5553 | f_vty_sms_clear(hex2str(g_pars.imsi)); |
| 5554 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5555 | /* A rejected paging with IMSI_unknown (see above) should always send |
| 5556 | * the SGs association to NULL. */ |
| 5557 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 5558 | |
| 5559 | f_sgsap_bssmap_screening(); |
| 5560 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5561 | setverdict(pass); |
| 5562 | } |
| 5563 | testcase TC_sgsap_mt_sms_and_reject() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5564 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5565 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5566 | f_init(1, true); |
| 5567 | pars := f_init_pars(11826, true); |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5568 | 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] | 5569 | 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] | 5570 | vc_conn.done; |
| 5571 | } |
| 5572 | |
Pau Espin Pedrol | 3acd19e | 2021-04-28 12:59:52 +0200 | [diff] [blame] | 5573 | /* Perform an MT CSFB call including LU */ |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5574 | private function f_mt_lu_and_csfb_call(charstring id, BSC_ConnHdlrPars pars, boolean bssmap_lu) runs on BSC_ConnHdlr { |
| 5575 | f_init_handler(pars); |
| 5576 | |
| 5577 | /* Be sure that the BSSMAP reset is done before we begin. */ |
| 5578 | f_sleep(2.0); |
| 5579 | |
| 5580 | /* Testcase variation: See what happens when we do a regular BSSMAP |
| 5581 | * LU first (this should not hurt in any way!) */ |
| 5582 | if (bssmap_lu) { |
| 5583 | f_perform_lu(); |
| 5584 | } |
Pau Espin Pedrol | e979c40 | 2021-04-28 17:29:54 +0200 | [diff] [blame] | 5585 | 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] | 5586 | |
| 5587 | f_sgs_perform_lu(); |
| 5588 | f_sleep(1.0); |
| 5589 | |
| 5590 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5591 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5592 | |
| 5593 | /* Initiate a call via MNCC interface */ |
Oliver Smith | 97dc91f | 2023-05-31 13:53:21 +0200 | [diff] [blame] | 5594 | f_mt_call_initiate(cpars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5595 | |
| 5596 | /* Expect a paging request and respond accordingly with a service request */ |
| 5597 | SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)); |
| 5598 | SGsAP.send(ts_SGsAP_SERVICE_REQ(pars.imsi, CS_call_indicator, EMM_CONNECTED)); |
| 5599 | |
| 5600 | /* Complete the call, hold it for some time and then tear it down */ |
| 5601 | f_mt_call_complete(cpars); |
| 5602 | f_sleep(3.0); |
Harald Welte | 4c422b7 | 2019-02-17 16:27:10 +0100 | [diff] [blame] | 5603 | f_call_hangup(cpars, true, is_csfb := true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5604 | |
| 5605 | /* Make sure that subscriber is still present and the SGs association is in tact (ref-counting) */ |
| 5606 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 5607 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5608 | /* Test for successful return by triggering a paging, when the paging |
| 5609 | * request is received via SGs, we can be sure that the MSC/VLR has |
| 5610 | * recognized that the UE is now back on 4G */ |
| 5611 | f_sleep(1.0); |
| 5612 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 5613 | alt { |
| 5614 | [] SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)) { |
| 5615 | setverdict(pass); |
| 5616 | } |
| 5617 | [] SGsAP.receive { |
| 5618 | setverdict(fail, "Received unexpected message on SGs"); |
| 5619 | } |
| 5620 | } |
| 5621 | |
| 5622 | f_sgsap_bssmap_screening(); |
| 5623 | |
| 5624 | setverdict(pass); |
| 5625 | } |
| 5626 | |
| 5627 | /* Perform a regular BSSAP LU first, do a SGSAP LU and then make a CSFB call */ |
| 5628 | private function f_tc_bssap_lu_sgsap_lu_and_mt_call(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5629 | f_mt_lu_and_csfb_call(id, pars, true); |
| 5630 | } |
| 5631 | 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] | 5632 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5633 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5634 | f_init(1, true); |
| 5635 | pars := f_init_pars(118139, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5636 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5637 | vc_conn := f_start_handler_with_pars(refers(f_tc_bssap_lu_sgsap_lu_and_mt_call), pars); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5638 | vc_conn.done; |
| 5639 | } |
| 5640 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5641 | /* Perform a SGSAP LU and then make a CSFB call */ |
| 5642 | private function f_tc_sgsap_lu_and_mt_call(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5643 | f_mt_lu_and_csfb_call(id, pars, false); |
| 5644 | } |
| 5645 | testcase TC_sgsap_lu_and_mt_call() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5646 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5647 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5648 | f_init(1, true); |
| 5649 | pars := f_init_pars(11827, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5650 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 5651 | 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] | 5652 | vc_conn.done; |
| 5653 | } |
| 5654 | |
Philipp Maier | 628c005 | 2019-04-09 17:36:57 +0200 | [diff] [blame] | 5655 | /* Simulate an HLR/VLR failure */ |
| 5656 | private function f_tc_sgsap_vlr_failure(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5657 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 5658 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 5659 | |
| 5660 | var PDU_SGsAP lur; |
| 5661 | |
| 5662 | f_init_handler(pars); |
| 5663 | |
| 5664 | /* Attempt location update (which is expected to fail) */ |
| 5665 | lur := valueof(ts_SGsAP_LU_REQ(g_pars.imsi, mme_name, IMSI_attach, |
| 5666 | ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 5667 | SGsAP.send(lur); |
| 5668 | |
| 5669 | /* Respond to SGsAP-RESET-INDICATION from VLR */ |
| 5670 | alt { |
| 5671 | [] SGsAP.receive(tr_SGsAP_RESET_IND_VLR(vlr_name)); { |
| 5672 | SGsAP.send(valueof(ts_SGsAP_RESET_ACK_MME(mme_name))); |
| 5673 | setverdict(pass); |
| 5674 | } |
| 5675 | [] SGsAP.receive { |
| 5676 | setverdict(fail, "Received unexpected message on SGs"); |
| 5677 | } |
| 5678 | } |
| 5679 | |
| 5680 | f_sleep(1.0); |
| 5681 | setverdict(pass); |
| 5682 | } |
| 5683 | testcase TC_sgsap_vlr_failure() runs on MTC_CT { |
| 5684 | var BSC_ConnHdlrPars pars; |
| 5685 | var BSC_ConnHdlr vc_conn; |
| 5686 | f_init(1, true, false); |
| 5687 | pars := f_init_pars(11811, true, false); |
| 5688 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_vlr_failure), pars); |
| 5689 | vc_conn.done; |
| 5690 | } |
| 5691 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 5692 | /* SGs TODO: |
| 5693 | * LU attempt for IMSI without NAM_PS in HLR |
| 5694 | * LU attempt with AUTH FAIL due to invalid RES/SRES |
| 5695 | * LU attempt with no response from HLR (VLR should timeout + LU REJ) |
| 5696 | * LU attempt with new TMSI but without TMSI REALL CMPL baco to VLR |
| 5697 | * implicit IMSI detach from EPS |
| 5698 | * implicit IMSI detach from non-EPS |
| 5699 | * MM INFO |
| 5700 | * |
| 5701 | */ |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 5702 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5703 | private function f_tc_ho_inter_bsc_unknown_cell(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 5704 | f_init_handler(pars); |
| 5705 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5706 | |
| 5707 | f_perform_lu(); |
| 5708 | f_mo_call_establish(cpars); |
| 5709 | |
| 5710 | f_sleep(1.0); |
| 5711 | |
| 5712 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_BETTER_CELL; |
| 5713 | var BssmapCause cause := enum2int(cause_val); |
| 5714 | |
| 5715 | var template BSSMAP_FIELD_CellIdentificationList cil; |
| 5716 | cil := { cIl_LAI := { ts_BSSMAP_CI_LAI('023'H, '42'H, 999) } }; |
| 5717 | |
| 5718 | BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 5719 | BSSAP.receive(tr_BSSMAP_HandoverRequiredReject); |
| 5720 | |
| 5721 | f_call_hangup(cpars, true); |
| 5722 | } |
| 5723 | testcase TC_ho_inter_bsc_unknown_cell() runs on MTC_CT { |
| 5724 | var BSC_ConnHdlr vc_conn; |
| 5725 | f_init(); |
| 5726 | |
| 5727 | vc_conn := f_start_handler(refers(f_tc_ho_inter_bsc_unknown_cell), 53); |
| 5728 | vc_conn.done; |
| 5729 | } |
| 5730 | |
| 5731 | private altstep as_mgcp_ack_all_mdcx(CallParameters cpars) runs on BSC_ConnHdlr { |
| 5732 | var MgcpCommand mgcp_cmd; |
| 5733 | [] MGCP.receive(tr_MDCX) -> value mgcp_cmd { |
Neels Hofmeyr | 8913b9e | 2021-07-27 22:33:45 +0200 | [diff] [blame] | 5734 | var charstring conn_id; |
| 5735 | f_mgcp_find_param_entry(mgcp_cmd.params, "I", conn_id); |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 5736 | 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] | 5737 | hex2str(cpars.mgcp_call_id), "42", |
Neels Hofmeyr | 3c89a6b | 2019-10-15 16:54:37 +0200 | [diff] [blame] | 5738 | cpars.mgw_conn_2.mgw_rtp_port, |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5739 | { int2str(cpars.rtp_payload_type) }, |
| 5740 | { valueof(ts_SDP_rtpmap(cpars.rtp_payload_type, |
| 5741 | cpars.rtp_sdp_format)), |
| 5742 | valueof(ts_SDP_ptime(20)) })); |
Neels Hofmeyr | 8913b9e | 2021-07-27 22:33:45 +0200 | [diff] [blame] | 5743 | 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] | 5744 | repeat; |
| 5745 | } |
| 5746 | } |
| 5747 | |
Neels Hofmeyr | 8853afb | 2021-07-27 22:34:15 +0200 | [diff] [blame] | 5748 | private altstep as_mgcp_ack_all_dlcx(CallParameters cpars) runs on BSC_ConnHdlr { |
| 5749 | var MgcpCommand mgcp_cmd; |
| 5750 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 5751 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
| 5752 | repeat; |
| 5753 | } |
| 5754 | } |
| 5755 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5756 | 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] | 5757 | var CallParameters cpars; |
| 5758 | |
| 5759 | cpars := valueof(t_CallParams('12345'H, 0)); |
| 5760 | if (pars.use_ipv6) { |
| 5761 | cpars.mgw_conn_1.mgw_rtp_ip := "::1"; |
| 5762 | cpars.mgw_conn_2.mgw_rtp_ip := "::2"; |
| 5763 | cpars.bss_rtp_ip := "::3"; |
| 5764 | } |
Oliver Smith | 44424db | 2023-08-22 13:54:09 +0200 | [diff] [blame] | 5765 | if (pars.use_csd) { |
| 5766 | f_set_cpars_csd(cpars, "BS25T", '1'B, GSM48_BCAP_TR_TRANSP, GSM48_BCAP_UR_4800); |
| 5767 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5768 | |
| 5769 | f_init_handler(pars); |
| 5770 | |
| 5771 | f_vty_transceive(MSCVTY, "configure terminal"); |
| 5772 | f_vty_transceive(MSCVTY, "msc"); |
| 5773 | 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] | 5774 | 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] | 5775 | f_vty_transceive(MSCVTY, "exit"); |
| 5776 | f_vty_transceive(MSCVTY, "exit"); |
| 5777 | |
| 5778 | f_perform_lu(); |
| 5779 | f_mo_call_establish(cpars); |
| 5780 | |
| 5781 | f_sleep(1.0); |
| 5782 | |
| 5783 | var default ack_mdcx := activate(as_mgcp_ack_all_mdcx(cpars)); |
| 5784 | |
| 5785 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_BETTER_CELL; |
| 5786 | var BssmapCause cause := enum2int(cause_val); |
| 5787 | |
| 5788 | var template BSSMAP_FIELD_CellIdentificationList cil; |
Neels Hofmeyr | 2822d07 | 2021-06-23 03:20:32 +0200 | [diff] [blame] | 5789 | 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] | 5790 | |
| 5791 | /* old BSS sends Handover Required */ |
| 5792 | BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 5793 | |
| 5794 | /* Now the action goes on in f_tc_ho_inter_bsc1() */ |
| 5795 | |
| 5796 | /* MSC forwards the RR Handover Command to old BSS */ |
| 5797 | var PDU_BSSAP ho_command; |
| 5798 | BSSAP.receive(tr_BSSMAP_HandoverCommand) -> value ho_command; |
| 5799 | |
| 5800 | log("GOT HandoverCommand", ho_command); |
| 5801 | |
| 5802 | BSSAP.receive(tr_BSSMAP_HandoverSucceeded); |
| 5803 | |
| 5804 | /* f_tc_ho_inter_bsc1() completes Handover, then expecting a Clear here. */ |
| 5805 | f_expect_clear(); |
| 5806 | |
| 5807 | log("FIRST inter-BSC Handover done"); |
| 5808 | |
| 5809 | |
| 5810 | /* ------------------------ */ |
| 5811 | |
| 5812 | /* Ok, that went well, now the other BSC is handovering back here -- |
| 5813 | * from now on this here is the new BSS. */ |
Andreas Eversberg | e5a6ef1 | 2023-07-28 10:45:20 +0200 | [diff] [blame] | 5814 | f_create_bssmap_exp_n_connect(193); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5815 | |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5816 | var template BSSMAP_IE_EncryptionInformation encryptionInformation; |
| 5817 | var template BSSMAP_IE_ChosenEncryptionAlgorithm chosenEncryptionAlgorithm; |
| 5818 | var template BSSMAP_IE_KC128 kC128; |
| 5819 | var OCT1 a5_perm_alg; |
| 5820 | f_get_expected_encryption(encryptionInformation, chosenEncryptionAlgorithm, kC128, a5_perm_alg); |
Vadim Yanitskiy | c5fcb89 | 2022-08-04 04:06:07 +0700 | [diff] [blame] | 5821 | var template PDU_BSSAP expect_ho_request := tr_BSSMAP_HandoverRequest(encryptionInformation, |
| 5822 | chosenEncryptionAlgorithm, |
| 5823 | kC128, codecList := ?); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5824 | var PDU_BSSAP ho_request; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5825 | alt { |
| 5826 | [] BSSAP.receive(expect_ho_request); |
| 5827 | [] BSSAP.receive(tr_BSSMAP_HandoverRequest) -> value ho_request { |
| 5828 | log("Error: Wrong handoverRequest received. Expected: ", expect_ho_request, |
| 5829 | " got ", ho_request); |
| 5830 | setverdict(fail, "Wrong handoverRequest received"); |
| 5831 | mtc.stop; |
| 5832 | } |
| 5833 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5834 | |
| 5835 | /* new BSS composes a RR Handover Command */ |
| 5836 | var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 5837 | 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] | 5838 | var BSSMAP_IE_AoIP_TransportLayerAddress tla tla := |
| 5839 | 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] | 5840 | BSSAP.send(ts_BSSMAP_HandoverRequestAcknowledge(rr_ho_cmd_enc, lengthof(rr_ho_cmd_enc), |
| 5841 | tla, ts_BSSMAP_IE_SpeechCodec({ts_CodecFR}))); |
| 5842 | |
| 5843 | /* Now f_tc_ho_inter_bsc1() expects HandoverCommand */ |
| 5844 | |
| 5845 | f_sleep(0.5); |
| 5846 | |
| 5847 | /* Notify that the MS is now over here */ |
| 5848 | |
| 5849 | BSSAP.send(ts_BSSMAP_HandoverDetect); |
| 5850 | f_sleep(0.1); |
| 5851 | BSSAP.send(ts_BSSMAP_HandoverComplete); |
| 5852 | |
| 5853 | f_sleep(3.0); |
| 5854 | |
| 5855 | deactivate(ack_mdcx); |
| 5856 | |
| 5857 | var default ccrel := activate(as_optional_cc_rel(cpars, true)); |
| 5858 | |
| 5859 | /* blatant cheating */ |
| 5860 | var N_Sd_Array last_n_sd := f_bssmap_last_n_sd(); |
| 5861 | last_n_sd[0] := 3; |
| 5862 | f_bssmap_continue_after_n_sd(last_n_sd); |
| 5863 | |
| 5864 | f_call_hangup(cpars, true); |
| 5865 | f_sleep(1.0); |
| 5866 | deactivate(ccrel); |
| 5867 | |
| 5868 | setverdict(pass); |
| 5869 | } |
| 5870 | 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] | 5871 | var charstring bss_rtp_ip; |
| 5872 | if (pars.use_ipv6) { |
| 5873 | bss_rtp_ip := "::8"; |
| 5874 | } else { |
| 5875 | bss_rtp_ip := "1.2.3.4"; |
| 5876 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5877 | f_init_handler(pars); |
Andreas Eversberg | e5a6ef1 | 2023-07-28 10:45:20 +0200 | [diff] [blame] | 5878 | f_create_bssmap_exp_n_connect(194); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5879 | |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5880 | var template BSSMAP_IE_EncryptionInformation encryptionInformation; |
| 5881 | var template BSSMAP_IE_ChosenEncryptionAlgorithm chosenEncryptionAlgorithm; |
| 5882 | var template BSSMAP_IE_KC128 kC128; |
| 5883 | var OCT1 a5_perm_alg; |
| 5884 | f_get_expected_encryption(encryptionInformation, chosenEncryptionAlgorithm, kC128, a5_perm_alg); |
Vadim Yanitskiy | c5fcb89 | 2022-08-04 04:06:07 +0700 | [diff] [blame] | 5885 | var template PDU_BSSAP expect_ho_request := tr_BSSMAP_HandoverRequest(encryptionInformation, |
| 5886 | chosenEncryptionAlgorithm, |
| 5887 | kC128, codecList := ?); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5888 | var PDU_BSSAP ho_request; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5889 | alt { |
| 5890 | [] BSSAP.receive(expect_ho_request); |
| 5891 | [] BSSAP.receive(tr_BSSMAP_HandoverRequest) -> value ho_request { |
| 5892 | log("Error: Wrong handoverRequest received. Expected: ", expect_ho_request, |
| 5893 | " got ", ho_request); |
| 5894 | setverdict(fail, "Wrong handoverRequest received"); |
| 5895 | mtc.stop; |
| 5896 | } |
| 5897 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5898 | /* new BSS composes a RR Handover Command */ |
| 5899 | var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 5900 | 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] | 5901 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := |
| 5902 | valueof(f_ts_BSSMAP_IE_AoIP_TLA(bss_rtp_ip, 2342)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5903 | BSSAP.send(ts_BSSMAP_HandoverRequestAcknowledge(rr_ho_cmd_enc, lengthof(rr_ho_cmd_enc), |
| 5904 | tla, ts_BSSMAP_IE_SpeechCodec({ts_CodecFR}))); |
| 5905 | |
| 5906 | /* Now f_tc_ho_inter_bsc0() expects HandoverCommand */ |
| 5907 | |
| 5908 | f_sleep(0.5); |
| 5909 | |
| 5910 | /* Notify that the MS is now over here */ |
| 5911 | |
| 5912 | BSSAP.send(ts_BSSMAP_HandoverDetect); |
| 5913 | f_sleep(0.1); |
| 5914 | BSSAP.send(ts_BSSMAP_HandoverComplete); |
| 5915 | |
| 5916 | f_sleep(3.0); |
| 5917 | |
| 5918 | /* Now I'd like to f_call_hangup() but we don't know any cpars here. So |
| 5919 | * ... handover back to the first BSC :P */ |
| 5920 | |
| 5921 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_BETTER_CELL; |
| 5922 | var BssmapCause cause := enum2int(cause_val); |
| 5923 | |
| 5924 | var template BSSMAP_FIELD_CellIdentificationList cil; |
Neels Hofmeyr | 2822d07 | 2021-06-23 03:20:32 +0200 | [diff] [blame] | 5925 | 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] | 5926 | |
| 5927 | /* old BSS sends Handover Required */ |
| 5928 | BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 5929 | |
| 5930 | /* Now the action goes on in f_tc_ho_inter_bsc0() */ |
| 5931 | |
| 5932 | /* MSC forwards the RR Handover Command to old BSS */ |
| 5933 | var PDU_BSSAP ho_command; |
| 5934 | BSSAP.receive(tr_BSSMAP_HandoverCommand) -> value ho_command; |
| 5935 | |
| 5936 | log("GOT HandoverCommand", ho_command); |
| 5937 | |
| 5938 | BSSAP.receive(tr_BSSMAP_HandoverSucceeded); |
| 5939 | |
| 5940 | /* f_tc_ho_inter_bsc1() completes Handover, then expecting a Clear here. */ |
| 5941 | f_expect_clear(); |
| 5942 | setverdict(pass); |
| 5943 | } |
Oliver Smith | 44424db | 2023-08-22 13:54:09 +0200 | [diff] [blame] | 5944 | function f_tc_ho_inter_bsc_main(boolean use_ipv6 := false, integer a5_n := 0, boolean use_csd := false) runs on MTC_CT { |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5945 | var BSC_ConnHdlr vc_conn0; |
| 5946 | var BSC_ConnHdlr vc_conn1; |
| 5947 | f_init(2); |
| 5948 | |
| 5949 | var BSC_ConnHdlrPars pars0 := f_init_pars(53); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 5950 | pars0.use_ipv6 := use_ipv6; |
Oliver Smith | 44424db | 2023-08-22 13:54:09 +0200 | [diff] [blame] | 5951 | pars0.use_csd := use_csd; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5952 | pars0.net.expect_ciph := a5_n > 0; |
| 5953 | pars0.net.expect_auth := pars0.net.expect_ciph; |
| 5954 | pars0.net.kc_support := bit2oct('00000001'B << a5_n); |
| 5955 | pars0.cm2.classmarkInformationType2_oct5.a5_3 := '1'B; |
| 5956 | pars0.cm2.classmarkInformationType2_oct5.a5_2 := '0'B; |
| 5957 | pars0.cm2.classmarkInformationType2_oct5.cm3 := '1'B; |
| 5958 | pars0.cm3 := valueof(ts_CM3_default); |
| 5959 | pars0.use_umts_aka := true; |
| 5960 | pars0.vec := f_gen_auth_vec_3g(); |
| 5961 | pars0.vec_keep := true; |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 5962 | pars0.ran_idx := 0; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5963 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5964 | var BSC_ConnHdlrPars pars1 := f_init_pars(53); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 5965 | pars1.use_ipv6 := use_ipv6; |
Oliver Smith | 44424db | 2023-08-22 13:54:09 +0200 | [diff] [blame] | 5966 | pars1.use_csd := use_csd; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5967 | pars1.net.expect_ciph := pars0.net.expect_ciph; |
| 5968 | pars1.net.expect_auth := pars0.net.expect_ciph; |
| 5969 | pars1.net.kc_support := bit2oct('00000001'B << a5_n); |
| 5970 | pars1.cm2 := pars0.cm2; |
| 5971 | pars1.cm3 := pars0.cm3; |
| 5972 | pars1.use_umts_aka := true; |
| 5973 | /* Both components need the same auth vector info because we expect f_tc_ho_inter_bsc0's ciphering key to be |
| 5974 | * identical to the one that shows up in f_tc_ho_inter_bsc1. Can only do that by feeding in a vector to both |
| 5975 | * components and then not overwriting it in BSC_ConnectionHandler. */ |
| 5976 | pars1.vec := pars0.vec; |
| 5977 | pars1.vec_keep := true; |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 5978 | pars1.ran_idx := 1; |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5979 | |
| 5980 | if (a5_n > 0) { |
| 5981 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 5982 | } |
| 5983 | f_vty_config(MSCVTY, "network", "encryption a5 " & int2str(a5_n)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 5984 | |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 5985 | vc_conn0 := f_start_handler_with_pars(refers(f_tc_ho_inter_bsc0), pars0); |
| 5986 | 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] | 5987 | vc_conn0.done; |
| 5988 | vc_conn1.done; |
| 5989 | } |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 5990 | testcase TC_ho_inter_bsc() runs on MTC_CT { |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 5991 | f_tc_ho_inter_bsc_main(false, a5_n := 0); |
| 5992 | } |
| 5993 | testcase TC_ho_inter_bsc_a5_1() runs on MTC_CT { |
| 5994 | f_tc_ho_inter_bsc_main(false, a5_n := 1); |
| 5995 | } |
| 5996 | testcase TC_ho_inter_bsc_a5_3() runs on MTC_CT { |
| 5997 | f_tc_ho_inter_bsc_main(false, a5_n := 3); |
| 5998 | } |
| 5999 | testcase TC_ho_inter_bsc_a5_4() runs on MTC_CT { |
| 6000 | f_tc_ho_inter_bsc_main(false, a5_n := 4); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 6001 | } |
| 6002 | testcase TC_ho_inter_bsc_ipv6() runs on MTC_CT { |
| 6003 | f_tc_ho_inter_bsc_main(true); |
| 6004 | } |
Oliver Smith | 44424db | 2023-08-22 13:54:09 +0200 | [diff] [blame] | 6005 | testcase TC_ho_inter_bsc_csd() runs on MTC_CT { |
| 6006 | f_tc_ho_inter_bsc_main(use_csd := true); |
| 6007 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6008 | |
| 6009 | function f_ML3_patch_seq_nr_MS_NW(in uint2_t seq_nr, inout octetstring enc_l3) { |
| 6010 | log("MS_NW patching N(SD)=", seq_nr, " into dtap ", enc_l3); |
| 6011 | enc_l3[2] := (enc_l3[2] and4b '3f'O) or4b bit2oct(int2bit(seq_nr, 8) << 6); |
| 6012 | log("MS_NW patched enc_l3: ", enc_l3); |
| 6013 | } |
| 6014 | |
| 6015 | 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] | 6016 | var CallParameters cpars; |
Neels Hofmeyr | 906af10 | 2021-07-01 12:08:35 +0200 | [diff] [blame] | 6017 | var PDU_BSSAP ho_request; |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 6018 | |
| 6019 | cpars := valueof(t_CallParams('12345'H, 0)); |
| 6020 | if (pars.use_ipv6) { |
Oliver Smith | be92291 | 2023-08-23 15:27:37 +0200 | [diff] [blame] | 6021 | cpars.mgw_conn_1.mgw_rtp_ip := "::1"; |
| 6022 | cpars.mgw_conn_2.mgw_rtp_ip := "::2"; |
| 6023 | cpars.bss_rtp_ip := "::3"; |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 6024 | } |
Oliver Smith | caa36c9 | 2023-08-23 15:30:33 +0200 | [diff] [blame] | 6025 | if (pars.use_csd) { |
| 6026 | f_set_cpars_csd(cpars, "BS25T", '1'B, GSM48_BCAP_TR_TRANSP, GSM48_BCAP_UR_4800); |
| 6027 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6028 | var hexstring ho_number := f_gen_msisdn(99999); |
| 6029 | |
| 6030 | f_init_handler(pars); |
| 6031 | |
| 6032 | f_create_mncc_expect(hex2str(ho_number)); |
| 6033 | |
| 6034 | f_vty_transceive(MSCVTY, "configure terminal"); |
| 6035 | f_vty_transceive(MSCVTY, "msc"); |
| 6036 | f_vty_transceive(MSCVTY, "neighbor a cgi 017 017 1 1 msc-ipa-name msc-017-017-1"); |
| 6037 | f_vty_transceive(MSCVTY, "exit"); |
| 6038 | f_vty_transceive(MSCVTY, "exit"); |
| 6039 | |
| 6040 | f_perform_lu(); |
| 6041 | f_mo_call_establish(cpars); |
| 6042 | |
| 6043 | f_sleep(1.0); |
| 6044 | |
| 6045 | var default ack_mdcx := activate(as_mgcp_ack_all_mdcx(cpars)); |
| 6046 | |
| 6047 | var myBSSMAP_Cause cause_val := GSM0808_CAUSE_BETTER_CELL; |
| 6048 | var BssmapCause cause := enum2int(cause_val); |
| 6049 | |
| 6050 | var template BSSMAP_FIELD_CellIdentificationList cil; |
Neels Hofmeyr | 36ebc33 | 2021-06-23 03:20:32 +0200 | [diff] [blame] | 6051 | cil := { cIl_CGI := { ts_BSSMAP_CI_CGI('017'H, '017'H, 1, 1) } }; |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6052 | |
| 6053 | /* old BSS sends Handover Required */ |
| 6054 | BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 6055 | |
| 6056 | /* The target cell 017-017 LAC 1 is configured to be a remote MSC of name "msc-017-017-1". |
| 6057 | * This MSC tries to reach the other MSC via GSUP. */ |
| 6058 | |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6059 | var template BSSMAP_IE_EncryptionInformation encryptionInformation; |
| 6060 | var template BSSMAP_IE_ChosenEncryptionAlgorithm chosenEncryptionAlgorithm; |
| 6061 | var template BSSMAP_IE_KC128 kC128; |
| 6062 | var OCT1 a5_perm_alg; |
| 6063 | f_get_expected_encryption(encryptionInformation, chosenEncryptionAlgorithm, kC128, a5_perm_alg); |
Vadim Yanitskiy | c5fcb89 | 2022-08-04 04:06:07 +0700 | [diff] [blame] | 6064 | var template PDU_BSSAP expect_ho_request := tr_BSSMAP_HandoverRequest(encryptionInformation, |
| 6065 | chosenEncryptionAlgorithm, |
| 6066 | kC128, codecList := ?); |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6067 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6068 | var octetstring remote_msc_name := '6D73632D3031372D3031372D3100'O; /* "msc-017-017-1\0" as octetstring */ |
| 6069 | var GSUP_PDU prep_ho_req; |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6070 | alt { |
| 6071 | [] GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST, |
| 6072 | pars.imsi, destination_name := remote_msc_name, |
Neels Hofmeyr | ec2e1f7 | 2021-07-02 02:08:32 +0200 | [diff] [blame] | 6073 | an_apdu := t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, pdu := ?))) -> value prep_ho_req; |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6074 | [] GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST)) { |
| 6075 | setverdict(fail, "Wrong OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST message received"); |
| 6076 | mtc.stop; |
| 6077 | } |
| 6078 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6079 | |
| 6080 | var GSUP_IeValue source_name_ie; |
| 6081 | f_gsup_find_ie(prep_ho_req, OSMO_GSUP_SOURCE_NAME_IE, source_name_ie); |
| 6082 | var octetstring local_msc_name := source_name_ie.source_name; |
| 6083 | |
Neels Hofmeyr | ec2e1f7 | 2021-07-02 02:08:32 +0200 | [diff] [blame] | 6084 | /* Decode PDU to 1) match with expect_ho_request and 2) to forward the actual chosen encryption algorithm. */ |
Neels Hofmeyr | 906af10 | 2021-07-01 12:08:35 +0200 | [diff] [blame] | 6085 | var GSUP_IeValue an_apdu_ie; |
| 6086 | f_gsup_find_ie(prep_ho_req, OSMO_GSUP_AN_APDU_IE, an_apdu_ie); |
| 6087 | ho_request := dec_PDU_BSSAP(an_apdu_ie.an_apdu.pdu); |
Neels Hofmeyr | ec2e1f7 | 2021-07-02 02:08:32 +0200 | [diff] [blame] | 6088 | if (not match(ho_request, expect_ho_request)) { |
| 6089 | setverdict(fail, "Wrong PDU in OSMO_GSUP_MSGT_E_PREPARE_HANDOVER_REQUEST message received"); |
| 6090 | mtc.stop; |
| 6091 | } |
Neels Hofmeyr | 906af10 | 2021-07-01 12:08:35 +0200 | [diff] [blame] | 6092 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6093 | /* Remote MSC has figured out its BSC and signals success */ |
| 6094 | var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 6095 | var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd); |
| 6096 | var PDU_BSSAP ho_req_ack := valueof(ts_BSSMAP_HandoverRequestAcknowledge(rr_ho_cmd_enc, lengthof(rr_ho_cmd_enc), |
Neels Hofmeyr | 906af10 | 2021-07-01 12:08:35 +0200 | [diff] [blame] | 6097 | aoIPTransportLayer := omit, |
| 6098 | speechCodec := ts_BSSMAP_IE_SpeechCodec({ts_CodecFR}), |
| 6099 | chosenEncryptionAlgorithm := ho_request.pdu.bssmap.handoverRequest.chosenEncryptionAlgorithm)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6100 | GSUP.send(ts_GSUP_E_PrepareHandoverResult( |
| 6101 | pars.imsi, |
| 6102 | ho_number, |
| 6103 | remote_msc_name, local_msc_name, |
| 6104 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, enc_PDU_BSSAP(ho_req_ack))))); |
| 6105 | |
| 6106 | /* MSC forwards the RR Handover Command to old BSS */ |
| 6107 | BSSAP.receive(tr_BSSMAP_HandoverCommand); |
| 6108 | |
| 6109 | /* The MS shows up at remote new BSS */ |
| 6110 | |
| 6111 | GSUP.send(ts_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PROCESS_ACCESS_SIGNALLING_REQUEST, |
| 6112 | pars.imsi, remote_msc_name, local_msc_name, |
| 6113 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, |
| 6114 | enc_PDU_BSSAP(valueof(ts_BSSMAP_HandoverDetect)))))); |
| 6115 | BSSAP.receive(tr_BSSMAP_HandoverSucceeded); |
| 6116 | f_sleep(0.1); |
| 6117 | |
| 6118 | /* Save the MS sequence counters for use on the other connection */ |
| 6119 | var N_Sd_Array last_n_sd := f_bssmap_last_n_sd(); |
| 6120 | |
| 6121 | GSUP.send(ts_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_SEND_END_SIGNAL_REQUEST, |
| 6122 | pars.imsi, remote_msc_name, local_msc_name, |
| 6123 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, |
| 6124 | enc_PDU_BSSAP(valueof(ts_BSSMAP_HandoverComplete)))))); |
| 6125 | |
| 6126 | /* The local BSS conn clears, all communication goes via remote MSC now */ |
| 6127 | f_expect_clear(); |
| 6128 | |
| 6129 | /**********************************/ |
| 6130 | /* Play through some signalling across the inter-MSC link. |
| 6131 | * This is a copy of f_tc_lu_and_mo_ussd_single_request() translated into GSUP AN-APDUs. */ |
| 6132 | |
| 6133 | if (false) { |
| 6134 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 6135 | invoke_id := 5, /* Phone may not start from 0 or 1 */ |
| 6136 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 6137 | ussd_string := "*#100#" |
| 6138 | ); |
| 6139 | |
| 6140 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 6141 | invoke_id := 5, /* InvokeID shall be the same for both REQ and RSP */ |
| 6142 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 6143 | ussd_string := "Your extension is " & hex2str(g_pars.msisdn) & "\r" |
| 6144 | ) |
| 6145 | |
| 6146 | /* Compose a new SS/REGISTER message with request */ |
| 6147 | var template (value) PDU_ML3_MS_NW ussd_req := ts_ML3_MO_SS_REGISTER( |
| 6148 | tid := 1, /* We just need a single transaction */ |
| 6149 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 6150 | facility := valueof(facility_req) |
| 6151 | ); |
| 6152 | var PDU_ML3_MS_NW ussd_req_v := valueof(ussd_req); |
| 6153 | |
| 6154 | /* Compose SS/RELEASE_COMPLETE template with expected response */ |
| 6155 | var template PDU_ML3_NW_MS ussd_rsp := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 6156 | tid := 1, /* Response should arrive within the same transaction */ |
| 6157 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 6158 | facility := valueof(facility_rsp) |
| 6159 | ); |
| 6160 | |
| 6161 | /* Compose expected MSC -> HLR message */ |
| 6162 | var template GSUP_PDU gsup_req := tr_GSUP_PROC_SS_REQ( |
| 6163 | imsi := g_pars.imsi, |
| 6164 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 6165 | ss := valueof(facility_req) |
| 6166 | ); |
| 6167 | |
| 6168 | /* To be used for sending response with correct session ID */ |
| 6169 | var GSUP_PDU gsup_req_complete; |
| 6170 | |
| 6171 | /* Request own number */ |
| 6172 | /* From remote MSC instead of BSSAP directly */ |
| 6173 | /* Patch the correct N_SD value into the message. */ |
| 6174 | var octetstring l3_enc := enc_PDU_ML3_MS_NW(ussd_req_v); |
| 6175 | var RAN_Emulation.ConnectionData cd; |
| 6176 | f_ML3_patch_seq_nr_MS_NW(f_next_n_sd(last_n_sd, f_ML3_n_sd_idx(ussd_req_v)), l3_enc); |
| 6177 | GSUP.send(ts_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PROCESS_ACCESS_SIGNALLING_REQUEST, |
| 6178 | pars.imsi, remote_msc_name, local_msc_name, |
| 6179 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, |
| 6180 | enc_PDU_BSSAP(valueof(ts_BSSAP_DTAP(l3_enc))) |
| 6181 | )) |
| 6182 | )); |
| 6183 | |
| 6184 | /* Expect GSUP message containing the SS payload */ |
| 6185 | gsup_req_complete := f_expect_gsup_msg(gsup_req); |
| 6186 | |
| 6187 | /* Compose the response from HLR using received session ID */ |
| 6188 | var template GSUP_PDU gsup_rsp := ts_GSUP_PROC_SS_REQ( |
| 6189 | imsi := g_pars.imsi, |
| 6190 | sid := gsup_req_complete.ies[1].val.session_id, |
| 6191 | state := OSMO_GSUP_SESSION_STATE_END, |
| 6192 | ss := valueof(facility_rsp) |
| 6193 | ); |
| 6194 | |
| 6195 | /* Finally, HLR terminates the session */ |
| 6196 | GSUP.send(gsup_rsp); |
| 6197 | |
| 6198 | /* The USSD response goes out to remote MSC, on GSUP E instead of BSSAP */ |
| 6199 | var GSUP_PDU gsup_ussd_rsp; |
| 6200 | GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_FORWARD_ACCESS_SIGNALLING_REQUEST, |
| 6201 | pars.imsi, destination_name := remote_msc_name)) -> value gsup_ussd_rsp; |
| 6202 | |
| 6203 | var GSUP_IeValue an_apdu; |
| 6204 | if (not f_gsup_find_ie(gsup_ussd_rsp, OSMO_GSUP_AN_APDU_IE, an_apdu)) { |
| 6205 | setverdict(fail, "No AN-APDU in received GSUP message. Expected USSD response in DTAP, got", gsup_ussd_rsp); |
| 6206 | mtc.stop; |
| 6207 | } |
| 6208 | var PDU_BSSAP bssap_dtap_mt := dec_PDU_BSSAP(an_apdu.an_apdu.pdu); |
| 6209 | var PDU_ML3_NW_MS dtap_mt := dec_PDU_ML3_NW_MS(bssap_dtap_mt.pdu.dtap); |
| 6210 | log("Expecting", ussd_rsp); |
| 6211 | log("Got", dtap_mt); |
| 6212 | if (not match(dtap_mt, ussd_rsp)) { |
| 6213 | setverdict(fail, "Unexpected GSUP message. Expected USSD response in DTAP, got", gsup_ussd_rsp); |
| 6214 | mtc.stop; |
| 6215 | } |
| 6216 | } |
| 6217 | /**********************************/ |
| 6218 | |
| 6219 | |
| 6220 | /* inter-MSC handover back to the first MSC */ |
Andreas Eversberg | e5a6ef1 | 2023-07-28 10:45:20 +0200 | [diff] [blame] | 6221 | f_create_bssmap_exp_n_connect(193); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6222 | cil := { cIl_CGI := { ts_BSSMAP_CI_CGI('262'H, '42'H, 23, 42) } }; |
| 6223 | |
| 6224 | /* old BSS sends Handover Required, via inter-MSC E link: like |
| 6225 | * BSSAP.send(ts_BSSMAP_HandoverRequired(cause, cil)); |
| 6226 | * but via GSUP */ |
| 6227 | GSUP.send(ts_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_REQUEST, |
| 6228 | pars.imsi, remote_msc_name, local_msc_name, |
| 6229 | valueof(t_GSUP_AN_APDU(OSMO_GSUP_AN_PROTO_48006, |
| 6230 | enc_PDU_BSSAP(valueof(ts_BSSMAP_HandoverRequired(cause, cil))) |
| 6231 | )) |
| 6232 | )); |
| 6233 | |
| 6234 | /* MSC asks local BSS to prepare Handover to it */ |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6235 | f_get_expected_encryption(encryptionInformation, chosenEncryptionAlgorithm, kC128, a5_perm_alg); |
Vadim Yanitskiy | c5fcb89 | 2022-08-04 04:06:07 +0700 | [diff] [blame] | 6236 | expect_ho_request := tr_BSSMAP_HandoverRequest(encryptionInformation, |
| 6237 | chosenEncryptionAlgorithm, |
| 6238 | kC128, codecList := ?); |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6239 | alt { |
Neels Hofmeyr | 906af10 | 2021-07-01 12:08:35 +0200 | [diff] [blame] | 6240 | [] BSSAP.receive(expect_ho_request) -> value ho_request; |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6241 | [] BSSAP.receive(tr_BSSMAP_HandoverRequest) -> value ho_request { |
| 6242 | log("Error: Wrong handoverRequest received. Expected: ", expect_ho_request, |
| 6243 | " got ", ho_request); |
| 6244 | setverdict(fail, "Wrong handoverRequest received"); |
| 6245 | mtc.stop; |
| 6246 | } |
| 6247 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6248 | |
| 6249 | /* Make sure the new BSSAP conn continues with the correct N_SD sequence numbers */ |
| 6250 | f_bssmap_continue_after_n_sd(last_n_sd); |
| 6251 | |
| 6252 | /* new BSS composes a RR Handover Command */ |
| 6253 | rr_ho_cmd := valueof(ts_RR_HandoverCommand); |
| 6254 | rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 6255 | var BSSMAP_IE_AoIP_TransportLayerAddress tla := |
| 6256 | valueof(f_ts_BSSMAP_IE_AoIP_TLA(cpars.bss_rtp_ip, cpars.bss_rtp_port)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6257 | BSSAP.send(ts_BSSMAP_HandoverRequestAcknowledge(rr_ho_cmd_enc, lengthof(rr_ho_cmd_enc), |
Neels Hofmeyr | 906af10 | 2021-07-01 12:08:35 +0200 | [diff] [blame] | 6258 | tla, ts_BSSMAP_IE_SpeechCodec({ts_CodecFR}), |
| 6259 | chosenEncryptionAlgorithm := ho_request.pdu.bssmap.handoverRequest.chosenEncryptionAlgorithm)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6260 | |
| 6261 | /* HandoverCommand goes out via remote MSC-I */ |
| 6262 | var GSUP_PDU prep_subsq_ho_res; |
| 6263 | GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_PREPARE_SUBSEQUENT_HANDOVER_RESULT, |
| 6264 | pars.imsi, destination_name := remote_msc_name)) -> value prep_subsq_ho_res; |
| 6265 | |
| 6266 | /* MS shows up at the local BSS */ |
| 6267 | BSSAP.send(ts_BSSMAP_HandoverDetect); |
| 6268 | f_sleep(0.1); |
| 6269 | BSSAP.send(ts_BSSMAP_HandoverComplete); |
| 6270 | |
| 6271 | /* Handover Succeeded message */ |
| 6272 | GSUP.receive(tr_GSUP_E_AN_APDU(OSMO_GSUP_MSGT_E_FORWARD_ACCESS_SIGNALLING_REQUEST, |
| 6273 | pars.imsi, destination_name := remote_msc_name)); |
| 6274 | |
| 6275 | /* MS has handovered to here, Clear Command goes out via remote MSC-I -- in form of a GSUP Close. */ |
| 6276 | GSUP.receive(tr_GSUP_E_NO_PDU(OSMO_GSUP_MSGT_E_CLOSE, |
| 6277 | pars.imsi, destination_name := remote_msc_name)); |
| 6278 | |
| 6279 | /* Handover ends successfully. Call goes on for a little longer and then we hang up. */ |
| 6280 | |
| 6281 | f_sleep(1.0); |
| 6282 | deactivate(ack_mdcx); |
| 6283 | |
| 6284 | /* FIXME: the inter-MSC call has put a number of MNCC messages in the queue, which above code should expect and |
| 6285 | * clear out. The f_call_hangup() expects an MNCC_REL_IND, so, for the time being, just clear the MNCC messages |
| 6286 | * before starting the call hangup. Instead of this, the individual messages should be tested for above. */ |
| 6287 | MNCC.clear; |
| 6288 | |
| 6289 | var default ccrel := activate(as_optional_cc_rel(cpars, true)); |
| 6290 | f_call_hangup(cpars, true); |
| 6291 | f_sleep(1.0); |
| 6292 | deactivate(ccrel); |
| 6293 | |
| 6294 | setverdict(pass); |
| 6295 | } |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6296 | function f_tc_ho_inter_msc_out_a5(integer a5_n) runs on MTC_CT { |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6297 | var BSC_ConnHdlr vc_conn; |
| 6298 | f_init(1); |
| 6299 | |
| 6300 | var BSC_ConnHdlrPars pars := f_init_pars(54); |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6301 | pars.net.expect_ciph := a5_n > 0; |
| 6302 | pars.net.expect_auth := pars.net.expect_ciph; |
| 6303 | pars.net.kc_support := bit2oct('00000001'B << a5_n); |
| 6304 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '1'B; |
| 6305 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '0'B; |
| 6306 | pars.cm2.classmarkInformationType2_oct5.cm3 := '1'B; |
| 6307 | pars.cm3 := valueof(ts_CM3_default); |
| 6308 | pars.use_umts_aka := true; |
| 6309 | |
| 6310 | if (a5_n > 0) { |
| 6311 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6312 | } |
| 6313 | f_vty_config(MSCVTY, "network", "encryption a5 " & int2str(a5_n)); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6314 | |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 6315 | vc_conn := f_start_handler_with_pars(refers(f_tc_ho_inter_msc_out), pars); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6316 | vc_conn.done; |
| 6317 | } |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 6318 | testcase TC_ho_inter_msc_out() runs on MTC_CT { |
| 6319 | f_tc_ho_inter_msc_out_a5(0); |
| 6320 | } |
| 6321 | testcase TC_ho_inter_msc_out_a5_1() runs on MTC_CT { |
| 6322 | f_tc_ho_inter_msc_out_a5(1); |
| 6323 | } |
| 6324 | testcase TC_ho_inter_msc_out_a5_3() runs on MTC_CT { |
| 6325 | f_tc_ho_inter_msc_out_a5(3); |
| 6326 | } |
| 6327 | testcase TC_ho_inter_msc_out_a5_4() runs on MTC_CT { |
| 6328 | f_tc_ho_inter_msc_out_a5(4); |
| 6329 | } |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 6330 | testcase TC_ho_inter_msc_out_ipv6() runs on MTC_CT { |
| 6331 | var BSC_ConnHdlr vc_conn; |
| 6332 | f_init(1); |
| 6333 | |
| 6334 | var BSC_ConnHdlrPars pars := f_init_pars(54); |
| 6335 | pars.use_ipv6 := true; |
| 6336 | |
Neels Hofmeyr | 60122f8 | 2021-07-28 17:59:38 +0200 | [diff] [blame] | 6337 | vc_conn := f_start_handler_with_pars(refers(f_tc_ho_inter_msc_out), pars); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 6338 | vc_conn.done; |
| 6339 | } |
Oliver Smith | caa36c9 | 2023-08-23 15:30:33 +0200 | [diff] [blame] | 6340 | testcase TC_ho_inter_msc_out_csd() runs on MTC_CT { |
| 6341 | var BSC_ConnHdlr vc_conn; |
| 6342 | f_init(1); |
| 6343 | |
| 6344 | var BSC_ConnHdlrPars pars := f_init_pars(54); |
| 6345 | pars.use_csd := true; |
| 6346 | |
| 6347 | vc_conn := f_start_handler_with_pars(refers(f_tc_ho_inter_msc_out), pars); |
| 6348 | vc_conn.done; |
| 6349 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6350 | |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6351 | private function f_tc_lu_imsi_auth_tmsi_check_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6352 | pars.net.expect_auth := true; |
| 6353 | pars.net.expect_imei := true; |
| 6354 | f_init_handler(pars); |
| 6355 | f_perform_lu(); |
| 6356 | } |
| 6357 | testcase TC_lu_imsi_auth_tmsi_check_imei() runs on MTC_CT { |
| 6358 | var BSC_ConnHdlr vc_conn; |
| 6359 | f_init(); |
| 6360 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6361 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6362 | |
| 6363 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei), 5); |
| 6364 | vc_conn.done; |
| 6365 | } |
| 6366 | |
| 6367 | private function f_tc_lu_imsi_auth3g_tmsi_check_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6368 | pars.net.expect_auth := true; |
| 6369 | pars.use_umts_aka := true; |
| 6370 | pars.net.expect_imei := true; |
| 6371 | f_init_handler(pars); |
| 6372 | f_perform_lu(); |
| 6373 | } |
| 6374 | testcase TC_lu_imsi_auth3g_tmsi_check_imei() runs on MTC_CT { |
| 6375 | var BSC_ConnHdlr vc_conn; |
| 6376 | f_init(); |
| 6377 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6378 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6379 | |
| 6380 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth3g_tmsi_check_imei), 5); |
| 6381 | vc_conn.done; |
| 6382 | } |
| 6383 | |
| 6384 | private function f_tc_lu_imsi_noauth_tmsi_check_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6385 | pars.net.expect_imei := true; |
| 6386 | f_init_handler(pars); |
| 6387 | f_perform_lu(); |
| 6388 | } |
| 6389 | testcase TC_lu_imsi_noauth_tmsi_check_imei() runs on MTC_CT { |
| 6390 | var BSC_ConnHdlr vc_conn; |
| 6391 | f_init(); |
| 6392 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6393 | |
| 6394 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_tmsi_check_imei), 5); |
| 6395 | vc_conn.done; |
| 6396 | } |
| 6397 | |
| 6398 | private function f_tc_lu_imsi_noauth_notmsi_check_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6399 | pars.net.expect_tmsi := false; |
| 6400 | pars.net.expect_imei := true; |
| 6401 | f_init_handler(pars); |
| 6402 | f_perform_lu(); |
| 6403 | } |
| 6404 | testcase TC_lu_imsi_noauth_notmsi_check_imei() runs on MTC_CT { |
| 6405 | var BSC_ConnHdlr vc_conn; |
| 6406 | f_init(); |
| 6407 | f_vty_config(MSCVTY, "msc", "no assign-tmsi"); |
| 6408 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6409 | |
| 6410 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_notmsi_check_imei), 5); |
| 6411 | vc_conn.done; |
| 6412 | } |
| 6413 | |
| 6414 | private function f_tc_lu_imsi_auth_tmsi_check_imei_nack(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6415 | var PDU_ML3_MS_NW l3_lu; |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6416 | |
| 6417 | pars.net.expect_auth := true; |
| 6418 | pars.net.expect_imei := true; |
| 6419 | pars.net.check_imei_result := OSMO_GSUP_IMEI_RESULT_NACK; |
| 6420 | f_init_handler(pars); |
| 6421 | |
| 6422 | /* Cannot use f_perform_lu() as we expect a reject */ |
| 6423 | l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 6424 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6425 | f_bssap_compl_l3(l3_lu); |
| 6426 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 6427 | |
| 6428 | f_mm_common(); |
| 6429 | f_msc_lu_hlr(); |
| 6430 | f_mm_imei(); |
Oliver Smith | 91bfa1c | 2019-07-19 15:01:15 +0200 | [diff] [blame] | 6431 | f_expect_lu_reject(); |
Eric Wild | 85cc161 | 2022-03-30 01:44:29 +0200 | [diff] [blame] | 6432 | f_expect_clear(verify_vlr_cell_id:=false); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6433 | } |
| 6434 | testcase TC_lu_imsi_auth_tmsi_check_imei_nack() runs on MTC_CT { |
| 6435 | var BSC_ConnHdlr vc_conn; |
| 6436 | f_init(); |
| 6437 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6438 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6439 | |
| 6440 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_nack), 5); |
| 6441 | vc_conn.done; |
| 6442 | } |
| 6443 | |
| 6444 | private function f_tc_lu_imsi_auth_tmsi_check_imei_err(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6445 | var PDU_ML3_MS_NW l3_lu; |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6446 | |
| 6447 | pars.net.expect_auth := true; |
| 6448 | pars.net.expect_imei := true; |
| 6449 | pars.net.check_imei_error := true; |
| 6450 | f_init_handler(pars); |
| 6451 | |
| 6452 | /* Cannot use f_perform_lu() as we expect a reject */ |
| 6453 | l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 6454 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6455 | f_bssap_compl_l3(l3_lu); |
| 6456 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 6457 | |
| 6458 | f_mm_common(); |
| 6459 | f_msc_lu_hlr(); |
| 6460 | f_mm_imei(); |
Oliver Smith | 91bfa1c | 2019-07-19 15:01:15 +0200 | [diff] [blame] | 6461 | f_expect_lu_reject(); |
Eric Wild | 85cc161 | 2022-03-30 01:44:29 +0200 | [diff] [blame] | 6462 | f_expect_clear(verify_vlr_cell_id:=false); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6463 | } |
| 6464 | testcase TC_lu_imsi_auth_tmsi_check_imei_err() runs on MTC_CT { |
| 6465 | var BSC_ConnHdlr vc_conn; |
| 6466 | f_init(); |
| 6467 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6468 | f_vty_config(MSCVTY, "msc", "check-imei-rqd 1"); |
| 6469 | |
| 6470 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_err), 5); |
| 6471 | vc_conn.done; |
| 6472 | } |
| 6473 | |
| 6474 | private function f_tc_lu_imsi_auth_tmsi_check_imei_early(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6475 | pars.net.expect_auth := true; |
| 6476 | pars.net.expect_imei_early := true; |
| 6477 | f_init_handler(pars); |
| 6478 | f_perform_lu(); |
| 6479 | } |
| 6480 | testcase TC_lu_imsi_auth_tmsi_check_imei_early() runs on MTC_CT { |
| 6481 | var BSC_ConnHdlr vc_conn; |
| 6482 | f_init(); |
| 6483 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6484 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6485 | |
| 6486 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_early), 5); |
| 6487 | vc_conn.done; |
| 6488 | } |
| 6489 | |
| 6490 | private function f_tc_lu_imsi_auth3g_tmsi_check_imei_early(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6491 | pars.net.expect_auth := true; |
| 6492 | pars.use_umts_aka := true; |
| 6493 | pars.net.expect_imei_early := true; |
| 6494 | f_init_handler(pars); |
| 6495 | f_perform_lu(); |
| 6496 | } |
| 6497 | testcase TC_lu_imsi_auth3g_tmsi_check_imei_early() runs on MTC_CT { |
| 6498 | var BSC_ConnHdlr vc_conn; |
| 6499 | f_init(); |
| 6500 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6501 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6502 | |
| 6503 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth3g_tmsi_check_imei_early), 5); |
| 6504 | vc_conn.done; |
| 6505 | } |
| 6506 | |
| 6507 | private function f_tc_lu_imsi_noauth_tmsi_check_imei_early(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6508 | pars.net.expect_imei_early := true; |
| 6509 | f_init_handler(pars); |
| 6510 | f_perform_lu(); |
| 6511 | } |
| 6512 | testcase TC_lu_imsi_noauth_tmsi_check_imei_early() runs on MTC_CT { |
| 6513 | var BSC_ConnHdlr vc_conn; |
| 6514 | f_init(); |
| 6515 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6516 | |
| 6517 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_tmsi_check_imei_early), 5); |
| 6518 | vc_conn.done; |
| 6519 | } |
| 6520 | |
| 6521 | private function f_tc_lu_imsi_noauth_notmsi_check_imei_early(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6522 | pars.net.expect_tmsi := false; |
| 6523 | pars.net.expect_imei_early := true; |
| 6524 | f_init_handler(pars); |
| 6525 | f_perform_lu(); |
| 6526 | } |
| 6527 | testcase TC_lu_imsi_noauth_notmsi_check_imei_early() runs on MTC_CT { |
| 6528 | var BSC_ConnHdlr vc_conn; |
| 6529 | f_init(); |
| 6530 | f_vty_config(MSCVTY, "msc", "no assign-tmsi"); |
| 6531 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6532 | |
| 6533 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_notmsi_check_imei_early), 5); |
| 6534 | vc_conn.done; |
| 6535 | } |
| 6536 | |
| 6537 | private function f_tc_lu_imsi_auth_tmsi_check_imei_early_nack(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6538 | var PDU_ML3_MS_NW l3_lu; |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6539 | |
| 6540 | pars.net.expect_auth := true; |
| 6541 | pars.net.expect_imei_early := true; |
| 6542 | pars.net.check_imei_result := OSMO_GSUP_IMEI_RESULT_NACK; |
| 6543 | f_init_handler(pars); |
| 6544 | |
| 6545 | /* Cannot use f_perform_lu() as we expect a reject */ |
| 6546 | l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 6547 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6548 | f_bssap_compl_l3(l3_lu); |
| 6549 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 6550 | |
| 6551 | f_mm_imei_early(); |
Oliver Smith | 91bfa1c | 2019-07-19 15:01:15 +0200 | [diff] [blame] | 6552 | f_expect_lu_reject(); |
Eric Wild | 85cc161 | 2022-03-30 01:44:29 +0200 | [diff] [blame] | 6553 | f_expect_clear(verify_vlr_cell_id:=false); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6554 | } |
| 6555 | testcase TC_lu_imsi_auth_tmsi_check_imei_early_nack() runs on MTC_CT { |
| 6556 | var BSC_ConnHdlr vc_conn; |
| 6557 | f_init(); |
| 6558 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6559 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6560 | |
| 6561 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_early_nack), 5); |
| 6562 | vc_conn.done; |
| 6563 | } |
| 6564 | |
| 6565 | private function f_tc_lu_imsi_auth_tmsi_check_imei_early_err(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6566 | var PDU_ML3_MS_NW l3_lu; |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6567 | |
| 6568 | pars.net.expect_auth := true; |
| 6569 | pars.net.expect_imei_early := true; |
| 6570 | pars.net.check_imei_error := true; |
| 6571 | f_init_handler(pars); |
| 6572 | |
| 6573 | /* Cannot use f_perform_lu() as we expect a reject */ |
| 6574 | l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 6575 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6576 | f_bssap_compl_l3(l3_lu); |
| 6577 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 6578 | |
| 6579 | f_mm_imei_early(); |
Oliver Smith | 91bfa1c | 2019-07-19 15:01:15 +0200 | [diff] [blame] | 6580 | f_expect_lu_reject(); |
Eric Wild | 85cc161 | 2022-03-30 01:44:29 +0200 | [diff] [blame] | 6581 | f_expect_clear(verify_vlr_cell_id:=false); |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 6582 | } |
| 6583 | testcase TC_lu_imsi_auth_tmsi_check_imei_early_err() runs on MTC_CT { |
| 6584 | var BSC_ConnHdlr vc_conn; |
| 6585 | f_init(); |
| 6586 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6587 | f_vty_config(MSCVTY, "msc", "check-imei-rqd early"); |
| 6588 | |
| 6589 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_check_imei_early_err), 5); |
| 6590 | vc_conn.done; |
| 6591 | } |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 6592 | |
Neels Hofmeyr | 8df6962 | 2019-11-02 19:16:03 +0100 | [diff] [blame] | 6593 | friend function f_tc_invalid_mgcp_crash(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6594 | f_init_handler(pars); |
| 6595 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 6596 | |
| 6597 | /* Set invalid IP address so that osmo-msc discards the rtp_stream and MGCP endpoint FSM instances in the middle |
| 6598 | * of successful MGCP response dispatch. If things aren't safeguarded, the on_success() in osmo_mgcpc_ep_fsm |
| 6599 | * will cause a use-after-free after that event dispatch. */ |
| 6600 | cpars.mgw_conn_1.mgw_rtp_ip := "0.0.0.0"; |
| 6601 | cpars.mgw_conn_2.mgw_rtp_ip := "0.0.0.0"; |
| 6602 | cpars.rtp_sdp_format := "FOO/8000"; |
| 6603 | cpars.expect_release := true; |
| 6604 | |
| 6605 | f_perform_lu(); |
| 6606 | f_mo_call_establish(cpars); |
| 6607 | } |
| 6608 | testcase TC_invalid_mgcp_crash() runs on MTC_CT { |
| 6609 | var BSC_ConnHdlr vc_conn; |
| 6610 | f_init(); |
| 6611 | |
| 6612 | vc_conn := f_start_handler(refers(f_tc_invalid_mgcp_crash), 7); |
| 6613 | vc_conn.done; |
| 6614 | } |
| 6615 | |
Vadim Yanitskiy | eddebaa | 2019-12-28 17:45:34 +0100 | [diff] [blame] | 6616 | friend function f_tc_mm_id_resp_no_identity(charstring id, BSC_ConnHdlrPars pars) |
| 6617 | runs on BSC_ConnHdlr { |
| 6618 | pars.tmsi := 'FFFFFFFF'O; |
| 6619 | f_init_handler(pars); |
| 6620 | |
| 6621 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6622 | |
| 6623 | /* Initiate Location Updating using an unknown TMSI */ |
| 6624 | f_bssap_compl_l3(f_build_lu_tmsi(pars.tmsi)); |
| 6625 | |
| 6626 | /* Expect an Identity Request, send response with no identity */ |
| 6627 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req(CM_ID_TYPE_IMSI))); |
| 6628 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp({ |
| 6629 | lengthIndicator := 1, |
| 6630 | mobileIdentityV := { |
| 6631 | typeOfIdentity := '000'B, |
| 6632 | oddEvenInd_identity := { |
| 6633 | no_identity := { |
| 6634 | oddevenIndicator := '0'B, |
| 6635 | fillerDigits := '00000'H |
| 6636 | } |
| 6637 | } |
| 6638 | } |
| 6639 | }))); |
| 6640 | |
| 6641 | f_expect_lu_reject(); |
| 6642 | f_expect_clear(); |
| 6643 | } |
| 6644 | testcase TC_mm_id_resp_no_identity() runs on MTC_CT { |
| 6645 | var BSC_ConnHdlr vc_conn; |
| 6646 | |
| 6647 | f_init(); |
| 6648 | |
Neels Hofmeyr | 4e18ccc | 2020-06-24 19:08:17 +0200 | [diff] [blame] | 6649 | 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] | 6650 | vc_conn.done; |
| 6651 | } |
| 6652 | |
Vadim Yanitskiy | 2521906 | 2020-01-21 01:41:33 +0700 | [diff] [blame] | 6653 | /* Verify the case when T3212 expires during Paging procedure, just before the receipt |
| 6654 | * of Paging Response. This used to provoke a NULL-pointer dereference in old versions |
| 6655 | * of OsmoMSC, but apparently the bug has been fixed, and we're safe now. */ |
| 6656 | friend function f_tc_lu_and_expire_while_paging(charstring id, BSC_ConnHdlrPars pars) |
| 6657 | runs on BSC_ConnHdlr { |
| 6658 | var charstring imsi := hex2str(pars.imsi); |
| 6659 | |
| 6660 | f_init_handler(pars); |
| 6661 | |
| 6662 | /* Perform location update */ |
| 6663 | f_perform_lu(); |
| 6664 | |
| 6665 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
| 6666 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 6667 | |
| 6668 | /* Initiate paging procedure from the VTY */ |
| 6669 | f_vty_transceive(MSCVTY, "subscriber imsi " & imsi & " paging"); |
| 6670 | f_expect_paging(); |
| 6671 | |
| 6672 | /* Emulate T3212 expiration during paging (we don't want to wait, right?) */ |
| 6673 | f_vty_transceive(MSCVTY, "subscriber imsi " & imsi & " expire"); |
| 6674 | |
| 6675 | /* MS sends PAGING RESPONSE, *old* OsmoMSC crashes here... */ |
| 6676 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 6677 | |
| 6678 | /* The recent OsmoMSC keeps subscriber in its VLR unless the Paging is completed. |
| 6679 | * 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] | 6680 | f_expect_clear(verify_vlr_cell_id := false); |
Vadim Yanitskiy | 2521906 | 2020-01-21 01:41:33 +0700 | [diff] [blame] | 6681 | } |
| 6682 | testcase TC_lu_and_expire_while_paging() runs on MTC_CT { |
| 6683 | var BSC_ConnHdlr vc_conn; |
| 6684 | |
| 6685 | f_init(); |
| 6686 | |
| 6687 | vc_conn := f_start_handler(refers(f_tc_lu_and_expire_while_paging), 7); |
| 6688 | vc_conn.done; |
| 6689 | } |
| 6690 | |
Neels Hofmeyr | 3ad76a4 | 2022-08-09 02:57:49 +0200 | [diff] [blame] | 6691 | private altstep as_mncc_rx_rtp_create(CallParameters cpars) runs on BSC_ConnHdlr { |
| 6692 | [] MNCC.receive(tr_MNCC_RTP_CREATE(cpars.mncc_callref)); |
| 6693 | } |
| 6694 | |
Neels Hofmeyr | 4f099b4 | 2021-07-27 03:45:26 +0200 | [diff] [blame] | 6695 | const charstring REEST_LOST_CONNECTION := "REEST_LOST_CONNECTION"; |
| 6696 | const charstring REEST_CLEARED := "REEST_CLEARED"; |
| 6697 | |
| 6698 | friend function f_tc_call_re_establishment_1(charstring id, BSC_ConnHdlrPars pars) |
| 6699 | runs on BSC_ConnHdlr { |
| 6700 | f_init_handler(pars, t_guard := 30.0); |
| 6701 | |
| 6702 | f_perform_lu(); |
| 6703 | |
| 6704 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 6705 | f_mo_call_establish(cpars); |
| 6706 | f_sleep(3.0); |
| 6707 | COORD.send(REEST_LOST_CONNECTION); |
| 6708 | COORD.send(cpars); |
| 6709 | f_expect_clear(verify_vlr_cell_id := false); |
| 6710 | COORD.send(REEST_CLEARED); |
| 6711 | } |
| 6712 | |
| 6713 | friend function f_tc_call_re_establishment_2(charstring id, BSC_ConnHdlrPars pars) |
| 6714 | runs on BSC_ConnHdlr { |
| 6715 | f_init_handler(pars, t_guard := 30.0); |
| 6716 | var CallParameters cpars; |
| 6717 | |
| 6718 | COORD.receive(REEST_LOST_CONNECTION); |
| 6719 | COORD.receive(tr_CallParams) -> value cpars; |
| 6720 | |
| 6721 | f_gsup_change_connhdlr(hex2str(g_pars.imsi)); |
| 6722 | f_create_smpp_expect(hex2str(pars.msisdn)); |
| 6723 | |
| 6724 | /* The MS has lost the first channel and decides to show up on a new conn (on a nearby neighbor cell) to ask for |
| 6725 | * CM Re-Establishment. Send a Complete Layer 3 to osmo-msc with a CM Re-Establishment Request. */ |
| 6726 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 6727 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_REESTABL_REQ(mi)); |
| 6728 | f_cl3_or_initial_ue(l3_info); |
| 6729 | |
| 6730 | /* At this point the other test component should receive the Clear Command for the first A connection. */ |
| 6731 | |
| 6732 | /* This new connection continues with Authentication... */ |
| 6733 | f_mm_common(); |
| 6734 | |
| 6735 | /* ...and with Assignment of a voice channel. */ |
| 6736 | var template BSSMAP_IE_AoIP_TransportLayerAddress tla_ass := |
Neels Hofmeyr | 02d513e | 2022-07-25 22:07:24 +0200 | [diff] [blame] | 6737 | (f_tr_BSSMAP_IE_AoIP_TLA(cpars.mgw_conn_1.mgw_rtp_ip, ?), |
| 6738 | f_tr_BSSMAP_IE_AoIP_TLA(cpars.mgw_conn_2.mgw_rtp_ip, ?)); |
Neels Hofmeyr | 4f099b4 | 2021-07-27 03:45:26 +0200 | [diff] [blame] | 6739 | BSSAP.receive(tr_BSSMAP_AssignmentReq(omit, tla_ass)); |
| 6740 | /* By this Assignment Request, the CM Re-Establishment Request is implicitly accepted. */ |
| 6741 | |
| 6742 | /* Send Assignment Complete from BSC */ |
| 6743 | var template BSSMAP_IE_AoIP_TransportLayerAddress tla; |
| 6744 | tla := f_ts_BSSMAP_IE_AoIP_TLA(cpars.bss_rtp_ip, cpars.bss_rtp_port); |
| 6745 | var BSSMAP_IE_SpeechCodec codec; |
| 6746 | codec := valueof(ts_BSSMAP_IE_SpeechCodec({ts_CodecFR})); |
| 6747 | |
| 6748 | /* Make really sure the other component is done with its MGCP */ |
| 6749 | COORD.receive(REEST_CLEARED); |
| 6750 | |
| 6751 | /* Transfer state for this call over to this test component so we can resolve MNCC and MGCP in this function. */ |
| 6752 | f_mncc_change_connhdlr(cpars.mncc_callref); |
| 6753 | f_mgcp_change_connhdlr(cpars.mgcp_ep); |
| 6754 | |
| 6755 | /* osmo-msc may redirect the MGW endpoint to the newly allocated channel. |
| 6756 | * Apparently osmo-msc currently also sends an MDCX to the CN side, just repeating the same configuration that |
| 6757 | * is already in use. This test accepts any number of or even lack of MDCX. */ |
| 6758 | var default ack_mdcx := activate(as_mgcp_ack_all_mdcx(cpars)); |
Neels Hofmeyr | 3ad76a4 | 2022-08-09 02:57:49 +0200 | [diff] [blame] | 6759 | var default optional_rtp_create := activate(as_mncc_rx_rtp_create(cpars)); |
Neels Hofmeyr | 4f099b4 | 2021-07-27 03:45:26 +0200 | [diff] [blame] | 6760 | |
| 6761 | BSSAP.send(ts_BSSMAP_AssignmentComplete(omit, tla, codec)); |
Neels Hofmeyr | 3ad76a4 | 2022-08-09 02:57:49 +0200 | [diff] [blame] | 6762 | |
Neels Hofmeyr | 4f099b4 | 2021-07-27 03:45:26 +0200 | [diff] [blame] | 6763 | /* The call has been fully re-established. |
| 6764 | * Let a bit of time pass before hanging up, for everything to settle. */ |
| 6765 | f_sleep(3.0); |
| 6766 | |
Neels Hofmeyr | 3ad76a4 | 2022-08-09 02:57:49 +0200 | [diff] [blame] | 6767 | deactivate(optional_rtp_create); |
Neels Hofmeyr | 4f099b4 | 2021-07-27 03:45:26 +0200 | [diff] [blame] | 6768 | deactivate(ack_mdcx); |
| 6769 | |
| 6770 | /* Hang up the call and clear the new, second A connection */ |
| 6771 | var default ack_dlcx := activate(as_mgcp_ack_all_dlcx(cpars)); |
| 6772 | |
| 6773 | /* CC release. This is the proper MS initiated release sequence as shown by |
| 6774 | * https://git.osmocom.org/osmo-msc/tree/doc/sequence_charts/voice_call_full.msc?id=e53ecde83e4fb2470209e818e9ad76a2d6a19190 |
| 6775 | * f_call_hangup() seems a bit mixed up, so here a "proper" sequence. Fix of f_call_hangup() pending. */ |
| 6776 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_DISC(cpars.transaction_id, '0'B, '0000000'B))); |
| 6777 | MNCC.receive(tr_MNCC_DISC_ind(cpars.mncc_callref)); |
| 6778 | MNCC.send(ts_MNCC_REL_req(cpars.mncc_callref, valueof(ts_MNCC_cause(23)))); |
| 6779 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))); |
| 6780 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_REL_COMPL(cpars.transaction_id, '0'B))); |
| 6781 | MNCC.receive(tr_MNCC_REL_cnf(cpars.mncc_callref, cause := *)); |
| 6782 | |
| 6783 | /* BSSAP clear */ |
| 6784 | interleave { |
| 6785 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 6786 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 6787 | } |
| 6788 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND); |
| 6789 | } |
| 6790 | |
| 6791 | f_sleep(1.0); |
| 6792 | deactivate(ack_dlcx); |
| 6793 | } |
| 6794 | |
| 6795 | testcase TC_call_re_establishment() runs on MTC_CT { |
| 6796 | var BSC_ConnHdlr vc_conn1; |
| 6797 | var BSC_ConnHdlr vc_conn2; |
| 6798 | f_init(); |
| 6799 | |
| 6800 | var BSC_ConnHdlrPars pars1 := f_init_pars(91); |
| 6801 | var BSC_ConnHdlrPars pars2 := pars1; |
| 6802 | |
| 6803 | vc_conn1 := f_start_handler_create(pars1); |
| 6804 | vc_conn2 := f_start_handler_create(pars2); |
| 6805 | connect(vc_conn1:COORD, vc_conn2:COORD); |
| 6806 | f_start_handler_run(vc_conn1, refers(f_tc_call_re_establishment_1), pars1); |
| 6807 | f_start_handler_run(vc_conn2, refers(f_tc_call_re_establishment_2), pars2); |
| 6808 | vc_conn1.done; |
| 6809 | vc_conn2.done; |
| 6810 | } |
| 6811 | |
Neels Hofmeyr | a9b2dcf | 2021-07-28 00:57:58 +0200 | [diff] [blame] | 6812 | testcase TC_call_re_establishment_auth() runs on MTC_CT { |
| 6813 | var BSC_ConnHdlr vc_conn1; |
| 6814 | var BSC_ConnHdlr vc_conn2; |
| 6815 | f_init(); |
| 6816 | |
| 6817 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6818 | |
| 6819 | var BSC_ConnHdlrPars pars1 := f_init_pars(92); |
| 6820 | pars1.net.expect_auth := true; |
| 6821 | var BSC_ConnHdlrPars pars2 := pars1; |
| 6822 | |
| 6823 | vc_conn1 := f_start_handler_create(pars1); |
| 6824 | vc_conn2 := f_start_handler_create(pars2); |
| 6825 | connect(vc_conn1:COORD, vc_conn2:COORD); |
| 6826 | f_start_handler_run(vc_conn1, refers(f_tc_call_re_establishment_1), pars1); |
| 6827 | f_start_handler_run(vc_conn2, refers(f_tc_call_re_establishment_2), pars2); |
| 6828 | vc_conn1.done; |
| 6829 | vc_conn2.done; |
| 6830 | } |
| 6831 | |
Neels Hofmeyr | 48e4d7d | 2021-07-28 00:57:58 +0200 | [diff] [blame] | 6832 | testcase TC_call_re_establishment_ciph() runs on MTC_CT { |
| 6833 | var BSC_ConnHdlr vc_conn1; |
| 6834 | var BSC_ConnHdlr vc_conn2; |
| 6835 | f_init(); |
| 6836 | |
| 6837 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 6838 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 6839 | |
| 6840 | var BSC_ConnHdlrPars pars1 := f_init_pars(92); |
| 6841 | pars1.net.expect_auth := true; |
| 6842 | pars1.net.expect_ciph := true; |
| 6843 | pars1.net.kc_support := '08'O; /* A5/3 only */ |
| 6844 | var BSC_ConnHdlrPars pars2 := pars1; |
| 6845 | |
| 6846 | vc_conn1 := f_start_handler_create(pars1); |
| 6847 | vc_conn2 := f_start_handler_create(pars2); |
| 6848 | connect(vc_conn1:COORD, vc_conn2:COORD); |
| 6849 | f_start_handler_run(vc_conn1, refers(f_tc_call_re_establishment_1), pars1); |
| 6850 | f_start_handler_run(vc_conn2, refers(f_tc_call_re_establishment_2), pars2); |
| 6851 | vc_conn1.done; |
| 6852 | vc_conn2.done; |
| 6853 | } |
| 6854 | |
Neels Hofmeyr | 07ea7f2 | 2022-05-05 01:39:26 +0200 | [diff] [blame] | 6855 | /* Establish a conn with a valid Mobile Identity. Then send a CM Service Request containing a mismatching Mobile |
| 6856 | * Identity on the same conn. Caused a crash, see OS#5532. */ |
| 6857 | friend function f_tc_cm_serv_wrong_mi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 6858 | f_init_handler(pars); |
| 6859 | |
| 6860 | /* Set up a fully identified conn */ |
| 6861 | f_perform_lu(); |
| 6862 | f_establish_fully(); |
| 6863 | |
| 6864 | /* CM Serv Req with mismatching Mobile Identity */ |
| 6865 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(99999))); /* ensure it is different from below*/ |
| 6866 | BSSAP.send(ts_PDU_DTAP_MO(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, mi))); |
| 6867 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)); |
| 6868 | |
| 6869 | /* Cancel the first CM Service from f_establish_fully() */ |
| 6870 | BSSAP.send(ts_BSSMAP_ClearRequest(0)); |
| 6871 | |
| 6872 | f_expect_clear(); |
| 6873 | } |
| 6874 | testcase TC_cm_serv_wrong_mi() runs on MTC_CT { |
| 6875 | var BSC_ConnHdlr vc_conn; |
| 6876 | f_init(); |
| 6877 | vc_conn := f_start_handler(refers(f_tc_cm_serv_wrong_mi), 94); |
| 6878 | vc_conn.done; |
| 6879 | } |
| 6880 | |
Neels Hofmeyr | e860fc4 | 2022-10-05 01:15:54 +0200 | [diff] [blame] | 6881 | /* a5 0 a5 0 a5 0 3 a5 0 3 a5 3 a5 3 |
| 6882 | * HLR has auth info no yes no yes no yes |
| 6883 | * |
| 6884 | * test case index [0] [1] [2] [3] [4] [5] |
| 6885 | * authentication optional No auth No auth attempt auth, auth reject auth |
| 6886 | * (%) fall back to +ciph +ciph |
| 6887 | * no-auth |
| 6888 | * |
| 6889 | * [6] [7] [8] [9] [10] [11] |
| 6890 | * authentication mandatory reject auth reject auth reject auth |
| 6891 | * only +ciph +ciph |
| 6892 | * |
| 6893 | * (%): Arguably, when HLR has auth info, the MSC should use it. Current behavior of osmo-msc is to not attempt auth at |
| 6894 | * all. Related: OS#4830. |
| 6895 | */ |
| 6896 | type record of BSC_ConnHdlrNetworkPars rof_netpars; |
| 6897 | |
| 6898 | const rof_netpars auth_options_testcases := { |
| 6899 | { |
| 6900 | /* [0] auth optional, encr a5 0: no-auth" */ |
| 6901 | kc_support := '01'O, |
| 6902 | net_config := { "authentication optional", |
| 6903 | "encryption a5 0" }, |
| 6904 | expect_attach_success := true, |
| 6905 | expect_tmsi := true, |
| 6906 | expect_auth_attempt := false, |
| 6907 | hlr_has_auth_info := false, |
| 6908 | expect_auth := false, |
| 6909 | expect_ciph := false, |
| 6910 | expect_imei := false, |
| 6911 | expect_imei_early := false, |
| 6912 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 6913 | check_imei_error := false |
| 6914 | }, |
| 6915 | { |
| 6916 | /* [1] auth optional, encr a5 0, HLR HAS auth info: no-auth */ |
| 6917 | kc_support := '01'O, |
| 6918 | net_config := { "authentication optional", |
| 6919 | "encryption a5 0" }, |
| 6920 | expect_attach_success := true, |
| 6921 | expect_tmsi := true, |
| 6922 | expect_auth_attempt := false, |
| 6923 | hlr_has_auth_info := true, |
| 6924 | expect_auth := false, |
| 6925 | expect_ciph := false, |
| 6926 | expect_imei := false, |
| 6927 | expect_imei_early := false, |
| 6928 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 6929 | check_imei_error := false |
| 6930 | }, |
| 6931 | { |
| 6932 | /* [2] auth optional, encr a5 0 3, HLR has NO Auth Info: Fall back to no-auth" */ |
| 6933 | kc_support := '09'O, |
| 6934 | net_config := { "authentication optional", |
| 6935 | "encryption a5 0 3" }, |
| 6936 | expect_attach_success := true, |
| 6937 | expect_tmsi := true, |
| 6938 | expect_auth_attempt := true, |
| 6939 | hlr_has_auth_info := false, |
| 6940 | expect_auth := false, |
| 6941 | expect_ciph := false, |
| 6942 | expect_imei := false, |
| 6943 | expect_imei_early := false, |
| 6944 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 6945 | check_imei_error := false |
| 6946 | }, |
| 6947 | { |
| 6948 | /* [3] auth optional, encr a5 0 3, HLR HAS Auth Info: Use A5/3 */ |
| 6949 | kc_support := '09'O, |
| 6950 | net_config := { "authentication optional", |
| 6951 | "encryption a5 0 3" }, |
| 6952 | expect_attach_success := true, |
| 6953 | expect_tmsi := true, |
| 6954 | expect_auth_attempt := true, |
| 6955 | hlr_has_auth_info := true, |
| 6956 | expect_auth := true, |
| 6957 | expect_ciph := true, |
| 6958 | expect_imei := false, |
| 6959 | expect_imei_early := false, |
| 6960 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 6961 | check_imei_error := false |
| 6962 | }, |
| 6963 | { |
| 6964 | /* [4] auth optional, encr a5 3, HLR has NO Auth Info: reject. |
| 6965 | * Auth is required implicitly because ciph is required. */ |
| 6966 | kc_support := '08'O, |
| 6967 | net_config := { "authentication optional", |
| 6968 | "encryption a5 3" }, |
| 6969 | expect_attach_success := false, |
| 6970 | expect_tmsi := true, |
| 6971 | expect_auth_attempt := true, |
| 6972 | hlr_has_auth_info := false, |
| 6973 | expect_auth := false, |
| 6974 | expect_ciph := false, |
| 6975 | expect_imei := false, |
| 6976 | expect_imei_early := false, |
| 6977 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 6978 | check_imei_error := false |
| 6979 | }, |
| 6980 | { |
| 6981 | /* [5] auth optional, encr a5 3, HLR HAS Auth Info: auth + ciph. |
| 6982 | * Auth is required implicitly because ciph is required. */ |
| 6983 | kc_support := '08'O, |
| 6984 | net_config := { "authentication optional", |
| 6985 | "encryption a5 3" }, |
| 6986 | expect_attach_success := true, |
| 6987 | expect_tmsi := true, |
| 6988 | expect_auth_attempt := true, |
| 6989 | hlr_has_auth_info := true, |
| 6990 | expect_auth := true, |
| 6991 | expect_ciph := true, |
| 6992 | expect_imei := false, |
| 6993 | expect_imei_early := false, |
| 6994 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 6995 | check_imei_error := false |
| 6996 | }, |
| 6997 | |
| 6998 | /* Same as above, but with 'authentication required' */ |
| 6999 | |
| 7000 | { |
| 7001 | /* [6] auth required, encr a5 0, HLR has NO auth info: reject */ |
| 7002 | kc_support := '01'O, |
| 7003 | net_config := { "authentication required", |
| 7004 | "encryption a5 0" }, |
| 7005 | expect_attach_success := false, |
| 7006 | expect_tmsi := true, |
| 7007 | expect_auth_attempt := true, |
| 7008 | hlr_has_auth_info := false, |
| 7009 | expect_auth := false, |
| 7010 | expect_ciph := false, |
| 7011 | expect_imei := false, |
| 7012 | expect_imei_early := false, |
| 7013 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 7014 | check_imei_error := false |
| 7015 | }, |
| 7016 | { |
| 7017 | /* [7] auth required, encr a5 0, HLR HAS auth info: do auth, no ciph" */ |
| 7018 | kc_support := '01'O, |
| 7019 | net_config := { "authentication required", |
| 7020 | "encryption a5 0" }, |
| 7021 | expect_attach_success := true, |
| 7022 | expect_tmsi := true, |
| 7023 | expect_auth_attempt := true, |
| 7024 | hlr_has_auth_info := true, |
| 7025 | expect_auth := true, |
| 7026 | expect_ciph := false, |
| 7027 | expect_imei := false, |
| 7028 | expect_imei_early := false, |
| 7029 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 7030 | check_imei_error := false |
| 7031 | }, |
| 7032 | { |
| 7033 | /* [8] auth required, encr a5 0 3, HLR has NO Auth Info: reject */ |
| 7034 | kc_support := '09'O, |
| 7035 | net_config := { "authentication required", |
| 7036 | "encryption a5 0 3" }, |
| 7037 | expect_attach_success := false, |
| 7038 | expect_tmsi := true, |
| 7039 | expect_auth_attempt := true, |
| 7040 | hlr_has_auth_info := false, |
| 7041 | expect_auth := false, |
| 7042 | expect_ciph := false, |
| 7043 | expect_imei := false, |
| 7044 | expect_imei_early := false, |
| 7045 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 7046 | check_imei_error := false |
| 7047 | }, |
| 7048 | { |
| 7049 | /* [9] auth required, encr a5 0 3, HLR HAS Auth Info: Use A5/3 */ |
| 7050 | kc_support := '09'O, |
| 7051 | net_config := { "authentication required", |
| 7052 | "encryption a5 0 3" }, |
| 7053 | expect_attach_success := true, |
| 7054 | expect_tmsi := true, |
| 7055 | expect_auth_attempt := true, |
| 7056 | hlr_has_auth_info := true, |
| 7057 | expect_auth := true, |
| 7058 | expect_ciph := true, |
| 7059 | expect_imei := false, |
| 7060 | expect_imei_early := false, |
| 7061 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 7062 | check_imei_error := false |
| 7063 | }, |
| 7064 | { |
| 7065 | /* [10] auth required, encr a5 3, HLR has NO Auth Info: reject. */ |
| 7066 | kc_support := '08'O, |
| 7067 | net_config := { "authentication required", |
| 7068 | "encryption a5 3" }, |
| 7069 | expect_attach_success := false, |
| 7070 | expect_tmsi := true, |
| 7071 | expect_auth_attempt := true, |
| 7072 | hlr_has_auth_info := false, |
| 7073 | expect_auth := false, |
| 7074 | expect_ciph := false, |
| 7075 | expect_imei := false, |
| 7076 | expect_imei_early := false, |
| 7077 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 7078 | check_imei_error := false |
| 7079 | }, |
| 7080 | { |
| 7081 | /* [11] auth required, encr a5 3, HLR HAS Auth Info: auth + ciph. */ |
| 7082 | kc_support := '08'O, |
| 7083 | net_config := { "authentication required", |
| 7084 | "encryption a5 3" }, |
| 7085 | expect_attach_success := true, |
| 7086 | expect_tmsi := true, |
| 7087 | expect_auth_attempt := true, |
| 7088 | hlr_has_auth_info := true, |
| 7089 | expect_auth := true, |
| 7090 | expect_ciph := true, |
| 7091 | expect_imei := false, |
| 7092 | expect_imei_early := false, |
| 7093 | check_imei_result := OSMO_GSUP_IMEI_RESULT_ACK, |
| 7094 | check_imei_error := false |
| 7095 | } |
| 7096 | }; |
| 7097 | |
| 7098 | private function f_tc_auth_options(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 7099 | f_init_handler(pars); |
| 7100 | |
| 7101 | /* Location Updating */ |
| 7102 | log(MSCVTY, "f_perform_lu() starting"); |
| 7103 | f_perform_lu(); |
| 7104 | log(MSCVTY, "f_perform_lu() done"); |
| 7105 | |
| 7106 | f_sleep(1.0); |
| 7107 | |
| 7108 | if (not pars.net.expect_attach_success) { |
| 7109 | /* Expected above LU to fail. In order to test CM Service Request below, a LU has to succeed first. So |
| 7110 | * run another LU that will be successful. Careful not to load auth tokens into the VLR that may taint |
| 7111 | * the test for CM Service Request below. */ |
| 7112 | |
| 7113 | log(MSCVTY, "Running a successful LU so that CM Service Request can be tested"); |
| 7114 | var BSC_ConnHdlrNetworkPars saved_net := g_pars.net; |
| 7115 | g_pars.net.kc_support := '01'O; |
| 7116 | g_pars.net.expect_attach_success := true; |
| 7117 | g_pars.net.expect_auth_attempt := false; |
| 7118 | g_pars.net.expect_auth := false; |
| 7119 | g_pars.net.expect_ciph := false; |
| 7120 | f_vty_config3(MSCVTY, {"network"}, {"authentication optional", "encryption a5 0"}); |
| 7121 | f_perform_lu(); |
| 7122 | |
| 7123 | /* Reconfigure like it was before */ |
| 7124 | g_pars.net := saved_net; |
| 7125 | f_vty_config3(MSCVTY, {"network"}, g_pars.net.net_config); |
| 7126 | log(MSCVTY, "Running a successful LU done"); |
| 7127 | } |
| 7128 | |
| 7129 | /* CM Service Request */ |
| 7130 | log(MSCVTY, "f_establish_fully() starting"); |
| 7131 | f_establish_fully(); |
| 7132 | log(MSCVTY, "f_establish_fully() done"); |
| 7133 | BSSAP.send(ts_BSSMAP_ClearRequest(0)); |
| 7134 | f_expect_clear(); |
| 7135 | } |
| 7136 | |
| 7137 | function f_TC_auth_options(integer tc_i) runs on MTC_CT { |
| 7138 | f_init(); |
| 7139 | |
| 7140 | var BSC_ConnHdlrNetworkPars tc := auth_options_testcases[tc_i]; |
| 7141 | |
| 7142 | f_vty_config3(MSCVTY, {"network"}, tc.net_config); |
| 7143 | |
| 7144 | var BSC_ConnHdlrPars pars := f_init_pars(42300 + tc_i); |
| 7145 | pars.net := tc; |
| 7146 | |
| 7147 | var BSC_ConnHdlr vc_conn; |
| 7148 | vc_conn := f_start_handler_with_pars(refers(f_tc_auth_options), pars); |
| 7149 | vc_conn.done; |
| 7150 | } |
| 7151 | |
| 7152 | testcase TC_auth_options_0() runs on MTC_CT { |
| 7153 | f_TC_auth_options(0); |
| 7154 | } |
| 7155 | |
| 7156 | testcase TC_auth_options_1() runs on MTC_CT { |
| 7157 | f_TC_auth_options(1); |
| 7158 | } |
| 7159 | |
| 7160 | testcase TC_auth_options_2() runs on MTC_CT { |
| 7161 | f_TC_auth_options(2); |
| 7162 | } |
| 7163 | |
| 7164 | testcase TC_auth_options_3() runs on MTC_CT { |
| 7165 | f_TC_auth_options(3); |
| 7166 | } |
| 7167 | |
| 7168 | testcase TC_auth_options_4() runs on MTC_CT { |
| 7169 | f_TC_auth_options(4); |
| 7170 | } |
| 7171 | |
| 7172 | testcase TC_auth_options_5() runs on MTC_CT { |
| 7173 | f_TC_auth_options(5); |
| 7174 | } |
| 7175 | |
| 7176 | testcase TC_auth_options_6() runs on MTC_CT { |
| 7177 | f_TC_auth_options(6); |
| 7178 | } |
| 7179 | |
| 7180 | testcase TC_auth_options_7() runs on MTC_CT { |
| 7181 | f_TC_auth_options(7); |
| 7182 | } |
| 7183 | |
| 7184 | testcase TC_auth_options_8() runs on MTC_CT { |
| 7185 | f_TC_auth_options(8); |
| 7186 | } |
| 7187 | |
| 7188 | testcase TC_auth_options_9() runs on MTC_CT { |
| 7189 | f_TC_auth_options(9); |
| 7190 | } |
| 7191 | |
| 7192 | testcase TC_auth_options_10() runs on MTC_CT { |
| 7193 | f_TC_auth_options(10); |
| 7194 | } |
| 7195 | |
| 7196 | testcase TC_auth_options_11() runs on MTC_CT { |
| 7197 | f_TC_auth_options(11); |
| 7198 | } |
| 7199 | |
Oliver Smith | c4a0c3c | 2023-08-23 15:40:12 +0200 | [diff] [blame] | 7200 | private function f_set_cpars_csd(inout CallParameters cpars, charstring bs_name, BIT1 async, |
| 7201 | GSM48_bcap_transp transp, GSM48_bcap_user_rate user_rate) { |
Oliver Smith | 9c417f2 | 2023-07-07 13:25:11 +0200 | [diff] [blame] | 7202 | log("-----------------------------------------------"); |
Oliver Smith | c4a0c3c | 2023-08-23 15:40:12 +0200 | [diff] [blame] | 7203 | log("CSD Bearer Service: " & bs_name); |
Oliver Smith | 9c417f2 | 2023-07-07 13:25:11 +0200 | [diff] [blame] | 7204 | log("-----------------------------------------------"); |
Oliver Smith | 9c417f2 | 2023-07-07 13:25:11 +0200 | [diff] [blame] | 7205 | |
Oliver Smith | 92b280c | 2023-04-20 13:13:23 +0200 | [diff] [blame] | 7206 | cpars.csd := true; |
Oliver Smith | c4a0c3c | 2023-08-23 15:40:12 +0200 | [diff] [blame] | 7207 | |
Oliver Smith | 9c417f2 | 2023-07-07 13:25:11 +0200 | [diff] [blame] | 7208 | cpars.bearer_cap := valueof(ts_Bcap_csd); |
| 7209 | cpars.bearer_cap.octet6.synchronous_asynchronous := async; |
| 7210 | cpars.bearer_cap.octet6.connectionElement := int2bit(enum2int(transp), 2); |
| 7211 | cpars.bearer_cap.octet6.userRate := int2bit(enum2int(user_rate), 4); |
| 7212 | |
Oliver Smith | c4a0c3c | 2023-08-23 15:40:12 +0200 | [diff] [blame] | 7213 | cpars.mncc_bearer_cap := valueof(ts_MNCC_bcap_data); |
| 7214 | cpars.mncc_bearer_cap.data.async := bit2int(async); |
| 7215 | cpars.mncc_bearer_cap.data.transp := transp; |
| 7216 | cpars.mncc_bearer_cap.data.user_rate := user_rate; |
| 7217 | } |
| 7218 | |
| 7219 | friend function f_mo_csd(charstring bs_name, BIT1 async, GSM48_bcap_transp transp, GSM48_bcap_user_rate user_rate) |
| 7220 | runs on BSC_ConnHdlr { |
| 7221 | var CallParameters cpars := valueof(t_CallParams); |
| 7222 | |
| 7223 | g_Tguard.start(20.0); |
| 7224 | f_set_cpars_csd(cpars, bs_name, async, transp, user_rate); |
Oliver Smith | 92b280c | 2023-04-20 13:13:23 +0200 | [diff] [blame] | 7225 | f_perform_lu(); |
Oliver Smith | 98e24bc | 2023-07-07 12:36:59 +0200 | [diff] [blame] | 7226 | f_mo_call(cpars, 0.5); |
Oliver Smith | 92b280c | 2023-04-20 13:13:23 +0200 | [diff] [blame] | 7227 | } |
Oliver Smith | 9c417f2 | 2023-07-07 13:25:11 +0200 | [diff] [blame] | 7228 | |
| 7229 | friend function f_tc_lu_and_mo_csd(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 7230 | f_init_handler(pars); |
| 7231 | |
| 7232 | f_mo_csd("BS21T", '1'B, GSM48_BCAP_TR_TRANSP, GSM48_BCAP_UR_300); |
| 7233 | f_mo_csd("BS22T", '1'B, GSM48_BCAP_TR_TRANSP, GSM48_BCAP_UR_1200); |
| 7234 | f_mo_csd("BS24T", '1'B, GSM48_BCAP_TR_TRANSP, GSM48_BCAP_UR_2400); |
| 7235 | f_mo_csd("BS25T", '1'B, GSM48_BCAP_TR_TRANSP, GSM48_BCAP_UR_4800); |
| 7236 | f_mo_csd("BS26T", '1'B, GSM48_BCAP_TR_TRANSP, GSM48_BCAP_UR_9600); |
| 7237 | |
| 7238 | f_mo_csd("BS21NT", '1'B, GSM48_BCAP_TR_RLP, GSM48_BCAP_UR_300); |
| 7239 | f_mo_csd("BS22NT", '1'B, GSM48_BCAP_TR_RLP, GSM48_BCAP_UR_1200); |
| 7240 | f_mo_csd("BS24NT", '1'B, GSM48_BCAP_TR_RLP, GSM48_BCAP_UR_2400); |
| 7241 | f_mo_csd("BS25NT", '1'B, GSM48_BCAP_TR_RLP, GSM48_BCAP_UR_4800); |
| 7242 | f_mo_csd("BS26NT", '1'B, GSM48_BCAP_TR_RLP, GSM48_BCAP_UR_9600); |
| 7243 | |
| 7244 | f_mo_csd("BS31T", '0'B, GSM48_BCAP_TR_TRANSP, GSM48_BCAP_UR_1200); |
| 7245 | f_mo_csd("BS32T", '0'B, GSM48_BCAP_TR_TRANSP, GSM48_BCAP_UR_2400); |
| 7246 | f_mo_csd("BS33T", '0'B, GSM48_BCAP_TR_TRANSP, GSM48_BCAP_UR_4800); |
| 7247 | f_mo_csd("BS34T", '0'B, GSM48_BCAP_TR_TRANSP, GSM48_BCAP_UR_9600); |
| 7248 | } |
Oliver Smith | 92b280c | 2023-04-20 13:13:23 +0200 | [diff] [blame] | 7249 | testcase TC_lu_and_mo_csd() runs on MTC_CT { |
| 7250 | var BSC_ConnHdlr vc_conn; |
| 7251 | f_init(); |
| 7252 | |
| 7253 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_csd), 7); |
| 7254 | vc_conn.done; |
| 7255 | } |
| 7256 | |
Oliver Smith | 8cf75ab | 2023-06-21 16:19:51 +0200 | [diff] [blame] | 7257 | friend function f_mt_csd(charstring bs_name, BIT1 async, GSM48_bcap_transp transp, GSM48_bcap_user_rate user_rate) |
| 7258 | runs on BSC_ConnHdlr { |
Oliver Smith | c1dd36a | 2023-05-31 13:52:24 +0200 | [diff] [blame] | 7259 | var CallParameters cpars := valueof(t_CallParams); |
Oliver Smith | 8cf75ab | 2023-06-21 16:19:51 +0200 | [diff] [blame] | 7260 | |
Oliver Smith | c4a0c3c | 2023-08-23 15:40:12 +0200 | [diff] [blame] | 7261 | g_Tguard.start(20.0); |
| 7262 | f_set_cpars_csd(cpars, bs_name, async, transp, user_rate); |
Oliver Smith | c1dd36a | 2023-05-31 13:52:24 +0200 | [diff] [blame] | 7263 | f_perform_lu(); |
Oliver Smith | 98e24bc | 2023-07-07 12:36:59 +0200 | [diff] [blame] | 7264 | f_mt_call(cpars, 0.5); |
Oliver Smith | c1dd36a | 2023-05-31 13:52:24 +0200 | [diff] [blame] | 7265 | } |
Oliver Smith | 8cf75ab | 2023-06-21 16:19:51 +0200 | [diff] [blame] | 7266 | friend function f_tc_lu_and_mt_csd(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 7267 | f_init_handler(pars); |
| 7268 | |
| 7269 | f_mt_csd("BS21T", '1'B, GSM48_BCAP_TR_TRANSP, GSM48_BCAP_UR_300); |
| 7270 | f_mt_csd("BS22T", '1'B, GSM48_BCAP_TR_TRANSP, GSM48_BCAP_UR_1200); |
| 7271 | f_mt_csd("BS24T", '1'B, GSM48_BCAP_TR_TRANSP, GSM48_BCAP_UR_2400); |
| 7272 | f_mt_csd("BS25T", '1'B, GSM48_BCAP_TR_TRANSP, GSM48_BCAP_UR_4800); |
| 7273 | f_mt_csd("BS26T", '1'B, GSM48_BCAP_TR_TRANSP, GSM48_BCAP_UR_9600); |
| 7274 | |
| 7275 | f_mt_csd("BS21NT", '1'B, GSM48_BCAP_TR_RLP, GSM48_BCAP_UR_300); |
| 7276 | f_mt_csd("BS22NT", '1'B, GSM48_BCAP_TR_RLP, GSM48_BCAP_UR_1200); |
| 7277 | f_mt_csd("BS24NT", '1'B, GSM48_BCAP_TR_RLP, GSM48_BCAP_UR_2400); |
| 7278 | f_mt_csd("BS25NT", '1'B, GSM48_BCAP_TR_RLP, GSM48_BCAP_UR_4800); |
| 7279 | f_mt_csd("BS26NT", '1'B, GSM48_BCAP_TR_RLP, GSM48_BCAP_UR_9600); |
| 7280 | |
| 7281 | f_mt_csd("BS31T", '0'B, GSM48_BCAP_TR_TRANSP, GSM48_BCAP_UR_1200); |
| 7282 | f_mt_csd("BS32T", '0'B, GSM48_BCAP_TR_TRANSP, GSM48_BCAP_UR_2400); |
| 7283 | f_mt_csd("BS33T", '0'B, GSM48_BCAP_TR_TRANSP, GSM48_BCAP_UR_4800); |
| 7284 | f_mt_csd("BS34T", '0'B, GSM48_BCAP_TR_TRANSP, GSM48_BCAP_UR_9600); |
| 7285 | } |
Oliver Smith | c1dd36a | 2023-05-31 13:52:24 +0200 | [diff] [blame] | 7286 | testcase TC_lu_and_mt_csd() runs on MTC_CT { |
| 7287 | var BSC_ConnHdlr vc_conn; |
| 7288 | f_init(); |
| 7289 | |
| 7290 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_csd), 7); |
| 7291 | vc_conn.done; |
| 7292 | } |
| 7293 | |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 7294 | control { |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 7295 | execute( TC_cr_before_reset() ); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 7296 | execute( TC_lu_imsi_noauth_tmsi() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 7297 | execute( TC_lu_imsi_noauth_notmsi() ); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 7298 | execute( TC_lu_imsi_reject() ); |
| 7299 | execute( TC_lu_imsi_timeout_gsup() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 7300 | execute( TC_lu_imsi_auth_tmsi() ); |
Harald Welte | 8a397ae | 2019-04-21 22:03:37 +0200 | [diff] [blame] | 7301 | execute( TC_lu_imsi_auth3g_tmsi() ); |
Pau Espin Pedrol | d3d54a9 | 2019-12-17 17:02:54 +0100 | [diff] [blame] | 7302 | execute( TC_lu_imsi_timeout_tmsi_realloc() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 7303 | execute( TC_cmserv_imsi_unknown() ); |
Neels Hofmeyr | 13737fb | 2020-08-19 13:16:14 +0000 | [diff] [blame] | 7304 | execute( TC_cmserv_tmsi_unknown() ); |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 7305 | execute( TC_lu_and_mo_call() ); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 7306 | execute( TC_lu_and_mo_call_ipv6() ); |
Pau Espin Pedrol | a42745c | 2020-01-10 18:03:28 +0100 | [diff] [blame] | 7307 | execute( TC_lu_and_mo_call_sccp_tiar_timeout() ); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 7308 | execute( TC_lu_auth_sai_timeout() ); |
| 7309 | execute( TC_lu_auth_sai_err() ); |
Harald Welte | e1a2f3c | 2018-01-24 17:28:48 +0100 | [diff] [blame] | 7310 | execute( TC_lu_clear_request() ); |
Vadim Yanitskiy | 109e755 | 2021-02-05 05:36:02 +0100 | [diff] [blame] | 7311 | execute( TC_mo_call_clear_request() ); |
| 7312 | execute( TC_mt_call_clear_request() ); |
Harald Welte | e1a2f3c | 2018-01-24 17:28:48 +0100 | [diff] [blame] | 7313 | execute( TC_lu_disconnect() ); |
| 7314 | execute( TC_lu_by_imei() ); |
| 7315 | execute( TC_lu_by_tmsi_noauth_unknown() ); |
Neels Hofmeyr | fc06c73 | 2020-08-19 12:52:28 +0000 | [diff] [blame] | 7316 | execute( TC_attached_imsi_lu_unknown_tmsi() ); |
Harald Welte | e1a2f3c | 2018-01-24 17:28:48 +0100 | [diff] [blame] | 7317 | execute( TC_imsi_detach_by_imsi() ); |
| 7318 | execute( TC_imsi_detach_by_tmsi() ); |
| 7319 | execute( TC_imsi_detach_by_imei() ); |
| 7320 | execute( TC_emerg_call_imei_reject() ); |
| 7321 | execute( TC_emerg_call_imsi() ); |
| 7322 | execute( TC_cm_serv_req_vgcs_reject() ); |
| 7323 | execute( TC_cm_serv_req_vbs_reject() ); |
| 7324 | execute( TC_cm_serv_req_lcs_reject() ); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 7325 | execute( TC_cm_reest_req_reject() ); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 7326 | execute( TC_lu_auth_2G_fail() ); |
| 7327 | execute( TC_lu_imsi_auth_tmsi_encr_13_13() ); |
| 7328 | execute( TC_cl3_no_payload() ); |
| 7329 | execute( TC_cl3_rnd_payload() ); |
Harald Welte | 1852a84 | 2018-01-26 22:53:36 +0100 | [diff] [blame] | 7330 | execute( TC_establish_and_nothing() ); |
| 7331 | execute( TC_mo_setup_and_nothing() ); |
| 7332 | execute( TC_mo_crcx_ran_timeout() ); |
| 7333 | execute( TC_mo_crcx_ran_reject() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 7334 | execute( TC_mt_crcx_ran_reject() ); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 7335 | execute( TC_mo_setup_and_dtmf_dup() ); |
Vadim Yanitskiy | b56701e | 2021-02-05 01:54:07 +0100 | [diff] [blame] | 7336 | execute( TC_mt_t310() ); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 7337 | execute( TC_gsup_cancel() ); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 7338 | execute( TC_lu_imsi_auth_tmsi_encr_1_13() ); |
| 7339 | execute( TC_lu_imsi_auth_tmsi_encr_3_13() ); |
| 7340 | execute( TC_lu_imsi_auth_tmsi_encr_3_1() ); |
Neels Hofmeyr | 29b8da0 | 2018-03-01 18:09:45 +0100 | [diff] [blame] | 7341 | execute( TC_lu_imsi_auth_tmsi_encr_3_1_no_cm() ); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 7342 | execute( TC_lu_imsi_auth_tmsi_encr_13_2() ); |
| 7343 | execute( TC_lu_imsi_auth_tmsi_encr_013_2() ); |
Eric Wild | 26f4a62 | 2021-05-17 15:27:05 +0200 | [diff] [blame] | 7344 | execute( TC_lu_imsi_auth_tmsi_encr_0134_1() ); |
| 7345 | execute( TC_lu_imsi_auth_tmsi_encr_0134_34() ); |
| 7346 | execute( TC_lu_imsi_auth_tmsi_encr_0134_34_no_cm3() ); |
| 7347 | |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 7348 | execute( TC_mo_release_timeout() ); |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 7349 | execute( TC_lu_and_mt_call_no_dlcx_resp() ); |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 7350 | execute( TC_reset_two() ); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 7351 | |
| 7352 | execute( TC_lu_and_mt_call() ); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 7353 | execute( TC_lu_and_mt_call_ipv6() ); |
Neels Hofmeyr | b58d974 | 2019-11-27 18:44:54 +0100 | [diff] [blame] | 7354 | execute( TC_lu_and_mt_call_already_paging() ); |
Pau Espin Pedrol | 9a732a4 | 2020-09-15 15:56:33 +0200 | [diff] [blame] | 7355 | execute( TC_lu_and_mt_call_osmux() ); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 7356 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 7357 | execute( TC_lu_and_mo_sms() ); |
| 7358 | execute( TC_lu_and_mt_sms() ); |
Neels Hofmeyr | b58d974 | 2019-11-27 18:44:54 +0100 | [diff] [blame] | 7359 | execute( TC_lu_and_mt_sms_already_paging() ); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 7360 | execute( TC_lu_and_mt_sms_paging_and_nothing() ); |
Alexander Couzens | fc02f24 | 2019-09-12 03:43:18 +0200 | [diff] [blame] | 7361 | execute( TC_lu_and_mt_sms_paging_repeated() ); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 7362 | execute( TC_smpp_mo_sms() ); |
Vadim Yanitskiy | 3382076 | 2020-01-15 11:26:07 +0700 | [diff] [blame] | 7363 | execute( TC_smpp_mo_sms_rp_error() ); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 7364 | execute( TC_smpp_mt_sms() ); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 7365 | |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 7366 | execute( TC_gsup_mo_sms() ); |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 7367 | execute( TC_gsup_mo_smma() ); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 7368 | execute( TC_gsup_mt_sms_ack() ); |
| 7369 | execute( TC_gsup_mt_sms_err() ); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 7370 | execute( TC_gsup_mt_sms_rp_mr() ); |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 7371 | execute( TC_gsup_mo_mt_sms_rp_mr() ); |
Vadim Yanitskiy | a2a8a11 | 2019-07-08 20:04:32 +0700 | [diff] [blame] | 7372 | execute( TC_gsup_mt_multi_part_sms() ); |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 7373 | |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 7374 | execute( TC_lu_and_mo_ussd_single_request() ); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 7375 | execute( TC_lu_and_mt_ussd_notification() ); |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 7376 | execute( TC_lu_and_mo_ussd_during_mt_call() ); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 7377 | execute( TC_lu_and_mt_ussd_during_mt_call() ); |
Vadim Yanitskiy | 2daf52d | 2018-06-21 04:19:58 +0700 | [diff] [blame] | 7378 | execute( TC_lu_and_mo_ussd_mo_release() ); |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 7379 | execute( TC_lu_and_ss_session_timeout() ); |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 7380 | |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 7381 | execute( TC_mt_ussd_for_unknown_subscr() ); |
Vadim Yanitskiy | c3c07d4 | 2019-06-17 23:00:44 +0700 | [diff] [blame] | 7382 | execute( TC_mo_ussd_for_unknown_trans() ); |
Vadim Yanitskiy | d612d28 | 2019-06-15 14:46:03 +0700 | [diff] [blame] | 7383 | execute( TC_proc_ss_for_unknown_session() ); |
Vadim Yanitskiy | e5f4ed9 | 2019-06-16 02:36:33 +0700 | [diff] [blame] | 7384 | execute( TC_proc_ss_paging_fail() ); |
Vadim Yanitskiy | 29ba8d6 | 2019-06-16 15:19:41 +0700 | [diff] [blame] | 7385 | execute( TC_proc_ss_abort() ); |
Vadim Yanitskiy | 0e6c9f5 | 2019-06-15 01:01:28 +0700 | [diff] [blame] | 7386 | |
Vadim Yanitskiy | 1c9754d | 2020-01-07 21:56:55 +0100 | [diff] [blame] | 7387 | execute( TC_multi_lu_and_mo_ussd() ); |
| 7388 | execute( TC_multi_lu_and_mt_ussd() ); |
| 7389 | |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 7390 | execute( TC_cipher_complete_with_invalid_cipher() ); |
Stefan Sperling | a2d59c6 | 2018-12-18 16:32:44 +0100 | [diff] [blame] | 7391 | execute( TC_cipher_complete_1_without_cipher() ); |
| 7392 | execute( TC_cipher_complete_3_without_cipher() ); |
| 7393 | execute( TC_cipher_complete_13_without_cipher() ); |
Harald Welte | b2284bd | 2019-05-10 11:30:43 +0200 | [diff] [blame] | 7394 | execute( TC_lu_with_invalid_mcc_mnc() ); |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 7395 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 7396 | execute( TC_sgsap_reset() ); |
| 7397 | execute( TC_sgsap_lu() ); |
| 7398 | execute( TC_sgsap_lu_imsi_reject() ); |
| 7399 | execute( TC_sgsap_lu_and_nothing() ); |
| 7400 | execute( TC_sgsap_expl_imsi_det_eps() ); |
Philipp Maier | fc19f17 | 2019-03-21 11:17:54 +0100 | [diff] [blame] | 7401 | execute( TC_sgsap_impl_imsi_det_eps() ); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 7402 | execute( TC_sgsap_expl_imsi_det_noneps() ); |
Philipp Maier | 5d81270 | 2019-03-21 10:51:26 +0100 | [diff] [blame] | 7403 | execute( TC_sgsap_impl_imsi_det_noneps() ); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 7404 | execute( TC_sgsap_paging_rej() ); |
| 7405 | execute( TC_sgsap_paging_subscr_rej() ); |
| 7406 | execute( TC_sgsap_paging_ue_unr() ); |
| 7407 | execute( TC_sgsap_paging_and_nothing() ); |
| 7408 | execute( TC_sgsap_paging_and_lu() ); |
| 7409 | execute( TC_sgsap_mt_sms() ); |
| 7410 | execute( TC_sgsap_mo_sms() ); |
| 7411 | execute( TC_sgsap_mt_sms_and_nothing() ); |
| 7412 | execute( TC_sgsap_mt_sms_and_reject() ); |
| 7413 | execute( TC_sgsap_unexp_ud() ); |
| 7414 | execute( TC_sgsap_unsol_ud() ); |
| 7415 | execute( TC_bssap_lu_sgsap_lu_and_mt_call() ); |
| 7416 | execute( TC_sgsap_lu_and_mt_call() ); |
Philipp Maier | 628c005 | 2019-04-09 17:36:57 +0200 | [diff] [blame] | 7417 | execute( TC_sgsap_vlr_failure() ); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 7418 | |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 7419 | execute( TC_ho_inter_bsc_unknown_cell() ); |
| 7420 | execute( TC_ho_inter_bsc() ); |
Neels Hofmeyr | 0d841d9 | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 7421 | execute( TC_ho_inter_bsc_a5_1() ); |
| 7422 | execute( TC_ho_inter_bsc_a5_3() ); |
| 7423 | execute( TC_ho_inter_bsc_a5_4() ); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 7424 | execute( TC_ho_inter_bsc_ipv6() ); |
Oliver Smith | 44424db | 2023-08-22 13:54:09 +0200 | [diff] [blame] | 7425 | execute( TC_ho_inter_bsc_csd() ); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 7426 | |
| 7427 | execute( TC_ho_inter_msc_out() ); |
Neels Hofmeyr | 666d39a | 2021-06-21 22:27:21 +0200 | [diff] [blame] | 7428 | execute( TC_ho_inter_msc_out_a5_1() ); |
| 7429 | execute( TC_ho_inter_msc_out_a5_3() ); |
| 7430 | execute( TC_ho_inter_msc_out_a5_4() ); |
Pau Espin Pedrol | 833174e | 2020-09-03 16:46:02 +0200 | [diff] [blame] | 7431 | execute( TC_ho_inter_msc_out_ipv6() ); |
Oliver Smith | caa36c9 | 2023-08-23 15:30:33 +0200 | [diff] [blame] | 7432 | execute( TC_ho_inter_msc_out_csd() ); |
Neels Hofmeyr | 0ac6315 | 2019-05-07 01:20:17 +0200 | [diff] [blame] | 7433 | |
Oliver Smith | 1d118ff | 2019-07-03 10:57:35 +0200 | [diff] [blame] | 7434 | execute( TC_lu_imsi_auth_tmsi_check_imei() ); |
| 7435 | execute( TC_lu_imsi_auth3g_tmsi_check_imei() ); |
| 7436 | execute( TC_lu_imsi_noauth_tmsi_check_imei() ); |
| 7437 | execute( TC_lu_imsi_noauth_notmsi_check_imei() ); |
| 7438 | execute( TC_lu_imsi_auth_tmsi_check_imei_nack() ); |
| 7439 | execute( TC_lu_imsi_auth_tmsi_check_imei_err() ); |
| 7440 | execute( TC_lu_imsi_auth_tmsi_check_imei_early() ); |
| 7441 | execute( TC_lu_imsi_auth3g_tmsi_check_imei_early() ); |
| 7442 | execute( TC_lu_imsi_noauth_tmsi_check_imei_early() ); |
| 7443 | execute( TC_lu_imsi_noauth_notmsi_check_imei_early() ); |
| 7444 | execute( TC_lu_imsi_auth_tmsi_check_imei_early_nack() ); |
| 7445 | execute( TC_lu_imsi_auth_tmsi_check_imei_early_err() ); |
Neels Hofmeyr | 1b3c6e3 | 2018-03-01 17:52:21 +0100 | [diff] [blame] | 7446 | 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] | 7447 | |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 7448 | execute( TC_mo_cc_bssmap_clear() ); |
Neels Hofmeyr | 8df6962 | 2019-11-02 19:16:03 +0100 | [diff] [blame] | 7449 | execute( TC_invalid_mgcp_crash() ); |
Vadim Yanitskiy | eddebaa | 2019-12-28 17:45:34 +0100 | [diff] [blame] | 7450 | execute( TC_mm_id_resp_no_identity() ); |
Vadim Yanitskiy | 2521906 | 2020-01-21 01:41:33 +0700 | [diff] [blame] | 7451 | execute( TC_lu_and_expire_while_paging() ); |
Pau Espin Pedrol | 174fac2 | 2021-02-26 13:20:10 +0100 | [diff] [blame] | 7452 | execute( TC_paging_response_imsi_unknown() ); |
| 7453 | execute( TC_paging_response_tmsi_unknown() ); |
Neels Hofmeyr | 4f099b4 | 2021-07-27 03:45:26 +0200 | [diff] [blame] | 7454 | |
| 7455 | execute( TC_call_re_establishment() ); |
Neels Hofmeyr | a9b2dcf | 2021-07-28 00:57:58 +0200 | [diff] [blame] | 7456 | execute( TC_call_re_establishment_auth() ); |
Neels Hofmeyr | 48e4d7d | 2021-07-28 00:57:58 +0200 | [diff] [blame] | 7457 | execute( TC_call_re_establishment_ciph() ); |
Neels Hofmeyr | 07ea7f2 | 2022-05-05 01:39:26 +0200 | [diff] [blame] | 7458 | |
| 7459 | execute( TC_cm_serv_wrong_mi() ); |
Neels Hofmeyr | e860fc4 | 2022-10-05 01:15:54 +0200 | [diff] [blame] | 7460 | |
| 7461 | execute( TC_auth_options_0() ); |
| 7462 | execute( TC_auth_options_1() ); |
| 7463 | execute( TC_auth_options_2() ); |
| 7464 | execute( TC_auth_options_3() ); |
| 7465 | execute( TC_auth_options_4() ); |
| 7466 | execute( TC_auth_options_5() ); |
| 7467 | execute( TC_auth_options_6() ); |
| 7468 | execute( TC_auth_options_7() ); |
| 7469 | execute( TC_auth_options_8() ); |
| 7470 | execute( TC_auth_options_9() ); |
| 7471 | execute( TC_auth_options_10() ); |
| 7472 | execute( TC_auth_options_11() ); |
Oliver Smith | 92b280c | 2023-04-20 13:13:23 +0200 | [diff] [blame] | 7473 | |
| 7474 | execute( TC_lu_and_mo_csd() ); |
Oliver Smith | c1dd36a | 2023-05-31 13:52:24 +0200 | [diff] [blame] | 7475 | execute( TC_lu_and_mt_csd() ); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 7476 | } |
| 7477 | |
| 7478 | |
| 7479 | } |