blob: 317210e15bc4e0357c0cd6d18c8882c8401b1345 [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
Pau Espin Pedrol3ede4f62022-02-14 18:55:56 +010018 modulepar {
19 SystemUnderTest mp_pl_SystemUnderTest := SGSN;
20 }
21
Harald Welte25606082017-08-03 17:00:40 +020022 /* identifies a remote peer (sender or receiver) */
23 type record GtpPeer {
Harald Welte627c7c72017-08-03 18:17:02 +020024 ConnectionId connId,
25 HostName remName,
26 PortNumber remPort
Harald Welte25606082017-08-03 17:00:40 +020027 }
28
29 /* Decoded GTP1C (Control Plane), used in send and receive direction */
30 type record Gtp1cUnitdata {
31 GtpPeer peer,
32 PDU_GTPC gtpc
33 }
34
35 /* Decoded GTP1U (User Plane), used in send and receive direction */
36 type record Gtp1uUnitdata {
37 GtpPeer peer,
38 PDU_GTPU gtpu
39 }
40
Harald Welte627c7c72017-08-03 18:17:02 +020041 /* Translation port on top of IPL4asp; ASP_Event passed through transparently */
Harald Welted418fc62017-08-04 00:34:42 +020042 type port GTPC_PT message {
43 out Gtp1cUnitdata;
44 in Gtp1cUnitdata,
Harald Welte04d74cd2017-11-19 09:29:51 +010045 ASP_ConnId_ReadyToRelease,
Harald Welte627c7c72017-08-03 18:17:02 +020046 ASP_Event;
Harald Welted418fc62017-08-04 00:34:42 +020047 } with { extension "user IPL4asp_PT
48 out(Gtp1cUnitdata -> ASP_SendTo: function(f_enc_Gtp1cUD))
49 in(ASP_RecvFrom -> Gtp1cUnitdata: function(f_dec_Gtp1cUD);
Harald Welte04d74cd2017-11-19 09:29:51 +010050 ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
Harald Welted418fc62017-08-04 00:34:42 +020051 ASP_Event -> ASP_Event: simple)" }
Harald Welte25606082017-08-03 17:00:40 +020052
Harald Welted418fc62017-08-04 00:34:42 +020053 private function f_enc_Gtp1cUD(in Gtp1cUnitdata in_ud, out ASP_SendTo out_ud) {
Harald Welte627c7c72017-08-03 18:17:02 +020054 out_ud.connId := in_ud.peer.connId;
55 out_ud.remName := in_ud.peer.remName;
56 out_ud.remPort := in_ud.peer.remPort;
57 out_ud.proto := { udp := {} };
58 out_ud.msg := enc_PDU_GTPC(in_ud.gtpc);
Harald Welte25606082017-08-03 17:00:40 +020059 } with { extension "prototype(fast)" };
60
Harald Welted418fc62017-08-04 00:34:42 +020061 private function f_dec_Gtp1cUD(in ASP_RecvFrom in_ud, out Gtp1cUnitdata out_ud) {
Harald Welte627c7c72017-08-03 18:17:02 +020062 out_ud.peer.connId := in_ud.connId;
63 out_ud.peer.remName := in_ud.remName;
64 out_ud.peer.remPort := in_ud.remPort;
Pau Espin Pedrol3ede4f62022-02-14 18:55:56 +010065 out_ud.gtpc := dec_PDU_GTPC(in_ud.msg, pl_SystemUnderTest := mp_pl_SystemUnderTest);
Harald Welte25606082017-08-03 17:00:40 +020066 } with { extension "prototype(fast)" };
67
68
Harald Welted418fc62017-08-04 00:34:42 +020069 /* dual-faced port on top of IPL4asp; ASP_Event passed through transparently */
70 type port GTPU_PT message {
71 out Gtp1uUnitdata;
72 in Gtp1uUnitdata,
Harald Welte04d74cd2017-11-19 09:29:51 +010073 ASP_ConnId_ReadyToRelease,
Harald Welte627c7c72017-08-03 18:17:02 +020074 ASP_Event;
Harald Welted418fc62017-08-04 00:34:42 +020075 } with { extension "user IPL4asp_PT
76 out(Gtp1uUnitdata -> ASP_SendTo: function(f_enc_Gtp1uUD))
77 in(ASP_RecvFrom -> Gtp1uUnitdata: function(f_dec_Gtp1uUD);
Harald Welte04d74cd2017-11-19 09:29:51 +010078 ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
Harald Welted418fc62017-08-04 00:34:42 +020079 ASP_Event -> ASP_Event: simple)" }
Harald Welte25606082017-08-03 17:00:40 +020080
Harald Welted418fc62017-08-04 00:34:42 +020081 function f_enc_Gtp1uUD(in Gtp1uUnitdata in_ud, out ASP_SendTo out_ud) {
Harald Welte627c7c72017-08-03 18:17:02 +020082 out_ud.connId := in_ud.peer.connId;
83 out_ud.remName := in_ud.peer.remName;
84 out_ud.remPort := in_ud.peer.remPort;
85 out_ud.proto := { udp := {} };
86 out_ud.msg := enc_PDU_GTPU(in_ud.gtpu);
Harald Welte25606082017-08-03 17:00:40 +020087 } with { extension "prototype(fast)" };
88
Harald Welted418fc62017-08-04 00:34:42 +020089 function f_dec_Gtp1uUD(in ASP_RecvFrom in_ud, out Gtp1uUnitdata out_ud) {
Harald Welte627c7c72017-08-03 18:17:02 +020090 out_ud.peer.connId := in_ud.connId;
91 out_ud.peer.remName := in_ud.remName;
92 out_ud.peer.remPort := in_ud.remPort;
93 out_ud.gtpu := dec_PDU_GTPU(in_ud.msg);
Harald Welte25606082017-08-03 17:00:40 +020094 } with { extension "prototype(fast)" };
Harald Welted418fc62017-08-04 00:34:42 +020095
Harald Welte25606082017-08-03 17:00:40 +020096}