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