osmo-ttcn3-hacks/library/CBSP_CodecPort.ttcn

65 lines
1.6 KiB
Plaintext

module CBSP_CodecPort {
/* Simple CBSP Codec Port, translating between raw TCP octetstring payload
* towards the IPL4asp port provider, and CBSP primitives
* which carry the decoded CBSP data types as payload.
*
* (C) 2018 by Harald Welte <laforge@gnumonks.org>
* All rights reserved.
*
* Released under the terms of GNU General Public License, Version 2 or
* (at your option) any later version.
*/
import from IPL4asp_PortType all;
import from IPL4asp_Types all;
import from CBSP_Types all;
type record CBSP_RecvFrom {
ConnectionId connId,
CBSP_PDU msg
}
type record CBSP_Send {
ConnectionId connId,
CBSP_PDU msg
}
template (value) CBSP_Send ts_CBSP_Send(ConnectionId conn_id, template (value) CBSP_PDU msg) := {
connId := conn_id,
msg := msg
}
template CBSP_RecvFrom tr_CBSP_Recv(template ConnectionId conn_id, template CBSP_PDU msg) := {
connId := conn_id,
msg := msg
}
private function IPL4_to_CBSP_RecvFrom(in ASP_RecvFrom pin, out CBSP_RecvFrom pout) {
pout.connId := pin.connId;
pout.msg := dec_CBSP_PDU(pin.msg);
} with { extension "prototype(fast)" }
private function CBSP_to_IPL4_Send(in CBSP_Send pin, out ASP_Send pout) {
pout.connId := pin.connId;
pout.proto := { tcp := {} };
pout.msg := enc_CBSP_PDU(pin.msg);
} with { extension "prototype(fast)" }
type port CBSP_CODEC_PT message {
out CBSP_Send;
in CBSP_RecvFrom,
ASP_ConnId_ReadyToRelease,
ASP_Event;
} with { extension "user IPL4asp_PT
out(CBSP_Send -> ASP_Send: function(CBSP_to_IPL4_Send))
in(ASP_RecvFrom -> CBSP_RecvFrom: function(IPL4_to_CBSP_RecvFrom);
ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
ASP_Event -> ASP_Event: simple)"
}
}