osmo-ttcn3-hacks/library/DIAMETER_CodecPort.ttcn

82 lines
2.2 KiB
Plaintext

module DIAMETER_CodecPort {
/* Simple DIAMETER Codec Port, translating between raw SCTP primitives with
* octetstring payload towards the IPL4asp provider, and DIAMETER primitives
* which carry the decoded DIAMETER data types as payload.
*
* (C) 2019 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.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
import from IPL4asp_PortType all;
import from IPL4asp_Types all;
import from DIAMETER_Types all;
type record DIAMETER_RecvFrom {
ConnectionId connId,
HostName remName,
PortNumber remPort,
HostName locName,
PortNumber locPort,
PDU_DIAMETER msg
};
template DIAMETER_RecvFrom t_DIAMETER_RecvFrom(template PDU_DIAMETER msg) := {
connId := ?,
remName := ?,
remPort := ?,
locName := ?,
locPort := ?,
msg := msg
}
type record DIAMETER_Send {
ConnectionId connId,
PDU_DIAMETER msg
}
template DIAMETER_Send t_DIAMETER_Send(template ConnectionId connId, template PDU_DIAMETER msg) := {
connId := connId,
msg := msg
}
private function IPL4_to_DIAMETER_RecvFrom(in ASP_RecvFrom pin, out DIAMETER_RecvFrom pout) {
pout.connId := pin.connId;
pout.remName := pin.remName;
pout.remPort := pin.remPort;
pout.locName := pin.locName;
pout.locPort := pin.locPort;
pout.msg := f_DIAMETER_Dec(pin.msg);
} with { extension "prototype(fast)" };
private function DIAMETER_to_IPL4_Send(in DIAMETER_Send pin, out ASP_Send pout) {
pout.connId := pin.connId;
pout.proto := {
sctp := {
sinfo_stream := omit,
sinfo_ppid := 46, /* plain text Diameter in SCTP DATA */
remSocks := omit,
assocId := omit
}
};
pout.msg := f_DIAMETER_Enc(pin.msg);
} with { extension "prototype(fast)" };
type port DIAMETER_CODEC_PT message {
out DIAMETER_Send;
in DIAMETER_RecvFrom,
ASP_ConnId_ReadyToRelease,
ASP_Event;
} with { extension "user IPL4asp_PT
out(DIAMETER_Send -> ASP_Send:function(DIAMETER_to_IPL4_Send))
in(ASP_RecvFrom -> DIAMETER_RecvFrom: function(IPL4_to_DIAMETER_RecvFrom);
ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
ASP_Event -> ASP_Event: simple)"
}
}