diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2020-09-15 18:32:59 +0200 |
---|---|---|
committer | pespin <pespin@sysmocom.de> | 2020-09-16 10:24:40 +0000 |
commit | 28aa466dd9cef55520fdbe2cab9e4d9dc2f98a87 (patch) | |
tree | 6a9dfcf81e9aaa699073ca37f61ca436412681fa | |
parent | 609f1d6c10253ec53605df0c5731c19b45c85bd4 (diff) |
library: CBSP_Adapter: Improve robustness of rebind and reconnect
Change-Id: Ibafbc8496eeadd0ea1b97056ef3b8a92bc43e9f1
-rw-r--r-- | library/CBSP_Adapter.ttcn | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/library/CBSP_Adapter.ttcn b/library/CBSP_Adapter.ttcn index fe399aa..de89d58 100644 --- a/library/CBSP_Adapter.ttcn +++ b/library/CBSP_Adapter.ttcn @@ -41,6 +41,10 @@ function f_connect(charstring remote_host, IPL4asp_Types.PortNumber remote_port, runs on CBSP_Adapter_CT { var IPL4asp_Types.Result res; map(self:CBSP[idx], system:CBSP); + if (g_cbsp_conn_id[idx] != -1) { + CBSP_CodecPort_CtrlFunct.f_IPL4_close(CBSP[idx], g_cbsp_conn_id[idx], {tcp := {}}); + g_cbsp_conn_id[idx] := -1; + } res := CBSP_CodecPort_CtrlFunct.f_IPL4_connect(CBSP[idx], remote_host, remote_port, local_host, local_port, 0, { tcp :={} }); if (not ispresent(res.connId)) { @@ -58,7 +62,16 @@ function f_bind(charstring local_host, IPL4asp_Types.PortNumber local_port, inte runs on CBSP_Adapter_CT { var IPL4asp_Types.Result res; map(self:CBSP[idx], system:CBSP); + if (g_cbsp_conn_id[idx] != -1) { + CBSP_CodecPort_CtrlFunct.f_IPL4_close(CBSP[idx], g_cbsp_conn_id[idx], {tcp := {}}); + g_cbsp_conn_id[idx] := -1; + } res := CBSP_CodecPort_CtrlFunct.f_IPL4_listen(CBSP[idx], local_host, local_port, { tcp:={} }); + if (not ispresent(res.connId)) { + setverdict(fail, "Could not bind to CBSP port, check your configuration ", + "{local ", local_host, ":", local_port, "}"); + mtc.stop; + } g_cbsp_conn_id[idx] := res.connId; f_set_tcp_segmentation(idx); |