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