Iuh_Emulation: Avoid sending events to HNBAP if socket is not connected

This should hopefully fix HNB_Tests errors showing up in jenkins after
the test finishes:
Iuh_Emulation.ttcn:203 Dynamic test case error: Port HNBAP has neither connections nor mappings. Message cannot be sent on it.

Change-Id: Ide201425e81dcfe2fd395d820bdcbd74f5415ef5
This commit is contained in:
Pau Espin 2021-12-23 15:11:05 +01:00
parent 4a8c45f0ac
commit 066f46f9d6
1 changed files with 9 additions and 3 deletions

View File

@ -128,6 +128,12 @@ return IPL4asp_Types.ConnectionId {
return conn_id;
}
private function f_send_IUHEM_Event(template (value) IUHEM_Event evt) runs on Iuh_Emulation_CT {
if (HNBAP.checkstate("Connected")) {
HNBAP.send(evt);
}
}
function main(Iuh_conn_parameters p, charstring id) runs on Iuh_Emulation_CT {
var Result res;
g_pars := p;
@ -147,7 +153,7 @@ function main(Iuh_conn_parameters p, charstring id) runs on Iuh_Emulation_CT {
/* notify user about SCTP establishment */
if (p.remote_sctp_port != -1) {
HNBAP.send(IUHEM_Event:{up_down:=IUHEM_EVENT_UP});
f_send_IUHEM_Event(IUHEM_Event:{up_down:=IUHEM_EVENT_UP});
}
while (true) {
@ -194,13 +200,13 @@ function main(Iuh_conn_parameters p, charstring id) runs on Iuh_Emulation_CT {
g_last_conn_id := asp_evt.connOpened.connId;
log("Established a new Iuh connection (conn_id=", g_last_conn_id, ")");
HNBAP.send(IUHEM_Event:{up_down:=IUHEM_EVENT_UP}); /* TODO: send g_last_conn_id */
f_send_IUHEM_Event(IUHEM_Event:{up_down:=IUHEM_EVENT_UP}); /* TODO: send g_last_conn_id */
}
[] Iuh.receive(ASP_Event:{connClosed:=?}) -> value asp_evt {
log("Iuh: Closed");
g_self_conn_id := -1;
HNBAP.send(IUHEM_Event:{up_down:=IUHEM_EVENT_DOWN}); /* TODO: send asp_evt.connClosed.connId */
f_send_IUHEM_Event(IUHEM_Event:{up_down:=IUHEM_EVENT_DOWN}); /* TODO: send asp_evt.connClosed.connId */
if (not emu_is_server()) {
self.stop;
}