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