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