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> |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 8 | * contributions by sysmocom - s.f.m.c. GmbH |
Harald Welte | 35bb716 | 2018-01-03 21:07:52 +0100 | [diff] [blame] | 9 | * All rights reserved. |
| 10 | * |
| 11 | * Released under the terms of GNU General Public License, Version 2 or |
| 12 | * (at your option) any later version. |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 13 | * |
| 14 | * SPDX-License-Identifier: GPL-2.0-or-later |
Harald Welte | 35bb716 | 2018-01-03 21:07:52 +0100 | [diff] [blame] | 15 | */ |
| 16 | |
Harald Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 17 | import from IPL4asp_PortType all; |
| 18 | import from IPL4asp_Types all; |
| 19 | import from MGCP_Types all; |
| 20 | |
| 21 | type record MGCP_RecvFrom { |
| 22 | ConnectionId connId, |
| 23 | HostName remName, |
| 24 | PortNumber remPort, |
| 25 | HostName locName, |
| 26 | PortNumber locPort, |
| 27 | MgcpMessage msg |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 28 | }; |
| 29 | |
| 30 | template MGCP_RecvFrom t_MGCP_RecvFrom(template MgcpMessage msg) := { |
| 31 | connId := ?, |
| 32 | remName := ?, |
| 33 | remPort := ?, |
| 34 | locName := ?, |
| 35 | locPort := ?, |
| 36 | msg := msg |
Harald Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | type record MGCP_Send { |
| 40 | ConnectionId connId, |
| 41 | MgcpMessage msg |
| 42 | } |
| 43 | |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 44 | template MGCP_Send t_MGCP_Send(template ConnectionId connId, template MgcpMessage msg) := { |
| 45 | connId := connId, |
| 46 | msg := msg |
| 47 | } |
| 48 | |
Harald Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 49 | private function IPL4_to_MGCP_RecvFrom(in ASP_RecvFrom pin, out MGCP_RecvFrom pout) { |
| 50 | pout.connId := pin.connId; |
| 51 | pout.remName := pin.remName; |
| 52 | pout.remPort := pin.remPort; |
| 53 | pout.locName := pin.locName; |
| 54 | pout.locPort := pin.locPort; |
Harald Welte | 9ccb480 | 2017-09-17 16:22:34 +0800 | [diff] [blame] | 55 | /* FIXME: This should actually be the below: |
| 56 | pout.msg := dec_MgcpMessage(oct2char(pin.msg)); - see |
| 57 | https://www.eclipse.org/forums/index.php/t/1088893/ |
| 58 | */ |
Daniel Willmann | 34e7dd0 | 2018-01-17 13:25:58 +0100 | [diff] [blame] | 59 | pout.msg := dec_MgcpMessage(oct2char(pin.msg)); |
Harald Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 60 | } with { extension "prototype(fast)" }; |
| 61 | |
| 62 | private function MGCP_to_IPL4_Send(in MGCP_Send pin, out ASP_Send pout) { |
| 63 | pout.connId := pin.connId; |
| 64 | pout.proto := { udp := {} }; |
| 65 | pout.msg := char2oct(enc_MgcpMessage(pin.msg)); |
| 66 | } with { extension "prototype(fast)" }; |
| 67 | |
| 68 | type port MGCP_CODEC_PT message { |
| 69 | out MGCP_Send; |
| 70 | in MGCP_RecvFrom, |
Harald Welte | 45295c5 | 2017-11-18 13:00:57 +0100 | [diff] [blame] | 71 | ASP_ConnId_ReadyToRelease, |
Harald Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 72 | ASP_Event; |
| 73 | } with { extension "user IPL4asp_PT |
| 74 | out(MGCP_Send -> ASP_Send:function(MGCP_to_IPL4_Send)) |
| 75 | in(ASP_RecvFrom -> MGCP_RecvFrom: function(IPL4_to_MGCP_RecvFrom); |
Harald Welte | 45295c5 | 2017-11-18 13:00:57 +0100 | [diff] [blame] | 76 | ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple; |
Harald Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 77 | ASP_Event -> ASP_Event: simple)" |
| 78 | } |
| 79 | } |