From 61564be045e4e7686638a9e65e9f2e6aed13e9da Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Mon, 18 May 2020 20:44:14 +0700 Subject: library/IPA: split t_ASP_IPA_EVT_UD into send / receive templates Change-Id: Ib5494bff3f9aa0ac396b729c326e7b4a64c5a5dd --- library/IPA_Emulation.ttcnpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'library/IPA_Emulation.ttcnpp') diff --git a/library/IPA_Emulation.ttcnpp b/library/IPA_Emulation.ttcnpp index 6658ca86..0edc0a74 100644 --- a/library/IPA_Emulation.ttcnpp +++ b/library/IPA_Emulation.ttcnpp @@ -88,7 +88,11 @@ type union ASP_IPA_Event { ASP_IPA_EventType up_down } -template ASP_IPA_Event t_ASP_IPA_EVT_UD(ASP_IPA_EventType ud) := { +template (value) ASP_IPA_Event ts_ASP_IPA_EV(ASP_IPA_EventType ud) := { + up_down := ud +} + +template ASP_IPA_Event tr_ASP_IPA_EV(template ASP_IPA_EventType ud) := { up_down := ud } @@ -291,7 +295,7 @@ private template IpaCcmRespPart t_IdRespPart(IpaCcmIdTag tag, charstring payload data := char2oct(payload) & '00'O } -private function f_send_IPA_EVT(template ASP_IPA_Event evt) runs on IPA_Emulation_CT { +private function f_send_IPA_EVT(template (value) ASP_IPA_Event evt) runs on IPA_Emulation_CT { if (IPA_SP_PORT.checkstate("Connected")) { IPA_SP_PORT.send(evt); } @@ -410,7 +414,7 @@ private function f_ccm_rx_client(PDU_IPA_CCM ccm) runs on IPA_Emulation_CT { f_ccm_tx(valueof(ts_IPA_PONG)); } case (IPAC_MSGT_ID_ACK) { - f_send_IPA_EVT(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_ID_ACK)); + f_send_IPA_EVT(ts_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)); } case (IPAC_MSGT_ID_GET) { f_ccm_tx(f_ccm_make_id_resp(ccm)); @@ -432,7 +436,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)); + f_send_IPA_EVT(ts_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)); } case (IPAC_MSGT_ID_RESP) { log("IPA ID RESP: ", ccm.u.resp); @@ -488,7 +492,7 @@ function main_client(charstring remote_host, IPL4asp_Types.PortNumber remote_por /* we're a client: Send ID_ACK immediately after connect */ f_ccm_tx(valueof(ts_IPA_ACK)); } - f_send_IPA_EVT(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_UP)); + f_send_IPA_EVT(ts_ASP_IPA_EV(ASP_IPA_EVENT_UP)); ScanEvents(); } @@ -666,7 +670,7 @@ private function ScanEvents() runs on IPA_Emulation_CT { [] IPA_PORT.receive(ASP_Event:{connOpened:=?}) -> value asp_evt { log("IPA: Connected"); g_ipa_conn_id := asp_evt.connOpened.connId; - f_send_IPA_EVT(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_UP)); + f_send_IPA_EVT(ts_ASP_IPA_EV(ASP_IPA_EVENT_UP)); if (g_mode == IPA_MODE_SERVER and g_ccm_enabled) { select (g_init_behavior) { case (IPA_INIT_SEND_IPA_ID_GET) { @@ -682,14 +686,14 @@ private function ScanEvents() runs on IPA_Emulation_CT { [] IPA_PORT.receive(ASP_Event:{connClosed:=?}) -> value asp_evt { log("IPA: Closed"); g_ipa_conn_id := -1; - f_send_IPA_EVT(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_DOWN)); + f_send_IPA_EVT(ts_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)); self.stop; } [] IPA_PORT.receive(Socket_API_Definitions.PortEvent:{result:={errorCode:=ERROR_SOCKET, connId:=?, os_error_code:=?, os_error_text:=?}}) -> value port_evt { log("PortEvent: ERROR_SOCKET: ", port_evt); g_ipa_conn_id := -1; - f_send_IPA_EVT(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_DOWN)); + f_send_IPA_EVT(ts_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)); self.stop; } @@ -774,7 +778,7 @@ 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)) +function waiter_main(template ASP_IPA_Event wait_for := tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) runs on IPA_EventWaiter_CT { alt { -- cgit v1.2.3