blob: 0c4e9d3be619b9b3289620e2ce0bc3dfc44edbe4 [file] [log] [blame]
Harald Welte0f7d03a2019-07-16 19:43:32 +09001/* dual-faced port sitting on top of IPL4_asp UDP to encode/decode GTPv2C
2 * (C) 2019 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
12module GTPv2_CodecPort {
13 import from IPL4asp_PortType all;
14 import from IPL4asp_Types all;
Harald Welteaf763aa2020-03-12 20:00:48 +010015 import from GTPv2_Types all;
Harald Welte0f7d03a2019-07-16 19:43:32 +090016
17 /* identifies a remote peer (sender or receiver) */
Pau Espin Pedrol4b090c92024-02-29 19:47:07 +010018 type record Gtp2cPeer {
Harald Welte0f7d03a2019-07-16 19:43:32 +090019 ConnectionId connId,
20 HostName remName,
Harald Welteaf763aa2020-03-12 20:00:48 +010021 IPL4asp_Types.PortNumber remPort
Harald Welte0f7d03a2019-07-16 19:43:32 +090022 }
23
24 /* Decoded GTP2C (Control Plane), used in send and receive direction */
25 type record Gtp2cUnitdata {
Pau Espin Pedrol4b090c92024-02-29 19:47:07 +010026 Gtp2cPeer peer,
Harald Welte0f7d03a2019-07-16 19:43:32 +090027 PDU_GTPCv2 gtpc
28 }
29
30 /* Translation port on top of IPL4asp; ASP_Event passed through transparently */
31 type port GTPv2C_PT message {
32 out Gtp2cUnitdata;
33 in Gtp2cUnitdata,
34 ASP_ConnId_ReadyToRelease,
35 ASP_Event;
36 } with { extension "user IPL4asp_PT
37 out(Gtp2cUnitdata -> ASP_SendTo: function(f_enc_Gtp2cUD))
38 in(ASP_RecvFrom -> Gtp2cUnitdata: function(f_dec_Gtp2cUD);
39 ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
40 ASP_Event -> ASP_Event: simple)" }
41
42 private function f_enc_Gtp2cUD(in Gtp2cUnitdata in_ud, out ASP_SendTo out_ud) {
43 out_ud.connId := in_ud.peer.connId;
44 out_ud.remName := in_ud.peer.remName;
45 out_ud.remPort := in_ud.peer.remPort;
46 out_ud.proto := { udp := {} };
47 out_ud.msg := enc_PDU_GTPCv2(in_ud.gtpc);
48 } with { extension "prototype(fast)" };
49
50 private function f_dec_Gtp2cUD(in ASP_RecvFrom in_ud, out Gtp2cUnitdata out_ud) {
51 out_ud.peer.connId := in_ud.connId;
52 out_ud.peer.remName := in_ud.remName;
53 out_ud.peer.remPort := in_ud.remPort;
54 out_ud.gtpc := dec_PDU_GTPCv2(in_ud.msg);
55 } with { extension "prototype(fast)" };
56
57}