blob: a8507a68a1f0f428514608c0831b6cae885a36c1 [file] [log] [blame]
Harald Welte34b5a952019-05-27 11:54:11 +02001/* dual-faced port sitting on top of IPL4_asp UDP to encode/decode GTP
2 * (C) 2017 Harald Welte <laforge@gnumonks.org>
3 * All rights reserved.
4 *
5 * Released under the terms of GNU General Public License, Version 2 or
6 * (at your option) any later version.
7 *
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
10
11
Harald Welte25606082017-08-03 17:00:40 +020012module GTP_CodecPort {
Harald Welte627c7c72017-08-03 18:17:02 +020013 import from IPL4asp_PortType all;
14 import from IPL4asp_Types all;
Harald Welte25606082017-08-03 17:00:40 +020015 import from GTPC_Types all;
16 import from GTPU_Types all;
17
18 /* identifies a remote peer (sender or receiver) */
19 type record GtpPeer {
Harald Welte627c7c72017-08-03 18:17:02 +020020 ConnectionId connId,
21 HostName remName,
22 PortNumber remPort
Harald Welte25606082017-08-03 17:00:40 +020023 }
24
25 /* Decoded GTP1C (Control Plane), used in send and receive direction */
26 type record Gtp1cUnitdata {
27 GtpPeer peer,
28 PDU_GTPC gtpc
29 }
30
31 /* Decoded GTP1U (User Plane), used in send and receive direction */
32 type record Gtp1uUnitdata {
33 GtpPeer peer,
34 PDU_GTPU gtpu
35 }
36
Harald Welte627c7c72017-08-03 18:17:02 +020037 /* Translation port on top of IPL4asp; ASP_Event passed through transparently */
Harald Welted418fc62017-08-04 00:34:42 +020038 type port GTPC_PT message {
39 out Gtp1cUnitdata;
40 in Gtp1cUnitdata,
Harald Welte04d74cd2017-11-19 09:29:51 +010041 ASP_ConnId_ReadyToRelease,
Harald Welte627c7c72017-08-03 18:17:02 +020042 ASP_Event;
Harald Welted418fc62017-08-04 00:34:42 +020043 } with { extension "user IPL4asp_PT
44 out(Gtp1cUnitdata -> ASP_SendTo: function(f_enc_Gtp1cUD))
45 in(ASP_RecvFrom -> Gtp1cUnitdata: function(f_dec_Gtp1cUD);
Harald Welte04d74cd2017-11-19 09:29:51 +010046 ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
Harald Welted418fc62017-08-04 00:34:42 +020047 ASP_Event -> ASP_Event: simple)" }
Harald Welte25606082017-08-03 17:00:40 +020048
Harald Welted418fc62017-08-04 00:34:42 +020049 private function f_enc_Gtp1cUD(in Gtp1cUnitdata in_ud, out ASP_SendTo out_ud) {
Harald Welte627c7c72017-08-03 18:17:02 +020050 out_ud.connId := in_ud.peer.connId;
51 out_ud.remName := in_ud.peer.remName;
52 out_ud.remPort := in_ud.peer.remPort;
53 out_ud.proto := { udp := {} };
54 out_ud.msg := enc_PDU_GTPC(in_ud.gtpc);
Harald Welte25606082017-08-03 17:00:40 +020055 } with { extension "prototype(fast)" };
56
Harald Welted418fc62017-08-04 00:34:42 +020057 private function f_dec_Gtp1cUD(in ASP_RecvFrom in_ud, out Gtp1cUnitdata out_ud) {
Harald Welte627c7c72017-08-03 18:17:02 +020058 out_ud.peer.connId := in_ud.connId;
59 out_ud.peer.remName := in_ud.remName;
60 out_ud.peer.remPort := in_ud.remPort;
61 out_ud.gtpc := dec_PDU_GTPC(in_ud.msg);
Harald Welte25606082017-08-03 17:00:40 +020062 } with { extension "prototype(fast)" };
63
64
Harald Welted418fc62017-08-04 00:34:42 +020065 /* dual-faced port on top of IPL4asp; ASP_Event passed through transparently */
66 type port GTPU_PT message {
67 out Gtp1uUnitdata;
68 in Gtp1uUnitdata,
Harald Welte04d74cd2017-11-19 09:29:51 +010069 ASP_ConnId_ReadyToRelease,
Harald Welte627c7c72017-08-03 18:17:02 +020070 ASP_Event;
Harald Welted418fc62017-08-04 00:34:42 +020071 } with { extension "user IPL4asp_PT
72 out(Gtp1uUnitdata -> ASP_SendTo: function(f_enc_Gtp1uUD))
73 in(ASP_RecvFrom -> Gtp1uUnitdata: function(f_dec_Gtp1uUD);
Harald Welte04d74cd2017-11-19 09:29:51 +010074 ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
Harald Welted418fc62017-08-04 00:34:42 +020075 ASP_Event -> ASP_Event: simple)" }
Harald Welte25606082017-08-03 17:00:40 +020076
Harald Welted418fc62017-08-04 00:34:42 +020077 function f_enc_Gtp1uUD(in Gtp1uUnitdata in_ud, out ASP_SendTo out_ud) {
Harald Welte627c7c72017-08-03 18:17:02 +020078 out_ud.connId := in_ud.peer.connId;
79 out_ud.remName := in_ud.peer.remName;
80 out_ud.remPort := in_ud.peer.remPort;
81 out_ud.proto := { udp := {} };
82 out_ud.msg := enc_PDU_GTPU(in_ud.gtpu);
Harald Welte25606082017-08-03 17:00:40 +020083 } with { extension "prototype(fast)" };
84
Harald Welted418fc62017-08-04 00:34:42 +020085 function f_dec_Gtp1uUD(in ASP_RecvFrom in_ud, out Gtp1uUnitdata out_ud) {
Harald Welte627c7c72017-08-03 18:17:02 +020086 out_ud.peer.connId := in_ud.connId;
87 out_ud.peer.remName := in_ud.remName;
88 out_ud.peer.remPort := in_ud.remPort;
89 out_ud.gtpu := dec_PDU_GTPU(in_ud.msg);
Harald Welte25606082017-08-03 17:00:40 +020090 } with { extension "prototype(fast)" };
Harald Welted418fc62017-08-04 00:34:42 +020091
Harald Welte25606082017-08-03 17:00:40 +020092}