blob: 0846c04d4239a9062efa1490b5db7286a569b75e [file] [log] [blame]
Harald Welte34b5a952019-05-27 11:54:11 +02001/* BSC Connection Handler of MSC test suite in TTCN-3
2 * (C) 2018-2019 Harald Welte <laforge@gnumonks.org>
3 * (C) 2018-2019 sysmocom - s.f.m.c. GmbH
4 * (C) 2018 Vadim Yanitskiy <axilirator@gmail.com>
5 * All rights reserved.
6 *
7 * Released under the terms of GNU General Public License, Version 2 or
8 * (at your option) any later version.
9 *
10 * SPDX-License-Identifier: GPL-2.0-or-later
11 */
12
Harald Weltea49e36e2018-01-21 19:29:33 +010013module BSC_ConnectionHandler {
14
15import from General_Types all;
16import from Osmocom_Types all;
Harald Welteb71901a2018-01-26 19:16:05 +010017import from Native_Functions all;
Harald Weltea49e36e2018-01-21 19:29:33 +010018import from GSM_Types all;
Harald Welteb71901a2018-01-26 19:16:05 +010019import from IPL4asp_Types all;
Harald Weltea49e36e2018-01-21 19:29:33 +010020import from SCCPasp_Types all;
21import from BSSAP_Types all;
Harald Welte6811d102019-04-14 22:23:14 +020022import from RAN_Emulation all;
Harald Weltea49e36e2018-01-21 19:29:33 +010023import from BSSMAP_Templates all;
24
Harald Welte9b751a62019-04-14 17:39:29 +020025import from RANAP_Constants all;
26import from RANAP_IEs all;
27import from RANAP_PDU_Contents all;
28import from RANAP_PDU_Descriptions all;
29import from RANAP_Templates all;
30
Harald Weltea49e36e2018-01-21 19:29:33 +010031import from GSUP_Types all;
32import from GSUP_Emulation all;
33
34import from MNCC_Types all;
35import from MNCC_Emulation all;
36
Harald Welte4aa970c2018-01-26 10:38:09 +010037import from MGCP_Types all;
38import from MGCP_Emulation all;
Harald Welteb71901a2018-01-26 19:16:05 +010039import from MGCP_Templates all;
40import from SDP_Types all;
Harald Welte4aa970c2018-01-26 10:38:09 +010041
Harald Weltea49e36e2018-01-21 19:29:33 +010042import from MobileL3_Types all;
43import from MobileL3_CommonIE_Types all;
44import from MobileL3_MM_Types all;
Harald Welteb71901a2018-01-26 19:16:05 +010045import from MobileL3_CC_Types all;
Harald Weltef45efeb2018-04-09 18:19:24 +020046import from MobileL3_SMS_Types all;
Harald Weltea49e36e2018-01-21 19:29:33 +010047import from L3_Templates all;
Harald Welte158a7ca2018-02-16 18:11:31 +010048import from L3_Common all;
Harald Weltea49e36e2018-01-21 19:29:33 +010049
Harald Weltef640a012018-04-14 17:49:21 +020050import from SMPP_Emulation all;
51
Philipp Maieraeb29a82018-11-08 17:40:53 +010052import from IPA_Emulation all;
53import from Osmocom_CTRL_Functions all;
54import from Osmocom_CTRL_Types all;
55import from Osmocom_CTRL_Adapter all;
56
Philipp Maierc39a9d82018-11-09 11:21:08 +010057import from TELNETasp_PortType all;
58import from Osmocom_VTY_Functions all;
59
Harald Welte4263c522018-12-06 11:56:27 +010060import from SGsAP_Emulation all;
61
Harald Weltea49e36e2018-01-21 19:29:33 +010062/* this component represents a single subscriber connection */
Harald Welte6811d102019-04-14 22:23:14 +020063type component BSC_ConnHdlr extends RAN_ConnHdlr, MNCC_ConnHdlr, GSUP_ConnHdlr, MGCP_ConnHdlr, SMPP_ConnHdlr, CTRL_Adapter_CT, SGsAP_ConnHdlr {
Harald Weltea49e36e2018-01-21 19:29:33 +010064 var BSC_ConnHdlrPars g_pars;
Harald Weltea10db902018-01-27 12:44:49 +010065 timer g_Tguard := 60.0;
Philipp Maierc39a9d82018-11-09 11:21:08 +010066 port TELNETasp_PT MSCVTY;
Harald Weltea49e36e2018-01-21 19:29:33 +010067}
68
Harald Weltede371492018-01-27 23:44:41 +010069type record BSC_ConnHdlrNetworkPars {
70 OCT1 kc_support,
71 boolean expect_tmsi,
72 boolean expect_auth,
Oliver Smith1d118ff2019-07-03 10:57:35 +020073 boolean expect_ciph,
74 boolean expect_imei,
75 boolean expect_imei_early,
76 GSUP_IMEIResult check_imei_result,
77 boolean check_imei_error
Harald Weltede371492018-01-27 23:44:41 +010078}
79
Harald Weltea49e36e2018-01-21 19:29:33 +010080type record BSC_ConnHdlrPars {
81 SCCP_PAR_Address sccp_addr_own,
82 SCCP_PAR_Address sccp_addr_peer,
83 BSSMAP_IE_CellIdentifier cell_id,
Harald Welte256571e2018-01-24 18:47:19 +010084 hexstring imei,
Harald Weltea49e36e2018-01-21 19:29:33 +010085 hexstring imsi,
Harald Welte82600572018-01-21 20:54:08 +010086 hexstring msisdn,
Harald Welte256571e2018-01-24 18:47:19 +010087 OCT4 tmsi optional,
Harald Welte9de84792018-01-28 01:06:35 +010088 MobileStationClassmark1_V cm1,
Harald Welte82600572018-01-21 20:54:08 +010089 BSSMAP_IE_ClassmarkInformationType2 cm2,
Harald Welte16114282018-01-24 22:41:21 +010090 BSSMAP_IE_ClassmarkInformationType3 cm3 optional,
Harald Weltede371492018-01-27 23:44:41 +010091 AuthVector vec optional,
Neels Hofmeyrc1f105a2018-03-01 20:00:19 +010092 BSC_ConnHdlrNetworkPars net,
Philipp Maieraeb29a82018-11-08 17:40:53 +010093 boolean send_early_cm,
94 charstring ipa_ctrl_ip,
95 integer ipa_ctrl_port,
Philipp Maier9b690e42018-12-21 11:50:03 +010096 boolean ipa_ctrl_enable,
Philipp Maier57865482019-01-07 18:33:13 +010097 boolean mm_info,
Philipp Maierc09a1312019-04-09 16:05:26 +020098 boolean sgsap_enable,
Harald Weltef9abf8d2019-04-21 13:07:17 +020099 boolean gsup_enable,
Harald Weltec1f937a2019-04-21 21:19:23 +0200100 integer ran_idx,
Harald Welte9b751a62019-04-14 17:39:29 +0200101 boolean use_umts_aka,
Pau Espin Pedrola65697d2019-05-21 12:54:39 +0200102 boolean ran_is_geran,
103 boolean use_osmux
Harald Weltea49e36e2018-01-21 19:29:33 +0100104};
105
Harald Welte9de84792018-01-28 01:06:35 +0100106/* get a one-octet bitmaks of supported algorithms based on Classmark information */
107function f_alg_mask_from_cm(BSSMAP_IE_ClassmarkInformationType2 cm2) return OCT1 {
108 var BIT8 res := '00000001'B; /* A5/0 always supported */
109
110 if (cm2.a5_1 == '0'B) {
111 res := res or4b '00000010'B;
112 }
113 if (cm2.classmarkInformationType2_oct5.a5_2 == '1'B ) {
114 res := res or4b '00000100'B;
115 }
116 if (cm2.classmarkInformationType2_oct5.a5_3 == '1'B) {
117 res := res or4b '00001000'B;
118 }
119 /* TODO: CM3 for A5/4 and beyond */
120 return bit2oct(res);
121}
122
123/* determine the best algorithm available within the bit-mask */
124function f_best_alg_from_mask(OCT1 alg_in) return OCT1 {
125 var BIT8 alg := oct2bit(alg_in);
126 var BIT8 ordered_algs[8] := {
127 '10000000'B, '01000000'B, '00100000'B, '00010000'B,
128 '00001000'B, /* A5/3 */
129 '00000010'B, /* A5/1 */
130 '00000100'B, /* A5/2 */
131 '00000001'B /* A5/0 */ }
132 for (var integer i := 0; i < sizeof(ordered_algs); i := i+1) {
133 if (alg and4b ordered_algs[i] != '00000000'B) {
134 return bit2oct(ordered_algs[i]);
135 }
136 }
137 return '00'O;
138}
139
140/* return an integer like '1' for A5/1 based on a mask (with only one bit set */
141function f_alg_from_mask(OCT1 mask_in) return integer {
142 var BIT8 mask := oct2bit(mask_in);
143 for (var integer i := 0; i < 8; i := i+1) {
144 if (mask and4b ('00000001'B << i) != '00000000'B) {
145 return i;
146 }
147 }
148 return -1;
149}
150
Harald Weltea10db902018-01-27 12:44:49 +0100151/* altstep for the global guard timer */
152private altstep as_Tguard() runs on BSC_ConnHdlr {
153 [] g_Tguard.timeout {
Daniel Willmann90829d62018-02-15 17:45:14 +0100154 setverdict(fail, "Tguard timeout");
Daniel Willmannafce8662018-07-06 23:11:32 +0200155 mtc.stop;
Harald Weltea10db902018-01-27 12:44:49 +0100156 }
157}
158
159/* init function, called as first function in new BSC_ConnHdlr */
Harald Weltead2952e2018-01-27 14:12:46 +0100160function f_init_handler(BSC_ConnHdlrPars pars, float t_guard := 60.0) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +0100161 /* make parameters available via component variable */
162 g_pars := pars;
163 /* Start guard timer and activate it as default */
Harald Weltead2952e2018-01-27 14:12:46 +0100164 g_Tguard.start(t_guard);
Harald Weltea10db902018-01-27 12:44:49 +0100165 activate(as_Tguard());
Harald Weltef640a012018-04-14 17:49:21 +0200166 /* Route all SMPP messages for our MSISDN to us */
167 f_create_smpp_expect(hex2str(pars.msisdn));
Philipp Maier57865482019-01-07 18:33:13 +0100168
Harald Welte4263c522018-12-06 11:56:27 +0100169 /* Route all SGs message for our IMSI to us */
Philipp Maier57865482019-01-07 18:33:13 +0100170 if (g_pars.sgsap_enable == true) {
171 f_create_sgsap_expect(pars.imsi);
172 }
Philipp Maieraeb29a82018-11-08 17:40:53 +0100173
174 if (g_pars.ipa_ctrl_enable == true) {
175 f_ipa_ctrl_start(g_pars.ipa_ctrl_ip, g_pars.ipa_ctrl_port);
176 }
Philipp Maierc39a9d82018-11-09 11:21:08 +0100177
178 map(self:MSCVTY, system:MSCVTY);
179 f_vty_set_prompts(MSCVTY);
180 f_vty_transceive(MSCVTY, "enable");
Harald Weltea10db902018-01-27 12:44:49 +0100181}
182
Harald Weltea49e36e2018-01-21 19:29:33 +0100183
Harald Welte6811d102019-04-14 22:23:14 +0200184/* Callback function from general RAN_Emulation whenever a connectionless
Harald Weltea49e36e2018-01-21 19:29:33 +0100185 * BSSMAP message arrives. Canreturn a PDU_BSSAPthat should be sent in return */
186private function BscUnitdataCallback(PDU_BSSAP bssap)
Harald Welte6811d102019-04-14 22:23:14 +0200187runs on RAN_Emulation_CT return template PDU_BSSAP {
Harald Weltea49e36e2018-01-21 19:29:33 +0100188 var template PDU_BSSAP resp := omit;
189
190 log("BSSMAP_BscUnitdataCallback");
191 /* answer all RESET with RESET ACK */
Pau Espin Pedrola65697d2019-05-21 12:54:39 +0200192 if (match(bssap, tr_BSSMAP_Reset(g_ran_ops.use_osmux))){
Harald Weltea49e36e2018-01-21 19:29:33 +0100193 log("BSSMAP_BscUnitdataCallback: Responding to RESET with RESET-ACK");
Pau Espin Pedrola65697d2019-05-21 12:54:39 +0200194 resp := ts_BSSMAP_ResetAck(g_ran_ops.use_osmux);
Harald Weltea49e36e2018-01-21 19:29:33 +0100195 }
196
197 /* FIXME: Handle paging, etc. */
198 return resp;
199}
200
Harald Welte9b751a62019-04-14 17:39:29 +0200201private function RncUnitdataCallback(RANAP_PDU ranap)
202runs on RAN_Emulation_CT return template RANAP_PDU {
203 var template RANAP_PDU resp := omit;
204
205 log("RANAP_RncUnitdataCallback");
206 /* answer all RESET with RESET ACK */
Pau Espin Pedrola65697d2019-05-21 12:54:39 +0200207 if (match(ranap, tr_RANAP_Reset())) {
Harald Welte9b751a62019-04-14 17:39:29 +0200208 log("RANAP_RncUnitdataCallback: Responding to RESET with RESET-ACK");
209 var CN_DomainIndicator dom;
210 dom := ranap.initiatingMessage.value_.Reset.protocolIEs[1].value_.cN_DomainIndicator;
211 resp := ts_RANAP_ResetAck(dom);
212 }
213
214 /* FIXME: Handle paging, etc. */
215 return resp;
216}
217
218
Harald Welte6811d102019-04-14 22:23:14 +0200219const RanOps BSC_RanOps := {
Harald Weltea49e36e2018-01-21 19:29:33 +0100220 /* Create call-back for inbound connections from MSC (hand-over) */
Harald Welte6811d102019-04-14 22:23:14 +0200221 create_cb := refers(RAN_Emulation.ExpectedCreateCallback),
Harald Weltea49e36e2018-01-21 19:29:33 +0100222 unitdata_cb := refers(BscUnitdataCallback),
Harald Welte9b751a62019-04-14 17:39:29 +0200223 ranap_create_cb := refers(RAN_Emulation.RanapExpectedCreateCallback),
224 ranap_unitdata_cb := refers(RncUnitdataCallback),
225 ps_domain := false,
Harald Weltea49e36e2018-01-21 19:29:33 +0100226 decode_dtap := true,
Harald Weltea4ca4462018-02-09 00:17:14 +0100227 role_ms := true,
Harald Welte2fce7882019-04-15 11:48:05 +0200228 protocol := RAN_PROTOCOL_BSSAP,
Pau Espin Pedrolc6b78ff2019-06-06 15:58:17 +0200229 transport := BSSAP_TRANSPORT_AoIP,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200230 use_osmux := false,
Harald Weltea4ca4462018-02-09 00:17:14 +0100231 sccp_addr_local := omit,
232 sccp_addr_peer := omit
Harald Weltea49e36e2018-01-21 19:29:33 +0100233}
234
235
236private function MnccUnitdataCallback(MNCC_PDU mncc)
237runs on MNCC_Emulation_CT return template MNCC_PDU {
238 log("Ignoring MNCC", mncc);
239 return omit;
240}
241
242const MnccOps BCC_MnccOps := {
243 create_cb := refers(MNCC_Emulation.ExpectedCreateCallback),
244 unitdata_cb := refers(MnccUnitdataCallback)
245}
246
247
248
Harald Welte6811d102019-04-14 22:23:14 +0200249/* Encode 'l3' and ask RAN_Emulation to create new connection with COMPL L3 INFO */
Harald Weltea49e36e2018-01-21 19:29:33 +0100250function f_bssap_compl_l3(PDU_ML3_MS_NW l3)
251runs on BSC_ConnHdlr {
252 log("Sending COMPL L3: ", l3);
253 var octetstring l3_enc := enc_PDU_ML3_MS_NW(l3);
254 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own,
255 valueof(ts_BSSMAP_ComplL3(g_pars.cell_id, l3_enc))));
Harald Welte71b69332018-01-21 20:43:53 +0100256 alt {
Harald Welte6811d102019-04-14 22:23:14 +0200257 [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND) {}
258 [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {
Harald Welte71b69332018-01-21 20:43:53 +0100259 setverdict(fail, "DISC.ind from SCCP");
Daniel Willmannafce8662018-07-06 23:11:32 +0200260 mtc.stop;
Harald Welte71b69332018-01-21 20:43:53 +0100261 }
262 }
Harald Weltea49e36e2018-01-21 19:29:33 +0100263}
264
Harald Welte9b751a62019-04-14 17:39:29 +0200265/* generate Iu LAI from BSSAP CGI */
266private function f_IuLAI_from_BssmapCI(BSSMAP_IE_CellIdentifier ci) return LAI {
267 var LAI lai;
268 if (ischosen(ci.cellIdentification.cI_CGI)) {
269 lai.pLMNidentity := ci.cellIdentification.cI_CGI.mcc_mnc;
270 lai.lAC := ci.cellIdentification.cI_CGI.lac;
271 } else if (ischosen(ci.cellIdentification.cI_SAI)) {
272 lai.pLMNidentity := ci.cellIdentification.cI_SAI.mcc_mnc;
273 lai.lAC := ci.cellIdentification.cI_SAI.lac;
274 } else if (ischosen(ci.cellIdentification.ci_LAC_RNC_CI)) {
275 lai.pLMNidentity := ci.cellIdentification.ci_LAC_RNC_CI.mcc_mnc;
276 lai.lAC := ci.cellIdentification.ci_LAC_RNC_CI.lac;
277 } else {
278 mtc.stop;
279 }
280 lai.iE_Extensions := omit;
281 return lai;
282}
283
284/* like f_bssap_compl_l3() but for 3G */
285function f_ranap_initial_ue(PDU_ML3_MS_NW l3)
286runs on BSC_ConnHdlr {
287 log("Sending InitialUE: ", l3);
288 var octetstring l3_enc := enc_PDU_ML3_MS_NW(l3);
289 var RANAP_PDU ranap;
290 var LAI lai := f_IuLAI_from_BssmapCI(g_pars.cell_id);
291 var SAI sai := {
292 pLMNidentity := lai.pLMNidentity,
293 lAC := lai.lAC,
294 sAC := '0000'O, /* FIXME */
295 iE_Extensions := omit
296 };
297 var IuSignallingConnectionIdentifier sigc_id := int2bit(23, 24);
298 var GlobalRNC_ID grnc_id := {
299 pLMNidentity := lai.pLMNidentity,
300 rNC_ID := 2342 /* FIXME */
301 };
302
303 ranap := valueof(ts_RANAP_initialUE_CS(lai, sai, l3_enc, sigc_id, grnc_id));
304 BSSAP.send(ts_RANAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own, ranap));
305 alt {
306 [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND) {}
307 [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {
308 setverdict(fail, "DISC.ind from SCCP");
309 mtc.stop;
310 }
311 }
312}
313
Harald Weltedceacc72019-04-21 20:58:35 +0200314/* Send BSSMAP Complete L3 or RANAP Initial UE depending on 2G/3G RAN type */
315function f_cl3_or_initial_ue(PDU_ML3_MS_NW l3)
316runs on BSC_ConnHdlr {
317 if (g_pars.ran_is_geran) {
318 f_bssap_compl_l3(l3);
319 } else {
320 f_ranap_initial_ue(l3);
321 }
322}
323
Harald Welte081b19a2018-02-10 09:11:13 +0100324type enumerated EstablishType {
325 EST_TYPE_MO_CALL,
Harald Welte0bef21e2018-02-10 09:48:23 +0100326 EST_TYPE_EMERG_CALL,
Harald Weltef45efeb2018-04-09 18:19:24 +0200327 EST_TYPE_PAG_RESP,
Vadim Yanitskiy20ee5e42018-05-27 17:54:21 +0700328 EST_TYPE_MO_SMS,
329 EST_TYPE_SS_ACT
Harald Welte081b19a2018-02-10 09:11:13 +0100330};
331
Harald Weltea49e36e2018-01-21 19:29:33 +0100332/* helper function to fully establish a dedicated channel */
Harald Welteb9e86fa2018-04-09 18:18:31 +0200333function f_establish_fully(EstablishType etype := EST_TYPE_MO_CALL)
Harald Weltea49e36e2018-01-21 19:29:33 +0100334runs on BSC_ConnHdlr {
Harald Welte081b19a2018-02-10 09:11:13 +0100335 var PDU_ML3_MS_NW l3_info;
Harald Welteb9e86fa2018-04-09 18:18:31 +0200336 var MobileIdentityLV mi;
337
338 /* If we have a TMSI, use TMSI instead of IMSI */
339 if (ispresent(g_pars.tmsi)) {
340 mi := valueof(ts_MI_TMSI_LV(g_pars.tmsi));
341 } else {
342 mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
343 }
344
Harald Welte081b19a2018-02-10 09:11:13 +0100345 select (etype) {
346 case (EST_TYPE_MO_CALL) {
347 l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi));
348 }
Harald Welte0bef21e2018-02-10 09:48:23 +0100349 case (EST_TYPE_EMERG_CALL) {
350 l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_EMERG_CALL, mi));
351 }
Harald Welte081b19a2018-02-10 09:11:13 +0100352 case (EST_TYPE_PAG_RESP) {
353 l3_info := valueof(ts_PAG_RESP(mi));
354 }
Harald Weltef45efeb2018-04-09 18:19:24 +0200355 case (EST_TYPE_MO_SMS) {
356 l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, mi));
357 }
Vadim Yanitskiy20ee5e42018-05-27 17:54:21 +0700358 case (EST_TYPE_SS_ACT) {
359 l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, mi));
360 }
Harald Welte081b19a2018-02-10 09:11:13 +0100361 }
Harald Weltea49e36e2018-01-21 19:29:33 +0100362
363 /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */
Harald Weltedceacc72019-04-21 20:58:35 +0200364 f_cl3_or_initial_ue(l3_info);
Harald Weltea49e36e2018-01-21 19:29:33 +0100365
Harald Weltede371492018-01-27 23:44:41 +0100366 f_mm_common();
Pau Espin Pedrolf8034482019-06-03 13:15:58 +0200367 if (g_pars.net.expect_ciph or not g_pars.ran_is_geran) {
Harald Welte148a7082018-01-26 18:56:43 +0100368 /* implicit CM SERVICE ACCEPT? */
369 } else {
Harald Welte0bef21e2018-02-10 09:48:23 +0100370 if (etype != EST_TYPE_PAG_RESP) {
Harald Welte081b19a2018-02-10 09:11:13 +0100371 /* explicit CM SERVICE ACCEPT */
372 BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_ACC));
373 }
Harald Weltea49e36e2018-01-21 19:29:33 +0100374 }
Harald Weltea49e36e2018-01-21 19:29:33 +0100375}
376
377/* build a PDU_ML3_MS_NW containing a Location Update by IMSI */
Harald Welte9de84792018-01-28 01:06:35 +0100378function f_build_lu_imsi(hexstring imsi) runs on BSC_ConnHdlr return PDU_ML3_MS_NW
Harald Weltea49e36e2018-01-21 19:29:33 +0100379{
380 var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(imsi));
381 return f_build_lu(mi);
382}
Harald Welte9de84792018-01-28 01:06:35 +0100383function f_build_lu_imei(hexstring imei) runs on BSC_ConnHdlr return PDU_ML3_MS_NW
Harald Welteba7b6d92018-01-23 21:32:34 +0100384{
385 var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(imei));
386 return f_build_lu(mi);
387}
Harald Welte9de84792018-01-28 01:06:35 +0100388function f_build_lu_tmsi(OCT4 tmsi) runs on BSC_ConnHdlr return PDU_ML3_MS_NW
Harald Welteba7b6d92018-01-23 21:32:34 +0100389{
390 var MobileIdentityLV mi := valueof(ts_MI_TMSI_LV(tmsi));
391 return f_build_lu(mi);
392}
Harald Welte9de84792018-01-28 01:06:35 +0100393private function f_build_lu(MobileIdentityLV mi) runs on BSC_ConnHdlr return PDU_ML3_MS_NW
Harald Weltea49e36e2018-01-21 19:29:33 +0100394{
395 var LocationAreaIdentification_V old_lai := { '62F220'O, '9999'O };
396 var PDU_ML3_MS_NW l3_info := valueof(ts_ML3_MO_LU_Req(valueof(ts_ML3_IE_LuType_Attach),
Harald Welte9de84792018-01-28 01:06:35 +0100397 old_lai, mi, g_pars.cm1));
Harald Weltea49e36e2018-01-21 19:29:33 +0100398 return l3_info;
399}
400
Harald Weltea183a5d2019-05-09 13:40:52 +0200401altstep as_GSUP_SAI() runs on BSC_ConnHdlr {
402var GSUP_IE auth_tuple;
403[] GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)) {
404 if (g_pars.use_umts_aka) {
405 g_pars.vec := f_gen_auth_vec_3g();
406 auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G3G(g_pars.vec.rand,
407 g_pars.vec.sres,
408 g_pars.vec.kc,
409 g_pars.vec.ik,
410 g_pars.vec.ck,
411 g_pars.vec.autn,
412 g_pars.vec.res));
413 GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple));
414 } else {
415 g_pars.vec := f_gen_auth_vec_2g();
416 auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G(g_pars.vec.rand,
417 g_pars.vec.sres,
418 g_pars.vec.kc));
419 GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple));
420 }
421 }
422}
423
Harald Welte9de84792018-01-28 01:06:35 +0100424function f_mm_auth() runs on BSC_ConnHdlr
Harald Welte148a7082018-01-26 18:56:43 +0100425{
Harald Weltede371492018-01-27 23:44:41 +0100426 if (g_pars.net.expect_auth) {
Harald Weltea183a5d2019-05-09 13:40:52 +0200427 as_GSUP_SAI();
Harald Weltec1f937a2019-04-21 21:19:23 +0200428 if (g_pars.use_umts_aka) {
Harald Weltec1f937a2019-04-21 21:19:23 +0200429 BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_AUTH_REQ_3G(g_pars.vec.rand, g_pars.vec.autn)));
430 var OCT4 res := substr(g_pars.vec.res, 0, 4);
431 var OCT4 xres := substr(g_pars.vec.res, 4, 4);
432 BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MT_MM_AUTH_RESP_3G(res, xres)));
433 } else {
Harald Weltec1f937a2019-04-21 21:19:23 +0200434 BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_AUTH_REQ(g_pars.vec.rand)));
435 BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MT_MM_AUTH_RESP_2G(g_pars.vec.sres)));
436 }
Harald Welte148a7082018-01-26 18:56:43 +0100437 }
Harald Welte9de84792018-01-28 01:06:35 +0100438}
Harald Welte148a7082018-01-26 18:56:43 +0100439
Oliver Smith1d118ff2019-07-03 10:57:35 +0200440function f_mm_imei() runs on BSC_ConnHdlr
441{
442 var PDU_DTAP_MT dtap_mt;
443 var GSUP_PDU gsup_msg;
444 var MobileL3_CommonIE_Types.MobileIdentityLV mi;
445
446 if (not g_pars.net.expect_imei) {
447 return
448 }
449
450 /* MSC <-> BSC: ID req/rsp for IMEI */
451 alt {
452 [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req(CM_ID_TYPE_IMEI))) {
453 mi := valueof(ts_MI_IMEI_LV(g_pars.imei));
454 BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp(mi)));
455 }
456 [] BSSAP.receive(tr_PDU_DTAP_MT(?)) -> value dtap_mt {
457 setverdict(fail, "Expected ID REQ for IMEI DTAP MT message, but got: ", dtap_mt);
458 mtc.stop;
459 }
460 }
461
462 /* MSC <-> HLR: Check IMEI req/res/err */
463 alt {
464 [g_pars.net.check_imei_error] GSUP.receive(tr_GSUP_CHECK_IMEI_REQ(g_pars.imsi, g_pars.imei)) {
465 GSUP.send(ts_GSUP_CHECK_IMEI_ERR(g_pars.imsi, 96 /* Invalid Mandatory Information */));
466 }
467 [not g_pars.net.check_imei_error] GSUP.receive(tr_GSUP_CHECK_IMEI_REQ(g_pars.imsi, g_pars.imei)) {
468 GSUP.send(ts_GSUP_CHECK_IMEI_RES(g_pars.imsi, g_pars.net.check_imei_result));
469 }
470 [] GSUP.receive(?) -> value gsup_msg {
471 setverdict(fail, "Expected CHECK IMEI REQ GSUP message (with IMEI:", g_pars.imei, " and IMSI: ",
472 g_pars.imsi, "), but got: ", gsup_msg);
473 mtc.stop;
474 }
475 }
476}
477
478function f_mm_imei_early() runs on BSC_ConnHdlr
479{
480 var PDU_DTAP_MT dtap_mt;
481 var GSUP_PDU gsup_msg;
482 var MobileL3_CommonIE_Types.MobileIdentityLV mi;
483
484 if (not g_pars.net.expect_imei_early) {
485 return
486 }
487
488 /* MSC <-> BSC: ID req/rsp for IMEISV */
489 alt {
490 [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_ID_Req(CM_ID_TYPE_IMEISV))) {
491 mi := valueof(ts_MI_IMEISV_LV(g_pars.imei));
492 BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_MM_ID_Rsp(mi)));
493 }
494 [] BSSAP.receive(tr_PDU_DTAP_MT(?)) -> value dtap_mt {
495 setverdict(fail, "Expected ID REQ for IMEISV DTAP MT message, but got: ", dtap_mt);
496 mtc.stop;
497 }
498 }
499
500 /* MSC <-> HLR: Check IMEI req/res/err */
501 alt {
502 [g_pars.net.check_imei_error] GSUP.receive(tr_GSUP_CHECK_IMEI_REQ(g_pars.imsi, g_pars.imei)) {
503 GSUP.send(ts_GSUP_CHECK_IMEI_ERR(g_pars.imsi, 96 /* Invalid Mandatory Information */));
504 }
505 [not g_pars.net.check_imei_error] GSUP.receive(tr_GSUP_CHECK_IMEI_REQ(g_pars.imsi, g_pars.imei)) {
506 GSUP.send(ts_GSUP_CHECK_IMEI_RES(g_pars.imsi, g_pars.net.check_imei_result));
507 }
508 [] GSUP.receive(?) -> value gsup_msg {
509 setverdict(fail, "Expected CHECK IMEI REQ GSUP message (with IMEI:", g_pars.imei, " and IMSI: ",
510 g_pars.imsi, "), but got: ", gsup_msg);
511 mtc.stop;
512 }
513 }
514}
515
Harald Welte9de84792018-01-28 01:06:35 +0100516function f_mm_common() runs on BSC_ConnHdlr
517{
518 f_mm_auth();
Harald Welte9b751a62019-04-14 17:39:29 +0200519 if (g_pars.ran_is_geran) {
520 if (g_pars.net.expect_ciph) {
521 var OCT1 a5_net := f_alg_mask_from_cm(g_pars.cm2);
522 var OCT1 a5_intersect := g_pars.net.kc_support and4b a5_net;
523 alt {
524 [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(a5_intersect, g_pars.vec.kc)) {
525 var OCT1 a5_chosen := f_best_alg_from_mask(a5_intersect);
526 var integer a5_nr := f_alg_from_mask(a5_chosen);
527 BSSAP.send(ts_BSSMAP_CipherModeCompl(int2oct(a5_nr+1, 1)));
528 }
529 [] BSSAP.receive(tr_BSSMAP_CipherModeCmd(?, g_pars.vec.kc)) {
530 setverdict(fail, "Wrong ciphering algorithm mask in CiphModCmd");
531 mtc.stop;
532 }
Harald Welte9de84792018-01-28 01:06:35 +0100533 }
Harald Welte9b751a62019-04-14 17:39:29 +0200534 /* FIXME: Send the best available algorithm */
535 }
536 } else { /* UTRAN */
537 alt {
538 [g_pars.net.expect_ciph] BSSAP.receive(tr_RANAP_SecurityModeCmdEnc(uia_algs := ?,
539 uia_key := oct2bit(g_pars.vec.ik),
540 key_sts := ?,
541 uea_algs := ?,
542 uea_key := oct2bit(g_pars.vec.ck))) {
543 var IntegrityProtectionAlgorithm uia_chosen := 0; /*standard_UMTS_integrity_algorithm_UIA1*/
544 var EncryptionAlgorithm uea_chosen := 1; /*standard_UMTS_encryption_algorith_UEA1*/
545 BSSAP.send(ts_RANAP_SecurityModeCompleteEnc(uia_chosen, uea_chosen));
546 BSSAP.receive(tr_RANAP_CommonId(imsi_hex2oct(g_pars.imsi)));
547 }
548 [g_pars.net.expect_ciph] BSSAP.receive(tr_RANAP_SecurityModeCmdEnc(?,?,?,?,?)) {
549 setverdict(fail, "Invalid SecurityModeCommand (ciphering case)");
550 mtc.stop;
551 }
552 [not g_pars.net.expect_ciph] BSSAP.receive(tr_RANAP_SecurityModeCmd(uia_algs := ?,
553 uia_key := oct2bit(g_pars.vec.ik),
554 key_sts := ?)) {
555 var IntegrityProtectionAlgorithm uia_chosen := 0; /*standard_UMTS_integrity_algorithm_UIA1;*/
556 BSSAP.send(ts_RANAP_SecurityModeComplete(uia_chosen));
557 BSSAP.receive(tr_RANAP_CommonId(imsi_hex2oct(g_pars.imsi)));
558 }
559 [not g_pars.net.expect_ciph] BSSAP.receive(tr_RANAP_SecurityModeCmd(?,?,?)) {
560 setverdict(fail, "Invalid SecurityModeCommand (non-ciphering case)");
Daniel Willmannafce8662018-07-06 23:11:32 +0200561 mtc.stop;
Harald Welte9de84792018-01-28 01:06:35 +0100562 }
563 }
Harald Welte148a7082018-01-26 18:56:43 +0100564 }
565}
566
Philipp Maier9b690e42018-12-21 11:50:03 +0100567function f_expect_mm_info() runs on BSC_ConnHdlr {
568 if (g_pars.mm_info == true) {
569 BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_Info));
570 }
571}
572
Neels Hofmeyrc1f105a2018-03-01 20:00:19 +0100573function f_perform_lu()
Harald Weltea49e36e2018-01-21 19:29:33 +0100574runs on BSC_ConnHdlr {
575 var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi)
576 var PDU_DTAP_MT dtap_mt;
577
578 /* tell GSUP dispatcher to send this IMSI to us */
579 f_create_gsup_expect(hex2str(g_pars.imsi));
580
581 /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */
Harald Welte9b751a62019-04-14 17:39:29 +0200582 if (g_pars.ran_is_geran) {
583 f_bssap_compl_l3(l3_lu);
584 if (g_pars.send_early_cm) {
585 BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3));
586 }
587 } else {
588 f_ranap_initial_ue(l3_lu);
Harald Welte8a121b32018-01-22 03:00:41 +0100589 }
Harald Welte5c2622c2018-01-21 20:45:20 +0100590
Oliver Smith1d118ff2019-07-03 10:57:35 +0200591 f_mm_imei_early();
Harald Weltede371492018-01-27 23:44:41 +0100592 f_mm_common();
Stefan Sperlinga2d59c62018-12-18 16:32:44 +0100593 f_msc_lu_hlr();
Oliver Smith1d118ff2019-07-03 10:57:35 +0200594 f_mm_imei();
Stefan Sperlinga2d59c62018-12-18 16:32:44 +0100595 f_accept_reject_lu();
596 /* FIXME: there could be pending SMS or other common procedures by the MSC, let's ignore them */
597 f_expect_clear();
Harald Welte16114282018-01-24 22:41:21 +0100598
Stefan Sperlinga2d59c62018-12-18 16:32:44 +0100599 setverdict(pass);
600}
601
602function f_msc_lu_hlr() runs on BSC_ConnHdlr
603{
Harald Weltea49e36e2018-01-21 19:29:33 +0100604 /* Expect MSC to perform LU with HLR */
605 GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi));
606 GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn));
607 GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi));
608 GSUP.send(ts_GSUP_UL_RES(g_pars.imsi));
Stefan Sperlinga2d59c62018-12-18 16:32:44 +0100609}
610
611function f_accept_reject_lu() runs on BSC_ConnHdlr {
612 var PDU_DTAP_MT dtap_mt;
Harald Weltea49e36e2018-01-21 19:29:33 +0100613
614 alt {
615 [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) -> value dtap_mt {
616 var PDU_ML3_LocationUpdateAccept lu_acc := dtap_mt.dtap.msgs.mm.locationUpdateAccept;
Harald Weltede371492018-01-27 23:44:41 +0100617 if (g_pars.net.expect_tmsi) {
Harald Weltea49e36e2018-01-21 19:29:33 +0100618 if (not ispresent(lu_acc.mobileIdentityTLV) or
619 not ischosen(lu_acc.mobileIdentityTLV.mobileIdentityLV.mobileIdentityV.oddEvenInd_identity.tmsi_ptmsi)) {
620 setverdict(fail, "Expected TMSI but no TMSI was allocated");
Daniel Willmannafce8662018-07-06 23:11:32 +0200621 mtc.stop;
Harald Weltea49e36e2018-01-21 19:29:33 +0100622 } else {
Harald Welte256571e2018-01-24 18:47:19 +0100623 g_pars.tmsi := lu_acc.mobileIdentityTLV.mobileIdentityLV.mobileIdentityV.oddEvenInd_identity.tmsi_ptmsi.octets;
Harald Weltea49e36e2018-01-21 19:29:33 +0100624 BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_TmsiRealloc_Cmpl));
625 }
626 } else {
627 if (ispresent(lu_acc.mobileIdentityTLV) and
628 ischosen(lu_acc.mobileIdentityTLV.mobileIdentityLV.mobileIdentityV.oddEvenInd_identity.tmsi_ptmsi)) {
629 setverdict(fail, "Expected no TMSI but TMSI was allocated");
Daniel Willmannafce8662018-07-06 23:11:32 +0200630 mtc.stop;
Harald Weltea49e36e2018-01-21 19:29:33 +0100631 }
632 }
633 }
634 [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) {
635 setverdict(fail, "Expected LU ACK, but received LU REJ");
Daniel Willmannafce8662018-07-06 23:11:32 +0200636 mtc.stop;
Harald Weltea49e36e2018-01-21 19:29:33 +0100637 }
638 }
Philipp Maier9b690e42018-12-21 11:50:03 +0100639
640 /* Wait for MM-Information (if enabled) */
641 f_expect_mm_info();
Harald Weltea49e36e2018-01-21 19:29:33 +0100642 setverdict(pass);
643}
644
Oliver Smith91bfa1c2019-07-19 15:01:15 +0200645function f_expect_lu_reject() runs on BSC_ConnHdlr {
646 var PDU_DTAP_MT dtap_mt;
647 timer T := 5.0;
648
649 T.start;
650 alt {
651 [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) {
652 setverdict(pass);
653 }
654 [] BSSAP.receive(tr_PDU_DTAP_MT(?)) -> value dtap_mt {
655 setverdict(fail, "Expected LU reject BSSAP message, got: ", dtap_mt);
656 }
657 [] T.timeout {
658 setverdict(fail, "Timeout waiting for LU reject");
659 }
660 }
661}
662
Harald Weltea49e36e2018-01-21 19:29:33 +0100663function f_foo() runs on BSC_ConnHdlr{
Harald Welte6811d102019-04-14 22:23:14 +0200664 /* SCCP CC handled by RAN_Emulation_CT.main() */
Harald Weltea49e36e2018-01-21 19:29:33 +0100665 /* Expect auth, if enabled */
666
667 /* TODO: ISD */
668 /* Expect encr, if enabled */
669 /* Expect encr, if enabled */
670 /* Expect ASS CMD, if chan_type != requested */
671 /* Send ASS CMPL in successful case */
672
673 /* Expect AoIP port/ip information for RTP stream */
674 /* Expect MSC-originated MGCP to our simulated MGW */
675 /* Verify Counters via CTRL */
676 /* re-configure MSC behaviour via VTY */
677}
678
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200679type record CrcxResponse {
680 integer resp, /* 1 = reply with OK, 0 = do not reply, -1 = reply with error */
681 HostName mgw_rtp_ip,
682 PortNumber mgw_rtp_port,
683 MgcpConnectionId mgcp_connection_id /* MGCP Connection ID BSS Side */
684}
685
Harald Welteb71901a2018-01-26 19:16:05 +0100686/* parameters related to a (MO?) voice call */
687type record CallParameters {
Harald Welteb71901a2018-01-26 19:16:05 +0100688 /* CC related parameters */
689 hexstring called_party, /* whom are we calling */
690 integer transaction_id optional, /* which TS 04.08 CC transaction ID to use */
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +0100691 boolean mo_call, /* For a MO call, the transaction_id was allocated by the MS,
692 important to set the TI flag properly */
Harald Welteb71901a2018-01-26 19:16:05 +0100693 BearerCapability_TLV bearer_cap, /* which bearer capabilities to claim */
Harald Welte0bef21e2018-02-10 09:48:23 +0100694 boolean emergency, /* is this an emergency call? */
Harald Welteb71901a2018-01-26 19:16:05 +0100695
696 /* MNCC related parameters */
697 uint32_t mncc_callref optional, /* call reference on the MNCC side */
698 MNCC_bearer_cap mncc_bearer_cap optional, /* MNCC-side bearer capabilities */
699
700 /* RTP related parameters */
701 HostName bss_rtp_ip optional, /* BSS Side RTP IP */
702 PortNumber bss_rtp_port optional, /* BSS Side RTP Port */
703 HostName mss_rtp_ip optional, /* MSS Side RTP IP */
704 PortNumber mss_rtp_port optional, /* MSS Side RTP Port */
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200705 integer got_crcx_count,
706 CrcxResponse mgw_conn_1,
707 CrcxResponse mgw_conn_2,
Harald Welteb71901a2018-01-26 19:16:05 +0100708 uint7_t rtp_payload_type, /* dynamic RTP payload type */
709 charstring rtp_sdp_format, /* AMR/8000 or the like */
Philipp Maier2a98a732018-03-19 16:06:12 +0100710 boolean mgw_drop_dlcx optional, /* Provoke errors by not responding to DLCX
711 (f_mt_call and f_mt_call) */
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200712 boolean stop_after_cc_setup, /* Special case: stop call establish after CC Setup */
713 boolean ran_clear_when_alerting, /* Special case: send Clear upon CC Alerting */
Neels Hofmeyr8df69622019-11-02 19:16:03 +0100714 boolean expect_release, /* Special case: expect call establish to cause direct CC Rel */
Harald Welteb71901a2018-01-26 19:16:05 +0100715
Philipp Maiercd668572018-03-19 16:11:52 +0100716 MgcpCallId mgcp_call_id optional, /* MGCP Call ID; CallAgent allocated */
Harald Welteb71901a2018-01-26 19:16:05 +0100717 MgcpEndpoint mgcp_ep optional /* MGCP Endpoint, CallAgent or MGW allocated */,
Pau Espin Pedrola65697d2019-05-21 12:54:39 +0200718
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200719 boolean use_osmux, /* MSC is expected to use Osmux for this call */
720 integer got_osmux_count
Harald Welteb71901a2018-01-26 19:16:05 +0100721}
722
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200723template (value) CallParameters t_CallParams(hexstring called := '12345'H, integer tid := 0) := {
Harald Welteb71901a2018-01-26 19:16:05 +0100724 called_party := called,
725 transaction_id := tid,
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +0100726 mo_call := false,
Harald Welteb71901a2018-01-26 19:16:05 +0100727 bearer_cap := valueof(ts_Bcap_voice),
Harald Welte0bef21e2018-02-10 09:48:23 +0100728 emergency := false,
Harald Welteb71901a2018-01-26 19:16:05 +0100729 mncc_callref := omit,
730 mncc_bearer_cap := valueof(ts_MNCC_bcap_voice),
Harald Welte4017d552018-01-26 21:40:05 +0100731 bss_rtp_ip := "9.8.7.6",
732 bss_rtp_port := 9000,
Harald Welteb71901a2018-01-26 19:16:05 +0100733 mss_rtp_ip := omit,
734 mss_rtp_port := omit,
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200735 got_crcx_count := 0,
736 mgw_conn_1 := {
737 resp := 1,
738 mgw_rtp_ip := "1.1.1.1",
739 mgw_rtp_port := 10000,
740 mgcp_connection_id := '11111'H
741 },
742 mgw_conn_2 := {
743 resp := 1,
744 mgw_rtp_ip := "1.1.1.1",
745 mgw_rtp_port := 11000,
746 mgcp_connection_id := '22222'H
747 },
Harald Welteb71901a2018-01-26 19:16:05 +0100748 rtp_payload_type := 98,
749 rtp_sdp_format := "AMR/8000",
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +0100750 mgw_drop_dlcx := false,
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200751 stop_after_cc_setup := false,
752 ran_clear_when_alerting := false,
Neels Hofmeyr8df69622019-11-02 19:16:03 +0100753 expect_release := false,
Harald Welteb71901a2018-01-26 19:16:05 +0100754 mgcp_call_id := omit,
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200755 mgcp_ep := "rtpbridge/1@mgw",
756 use_osmux := false,
757 got_osmux_count := 0
Harald Welteb71901a2018-01-26 19:16:05 +0100758};
759
Harald Welte4263c522018-12-06 11:56:27 +0100760/* Allocate a call reference and send SETUP via MNCC to MSC */
761function f_mt_call_initate(inout CallParameters cpars)
Harald Welte33ec09b2018-02-10 15:34:46 +0100762runs on BSC_ConnHdlr {
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200763 cpars.mo_call := false;
Harald Welte4263c522018-12-06 11:56:27 +0100764 cpars.mncc_callref := f_rnd_int(2147483648);
765 MNCC.send(ts_MNCC_SETUP_req(cpars.mncc_callref, hex2str(g_pars.msisdn),
766 hex2str(cpars.called_party), hex2str(g_pars.imsi)));
767}
Harald Welte33ec09b2018-02-10 15:34:46 +0100768
Harald Welte408a7ef2019-04-21 17:08:40 +0200769private template (value) SDP_Message ts_SDP_CRCX_CN(CallParameters cpars) :=
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200770 ts_SDP(cpars.mgw_conn_2.mgw_rtp_ip, cpars.mgw_conn_2.mgw_rtp_ip,
Harald Welte408a7ef2019-04-21 17:08:40 +0200771 hex2str(cpars.mgcp_call_id), "42",
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200772 cpars.mgw_conn_2.mgw_rtp_port,
Harald Welte408a7ef2019-04-21 17:08:40 +0200773 { int2str(cpars.rtp_payload_type) },
774 { valueof(ts_SDP_rtpmap(cpars.rtp_payload_type,
775 cpars.rtp_sdp_format)),
776 valueof(ts_SDP_ptime(20)) });
777
Harald Welte4263c522018-12-06 11:56:27 +0100778/* Complete call, begin with a paging response message via BSSAP */
779function f_mt_call_complete(inout CallParameters cpars)
780runs on BSC_ConnHdlr {
Harald Welte33ec09b2018-02-10 15:34:46 +0100781 var MNCC_PDU mncc;
782 var MgcpCommand mgcp_cmd;
Pau Espin Pedrola65697d2019-05-21 12:54:39 +0200783 var template MgcpResponse mgcp_resp;
784 var MgcpOsmuxCID osmux_cid;
785 var PDU_BSSAP bssap;
Harald Welte33ec09b2018-02-10 15:34:46 +0100786
Harald Welte6811d102019-04-14 22:23:14 +0200787 f_ran_register_imsi(g_pars.imsi, g_pars.tmsi);
Harald Welte33ec09b2018-02-10 15:34:46 +0100788
Harald Welteb9e86fa2018-04-09 18:18:31 +0200789 f_establish_fully(EST_TYPE_PAG_RESP);
Harald Welte33ec09b2018-02-10 15:34:46 +0100790
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +0100791 log("f_mt_call_complete 1");
792
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200793 cpars.got_osmux_count := 0;
794
Harald Welte33ec09b2018-02-10 15:34:46 +0100795 /* MS <- MSC: Expect CC SETUP */
796 BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_SETUP(cpars.transaction_id, *, cpars.called_party)));
797
798 /* MS -> MSC: ALERTING */
799 BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_ALERTING(cpars.transaction_id)));
800 MNCC.receive(tr_MNCC_ALERT_ind(cpars.mncc_callref));
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +0100801 log("f_mt_call_complete 2");
Harald Welte33ec09b2018-02-10 15:34:46 +0100802
Harald Welte33ec09b2018-02-10 15:34:46 +0100803 /* Create MGCP expect */
804 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
805 /* Ask MSC via MNCC to create the RTP socket on the MSC/MGW side */
806 MNCC.send(ts_MNCC_RTP_CREATE(cpars.mncc_callref));
807
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200808 /* First MGCP CRCX */
Harald Welte33ec09b2018-02-10 15:34:46 +0100809 MGCP.receive(tr_CRCX) -> value mgcp_cmd {
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +0100810 log("f_mt_call_complete 3");
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200811 if (not f_handle_crcx(cpars, mgcp_cmd)) {
812 return;
Philipp Maier4b2692d2018-03-14 16:37:48 +0100813 }
Harald Welte33ec09b2018-02-10 15:34:46 +0100814 }
Neels Hofmeyr59e0c6f2019-03-06 15:21:20 +0100815
Neels Hofmeyr59e0c6f2019-03-06 15:21:20 +0100816
Harald Welte9b751a62019-04-14 17:39:29 +0200817 if (g_pars.ran_is_geran) {
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200818 var template BSSMAP_IE_AoIP_TransportLayerAddress tla_ass :=
819 tr_BSSMAP_IE_AoIP_TLA4(f_inet_addr(cpars.mgw_conn_1.mgw_rtp_ip), ?);
Harald Welte9b751a62019-04-14 17:39:29 +0200820
821 interleave {
822 /* Second MGCP CRCX (this time for MSS/CN side) */
823 [] MGCP.receive(tr_CRCX(cpars.mgcp_ep)) -> value mgcp_cmd {
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +0100824 log("f_mt_call_complete 4");
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200825 if (not f_handle_crcx(cpars, mgcp_cmd)) {
826 break;
827 }
Harald Welte9b751a62019-04-14 17:39:29 +0200828 }
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +0100829
830 /* MSC acknowledges the MNCC_CREATE to the MNCC handler */
831 [] MNCC.receive(tr_MNCC_RTP_CREATE(cpars.mncc_callref)) {
832 log("f_mt_call_complete 5");
833 }
834
Harald Welte9b751a62019-04-14 17:39:29 +0200835 /* expect the MSC to trigger a BSSMAP ASSIGNMENT */
Pau Espin Pedrola65697d2019-05-21 12:54:39 +0200836 [] BSSAP.receive(tr_BSSMAP_AssignmentReq(omit, tla_ass)) -> value bssap {
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200837 var template BSSMAP_IE_AoIP_TransportLayerAddress tla;
Harald Welte9b751a62019-04-14 17:39:29 +0200838 var BSSMAP_IE_SpeechCodec codec;
Pau Espin Pedrola65697d2019-05-21 12:54:39 +0200839 var BSSMAP_IE_Osmo_OsmuxCID osmuxCID;
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +0100840 log("f_mt_call_complete 6");
Harald Welte9b751a62019-04-14 17:39:29 +0200841
842 tla := valueof(ts_BSSMAP_IE_AoIP_TLA4(f_inet_addr(cpars.bss_rtp_ip), cpars.bss_rtp_port));
843 codec := valueof(ts_BSSMAP_IE_SpeechCodec({ts_CodecFR}));
844
Pau Espin Pedrola65697d2019-05-21 12:54:39 +0200845 if (cpars.use_osmux) {
846 if (not ispresent(bssap.pdu.bssmap.assignmentRequest.osmuxCID)) {
847 setverdict(fail, "MSC sent AssignReq without expected OsmuxCID IE");
848 mtc.stop;
849 }
850 osmuxCID := valueof(ts_OsmuxCID(0));
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200851 if (not match(bssap.pdu.bssmap.assignmentRequest.osmuxCID, osmuxCID)) {
852 setverdict(fail, "MSC sent AssignReq without expected OsmuxCID IE. Expected ", osmuxCID, " Got ", bssap.pdu.bssmap.assignmentRequest.osmuxCID);
Pau Espin Pedrola65697d2019-05-21 12:54:39 +0200853 mtc.stop;
854 }
855 bssap := valueof(ts_BSSMAP_AssignmentComplete(omit, tla, codec, osmuxCID));
856 } else {
857 bssap := valueof(ts_BSSMAP_AssignmentComplete(omit, tla, codec));
858 }
859 BSSAP.send(bssap);
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +0100860
861 BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CONNECT(cpars.transaction_id)));
Harald Welte9b751a62019-04-14 17:39:29 +0200862 }
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +0100863
864 [] MNCC.receive(tr_MNCC_SETUP_cnf(cpars.mncc_callref)) {
865 log("f_mt_call_complete 7");
866 MNCC.send(ts_MNCC_RTP_CONNECT(cpars.mncc_callref,
867 /* ip 42.23.11.5 */ hex2int('42231105'H),
868 /* port 423 */ 423,
869 /* payload type 3 = GSM FR */ 3));
870 }
871
872 /* MDCX setting up the RAN side remote RTP address received from Assignment Complete */
873 [] MGCP.receive(tr_MDCX) -> value mgcp_cmd {
874 log("f_mt_call_complete 8");
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200875 var SDP_Message sdp := valueof(ts_SDP(cpars.mgw_conn_2.mgw_rtp_ip, cpars.mgw_conn_2.mgw_rtp_ip,
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +0100876 hex2str(cpars.mgcp_call_id), "42",
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200877 cpars.mgw_conn_2.mgw_rtp_port,
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +0100878 { int2str(cpars.rtp_payload_type) },
879 { valueof(ts_SDP_rtpmap(cpars.rtp_payload_type,
880 cpars.rtp_sdp_format)),
Pau Espin Pedrola65697d2019-05-21 12:54:39 +0200881 valueof(ts_SDP_ptime(20)) }));
882 if (cpars.use_osmux) {
883 osmux_cid := f_MgcpCmd_extract_osmux_cid(mgcp_cmd);
884 if (osmux_cid != 0) { /* we expect MSC to use specific CID here */
885 setverdict(fail, "MSC using unexpected CID " & int2str(osmux_cid) & " != 0");
886 mtc.stop;
887 }
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200888 mgcp_resp := ts_MDCX_ACK_osmux(mgcp_cmd.line.trans_id, cpars.mgw_conn_1.mgcp_connection_id, osmux_cid, sdp);
Pau Espin Pedrola65697d2019-05-21 12:54:39 +0200889 } else {
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200890 mgcp_resp := ts_MDCX_ACK(mgcp_cmd.line.trans_id, cpars.mgw_conn_2.mgcp_connection_id, sdp);
Pau Espin Pedrola65697d2019-05-21 12:54:39 +0200891 }
892 MGCP.send(mgcp_resp);
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +0100893 }
894
895 /* MDCX setting up the CN side remote RTP address received from MNCC CONNECT */
896 [] MGCP.receive(tr_MDCX) -> value mgcp_cmd {
897 log("f_mt_call_complete 9");
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200898 var SDP_Message sdp := valueof(ts_SDP(cpars.mgw_conn_2.mgw_rtp_ip, cpars.mgw_conn_2.mgw_rtp_ip,
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +0100899 hex2str(cpars.mgcp_call_id), "42",
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200900 cpars.mgw_conn_2.mgw_rtp_port,
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +0100901 { int2str(cpars.rtp_payload_type) },
902 { valueof(ts_SDP_rtpmap(cpars.rtp_payload_type,
903 cpars.rtp_sdp_format)),
904 valueof(ts_SDP_ptime(20)) }));
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200905 MGCP.send(ts_MDCX_ACK(mgcp_cmd.line.trans_id, cpars.mgw_conn_2.mgcp_connection_id, sdp));
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +0100906 }
907
Neels Hofmeyr59e0c6f2019-03-06 15:21:20 +0100908 }
Harald Welte9b751a62019-04-14 17:39:29 +0200909 } else {
Harald Welte9b751a62019-04-14 17:39:29 +0200910 interleave {
911 [] MGCP.receive(tr_CRCX(cpars.mgcp_ep)) -> value mgcp_cmd {
Neels Hofmeyr8fe8a902019-11-03 05:51:03 +0100912 log("f_mt_call_complete 4.iu");
913 if (not f_handle_crcx(cpars, mgcp_cmd)) {
914 break;
Harald Welte9b751a62019-04-14 17:39:29 +0200915 }
Harald Welte9b751a62019-04-14 17:39:29 +0200916 }
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +0100917
Neels Hofmeyr8fe8a902019-11-03 05:51:03 +0100918 /* MSC acknowledges the MNCC_CREATE to the MNCC handler */
919 [] MNCC.receive(tr_MNCC_RTP_CREATE(cpars.mncc_callref)) {
920 log("f_mt_call_complete 5.iu");
921 }
922
923 [] BSSAP.receive(tr_RANAP_RabAssReq(?)) {
924 log("f_mt_call_complete 6.iu");
925 var RAB_SetupOrModifiedList l := {
926 {
927 {
928 id := id_RAB_SetupOrModifiedItem,
929 criticality := ignore,
930 value_ := {
931 rAB_SetupOrModifiedItem := {
932 rAB_ID := int2bit(23, 8),
933 transportLayerAddress := hex2bit( '350001c0a8021500000000000000000000000000'H),
934 iuTransportAssociation := {
935 bindingID := '040c0000'O
936 },
937 dl_dataVolumes := omit,
938 iE_Extensions := omit
939 }
940 }
941 }
942 }
943 };
944 BSSAP.send(ts_RANAP_RabAssResp(l));
945
946 BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CONNECT(cpars.transaction_id)));
947 }
948
949 [] MNCC.receive(tr_MNCC_SETUP_cnf(cpars.mncc_callref)) {
950 log("f_mt_call_complete 7.iu");
951 MNCC.send(ts_MNCC_RTP_CONNECT(cpars.mncc_callref,
952 /* ip 42.23.11.5 */ hex2int('42231105'H),
953 /* port 423 */ 423,
954 /* payload type 3 = GSM FR */ 3));
955 }
956
957 /* MDCX setting up the RAN side remote RTP address received from Assignment Complete */
958 [] MGCP.receive(tr_MDCX) -> value mgcp_cmd {
959 log("f_mt_call_complete 8.iu");
960 var SDP_Message sdp := valueof(ts_SDP(cpars.mgw_conn_2.mgw_rtp_ip, cpars.mgw_conn_2.mgw_rtp_ip,
961 hex2str(cpars.mgcp_call_id), "42",
962 cpars.mgw_conn_2.mgw_rtp_port,
963 { int2str(cpars.rtp_payload_type) },
964 { valueof(ts_SDP_rtpmap(cpars.rtp_payload_type,
965 cpars.rtp_sdp_format)),
966 valueof(ts_SDP_ptime(20)) }));
967 if (cpars.use_osmux) {
968 osmux_cid := f_MgcpCmd_extract_osmux_cid(mgcp_cmd);
969 if (osmux_cid != 0) { /* we expect MSC to use specific CID here */
970 setverdict(fail, "MSC using unexpected CID " & int2str(osmux_cid) & " != 0");
971 mtc.stop;
972 }
973 mgcp_resp := ts_MDCX_ACK_osmux(mgcp_cmd.line.trans_id, cpars.mgw_conn_1.mgcp_connection_id, osmux_cid, sdp);
974 } else {
975 mgcp_resp := ts_MDCX_ACK(mgcp_cmd.line.trans_id, cpars.mgw_conn_2.mgcp_connection_id, sdp);
976 }
977 MGCP.send(mgcp_resp);
978 }
979
980 /* MDCX setting up the CN side remote RTP address received from MNCC CONNECT */
981 [] MGCP.receive(tr_MDCX) -> value mgcp_cmd {
982 log("f_mt_call_complete 9.iu");
983 var SDP_Message sdp := valueof(ts_SDP(cpars.mgw_conn_2.mgw_rtp_ip, cpars.mgw_conn_2.mgw_rtp_ip,
984 hex2str(cpars.mgcp_call_id), "42",
985 cpars.mgw_conn_2.mgw_rtp_port,
986 { int2str(cpars.rtp_payload_type) },
987 { valueof(ts_SDP_rtpmap(cpars.rtp_payload_type,
988 cpars.rtp_sdp_format)),
989 valueof(ts_SDP_ptime(20)) }));
990 MGCP.send(ts_MDCX_ACK(mgcp_cmd.line.trans_id, cpars.mgw_conn_2.mgcp_connection_id, sdp));
991 }
992
Harald Welte33ec09b2018-02-10 15:34:46 +0100993 }
Neels Hofmeyr59e0c6f2019-03-06 15:21:20 +0100994 }
Harald Welte33ec09b2018-02-10 15:34:46 +0100995
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +0200996 if (cpars.use_osmux == (cpars.got_osmux_count != 0)) {
997 log("Osmux ok: use_osmux = ", cpars.use_osmux, " got_osmux_count = ", cpars.got_osmux_count);
998 } else {
999 setverdict(fail, "Osmux failure: use_osmux = ", cpars.use_osmux, " got_osmux_count = ", cpars.got_osmux_count);
1000 mtc.stop;
1001 }
1002
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001003 log("f_mt_call_complete DONE");
Harald Welte4263c522018-12-06 11:56:27 +01001004}
1005
Harald Weltee035e3e2019-04-21 17:32:05 +02001006function f_expect_paging(boolean by_tmsi := true)
1007runs on BSC_ConnHdlr {
Harald Welte9b751a62019-04-14 17:39:29 +02001008 if (g_pars.ran_is_geran) {
1009 BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi));
1010 } else {
Harald Welte62113fc2019-05-09 13:04:02 +02001011 BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi)));
Harald Welte9b751a62019-04-14 17:39:29 +02001012 }
Harald Weltee035e3e2019-04-21 17:32:05 +02001013}
1014
Harald Welte4263c522018-12-06 11:56:27 +01001015function f_mt_call_establish(inout CallParameters cpars)
1016runs on BSC_ConnHdlr {
1017
1018 /* Initiate the call via MNCC */
1019 f_mt_call_initate(cpars);
1020
1021 /* BSC <- MSC: Expect paging. FIXME: By TMSI or not? */
Harald Welte6811d102019-04-14 22:23:14 +02001022 f_ran_register_imsi(g_pars.imsi, g_pars.tmsi);
Harald Weltee035e3e2019-04-21 17:32:05 +02001023 f_expect_paging()
Harald Welte4263c522018-12-06 11:56:27 +01001024
1025 /* Complete the call via BSSAP */
1026 f_mt_call_complete(cpars);
Harald Welte33ec09b2018-02-10 15:34:46 +01001027
Harald Welte33ec09b2018-02-10 15:34:46 +01001028 setverdict(pass);
1029}
1030
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +02001031/* Reply to a received CRCX with an OK (or the reply configured in cpars), using the given parameters.
1032 * Return true when an OK reply was sent, false otherwise.
1033 * Count occurence of Osmux, include Osmux parameters in the reply if necessary. */
1034function f_handle_crcx(inout CallParameters cpars, MgcpCommand mgcp_cmd)
1035runs on BSC_ConnHdlr
1036return boolean {
1037 var CrcxResponse conn := cpars.mgw_conn_1;
1038 if (cpars.got_crcx_count > 0) {
1039 conn := cpars.mgw_conn_2;
1040 }
1041 cpars.got_crcx_count := cpars.got_crcx_count + 1;
1042
1043 var MgcpMessage mgcp_msg := {
1044 command := mgcp_cmd
1045 }
1046 var template MgcpResponse mgcp_resp;
1047 var MgcpOsmuxCID osmux_cid;
1048 var MgcpCallId call_id := f_MgcpCmd_extract_call_id(mgcp_cmd);
1049 if (ispresent(cpars.mgcp_call_id)) {
1050 if (cpars.mgcp_call_id != call_id) {
1051 setverdict(fail, "CRCX contained unexpected call id. Expected:", cpars.mgcp_call_id, " got:", call_id);
1052 mtc.stop;
1053 }
1054 } else {
1055 cpars.mgcp_call_id := call_id;
1056 }
1057
1058 /* When the endpoint contains a wildcard we keep the endpoint
1059 * identifier we have set up in cpars. Otherwise we use the
1060 * endpoint name that the call agent has supplied */
1061 if (match(mgcp_cmd.line.ep, t_MGCP_EP_wildcard) == false) {
1062 cpars.mgcp_ep := mgcp_cmd.line.ep;
1063 }
1064
1065 if (conn.resp == -1) {
1066 /* Reply with error */
1067 var MgcpResponse mgcp_rsp := {
1068 line := {
1069 code := "542",
1070 trans_id := mgcp_cmd.line.trans_id,
1071 string := "FORCED_FAIL"
1072 },
1073 sdp := omit
1074
1075 }
1076 var MgcpParameter mgcp_rsp_param := {
1077 code := "Z",
1078 val := cpars.mgcp_ep
1079 };
1080 mgcp_rsp.params[0] := mgcp_rsp_param;
1081 MGCP.send(mgcp_rsp);
1082 return false;
1083 }
1084
1085 if (conn.resp == 0) {
1086 /* Do not reply at all */
1087 return false;
1088 }
1089
1090 if (conn.resp != 1) {
1091 setverdict(fail, "Unexpected value for cpars.mgw_conn_*.resp, expect -1, 0 or 1");
1092 mtc.stop;
1093 }
1094
1095 var SDP_Message sdp := valueof(ts_SDP(conn.mgw_rtp_ip, conn.mgw_rtp_ip,
1096 hex2str(cpars.mgcp_call_id), "42",
1097 conn.mgw_rtp_port,
1098 { int2str(cpars.rtp_payload_type) },
1099 { valueof(ts_SDP_rtpmap(cpars.rtp_payload_type,
1100 cpars.rtp_sdp_format)),
1101 valueof(ts_SDP_ptime(20)) }));
1102
1103 if (f_mgcp_contains_par(mgcp_msg, "X-OSMUX")) {
1104 if (not cpars.use_osmux) {
1105 setverdict(fail, "MSC sent X-Osmux parameter in MGCP, but not expecting any Osmux");
1106 mtc.stop;
1107 }
1108 cpars.got_osmux_count := cpars.got_osmux_count + 1;
1109 /* we expect MSC to use wildcard here, i.e. osmux_cid == -1 */
1110 osmux_cid := f_MgcpCmd_extract_osmux_cid(mgcp_cmd);
1111 log("f_handle_crcx(): got Osmux CID: ", osmux_cid);
1112 if (osmux_cid != -1) {
1113 setverdict(fail, "MSC using unexpected CID " & int2str(osmux_cid) & " != -1");
1114 mtc.stop;
1115 }
1116
1117 osmux_cid := 0;
1118 mgcp_resp := ts_CRCX_ACK_osmux(mgcp_cmd.line.trans_id, conn.mgcp_connection_id, osmux_cid, sdp);
1119 } else {
1120 mgcp_resp := ts_CRCX_ACK(mgcp_cmd.line.trans_id, conn.mgcp_connection_id, sdp);
1121 }
1122
1123 f_mgcp_par_append(mgcp_resp.params, ts_MgcpParSpecEP(cpars.mgcp_ep));
1124 MGCP.send(mgcp_resp);
1125 return true;
1126}
1127
1128
1129altstep as_optional_mgcp_crcx(CallParameters cpars) runs on BSC_ConnHdlr {
1130 var MgcpCommand mgcp_cmd;
1131 [] MGCP.receive(tr_CRCX) -> value mgcp_cmd {
1132 log("as_optional_mgcp_crcx: rx CRCX");
1133 f_handle_crcx(cpars, mgcp_cmd);
1134
1135 /* Without this 'repeat', the as_optional_mgcp_crcx() exits currently waiting interleaves as soon as an
1136 * CRCX is handled. */
1137 repeat;
1138 }
1139}
1140
1141private altstep as_optional_mgcp_mdcx(HostName mgw_rtp_ip, PortNumber mgw_rtp_port) runs on BSC_ConnHdlr {
1142 var MgcpCommand mgcp_cmd;
1143 [] MGCP.receive(tr_MDCX) -> value mgcp_cmd {
1144 log("as_optional_mgcp_mdcx: rx MDCX");
1145 log(mgcp_cmd);
1146 var charstring conn_id;
1147 var charstring rtp_payload_type;
1148 f_mgcp_find_param_entry(mgcp_cmd.params, "I", conn_id);
1149 rtp_payload_type := mgcp_cmd.sdp.media_list[0].media_field.fmts[0];
1150
1151 var SDP_Message sdp := valueof(ts_SDP(mgw_rtp_ip, mgw_rtp_ip,
1152 mgcp_cmd.sdp.origin.session_id, "42",
1153 mgw_rtp_port,
1154 { rtp_payload_type },
1155 { valueof(ts_SDP_ptime(20)) }));
1156 MGCP.send(ts_MDCX_ACK(mgcp_cmd.line.trans_id, str2hex(conn_id), sdp));
1157
1158 /* Without this 'repeat', currently active other interleave and alt series exit as soon as an MDCX is
1159 * handled. */
1160 repeat;
1161 }
1162}
1163
Neels Hofmeyr0b16bf12019-11-03 05:10:12 +01001164private altstep as_optional_mgcp_dlcx(CallParameters cpars) runs on BSC_ConnHdlr {
1165 var MgcpCommand mgcp_cmd;
1166 var boolean respond_to_dlcx := not (isbound(cpars.mgw_drop_dlcx) and valueof(cpars.mgw_drop_dlcx));
1167 [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd {
1168 log("as_optional_mgcp_dlcx: rx MGCP DLCX");
1169 if (respond_to_dlcx) {
1170 MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id));
1171 }
1172 /* Without this 'repeat', currently active other interleave and alt series exit as soon as a
1173 * DLCX is handled. */
1174 repeat;
1175 }
1176}
1177
Philipp Maier3716a5e2018-03-21 15:53:35 +01001178function f_mo_call_establish(inout CallParameters cpars)
Harald Welteb71901a2018-01-26 19:16:05 +01001179runs on BSC_ConnHdlr {
1180
Harald Welteb71901a2018-01-26 19:16:05 +01001181 var MNCC_PDU mncc;
1182 var MgcpCommand mgcp_cmd;
Pau Espin Pedrola65697d2019-05-21 12:54:39 +02001183 var template MgcpResponse mgcp_resp;
Philipp Maier2a98a732018-03-19 16:06:12 +01001184 var boolean respond_to_dlcx;
Pau Espin Pedrola65697d2019-05-21 12:54:39 +02001185 var PDU_BSSAP bssap;
Neels Hofmeyr0b16bf12019-11-03 05:10:12 +01001186 var RANAP_PDU ranap;
Pau Espin Pedrola65697d2019-05-21 12:54:39 +02001187 var MgcpOsmuxCID osmux_cid;
Harald Welteb71901a2018-01-26 19:16:05 +01001188
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +02001189 cpars.mo_call := true;
1190
Harald Welte0bef21e2018-02-10 09:48:23 +01001191 if (cpars.emergency) {
Harald Welteb9e86fa2018-04-09 18:18:31 +02001192 f_establish_fully(EST_TYPE_EMERG_CALL);
Harald Welte0bef21e2018-02-10 09:48:23 +01001193 } else {
Harald Welteb9e86fa2018-04-09 18:18:31 +02001194 f_establish_fully(EST_TYPE_MO_CALL);
Harald Welte0bef21e2018-02-10 09:48:23 +01001195 }
Harald Welteb71901a2018-01-26 19:16:05 +01001196
1197 /* Create MNCC and MGCP expect */
1198 f_create_mncc_expect(hex2str(cpars.called_party));
1199 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
1200
Harald Welte0bef21e2018-02-10 09:48:23 +01001201 if (cpars.emergency) {
1202 BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_EMERG_SETUP(cpars.transaction_id)));
1203 } else {
1204 BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_SETUP(cpars.transaction_id, cpars.called_party)));
1205 }
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001206
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +02001207 if (cpars.stop_after_cc_setup) {
1208 return;
1209 }
1210
1211 var template BSSMAP_IE_AoIP_TransportLayerAddress tla_ass :=
1212 tr_BSSMAP_IE_AoIP_TLA4(f_inet_addr(cpars.mgw_conn_1.mgw_rtp_ip), ?);
1213
1214 var default mdcx := activate(as_optional_mgcp_mdcx(cpars.mgw_conn_2.mgw_rtp_ip, cpars.mgw_conn_2.mgw_rtp_port));
Neels Hofmeyr8df69622019-11-02 19:16:03 +01001215 var boolean got_mncc_setup_compl_ind := false;
1216 var boolean got_cc_connect := false;
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001217
Harald Welteb71901a2018-01-26 19:16:05 +01001218 interleave {
1219 [] MNCC.receive(tr_MNCC_SETUP_ind(?, tr_MNCC_number(hex2str(cpars.called_party)))) -> value mncc {
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001220 log("f_mo_call_establish 1: rx MNCC SETUP ind");
Harald Welteb71901a2018-01-26 19:16:05 +01001221 cpars.mncc_callref := mncc.u.signal.callref;
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001222 MNCC.send(ts_MNCC_RTP_CREATE(cpars.mncc_callref));
1223 }
1224
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +02001225 /* First MGCP CRCX */
Harald Welteb71901a2018-01-26 19:16:05 +01001226 [] MGCP.receive(tr_CRCX) -> value mgcp_cmd {
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001227 log("f_mo_call_establish 2: rx 1st CRCX");
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +02001228 if (not f_handle_crcx(cpars, mgcp_cmd)) {
1229 break;
1230 }
Philipp Maierf1e02bb2018-03-15 16:30:00 +01001231 }
1232
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +02001233 /* Second MGCP CRCX */
1234 [] MGCP.receive(tr_CRCX(cpars.mgcp_ep)) -> value mgcp_cmd {
1235 log("f_mo_call_establish 6: rx 2nd CRCX");
1236 if (not f_handle_crcx(cpars, mgcp_cmd)) {
1237 break;
Pau Espin Pedrola65697d2019-05-21 12:54:39 +02001238 }
Harald Welteb71901a2018-01-26 19:16:05 +01001239 }
Neels Hofmeyr59e0c6f2019-03-06 15:21:20 +01001240
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001241 [] MNCC.receive(tr_MNCC_RTP_CREATE(cpars.mncc_callref)) {
1242 log("f_mo_call_establish 3: rx RTP CREATE");
1243 /* Call Proceeding */
1244 MNCC.send(ts_MNCC_CALL_PROC_req(cpars.mncc_callref, cpars.mncc_bearer_cap));
1245 BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CALL_PROC(cpars.transaction_id)));
Harald Welteb71901a2018-01-26 19:16:05 +01001246
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001247 /* Alerting */
1248 MNCC.send(ts_MNCC_ALERT_req(cpars.mncc_callref));
Neels Hofmeyr59e0c6f2019-03-06 15:21:20 +01001249 }
Harald Welte9b751a62019-04-14 17:39:29 +02001250
Neels Hofmeyreccaa992019-10-15 16:42:21 +02001251 //[g_pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_AssignmentReq(omit, tla_ass)) -> value bssap
Neels Hofmeyrd9d835d2019-09-17 18:19:08 +02001252 [] BSSAP.receive(tr_BSSMAP_AssignmentReq(omit)) -> value bssap {
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001253 log("f_mo_call_establish 4: rx Assignment Request");
1254 var BSSMAP_IE_AoIP_TransportLayerAddress tla;
1255 var BSSMAP_IE_SpeechCodec codec;
Pau Espin Pedrola65697d2019-05-21 12:54:39 +02001256 var BSSMAP_IE_Osmo_OsmuxCID osmuxCID;
1257
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +02001258 if (not match(bssap.pdu.bssmap.assignmentRequest.aoIPTransportLayer, tla_ass)) {
Neels Hofmeyrd9d835d2019-09-17 18:19:08 +02001259 log("Expected:", tla_ass);
1260 log("Got:", bssap.pdu.bssmap.assignmentRequest.aoIPTransportLayer);
1261 setverdict(fail, "MSC sent Assignment Request with unexpected AoIP Transport Layer IE");
1262 mtc.stop;
1263 }
1264
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001265 tla := valueof(ts_BSSMAP_IE_AoIP_TLA4(f_inet_addr(cpars.bss_rtp_ip), cpars.bss_rtp_port));
1266 codec := valueof(ts_BSSMAP_IE_SpeechCodec({ts_CodecFR}));
Pau Espin Pedrola65697d2019-05-21 12:54:39 +02001267 if (cpars.use_osmux) {
1268 if (not ispresent(bssap.pdu.bssmap.assignmentRequest.osmuxCID)) {
1269 setverdict(fail, "MSC sent AssignReq without expected OsmuxCID IE");
1270 mtc.stop;
1271 }
1272 osmuxCID := valueof(ts_OsmuxCID(0));
1273 if (cpars.use_osmux and not match(bssap.pdu.bssmap.assignmentRequest.osmuxCID, osmuxCID)) {
1274 setverdict(fail, "MSC sent AssignReq without expected OsmuxCID IE");
1275 mtc.stop;
1276 }
1277 bssap := valueof(ts_BSSMAP_AssignmentComplete(omit, tla, codec, osmuxCID));
1278 } else {
1279 bssap := valueof(ts_BSSMAP_AssignmentComplete(omit, tla, codec));
1280 }
1281 BSSAP.send(bssap);
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001282 }
Neels Hofmeyr0b16bf12019-11-03 05:10:12 +01001283 [] BSSAP.receive(tr_RANAP_RabAssReq(*)) -> value ranap {
1284 log("f_mo_call_establish 4.iu: rx RANAP RAB Assignment Request");
1285 var RAB_SetupOrModifiedList l := {
1286 {
1287 {
1288 id := id_RAB_SetupOrModifiedItem,
1289 criticality := ignore,
1290 value_ := {
1291 rAB_SetupOrModifiedItem := {
1292 rAB_ID := int2bit(23, 8),
1293 transportLayerAddress := hex2bit( '350001c0a8021500000000000000000000000000'H),
1294 iuTransportAssociation := {
1295 bindingID := '040c0000'O
1296 },
1297 dl_dataVolumes := omit,
1298 iE_Extensions := omit
1299 }
1300 }
1301 }
1302 }
1303 };
1304 BSSAP.send(ts_RANAP_RabAssResp(l));
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001305 }
Harald Welte9b751a62019-04-14 17:39:29 +02001306
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001307 /* MDCX setting up the RAN side remote RTP address received from Assignment Complete */
1308 [] MGCP.receive(tr_MDCX) -> value mgcp_cmd {
1309 log("f_mo_call_establish 5: rx MDCX for the RAN side");
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +02001310 var SDP_Message sdp := valueof(ts_SDP(cpars.mgw_conn_2.mgw_rtp_ip, cpars.mgw_conn_2.mgw_rtp_ip,
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001311 hex2str(cpars.mgcp_call_id), "42",
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +02001312 cpars.mgw_conn_2.mgw_rtp_port,
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001313 { int2str(cpars.rtp_payload_type) },
1314 { valueof(ts_SDP_rtpmap(cpars.rtp_payload_type,
1315 cpars.rtp_sdp_format)),
1316 valueof(ts_SDP_ptime(20)) }));
Pau Espin Pedrola65697d2019-05-21 12:54:39 +02001317
1318 if (cpars.use_osmux) {
1319 osmux_cid := f_MgcpCmd_extract_osmux_cid(mgcp_cmd);
1320 if (osmux_cid != 0) { /* we expect MSC to use specific CID here */
1321 setverdict(fail, "MSC using unexpected CID " & int2str(osmux_cid) & " != 0");
1322 mtc.stop;
1323 }
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +02001324 mgcp_resp := ts_MDCX_ACK_osmux(mgcp_cmd.line.trans_id, cpars.mgw_conn_1.mgcp_connection_id, osmux_cid, sdp);
Pau Espin Pedrola65697d2019-05-21 12:54:39 +02001325 } else {
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +02001326 mgcp_resp := ts_MDCX_ACK(mgcp_cmd.line.trans_id, cpars.mgw_conn_2.mgcp_connection_id, sdp);
Pau Espin Pedrola65697d2019-05-21 12:54:39 +02001327 }
1328 MGCP.send(mgcp_resp);
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001329 }
Harald Welte9b751a62019-04-14 17:39:29 +02001330
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001331 [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_ALERTING(cpars.transaction_id))) {
1332 log("f_mo_call_establish 7: rx CC Alerting");
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +02001333
1334 if (cpars.ran_clear_when_alerting) {
1335 if (g_pars.ran_is_geran) {
1336 BSSAP.send(ts_BSSMAP_ClearRequest(0));
1337 } else {
1338 BSSAP.send(ts_RANAP_IuReleaseRequest(ts_RanapCause_om_intervention));
1339 }
1340 break;
1341 }
1342
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001343 cpars.mncc_callref := mncc.u.signal.callref;
1344 /* Call Proceeding */
1345 MNCC.send(ts_MNCC_RTP_CONNECT(cpars.mncc_callref,
1346 /* ip 42.23.11.5 */ hex2int('42231105'H),
1347 /* port 423 */ 423,
1348 /* payload type 3 = GSM FR */ 3));
1349 MNCC.send(ts_MNCC_SETUP_rsp(cpars.mncc_callref));
1350 }
1351
1352 [] MNCC.receive(tr_MNCC_SETUP_COMPL_ind(?)) -> value mncc {
1353 log("f_mo_call_establish 8: rx MNCC SETUP COMPLETE ind");
Neels Hofmeyr8df69622019-11-02 19:16:03 +01001354 got_mncc_setup_compl_ind := true;
1355 if (not cpars.expect_release and got_cc_connect) {
1356 break;
1357 }
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001358 }
1359
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001360 [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CONNECT(cpars.transaction_id))) {
1361 log("f_mo_call_establish 10: rx CC CONNECT");
1362 BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CONNECT_ACK(cpars.transaction_id)));
Neels Hofmeyr8df69622019-11-02 19:16:03 +01001363 got_cc_connect := true;
1364 if (not cpars.expect_release and got_mncc_setup_compl_ind) {
1365 break;
1366 }
Harald Welteb71901a2018-01-26 19:16:05 +01001367 }
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +02001368
1369 [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id))) {
1370 log("f_mo_call_establish 11: rx CC RELEASE");
Neels Hofmeyr8df69622019-11-02 19:16:03 +01001371 if (not cpars.expect_release) {
1372 setverdict(fail, "Got unexpected CC Release");
1373 mtc.stop;
1374 }
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +02001375 f_expect_clear();
1376 break;
1377 }
1378 }
1379
1380 f_sleep(0.5);
1381 deactivate(mdcx);
1382
1383 if (cpars.use_osmux == (cpars.got_osmux_count != 0)) {
1384 log("Osmux ok: use_osmux = ", cpars.use_osmux, " got_osmux_count = ", cpars.got_osmux_count);
1385 } else {
1386 setverdict(fail, "Osmux failure: use_osmux = ", cpars.use_osmux, " got_osmux_count = ", cpars.got_osmux_count);
1387 mtc.stop;
Harald Welteb71901a2018-01-26 19:16:05 +01001388 }
1389
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001390 log("f_mo_call_establish DONE");
Philipp Maier3716a5e2018-03-21 15:53:35 +01001391 setverdict(pass);
1392}
Harald Welteb71901a2018-01-26 19:16:05 +01001393
Harald Welte4c422b72019-02-17 16:27:10 +01001394function f_call_hangup(inout CallParameters cpars, boolean release_by_ms, boolean is_csfb := false)
Philipp Maier3716a5e2018-03-21 15:53:35 +01001395runs on BSC_ConnHdlr {
1396
1397 var MobileIdentityLV mi;
1398 var MNCC_PDU mncc;
1399 var MgcpCommand mgcp_cmd;
1400 var boolean respond_to_dlcx;
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001401 var boolean dlcx_contained_ci := false;
1402 var template PDU_BSSAP t_clear := tr_BSSMAP_ClearCommand;
1403
1404 if (is_csfb) {
1405 t_clear := tr_BSSMAP_ClearCommandCSFB;
1406 }
1407
Neels Hofmeyrba960a12019-11-02 19:17:38 +01001408 log("f_call_hangup 0: tx MNCC_DISC_REQ");
Harald Welteb71901a2018-01-26 19:16:05 +01001409 MNCC.send(ts_MNCC_DISC_req(cpars.mncc_callref, valueof(ts_MNCC_cause(23))));
1410 BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_DISC(cpars.transaction_id)));
1411
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001412 log("f_call_hangup 1: rx DTAP CC DISC");
1413
Philipp Maier3716a5e2018-03-21 15:53:35 +01001414 if (release_by_ms) {
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001415 var BIT1 tid_remote := '1'B;
1416 if (cpars.mo_call) {
1417 tid_remote := '0'B;
1418 }
Philipp Maier3716a5e2018-03-21 15:53:35 +01001419 /* B-side (MS) Release of call */
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001420 BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_RELEASE(cpars.transaction_id, tid_remote, '0000000'B)));
Philipp Maier3716a5e2018-03-21 15:53:35 +01001421 MNCC.receive(tr_MNCC_REL_ind(cpars.mncc_callref));
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001422 log("f_call_hangup 2: rx MNCC REL ind");
Philipp Maier3716a5e2018-03-21 15:53:35 +01001423 BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_REL_COMPL(cpars.transaction_id)));
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001424 log("f_call_hangup 3: rx DTAP CC REL COMPL");
Philipp Maier3716a5e2018-03-21 15:53:35 +01001425 } else {
1426 /* A-side (PLMN) Release of call */
1427 MNCC.send(ts_MNCC_REL_req(cpars.mncc_callref, valueof(ts_MNCC_cause(42))));
1428 BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id)));
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001429 log("f_call_hangup 4: rx DTAP CC RELEASE");
Philipp Maier3716a5e2018-03-21 15:53:35 +01001430 BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_REL_COMPL(cpars.transaction_id)));
1431 }
Harald Welteb71901a2018-01-26 19:16:05 +01001432
Philipp Maier2a98a732018-03-19 16:06:12 +01001433 respond_to_dlcx := not (isbound(cpars.mgw_drop_dlcx) and valueof(cpars.mgw_drop_dlcx));
1434
Neels Hofmeyr3c89a6b2019-10-15 16:54:37 +02001435 var default mdcx := activate(as_optional_mgcp_mdcx(cpars.mgw_conn_2.mgw_rtp_ip, cpars.mgw_conn_2.mgw_rtp_port));
Neels Hofmeyr0b16bf12019-11-03 05:10:12 +01001436 var default dlcx := activate(as_optional_mgcp_dlcx(cpars));
Harald Welte9b751a62019-04-14 17:39:29 +02001437
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001438 /* clearing of radio channel */
Neels Hofmeyr0b16bf12019-11-03 05:10:12 +01001439 alt {
1440 [g_pars.ran_is_geran] BSSAP.receive(t_clear) {
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001441 log("f_call_hangup 5: rx BSSAP Clear Command");
1442 BSSAP.send(ts_BSSMAP_ClearComplete);
1443 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND);
1444 log("f_call_hangup 6: rx SCCP DISC");
Neels Hofmeyr0b16bf12019-11-03 05:10:12 +01001445 setverdict(pass);
Philipp Maier2a98a732018-03-19 16:06:12 +01001446 }
Neels Hofmeyr0b16bf12019-11-03 05:10:12 +01001447 [not g_pars.ran_is_geran] BSSAP.receive(tr_RANAP_IuReleaseCommand(?)) {
1448 log("f_call_hangup 5.iu: rx Iu Release Command");
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001449 BSSAP.send(ts_RANAP_IuReleaseComplete);
1450 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND);
Neels Hofmeyr0b16bf12019-11-03 05:10:12 +01001451 log("f_call_hangup 6.iu: rx SCCP DISC");
1452 setverdict(pass);
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001453 }
1454 }
1455
Neels Hofmeyr0b16bf12019-11-03 05:10:12 +01001456 f_sleep(1.0);
Neels Hofmeyr2ca1ab42019-03-08 03:45:43 +01001457 f_create_mgcp_delete_ep(cpars.mgcp_ep);
1458 log("f_call_hangup 9: done");
1459
1460 deactivate(mdcx);
Neels Hofmeyr0b16bf12019-11-03 05:10:12 +01001461 deactivate(dlcx);
Philipp Maier3716a5e2018-03-21 15:53:35 +01001462}
1463
1464function f_mt_call(inout CallParameters cpars)
1465runs on BSC_ConnHdlr {
1466
1467 f_mt_call_establish(cpars);
1468
Neels Hofmeyrba960a12019-11-02 19:17:38 +01001469 log("Hold the call for some time");
Philipp Maier3716a5e2018-03-21 15:53:35 +01001470 f_sleep(3.0);
1471
Neels Hofmeyrba960a12019-11-02 19:17:38 +01001472 log("Hangup");
Philipp Maier3716a5e2018-03-21 15:53:35 +01001473 f_call_hangup(cpars, true);
1474
1475 setverdict(pass);
1476}
1477
1478function f_mo_call(inout CallParameters cpars)
1479runs on BSC_ConnHdlr {
1480
1481 f_mo_call_establish(cpars);
1482
Neels Hofmeyrba960a12019-11-02 19:17:38 +01001483 log("Hold the call for some time");
Philipp Maier3716a5e2018-03-21 15:53:35 +01001484 f_sleep(3.0);
1485
Neels Hofmeyrba960a12019-11-02 19:17:38 +01001486 log("Hangup");
Philipp Maier3716a5e2018-03-21 15:53:35 +01001487 f_call_hangup(cpars, false);
1488
Harald Welteb71901a2018-01-26 19:16:05 +01001489 setverdict(pass);
1490}
Harald Weltea49e36e2018-01-21 19:29:33 +01001491
Daniel Willmann8b084372018-02-04 13:35:26 +01001492function f_mo_seq_dtmf_dup(inout CallParameters cpars)
1493runs on BSC_ConnHdlr {
1494
1495 timer T := 1.0;
Daniel Willmann8b084372018-02-04 13:35:26 +01001496 var MNCC_PDU mncc;
1497 var MgcpCommand mgcp_cmd;
1498 var template PDU_ML3_MS_NW dtmf_dtap;
1499
Neels Hofmeyr3d22e4a2019-10-03 04:07:47 +02001500 f_mo_call_establish(cpars);
Daniel Willmann8b084372018-02-04 13:35:26 +01001501
Neels Hofmeyr3d22e4a2019-10-03 04:07:47 +02001502 /* Send DTMF: send the exact same DTAP message twice, the dup should be filtered out by
1503 * 3GPP TS 24.007 11.2.3.2 Message Type Octet / Duplicate Detection. */
Daniel Willmann8b084372018-02-04 13:35:26 +01001504
Neels Hofmeyr3d22e4a2019-10-03 04:07:47 +02001505 /* Find out the next NSD that will be used, from RAN emulation. */
1506 var N_Sd_Array last_n_sd := f_bssmap_last_n_sd();
1507 var uint2_t next_n_sd := f_next_n_sd(last_n_sd, 0 /* cc is index 0 */);
Daniel Willmann8b084372018-02-04 13:35:26 +01001508
Neels Hofmeyr3d22e4a2019-10-03 04:07:47 +02001509 /* Compose DTAP with this correct NSD */
Daniel Willmann8b084372018-02-04 13:35:26 +01001510 dtmf_dtap := ts_ML3_MO_CC_START_DTMF(cpars.transaction_id, "2");
Neels Hofmeyr3d22e4a2019-10-03 04:07:47 +02001511
1512 /* Here, pass skip_seq_patching == false so that the RAN Emulation NSD increments after this message. */
1513 BSSAP.send(ts_PDU_DTAP_MO(dtmf_dtap, '00'O, false));
Daniel Willmann8b084372018-02-04 13:35:26 +01001514 T.start;
1515 alt {
Neels Hofmeyr3d22e4a2019-10-03 04:07:47 +02001516 [] MNCC.receive(tr_MNCC_START_DTMF_ind(cpars.mncc_callref, "2")) {
1517 log("f_mo_seq_dtmf_dup() 1: got first START_DTMF_ind");
1518 }
Daniel Willmann8b084372018-02-04 13:35:26 +01001519 [] T.timeout {
1520 setverdict(fail, "Timeout waiting for START_DTMF_ind");
Daniel Willmannafce8662018-07-06 23:11:32 +02001521 mtc.stop;
Daniel Willmann8b084372018-02-04 13:35:26 +01001522 }
1523 }
1524
Neels Hofmeyr3d22e4a2019-10-03 04:07:47 +02001525 /* Send the exact same DTAP with above NSD, which is now incorrect (has not incremented), so that this message
1526 * will get filtered by the duplicate detection. Write NSD into DTAP and pass skip_seq_patching == true. */
1527 dtmf_dtap.msgs.cc.startDTMF.nsd := int2bit(next_n_sd, 2);
Daniel Willmann92f66272018-02-06 15:50:52 +01001528 BSSAP.send(ts_PDU_DTAP_MO(dtmf_dtap, '00'O, true));
Daniel Willmann8b084372018-02-04 13:35:26 +01001529 T.start;
1530 alt {
1531 [] MNCC.receive(tr_MNCC_START_DTMF_ind(cpars.mncc_callref, "2")) {
Neels Hofmeyr3d22e4a2019-10-03 04:07:47 +02001532 setverdict(fail, "f_mo_seq_dtmf_dup() 2: Received duplicate START_DTMF_ind");
Daniel Willmannafce8662018-07-06 23:11:32 +02001533 mtc.stop;
Daniel Willmann8b084372018-02-04 13:35:26 +01001534 }
1535 [] T.timeout { }
1536 }
1537
Neels Hofmeyr3d22e4a2019-10-03 04:07:47 +02001538 /* Here the NSD should be correct again and we see a DTMF. */
Daniel Willmann8b084372018-02-04 13:35:26 +01001539 dtmf_dtap := ts_ML3_MO_CC_START_DTMF(cpars.transaction_id, "3");
Neels Hofmeyr3d22e4a2019-10-03 04:07:47 +02001540 BSSAP.send(ts_PDU_DTAP_MO(dtmf_dtap, '00'O, false));
Daniel Willmann8b084372018-02-04 13:35:26 +01001541 alt {
Neels Hofmeyr3d22e4a2019-10-03 04:07:47 +02001542 [] MNCC.receive(tr_MNCC_START_DTMF_ind(cpars.mncc_callref, "3")) {
1543 log("f_mo_seq_dtmf_dup() 3: got second START_DTMF_ind");
1544 }
Daniel Willmann8b084372018-02-04 13:35:26 +01001545 [] T.timeout {
Neels Hofmeyr3d22e4a2019-10-03 04:07:47 +02001546 setverdict(fail, "Timeout waiting for final START_DTMF_ind");
Daniel Willmannafce8662018-07-06 23:11:32 +02001547 mtc.stop;
Daniel Willmann8b084372018-02-04 13:35:26 +01001548 }
1549 }
1550
Neels Hofmeyr3d22e4a2019-10-03 04:07:47 +02001551 f_call_hangup(cpars, true);
Daniel Willmann8b084372018-02-04 13:35:26 +01001552 setverdict(pass);
1553}
Harald Welte9b751a62019-04-14 17:39:29 +02001554
Harald Welte1ddc7162018-01-27 14:25:46 +01001555/* expect a clear command */
Harald Welte5946b332018-03-18 23:32:21 +01001556altstep as_clear_cmd_compl_disc(float t := 5.0) runs on BSC_ConnHdlr {
Neels Hofmeyr6b468a42019-03-06 15:25:14 +01001557 var PDU_BSSAP bssap;
Harald Welte5946b332018-03-18 23:32:21 +01001558 [] BSSAP.receive(tr_BSSMAP_ClearCommand) {
1559 BSSAP.send(ts_BSSMAP_ClearComplete);
1560 alt {
Harald Welte6811d102019-04-14 22:23:14 +02001561 [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {
Harald Welte5946b332018-03-18 23:32:21 +01001562 setverdict(pass);
1563 }
1564 [] BSSAP.receive {
1565 setverdict(fail, "Unexpected BSSMAP while waiting for SCCP Release");
Daniel Willmannafce8662018-07-06 23:11:32 +02001566 mtc.stop;
Harald Welte5946b332018-03-18 23:32:21 +01001567 }
1568 }
1569 }
Neels Hofmeyr6b468a42019-03-06 15:25:14 +01001570 [] BSSAP.receive(tr_BSSAP_BSSMAP) -> value bssap {
1571 setverdict(fail, "Unexpected BSSMAP while waiting for ClearCommand", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02001572 mtc.stop;
Harald Welte5946b332018-03-18 23:32:21 +01001573 }
1574}
1575
Harald Welte1ddc7162018-01-27 14:25:46 +01001576function f_expect_clear(float t := 5.0) runs on BSC_ConnHdlr {
1577 timer T := t;
1578
1579 T.start;
1580 alt {
Harald Welte9b751a62019-04-14 17:39:29 +02001581 [g_pars.ran_is_geran] as_clear_cmd_compl_disc(t) { }
1582 [not g_pars.ran_is_geran] as_iu_release_compl_disc(t) { }
Harald Welte1ddc7162018-01-27 14:25:46 +01001583 [] T.timeout {
Harald Welte5946b332018-03-18 23:32:21 +01001584 setverdict(fail, "Timeout waiting for ClearCommand/Release");
Daniel Willmannafce8662018-07-06 23:11:32 +02001585 mtc.stop;
Harald Welte1ddc7162018-01-27 14:25:46 +01001586 }
1587 }
1588}
1589
Neels Hofmeyr0ac63152019-05-07 01:20:17 +02001590function f_create_bssmap_exp_handoverRequest(integer targetPointCode) runs on BSC_ConnHdlr {
1591 BSSAP_PROC.call(RAN_register_handoverRequest:{targetPointCode, self}) {
1592 [] BSSAP_PROC.getreply(RAN_register_handoverRequest:{?, ?}) {};
1593 }
1594}
1595
1596function f_bssmap_last_n_sd() runs on BSC_ConnHdlr return N_Sd_Array {
1597 var N_Sd_Array last_n_sd;
1598 BSSAP_PROC.call(RAN_last_n_sd:{self, -}) {
1599 [] BSSAP_PROC.getreply(RAN_last_n_sd:{self, ?}) -> param(last_n_sd) {
1600 return last_n_sd;
1601 };
1602 }
1603}
1604
1605function f_bssmap_continue_after_n_sd(N_Sd_Array last_n_sd) runs on BSC_ConnHdlr {
1606 BSSAP_PROC.call(RAN_continue_after_n_sd:{last_n_sd, self}) {
1607 [] BSSAP_PROC.getreply(RAN_continue_after_n_sd:{last_n_sd, self});
1608 }
1609}
1610
Harald Weltef45efeb2018-04-09 18:19:24 +02001611type record SmsParametersTp {
1612 OCT1 msg_ref,
1613 TP_DA da,
1614 OCT1 pid,
1615 OCT1 dcs,
1616 integer udl,
1617 octetstring ud
1618}
1619type record SmsParametersRp {
1620 OCT1 msg_ref,
1621 RP_NumberingPlan_and_NumberDigits orig optional,
1622 RP_NumberingPlan_and_NumberDigits dest optional
1623}
1624type record SmsParameters {
1625 SmsParametersTp tp,
1626 SmsParametersRp rp,
1627 uint3_t tid,
1628 OCT1 dlci,
1629 uint7_t exp_rp_err optional
1630}
1631
1632template (value) TP_DA ts_TP_DA(BIT4 npl, BIT3 ton, hexstring addr) := {
1633 tP_DA_NoPad := {
1634 tP_LengthIndicator := 0, /* overwritten */
1635 tP_NumberingPlanID := npl,
1636 tP_TypeOfNumber := ton,
1637 tp_Spare := '0'B,
1638 tP_DAValue := addr
1639 }
1640}
1641
1642template (value) SmsParameters t_SmsPars(hexstring tp_daddr := '12345'H) := {
1643 tp := {
1644 msg_ref := '23'O,
1645 da := ts_TP_DA('0000'B, '000'B, tp_daddr),
1646 pid := '00'O,
1647 dcs := '00'O,
1648 udl := 0,
1649 ud := ''O
1650 },
1651 rp := {
1652 msg_ref := '42'O,
1653 orig := omit,
1654 dest := { '0000'B, '000'B, '0'B, '98765'H }
1655 },
1656 tid := 0,
1657 dlci := '03'O,
1658 exp_rp_err := omit
1659}
1660
1661private altstep as_other_sms() runs on BSC_ConnHdlr {
1662 [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_SMS(?, ?, ?), ?)) {
1663 setverdict(fail, "Unexpected SMS related PDU from MSC");
Daniel Willmannafce8662018-07-06 23:11:32 +02001664 mtc.stop;
Harald Weltef45efeb2018-04-09 18:19:24 +02001665 }
1666}
1667
Vadim Yanitskiy9cc019a2018-11-15 02:06:07 +07001668/* Submit a MO RP-SMMA over an already existing DTAP connection */
1669function f_mo_smma(inout SmsParameters spars)
1670runs on BSC_ConnHdlr {
1671 var template (value) RPDU_MS_SGSN rp_mo;
1672 var template (value) PDU_ML3_MS_NW l3_mo;
1673
1674 var default d := activate(as_other_sms());
1675
1676 /* just in case this is routed to SMPP.. */
1677 f_create_smpp_expect(hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue));
1678
1679 rp_mo := ts_RP_SMMA_MO(spars.rp.msg_ref);
1680 l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_DATA_MO(rp_mo));
1681 BSSAP.send(ts_PDU_DTAP_MO(l3_mo, spars.dlci, true));
1682 /* receive CP-ACK for CP-DATA above */
1683 BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_ACK_MT), spars.dlci));
1684
1685 deactivate(d);
1686 setverdict(pass);
1687}
1688
Vadim Yanitskiyd4cc1502018-11-12 01:46:21 +07001689/* Submit a MO-SMS over an already existing DTAP connection */
1690function f_mo_sms_submit(inout SmsParameters spars)
Harald Weltef45efeb2018-04-09 18:19:24 +02001691runs on BSC_ConnHdlr {
1692 var template (value) TPDU_RP_DATA_MS_SGSN tp_mo;
1693 var template (value) RPDU_MS_SGSN rp_mo;
1694 var template (value) PDU_ML3_MS_NW l3_mo;
1695
Harald Weltef45efeb2018-04-09 18:19:24 +02001696 var default d := activate(as_other_sms());
1697
Harald Weltef640a012018-04-14 17:49:21 +02001698 /* just in case this is routed to SMPP.. */
1699 f_create_smpp_expect(hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue));
1700
Harald Weltef45efeb2018-04-09 18:19:24 +02001701 tp_mo := ts_SMS_SUBMIT(spars.tp.msg_ref, spars.tp.da, spars.tp.pid, spars.tp.dcs,
1702 spars.tp.udl, spars.tp.ud);
1703 rp_mo := ts_RP_DATA_MO(spars.rp.msg_ref, spars.rp.orig, spars.rp.dest, tp_mo);
1704 l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_DATA_MO(rp_mo));
1705 BSSAP.send(ts_PDU_DTAP_MO(l3_mo, spars.dlci, true));
1706 /* receive CP-ACK for CP-DATA above */
1707 BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_ACK_MT), spars.dlci));
1708
Vadim Yanitskiyd4cc1502018-11-12 01:46:21 +07001709 deactivate(d);
1710 setverdict(pass);
1711}
1712
1713/* Wait RP-ACK for MO-SMS on an already existing DTAP connection */
1714function f_mo_sms_wait_rp_ack(inout SmsParameters spars)
1715runs on BSC_ConnHdlr {
1716 var template (value) PDU_ML3_MS_NW l3_mo;
1717
1718 var template TPDU_RP_DATA_SGSN_MS tp_mt;
1719 var template RPDU_SGSN_MS rp_mt;
1720 var template PDU_ML3_NW_MS l3_mt;
1721
1722 var default d := activate(as_other_sms());
1723
1724 /* just in case this is routed to SMPP.. */
1725 f_create_smpp_expect(hex2str(spars.tp.da.tP_DA_NoPad.tP_DAValue));
1726
Harald Weltef45efeb2018-04-09 18:19:24 +02001727 if (ispresent(spars.exp_rp_err)) {
1728 /* expect an RP-ERROR message from MSC with given cause */
1729 rp_mt := tr_RP_ERROR_MT(spars.rp.msg_ref, spars.exp_rp_err);
1730 l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_DATA_MT(rp_mt));
1731 BSSAP.receive(tr_PDU_DTAP_MT(l3_mt, spars.dlci));
1732 /* send CP-ACK for CP-DATA just received */
1733 l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_ACK_MO);
1734 BSSAP.send(ts_PDU_DTAP_MO(l3_mo, spars.dlci, true));
1735 } else {
1736 /* expect RP-ACK for RP-DATA */
1737 rp_mt := tr_RP_ACK_MT(spars.rp.msg_ref);
1738 l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_REPL, tr_CP_DATA_MT(rp_mt));
1739 BSSAP.receive(tr_PDU_DTAP_MT(l3_mt, spars.dlci));
1740 /* send CP-ACO for CP-DATA just received */
1741 l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_ORIG, ts_CP_ACK_MO);
1742 BSSAP.send(ts_PDU_DTAP_MO(l3_mo, spars.dlci, true));
1743 }
Vadim Yanitskiyd4cc1502018-11-12 01:46:21 +07001744
Harald Weltef45efeb2018-04-09 18:19:24 +02001745 deactivate(d);
1746 setverdict(pass);
1747}
1748
Vadim Yanitskiyd4cc1502018-11-12 01:46:21 +07001749/* Submit a MO-SMS, and wait for RP-ACK on an existing
1750 * (and authenticated, ...) DTAP connection */
1751function f_mo_sms(inout SmsParameters spars)
1752runs on BSC_ConnHdlr {
1753 f_mo_sms_submit(spars);
1754 f_mo_sms_wait_rp_ack(spars);
1755}
1756
Vadim Yanitskiy2159acb2018-11-24 02:50:29 +07001757/* Wait for MT SMS on an already existing DTAP connection */
1758function f_mt_sms_expect(inout SmsParameters spars)
Harald Weltef45efeb2018-04-09 18:19:24 +02001759runs on BSC_ConnHdlr {
Harald Weltef45efeb2018-04-09 18:19:24 +02001760 var template (value) PDU_ML3_MS_NW l3_mo;
Harald Weltef45efeb2018-04-09 18:19:24 +02001761 var template TPDU_RP_DATA_SGSN_MS tp_mt;
1762 var template RPDU_SGSN_MS rp_mt;
1763 var template PDU_ML3_NW_MS l3_mt;
Harald Weltef45efeb2018-04-09 18:19:24 +02001764 var PDU_DTAP_MT dtap_mt;
1765
1766 var default d := activate(as_other_sms());
1767
1768 /* Expect CP-DATA(RP-DATA(SMS-DELIVER)) */
1769 tp_mt := tr_SMS_DELIVER(?, spars.tp.ud, spars.tp.pid, spars.tp.dcs, ?);
1770 rp_mt := tr_RP_DATA_MT(?, ?, omit, tp_mt);
1771 l3_mt := tr_ML3_MT_SMS(?, c_TIF_ORIG, tr_CP_DATA_MT(rp_mt));
1772 BSSAP.receive(tr_PDU_DTAP_MT(l3_mt, spars.dlci)) -> value dtap_mt;
Vadim Yanitskiy2159acb2018-11-24 02:50:29 +07001773
Harald Weltef45efeb2018-04-09 18:19:24 +02001774 /* Extract relevant identifiers */
1775 spars.tid := bit2int(dtap_mt.dtap.tiOrSkip.transactionId.tio);
1776 spars.rp.msg_ref := dtap_mt.dtap.msgs.sms.cP_DATA.cP_User_Data.cP_RPDU.rP_DATA_SGSN_MS.rP_MessageReference;
1777
1778 /* send CP-ACK for CP-DATA just received */
1779 l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_REPL, ts_CP_ACK_MO);
1780 BSSAP.send(ts_PDU_DTAP_MO(l3_mo, spars.dlci, true));
1781
Vadim Yanitskiy2159acb2018-11-24 02:50:29 +07001782 deactivate(d);
1783 setverdict(pass);
1784}
1785
1786/* Send RP-ACK for MT-SMS over an already existing DTAP connection */
1787function f_mt_sms_send_rp_ack(inout SmsParameters spars)
1788runs on BSC_ConnHdlr {
1789 var template (value) RPDU_MS_SGSN rp_mo;
1790 var template (value) PDU_ML3_MS_NW l3_mo;
1791 var template PDU_ML3_NW_MS l3_mt;
1792
1793 var default d := activate(as_other_sms());
1794
Harald Weltef45efeb2018-04-09 18:19:24 +02001795 /* send RP-ACK for RP-DATA */
1796 rp_mo := ts_RP_ACK_MO(spars.rp.msg_ref);
1797 l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_REPL, ts_CP_DATA_MO(rp_mo));
1798 BSSAP.send(ts_PDU_DTAP_MO(l3_mo, spars.dlci, true));
1799
1800 /* expect CP-ACK for CP-DATA(RP-ACK) just sent */
Harald Weltee008eea2018-04-14 21:05:48 +02001801 l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_ORIG, tr_CP_ACK_MT);
Harald Weltef45efeb2018-04-09 18:19:24 +02001802 BSSAP.receive(tr_PDU_DTAP_MT(l3_mt, spars.dlci));
1803
1804 deactivate(d);
1805 setverdict(pass);
1806}
1807
Vadim Yanitskiy56318522018-11-24 03:40:47 +07001808/* Send RP-ERROR for MT-SMS over an already existing DTAP connection */
1809function f_mt_sms_send_rp_error(inout SmsParameters spars, uint7_t cause)
1810runs on BSC_ConnHdlr {
1811 var template (value) RPDU_MS_SGSN rp_mo;
1812 var template (value) PDU_ML3_MS_NW l3_mo;
1813 var template PDU_ML3_NW_MS l3_mt;
1814
1815 var default d := activate(as_other_sms());
1816
1817 /* send RP-ACK for RP-DATA */
1818 rp_mo := ts_RP_ERROR_MO(spars.rp.msg_ref, cause);
1819 l3_mo := ts_ML3_MO_SMS(spars.tid, c_TIF_REPL, ts_CP_DATA_MO(rp_mo));
1820 BSSAP.send(ts_PDU_DTAP_MO(l3_mo, spars.dlci, true));
1821
1822 /* expect CP-ACK for CP-DATA(RP-ERROR) just sent */
1823 l3_mt := tr_ML3_MT_SMS(spars.tid, c_TIF_ORIG, tr_CP_ACK_MT);
1824 BSSAP.receive(tr_PDU_DTAP_MT(l3_mt, spars.dlci));
1825
1826 deactivate(d);
1827 setverdict(pass);
1828}
1829
Vadim Yanitskiy2159acb2018-11-24 02:50:29 +07001830/* Wait for a MT-SMS and send RP-ACK over an already existing
1831 * (and authenticated, ...) DTAP connection */
1832function f_mt_sms(inout SmsParameters spars)
1833runs on BSC_ConnHdlr {
1834 f_mt_sms_expect(spars);
1835 f_mt_sms_send_rp_ack(spars);
1836}
Harald Weltea49e36e2018-01-21 19:29:33 +01001837
1838
Harald Weltea49e36e2018-01-21 19:29:33 +01001839}
1840
1841