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