Harald Welte | 0f7d03a | 2019-07-16 19:43:32 +0900 | [diff] [blame] | 1 | /* 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 | |
| 12 | module GTPv2_CodecPort { |
| 13 | import from IPL4asp_PortType all; |
| 14 | import from IPL4asp_Types all; |
| 15 | import from GTPv2C_Types all; |
| 16 | |
| 17 | /* identifies a remote peer (sender or receiver) */ |
| 18 | type record GtpPeer { |
| 19 | ConnectionId connId, |
| 20 | HostName remName, |
| 21 | PortNumber remPort |
| 22 | } |
| 23 | |
| 24 | /* Decoded GTP2C (Control Plane), used in send and receive direction */ |
| 25 | type record Gtp2cUnitdata { |
| 26 | GtpPeer peer, |
| 27 | 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 | } |