Harald Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 1 | module MGCP_CodecPort { |
| 2 | |
Harald Welte | 35bb716 | 2018-01-03 21:07:52 +0100 | [diff] [blame] | 3 | /* Simple MGCP Codec Port, translating between raw UDP primitives with |
| 4 | * octetstring payload towards the IPL4asp provider, and MGCP primitives |
| 5 | * which carry the decoded MGCP data types as payload. |
| 6 | * |
| 7 | * (C) 2017 by Harald Welte <laforge@gnumonks.org> |
| 8 | * All rights reserved. |
| 9 | * |
| 10 | * Released under the terms of GNU General Public License, Version 2 or |
| 11 | * (at your option) any later version. |
| 12 | */ |
| 13 | |
Harald Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 14 | import from IPL4asp_PortType all; |
| 15 | import from IPL4asp_Types all; |
| 16 | import from MGCP_Types all; |
| 17 | |
| 18 | type record MGCP_RecvFrom { |
| 19 | ConnectionId connId, |
| 20 | HostName remName, |
| 21 | PortNumber remPort, |
| 22 | HostName locName, |
| 23 | PortNumber locPort, |
| 24 | MgcpMessage msg |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 25 | }; |
| 26 | |
| 27 | template MGCP_RecvFrom t_MGCP_RecvFrom(template MgcpMessage msg) := { |
| 28 | connId := ?, |
| 29 | remName := ?, |
| 30 | remPort := ?, |
| 31 | locName := ?, |
| 32 | locPort := ?, |
| 33 | msg := msg |
Harald Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | type record MGCP_Send { |
| 37 | ConnectionId connId, |
| 38 | MgcpMessage msg |
| 39 | } |
| 40 | |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 41 | template MGCP_Send t_MGCP_Send(template ConnectionId connId, template MgcpMessage msg) := { |
| 42 | connId := connId, |
| 43 | msg := msg |
| 44 | } |
| 45 | |
Harald Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 46 | private function IPL4_to_MGCP_RecvFrom(in ASP_RecvFrom pin, out MGCP_RecvFrom pout) { |
| 47 | pout.connId := pin.connId; |
| 48 | pout.remName := pin.remName; |
| 49 | pout.remPort := pin.remPort; |
| 50 | pout.locName := pin.locName; |
| 51 | pout.locPort := pin.locPort; |
Harald Welte | 9ccb480 | 2017-09-17 16:22:34 +0800 | [diff] [blame] | 52 | /* FIXME: This should actually be the below: |
| 53 | pout.msg := dec_MgcpMessage(oct2char(pin.msg)); - see |
| 54 | https://www.eclipse.org/forums/index.php/t/1088893/ |
| 55 | */ |
Daniel Willmann | 34e7dd0 | 2018-01-17 13:25:58 +0100 | [diff] [blame] | 56 | pout.msg := dec_MgcpMessage(oct2char(pin.msg)); |
Harald Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 57 | } with { extension "prototype(fast)" }; |
| 58 | |
| 59 | private function MGCP_to_IPL4_Send(in MGCP_Send pin, out ASP_Send pout) { |
| 60 | pout.connId := pin.connId; |
| 61 | pout.proto := { udp := {} }; |
| 62 | pout.msg := char2oct(enc_MgcpMessage(pin.msg)); |
| 63 | } with { extension "prototype(fast)" }; |
| 64 | |
| 65 | type port MGCP_CODEC_PT message { |
| 66 | out MGCP_Send; |
| 67 | in MGCP_RecvFrom, |
Harald Welte | 45295c5 | 2017-11-18 13:00:57 +0100 | [diff] [blame] | 68 | ASP_ConnId_ReadyToRelease, |
Harald Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 69 | ASP_Event; |
| 70 | } with { extension "user IPL4asp_PT |
| 71 | out(MGCP_Send -> ASP_Send:function(MGCP_to_IPL4_Send)) |
| 72 | in(ASP_RecvFrom -> MGCP_RecvFrom: function(IPL4_to_MGCP_RecvFrom); |
Harald Welte | 45295c5 | 2017-11-18 13:00:57 +0100 | [diff] [blame] | 73 | ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple; |
Harald Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 74 | ASP_Event -> ASP_Event: simple)" |
| 75 | } |
| 76 | } |