From 2e32e4321b4db01537919a725b679ad554d96dbc Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 24 May 2018 20:00:00 +0200 Subject: BSSAP/IPA integration: Wait for SCCPLite to be established Before this patch, we had some problems related to synchronization between the IPA transport, SCCP emulation and BSSAP layer in SCCPlite configurations. This code ensures that f_bssap_init() will block until the IPA connection (client or server) is established, and then start the SCCP and BSSAP emulation components in the right order. This in turn ensures that the initial BSSMAP RESET that we're sending from the TTCN-3 side is only sent once the IPA connection is fully established, and the CCM Identity handshake has happened before. Change-Id: I483ddd45c1cf631a5a9d8f862b6ca728b38bdc14 Related: OS#2544 --- library/BSSAP_Adapter.ttcn | 24 ++++++++++++++++++++---- library/IPA_Emulation.ttcnpp | 24 ++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/library/BSSAP_Adapter.ttcn b/library/BSSAP_Adapter.ttcn index 1a9fdb42..7404a6f6 100644 --- a/library/BSSAP_Adapter.ttcn +++ b/library/BSSAP_Adapter.ttcn @@ -28,8 +28,9 @@ import from BSSMAP_Emulation all; type record BSSAP_Adapter { /* component references */ - M3UA_CT vc_M3UA, /* only in 3GPP AoIP */ - IPA_Emulation_CT vc_IPA, /* only in SCCPliste */ + M3UA_CT vc_M3UA, /* only in 3GPP AoIP */ + IPA_Emulation_CT vc_IPA, /* only in SCCPlite */ + IPA_EventWaiter_CT vc_WAIT, /* only in SCCPlite */ SCCP_CT vc_SCCP, MSC_SCCP_MTP3_parameters sccp_pars, @@ -114,18 +115,32 @@ function f_bssap_init(inout BSSAP_Adapter ba, in BSSAP_Configuration cfg, charst map(ba.vc_IPA:IPA_PORT, system:IPA_CODEC_PT); /* connect MTP3 service provider (IPA) to lower side of SCCP */ connect(ba.vc_IPA:MTP3_SP_PORT, ba.vc_SCCP:MTP3_SCCP_PORT); + /* connect waiter to general IPA port (for ASP_IPA_Event) */ + ba.vc_WAIT := IPA_EventWaiter_CT.create(id & "-IPA-WAIT"); + connect(ba.vc_IPA:IPA_SP_PORT, ba.vc_WAIT:IPA_SP_PORT); + ba.vc_WAIT.start(IPA_Emulation.waiter_main()); ba.vc_IPA.start(IPA_Emulation.main_server(cfg.sctp_addr.local_ip_addr, cfg.sctp_addr.local_sctp_port)); + /* wait until we received an IPA CCM ID_ACK */ + ba.vc_WAIT.done; + disconnect(ba.vc_IPA:IPA_SP_PORT, ba.vc_WAIT:IPA_SP_PORT); } case (BSSAP_TRANSPORT_SCCPlite_CLIENT) { ba.vc_IPA := IPA_Emulation_CT.create(id & "-IPA"); map(ba.vc_IPA:IPA_PORT, system:IPA_CODEC_PT); /* connect MTP3 service provider (IPA) to lower side of SCCP */ connect(ba.vc_IPA:MTP3_SP_PORT, ba.vc_SCCP:MTP3_SCCP_PORT); + /* connect waiter to general IPA port (for ASP_IPA_Event) */ + ba.vc_WAIT := IPA_EventWaiter_CT.create(id & "-IPA-WAIT"); + connect(ba.vc_IPA:IPA_SP_PORT, ba.vc_WAIT:IPA_SP_PORT); + ba.vc_WAIT.start(IPA_Emulation.waiter_main()); ba.vc_IPA.start(IPA_Emulation.main_client(cfg.sctp_addr.remote_ip_addr, cfg.sctp_addr.remote_sctp_port, cfg.sctp_addr.local_ip_addr, cfg.sctp_addr.local_sctp_port)); + /* wait until we received an IPA CCM ID_ACK */ + ba.vc_WAIT.done; + disconnect(ba.vc_IPA:IPA_SP_PORT, ba.vc_WAIT:IPA_SP_PORT); } case else { setverdict(fail, "Unsuppored BSSAP_Transport"); @@ -133,8 +148,6 @@ function f_bssap_init(inout BSSAP_Adapter ba, in BSSAP_Configuration cfg, charst } } - ba.vc_SCCP.start(SCCPStart(ba.sccp_pars)); - if (isvalue(ops)) { timer T := 5.0; T.start; @@ -145,6 +158,9 @@ function f_bssap_init(inout BSSAP_Adapter ba, in BSSAP_Configuration cfg, charst /* start the BSSMAP emulation */ ba.vc_BSSMAP.start(BSSMAP_Emulation.main(valueof(ops), "")); } + + ba.vc_SCCP.start(SCCPStart(ba.sccp_pars)); + } diff --git a/library/IPA_Emulation.ttcnpp b/library/IPA_Emulation.ttcnpp index 41a3968d..df2b15e4 100644 --- a/library/IPA_Emulation.ttcnpp +++ b/library/IPA_Emulation.ttcnpp @@ -243,6 +243,9 @@ private template IpaCcmRespPart t_IdRespPart(IpaCcmIdTag tag, charstring payload } private function f_send_IPA_EVT(template ASP_IPA_Event evt) runs on IPA_Emulation_CT { + if (IPA_SP_PORT.checkstate("Connected")) { + IPA_SP_PORT.send(evt); + } #ifdef IPA_EMULATION_RSL if (IPA_RSL_PORT.checkstate("Connected")) { IPA_RSL_PORT.send(evt); @@ -368,6 +371,7 @@ private function f_ccm_rx_server(PDU_IPA_CCM ccm) runs on IPA_Emulation_CT { * the TCP connection is established. Other implementations may differ. * We currently ignore it completely - but actually we should make sure that * one ID_ACK is received by the server at some point */ + f_send_IPA_EVT(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_ID_ACK)); } case (IPAC_MSGT_ID_RESP) { log("IPA ID RESP: ", ccm.u.resp); @@ -635,4 +639,24 @@ private function ScanEvents() runs on IPA_Emulation_CT { } } +/*********************************************************************** + * IPA Event waiter component. Wait for ASP_IPA_EVENT_ID_ACK + ***********************************************************************/ + +type component IPA_EventWaiter_CT { + port IPA_SP_PT IPA_SP_PORT; +} + +function waiter_main(template ASP_IPA_Event wait_for := t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_ID_ACK)) +runs on IPA_EventWaiter_CT { + + alt { + [] IPA_SP_PORT.receive(wait_for) { + setverdict(pass); + } + [] IPA_SP_PORT.receive { repeat; } + } +} + + } -- cgit v1.2.3