blob: 561e5b9b0b21e94174cda002a9fd8a8b6d1a264e [file] [log] [blame]
Harald Welted418fc62017-08-04 00:34:42 +02001/* dual-faced port sitting on top of IPL4_asp UDP to encode/decode GTP */
Harald Welte25606082017-08-03 17:00:40 +02002/* (C) 2017 by Harald Welte <laforge@gnumonks.org */
3module GTP_CodecPort {
Harald Welte627c7c72017-08-03 18:17:02 +02004 import from IPL4asp_PortType all;
5 import from IPL4asp_Types all;
Harald Welte25606082017-08-03 17:00:40 +02006 import from GTPC_Types all;
7 import from GTPU_Types all;
8
9 /* identifies a remote peer (sender or receiver) */
10 type record GtpPeer {
Harald Welte627c7c72017-08-03 18:17:02 +020011 ConnectionId connId,
12 HostName remName,
13 PortNumber remPort
Harald Welte25606082017-08-03 17:00:40 +020014 }
15
16 /* Decoded GTP1C (Control Plane), used in send and receive direction */
17 type record Gtp1cUnitdata {
18 GtpPeer peer,
19 PDU_GTPC gtpc
20 }
21
22 /* Decoded GTP1U (User Plane), used in send and receive direction */
23 type record Gtp1uUnitdata {
24 GtpPeer peer,
25 PDU_GTPU gtpu
26 }
27
Harald Welte627c7c72017-08-03 18:17:02 +020028 /* Translation port on top of IPL4asp; ASP_Event passed through transparently */
Harald Welted418fc62017-08-04 00:34:42 +020029 type port GTPC_PT message {
30 out Gtp1cUnitdata;
31 in Gtp1cUnitdata,
Harald Welte627c7c72017-08-03 18:17:02 +020032 ASP_Event;
Harald Welted418fc62017-08-04 00:34:42 +020033 } with { extension "user IPL4asp_PT
34 out(Gtp1cUnitdata -> ASP_SendTo: function(f_enc_Gtp1cUD))
35 in(ASP_RecvFrom -> Gtp1cUnitdata: function(f_dec_Gtp1cUD);
36 ASP_Event -> ASP_Event: simple)" }
Harald Welte25606082017-08-03 17:00:40 +020037
Harald Welted418fc62017-08-04 00:34:42 +020038 private function f_enc_Gtp1cUD(in Gtp1cUnitdata in_ud, out ASP_SendTo out_ud) {
Harald Welte627c7c72017-08-03 18:17:02 +020039 out_ud.connId := in_ud.peer.connId;
40 out_ud.remName := in_ud.peer.remName;
41 out_ud.remPort := in_ud.peer.remPort;
42 out_ud.proto := { udp := {} };
43 out_ud.msg := enc_PDU_GTPC(in_ud.gtpc);
Harald Welte25606082017-08-03 17:00:40 +020044 } with { extension "prototype(fast)" };
45
Harald Welted418fc62017-08-04 00:34:42 +020046 private function f_dec_Gtp1cUD(in ASP_RecvFrom in_ud, out Gtp1cUnitdata out_ud) {
Harald Welte627c7c72017-08-03 18:17:02 +020047 out_ud.peer.connId := in_ud.connId;
48 out_ud.peer.remName := in_ud.remName;
49 out_ud.peer.remPort := in_ud.remPort;
50 out_ud.gtpc := dec_PDU_GTPC(in_ud.msg);
Harald Welte25606082017-08-03 17:00:40 +020051 } with { extension "prototype(fast)" };
52
53
Harald Welted418fc62017-08-04 00:34:42 +020054 /* dual-faced port on top of IPL4asp; ASP_Event passed through transparently */
55 type port GTPU_PT message {
56 out Gtp1uUnitdata;
57 in Gtp1uUnitdata,
Harald Welte627c7c72017-08-03 18:17:02 +020058 ASP_Event;
Harald Welted418fc62017-08-04 00:34:42 +020059 } with { extension "user IPL4asp_PT
60 out(Gtp1uUnitdata -> ASP_SendTo: function(f_enc_Gtp1uUD))
61 in(ASP_RecvFrom -> Gtp1uUnitdata: function(f_dec_Gtp1uUD);
62 ASP_Event -> ASP_Event: simple)" }
Harald Welte25606082017-08-03 17:00:40 +020063
Harald Welted418fc62017-08-04 00:34:42 +020064 function f_enc_Gtp1uUD(in Gtp1uUnitdata in_ud, out ASP_SendTo out_ud) {
Harald Welte627c7c72017-08-03 18:17:02 +020065 out_ud.connId := in_ud.peer.connId;
66 out_ud.remName := in_ud.peer.remName;
67 out_ud.remPort := in_ud.peer.remPort;
68 out_ud.proto := { udp := {} };
69 out_ud.msg := enc_PDU_GTPU(in_ud.gtpu);
Harald Welte25606082017-08-03 17:00:40 +020070 } with { extension "prototype(fast)" };
71
Harald Welted418fc62017-08-04 00:34:42 +020072 function f_dec_Gtp1uUD(in ASP_RecvFrom in_ud, out Gtp1uUnitdata out_ud) {
Harald Welte627c7c72017-08-03 18:17:02 +020073 out_ud.peer.connId := in_ud.connId;
74 out_ud.peer.remName := in_ud.remName;
75 out_ud.peer.remPort := in_ud.remPort;
76 out_ud.gtpu := dec_PDU_GTPU(in_ud.msg);
Harald Welte25606082017-08-03 17:00:40 +020077 } with { extension "prototype(fast)" };
Harald Welted418fc62017-08-04 00:34:42 +020078
Harald Welte25606082017-08-03 17:00:40 +020079}