Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 1 | /* 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 Welte | 2560608 | 2017-08-03 17:00:40 +0200 | [diff] [blame] | 12 | module GTP_CodecPort { |
Harald Welte | 627c7c7 | 2017-08-03 18:17:02 +0200 | [diff] [blame] | 13 | import from IPL4asp_PortType all; |
| 14 | import from IPL4asp_Types all; |
Harald Welte | 2560608 | 2017-08-03 17:00:40 +0200 | [diff] [blame] | 15 | 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 Welte | 627c7c7 | 2017-08-03 18:17:02 +0200 | [diff] [blame] | 20 | ConnectionId connId, |
| 21 | HostName remName, |
| 22 | PortNumber remPort |
Harald Welte | 2560608 | 2017-08-03 17:00:40 +0200 | [diff] [blame] | 23 | } |
| 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 Welte | 627c7c7 | 2017-08-03 18:17:02 +0200 | [diff] [blame] | 37 | /* Translation port on top of IPL4asp; ASP_Event passed through transparently */ |
Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 38 | type port GTPC_PT message { |
| 39 | out Gtp1cUnitdata; |
| 40 | in Gtp1cUnitdata, |
Harald Welte | 04d74cd | 2017-11-19 09:29:51 +0100 | [diff] [blame] | 41 | ASP_ConnId_ReadyToRelease, |
Harald Welte | 627c7c7 | 2017-08-03 18:17:02 +0200 | [diff] [blame] | 42 | ASP_Event; |
Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 43 | } with { extension "user IPL4asp_PT |
| 44 | out(Gtp1cUnitdata -> ASP_SendTo: function(f_enc_Gtp1cUD)) |
| 45 | in(ASP_RecvFrom -> Gtp1cUnitdata: function(f_dec_Gtp1cUD); |
Harald Welte | 04d74cd | 2017-11-19 09:29:51 +0100 | [diff] [blame] | 46 | ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple; |
Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 47 | ASP_Event -> ASP_Event: simple)" } |
Harald Welte | 2560608 | 2017-08-03 17:00:40 +0200 | [diff] [blame] | 48 | |
Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 49 | private function f_enc_Gtp1cUD(in Gtp1cUnitdata in_ud, out ASP_SendTo out_ud) { |
Harald Welte | 627c7c7 | 2017-08-03 18:17:02 +0200 | [diff] [blame] | 50 | 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 Welte | 2560608 | 2017-08-03 17:00:40 +0200 | [diff] [blame] | 55 | } with { extension "prototype(fast)" }; |
| 56 | |
Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 57 | private function f_dec_Gtp1cUD(in ASP_RecvFrom in_ud, out Gtp1cUnitdata out_ud) { |
Harald Welte | 627c7c7 | 2017-08-03 18:17:02 +0200 | [diff] [blame] | 58 | 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 Welte | 2560608 | 2017-08-03 17:00:40 +0200 | [diff] [blame] | 62 | } with { extension "prototype(fast)" }; |
| 63 | |
| 64 | |
Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 65 | /* 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 Welte | 04d74cd | 2017-11-19 09:29:51 +0100 | [diff] [blame] | 69 | ASP_ConnId_ReadyToRelease, |
Harald Welte | 627c7c7 | 2017-08-03 18:17:02 +0200 | [diff] [blame] | 70 | ASP_Event; |
Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 71 | } with { extension "user IPL4asp_PT |
| 72 | out(Gtp1uUnitdata -> ASP_SendTo: function(f_enc_Gtp1uUD)) |
| 73 | in(ASP_RecvFrom -> Gtp1uUnitdata: function(f_dec_Gtp1uUD); |
Harald Welte | 04d74cd | 2017-11-19 09:29:51 +0100 | [diff] [blame] | 74 | ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple; |
Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 75 | ASP_Event -> ASP_Event: simple)" } |
Harald Welte | 2560608 | 2017-08-03 17:00:40 +0200 | [diff] [blame] | 76 | |
Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 77 | function f_enc_Gtp1uUD(in Gtp1uUnitdata in_ud, out ASP_SendTo out_ud) { |
Harald Welte | 627c7c7 | 2017-08-03 18:17:02 +0200 | [diff] [blame] | 78 | 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 Welte | 2560608 | 2017-08-03 17:00:40 +0200 | [diff] [blame] | 83 | } with { extension "prototype(fast)" }; |
| 84 | |
Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 85 | function f_dec_Gtp1uUD(in ASP_RecvFrom in_ud, out Gtp1uUnitdata out_ud) { |
Harald Welte | 627c7c7 | 2017-08-03 18:17:02 +0200 | [diff] [blame] | 86 | 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 Welte | 2560608 | 2017-08-03 17:00:40 +0200 | [diff] [blame] | 90 | } with { extension "prototype(fast)" }; |
Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 91 | |
Harald Welte | 2560608 | 2017-08-03 17:00:40 +0200 | [diff] [blame] | 92 | } |