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