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 | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 45 | import from MobileL3_Types all; |
| 46 | import from MobileL3_CommonIE_Types all; |
| 47 | import from L3_Templates all; |
Harald Welte | 158a7ca | 2018-02-16 18:11:31 +0100 | [diff] [blame] | 48 | import from L3_Common all; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 49 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 50 | import from SMPP_Types all; |
| 51 | import from SMPP_Templates all; |
| 52 | import from SMPP_Emulation all; |
| 53 | |
Stefan Sperling | c307e68 | 2018-06-14 15:15:46 +0200 | [diff] [blame] | 54 | import from SCCP_Templates all; |
| 55 | |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 56 | import from SS_Types all; |
| 57 | import from SS_Templates all; |
| 58 | import from USSD_Helpers all; |
| 59 | |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 60 | const integer NUM_BSC := 2; |
| 61 | type record of BSSAP_Configuration BSSAP_Configurations; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 62 | |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 63 | type component MTC_CT extends CTRL_Adapter_CT { |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 64 | var boolean g_initialized := false; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 65 | |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 66 | var BSSAP_Adapter g_bssap[NUM_BSC]; |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 67 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 68 | /* no 'adapter_CT' for MNCC or GSUP */ |
| 69 | var MNCC_Emulation_CT vc_MNCC; |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 70 | var MGCP_Emulation_CT vc_MGCP; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 71 | var GSUP_Emulation_CT vc_GSUP; |
| 72 | var IPA_Emulation_CT vc_GSUP_IPA; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 73 | var SMPP_Emulation_CT vc_SMPP; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 74 | |
| 75 | /* only to get events from IPA underneath GSUP */ |
| 76 | port IPA_CTRL_PT GSUP_IPA_EVENT; |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 77 | /* VTY to MSC */ |
| 78 | port TELNETasp_PT MSCVTY; |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 79 | |
| 80 | /* A port to directly send BSSAP messages. This port is used for |
| 81 | * tests that require low level access to sen arbitrary BSSAP |
| 82 | * messages. Run f_init_bssap_direct() to connect and initialize */ |
| 83 | port BSSAP_CODEC_PT BSSAP_DIRECT; |
| 84 | |
| 85 | /* When BSSAP messages are directly sent, then the connection |
| 86 | * handler is not active, which means that also no guard timer is |
| 87 | * set up. The following timer will serve as a replacement */ |
| 88 | timer Tguard_direct := 60.0; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | modulepar { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 92 | /* remote parameters of IUT */ |
| 93 | charstring mp_msc_ip := "127.0.0.1"; |
| 94 | integer mp_msc_ctrl_port := 4255; |
| 95 | integer mp_msc_vty_port := 4254; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 96 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 97 | /* local parameters of emulated HLR */ |
Philipp Maier | 9b690e4 | 2018-12-21 11:50:03 +0100 | [diff] [blame^] | 98 | boolean mp_mm_info := false; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 99 | charstring mp_hlr_ip := "127.0.0.1"; |
| 100 | integer mp_hlr_port := 4222; |
Harald Welte | 6126fb0 | 2018-01-27 20:08:24 +0100 | [diff] [blame] | 101 | charstring mp_mgw_ip := "127.0.0.1"; |
| 102 | integer mp_mgw_port := 2427; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 103 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 104 | charstring mp_msc_mncc := "/tmp/mncc"; |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 105 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 106 | integer mp_msc_smpp_port := 2775; |
| 107 | charstring mp_smpp_system_id := "msc_tester"; |
| 108 | charstring mp_smpp_password := "osmocom1"; |
| 109 | |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 110 | BSSAP_Configurations mp_bssap_cfg := { |
| 111 | { |
| 112 | sccp_service_type := "mtp3_itu", |
| 113 | sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" }, |
| 114 | own_pc := 185, |
| 115 | own_ssn := 254, |
| 116 | peer_pc := 187, |
| 117 | peer_ssn := 254, |
| 118 | sio := '83'O, |
| 119 | rctx := 0 |
| 120 | }, |
| 121 | { |
| 122 | sccp_service_type := "mtp3_itu", |
| 123 | sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" }, |
| 124 | own_pc := 186, |
| 125 | own_ssn := 254, |
| 126 | peer_pc := 187, |
| 127 | peer_ssn := 254, |
| 128 | sio := '83'O, |
| 129 | rctx := 1 |
| 130 | } |
Harald Welte | a4ca446 | 2018-02-09 00:17:14 +0100 | [diff] [blame] | 131 | }; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 132 | } |
| 133 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 134 | /* altstep for the global guard timer (only used when BSSAP_DIRECT |
| 135 | * is used for communication */ |
| 136 | private altstep as_Tguard_direct() runs on MTC_CT { |
| 137 | [] Tguard_direct.timeout { |
| 138 | setverdict(fail, "Tguard timeout"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 139 | mtc.stop; |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 140 | } |
| 141 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 142 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 143 | function f_init_smpp(charstring id) runs on MTC_CT { |
| 144 | id := id & "-SMPP"; |
| 145 | var EsmePars pars := { |
| 146 | mode := MODE_TRANSCEIVER, |
| 147 | bind := { |
| 148 | system_id := mp_smpp_system_id, |
| 149 | password := mp_smpp_password, |
| 150 | system_type := "MSC_Tests", |
| 151 | interface_version := hex2int('34'H), |
| 152 | addr_ton := unknown, |
| 153 | addr_npi := unknown, |
| 154 | address_range := "" |
| 155 | }, |
| 156 | esme_role := true |
| 157 | } |
| 158 | |
| 159 | vc_SMPP := SMPP_Emulation_CT.create(id); |
| 160 | map(vc_SMPP:SMPP_PORT, system:SMPP_PORT); |
| 161 | vc_SMPP.start(SMPP_Emulation.main_client(pars, mp_msc_ip, mp_msc_smpp_port, "", -1)); |
| 162 | } |
| 163 | |
| 164 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 165 | function f_init_mncc(charstring id) runs on MTC_CT { |
| 166 | id := id & "-MNCC"; |
| 167 | var MnccOps ops := { |
| 168 | create_cb := refers(MNCC_Emulation.ExpectedCreateCallback), |
| 169 | unitdata_cb := refers(MNCC_Emulation.DummyUnitdataCallback) |
| 170 | } |
| 171 | |
| 172 | vc_MNCC := MNCC_Emulation_CT.create(id); |
| 173 | map(vc_MNCC:MNCC, system:MNCC_CODEC_PT); |
| 174 | vc_MNCC.start(MNCC_Emulation.main(ops, id, mp_msc_mncc)); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 175 | } |
| 176 | |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 177 | function f_init_mgcp(charstring id) runs on MTC_CT { |
| 178 | id := id & "-MGCP"; |
| 179 | var MGCPOps ops := { |
| 180 | create_cb := refers(MGCP_Emulation.ExpectedCreateCallback), |
| 181 | unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback) |
| 182 | } |
| 183 | var MGCP_conn_parameters pars := { |
Harald Welte | 6126fb0 | 2018-01-27 20:08:24 +0100 | [diff] [blame] | 184 | callagent_ip := mp_msc_ip, |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 185 | callagent_udp_port := -1, |
Harald Welte | 6126fb0 | 2018-01-27 20:08:24 +0100 | [diff] [blame] | 186 | mgw_ip := mp_mgw_ip, |
| 187 | mgw_udp_port := mp_mgw_port |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | vc_MGCP := MGCP_Emulation_CT.create(id); |
| 191 | map(vc_MGCP:MGCP, system:MGCP_CODEC_PT); |
| 192 | vc_MGCP.start(MGCP_Emulation.main(ops, pars, id)); |
| 193 | } |
| 194 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 195 | function f_init_gsup(charstring id) runs on MTC_CT { |
| 196 | id := id & "-GSUP"; |
| 197 | var GsupOps ops := { |
| 198 | create_cb := refers(GSUP_Emulation.ExpectedCreateCallback) |
| 199 | } |
| 200 | |
| 201 | vc_GSUP_IPA := IPA_Emulation_CT.create(id & "-IPA"); |
| 202 | vc_GSUP := GSUP_Emulation_CT.create(id); |
| 203 | |
| 204 | map(vc_GSUP_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 205 | connect(vc_GSUP:GSUP, vc_GSUP_IPA:IPA_GSUP_PORT); |
| 206 | /* we use this hack to get events like ASP_IPA_EVENT_UP */ |
| 207 | connect(vc_GSUP_IPA:IPA_CTRL_PORT, self:GSUP_IPA_EVENT); |
| 208 | |
| 209 | vc_GSUP.start(GSUP_Emulation.main(ops, id)); |
| 210 | vc_GSUP_IPA.start(IPA_Emulation.main_server(mp_hlr_ip, mp_hlr_port)); |
| 211 | |
| 212 | /* wait for incoming connection to GSUP port before proceeding */ |
| 213 | timer T := 10.0; |
| 214 | T.start; |
| 215 | alt { |
| 216 | [] GSUP_IPA_EVENT.receive(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_UP)) { } |
| 217 | [] T.timeout { |
Harald Welte | 458fd37 | 2018-03-21 11:26:23 +0100 | [diff] [blame] | 218 | setverdict(fail, "No connection to GSUP Port"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 219 | mtc.stop |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 220 | } |
| 221 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 222 | } |
| 223 | |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 224 | function f_init(integer num_bsc := 1) runs on MTC_CT { |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 225 | |
| 226 | if (g_initialized == true) { |
| 227 | return; |
| 228 | } |
| 229 | g_initialized := true; |
| 230 | |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 231 | if (num_bsc > NUM_BSC) { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 232 | testcase.stop("excess number of BSC instances requested"); |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | for (var integer i := 0; i < num_bsc; i := i + 1) { |
| 236 | if (isbound(mp_bssap_cfg[i])) { |
Philipp Maier | defd948 | 2018-05-16 16:44:37 +0200 | [diff] [blame] | 237 | 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] | 238 | f_bssap_start(g_bssap[i]); |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 239 | } else { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 240 | testcase.stop("missing BSSAP configuration"); |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 241 | } |
| 242 | } |
| 243 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 244 | f_ipa_ctrl_start(mp_msc_ip, mp_msc_ctrl_port); |
| 245 | f_init_mncc("MSC_Test"); |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 246 | f_init_mgcp("MSC_Test"); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 247 | f_init_gsup("MSC_Test"); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 248 | f_init_smpp("MSC_Test"); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 249 | |
| 250 | map(self:MSCVTY, system:MSCVTY); |
| 251 | f_vty_set_prompts(MSCVTY); |
| 252 | f_vty_transceive(MSCVTY, "enable"); |
Harald Welte | b14c77a | 2018-01-25 17:25:44 +0100 | [diff] [blame] | 253 | |
| 254 | /* set some defaults */ |
| 255 | f_vty_config(MSCVTY, "network", "authentication optional"); |
| 256 | f_vty_config(MSCVTY, "msc", "assign-tmsi"); |
| 257 | f_vty_config(MSCVTY, "network", "encryption a5 0"); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 258 | } |
| 259 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 260 | /* Initialize for a direct connection to BSSAP. This function is an alternative |
| 261 | * to f_init() when the high level functions of the BSC_ConnectionHandler are |
| 262 | * not needed. */ |
| 263 | function f_init_bssap_direct() runs on MTC_CT { |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 264 | f_bssap_init(g_bssap[0], mp_bssap_cfg[0], "MSC_Test", omit); |
| 265 | connect(g_bssap[0].vc_SCCP:SCCP_SP_PORT, self:BSSAP_DIRECT); |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 266 | |
| 267 | /* Start guard timer and activate it as default */ |
| 268 | Tguard_direct.start |
| 269 | activate(as_Tguard_direct()); |
| 270 | } |
| 271 | |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 272 | template PDU_BSSAP ts_BSSAP_BSSMAP := { |
| 273 | discriminator := '0'B, |
| 274 | spare := '0000000'B, |
| 275 | dlci := omit, |
| 276 | lengthIndicator := 0, /* overwritten by codec */ |
| 277 | pdu := ? |
| 278 | } |
| 279 | |
| 280 | template PDU_BSSAP tr_BSSAP_BSSMAP := { |
| 281 | discriminator := '0'B, |
| 282 | spare := '0000000'B, |
| 283 | dlci := omit, |
| 284 | lengthIndicator := ?, |
| 285 | pdu := { |
| 286 | bssmap := ? |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | |
| 291 | type integer BssmapCause; |
| 292 | |
| 293 | template (value) BSSMAP_IE_Cause ts_BSSMAP_IE_Cause(BssmapCause val) := { |
| 294 | elementIdentifier := '04'O, |
| 295 | lengthIndicator := 0, |
| 296 | causeValue := int2bit(val, 7), |
| 297 | extensionCauseValue := '0'B, |
| 298 | spare1 := omit |
| 299 | } |
| 300 | |
| 301 | template (value) PDU_BSSAP ts_BSSMAP_Reset(BssmapCause cause) modifies ts_BSSAP_BSSMAP := { |
| 302 | pdu := { |
| 303 | bssmap := { |
| 304 | reset := { |
| 305 | messageType := '30'O, |
| 306 | cause := ts_BSSMAP_IE_Cause(cause), |
| 307 | a_InterfaceSelectorForReset := omit |
| 308 | } |
| 309 | } |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | template (value) PDU_BSSAP ts_BSSMAP_ResetAck modifies ts_BSSAP_BSSMAP := { |
| 314 | pdu := { |
| 315 | bssmap := { |
| 316 | resetAck := { |
| 317 | messageType := '31'O, |
| 318 | a_InterfaceSelectorForReset := omit |
| 319 | } |
| 320 | } |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | template PDU_BSSAP tr_BSSMAP_ResetAck modifies tr_BSSAP_BSSMAP := { |
| 325 | pdu := { |
| 326 | bssmap := { |
| 327 | resetAck := { |
| 328 | messageType := '31'O, |
| 329 | a_InterfaceSelectorForReset := * |
| 330 | } |
| 331 | } |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | template BSSMAP_IE_CellIdentifier ts_BSSMAP_IE_CellID := { |
| 336 | elementIdentifier := '05'O, |
| 337 | lengthIndicator := 0, |
| 338 | cellIdentifierDiscriminator := '0000'B, |
| 339 | spare1_4 := '0000'B, |
| 340 | cellIdentification := ? |
| 341 | } |
| 342 | |
| 343 | type uint16_t BssmapLAC; |
| 344 | type uint16_t BssmapCI; |
| 345 | |
| 346 | /* |
| 347 | template BSSMAP_IE_CellIdentifier ts_CellId_CGI(mcc, mnc, lac, ci) |
| 348 | modifies ts_BSSMAP_IE_CellID := { |
| 349 | cellIdentification := { |
| 350 | cI_LAC_CGI := { |
| 351 | mnc_mcc := FIXME, |
| 352 | lac := int2oct(lac, 2), |
| 353 | ci := int2oct(ci, 2) |
| 354 | } |
| 355 | } |
| 356 | } |
| 357 | */ |
| 358 | |
| 359 | template BSSMAP_IE_CellIdentifier ts_CellID_LAC_CI(BssmapLAC lac, BssmapCI ci) |
| 360 | modifies ts_BSSMAP_IE_CellID := { |
| 361 | cellIdentification := { |
| 362 | cI_LAC_CI := { |
| 363 | lac := int2oct(lac, 2), |
| 364 | ci := int2oct(ci, 2) |
| 365 | } |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | template BSSMAP_IE_CellIdentifier ts_CellId_CI(BssmapCI ci) |
| 370 | modifies ts_BSSMAP_IE_CellID := { |
| 371 | cellIdentification := { |
| 372 | cI_CI := int2oct(ci, 2) |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | template BSSMAP_IE_CellIdentifier ts_CellId_none |
| 377 | modifies ts_BSSMAP_IE_CellID := { |
| 378 | cellIdentification := { |
| 379 | cI_noCell := ''O |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | |
| 384 | template BSSMAP_IE_Layer3Information ts_BSSMAP_IE_L3Info(octetstring l3info) := { |
| 385 | elementIdentifier := '17'O, |
| 386 | lengthIndicator := 0, |
| 387 | layer3info := l3info |
| 388 | } |
| 389 | |
| 390 | template PDU_BSSAP ts_BSSMAP_ComplL3(BSSMAP_IE_CellIdentifier cell_id, octetstring l3_info) |
| 391 | modifies ts_BSSAP_BSSMAP := { |
| 392 | pdu := { |
| 393 | bssmap := { |
| 394 | completeLayer3Information := { |
| 395 | messageType := '57'O, |
| 396 | cellIdentifier := cell_id, |
| 397 | layer3Information := ts_BSSMAP_IE_L3Info(l3_info), |
| 398 | chosenChannel := omit, |
| 399 | lSAIdentifier := omit, |
| 400 | aPDU := omit, |
| 401 | codecList := omit, |
| 402 | redirectAttemptFlag := omit, |
| 403 | sendSequenceNumber := omit, |
| 404 | iMSI := omit |
| 405 | } |
| 406 | } |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | template PDU_BSSAP ts_BSSMAP_HandoReq(BssmapCause cause, BSSMAP_IE_CellIdentifierList cid_list) |
| 411 | modifies ts_BSSAP_BSSMAP := { |
| 412 | pdu := { |
| 413 | bssmap := { |
| 414 | handoverRequired := { |
| 415 | messageType := '11'O, |
| 416 | cause := ts_BSSMAP_IE_Cause(cause), |
| 417 | responseRequest := omit, |
| 418 | cellIdentifierList := cid_list, |
| 419 | circuitPoolList := omit, |
| 420 | currentChannelType1 := omit, |
| 421 | speechVersion := omit, |
| 422 | queueingIndicator := omit, |
| 423 | oldToNewBSSInfo := omit, |
| 424 | sourceToTargetRNCTransparentInfo := omit, |
| 425 | sourceToTargetRNCTransparentInfoCDMA := omit, |
| 426 | gERANClassmark := omit, |
| 427 | talkerPriority := omit, |
| 428 | speechCodec := omit, |
| 429 | cSG_Identifier := omit |
| 430 | } |
| 431 | } |
| 432 | } |
| 433 | } |
| 434 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 435 | 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] | 436 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 437 | /* FIXME: move into BSC_ConnectionHandler? */ |
Neels Hofmeyr | 9adaa70 | 2018-03-01 20:23:19 +0100 | [diff] [blame] | 438 | 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] | 439 | var BSC_ConnHdlrNetworkPars net_pars := { |
| 440 | kc_support := '0A'O, /* A5/1 and A5/3 enabled */ |
| 441 | expect_tmsi := true, |
| 442 | expect_auth := false, |
| 443 | expect_ciph := false |
| 444 | }; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 445 | var BSC_ConnHdlrPars pars := { |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 446 | sccp_addr_own := g_bssap[0].sccp_addr_own, |
| 447 | sccp_addr_peer := g_bssap[0].sccp_addr_peer, |
Harald Welte | edbab81 | 2018-03-18 16:02:25 +0100 | [diff] [blame] | 448 | cell_id := valueof(ts_CellId_CGI('262'H, '42'H, 23, 42)), |
Harald Welte | 81b7f9d | 2018-01-24 19:06:24 +0100 | [diff] [blame] | 449 | imei := f_gen_imei(imsi_suffix), |
| 450 | imsi := f_gen_imsi(imsi_suffix), |
| 451 | msisdn := f_gen_msisdn(imsi_suffix), |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 452 | tmsi := omit, |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 453 | cm1 := valueof(ts_CM1), |
Harald Welte | 8260057 | 2018-01-21 20:54:08 +0100 | [diff] [blame] | 454 | cm2 := valueof(ts_CM2_default), |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 455 | cm3 := omit, |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 456 | vec := omit, |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 457 | net := net_pars, |
Philipp Maier | aeb29a8 | 2018-11-08 17:40:53 +0100 | [diff] [blame] | 458 | send_early_cm := true, |
| 459 | ipa_ctrl_ip := mp_msc_ip, |
| 460 | ipa_ctrl_port := mp_msc_ctrl_port, |
Philipp Maier | 9b690e4 | 2018-12-21 11:50:03 +0100 | [diff] [blame^] | 461 | ipa_ctrl_enable := true, |
| 462 | mm_info := mp_mm_info |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 463 | }; |
Neels Hofmeyr | 9adaa70 | 2018-03-01 20:23:19 +0100 | [diff] [blame] | 464 | return pars; |
| 465 | } |
| 466 | |
| 467 | function f_start_handler_with_pars(void_fn fn, BSC_ConnHdlrPars pars) runs on MTC_CT return BSC_ConnHdlr { |
| 468 | var BSC_ConnHdlr vc_conn; |
| 469 | var charstring id := testcasename(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 470 | |
| 471 | vc_conn := BSC_ConnHdlr.create(id); |
| 472 | /* BSSMAP part / A interface */ |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 473 | connect(vc_conn:BSSAP, g_bssap[0].vc_BSSMAP:CLIENT); |
| 474 | connect(vc_conn:BSSAP_PROC, g_bssap[0].vc_BSSMAP:PROC); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 475 | /* MNCC part */ |
| 476 | connect(vc_conn:MNCC, vc_MNCC:MNCC_CLIENT); |
| 477 | connect(vc_conn:MNCC_PROC, vc_MNCC:MNCC_PROC); |
Harald Welte | 4aa970c | 2018-01-26 10:38:09 +0100 | [diff] [blame] | 478 | /* MGCP part */ |
| 479 | connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT); |
| 480 | connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 481 | /* GSUP part */ |
| 482 | connect(vc_conn:GSUP, vc_GSUP:GSUP_CLIENT); |
| 483 | connect(vc_conn:GSUP_PROC, vc_GSUP:GSUP_PROC); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 484 | /* SMPP part */ |
| 485 | connect(vc_conn:SMPP, vc_SMPP:SMPP_CLIENT); |
| 486 | connect(vc_conn:SMPP_PROC, vc_SMPP:SMPP_PROC); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 487 | |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 488 | /* We cannot use vc_conn.start(f_init_handler(fn, id, pars)); as we cannot have |
| 489 | * 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] | 490 | vc_conn.start(derefers(fn)(id, pars)); |
| 491 | return vc_conn; |
| 492 | } |
| 493 | |
Neels Hofmeyr | 9adaa70 | 2018-03-01 20:23:19 +0100 | [diff] [blame] | 494 | function f_start_handler(void_fn fn, integer imsi_suffix) runs on MTC_CT return BSC_ConnHdlr { |
| 495 | return f_start_handler_with_pars(fn, f_init_pars(imsi_suffix)); |
| 496 | } |
| 497 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 498 | 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] | 499 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 500 | f_perform_lu(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 501 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 502 | testcase TC_lu_imsi_noauth_tmsi() runs on MTC_CT { |
| 503 | var BSC_ConnHdlr vc_conn; |
| 504 | f_init(); |
| 505 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 506 | 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] | 507 | vc_conn.done; |
| 508 | } |
| 509 | |
| 510 | 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] | 511 | pars.net.expect_tmsi := false; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 512 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 513 | f_perform_lu(); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 514 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 515 | testcase TC_lu_imsi_noauth_notmsi() runs on MTC_CT { |
| 516 | var BSC_ConnHdlr vc_conn; |
| 517 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 518 | f_vty_config(MSCVTY, "msc", "no assign-tmsi"); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 519 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 520 | 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] | 521 | vc_conn.done; |
| 522 | } |
| 523 | |
| 524 | /* Do LU by IMSI, refuse it on GSUP and expect LU REJ back to MS */ |
| 525 | 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] | 526 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 527 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 528 | |
| 529 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 530 | f_bssap_compl_l3(l3_lu); |
| 531 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 532 | GSUP.send(ts_GSUP_UL_ERR(g_pars.imsi, 23)); |
| 533 | alt { |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 534 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej(int2oct(23,1)))) { |
| 535 | f_expect_clear(); |
| 536 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 537 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 538 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 539 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 540 | } |
| 541 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 542 | } |
| 543 | testcase TC_lu_imsi_reject() runs on MTC_CT { |
| 544 | var BSC_ConnHdlr vc_conn; |
| 545 | f_init(); |
| 546 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 547 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_reject), 3); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 548 | vc_conn.done; |
| 549 | } |
| 550 | |
| 551 | /* Do LU by IMSI, timeout on GSUP */ |
| 552 | 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] | 553 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 554 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 555 | |
| 556 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 557 | f_bssap_compl_l3(l3_lu); |
| 558 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 559 | /* Normally the HLR would need to respond here, but we decide to force a timeout here */ |
| 560 | alt { |
| 561 | /* FIXME: Expect specific reject cause */ |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 562 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 563 | f_expect_clear(); |
| 564 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 565 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 566 | setverdict(fail, "Expecting LU REJ, but got ACCEPT"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 567 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 568 | } |
| 569 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 570 | } |
| 571 | testcase TC_lu_imsi_timeout_gsup() runs on MTC_CT { |
| 572 | var BSC_ConnHdlr vc_conn; |
| 573 | f_init(); |
| 574 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 575 | 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] | 576 | vc_conn.done; |
| 577 | } |
| 578 | |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 579 | 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] | 580 | pars.net.expect_auth := true; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 581 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 582 | f_perform_lu(); |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 583 | } |
| 584 | testcase TC_lu_imsi_auth_tmsi() runs on MTC_CT { |
| 585 | var BSC_ConnHdlr vc_conn; |
| 586 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 587 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 7b1b281 | 2018-01-22 21:23:06 +0100 | [diff] [blame] | 588 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 589 | 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] | 590 | vc_conn.done; |
| 591 | } |
| 592 | |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 593 | |
| 594 | /* Send CM SERVICE REQ for IMSI that has never performed LU before */ |
| 595 | private function f_tc_cmserv_imsi_unknown(charstring id, BSC_ConnHdlrPars pars) |
| 596 | runs on BSC_ConnHdlr { |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 597 | f_init_handler(pars); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 598 | |
| 599 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | edbab81 | 2018-03-18 16:02:25 +0100 | [diff] [blame] | 600 | 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] | 601 | 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] | 602 | |
| 603 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 604 | |
| 605 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 606 | f_bssap_compl_l3(l3_info); |
| 607 | |
| 608 | timer T := 10.0; |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 609 | T.start; |
| 610 | alt { |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 611 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)) { } |
| 612 | //[] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_ACC)) { } |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 613 | [] BSSAP.receive { |
| 614 | setverdict(fail, "Received unexpected BSSAP"); |
| 615 | mtc.stop; |
| 616 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 617 | [] GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)) { |
| 618 | setverdict(fail, "Unexpected GSUP UL REQ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 619 | mtc.stop; |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 620 | } |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 621 | [] T.timeout { |
| 622 | setverdict(fail, "Timeout waiting for CM SERV REQ"); |
| 623 | mtc.stop; |
| 624 | } |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 625 | } |
| 626 | |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 627 | f_expect_clear(); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 628 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 629 | testcase TC_cmserv_imsi_unknown() runs on MTC_CT { |
| 630 | var BSC_ConnHdlr vc_conn; |
| 631 | f_init(); |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 632 | vc_conn := f_start_handler(refers(f_tc_cmserv_imsi_unknown), 6); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 633 | vc_conn.done; |
| 634 | } |
| 635 | |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 636 | 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] | 637 | f_init_handler(pars); |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 638 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 639 | cpars.bss_rtp_port := 1110; |
| 640 | cpars.mgcp_connection_id_bss := '22222'H; |
| 641 | cpars.mgcp_connection_id_mss := '33333'H; |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 642 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 643 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 644 | f_perform_lu(); |
Harald Welte | b71901a | 2018-01-26 19:16:05 +0100 | [diff] [blame] | 645 | f_mo_call(cpars); |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 646 | } |
| 647 | testcase TC_lu_and_mo_call() runs on MTC_CT { |
| 648 | var BSC_ConnHdlr vc_conn; |
| 649 | f_init(); |
| 650 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 651 | 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] | 652 | vc_conn.done; |
| 653 | } |
| 654 | |
| 655 | /* Test LU (with authentication enabled), where HLR times out sending SAI response */ |
| 656 | 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] | 657 | f_init_handler(pars); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 658 | |
| 659 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 660 | var PDU_DTAP_MT dtap_mt; |
| 661 | |
| 662 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 663 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 664 | |
| 665 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 666 | f_bssap_compl_l3(l3_lu); |
| 667 | |
| 668 | /* Send Early Classmark, just for the fun of it */ |
| 669 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 670 | |
| 671 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 672 | /* The HLR would normally return an auth vector here, but we fail to do so. */ |
| 673 | |
| 674 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 675 | f_expect_clear(); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 676 | } |
| 677 | testcase TC_lu_auth_sai_timeout() runs on MTC_CT { |
| 678 | var BSC_ConnHdlr vc_conn; |
| 679 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 680 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 681 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 682 | 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] | 683 | vc_conn.done; |
| 684 | } |
| 685 | |
| 686 | /* Test LU (with authentication enabled), where HLR rejects sending SAI error */ |
| 687 | 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] | 688 | f_init_handler(pars); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 689 | |
| 690 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 691 | var PDU_DTAP_MT dtap_mt; |
| 692 | |
| 693 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 694 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 695 | |
| 696 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 697 | f_bssap_compl_l3(l3_lu); |
| 698 | |
| 699 | /* Send Early Classmark, just for the fun of it */ |
| 700 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 701 | |
| 702 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 703 | GSUP.send(ts_GSUP_SAI_ERR(g_pars.imsi, 13)); |
| 704 | |
| 705 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 706 | f_expect_clear(); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 707 | } |
| 708 | testcase TC_lu_auth_sai_err() runs on MTC_CT { |
| 709 | var BSC_ConnHdlr vc_conn; |
| 710 | f_init(); |
Harald Welte | 3ca1c90 | 2018-01-24 18:51:27 +0100 | [diff] [blame] | 711 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 712 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 713 | 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] | 714 | vc_conn.done; |
| 715 | } |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 716 | |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 717 | /* Test LU but BSC will send a clear request in the middle */ |
| 718 | 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] | 719 | f_init_handler(pars); |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 720 | |
| 721 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 722 | var PDU_DTAP_MT dtap_mt; |
| 723 | |
| 724 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 725 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 726 | |
| 727 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 728 | f_bssap_compl_l3(l3_lu); |
| 729 | |
| 730 | /* Send Early Classmark, just for the fun of it */ |
| 731 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 732 | |
| 733 | f_sleep(1.0); |
| 734 | /* send clear request in the middle of the LU */ |
| 735 | BSSAP.send(ts_BSSMAP_ClearRequest(0)); |
Neels Hofmeyr | 2b326fa | 2018-04-06 00:59:36 +0200 | [diff] [blame] | 736 | alt { |
| 737 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { repeat; } |
| 738 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) {} |
| 739 | } |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 740 | BSSAP.send(ts_BSSMAP_ClearComplete); |
Harald Welte | 89a3249 | 2018-01-27 19:07:28 +0100 | [diff] [blame] | 741 | alt { |
| 742 | /* See https://osmocom.org/issues/2862 */ |
Neels Hofmeyr | 2b326fa | 2018-04-06 00:59:36 +0200 | [diff] [blame] | 743 | [] BSSAP.receive(tr_BSSMAP_ClearCommand) { |
| 744 | setverdict(fail, "Got a second Clear Command, only one expected"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 745 | mtc.stop; |
Neels Hofmeyr | 2b326fa | 2018-04-06 00:59:36 +0200 | [diff] [blame] | 746 | repeat; |
| 747 | } |
Harald Welte | 89a3249 | 2018-01-27 19:07:28 +0100 | [diff] [blame] | 748 | [] BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
| 749 | } |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 750 | setverdict(pass); |
| 751 | } |
| 752 | testcase TC_lu_clear_request() runs on MTC_CT { |
| 753 | var BSC_ConnHdlr vc_conn; |
| 754 | f_init(); |
| 755 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 756 | vc_conn := f_start_handler(refers(f_tc_lu_clear_request), 10); |
Harald Welte | bc88178 | 2018-01-23 20:09:15 +0100 | [diff] [blame] | 757 | vc_conn.done; |
| 758 | } |
| 759 | |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 760 | /* Test LU but BSC will send a clear request in the middle */ |
| 761 | 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] | 762 | f_init_handler(pars); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +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(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_REQ); |
| 779 | setverdict(pass); |
| 780 | } |
| 781 | testcase TC_lu_disconnect() runs on MTC_CT { |
| 782 | var BSC_ConnHdlr vc_conn; |
| 783 | f_init(); |
| 784 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 785 | vc_conn := f_start_handler(refers(f_tc_lu_disconnect), 11); |
Harald Welte | 66af9e6 | 2018-01-24 17:28:21 +0100 | [diff] [blame] | 786 | vc_conn.done; |
| 787 | } |
| 788 | |
| 789 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 790 | /* Test LU but with illegal mobile identity type = IMEI */ |
| 791 | 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] | 792 | f_init_handler(pars); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 793 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 794 | 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] | 795 | var PDU_DTAP_MT dtap_mt; |
| 796 | |
| 797 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 798 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 799 | |
| 800 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 801 | f_bssap_compl_l3(l3_lu); |
| 802 | |
| 803 | /* Send Early Classmark, just for the fun of it */ |
| 804 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 805 | /* wait for LU reject, ignore any ID REQ */ |
| 806 | alt { |
| 807 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { } |
| 808 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req)) { repeat; } |
| 809 | } |
| 810 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 811 | f_expect_clear(); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 812 | } |
| 813 | testcase TC_lu_by_imei() runs on MTC_CT { |
| 814 | var BSC_ConnHdlr vc_conn; |
| 815 | f_init(); |
| 816 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 817 | vc_conn := f_start_handler(refers(f_tc_lu_by_imei), 12); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 818 | vc_conn.done; |
| 819 | } |
| 820 | |
| 821 | /* Test LU by TMSI with unknown TMSI, expect (and answer) ID REQ. */ |
| 822 | 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] | 823 | /* We piggyback a test for an MSC crash on overlong IMSI (OS#2864) onto this test. */ |
| 824 | var hexstring overlong_imsi := '012345789ABCDEF0123456789ABCDEF'H; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 825 | f_init_handler(pars); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 826 | |
| 827 | var PDU_ML3_MS_NW l3_lu := f_build_lu_tmsi('01020304'O); /* FIXME: Random */ |
| 828 | var PDU_DTAP_MT dtap_mt; |
| 829 | |
| 830 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 831 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 832 | |
| 833 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 834 | f_bssap_compl_l3(l3_lu); |
| 835 | |
| 836 | /* Send Early Classmark, just for the fun of it */ |
| 837 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 838 | |
| 839 | /* Wait for + respond to ID REQ (IMSI) */ |
| 840 | 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] | 841 | 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] | 842 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp_IMSI(g_pars.imsi))); |
| 843 | |
| 844 | /* Expect MSC to do UpdateLocation to HLR; respond to it */ |
| 845 | GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)); |
| 846 | GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn)); |
| 847 | GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi)); |
| 848 | GSUP.send(ts_GSUP_UL_RES(g_pars.imsi)); |
| 849 | |
| 850 | alt { |
Harald Welte | 7ec4fa8 | 2018-01-27 10:57:40 +0100 | [diff] [blame] | 851 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) { |
| 852 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_TmsiRealloc_Cmpl)); |
| 853 | } |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 854 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 855 | setverdict(fail, "Expected LU ACK, but received REJ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 856 | mtc.stop; |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 857 | } |
| 858 | } |
| 859 | |
Philipp Maier | 9b690e4 | 2018-12-21 11:50:03 +0100 | [diff] [blame^] | 860 | /* Wait for MM-Information (if enabled) */ |
| 861 | f_expect_mm_info(); |
| 862 | |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 863 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 864 | f_expect_clear(); |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 865 | } |
| 866 | testcase TC_lu_by_tmsi_noauth_unknown() runs on MTC_CT { |
| 867 | var BSC_ConnHdlr vc_conn; |
| 868 | f_init(); |
| 869 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 870 | 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] | 871 | vc_conn.done; |
| 872 | } |
| 873 | |
| 874 | |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 875 | /* Test IMSI DETACH (MI=IMSI) */ |
| 876 | 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] | 877 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 878 | |
| 879 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 880 | |
| 881 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 882 | f_bssap_compl_l3(valueof(ts_ML3_MO_MM_IMSI_DET_Ind(mi))); |
| 883 | |
| 884 | /* Send Early Classmark, just for the fun of it? */ |
| 885 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 886 | |
| 887 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 888 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 889 | } |
| 890 | testcase TC_imsi_detach_by_imsi() runs on MTC_CT { |
| 891 | var BSC_ConnHdlr vc_conn; |
| 892 | f_init(); |
| 893 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 894 | vc_conn := f_start_handler(refers(f_tc_imsi_detach_by_imsi), 14); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 895 | vc_conn.done; |
| 896 | } |
| 897 | |
| 898 | /* Test IMSI DETACH (MI=TMSI) */ |
| 899 | 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] | 900 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 901 | |
| 902 | var MobileIdentityLV mi := valueof(ts_MI_TMSI_LV('01020304'O)); |
| 903 | |
| 904 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 905 | f_bssap_compl_l3(valueof(ts_ML3_MO_MM_IMSI_DET_Ind(mi))); |
| 906 | |
| 907 | /* Send Early Classmark, just for the fun of it? */ |
| 908 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 909 | |
| 910 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 911 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 912 | } |
| 913 | testcase TC_imsi_detach_by_tmsi() runs on MTC_CT { |
| 914 | var BSC_ConnHdlr vc_conn; |
| 915 | f_init(); |
| 916 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 917 | 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] | 918 | vc_conn.done; |
| 919 | } |
| 920 | |
| 921 | /* Test IMSI DETACH (MI=IMEI), which is illegal */ |
| 922 | 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] | 923 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 924 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 925 | var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 926 | |
| 927 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 928 | f_bssap_compl_l3(valueof(ts_ML3_MO_MM_IMSI_DET_Ind(mi))); |
| 929 | |
| 930 | /* Send Early Classmark, just for the fun of it? */ |
| 931 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 932 | |
| 933 | /* wait for normal teardown */ |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 934 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 935 | } |
| 936 | testcase TC_imsi_detach_by_imei() runs on MTC_CT { |
| 937 | var BSC_ConnHdlr vc_conn; |
| 938 | f_init(); |
| 939 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 940 | 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] | 941 | vc_conn.done; |
| 942 | } |
| 943 | |
| 944 | |
| 945 | /* helper function for an emergency call. caller passes in mobile identity to use */ |
| 946 | private function f_emerg_call(MobileIdentityLV mi) runs on BSC_ConnHdlr { |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 947 | var CallParameters cpars := valueof(t_CallParams('112'H, 0)); |
| 948 | cpars.emergency := true; |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 949 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 950 | |
Harald Welte | 0bef21e | 2018-02-10 09:48:23 +0100 | [diff] [blame] | 951 | f_mo_call(cpars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 952 | } |
| 953 | |
| 954 | /* establish an emergency call by IMEI, no SIM inserted (and hence no IMSI) */ |
| 955 | 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] | 956 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 957 | |
Harald Welte | 256571e | 2018-01-24 18:47:19 +0100 | [diff] [blame] | 958 | var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(g_pars.imei)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 959 | 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] | 960 | f_bssap_compl_l3(l3_info); |
| 961 | BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ('05'O))); |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 962 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 963 | } |
| 964 | testcase TC_emerg_call_imei_reject() runs on MTC_CT { |
| 965 | var BSC_ConnHdlr vc_conn; |
| 966 | f_init(); |
| 967 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 968 | 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] | 969 | vc_conn.done; |
| 970 | } |
| 971 | |
Harald Welte | d5b9140 | 2018-01-24 18:48:16 +0100 | [diff] [blame] | 972 | /* establish an emergency call by IMSI, SIM inserted (and hence IMSI) */ |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 973 | 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] | 974 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 975 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 976 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 977 | /* Then issue emergency call identified by IMSI */ |
| 978 | f_emerg_call(valueof(ts_MI_IMSI_LV(g_pars.imsi))); |
| 979 | } |
| 980 | testcase TC_emerg_call_imsi() runs on MTC_CT { |
| 981 | var BSC_ConnHdlr vc_conn; |
| 982 | f_init(); |
| 983 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 984 | vc_conn := f_start_handler(refers(f_tc_emerg_call_imsi), 18); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 985 | vc_conn.done; |
| 986 | } |
| 987 | |
| 988 | /* CM Service Request for VGCS -> reject */ |
| 989 | 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] | 990 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 991 | |
| 992 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 993 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 994 | |
| 995 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 996 | 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] | 997 | f_bssap_compl_l3(l3_info); |
| 998 | 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] | 999 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1000 | } |
| 1001 | testcase TC_cm_serv_req_vgcs_reject() runs on MTC_CT { |
| 1002 | var BSC_ConnHdlr vc_conn; |
| 1003 | f_init(); |
| 1004 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1005 | 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] | 1006 | vc_conn.done; |
| 1007 | } |
| 1008 | |
| 1009 | /* CM Service Request for VBS -> reject */ |
| 1010 | 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] | 1011 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1012 | |
| 1013 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1014 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1015 | |
| 1016 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1017 | 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] | 1018 | f_bssap_compl_l3(l3_info); |
| 1019 | 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] | 1020 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1021 | } |
| 1022 | testcase TC_cm_serv_req_vbs_reject() runs on MTC_CT { |
| 1023 | var BSC_ConnHdlr vc_conn; |
| 1024 | f_init(); |
| 1025 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1026 | 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] | 1027 | vc_conn.done; |
| 1028 | } |
| 1029 | |
| 1030 | /* CM Service Request for LCS -> reject */ |
| 1031 | 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] | 1032 | f_init_handler(pars); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1033 | |
| 1034 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1035 | f_perform_lu(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1036 | |
| 1037 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
Harald Welte | 6ed6bf9 | 2018-01-24 21:09:15 +0100 | [diff] [blame] | 1038 | 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] | 1039 | f_bssap_compl_l3(l3_info); |
| 1040 | 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] | 1041 | f_expect_clear(); |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1042 | } |
| 1043 | testcase TC_cm_serv_req_lcs_reject() runs on MTC_CT { |
| 1044 | var BSC_ConnHdlr vc_conn; |
| 1045 | f_init(); |
| 1046 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1047 | 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] | 1048 | vc_conn.done; |
| 1049 | } |
| 1050 | |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1051 | /* CM Re-Establishment Request */ |
| 1052 | 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] | 1053 | f_init_handler(pars); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1054 | |
| 1055 | /* First perform location update to ensure subscriber is known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1056 | f_perform_lu(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1057 | |
| 1058 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 1059 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_REEST_REQ(0, mi)); |
| 1060 | f_bssap_compl_l3(l3_info); |
| 1061 | 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] | 1062 | f_expect_clear(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1063 | } |
| 1064 | testcase TC_cm_reest_req_reject() runs on MTC_CT { |
| 1065 | var BSC_ConnHdlr vc_conn; |
| 1066 | f_init(); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 1067 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1068 | 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] | 1069 | vc_conn.done; |
| 1070 | } |
| 1071 | |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1072 | /* Test LU (with authentication enabled), with wrong response from MS */ |
| 1073 | 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] | 1074 | f_init_handler(pars); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1075 | |
| 1076 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 1077 | |
| 1078 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 1079 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1080 | |
| 1081 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 1082 | f_bssap_compl_l3(l3_lu); |
| 1083 | |
| 1084 | /* Send Early Classmark, just for the fun of it */ |
| 1085 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1086 | |
| 1087 | var AuthVector vec := f_gen_auth_vec_2g(); |
| 1088 | var GSUP_IE auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G(vec.rand, vec.sres, vec.kc)); |
| 1089 | GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)); |
| 1090 | GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple)); |
| 1091 | |
| 1092 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_AUTH_REQ(vec.rand))); |
| 1093 | /* Send back wrong auth response */ |
| 1094 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MT_MM_AUTH_RESP_2G('00000000'O))); |
| 1095 | |
| 1096 | /* Expect GSUP AUTH FAIL REP to HLR */ |
| 1097 | GSUP.receive(tr_GSUP_AUTH_FAIL_IND(g_pars.imsi)); |
| 1098 | |
| 1099 | /* Expect LU REJECT with Cause == Illegal MS */ |
| 1100 | 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] | 1101 | f_expect_clear(); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1102 | } |
| 1103 | testcase TC_lu_auth_2G_fail() runs on MTC_CT { |
| 1104 | var BSC_ConnHdlr vc_conn; |
| 1105 | f_init(); |
| 1106 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | c638f4d | 2018-01-24 22:00:36 +0100 | [diff] [blame] | 1107 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1108 | 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] | 1109 | vc_conn.done; |
| 1110 | } |
| 1111 | |
Harald Welte | de37149 | 2018-01-27 23:44:41 +0100 | [diff] [blame] | 1112 | /* 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] | 1113 | 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] | 1114 | pars.net.expect_auth := true; |
| 1115 | pars.net.expect_ciph := true; |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1116 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1117 | f_perform_lu(); |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 1118 | } |
| 1119 | testcase TC_lu_imsi_auth_tmsi_encr_13_13() runs on MTC_CT { |
| 1120 | var BSC_ConnHdlr vc_conn; |
| 1121 | f_init(); |
| 1122 | f_vty_config(MSCVTY, "network", "authentication required"); |
Harald Welte | 1611428 | 2018-01-24 22:41:21 +0100 | [diff] [blame] | 1123 | f_vty_config(MSCVTY, "network", "encryption a5 1 3"); |
| 1124 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1125 | 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] | 1126 | vc_conn.done; |
| 1127 | } |
| 1128 | |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1129 | /* Test Complete L3 without payload */ |
| 1130 | 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] | 1131 | f_init_handler(pars); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1132 | |
| 1133 | /* Send Complete L3 Info with empty L3 frame */ |
| 1134 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own, |
| 1135 | valueof(ts_BSSMAP_ComplL3(g_pars.cell_id, ''O)))); |
| 1136 | |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1137 | timer T := 5.0; |
| 1138 | T.start; |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1139 | alt { |
| 1140 | [] BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
| 1141 | /* Expect LU REJECT with Cause == Illegal MS */ |
Harald Welte | bdb3c45 | 2018-03-18 22:43:06 +0100 | [diff] [blame] | 1142 | [] BSSAP.receive(tr_PDU_DTAP_MT(?)) { repeat; } |
| 1143 | [] BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_CONF_IND) { repeat; } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1144 | [] as_clear_cmd_compl_disc(); |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1145 | [] T.timeout { |
Daniel Willmann | 90829d6 | 2018-02-15 17:45:14 +0100 | [diff] [blame] | 1146 | setverdict(fail, "Timeout waiting for ClearCommand or SCCP Release"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1147 | mtc.stop; |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1148 | } |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1149 | } |
| 1150 | setverdict(pass); |
| 1151 | } |
| 1152 | testcase TC_cl3_no_payload() runs on MTC_CT { |
| 1153 | var BSC_ConnHdlr vc_conn; |
| 1154 | f_init(); |
| 1155 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1156 | vc_conn := f_start_handler(refers(f_tc_cl3_no_payload), 25); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1157 | vc_conn.done; |
| 1158 | } |
| 1159 | |
| 1160 | /* Test Complete L3 with random payload */ |
| 1161 | 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] | 1162 | f_init_handler(pars); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1163 | |
Daniel Willmann | aa14a38 | 2018-07-26 08:29:45 +0200 | [diff] [blame] | 1164 | /* length is limited by PDU_BSSAP length field which includes some |
| 1165 | * other fields beside l3info payload. So payl can only be 240 bytes |
| 1166 | * Since rnd() returns values < 1 multiply with 241 |
| 1167 | */ |
| 1168 | var integer len := float2int(rnd() * 241.0); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1169 | var octetstring payl := f_rnd_octstring(len); |
| 1170 | |
| 1171 | /* Send Complete L3 Info with empty L3 frame */ |
| 1172 | BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own, |
| 1173 | valueof(ts_BSSMAP_ComplL3(g_pars.cell_id, payl)))); |
| 1174 | |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1175 | timer T := 5.0; |
| 1176 | T.start; |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1177 | alt { |
| 1178 | /* Immediate disconnect */ |
| 1179 | [] BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {} |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1180 | [] BSSAP.receive(tr_PDU_DTAP_MT(?)) { repeat; } |
Harald Welte | bdb3c45 | 2018-03-18 22:43:06 +0100 | [diff] [blame] | 1181 | [] BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_CONF_IND) { repeat; } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1182 | [] as_clear_cmd_compl_disc(); |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1183 | [] T.timeout { |
Daniel Willmann | 90829d6 | 2018-02-15 17:45:14 +0100 | [diff] [blame] | 1184 | setverdict(fail, "Timeout waiting for ClearCommand or SCCP Release"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1185 | mtc.stop; |
Harald Welte | f466eb4 | 2018-01-27 14:26:54 +0100 | [diff] [blame] | 1186 | } |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1187 | } |
| 1188 | setverdict(pass); |
| 1189 | } |
| 1190 | testcase TC_cl3_rnd_payload() runs on MTC_CT { |
| 1191 | var BSC_ConnHdlr vc_conn; |
| 1192 | f_init(); |
| 1193 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1194 | vc_conn := f_start_handler(refers(f_tc_cl3_rnd_payload), 26); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 1195 | vc_conn.done; |
| 1196 | } |
| 1197 | |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1198 | /* Test Complete L3 with random payload */ |
| 1199 | 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] | 1200 | f_init_handler(pars); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1201 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1202 | f_perform_lu(); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1203 | |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1204 | f_establish_fully(); |
Daniel Willmann | 898a7e0 | 2018-05-17 12:16:16 +0200 | [diff] [blame] | 1205 | f_expect_clear(10.0); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1206 | } |
| 1207 | testcase TC_establish_and_nothing() runs on MTC_CT { |
| 1208 | var BSC_ConnHdlr vc_conn; |
| 1209 | f_init(); |
| 1210 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1211 | vc_conn := f_start_handler(refers(f_tc_establish_and_nothing), 27); |
Harald Welte | 116e433 | 2018-01-26 22:17:48 +0100 | [diff] [blame] | 1212 | vc_conn.done; |
| 1213 | } |
| 1214 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1215 | /* Test MO Call SETUP with no response from MNCC */ |
| 1216 | 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] | 1217 | f_init_handler(pars, 190.0); |
Harald Welte | a10db90 | 2018-01-27 12:44:49 +0100 | [diff] [blame] | 1218 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1219 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1220 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1221 | f_perform_lu(); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1222 | |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1223 | f_establish_fully(); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1224 | f_create_mncc_expect(hex2str(cpars.called_party)); |
| 1225 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1226 | |
| 1227 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_SETUP(cpars.transaction_id, cpars.called_party))); |
| 1228 | |
Philipp Maier | 109e6aa | 2018-10-17 10:53:32 +0200 | [diff] [blame] | 1229 | f_expect_clear(185.0); |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1230 | } |
| 1231 | testcase TC_mo_setup_and_nothing() runs on MTC_CT { |
| 1232 | var BSC_ConnHdlr vc_conn; |
| 1233 | f_init(); |
| 1234 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1235 | 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] | 1236 | vc_conn.done; |
| 1237 | } |
| 1238 | |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1239 | /* Test MO Call with no response to RAN-side CRCX */ |
| 1240 | 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] | 1241 | f_init_handler(pars); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1242 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1243 | var MNCC_PDU mncc; |
| 1244 | var MgcpCommand mgcp_cmd; |
| 1245 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1246 | f_perform_lu(); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1247 | |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1248 | f_establish_fully(); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1249 | f_create_mncc_expect(hex2str(cpars.called_party)); |
| 1250 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1251 | |
| 1252 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_SETUP(cpars.transaction_id, cpars.called_party))); |
| 1253 | MNCC.receive(tr_MNCC_SETUP_ind(?, tr_MNCC_number(hex2str(cpars.called_party)))) -> value mncc; |
| 1254 | cpars.mncc_callref := mncc.u.signal.callref; |
| 1255 | MNCC.send(ts_MNCC_CALL_PROC_req(cpars.mncc_callref, cpars.mncc_bearer_cap)); |
| 1256 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CALL_PROC(cpars.transaction_id))); |
| 1257 | |
| 1258 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
Harald Welte | 1852a84 | 2018-01-26 22:53:36 +0100 | [diff] [blame] | 1259 | cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
| 1260 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1261 | /* never respond to this */ |
| 1262 | |
Philipp Maier | 8e58f59 | 2018-03-14 11:10:56 +0100 | [diff] [blame] | 1263 | /* When the connection with the MGW fails, the MSC will first request |
| 1264 | * a release via call control. We will answer this request normally. */ |
| 1265 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))); |
| 1266 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_REL_COMPL(cpars.transaction_id))); |
| 1267 | |
Harald Welte | 1ddc716 | 2018-01-27 14:25:46 +0100 | [diff] [blame] | 1268 | f_expect_clear(30.0); |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1269 | } |
| 1270 | testcase TC_mo_crcx_ran_timeout() runs on MTC_CT { |
| 1271 | var BSC_ConnHdlr vc_conn; |
| 1272 | f_init(); |
| 1273 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1274 | 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] | 1275 | vc_conn.done; |
| 1276 | } |
| 1277 | |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1278 | /* Test MO Call with reject to RAN-side CRCX */ |
| 1279 | 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] | 1280 | f_init_handler(pars); |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1281 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1282 | var MNCC_PDU mncc; |
| 1283 | var MgcpCommand mgcp_cmd; |
| 1284 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1285 | f_perform_lu(); |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1286 | |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1287 | f_establish_fully(); |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1288 | f_create_mncc_expect(hex2str(cpars.called_party)); |
| 1289 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1290 | |
| 1291 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_SETUP(cpars.transaction_id, cpars.called_party))); |
| 1292 | MNCC.receive(tr_MNCC_SETUP_ind(?, tr_MNCC_number(hex2str(cpars.called_party)))) -> value mncc; |
| 1293 | cpars.mncc_callref := mncc.u.signal.callref; |
| 1294 | MNCC.send(ts_MNCC_CALL_PROC_req(cpars.mncc_callref, cpars.mncc_bearer_cap)); |
| 1295 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CALL_PROC(cpars.transaction_id))); |
| 1296 | |
| 1297 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 1298 | |
| 1299 | /* Detect if the received CRCX is a wildcarded CRCX request. If yes, |
| 1300 | * set an endpoint name that fits the pattern. If not, just use the |
| 1301 | * endpoint name from the request */ |
| 1302 | if (match(mgcp_cmd.line.ep, t_MGCP_EP_wildcard)) { |
| 1303 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
| 1304 | } else { |
| 1305 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
| 1306 | } |
| 1307 | |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1308 | cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 1309 | |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1310 | /* Respond to CRCX with error */ |
| 1311 | var MgcpResponse mgcp_rsp := { |
| 1312 | line := { |
| 1313 | code := "542", |
| 1314 | trans_id := mgcp_cmd.line.trans_id, |
| 1315 | string := "FORCED_FAIL" |
| 1316 | }, |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1317 | sdp := omit |
| 1318 | } |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 1319 | var MgcpParameter mgcp_rsp_param := { |
| 1320 | code := "Z", |
| 1321 | val := cpars.mgcp_ep |
| 1322 | }; |
| 1323 | mgcp_rsp.params[0] := mgcp_rsp_param; |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1324 | MGCP.send(mgcp_rsp); |
| 1325 | |
| 1326 | timer T := 30.0; |
| 1327 | T.start; |
| 1328 | alt { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1329 | [] T.timeout { |
| 1330 | setverdict(fail, "Timeout waiting for channel release"); |
| 1331 | mtc.stop; |
| 1332 | } |
Daniel Willmann | 5868e62 | 2018-02-15 17:42:59 +0100 | [diff] [blame] | 1333 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))) { |
| 1334 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_REL_COMPL(cpars.transaction_id))); |
| 1335 | repeat; |
| 1336 | } |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1337 | [] MNCC.receive { repeat; } |
| 1338 | [] GSUP.receive { repeat; } |
Philipp Maier | c6e06f7 | 2018-04-11 18:12:23 +0200 | [diff] [blame] | 1339 | /* Note: As we did not respond properly to the CRCX from the MSC we |
| 1340 | * expect the MSC to omit any further MGCP operation (At least in the |
| 1341 | * the current implementation, there is no recovery mechanism implemented |
| 1342 | * and a DLCX can not be performed as the MSC does not know a specific |
| 1343 | * endpoint yet. */ |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1344 | [] MGCP.receive { |
| 1345 | setverdict(fail, "Unexpected MGCP message"); |
| 1346 | mtc.stop; |
| 1347 | } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1348 | [] as_clear_cmd_compl_disc(); |
Harald Welte | 0cc82d9 | 2018-01-26 22:52:34 +0100 | [diff] [blame] | 1349 | } |
| 1350 | } |
| 1351 | testcase TC_mo_crcx_ran_reject() runs on MTC_CT { |
| 1352 | var BSC_ConnHdlr vc_conn; |
| 1353 | f_init(); |
| 1354 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1355 | 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] | 1356 | vc_conn.done; |
| 1357 | } |
| 1358 | |
Harald Welte | 3ab8800 | 2018-01-26 22:37:25 +0100 | [diff] [blame] | 1359 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1360 | /* helper function to start a MT call: MNCC SETUP; Paging; DChan est.; DTAP SETUP */ |
| 1361 | private function f_mt_call_start(inout CallParameters cpars) runs on BSC_ConnHdlr { |
| 1362 | var MNCC_PDU mncc; |
| 1363 | var MgcpCommand mgcp_cmd; |
| 1364 | var OCT4 tmsi; |
| 1365 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1366 | f_perform_lu(); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1367 | if (isvalue(g_pars.tmsi)) { |
| 1368 | tmsi := g_pars.tmsi; |
| 1369 | } else { |
| 1370 | tmsi := 'FFFFFFFF'O; |
| 1371 | } |
| 1372 | f_bssmap_register_imsi(g_pars.imsi, tmsi); |
| 1373 | |
| 1374 | /* Allocate call reference and send SETUP via MNCC to MSC */ |
| 1375 | cpars.mncc_callref := f_rnd_int(2147483648); |
| 1376 | MNCC.send(ts_MNCC_SETUP_req(cpars.mncc_callref, hex2str(g_pars.msisdn), |
| 1377 | hex2str(cpars.called_party), hex2str(g_pars.imsi))); |
| 1378 | |
| 1379 | /* MSC->BSC: expect PAGING from MSC */ |
| 1380 | BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)); |
| 1381 | /* MS -> MSC: PAGING RESPONSE */ |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1382 | f_establish_fully(EST_TYPE_PAG_RESP); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1383 | |
| 1384 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1385 | |
| 1386 | /* MSC->MS: SETUP */ |
| 1387 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_SETUP(cpars.transaction_id, *, cpars.called_party))); |
| 1388 | } |
| 1389 | |
| 1390 | /* Test MT Call */ |
| 1391 | 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] | 1392 | f_init_handler(pars); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1393 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
| 1394 | var MNCC_PDU mncc; |
| 1395 | var MgcpCommand mgcp_cmd; |
| 1396 | |
| 1397 | f_mt_call_start(cpars); |
| 1398 | |
| 1399 | /* MS->MSC: CALL CONFIRMED */ |
| 1400 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CALL_CONF(cpars.transaction_id))); |
| 1401 | |
| 1402 | MNCC.receive(tr_MNCC_CALL_CONF_ind(cpars.mncc_callref)); |
| 1403 | |
| 1404 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
| 1405 | cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 1406 | |
| 1407 | /* Detect if the received CRCX is a wildcarded CRCX request. If yes, |
| 1408 | * set an endpoint name that fits the pattern. If not, just use the |
| 1409 | * endpoint name from the request */ |
| 1410 | if (match(mgcp_cmd.line.ep, t_MGCP_EP_wildcard)) { |
| 1411 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
| 1412 | } else { |
| 1413 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
| 1414 | } |
| 1415 | |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1416 | /* Respond to CRCX with error */ |
| 1417 | var MgcpResponse mgcp_rsp := { |
| 1418 | line := { |
| 1419 | code := "542", |
| 1420 | trans_id := mgcp_cmd.line.trans_id, |
| 1421 | string := "FORCED_FAIL" |
| 1422 | }, |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1423 | sdp := omit |
| 1424 | } |
Philipp Maier | f1e02bb | 2018-03-15 16:30:00 +0100 | [diff] [blame] | 1425 | var MgcpParameter mgcp_rsp_param := { |
| 1426 | code := "Z", |
| 1427 | val := cpars.mgcp_ep |
| 1428 | }; |
| 1429 | mgcp_rsp.params[0] := mgcp_rsp_param; |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1430 | MGCP.send(mgcp_rsp); |
| 1431 | |
| 1432 | timer T := 30.0; |
| 1433 | T.start; |
| 1434 | alt { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1435 | [] T.timeout { |
| 1436 | setverdict(fail, "Timeout waiting for channel release"); |
| 1437 | mtc.stop; |
| 1438 | } |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1439 | [] BSSAP.receive { repeat; } |
| 1440 | [] MNCC.receive { repeat; } |
| 1441 | [] GSUP.receive { repeat; } |
| 1442 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 1443 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
| 1444 | f_create_mgcp_delete_ep(cpars.mgcp_ep); |
| 1445 | repeat; |
| 1446 | } |
| 1447 | [] MGCP.receive { repeat; } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1448 | [] as_clear_cmd_compl_disc(); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1449 | } |
| 1450 | } |
| 1451 | testcase TC_mt_crcx_ran_reject() runs on MTC_CT { |
| 1452 | var BSC_ConnHdlr vc_conn; |
| 1453 | f_init(); |
| 1454 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1455 | 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] | 1456 | vc_conn.done; |
| 1457 | } |
| 1458 | |
| 1459 | |
| 1460 | /* Test MT Call T310 timer */ |
| 1461 | 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] | 1462 | f_init_handler(pars, 200.0); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1463 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
| 1464 | var MNCC_PDU mncc; |
| 1465 | var MgcpCommand mgcp_cmd; |
| 1466 | |
| 1467 | f_mt_call_start(cpars); |
| 1468 | |
| 1469 | /* MS->MSC: CALL CONFIRMED */ |
| 1470 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CALL_CONF(cpars.transaction_id))); |
| 1471 | MNCC.receive(tr_MNCC_CALL_CONF_ind(cpars.mncc_callref)); |
| 1472 | |
| 1473 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
| 1474 | cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
| 1475 | cpars.mgcp_ep := mgcp_cmd.line.ep; |
| 1476 | /* FIXME: Respond to CRCX */ |
| 1477 | |
| 1478 | /* old libosmocore T310 default timeout is 180s. so let's wait 190 */ |
| 1479 | timer T := 190.0; |
| 1480 | T.start; |
| 1481 | alt { |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1482 | [] T.timeout { |
| 1483 | setverdict(fail, "Timeout waiting for T310"); |
| 1484 | mtc.stop; |
| 1485 | } |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1486 | [] MNCC.receive(tr_MNCC_DISC_ind(cpars.mncc_callref)) { |
| 1487 | MNCC.send(ts_MNCC_REL_req(cpars.mncc_callref, valueof(ts_MNCC_cause(23)))); |
| 1488 | } |
| 1489 | } |
| 1490 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_DISC(cpars.transaction_id))); |
| 1491 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))); |
| 1492 | /* FIXME: We're sending this with TIflag 0: allocated by sender, which is wrong */ |
| 1493 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_REL_COMPL(cpars.transaction_id))); |
| 1494 | |
| 1495 | alt { |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1496 | [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd { |
| 1497 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
| 1498 | f_create_mgcp_delete_ep(cpars.mgcp_ep); |
| 1499 | repeat; |
| 1500 | } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1501 | [] as_clear_cmd_compl_disc(); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1502 | } |
| 1503 | } |
| 1504 | testcase TC_mt_t310() runs on MTC_CT { |
| 1505 | var BSC_ConnHdlr vc_conn; |
| 1506 | f_init(); |
| 1507 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1508 | vc_conn := f_start_handler(refers(f_tc_mt_t310), 32); |
Harald Welte | 812f7a4 | 2018-01-27 00:49:18 +0100 | [diff] [blame] | 1509 | vc_conn.done; |
| 1510 | } |
| 1511 | |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1512 | /* Perform successful LU + MO call, then GSUP LocationCancel. Subscriber must be denied CM SERV */ |
| 1513 | private function f_tc_gsup_cancel(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1514 | f_init_handler(pars); |
| 1515 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1516 | cpars.bss_rtp_port := 1110; |
| 1517 | cpars.mgcp_connection_id_bss := '22222'H; |
| 1518 | cpars.mgcp_connection_id_mss := '33333'H; |
Daniel Willmann | 9b0235b | 2018-07-24 12:13:34 +0200 | [diff] [blame] | 1519 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1520 | |
| 1521 | /* Location Update to make subscriber known */ |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1522 | f_perform_lu(); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1523 | |
| 1524 | /* First MO call should succeed */ |
| 1525 | f_mo_call(cpars); |
| 1526 | |
| 1527 | /* Cancel the subscriber in the VLR */ |
| 1528 | GSUP.send(ts_GSUP_CL_REQ(g_pars.imsi, OSMO_GSUP_CANCEL_TYPE_WITHDRAW)); |
| 1529 | alt { |
| 1530 | [] GSUP.receive(tr_GSUP_CL_RES(g_pars.imsi)) { } |
| 1531 | [] GSUP.receive(tr_GSUP_CL_ERR(g_pars.imsi)) { |
| 1532 | setverdict(fail, "Received GSUP Location Cancel Error"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1533 | mtc.stop; |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1534 | } |
| 1535 | } |
| 1536 | |
| 1537 | /* Follow-up transactions should fail */ |
| 1538 | var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi)); |
| 1539 | var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi)); |
| 1540 | f_bssap_compl_l3(l3_info); |
| 1541 | alt { |
| 1542 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)) { } |
| 1543 | [] BSSAP.receive { |
| 1544 | setverdict(fail, "Received unexpected BSSAP instead of CM SERV REJ"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1545 | mtc.stop; |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1546 | } |
| 1547 | } |
| 1548 | setverdict(pass); |
| 1549 | } |
| 1550 | testcase TC_gsup_cancel() runs on MTC_CT { |
| 1551 | var BSC_ConnHdlr vc_conn; |
| 1552 | f_init(); |
| 1553 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1554 | vc_conn := f_start_handler(refers(f_tc_gsup_cancel), 33); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 1555 | vc_conn.done; |
| 1556 | } |
| 1557 | |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1558 | /* A5/1 only permitted on network side, and MS capable to do it */ |
| 1559 | private function f_tc_lu_imsi_auth_tmsi_encr_1_13(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1560 | pars.net.expect_auth := true; |
| 1561 | pars.net.expect_ciph := true; |
| 1562 | pars.net.kc_support := '02'O; /* A5/1 only */ |
| 1563 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1564 | f_perform_lu(); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1565 | } |
| 1566 | testcase TC_lu_imsi_auth_tmsi_encr_1_13() runs on MTC_CT { |
| 1567 | var BSC_ConnHdlr vc_conn; |
| 1568 | f_init(); |
| 1569 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1570 | f_vty_config(MSCVTY, "network", "encryption a5 1"); |
| 1571 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1572 | 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] | 1573 | vc_conn.done; |
| 1574 | } |
| 1575 | |
| 1576 | /* A5/3 only permitted on network side, and MS capable to do it */ |
| 1577 | private function f_tc_lu_imsi_auth_tmsi_encr_3_13(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1578 | pars.net.expect_auth := true; |
| 1579 | pars.net.expect_ciph := true; |
| 1580 | pars.net.kc_support := '08'O; /* A5/3 only */ |
| 1581 | f_init_handler(pars); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1582 | f_perform_lu(); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1583 | } |
| 1584 | testcase TC_lu_imsi_auth_tmsi_encr_3_13() runs on MTC_CT { |
| 1585 | var BSC_ConnHdlr vc_conn; |
| 1586 | f_init(); |
| 1587 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1588 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1589 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1590 | 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] | 1591 | vc_conn.done; |
| 1592 | } |
| 1593 | |
| 1594 | /* A5/3 only permitted on network side, and MS with only A5/1 support */ |
| 1595 | private function f_tc_lu_imsi_auth_tmsi_encr_3_1(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1596 | pars.net.expect_auth := true; |
| 1597 | pars.net.expect_ciph := true; |
| 1598 | pars.net.kc_support := '08'O; /* A5/3 only */ |
| 1599 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 1600 | f_init_handler(pars, 15.0); |
| 1601 | |
| 1602 | /* cannot use f_perform_lu() as we expect a reject */ |
| 1603 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 1604 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1605 | f_bssap_compl_l3(l3_lu); |
Neels Hofmeyr | 29b8da0 | 2018-03-01 18:09:45 +0100 | [diff] [blame] | 1606 | if (pars.send_early_cm) { |
| 1607 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1608 | } else { |
| 1609 | pars.cm1.esind := '0'B; |
| 1610 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1611 | f_mm_auth(); |
| 1612 | alt { |
Daniel Willmann | 52918e5 | 2018-09-20 14:39:09 +0200 | [diff] [blame] | 1613 | [] BSSAP.receive(tr_BSSMAP_ClassmarkReq) { |
| 1614 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1615 | repeat; |
| 1616 | } |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1617 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 1618 | f_expect_clear(); |
| 1619 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1620 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?,?)) { |
| 1621 | setverdict(fail, "CipherModeCommand despite no A5 intersection"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1622 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1623 | } |
| 1624 | [] BSSAP.receive { |
Harald Welte | 458fd37 | 2018-03-21 11:26:23 +0100 | [diff] [blame] | 1625 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1626 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1627 | } |
| 1628 | } |
| 1629 | setverdict(pass); |
| 1630 | } |
| 1631 | testcase TC_lu_imsi_auth_tmsi_encr_3_1() runs on MTC_CT { |
| 1632 | var BSC_ConnHdlr vc_conn; |
| 1633 | f_init(); |
| 1634 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1635 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1636 | |
Neels Hofmeyr | 29b8da0 | 2018-03-01 18:09:45 +0100 | [diff] [blame] | 1637 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_3_1), 360); |
| 1638 | vc_conn.done; |
| 1639 | } |
| 1640 | testcase TC_lu_imsi_auth_tmsi_encr_3_1_no_cm() runs on MTC_CT { |
| 1641 | var BSC_ConnHdlrPars pars; |
| 1642 | var BSC_ConnHdlr vc_conn; |
| 1643 | f_init(); |
| 1644 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1645 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1646 | |
| 1647 | pars := f_init_pars(361); |
| 1648 | pars.send_early_cm := false; |
| 1649 | 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] | 1650 | vc_conn.done; |
| 1651 | } |
Neels Hofmeyr | 1b3c6e3 | 2018-03-01 17:52:21 +0100 | [diff] [blame] | 1652 | testcase TC_lu_imsi_auth_tmsi_encr_3_1_log_msc_debug() runs on MTC_CT { |
| 1653 | var BSC_ConnHdlr vc_conn; |
| 1654 | f_init(); |
| 1655 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1656 | f_vty_config(MSCVTY, "network", "encryption a5 3"); |
| 1657 | |
| 1658 | /* Make sure the MSC category is on DEBUG level to trigger the log |
| 1659 | * message that is reported in OS#2947 to trigger the segfault */ |
| 1660 | f_vty_config(MSCVTY, "log stderr", "logging level msc debug"); |
| 1661 | |
| 1662 | vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_3_1), 362); |
| 1663 | vc_conn.done; |
| 1664 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1665 | |
| 1666 | /* A5/1 + A5/3 only permitted on network side, and MS with only A5/2 support */ |
| 1667 | private function f_tc_lu_imsi_auth_tmsi_encr_13_2(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1668 | pars.net.expect_auth := true; |
| 1669 | pars.net.expect_ciph := true; |
| 1670 | pars.net.kc_support := '0A'O; /* A5/1 + A5/3 */ |
| 1671 | pars.cm1.a5_1 := '1'B; |
| 1672 | pars.cm2.a5_1 := '1'B; |
| 1673 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 1674 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '1'B; |
| 1675 | f_init_handler(pars, 15.0); |
| 1676 | |
| 1677 | /* cannot use f_perform_lu() as we expect a reject */ |
| 1678 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi); |
| 1679 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 1680 | f_bssap_compl_l3(l3_lu); |
| 1681 | BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3)); |
| 1682 | f_mm_auth(); |
| 1683 | alt { |
Harald Welte | 5946b33 | 2018-03-18 23:32:21 +0100 | [diff] [blame] | 1684 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 1685 | f_expect_clear(); |
| 1686 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1687 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?,?)) { |
| 1688 | setverdict(fail, "CipherModeCommand despite no A5 intersection"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1689 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1690 | } |
| 1691 | [] BSSAP.receive { |
Harald Welte | 458fd37 | 2018-03-21 11:26:23 +0100 | [diff] [blame] | 1692 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1693 | mtc.stop; |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1694 | } |
| 1695 | } |
| 1696 | setverdict(pass); |
| 1697 | } |
| 1698 | testcase TC_lu_imsi_auth_tmsi_encr_13_2() runs on MTC_CT { |
| 1699 | var BSC_ConnHdlr vc_conn; |
| 1700 | f_init(); |
| 1701 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1702 | f_vty_config(MSCVTY, "network", "encryption a5 1 3"); |
| 1703 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1704 | 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] | 1705 | vc_conn.done; |
| 1706 | } |
| 1707 | |
| 1708 | /* A5/0 + A5/1 + A5/3 only permitted on network side, and MS with only A5/2 support */ |
| 1709 | private function f_tc_lu_imsi_auth_tmsi_encr_013_2(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1710 | pars.net.expect_auth := true; |
| 1711 | pars.net.expect_ciph := true; |
| 1712 | pars.net.kc_support := '0B'O; /* A5/1 + A5/3 */ |
| 1713 | pars.cm1.a5_1 := '1'B; |
| 1714 | pars.cm2.a5_1 := '1'B; |
| 1715 | pars.cm2.classmarkInformationType2_oct5.a5_3 := '0'B; |
| 1716 | pars.cm2.classmarkInformationType2_oct5.a5_2 := '1'B; |
| 1717 | f_init_handler(pars, 15.0); |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1718 | f_perform_lu(); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1719 | } |
| 1720 | testcase TC_lu_imsi_auth_tmsi_encr_013_2() runs on MTC_CT { |
| 1721 | var BSC_ConnHdlr vc_conn; |
| 1722 | f_init(); |
| 1723 | f_vty_config(MSCVTY, "network", "authentication required"); |
| 1724 | f_vty_config(MSCVTY, "network", "encryption a5 0 1 3"); |
| 1725 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1726 | 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] | 1727 | vc_conn.done; |
| 1728 | } |
| 1729 | |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 1730 | /* LU followed by MT call (including paging) */ |
| 1731 | private function f_tc_lu_and_mt_call(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1732 | f_init_handler(pars); |
Stefan Sperling | 26d57be | 2018-11-12 17:03:26 +0100 | [diff] [blame] | 1733 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 1734 | cpars.bss_rtp_port := 1110; |
| 1735 | cpars.mgcp_connection_id_bss := '10004'H; |
| 1736 | cpars.mgcp_connection_id_mss := '10005'H; |
| 1737 | |
Philipp Maier | 4b2692d | 2018-03-14 16:37:48 +0100 | [diff] [blame] | 1738 | /* Note: This is an optional parameter. When the call-agent (MSC) does |
| 1739 | * supply a full endpoint name this setting will be overwritten. */ |
| 1740 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
| 1741 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1742 | f_perform_lu(); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 1743 | f_mt_call(cpars); |
| 1744 | } |
| 1745 | testcase TC_lu_and_mt_call() runs on MTC_CT { |
| 1746 | var BSC_ConnHdlr vc_conn; |
| 1747 | f_init(); |
| 1748 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1749 | 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] | 1750 | vc_conn.done; |
| 1751 | } |
| 1752 | |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1753 | /* Test MO Call SETUP with DTMF */ |
| 1754 | private function f_tc_mo_setup_dtmf_dup(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1755 | f_init_handler(pars); |
| 1756 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1757 | cpars.bss_rtp_port := 1110; |
| 1758 | cpars.mgcp_connection_id_bss := '22222'H; |
| 1759 | cpars.mgcp_connection_id_mss := '33333'H; |
| 1760 | |
Neels Hofmeyr | c1f105a | 2018-03-01 20:00:19 +0100 | [diff] [blame] | 1761 | f_perform_lu(); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 1762 | f_mo_seq_dtmf_dup(cpars); |
| 1763 | } |
| 1764 | testcase TC_mo_setup_and_dtmf_dup() runs on MTC_CT { |
| 1765 | var BSC_ConnHdlr vc_conn; |
| 1766 | f_init(); |
| 1767 | |
Neels Hofmeyr | e9b8eeb | 2018-03-01 20:29:58 +0100 | [diff] [blame] | 1768 | 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] | 1769 | vc_conn.done; |
| 1770 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1771 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 1772 | testcase TC_cr_before_reset() runs on MTC_CT { |
| 1773 | timer T := 4.0; |
| 1774 | var boolean reset_ack_seen := false; |
| 1775 | f_init_bssap_direct(); |
| 1776 | |
Daniel Willmann | 42d1d5b | 2018-08-07 15:18:41 +0200 | [diff] [blame] | 1777 | f_bssap_start(g_bssap[0]); |
| 1778 | |
Daniel Willmann | e801896 | 2018-08-21 14:18:00 +0200 | [diff] [blame] | 1779 | f_sleep(3.0); |
| 1780 | |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 1781 | /* Make a blind connection attemt, to trigger the deadlock condition */ |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 1782 | 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] | 1783 | |
| 1784 | /* Send a BSSMAP reset */ |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 1785 | 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] | 1786 | T.start |
| 1787 | alt { |
| 1788 | [] BSSAP_DIRECT.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_ResetAck)) { |
| 1789 | reset_ack_seen := true; |
| 1790 | repeat; |
| 1791 | } |
| 1792 | |
| 1793 | /* Acknowledge MSC sided reset requests */ |
| 1794 | [] BSSAP_DIRECT.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset)) { |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 1795 | 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] | 1796 | repeat; |
| 1797 | } |
| 1798 | |
| 1799 | /* Ignore all other messages (e.g CR from the connection request) */ |
| 1800 | [] BSSAP_DIRECT.receive { repeat } |
| 1801 | |
| 1802 | /* If we got no BSSMAP RESET ACK back, then the MSC entered the |
| 1803 | * deadlock situation. The MSC is then unable to respond to any |
| 1804 | * further BSSMAP RESET or any other sort of traffic. */ |
| 1805 | [reset_ack_seen == true] T.timeout { setverdict(pass) } |
| 1806 | [reset_ack_seen == false] T.timeout { |
| 1807 | setverdict(fail, "no BSSMAP RESET ACK seen!"); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 1808 | mtc.stop; |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 1809 | } |
| 1810 | } |
| 1811 | } |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 1812 | |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 1813 | /* Test MO Call with no response to RAN-side CRCX or DTAP Release */ |
| 1814 | private function f_tc_mo_release_timeout(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1815 | f_init_handler(pars); |
| 1816 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 1817 | var MNCC_PDU mncc; |
| 1818 | var MgcpCommand mgcp_cmd; |
| 1819 | |
| 1820 | f_perform_lu(); |
| 1821 | |
Harald Welte | b9e86fa | 2018-04-09 18:18:31 +0200 | [diff] [blame] | 1822 | f_establish_fully(); |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 1823 | f_create_mncc_expect(hex2str(cpars.called_party)); |
| 1824 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1825 | |
| 1826 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_SETUP(cpars.transaction_id, cpars.called_party))); |
| 1827 | MNCC.receive(tr_MNCC_SETUP_ind(?, tr_MNCC_number(hex2str(cpars.called_party)))) -> value mncc; |
| 1828 | cpars.mncc_callref := mncc.u.signal.callref; |
| 1829 | MNCC.send(ts_MNCC_CALL_PROC_req(cpars.mncc_callref, cpars.mncc_bearer_cap)); |
| 1830 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CALL_PROC(cpars.transaction_id))); |
| 1831 | |
| 1832 | /* Drop CRCX */ |
| 1833 | MGCP.receive(tr_CRCX) -> value mgcp_cmd; |
| 1834 | |
| 1835 | /* Drop DTAP Release */ |
| 1836 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))); |
| 1837 | |
| 1838 | /* Drop resent DTAP Release */ |
| 1839 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))); |
| 1840 | |
| 1841 | f_expect_clear(60.0); |
| 1842 | } |
| 1843 | testcase TC_mo_release_timeout() runs on MTC_CT { |
| 1844 | var BSC_ConnHdlr vc_conn; |
| 1845 | f_init(); |
| 1846 | |
| 1847 | vc_conn := f_start_handler(refers(f_tc_mo_release_timeout), 40); |
| 1848 | vc_conn.done; |
| 1849 | } |
| 1850 | |
Harald Welte | 12510c5 | 2018-01-26 22:26:24 +0100 | [diff] [blame] | 1851 | |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 1852 | /* LU followed by MT call (including paging) */ |
| 1853 | private function f_tc_lu_and_mt_call_no_dlcx_resp(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1854 | f_init_handler(pars); |
Stefan Sperling | 26d57be | 2018-11-12 17:03:26 +0100 | [diff] [blame] | 1855 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 1856 | cpars.bss_rtp_port := 1110; |
| 1857 | cpars.mgcp_connection_id_bss := '10004'H; |
| 1858 | cpars.mgcp_connection_id_mss := '10005'H; |
| 1859 | |
| 1860 | /* Note: This is an optional parameter. When the call-agent (MSC) does |
| 1861 | * supply a full endpoint name this setting will be overwritten. */ |
| 1862 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
| 1863 | |
| 1864 | /* Intentionally disable the CRCX response */ |
| 1865 | cpars.mgw_drop_dlcx := true; |
| 1866 | |
| 1867 | /* Perform location update and call */ |
| 1868 | f_perform_lu(); |
| 1869 | f_mt_call(cpars); |
| 1870 | } |
| 1871 | testcase TC_lu_and_mt_call_no_dlcx_resp() runs on MTC_CT { |
| 1872 | var BSC_ConnHdlr vc_conn; |
| 1873 | f_init(); |
| 1874 | |
| 1875 | /* Perform an almost normal looking locationupdate + mt-call, but do |
| 1876 | * not respond to the DLCX at the end of the call */ |
| 1877 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_call_no_dlcx_resp), 41); |
| 1878 | vc_conn.done; |
| 1879 | |
| 1880 | /* Wait a guard period until the MGCP layer in the MSC times out, |
| 1881 | * if the MSC is vulnerable to the use-after-free situation that is |
| 1882 | * fixed by I78f1b6a9149488a4ad3f120c1e190a83c07d4b89 then it should |
| 1883 | * segfault now */ |
| 1884 | f_sleep(6.0); |
| 1885 | |
| 1886 | /* Run the init procedures once more. If the MSC has crashed, this |
| 1887 | * this will fail */ |
| 1888 | f_init(); |
| 1889 | } |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 1890 | |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 1891 | /* Two BSSMAP resets from two different BSCs */ |
| 1892 | testcase TC_reset_two() runs on MTC_CT { |
| 1893 | var BSC_ConnHdlr vc_conn; |
| 1894 | f_init(2); |
| 1895 | f_sleep(2.0); |
| 1896 | setverdict(pass); |
| 1897 | } |
| 1898 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 1899 | /*********************************************************************** |
| 1900 | * SMS Testing |
| 1901 | ***********************************************************************/ |
| 1902 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1903 | /* LU followed by MO SMS */ |
| 1904 | private function f_tc_lu_and_mo_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1905 | var SmsParameters spars := valueof(t_SmsPars); |
| 1906 | |
| 1907 | f_init_handler(pars); |
| 1908 | |
| 1909 | /* Perform location update and call */ |
| 1910 | f_perform_lu(); |
| 1911 | |
| 1912 | f_establish_fully(EST_TYPE_MO_SMS); |
| 1913 | |
| 1914 | //spars.exp_rp_err := 96; /* invalid mandatory information */ |
| 1915 | f_mo_sms(spars); |
| 1916 | |
| 1917 | f_expect_clear(); |
| 1918 | } |
| 1919 | testcase TC_lu_and_mo_sms() runs on MTC_CT { |
| 1920 | var BSC_ConnHdlr vc_conn; |
| 1921 | f_init(); |
| 1922 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_sms), 42); |
| 1923 | vc_conn.done; |
| 1924 | } |
| 1925 | |
| 1926 | private function f_vty_sms_send(charstring imsi, charstring msisdn, charstring text) |
| 1927 | runs on MTC_CT { |
| 1928 | f_vty_transceive(MSCVTY, "subscriber imsi "&imsi&" sms sender msisdn "&msisdn&" send "&text); |
| 1929 | } |
| 1930 | |
| 1931 | /* LU followed by MT SMS */ |
| 1932 | private function f_tc_lu_and_mt_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1933 | var SmsParameters spars := valueof(t_SmsPars); |
| 1934 | var OCT4 tmsi; |
| 1935 | |
| 1936 | f_init_handler(pars); |
| 1937 | |
| 1938 | /* Perform location update and call */ |
| 1939 | f_perform_lu(); |
| 1940 | |
| 1941 | /* register an 'expect' for given IMSI (+TMSI) */ |
| 1942 | if (isvalue(g_pars.tmsi)) { |
| 1943 | tmsi := g_pars.tmsi; |
| 1944 | } else { |
| 1945 | tmsi := 'FFFFFFFF'O; |
| 1946 | } |
| 1947 | f_bssmap_register_imsi(g_pars.imsi, tmsi); |
| 1948 | |
| 1949 | /* FIXME: actually cause MSC to send a SMS via VTY or SMPP */ |
| 1950 | |
| 1951 | /* MSC->BSC: expect PAGING from MSC */ |
| 1952 | BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)); |
| 1953 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 1954 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 1955 | |
| 1956 | spars.tp.ud := 'C8329BFD064D9B53'O; |
| 1957 | f_mt_sms(spars); |
| 1958 | |
| 1959 | f_expect_clear(); |
| 1960 | } |
| 1961 | testcase TC_lu_and_mt_sms() runs on MTC_CT { |
| 1962 | var BSC_ConnHdlrPars pars; |
| 1963 | var BSC_ConnHdlr vc_conn; |
| 1964 | f_init(); |
| 1965 | pars := f_init_pars(43); |
| 1966 | vc_conn := f_start_handler_with_pars(refers(f_tc_lu_and_mt_sms), pars); |
| 1967 | f_sleep(2.0); |
| 1968 | f_vty_sms_send(hex2str(pars.imsi), "2342", "Hello SMS"); |
| 1969 | vc_conn.done; |
| 1970 | } |
| 1971 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 1972 | /* mobile originated SMS from MS/BTS/BSC side to SMPP */ |
| 1973 | private function f_tc_smpp_mo_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 1974 | var SmsParameters spars := valueof(t_SmsPars); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1975 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 1976 | f_init_handler(pars); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 1977 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 1978 | /* Perform location update so IMSI is known + registered in MSC/VLR */ |
| 1979 | f_perform_lu(); |
| 1980 | f_establish_fully(EST_TYPE_MO_SMS); |
| 1981 | |
| 1982 | f_mo_sms(spars); |
| 1983 | |
| 1984 | var SMPP_PDU smpp; |
| 1985 | var template SMPP_PDU tr_smpp := tr_SMPP(c_SMPP_command_id_deliver_sm, ESME_ROK); |
| 1986 | tr_smpp.body.deliver_sm := { |
| 1987 | service_type := "CMT", |
| 1988 | source_addr_ton := network_specific, |
| 1989 | source_addr_npi := isdn, |
| 1990 | source_addr := hex2str(pars.msisdn), |
| 1991 | dest_addr_ton := f_sm_ton_from_gsm(spars.tp.da.tP_DA_NoPad.tP_TypeOfNumber), |
| 1992 | dest_addr_npi := f_sm_npi_from_gsm(spars.tp.da.tP_DA_NoPad.tP_NumberingPlanID), |
| 1993 | destination_addr := hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue), |
| 1994 | esm_class := '00000001'B, |
| 1995 | protocol_id := 0, |
| 1996 | priority_flag := 0, |
| 1997 | schedule_delivery_time := "", |
| 1998 | replace_if_present := 0, |
| 1999 | data_coding := '00000001'B, |
| 2000 | sm_default_msg_id := 0, |
| 2001 | sm_length := ?, |
| 2002 | short_message := spars.tp.ud, |
| 2003 | opt_pars := { |
| 2004 | { |
| 2005 | tag := user_message_reference, |
| 2006 | len := 2, |
| 2007 | opt_value := { |
| 2008 | int2_val := oct2int(spars.tp.msg_ref) |
| 2009 | } |
| 2010 | } |
| 2011 | } |
| 2012 | }; |
| 2013 | alt { |
| 2014 | [] SMPP.receive(tr_smpp) -> value smpp { |
| 2015 | SMPP.send(ts_SMPP_DELIVER_SM_resp(ESME_ROK, smpp.header.seq_num)); |
| 2016 | } |
| 2017 | [] SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)) { repeat; } |
| 2018 | } |
| 2019 | |
| 2020 | f_expect_clear(); |
| 2021 | } |
| 2022 | testcase TC_smpp_mo_sms() runs on MTC_CT { |
| 2023 | var BSC_ConnHdlr vc_conn; |
| 2024 | f_init(); |
| 2025 | f_vty_config2(MSCVTY, { "smpp", "esme msc_tester"}, "default-route"); |
| 2026 | vc_conn := f_start_handler(refers(f_tc_smpp_mo_sms), 44); |
| 2027 | vc_conn.done; |
| 2028 | f_vty_config2(MSCVTY, { "smpp", "esme msc_tester"}, "no default-route"); |
| 2029 | } |
| 2030 | |
| 2031 | /* convert GSM L3 TON to SMPP_TON enum */ |
| 2032 | function f_sm_ton_from_gsm(BIT3 ton) return SMPP_TON { |
| 2033 | select (ton) { |
| 2034 | case ('000'B) { return unknown; } |
| 2035 | case ('001'B) { return international; } |
| 2036 | case ('010'B) { return national; } |
| 2037 | case ('011'B) { return network_specific; } |
| 2038 | case ('100'B) { return subscriber_number; } |
| 2039 | case ('101'B) { return alphanumeric; } |
| 2040 | case ('110'B) { return abbreviated; } |
| 2041 | } |
| 2042 | setverdict(fail, "Unknown TON ", ton); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2043 | mtc.stop; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2044 | } |
| 2045 | /* convert GSM L3 NPI to SMPP_NPI enum */ |
| 2046 | function f_sm_npi_from_gsm(BIT4 npi) return SMPP_NPI { |
| 2047 | select (npi) { |
| 2048 | case ('0000'B) { return unknown; } |
| 2049 | case ('0001'B) { return isdn; } |
| 2050 | case ('0011'B) { return data; } |
| 2051 | case ('0100'B) { return telex; } |
| 2052 | case ('0110'B) { return land_mobile; } |
| 2053 | case ('1000'B) { return national; } |
| 2054 | case ('1001'B) { return private_; } |
| 2055 | case ('1010'B) { return ermes; } |
| 2056 | } |
| 2057 | setverdict(fail, "Unknown NPI ", npi); |
Daniel Willmann | afce866 | 2018-07-06 23:11:32 +0200 | [diff] [blame] | 2058 | mtc.stop; |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2059 | } |
| 2060 | |
| 2061 | /* build a SMPP_SM from SmsParameters */ |
| 2062 | function f_mt_sm_from_spars(SmsParameters spars) |
| 2063 | runs on BSC_ConnHdlr return SMPP_SM { |
| 2064 | var SMPP_SM sm := { |
| 2065 | service_type := "CMT", |
| 2066 | source_addr_ton := f_sm_ton_from_gsm(spars.tp.da.tP_DA_NoPad.tP_TypeOfNumber), |
| 2067 | source_addr_npi := f_sm_npi_from_gsm(spars.tp.da.tP_DA_NoPad.tP_NumberingPlanID), |
| 2068 | source_addr := hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue), |
| 2069 | dest_addr_ton := international, |
| 2070 | dest_addr_npi := isdn, |
| 2071 | destination_addr := hex2str(g_pars.msisdn), |
| 2072 | esm_class := '00000001'B, |
| 2073 | protocol_id := 0, |
| 2074 | priority_flag := 0, |
| 2075 | schedule_delivery_time := "", |
| 2076 | validity_period := "", |
| 2077 | registered_delivery := '00000000'B, |
| 2078 | replace_if_present := 0, |
| 2079 | data_coding := '00000001'B, |
| 2080 | sm_default_msg_id := 0, |
| 2081 | sm_length := spars.tp.udl, |
| 2082 | short_message := spars.tp.ud, |
| 2083 | opt_pars := {} |
| 2084 | }; |
| 2085 | return sm; |
| 2086 | } |
| 2087 | |
| 2088 | /* helper function to encode SMS from 'spars', send it via SMPP to MSC; receive it on MS side */ |
| 2089 | private function f_smpp_mt_sms(SmsParameters spars, boolean trans_mode) runs on BSC_ConnHdlr { |
| 2090 | var SMPP_SM sm := f_mt_sm_from_spars(spars); |
| 2091 | if (trans_mode) { |
| 2092 | sm.esm_class := '00000010'B; |
| 2093 | } |
| 2094 | |
| 2095 | /* actually cause MSC to send a SMS via SUBMIT-SM from SMPP side */ |
| 2096 | SMPP.send(ts_SMPP_SUBMIT_SM(sm)); |
| 2097 | if (not match(sm.esm_class, tr_ESM_CLASS_TRANSACTION)) { |
| 2098 | /* if we're not in SMPP transaction mode, we expect the SMPP-level ACK |
| 2099 | * before we expect the SMS delivery on the BSC/radio side */ |
| 2100 | SMPP.receive(tr_SMPP(c_SMPP_command_id_submit_sm_resp, ESME_ROK)); |
| 2101 | } |
| 2102 | |
| 2103 | /* MSC->BSC: expect PAGING from MSC */ |
| 2104 | BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)); |
| 2105 | /* Establish DTAP / BSSAP / SCCP connection */ |
| 2106 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2107 | SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)); |
| 2108 | |
| 2109 | f_mt_sms(spars); |
| 2110 | |
| 2111 | if (match(sm.esm_class, tr_ESM_CLASS_TRANSACTION)) { |
| 2112 | SMPP.receive(tr_SMPP(c_SMPP_command_id_submit_sm_resp, ESME_ROK)); |
| 2113 | } |
| 2114 | f_expect_clear(); |
| 2115 | } |
| 2116 | |
| 2117 | /* mobile terminated SMS, from SMPP to BSC/BTS/MS */ |
| 2118 | private function f_tc_smpp_mt_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2119 | f_init_handler(pars); |
| 2120 | |
| 2121 | /* Perform location update so IMSI is known + registered in MSC/VLR */ |
| 2122 | f_perform_lu(); |
| 2123 | SMPP.receive(tr_SMPP(c_SMPP_command_id_alert_notification, ESME_ROK)); |
| 2124 | |
| 2125 | /* register an 'expect' for given IMSI (+TMSI) */ |
| 2126 | var OCT4 tmsi; |
| 2127 | if (isvalue(g_pars.tmsi)) { |
| 2128 | tmsi := g_pars.tmsi; |
| 2129 | } else { |
| 2130 | tmsi := 'FFFFFFFF'O; |
| 2131 | } |
| 2132 | f_bssmap_register_imsi(g_pars.imsi, tmsi); |
| 2133 | |
| 2134 | var SmsParameters spars := valueof(t_SmsPars); |
| 2135 | /* TODO: test with more intelligent user data; test different coding schemes */ |
| 2136 | spars.tp.ud := '00'O; |
| 2137 | spars.tp.udl := 1; |
| 2138 | |
| 2139 | /* first test the non-transaction store+forward mode */ |
| 2140 | f_smpp_mt_sms(spars, false); |
| 2141 | |
| 2142 | /* then test the transaction mode */ |
| 2143 | f_smpp_mt_sms(spars, true); |
| 2144 | } |
| 2145 | testcase TC_smpp_mt_sms() runs on MTC_CT { |
| 2146 | var BSC_ConnHdlr vc_conn; |
| 2147 | f_init(); |
| 2148 | vc_conn := f_start_handler(refers(f_tc_smpp_mt_sms), 45); |
| 2149 | vc_conn.done; |
| 2150 | } |
| 2151 | |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2152 | /*********************************************************************** |
| 2153 | * USSD Testing |
| 2154 | ***********************************************************************/ |
| 2155 | |
Vadim Yanitskiy | ce8cc37 | 2018-06-21 01:46:33 +0700 | [diff] [blame] | 2156 | private altstep as_unexp_gsup_or_bssap_msg() |
| 2157 | runs on BSC_ConnHdlr { |
| 2158 | [] GSUP.receive { |
| 2159 | setverdict(fail, "Unknown/unexpected GSUP received"); |
| 2160 | self.stop; |
| 2161 | } |
| 2162 | [] BSSAP.receive { |
| 2163 | setverdict(fail, "Unknown/unexpected BSSAP message received"); |
| 2164 | self.stop; |
| 2165 | } |
| 2166 | } |
| 2167 | |
| 2168 | private function f_expect_gsup_msg(template GSUP_PDU msg) |
| 2169 | runs on BSC_ConnHdlr return GSUP_PDU { |
| 2170 | var GSUP_PDU gsup_msg_complete; |
| 2171 | |
| 2172 | alt { |
| 2173 | [] GSUP.receive(msg) -> value gsup_msg_complete { |
| 2174 | setverdict(pass); |
| 2175 | } |
| 2176 | /* We don't expect anything else */ |
| 2177 | [] as_unexp_gsup_or_bssap_msg(); |
| 2178 | } |
| 2179 | |
| 2180 | return gsup_msg_complete; |
| 2181 | } |
| 2182 | |
| 2183 | private function f_expect_mt_dtap_msg(template PDU_ML3_NW_MS msg) |
| 2184 | runs on BSC_ConnHdlr return PDU_ML3_NW_MS { |
| 2185 | var PDU_DTAP_MT bssap_msg_complete; |
| 2186 | |
| 2187 | alt { |
| 2188 | [] BSSAP.receive(tr_PDU_DTAP_MT(msg)) -> value bssap_msg_complete { |
| 2189 | setverdict(pass); |
| 2190 | } |
| 2191 | /* We don't expect anything else */ |
| 2192 | [] as_unexp_gsup_or_bssap_msg(); |
| 2193 | } |
| 2194 | |
| 2195 | return bssap_msg_complete.dtap; |
| 2196 | } |
| 2197 | |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 2198 | /* LU followed by MO USSD request */ |
| 2199 | 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] | 2200 | runs on BSC_ConnHdlr { |
| 2201 | f_init_handler(pars); |
| 2202 | |
| 2203 | /* Perform location update */ |
| 2204 | f_perform_lu(); |
| 2205 | |
| 2206 | /* Send CM Service Request for SS/USSD */ |
| 2207 | f_establish_fully(EST_TYPE_SS_ACT); |
| 2208 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 2209 | /* We need to inspect GSUP activity */ |
| 2210 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2211 | |
| 2212 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 2213 | invoke_id := 5, /* Phone may not start from 0 or 1 */ |
| 2214 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 2215 | ussd_string := "*#100#" |
| 2216 | ); |
| 2217 | |
| 2218 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 2219 | invoke_id := 5, /* InvokeID shall be the same for both REQ and RSP */ |
| 2220 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 2221 | ussd_string := "Your extension is " & hex2str(g_pars.msisdn) & "\r" |
| 2222 | ) |
| 2223 | |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2224 | /* Compose a new SS/REGISTER message with request */ |
| 2225 | var template (value) PDU_ML3_MS_NW ussd_req := ts_ML3_MO_SS_REGISTER( |
| 2226 | tid := 1, /* We just need a single transaction */ |
| 2227 | 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] | 2228 | facility := valueof(facility_req) |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2229 | ); |
| 2230 | |
| 2231 | /* Compose SS/RELEASE_COMPLETE template with expected response */ |
| 2232 | var template PDU_ML3_NW_MS ussd_rsp := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 2233 | tid := 1, /* Response should arrive within the same transaction */ |
| 2234 | 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] | 2235 | facility := valueof(facility_rsp) |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2236 | ); |
| 2237 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 2238 | /* Compose expected MSC -> HLR message */ |
| 2239 | var template GSUP_PDU gsup_req := tr_GSUP_PROC_SS_REQ( |
| 2240 | imsi := g_pars.imsi, |
| 2241 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 2242 | ss := valueof(facility_req) |
| 2243 | ); |
| 2244 | |
| 2245 | /* To be used for sending response with correct session ID */ |
| 2246 | var GSUP_PDU gsup_req_complete; |
| 2247 | |
| 2248 | /* Request own number */ |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2249 | BSSAP.send(ts_PDU_DTAP_MO(ussd_req)); |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 2250 | /* Expect GSUP message containing the SS payload */ |
| 2251 | gsup_req_complete := f_expect_gsup_msg(gsup_req); |
| 2252 | |
| 2253 | /* Compose the response from HLR using received session ID */ |
| 2254 | var template GSUP_PDU gsup_rsp := ts_GSUP_PROC_SS_REQ( |
| 2255 | imsi := g_pars.imsi, |
| 2256 | sid := gsup_req_complete.ies[1].val.session_id, |
| 2257 | state := OSMO_GSUP_SESSION_STATE_END, |
| 2258 | ss := valueof(facility_rsp) |
| 2259 | ); |
| 2260 | |
| 2261 | /* Finally, HLR terminates the session */ |
| 2262 | GSUP.send(gsup_rsp); |
| 2263 | /* Expect RELEASE_COMPLETE message with the response */ |
| 2264 | f_expect_mt_dtap_msg(ussd_rsp); |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2265 | |
| 2266 | f_expect_clear(); |
| 2267 | } |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 2268 | testcase TC_lu_and_mo_ussd_single_request() runs on MTC_CT { |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2269 | var BSC_ConnHdlr vc_conn; |
| 2270 | f_init(); |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 2271 | 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] | 2272 | vc_conn.done; |
| 2273 | } |
| 2274 | |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 2275 | /* LU followed by MT USSD notification */ |
| 2276 | private function f_tc_lu_and_mt_ussd_notification(charstring id, BSC_ConnHdlrPars pars) |
| 2277 | runs on BSC_ConnHdlr { |
| 2278 | f_init_handler(pars); |
| 2279 | |
| 2280 | /* Perform location update */ |
| 2281 | f_perform_lu(); |
| 2282 | |
| 2283 | f_bssmap_register_imsi(g_pars.imsi, g_pars.tmsi); |
| 2284 | |
| 2285 | /* We need to inspect GSUP activity */ |
| 2286 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2287 | |
| 2288 | /* Facility IE with network-originated USSD notification */ |
| 2289 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 2290 | op_code := SS_OP_CODE_USS_NOTIFY, |
| 2291 | ussd_string := "Mahlzeit!" |
| 2292 | ); |
| 2293 | |
| 2294 | /* Facility IE with acknowledgment to the USSD notification */ |
| 2295 | var template OCTN facility_rsp := enc_SS_FacilityInformation( |
| 2296 | /* In case of USSD notification, Return Result is empty */ |
| 2297 | valueof(ts_SS_USSD_FACILITY_RETURN_RESULT_EMPTY()) |
| 2298 | ); |
| 2299 | |
| 2300 | /* Compose a new MT SS/REGISTER message with USSD notification */ |
| 2301 | var template PDU_ML3_NW_MS ussd_ntf := tr_ML3_MT_SS_REGISTER( |
| 2302 | tid := 0, /* FIXME: most likely, it should be 0 */ |
| 2303 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 2304 | facility := valueof(facility_req) |
| 2305 | ); |
| 2306 | |
| 2307 | /* Compose HLR -> MSC GSUP message */ |
| 2308 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 2309 | imsi := g_pars.imsi, |
| 2310 | sid := '20000101'O, |
| 2311 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 2312 | ss := valueof(facility_req) |
| 2313 | ); |
| 2314 | |
| 2315 | /* Send it to MSC and expect Paging Request */ |
| 2316 | GSUP.send(gsup_req); |
| 2317 | alt { |
| 2318 | [] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) { |
| 2319 | setverdict(pass); |
| 2320 | } |
| 2321 | /* We don't expect anything else */ |
| 2322 | [] as_unexp_gsup_or_bssap_msg(); |
| 2323 | } |
| 2324 | |
| 2325 | /* Send Paging Response and expect USSD notification */ |
| 2326 | f_establish_fully(EST_TYPE_PAG_RESP); |
| 2327 | /* Expect MT REGISTER message with USSD notification */ |
| 2328 | f_expect_mt_dtap_msg(ussd_ntf); |
| 2329 | |
| 2330 | /* Compose a new MO SS/FACILITY message with empty response */ |
| 2331 | var template (value) PDU_ML3_MS_NW ussd_rsp := ts_ML3_MO_SS_FACILITY( |
| 2332 | tid := 0, /* FIXME: it shall match the request tid */ |
| 2333 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 2334 | facility := valueof(facility_rsp) |
| 2335 | ); |
| 2336 | |
| 2337 | /* Compose expected MSC -> HLR GSUP message */ |
| 2338 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_REQ( |
| 2339 | imsi := g_pars.imsi, |
| 2340 | sid := '20000101'O, |
| 2341 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 2342 | ss := valueof(facility_rsp) |
| 2343 | ); |
| 2344 | |
| 2345 | /* MS sends response to the notification */ |
| 2346 | BSSAP.send(ts_PDU_DTAP_MO(ussd_rsp)); |
| 2347 | /* Expect GSUP message containing the SS payload */ |
| 2348 | f_expect_gsup_msg(gsup_rsp); |
| 2349 | |
| 2350 | /* Compose expected MT SS/RELEASE COMPLETE message */ |
| 2351 | var template PDU_ML3_NW_MS ussd_term := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 2352 | tid := 0, /* FIXME: it shall match the request tid */ |
| 2353 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 2354 | facility := omit |
| 2355 | ); |
| 2356 | |
| 2357 | /* Compose MSC -> HLR GSUP message */ |
| 2358 | var template GSUP_PDU gsup_term := ts_GSUP_PROC_SS_REQ( |
| 2359 | imsi := g_pars.imsi, |
| 2360 | sid := '20000101'O, |
| 2361 | state := OSMO_GSUP_SESSION_STATE_END |
| 2362 | ); |
| 2363 | |
| 2364 | /* Finally, HLR terminates the session */ |
| 2365 | GSUP.send(gsup_term) |
| 2366 | /* Expect MT RELEASE COMPLETE without Facility IE */ |
| 2367 | f_expect_mt_dtap_msg(ussd_term); |
| 2368 | |
| 2369 | f_expect_clear(); |
| 2370 | } |
| 2371 | testcase TC_lu_and_mt_ussd_notification() runs on MTC_CT { |
| 2372 | var BSC_ConnHdlr vc_conn; |
| 2373 | f_init(); |
| 2374 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_ussd_notification), 47); |
| 2375 | vc_conn.done; |
| 2376 | } |
| 2377 | |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 2378 | /* LU followed by MT call and MO USSD request during this call */ |
| 2379 | 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] | 2380 | runs on BSC_ConnHdlr { |
| 2381 | f_init_handler(pars); |
| 2382 | |
| 2383 | /* Call parameters taken from f_tc_lu_and_mt_call */ |
| 2384 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
| 2385 | cpars.mgcp_connection_id_bss := '10004'H; |
| 2386 | cpars.mgcp_connection_id_mss := '10005'H; |
| 2387 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
| 2388 | cpars.bss_rtp_port := 1110; |
| 2389 | |
| 2390 | /* Perform location update */ |
| 2391 | f_perform_lu(); |
| 2392 | |
| 2393 | /* Establish a MT call */ |
| 2394 | f_mt_call_establish(cpars); |
| 2395 | |
| 2396 | /* Hold the call for some time */ |
| 2397 | f_sleep(1.0); |
| 2398 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 2399 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 2400 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 2401 | ussd_string := "*#100#" |
| 2402 | ); |
| 2403 | |
| 2404 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 2405 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 2406 | ussd_string := "Your extension is " & hex2str(g_pars.msisdn) & "\r" |
| 2407 | ) |
| 2408 | |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 2409 | /* Compose a new SS/REGISTER message with request */ |
| 2410 | var template (value) PDU_ML3_MS_NW ussd_req := ts_ML3_MO_SS_REGISTER( |
| 2411 | tid := 1, /* We just need a single transaction */ |
| 2412 | 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] | 2413 | facility := valueof(facility_req) |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 2414 | ); |
| 2415 | |
| 2416 | /* Compose SS/RELEASE_COMPLETE template with expected response */ |
| 2417 | var template PDU_ML3_NW_MS ussd_rsp := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 2418 | tid := 1, /* Response should arrive within the same transaction */ |
| 2419 | 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] | 2420 | facility := valueof(facility_rsp) |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 2421 | ); |
| 2422 | |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 2423 | /* Compose expected MSC -> HLR message */ |
| 2424 | var template GSUP_PDU gsup_req := tr_GSUP_PROC_SS_REQ( |
| 2425 | imsi := g_pars.imsi, |
| 2426 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 2427 | ss := valueof(facility_req) |
| 2428 | ); |
| 2429 | |
| 2430 | /* To be used for sending response with correct session ID */ |
| 2431 | var GSUP_PDU gsup_req_complete; |
| 2432 | |
| 2433 | /* Request own number */ |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 2434 | BSSAP.send(ts_PDU_DTAP_MO(ussd_req)); |
Vadim Yanitskiy | 747689e | 2018-06-19 00:14:28 +0700 | [diff] [blame] | 2435 | /* Expect GSUP message containing the SS payload */ |
| 2436 | gsup_req_complete := f_expect_gsup_msg(gsup_req); |
| 2437 | |
| 2438 | /* Compose the response from HLR using received session ID */ |
| 2439 | var template GSUP_PDU gsup_rsp := ts_GSUP_PROC_SS_REQ( |
| 2440 | imsi := g_pars.imsi, |
| 2441 | sid := gsup_req_complete.ies[1].val.session_id, |
| 2442 | state := OSMO_GSUP_SESSION_STATE_END, |
| 2443 | ss := valueof(facility_rsp) |
| 2444 | ); |
| 2445 | |
| 2446 | /* Finally, HLR terminates the session */ |
| 2447 | GSUP.send(gsup_rsp); |
| 2448 | /* Expect RELEASE_COMPLETE message with the response */ |
| 2449 | f_expect_mt_dtap_msg(ussd_rsp); |
Vadim Yanitskiy | 0aaf48d | 2018-06-06 07:02:47 +0700 | [diff] [blame] | 2450 | |
| 2451 | /* Hold the call for some time */ |
| 2452 | f_sleep(1.0); |
| 2453 | |
| 2454 | /* Release the call (does Clear Complete itself) */ |
| 2455 | f_call_hangup(cpars, true); |
| 2456 | } |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 2457 | 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] | 2458 | var BSC_ConnHdlr vc_conn; |
| 2459 | f_init(); |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 2460 | 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] | 2461 | vc_conn.done; |
| 2462 | } |
| 2463 | |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 2464 | /* BSSMAP Clear Request in the middle of a call, see OS#3062 */ |
| 2465 | private function f_tc_mo_cc_bssmap_clear(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2466 | f_init_handler(pars); |
| 2467 | var CallParameters cpars := valueof(t_CallParams('12345'H, 0)); |
| 2468 | var MNCC_PDU mncc; |
| 2469 | var MgcpCommand mgcp_cmd; |
| 2470 | |
| 2471 | f_perform_lu(); |
| 2472 | |
| 2473 | f_establish_fully(); |
| 2474 | f_create_mncc_expect(hex2str(cpars.called_party)); |
| 2475 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 2476 | |
| 2477 | BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_SETUP(cpars.transaction_id, cpars.called_party))); |
| 2478 | MNCC.receive(tr_MNCC_SETUP_ind(?, tr_MNCC_number(hex2str(cpars.called_party)))) -> value mncc; |
| 2479 | cpars.mncc_callref := mncc.u.signal.callref; |
| 2480 | log("mncc_callref=", cpars.mncc_callref); |
| 2481 | MNCC.send(ts_MNCC_CALL_PROC_req(cpars.mncc_callref, cpars.mncc_bearer_cap)); |
| 2482 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CALL_PROC(cpars.transaction_id))); |
| 2483 | |
| 2484 | MNCC.send(ts_MNCC_ALERT_req(cpars.mncc_callref)); |
| 2485 | BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_ALERTING(cpars.transaction_id))); |
| 2486 | MGCP.receive(tr_CRCX); |
| 2487 | |
| 2488 | f_sleep(1.0); |
| 2489 | BSSAP.send(ts_BSSMAP_ClearRequest(0)); |
| 2490 | |
| 2491 | MNCC.receive(tr_MNCC_REL_ind(?, ?)) -> value mncc; |
| 2492 | |
| 2493 | BSSAP.receive(tr_BSSMAP_ClearCommand); |
| 2494 | BSSAP.send(ts_BSSMAP_ClearComplete); |
| 2495 | |
| 2496 | f_sleep(1.0); |
| 2497 | } |
| 2498 | testcase TC_mo_cc_bssmap_clear() runs on MTC_CT { |
| 2499 | var BSC_ConnHdlr vc_conn; |
| 2500 | f_init(); |
| 2501 | |
| 2502 | vc_conn := f_start_handler(refers(f_tc_mo_cc_bssmap_clear), 43); |
| 2503 | vc_conn.done; |
| 2504 | } |
| 2505 | |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 2506 | /* LU followed by MT call and MT USSD request during this call */ |
| 2507 | private function f_tc_lu_and_mt_ussd_during_mt_call(charstring id, BSC_ConnHdlrPars pars) |
| 2508 | runs on BSC_ConnHdlr { |
| 2509 | f_init_handler(pars); |
| 2510 | |
| 2511 | /* Call parameters taken from f_tc_lu_and_mt_call */ |
| 2512 | var CallParameters cpars := valueof(t_CallParams('123456'H, 0)); |
| 2513 | cpars.mgcp_connection_id_bss := '10004'H; |
| 2514 | cpars.mgcp_connection_id_mss := '10005'H; |
| 2515 | cpars.mgcp_ep := "rtpbridge/1@mgw"; |
| 2516 | cpars.bss_rtp_port := 1110; |
| 2517 | |
| 2518 | /* Perform location update */ |
| 2519 | f_perform_lu(); |
| 2520 | |
| 2521 | /* Establish a MT call */ |
| 2522 | f_mt_call_establish(cpars); |
| 2523 | |
| 2524 | /* Hold the call for some time */ |
| 2525 | f_sleep(1.0); |
| 2526 | |
| 2527 | var template OCTN facility_req := f_USSD_FACILITY_IE_INVOKE( |
| 2528 | op_code := SS_OP_CODE_USS_REQUEST, |
| 2529 | ussd_string := "Please type anything..." |
| 2530 | ); |
| 2531 | |
| 2532 | var template OCTN facility_rsp := f_USSD_FACILITY_IE_RETURN_RESULT( |
| 2533 | op_code := SS_OP_CODE_USS_REQUEST, |
| 2534 | ussd_string := "Nope." |
| 2535 | ) |
| 2536 | |
| 2537 | /* Compose MT SS/REGISTER message with network-originated request */ |
| 2538 | var template (value) PDU_ML3_NW_MS ussd_req := ts_ML3_MT_SS_REGISTER( |
| 2539 | tid := 0, /* FIXME: most likely, it should be 0 */ |
| 2540 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 2541 | facility := valueof(facility_req) |
| 2542 | ); |
| 2543 | |
| 2544 | /* Compose HLR -> MSC GSUP message */ |
| 2545 | var template (value) GSUP_PDU gsup_req := ts_GSUP_PROC_SS_REQ( |
| 2546 | imsi := g_pars.imsi, |
| 2547 | sid := '20000101'O, |
| 2548 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 2549 | ss := valueof(facility_req) |
| 2550 | ); |
| 2551 | |
| 2552 | /* Send it to MSC */ |
| 2553 | GSUP.send(gsup_req); |
| 2554 | /* Expect MT REGISTER message with USSD request */ |
| 2555 | f_expect_mt_dtap_msg(ussd_req); |
| 2556 | |
| 2557 | /* Compose a new MO SS/FACILITY message with response */ |
| 2558 | var template (value) PDU_ML3_MS_NW ussd_rsp := ts_ML3_MO_SS_FACILITY( |
| 2559 | tid := 0, /* FIXME: it shall match the request tid */ |
| 2560 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 2561 | facility := valueof(facility_rsp) |
| 2562 | ); |
| 2563 | |
| 2564 | /* Compose expected MSC -> HLR GSUP message */ |
| 2565 | var template GSUP_PDU gsup_rsp := tr_GSUP_PROC_SS_REQ( |
| 2566 | imsi := g_pars.imsi, |
| 2567 | sid := '20000101'O, |
| 2568 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 2569 | ss := valueof(facility_rsp) |
| 2570 | ); |
| 2571 | |
| 2572 | /* MS sends response */ |
| 2573 | BSSAP.send(ts_PDU_DTAP_MO(ussd_rsp)); |
| 2574 | f_expect_gsup_msg(gsup_rsp); |
| 2575 | |
| 2576 | /* Compose expected MT SS/RELEASE COMPLETE message */ |
| 2577 | var template PDU_ML3_NW_MS ussd_term := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 2578 | tid := 0, /* FIXME: it shall match the request tid */ |
| 2579 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 2580 | facility := omit |
| 2581 | ); |
| 2582 | |
| 2583 | /* Compose MSC -> HLR GSUP message */ |
| 2584 | var template GSUP_PDU gsup_term := ts_GSUP_PROC_SS_REQ( |
| 2585 | imsi := g_pars.imsi, |
| 2586 | sid := '20000101'O, |
| 2587 | state := OSMO_GSUP_SESSION_STATE_END |
| 2588 | ); |
| 2589 | |
| 2590 | /* Finally, HLR terminates the session */ |
| 2591 | GSUP.send(gsup_term); |
| 2592 | /* Expect MT RELEASE COMPLETE without Facility IE */ |
| 2593 | f_expect_mt_dtap_msg(ussd_term); |
| 2594 | |
| 2595 | /* Hold the call for some time */ |
| 2596 | f_sleep(1.0); |
| 2597 | |
| 2598 | /* Release the call (does Clear Complete itself) */ |
| 2599 | f_call_hangup(cpars, true); |
| 2600 | } |
| 2601 | testcase TC_lu_and_mt_ussd_during_mt_call() runs on MTC_CT { |
| 2602 | var BSC_ConnHdlr vc_conn; |
| 2603 | f_init(); |
| 2604 | vc_conn := f_start_handler(refers(f_tc_lu_and_mt_ussd_during_mt_call), 49); |
| 2605 | vc_conn.done; |
| 2606 | } |
| 2607 | |
Vadim Yanitskiy | 2daf52d | 2018-06-21 04:19:58 +0700 | [diff] [blame] | 2608 | /* LU followed by MO USSD request and MO Release during transaction */ |
| 2609 | private function f_tc_lu_and_mo_ussd_mo_release(charstring id, BSC_ConnHdlrPars pars) |
| 2610 | runs on BSC_ConnHdlr { |
| 2611 | f_init_handler(pars); |
| 2612 | |
| 2613 | /* Perform location update */ |
| 2614 | f_perform_lu(); |
| 2615 | |
| 2616 | /* Send CM Service Request for SS/USSD */ |
| 2617 | f_establish_fully(EST_TYPE_SS_ACT); |
| 2618 | |
| 2619 | /* We need to inspect GSUP activity */ |
| 2620 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2621 | |
| 2622 | var template OCTN facility_ms_req := f_USSD_FACILITY_IE_INVOKE( |
| 2623 | invoke_id := 1, /* Initial request */ |
| 2624 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 2625 | ussd_string := "*6766*266#" |
| 2626 | ); |
| 2627 | |
| 2628 | var template OCTN facility_net_req := f_USSD_FACILITY_IE_INVOKE( |
| 2629 | invoke_id := 2, /* Counter request */ |
| 2630 | op_code := SS_OP_CODE_USS_REQUEST, |
| 2631 | ussd_string := "Password?!?" |
| 2632 | ) |
| 2633 | |
| 2634 | /* Compose MO SS/REGISTER message with request */ |
| 2635 | var template (value) PDU_ML3_MS_NW ussd_ms_req := ts_ML3_MO_SS_REGISTER( |
| 2636 | tid := 1, /* We just need a single transaction */ |
| 2637 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 2638 | facility := valueof(facility_ms_req) |
| 2639 | ); |
| 2640 | |
| 2641 | /* Compose expected MSC -> HLR message */ |
| 2642 | var template GSUP_PDU gsup_ms_req := tr_GSUP_PROC_SS_REQ( |
| 2643 | imsi := g_pars.imsi, |
| 2644 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 2645 | ss := valueof(facility_ms_req) |
| 2646 | ); |
| 2647 | |
| 2648 | /* To be used for sending response with correct session ID */ |
| 2649 | var GSUP_PDU gsup_ms_req_complete; |
| 2650 | |
| 2651 | /* Initiate a new transaction */ |
| 2652 | BSSAP.send(ts_PDU_DTAP_MO(ussd_ms_req)); |
| 2653 | /* Expect GSUP request with original Facility IE */ |
| 2654 | gsup_ms_req_complete := f_expect_gsup_msg(gsup_ms_req); |
| 2655 | |
| 2656 | /* Compose the response from HLR using received session ID */ |
| 2657 | var template (value) GSUP_PDU gsup_net_req := ts_GSUP_PROC_SS_REQ( |
| 2658 | imsi := g_pars.imsi, |
| 2659 | sid := gsup_ms_req_complete.ies[1].val.session_id, |
| 2660 | state := OSMO_GSUP_SESSION_STATE_CONTINUE, |
| 2661 | ss := valueof(facility_net_req) |
| 2662 | ); |
| 2663 | |
| 2664 | /* Compose expected MT SS/FACILITY template with counter request */ |
| 2665 | var template PDU_ML3_NW_MS ussd_net_req := tr_ML3_MT_SS_FACILITY( |
| 2666 | tid := 1, /* Response should arrive within the same transaction */ |
| 2667 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 2668 | facility := valueof(facility_net_req) |
| 2669 | ); |
| 2670 | |
| 2671 | /* Send response over GSUP */ |
| 2672 | GSUP.send(gsup_net_req); |
| 2673 | /* Expect MT SS/FACILITY message with counter request */ |
| 2674 | f_expect_mt_dtap_msg(ussd_net_req); |
| 2675 | |
| 2676 | /* Compose MO SS/RELEASE COMPLETE */ |
| 2677 | var template (value) PDU_ML3_MS_NW ussd_abort := ts_ML3_MO_SS_RELEASE_COMPLETE( |
| 2678 | tid := 1, /* Response should arrive within the same transaction */ |
| 2679 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 2680 | facility := omit |
| 2681 | /* TODO: cause? */ |
| 2682 | ); |
| 2683 | |
| 2684 | /* Compose expected HLR -> MSC abort message */ |
| 2685 | var template GSUP_PDU gsup_abort := tr_GSUP_PROC_SS_REQ( |
| 2686 | imsi := g_pars.imsi, |
| 2687 | sid := gsup_ms_req_complete.ies[1].val.session_id, |
| 2688 | state := OSMO_GSUP_SESSION_STATE_END |
| 2689 | ); |
| 2690 | |
| 2691 | /* Abort transaction */ |
| 2692 | BSSAP.send(ts_PDU_DTAP_MO(ussd_abort)); |
| 2693 | /* Expect GSUP message indicating abort */ |
| 2694 | f_expect_gsup_msg(gsup_abort); |
| 2695 | |
| 2696 | f_expect_clear(); |
| 2697 | } |
| 2698 | testcase TC_lu_and_mo_ussd_mo_release() runs on MTC_CT { |
| 2699 | var BSC_ConnHdlr vc_conn; |
| 2700 | f_init(); |
| 2701 | vc_conn := f_start_handler(refers(f_tc_lu_and_mo_ussd_mo_release), 50); |
| 2702 | vc_conn.done; |
| 2703 | } |
| 2704 | |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 2705 | /* LU followed by MO USSD request and MT Release due to timeout */ |
| 2706 | private function f_tc_lu_and_ss_session_timeout(charstring id, BSC_ConnHdlrPars pars) |
| 2707 | runs on BSC_ConnHdlr { |
| 2708 | f_init_handler(pars); |
| 2709 | |
| 2710 | /* Perform location update */ |
| 2711 | f_perform_lu(); |
| 2712 | |
| 2713 | /* Send CM Service Request for SS/USSD */ |
| 2714 | f_establish_fully(EST_TYPE_SS_ACT); |
| 2715 | |
| 2716 | /* We need to inspect GSUP activity */ |
| 2717 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2718 | |
| 2719 | var template OCTN facility_ms_req := f_USSD_FACILITY_IE_INVOKE( |
| 2720 | invoke_id := 1, |
| 2721 | op_code := SS_OP_CODE_PROCESS_USS_REQ, |
| 2722 | ussd_string := "#release_me"); |
| 2723 | |
| 2724 | /* Compose MO SS/REGISTER message with request */ |
| 2725 | var template (value) PDU_ML3_MS_NW ussd_ms_req := ts_ML3_MO_SS_REGISTER( |
| 2726 | tid := 1, /* An arbitrary transaction identifier */ |
| 2727 | ti_flag := c_TIF_ORIG, /* Sent from the side that originates the TI */ |
| 2728 | facility := valueof(facility_ms_req)); |
| 2729 | |
| 2730 | /* Compose expected MSC -> HLR message */ |
| 2731 | var template GSUP_PDU gsup_ms_req := tr_GSUP_PROC_SS_REQ( |
| 2732 | imsi := g_pars.imsi, |
| 2733 | state := OSMO_GSUP_SESSION_STATE_BEGIN, |
| 2734 | ss := valueof(facility_ms_req)); |
| 2735 | |
| 2736 | /* To be used for sending response with correct session ID */ |
| 2737 | var GSUP_PDU gsup_ms_req_complete; |
| 2738 | |
| 2739 | /* Initiate a new SS transaction */ |
| 2740 | BSSAP.send(ts_PDU_DTAP_MO(ussd_ms_req)); |
| 2741 | /* Expect GSUP request with original Facility IE */ |
| 2742 | gsup_ms_req_complete := f_expect_gsup_msg(gsup_ms_req); |
| 2743 | |
| 2744 | /* Don't respond, wait for timeout */ |
| 2745 | f_sleep(3.0); |
| 2746 | |
| 2747 | var template PDU_ML3_NW_MS dtap_rel := tr_ML3_MT_SS_RELEASE_COMPLETE( |
| 2748 | tid := 1, /* Should match the request's tid */ |
| 2749 | ti_flag := c_TIF_REPL, /* Sent to the side that originates the TI */ |
| 2750 | cause := *, /* TODO: expect some specific value */ |
| 2751 | facility := omit); |
| 2752 | |
| 2753 | var template GSUP_PDU gsup_rel := tr_GSUP_PROC_SS_ERR( |
| 2754 | imsi := g_pars.imsi, |
| 2755 | sid := gsup_ms_req_complete.ies[1].val.session_id, |
| 2756 | state := OSMO_GSUP_SESSION_STATE_END, |
| 2757 | cause := ?); /* TODO: expect some specific value */ |
| 2758 | |
| 2759 | /* Expect release on both interfaces */ |
| 2760 | interleave { |
| 2761 | [] BSSAP.receive(tr_PDU_DTAP_MT(dtap_rel)) { }; |
| 2762 | [] GSUP.receive(gsup_rel) { }; |
| 2763 | } |
| 2764 | |
| 2765 | f_expect_clear(); |
| 2766 | setverdict(pass); |
| 2767 | } |
| 2768 | testcase TC_lu_and_ss_session_timeout() runs on MTC_CT { |
| 2769 | var BSC_ConnHdlr vc_conn; |
| 2770 | f_init(); |
Vadim Yanitskiy | 36d28dd | 2018-12-03 02:45:45 +0700 | [diff] [blame] | 2771 | f_vty_config(MSCVTY, "msc", "ncss guard-timeout 3"); |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 2772 | vc_conn := f_start_handler(refers(f_tc_lu_and_ss_session_timeout), 51); |
| 2773 | vc_conn.done; |
Vadim Yanitskiy | 36d28dd | 2018-12-03 02:45:45 +0700 | [diff] [blame] | 2774 | f_vty_config(MSCVTY, "msc", "ncss guard-timeout 0"); |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 2775 | } |
| 2776 | |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 2777 | /* A5/1 only permitted on network side; attempt an invalid CIPHER MODE COMPLETE with A5/3 which MSC should reject. */ |
| 2778 | private function f_tc_cipher_complete_with_invalid_cipher(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr { |
| 2779 | pars.net.expect_auth := true; |
| 2780 | pars.net.expect_ciph := true; |
| 2781 | pars.net.kc_support := '02'O; /* A5/1 only */ |
| 2782 | f_init_handler(pars); |
| 2783 | |
| 2784 | g_pars.vec := f_gen_auth_vec_2g(); |
| 2785 | |
| 2786 | /* Can't use f_perform_lu() directly. Code below is based on it. */ |
| 2787 | |
| 2788 | /* tell GSUP dispatcher to send this IMSI to us */ |
| 2789 | f_create_gsup_expect(hex2str(g_pars.imsi)); |
| 2790 | |
| 2791 | /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */ |
| 2792 | var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi) |
| 2793 | f_bssap_compl_l3(l3_lu); |
| 2794 | |
| 2795 | f_mm_auth(); |
| 2796 | |
| 2797 | var OCT1 a5_net := f_alg_mask_from_cm(g_pars.cm2); |
| 2798 | var OCT1 a5_intersect := g_pars.net.kc_support and4b a5_net; |
| 2799 | alt { |
| 2800 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(a5_intersect, g_pars.vec.kc)) { |
| 2801 | BSSAP.send(ts_BSSMAP_CipherModeCompl(int2oct(4 /* "accept" A5/3 */, 1))); |
| 2802 | } |
| 2803 | [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?, g_pars.vec.kc)) { |
| 2804 | setverdict(fail, "Wrong ciphering algorithm mask in CiphModCmd"); |
| 2805 | mtc.stop; |
| 2806 | } |
| 2807 | [] BSSAP.receive { |
| 2808 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 2809 | mtc.stop; |
| 2810 | } |
| 2811 | } |
| 2812 | |
| 2813 | /* Expect LU reject from MSC. */ |
| 2814 | alt { |
| 2815 | [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { |
| 2816 | setverdict(pass); |
| 2817 | } |
| 2818 | [] BSSAP.receive { |
| 2819 | setverdict(fail, "Unknown/unexpected BSSAP received"); |
| 2820 | mtc.stop; |
| 2821 | } |
| 2822 | } |
Stefan Sperling | c620b35 | 2018-12-18 17:23:36 +0100 | [diff] [blame] | 2823 | f_expect_clear(); |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 2824 | } |
| 2825 | |
| 2826 | testcase TC_cipher_complete_with_invalid_cipher() runs on MTC_CT { |
| 2827 | var BSC_ConnHdlr vc_conn; |
| 2828 | f_init(); |
| 2829 | f_vty_config(MSCVTY, "network", "encryption a5 1"); |
| 2830 | |
| 2831 | vc_conn := f_start_handler(refers(f_tc_cipher_complete_with_invalid_cipher), 52); |
| 2832 | vc_conn.done; |
| 2833 | } |
| 2834 | |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2835 | /* TODO (SMS): |
| 2836 | * different user data lengths |
| 2837 | * SMPP transaction mode with unsuccessful delivery |
| 2838 | * queued MT-SMS with no paging response + later delivery |
| 2839 | * different data coding schemes |
| 2840 | * multi-part SMS |
| 2841 | * user-data headers |
| 2842 | * TP-PID for SMS to SIM |
| 2843 | * behavior if SMS memory is full + RP-SMMA |
| 2844 | * delivery reports |
| 2845 | * SMPP osmocom extensions |
| 2846 | * more-messages-to-send |
| 2847 | * SMS during ongoing call (SACCH/SAPI3) |
| 2848 | */ |
| 2849 | |
| 2850 | /* TODO (General): |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 2851 | * continue to send repeated MO signalling messages to keep channel open: does MSC tmeout? |
| 2852 | * malformed messages (missing IE, invalid message type): properly rejected? |
| 2853 | * MT call while LU or is ongoing: Do we use existing lchan or page while lchan active? |
| 2854 | * 3G/2G auth permutations |
| 2855 | * encryption algorithms vs. classmark vs. vty config |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 2856 | * send new transaction after/during clear (like SMS, ...) |
Harald Welte | 45164da | 2018-01-24 12:51:27 +0100 | [diff] [blame] | 2857 | * too long L3 INFO in DTAP |
| 2858 | * too long / padded BSSAP |
| 2859 | * too long / short TLV values |
Harald Welte | ba7b6d9 | 2018-01-23 21:32:34 +0100 | [diff] [blame] | 2860 | */ |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 2861 | |
| 2862 | |
| 2863 | control { |
Philipp Maier | 328d166 | 2018-03-07 10:40:27 +0100 | [diff] [blame] | 2864 | execute( TC_cr_before_reset() ); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 2865 | execute( TC_lu_imsi_noauth_tmsi() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 2866 | execute( TC_lu_imsi_noauth_notmsi() ); |
Harald Welte | a49e36e | 2018-01-21 19:29:33 +0100 | [diff] [blame] | 2867 | execute( TC_lu_imsi_reject() ); |
| 2868 | execute( TC_lu_imsi_timeout_gsup() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 2869 | execute( TC_lu_imsi_auth_tmsi() ); |
| 2870 | execute( TC_cmserv_imsi_unknown() ); |
Harald Welte | 2bb825f | 2018-01-22 11:31:18 +0100 | [diff] [blame] | 2871 | execute( TC_lu_and_mo_call() ); |
Harald Welte | 071ed73 | 2018-01-23 19:53:52 +0100 | [diff] [blame] | 2872 | execute( TC_lu_auth_sai_timeout() ); |
| 2873 | execute( TC_lu_auth_sai_err() ); |
Harald Welte | e1a2f3c | 2018-01-24 17:28:48 +0100 | [diff] [blame] | 2874 | execute( TC_lu_clear_request() ); |
| 2875 | execute( TC_lu_disconnect() ); |
| 2876 | execute( TC_lu_by_imei() ); |
| 2877 | execute( TC_lu_by_tmsi_noauth_unknown() ); |
| 2878 | execute( TC_imsi_detach_by_imsi() ); |
| 2879 | execute( TC_imsi_detach_by_tmsi() ); |
| 2880 | execute( TC_imsi_detach_by_imei() ); |
| 2881 | execute( TC_emerg_call_imei_reject() ); |
| 2882 | execute( TC_emerg_call_imsi() ); |
| 2883 | execute( TC_cm_serv_req_vgcs_reject() ); |
| 2884 | execute( TC_cm_serv_req_vbs_reject() ); |
| 2885 | execute( TC_cm_serv_req_lcs_reject() ); |
Harald Welte | 0195ab1 | 2018-01-24 21:50:20 +0100 | [diff] [blame] | 2886 | execute( TC_cm_reest_req_reject() ); |
Harald Welte | 1af6ea8 | 2018-01-25 18:33:15 +0100 | [diff] [blame] | 2887 | execute( TC_lu_auth_2G_fail() ); |
| 2888 | execute( TC_lu_imsi_auth_tmsi_encr_13_13() ); |
| 2889 | execute( TC_cl3_no_payload() ); |
| 2890 | execute( TC_cl3_rnd_payload() ); |
Harald Welte | 1852a84 | 2018-01-26 22:53:36 +0100 | [diff] [blame] | 2891 | execute( TC_establish_and_nothing() ); |
| 2892 | execute( TC_mo_setup_and_nothing() ); |
| 2893 | execute( TC_mo_crcx_ran_timeout() ); |
| 2894 | execute( TC_mo_crcx_ran_reject() ); |
Harald Welte | d2328a2 | 2018-01-27 14:27:16 +0100 | [diff] [blame] | 2895 | execute( TC_mt_crcx_ran_reject() ); |
Daniel Willmann | 8b08437 | 2018-02-04 13:35:26 +0100 | [diff] [blame] | 2896 | execute( TC_mo_setup_and_dtmf_dup() ); |
Harald Welte | aa54cf8 | 2018-01-30 08:15:32 +0100 | [diff] [blame] | 2897 | //execute( TC_mt_t310() ); |
Harald Welte | 167458a | 2018-01-27 15:58:16 +0100 | [diff] [blame] | 2898 | execute( TC_gsup_cancel() ); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2899 | execute( TC_lu_imsi_auth_tmsi_encr_1_13() ); |
| 2900 | execute( TC_lu_imsi_auth_tmsi_encr_3_13() ); |
| 2901 | execute( TC_lu_imsi_auth_tmsi_encr_3_1() ); |
Neels Hofmeyr | 29b8da0 | 2018-03-01 18:09:45 +0100 | [diff] [blame] | 2902 | execute( TC_lu_imsi_auth_tmsi_encr_3_1_no_cm() ); |
Harald Welte | 9de8479 | 2018-01-28 01:06:35 +0100 | [diff] [blame] | 2903 | execute( TC_lu_imsi_auth_tmsi_encr_13_2() ); |
| 2904 | execute( TC_lu_imsi_auth_tmsi_encr_013_2() ); |
Philipp Maier | 94f3f1b | 2018-03-15 18:54:13 +0100 | [diff] [blame] | 2905 | execute( TC_mo_release_timeout() ); |
Philipp Maier | 2a98a73 | 2018-03-19 16:06:12 +0100 | [diff] [blame] | 2906 | execute( TC_lu_and_mt_call_no_dlcx_resp() ); |
Philipp Maier | 7593298 | 2018-03-27 14:52:35 +0200 | [diff] [blame] | 2907 | execute( TC_reset_two() ); |
Harald Welte | 33ec09b | 2018-02-10 15:34:46 +0100 | [diff] [blame] | 2908 | |
| 2909 | execute( TC_lu_and_mt_call() ); |
| 2910 | |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2911 | execute( TC_lu_and_mo_sms() ); |
| 2912 | execute( TC_lu_and_mt_sms() ); |
Harald Welte | f640a01 | 2018-04-14 17:49:21 +0200 | [diff] [blame] | 2913 | execute( TC_smpp_mo_sms() ); |
| 2914 | execute( TC_smpp_mt_sms() ); |
Harald Welte | f45efeb | 2018-04-09 18:19:24 +0200 | [diff] [blame] | 2915 | |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 2916 | execute( TC_lu_and_mo_ussd_single_request() ); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 2917 | execute( TC_lu_and_mt_ussd_notification() ); |
Vadim Yanitskiy | 2a978b9 | 2018-06-19 17:51:20 +0700 | [diff] [blame] | 2918 | execute( TC_lu_and_mo_ussd_during_mt_call() ); |
Vadim Yanitskiy | 13e4a27 | 2018-06-19 18:24:31 +0700 | [diff] [blame] | 2919 | execute( TC_lu_and_mt_ussd_during_mt_call() ); |
Vadim Yanitskiy | 2daf52d | 2018-06-21 04:19:58 +0700 | [diff] [blame] | 2920 | execute( TC_lu_and_mo_ussd_mo_release() ); |
Vadim Yanitskiy | 0e392dd | 2018-11-29 00:47:54 +0700 | [diff] [blame] | 2921 | execute( TC_lu_and_ss_session_timeout() ); |
Vadim Yanitskiy | 7d1f918 | 2018-05-28 16:21:42 +0700 | [diff] [blame] | 2922 | |
Stefan Sperling | 89eb1f3 | 2018-12-17 15:06:20 +0100 | [diff] [blame] | 2923 | execute( TC_cipher_complete_with_invalid_cipher() ); |
| 2924 | |
Neels Hofmeyr | 1b3c6e3 | 2018-03-01 17:52:21 +0100 | [diff] [blame] | 2925 | /* Run this last: at the time of writing this test crashes the MSC */ |
| 2926 | execute( TC_lu_imsi_auth_tmsi_encr_3_1_log_msc_debug() ); |
Neels Hofmeyr | 692c9ee | 2018-04-10 02:07:13 +0200 | [diff] [blame] | 2927 | execute( TC_mo_cc_bssmap_clear() ); |
Harald Welte | f6dd64d | 2017-11-19 12:09:51 +0100 | [diff] [blame] | 2928 | } |
| 2929 | |
| 2930 | |
| 2931 | } |