blob: 1b37329d5f71b10682941c29b587ca20607529f2 [file] [log] [blame]
Harald Weltef6dd64d2017-11-19 12:09:51 +01001module MSC_Tests {
2
3import from General_Types all;
4import from Osmocom_Types all;
5
6import from M3UA_Types all;
7import from M3UA_Emulation all;
8
9import from MTP3asp_Types all;
10import from MTP3asp_PortType all;
11
12import from SCCPasp_Types all;
13import from SCCP_Types all;
14import from SCCP_Emulation all;
15
16import from SCTPasp_Types all;
17import from SCTPasp_PortType all;
18
Harald Weltea49e36e2018-01-21 19:29:33 +010019import from Osmocom_CTRL_Functions all;
20import from Osmocom_CTRL_Types all;
21import from Osmocom_CTRL_Adapter all;
22
Harald Welte3ca1c902018-01-24 18:51:27 +010023import from TELNETasp_PortType all;
24import from Osmocom_VTY_Functions all;
25
Harald Weltea49e36e2018-01-21 19:29:33 +010026import from MNCC_Emulation all;
Harald Welte2bb825f2018-01-22 11:31:18 +010027import from MNCC_Types all;
Harald Weltea49e36e2018-01-21 19:29:33 +010028
Harald Welte4aa970c2018-01-26 10:38:09 +010029import from MGCP_Emulation all;
30import from MGCP_Types all;
31import from MGCP_Templates all;
32import from SDP_Types all;
33
Harald Weltea49e36e2018-01-21 19:29:33 +010034import from GSUP_Emulation all;
35import from GSUP_Types all;
36import from IPA_Emulation all;
37
Harald Weltef6dd64d2017-11-19 12:09:51 +010038import from BSSAP_Types all;
Harald Weltea49e36e2018-01-21 19:29:33 +010039import from BSSAP_Adapter all;
40import from BSSAP_CodecPort all;
41import from BSSMAP_Templates all;
42import from BSSMAP_Emulation all;
43import from BSC_ConnectionHandler all;
Harald Weltef6dd64d2017-11-19 12:09:51 +010044
Harald Weltea49e36e2018-01-21 19:29:33 +010045import from MobileL3_Types all;
46import from MobileL3_CommonIE_Types all;
47import from L3_Templates all;
Harald Welte158a7ca2018-02-16 18:11:31 +010048import from L3_Common all;
Harald Weltef6dd64d2017-11-19 12:09:51 +010049
Harald Weltef640a012018-04-14 17:49:21 +020050import from SMPP_Types all;
51import from SMPP_Templates all;
52import from SMPP_Emulation all;
53
Stefan Sperlingc307e682018-06-14 15:15:46 +020054import from SCCP_Templates all;
55
Vadim Yanitskiy7d1f9182018-05-28 16:21:42 +070056import from SS_Types all;
57import from SS_Templates all;
58import from USSD_Helpers all;
59
Philipp Maier75932982018-03-27 14:52:35 +020060const integer NUM_BSC := 2;
61type record of BSSAP_Configuration BSSAP_Configurations;
Harald Weltef6dd64d2017-11-19 12:09:51 +010062
Harald Weltea4ca4462018-02-09 00:17:14 +010063type component MTC_CT extends CTRL_Adapter_CT {
Harald Weltef6dd64d2017-11-19 12:09:51 +010064 var boolean g_initialized := false;
Harald Weltea49e36e2018-01-21 19:29:33 +010065
Philipp Maier75932982018-03-27 14:52:35 +020066 var BSSAP_Adapter g_bssap[NUM_BSC];
Harald Weltea4ca4462018-02-09 00:17:14 +010067
Harald Weltea49e36e2018-01-21 19:29:33 +010068 /* no 'adapter_CT' for MNCC or GSUP */
69 var MNCC_Emulation_CT vc_MNCC;
Harald Welte4aa970c2018-01-26 10:38:09 +010070 var MGCP_Emulation_CT vc_MGCP;
Harald Weltea49e36e2018-01-21 19:29:33 +010071 var GSUP_Emulation_CT vc_GSUP;
72 var IPA_Emulation_CT vc_GSUP_IPA;
Harald Weltef640a012018-04-14 17:49:21 +020073 var SMPP_Emulation_CT vc_SMPP;
Harald Weltea49e36e2018-01-21 19:29:33 +010074
75 /* only to get events from IPA underneath GSUP */
76 port IPA_CTRL_PT GSUP_IPA_EVENT;
Harald Welte3ca1c902018-01-24 18:51:27 +010077 /* VTY to MSC */
78 port TELNETasp_PT MSCVTY;
Philipp Maier328d1662018-03-07 10:40:27 +010079
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 Weltef6dd64d2017-11-19 12:09:51 +010089}
90
91modulepar {
Harald Weltea49e36e2018-01-21 19:29:33 +010092 /* 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 Weltef6dd64d2017-11-19 12:09:51 +010096
Harald Weltea49e36e2018-01-21 19:29:33 +010097 /* local parameters of emulated HLR */
98 charstring mp_hlr_ip := "127.0.0.1";
99 integer mp_hlr_port := 4222;
Harald Welte6126fb02018-01-27 20:08:24 +0100100 charstring mp_mgw_ip := "127.0.0.1";
101 integer mp_mgw_port := 2427;
Harald Weltef6dd64d2017-11-19 12:09:51 +0100102
Harald Weltea49e36e2018-01-21 19:29:33 +0100103 charstring mp_msc_mncc := "/tmp/mncc";
Harald Weltea4ca4462018-02-09 00:17:14 +0100104
Harald Weltef640a012018-04-14 17:49:21 +0200105 integer mp_msc_smpp_port := 2775;
106 charstring mp_smpp_system_id := "msc_tester";
107 charstring mp_smpp_password := "osmocom1";
108
Philipp Maier75932982018-03-27 14:52:35 +0200109 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 Weltea4ca4462018-02-09 00:17:14 +0100130 };
Harald Weltef6dd64d2017-11-19 12:09:51 +0100131}
132
Philipp Maier328d1662018-03-07 10:40:27 +0100133/* altstep for the global guard timer (only used when BSSAP_DIRECT
134 * is used for communication */
135private altstep as_Tguard_direct() runs on MTC_CT {
136 [] Tguard_direct.timeout {
137 setverdict(fail, "Tguard timeout");
Daniel Willmannafce8662018-07-06 23:11:32 +0200138 mtc.stop;
Philipp Maier328d1662018-03-07 10:40:27 +0100139 }
140}
Harald Weltef6dd64d2017-11-19 12:09:51 +0100141
Harald Weltef640a012018-04-14 17:49:21 +0200142function 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 Weltea49e36e2018-01-21 19:29:33 +0100164function 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 Weltef6dd64d2017-11-19 12:09:51 +0100174}
175
Harald Welte4aa970c2018-01-26 10:38:09 +0100176function 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 Welte6126fb02018-01-27 20:08:24 +0100183 callagent_ip := mp_msc_ip,
Harald Welte4aa970c2018-01-26 10:38:09 +0100184 callagent_udp_port := -1,
Harald Welte6126fb02018-01-27 20:08:24 +0100185 mgw_ip := mp_mgw_ip,
186 mgw_udp_port := mp_mgw_port
Harald Welte4aa970c2018-01-26 10:38:09 +0100187 }
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 Weltea49e36e2018-01-21 19:29:33 +0100194function 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 Welte458fd372018-03-21 11:26:23 +0100217 setverdict(fail, "No connection to GSUP Port");
Daniel Willmannafce8662018-07-06 23:11:32 +0200218 mtc.stop
Harald Weltea49e36e2018-01-21 19:29:33 +0100219 }
220 }
Harald Weltef6dd64d2017-11-19 12:09:51 +0100221}
222
Philipp Maier75932982018-03-27 14:52:35 +0200223function f_init(integer num_bsc := 1) runs on MTC_CT {
Harald Weltef6dd64d2017-11-19 12:09:51 +0100224
225 if (g_initialized == true) {
226 return;
227 }
228 g_initialized := true;
229
Philipp Maier75932982018-03-27 14:52:35 +0200230 if (num_bsc > NUM_BSC) {
Daniel Willmannafce8662018-07-06 23:11:32 +0200231 testcase.stop("excess number of BSC instances requested");
Philipp Maier75932982018-03-27 14:52:35 +0200232 }
233
234 for (var integer i := 0; i < num_bsc; i := i + 1) {
235 if (isbound(mp_bssap_cfg[i])) {
Philipp Maierdefd9482018-05-16 16:44:37 +0200236 f_bssap_init(g_bssap[i], mp_bssap_cfg[i], "MSC_Test_" & int2str(i), BSC_BssmapOps);
Harald Welted5833a82018-05-27 16:52:56 +0200237 f_bssap_start(g_bssap[i]);
Philipp Maier75932982018-03-27 14:52:35 +0200238 } else {
Daniel Willmannafce8662018-07-06 23:11:32 +0200239 testcase.stop("missing BSSAP configuration");
Philipp Maier75932982018-03-27 14:52:35 +0200240 }
241 }
242
Harald Weltea49e36e2018-01-21 19:29:33 +0100243 f_ipa_ctrl_start(mp_msc_ip, mp_msc_ctrl_port);
244 f_init_mncc("MSC_Test");
Harald Welte4aa970c2018-01-26 10:38:09 +0100245 f_init_mgcp("MSC_Test");
Harald Weltea49e36e2018-01-21 19:29:33 +0100246 f_init_gsup("MSC_Test");
Harald Weltef640a012018-04-14 17:49:21 +0200247 f_init_smpp("MSC_Test");
Harald Welte3ca1c902018-01-24 18:51:27 +0100248
249 map(self:MSCVTY, system:MSCVTY);
250 f_vty_set_prompts(MSCVTY);
251 f_vty_transceive(MSCVTY, "enable");
Harald Welteb14c77a2018-01-25 17:25:44 +0100252
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 Weltef6dd64d2017-11-19 12:09:51 +0100257}
258
Philipp Maier328d1662018-03-07 10:40:27 +0100259/* 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. */
262function f_init_bssap_direct() runs on MTC_CT {
Philipp Maier75932982018-03-27 14:52:35 +0200263 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 Maier328d1662018-03-07 10:40:27 +0100265
266 /* Start guard timer and activate it as default */
267 Tguard_direct.start
268 activate(as_Tguard_direct());
269}
270
Harald Weltef6dd64d2017-11-19 12:09:51 +0100271template 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
279template 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
290type integer BssmapCause;
291
292template (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
300template (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
312template (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
323template 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
334template 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
342type uint16_t BssmapLAC;
343type uint16_t BssmapCI;
344
345/*
346template BSSMAP_IE_CellIdentifier ts_CellId_CGI(mcc, mnc, lac, ci)
347modifies 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
358template BSSMAP_IE_CellIdentifier ts_CellID_LAC_CI(BssmapLAC lac, BssmapCI ci)
359modifies ts_BSSMAP_IE_CellID := {
360 cellIdentification := {
361 cI_LAC_CI := {
362 lac := int2oct(lac, 2),
363 ci := int2oct(ci, 2)
364 }
365 }
366}
367
368template BSSMAP_IE_CellIdentifier ts_CellId_CI(BssmapCI ci)
369modifies ts_BSSMAP_IE_CellID := {
370 cellIdentification := {
371 cI_CI := int2oct(ci, 2)
372 }
373}
374
375template BSSMAP_IE_CellIdentifier ts_CellId_none
376modifies ts_BSSMAP_IE_CellID := {
377 cellIdentification := {
378 cI_noCell := ''O
379 }
380}
381
382
383template BSSMAP_IE_Layer3Information ts_BSSMAP_IE_L3Info(octetstring l3info) := {
384 elementIdentifier := '17'O,
385 lengthIndicator := 0,
386 layer3info := l3info
387}
388
389template PDU_BSSAP ts_BSSMAP_ComplL3(BSSMAP_IE_CellIdentifier cell_id, octetstring l3_info)
390modifies 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
409template PDU_BSSAP ts_BSSMAP_HandoReq(BssmapCause cause, BSSMAP_IE_CellIdentifierList cid_list)
410modifies 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 Weltea49e36e2018-01-21 19:29:33 +0100434type function void_fn(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr;
Harald Weltef6dd64d2017-11-19 12:09:51 +0100435
Harald Weltea49e36e2018-01-21 19:29:33 +0100436/* FIXME: move into BSC_ConnectionHandler? */
Neels Hofmeyr9adaa702018-03-01 20:23:19 +0100437function f_init_pars(integer imsi_suffix) runs on MTC_CT return BSC_ConnHdlrPars {
Harald Weltede371492018-01-27 23:44:41 +0100438 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 Weltea49e36e2018-01-21 19:29:33 +0100444 var BSC_ConnHdlrPars pars := {
Philipp Maier75932982018-03-27 14:52:35 +0200445 sccp_addr_own := g_bssap[0].sccp_addr_own,
446 sccp_addr_peer := g_bssap[0].sccp_addr_peer,
Harald Welteedbab812018-03-18 16:02:25 +0100447 cell_id := valueof(ts_CellId_CGI('262'H, '42'H, 23, 42)),
Harald Welte81b7f9d2018-01-24 19:06:24 +0100448 imei := f_gen_imei(imsi_suffix),
449 imsi := f_gen_imsi(imsi_suffix),
450 msisdn := f_gen_msisdn(imsi_suffix),
Harald Welte256571e2018-01-24 18:47:19 +0100451 tmsi := omit,
Harald Welte9de84792018-01-28 01:06:35 +0100452 cm1 := valueof(ts_CM1),
Harald Welte82600572018-01-21 20:54:08 +0100453 cm2 := valueof(ts_CM2_default),
Harald Welte16114282018-01-24 22:41:21 +0100454 cm3 := omit,
Harald Weltede371492018-01-27 23:44:41 +0100455 vec := omit,
Neels Hofmeyrc1f105a2018-03-01 20:00:19 +0100456 net := net_pars,
Philipp Maieraeb29a82018-11-08 17:40:53 +0100457 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 Weltea49e36e2018-01-21 19:29:33 +0100461 };
Neels Hofmeyr9adaa702018-03-01 20:23:19 +0100462 return pars;
463}
464
465function 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 Weltea49e36e2018-01-21 19:29:33 +0100468
469 vc_conn := BSC_ConnHdlr.create(id);
470 /* BSSMAP part / A interface */
Philipp Maier75932982018-03-27 14:52:35 +0200471 connect(vc_conn:BSSAP, g_bssap[0].vc_BSSMAP:CLIENT);
472 connect(vc_conn:BSSAP_PROC, g_bssap[0].vc_BSSMAP:PROC);
Harald Weltea49e36e2018-01-21 19:29:33 +0100473 /* MNCC part */
474 connect(vc_conn:MNCC, vc_MNCC:MNCC_CLIENT);
475 connect(vc_conn:MNCC_PROC, vc_MNCC:MNCC_PROC);
Harald Welte4aa970c2018-01-26 10:38:09 +0100476 /* MGCP part */
477 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
478 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltea49e36e2018-01-21 19:29:33 +0100479 /* GSUP part */
480 connect(vc_conn:GSUP, vc_GSUP:GSUP_CLIENT);
481 connect(vc_conn:GSUP_PROC, vc_GSUP:GSUP_PROC);
Harald Weltef640a012018-04-14 17:49:21 +0200482 /* SMPP part */
483 connect(vc_conn:SMPP, vc_SMPP:SMPP_CLIENT);
484 connect(vc_conn:SMPP_PROC, vc_SMPP:SMPP_PROC);
Harald Weltea49e36e2018-01-21 19:29:33 +0100485
Harald Weltea10db902018-01-27 12:44:49 +0100486 /* 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 Weltea49e36e2018-01-21 19:29:33 +0100488 vc_conn.start(derefers(fn)(id, pars));
489 return vc_conn;
490}
491
Neels Hofmeyr9adaa702018-03-01 20:23:19 +0100492function 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 Weltea49e36e2018-01-21 19:29:33 +0100496private function f_tc_lu_imsi_noauth_tmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +0100497 f_init_handler(pars);
Neels Hofmeyrc1f105a2018-03-01 20:00:19 +0100498 f_perform_lu();
Harald Weltea49e36e2018-01-21 19:29:33 +0100499}
Harald Weltea49e36e2018-01-21 19:29:33 +0100500testcase TC_lu_imsi_noauth_tmsi() runs on MTC_CT {
501 var BSC_ConnHdlr vc_conn;
502 f_init();
503
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +0100504 vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_tmsi), 1);
Harald Weltea49e36e2018-01-21 19:29:33 +0100505 vc_conn.done;
506}
507
508private function f_tc_lu_imsi_noauth_notmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltede371492018-01-27 23:44:41 +0100509 pars.net.expect_tmsi := false;
Harald Weltea10db902018-01-27 12:44:49 +0100510 f_init_handler(pars);
Neels Hofmeyrc1f105a2018-03-01 20:00:19 +0100511 f_perform_lu();
Harald Weltea49e36e2018-01-21 19:29:33 +0100512}
Harald Weltea49e36e2018-01-21 19:29:33 +0100513testcase TC_lu_imsi_noauth_notmsi() runs on MTC_CT {
514 var BSC_ConnHdlr vc_conn;
515 f_init();
Harald Welte3ca1c902018-01-24 18:51:27 +0100516 f_vty_config(MSCVTY, "msc", "no assign-tmsi");
Harald Weltea49e36e2018-01-21 19:29:33 +0100517
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +0100518 vc_conn := f_start_handler(refers(f_tc_lu_imsi_noauth_notmsi), 2);
Harald Weltea49e36e2018-01-21 19:29:33 +0100519 vc_conn.done;
520}
521
522/* Do LU by IMSI, refuse it on GSUP and expect LU REJ back to MS */
523private function f_tc_lu_imsi_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +0100524 f_init_handler(pars);
Harald Weltea49e36e2018-01-21 19:29:33 +0100525 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 Welte5946b332018-03-18 23:32:21 +0100532 [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej(int2oct(23,1)))) {
533 f_expect_clear();
534 }
Harald Weltea49e36e2018-01-21 19:29:33 +0100535 [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) {
536 setverdict(fail, "Expecting LU REJ, but got ACCEPT");
Daniel Willmannafce8662018-07-06 23:11:32 +0200537 mtc.stop;
Harald Weltea49e36e2018-01-21 19:29:33 +0100538 }
539 }
Harald Weltea49e36e2018-01-21 19:29:33 +0100540}
541testcase TC_lu_imsi_reject() runs on MTC_CT {
542 var BSC_ConnHdlr vc_conn;
543 f_init();
544
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +0100545 vc_conn := f_start_handler(refers(f_tc_lu_imsi_reject), 3);
Harald Weltea49e36e2018-01-21 19:29:33 +0100546 vc_conn.done;
547}
548
549/* Do LU by IMSI, timeout on GSUP */
550private function f_tc_lu_imsi_timeout_gsup(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +0100551 f_init_handler(pars);
Harald Weltea49e36e2018-01-21 19:29:33 +0100552 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 Welte5946b332018-03-18 23:32:21 +0100560 [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) {
561 f_expect_clear();
562 }
Harald Weltea49e36e2018-01-21 19:29:33 +0100563 [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) {
564 setverdict(fail, "Expecting LU REJ, but got ACCEPT");
Daniel Willmannafce8662018-07-06 23:11:32 +0200565 mtc.stop;
Harald Weltea49e36e2018-01-21 19:29:33 +0100566 }
567 }
Harald Weltea49e36e2018-01-21 19:29:33 +0100568}
569testcase TC_lu_imsi_timeout_gsup() runs on MTC_CT {
570 var BSC_ConnHdlr vc_conn;
571 f_init();
572
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +0100573 vc_conn := f_start_handler(refers(f_tc_lu_imsi_timeout_gsup), 4);
Harald Weltea49e36e2018-01-21 19:29:33 +0100574 vc_conn.done;
575}
576
Harald Welte7b1b2812018-01-22 21:23:06 +0100577private function f_tc_lu_imsi_auth_tmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltede371492018-01-27 23:44:41 +0100578 pars.net.expect_auth := true;
Harald Weltea10db902018-01-27 12:44:49 +0100579 f_init_handler(pars);
Neels Hofmeyrc1f105a2018-03-01 20:00:19 +0100580 f_perform_lu();
Harald Welte7b1b2812018-01-22 21:23:06 +0100581}
582testcase TC_lu_imsi_auth_tmsi() runs on MTC_CT {
583 var BSC_ConnHdlr vc_conn;
584 f_init();
Harald Welte3ca1c902018-01-24 18:51:27 +0100585 f_vty_config(MSCVTY, "network", "authentication required");
Harald Welte7b1b2812018-01-22 21:23:06 +0100586
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +0100587 vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi), 5);
Harald Welte7b1b2812018-01-22 21:23:06 +0100588 vc_conn.done;
589}
590
Harald Weltea49e36e2018-01-21 19:29:33 +0100591
592/* Send CM SERVICE REQ for IMSI that has never performed LU before */
593private function f_tc_cmserv_imsi_unknown(charstring id, BSC_ConnHdlrPars pars)
594runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +0100595 f_init_handler(pars);
Harald Weltea49e36e2018-01-21 19:29:33 +0100596
597 var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
Harald Welteedbab812018-03-18 16:02:25 +0100598 var BSSMAP_IE_CellIdentifier cell_id := valueof(ts_CellId_CGI('262'H, '42'H, 23, 42));
Harald Welte6ed6bf92018-01-24 21:09:15 +0100599 var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi));
Harald Weltea49e36e2018-01-21 19:29:33 +0100600
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 Weltef6dd64d2017-11-19 12:09:51 +0100607 T.start;
608 alt {
Harald Weltea49e36e2018-01-21 19:29:33 +0100609 [] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ)) { }
610 //[] BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_ACC)) { }
Daniel Willmannafce8662018-07-06 23:11:32 +0200611 [] BSSAP.receive {
612 setverdict(fail, "Received unexpected BSSAP");
613 mtc.stop;
614 }
Harald Weltea49e36e2018-01-21 19:29:33 +0100615 [] GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi)) {
616 setverdict(fail, "Unexpected GSUP UL REQ");
Daniel Willmannafce8662018-07-06 23:11:32 +0200617 mtc.stop;
Harald Weltea49e36e2018-01-21 19:29:33 +0100618 }
Daniel Willmannafce8662018-07-06 23:11:32 +0200619 [] T.timeout {
620 setverdict(fail, "Timeout waiting for CM SERV REQ");
621 mtc.stop;
622 }
Harald Weltef6dd64d2017-11-19 12:09:51 +0100623 }
624
Harald Welte1ddc7162018-01-27 14:25:46 +0100625 f_expect_clear();
Harald Weltef6dd64d2017-11-19 12:09:51 +0100626}
Harald Weltea49e36e2018-01-21 19:29:33 +0100627testcase TC_cmserv_imsi_unknown() runs on MTC_CT {
628 var BSC_ConnHdlr vc_conn;
629 f_init();
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +0100630 vc_conn := f_start_handler(refers(f_tc_cmserv_imsi_unknown), 6);
Harald Weltea49e36e2018-01-21 19:29:33 +0100631 vc_conn.done;
632}
633
Harald Welte2bb825f2018-01-22 11:31:18 +0100634private function f_tc_lu_and_mo_call(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +0100635 f_init_handler(pars);
Harald Welteb71901a2018-01-26 19:16:05 +0100636 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 Maierf1e02bb2018-03-15 16:30:00 +0100640 cpars.mgcp_ep := "rtpbridge/1@mgw";
Harald Welte2bb825f2018-01-22 11:31:18 +0100641
Neels Hofmeyrc1f105a2018-03-01 20:00:19 +0100642 f_perform_lu();
Harald Welteb71901a2018-01-26 19:16:05 +0100643 f_mo_call(cpars);
Harald Welte2bb825f2018-01-22 11:31:18 +0100644}
645testcase TC_lu_and_mo_call() runs on MTC_CT {
646 var BSC_ConnHdlr vc_conn;
647 f_init();
648
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +0100649 vc_conn := f_start_handler(refers(f_tc_lu_and_mo_call), 7);
Harald Welte071ed732018-01-23 19:53:52 +0100650 vc_conn.done;
651}
652
653/* Test LU (with authentication enabled), where HLR times out sending SAI response */
654private function f_tc_lu_auth_sai_timeout(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +0100655 f_init_handler(pars);
Harald Welte071ed732018-01-23 19:53:52 +0100656
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 Welte1ddc7162018-01-27 14:25:46 +0100673 f_expect_clear();
Harald Welte071ed732018-01-23 19:53:52 +0100674}
675testcase TC_lu_auth_sai_timeout() runs on MTC_CT {
676 var BSC_ConnHdlr vc_conn;
677 f_init();
Harald Welte3ca1c902018-01-24 18:51:27 +0100678 f_vty_config(MSCVTY, "network", "authentication required");
Harald Welte071ed732018-01-23 19:53:52 +0100679
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +0100680 vc_conn := f_start_handler(refers(f_tc_lu_auth_sai_timeout), 8);
Harald Welte071ed732018-01-23 19:53:52 +0100681 vc_conn.done;
682}
683
684/* Test LU (with authentication enabled), where HLR rejects sending SAI error */
685private function f_tc_lu_auth_sai_err(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +0100686 f_init_handler(pars);
Harald Welte071ed732018-01-23 19:53:52 +0100687
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 Welte1ddc7162018-01-27 14:25:46 +0100704 f_expect_clear();
Harald Welte071ed732018-01-23 19:53:52 +0100705}
706testcase TC_lu_auth_sai_err() runs on MTC_CT {
707 var BSC_ConnHdlr vc_conn;
708 f_init();
Harald Welte3ca1c902018-01-24 18:51:27 +0100709 f_vty_config(MSCVTY, "network", "authentication required");
Harald Welte071ed732018-01-23 19:53:52 +0100710
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +0100711 vc_conn := f_start_handler(refers(f_tc_lu_auth_sai_err), 9);
Harald Welte2bb825f2018-01-22 11:31:18 +0100712 vc_conn.done;
713}
Harald Weltea49e36e2018-01-21 19:29:33 +0100714
Harald Weltebc881782018-01-23 20:09:15 +0100715/* Test LU but BSC will send a clear request in the middle */
716private function f_tc_lu_clear_request(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +0100717 f_init_handler(pars);
Harald Weltebc881782018-01-23 20:09:15 +0100718
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 Hofmeyr2b326fa2018-04-06 00:59:36 +0200734 alt {
735 [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) { repeat; }
736 [] BSSAP.receive(tr_BSSMAP_ClearCommand) {}
737 }
Harald Weltebc881782018-01-23 20:09:15 +0100738 BSSAP.send(ts_BSSMAP_ClearComplete);
Harald Welte89a32492018-01-27 19:07:28 +0100739 alt {
740 /* See https://osmocom.org/issues/2862 */
Neels Hofmeyr2b326fa2018-04-06 00:59:36 +0200741 [] BSSAP.receive(tr_BSSMAP_ClearCommand) {
742 setverdict(fail, "Got a second Clear Command, only one expected");
Daniel Willmannafce8662018-07-06 23:11:32 +0200743 mtc.stop;
Neels Hofmeyr2b326fa2018-04-06 00:59:36 +0200744 repeat;
745 }
Harald Welte89a32492018-01-27 19:07:28 +0100746 [] BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {}
747 }
Harald Weltebc881782018-01-23 20:09:15 +0100748 setverdict(pass);
749}
750testcase TC_lu_clear_request() runs on MTC_CT {
751 var BSC_ConnHdlr vc_conn;
752 f_init();
753
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +0100754 vc_conn := f_start_handler(refers(f_tc_lu_clear_request), 10);
Harald Weltebc881782018-01-23 20:09:15 +0100755 vc_conn.done;
756}
757
Harald Welte66af9e62018-01-24 17:28:21 +0100758/* Test LU but BSC will send a clear request in the middle */
759private function f_tc_lu_disconnect(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +0100760 f_init_handler(pars);
Harald Welte66af9e62018-01-24 17:28:21 +0100761
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}
779testcase TC_lu_disconnect() runs on MTC_CT {
780 var BSC_ConnHdlr vc_conn;
781 f_init();
782
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +0100783 vc_conn := f_start_handler(refers(f_tc_lu_disconnect), 11);
Harald Welte66af9e62018-01-24 17:28:21 +0100784 vc_conn.done;
785}
786
787
Harald Welteba7b6d92018-01-23 21:32:34 +0100788/* Test LU but with illegal mobile identity type = IMEI */
789private function f_tc_lu_by_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +0100790 f_init_handler(pars);
Harald Welteba7b6d92018-01-23 21:32:34 +0100791
Harald Welte256571e2018-01-24 18:47:19 +0100792 var PDU_ML3_MS_NW l3_lu := f_build_lu_imei(g_pars.imei)
Harald Welteba7b6d92018-01-23 21:32:34 +0100793 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 Welte1ddc7162018-01-27 14:25:46 +0100809 f_expect_clear();
Harald Welteba7b6d92018-01-23 21:32:34 +0100810}
811testcase TC_lu_by_imei() runs on MTC_CT {
812 var BSC_ConnHdlr vc_conn;
813 f_init();
814
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +0100815 vc_conn := f_start_handler(refers(f_tc_lu_by_imei), 12);
Harald Welteba7b6d92018-01-23 21:32:34 +0100816 vc_conn.done;
817}
818
819/* Test LU by TMSI with unknown TMSI, expect (and answer) ID REQ. */
820private function f_tc_lu_tmsi_noauth_unknown(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Stefan Sperling04fc4bc2018-06-25 17:44:57 +0200821 /* We piggyback a test for an MSC crash on overlong IMSI (OS#2864) onto this test. */
822 var hexstring overlong_imsi := '012345789ABCDEF0123456789ABCDEF'H;
Harald Weltea10db902018-01-27 12:44:49 +0100823 f_init_handler(pars);
Harald Welteba7b6d92018-01-23 21:32:34 +0100824
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 Sperling04fc4bc2018-06-25 17:44:57 +0200839 BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp_IMSI(overlong_imsi))); /* test for OS#2864 */
Harald Welteba7b6d92018-01-23 21:32:34 +0100840 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 Welte7ec4fa82018-01-27 10:57:40 +0100849 [] 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 Welteba7b6d92018-01-23 21:32:34 +0100852 [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) {
853 setverdict(fail, "Expected LU ACK, but received REJ");
Daniel Willmannafce8662018-07-06 23:11:32 +0200854 mtc.stop;
Harald Welteba7b6d92018-01-23 21:32:34 +0100855 }
856 }
857
858 /* wait for normal teardown */
Harald Welte1ddc7162018-01-27 14:25:46 +0100859 f_expect_clear();
Harald Welteba7b6d92018-01-23 21:32:34 +0100860}
861testcase TC_lu_by_tmsi_noauth_unknown() runs on MTC_CT {
862 var BSC_ConnHdlr vc_conn;
863 f_init();
864
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +0100865 vc_conn := f_start_handler(refers(f_tc_lu_tmsi_noauth_unknown), 13);
Harald Welteba7b6d92018-01-23 21:32:34 +0100866 vc_conn.done;
867}
868
869
Harald Welte45164da2018-01-24 12:51:27 +0100870/* Test IMSI DETACH (MI=IMSI) */
871private function f_tc_imsi_detach_by_imsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +0100872 f_init_handler(pars);
Harald Welte45164da2018-01-24 12:51:27 +0100873
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 Welte1ddc7162018-01-27 14:25:46 +0100883 f_expect_clear();
Harald Welte45164da2018-01-24 12:51:27 +0100884}
885testcase TC_imsi_detach_by_imsi() runs on MTC_CT {
886 var BSC_ConnHdlr vc_conn;
887 f_init();
888
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +0100889 vc_conn := f_start_handler(refers(f_tc_imsi_detach_by_imsi), 14);
Harald Welte45164da2018-01-24 12:51:27 +0100890 vc_conn.done;
891}
892
893/* Test IMSI DETACH (MI=TMSI) */
894private function f_tc_imsi_detach_by_tmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +0100895 f_init_handler(pars);
Harald Welte45164da2018-01-24 12:51:27 +0100896
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 Welte1ddc7162018-01-27 14:25:46 +0100906 f_expect_clear();
Harald Welte45164da2018-01-24 12:51:27 +0100907}
908testcase TC_imsi_detach_by_tmsi() runs on MTC_CT {
909 var BSC_ConnHdlr vc_conn;
910 f_init();
911
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +0100912 vc_conn := f_start_handler(refers(f_tc_imsi_detach_by_tmsi), 15);
Harald Welte45164da2018-01-24 12:51:27 +0100913 vc_conn.done;
914}
915
916/* Test IMSI DETACH (MI=IMEI), which is illegal */
917private function f_tc_imsi_detach_by_imei(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +0100918 f_init_handler(pars);
Harald Welte45164da2018-01-24 12:51:27 +0100919
Harald Welte256571e2018-01-24 18:47:19 +0100920 var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(g_pars.imei));
Harald Welte45164da2018-01-24 12:51:27 +0100921
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 Welte1ddc7162018-01-27 14:25:46 +0100929 f_expect_clear();
Harald Welte45164da2018-01-24 12:51:27 +0100930}
931testcase TC_imsi_detach_by_imei() runs on MTC_CT {
932 var BSC_ConnHdlr vc_conn;
933 f_init();
934
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +0100935 vc_conn := f_start_handler(refers(f_tc_imsi_detach_by_imei), 16);
Harald Welte45164da2018-01-24 12:51:27 +0100936 vc_conn.done;
937}
938
939
940/* helper function for an emergency call. caller passes in mobile identity to use */
941private function f_emerg_call(MobileIdentityLV mi) runs on BSC_ConnHdlr {
Harald Welte0bef21e2018-02-10 09:48:23 +0100942 var CallParameters cpars := valueof(t_CallParams('112'H, 0));
943 cpars.emergency := true;
Philipp Maierf1e02bb2018-03-15 16:30:00 +0100944 cpars.mgcp_ep := "rtpbridge/1@mgw";
Harald Welte45164da2018-01-24 12:51:27 +0100945
Harald Welte0bef21e2018-02-10 09:48:23 +0100946 f_mo_call(cpars);
Harald Welte45164da2018-01-24 12:51:27 +0100947}
948
949/* establish an emergency call by IMEI, no SIM inserted (and hence no IMSI) */
950private function f_tc_emerg_call_imei_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +0100951 f_init_handler(pars);
Harald Welte45164da2018-01-24 12:51:27 +0100952
Harald Welte256571e2018-01-24 18:47:19 +0100953 var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(g_pars.imei));
Harald Welte6ed6bf92018-01-24 21:09:15 +0100954 var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_EMERG_CALL, mi));
Harald Welte45164da2018-01-24 12:51:27 +0100955 f_bssap_compl_l3(l3_info);
956 BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ('05'O)));
Harald Welte1ddc7162018-01-27 14:25:46 +0100957 f_expect_clear();
Harald Welte45164da2018-01-24 12:51:27 +0100958}
959testcase TC_emerg_call_imei_reject() runs on MTC_CT {
960 var BSC_ConnHdlr vc_conn;
961 f_init();
962
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +0100963 vc_conn := f_start_handler(refers(f_tc_emerg_call_imei_reject), 17);
Harald Welte45164da2018-01-24 12:51:27 +0100964 vc_conn.done;
965}
966
Harald Welted5b91402018-01-24 18:48:16 +0100967/* establish an emergency call by IMSI, SIM inserted (and hence IMSI) */
Harald Welte45164da2018-01-24 12:51:27 +0100968private function f_tc_emerg_call_imsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +0100969 f_init_handler(pars);
Harald Welte45164da2018-01-24 12:51:27 +0100970 /* First perform location update to ensure subscriber is known */
Neels Hofmeyrc1f105a2018-03-01 20:00:19 +0100971 f_perform_lu();
Harald Welte45164da2018-01-24 12:51:27 +0100972 /* Then issue emergency call identified by IMSI */
973 f_emerg_call(valueof(ts_MI_IMSI_LV(g_pars.imsi)));
974}
975testcase TC_emerg_call_imsi() runs on MTC_CT {
976 var BSC_ConnHdlr vc_conn;
977 f_init();
978
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +0100979 vc_conn := f_start_handler(refers(f_tc_emerg_call_imsi), 18);
Harald Welte45164da2018-01-24 12:51:27 +0100980 vc_conn.done;
981}
982
983/* CM Service Request for VGCS -> reject */
984private function f_tc_cm_serv_req_vgcs_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +0100985 f_init_handler(pars);
Harald Welte45164da2018-01-24 12:51:27 +0100986
987 /* First perform location update to ensure subscriber is known */
Neels Hofmeyrc1f105a2018-03-01 20:00:19 +0100988 f_perform_lu();
Harald Welte45164da2018-01-24 12:51:27 +0100989
990 var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
Harald Welte6ed6bf92018-01-24 21:09:15 +0100991 var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_VGCS, mi));
Harald Welte45164da2018-01-24 12:51:27 +0100992 f_bssap_compl_l3(l3_info);
993 BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ(int2oct(32,1))));
Harald Welte1ddc7162018-01-27 14:25:46 +0100994 f_expect_clear();
Harald Welte45164da2018-01-24 12:51:27 +0100995}
996testcase TC_cm_serv_req_vgcs_reject() runs on MTC_CT {
997 var BSC_ConnHdlr vc_conn;
998 f_init();
999
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +01001000 vc_conn := f_start_handler(refers(f_tc_cm_serv_req_vgcs_reject), 19);
Harald Welte45164da2018-01-24 12:51:27 +01001001 vc_conn.done;
1002}
1003
1004/* CM Service Request for VBS -> reject */
1005private function f_tc_cm_serv_req_vbs_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +01001006 f_init_handler(pars);
Harald Welte45164da2018-01-24 12:51:27 +01001007
1008 /* First perform location update to ensure subscriber is known */
Neels Hofmeyrc1f105a2018-03-01 20:00:19 +01001009 f_perform_lu();
Harald Welte45164da2018-01-24 12:51:27 +01001010
1011 var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
Harald Welte6ed6bf92018-01-24 21:09:15 +01001012 var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_VBS, mi));
Harald Welte45164da2018-01-24 12:51:27 +01001013 f_bssap_compl_l3(l3_info);
1014 BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ(int2oct(32,1))));
Harald Welte1ddc7162018-01-27 14:25:46 +01001015 f_expect_clear();
Harald Welte45164da2018-01-24 12:51:27 +01001016}
1017testcase TC_cm_serv_req_vbs_reject() runs on MTC_CT {
1018 var BSC_ConnHdlr vc_conn;
1019 f_init();
1020
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +01001021 vc_conn := f_start_handler(refers(f_tc_cm_serv_req_vbs_reject), 20);
Harald Welte45164da2018-01-24 12:51:27 +01001022 vc_conn.done;
1023}
1024
1025/* CM Service Request for LCS -> reject */
1026private function f_tc_cm_serv_req_lcs_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +01001027 f_init_handler(pars);
Harald Welte45164da2018-01-24 12:51:27 +01001028
1029 /* First perform location update to ensure subscriber is known */
Neels Hofmeyrc1f105a2018-03-01 20:00:19 +01001030 f_perform_lu();
Harald Welte45164da2018-01-24 12:51:27 +01001031
1032 var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
Harald Welte6ed6bf92018-01-24 21:09:15 +01001033 var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_LCS, mi));
Harald Welte45164da2018-01-24 12:51:27 +01001034 f_bssap_compl_l3(l3_info);
1035 BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_REJ(int2oct(32,1))));
Harald Welte1ddc7162018-01-27 14:25:46 +01001036 f_expect_clear();
Harald Welte45164da2018-01-24 12:51:27 +01001037}
1038testcase TC_cm_serv_req_lcs_reject() runs on MTC_CT {
1039 var BSC_ConnHdlr vc_conn;
1040 f_init();
1041
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +01001042 vc_conn := f_start_handler(refers(f_tc_cm_serv_req_lcs_reject), 21);
Harald Welte45164da2018-01-24 12:51:27 +01001043 vc_conn.done;
1044}
1045
Harald Welte0195ab12018-01-24 21:50:20 +01001046/* CM Re-Establishment Request */
1047private function f_tc_cm_reest_req_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +01001048 f_init_handler(pars);
Harald Welte0195ab12018-01-24 21:50:20 +01001049
1050 /* First perform location update to ensure subscriber is known */
Neels Hofmeyrc1f105a2018-03-01 20:00:19 +01001051 f_perform_lu();
Harald Welte0195ab12018-01-24 21:50:20 +01001052
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 Welte1ddc7162018-01-27 14:25:46 +01001057 f_expect_clear();
Harald Welte0195ab12018-01-24 21:50:20 +01001058}
1059testcase TC_cm_reest_req_reject() runs on MTC_CT {
1060 var BSC_ConnHdlr vc_conn;
1061 f_init();
Harald Welte0195ab12018-01-24 21:50:20 +01001062
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +01001063 vc_conn := f_start_handler(refers(f_tc_cm_reest_req_reject), 22);
Harald Welte0195ab12018-01-24 21:50:20 +01001064 vc_conn.done;
1065}
1066
Harald Weltec638f4d2018-01-24 22:00:36 +01001067/* Test LU (with authentication enabled), with wrong response from MS */
1068private function f_tc_lu_auth_2G_fail(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +01001069 f_init_handler(pars);
Harald Weltec638f4d2018-01-24 22:00:36 +01001070
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 Welte1ddc7162018-01-27 14:25:46 +01001096 f_expect_clear();
Harald Weltec638f4d2018-01-24 22:00:36 +01001097}
1098testcase 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 Weltec638f4d2018-01-24 22:00:36 +01001102
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +01001103 vc_conn := f_start_handler(refers(f_tc_lu_auth_2G_fail), 23);
Harald Weltec638f4d2018-01-24 22:00:36 +01001104 vc_conn.done;
1105}
1106
Harald Weltede371492018-01-27 23:44:41 +01001107/* A5/1 + A5/3 permitted on network side, and MS capable to do it */
Harald Welte16114282018-01-24 22:41:21 +01001108private function f_tc_lu_imsi_auth_tmsi_encr_13_13(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltede371492018-01-27 23:44:41 +01001109 pars.net.expect_auth := true;
1110 pars.net.expect_ciph := true;
Harald Weltea10db902018-01-27 12:44:49 +01001111 f_init_handler(pars);
Neels Hofmeyrc1f105a2018-03-01 20:00:19 +01001112 f_perform_lu();
Harald Welte16114282018-01-24 22:41:21 +01001113}
1114testcase 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 Welte16114282018-01-24 22:41:21 +01001118 f_vty_config(MSCVTY, "network", "encryption a5 1 3");
1119
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +01001120 vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_13_13), 24);
Harald Welte16114282018-01-24 22:41:21 +01001121 vc_conn.done;
1122}
1123
Harald Welte1af6ea82018-01-25 18:33:15 +01001124/* Test Complete L3 without payload */
1125private function f_tc_cl3_no_payload(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +01001126 f_init_handler(pars);
Harald Welte1af6ea82018-01-25 18:33:15 +01001127
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 Weltef466eb42018-01-27 14:26:54 +01001132 timer T := 5.0;
1133 T.start;
Harald Welte1af6ea82018-01-25 18:33:15 +01001134 alt {
1135 [] BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {}
1136 /* Expect LU REJECT with Cause == Illegal MS */
Harald Weltebdb3c452018-03-18 22:43:06 +01001137 [] BSSAP.receive(tr_PDU_DTAP_MT(?)) { repeat; }
1138 [] BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_CONF_IND) { repeat; }
Harald Welte5946b332018-03-18 23:32:21 +01001139 [] as_clear_cmd_compl_disc();
Harald Weltef466eb42018-01-27 14:26:54 +01001140 [] T.timeout {
Daniel Willmann90829d62018-02-15 17:45:14 +01001141 setverdict(fail, "Timeout waiting for ClearCommand or SCCP Release");
Daniel Willmannafce8662018-07-06 23:11:32 +02001142 mtc.stop;
Harald Weltef466eb42018-01-27 14:26:54 +01001143 }
Harald Welte1af6ea82018-01-25 18:33:15 +01001144 }
1145 setverdict(pass);
1146}
1147testcase TC_cl3_no_payload() runs on MTC_CT {
1148 var BSC_ConnHdlr vc_conn;
1149 f_init();
1150
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +01001151 vc_conn := f_start_handler(refers(f_tc_cl3_no_payload), 25);
Harald Welte1af6ea82018-01-25 18:33:15 +01001152 vc_conn.done;
1153}
1154
1155/* Test Complete L3 with random payload */
1156private function f_tc_cl3_rnd_payload(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +01001157 f_init_handler(pars);
Harald Welte1af6ea82018-01-25 18:33:15 +01001158
Daniel Willmannaa14a382018-07-26 08:29:45 +02001159 /* 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 Welte1af6ea82018-01-25 18:33:15 +01001164 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 Weltef466eb42018-01-27 14:26:54 +01001170 timer T := 5.0;
1171 T.start;
Harald Welte1af6ea82018-01-25 18:33:15 +01001172 alt {
1173 /* Immediate disconnect */
1174 [] BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {}
Harald Welte1af6ea82018-01-25 18:33:15 +01001175 [] BSSAP.receive(tr_PDU_DTAP_MT(?)) { repeat; }
Harald Weltebdb3c452018-03-18 22:43:06 +01001176 [] BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_CONF_IND) { repeat; }
Harald Welte5946b332018-03-18 23:32:21 +01001177 [] as_clear_cmd_compl_disc();
Harald Weltef466eb42018-01-27 14:26:54 +01001178 [] T.timeout {
Daniel Willmann90829d62018-02-15 17:45:14 +01001179 setverdict(fail, "Timeout waiting for ClearCommand or SCCP Release");
Daniel Willmannafce8662018-07-06 23:11:32 +02001180 mtc.stop;
Harald Weltef466eb42018-01-27 14:26:54 +01001181 }
Harald Welte1af6ea82018-01-25 18:33:15 +01001182 }
1183 setverdict(pass);
1184}
1185testcase TC_cl3_rnd_payload() runs on MTC_CT {
1186 var BSC_ConnHdlr vc_conn;
1187 f_init();
1188
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +01001189 vc_conn := f_start_handler(refers(f_tc_cl3_rnd_payload), 26);
Harald Welte1af6ea82018-01-25 18:33:15 +01001190 vc_conn.done;
1191}
1192
Harald Welte116e4332018-01-26 22:17:48 +01001193/* Test Complete L3 with random payload */
1194private function f_tc_establish_and_nothing(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +01001195 f_init_handler(pars);
Harald Welte116e4332018-01-26 22:17:48 +01001196
Neels Hofmeyrc1f105a2018-03-01 20:00:19 +01001197 f_perform_lu();
Harald Welte116e4332018-01-26 22:17:48 +01001198
Harald Welteb9e86fa2018-04-09 18:18:31 +02001199 f_establish_fully();
Daniel Willmann898a7e02018-05-17 12:16:16 +02001200 f_expect_clear(10.0);
Harald Welte116e4332018-01-26 22:17:48 +01001201}
1202testcase TC_establish_and_nothing() runs on MTC_CT {
1203 var BSC_ConnHdlr vc_conn;
1204 f_init();
1205
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +01001206 vc_conn := f_start_handler(refers(f_tc_establish_and_nothing), 27);
Harald Welte116e4332018-01-26 22:17:48 +01001207 vc_conn.done;
1208}
1209
Harald Welte12510c52018-01-26 22:26:24 +01001210/* Test MO Call SETUP with no response from MNCC */
1211private function f_tc_mo_setup_and_nothing(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Philipp Maier109e6aa2018-10-17 10:53:32 +02001212 f_init_handler(pars, 190.0);
Harald Weltea10db902018-01-27 12:44:49 +01001213
Harald Welte12510c52018-01-26 22:26:24 +01001214 var CallParameters cpars := valueof(t_CallParams('12345'H, 0));
1215
Neels Hofmeyrc1f105a2018-03-01 20:00:19 +01001216 f_perform_lu();
Harald Welte12510c52018-01-26 22:26:24 +01001217
Harald Welteb9e86fa2018-04-09 18:18:31 +02001218 f_establish_fully();
Harald Welte12510c52018-01-26 22:26:24 +01001219 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 Maier109e6aa2018-10-17 10:53:32 +02001224 f_expect_clear(185.0);
Harald Welte12510c52018-01-26 22:26:24 +01001225}
1226testcase TC_mo_setup_and_nothing() runs on MTC_CT {
1227 var BSC_ConnHdlr vc_conn;
1228 f_init();
1229
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +01001230 vc_conn := f_start_handler(refers(f_tc_mo_setup_and_nothing), 28);
Harald Welte12510c52018-01-26 22:26:24 +01001231 vc_conn.done;
1232}
1233
Harald Welte3ab88002018-01-26 22:37:25 +01001234/* Test MO Call with no response to RAN-side CRCX */
1235private function f_tc_mo_crcx_ran_timeout(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +01001236 f_init_handler(pars);
Harald Welte3ab88002018-01-26 22:37:25 +01001237 var CallParameters cpars := valueof(t_CallParams('12345'H, 0));
1238 var MNCC_PDU mncc;
1239 var MgcpCommand mgcp_cmd;
1240
Neels Hofmeyrc1f105a2018-03-01 20:00:19 +01001241 f_perform_lu();
Harald Welte3ab88002018-01-26 22:37:25 +01001242
Harald Welteb9e86fa2018-04-09 18:18:31 +02001243 f_establish_fully();
Harald Welte3ab88002018-01-26 22:37:25 +01001244 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 Welte1852a842018-01-26 22:53:36 +01001254 cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd);
1255 cpars.mgcp_ep := mgcp_cmd.line.ep;
Harald Welte3ab88002018-01-26 22:37:25 +01001256 /* never respond to this */
1257
Philipp Maier8e58f592018-03-14 11:10:56 +01001258 /* 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 Welte1ddc7162018-01-27 14:25:46 +01001263 f_expect_clear(30.0);
Harald Welte3ab88002018-01-26 22:37:25 +01001264}
1265testcase TC_mo_crcx_ran_timeout() runs on MTC_CT {
1266 var BSC_ConnHdlr vc_conn;
1267 f_init();
1268
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +01001269 vc_conn := f_start_handler(refers(f_tc_mo_crcx_ran_timeout), 29);
Harald Welte3ab88002018-01-26 22:37:25 +01001270 vc_conn.done;
1271}
1272
Harald Welte0cc82d92018-01-26 22:52:34 +01001273/* Test MO Call with reject to RAN-side CRCX */
1274private function f_tc_mo_crcx_ran_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +01001275 f_init_handler(pars);
Harald Welte0cc82d92018-01-26 22:52:34 +01001276 var CallParameters cpars := valueof(t_CallParams('12345'H, 0));
1277 var MNCC_PDU mncc;
1278 var MgcpCommand mgcp_cmd;
1279
Neels Hofmeyrc1f105a2018-03-01 20:00:19 +01001280 f_perform_lu();
Harald Welte0cc82d92018-01-26 22:52:34 +01001281
Harald Welteb9e86fa2018-04-09 18:18:31 +02001282 f_establish_fully();
Harald Welte0cc82d92018-01-26 22:52:34 +01001283 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 Maierf1e02bb2018-03-15 16:30:00 +01001293
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 Welte0cc82d92018-01-26 22:52:34 +01001303 cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd);
Philipp Maierf1e02bb2018-03-15 16:30:00 +01001304
Harald Welte0cc82d92018-01-26 22:52:34 +01001305 /* 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 Welte0cc82d92018-01-26 22:52:34 +01001312 sdp := omit
1313 }
Philipp Maierf1e02bb2018-03-15 16:30:00 +01001314 var MgcpParameter mgcp_rsp_param := {
1315 code := "Z",
1316 val := cpars.mgcp_ep
1317 };
1318 mgcp_rsp.params[0] := mgcp_rsp_param;
Harald Welte0cc82d92018-01-26 22:52:34 +01001319 MGCP.send(mgcp_rsp);
1320
1321 timer T := 30.0;
1322 T.start;
1323 alt {
Daniel Willmannafce8662018-07-06 23:11:32 +02001324 [] T.timeout {
1325 setverdict(fail, "Timeout waiting for channel release");
1326 mtc.stop;
1327 }
Daniel Willmann5868e622018-02-15 17:42:59 +01001328 [] 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 Welte0cc82d92018-01-26 22:52:34 +01001332 [] MNCC.receive { repeat; }
1333 [] GSUP.receive { repeat; }
Philipp Maierc6e06f72018-04-11 18:12:23 +02001334 /* 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 Willmannafce8662018-07-06 23:11:32 +02001339 [] MGCP.receive {
1340 setverdict(fail, "Unexpected MGCP message");
1341 mtc.stop;
1342 }
Harald Welte5946b332018-03-18 23:32:21 +01001343 [] as_clear_cmd_compl_disc();
Harald Welte0cc82d92018-01-26 22:52:34 +01001344 }
1345}
1346testcase TC_mo_crcx_ran_reject() runs on MTC_CT {
1347 var BSC_ConnHdlr vc_conn;
1348 f_init();
1349
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +01001350 vc_conn := f_start_handler(refers(f_tc_mo_crcx_ran_reject), 30);
Harald Welte0cc82d92018-01-26 22:52:34 +01001351 vc_conn.done;
1352}
1353
Harald Welte3ab88002018-01-26 22:37:25 +01001354
Harald Welte812f7a42018-01-27 00:49:18 +01001355/* helper function to start a MT call: MNCC SETUP; Paging; DChan est.; DTAP SETUP */
1356private 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 Hofmeyrc1f105a2018-03-01 20:00:19 +01001361 f_perform_lu();
Harald Welte812f7a42018-01-27 00:49:18 +01001362 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 Welteb9e86fa2018-04-09 18:18:31 +02001377 f_establish_fully(EST_TYPE_PAG_RESP);
Harald Welte812f7a42018-01-27 00:49:18 +01001378
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 */
1386private function f_tc_mt_crcx_ran_reject(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +01001387 f_init_handler(pars);
Harald Welte812f7a42018-01-27 00:49:18 +01001388 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 Maierf1e02bb2018-03-15 16:30:00 +01001401
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 Welte812f7a42018-01-27 00:49:18 +01001411 /* 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 Welte812f7a42018-01-27 00:49:18 +01001418 sdp := omit
1419 }
Philipp Maierf1e02bb2018-03-15 16:30:00 +01001420 var MgcpParameter mgcp_rsp_param := {
1421 code := "Z",
1422 val := cpars.mgcp_ep
1423 };
1424 mgcp_rsp.params[0] := mgcp_rsp_param;
Harald Welte812f7a42018-01-27 00:49:18 +01001425 MGCP.send(mgcp_rsp);
1426
1427 timer T := 30.0;
1428 T.start;
1429 alt {
Daniel Willmannafce8662018-07-06 23:11:32 +02001430 [] T.timeout {
1431 setverdict(fail, "Timeout waiting for channel release");
1432 mtc.stop;
1433 }
Harald Welte812f7a42018-01-27 00:49:18 +01001434 [] 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 Welte5946b332018-03-18 23:32:21 +01001443 [] as_clear_cmd_compl_disc();
Harald Welte812f7a42018-01-27 00:49:18 +01001444 }
1445}
1446testcase TC_mt_crcx_ran_reject() runs on MTC_CT {
1447 var BSC_ConnHdlr vc_conn;
1448 f_init();
1449
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +01001450 vc_conn := f_start_handler(refers(f_tc_mt_crcx_ran_reject), 31);
Harald Welte812f7a42018-01-27 00:49:18 +01001451 vc_conn.done;
1452}
1453
1454
1455/* Test MT Call T310 timer */
1456private function f_tc_mt_t310(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
Harald Weltead2952e2018-01-27 14:12:46 +01001457 f_init_handler(pars, 200.0);
Harald Welte812f7a42018-01-27 00:49:18 +01001458 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 Willmannafce8662018-07-06 23:11:32 +02001477 [] T.timeout {
1478 setverdict(fail, "Timeout waiting for T310");
1479 mtc.stop;
1480 }
Harald Welte812f7a42018-01-27 00:49:18 +01001481 [] 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 Welte812f7a42018-01-27 00:49:18 +01001491 [] 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 Welte5946b332018-03-18 23:32:21 +01001496 [] as_clear_cmd_compl_disc();
Harald Welte812f7a42018-01-27 00:49:18 +01001497 }
1498}
1499testcase TC_mt_t310() runs on MTC_CT {
1500 var BSC_ConnHdlr vc_conn;
1501 f_init();
1502
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +01001503 vc_conn := f_start_handler(refers(f_tc_mt_t310), 32);
Harald Welte812f7a42018-01-27 00:49:18 +01001504 vc_conn.done;
1505}
1506
Harald Welte167458a2018-01-27 15:58:16 +01001507/* Perform successful LU + MO call, then GSUP LocationCancel. Subscriber must be denied CM SERV */
1508private 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 Willmann9b0235b2018-07-24 12:13:34 +02001514 cpars.mgcp_ep := "rtpbridge/1@mgw";
Harald Welte167458a2018-01-27 15:58:16 +01001515
1516 /* Location Update to make subscriber known */
Neels Hofmeyrc1f105a2018-03-01 20:00:19 +01001517 f_perform_lu();
Harald Welte167458a2018-01-27 15:58:16 +01001518
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 Willmannafce8662018-07-06 23:11:32 +02001528 mtc.stop;
Harald Welte167458a2018-01-27 15:58:16 +01001529 }
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 Willmannafce8662018-07-06 23:11:32 +02001540 mtc.stop;
Harald Welte167458a2018-01-27 15:58:16 +01001541 }
1542 }
1543 setverdict(pass);
1544}
1545testcase TC_gsup_cancel() runs on MTC_CT {
1546 var BSC_ConnHdlr vc_conn;
1547 f_init();
1548
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +01001549 vc_conn := f_start_handler(refers(f_tc_gsup_cancel), 33);
Harald Welte167458a2018-01-27 15:58:16 +01001550 vc_conn.done;
1551}
1552
Harald Welte9de84792018-01-28 01:06:35 +01001553/* A5/1 only permitted on network side, and MS capable to do it */
1554private 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 Hofmeyrc1f105a2018-03-01 20:00:19 +01001559 f_perform_lu();
Harald Welte9de84792018-01-28 01:06:35 +01001560}
1561testcase 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 Hofmeyre9b8eeb2018-03-01 20:29:58 +01001567 vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_1_13), 34);
Harald Welte9de84792018-01-28 01:06:35 +01001568 vc_conn.done;
1569}
1570
1571/* A5/3 only permitted on network side, and MS capable to do it */
1572private 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 Hofmeyrc1f105a2018-03-01 20:00:19 +01001577 f_perform_lu();
Harald Welte9de84792018-01-28 01:06:35 +01001578}
1579testcase 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 Hofmeyre9b8eeb2018-03-01 20:29:58 +01001585 vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_3_13), 35);
Harald Welte9de84792018-01-28 01:06:35 +01001586 vc_conn.done;
1587}
1588
1589/* A5/3 only permitted on network side, and MS with only A5/1 support */
1590private 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 Hofmeyr29b8da02018-03-01 18:09:45 +01001601 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 Welte9de84792018-01-28 01:06:35 +01001606 f_mm_auth();
1607 alt {
Daniel Willmann52918e52018-09-20 14:39:09 +02001608 [] BSSAP.receive(tr_BSSMAP_ClassmarkReq) {
1609 BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3));
1610 repeat;
1611 }
Harald Welte5946b332018-03-18 23:32:21 +01001612 [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) {
1613 f_expect_clear();
1614 }
Harald Welte9de84792018-01-28 01:06:35 +01001615 [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?,?)) {
1616 setverdict(fail, "CipherModeCommand despite no A5 intersection");
Daniel Willmannafce8662018-07-06 23:11:32 +02001617 mtc.stop;
Harald Welte9de84792018-01-28 01:06:35 +01001618 }
1619 [] BSSAP.receive {
Harald Welte458fd372018-03-21 11:26:23 +01001620 setverdict(fail, "Unknown/unexpected BSSAP received");
Daniel Willmannafce8662018-07-06 23:11:32 +02001621 mtc.stop;
Harald Welte9de84792018-01-28 01:06:35 +01001622 }
1623 }
1624 setverdict(pass);
1625}
1626testcase 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 Hofmeyr29b8da02018-03-01 18:09:45 +01001632 vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_3_1), 360);
1633 vc_conn.done;
1634}
1635testcase 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 Welte9de84792018-01-28 01:06:35 +01001645 vc_conn.done;
1646}
Neels Hofmeyr1b3c6e32018-03-01 17:52:21 +01001647testcase 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 Welte9de84792018-01-28 01:06:35 +01001660
1661/* A5/1 + A5/3 only permitted on network side, and MS with only A5/2 support */
1662private 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 Welte5946b332018-03-18 23:32:21 +01001679 [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) {
1680 f_expect_clear();
1681 }
Harald Welte9de84792018-01-28 01:06:35 +01001682 [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?,?)) {
1683 setverdict(fail, "CipherModeCommand despite no A5 intersection");
Daniel Willmannafce8662018-07-06 23:11:32 +02001684 mtc.stop;
Harald Welte9de84792018-01-28 01:06:35 +01001685 }
1686 [] BSSAP.receive {
Harald Welte458fd372018-03-21 11:26:23 +01001687 setverdict(fail, "Unknown/unexpected BSSAP received");
Daniel Willmannafce8662018-07-06 23:11:32 +02001688 mtc.stop;
Harald Welte9de84792018-01-28 01:06:35 +01001689 }
1690 }
1691 setverdict(pass);
1692}
1693testcase 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 Hofmeyre9b8eeb2018-03-01 20:29:58 +01001699 vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_13_2), 37);
Harald Welte9de84792018-01-28 01:06:35 +01001700 vc_conn.done;
1701}
1702
1703/* A5/0 + A5/1 + A5/3 only permitted on network side, and MS with only A5/2 support */
1704private 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 Hofmeyrc1f105a2018-03-01 20:00:19 +01001713 f_perform_lu();
Harald Welte9de84792018-01-28 01:06:35 +01001714}
1715testcase 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 Hofmeyre9b8eeb2018-03-01 20:29:58 +01001721 vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_013_2), 38);
Harald Welte9de84792018-01-28 01:06:35 +01001722 vc_conn.done;
1723}
1724
Harald Welte33ec09b2018-02-10 15:34:46 +01001725/* LU followed by MT call (including paging) */
1726private function f_tc_lu_and_mt_call(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
1727 f_init_handler(pars);
Stefan Sperling26d57be2018-11-12 17:03:26 +01001728 var CallParameters cpars := valueof(t_CallParams('12345'H, 0));
Harald Welte33ec09b2018-02-10 15:34:46 +01001729 cpars.bss_rtp_port := 1110;
1730 cpars.mgcp_connection_id_bss := '10004'H;
1731 cpars.mgcp_connection_id_mss := '10005'H;
1732
Philipp Maier4b2692d2018-03-14 16:37:48 +01001733 /* 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 Hofmeyrc1f105a2018-03-01 20:00:19 +01001737 f_perform_lu();
Harald Welte33ec09b2018-02-10 15:34:46 +01001738 f_mt_call(cpars);
1739}
1740testcase TC_lu_and_mt_call() runs on MTC_CT {
1741 var BSC_ConnHdlr vc_conn;
1742 f_init();
1743
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +01001744 vc_conn := f_start_handler(refers(f_tc_lu_and_mt_call), 39);
Harald Welte33ec09b2018-02-10 15:34:46 +01001745 vc_conn.done;
1746}
1747
Daniel Willmann8b084372018-02-04 13:35:26 +01001748/* Test MO Call SETUP with DTMF */
1749private 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 Hofmeyrc1f105a2018-03-01 20:00:19 +01001756 f_perform_lu();
Daniel Willmann8b084372018-02-04 13:35:26 +01001757 f_mo_seq_dtmf_dup(cpars);
1758}
1759testcase TC_mo_setup_and_dtmf_dup() runs on MTC_CT {
1760 var BSC_ConnHdlr vc_conn;
1761 f_init();
1762
Neels Hofmeyre9b8eeb2018-03-01 20:29:58 +01001763 vc_conn := f_start_handler(refers(f_tc_mo_setup_dtmf_dup), 39);
Daniel Willmann8b084372018-02-04 13:35:26 +01001764 vc_conn.done;
1765}
Harald Welte9de84792018-01-28 01:06:35 +01001766
Philipp Maier328d1662018-03-07 10:40:27 +01001767testcase 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 Willmann42d1d5b2018-08-07 15:18:41 +02001772 f_bssap_start(g_bssap[0]);
1773
Daniel Willmanne8018962018-08-21 14:18:00 +02001774 f_sleep(3.0);
1775
Philipp Maier328d1662018-03-07 10:40:27 +01001776 /* Make a blind connection attemt, to trigger the deadlock condition */
Philipp Maier75932982018-03-27 14:52:35 +02001777 BSSAP_DIRECT.send(ts_BSSAP_CONNECT_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own, 1, omit));
Philipp Maier328d1662018-03-07 10:40:27 +01001778
1779 /* Send a BSSMAP reset */
Philipp Maier75932982018-03-27 14:52:35 +02001780 BSSAP_DIRECT.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own, ts_BSSMAP_Reset(0)));
Philipp Maier328d1662018-03-07 10:40:27 +01001781 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 Maier75932982018-03-27 14:52:35 +02001790 BSSAP_DIRECT.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own, ts_BSSMAP_ResetAck));
Philipp Maier328d1662018-03-07 10:40:27 +01001791 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 Willmannafce8662018-07-06 23:11:32 +02001803 mtc.stop;
Philipp Maier328d1662018-03-07 10:40:27 +01001804 }
1805 }
1806}
Harald Welte9de84792018-01-28 01:06:35 +01001807
Philipp Maier94f3f1b2018-03-15 18:54:13 +01001808/* Test MO Call with no response to RAN-side CRCX or DTAP Release */
1809private 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 Welteb9e86fa2018-04-09 18:18:31 +02001817 f_establish_fully();
Philipp Maier94f3f1b2018-03-15 18:54:13 +01001818 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}
1838testcase 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 Welte12510c52018-01-26 22:26:24 +01001846
Philipp Maier2a98a732018-03-19 16:06:12 +01001847/* LU followed by MT call (including paging) */
1848private 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 Sperling26d57be2018-11-12 17:03:26 +01001850 var CallParameters cpars := valueof(t_CallParams('12345'H, 0));
Philipp Maier2a98a732018-03-19 16:06:12 +01001851 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}
1866testcase 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 Welte45164da2018-01-24 12:51:27 +01001885
Philipp Maier75932982018-03-27 14:52:35 +02001886/* Two BSSMAP resets from two different BSCs */
1887testcase 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 Weltef640a012018-04-14 17:49:21 +02001894/***********************************************************************
1895 * SMS Testing
1896 ***********************************************************************/
1897
Harald Weltef45efeb2018-04-09 18:19:24 +02001898/* LU followed by MO SMS */
1899private 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}
1914testcase 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
1921private function f_vty_sms_send(charstring imsi, charstring msisdn, charstring text)
1922runs 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 */
1927private 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}
1956testcase 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 Weltef640a012018-04-14 17:49:21 +02001967/* mobile originated SMS from MS/BTS/BSC side to SMPP */
1968private function f_tc_smpp_mo_sms(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
1969 var SmsParameters spars := valueof(t_SmsPars);
Harald Weltef45efeb2018-04-09 18:19:24 +02001970
Harald Weltef640a012018-04-14 17:49:21 +02001971 f_init_handler(pars);
Harald Weltef45efeb2018-04-09 18:19:24 +02001972
Harald Weltef640a012018-04-14 17:49:21 +02001973 /* 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}
2017testcase 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 */
2027function 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 Willmannafce8662018-07-06 23:11:32 +02002038 mtc.stop;
Harald Weltef640a012018-04-14 17:49:21 +02002039}
2040/* convert GSM L3 NPI to SMPP_NPI enum */
2041function 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 Willmannafce8662018-07-06 23:11:32 +02002053 mtc.stop;
Harald Weltef640a012018-04-14 17:49:21 +02002054}
2055
2056/* build a SMPP_SM from SmsParameters */
2057function f_mt_sm_from_spars(SmsParameters spars)
2058runs 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 */
2084private 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 */
2113private 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}
2140testcase 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 Yanitskiy7d1f9182018-05-28 16:21:42 +07002147/***********************************************************************
2148 * USSD Testing
2149 ***********************************************************************/
2150
Vadim Yanitskiyce8cc372018-06-21 01:46:33 +07002151private altstep as_unexp_gsup_or_bssap_msg()
2152runs 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
2163private function f_expect_gsup_msg(template GSUP_PDU msg)
2164runs 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
2178private function f_expect_mt_dtap_msg(template PDU_ML3_NW_MS msg)
2179runs 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 Yanitskiy2a978b92018-06-19 17:51:20 +07002193/* LU followed by MO USSD request */
2194private function f_tc_lu_and_mo_ussd_single_request(charstring id, BSC_ConnHdlrPars pars)
Vadim Yanitskiy7d1f9182018-05-28 16:21:42 +07002195runs 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 Yanitskiy747689e2018-06-19 00:14:28 +07002204 /* 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 Yanitskiy7d1f9182018-05-28 16:21:42 +07002219 /* 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 Yanitskiy747689e2018-06-19 00:14:28 +07002223 facility := valueof(facility_req)
Vadim Yanitskiy7d1f9182018-05-28 16:21:42 +07002224 );
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 Yanitskiy747689e2018-06-19 00:14:28 +07002230 facility := valueof(facility_rsp)
Vadim Yanitskiy7d1f9182018-05-28 16:21:42 +07002231 );
2232
Vadim Yanitskiy747689e2018-06-19 00:14:28 +07002233 /* 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 Yanitskiy7d1f9182018-05-28 16:21:42 +07002244 BSSAP.send(ts_PDU_DTAP_MO(ussd_req));
Vadim Yanitskiy747689e2018-06-19 00:14:28 +07002245 /* 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 Yanitskiy7d1f9182018-05-28 16:21:42 +07002260
2261 f_expect_clear();
2262}
Vadim Yanitskiy2a978b92018-06-19 17:51:20 +07002263testcase TC_lu_and_mo_ussd_single_request() runs on MTC_CT {
Vadim Yanitskiy7d1f9182018-05-28 16:21:42 +07002264 var BSC_ConnHdlr vc_conn;
2265 f_init();
Vadim Yanitskiy2a978b92018-06-19 17:51:20 +07002266 vc_conn := f_start_handler(refers(f_tc_lu_and_mo_ussd_single_request), 46);
Vadim Yanitskiy7d1f9182018-05-28 16:21:42 +07002267 vc_conn.done;
2268}
2269
Vadim Yanitskiy13e4a272018-06-19 18:24:31 +07002270/* LU followed by MT USSD notification */
2271private function f_tc_lu_and_mt_ussd_notification(charstring id, BSC_ConnHdlrPars pars)
2272runs 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}
2366testcase 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 Yanitskiy2a978b92018-06-19 17:51:20 +07002373/* LU followed by MT call and MO USSD request during this call */
2374private function f_tc_lu_and_mo_ussd_during_mt_call(charstring id, BSC_ConnHdlrPars pars)
Vadim Yanitskiy0aaf48d2018-06-06 07:02:47 +07002375runs 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 Yanitskiy747689e2018-06-19 00:14:28 +07002394 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 Yanitskiy0aaf48d2018-06-06 07:02:47 +07002404 /* 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 Yanitskiy747689e2018-06-19 00:14:28 +07002408 facility := valueof(facility_req)
Vadim Yanitskiy0aaf48d2018-06-06 07:02:47 +07002409 );
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 Yanitskiy747689e2018-06-19 00:14:28 +07002415 facility := valueof(facility_rsp)
Vadim Yanitskiy0aaf48d2018-06-06 07:02:47 +07002416 );
2417
Vadim Yanitskiy747689e2018-06-19 00:14:28 +07002418 /* 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 Yanitskiy0aaf48d2018-06-06 07:02:47 +07002429 BSSAP.send(ts_PDU_DTAP_MO(ussd_req));
Vadim Yanitskiy747689e2018-06-19 00:14:28 +07002430 /* 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 Yanitskiy0aaf48d2018-06-06 07:02:47 +07002445
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 Yanitskiy2a978b92018-06-19 17:51:20 +07002452testcase TC_lu_and_mo_ussd_during_mt_call() runs on MTC_CT {
Vadim Yanitskiy0aaf48d2018-06-06 07:02:47 +07002453 var BSC_ConnHdlr vc_conn;
2454 f_init();
Vadim Yanitskiy2a978b92018-06-19 17:51:20 +07002455 vc_conn := f_start_handler(refers(f_tc_lu_and_mo_ussd_during_mt_call), 48);
Vadim Yanitskiy0aaf48d2018-06-06 07:02:47 +07002456 vc_conn.done;
2457}
2458
Neels Hofmeyr692c9ee2018-04-10 02:07:13 +02002459/* BSSMAP Clear Request in the middle of a call, see OS#3062 */
2460private 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}
2493testcase 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 Yanitskiy13e4a272018-06-19 18:24:31 +07002501/* LU followed by MT call and MT USSD request during this call */
2502private function f_tc_lu_and_mt_ussd_during_mt_call(charstring id, BSC_ConnHdlrPars pars)
2503runs 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}
2596testcase 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 Yanitskiy2daf52d2018-06-21 04:19:58 +07002603/* LU followed by MO USSD request and MO Release during transaction */
2604private function f_tc_lu_and_mo_ussd_mo_release(charstring id, BSC_ConnHdlrPars pars)
2605runs 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}
2693testcase 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 Yanitskiy0e392dd2018-11-29 00:47:54 +07002700/* LU followed by MO USSD request and MT Release due to timeout */
2701private function f_tc_lu_and_ss_session_timeout(charstring id, BSC_ConnHdlrPars pars)
2702runs 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}
2763testcase TC_lu_and_ss_session_timeout() runs on MTC_CT {
2764 var BSC_ConnHdlr vc_conn;
2765 f_init();
Vadim Yanitskiy36d28dd2018-12-03 02:45:45 +07002766 f_vty_config(MSCVTY, "msc", "ncss guard-timeout 3");
Vadim Yanitskiy0e392dd2018-11-29 00:47:54 +07002767 vc_conn := f_start_handler(refers(f_tc_lu_and_ss_session_timeout), 51);
2768 vc_conn.done;
Vadim Yanitskiy36d28dd2018-12-03 02:45:45 +07002769 f_vty_config(MSCVTY, "msc", "ncss guard-timeout 0");
Vadim Yanitskiy0e392dd2018-11-29 00:47:54 +07002770}
2771
Stefan Sperling89eb1f32018-12-17 15:06:20 +01002772/* A5/1 only permitted on network side; attempt an invalid CIPHER MODE COMPLETE with A5/3 which MSC should reject. */
2773private 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 }
2818}
2819
2820testcase TC_cipher_complete_with_invalid_cipher() runs on MTC_CT {
2821 var BSC_ConnHdlr vc_conn;
2822 f_init();
2823 f_vty_config(MSCVTY, "network", "encryption a5 1");
2824
2825 vc_conn := f_start_handler(refers(f_tc_cipher_complete_with_invalid_cipher), 52);
2826 vc_conn.done;
2827}
2828
Harald Weltef640a012018-04-14 17:49:21 +02002829/* TODO (SMS):
2830 * different user data lengths
2831 * SMPP transaction mode with unsuccessful delivery
2832 * queued MT-SMS with no paging response + later delivery
2833 * different data coding schemes
2834 * multi-part SMS
2835 * user-data headers
2836 * TP-PID for SMS to SIM
2837 * behavior if SMS memory is full + RP-SMMA
2838 * delivery reports
2839 * SMPP osmocom extensions
2840 * more-messages-to-send
2841 * SMS during ongoing call (SACCH/SAPI3)
2842 */
2843
2844/* TODO (General):
Harald Welteba7b6d92018-01-23 21:32:34 +01002845 * continue to send repeated MO signalling messages to keep channel open: does MSC tmeout?
2846 * malformed messages (missing IE, invalid message type): properly rejected?
2847 * MT call while LU or is ongoing: Do we use existing lchan or page while lchan active?
2848 * 3G/2G auth permutations
2849 * encryption algorithms vs. classmark vs. vty config
Harald Welteba7b6d92018-01-23 21:32:34 +01002850 * send new transaction after/during clear (like SMS, ...)
Harald Welte45164da2018-01-24 12:51:27 +01002851 * too long L3 INFO in DTAP
2852 * too long / padded BSSAP
2853 * too long / short TLV values
Harald Welteba7b6d92018-01-23 21:32:34 +01002854 */
Harald Weltef6dd64d2017-11-19 12:09:51 +01002855
2856
2857control {
Philipp Maier328d1662018-03-07 10:40:27 +01002858 execute( TC_cr_before_reset() );
Harald Weltea49e36e2018-01-21 19:29:33 +01002859 execute( TC_lu_imsi_noauth_tmsi() );
Harald Welted2328a22018-01-27 14:27:16 +01002860 execute( TC_lu_imsi_noauth_notmsi() );
Harald Weltea49e36e2018-01-21 19:29:33 +01002861 execute( TC_lu_imsi_reject() );
2862 execute( TC_lu_imsi_timeout_gsup() );
Harald Welted2328a22018-01-27 14:27:16 +01002863 execute( TC_lu_imsi_auth_tmsi() );
2864 execute( TC_cmserv_imsi_unknown() );
Harald Welte2bb825f2018-01-22 11:31:18 +01002865 execute( TC_lu_and_mo_call() );
Harald Welte071ed732018-01-23 19:53:52 +01002866 execute( TC_lu_auth_sai_timeout() );
2867 execute( TC_lu_auth_sai_err() );
Harald Weltee1a2f3c2018-01-24 17:28:48 +01002868 execute( TC_lu_clear_request() );
2869 execute( TC_lu_disconnect() );
2870 execute( TC_lu_by_imei() );
2871 execute( TC_lu_by_tmsi_noauth_unknown() );
2872 execute( TC_imsi_detach_by_imsi() );
2873 execute( TC_imsi_detach_by_tmsi() );
2874 execute( TC_imsi_detach_by_imei() );
2875 execute( TC_emerg_call_imei_reject() );
2876 execute( TC_emerg_call_imsi() );
2877 execute( TC_cm_serv_req_vgcs_reject() );
2878 execute( TC_cm_serv_req_vbs_reject() );
2879 execute( TC_cm_serv_req_lcs_reject() );
Harald Welte0195ab12018-01-24 21:50:20 +01002880 execute( TC_cm_reest_req_reject() );
Harald Welte1af6ea82018-01-25 18:33:15 +01002881 execute( TC_lu_auth_2G_fail() );
2882 execute( TC_lu_imsi_auth_tmsi_encr_13_13() );
2883 execute( TC_cl3_no_payload() );
2884 execute( TC_cl3_rnd_payload() );
Harald Welte1852a842018-01-26 22:53:36 +01002885 execute( TC_establish_and_nothing() );
2886 execute( TC_mo_setup_and_nothing() );
2887 execute( TC_mo_crcx_ran_timeout() );
2888 execute( TC_mo_crcx_ran_reject() );
Harald Welted2328a22018-01-27 14:27:16 +01002889 execute( TC_mt_crcx_ran_reject() );
Daniel Willmann8b084372018-02-04 13:35:26 +01002890 execute( TC_mo_setup_and_dtmf_dup() );
Harald Welteaa54cf82018-01-30 08:15:32 +01002891 //execute( TC_mt_t310() );
Harald Welte167458a2018-01-27 15:58:16 +01002892 execute( TC_gsup_cancel() );
Harald Welte9de84792018-01-28 01:06:35 +01002893 execute( TC_lu_imsi_auth_tmsi_encr_1_13() );
2894 execute( TC_lu_imsi_auth_tmsi_encr_3_13() );
2895 execute( TC_lu_imsi_auth_tmsi_encr_3_1() );
Neels Hofmeyr29b8da02018-03-01 18:09:45 +01002896 execute( TC_lu_imsi_auth_tmsi_encr_3_1_no_cm() );
Harald Welte9de84792018-01-28 01:06:35 +01002897 execute( TC_lu_imsi_auth_tmsi_encr_13_2() );
2898 execute( TC_lu_imsi_auth_tmsi_encr_013_2() );
Philipp Maier94f3f1b2018-03-15 18:54:13 +01002899 execute( TC_mo_release_timeout() );
Philipp Maier2a98a732018-03-19 16:06:12 +01002900 execute( TC_lu_and_mt_call_no_dlcx_resp() );
Philipp Maier75932982018-03-27 14:52:35 +02002901 execute( TC_reset_two() );
Harald Welte33ec09b2018-02-10 15:34:46 +01002902
2903 execute( TC_lu_and_mt_call() );
2904
Harald Weltef45efeb2018-04-09 18:19:24 +02002905 execute( TC_lu_and_mo_sms() );
2906 execute( TC_lu_and_mt_sms() );
Harald Weltef640a012018-04-14 17:49:21 +02002907 execute( TC_smpp_mo_sms() );
2908 execute( TC_smpp_mt_sms() );
Harald Weltef45efeb2018-04-09 18:19:24 +02002909
Vadim Yanitskiy2a978b92018-06-19 17:51:20 +07002910 execute( TC_lu_and_mo_ussd_single_request() );
Vadim Yanitskiy13e4a272018-06-19 18:24:31 +07002911 execute( TC_lu_and_mt_ussd_notification() );
Vadim Yanitskiy2a978b92018-06-19 17:51:20 +07002912 execute( TC_lu_and_mo_ussd_during_mt_call() );
Vadim Yanitskiy13e4a272018-06-19 18:24:31 +07002913 execute( TC_lu_and_mt_ussd_during_mt_call() );
Vadim Yanitskiy2daf52d2018-06-21 04:19:58 +07002914 execute( TC_lu_and_mo_ussd_mo_release() );
Vadim Yanitskiy0e392dd2018-11-29 00:47:54 +07002915 execute( TC_lu_and_ss_session_timeout() );
Vadim Yanitskiy7d1f9182018-05-28 16:21:42 +07002916
Stefan Sperling89eb1f32018-12-17 15:06:20 +01002917 execute( TC_cipher_complete_with_invalid_cipher() );
2918
Neels Hofmeyr1b3c6e32018-03-01 17:52:21 +01002919 /* Run this last: at the time of writing this test crashes the MSC */
2920 execute( TC_lu_imsi_auth_tmsi_encr_3_1_log_msc_debug() );
Neels Hofmeyr692c9ee2018-04-10 02:07:13 +02002921 execute( TC_mo_cc_bssmap_clear() );
Harald Weltef6dd64d2017-11-19 12:09:51 +01002922}
2923
2924
2925}