blob: a7ce1eae964e6e896c2a3238f70d97689e004249 [file] [log] [blame]
Harald Weltea49e36e2018-01-21 19:29:33 +01001module BSC_ConnectionHandler {
2
3import from General_Types all;
4import from Osmocom_Types all;
Harald Welteb71901a2018-01-26 19:16:05 +01005import from Native_Functions all;
Harald Weltea49e36e2018-01-21 19:29:33 +01006import from GSM_Types all;
Harald Welteb71901a2018-01-26 19:16:05 +01007import from IPL4asp_Types all;
Harald Weltea49e36e2018-01-21 19:29:33 +01008import from SCCPasp_Types all;
9import from BSSAP_Types all;
10import from BSSMAP_Emulation all;
11import from BSSMAP_Templates all;
12
13import from GSUP_Types all;
14import from GSUP_Emulation all;
15
16import from MNCC_Types all;
17import from MNCC_Emulation all;
18
Harald Welte4aa970c2018-01-26 10:38:09 +010019import from MGCP_Types all;
20import from MGCP_Emulation all;
Harald Welteb71901a2018-01-26 19:16:05 +010021import from MGCP_Templates all;
22import from SDP_Types all;
Harald Welte4aa970c2018-01-26 10:38:09 +010023
Harald Weltea49e36e2018-01-21 19:29:33 +010024import from MobileL3_Types all;
25import from MobileL3_CommonIE_Types all;
26import from MobileL3_MM_Types all;
Harald Welteb71901a2018-01-26 19:16:05 +010027import from MobileL3_CC_Types all;
Harald Weltea49e36e2018-01-21 19:29:33 +010028import from L3_Templates all;
29
30/* this component represents a single subscriber connection */
Harald Welte4aa970c2018-01-26 10:38:09 +010031type component BSC_ConnHdlr extends BSSAP_ConnHdlr, MNCC_ConnHdlr, GSUP_ConnHdlr, MGCP_ConnHdlr {
Harald Weltea49e36e2018-01-21 19:29:33 +010032 var BSC_ConnHdlrPars g_pars;
Harald Weltea10db902018-01-27 12:44:49 +010033 timer g_Tguard := 60.0;
Harald Weltea49e36e2018-01-21 19:29:33 +010034}
35
Harald Welte148a7082018-01-26 18:56:43 +010036type record AuthVector {
37 OCT16 rand,
38 OCT4 sres,
39 OCT8 kc
40 /* FIXME: 3G elements */
41}
42
Harald Weltea49e36e2018-01-21 19:29:33 +010043type record BSC_ConnHdlrPars {
44 SCCP_PAR_Address sccp_addr_own,
45 SCCP_PAR_Address sccp_addr_peer,
46 BSSMAP_IE_CellIdentifier cell_id,
Harald Welte256571e2018-01-24 18:47:19 +010047 hexstring imei,
Harald Weltea49e36e2018-01-21 19:29:33 +010048 hexstring imsi,
Harald Welte82600572018-01-21 20:54:08 +010049 hexstring msisdn,
Harald Welte256571e2018-01-24 18:47:19 +010050 OCT4 tmsi optional,
Harald Welte82600572018-01-21 20:54:08 +010051 BSSMAP_IE_ClassmarkInformationType2 cm2,
Harald Welte16114282018-01-24 22:41:21 +010052 BSSMAP_IE_ClassmarkInformationType3 cm3 optional,
Harald Welte148a7082018-01-26 18:56:43 +010053 AuthVector vec optional
Harald Weltea49e36e2018-01-21 19:29:33 +010054};
55
Harald Weltea10db902018-01-27 12:44:49 +010056/* altstep for the global guard timer */
57private altstep as_Tguard() runs on BSC_ConnHdlr {
58 [] g_Tguard.timeout {
59 setverdict(inconc, "Tguard timeout");
60 self.stop;
61 }
62}
63
64/* init function, called as first function in new BSC_ConnHdlr */
Harald Weltead2952e2018-01-27 14:12:46 +010065function f_init_handler(BSC_ConnHdlrPars pars, float t_guard := 60.0) runs on BSC_ConnHdlr {
Harald Weltea10db902018-01-27 12:44:49 +010066 /* make parameters available via component variable */
67 g_pars := pars;
68 /* Start guard timer and activate it as default */
Harald Weltead2952e2018-01-27 14:12:46 +010069 g_Tguard.start(t_guard);
Harald Weltea10db902018-01-27 12:44:49 +010070 activate(as_Tguard());
71}
72
Harald Weltea49e36e2018-01-21 19:29:33 +010073
74/* Callback function from general BSSMAP_Emulation whenever a connectionless
75 * BSSMAP message arrives. Canreturn a PDU_BSSAPthat should be sent in return */
76private function BscUnitdataCallback(PDU_BSSAP bssap)
77runs on BSSMAP_Emulation_CT return template PDU_BSSAP {
78 var template PDU_BSSAP resp := omit;
79
80 log("BSSMAP_BscUnitdataCallback");
81 /* answer all RESET with RESET ACK */
82 if (match(bssap, tr_BSSMAP_Reset)){
83 log("BSSMAP_BscUnitdataCallback: Responding to RESET with RESET-ACK");
84 resp := ts_BSSMAP_ResetAck;
85 }
86
87 /* FIXME: Handle paging, etc. */
88 return resp;
89}
90
91const BssmapOps BSC_BssmapOps := {
92 /* Create call-back for inbound connections from MSC (hand-over) */
93 create_cb := refers(BSSMAP_Emulation.ExpectedCreateCallback),
94 unitdata_cb := refers(BscUnitdataCallback),
95 decode_dtap := true,
96 role_ms := true
97}
98
99
100private function MnccUnitdataCallback(MNCC_PDU mncc)
101runs on MNCC_Emulation_CT return template MNCC_PDU {
102 log("Ignoring MNCC", mncc);
103 return omit;
104}
105
106const MnccOps BCC_MnccOps := {
107 create_cb := refers(MNCC_Emulation.ExpectedCreateCallback),
108 unitdata_cb := refers(MnccUnitdataCallback)
109}
110
111
112
113template BSSAP_Conn_Req ts_BSSAP_Conn_Req(SCCP_PAR_Address peer, SCCP_PAR_Address own, PDU_BSSAP bssap) := {
114 addr_peer := peer,
115 addr_own := own,
116 bssap := bssap
117};
118
Harald Weltea49e36e2018-01-21 19:29:33 +0100119/* Encode 'l3' and ask BSSMAP_Emulation to create new connection with COMPL L3 INFO */
120function f_bssap_compl_l3(PDU_ML3_MS_NW l3)
121runs on BSC_ConnHdlr {
122 log("Sending COMPL L3: ", l3);
123 var octetstring l3_enc := enc_PDU_ML3_MS_NW(l3);
124 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_own,
125 valueof(ts_BSSMAP_ComplL3(g_pars.cell_id, l3_enc))));
Harald Welte71b69332018-01-21 20:43:53 +0100126 alt {
127 [] BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_CONF_IND) {}
128 [] BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {
129 setverdict(fail, "DISC.ind from SCCP");
130 self.stop;
131 }
132 }
Harald Weltea49e36e2018-01-21 19:29:33 +0100133}
134
135/* helper function to fully establish a dedicated channel */
Harald Welte148a7082018-01-26 18:56:43 +0100136function f_establish_fully(MobileIdentityLV mi, boolean expect_auth, boolean expect_ciph)
Harald Weltea49e36e2018-01-21 19:29:33 +0100137runs on BSC_ConnHdlr {
Harald Welte6ed6bf92018-01-24 21:09:15 +0100138 var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi));
Harald Weltea49e36e2018-01-21 19:29:33 +0100139 var PDU_DTAP_MT dtap_mt;
140
141 /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */
142 f_bssap_compl_l3(l3_info);
143
Harald Welte148a7082018-01-26 18:56:43 +0100144 f_mm_common(expect_auth, expect_ciph);
145 if (expect_ciph) {
146 /* implicit CM SERVICE ACCEPT? */
147 } else {
148 /* explicit CM SERVICE ACCEPT */
149 BSSAP.receive(tr_PDU_DTAP_MT(tr_CM_SERV_ACC));
Harald Weltea49e36e2018-01-21 19:29:33 +0100150 }
Harald Weltea49e36e2018-01-21 19:29:33 +0100151}
152
Harald Welte812f7a42018-01-27 00:49:18 +0100153/* helper function to fully establish a dedicated channel */
154function f_establish_fully_pag(MobileIdentityLV mi, boolean expect_auth, boolean expect_ciph)
155runs on BSC_ConnHdlr {
156 var PDU_ML3_MS_NW l3_info := valueof(ts_PAG_RESP(mi));
157 var PDU_DTAP_MT dtap_mt;
158
159 /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */
160 f_bssap_compl_l3(l3_info);
161
162 f_mm_common(expect_auth, expect_ciph);
163}
164
165
Harald Weltea49e36e2018-01-21 19:29:33 +0100166/* build a PDU_ML3_MS_NW containing a Location Update by IMSI */
167function f_build_lu_imsi(hexstring imsi) return PDU_ML3_MS_NW
168{
169 var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(imsi));
170 return f_build_lu(mi);
171}
Harald Welteba7b6d92018-01-23 21:32:34 +0100172function f_build_lu_imei(hexstring imei) return PDU_ML3_MS_NW
173{
174 var MobileIdentityLV mi := valueof(ts_MI_IMEI_LV(imei));
175 return f_build_lu(mi);
176}
177function f_build_lu_tmsi(OCT4 tmsi) return PDU_ML3_MS_NW
178{
179 var MobileIdentityLV mi := valueof(ts_MI_TMSI_LV(tmsi));
180 return f_build_lu(mi);
181}
Harald Weltea49e36e2018-01-21 19:29:33 +0100182private function f_build_lu(MobileIdentityLV mi) return PDU_ML3_MS_NW
183{
184 var LocationAreaIdentification_V old_lai := { '62F220'O, '9999'O };
185 var PDU_ML3_MS_NW l3_info := valueof(ts_ML3_MO_LU_Req(valueof(ts_ML3_IE_LuType_Attach),
186 old_lai, mi, valueof(ts_CM1)));
187 return l3_info;
188}
189
Harald Weltecf66d5a2018-01-23 19:24:28 +0100190private function f_rnd_oct(integer len) return octetstring {
191 var integer i;
192 var octetstring res;
193 for (i := 0; i < len; i := i + 1) {
194 res[i] := int2oct(float2int(rnd()*256.0), 1);
195 }
196 return res;
197}
198
199function f_gen_auth_vec_2g() return AuthVector {
200 var AuthVector vec;
201 vec.rand := f_rnd_oct(16);
202 vec.sres := f_rnd_oct(4);
203 vec.kc := f_rnd_oct(8);
204 return vec;
205}
206
Harald Welte148a7082018-01-26 18:56:43 +0100207
208function f_mm_common(boolean expect_auth, boolean expect_ciph) runs on BSC_ConnHdlr
209{
210 if (expect_auth) {
211 g_pars.vec := f_gen_auth_vec_2g();
212 var GSUP_IE auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G(g_pars.vec.rand,
213 g_pars.vec.sres,
214 g_pars.vec.kc));
215 GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi));
216 GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple));
217
218 BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_MM_AUTH_REQ(g_pars.vec.rand)));
219 BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MT_MM_AUTH_RESP_2G(g_pars.vec.sres)));
220 }
221
222 if (expect_ciph) {
223 BSSAP.receive(tr_BSSMAP_CipherModeCmd(?, g_pars.vec.kc));
224 BSSAP.send(ts_BSSMAP_CipherModeCompl('02'O));
225 }
226}
227
Harald Welte16114282018-01-24 22:41:21 +0100228function f_perform_lu(boolean expect_auth, boolean expect_tmsi, boolean send_early_cm,
229 boolean expect_ciph := false)
Harald Weltea49e36e2018-01-21 19:29:33 +0100230runs on BSC_ConnHdlr {
231 var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi)
232 var PDU_DTAP_MT dtap_mt;
233
234 /* tell GSUP dispatcher to send this IMSI to us */
235 f_create_gsup_expect(hex2str(g_pars.imsi));
236
237 /* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */
238 f_bssap_compl_l3(l3_lu);
239
Harald Welte8a121b32018-01-22 03:00:41 +0100240 if (send_early_cm) {
241 BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3));
242 }
Harald Welte5c2622c2018-01-21 20:45:20 +0100243
Harald Welte148a7082018-01-26 18:56:43 +0100244 f_mm_common(expect_auth, expect_ciph);
Harald Welte16114282018-01-24 22:41:21 +0100245
Harald Weltea49e36e2018-01-21 19:29:33 +0100246 /* Expect MSC to perform LU with HLR */
247 GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi));
248 GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn));
249 GSUP.receive(tr_GSUP_ISD_RES(g_pars.imsi));
250 GSUP.send(ts_GSUP_UL_RES(g_pars.imsi));
251
252 alt {
253 [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) -> value dtap_mt {
254 var PDU_ML3_LocationUpdateAccept lu_acc := dtap_mt.dtap.msgs.mm.locationUpdateAccept;
255 if (expect_tmsi) {
256 if (not ispresent(lu_acc.mobileIdentityTLV) or
257 not ischosen(lu_acc.mobileIdentityTLV.mobileIdentityLV.mobileIdentityV.oddEvenInd_identity.tmsi_ptmsi)) {
258 setverdict(fail, "Expected TMSI but no TMSI was allocated");
259 self.stop;
260 } else {
Harald Welte256571e2018-01-24 18:47:19 +0100261 g_pars.tmsi := lu_acc.mobileIdentityTLV.mobileIdentityLV.mobileIdentityV.oddEvenInd_identity.tmsi_ptmsi.octets;
Harald Weltea49e36e2018-01-21 19:29:33 +0100262 BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_TmsiRealloc_Cmpl));
263 }
264 } else {
265 if (ispresent(lu_acc.mobileIdentityTLV) and
266 ischosen(lu_acc.mobileIdentityTLV.mobileIdentityLV.mobileIdentityV.oddEvenInd_identity.tmsi_ptmsi)) {
267 setverdict(fail, "Expected no TMSI but TMSI was allocated");
268 self.stop;
269 }
270 }
271 }
272 [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Rej)) {
273 setverdict(fail, "Expected LU ACK, but received LU REJ");
274 self.stop;
275 }
276 }
277 /* FIXME: there could be pending SMS or other common procedures by the MSC, let's ignore them */
278 BSSAP.receive(tr_BSSMAP_ClearCommand);
279 BSSAP.send(ts_BSSMAP_ClearComplete);
280 BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND);
281 setverdict(pass);
282}
283
284function f_foo() runs on BSC_ConnHdlr{
285 /* SCCP CC handled by BSSMAP_Emulation_CT.main() */
286 /* Expect auth, if enabled */
287
288 /* TODO: ISD */
289 /* Expect encr, if enabled */
290 /* Expect encr, if enabled */
291 /* Expect ASS CMD, if chan_type != requested */
292 /* Send ASS CMPL in successful case */
293
294 /* Expect AoIP port/ip information for RTP stream */
295 /* Expect MSC-originated MGCP to our simulated MGW */
296 /* Verify Counters via CTRL */
297 /* re-configure MSC behaviour via VTY */
298}
299
Harald Welteb71901a2018-01-26 19:16:05 +0100300/* parameters related to a (MO?) voice call */
301type record CallParameters {
302 boolean expect_auth, /* do we expect AUTHENTICATE from network */
303 boolean expect_ciph, /* do we expect CIPHER MODE from network */
304
305 /* CC related parameters */
306 hexstring called_party, /* whom are we calling */
307 integer transaction_id optional, /* which TS 04.08 CC transaction ID to use */
308 BearerCapability_TLV bearer_cap, /* which bearer capabilities to claim */
309
310 /* MNCC related parameters */
311 uint32_t mncc_callref optional, /* call reference on the MNCC side */
312 MNCC_bearer_cap mncc_bearer_cap optional, /* MNCC-side bearer capabilities */
313
314 /* RTP related parameters */
315 HostName bss_rtp_ip optional, /* BSS Side RTP IP */
316 PortNumber bss_rtp_port optional, /* BSS Side RTP Port */
317 HostName mss_rtp_ip optional, /* MSS Side RTP IP */
318 PortNumber mss_rtp_port optional, /* MSS Side RTP Port */
Harald Welte4017d552018-01-26 21:40:05 +0100319 HostName mgw_rtp_ip_bss, /* BSS-facing MGW RTP IP */
320 PortNumber mgw_rtp_port_bss, /* BSS-facing MGW RTP Port */
321 HostName mgw_rtp_ip_mss, /* MSS-facing MGW RTP IP */
322 PortNumber mgw_rtp_port_mss, /* MSS-facing MGW RTP Port */
Harald Welteb71901a2018-01-26 19:16:05 +0100323 uint7_t rtp_payload_type, /* dynamic RTP payload type */
324 charstring rtp_sdp_format, /* AMR/8000 or the like */
325
326 MgcpCallId mgcp_call_id optional, /* MGCP Call ID; CallAgent allocated */
327 MgcpEndpoint mgcp_ep optional /* MGCP Endpoint, CallAgent or MGW allocated */,
328 MgcpConnectionId mgcp_connection_id_bss, /* MGCP Connection ID BSS Side */
329 MgcpConnectionId mgcp_connection_id_mss /* MGCP Connection ID MSS Side */
330}
331
332template (value) CallParameters t_CallParams(hexstring called, integer tid) := {
333 expect_auth := false,
334 expect_ciph := false,
335 called_party := called,
336 transaction_id := tid,
337 bearer_cap := valueof(ts_Bcap_voice),
338 mncc_callref := omit,
339 mncc_bearer_cap := valueof(ts_MNCC_bcap_voice),
Harald Welte4017d552018-01-26 21:40:05 +0100340 bss_rtp_ip := "9.8.7.6",
341 bss_rtp_port := 9000,
Harald Welteb71901a2018-01-26 19:16:05 +0100342 mss_rtp_ip := omit,
343 mss_rtp_port := omit,
Harald Welte4017d552018-01-26 21:40:05 +0100344 mgw_rtp_ip_bss := "1.1.1.1",
345 mgw_rtp_port_bss := 10000,
346 mgw_rtp_ip_mss := "1.1.1.1",
347 mgw_rtp_port_mss := 11000,
Harald Welteb71901a2018-01-26 19:16:05 +0100348 rtp_payload_type := 98,
349 rtp_sdp_format := "AMR/8000",
350 mgcp_call_id := omit,
351 mgcp_ep := omit,
352 mgcp_connection_id_bss := '0'H,//
353 mgcp_connection_id_mss := '0'H //
354};
355
356
357function f_mo_call(inout CallParameters cpars)
358runs on BSC_ConnHdlr {
359
360 var MobileIdentityLV mi;
361 var MNCC_PDU mncc;
362 var MgcpCommand mgcp_cmd;
363
364 /* If we have a TMSI, use TMSI instead of IMSI */
365 if (ispresent(g_pars.tmsi)) {
366 mi := valueof(ts_MI_TMSI_LV(g_pars.tmsi));
367 } else {
368 mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
369 }
370 f_establish_fully(mi, cpars.expect_auth, cpars.expect_ciph);
371
372 /* Create MNCC and MGCP expect */
373 f_create_mncc_expect(hex2str(cpars.called_party));
374 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
375
376 BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_SETUP(cpars.transaction_id, cpars.called_party)));
377 interleave {
378 [] MNCC.receive(tr_MNCC_SETUP_ind(?, tr_MNCC_number(hex2str(cpars.called_party)))) -> value mncc {
379 cpars.mncc_callref := mncc.u.signal.callref;
380 /* Call Proceeding */
381 MNCC.send(ts_MNCC_CALL_PROC_req(cpars.mncc_callref, cpars.mncc_bearer_cap));
382 BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CALL_PROC(cpars.transaction_id)));
383 };
Harald Welte4017d552018-01-26 21:40:05 +0100384 /* First MGCP CRCX (for BSS/RAN side) */
Harald Welteb71901a2018-01-26 19:16:05 +0100385 [] MGCP.receive(tr_CRCX) -> value mgcp_cmd {
386 cpars.mgcp_call_id := f_MgcpCmd_extract_call_id(mgcp_cmd);
387 /* TODO: dynamic EP allocation case */
388 cpars.mgcp_ep := mgcp_cmd.line.ep;
Harald Welte4017d552018-01-26 21:40:05 +0100389 var SDP_Message sdp := valueof(ts_SDP(cpars.mgw_rtp_ip_bss, cpars.mgw_rtp_ip_bss,
Harald Welteb71901a2018-01-26 19:16:05 +0100390 hex2str(cpars.mgcp_call_id), "42",
Harald Welte4017d552018-01-26 21:40:05 +0100391 cpars.mgw_rtp_port_bss,
Harald Welteb71901a2018-01-26 19:16:05 +0100392 { int2str(cpars.rtp_payload_type) },
393 { valueof(ts_SDP_rtpmap(cpars.rtp_payload_type,
394 cpars.rtp_sdp_format)),
395 valueof(ts_SDP_ptime(20)) }));
396 MGCP.send(ts_CRCX_ACK(mgcp_cmd.line.trans_id, cpars.mgcp_connection_id_bss, sdp));
397 }
398 }
Harald Welte4017d552018-01-26 21:40:05 +0100399 /* Second MGCP CRCX (this time for MSS/CN side) */
400 MGCP.receive(tr_CRCX(cpars.mgcp_ep)) -> value mgcp_cmd {
401 var SDP_Message sdp := valueof(ts_SDP(cpars.mgw_rtp_ip_mss, cpars.mgw_rtp_ip_mss,
402 hex2str(cpars.mgcp_call_id), "42",
403 cpars.mgw_rtp_port_mss,
404 { int2str(cpars.rtp_payload_type) },
405 { valueof(ts_SDP_rtpmap(cpars.rtp_payload_type,
406 cpars.rtp_sdp_format)),
407 valueof(ts_SDP_ptime(20)) }));
408 MGCP.send(ts_CRCX_ACK(mgcp_cmd.line.trans_id, cpars.mgcp_connection_id_mss, sdp));
409 }
Harald Welteb71901a2018-01-26 19:16:05 +0100410
411 /* Alerting */
412 MNCC.send(ts_MNCC_ALERT_req(cpars.mncc_callref));
Harald Welteb71901a2018-01-26 19:16:05 +0100413
Harald Welte4017d552018-01-26 21:40:05 +0100414 var BSSMAP_IE_AoIP_TransportLayerAddress tla_ass :=
415 valueof(ts_BSSMAP_IE_AoIP_TLA4(f_inet_addr(cpars.mgw_rtp_ip_bss),cpars.mgw_rtp_port_bss));
416 interleave {
417 [] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_ALERTING(cpars.transaction_id))) {}
418 /* expect AoIP IP/Port to match what we returned in CRCX_ACK above */
419 [] BSSAP.receive(tr_BSSMAP_AssignmentReq(omit, tla_ass)) {
Harald Welteb71901a2018-01-26 19:16:05 +0100420 var BSSMAP_IE_AoIP_TransportLayerAddress tla;
421 tla := valueof(ts_BSSMAP_IE_AoIP_TLA4(f_inet_addr(cpars.bss_rtp_ip), cpars.bss_rtp_port));
422 BSSAP.send(ts_BSSMAP_AssignmentComplete(omit, tla));
423 }
424 }
425
Harald Welte4017d552018-01-26 21:40:05 +0100426 /* Answer. MNCC_SETUP_RSP -> CONNECT to MS; CONNECT_ACK from MS */
427 MNCC.send(ts_MNCC_SETUP_rsp(cpars.mncc_callref));
428 BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_CONNECT(cpars.transaction_id)));
429 BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_CONNECT_ACK(cpars.transaction_id)));
Harald Welteb71901a2018-01-26 19:16:05 +0100430
431 f_sleep(3.0);
432
433 /* Hangup by "B" side */
434 MNCC.send(ts_MNCC_DISC_req(cpars.mncc_callref, valueof(ts_MNCC_cause(23))));
435 BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_DISC(cpars.transaction_id)));
436
437 /* Release of call */
438 MNCC.send(ts_MNCC_REL_req(cpars.mncc_callref, valueof(ts_MNCC_cause(42))));
439 BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_CC_RELEASE(cpars.transaction_id)));
440 BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MO_CC_REL_COMPL(cpars.transaction_id)));
441
442 /* clearing of radio channel */
443 interleave {
444 [] BSSAP.receive(tr_BSSMAP_ClearCommand) {
445 BSSAP.send(ts_BSSMAP_ClearComplete);
446 BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND);
447 }
448 [] MGCP.receive(tr_DLCX(?)) -> value mgcp_cmd {
449 /* TODO: For one or all connections on EP? */
450 MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id));
451 f_create_mgcp_delete_ep(cpars.mgcp_ep);
452 }
453 }
454 setverdict(pass);
455}
Harald Weltea49e36e2018-01-21 19:29:33 +0100456
Harald Welte1ddc7162018-01-27 14:25:46 +0100457/* expect a clear command */
458function f_expect_clear(float t := 5.0) runs on BSC_ConnHdlr {
459 timer T := t;
460
461 T.start;
462 alt {
463 [] BSSAP.receive(tr_BSSMAP_ClearCommand) { }
464 [] BSSAP.receive {
465 setverdict(fail, "Unexpected BSSMAP while waiting for ClearCommand");
466 self.stop;
467 }
468 [] T.timeout {
469 setverdict(inconc, "Timeout waiting for ClearCommand");
470 self.stop;
471 }
472 }
473
474 BSSAP.send(ts_BSSMAP_ClearComplete);
475
476 T.start;
477 alt {
478 [] BSSAP.receive(BSSAP_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {
479 setverdict(pass);
480 }
481 [] BSSAP.receive {
482 setverdict(fail, "Unexpected BSSMAP while waiting for SCCP Release");
483 self.stop;
484 }
485 [] T.timeout {
486 setverdict(inconc, "Timeout waiting for SCCP Release");
487 self.stop;
488 }
489 }
490}
491
Harald Weltea49e36e2018-01-21 19:29:33 +0100492
493
494
495}
496
497