This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Vadim Yanitskiy gerrit-no-reply at lists.osmocom.orgVadim Yanitskiy has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/18357 ) Change subject: library/IPA: fix server mode: properly handle multiple client connections ...................................................................... library/IPA: fix server mode: properly handle multiple client connections Change-Id: I93c58c08cf296e5cea81d811650caa1a09b8a579 --- M library/IPA_Emulation.ttcnpp 1 file changed, 33 insertions(+), 25 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/57/18357/1 diff --git a/library/IPA_Emulation.ttcnpp b/library/IPA_Emulation.ttcnpp index 0edc0a7..b9c7940 100644 --- a/library/IPA_Emulation.ttcnpp +++ b/library/IPA_Emulation.ttcnpp @@ -84,16 +84,21 @@ /* an event indicating us whether or not a connection is physically up or down, * and whether we have received an ID_ACK */ -type union ASP_IPA_Event { - ASP_IPA_EventType up_down +type record ASP_IPA_Event { + ASP_IPA_EventType ev_type, + IPL4asp_Types.ConnectionId conn_id } -template (value) ASP_IPA_Event ts_ASP_IPA_EV(ASP_IPA_EventType ud) := { - up_down := ud +template (value) ASP_IPA_Event ts_ASP_IPA_EV(ASP_IPA_EventType ev_type, + IPL4asp_Types.ConnectionId conn_id) := { + ev_type := ev_type, + conn_id := conn_id } -template ASP_IPA_Event tr_ASP_IPA_EV(template ASP_IPA_EventType ud) := { - up_down := ud +template ASP_IPA_Event tr_ASP_IPA_EV(template ASP_IPA_EventType ev_type, + template IPL4asp_Types.ConnectionId conn_id := ?) := { + ev_type := ev_type, + conn_id := conn_id } template ASP_IPA_Unitdata t_ASP_IPA_UD(IpaStreamId sid, octetstring pl, @@ -382,8 +387,9 @@ } /* transmit IPA CCM message */ -private function f_ccm_tx(PDU_IPA_CCM ccm) runs on IPA_Emulation_CT { - var IPA_Send ipa_tx := valueof(t_IPA_Send(g_ipa_conn_id, IPAC_PROTO_CCM, enc_PDU_IPA_CCM(ccm))); +private function f_ccm_tx(PDU_IPA_CCM ccm, IPL4asp_Types.ConnectionId conn_id) +runs on IPA_Emulation_CT { + var IPA_Send ipa_tx := valueof(t_IPA_Send(conn_id, IPAC_PROTO_CCM, enc_PDU_IPA_CCM(ccm))); log("CCM Tx:", ccm); IPA_PORT.send(ipa_tx); } @@ -411,13 +417,13 @@ private function f_ccm_rx_client(PDU_IPA_CCM ccm) runs on IPA_Emulation_CT { select (ccm.msg_type) { case (IPAC_MSGT_PING) { - f_ccm_tx(valueof(ts_IPA_PONG)); + f_ccm_tx(valueof(ts_IPA_PONG), g_ipa_conn_id); } case (IPAC_MSGT_ID_ACK) { - f_send_IPA_EVT(ts_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)); + f_send_IPA_EVT(ts_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK, g_ipa_conn_id)); } case (IPAC_MSGT_ID_GET) { - f_ccm_tx(f_ccm_make_id_resp(ccm)); + f_ccm_tx(f_ccm_make_id_resp(ccm), g_ipa_conn_id); } case else { log("Unknown/unsupported IPA CCM message type", ccm); @@ -425,10 +431,11 @@ } } -private function f_ccm_rx_server(PDU_IPA_CCM ccm) runs on IPA_Emulation_CT { +private function f_ccm_rx_server(PDU_IPA_CCM ccm, IPL4asp_Types.ConnectionId conn_id) +runs on IPA_Emulation_CT { select (ccm.msg_type) { case (IPAC_MSGT_PING) { - f_ccm_tx(valueof(ts_IPA_PONG)); + f_ccm_tx(valueof(ts_IPA_PONG), conn_id); } case (IPAC_MSGT_ID_ACK) { /* the IPA server should at some point receive an ID_ACK from the client, @@ -436,12 +443,12 @@ * 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(ts_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)); + f_send_IPA_EVT(ts_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK, conn_id)); } case (IPAC_MSGT_ID_RESP) { log("IPA ID RESP: ", ccm.u.resp); /* acknowledge any identity that the client may have sent */ - f_ccm_tx(valueof(ts_IPA_ACK)); + f_ccm_tx(valueof(ts_IPA_ACK), conn_id); } case else { log("Unknown/unsupported IPA CCM message type", ccm); @@ -490,9 +497,9 @@ f_connect(remote_host, remote_port, local_host, local_port, ccm_pars); if (g_ccm_enabled) { /* we're a client: Send ID_ACK immediately after connect */ - f_ccm_tx(valueof(ts_IPA_ACK)); + f_ccm_tx(valueof(ts_IPA_ACK), g_ipa_conn_id); } - f_send_IPA_EVT(ts_ASP_IPA_EV(ASP_IPA_EVENT_UP)); + f_send_IPA_EVT(ts_ASP_IPA_EV(ASP_IPA_EVENT_UP, g_ipa_conn_id)); ScanEvents(); } @@ -596,7 +603,7 @@ f_ccm_rx_client(ccm); } case (IPA_MODE_SERVER) { - f_ccm_rx_server(ccm); + f_ccm_rx_server(ccm, ipa_rx.connId); } case else { setverdict(fail, "Unknown mode"); @@ -668,16 +675,17 @@ /* server only */ [] IPA_PORT.receive(ASP_Event:{connOpened:=?}) -> value asp_evt { - log("IPA: Connected"); - g_ipa_conn_id := asp_evt.connOpened.connId; - f_send_IPA_EVT(ts_ASP_IPA_EV(ASP_IPA_EVENT_UP)); + var IPL4asp_Types.ConnectionId conn_id := asp_evt.connOpened.connId; + log("IPA: accepted a new client connection (conn_id=", conn_id, ")"); + + f_send_IPA_EVT(ts_ASP_IPA_EV(ASP_IPA_EVENT_UP, conn_id)); if (g_mode == IPA_MODE_SERVER and g_ccm_enabled) { select (g_init_behavior) { case (IPA_INIT_SEND_IPA_ID_GET) { - f_ccm_tx(valueof(ts_IPA_ID_GET)); + f_ccm_tx(valueof(ts_IPA_ID_GET), conn_id); } case (IPA_INIT_SEND_IPA_ID_ACK) { - f_ccm_tx(valueof(ts_IPA_ACK)); + f_ccm_tx(valueof(ts_IPA_ACK), conn_id); } } } @@ -686,14 +694,14 @@ [] IPA_PORT.receive(ASP_Event:{connClosed:=?}) -> value asp_evt { log("IPA: Closed"); g_ipa_conn_id := -1; - f_send_IPA_EVT(ts_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)); + f_send_IPA_EVT(ts_ASP_IPA_EV(ASP_IPA_EVENT_DOWN, asp_evt.connClosed.connId)); 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(ts_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)); + f_send_IPA_EVT(ts_ASP_IPA_EV(ASP_IPA_EVENT_DOWN, port_evt.result.connId)); self.stop; } -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/18357 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I93c58c08cf296e5cea81d811650caa1a09b8a579 Gerrit-Change-Number: 18357 Gerrit-PatchSet: 1 Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200518/9c2b1282/attachment.htm>