Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 1 | module MSC_Tests { |
| 2 | |
| 3 | import from General_Types all; |
| 4 | import from Osmocom_Types all; |
| 5 | |
| 6 | import from M3UA_Types all; |
| 7 | import from M3UA_Emulation all; |
| 8 | |
| 9 | import from MTP3asp_Types all; |
| 10 | import from MTP3asp_PortType all; |
| 11 | |
| 12 | import from SCCPasp_Types all; |
| 13 | import from SCCP_Types all; |
| 14 | import from SCCP_Emulation all; |
| 15 | |
| 16 | import from SCTPasp_Types all; |
| 17 | import from SCTPasp_PortType all; |
| 18 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 19 | import from Osmocom_CTRL_Functions all; |
| 20 | import from Osmocom_CTRL_Types all; |
| 21 | import from Osmocom_CTRL_Adapter all; |
| 22 | |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 23 | import from TELNETasp_PortType all; |
| 24 | import from Osmocom_VTY_Functions all; |
| 25 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 26 | import from MNCC_Emulation all; |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 27 | import from MNCC_Types all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 28 | |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 29 | import from MGCP_Emulation all; |
| 30 | import from MGCP_Types all; |
| 31 | import from MGCP_Templates all; |
| 32 | import from SDP_Types all; |
| 33 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 34 | import from GSUP_Emulation all; |
| 35 | import from GSUP_Types all; |
| 36 | import from IPA_Emulation all; |
| 37 | |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 38 | import from BSSAP_Types all; |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 39 | import from RAN_Adapter all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 40 | import from BSSAP_CodecPort all; |
| 41 | import from BSSMAP_Templates all; |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 42 | import from RAN_Emulation all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 43 | import from BSC_ConnectionHandler all; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 44 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 45 | import from SGsAP_Templates all; |
| 46 | import from SGsAP_Types all; |
| 47 | import from SGsAP_Emulation all; |
| 48 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 49 | import from MobileL3_Types all; |
| 50 | import from MobileL3_CommonIE_Types all; |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 51 | import from MobileL3_SMS_Types all; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 52 | import from L3_Templates all; |
Harald Welte | 158a7ca | 2018-02-16 18:11:31 +0100 | [diff] [blame] | 53 | import from L3_Common all; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 54 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 55 | import from SMPP_Types all; |
| 56 | import from SMPP_Templates all; |
| 57 | import from SMPP_Emulation all; |
| 58 | |
Stefan Sperling | c307e68 | 2018-06-14 15:15:46 +0200 | [diff] [blame] | 59 | import from SCCP_Templates all; |
| 60 | |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 61 | import from SS_Types all; |
| 62 | import from SS_Templates all; |
| 63 | import from USSD_Helpers all; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 64 | import from DNS_Helpers all; |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 65 | |
Philipp Maier | 948747b | 2019-04-02 15:22:33 +0200 | [diff] [blame] | 66 | import from TCCConversion_Functions all; |
| 67 | |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 68 | const integer NUM_BSC := 2; |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 69 | type record of RAN_Configuration RAN_Configurations; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 70 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 71 | /* Needed for SGsAP SMS */ |
| 72 | import from MobileL3_SMS_Types all; |
| 73 | |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 74 | type component MTC_CT extends CTRL_Adapter_CT { |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 75 | var boolean g_initialized := false; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 76 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 77 | var RAN_Adapter g_bssap[NUM_BSC]; |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 78 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 79 | /* no 'adapter_CT' for MNCC or GSUP */ |
| 80 | var MNCC_Emulation_CT vc_MNCC; |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 81 | var MGCP_Emulation_CT vc_MGCP; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 82 | var GSUP_Emulation_CT vc_GSUP; |
| 83 | var IPA_Emulation_CT vc_GSUP_IPA; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 84 | var SMPP_Emulation_CT vc_SMPP; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 85 | var SGsAP_Emulation_CT vc_SGsAP; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 86 | |
| 87 | /* only to get events from IPA underneath GSUP */ |
| 88 | port IPA_CTRL_PT GSUP_IPA_EVENT; |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 89 | /* VTY to MSC */ |
| 90 | port TELNETasp_PT MSCVTY; |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 91 | |
| 92 | /* A port to directly send BSSAP messages. This port is used for |
| 93 | * tests that require low level access to sen arbitrary BSSAP |
| 94 | * messages. Run f_init_bssap_direct() to connect and initialize */ |
| 95 | port BSSAP_CODEC_PT BSSAP_DIRECT; |
| 96 | |
| 97 | /* When BSSAP messages are directly sent, then the connection |
| 98 | * handler is not active, which means that also no guard timer is |
| 99 | * set up. The following timer will serve as a replacement */ |
| 100 | timer Tguard_direct := 60.0; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | modulepar { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 104 | /* remote parameters of IUT */ |
| 105 | charstring mp_msc_ip := "127.0.0.1"; |
| 106 | integer mp_msc_ctrl_port := 4255; |
| 107 | integer mp_msc_vty_port := 4254; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 108 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 109 | /* local parameters of emulated HLR */ |
Philipp Maier | 9b690e4 | 2018-12-21 11:50:03 +0100 | [diff] [blame] | 110 | boolean mp_mm_info := false; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 111 | charstring mp_hlr_ip := "127.0.0.1"; |
| 112 | integer mp_hlr_port := 4222; |
Harald Welte | 6126fb0 | 2018-01-27 20:08:24 +0100 | [diff] [blame] | 113 | charstring mp_mgw_ip := "127.0.0.1"; |
| 114 | integer mp_mgw_port := 2427; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 115 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 116 | charstring mp_msc_mncc := "/tmp/mncc"; |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 117 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 118 | integer mp_msc_smpp_port := 2775; |
| 119 | charstring mp_smpp_system_id := "msc_tester"; |
| 120 | charstring mp_smpp_password := "osmocom1"; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 121 | charstring mp_mme_name := "mmec01.mmegi0001.mme.epc.mnc070.mcc901.3gppnetwork.org"; |
| 122 | charstring mp_vlr_name := "vlr.example.net"; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 123 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 124 | RAN_Configurations mp_bssap_cfg := { |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 125 | { |
| 126 | sccp_service_type := "mtp3_itu", |
| 127 | sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" }, |
| 128 | own_pc := 185, |
| 129 | own_ssn := 254, |
| 130 | peer_pc := 187, |
| 131 | peer_ssn := 254, |
| 132 | sio := '83'O, |
| 133 | rctx := 0 |
| 134 | }, |
| 135 | { |
| 136 | sccp_service_type := "mtp3_itu", |
| 137 | sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" }, |
| 138 | own_pc := 186, |
| 139 | own_ssn := 254, |
| 140 | peer_pc := 187, |
| 141 | peer_ssn := 254, |
| 142 | sio := '83'O, |
| 143 | rctx := 1 |
| 144 | } |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 145 | }; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 146 | } |
| 147 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 148 | /* altstep for the global guard timer (only used when BSSAP_DIRECT |
| 149 | * is used for communication */ |
| 150 | private altstep as_Tguard_direct() runs on MTC_CT { |
| 151 | [] Tguard_direct.timeout { |
| 152 | setverdict(fail, "Tguard timeout"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 153 | mtc.stop; |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 154 | } |
| 155 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 156 | |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 157 | private altstep as_optional_cc_rel(CallParameters cpars) runs on BSC_ConnHdlr { |
| 158 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))) { repeat; }; |
| 159 | } |
| 160 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 161 | function f_init_smpp(charstring id) runs on MTC_CT { |
| 162 | id := id & "-SMPP"; |
| 163 | var EsmePars pars := { |
| 164 | mode := MODE_TRANSCEIVER, |
| 165 | bind := { |
| 166 | system_id := mp_smpp_system_id, |
| 167 | password := mp_smpp_password, |
| 168 | system_type := "MSC_Tests", |
| 169 | interface_version := hex2int('34'H), |
| 170 | addr_ton := unknown, |
| 171 | addr_npi := unknown, |
| 172 | address_range := "" |
| 173 | }, |
| 174 | esme_role := true |
| 175 | } |
| 176 | |
| 177 | vc_SMPP := SMPP_Emulation_CT.create(id); |
| 178 | map(vc_SMPP:SMPP_PORT, system:SMPP_PORT); |
| 179 | vc_SMPP.start(SMPP_Emulation.main_client(pars, mp_msc_ip, mp_msc_smpp_port, "", -1)); |
| 180 | } |
| 181 | |
| 182 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 183 | function f_init_mncc(charstring id) runs on MTC_CT { |
| 184 | id := id & "-MNCC"; |
| 185 | var MnccOps ops := { |
| 186 | create_cb := refers(MNCC_Emulation.ExpectedCreateCallback), |
| 187 | unitdata_cb := refers(MNCC_Emulation.DummyUnitdataCallback) |
| 188 | } |
| 189 | |
| 190 | vc_MNCC := MNCC_Emulation_CT.create(id); |
| 191 | map(vc_MNCC:MNCC, system:MNCC_CODEC_PT); |
| 192 | vc_MNCC.start(MNCC_Emulation.main(ops, id, mp_msc_mncc)); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 193 | } |
| 194 | |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 195 | function f_init_mgcp(charstring id) runs on MTC_CT { |
| 196 | id := id & "-MGCP"; |
| 197 | var MGCPOps ops := { |
| 198 | create_cb := refers(MGCP_Emulation.ExpectedCreateCallback), |
| 199 | unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback) |
| 200 | } |
| 201 | var MGCP_conn_parameters pars := { |
Harald Welte | 6126fb0 | 2018-01-27 20:08:24 +0100 | [diff] [blame] | 202 | callagent_ip := mp_msc_ip, |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 203 | callagent_udp_port := -1, |
Harald Welte | 6126fb0 | 2018-01-27 20:08:24 +0100 | [diff] [blame] | 204 | mgw_ip := mp_mgw_ip, |
| 205 | mgw_udp_port := mp_mgw_port |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | vc_MGCP := MGCP_Emulation_CT.create(id); |
| 209 | map(vc_MGCP:MGCP, system:MGCP_CODEC_PT); |
| 210 | vc_MGCP.start(MGCP_Emulation.main(ops, pars, id)); |
| 211 | } |
| 212 | |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 213 | function ForwardUnitdataCallback(PDU_SGsAP msg) |
| 214 | runs on SGsAP_Emulation_CT return template PDU_SGsAP { |
| 215 | SGsAP_CLIENT.send(msg); |
| 216 | return omit; |
| 217 | } |
| 218 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 219 | function f_init_sgsap(charstring id) runs on MTC_CT { |
| 220 | id := id & "-SGsAP"; |
| 221 | var SGsAPOps ops := { |
| 222 | create_cb := refers(SGsAP_Emulation.ExpectedCreateCallback), |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 223 | unitdata_cb := refers(ForwardUnitdataCallback) |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 224 | } |
| 225 | var SGsAP_conn_parameters pars := { |
| 226 | remote_ip := mp_msc_ip, |
| 227 | remote_sctp_port := 29118, |
| 228 | local_ip := "", |
| 229 | local_sctp_port := -1 |
| 230 | } |
| 231 | |
| 232 | vc_SGsAP := SGsAP_Emulation_CT.create(id); |
| 233 | map(vc_SGsAP:SGsAP, system:SGsAP_CODEC_PT); |
| 234 | vc_SGsAP.start(SGsAP_Emulation.main(ops, pars, id)); |
| 235 | } |
| 236 | |
| 237 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 238 | function f_init_gsup(charstring id) runs on MTC_CT { |
| 239 | id := id & "-GSUP"; |
| 240 | var GsupOps ops := { |
| 241 | create_cb := refers(GSUP_Emulation.ExpectedCreateCallback) |
| 242 | } |
| 243 | |
| 244 | vc_GSUP_IPA := IPA_Emulation_CT.create(id & "-IPA"); |
| 245 | vc_GSUP := GSUP_Emulation_CT.create(id); |
| 246 | |
| 247 | map(vc_GSUP_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 248 | connect(vc_GSUP:GSUP, vc_GSUP_IPA:IPA_GSUP_PORT); |
| 249 | /* we use this hack to get events like ASP_IPA_EVENT_UP */ |
| 250 | connect(vc_GSUP_IPA:IPA_CTRL_PORT, self:GSUP_IPA_EVENT); |
| 251 | |
| 252 | vc_GSUP.start(GSUP_Emulation.main(ops, id)); |
| 253 | vc_GSUP_IPA.start(IPA_Emulation.main_server(mp_hlr_ip, mp_hlr_port)); |
| 254 | |
| 255 | /* wait for incoming connection to GSUP port before proceeding */ |
| 256 | timer T := 10.0; |
| 257 | T.start; |
| 258 | alt { |
| 259 | [] GSUP_IPA_EVENT.receive(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_UP)) { } |
| 260 | [] T.timeout { |
Harald Welte | 458fd37 | 2018-03-21 11:26:23 +0100 | [diff] [blame] | 261 | setverdict(fail, "No connection to GSUP Port"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 262 | mtc.stop |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 263 | } |
| 264 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 265 | } |
| 266 | |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 267 | function f_init(integer num_bsc := 1, boolean sgsap := false, boolean gsup := true) runs on MTC_CT { |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 268 | |
| 269 | if (g_initialized == true) { |
| 270 | return; |
| 271 | } |
| 272 | g_initialized := true; |
| 273 | |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 274 | if (num_bsc > NUM_BSC) { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 275 | testcase.stop("excess number of BSC instances requested"); |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | for (var integer i := 0; i < num_bsc; i := i + 1) { |
| 279 | if (isbound(mp_bssap_cfg[i])) { |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 280 | f_bssap_init(g_bssap[i], mp_bssap_cfg[i], "MSC_Test_" & int2str(i), BSC_RanOps); |
Harald Welte | d5833a8 | 2018-05-27 16:52:56 +0200 | [diff] [blame] | 281 | f_bssap_start(g_bssap[i]); |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 282 | } else { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 283 | testcase.stop("missing BSSAP configuration"); |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 284 | } |
| 285 | } |
| 286 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 287 | f_ipa_ctrl_start(mp_msc_ip, mp_msc_ctrl_port); |
| 288 | f_init_mncc("MSC_Test"); |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 289 | f_init_mgcp("MSC_Test"); |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 290 | |
| 291 | if (gsup == true) { |
| 292 | f_init_gsup("MSC_Test"); |
| 293 | } |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 294 | f_init_smpp("MSC_Test"); |
Philipp Maier | 5786548 | 2019-01-07 18:33:13 +0100 | [diff] [blame] | 295 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 296 | if (sgsap == true) { |
Philipp Maier | 5786548 | 2019-01-07 18:33:13 +0100 | [diff] [blame] | 297 | f_init_sgsap("MSC_Test"); |
| 298 | } |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 299 | |
| 300 | map(self:MSCVTY, system:MSCVTY); |
| 301 | f_vty_set_prompts(MSCVTY); |
| 302 | f_vty_transceive(MSCVTY, "enable"); |
Harald Welte | b14c77a | 2018-01-25 17:25:44 +0100 | [diff] [blame] | 303 | |
| 304 | /* set some defaults */ |
| 305 | f_vty_config(MSCVTY, "network", "authentication optional"); |
| 306 | f_vty_config(MSCVTY, "msc", "assign-tmsi"); |
| 307 | f_vty_config(MSCVTY, "network", "encryption a5 0"); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 308 | } |
| 309 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 310 | /* Initialize for a direct connection to BSSAP. This function is an alternative |
| 311 | * to f_init() when the high level functions of the BSC_ConnectionHandler are |
| 312 | * not needed. */ |
| 313 | function f_init_bssap_direct() runs on MTC_CT { |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 314 | f_bssap_init(g_bssap[0], mp_bssap_cfg[0], "MSC_Test", omit); |
| 315 | connect(g_bssap[0].vc_SCCP:SCCP_SP_PORT, self:BSSAP_DIRECT); |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 316 | |
| 317 | /* Start guard timer and activate it as default */ |
| 318 | Tguard_direct.start |
| 319 | activate(as_Tguard_direct()); |
| 320 | } |
| 321 | |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 322 | template PDU_BSSAP ts_BSSAP_BSSMAP := { |
| 323 | discriminator := '0'B, |
| 324 | spare := '0000000'B, |
| 325 | dlci := omit, |
| 326 | lengthIndicator := 0, /* overwritten by codec */ |
| 327 | pdu := ? |
| 328 | } |
| 329 | |
| 330 | template PDU_BSSAP tr_BSSAP_BSSMAP := { |
| 331 | discriminator := '0'B, |
| 332 | spare := '0000000'B, |
| 333 | dlci := omit, |
| 334 | lengthIndicator := ?, |
| 335 | pdu := { |
| 336 | bssmap := ? |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | |
| 341 | type integer BssmapCause; |
| 342 | |
| 343 | template (value) BSSMAP_IE_Cause ts_BSSMAP_IE_Cause(BssmapCause val) := { |
| 344 | elementIdentifier := '04'O, |
| 345 | lengthIndicator := 0, |
| 346 | causeValue := int2bit(val, 7), |
| 347 | extensionCauseValue := '0'B, |
| 348 | spare1 := omit |
| 349 | } |
| 350 | |
| 351 | template (value) PDU_BSSAP ts_BSSMAP_Reset(BssmapCause cause) modifies ts_BSSAP_BSSMAP := { |
| 352 | pdu := { |
| 353 | bssmap := { |
| 354 | reset := { |
| 355 | messageType := '30'O, |
| 356 | cause := ts_BSSMAP_IE_Cause(cause), |
| 357 | a_InterfaceSelectorForReset := omit |
| 358 | } |
| 359 | } |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | template (value) PDU_BSSAP ts_BSSMAP_ResetAck modifies ts_BSSAP_BSSMAP := { |
| 364 | pdu := { |
| 365 | bssmap := { |
| 366 | resetAck := { |
| 367 | messageType := '31'O, |
| 368 | a_InterfaceSelectorForReset := omit |
| 369 | } |
| 370 | } |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | template PDU_BSSAP tr_BSSMAP_ResetAck modifies tr_BSSAP_BSSMAP := { |
| 375 | pdu := { |
| 376 | bssmap := { |
| 377 | resetAck := { |
| 378 | messageType := '31'O, |
| 379 | a_InterfaceSelectorForReset := * |
| 380 | } |
| 381 | } |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | template BSSMAP_IE_CellIdentifier ts_BSSMAP_IE_CellID := { |
| 386 | elementIdentifier := '05'O, |
| 387 | lengthIndicator := 0, |
| 388 | cellIdentifierDiscriminator := '0000'B, |
| 389 | spare1_4 := '0000'B, |
| 390 | cellIdentification := ? |
| 391 | } |
| 392 | |
| 393 | type uint16_t BssmapLAC; |
| 394 | type uint16_t BssmapCI; |
| 395 | |
| 396 | /* |
| 397 | template BSSMAP_IE_CellIdentifier ts_CellId_CGI(mcc, mnc, lac, ci) |
| 398 | modifies ts_BSSMAP_IE_CellID := { |
| 399 | cellIdentification := { |
| 400 | cI_LAC_CGI := { |
| 401 | mnc_mcc := FIXME, |
| 402 | lac := int2oct(lac, 2), |
| 403 | ci := int2oct(ci, 2) |
| 404 | } |
| 405 | } |
| 406 | } |
| 407 | */ |
| 408 | |
| 409 | template BSSMAP_IE_CellIdentifier ts_CellID_LAC_CI(BssmapLAC lac, BssmapCI ci) |
| 410 | modifies ts_BSSMAP_IE_CellID := { |
| 411 | cellIdentification := { |
| 412 | cI_LAC_CI := { |
| 413 | lac := int2oct(lac, 2), |
| 414 | ci := int2oct(ci, 2) |
| 415 | } |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | template BSSMAP_IE_CellIdentifier ts_CellId_CI(BssmapCI ci) |
| 420 | modifies ts_BSSMAP_IE_CellID := { |
| 421 | cellIdentification := { |
| 422 | cI_CI := int2oct(ci, 2) |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | template BSSMAP_IE_CellIdentifier ts_CellId_none |
| 427 | modifies ts_BSSMAP_IE_CellID := { |
| 428 | cellIdentification := { |
| 429 | cI_noCell := ''O |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | |
| 434 | template BSSMAP_IE_Layer3Information ts_BSSMAP_IE_L3Info(octetstring l3info) := { |
| 435 | elementIdentifier := '17'O, |
| 436 | lengthIndicator := 0, |
| 437 | layer3info := l3info |
| 438 | } |
| 439 | |
| 440 | template PDU_BSSAP ts_BSSMAP_ComplL3(BSSMAP_IE_CellIdentifier cell_id, octetstring l3_info) |
| 441 | modifies ts_BSSAP_BSSMAP := { |
| 442 | pdu := { |
| 443 | bssmap := { |
| 444 | completeLayer3Information := { |
| 445 | messageType := '57'O, |
| 446 | cellIdentifier := cell_id, |
| 447 | layer3Information := ts_BSSMAP_IE_L3Info(l3_info), |
| 448 | chosenChannel := omit, |
| 449 | lSAIdentifier := omit, |
| 450 | aPDU := omit, |
| 451 | codecList := omit, |
| 452 | redirectAttemptFlag := omit, |
| 453 | sendSequenceNumber := omit, |
| 454 | iMSI := omit |
| 455 | } |
| 456 | } |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | template PDU_BSSAP ts_BSSMAP_HandoReq(BssmapCause cause, BSSMAP_IE_CellIdentifierList cid_list) |
| 461 | modifies ts_BSSAP_BSSMAP := { |
| 462 | pdu := { |
| 463 | bssmap := { |
| 464 | handoverRequired := { |
| 465 | messageType := '11'O, |
| 466 | cause := ts_BSSMAP_IE_Cause(cause), |
| 467 | responseRequest := omit, |
| 468 | cellIdentifierList := cid_list, |
| 469 | circuitPoolList := omit, |
| 470 | currentChannelType1 := omit, |
| 471 | speechVersion := omit, |
| 472 | queueingIndicator := omit, |
| 473 | oldToNewBSSInfo := omit, |
| 474 | sourceToTargetRNCTransparentInfo := omit, |
| 475 | sourceToTargetRNCTransparentInfoCDMA := omit, |
| 476 | gERANClassmark := omit, |
| 477 | talkerPriority := omit, |
| 478 | speechCodec := omit, |
| 479 | cSG_Identifier := omit |
| 480 | } |
| 481 | } |
| 482 | } |
| 483 | } |
| 484 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 485 | 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] | 486 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 487 | /* FIXME: move into BSC_ConnectionHandler? */ |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 488 | function f_init_pars(integer imsi_suffix, boolean sgsap := false, boolean gsup := true) runs on MTC_CT return BSC_ConnHdlrPars { |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 489 | var BSC_ConnHdlrNetworkPars net_pars := { |
| 490 | kc_support := '0A'O, /* A5/1 and A5/3 enabled */ |
| 491 | expect_tmsi := true, |
| 492 | expect_auth := false, |
| 493 | expect_ciph := false |
| 494 | }; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 495 | var BSC_ConnHdlrPars pars := { |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 496 | sccp_addr_own := g_bssap[0].sccp_addr_own, |
| 497 | sccp_addr_peer := g_bssap[0].sccp_addr_peer, |
Harald Welte | edbab81 | 2018-03-18 16:02:25 +0100 | [diff] [blame] | 498 | cell_id := valueof(ts_CellId_CGI('262'H, '42'H, 23, 42)), |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 499 | imei := f_gen_imei(imsi_suffix), |
| 500 | imsi := f_gen_imsi(imsi_suffix), |
| 501 | msisdn := f_gen_msisdn(imsi_suffix), |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 502 | tmsi := omit, |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 503 | cm1 := valueof(ts_CM1), |
Harald Welte | 8260057 | 2018-01-21 20:54:08 +0100 | [diff] [blame] | 504 | cm2 := valueof(ts_CM2_default), |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 505 | cm3 := omit, |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 506 | vec := omit, |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 507 | net := net_pars, |
Philipp Maier | aeb29a8 | 2018-11-08 17:40:53 +0100 | [diff] [blame] | 508 | send_early_cm := true, |
| 509 | ipa_ctrl_ip := mp_msc_ip, |
| 510 | ipa_ctrl_port := mp_msc_ctrl_port, |
Philipp Maier | 9b690e4 | 2018-12-21 11:50:03 +0100 | [diff] [blame] | 511 | ipa_ctrl_enable := true, |
Philipp Maier | 5786548 | 2019-01-07 18:33:13 +0100 | [diff] [blame] | 512 | mm_info := mp_mm_info, |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 513 | sgsap_enable := sgsap, |
| 514 | gsup_enable := gsup |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 515 | }; |
Neels Hofmeyr | 9adaa70 | 2018-03-01 20:23:19 +0100 | [diff] [blame] | 516 | return pars; |
| 517 | } |
| 518 | |
| 519 | function f_start_handler_with_pars(void_fn fn, BSC_ConnHdlrPars pars) runs on MTC_CT return BSC_ConnHdlr { |
| 520 | var BSC_ConnHdlr vc_conn; |
| 521 | var charstring id := testcasename(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 522 | |
| 523 | vc_conn := BSC_ConnHdlr.create(id); |
| 524 | /* BSSMAP part / A interface */ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 525 | connect(vc_conn:BSSAP, g_bssap[0].vc_RAN:CLIENT); |
| 526 | connect(vc_conn:BSSAP_PROC, g_bssap[0].vc_RAN:PROC); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 527 | /* MNCC part */ |
| 528 | connect(vc_conn:MNCC, vc_MNCC:MNCC_CLIENT); |
| 529 | connect(vc_conn:MNCC_PROC, vc_MNCC:MNCC_PROC); |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 530 | /* MGCP part */ |
| 531 | connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT); |
| 532 | connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 533 | /* GSUP part */ |
Philipp Maier | c09a131 | 2019-04-09 16:05:26 +0200 | [diff] [blame] | 534 | if (pars.gsup_enable == true) { |
| 535 | connect(vc_conn:GSUP, vc_GSUP:GSUP_CLIENT); |
| 536 | connect(vc_conn:GSUP_PROC, vc_GSUP:GSUP_PROC); |
| 537 | } |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 538 | /* SMPP part */ |
| 539 | connect(vc_conn:SMPP, vc_SMPP:SMPP_CLIENT); |
| 540 | connect(vc_conn:SMPP_PROC, vc_SMPP:SMPP_PROC); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 541 | /* SGs part */ |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 542 | if (pars.sgsap_enable == true) { |
Philipp Maier | 5786548 | 2019-01-07 18:33:13 +0100 | [diff] [blame] | 543 | connect(vc_conn:SGsAP, vc_SGsAP:SGsAP_CLIENT); |
| 544 | connect(vc_conn:SGsAP_PROC, vc_SGsAP:SGsAP_PROC); |
| 545 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 546 | |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 547 | /* We cannot use vc_conn.start(f_init_handler(fn, id, pars)); as we cannot have |
| 548 | * 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] | 549 | vc_conn.start(derefers(fn)(id, pars)); |
| 550 | return vc_conn; |
| 551 | } |
| 552 | |
Neels Hofmeyr | 9adaa70 | 2018-03-01 20:23:19 +0100 | [diff] [blame] | 553 | function f_start_handler(void_fn fn, integer imsi_suffix) runs on MTC_CT return BSC_ConnHdlr { |
| 554 | return f_start_handler_with_pars(fn, f_init_pars(imsi_suffix)); |
| 555 | } |
| 556 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 557 | 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] | 558 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 559 | f_perform_lu(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 560 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 561 | testcase TC_lu_imsi_noauth_tmsi() runs on MTC_CT { |
| 562 | var BSC_ConnHdlr vc_conn; |
| 563 | f_init(); |
| 564 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 565 | 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] | 566 | vc_conn.done; |
| 567 | } |
| 568 | |
| 569 | 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] | 570 | pars.net.expect_tmsi := false; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 571 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 572 | f_perform_lu(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 573 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 574 | testcase TC_lu_imsi_noauth_notmsi() runs on MTC_CT { |
| 575 | var BSC_ConnHdlr vc_conn; |
| 576 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 577 | f_vty_config(MSCVTY, "msc", "no assign-tmsi"); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 578 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 579 | 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] | 580 | vc_conn.done; |
| 581 | } |
| 582 | |
| 583 | /* Do LU by IMSI, refuse it on GSUP and expect LU REJ back to MS */ |
| 584 | private 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] | 585 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 586 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 587 | |
| 588 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 589 | f_bssap_compl_l3(l3_lu); |
| 590 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 591 | GSUP.send(ts_GSUP_UL_ERR(g_pars.imsi, 23)); |
| 592 | alt { |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 593 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej(int2oct(23,1)))) { |
| 594 | f_expect_clear(); |
| 595 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 596 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 597 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 598 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 599 | } |
| 600 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 601 | } |
| 602 | testcase TC_lu_imsi_reject() runs on MTC_CT { |
| 603 | var BSC_ConnHdlr vc_conn; |
| 604 | f_init(); |
| 605 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 606 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_reject), 3); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 607 | vc_conn.done; |
| 608 | } |
| 609 | |
| 610 | /* Do LU by IMSI, timeout on GSUP */ |
| 611 | private 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] | 612 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 613 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 614 | |
| 615 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 616 | f_bssap_compl_l3(l3_lu); |
| 617 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 618 | /* Normally the HLR would need to respond here, but we decide to force a timeout here */ |
| 619 | alt { |
| 620 | /* FIXME: Expect specific reject cause */ |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 621 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 622 | f_expect_clear(); |
| 623 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 624 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 625 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 626 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 627 | } |
| 628 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 629 | } |
| 630 | testcase TC_lu_imsi_timeout_gsup() runs on MTC_CT { |
| 631 | var BSC_ConnHdlr vc_conn; |
| 632 | f_init(); |
| 633 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 634 | 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] | 635 | vc_conn.done; |
| 636 | } |
| 637 | |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 638 | 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] | 639 | pars.net.expect_auth := true; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 640 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 641 | f_perform_lu(); |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 642 | } |
| 643 | testcase TC_lu_imsi_auth_tmsi() runs on MTC_CT { |
| 644 | var BSC_ConnHdlr vc_conn; |
| 645 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 646 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 647 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 648 | 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] | 649 | vc_conn.done; |
| 650 | } |
| 651 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 652 | |
| 653 | /* Send CM SERVICE REQ for IMSI that has never performed LU before */ |
| 654 | private function f_tc_cmserv_imsi_unknown(charstring id, BSC_ConnHdlrPars pars) |
| 655 | runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 656 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 657 | |
| 658 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | edbab81 | 2018-03-18 16:02:25 +0100 | [diff] [blame] | 659 | 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] | 660 | 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] | 661 | |
| 662 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 663 | |
| 664 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 665 | f_bssap_compl_l3(l3_info); |
| 666 | |
| 667 | timer T := 10.0; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 668 | T.start; |
| 669 | alt { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 670 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)) { } |
| 671 | //[] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_ACC)) { } |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 672 | [] BSSAP.receive { |
| 673 | setverdict(fail, "Received unexpected BSSAP"); |
| 674 | mtc.stop; |
| 675 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 676 | [] GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)) { |
| 677 | setverdict(fail, "Unexpected GSUP UL REQ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 678 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 679 | } |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 680 | [] T.timeout { |
| 681 | setverdict(fail, "Timeout waiting for CM SERV REQ"); |
| 682 | mtc.stop; |
| 683 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 684 | } |
| 685 | |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 686 | f_expect_clear(); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 687 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 688 | testcase TC_cmserv_imsi_unknown() runs on MTC_CT { |
| 689 | var BSC_ConnHdlr vc_conn; |
| 690 | f_init(); |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 691 | vc_conn := f_start_handler(refers(f_tc_cmserv_imsi_unknown), 6); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 692 | vc_conn.done; |
| 693 | } |
| 694 | |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 695 | private 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] | 696 | f_init_handler(pars); |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 697 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 698 | cpars.bss_rtp_port := 1110; |
| 699 | cpars.mgcp_connection_id_bss := '22222'H; |
| 700 | cpars.mgcp_connection_id_mss := '33333'H; |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 701 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 702 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 703 | f_perform_lu(); |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 704 | f_mo_call(cpars); |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 705 | } |
| 706 | testcase TC_lu_and_mo_call() runs on MTC_CT { |
| 707 | var BSC_ConnHdlr vc_conn; |
| 708 | f_init(); |
| 709 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 710 | 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] | 711 | vc_conn.done; |
| 712 | } |
| 713 | |
| 714 | /* Test LU (with authentication enabled), where HLR times out sending SAI response */ |
| 715 | private 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] | 716 | f_init_handler(pars); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 717 | |
| 718 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 719 | var PDU_DTAP_MT dtap_mt; |
| 720 | |
| 721 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 722 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 723 | |
| 724 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 725 | f_bssap_compl_l3(l3_lu); |
| 726 | |
| 727 | /* Send Early Classmark, just for the fun of it */ |
| 728 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 729 | |
| 730 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 731 | /* The HLR would normally return an auth vector here, but we fail to do so. */ |
| 732 | |
| 733 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 734 | f_expect_clear(); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 735 | } |
| 736 | testcase TC_lu_auth_sai_timeout() runs on MTC_CT { |
| 737 | var BSC_ConnHdlr vc_conn; |
| 738 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 739 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 740 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 741 | 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] | 742 | vc_conn.done; |
| 743 | } |
| 744 | |
| 745 | /* Test LU (with authentication enabled), where HLR rejects sending SAI error */ |
| 746 | private 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] | 747 | f_init_handler(pars); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 748 | |
| 749 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 750 | var PDU_DTAP_MT dtap_mt; |
| 751 | |
| 752 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 753 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 754 | |
| 755 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 756 | f_bssap_compl_l3(l3_lu); |
| 757 | |
| 758 | /* Send Early Classmark, just for the fun of it */ |
| 759 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 760 | |
| 761 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 762 | GSUP.send(ts_GSUP_SAI_ERR(g_pars.imsi, 13)); |
| 763 | |
| 764 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 765 | f_expect_clear(); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 766 | } |
| 767 | testcase TC_lu_auth_sai_err() runs on MTC_CT { |
| 768 | var BSC_ConnHdlr vc_conn; |
| 769 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 770 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 771 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 772 | 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] | 773 | vc_conn.done; |
| 774 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 775 | |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 776 | /* Test LU but BSC will send a clear request in the middle */ |
| 777 | 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] | 778 | f_init_handler(pars); |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 779 | |
| 780 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 781 | var PDU_DTAP_MT dtap_mt; |
| 782 | |
| 783 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 784 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 785 | |
| 786 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 787 | f_bssap_compl_l3(l3_lu); |
| 788 | |
| 789 | /* Send Early Classmark, just for the fun of it */ |
| 790 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 791 | |
| 792 | f_sleep(1.0); |
| 793 | /* send clear request in the middle of the LU */ |
| 794 | BSSAP.send(ts_BSSMAP_ClearRequest(0)); |
Neels Hofmeyr | 2b326fa | 2018-04-06 00:59:36 +0200 | [diff] [blame] | 795 | alt { |
| 796 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { repeat; } |
| 797 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) {} |
| 798 | } |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 799 | BSSAP.send(ts_BSSMAP_ClearComplete); |
Harald Welte | 89a3249 | 2018-01-27 19:07:28 +0100 | [diff] [blame] | 800 | alt { |
| 801 | /* See https://osmocom.org/issues/2862 */ |
Neels Hofmeyr | 2b326fa | 2018-04-06 00:59:36 +0200 | [diff] [blame] | 802 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 803 | setverdict(fail, "Got a second Clear Command, only one expected"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 804 | mtc.stop; |
Neels Hofmeyr | 2b326fa | 2018-04-06 00:59:36 +0200 | [diff] [blame] | 805 | repeat; |
| 806 | } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 807 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
Harald Welte | 89a3249 | 2018-01-27 19:07:28 +0100 | [diff] [blame] | 808 | } |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 809 | setverdict(pass); |
| 810 | } |
| 811 | testcase TC_lu_clear_request() runs on MTC_CT { |
| 812 | var BSC_ConnHdlr vc_conn; |
| 813 | f_init(); |
| 814 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 815 | vc_conn := f_start_handler(refers(f_tc_lu_clear_request), 10); |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 816 | vc_conn.done; |
| 817 | } |
| 818 | |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 819 | /* Test LU but BSC will send a clear request in the middle */ |
| 820 | private 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] | 821 | f_init_handler(pars); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 822 | |
| 823 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 824 | var PDU_DTAP_MT dtap_mt; |
| 825 | |
| 826 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 827 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 828 | |
| 829 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 830 | f_bssap_compl_l3(l3_lu); |
| 831 | |
| 832 | /* Send Early Classmark, just for the fun of it */ |
| 833 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 834 | |
| 835 | f_sleep(1.0); |
| 836 | /* send clear request in the middle of the LU */ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 837 | BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 838 | setverdict(pass); |
Neels Hofmeyr | bb825c9 | 2019-03-06 15:35:50 +0100 | [diff] [blame] | 839 | f_sleep(1.0); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 840 | } |
| 841 | testcase TC_lu_disconnect() runs on MTC_CT { |
| 842 | var BSC_ConnHdlr vc_conn; |
| 843 | f_init(); |
| 844 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 845 | vc_conn := f_start_handler(refers(f_tc_lu_disconnect), 11); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 846 | vc_conn.done; |
| 847 | } |
| 848 | |
| 849 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 850 | /* Test LU but with illegal mobile identity type = IMEI */ |
| 851 | private 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] | 852 | f_init_handler(pars); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 853 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 854 | 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] | 855 | var PDU_DTAP_MT dtap_mt; |
| 856 | |
| 857 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 858 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 859 | |
| 860 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 861 | f_bssap_compl_l3(l3_lu); |
| 862 | |
| 863 | /* Send Early Classmark, just for the fun of it */ |
| 864 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 865 | /* wait for LU reject, ignore any ID REQ */ |
| 866 | alt { |
| 867 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { } |
| 868 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req)) { repeat; } |
| 869 | } |
| 870 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 871 | f_expect_clear(); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 872 | } |
| 873 | testcase TC_lu_by_imei() runs on MTC_CT { |
| 874 | var BSC_ConnHdlr vc_conn; |
| 875 | f_init(); |
| 876 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 877 | vc_conn := f_start_handler(refers(f_tc_lu_by_imei), 12); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 878 | vc_conn.done; |
| 879 | } |
| 880 | |
| 881 | /* Test LU by TMSI with unknown TMSI, expect (and answer) ID REQ. */ |
| 882 | 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] | 883 | /* We piggyback a test for an MSC crash on overlong IMSI (OS#2864) onto this test. */ |
| 884 | var hexstring overlong_imsi := '012345789ABCDEF0123456789ABCDEF'H; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 885 | f_init_handler(pars); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 886 | |
| 887 | var PDU_ML3_MS_NW l3_lu := f_build_lu_tmsi('01020304'O); /* FIXME: Random */ |
| 888 | var PDU_DTAP_MT dtap_mt; |
| 889 | |
| 890 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 891 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 892 | |
| 893 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 894 | f_bssap_compl_l3(l3_lu); |
| 895 | |
| 896 | /* Send Early Classmark, just for the fun of it */ |
| 897 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 898 | |
| 899 | /* Wait for + respond to ID REQ (IMSI) */ |
| 900 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req('001'B))); |
Stefan Sperling | 04fc4bc | 2018-06-25 17:44:57 +0200 | [diff] [blame] | 901 | 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] | 902 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp_IMSI(g_pars.imsi))); |
| 903 | |
| 904 | /* Expect MSC to do UpdateLocation to HLR; respond to it */ |
| 905 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 906 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 907 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 908 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 909 | |
| 910 | alt { |
Harald Welte | 7ec4fa8 | 2018-01-27 10:57:40 +0100 | [diff] [blame] | 911 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 912 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_TmsiRealloc_Cmpl)); |
| 913 | } |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 914 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 915 | setverdict(fail, "Expected LU ACK, but received REJ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 916 | mtc.stop; |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 917 | } |
| 918 | } |
| 919 | |
Philipp Maier | 9b690e4 | 2018-12-21 11:50:03 +0100 | [diff] [blame] | 920 | /* Wait for MM-Information (if enabled) */ |
| 921 | f_expect_mm_info(); |
| 922 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 923 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 924 | f_expect_clear(); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 925 | } |
| 926 | testcase TC_lu_by_tmsi_noauth_unknown() runs on MTC_CT { |
| 927 | var BSC_ConnHdlr vc_conn; |
| 928 | f_init(); |
| 929 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 930 | 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] | 931 | vc_conn.done; |
| 932 | } |
| 933 | |
| 934 | |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 935 | /* Test IMSI DETACH (MI=IMSI) */ |
| 936 | private 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] | 937 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 938 | |
| 939 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 940 | |
| 941 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 942 | f_bssap_compl_l3(valueof(ts_ML3_MO_MM_IMSI_DET_Ind(mi))); |
| 943 | |
| 944 | /* Send Early Classmark, just for the fun of it? */ |
| 945 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 946 | |
| 947 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 948 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 949 | } |
| 950 | testcase TC_imsi_detach_by_imsi() runs on MTC_CT { |
| 951 | var BSC_ConnHdlr vc_conn; |
| 952 | f_init(); |
| 953 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 954 | 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] | 955 | vc_conn.done; |
| 956 | } |
| 957 | |
| 958 | /* Test IMSI DETACH (MI=TMSI) */ |
| 959 | private 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] | 960 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 961 | |
| 962 | var MobileIdentityLV mi := valueof(ts_MI_TMSI_LV('01020304'O)); |
| 963 | |
| 964 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 965 | f_bssap_compl_l3(valueof(ts_ML3_MO_MM_IMSI_DET_Ind(mi))); |
| 966 | |
| 967 | /* Send Early Classmark, just for the fun of it? */ |
| 968 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 969 | |
| 970 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 971 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 972 | } |
| 973 | testcase TC_imsi_detach_by_tmsi() runs on MTC_CT { |
| 974 | var BSC_ConnHdlr vc_conn; |
| 975 | f_init(); |
| 976 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 977 | 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] | 978 | vc_conn.done; |
| 979 | } |
| 980 | |
| 981 | /* Test IMSI DETACH (MI=IMEI), which is illegal */ |
| 982 | private 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] | 983 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 984 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 985 | var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 986 | |
| 987 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 988 | f_bssap_compl_l3(valueof(ts_ML3_MO_MM_IMSI_DET_Ind(mi))); |
| 989 | |
| 990 | /* Send Early Classmark, just for the fun of it? */ |
| 991 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 992 | |
| 993 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 994 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 995 | } |
| 996 | testcase TC_imsi_detach_by_imei() runs on MTC_CT { |
| 997 | var BSC_ConnHdlr vc_conn; |
| 998 | f_init(); |
| 999 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1000 | 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] | 1001 | vc_conn.done; |
| 1002 | } |
| 1003 | |
| 1004 | |
| 1005 | /* helper function for an emergency call. caller passes in mobile identity to use */ |
| 1006 | private function f_emerg_call(MobileIdentityLV mi) runs on BSC_ConnHdlr { |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 1007 | var CallParameters cpars := valueof(t_CallParams('112'H, 0)); |
| 1008 | cpars.emergency := true; |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 1009 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1010 | |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 1011 | f_mo_call(cpars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1012 | } |
| 1013 | |
| 1014 | /* establish an emergency call by IMEI, no SIM inserted (and hence no IMSI) */ |
| 1015 | private 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] | 1016 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1017 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 1018 | var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1019 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_EMERG_CALL, mi)); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1020 | f_bssap_compl_l3(l3_info); |
| 1021 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ('05'O))); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1022 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1023 | } |
| 1024 | testcase TC_emerg_call_imei_reject() runs on MTC_CT { |
| 1025 | var BSC_ConnHdlr vc_conn; |
| 1026 | f_init(); |
| 1027 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1028 | 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] | 1029 | vc_conn.done; |
| 1030 | } |
| 1031 | |
Harald Welte | d5b9140 | 2018-01-24 18:48:16 +0100 | [diff] [blame] | 1032 | /* establish an emergency call by IMSI, SIM inserted (and hence IMSI) */ |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1033 | private 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] | 1034 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1035 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1036 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1037 | /* Then issue emergency call identified by IMSI */ |
| 1038 | f_emerg_call(valueof(ts_MI_IMSI_LV(g_pars.imsi))); |
| 1039 | } |
| 1040 | testcase TC_emerg_call_imsi() runs on MTC_CT { |
| 1041 | var BSC_ConnHdlr vc_conn; |
| 1042 | f_init(); |
| 1043 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1044 | vc_conn := f_start_handler(refers(f_tc_emerg_call_imsi), 18); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1045 | vc_conn.done; |
| 1046 | } |
| 1047 | |
| 1048 | /* CM Service Request for VGCS -> reject */ |
| 1049 | 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] | 1050 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1051 | |
| 1052 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1053 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1054 | |
| 1055 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1056 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_VGCS, mi)); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1057 | f_bssap_compl_l3(l3_info); |
| 1058 | 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] | 1059 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1060 | } |
| 1061 | testcase TC_cm_serv_req_vgcs_reject() runs on MTC_CT { |
| 1062 | var BSC_ConnHdlr vc_conn; |
| 1063 | f_init(); |
| 1064 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1065 | 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] | 1066 | vc_conn.done; |
| 1067 | } |
| 1068 | |
| 1069 | /* CM Service Request for VBS -> reject */ |
| 1070 | 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] | 1071 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1072 | |
| 1073 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1074 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1075 | |
| 1076 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1077 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_VBS, mi)); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1078 | f_bssap_compl_l3(l3_info); |
| 1079 | 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] | 1080 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1081 | } |
| 1082 | testcase TC_cm_serv_req_vbs_reject() runs on MTC_CT { |
| 1083 | var BSC_ConnHdlr vc_conn; |
| 1084 | f_init(); |
| 1085 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1086 | 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] | 1087 | vc_conn.done; |
| 1088 | } |
| 1089 | |
| 1090 | /* CM Service Request for LCS -> reject */ |
| 1091 | 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] | 1092 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1093 | |
| 1094 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1095 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1096 | |
| 1097 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1098 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_LCS, mi)); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1099 | f_bssap_compl_l3(l3_info); |
| 1100 | 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] | 1101 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1102 | } |
| 1103 | testcase TC_cm_serv_req_lcs_reject() runs on MTC_CT { |
| 1104 | var BSC_ConnHdlr vc_conn; |
| 1105 | f_init(); |
| 1106 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1107 | 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] | 1108 | vc_conn.done; |
| 1109 | } |
| 1110 | |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1111 | /* CM Re-Establishment Request */ |
| 1112 | 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] | 1113 | f_init_handler(pars); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1114 | |
| 1115 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1116 | f_perform_lu(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1117 | |
| 1118 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 1119 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_REEST_REQ(0, mi)); |
| 1120 | f_bssap_compl_l3(l3_info); |
| 1121 | 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] | 1122 | f_expect_clear(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1123 | } |
| 1124 | testcase TC_cm_reest_req_reject() runs on MTC_CT { |
| 1125 | var BSC_ConnHdlr vc_conn; |
| 1126 | f_init(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1127 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1128 | 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] | 1129 | vc_conn.done; |
| 1130 | } |
| 1131 | |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1132 | /* Test LU (with authentication enabled), with wrong response from MS */ |
| 1133 | 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] | 1134 | f_init_handler(pars); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1135 | |
| 1136 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 1137 | |
| 1138 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1139 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1140 | |
| 1141 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 1142 | f_bssap_compl_l3(l3_lu); |
| 1143 | |
| 1144 | /* Send Early Classmark, just for the fun of it */ |
| 1145 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1146 | |
| 1147 | var AuthVector vec := f_gen_auth_vec_2g(); |
| 1148 | var GSUP_IE auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G(vec.rand, vec.sres, vec.kc)); |
| 1149 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 1150 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
| 1151 | |
| 1152 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_AUTH_REQ(vec.rand))); |
| 1153 | /* Send back wrong auth response */ |
| 1154 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MT_MM_AUTH_RESP_2G('00000000'O))); |
| 1155 | |
| 1156 | /* Expect GSUP AUTH FAIL REP to HLR */ |
| 1157 | GSUP.receive(tr_GSUP_AUTH_FAIL_IND(g_pars.imsi)); |
| 1158 | |
| 1159 | /* Expect LU REJECT with Cause == Illegal MS */ |
| 1160 | 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] | 1161 | f_expect_clear(); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1162 | } |
| 1163 | testcase TC_lu_auth_2G_fail() runs on MTC_CT { |
| 1164 | var BSC_ConnHdlr vc_conn; |
| 1165 | f_init(); |
| 1166 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1167 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1168 | 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] | 1169 | vc_conn.done; |
| 1170 | } |
| 1171 | |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 1172 | /* 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] | 1173 | 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] | 1174 | pars.net.expect_auth := true; |
| 1175 | pars.net.expect_ciph := true; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1176 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1177 | f_perform_lu(); |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 1178 | } |
| 1179 | testcase TC_lu_imsi_auth_tmsi_encr_13_13() runs on MTC_CT { |
| 1180 | var BSC_ConnHdlr vc_conn; |
| 1181 | f_init(); |
| 1182 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 1183 | f_vty_config(MSCVTY, "network", "encryption a5 1 3"); |
| 1184 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1185 | 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] | 1186 | vc_conn.done; |
| 1187 | } |
| 1188 | |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1189 | /* Test Complete L3 without payload */ |
| 1190 | 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] | 1191 | f_init_handler(pars); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1192 | |
| 1193 | /* Send Complete L3 Info with empty L3 frame */ |
| 1194 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own, |
| 1195 | valueof(ts_BSSMAP_ComplL3(g_pars.cell_id, ''O)))); |
| 1196 | |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1197 | timer T := 5.0; |
| 1198 | T.start; |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1199 | alt { |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1200 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1201 | /* Expect LU REJECT with Cause == Illegal MS */ |
Harald Welte | bdb3c45 | 2018-03-18 22:43:06 +0100 | [diff] [blame] | 1202 | [] BSSAP.receive(tr_PDU_DTAP_MT(?)) { repeat; } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1203 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND) { repeat; } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1204 | [] as_clear_cmd_compl_disc(); |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1205 | [] T.timeout { |
Daniel Willmann | 90829d6 | 2018-02-15 17:45:14 +0100 | [diff] [blame] | 1206 | setverdict(fail, "Timeout waiting for ClearCommand or SCCP Release"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1207 | mtc.stop; |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1208 | } |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1209 | } |
| 1210 | setverdict(pass); |
| 1211 | } |
| 1212 | testcase TC_cl3_no_payload() runs on MTC_CT { |
| 1213 | var BSC_ConnHdlr vc_conn; |
| 1214 | f_init(); |
| 1215 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1216 | vc_conn := f_start_handler(refers(f_tc_cl3_no_payload), 25); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1217 | vc_conn.done; |
| 1218 | } |
| 1219 | |
| 1220 | /* Test Complete L3 with random payload */ |
| 1221 | 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] | 1222 | f_init_handler(pars); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1223 | |
Daniel Willmann | aa14a38 | 2018-07-26 08:29:45 +0200 | [diff] [blame] | 1224 | /* length is limited by PDU_BSSAP length field which includes some |
| 1225 | * other fields beside l3info payload. So payl can only be 240 bytes |
| 1226 | * Since rnd() returns values < 1 multiply with 241 |
| 1227 | */ |
| 1228 | var integer len := float2int(rnd() * 241.0); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1229 | var octetstring payl := f_rnd_octstring(len); |
| 1230 | |
| 1231 | /* Send Complete L3 Info with empty L3 frame */ |
| 1232 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own, |
| 1233 | valueof(ts_BSSMAP_ComplL3(g_pars.cell_id, payl)))); |
| 1234 | |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1235 | timer T := 5.0; |
| 1236 | T.start; |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1237 | alt { |
| 1238 | /* Immediate disconnect */ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1239 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1240 | [] BSSAP.receive(tr_PDU_DTAP_MT(?)) { repeat; } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1241 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND) { repeat; } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1242 | [] as_clear_cmd_compl_disc(); |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1243 | [] T.timeout { |
Daniel Willmann | 90829d6 | 2018-02-15 17:45:14 +0100 | [diff] [blame] | 1244 | setverdict(fail, "Timeout waiting for ClearCommand or SCCP Release"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1245 | mtc.stop; |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1246 | } |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1247 | } |
| 1248 | setverdict(pass); |
| 1249 | } |
| 1250 | testcase TC_cl3_rnd_payload() runs on MTC_CT { |
| 1251 | var BSC_ConnHdlr vc_conn; |
| 1252 | f_init(); |
| 1253 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1254 | vc_conn := f_start_handler(refers(f_tc_cl3_rnd_payload), 26); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1255 | vc_conn.done; |
| 1256 | } |
| 1257 | |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1258 | /* Test Complete L3 with random payload */ |
| 1259 | private 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] | 1260 | f_init_handler(pars); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1261 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1262 | f_perform_lu(); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1263 | |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1264 | f_establish_fully(); |
Daniel Willmann | 898a7e0 | 2018-05-17 12:16:16 +0200 | [diff] [blame] | 1265 | f_expect_clear(10.0); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1266 | } |
| 1267 | testcase TC_establish_and_nothing() runs on MTC_CT { |
| 1268 | var BSC_ConnHdlr vc_conn; |
| 1269 | f_init(); |
| 1270 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1271 | vc_conn := f_start_handler(refers(f_tc_establish_and_nothing), 27); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1272 | vc_conn.done; |
| 1273 | } |
| 1274 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1275 | /* Test MO Call SETUP with no response from MNCC */ |
| 1276 | private 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] | 1277 | f_init_handler(pars, 190.0); |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1278 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1279 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1280 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1281 | f_perform_lu(); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1282 | |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1283 | f_establish_fully(); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1284 | f_create_mncc_expect(hex2str(cpars.called_party)); |
| 1285 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1286 | |
| 1287 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_SETUP(cpars.transaction_id, cpars.called_party))); |
| 1288 | |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 1289 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
| 1290 | |
Philipp Maier | 109e6aa | 2018-10-17 10:53:32 +0200 | [diff] [blame] | 1291 | f_expect_clear(185.0); |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 1292 | |
| 1293 | deactivate(ccrel); |
| 1294 | |
| 1295 | f_sleep(1.0); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1296 | } |
| 1297 | testcase TC_mo_setup_and_nothing() runs on MTC_CT { |
| 1298 | var BSC_ConnHdlr vc_conn; |
| 1299 | f_init(); |
| 1300 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1301 | 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] | 1302 | vc_conn.done; |
| 1303 | } |
| 1304 | |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1305 | /* Test MO Call with no response to RAN-side CRCX */ |
| 1306 | private 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] | 1307 | f_init_handler(pars); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1308 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1309 | var MNCC_PDU mncc; |
| 1310 | var MgcpCommand mgcp_cmd; |
| 1311 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1312 | f_perform_lu(); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1313 | |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1314 | f_establish_fully(); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1315 | f_create_mncc_expect(hex2str(cpars.called_party)); |
| 1316 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1317 | |
| 1318 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_SETUP(cpars.transaction_id, cpars.called_party))); |
| 1319 | MNCC.receive(tr_MNCC_SETUP_ind(?, tr_MNCC_number(hex2str(cpars.called_party)))) -> value mncc; |
| 1320 | cpars.mncc_callref := mncc.u.signal.callref; |
| 1321 | MNCC.send(ts_MNCC_CALL_PROC_req(cpars.mncc_callref, cpars.mncc_bearer_cap)); |
| 1322 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CALL_PROC(cpars.transaction_id))); |
| 1323 | |
| 1324 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
Harald Welte | 1852a84 | 2018-01-26 22:53:36 +0100 | [diff] [blame] | 1325 | cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
| 1326 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1327 | /* never respond to this */ |
| 1328 | |
Philipp Maier | 8e58f59 | 2018-03-14 11:10:56 +0100 | [diff] [blame] | 1329 | /* When the connection with the MGW fails, the MSC will first request |
| 1330 | * a release via call control. We will answer this request normally. */ |
| 1331 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))); |
| 1332 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_REL_COMPL(cpars.transaction_id))); |
| 1333 | |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1334 | f_expect_clear(30.0); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1335 | } |
| 1336 | testcase TC_mo_crcx_ran_timeout() runs on MTC_CT { |
| 1337 | var BSC_ConnHdlr vc_conn; |
| 1338 | f_init(); |
| 1339 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1340 | 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] | 1341 | vc_conn.done; |
| 1342 | } |
| 1343 | |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1344 | /* Test MO Call with reject to RAN-side CRCX */ |
| 1345 | private 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] | 1346 | f_init_handler(pars); |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1347 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1348 | var MNCC_PDU mncc; |
| 1349 | var MgcpCommand mgcp_cmd; |
| 1350 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1351 | f_perform_lu(); |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1352 | |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1353 | f_establish_fully(); |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1354 | f_create_mncc_expect(hex2str(cpars.called_party)); |
| 1355 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1356 | |
| 1357 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_SETUP(cpars.transaction_id, cpars.called_party))); |
| 1358 | MNCC.receive(tr_MNCC_SETUP_ind(?, tr_MNCC_number(hex2str(cpars.called_party)))) -> value mncc; |
| 1359 | cpars.mncc_callref := mncc.u.signal.callref; |
| 1360 | MNCC.send(ts_MNCC_CALL_PROC_req(cpars.mncc_callref, cpars.mncc_bearer_cap)); |
| 1361 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CALL_PROC(cpars.transaction_id))); |
| 1362 | |
| 1363 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 1364 | |
| 1365 | /* Detect if the received CRCX is a wildcarded CRCX request. If yes, |
| 1366 | * set an endpoint name that fits the pattern. If not, just use the |
| 1367 | * endpoint name from the request */ |
| 1368 | if (match(mgcp_cmd.line.ep, t_MGCP_EP_wildcard)) { |
| 1369 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
| 1370 | } else { |
| 1371 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
| 1372 | } |
| 1373 | |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1374 | cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 1375 | |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1376 | /* Respond to CRCX with error */ |
| 1377 | var MgcpResponse mgcp_rsp := { |
| 1378 | line := { |
| 1379 | code := "542", |
| 1380 | trans_id := mgcp_cmd.line.trans_id, |
| 1381 | string := "FORCED_FAIL" |
| 1382 | }, |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1383 | sdp := omit |
| 1384 | } |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 1385 | var MgcpParameter mgcp_rsp_param := { |
| 1386 | code := "Z", |
| 1387 | val := cpars.mgcp_ep |
| 1388 | }; |
| 1389 | mgcp_rsp.params[0] := mgcp_rsp_param; |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1390 | MGCP.send(mgcp_rsp); |
| 1391 | |
| 1392 | timer T := 30.0; |
| 1393 | T.start; |
| 1394 | alt { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1395 | [] T.timeout { |
| 1396 | setverdict(fail, "Timeout waiting for channel release"); |
| 1397 | mtc.stop; |
| 1398 | } |
Daniel Willmann | 5868e62 | 2018-02-15 17:42:59 +0100 | [diff] [blame] | 1399 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))) { |
| 1400 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_REL_COMPL(cpars.transaction_id))); |
| 1401 | repeat; |
| 1402 | } |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1403 | [] MNCC.receive { repeat; } |
| 1404 | [] GSUP.receive { repeat; } |
Philipp Maier | c6e06f7 | 2018-04-11 18:12:23 +0200 | [diff] [blame] | 1405 | /* Note: As we did not respond properly to the CRCX from the MSC we |
| 1406 | * expect the MSC to omit any further MGCP operation (At least in the |
| 1407 | * the current implementation, there is no recovery mechanism implemented |
| 1408 | * and a DLCX can not be performed as the MSC does not know a specific |
| 1409 | * endpoint yet. */ |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1410 | [] MGCP.receive { |
| 1411 | setverdict(fail, "Unexpected MGCP message"); |
| 1412 | mtc.stop; |
| 1413 | } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1414 | [] as_clear_cmd_compl_disc(); |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1415 | } |
| 1416 | } |
| 1417 | testcase TC_mo_crcx_ran_reject() runs on MTC_CT { |
| 1418 | var BSC_ConnHdlr vc_conn; |
| 1419 | f_init(); |
| 1420 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1421 | 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] | 1422 | vc_conn.done; |
| 1423 | } |
| 1424 | |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1425 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1426 | /* helper function to start a MT call: MNCC SETUP; Paging; DChan est.; DTAP SETUP */ |
| 1427 | private function f_mt_call_start(inout CallParameters cpars) runs on BSC_ConnHdlr { |
| 1428 | var MNCC_PDU mncc; |
| 1429 | var MgcpCommand mgcp_cmd; |
| 1430 | var OCT4 tmsi; |
| 1431 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1432 | f_perform_lu(); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1433 | if (isvalue(g_pars.tmsi)) { |
| 1434 | tmsi := g_pars.tmsi; |
| 1435 | } else { |
| 1436 | tmsi := 'FFFFFFFF'O; |
| 1437 | } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 1438 | f_ran_register_imsi(g_pars.imsi, tmsi); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1439 | |
| 1440 | /* Allocate call reference and send SETUP via MNCC to MSC */ |
| 1441 | cpars.mncc_callref := f_rnd_int(2147483648); |
| 1442 | MNCC.send(ts_MNCC_SETUP_req(cpars.mncc_callref, hex2str(g_pars.msisdn), |
| 1443 | hex2str(cpars.called_party), hex2str(g_pars.imsi))); |
| 1444 | |
| 1445 | /* MSC->BSC: expect PAGING from MSC */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 1446 | f_expect_paging(); |
| 1447 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1448 | /* MS -> MSC: PAGING RESPONSE */ |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1449 | f_establish_fully(EST_TYPE_PAG_RESP); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1450 | |
| 1451 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1452 | |
| 1453 | /* MSC->MS: SETUP */ |
| 1454 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_SETUP(cpars.transaction_id, *, cpars.called_party))); |
| 1455 | } |
| 1456 | |
| 1457 | /* Test MT Call */ |
| 1458 | private 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] | 1459 | f_init_handler(pars); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1460 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
| 1461 | var MNCC_PDU mncc; |
| 1462 | var MgcpCommand mgcp_cmd; |
| 1463 | |
| 1464 | f_mt_call_start(cpars); |
| 1465 | |
| 1466 | /* MS->MSC: CALL CONFIRMED */ |
| 1467 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CALL_CONF(cpars.transaction_id))); |
| 1468 | |
| 1469 | MNCC.receive(tr_MNCC_CALL_CONF_ind(cpars.mncc_callref)); |
| 1470 | |
| 1471 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
| 1472 | cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 1473 | |
| 1474 | /* Detect if the received CRCX is a wildcarded CRCX request. If yes, |
| 1475 | * set an endpoint name that fits the pattern. If not, just use the |
| 1476 | * endpoint name from the request */ |
| 1477 | if (match(mgcp_cmd.line.ep, t_MGCP_EP_wildcard)) { |
| 1478 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
| 1479 | } else { |
| 1480 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
| 1481 | } |
| 1482 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1483 | /* Respond to CRCX with error */ |
| 1484 | var MgcpResponse mgcp_rsp := { |
| 1485 | line := { |
| 1486 | code := "542", |
| 1487 | trans_id := mgcp_cmd.line.trans_id, |
| 1488 | string := "FORCED_FAIL" |
| 1489 | }, |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1490 | sdp := omit |
| 1491 | } |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 1492 | var MgcpParameter mgcp_rsp_param := { |
| 1493 | code := "Z", |
| 1494 | val := cpars.mgcp_ep |
| 1495 | }; |
| 1496 | mgcp_rsp.params[0] := mgcp_rsp_param; |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1497 | MGCP.send(mgcp_rsp); |
| 1498 | |
| 1499 | timer T := 30.0; |
| 1500 | T.start; |
| 1501 | alt { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1502 | [] T.timeout { |
| 1503 | setverdict(fail, "Timeout waiting for channel release"); |
| 1504 | mtc.stop; |
| 1505 | } |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1506 | [] MNCC.receive { repeat; } |
| 1507 | [] GSUP.receive { repeat; } |
| 1508 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 1509 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
| 1510 | f_create_mgcp_delete_ep(cpars.mgcp_ep); |
| 1511 | repeat; |
| 1512 | } |
| 1513 | [] MGCP.receive { repeat; } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1514 | [] as_clear_cmd_compl_disc(); |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 1515 | [] as_optional_cc_rel(cpars); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1516 | } |
| 1517 | } |
| 1518 | testcase TC_mt_crcx_ran_reject() runs on MTC_CT { |
| 1519 | var BSC_ConnHdlr vc_conn; |
| 1520 | f_init(); |
| 1521 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1522 | 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] | 1523 | vc_conn.done; |
| 1524 | } |
| 1525 | |
| 1526 | |
| 1527 | /* Test MT Call T310 timer */ |
| 1528 | private 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] | 1529 | f_init_handler(pars, 200.0); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1530 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
| 1531 | var MNCC_PDU mncc; |
| 1532 | var MgcpCommand mgcp_cmd; |
| 1533 | |
| 1534 | f_mt_call_start(cpars); |
| 1535 | |
| 1536 | /* MS->MSC: CALL CONFIRMED */ |
| 1537 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CALL_CONF(cpars.transaction_id))); |
| 1538 | MNCC.receive(tr_MNCC_CALL_CONF_ind(cpars.mncc_callref)); |
| 1539 | |
| 1540 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
| 1541 | cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
| 1542 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
| 1543 | /* FIXME: Respond to CRCX */ |
| 1544 | |
| 1545 | /* old libosmocore T310 default timeout is 180s. so let's wait 190 */ |
| 1546 | timer T := 190.0; |
| 1547 | T.start; |
| 1548 | alt { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1549 | [] T.timeout { |
| 1550 | setverdict(fail, "Timeout waiting for T310"); |
| 1551 | mtc.stop; |
| 1552 | } |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1553 | [] MNCC.receive(tr_MNCC_DISC_ind(cpars.mncc_callref)) { |
| 1554 | MNCC.send(ts_MNCC_REL_req(cpars.mncc_callref, valueof(ts_MNCC_cause(23)))); |
| 1555 | } |
| 1556 | } |
| 1557 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_DISC(cpars.transaction_id))); |
| 1558 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))); |
| 1559 | /* FIXME: We're sending this with TIflag 0: allocated by sender, which is wrong */ |
| 1560 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_REL_COMPL(cpars.transaction_id))); |
| 1561 | |
| 1562 | alt { |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1563 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 1564 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
| 1565 | f_create_mgcp_delete_ep(cpars.mgcp_ep); |
| 1566 | repeat; |
| 1567 | } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1568 | [] as_clear_cmd_compl_disc(); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1569 | } |
| 1570 | } |
| 1571 | testcase TC_mt_t310() runs on MTC_CT { |
| 1572 | var BSC_ConnHdlr vc_conn; |
| 1573 | f_init(); |
| 1574 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1575 | vc_conn := f_start_handler(refers(f_tc_mt_t310), 32); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1576 | vc_conn.done; |
| 1577 | } |
| 1578 | |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1579 | /* Perform successful LU + MO call, then GSUP LocationCancel. Subscriber must be denied CM SERV */ |
| 1580 | private function f_tc_gsup_cancel(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1581 | f_init_handler(pars); |
| 1582 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1583 | cpars.bss_rtp_port := 1110; |
| 1584 | cpars.mgcp_connection_id_bss := '22222'H; |
| 1585 | cpars.mgcp_connection_id_mss := '33333'H; |
Daniel Willmann | 9b0235b | 2018-07-24 12:13:34 +0200 | [diff] [blame] | 1586 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1587 | |
| 1588 | /* Location Update to make subscriber known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1589 | f_perform_lu(); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1590 | |
| 1591 | /* First MO call should succeed */ |
| 1592 | f_mo_call(cpars); |
| 1593 | |
| 1594 | /* Cancel the subscriber in the VLR */ |
| 1595 | GSUP.send(ts_GSUP_CL_REQ(g_pars.imsi, OSMO_GSUP_CANCEL_TYPE_WITHDRAW)); |
| 1596 | alt { |
| 1597 | [] GSUP.receive(tr_GSUP_CL_RES(g_pars.imsi)) { } |
| 1598 | [] GSUP.receive(tr_GSUP_CL_ERR(g_pars.imsi)) { |
| 1599 | setverdict(fail, "Received GSUP Location Cancel Error"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1600 | mtc.stop; |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1601 | } |
| 1602 | } |
| 1603 | |
| 1604 | /* Follow-up transactions should fail */ |
| 1605 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 1606 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi)); |
| 1607 | f_bssap_compl_l3(l3_info); |
| 1608 | alt { |
| 1609 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)) { } |
| 1610 | [] BSSAP.receive { |
| 1611 | setverdict(fail, "Received unexpected BSSAP instead of CM SERV REJ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1612 | mtc.stop; |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1613 | } |
| 1614 | } |
Neels Hofmeyr | 0f7429a | 2019-03-07 22:28:41 +0100 | [diff] [blame] | 1615 | |
| 1616 | f_expect_clear(); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1617 | setverdict(pass); |
| 1618 | } |
| 1619 | testcase TC_gsup_cancel() runs on MTC_CT { |
| 1620 | var BSC_ConnHdlr vc_conn; |
| 1621 | f_init(); |
| 1622 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1623 | vc_conn := f_start_handler(refers(f_tc_gsup_cancel), 33); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1624 | vc_conn.done; |
| 1625 | } |
| 1626 | |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1627 | /* A5/1 only permitted on network side, and MS capable to do it */ |
| 1628 | private function f_tc_lu_imsi_auth_tmsi_encr_1_13(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1629 | pars.net.expect_auth := true; |
| 1630 | pars.net.expect_ciph := true; |
| 1631 | pars.net.kc_support := '02'O; /* A5/1 only */ |
| 1632 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1633 | f_perform_lu(); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1634 | } |
| 1635 | testcase TC_lu_imsi_auth_tmsi_encr_1_13() runs on MTC_CT { |
| 1636 | var BSC_ConnHdlr vc_conn; |
| 1637 | f_init(); |
| 1638 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1639 | f_vty_config(MSCVTY, "network", "encryption a5 1"); |
| 1640 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1641 | 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] | 1642 | vc_conn.done; |
| 1643 | } |
| 1644 | |
| 1645 | /* A5/3 only permitted on network side, and MS capable to do it */ |
| 1646 | private function f_tc_lu_imsi_auth_tmsi_encr_3_13(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1647 | pars.net.expect_auth := true; |
| 1648 | pars.net.expect_ciph := true; |
| 1649 | pars.net.kc_support := '08'O; /* A5/3 only */ |
| 1650 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1651 | f_perform_lu(); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1652 | } |
| 1653 | testcase TC_lu_imsi_auth_tmsi_encr_3_13() runs on MTC_CT { |
| 1654 | var BSC_ConnHdlr vc_conn; |
| 1655 | f_init(); |
| 1656 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1657 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1658 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1659 | 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] | 1660 | vc_conn.done; |
| 1661 | } |
| 1662 | |
| 1663 | /* A5/3 only permitted on network side, and MS with only A5/1 support */ |
| 1664 | private function f_tc_lu_imsi_auth_tmsi_encr_3_1(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1665 | pars.net.expect_auth := true; |
| 1666 | pars.net.expect_ciph := true; |
| 1667 | pars.net.kc_support := '08'O; /* A5/3 only */ |
| 1668 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 1669 | f_init_handler(pars, 15.0); |
| 1670 | |
| 1671 | /* cannot use f_perform_lu() as we expect a reject */ |
| 1672 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 1673 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1674 | f_bssap_compl_l3(l3_lu); |
Neels Hofmeyr | 29b8da0 | 2018-03-01 18:09:45 +0100 | [diff] [blame] | 1675 | if (pars.send_early_cm) { |
| 1676 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1677 | } else { |
| 1678 | pars.cm1.esind := '0'B; |
| 1679 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1680 | f_mm_auth(); |
| 1681 | alt { |
Daniel Willmann | 52918e5 | 2018-09-20 14:39:09 +0200 | [diff] [blame] | 1682 | [] BSSAP.receive(tr_BSSMAP_ClassmarkReq) { |
| 1683 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1684 | repeat; |
| 1685 | } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1686 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 1687 | f_expect_clear(); |
| 1688 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1689 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?,?)) { |
| 1690 | setverdict(fail, "CipherModeCommand despite no A5 intersection"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1691 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1692 | } |
| 1693 | [] BSSAP.receive { |
Harald Welte | 458fd37 | 2018-03-21 11:26:23 +0100 | [diff] [blame] | 1694 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1695 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1696 | } |
| 1697 | } |
| 1698 | setverdict(pass); |
| 1699 | } |
| 1700 | testcase TC_lu_imsi_auth_tmsi_encr_3_1() runs on MTC_CT { |
| 1701 | var BSC_ConnHdlr vc_conn; |
| 1702 | f_init(); |
| 1703 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1704 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1705 | |
Neels Hofmeyr | 29b8da0 | 2018-03-01 18:09:45 +0100 | [diff] [blame] | 1706 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_3_1), 360); |
| 1707 | vc_conn.done; |
| 1708 | } |
| 1709 | testcase TC_lu_imsi_auth_tmsi_encr_3_1_no_cm() runs on MTC_CT { |
| 1710 | var BSC_ConnHdlrPars pars; |
| 1711 | var BSC_ConnHdlr vc_conn; |
| 1712 | f_init(); |
| 1713 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1714 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1715 | |
| 1716 | pars := f_init_pars(361); |
| 1717 | pars.send_early_cm := false; |
| 1718 | 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] | 1719 | vc_conn.done; |
| 1720 | } |
Neels Hofmeyr | 1b3c6e3 | 2018-03-01 17:52:21 +0100 | [diff] [blame] | 1721 | testcase TC_lu_imsi_auth_tmsi_encr_3_1_log_msc_debug() runs on MTC_CT { |
| 1722 | var BSC_ConnHdlr vc_conn; |
| 1723 | f_init(); |
| 1724 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1725 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1726 | |
| 1727 | /* Make sure the MSC category is on DEBUG level to trigger the log |
| 1728 | * message that is reported in OS#2947 to trigger the segfault */ |
| 1729 | f_vty_config(MSCVTY, "log stderr", "logging level msc debug"); |
| 1730 | |
| 1731 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_3_1), 362); |
| 1732 | vc_conn.done; |
| 1733 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1734 | |
| 1735 | /* A5/1 + A5/3 only permitted on network side, and MS with only A5/2 support */ |
| 1736 | private function f_tc_lu_imsi_auth_tmsi_encr_13_2(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1737 | pars.net.expect_auth := true; |
| 1738 | pars.net.expect_ciph := true; |
| 1739 | pars.net.kc_support := '0A'O; /* A5/1 + A5/3 */ |
| 1740 | pars.cm1.a5_1 := '1'B; |
| 1741 | pars.cm2.a5_1 := '1'B; |
| 1742 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 1743 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '1'B; |
| 1744 | f_init_handler(pars, 15.0); |
| 1745 | |
| 1746 | /* cannot use f_perform_lu() as we expect a reject */ |
| 1747 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 1748 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1749 | f_bssap_compl_l3(l3_lu); |
| 1750 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1751 | f_mm_auth(); |
| 1752 | alt { |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1753 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 1754 | f_expect_clear(); |
| 1755 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1756 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?,?)) { |
| 1757 | setverdict(fail, "CipherModeCommand despite no A5 intersection"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1758 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1759 | } |
| 1760 | [] BSSAP.receive { |
Harald Welte | 458fd37 | 2018-03-21 11:26:23 +0100 | [diff] [blame] | 1761 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1762 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1763 | } |
| 1764 | } |
| 1765 | setverdict(pass); |
| 1766 | } |
| 1767 | testcase TC_lu_imsi_auth_tmsi_encr_13_2() runs on MTC_CT { |
| 1768 | var BSC_ConnHdlr vc_conn; |
| 1769 | f_init(); |
| 1770 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1771 | f_vty_config(MSCVTY, "network", "encryption a5 1 3"); |
| 1772 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1773 | 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] | 1774 | vc_conn.done; |
| 1775 | } |
| 1776 | |
| 1777 | /* A5/0 + A5/1 + A5/3 only permitted on network side, and MS with only A5/2 support */ |
| 1778 | private function f_tc_lu_imsi_auth_tmsi_encr_013_2(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1779 | pars.net.expect_auth := true; |
| 1780 | pars.net.expect_ciph := true; |
| 1781 | pars.net.kc_support := '0B'O; /* A5/1 + A5/3 */ |
| 1782 | pars.cm1.a5_1 := '1'B; |
| 1783 | pars.cm2.a5_1 := '1'B; |
| 1784 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 1785 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '1'B; |
| 1786 | f_init_handler(pars, 15.0); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1787 | f_perform_lu(); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1788 | } |
| 1789 | testcase TC_lu_imsi_auth_tmsi_encr_013_2() runs on MTC_CT { |
| 1790 | var BSC_ConnHdlr vc_conn; |
| 1791 | f_init(); |
| 1792 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1793 | f_vty_config(MSCVTY, "network", "encryption a5 0 1 3"); |
| 1794 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1795 | 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] | 1796 | vc_conn.done; |
| 1797 | } |
| 1798 | |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 1799 | /* LU followed by MT call (including paging) */ |
| 1800 | private function f_tc_lu_and_mt_call(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1801 | f_init_handler(pars); |
Stefan Sperling | 26d57be | 2018-11-12 17:03:26 +0100 | [diff] [blame] | 1802 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 1803 | cpars.bss_rtp_port := 1110; |
| 1804 | cpars.mgcp_connection_id_bss := '10004'H; |
| 1805 | cpars.mgcp_connection_id_mss := '10005'H; |
| 1806 | |
Philipp Maier | 4b2692d | 2018-03-14 16:37:48 +0100 | [diff] [blame] | 1807 | /* Note: This is an optional parameter. When the call-agent (MSC) does |
| 1808 | * supply a full endpoint name this setting will be overwritten. */ |
| 1809 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
| 1810 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1811 | f_perform_lu(); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 1812 | f_mt_call(cpars); |
| 1813 | } |
| 1814 | testcase TC_lu_and_mt_call() runs on MTC_CT { |
| 1815 | var BSC_ConnHdlr vc_conn; |
| 1816 | f_init(); |
| 1817 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1818 | 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] | 1819 | vc_conn.done; |
| 1820 | } |
| 1821 | |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1822 | /* Test MO Call SETUP with DTMF */ |
| 1823 | private function f_tc_mo_setup_dtmf_dup(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1824 | f_init_handler(pars); |
| 1825 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1826 | cpars.bss_rtp_port := 1110; |
| 1827 | cpars.mgcp_connection_id_bss := '22222'H; |
| 1828 | cpars.mgcp_connection_id_mss := '33333'H; |
| 1829 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1830 | f_perform_lu(); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1831 | f_mo_seq_dtmf_dup(cpars); |
| 1832 | } |
| 1833 | testcase TC_mo_setup_and_dtmf_dup() runs on MTC_CT { |
| 1834 | var BSC_ConnHdlr vc_conn; |
| 1835 | f_init(); |
| 1836 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1837 | 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] | 1838 | vc_conn.done; |
| 1839 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1840 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 1841 | testcase TC_cr_before_reset() runs on MTC_CT { |
| 1842 | timer T := 4.0; |
| 1843 | var boolean reset_ack_seen := false; |
| 1844 | f_init_bssap_direct(); |
| 1845 | |
Daniel Willmann | 42d1d5b | 2018-08-07 15:18:41 +0200 | [diff] [blame] | 1846 | f_bssap_start(g_bssap[0]); |
| 1847 | |
Daniel Willmann | e801896 | 2018-08-21 14:18:00 +0200 | [diff] [blame] | 1848 | f_sleep(3.0); |
| 1849 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 1850 | /* Make a blind connection attemt, to trigger the deadlock condition */ |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 1851 | 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] | 1852 | |
| 1853 | /* Send a BSSMAP reset */ |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 1854 | 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] | 1855 | T.start |
| 1856 | alt { |
| 1857 | [] BSSAP_DIRECT.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_ResetAck)) { |
| 1858 | reset_ack_seen := true; |
| 1859 | repeat; |
| 1860 | } |
| 1861 | |
| 1862 | /* Acknowledge MSC sided reset requests */ |
| 1863 | [] BSSAP_DIRECT.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) { |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 1864 | 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] | 1865 | repeat; |
| 1866 | } |
| 1867 | |
| 1868 | /* Ignore all other messages (e.g CR from the connection request) */ |
| 1869 | [] BSSAP_DIRECT.receive { repeat } |
| 1870 | |
| 1871 | /* If we got no BSSMAP RESET ACK back, then the MSC entered the |
| 1872 | * deadlock situation. The MSC is then unable to respond to any |
| 1873 | * further BSSMAP RESET or any other sort of traffic. */ |
| 1874 | [reset_ack_seen == true] T.timeout { setverdict(pass) } |
| 1875 | [reset_ack_seen == false] T.timeout { |
| 1876 | setverdict(fail, "no BSSMAP RESET ACK seen!"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1877 | mtc.stop; |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 1878 | } |
| 1879 | } |
| 1880 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1881 | |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 1882 | /* Test MO Call with no response to RAN-side CRCX or DTAP Release */ |
| 1883 | private function f_tc_mo_release_timeout(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1884 | f_init_handler(pars); |
| 1885 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1886 | var MNCC_PDU mncc; |
| 1887 | var MgcpCommand mgcp_cmd; |
| 1888 | |
| 1889 | f_perform_lu(); |
| 1890 | |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1891 | f_establish_fully(); |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 1892 | f_create_mncc_expect(hex2str(cpars.called_party)); |
| 1893 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1894 | |
| 1895 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_SETUP(cpars.transaction_id, cpars.called_party))); |
| 1896 | MNCC.receive(tr_MNCC_SETUP_ind(?, tr_MNCC_number(hex2str(cpars.called_party)))) -> value mncc; |
| 1897 | cpars.mncc_callref := mncc.u.signal.callref; |
| 1898 | MNCC.send(ts_MNCC_CALL_PROC_req(cpars.mncc_callref, cpars.mncc_bearer_cap)); |
| 1899 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CALL_PROC(cpars.transaction_id))); |
| 1900 | |
| 1901 | /* Drop CRCX */ |
| 1902 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
| 1903 | |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 1904 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 1905 | |
| 1906 | f_expect_clear(60.0); |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 1907 | |
| 1908 | deactivate(ccrel); |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 1909 | } |
| 1910 | testcase TC_mo_release_timeout() runs on MTC_CT { |
| 1911 | var BSC_ConnHdlr vc_conn; |
| 1912 | f_init(); |
| 1913 | |
| 1914 | vc_conn := f_start_handler(refers(f_tc_mo_release_timeout), 40); |
| 1915 | vc_conn.done; |
| 1916 | } |
| 1917 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1918 | |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 1919 | /* LU followed by MT call (including paging) */ |
| 1920 | private function f_tc_lu_and_mt_call_no_dlcx_resp(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1921 | f_init_handler(pars); |
Stefan Sperling | 26d57be | 2018-11-12 17:03:26 +0100 | [diff] [blame] | 1922 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 1923 | cpars.bss_rtp_port := 1110; |
| 1924 | cpars.mgcp_connection_id_bss := '10004'H; |
| 1925 | cpars.mgcp_connection_id_mss := '10005'H; |
| 1926 | |
| 1927 | /* Note: This is an optional parameter. When the call-agent (MSC) does |
| 1928 | * supply a full endpoint name this setting will be overwritten. */ |
| 1929 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
| 1930 | |
| 1931 | /* Intentionally disable the CRCX response */ |
| 1932 | cpars.mgw_drop_dlcx := true; |
| 1933 | |
| 1934 | /* Perform location update and call */ |
| 1935 | f_perform_lu(); |
| 1936 | f_mt_call(cpars); |
| 1937 | } |
| 1938 | testcase TC_lu_and_mt_call_no_dlcx_resp() runs on MTC_CT { |
| 1939 | var BSC_ConnHdlr vc_conn; |
| 1940 | f_init(); |
| 1941 | |
| 1942 | /* Perform an almost normal looking locationupdate + mt-call, but do |
| 1943 | * not respond to the DLCX at the end of the call */ |
| 1944 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_call_no_dlcx_resp), 41); |
| 1945 | vc_conn.done; |
| 1946 | |
| 1947 | /* Wait a guard period until the MGCP layer in the MSC times out, |
| 1948 | * if the MSC is vulnerable to the use-after-free situation that is |
| 1949 | * fixed by I78f1b6a9149488a4ad3f120c1e190a83c07d4b89 then it should |
| 1950 | * segfault now */ |
| 1951 | f_sleep(6.0); |
| 1952 | |
| 1953 | /* Run the init procedures once more. If the MSC has crashed, this |
| 1954 | * this will fail */ |
| 1955 | f_init(); |
| 1956 | } |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1957 | |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 1958 | /* Two BSSMAP resets from two different BSCs */ |
| 1959 | testcase TC_reset_two() runs on MTC_CT { |
| 1960 | var BSC_ConnHdlr vc_conn; |
| 1961 | f_init(2); |
| 1962 | f_sleep(2.0); |
| 1963 | setverdict(pass); |
| 1964 | } |
| 1965 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 1966 | /*********************************************************************** |
| 1967 | * SMS Testing |
| 1968 | ***********************************************************************/ |
| 1969 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1970 | /* LU followed by MO SMS */ |
| 1971 | private function f_tc_lu_and_mo_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1972 | var SmsParameters spars := valueof(t_SmsPars); |
| 1973 | |
| 1974 | f_init_handler(pars); |
| 1975 | |
| 1976 | /* Perform location update and call */ |
| 1977 | f_perform_lu(); |
| 1978 | |
| 1979 | f_establish_fully(EST_TYPE_MO_SMS); |
| 1980 | |
| 1981 | //spars.exp_rp_err := 96; /* invalid mandatory information */ |
| 1982 | f_mo_sms(spars); |
| 1983 | |
| 1984 | f_expect_clear(); |
| 1985 | } |
| 1986 | testcase TC_lu_and_mo_sms() runs on MTC_CT { |
| 1987 | var BSC_ConnHdlr vc_conn; |
| 1988 | f_init(); |
| 1989 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_sms), 42); |
| 1990 | vc_conn.done; |
| 1991 | } |
| 1992 | |
| 1993 | private function f_vty_sms_send(charstring imsi, charstring msisdn, charstring text) |
Neels Hofmeyr | 6aaeccf | 2019-03-06 15:32:26 +0100 | [diff] [blame] | 1994 | runs on BSC_ConnHdlr { |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1995 | f_vty_transceive(MSCVTY, "subscriber imsi "&imsi&" sms sender msisdn "&msisdn&" send "&text); |
| 1996 | } |
| 1997 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 1998 | /* Remove still pending SMS */ |
| 1999 | private function f_vty_sms_clear(charstring imsi) |
| 2000 | runs on BSC_ConnHdlr { |
| 2001 | f_vty_transceive(MSCVTY, "subscriber imsi " & imsi & " sms delete-all"); |
| 2002 | f_vty_transceive(MSCVTY, "sms-queue clear"); |
| 2003 | } |
| 2004 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2005 | /* LU followed by MT SMS */ |
| 2006 | private function f_tc_lu_and_mt_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2007 | var SmsParameters spars := valueof(t_SmsPars); |
| 2008 | var OCT4 tmsi; |
| 2009 | |
| 2010 | f_init_handler(pars); |
| 2011 | |
| 2012 | /* Perform location update and call */ |
| 2013 | f_perform_lu(); |
| 2014 | |
| 2015 | /* register an 'expect' for given IMSI (+TMSI) */ |
| 2016 | if (isvalue(g_pars.tmsi)) { |
| 2017 | tmsi := g_pars.tmsi; |
| 2018 | } else { |
| 2019 | tmsi := 'FFFFFFFF'O; |
| 2020 | } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 2021 | f_ran_register_imsi(g_pars.imsi, tmsi); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2022 | |
Neels Hofmeyr | 6aaeccf | 2019-03-06 15:32:26 +0100 | [diff] [blame] | 2023 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2024 | |
| 2025 | /* MSC->BSC: expect PAGING from MSC */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 2026 | f_expect_paging(); |
| 2027 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2028 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 2029 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2030 | |
| 2031 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 2032 | f_mt_sms(spars); |
| 2033 | |
| 2034 | f_expect_clear(); |
| 2035 | } |
| 2036 | testcase TC_lu_and_mt_sms() runs on MTC_CT { |
| 2037 | var BSC_ConnHdlrPars pars; |
| 2038 | var BSC_ConnHdlr vc_conn; |
| 2039 | f_init(); |
| 2040 | pars := f_init_pars(43); |
| 2041 | 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] | 2042 | vc_conn.done; |
| 2043 | } |
| 2044 | |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2045 | /* Paging for MT SMS but no response */ |
| 2046 | private function f_tc_lu_and_mt_sms_paging_and_nothing(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2047 | var SmsParameters spars := valueof(t_SmsPars); |
| 2048 | var OCT4 tmsi; |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2049 | f_init_handler(pars, 150.0); |
| 2050 | |
| 2051 | /* Perform location update */ |
| 2052 | f_perform_lu(); |
| 2053 | |
| 2054 | /* register an 'expect' for given IMSI (+TMSI) */ |
| 2055 | if (isvalue(g_pars.tmsi)) { |
| 2056 | tmsi := g_pars.tmsi; |
| 2057 | } else { |
| 2058 | tmsi := 'FFFFFFFF'O; |
| 2059 | } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 2060 | f_ran_register_imsi(g_pars.imsi, tmsi); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2061 | |
Neels Hofmeyr | 6aaeccf | 2019-03-06 15:32:26 +0100 | [diff] [blame] | 2062 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 2063 | |
Neels Hofmeyr | 1623774 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 2064 | /* Expect the MSC to page exactly once */ |
| 2065 | BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { }; |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2066 | |
| 2067 | /* Wait some time to make sure the MSC is not delivering any further |
| 2068 | * paging messages or anything else that could be unexpected. */ |
| 2069 | timer T := 20.0; |
| 2070 | T.start |
| 2071 | alt { |
| 2072 | [] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) |
| 2073 | { |
| 2074 | setverdict(fail, "paging seems not to stop!"); |
| 2075 | mtc.stop; |
| 2076 | } |
| 2077 | [] BSSAP.receive { |
| 2078 | setverdict(fail, "unexpected BSSAP message received"); |
| 2079 | self.stop; |
| 2080 | } |
| 2081 | [] T.timeout { |
| 2082 | setverdict(pass); |
| 2083 | } |
| 2084 | } |
| 2085 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 2086 | f_vty_sms_clear(hex2str(g_pars.imsi)); |
| 2087 | |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2088 | setverdict(pass); |
| 2089 | } |
| 2090 | testcase TC_lu_and_mt_sms_paging_and_nothing() runs on MTC_CT { |
| 2091 | var BSC_ConnHdlrPars pars; |
| 2092 | var BSC_ConnHdlr vc_conn; |
| 2093 | f_init(); |
Philipp Maier | a99ad26 | 2019-01-22 15:35:42 +0100 | [diff] [blame] | 2094 | pars := f_init_pars(1843); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 2095 | 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] | 2096 | vc_conn.done; |
| 2097 | } |
| 2098 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2099 | /* mobile originated SMS from MS/BTS/BSC side to SMPP */ |
| 2100 | private function f_tc_smpp_mo_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2101 | var SmsParameters spars := valueof(t_SmsPars); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2102 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2103 | f_init_handler(pars); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2104 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2105 | /* Perform location update so IMSI is known + registered in MSC/VLR */ |
| 2106 | f_perform_lu(); |
| 2107 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2108 | |
| 2109 | f_mo_sms(spars); |
| 2110 | |
| 2111 | var SMPP_PDU smpp; |
| 2112 | var template SMPP_PDU tr_smpp := tr_SMPP(c_SMPP_command_id_deliver_sm, ESME_ROK); |
| 2113 | tr_smpp.body.deliver_sm := { |
| 2114 | service_type := "CMT", |
| 2115 | source_addr_ton := network_specific, |
| 2116 | source_addr_npi := isdn, |
| 2117 | source_addr := hex2str(pars.msisdn), |
| 2118 | dest_addr_ton := f_sm_ton_from_gsm(spars.tp.da.tP_DA_NoPad.tP_TypeOfNumber), |
| 2119 | dest_addr_npi := f_sm_npi_from_gsm(spars.tp.da.tP_DA_NoPad.tP_NumberingPlanID), |
| 2120 | destination_addr := hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue), |
| 2121 | esm_class := '00000001'B, |
| 2122 | protocol_id := 0, |
| 2123 | priority_flag := 0, |
| 2124 | schedule_delivery_time := "", |
| 2125 | replace_if_present := 0, |
| 2126 | data_coding := '00000001'B, |
| 2127 | sm_default_msg_id := 0, |
| 2128 | sm_length := ?, |
| 2129 | short_message := spars.tp.ud, |
| 2130 | opt_pars := { |
| 2131 | { |
| 2132 | tag := user_message_reference, |
| 2133 | len := 2, |
| 2134 | opt_value := { |
| 2135 | int2_val := oct2int(spars.tp.msg_ref) |
| 2136 | } |
| 2137 | } |
| 2138 | } |
| 2139 | }; |
| 2140 | alt { |
| 2141 | [] SMPP.receive(tr_smpp) -> value smpp { |
| 2142 | SMPP.send(ts_SMPP_DELIVER_SM_resp(ESME_ROK, smpp.header.seq_num)); |
| 2143 | } |
| 2144 | [] SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)) { repeat; } |
| 2145 | } |
| 2146 | |
| 2147 | f_expect_clear(); |
| 2148 | } |
| 2149 | testcase TC_smpp_mo_sms() runs on MTC_CT { |
| 2150 | var BSC_ConnHdlr vc_conn; |
| 2151 | f_init(); |
| 2152 | f_vty_config2(MSCVTY, { "smpp", "esme msc_tester"}, "default-route"); |
| 2153 | vc_conn := f_start_handler(refers(f_tc_smpp_mo_sms), 44); |
| 2154 | vc_conn.done; |
| 2155 | f_vty_config2(MSCVTY, { "smpp", "esme msc_tester"}, "no default-route"); |
| 2156 | } |
| 2157 | |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 2158 | /* Test MO-SMS from MS/BTS/BSC towards HLR (via GSUP) */ |
| 2159 | private function f_tc_gsup_mo_sms(charstring id, BSC_ConnHdlrPars pars) |
| 2160 | runs on BSC_ConnHdlr { |
| 2161 | var SmsParameters spars := valueof(t_SmsPars); |
| 2162 | var GSUP_PDU gsup_msg_rx; |
| 2163 | var octetstring sm_tpdu; |
| 2164 | |
| 2165 | f_init_handler(pars); |
| 2166 | |
| 2167 | /* We need to inspect GSUP activity */ |
| 2168 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2169 | |
| 2170 | /* Perform location update */ |
| 2171 | f_perform_lu(); |
| 2172 | |
| 2173 | /* Send CM Service Request for SMS */ |
| 2174 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2175 | |
| 2176 | /* Prepare expected SM-RP-UI (SM TPDU) */ |
| 2177 | enc_TPDU_RP_DATA_MS_SGSN_fast( |
| 2178 | valueof(ts_SMS_SUBMIT(spars.tp.msg_ref, |
| 2179 | spars.tp.da, spars.tp.pid, spars.tp.dcs, |
| 2180 | spars.tp.udl, spars.tp.ud)), |
| 2181 | sm_tpdu); |
| 2182 | |
| 2183 | var template GSUP_PDU mo_forwardSM := tr_GSUP_MO_FORWARD_SM_REQ( |
| 2184 | imsi := g_pars.imsi, |
| 2185 | sm_rp_mr := spars.rp.msg_ref, |
| 2186 | /* FIXME: extract SM-RP-DA from spars.rp.dest */ |
| 2187 | sm_rp_da := tr_GSUP_SM_RP_DA_SMSC_ADDR(?), |
| 2188 | /* FIXME: MSISDN coding troubles */ |
| 2189 | sm_rp_oa := tr_GSUP_SM_RP_OA_MSISDN(?), |
| 2190 | /* TODO: can we use decmatch here? */ |
| 2191 | sm_rp_ui := sm_tpdu |
| 2192 | ); |
| 2193 | |
| 2194 | /* Submit an SMS on DTAP and expect MO-forwardSM-Req on GSUP */ |
| 2195 | f_mo_sms_submit(spars); |
| 2196 | alt { |
| 2197 | [] GSUP.receive(mo_forwardSM) -> value gsup_msg_rx { |
| 2198 | log("RX MO-forwardSM-Req"); |
| 2199 | log(gsup_msg_rx); |
| 2200 | setverdict(pass); |
| 2201 | } |
| 2202 | [] GSUP.receive { |
| 2203 | log("RX unexpected GSUP message"); |
| 2204 | setverdict(fail); |
| 2205 | mtc.stop; |
| 2206 | } |
| 2207 | } |
| 2208 | |
| 2209 | /* Trigger RP-ACK by sending MO-forwardSM-Res */ |
| 2210 | GSUP.send(valueof(ts_GSUP_MO_FORWARD_SM_RES( |
| 2211 | imsi := g_pars.imsi, |
| 2212 | sm_rp_mr := spars.rp.msg_ref))); |
| 2213 | /* Expect RP-ACK on DTAP */ |
| 2214 | f_mo_sms_wait_rp_ack(spars); |
| 2215 | |
| 2216 | f_expect_clear(); |
| 2217 | } |
| 2218 | testcase TC_gsup_mo_sms() runs on MTC_CT { |
| 2219 | var BSC_ConnHdlr vc_conn; |
| 2220 | f_init(); |
| 2221 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2222 | vc_conn := f_start_handler(refers(f_tc_gsup_mo_sms), 88); |
| 2223 | vc_conn.done; |
| 2224 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2225 | } |
| 2226 | |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 2227 | /* Test MO-SMMA from MS/BTS/BSC towards HLR (via GSUP) */ |
| 2228 | private function f_tc_gsup_mo_smma(charstring id, BSC_ConnHdlrPars pars) |
| 2229 | runs on BSC_ConnHdlr { |
| 2230 | var SmsParameters spars := valueof(t_SmsPars); |
| 2231 | var GSUP_PDU gsup_msg_rx; |
| 2232 | |
| 2233 | f_init_handler(pars); |
| 2234 | |
| 2235 | /* We need to inspect GSUP activity */ |
| 2236 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2237 | |
| 2238 | /* Perform location update */ |
| 2239 | f_perform_lu(); |
| 2240 | |
| 2241 | /* Send CM Service Request for SMS */ |
| 2242 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2243 | |
| 2244 | var template GSUP_PDU mo_ReadyForSM := tr_GSUP_MO_READY_FOR_SM_REQ( |
| 2245 | imsi := g_pars.imsi, |
| 2246 | sm_rp_mr := spars.rp.msg_ref, |
| 2247 | sm_alert_rsn := GSUP_SM_ALERT_RSN_TYPE_MEM_AVAIL |
| 2248 | ); |
| 2249 | |
| 2250 | /* Submit an SMS on DTAP and expect MO-forwardSM-Req on GSUP */ |
| 2251 | f_mo_smma(spars); |
| 2252 | alt { |
| 2253 | [] GSUP.receive(mo_ReadyForSM) -> value gsup_msg_rx { |
| 2254 | log("RX MO-ReadyForSM-Req"); |
| 2255 | log(gsup_msg_rx); |
| 2256 | setverdict(pass); |
| 2257 | } |
| 2258 | [] GSUP.receive { |
| 2259 | log("RX unexpected GSUP message"); |
| 2260 | setverdict(fail); |
| 2261 | mtc.stop; |
| 2262 | } |
| 2263 | } |
| 2264 | |
| 2265 | /* Trigger RP-ACK by sending MO-forwardSM-Res */ |
| 2266 | GSUP.send(valueof(ts_GSUP_MO_READY_FOR_SM_RES( |
| 2267 | imsi := g_pars.imsi, |
| 2268 | sm_rp_mr := spars.rp.msg_ref))); |
| 2269 | /* Expect RP-ACK on DTAP */ |
| 2270 | f_mo_sms_wait_rp_ack(spars); |
| 2271 | |
| 2272 | f_expect_clear(); |
| 2273 | } |
| 2274 | testcase TC_gsup_mo_smma() runs on MTC_CT { |
| 2275 | var BSC_ConnHdlr vc_conn; |
| 2276 | f_init(); |
| 2277 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2278 | vc_conn := f_start_handler(refers(f_tc_gsup_mo_smma), 89); |
| 2279 | vc_conn.done; |
| 2280 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2281 | } |
| 2282 | |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2283 | /* Helper for sending MT SMS over GSUP */ |
| 2284 | private function f_gsup_forwardSM_req(SmsParameters spars, OCT1 mms := '00'O) |
| 2285 | runs on BSC_ConnHdlr { |
| 2286 | GSUP.send(ts_GSUP_MT_FORWARD_SM_REQ( |
| 2287 | imsi := g_pars.imsi, |
| 2288 | /* NOTE: MSC should assign RP-MR itself */ |
| 2289 | sm_rp_mr := 'FF'O, |
| 2290 | /* FIXME: extract SM-RP-DA from spars.rp.dest */ |
| 2291 | /* TODO: fix encoding of ts_GSUP_SM_RP_DA_IMSI */ |
| 2292 | sm_rp_da := valueof(ts_GSUP_SM_RP_DA_MSISDN(g_pars.msisdn)), |
| 2293 | sm_rp_oa := valueof(ts_GSUP_SM_RP_OA_SMSC_ADDR(g_pars.msisdn)), |
| 2294 | /* Encoded SMS TPDU (taken from Wireshark) |
| 2295 | * FIXME: we should encode spars somehow */ |
| 2296 | sm_rp_ui := '00068021436500008111328130858200'O, |
| 2297 | sm_rp_mms := mms |
| 2298 | )); |
| 2299 | } |
| 2300 | |
| 2301 | /* Test successful MT-SMS (RP-ACK) over GSUP */ |
| 2302 | private function f_tc_gsup_mt_sms_ack(charstring id, BSC_ConnHdlrPars pars) |
| 2303 | runs on BSC_ConnHdlr { |
| 2304 | var SmsParameters spars := valueof(t_SmsPars); |
| 2305 | |
| 2306 | f_init_handler(pars); |
| 2307 | |
| 2308 | /* We need to inspect GSUP activity */ |
| 2309 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2310 | |
| 2311 | /* Perform location update */ |
| 2312 | f_perform_lu(); |
| 2313 | |
| 2314 | /* Register an 'expect' for given IMSI (+TMSI) */ |
| 2315 | if (isvalue(g_pars.tmsi)) { |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 2316 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2317 | } else { |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 2318 | f_ran_register_imsi(g_pars.imsi, 'FFFFFFFF'O); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2319 | } |
| 2320 | |
| 2321 | var template GSUP_PDU mt_forwardSM_res := tr_GSUP_MT_FORWARD_SM_RES( |
| 2322 | imsi := g_pars.imsi, |
| 2323 | /* NOTE: MSC should assign RP-MR itself */ |
| 2324 | sm_rp_mr := ? |
| 2325 | ); |
| 2326 | |
| 2327 | /* Submit a MT SMS on GSUP */ |
| 2328 | f_gsup_forwardSM_req(spars); |
| 2329 | |
| 2330 | /* Expect Paging Request and Establish DTAP / BSSAP / SCCP connection */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 2331 | f_expect_paging(); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2332 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2333 | |
| 2334 | /* Wait for MT SMS on DTAP */ |
| 2335 | f_mt_sms_expect(spars); |
| 2336 | |
| 2337 | /* Send RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 2338 | f_mt_sms_send_rp_ack(spars); |
| 2339 | alt { |
| 2340 | [] GSUP.receive(mt_forwardSM_res) { |
| 2341 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 2342 | setverdict(pass); |
| 2343 | } |
| 2344 | [] GSUP.receive { |
| 2345 | log("RX unexpected GSUP message"); |
| 2346 | setverdict(fail); |
| 2347 | mtc.stop; |
| 2348 | } |
| 2349 | } |
| 2350 | |
| 2351 | f_expect_clear(); |
| 2352 | } |
| 2353 | testcase TC_gsup_mt_sms_ack() runs on MTC_CT { |
| 2354 | var BSC_ConnHdlrPars pars; |
| 2355 | var BSC_ConnHdlr vc_conn; |
| 2356 | f_init(); |
| 2357 | pars := f_init_pars(90); |
| 2358 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2359 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_sms_ack), pars); |
| 2360 | vc_conn.done; |
| 2361 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2362 | } |
| 2363 | |
| 2364 | /* Test rejected MT-SMS (RP-ERROR) over GSUP */ |
| 2365 | private function f_tc_gsup_mt_sms_err(charstring id, BSC_ConnHdlrPars pars) |
| 2366 | runs on BSC_ConnHdlr { |
| 2367 | var SmsParameters spars := valueof(t_SmsPars); |
| 2368 | var OCT1 sm_rp_cause := '78'O; /* dummy RP-Cause value */ |
| 2369 | |
| 2370 | f_init_handler(pars); |
| 2371 | |
| 2372 | /* We need to inspect GSUP activity */ |
| 2373 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2374 | |
| 2375 | /* Perform location update */ |
| 2376 | f_perform_lu(); |
| 2377 | |
| 2378 | /* Register an 'expect' for given IMSI (+TMSI) */ |
| 2379 | if (isvalue(g_pars.tmsi)) { |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 2380 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2381 | } else { |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 2382 | f_ran_register_imsi(g_pars.imsi, 'FFFFFFFF'O); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2383 | } |
| 2384 | |
| 2385 | var template GSUP_PDU mt_forwardSM_err := tr_GSUP_MT_FORWARD_SM_ERR( |
| 2386 | imsi := g_pars.imsi, |
| 2387 | /* NOTE: MSC should assign RP-MR itself */ |
| 2388 | sm_rp_mr := ?, |
| 2389 | sm_rp_cause := sm_rp_cause |
| 2390 | ); |
| 2391 | |
| 2392 | /* Submit a MT SMS on GSUP */ |
| 2393 | f_gsup_forwardSM_req(spars); |
| 2394 | |
| 2395 | /* Expect Paging Request and Establish DTAP / BSSAP / SCCP connection */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 2396 | f_expect_paging(); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 2397 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2398 | |
| 2399 | /* Wait for MT SMS on DTAP */ |
| 2400 | f_mt_sms_expect(spars); |
| 2401 | |
| 2402 | /* Send RP-ERROR and expect MT-forwardSM-Err on GSUP */ |
| 2403 | f_mt_sms_send_rp_error(spars, oct2int(sm_rp_cause)); |
| 2404 | alt { |
| 2405 | [] GSUP.receive(mt_forwardSM_err) { |
| 2406 | log("RX MT-forwardSM-Err (RP-ERROR)"); |
| 2407 | setverdict(pass); |
| 2408 | mtc.stop; |
| 2409 | } |
| 2410 | [] GSUP.receive { |
| 2411 | log("RX unexpected GSUP message"); |
| 2412 | setverdict(fail); |
| 2413 | mtc.stop; |
| 2414 | } |
| 2415 | } |
| 2416 | |
| 2417 | f_expect_clear(); |
| 2418 | } |
| 2419 | testcase TC_gsup_mt_sms_err() runs on MTC_CT { |
| 2420 | var BSC_ConnHdlrPars pars; |
| 2421 | var BSC_ConnHdlr vc_conn; |
| 2422 | f_init(); |
| 2423 | pars := f_init_pars(91); |
| 2424 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2425 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_sms_err), pars); |
| 2426 | vc_conn.done; |
| 2427 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2428 | } |
| 2429 | |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 2430 | /* Test SM-RP-MR assignment for MT-SMS over GSUP */ |
| 2431 | private function f_tc_gsup_mt_sms_rp_mr(charstring id, BSC_ConnHdlrPars pars) |
| 2432 | runs on BSC_ConnHdlr { |
| 2433 | var SmsParameters spars1 := valueof(t_SmsPars); /* 1st SMS */ |
| 2434 | var SmsParameters spars2 := valueof(t_SmsPars); /* 2nd SMS */ |
| 2435 | |
| 2436 | f_init_handler(pars); |
| 2437 | |
| 2438 | /* We need to inspect GSUP activity */ |
| 2439 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2440 | |
| 2441 | /* Perform location update */ |
| 2442 | f_perform_lu(); |
| 2443 | |
| 2444 | /* Register an 'expect' for given IMSI (+TMSI) */ |
| 2445 | if (isvalue(g_pars.tmsi)) { |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 2446 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 2447 | } else { |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 2448 | f_ran_register_imsi(g_pars.imsi, 'FFFFFFFF'O); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 2449 | } |
| 2450 | |
| 2451 | /* Submit the 1st MT SMS on GSUP */ |
| 2452 | log("TX MT-forwardSM-Req for the 1st SMS"); |
| 2453 | f_gsup_forwardSM_req(spars1); |
| 2454 | |
| 2455 | /* Expect Paging Request and Establish DTAP / BSSAP / SCCP connection */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 2456 | f_expect_paging(); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 2457 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2458 | |
| 2459 | /* Wait for 1st MT SMS on DTAP */ |
| 2460 | f_mt_sms_expect(spars1); |
| 2461 | log("RX the 1st SMS on DTAP, DTAP TID is ", spars1.tid, |
| 2462 | ", SM-RP-MR is ", spars1.rp.msg_ref); |
| 2463 | |
| 2464 | /* Submit the 2nd MT SMS on GSUP */ |
| 2465 | log("TX MT-forwardSM-Req for the 2nd SMS"); |
| 2466 | f_gsup_forwardSM_req(spars2); |
| 2467 | |
| 2468 | /* Wait for 2nd MT SMS on DTAP */ |
| 2469 | f_mt_sms_expect(spars2); |
| 2470 | log("RX the 2nd SMS on DTAP, DTAP TID is ", spars2.tid, |
| 2471 | ", SM-RP-MR is ", spars2.rp.msg_ref); |
| 2472 | |
| 2473 | /* Both transaction IDs shall be different */ |
| 2474 | if (spars1.tid == spars2.tid) { |
| 2475 | log("Both DTAP transaction IDs shall be different"); |
| 2476 | setverdict(fail); |
| 2477 | } |
| 2478 | |
| 2479 | /* Both SM-RP-MR values shall be different */ |
| 2480 | if (spars1.rp.msg_ref == spars2.rp.msg_ref) { |
| 2481 | log("Both SM-RP-MR values shall be different"); |
| 2482 | setverdict(fail); |
| 2483 | } |
| 2484 | |
| 2485 | /* Both SM-RP-MR values shall be assigned */ |
| 2486 | if (spars1.rp.msg_ref == 'FF'O) { |
| 2487 | log("Unassigned SM-RP-MR value for the 1st SMS"); |
| 2488 | setverdict(fail); |
| 2489 | } |
| 2490 | if (spars2.rp.msg_ref == 'FF'O) { |
| 2491 | log("Unassigned SM-RP-MR value for the 2nd SMS"); |
| 2492 | setverdict(fail); |
| 2493 | } |
| 2494 | |
| 2495 | /* Send the 1st RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 2496 | f_mt_sms_send_rp_ack(spars1); |
| 2497 | alt { |
| 2498 | [] GSUP.receive(tr_GSUP_MT_FORWARD_SM_RES( |
| 2499 | imsi := g_pars.imsi, |
| 2500 | sm_rp_mr := spars1.rp.msg_ref |
| 2501 | )) { |
| 2502 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 2503 | setverdict(pass); |
| 2504 | } |
| 2505 | [] GSUP.receive { |
| 2506 | log("RX unexpected GSUP message"); |
| 2507 | setverdict(fail); |
| 2508 | mtc.stop; |
| 2509 | } |
| 2510 | } |
| 2511 | |
| 2512 | /* Send the 2nd RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 2513 | f_mt_sms_send_rp_ack(spars2); |
| 2514 | alt { |
| 2515 | [] GSUP.receive(tr_GSUP_MT_FORWARD_SM_RES( |
| 2516 | imsi := g_pars.imsi, |
| 2517 | sm_rp_mr := spars2.rp.msg_ref |
| 2518 | )) { |
| 2519 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 2520 | setverdict(pass); |
| 2521 | } |
| 2522 | [] GSUP.receive { |
| 2523 | log("RX unexpected GSUP message"); |
| 2524 | setverdict(fail); |
| 2525 | mtc.stop; |
| 2526 | } |
| 2527 | } |
| 2528 | |
| 2529 | f_expect_clear(); |
| 2530 | } |
| 2531 | testcase TC_gsup_mt_sms_rp_mr() runs on MTC_CT { |
| 2532 | var BSC_ConnHdlrPars pars; |
| 2533 | var BSC_ConnHdlr vc_conn; |
| 2534 | f_init(); |
| 2535 | pars := f_init_pars(92); |
| 2536 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2537 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_sms_rp_mr), pars); |
| 2538 | vc_conn.done; |
| 2539 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2540 | } |
| 2541 | |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 2542 | /* Test SM-RP-MR assignment for MT-SMS over GSUP */ |
| 2543 | private function f_tc_gsup_mo_mt_sms_rp_mr(charstring id, BSC_ConnHdlrPars pars) |
| 2544 | runs on BSC_ConnHdlr { |
| 2545 | var SmsParameters spars_mo := valueof(t_SmsPars); /* MO SMMA */ |
| 2546 | var SmsParameters spars_mt := valueof(t_SmsPars); /* MT SMS */ |
| 2547 | |
| 2548 | f_init_handler(pars); |
| 2549 | |
| 2550 | /* We need to inspect GSUP activity */ |
| 2551 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2552 | |
| 2553 | /* Perform location update */ |
| 2554 | f_perform_lu(); |
| 2555 | |
| 2556 | /* Register an 'expect' for given IMSI (+TMSI) */ |
| 2557 | if (isvalue(g_pars.tmsi)) { |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 2558 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 2559 | } else { |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 2560 | f_ran_register_imsi(g_pars.imsi, 'FFFFFFFF'O); |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 2561 | } |
| 2562 | |
| 2563 | /* Send CM Service Request for MO SMMA */ |
| 2564 | f_establish_fully(EST_TYPE_MO_SMS); |
| 2565 | |
| 2566 | /* Submit MO SMMA on DTAP */ |
| 2567 | log("Submit MO SMMA on DTAP, SM-RP-MR is '00'O"); |
| 2568 | spars_mo.rp.msg_ref := '00'O; |
| 2569 | f_mo_smma(spars_mo); |
| 2570 | |
| 2571 | /* Expect MO-forwardSM-Req for MO SMMA on GSUP */ |
| 2572 | alt { |
| 2573 | [] GSUP.receive(tr_GSUP_MO_READY_FOR_SM_REQ( |
| 2574 | imsi := g_pars.imsi, |
| 2575 | sm_rp_mr := spars_mo.rp.msg_ref, |
| 2576 | sm_alert_rsn := GSUP_SM_ALERT_RSN_TYPE_MEM_AVAIL |
| 2577 | )) { |
| 2578 | log("RX MO-ReadyForSM-Req, SM-RP-MR is '00'O"); |
| 2579 | setverdict(pass); |
| 2580 | } |
| 2581 | [] GSUP.receive { |
| 2582 | log("RX unexpected GSUP message"); |
| 2583 | setverdict(fail); |
| 2584 | mtc.stop; |
| 2585 | } |
| 2586 | } |
| 2587 | |
| 2588 | /* Submit MT SMS on GSUP */ |
| 2589 | log("TX MT-forwardSM-Req for the MT SMS"); |
| 2590 | f_gsup_forwardSM_req(spars_mt); |
| 2591 | |
| 2592 | /* Wait for MT SMS on DTAP */ |
| 2593 | f_mt_sms_expect(spars_mt); |
| 2594 | log("RX MT SMS on DTAP, DTAP TID is ", spars_mt.tid, |
| 2595 | ", SM-RP-MR is ", spars_mt.rp.msg_ref); |
| 2596 | |
| 2597 | /* Both SM-RP-MR values shall be different */ |
| 2598 | if (spars_mo.rp.msg_ref == spars_mt.rp.msg_ref) { |
| 2599 | log("Both SM-RP-MR values shall be different"); |
| 2600 | setverdict(fail); |
| 2601 | } |
| 2602 | |
| 2603 | /* SM-RP-MR value for MT SMS shall be assigned */ |
| 2604 | if (spars_mt.rp.msg_ref == 'FF'O) { |
| 2605 | log("Unassigned SM-RP-MR value for the MT SMS"); |
| 2606 | setverdict(fail); |
| 2607 | } |
| 2608 | |
| 2609 | /* Trigger RP-ACK for MO SMMA by sending MO-forwardSM-Res */ |
| 2610 | GSUP.send(valueof(ts_GSUP_MO_READY_FOR_SM_RES( |
| 2611 | imsi := g_pars.imsi, |
| 2612 | sm_rp_mr := spars_mo.rp.msg_ref))); |
| 2613 | /* Expect RP-ACK for MO SMMA on DTAP */ |
| 2614 | f_mo_sms_wait_rp_ack(spars_mo); |
| 2615 | |
| 2616 | /* Send RP-ACK for MT SMS and expect MT-forwardSM-Res on GSUP */ |
| 2617 | f_mt_sms_send_rp_ack(spars_mt); |
| 2618 | alt { |
| 2619 | [] GSUP.receive(tr_GSUP_MT_FORWARD_SM_RES( |
| 2620 | imsi := g_pars.imsi, |
| 2621 | sm_rp_mr := spars_mt.rp.msg_ref |
| 2622 | )) { |
| 2623 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 2624 | setverdict(pass); |
| 2625 | } |
| 2626 | [] GSUP.receive { |
| 2627 | log("RX unexpected GSUP message"); |
| 2628 | setverdict(fail); |
| 2629 | mtc.stop; |
| 2630 | } |
| 2631 | } |
| 2632 | |
| 2633 | f_expect_clear(); |
| 2634 | } |
| 2635 | testcase TC_gsup_mo_mt_sms_rp_mr() runs on MTC_CT { |
| 2636 | var BSC_ConnHdlrPars pars; |
| 2637 | var BSC_ConnHdlr vc_conn; |
| 2638 | f_init(); |
| 2639 | pars := f_init_pars(93); |
| 2640 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2641 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mo_mt_sms_rp_mr), pars); |
| 2642 | vc_conn.done; |
| 2643 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2644 | } |
| 2645 | |
Vadim Yanitskiy | 1cd11a0 | 2018-12-03 02:43:35 +0700 | [diff] [blame] | 2646 | /* Test multi-part MT-SMS over GSUP */ |
| 2647 | private function f_tc_gsup_mt_multi_part_sms(charstring id, BSC_ConnHdlrPars pars) |
| 2648 | runs on BSC_ConnHdlr { |
| 2649 | var SmsParameters spars := valueof(t_SmsPars); |
| 2650 | |
| 2651 | f_init_handler(pars); |
| 2652 | |
| 2653 | /* We need to inspect GSUP activity */ |
| 2654 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2655 | |
| 2656 | /* Perform location update */ |
| 2657 | f_perform_lu(); |
| 2658 | |
| 2659 | /* Register an 'expect' for given IMSI (+TMSI) */ |
| 2660 | if (isvalue(g_pars.tmsi)) { |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 2661 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 1cd11a0 | 2018-12-03 02:43:35 +0700 | [diff] [blame] | 2662 | } else { |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 2663 | f_ran_register_imsi(g_pars.imsi, 'FFFFFFFF'O); |
Vadim Yanitskiy | 1cd11a0 | 2018-12-03 02:43:35 +0700 | [diff] [blame] | 2664 | } |
| 2665 | |
| 2666 | var template GSUP_PDU mt_forwardSM_res := tr_GSUP_MT_FORWARD_SM_RES( |
| 2667 | imsi := g_pars.imsi, |
| 2668 | /* NOTE: MSC should assign RP-MR itself */ |
| 2669 | sm_rp_mr := ? |
| 2670 | ); |
| 2671 | |
| 2672 | /* Send 4 messages (NOTE: SM-RP-UI remains unchanged) */ |
| 2673 | for (var integer i := 3; i >= 0; i := i-1) { |
| 2674 | /* Submit a MT SMS on GSUP (MMS is decremented) */ |
| 2675 | f_gsup_forwardSM_req(spars, int2oct(i, 1)); |
| 2676 | |
| 2677 | /* Expect Paging Request and Establish connection */ |
| 2678 | if (i == 3) { /* ... only once! */ |
| 2679 | BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)); |
| 2680 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2681 | } |
| 2682 | |
| 2683 | /* Wait for MT SMS on DTAP */ |
| 2684 | f_mt_sms_expect(spars); |
| 2685 | |
| 2686 | /* Send RP-ACK and expect MT-forwardSM-Res on GSUP */ |
| 2687 | f_mt_sms_send_rp_ack(spars); |
| 2688 | alt { |
| 2689 | [] GSUP.receive(mt_forwardSM_res) { |
| 2690 | log("RX MT-forwardSM-Res (RP-ACK)"); |
| 2691 | setverdict(pass); |
| 2692 | } |
| 2693 | [] GSUP.receive { |
| 2694 | log("RX unexpected GSUP message"); |
| 2695 | setverdict(fail); |
| 2696 | mtc.stop; |
| 2697 | } |
| 2698 | } |
| 2699 | |
| 2700 | /* Keep some 'distance' between transmissions */ |
| 2701 | f_sleep(1.5); |
| 2702 | } |
| 2703 | |
| 2704 | f_expect_clear(); |
| 2705 | } |
| 2706 | testcase TC_gsup_mt_multi_part_sms() runs on MTC_CT { |
| 2707 | var BSC_ConnHdlrPars pars; |
| 2708 | var BSC_ConnHdlr vc_conn; |
| 2709 | f_init(); |
| 2710 | pars := f_init_pars(91); |
| 2711 | f_vty_config(MSCVTY, "msc", "sms-over-gsup"); |
| 2712 | vc_conn := f_start_handler_with_pars(refers(f_tc_gsup_mt_multi_part_sms), pars); |
| 2713 | vc_conn.done; |
| 2714 | f_vty_config(MSCVTY, "msc", "no sms-over-gsup"); |
| 2715 | } |
| 2716 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2717 | /* convert GSM L3 TON to SMPP_TON enum */ |
| 2718 | function f_sm_ton_from_gsm(BIT3 ton) return SMPP_TON { |
| 2719 | select (ton) { |
| 2720 | case ('000'B) { return unknown; } |
| 2721 | case ('001'B) { return international; } |
| 2722 | case ('010'B) { return national; } |
| 2723 | case ('011'B) { return network_specific; } |
| 2724 | case ('100'B) { return subscriber_number; } |
| 2725 | case ('101'B) { return alphanumeric; } |
| 2726 | case ('110'B) { return abbreviated; } |
| 2727 | } |
| 2728 | setverdict(fail, "Unknown TON ", ton); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2729 | mtc.stop; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2730 | } |
| 2731 | /* convert GSM L3 NPI to SMPP_NPI enum */ |
| 2732 | function f_sm_npi_from_gsm(BIT4 npi) return SMPP_NPI { |
| 2733 | select (npi) { |
| 2734 | case ('0000'B) { return unknown; } |
| 2735 | case ('0001'B) { return isdn; } |
| 2736 | case ('0011'B) { return data; } |
| 2737 | case ('0100'B) { return telex; } |
| 2738 | case ('0110'B) { return land_mobile; } |
| 2739 | case ('1000'B) { return national; } |
| 2740 | case ('1001'B) { return private_; } |
| 2741 | case ('1010'B) { return ermes; } |
| 2742 | } |
| 2743 | setverdict(fail, "Unknown NPI ", npi); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2744 | mtc.stop; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2745 | } |
| 2746 | |
| 2747 | /* build a SMPP_SM from SmsParameters */ |
| 2748 | function f_mt_sm_from_spars(SmsParameters spars) |
| 2749 | runs on BSC_ConnHdlr return SMPP_SM { |
| 2750 | var SMPP_SM sm := { |
| 2751 | service_type := "CMT", |
| 2752 | source_addr_ton := f_sm_ton_from_gsm(spars.tp.da.tP_DA_NoPad.tP_TypeOfNumber), |
| 2753 | source_addr_npi := f_sm_npi_from_gsm(spars.tp.da.tP_DA_NoPad.tP_NumberingPlanID), |
| 2754 | source_addr := hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue), |
| 2755 | dest_addr_ton := international, |
| 2756 | dest_addr_npi := isdn, |
| 2757 | destination_addr := hex2str(g_pars.msisdn), |
| 2758 | esm_class := '00000001'B, |
| 2759 | protocol_id := 0, |
| 2760 | priority_flag := 0, |
| 2761 | schedule_delivery_time := "", |
| 2762 | validity_period := "", |
| 2763 | registered_delivery := '00000000'B, |
| 2764 | replace_if_present := 0, |
| 2765 | data_coding := '00000001'B, |
| 2766 | sm_default_msg_id := 0, |
| 2767 | sm_length := spars.tp.udl, |
| 2768 | short_message := spars.tp.ud, |
| 2769 | opt_pars := {} |
| 2770 | }; |
| 2771 | return sm; |
| 2772 | } |
| 2773 | |
| 2774 | /* helper function to encode SMS from 'spars', send it via SMPP to MSC; receive it on MS side */ |
| 2775 | private function f_smpp_mt_sms(SmsParameters spars, boolean trans_mode) runs on BSC_ConnHdlr { |
| 2776 | var SMPP_SM sm := f_mt_sm_from_spars(spars); |
| 2777 | if (trans_mode) { |
| 2778 | sm.esm_class := '00000010'B; |
| 2779 | } |
| 2780 | |
| 2781 | /* actually cause MSC to send a SMS via SUBMIT-SM from SMPP side */ |
| 2782 | SMPP.send(ts_SMPP_SUBMIT_SM(sm)); |
| 2783 | if (not match(sm.esm_class, tr_ESM_CLASS_TRANSACTION)) { |
| 2784 | /* if we're not in SMPP transaction mode, we expect the SMPP-level ACK |
| 2785 | * before we expect the SMS delivery on the BSC/radio side */ |
| 2786 | SMPP.receive(tr_SMPP(c_SMPP_command_id_submit_sm_resp, ESME_ROK)); |
| 2787 | } |
| 2788 | |
| 2789 | /* MSC->BSC: expect PAGING from MSC */ |
Harald Welte | e035e3e | 2019-04-21 17:32:05 +0200 | [diff] [blame] | 2790 | f_expect_paging(); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2791 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 2792 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2793 | SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)); |
| 2794 | |
| 2795 | f_mt_sms(spars); |
| 2796 | |
| 2797 | if (match(sm.esm_class, tr_ESM_CLASS_TRANSACTION)) { |
| 2798 | SMPP.receive(tr_SMPP(c_SMPP_command_id_submit_sm_resp, ESME_ROK)); |
| 2799 | } |
| 2800 | f_expect_clear(); |
| 2801 | } |
| 2802 | |
| 2803 | /* mobile terminated SMS, from SMPP to BSC/BTS/MS */ |
| 2804 | private function f_tc_smpp_mt_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2805 | f_init_handler(pars); |
| 2806 | |
| 2807 | /* Perform location update so IMSI is known + registered in MSC/VLR */ |
| 2808 | f_perform_lu(); |
| 2809 | SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)); |
| 2810 | |
| 2811 | /* register an 'expect' for given IMSI (+TMSI) */ |
| 2812 | var OCT4 tmsi; |
| 2813 | if (isvalue(g_pars.tmsi)) { |
| 2814 | tmsi := g_pars.tmsi; |
| 2815 | } else { |
| 2816 | tmsi := 'FFFFFFFF'O; |
| 2817 | } |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 2818 | f_ran_register_imsi(g_pars.imsi, tmsi); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2819 | |
| 2820 | var SmsParameters spars := valueof(t_SmsPars); |
| 2821 | /* TODO: test with more intelligent user data; test different coding schemes */ |
| 2822 | spars.tp.ud := '00'O; |
| 2823 | spars.tp.udl := 1; |
| 2824 | |
| 2825 | /* first test the non-transaction store+forward mode */ |
| 2826 | f_smpp_mt_sms(spars, false); |
| 2827 | |
| 2828 | /* then test the transaction mode */ |
| 2829 | f_smpp_mt_sms(spars, true); |
| 2830 | } |
| 2831 | testcase TC_smpp_mt_sms() runs on MTC_CT { |
| 2832 | var BSC_ConnHdlr vc_conn; |
| 2833 | f_init(); |
| 2834 | vc_conn := f_start_handler(refers(f_tc_smpp_mt_sms), 45); |
| 2835 | vc_conn.done; |
| 2836 | } |
| 2837 | |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2838 | /*********************************************************************** |
| 2839 | * USSD Testing |
| 2840 | ***********************************************************************/ |
| 2841 | |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 2842 | private altstep as_unexp_gsup_or_bssap_msg() |
| 2843 | runs on BSC_ConnHdlr { |
| 2844 | [] GSUP.receive { |
| 2845 | setverdict(fail, "Unknown/unexpected GSUP received"); |
| 2846 | self.stop; |
| 2847 | } |
| 2848 | [] BSSAP.receive { |
| 2849 | setverdict(fail, "Unknown/unexpected BSSAP message received"); |
| 2850 | self.stop; |
| 2851 | } |
| 2852 | } |
| 2853 | |
| 2854 | private function f_expect_gsup_msg(template GSUP_PDU msg) |
| 2855 | runs on BSC_ConnHdlr return GSUP_PDU { |
| 2856 | var GSUP_PDU gsup_msg_complete; |
| 2857 | |
| 2858 | alt { |
| 2859 | [] GSUP.receive(msg) -> value gsup_msg_complete { |
| 2860 | setverdict(pass); |
| 2861 | } |
| 2862 | /* We don't expect anything else */ |
| 2863 | [] as_unexp_gsup_or_bssap_msg(); |
| 2864 | } |
| 2865 | |
| 2866 | return gsup_msg_complete; |
| 2867 | } |
| 2868 | |
| 2869 | private function f_expect_mt_dtap_msg(template PDU_ML3_NW_MS msg) |
| 2870 | runs on BSC_ConnHdlr return PDU_ML3_NW_MS { |
| 2871 | var PDU_DTAP_MT bssap_msg_complete; |
| 2872 | |
| 2873 | alt { |
| 2874 | [] BSSAP.receive(tr_PDU_DTAP_MT(msg)) -> value bssap_msg_complete { |
| 2875 | setverdict(pass); |
| 2876 | } |
| 2877 | /* We don't expect anything else */ |
| 2878 | [] as_unexp_gsup_or_bssap_msg(); |
| 2879 | } |
| 2880 | |
| 2881 | return bssap_msg_complete.dtap; |
| 2882 | } |
| 2883 | |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 2884 | /* LU followed by MO USSD request */ |
| 2885 | private 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] | 2886 | runs on BSC_ConnHdlr { |
| 2887 | f_init_handler(pars); |
| 2888 | |
| 2889 | /* Perform location update */ |
| 2890 | f_perform_lu(); |
| 2891 | |
| 2892 | /* Send CM Service Request for SS/USSD */ |
| 2893 | f_establish_fully(EST_TYPE_SS_ACT); |
| 2894 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 2895 | /* We need to inspect GSUP activity */ |
| 2896 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2897 | |
| 2898 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 2899 | invoke_id := 5, /* Phone may not start from 0 or 1 */ |
| 2900 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 2901 | ussd_string := "*#100#" |
| 2902 | ); |
| 2903 | |
| 2904 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 2905 | invoke_id := 5, /* InvokeID shall be the same for both REQ and RSP */ |
| 2906 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 2907 | ussd_string := "Your extension is " & hex2str(g_pars.msisdn) & "\r" |
| 2908 | ) |
| 2909 | |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2910 | /* Compose a new SS/REGISTER message with request */ |
| 2911 | var template (value) PDU_ML3_MS_NW ussd_req := ts_ML3_MO_SS_REGISTER( |
| 2912 | tid := 1, /* We just need a single transaction */ |
| 2913 | 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] | 2914 | facility := valueof(facility_req) |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2915 | ); |
| 2916 | |
| 2917 | /* Compose SS/RELEASE_COMPLETE template with expected response */ |
| 2918 | var template PDU_ML3_NW_MS ussd_rsp := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 2919 | tid := 1, /* Response should arrive within the same transaction */ |
| 2920 | 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] | 2921 | facility := valueof(facility_rsp) |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2922 | ); |
| 2923 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 2924 | /* Compose expected MSC -> HLR message */ |
| 2925 | var template GSUP_PDU gsup_req := tr_GSUP_PROC_SS_REQ( |
| 2926 | imsi := g_pars.imsi, |
| 2927 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 2928 | ss := valueof(facility_req) |
| 2929 | ); |
| 2930 | |
| 2931 | /* To be used for sending response with correct session ID */ |
| 2932 | var GSUP_PDU gsup_req_complete; |
| 2933 | |
| 2934 | /* Request own number */ |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2935 | BSSAP.send(ts_PDU_DTAP_MO(ussd_req)); |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 2936 | /* Expect GSUP message containing the SS payload */ |
| 2937 | gsup_req_complete := f_expect_gsup_msg(gsup_req); |
| 2938 | |
| 2939 | /* Compose the response from HLR using received session ID */ |
| 2940 | var template GSUP_PDU gsup_rsp := ts_GSUP_PROC_SS_REQ( |
| 2941 | imsi := g_pars.imsi, |
| 2942 | sid := gsup_req_complete.ies[1].val.session_id, |
| 2943 | state := OSMO_GSUP_SESSION_STATE_END, |
| 2944 | ss := valueof(facility_rsp) |
| 2945 | ); |
| 2946 | |
| 2947 | /* Finally, HLR terminates the session */ |
| 2948 | GSUP.send(gsup_rsp); |
| 2949 | /* Expect RELEASE_COMPLETE message with the response */ |
| 2950 | f_expect_mt_dtap_msg(ussd_rsp); |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2951 | |
| 2952 | f_expect_clear(); |
| 2953 | } |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 2954 | testcase TC_lu_and_mo_ussd_single_request() runs on MTC_CT { |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2955 | var BSC_ConnHdlr vc_conn; |
| 2956 | f_init(); |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 2957 | 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] | 2958 | vc_conn.done; |
| 2959 | } |
| 2960 | |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 2961 | /* LU followed by MT USSD notification */ |
| 2962 | private function f_tc_lu_and_mt_ussd_notification(charstring id, BSC_ConnHdlrPars pars) |
| 2963 | runs on BSC_ConnHdlr { |
| 2964 | f_init_handler(pars); |
| 2965 | |
| 2966 | /* Perform location update */ |
| 2967 | f_perform_lu(); |
| 2968 | |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 2969 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 2970 | |
| 2971 | /* We need to inspect GSUP activity */ |
| 2972 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2973 | |
| 2974 | /* Facility IE with network-originated USSD notification */ |
| 2975 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 2976 | op_code := SS_OP_CODE_USS_NOTIFY, |
| 2977 | ussd_string := "Mahlzeit!" |
| 2978 | ); |
| 2979 | |
| 2980 | /* Facility IE with acknowledgment to the USSD notification */ |
| 2981 | var template OCTN facility_rsp := enc_SS_FacilityInformation( |
| 2982 | /* In case of USSD notification, Return Result is empty */ |
| 2983 | valueof(ts_SS_USSD_FACILITY_RETURN_RESULT_EMPTY()) |
| 2984 | ); |
| 2985 | |
| 2986 | /* Compose a new MT SS/REGISTER message with USSD notification */ |
| 2987 | var template PDU_ML3_NW_MS ussd_ntf := tr_ML3_MT_SS_REGISTER( |
| 2988 | tid := 0, /* FIXME: most likely, it should be 0 */ |
| 2989 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 2990 | facility := valueof(facility_req) |
| 2991 | ); |
| 2992 | |
| 2993 | /* Compose HLR -> MSC GSUP message */ |
| 2994 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 2995 | imsi := g_pars.imsi, |
| 2996 | sid := '20000101'O, |
| 2997 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 2998 | ss := valueof(facility_req) |
| 2999 | ); |
| 3000 | |
| 3001 | /* Send it to MSC and expect Paging Request */ |
| 3002 | GSUP.send(gsup_req); |
| 3003 | alt { |
| 3004 | [] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 3005 | setverdict(pass); |
| 3006 | } |
| 3007 | /* We don't expect anything else */ |
| 3008 | [] as_unexp_gsup_or_bssap_msg(); |
| 3009 | } |
| 3010 | |
| 3011 | /* Send Paging Response and expect USSD notification */ |
| 3012 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 3013 | /* Expect MT REGISTER message with USSD notification */ |
| 3014 | f_expect_mt_dtap_msg(ussd_ntf); |
| 3015 | |
| 3016 | /* Compose a new MO SS/FACILITY message with empty response */ |
| 3017 | var template (value) PDU_ML3_MS_NW ussd_rsp := ts_ML3_MO_SS_FACILITY( |
| 3018 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3019 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3020 | facility := valueof(facility_rsp) |
| 3021 | ); |
| 3022 | |
| 3023 | /* Compose expected MSC -> HLR GSUP message */ |
| 3024 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_REQ( |
| 3025 | imsi := g_pars.imsi, |
| 3026 | sid := '20000101'O, |
| 3027 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 3028 | ss := valueof(facility_rsp) |
| 3029 | ); |
| 3030 | |
| 3031 | /* MS sends response to the notification */ |
| 3032 | BSSAP.send(ts_PDU_DTAP_MO(ussd_rsp)); |
| 3033 | /* Expect GSUP message containing the SS payload */ |
| 3034 | f_expect_gsup_msg(gsup_rsp); |
| 3035 | |
| 3036 | /* Compose expected MT SS/RELEASE COMPLETE message */ |
| 3037 | var template PDU_ML3_NW_MS ussd_term := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3038 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3039 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3040 | facility := omit |
| 3041 | ); |
| 3042 | |
| 3043 | /* Compose MSC -> HLR GSUP message */ |
| 3044 | var template GSUP_PDU gsup_term := ts_GSUP_PROC_SS_REQ( |
| 3045 | imsi := g_pars.imsi, |
| 3046 | sid := '20000101'O, |
| 3047 | state := OSMO_GSUP_SESSION_STATE_END |
| 3048 | ); |
| 3049 | |
| 3050 | /* Finally, HLR terminates the session */ |
| 3051 | GSUP.send(gsup_term) |
| 3052 | /* Expect MT RELEASE COMPLETE without Facility IE */ |
| 3053 | f_expect_mt_dtap_msg(ussd_term); |
| 3054 | |
| 3055 | f_expect_clear(); |
| 3056 | } |
| 3057 | testcase TC_lu_and_mt_ussd_notification() runs on MTC_CT { |
| 3058 | var BSC_ConnHdlr vc_conn; |
| 3059 | f_init(); |
| 3060 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_ussd_notification), 47); |
| 3061 | vc_conn.done; |
| 3062 | } |
| 3063 | |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3064 | /* LU followed by MT call and MO USSD request during this call */ |
| 3065 | private 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] | 3066 | runs on BSC_ConnHdlr { |
| 3067 | f_init_handler(pars); |
| 3068 | |
| 3069 | /* Call parameters taken from f_tc_lu_and_mt_call */ |
| 3070 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
| 3071 | cpars.mgcp_connection_id_bss := '10004'H; |
| 3072 | cpars.mgcp_connection_id_mss := '10005'H; |
| 3073 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
| 3074 | cpars.bss_rtp_port := 1110; |
| 3075 | |
| 3076 | /* Perform location update */ |
| 3077 | f_perform_lu(); |
| 3078 | |
| 3079 | /* Establish a MT call */ |
| 3080 | f_mt_call_establish(cpars); |
| 3081 | |
| 3082 | /* Hold the call for some time */ |
| 3083 | f_sleep(1.0); |
| 3084 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3085 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 3086 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3087 | ussd_string := "*#100#" |
| 3088 | ); |
| 3089 | |
| 3090 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 3091 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3092 | ussd_string := "Your extension is " & hex2str(g_pars.msisdn) & "\r" |
| 3093 | ) |
| 3094 | |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3095 | /* Compose a new SS/REGISTER message with request */ |
| 3096 | var template (value) PDU_ML3_MS_NW ussd_req := ts_ML3_MO_SS_REGISTER( |
| 3097 | tid := 1, /* We just need a single transaction */ |
| 3098 | 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] | 3099 | facility := valueof(facility_req) |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3100 | ); |
| 3101 | |
| 3102 | /* Compose SS/RELEASE_COMPLETE template with expected response */ |
| 3103 | var template PDU_ML3_NW_MS ussd_rsp := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3104 | tid := 1, /* Response should arrive within the same transaction */ |
| 3105 | 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] | 3106 | facility := valueof(facility_rsp) |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3107 | ); |
| 3108 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3109 | /* Compose expected MSC -> HLR message */ |
| 3110 | var template GSUP_PDU gsup_req := tr_GSUP_PROC_SS_REQ( |
| 3111 | imsi := g_pars.imsi, |
| 3112 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3113 | ss := valueof(facility_req) |
| 3114 | ); |
| 3115 | |
| 3116 | /* To be used for sending response with correct session ID */ |
| 3117 | var GSUP_PDU gsup_req_complete; |
| 3118 | |
| 3119 | /* Request own number */ |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3120 | BSSAP.send(ts_PDU_DTAP_MO(ussd_req)); |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 3121 | /* Expect GSUP message containing the SS payload */ |
| 3122 | gsup_req_complete := f_expect_gsup_msg(gsup_req); |
| 3123 | |
| 3124 | /* Compose the response from HLR using received session ID */ |
| 3125 | var template GSUP_PDU gsup_rsp := ts_GSUP_PROC_SS_REQ( |
| 3126 | imsi := g_pars.imsi, |
| 3127 | sid := gsup_req_complete.ies[1].val.session_id, |
| 3128 | state := OSMO_GSUP_SESSION_STATE_END, |
| 3129 | ss := valueof(facility_rsp) |
| 3130 | ); |
| 3131 | |
| 3132 | /* Finally, HLR terminates the session */ |
| 3133 | GSUP.send(gsup_rsp); |
| 3134 | /* Expect RELEASE_COMPLETE message with the response */ |
| 3135 | f_expect_mt_dtap_msg(ussd_rsp); |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 3136 | |
| 3137 | /* Hold the call for some time */ |
| 3138 | f_sleep(1.0); |
| 3139 | |
| 3140 | /* Release the call (does Clear Complete itself) */ |
| 3141 | f_call_hangup(cpars, true); |
| 3142 | } |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3143 | 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] | 3144 | var BSC_ConnHdlr vc_conn; |
| 3145 | f_init(); |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 3146 | 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] | 3147 | vc_conn.done; |
| 3148 | } |
| 3149 | |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 3150 | /* BSSMAP Clear Request in the middle of a call, see OS#3062 */ |
| 3151 | private function f_tc_mo_cc_bssmap_clear(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 3152 | f_init_handler(pars); |
| 3153 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 3154 | var MNCC_PDU mncc; |
| 3155 | var MgcpCommand mgcp_cmd; |
| 3156 | |
| 3157 | f_perform_lu(); |
| 3158 | |
| 3159 | f_establish_fully(); |
| 3160 | f_create_mncc_expect(hex2str(cpars.called_party)); |
| 3161 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 3162 | |
| 3163 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_SETUP(cpars.transaction_id, cpars.called_party))); |
| 3164 | MNCC.receive(tr_MNCC_SETUP_ind(?, tr_MNCC_number(hex2str(cpars.called_party)))) -> value mncc; |
| 3165 | cpars.mncc_callref := mncc.u.signal.callref; |
| 3166 | log("mncc_callref=", cpars.mncc_callref); |
| 3167 | MNCC.send(ts_MNCC_CALL_PROC_req(cpars.mncc_callref, cpars.mncc_bearer_cap)); |
| 3168 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CALL_PROC(cpars.transaction_id))); |
| 3169 | |
| 3170 | MNCC.send(ts_MNCC_ALERT_req(cpars.mncc_callref)); |
| 3171 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_ALERTING(cpars.transaction_id))); |
| 3172 | MGCP.receive(tr_CRCX); |
| 3173 | |
| 3174 | f_sleep(1.0); |
| 3175 | BSSAP.send(ts_BSSMAP_ClearRequest(0)); |
| 3176 | |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 3177 | var default ccrel := activate(as_optional_cc_rel(cpars)); |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 3178 | |
Neels Hofmeyr | de76f05 | 2019-02-26 05:02:46 +0100 | [diff] [blame] | 3179 | interleave { |
| 3180 | [] MNCC.receive(tr_MNCC_REL_ind(?, ?)) { }; |
| 3181 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 3182 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 3183 | }; |
| 3184 | } |
| 3185 | |
| 3186 | deactivate(ccrel); |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 3187 | |
| 3188 | f_sleep(1.0); |
| 3189 | } |
| 3190 | testcase TC_mo_cc_bssmap_clear() runs on MTC_CT { |
| 3191 | var BSC_ConnHdlr vc_conn; |
| 3192 | f_init(); |
| 3193 | |
| 3194 | vc_conn := f_start_handler(refers(f_tc_mo_cc_bssmap_clear), 43); |
| 3195 | vc_conn.done; |
| 3196 | } |
| 3197 | |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 3198 | /* LU followed by MT call and MT USSD request during this call */ |
| 3199 | private function f_tc_lu_and_mt_ussd_during_mt_call(charstring id, BSC_ConnHdlrPars pars) |
| 3200 | runs on BSC_ConnHdlr { |
| 3201 | f_init_handler(pars); |
| 3202 | |
| 3203 | /* Call parameters taken from f_tc_lu_and_mt_call */ |
| 3204 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
| 3205 | cpars.mgcp_connection_id_bss := '10004'H; |
| 3206 | cpars.mgcp_connection_id_mss := '10005'H; |
| 3207 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
| 3208 | cpars.bss_rtp_port := 1110; |
| 3209 | |
| 3210 | /* Perform location update */ |
| 3211 | f_perform_lu(); |
| 3212 | |
| 3213 | /* Establish a MT call */ |
| 3214 | f_mt_call_establish(cpars); |
| 3215 | |
| 3216 | /* Hold the call for some time */ |
| 3217 | f_sleep(1.0); |
| 3218 | |
| 3219 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 3220 | op_code := SS_OP_CODE_USS_REQUEST, |
| 3221 | ussd_string := "Please type anything..." |
| 3222 | ); |
| 3223 | |
| 3224 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 3225 | op_code := SS_OP_CODE_USS_REQUEST, |
| 3226 | ussd_string := "Nope." |
| 3227 | ) |
| 3228 | |
| 3229 | /* Compose MT SS/REGISTER message with network-originated request */ |
| 3230 | var template (value) PDU_ML3_NW_MS ussd_req := ts_ML3_MT_SS_REGISTER( |
| 3231 | tid := 0, /* FIXME: most likely, it should be 0 */ |
| 3232 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3233 | facility := valueof(facility_req) |
| 3234 | ); |
| 3235 | |
| 3236 | /* Compose HLR -> MSC GSUP message */ |
| 3237 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 3238 | imsi := g_pars.imsi, |
| 3239 | sid := '20000101'O, |
| 3240 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3241 | ss := valueof(facility_req) |
| 3242 | ); |
| 3243 | |
| 3244 | /* Send it to MSC */ |
| 3245 | GSUP.send(gsup_req); |
| 3246 | /* Expect MT REGISTER message with USSD request */ |
| 3247 | f_expect_mt_dtap_msg(ussd_req); |
| 3248 | |
| 3249 | /* Compose a new MO SS/FACILITY message with response */ |
| 3250 | var template (value) PDU_ML3_MS_NW ussd_rsp := ts_ML3_MO_SS_FACILITY( |
| 3251 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3252 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3253 | facility := valueof(facility_rsp) |
| 3254 | ); |
| 3255 | |
| 3256 | /* Compose expected MSC -> HLR GSUP message */ |
| 3257 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_REQ( |
| 3258 | imsi := g_pars.imsi, |
| 3259 | sid := '20000101'O, |
| 3260 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 3261 | ss := valueof(facility_rsp) |
| 3262 | ); |
| 3263 | |
| 3264 | /* MS sends response */ |
| 3265 | BSSAP.send(ts_PDU_DTAP_MO(ussd_rsp)); |
| 3266 | f_expect_gsup_msg(gsup_rsp); |
| 3267 | |
| 3268 | /* Compose expected MT SS/RELEASE COMPLETE message */ |
| 3269 | var template PDU_ML3_NW_MS ussd_term := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3270 | tid := 0, /* FIXME: it shall match the request tid */ |
| 3271 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3272 | facility := omit |
| 3273 | ); |
| 3274 | |
| 3275 | /* Compose MSC -> HLR GSUP message */ |
| 3276 | var template GSUP_PDU gsup_term := ts_GSUP_PROC_SS_REQ( |
| 3277 | imsi := g_pars.imsi, |
| 3278 | sid := '20000101'O, |
| 3279 | state := OSMO_GSUP_SESSION_STATE_END |
| 3280 | ); |
| 3281 | |
| 3282 | /* Finally, HLR terminates the session */ |
| 3283 | GSUP.send(gsup_term); |
| 3284 | /* Expect MT RELEASE COMPLETE without Facility IE */ |
| 3285 | f_expect_mt_dtap_msg(ussd_term); |
| 3286 | |
| 3287 | /* Hold the call for some time */ |
| 3288 | f_sleep(1.0); |
| 3289 | |
| 3290 | /* Release the call (does Clear Complete itself) */ |
| 3291 | f_call_hangup(cpars, true); |
| 3292 | } |
| 3293 | testcase TC_lu_and_mt_ussd_during_mt_call() runs on MTC_CT { |
| 3294 | var BSC_ConnHdlr vc_conn; |
| 3295 | f_init(); |
| 3296 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_ussd_during_mt_call), 49); |
| 3297 | vc_conn.done; |
| 3298 | } |
| 3299 | |
Vadim Yanitskiy | 2daf52d | 2018-06-21 04:19:58 +0700 | [diff] [blame] | 3300 | /* LU followed by MO USSD request and MO Release during transaction */ |
| 3301 | private function f_tc_lu_and_mo_ussd_mo_release(charstring id, BSC_ConnHdlrPars pars) |
| 3302 | runs on BSC_ConnHdlr { |
| 3303 | f_init_handler(pars); |
| 3304 | |
| 3305 | /* Perform location update */ |
| 3306 | f_perform_lu(); |
| 3307 | |
| 3308 | /* Send CM Service Request for SS/USSD */ |
| 3309 | f_establish_fully(EST_TYPE_SS_ACT); |
| 3310 | |
| 3311 | /* We need to inspect GSUP activity */ |
| 3312 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3313 | |
| 3314 | var template OCTN facility_ms_req := f_USSD_FACILITY_IE_INVOKE( |
| 3315 | invoke_id := 1, /* Initial request */ |
| 3316 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3317 | ussd_string := "*6766*266#" |
| 3318 | ); |
| 3319 | |
| 3320 | var template OCTN facility_net_req := f_USSD_FACILITY_IE_INVOKE( |
| 3321 | invoke_id := 2, /* Counter request */ |
| 3322 | op_code := SS_OP_CODE_USS_REQUEST, |
| 3323 | ussd_string := "Password?!?" |
| 3324 | ) |
| 3325 | |
| 3326 | /* Compose MO SS/REGISTER message with request */ |
| 3327 | var template (value) PDU_ML3_MS_NW ussd_ms_req := ts_ML3_MO_SS_REGISTER( |
| 3328 | tid := 1, /* We just need a single transaction */ |
| 3329 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3330 | facility := valueof(facility_ms_req) |
| 3331 | ); |
| 3332 | |
| 3333 | /* Compose expected MSC -> HLR message */ |
| 3334 | var template GSUP_PDU gsup_ms_req := tr_GSUP_PROC_SS_REQ( |
| 3335 | imsi := g_pars.imsi, |
| 3336 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3337 | ss := valueof(facility_ms_req) |
| 3338 | ); |
| 3339 | |
| 3340 | /* To be used for sending response with correct session ID */ |
| 3341 | var GSUP_PDU gsup_ms_req_complete; |
| 3342 | |
| 3343 | /* Initiate a new transaction */ |
| 3344 | BSSAP.send(ts_PDU_DTAP_MO(ussd_ms_req)); |
| 3345 | /* Expect GSUP request with original Facility IE */ |
| 3346 | gsup_ms_req_complete := f_expect_gsup_msg(gsup_ms_req); |
| 3347 | |
| 3348 | /* Compose the response from HLR using received session ID */ |
| 3349 | var template (value) GSUP_PDU gsup_net_req := ts_GSUP_PROC_SS_REQ( |
| 3350 | imsi := g_pars.imsi, |
| 3351 | sid := gsup_ms_req_complete.ies[1].val.session_id, |
| 3352 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 3353 | ss := valueof(facility_net_req) |
| 3354 | ); |
| 3355 | |
| 3356 | /* Compose expected MT SS/FACILITY template with counter request */ |
| 3357 | var template PDU_ML3_NW_MS ussd_net_req := tr_ML3_MT_SS_FACILITY( |
| 3358 | tid := 1, /* Response should arrive within the same transaction */ |
| 3359 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3360 | facility := valueof(facility_net_req) |
| 3361 | ); |
| 3362 | |
| 3363 | /* Send response over GSUP */ |
| 3364 | GSUP.send(gsup_net_req); |
| 3365 | /* Expect MT SS/FACILITY message with counter request */ |
| 3366 | f_expect_mt_dtap_msg(ussd_net_req); |
| 3367 | |
| 3368 | /* Compose MO SS/RELEASE COMPLETE */ |
| 3369 | var template (value) PDU_ML3_MS_NW ussd_abort := ts_ML3_MO_SS_RELEASE_COMPLETE( |
| 3370 | tid := 1, /* Response should arrive within the same transaction */ |
| 3371 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3372 | facility := omit |
| 3373 | /* TODO: cause? */ |
| 3374 | ); |
| 3375 | |
| 3376 | /* Compose expected HLR -> MSC abort message */ |
| 3377 | var template GSUP_PDU gsup_abort := tr_GSUP_PROC_SS_REQ( |
| 3378 | imsi := g_pars.imsi, |
| 3379 | sid := gsup_ms_req_complete.ies[1].val.session_id, |
| 3380 | state := OSMO_GSUP_SESSION_STATE_END |
| 3381 | ); |
| 3382 | |
| 3383 | /* Abort transaction */ |
| 3384 | BSSAP.send(ts_PDU_DTAP_MO(ussd_abort)); |
| 3385 | /* Expect GSUP message indicating abort */ |
| 3386 | f_expect_gsup_msg(gsup_abort); |
| 3387 | |
| 3388 | f_expect_clear(); |
| 3389 | } |
| 3390 | testcase TC_lu_and_mo_ussd_mo_release() runs on MTC_CT { |
| 3391 | var BSC_ConnHdlr vc_conn; |
| 3392 | f_init(); |
| 3393 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_ussd_mo_release), 50); |
| 3394 | vc_conn.done; |
| 3395 | } |
| 3396 | |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 3397 | /* LU followed by MO USSD request and MT Release due to timeout */ |
| 3398 | private function f_tc_lu_and_ss_session_timeout(charstring id, BSC_ConnHdlrPars pars) |
| 3399 | runs on BSC_ConnHdlr { |
| 3400 | f_init_handler(pars); |
| 3401 | |
| 3402 | /* Perform location update */ |
| 3403 | f_perform_lu(); |
| 3404 | |
| 3405 | /* Send CM Service Request for SS/USSD */ |
| 3406 | f_establish_fully(EST_TYPE_SS_ACT); |
| 3407 | |
| 3408 | /* We need to inspect GSUP activity */ |
| 3409 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3410 | |
| 3411 | var template OCTN facility_ms_req := f_USSD_FACILITY_IE_INVOKE( |
| 3412 | invoke_id := 1, |
| 3413 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 3414 | ussd_string := "#release_me"); |
| 3415 | |
| 3416 | /* Compose MO SS/REGISTER message with request */ |
| 3417 | var template (value) PDU_ML3_MS_NW ussd_ms_req := ts_ML3_MO_SS_REGISTER( |
| 3418 | tid := 1, /* An arbitrary transaction identifier */ |
| 3419 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 3420 | facility := valueof(facility_ms_req)); |
| 3421 | |
| 3422 | /* Compose expected MSC -> HLR message */ |
| 3423 | var template GSUP_PDU gsup_ms_req := tr_GSUP_PROC_SS_REQ( |
| 3424 | imsi := g_pars.imsi, |
| 3425 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 3426 | ss := valueof(facility_ms_req)); |
| 3427 | |
| 3428 | /* To be used for sending response with correct session ID */ |
| 3429 | var GSUP_PDU gsup_ms_req_complete; |
| 3430 | |
| 3431 | /* Initiate a new SS transaction */ |
| 3432 | BSSAP.send(ts_PDU_DTAP_MO(ussd_ms_req)); |
| 3433 | /* Expect GSUP request with original Facility IE */ |
| 3434 | gsup_ms_req_complete := f_expect_gsup_msg(gsup_ms_req); |
| 3435 | |
| 3436 | /* Don't respond, wait for timeout */ |
| 3437 | f_sleep(3.0); |
| 3438 | |
| 3439 | var template PDU_ML3_NW_MS dtap_rel := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 3440 | tid := 1, /* Should match the request's tid */ |
| 3441 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 3442 | cause := *, /* TODO: expect some specific value */ |
| 3443 | facility := omit); |
| 3444 | |
| 3445 | var template GSUP_PDU gsup_rel := tr_GSUP_PROC_SS_ERR( |
| 3446 | imsi := g_pars.imsi, |
| 3447 | sid := gsup_ms_req_complete.ies[1].val.session_id, |
| 3448 | state := OSMO_GSUP_SESSION_STATE_END, |
| 3449 | cause := ?); /* TODO: expect some specific value */ |
| 3450 | |
| 3451 | /* Expect release on both interfaces */ |
| 3452 | interleave { |
| 3453 | [] BSSAP.receive(tr_PDU_DTAP_MT(dtap_rel)) { }; |
| 3454 | [] GSUP.receive(gsup_rel) { }; |
| 3455 | } |
| 3456 | |
| 3457 | f_expect_clear(); |
| 3458 | setverdict(pass); |
| 3459 | } |
| 3460 | testcase TC_lu_and_ss_session_timeout() runs on MTC_CT { |
| 3461 | var BSC_ConnHdlr vc_conn; |
| 3462 | f_init(); |
Vadim Yanitskiy | 36d28dd | 2018-12-03 02:45:45 +0700 | [diff] [blame] | 3463 | f_vty_config(MSCVTY, "msc", "ncss guard-timeout 3"); |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 3464 | vc_conn := f_start_handler(refers(f_tc_lu_and_ss_session_timeout), 51); |
| 3465 | vc_conn.done; |
Vadim Yanitskiy | 36d28dd | 2018-12-03 02:45:45 +0700 | [diff] [blame] | 3466 | f_vty_config(MSCVTY, "msc", "ncss guard-timeout 0"); |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 3467 | } |
| 3468 | |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 3469 | /* A5/1 only permitted on network side; attempt an invalid CIPHER MODE COMPLETE with A5/3 which MSC should reject. */ |
| 3470 | private function f_tc_cipher_complete_with_invalid_cipher(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 3471 | pars.net.expect_auth := true; |
| 3472 | pars.net.expect_ciph := true; |
| 3473 | pars.net.kc_support := '02'O; /* A5/1 only */ |
| 3474 | f_init_handler(pars); |
| 3475 | |
| 3476 | g_pars.vec := f_gen_auth_vec_2g(); |
| 3477 | |
| 3478 | /* Can't use f_perform_lu() directly. Code below is based on it. */ |
| 3479 | |
| 3480 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 3481 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3482 | |
| 3483 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 3484 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 3485 | f_bssap_compl_l3(l3_lu); |
| 3486 | |
| 3487 | f_mm_auth(); |
| 3488 | |
| 3489 | var OCT1 a5_net := f_alg_mask_from_cm(g_pars.cm2); |
| 3490 | var OCT1 a5_intersect := g_pars.net.kc_support and4b a5_net; |
| 3491 | alt { |
| 3492 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(a5_intersect, g_pars.vec.kc)) { |
| 3493 | BSSAP.send(ts_BSSMAP_CipherModeCompl(int2oct(4 /* "accept" A5/3 */, 1))); |
| 3494 | } |
| 3495 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?, g_pars.vec.kc)) { |
| 3496 | setverdict(fail, "Wrong ciphering algorithm mask in CiphModCmd"); |
| 3497 | mtc.stop; |
| 3498 | } |
| 3499 | [] BSSAP.receive { |
| 3500 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 3501 | mtc.stop; |
| 3502 | } |
| 3503 | } |
| 3504 | |
| 3505 | /* Expect LU reject from MSC. */ |
| 3506 | alt { |
| 3507 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 3508 | setverdict(pass); |
| 3509 | } |
| 3510 | [] BSSAP.receive { |
| 3511 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 3512 | mtc.stop; |
| 3513 | } |
| 3514 | } |
Stefan Sperling | c620b35 | 2018-12-18 17:23:36 +0100 | [diff] [blame] | 3515 | f_expect_clear(); |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 3516 | } |
| 3517 | |
| 3518 | testcase TC_cipher_complete_with_invalid_cipher() runs on MTC_CT { |
| 3519 | var BSC_ConnHdlr vc_conn; |
| 3520 | f_init(); |
| 3521 | f_vty_config(MSCVTY, "network", "encryption a5 1"); |
| 3522 | |
| 3523 | vc_conn := f_start_handler(refers(f_tc_cipher_complete_with_invalid_cipher), 52); |
| 3524 | vc_conn.done; |
| 3525 | } |
| 3526 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 3527 | /* TODO (SMS): |
| 3528 | * different user data lengths |
| 3529 | * SMPP transaction mode with unsuccessful delivery |
| 3530 | * queued MT-SMS with no paging response + later delivery |
| 3531 | * different data coding schemes |
| 3532 | * multi-part SMS |
| 3533 | * user-data headers |
| 3534 | * TP-PID for SMS to SIM |
| 3535 | * behavior if SMS memory is full + RP-SMMA |
| 3536 | * delivery reports |
| 3537 | * SMPP osmocom extensions |
| 3538 | * more-messages-to-send |
| 3539 | * SMS during ongoing call (SACCH/SAPI3) |
| 3540 | */ |
| 3541 | |
| 3542 | /* TODO (General): |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 3543 | * continue to send repeated MO signalling messages to keep channel open: does MSC tmeout? |
| 3544 | * malformed messages (missing IE, invalid message type): properly rejected? |
| 3545 | * MT call while LU or is ongoing: Do we use existing lchan or page while lchan active? |
| 3546 | * 3G/2G auth permutations |
| 3547 | * encryption algorithms vs. classmark vs. vty config |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 3548 | * send new transaction after/during clear (like SMS, ...) |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 3549 | * too long L3 INFO in DTAP |
| 3550 | * too long / padded BSSAP |
| 3551 | * too long / short TLV values |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 3552 | */ |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 3553 | |
Philipp Maier | 948747b | 2019-04-02 15:22:33 +0200 | [diff] [blame] | 3554 | /* Check if a subscriber exists in the VLR */ |
| 3555 | private function f_ctrl_subscr_in_vlr(charstring imsi_or_msisdn) runs on BSC_ConnHdlr return boolean { |
| 3556 | |
| 3557 | var CtrlValue active_subsribers; |
| 3558 | var integer rc; |
| 3559 | active_subsribers := f_ctrl_get(IPA_CTRL, "subscriber-list-active-v1"); |
| 3560 | |
| 3561 | rc := f_strstr(active_subsribers, imsi_or_msisdn); |
| 3562 | if (rc < 0) { |
| 3563 | return false; |
| 3564 | } |
| 3565 | |
| 3566 | return true; |
| 3567 | } |
| 3568 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 3569 | /* Perform a location updatye at the A-Interface and run some checks to confirm |
| 3570 | * that everything is back to normal. */ |
| 3571 | private function f_sgsap_bssmap_screening() runs on BSC_ConnHdlr { |
| 3572 | var SmsParameters spars := valueof(t_SmsPars); |
| 3573 | |
| 3574 | /* Perform a location update, the SGs association is expected to fall |
| 3575 | * back to NULL */ |
| 3576 | f_perform_lu(); |
| 3577 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 3578 | |
| 3579 | /* Trigger a paging request and expect the paging on BSSMAP, this is |
| 3580 | * to make sure that pagings are sent throught the A-Interface again |
| 3581 | * and not throught the SGs interface.*/ |
Harald Welte | 6811d10 | 2019-04-14 22:23:14 +0200 | [diff] [blame] | 3582 | f_ran_register_imsi(g_pars.imsi, g_pars.tmsi); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 3583 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 3584 | |
| 3585 | alt { |
| 3586 | [] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)); { |
| 3587 | setverdict(pass); |
| 3588 | } |
| 3589 | [] SGsAP.receive { |
| 3590 | setverdict(fail, "Received unexpected message on SGs"); |
| 3591 | } |
| 3592 | } |
| 3593 | |
| 3594 | /* Send an SMS to make sure that also payload messages are routed |
| 3595 | * throught the A-Interface again */ |
| 3596 | f_establish_fully(EST_TYPE_MO_SMS); |
| 3597 | f_mo_sms(spars); |
| 3598 | f_expect_clear(); |
| 3599 | } |
| 3600 | |
| 3601 | private function f_tc_sgsap_reset(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 3602 | var charstring vlr_name; |
| 3603 | f_init_handler(pars); |
| 3604 | |
| 3605 | vlr_name := f_sgsap_reset_mme(mp_mme_name); |
| 3606 | log("VLR name: ", vlr_name); |
| 3607 | setverdict(pass); |
Neels Hofmeyr | c0b520d | 2019-03-06 15:35:50 +0100 | [diff] [blame] | 3608 | f_sleep(1.0); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 3609 | } |
| 3610 | |
| 3611 | testcase TC_sgsap_reset() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 3612 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 3613 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 3614 | f_init(1, true); |
| 3615 | pars := f_init_pars(11810, true); |
| 3616 | 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] | 3617 | vc_conn.done; |
| 3618 | } |
| 3619 | |
| 3620 | /* like f_mm_auth() but for SGs */ |
| 3621 | function f_mm_auth_sgs() runs on BSC_ConnHdlr { |
| 3622 | if (g_pars.net.expect_auth) { |
| 3623 | g_pars.vec := f_gen_auth_vec_3g(); |
| 3624 | var GSUP_IE auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G3G(g_pars.vec.rand, |
| 3625 | g_pars.vec.sres, |
| 3626 | g_pars.vec.kc, |
| 3627 | g_pars.vec.ik, |
| 3628 | g_pars.vec.ck, |
| 3629 | g_pars.vec.autn, |
| 3630 | g_pars.vec.res)); |
| 3631 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 3632 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
| 3633 | SGsAP.receive(tr_ML3_MT_MM_AUTH_REQ_3G(g_pars.vec.rand, g_pars.vec.autn)); |
| 3634 | SGsAP.send(ts_ML3_MT_MM_AUTH_RESP_3G(g_pars.vec.sres, g_pars.vec.res)); |
| 3635 | } |
| 3636 | } |
| 3637 | |
| 3638 | /* like f_perform_lu(), but on SGs rather than BSSAP */ |
| 3639 | function f_sgs_perform_lu() runs on BSC_ConnHdlr { |
| 3640 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 3641 | var PDU_SGsAP lur; |
| 3642 | var PDU_SGsAP lua; |
| 3643 | var PDU_SGsAP mm_info; |
| 3644 | var octetstring mm_info_dtap; |
| 3645 | |
| 3646 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 3647 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3648 | |
| 3649 | lur := valueof(ts_SGsAP_LU_REQ(g_pars.imsi, mme_name, IMSI_attach, |
| 3650 | ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 3651 | /* Old LAI, if MS sends it */ |
| 3652 | /* TMSI status, if MS has no valid TMSI */ |
| 3653 | /* IMEISV, if it supports "automatic device detection" */ |
| 3654 | /* TAI, if available in MME */ |
| 3655 | /* E-CGI, if available in MME */ |
| 3656 | SGsAP.send(lur); |
| 3657 | |
| 3658 | /* FIXME: is this really done over SGs? The Ue is already authenticated |
| 3659 | * via the MME ... */ |
| 3660 | f_mm_auth_sgs(); |
| 3661 | |
| 3662 | /* Expect MSC to perform LU with HLR */ |
| 3663 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 3664 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 3665 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 3666 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 3667 | |
| 3668 | alt { |
| 3669 | [] SGsAP.receive(tr_SGsAP_LU_ACCEPT(g_pars.imsi, ?)) -> value lua { |
| 3670 | if (isvalue(lua.sGsAP_LOCATION_UPDATE_ACCEPT.newTMSIorIMSI.iD.iD.tmsi_ptmsi.octets)) { |
| 3671 | g_pars.tmsi :=lua.sGsAP_LOCATION_UPDATE_ACCEPT.newTMSIorIMSI.iD.iD.tmsi_ptmsi.octets |
| 3672 | SGsAP.send(ts_SGsAP_TMSI_REALL_CMPL(g_pars.imsi)); |
| 3673 | } |
| 3674 | setverdict(pass); |
| 3675 | } |
| 3676 | [] SGsAP.receive(tr_SGsAP_LU_REJECT(g_pars.imsi, ?, ?)) { |
| 3677 | setverdict(fail, "Received LU-REJECT instead of ACCEPT"); |
| 3678 | } |
| 3679 | [] SGsAP.receive { |
| 3680 | setverdict(fail, "Received unexpected message on SGs"); |
| 3681 | } |
| 3682 | } |
| 3683 | |
| 3684 | /* Check MM information */ |
| 3685 | if (mp_mm_info == true) { |
| 3686 | SGsAP.receive(tr_SGsAP_MM_INFO_REQ(g_pars.imsi, ?)) -> value mm_info; |
| 3687 | mm_info_dtap := '0532'O & mm_info.sGsAP_MM_INFORMATION_REQUEST.mM_Information.information; |
| 3688 | if (not match(dec_PDU_ML3_NW_MS(mm_info_dtap), tr_ML3_MT_MM_Info)) { |
| 3689 | setverdict(fail, "Unexpected MM Information"); |
| 3690 | } |
| 3691 | } |
| 3692 | |
| 3693 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 3694 | } |
| 3695 | |
| 3696 | private function f_tc_sgsap_lu(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 3697 | f_init_handler(pars); |
| 3698 | f_sgs_perform_lu(); |
| 3699 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 3700 | |
| 3701 | f_sgsap_bssmap_screening(); |
| 3702 | |
| 3703 | setverdict(pass); |
| 3704 | } |
| 3705 | testcase TC_sgsap_lu() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 3706 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 3707 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 3708 | f_init(1, true); |
| 3709 | pars := f_init_pars(11811, true); |
| 3710 | 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] | 3711 | vc_conn.done; |
| 3712 | } |
| 3713 | |
| 3714 | /* Do LU by IMSI, refuse it on GSUP and expect LU REJ back to MS */ |
| 3715 | private function f_tc_sgsap_lu_imsi_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 3716 | f_init_handler(pars); |
| 3717 | var PDU_SGsAP lur; |
| 3718 | |
| 3719 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3720 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 3721 | lur := valueof(ts_SGsAP_LU_REQ(g_pars.imsi, mme_name, IMSI_attach, |
| 3722 | ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 3723 | SGsAP.send(lur); |
| 3724 | |
| 3725 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 3726 | GSUP.send(ts_GSUP_UL_ERR(g_pars.imsi, 23)); |
| 3727 | alt { |
| 3728 | [] SGsAP.receive(tr_SGsAP_LU_REJECT(g_pars.imsi, ?, ?)) { |
| 3729 | setverdict(pass); |
| 3730 | } |
| 3731 | [] SGsAP.receive(tr_SGsAP_LU_ACCEPT(g_pars.imsi, ?)) { |
| 3732 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
| 3733 | mtc.stop; |
| 3734 | } |
| 3735 | [] SGsAP.receive { |
| 3736 | setverdict(fail, "Received unexpected message on SGs"); |
| 3737 | } |
| 3738 | } |
| 3739 | |
| 3740 | f_sgsap_bssmap_screening(); |
| 3741 | |
| 3742 | setverdict(pass); |
| 3743 | } |
| 3744 | testcase TC_sgsap_lu_imsi_reject() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 3745 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 3746 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 3747 | f_init(1, true); |
| 3748 | pars := f_init_pars(11812, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 3749 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 3750 | 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] | 3751 | vc_conn.done; |
| 3752 | } |
| 3753 | |
| 3754 | /* Do LU by IMSI, but then remain silent so that Ts6-1 times out */ |
| 3755 | private function f_tc_sgsap_lu_and_nothing(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 3756 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 3757 | var PDU_SGsAP lur; |
| 3758 | |
| 3759 | f_init_handler(pars); |
| 3760 | |
| 3761 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 3762 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 3763 | |
| 3764 | lur := valueof(ts_SGsAP_LU_REQ(g_pars.imsi, mme_name, IMSI_attach, |
| 3765 | ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 3766 | /* Old LAI, if MS sends it */ |
| 3767 | /* TMSI status, if MS has no valid TMSI */ |
| 3768 | /* IMEISV, if it supports "automatic device detection" */ |
| 3769 | /* TAI, if available in MME */ |
| 3770 | /* E-CGI, if available in MME */ |
| 3771 | SGsAP.send(lur); |
| 3772 | |
| 3773 | /* FIXME: is this really done over SGs? The Ue is already authenticated |
| 3774 | * via the MME ... */ |
| 3775 | f_mm_auth_sgs(); |
| 3776 | |
| 3777 | /* Expect MSC to perform LU with HLR */ |
| 3778 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 3779 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 3780 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 3781 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 3782 | |
| 3783 | alt { |
| 3784 | [] SGsAP.receive(tr_SGsAP_LU_ACCEPT(g_pars.imsi, ?)) { |
| 3785 | setverdict(pass); |
| 3786 | } |
| 3787 | [] SGsAP.receive(tr_SGsAP_LU_REJECT(g_pars.imsi, ?, ?)) { |
| 3788 | setverdict(fail, "Received LU-REJECT instead of ACCEPT"); |
| 3789 | } |
| 3790 | [] SGsAP.receive { |
| 3791 | setverdict(fail, "Received unexpected message on SGs"); |
| 3792 | } |
| 3793 | } |
| 3794 | |
| 3795 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 3796 | |
| 3797 | /* Wait until the VLR has abort the TMSI reallocation procedure */ |
| 3798 | f_sleep(45.0); |
| 3799 | |
| 3800 | /* The outcome does not change the SGs state, see also 5.2.3.4 */ |
| 3801 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 3802 | |
| 3803 | f_sgsap_bssmap_screening(); |
| 3804 | |
| 3805 | setverdict(pass); |
| 3806 | } |
| 3807 | testcase TC_sgsap_lu_and_nothing() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 3808 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 3809 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 3810 | f_init(1, true); |
| 3811 | pars := f_init_pars(11813, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 3812 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 3813 | 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] | 3814 | vc_conn.done; |
| 3815 | } |
| 3816 | |
| 3817 | private function f_tc_sgsap_expl_imsi_det_eps(charstring id, BSC_ConnHdlrPars pars) |
| 3818 | runs on BSC_ConnHdlr { |
| 3819 | f_init_handler(pars); |
| 3820 | f_sgs_perform_lu(); |
| 3821 | f_sleep(3.0); |
| 3822 | |
| 3823 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 3824 | SGsAP.send(ts_SGsAP_EPS_DETACH_IND(g_pars.imsi, mme_name, UE_initiated)); |
| 3825 | SGsAP.receive(tr_SGsAP_EPS_DETACH_ACK(g_pars.imsi)); |
| 3826 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 3827 | |
| 3828 | f_sgsap_bssmap_screening(); |
| 3829 | |
| 3830 | setverdict(pass); |
| 3831 | } |
| 3832 | testcase TC_sgsap_expl_imsi_det_eps() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 3833 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 3834 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 3835 | f_init(1, true); |
| 3836 | pars := f_init_pars(11814, true); |
| 3837 | 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] | 3838 | vc_conn.done; |
| 3839 | } |
| 3840 | |
Philipp Maier | fc19f17 | 2019-03-21 11:17:54 +0100 | [diff] [blame] | 3841 | private function f_tc_sgsap_impl_imsi_det_eps(charstring id, BSC_ConnHdlrPars pars) |
| 3842 | runs on BSC_ConnHdlr { |
| 3843 | f_init_handler(pars); |
| 3844 | f_sgs_perform_lu(); |
| 3845 | f_sleep(3.0); |
| 3846 | |
| 3847 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 3848 | SGsAP.send(ts_SGsAP_EPS_DETACH_IND(g_pars.imsi, mme_name, network_initiated)); |
| 3849 | SGsAP.receive(tr_SGsAP_EPS_DETACH_ACK(g_pars.imsi)); |
| 3850 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 3851 | |
| 3852 | f_sgsap_bssmap_screening(); |
| 3853 | |
| 3854 | setverdict(pass); |
| 3855 | } |
| 3856 | testcase TC_sgsap_impl_imsi_det_eps() runs on MTC_CT { |
| 3857 | var BSC_ConnHdlrPars pars; |
| 3858 | var BSC_ConnHdlr vc_conn; |
| 3859 | f_init(1, true); |
| 3860 | pars := f_init_pars(11814, true); |
| 3861 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_impl_imsi_det_eps), pars); |
| 3862 | vc_conn.done; |
| 3863 | } |
| 3864 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 3865 | private function f_tc_sgsap_expl_imsi_det_noneps(charstring id, BSC_ConnHdlrPars pars) |
| 3866 | runs on BSC_ConnHdlr { |
| 3867 | f_init_handler(pars); |
| 3868 | f_sgs_perform_lu(); |
| 3869 | f_sleep(3.0); |
| 3870 | |
| 3871 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 3872 | SGsAP.send(ts_SGsAP_IMSI_DETACH_IND(g_pars.imsi, mme_name, combined_UE_initiated)); |
| 3873 | SGsAP.receive(tr_SGsAP_IMSI_DETACH_ACK(g_pars.imsi)); |
Philipp Maier | d08e7e7 | 2019-04-02 15:27:10 +0200 | [diff] [blame] | 3874 | |
| 3875 | if (f_ctrl_subscr_in_vlr(hex2str(g_pars.imsi))) { |
| 3876 | setverdict(fail, "subscriber not removed from VLR"); |
| 3877 | } |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 3878 | |
| 3879 | f_sgsap_bssmap_screening(); |
| 3880 | |
| 3881 | setverdict(pass); |
| 3882 | } |
| 3883 | testcase TC_sgsap_expl_imsi_det_noneps() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 3884 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 3885 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 3886 | f_init(1, true); |
| 3887 | pars := f_init_pars(11815, true); |
| 3888 | 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] | 3889 | vc_conn.done; |
| 3890 | } |
| 3891 | |
Philipp Maier | 5d81270 | 2019-03-21 10:51:26 +0100 | [diff] [blame] | 3892 | private function f_tc_sgsap_impl_imsi_det_noneps(charstring id, BSC_ConnHdlrPars pars) |
| 3893 | runs on BSC_ConnHdlr { |
| 3894 | f_init_handler(pars); |
| 3895 | f_sgs_perform_lu(); |
| 3896 | f_sleep(3.0); |
| 3897 | |
| 3898 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 3899 | SGsAP.send(ts_SGsAP_IMSI_DETACH_IND(g_pars.imsi, mme_name, implicit_network_initiated)); |
| 3900 | SGsAP.receive(tr_SGsAP_IMSI_DETACH_ACK(g_pars.imsi)); |
| 3901 | |
| 3902 | if (f_ctrl_subscr_in_vlr(hex2str(g_pars.imsi))) { |
| 3903 | setverdict(fail, "subscriber not removed from VLR"); |
| 3904 | } |
| 3905 | |
| 3906 | f_sgsap_bssmap_screening(); |
| 3907 | |
| 3908 | setverdict(pass); |
| 3909 | } |
| 3910 | testcase TC_sgsap_impl_imsi_det_noneps() runs on MTC_CT { |
| 3911 | var BSC_ConnHdlrPars pars; |
| 3912 | var BSC_ConnHdlr vc_conn; |
| 3913 | f_init(1, true); |
| 3914 | pars := f_init_pars(11815, true); |
| 3915 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_impl_imsi_det_noneps), pars); |
| 3916 | vc_conn.done; |
| 3917 | } |
| 3918 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 3919 | /* Trigger a paging request via VTY and send a paging reject in response */ |
| 3920 | private function f_tc_sgsap_paging_rej(charstring id, BSC_ConnHdlrPars pars) |
| 3921 | runs on BSC_ConnHdlr { |
| 3922 | f_init_handler(pars); |
| 3923 | f_sgs_perform_lu(); |
| 3924 | f_sleep(1.0); |
| 3925 | |
| 3926 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 3927 | var template PDU_SGsAP exp_resp := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, CS_call_indicator, omit); |
| 3928 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 3929 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 3930 | |
| 3931 | /* Initiate paging via VTY */ |
| 3932 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 3933 | alt { |
| 3934 | [] SGsAP.receive(exp_resp) { |
| 3935 | setverdict(pass); |
| 3936 | } |
| 3937 | [] SGsAP.receive { |
| 3938 | setverdict(fail, "Received unexpected message on SGs"); |
| 3939 | } |
| 3940 | } |
| 3941 | |
| 3942 | /* Now reject the paging */ |
| 3943 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, IMSI_unknown)); |
| 3944 | |
| 3945 | /* Wait for the states inside the MSC to settle and check the state |
| 3946 | * of the SGs Association */ |
| 3947 | f_sleep(1.0); |
| 3948 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 3949 | |
| 3950 | /* FIXME: At the moment we send an IMSI_unknown as cause code, which is fine, |
| 3951 | * but we also need to cover tha case where the cause code indicates an |
| 3952 | * "IMSI detached for EPS services". In those cases the VLR is expected to |
| 3953 | * try paging on tha A/Iu interface. This will be another testcase similar to |
| 3954 | * this one, but extended with checks for the presence of the A/Iu paging |
| 3955 | * messages. */ |
| 3956 | |
| 3957 | f_sgsap_bssmap_screening(); |
| 3958 | |
| 3959 | setverdict(pass); |
| 3960 | } |
| 3961 | testcase TC_sgsap_paging_rej() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 3962 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 3963 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 3964 | f_init(1, true); |
| 3965 | pars := f_init_pars(11816, true); |
| 3966 | 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] | 3967 | vc_conn.done; |
| 3968 | } |
| 3969 | |
| 3970 | /* Trigger a paging request via VTY and send a paging reject that indicates |
| 3971 | * that the subscriber intentionally rejected the call. */ |
| 3972 | private function f_tc_sgsap_paging_subscr_rej(charstring id, BSC_ConnHdlrPars pars) |
| 3973 | runs on BSC_ConnHdlr { |
| 3974 | f_init_handler(pars); |
| 3975 | f_sgs_perform_lu(); |
| 3976 | f_sleep(1.0); |
| 3977 | |
| 3978 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 3979 | var template PDU_SGsAP exp_resp := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, CS_call_indicator, omit); |
| 3980 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 3981 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 3982 | |
| 3983 | /* Initiate paging via VTY */ |
| 3984 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 3985 | alt { |
| 3986 | [] SGsAP.receive(exp_resp) { |
| 3987 | setverdict(pass); |
| 3988 | } |
| 3989 | [] SGsAP.receive { |
| 3990 | setverdict(fail, "Received unexpected message on SGs"); |
| 3991 | } |
| 3992 | } |
| 3993 | |
| 3994 | /* Now reject the paging */ |
| 3995 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, user_rejected_mobile_terminating_CS_fallback_call)); |
| 3996 | |
| 3997 | /* Wait for the states inside the MSC to settle and check the state |
| 3998 | * of the SGs Association */ |
| 3999 | f_sleep(1.0); |
| 4000 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4001 | |
| 4002 | /* FIXME: The VLR is supposed to trigger an User Determined User Busy (UDUB) as specified |
| 4003 | * in 3GPP TS 24.082, this is not yet implemented in the MSC or in this tests, we need |
| 4004 | * to check back how this works and how it can be tested */ |
| 4005 | |
| 4006 | f_sgsap_bssmap_screening(); |
| 4007 | |
| 4008 | setverdict(pass); |
| 4009 | } |
| 4010 | testcase TC_sgsap_paging_subscr_rej() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4011 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4012 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4013 | f_init(1, true); |
| 4014 | pars := f_init_pars(11817, true); |
| 4015 | 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] | 4016 | vc_conn.done; |
| 4017 | } |
| 4018 | |
| 4019 | /* Trigger a paging request via VTY and send an UE unreacable messge in response */ |
| 4020 | private function f_tc_sgsap_paging_ue_unr(charstring id, BSC_ConnHdlrPars pars) |
| 4021 | runs on BSC_ConnHdlr { |
| 4022 | f_init_handler(pars); |
| 4023 | f_sgs_perform_lu(); |
| 4024 | f_sleep(1.0); |
| 4025 | |
| 4026 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4027 | var template PDU_SGsAP exp_resp := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, CS_call_indicator, omit); |
| 4028 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4029 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 4030 | |
| 4031 | /* Initiate paging via VTY */ |
| 4032 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 4033 | alt { |
| 4034 | [] SGsAP.receive(exp_resp) { |
| 4035 | setverdict(pass); |
| 4036 | } |
| 4037 | [] SGsAP.receive { |
| 4038 | setverdict(fail, "Received unexpected message on SGs"); |
| 4039 | } |
| 4040 | } |
| 4041 | |
| 4042 | /* Now pretend that the UE is unreachable */ |
| 4043 | SGsAP.send(ts_SGsAP_UE_UNREACHABLE(g_pars.imsi, UE_unreachable)); |
| 4044 | |
| 4045 | /* Wait for the states inside the MSC to settle and check the state |
| 4046 | * of the SGs Association. */ |
| 4047 | f_sleep(1.0); |
| 4048 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4049 | |
| 4050 | f_sgsap_bssmap_screening(); |
| 4051 | |
| 4052 | setverdict(pass); |
| 4053 | } |
| 4054 | testcase TC_sgsap_paging_ue_unr() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4055 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4056 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4057 | f_init(1, true); |
| 4058 | pars := f_init_pars(11818, true); |
| 4059 | 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] | 4060 | vc_conn.done; |
| 4061 | } |
| 4062 | |
| 4063 | /* Trigger a paging request via VTY but don't respond to it */ |
| 4064 | private function f_tc_sgsap_paging_and_nothing(charstring id, BSC_ConnHdlrPars pars) |
| 4065 | runs on BSC_ConnHdlr { |
| 4066 | f_init_handler(pars); |
| 4067 | f_sgs_perform_lu(); |
| 4068 | f_sleep(1.0); |
| 4069 | |
| 4070 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4071 | var template PDU_SGsAP exp_resp := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, CS_call_indicator, omit); |
| 4072 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4073 | exp_resp.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 4074 | |
| 4075 | /* Initiate paging via VTY */ |
| 4076 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 4077 | alt { |
| 4078 | [] SGsAP.receive(exp_resp) { |
| 4079 | setverdict(pass); |
| 4080 | } |
| 4081 | [] SGsAP.receive { |
| 4082 | setverdict(fail, "Received unexpected message on SGs"); |
| 4083 | } |
| 4084 | } |
| 4085 | |
| 4086 | /* Now do nothing, the MSC/VLR should fail silently to page after a |
| 4087 | * few seconds, The SGs association must remain unchanged. */ |
| 4088 | f_sleep(15.0); |
| 4089 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4090 | |
| 4091 | f_sgsap_bssmap_screening(); |
| 4092 | |
| 4093 | setverdict(pass); |
| 4094 | } |
| 4095 | testcase TC_sgsap_paging_and_nothing() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4096 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4097 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4098 | f_init(1, true); |
| 4099 | pars := f_init_pars(11819, true); |
| 4100 | 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] | 4101 | vc_conn.done; |
| 4102 | } |
| 4103 | |
| 4104 | /* Trigger a paging request via VTY and slip in an LU */ |
| 4105 | private function f_tc_sgsap_paging_and_lu(charstring id, BSC_ConnHdlrPars pars) |
| 4106 | runs on BSC_ConnHdlr { |
| 4107 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4108 | f_init_handler(pars); |
| 4109 | |
| 4110 | /* First we prepar the situation, where the SGs association is in state |
| 4111 | * NULL and the confirmed by radio contact indicator is set to false |
| 4112 | * as well. This can be archived by performing an SGs LU and then |
| 4113 | * resetting the VLR */ |
| 4114 | f_sgs_perform_lu(); |
| 4115 | f_sgsap_reset_mme(mp_mme_name); |
| 4116 | f_sleep(1.0); |
| 4117 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4118 | |
| 4119 | /* Perform a paging, expect the paging messages on the SGs interface */ |
| 4120 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 4121 | alt { |
| 4122 | [] SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)) { |
| 4123 | setverdict(pass); |
| 4124 | } |
| 4125 | [] SGsAP.receive { |
| 4126 | setverdict(fail, "Received unexpected message on SGs"); |
| 4127 | } |
| 4128 | } |
| 4129 | |
| 4130 | /* Perform the LU as normal */ |
| 4131 | f_sgs_perform_lu(); |
| 4132 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4133 | |
| 4134 | /* Expect a new paging request right after the LU */ |
| 4135 | alt { |
| 4136 | [] SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)) { |
| 4137 | setverdict(pass); |
| 4138 | } |
| 4139 | [] SGsAP.receive { |
| 4140 | setverdict(fail, "Received unexpected message on SGs"); |
| 4141 | } |
| 4142 | } |
| 4143 | |
| 4144 | /* Test is done now, lets round everything up by rejecting the paging |
| 4145 | * cleanly. */ |
| 4146 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, user_rejected_mobile_terminating_CS_fallback_call)); |
| 4147 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4148 | |
| 4149 | f_sgsap_bssmap_screening(); |
| 4150 | |
| 4151 | setverdict(pass); |
| 4152 | } |
| 4153 | testcase TC_sgsap_paging_and_lu() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4154 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4155 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4156 | f_init(1, true); |
| 4157 | pars := f_init_pars(11820, true); |
| 4158 | 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] | 4159 | vc_conn.done; |
| 4160 | } |
| 4161 | |
| 4162 | /* Send unexpected unit-data through the SGs interface */ |
| 4163 | private function f_tc_sgsap_unexp_ud(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4164 | f_init_handler(pars); |
| 4165 | f_sleep(1.0); |
| 4166 | |
| 4167 | /* This simulates what happens when a subscriber without SGs |
| 4168 | * association gets unitdata via the SGs interface. */ |
| 4169 | |
| 4170 | /* Make sure the subscriber exists and the SGs association |
| 4171 | * is in NULL state */ |
| 4172 | f_perform_lu(); |
| 4173 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4174 | |
| 4175 | /* Send some random unit data, the MSC/VLR should send a release |
| 4176 | * immediately. */ |
| 4177 | SGsAP.send(ts_SGsAP_UL_UD(pars.imsi,'1234'O)); |
| 4178 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, IMSI_detached_for_EPS_nonEPS_services)); |
| 4179 | |
| 4180 | f_sgsap_bssmap_screening(); |
| 4181 | |
| 4182 | setverdict(pass); |
| 4183 | } |
| 4184 | testcase TC_sgsap_unexp_ud() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4185 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4186 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4187 | f_init(1, true); |
| 4188 | pars := f_init_pars(11821, true); |
| 4189 | 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] | 4190 | vc_conn.done; |
| 4191 | } |
| 4192 | |
| 4193 | /* Send unsolicited unit-data through the SGs interface */ |
| 4194 | private function f_tc_sgsap_unsol_ud(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4195 | f_init_handler(pars); |
| 4196 | f_sleep(1.0); |
| 4197 | |
| 4198 | /* This simulates what happens when the MME attempts to send unitdata |
| 4199 | * to a subscriber that is completely unknown to the VLR */ |
| 4200 | |
| 4201 | /* Send some random unit data, the MSC/VLR should send a release |
| 4202 | * immediately. */ |
| 4203 | SGsAP.send(ts_SGsAP_UL_UD(pars.imsi,'1234'O)); |
| 4204 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, IMSI_unknown)); |
| 4205 | |
| 4206 | f_sgsap_bssmap_screening(); |
| 4207 | |
| 4208 | setverdict(pass); |
| 4209 | } |
| 4210 | testcase TC_sgsap_unsol_ud() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4211 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4212 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4213 | f_init(1, true); |
| 4214 | pars := f_init_pars(11822, true); |
| 4215 | 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] | 4216 | vc_conn.done; |
| 4217 | } |
| 4218 | |
| 4219 | private altstep as_other_sms_sgs() runs on BSC_ConnHdlr { |
| 4220 | /* FIXME: Match an actual payload (second questionmark), the type is |
| 4221 | * octetstring, how do we use a tr_PDU_DTAP_MT here? */ |
| 4222 | [] SGsAP.receive(tr_SGsAP_DL_UD(?,?)) { |
| 4223 | setverdict(fail, "Unexpected SMS related PDU from MSC"); |
| 4224 | mtc.stop; |
| 4225 | } |
| 4226 | } |
| 4227 | |
| 4228 | /* receive a MT-SMS delivered from the MSC/SMSC over an already existing SGsAP connection */ |
| 4229 | function f_mt_sms_sgs(inout SmsParameters spars) |
| 4230 | runs on BSC_ConnHdlr { |
| 4231 | var template (value) TPDU_RP_DATA_MS_SGSN tp_mo; |
| 4232 | var template (value) RPDU_MS_SGSN rp_mo; |
| 4233 | var template (value) PDU_ML3_MS_NW l3_mo; |
| 4234 | |
| 4235 | var template TPDU_RP_DATA_SGSN_MS tp_mt; |
| 4236 | var template RPDU_SGSN_MS rp_mt; |
| 4237 | var template PDU_ML3_NW_MS l3_mt; |
| 4238 | |
| 4239 | var PDU_ML3_NW_MS sgsap_l3_mt; |
| 4240 | |
| 4241 | var default d := activate(as_other_sms_sgs()); |
| 4242 | |
| 4243 | /* Expect CP-DATA(RP-DATA(SMS-DELIVER)) */ |
| 4244 | tp_mt := tr_SMS_DELIVER(?, spars.tp.ud, spars.tp.pid, spars.tp.dcs, ?); |
| 4245 | rp_mt := tr_RP_DATA_MT(?, ?, omit, tp_mt); |
| 4246 | l3_mt := tr_ML3_MT_SMS(?, c_TIF_ORIG, tr_CP_DATA_MT(rp_mt)); |
| 4247 | |
| 4248 | SGsAP.receive(l3_mt) -> value sgsap_l3_mt; |
| 4249 | |
| 4250 | /* Extract relevant identifiers */ |
| 4251 | spars.tid := bit2int(sgsap_l3_mt.tiOrSkip.transactionId.tio); |
| 4252 | spars.rp.msg_ref := sgsap_l3_mt.msgs.sms.cP_DATA.cP_User_Data.cP_RPDU.rP_DATA_SGSN_MS.rP_MessageReference; |
| 4253 | |
| 4254 | /* send CP-ACK for CP-DATA just received */ |
| 4255 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_REPL, ts_CP_ACK_MO); |
| 4256 | |
| 4257 | SGsAP.send(l3_mo); |
| 4258 | |
| 4259 | /* send RP-ACK for RP-DATA */ |
| 4260 | rp_mo := ts_RP_ACK_MO(spars.rp.msg_ref); |
| 4261 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_REPL, ts_CP_DATA_MO(rp_mo)); |
| 4262 | |
| 4263 | SGsAP.send(l3_mo); |
| 4264 | |
| 4265 | /* expect CP-ACK for CP-DATA(RP-ACK) just sent */ |
| 4266 | l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_ORIG, tr_CP_ACK_MT); |
| 4267 | |
| 4268 | SGsAP.receive(l3_mt); |
| 4269 | |
| 4270 | deactivate(d); |
| 4271 | |
| 4272 | setverdict(pass); |
| 4273 | } |
| 4274 | |
| 4275 | /* submit a MO-SMS to MSC/SMSC over an already existing SGsAP connection */ |
| 4276 | function f_mo_sms_sgs(inout SmsParameters spars) |
| 4277 | runs on BSC_ConnHdlr { |
| 4278 | var template (value) TPDU_RP_DATA_MS_SGSN tp_mo; |
| 4279 | var template (value) RPDU_MS_SGSN rp_mo; |
| 4280 | var template (value) PDU_ML3_MS_NW l3_mo; |
| 4281 | |
| 4282 | var template TPDU_RP_DATA_SGSN_MS tp_mt; |
| 4283 | var template RPDU_SGSN_MS rp_mt; |
| 4284 | var template PDU_ML3_NW_MS l3_mt; |
| 4285 | |
| 4286 | var default d := activate(as_other_sms_sgs()); |
| 4287 | |
| 4288 | /* just in case this is routed to SMPP.. */ |
| 4289 | f_create_smpp_expect(hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue)); |
| 4290 | |
| 4291 | tp_mo := ts_SMS_SUBMIT(spars.tp.msg_ref, spars.tp.da, spars.tp.pid, spars.tp.dcs, |
| 4292 | spars.tp.udl, spars.tp.ud); |
| 4293 | rp_mo := ts_RP_DATA_MO(spars.rp.msg_ref, spars.rp.orig, spars.rp.dest, tp_mo); |
| 4294 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_DATA_MO(rp_mo)); |
| 4295 | |
| 4296 | SGsAP.send(l3_mo); |
| 4297 | |
| 4298 | /* receive CP-ACK for CP-DATA above */ |
| 4299 | SGsAP.receive(tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_ACK_MT)); |
| 4300 | |
| 4301 | if (ispresent(spars.exp_rp_err)) { |
| 4302 | /* expect an RP-ERROR message from MSC with given cause */ |
| 4303 | rp_mt := tr_RP_ERROR_MT(spars.rp.msg_ref, spars.exp_rp_err); |
| 4304 | l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_DATA_MT(rp_mt)); |
| 4305 | SGsAP.receive(l3_mt); |
| 4306 | /* send CP-ACK for CP-DATA just received */ |
| 4307 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_ACK_MO); |
| 4308 | SGsAP.send(l3_mo); |
| 4309 | } else { |
| 4310 | /* expect RP-ACK for RP-DATA */ |
| 4311 | rp_mt := tr_RP_ACK_MT(spars.rp.msg_ref); |
| 4312 | l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_DATA_MT(rp_mt)); |
| 4313 | SGsAP.receive(l3_mt); |
| 4314 | /* send CP-ACO for CP-DATA just received */ |
| 4315 | l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_ACK_MO); |
| 4316 | SGsAP.send(l3_mo); |
| 4317 | } |
| 4318 | |
| 4319 | deactivate(d); |
| 4320 | |
| 4321 | setverdict(pass); |
| 4322 | } |
| 4323 | |
| 4324 | private function f_vty_sms_send_conn_hdlr(charstring imsi, charstring msisdn, charstring text) |
| 4325 | runs on BSC_ConnHdlr { |
| 4326 | f_vty_transceive(MSCVTY, "subscriber imsi "&imsi&" sms sender msisdn "&msisdn&" send "&text); |
| 4327 | } |
| 4328 | |
| 4329 | /* Send a MT SMS via SGs interface */ |
| 4330 | private function f_tc_sgsap_mt_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4331 | f_init_handler(pars); |
| 4332 | f_sgs_perform_lu(); |
| 4333 | f_sleep(1.0); |
| 4334 | var SmsParameters spars := valueof(t_SmsPars); |
| 4335 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 4336 | |
| 4337 | /* Trigger SMS via VTY */ |
| 4338 | f_vty_sms_send_conn_hdlr(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 4339 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4340 | |
| 4341 | /* Expect a paging request and respond accordingly with a service request */ |
| 4342 | SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, SMS_indicator, omit)); |
| 4343 | SGsAP.send(ts_SGsAP_SERVICE_REQ(pars.imsi, SMS_indicator, EMM_CONNECTED)); |
| 4344 | |
| 4345 | /* Connection is now live, receive the MT-SMS */ |
| 4346 | f_mt_sms_sgs(spars); |
| 4347 | |
| 4348 | /* Expect a concluding release from the MSC */ |
| 4349 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, omit)); |
| 4350 | |
| 4351 | /* Make sure that subscriber is still present and the SGs association is in tact (ref-counting) */ |
| 4352 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4353 | |
| 4354 | f_sgsap_bssmap_screening(); |
| 4355 | |
| 4356 | setverdict(pass); |
| 4357 | } |
| 4358 | testcase TC_sgsap_mt_sms() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4359 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4360 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4361 | f_init(1, true); |
| 4362 | pars := f_init_pars(11823, true); |
| 4363 | 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] | 4364 | vc_conn.done; |
| 4365 | } |
| 4366 | |
| 4367 | /* Send a MO SMS via SGs interface */ |
| 4368 | private function f_tc_sgsap_mo_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4369 | f_init_handler(pars); |
| 4370 | f_sgs_perform_lu(); |
| 4371 | f_sleep(1.0); |
| 4372 | var SmsParameters spars := valueof(t_SmsPars); |
| 4373 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 4374 | |
| 4375 | /* Send the MO-SMS */ |
| 4376 | f_mo_sms_sgs(spars); |
| 4377 | |
| 4378 | /* Expect a concluding release from the MSC/VLR */ |
| 4379 | SGsAP.receive(tr_SGsAP_RELEASE_REQ(pars.imsi, omit)); |
| 4380 | |
| 4381 | /* Make sure that subscriber is still present and the SGs association is in tact (ref-counting) */ |
| 4382 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4383 | |
| 4384 | setverdict(pass); |
| 4385 | |
| 4386 | f_sgsap_bssmap_screening() |
| 4387 | } |
| 4388 | testcase TC_sgsap_mo_sms() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4389 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4390 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4391 | f_init(1, true); |
| 4392 | pars := f_init_pars(11824, true); |
| 4393 | 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] | 4394 | vc_conn.done; |
| 4395 | } |
| 4396 | |
| 4397 | /* Trigger sending of an MT sms via VTY but never respond to anything */ |
| 4398 | private function f_tc_sgsap_mt_sms_and_nothing(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4399 | f_init_handler(pars, 170.0); |
| 4400 | f_sgs_perform_lu(); |
| 4401 | f_sleep(1.0); |
| 4402 | |
| 4403 | var SmsParameters spars := valueof(t_SmsPars); |
| 4404 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 4405 | var integer page_count := 0; |
| 4406 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4407 | var template PDU_SGsAP exp_pag_req := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, SMS_indicator, omit); |
| 4408 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4409 | exp_pag_req.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 4410 | |
| 4411 | /* Trigger SMS via VTY */ |
| 4412 | f_vty_sms_send_conn_hdlr(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 4413 | |
Neels Hofmeyr | 1623774 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 4414 | /* Expect the MSC/VLR to page exactly once */ |
| 4415 | SGsAP.receive(exp_pag_req); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4416 | |
| 4417 | /* Wait some time to make sure the MSC is not delivering any further |
| 4418 | * paging messages or anything else that could be unexpected. */ |
| 4419 | timer T := 20.0; |
| 4420 | T.start |
| 4421 | alt { |
| 4422 | [] SGsAP.receive(exp_pag_req) |
| 4423 | { |
| 4424 | setverdict(fail, "paging seems not to stop!"); |
| 4425 | mtc.stop; |
| 4426 | } |
| 4427 | [] SGsAP.receive { |
| 4428 | setverdict(fail, "unexpected SGsAP message received"); |
| 4429 | self.stop; |
| 4430 | } |
| 4431 | [] T.timeout { |
| 4432 | setverdict(pass); |
| 4433 | } |
| 4434 | } |
| 4435 | |
| 4436 | /* Even on a failed paging the SGs Association should stay intact */ |
| 4437 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4438 | |
| 4439 | /* Note: We do not execute f_sgsap_bssmap_screening() here since the |
| 4440 | * MSC/VLR would re-try to deliver the test SMS trigered above and |
| 4441 | * so the screening would fail. */ |
| 4442 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 4443 | f_vty_sms_clear(hex2str(g_pars.imsi)); |
| 4444 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4445 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " expire"); |
| 4446 | |
| 4447 | setverdict(pass); |
Neels Hofmeyr | b0f8234 | 2019-03-06 15:36:51 +0100 | [diff] [blame] | 4448 | |
| 4449 | f_sgsap_bssmap_screening(); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4450 | } |
| 4451 | testcase TC_sgsap_mt_sms_and_nothing() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4452 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4453 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4454 | f_init(1, true); |
| 4455 | pars := f_init_pars(11825, true); |
| 4456 | 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] | 4457 | vc_conn.done; |
| 4458 | } |
| 4459 | |
| 4460 | /* Trigger sending of an MT sms via VTY but reject the paging immediately */ |
| 4461 | private function f_tc_sgsap_mt_sms_and_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4462 | f_init_handler(pars, 150.0); |
| 4463 | f_sgs_perform_lu(); |
| 4464 | f_sleep(1.0); |
| 4465 | |
| 4466 | var SmsParameters spars := valueof(t_SmsPars); |
| 4467 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 4468 | var integer page_count := 0; |
| 4469 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4470 | var template PDU_SGsAP exp_pag_req := tr_SGsAP_PAGING_REQ(g_pars.imsi, vlr_name, SMS_indicator, omit); |
| 4471 | var template LocationAreaId exp_lai := ts_SGsAP_IE_Lai(valueof(ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4472 | exp_pag_req.sGsAP_PAGING_REQUEST.locationAreaId := exp_lai; |
| 4473 | |
| 4474 | /* Trigger SMS via VTY */ |
| 4475 | f_vty_sms_send_conn_hdlr(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 4476 | |
| 4477 | /* Expect a paging request and reject it immediately */ |
| 4478 | SGsAP.receive(exp_pag_req); |
| 4479 | SGsAP.send(ts_SGsAP_PAGING_REJ(g_pars.imsi, IMSI_unknown)); |
| 4480 | |
| 4481 | /* The MSC/VLR should no longer try to page once the paging has been |
| 4482 | * rejected. Wait some time and check if there are no unexpected |
| 4483 | * messages on the SGs interface. */ |
| 4484 | timer T := 20.0; |
| 4485 | T.start |
| 4486 | alt { |
| 4487 | [] SGsAP.receive(exp_pag_req) |
| 4488 | { |
| 4489 | setverdict(fail, "paging seems not to stop!"); |
| 4490 | mtc.stop; |
| 4491 | } |
| 4492 | [] SGsAP.receive { |
| 4493 | setverdict(fail, "unexpected SGsAP message received"); |
| 4494 | self.stop; |
| 4495 | } |
| 4496 | [] T.timeout { |
| 4497 | setverdict(pass); |
| 4498 | } |
| 4499 | } |
| 4500 | |
Neels Hofmeyr | 8256ed2 | 2019-03-06 15:34:01 +0100 | [diff] [blame] | 4501 | f_vty_sms_clear(hex2str(g_pars.imsi)); |
| 4502 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4503 | /* A rejected paging with IMSI_unknown (see above) should always send |
| 4504 | * the SGs association to NULL. */ |
| 4505 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-NULL"); |
| 4506 | |
| 4507 | f_sgsap_bssmap_screening(); |
| 4508 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4509 | setverdict(pass); |
| 4510 | } |
| 4511 | testcase TC_sgsap_mt_sms_and_reject() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4512 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4513 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4514 | f_init(1, true); |
| 4515 | pars := f_init_pars(11826, true); |
| 4516 | 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] | 4517 | vc_conn.done; |
| 4518 | } |
| 4519 | |
| 4520 | /* Perform an MT CSDB call including LU */ |
| 4521 | private function f_mt_lu_and_csfb_call(charstring id, BSC_ConnHdlrPars pars, boolean bssmap_lu) runs on BSC_ConnHdlr { |
| 4522 | f_init_handler(pars); |
| 4523 | |
| 4524 | /* Be sure that the BSSMAP reset is done before we begin. */ |
| 4525 | f_sleep(2.0); |
| 4526 | |
| 4527 | /* Testcase variation: See what happens when we do a regular BSSMAP |
| 4528 | * LU first (this should not hurt in any way!) */ |
| 4529 | if (bssmap_lu) { |
| 4530 | f_perform_lu(); |
| 4531 | } |
| 4532 | |
| 4533 | f_sgs_perform_lu(); |
| 4534 | f_sleep(1.0); |
| 4535 | |
| 4536 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4537 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 4538 | cpars.bss_rtp_port := 1110; |
| 4539 | cpars.mgcp_connection_id_bss := '10004'H; |
| 4540 | cpars.mgcp_connection_id_mss := '10005'H; |
| 4541 | |
| 4542 | /* Note: This is an optional parameter. When the call-agent (MSC) does |
| 4543 | * supply a full endpoint name this setting will be overwritten. */ |
| 4544 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
| 4545 | |
| 4546 | /* Initiate a call via MNCC interface */ |
| 4547 | f_mt_call_initate(cpars); |
| 4548 | |
| 4549 | /* Expect a paging request and respond accordingly with a service request */ |
| 4550 | SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)); |
| 4551 | SGsAP.send(ts_SGsAP_SERVICE_REQ(pars.imsi, CS_call_indicator, EMM_CONNECTED)); |
| 4552 | |
| 4553 | /* Complete the call, hold it for some time and then tear it down */ |
| 4554 | f_mt_call_complete(cpars); |
| 4555 | f_sleep(3.0); |
Harald Welte | 4c422b7 | 2019-02-17 16:27:10 +0100 | [diff] [blame] | 4556 | f_call_hangup(cpars, true, is_csfb := true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4557 | |
| 4558 | /* Make sure that subscriber is still present and the SGs association is in tact (ref-counting) */ |
| 4559 | f_ctrl_get_exp(IPA_CTRL, "fsm.SGs-UE.id.imsi:" & hex2str(g_pars.imsi) & ".state", "SGs-ASSOCIATED"); |
| 4560 | |
| 4561 | /* Finally simulate the return of the UE to the 4G network */ |
| 4562 | SGsAP.send(ts_SGsAP_MO_CSFB_IND(pars.imsi)); |
| 4563 | |
| 4564 | /* Test for successful return by triggering a paging, when the paging |
| 4565 | * request is received via SGs, we can be sure that the MSC/VLR has |
| 4566 | * recognized that the UE is now back on 4G */ |
| 4567 | f_sleep(1.0); |
| 4568 | f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging"); |
| 4569 | alt { |
| 4570 | [] SGsAP.receive(tr_SGsAP_PAGING_REQ(pars.imsi, vlr_name, CS_call_indicator, omit)) { |
| 4571 | setverdict(pass); |
| 4572 | } |
| 4573 | [] SGsAP.receive { |
| 4574 | setverdict(fail, "Received unexpected message on SGs"); |
| 4575 | } |
| 4576 | } |
| 4577 | |
| 4578 | f_sgsap_bssmap_screening(); |
| 4579 | |
| 4580 | setverdict(pass); |
| 4581 | } |
| 4582 | |
| 4583 | /* Perform a regular BSSAP LU first, do a SGSAP LU and then make a CSFB call */ |
| 4584 | private function f_tc_bssap_lu_sgsap_lu_and_mt_call(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4585 | f_mt_lu_and_csfb_call(id, pars, true); |
| 4586 | } |
| 4587 | 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] | 4588 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4589 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4590 | f_init(1, true); |
| 4591 | pars := f_init_pars(118139, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4592 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4593 | 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] | 4594 | vc_conn.done; |
| 4595 | } |
| 4596 | |
| 4597 | |
| 4598 | /* Perform a SGSAP LU and then make a CSFB call */ |
| 4599 | private function f_tc_sgsap_lu_and_mt_call(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4600 | f_mt_lu_and_csfb_call(id, pars, false); |
| 4601 | } |
| 4602 | testcase TC_sgsap_lu_and_mt_call() runs on MTC_CT { |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4603 | var BSC_ConnHdlrPars pars; |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4604 | var BSC_ConnHdlr vc_conn; |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4605 | f_init(1, true); |
| 4606 | pars := f_init_pars(11827, true); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4607 | |
Philipp Maier | 8e07a4a | 2019-02-14 18:23:28 +0100 | [diff] [blame] | 4608 | 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] | 4609 | vc_conn.done; |
| 4610 | } |
| 4611 | |
Philipp Maier | 628c005 | 2019-04-09 17:36:57 +0200 | [diff] [blame] | 4612 | /* Simulate an HLR/VLR failure */ |
| 4613 | private function f_tc_sgsap_vlr_failure(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 4614 | var octetstring mme_name := f_enc_dns_hostname(mp_mme_name); |
| 4615 | var octetstring vlr_name := f_enc_dns_hostname(mp_vlr_name); |
| 4616 | |
| 4617 | var PDU_SGsAP lur; |
| 4618 | |
| 4619 | f_init_handler(pars); |
| 4620 | |
| 4621 | /* Attempt location update (which is expected to fail) */ |
| 4622 | lur := valueof(ts_SGsAP_LU_REQ(g_pars.imsi, mme_name, IMSI_attach, |
| 4623 | ts_SGsAP_LAI('901'H, '70'H, 2342))); |
| 4624 | SGsAP.send(lur); |
| 4625 | |
| 4626 | /* Respond to SGsAP-RESET-INDICATION from VLR */ |
| 4627 | alt { |
| 4628 | [] SGsAP.receive(tr_SGsAP_RESET_IND_VLR(vlr_name)); { |
| 4629 | SGsAP.send(valueof(ts_SGsAP_RESET_ACK_MME(mme_name))); |
| 4630 | setverdict(pass); |
| 4631 | } |
| 4632 | [] SGsAP.receive { |
| 4633 | setverdict(fail, "Received unexpected message on SGs"); |
| 4634 | } |
| 4635 | } |
| 4636 | |
| 4637 | f_sleep(1.0); |
| 4638 | setverdict(pass); |
| 4639 | } |
| 4640 | testcase TC_sgsap_vlr_failure() runs on MTC_CT { |
| 4641 | var BSC_ConnHdlrPars pars; |
| 4642 | var BSC_ConnHdlr vc_conn; |
| 4643 | f_init(1, true, false); |
| 4644 | pars := f_init_pars(11811, true, false); |
| 4645 | vc_conn := f_start_handler_with_pars(refers(f_tc_sgsap_vlr_failure), pars); |
| 4646 | vc_conn.done; |
| 4647 | } |
| 4648 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4649 | /* SGs TODO: |
| 4650 | * LU attempt for IMSI without NAM_PS in HLR |
| 4651 | * LU attempt with AUTH FAIL due to invalid RES/SRES |
| 4652 | * LU attempt with no response from HLR (VLR should timeout + LU REJ) |
| 4653 | * LU attempt with new TMSI but without TMSI REALL CMPL baco to VLR |
| 4654 | * implicit IMSI detach from EPS |
| 4655 | * implicit IMSI detach from non-EPS |
| 4656 | * MM INFO |
| 4657 | * |
| 4658 | */ |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 4659 | |
| 4660 | control { |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 4661 | execute( TC_cr_before_reset() ); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 4662 | execute( TC_lu_imsi_noauth_tmsi() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 4663 | execute( TC_lu_imsi_noauth_notmsi() ); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 4664 | execute( TC_lu_imsi_reject() ); |
| 4665 | execute( TC_lu_imsi_timeout_gsup() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 4666 | execute( TC_lu_imsi_auth_tmsi() ); |
| 4667 | execute( TC_cmserv_imsi_unknown() ); |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 4668 | execute( TC_lu_and_mo_call() ); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 4669 | execute( TC_lu_auth_sai_timeout() ); |
| 4670 | execute( TC_lu_auth_sai_err() ); |
Harald Welte | e1a2f3c | 2018-01-24 17:28:48 +0100 | [diff] [blame] | 4671 | execute( TC_lu_clear_request() ); |
| 4672 | execute( TC_lu_disconnect() ); |
| 4673 | execute( TC_lu_by_imei() ); |
| 4674 | execute( TC_lu_by_tmsi_noauth_unknown() ); |
| 4675 | execute( TC_imsi_detach_by_imsi() ); |
| 4676 | execute( TC_imsi_detach_by_tmsi() ); |
| 4677 | execute( TC_imsi_detach_by_imei() ); |
| 4678 | execute( TC_emerg_call_imei_reject() ); |
| 4679 | execute( TC_emerg_call_imsi() ); |
| 4680 | execute( TC_cm_serv_req_vgcs_reject() ); |
| 4681 | execute( TC_cm_serv_req_vbs_reject() ); |
| 4682 | execute( TC_cm_serv_req_lcs_reject() ); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 4683 | execute( TC_cm_reest_req_reject() ); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 4684 | execute( TC_lu_auth_2G_fail() ); |
| 4685 | execute( TC_lu_imsi_auth_tmsi_encr_13_13() ); |
| 4686 | execute( TC_cl3_no_payload() ); |
| 4687 | execute( TC_cl3_rnd_payload() ); |
Harald Welte | 1852a84 | 2018-01-26 22:53:36 +0100 | [diff] [blame] | 4688 | execute( TC_establish_and_nothing() ); |
| 4689 | execute( TC_mo_setup_and_nothing() ); |
| 4690 | execute( TC_mo_crcx_ran_timeout() ); |
| 4691 | execute( TC_mo_crcx_ran_reject() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 4692 | execute( TC_mt_crcx_ran_reject() ); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 4693 | execute( TC_mo_setup_and_dtmf_dup() ); |
Harald Welte | aa54cf8 | 2018-01-30 08:15:32 +0100 | [diff] [blame] | 4694 | //execute( TC_mt_t310() ); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 4695 | execute( TC_gsup_cancel() ); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 4696 | execute( TC_lu_imsi_auth_tmsi_encr_1_13() ); |
| 4697 | execute( TC_lu_imsi_auth_tmsi_encr_3_13() ); |
| 4698 | execute( TC_lu_imsi_auth_tmsi_encr_3_1() ); |
Neels Hofmeyr | 29b8da0 | 2018-03-01 18:09:45 +0100 | [diff] [blame] | 4699 | execute( TC_lu_imsi_auth_tmsi_encr_3_1_no_cm() ); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 4700 | execute( TC_lu_imsi_auth_tmsi_encr_13_2() ); |
| 4701 | execute( TC_lu_imsi_auth_tmsi_encr_013_2() ); |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 4702 | execute( TC_mo_release_timeout() ); |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 4703 | execute( TC_lu_and_mt_call_no_dlcx_resp() ); |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 4704 | execute( TC_reset_two() ); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 4705 | |
| 4706 | execute( TC_lu_and_mt_call() ); |
| 4707 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 4708 | execute( TC_lu_and_mo_sms() ); |
| 4709 | execute( TC_lu_and_mt_sms() ); |
Philipp Maier | 3983e70 | 2018-11-22 19:01:33 +0100 | [diff] [blame] | 4710 | execute( TC_lu_and_mt_sms_paging_and_nothing() ); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 4711 | execute( TC_smpp_mo_sms() ); |
| 4712 | execute( TC_smpp_mt_sms() ); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 4713 | |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 4714 | execute( TC_gsup_mo_sms() ); |
Vadim Yanitskiy | 9cc019a | 2018-11-15 02:06:07 +0700 | [diff] [blame] | 4715 | execute( TC_gsup_mo_smma() ); |
Vadim Yanitskiy | d7b37ab | 2018-11-24 03:40:20 +0700 | [diff] [blame] | 4716 | execute( TC_gsup_mt_sms_ack() ); |
| 4717 | execute( TC_gsup_mt_sms_err() ); |
Vadim Yanitskiy | be1ff4b | 2019-01-18 15:04:13 +0700 | [diff] [blame] | 4718 | execute( TC_gsup_mt_sms_rp_mr() ); |
Vadim Yanitskiy | 5ac49cc | 2019-01-24 16:57:31 +0700 | [diff] [blame] | 4719 | execute( TC_gsup_mo_mt_sms_rp_mr() ); |
Vadim Yanitskiy | 103d09f | 2018-11-12 02:50:23 +0700 | [diff] [blame] | 4720 | |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 4721 | execute( TC_lu_and_mo_ussd_single_request() ); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 4722 | execute( TC_lu_and_mt_ussd_notification() ); |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 4723 | execute( TC_lu_and_mo_ussd_during_mt_call() ); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 4724 | execute( TC_lu_and_mt_ussd_during_mt_call() ); |
Vadim Yanitskiy | 2daf52d | 2018-06-21 04:19:58 +0700 | [diff] [blame] | 4725 | execute( TC_lu_and_mo_ussd_mo_release() ); |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 4726 | execute( TC_lu_and_ss_session_timeout() ); |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 4727 | |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 4728 | execute( TC_cipher_complete_with_invalid_cipher() ); |
| 4729 | |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4730 | execute( TC_sgsap_reset() ); |
| 4731 | execute( TC_sgsap_lu() ); |
| 4732 | execute( TC_sgsap_lu_imsi_reject() ); |
| 4733 | execute( TC_sgsap_lu_and_nothing() ); |
| 4734 | execute( TC_sgsap_expl_imsi_det_eps() ); |
Philipp Maier | fc19f17 | 2019-03-21 11:17:54 +0100 | [diff] [blame] | 4735 | execute( TC_sgsap_impl_imsi_det_eps() ); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4736 | execute( TC_sgsap_expl_imsi_det_noneps() ); |
Philipp Maier | 5d81270 | 2019-03-21 10:51:26 +0100 | [diff] [blame] | 4737 | execute( TC_sgsap_impl_imsi_det_noneps() ); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4738 | execute( TC_sgsap_paging_rej() ); |
| 4739 | execute( TC_sgsap_paging_subscr_rej() ); |
| 4740 | execute( TC_sgsap_paging_ue_unr() ); |
| 4741 | execute( TC_sgsap_paging_and_nothing() ); |
| 4742 | execute( TC_sgsap_paging_and_lu() ); |
| 4743 | execute( TC_sgsap_mt_sms() ); |
| 4744 | execute( TC_sgsap_mo_sms() ); |
| 4745 | execute( TC_sgsap_mt_sms_and_nothing() ); |
| 4746 | execute( TC_sgsap_mt_sms_and_reject() ); |
| 4747 | execute( TC_sgsap_unexp_ud() ); |
| 4748 | execute( TC_sgsap_unsol_ud() ); |
| 4749 | execute( TC_bssap_lu_sgsap_lu_and_mt_call() ); |
| 4750 | execute( TC_sgsap_lu_and_mt_call() ); |
Philipp Maier | 628c005 | 2019-04-09 17:36:57 +0200 | [diff] [blame] | 4751 | execute( TC_sgsap_vlr_failure() ); |
Harald Welte | 4263c52 | 2018-12-06 11:56:27 +0100 | [diff] [blame] | 4752 | |
Neels Hofmeyr | 1b3c6e3 | 2018-03-01 17:52:21 +0100 | [diff] [blame] | 4753 | /* Run this last: at the time of writing this test crashes the MSC */ |
| 4754 | execute( TC_lu_imsi_auth_tmsi_encr_3_1_log_msc_debug() ); |
Philipp Maier | db7fb8d | 2019-02-11 10:50:13 +0100 | [diff] [blame] | 4755 | execute( TC_gsup_mt_multi_part_sms() ); |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 4756 | execute( TC_mo_cc_bssmap_clear() ); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 4757 | } |
| 4758 | |
| 4759 | |
| 4760 | } |