Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 1 | /* dual-faced port sitting on top of IPL4_asp UDP to encode/decode GTP */ |
Harald Welte | 2560608 | 2017-08-03 17:00:40 +0200 | [diff] [blame] | 2 | /* (C) 2017 by Harald Welte <laforge@gnumonks.org */ |
| 3 | module GTP_CodecPort { |
Harald Welte | 627c7c7 | 2017-08-03 18:17:02 +0200 | [diff] [blame] | 4 | import from IPL4asp_PortType all; |
| 5 | import from IPL4asp_Types all; |
Harald Welte | 2560608 | 2017-08-03 17:00:40 +0200 | [diff] [blame] | 6 | 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 Welte | 627c7c7 | 2017-08-03 18:17:02 +0200 | [diff] [blame] | 11 | ConnectionId connId, |
| 12 | HostName remName, |
| 13 | PortNumber remPort |
Harald Welte | 2560608 | 2017-08-03 17:00:40 +0200 | [diff] [blame] | 14 | } |
| 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 Welte | 627c7c7 | 2017-08-03 18:17:02 +0200 | [diff] [blame] | 28 | /* Translation port on top of IPL4asp; ASP_Event passed through transparently */ |
Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 29 | type port GTPC_PT message { |
| 30 | out Gtp1cUnitdata; |
| 31 | in Gtp1cUnitdata, |
Harald Welte | 04d74cd | 2017-11-19 09:29:51 +0100 | [diff] [blame] | 32 | ASP_ConnId_ReadyToRelease, |
Harald Welte | 627c7c7 | 2017-08-03 18:17:02 +0200 | [diff] [blame] | 33 | ASP_Event; |
Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 34 | } with { extension "user IPL4asp_PT |
| 35 | out(Gtp1cUnitdata -> ASP_SendTo: function(f_enc_Gtp1cUD)) |
| 36 | in(ASP_RecvFrom -> Gtp1cUnitdata: function(f_dec_Gtp1cUD); |
Harald Welte | 04d74cd | 2017-11-19 09:29:51 +0100 | [diff] [blame] | 37 | ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple; |
Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 38 | ASP_Event -> ASP_Event: simple)" } |
Harald Welte | 2560608 | 2017-08-03 17:00:40 +0200 | [diff] [blame] | 39 | |
Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 40 | 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] | 41 | out_ud.connId := in_ud.peer.connId; |
| 42 | out_ud.remName := in_ud.peer.remName; |
| 43 | out_ud.remPort := in_ud.peer.remPort; |
| 44 | out_ud.proto := { udp := {} }; |
| 45 | out_ud.msg := enc_PDU_GTPC(in_ud.gtpc); |
Harald Welte | 2560608 | 2017-08-03 17:00:40 +0200 | [diff] [blame] | 46 | } with { extension "prototype(fast)" }; |
| 47 | |
Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 48 | 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] | 49 | out_ud.peer.connId := in_ud.connId; |
| 50 | out_ud.peer.remName := in_ud.remName; |
| 51 | out_ud.peer.remPort := in_ud.remPort; |
| 52 | out_ud.gtpc := dec_PDU_GTPC(in_ud.msg); |
Harald Welte | 2560608 | 2017-08-03 17:00:40 +0200 | [diff] [blame] | 53 | } with { extension "prototype(fast)" }; |
| 54 | |
| 55 | |
Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 56 | /* dual-faced port on top of IPL4asp; ASP_Event passed through transparently */ |
| 57 | type port GTPU_PT message { |
| 58 | out Gtp1uUnitdata; |
| 59 | in Gtp1uUnitdata, |
Harald Welte | 04d74cd | 2017-11-19 09:29:51 +0100 | [diff] [blame] | 60 | ASP_ConnId_ReadyToRelease, |
Harald Welte | 627c7c7 | 2017-08-03 18:17:02 +0200 | [diff] [blame] | 61 | ASP_Event; |
Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 62 | } with { extension "user IPL4asp_PT |
| 63 | out(Gtp1uUnitdata -> ASP_SendTo: function(f_enc_Gtp1uUD)) |
| 64 | in(ASP_RecvFrom -> Gtp1uUnitdata: function(f_dec_Gtp1uUD); |
Harald Welte | 04d74cd | 2017-11-19 09:29:51 +0100 | [diff] [blame] | 65 | ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple; |
Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 66 | ASP_Event -> ASP_Event: simple)" } |
Harald Welte | 2560608 | 2017-08-03 17:00:40 +0200 | [diff] [blame] | 67 | |
Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 68 | 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] | 69 | out_ud.connId := in_ud.peer.connId; |
| 70 | out_ud.remName := in_ud.peer.remName; |
| 71 | out_ud.remPort := in_ud.peer.remPort; |
| 72 | out_ud.proto := { udp := {} }; |
| 73 | out_ud.msg := enc_PDU_GTPU(in_ud.gtpu); |
Harald Welte | 2560608 | 2017-08-03 17:00:40 +0200 | [diff] [blame] | 74 | } with { extension "prototype(fast)" }; |
| 75 | |
Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 76 | 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] | 77 | out_ud.peer.connId := in_ud.connId; |
| 78 | out_ud.peer.remName := in_ud.remName; |
| 79 | out_ud.peer.remPort := in_ud.remPort; |
| 80 | out_ud.gtpu := dec_PDU_GTPU(in_ud.msg); |
Harald Welte | 2560608 | 2017-08-03 17:00:40 +0200 | [diff] [blame] | 81 | } with { extension "prototype(fast)" }; |
Harald Welte | d418fc6 | 2017-08-04 00:34:42 +0200 | [diff] [blame] | 82 | |
Harald Welte | 2560608 | 2017-08-03 17:00:40 +0200 | [diff] [blame] | 83 | } |