2017-08-03 16:17:02 +00:00
|
|
|
/* Translation Port sitting on top of IPL4_asp UDP to encode/decode GTP */
|
2017-08-03 15:00:40 +00:00
|
|
|
/* (C) 2017 by Harald Welte <laforge@gnumonks.org */
|
|
|
|
module GTP_CodecPort {
|
2017-08-03 16:17:02 +00:00
|
|
|
import from IPL4asp_PortType all;
|
|
|
|
import from IPL4asp_Types all;
|
2017-08-03 15:00:40 +00:00
|
|
|
import from GTPC_Types all;
|
|
|
|
import from GTPU_Types all;
|
|
|
|
|
|
|
|
/* identifies a remote peer (sender or receiver) */
|
|
|
|
type record GtpPeer {
|
2017-08-03 16:17:02 +00:00
|
|
|
ConnectionId connId,
|
|
|
|
HostName remName,
|
|
|
|
PortNumber remPort
|
2017-08-03 15:00:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Decoded GTP1C (Control Plane), used in send and receive direction */
|
|
|
|
type record Gtp1cUnitdata {
|
|
|
|
GtpPeer peer,
|
|
|
|
PDU_GTPC gtpc
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Decoded GTP1U (User Plane), used in send and receive direction */
|
|
|
|
type record Gtp1uUnitdata {
|
|
|
|
GtpPeer peer,
|
|
|
|
PDU_GTPU gtpu
|
|
|
|
}
|
|
|
|
|
2017-08-03 16:17:02 +00:00
|
|
|
/* Translation port on top of IPL4asp; ASP_Event passed through transparently */
|
|
|
|
type port GTPC_PT message map to IPL4asp_PT {
|
|
|
|
out Gtp1cUnitdata to ASP_SendTo with f_enc_Gtp1cUD();
|
|
|
|
in Gtp1cUnitdata from ASP_RecvFrom with f_dec_Gtp1cUD(),
|
|
|
|
ASP_Event;
|
2017-08-03 15:00:40 +00:00
|
|
|
/* we can declare variables here and use them from all functions with "port" label */
|
|
|
|
}
|
|
|
|
|
2017-08-03 16:17:02 +00:00
|
|
|
function f_enc_Gtp1cUD(in Gtp1cUnitdata in_ud, out ASP_SendTo out_ud) port GTPC_PT {
|
|
|
|
out_ud.connId := in_ud.peer.connId;
|
|
|
|
out_ud.remName := in_ud.peer.remName;
|
|
|
|
out_ud.remPort := in_ud.peer.remPort;
|
|
|
|
out_ud.proto := { udp := {} };
|
|
|
|
out_ud.msg := enc_PDU_GTPC(in_ud.gtpc);
|
2017-08-03 15:00:40 +00:00
|
|
|
port.setstate(0);
|
|
|
|
} with { extension "prototype(fast)" };
|
|
|
|
|
2017-08-03 16:17:02 +00:00
|
|
|
function f_dec_Gtp1cUD(in ASP_RecvFrom in_ud, out Gtp1cUnitdata out_ud) port GTPC_PT {
|
|
|
|
out_ud.peer.connId := in_ud.connId;
|
|
|
|
out_ud.peer.remName := in_ud.remName;
|
|
|
|
out_ud.peer.remPort := in_ud.remPort;
|
|
|
|
out_ud.gtpc := dec_PDU_GTPC(in_ud.msg);
|
2017-08-03 15:00:40 +00:00
|
|
|
port.setstate(0);
|
|
|
|
} with { extension "prototype(fast)" };
|
|
|
|
|
|
|
|
|
2017-08-03 16:17:02 +00:00
|
|
|
/* Translation port on top of IPL4asp; ASP_Event passed through transparently */
|
|
|
|
type port GTPU_PT message map to IPL4asp_PT {
|
|
|
|
out Gtp1uUnitdata to ASP_SendTo with f_enc_Gtp1uUD();
|
|
|
|
in Gtp1uUnitdata from ASP_RecvFrom with f_dec_Gtp1uUD(),
|
|
|
|
ASP_Event;
|
2017-08-03 15:00:40 +00:00
|
|
|
/* we can declare variables here and use them from all functions with "port" label */
|
|
|
|
}
|
|
|
|
|
2017-08-03 16:17:02 +00:00
|
|
|
function f_enc_Gtp1uUD(in Gtp1uUnitdata in_ud, out ASP_SendTo out_ud) port GTPU_PT {
|
|
|
|
out_ud.connId := in_ud.peer.connId;
|
|
|
|
out_ud.remName := in_ud.peer.remName;
|
|
|
|
out_ud.remPort := in_ud.peer.remPort;
|
|
|
|
out_ud.proto := { udp := {} };
|
|
|
|
out_ud.msg := enc_PDU_GTPU(in_ud.gtpu);
|
2017-08-03 15:00:40 +00:00
|
|
|
port.setstate(0);
|
|
|
|
} with { extension "prototype(fast)" };
|
|
|
|
|
2017-08-03 16:17:02 +00:00
|
|
|
function f_dec_Gtp1uUD(in ASP_RecvFrom in_ud, out Gtp1uUnitdata out_ud) port GTPU_PT {
|
|
|
|
out_ud.peer.connId := in_ud.connId;
|
|
|
|
out_ud.peer.remName := in_ud.remName;
|
|
|
|
out_ud.peer.remPort := in_ud.remPort;
|
|
|
|
out_ud.gtpu := dec_PDU_GTPU(in_ud.msg);
|
2017-08-03 15:00:40 +00:00
|
|
|
port.setstate(0);
|
|
|
|
} with { extension "prototype(fast)" };
|
2017-08-03 16:17:02 +00:00
|
|
|
/*
|
|
|
|
function f_GTPC_listen(inout GTPC_PT portRef, in HostName locName,
|
|
|
|
in PortNumber locPort) return Result {
|
|
|
|
return f_IPL4_listen(portRef, locName, locPort, { udp := {} });
|
|
|
|
}
|
|
|
|
*/
|
2017-08-03 15:00:40 +00:00
|
|
|
}
|