osmo-ttcn3-hacks/library/PFCP_CodecPort.ttcn

57 lines
1.7 KiB
Plaintext

/* dual-faced port sitting on top of IPL4_asp UDP to encode/decode PFCP
*
* (C) 2022 sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
* 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
*/
module PFCP_CodecPort {
import from IPL4asp_PortType all;
import from IPL4asp_Types all;
import from PFCP_Types all;
/* identifies a remote peer (sender or receiver) */
type record PFCP_Peer {
ConnectionId conn_id,
HostName remote_name,
PortNumber remote_port
}
type record PFCP_Unitdata {
PFCP_Peer peer,
PDU_PFCP pdu
}
/* Translation port on top of IPL4asp; ASP_Event passed through transparently */
type port PFCP_PT message {
out PFCP_Unitdata;
in PFCP_Unitdata,
ASP_ConnId_ReadyToRelease,
ASP_Event;
} with { extension "user IPL4asp_PT
out(PFCP_Unitdata -> ASP_SendTo: function(f_enc_pfcp_unitdata))
in(ASP_RecvFrom -> PFCP_Unitdata: function(f_dec_pfcp_unitdata);
ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
ASP_Event -> ASP_Event: simple)" }
private function f_enc_pfcp_unitdata(in PFCP_Unitdata in_ud, out ASP_SendTo out_ud) {
out_ud.connId := in_ud.peer.conn_id;
out_ud.remName := in_ud.peer.remote_name;
out_ud.remPort := in_ud.peer.remote_port;
out_ud.proto := { udp := {} };
out_ud.msg := enc_PDU_PFCP(in_ud.pdu);
} with { extension "prototype(fast)" };
private function f_dec_pfcp_unitdata(in ASP_RecvFrom in_ud, out PFCP_Unitdata out_ud) {
out_ud.peer.conn_id := in_ud.connId;
out_ud.peer.remote_name := in_ud.remName;
out_ud.peer.remote_port := in_ud.remPort;
out_ud.pdu := dec_PDU_PFCP(in_ud.msg);
} with { extension "prototype(fast)" };
}