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 | |
Pau Espin Pedrol | 1a026a5 | 2019-06-18 17:21:52 +0200 | [diff] [blame] | 44 | type record MGCP_SendTo { |
| 45 | ConnectionId connId, |
| 46 | HostName remName, |
| 47 | PortNumber remPort, |
| 48 | MgcpMessage msg |
| 49 | }; |
| 50 | |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 51 | template MGCP_Send t_MGCP_Send(template ConnectionId connId, template MgcpMessage msg) := { |
| 52 | connId := connId, |
| 53 | msg := msg |
| 54 | } |
| 55 | |
Pau Espin Pedrol | 1a026a5 | 2019-06-18 17:21:52 +0200 | [diff] [blame] | 56 | template MGCP_SendTo t_MGCP_SendTo(template ConnectionId connId, HostName remName, |
| 57 | PortNumber remPort,template MgcpMessage msg) := { |
| 58 | connId := connId, |
| 59 | remName := remName, |
| 60 | remPort := remPort, |
| 61 | msg := msg |
| 62 | } |
| 63 | |
| 64 | template MGCP_SendTo t_MGCP_SendToMrf(MGCP_RecvFrom mrf,template MgcpMessage msg) := { |
| 65 | connId := mrf.connId, |
| 66 | remName := mrf.remName, |
| 67 | remPort := mrf.remPort, |
| 68 | msg := msg |
| 69 | } |
| 70 | |
Harald Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 71 | private function IPL4_to_MGCP_RecvFrom(in ASP_RecvFrom pin, out MGCP_RecvFrom pout) { |
| 72 | pout.connId := pin.connId; |
| 73 | pout.remName := pin.remName; |
| 74 | pout.remPort := pin.remPort; |
| 75 | pout.locName := pin.locName; |
| 76 | pout.locPort := pin.locPort; |
Harald Welte | 9ccb480 | 2017-09-17 16:22:34 +0800 | [diff] [blame] | 77 | /* FIXME: This should actually be the below: |
| 78 | pout.msg := dec_MgcpMessage(oct2char(pin.msg)); - see |
| 79 | https://www.eclipse.org/forums/index.php/t/1088893/ |
| 80 | */ |
Daniel Willmann | 34e7dd0 | 2018-01-17 13:25:58 +0100 | [diff] [blame] | 81 | pout.msg := dec_MgcpMessage(oct2char(pin.msg)); |
Harald Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 82 | } with { extension "prototype(fast)" }; |
| 83 | |
| 84 | private function MGCP_to_IPL4_Send(in MGCP_Send pin, out ASP_Send pout) { |
| 85 | pout.connId := pin.connId; |
| 86 | pout.proto := { udp := {} }; |
| 87 | pout.msg := char2oct(enc_MgcpMessage(pin.msg)); |
| 88 | } with { extension "prototype(fast)" }; |
| 89 | |
Pau Espin Pedrol | 1a026a5 | 2019-06-18 17:21:52 +0200 | [diff] [blame] | 90 | private function MGCP_to_IPL4_SendTo(in MGCP_SendTo pin, out ASP_SendTo out_ud) { |
| 91 | out_ud.connId := pin.connId; |
| 92 | out_ud.remName := pin.remName; |
| 93 | out_ud.remPort := pin.remPort; |
| 94 | out_ud.proto := { udp := {} }; |
| 95 | out_ud.msg := char2oct(enc_MgcpMessage(pin.msg)); |
| 96 | } with { extension "prototype(fast)" }; |
| 97 | |
Harald Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 98 | type port MGCP_CODEC_PT message { |
Pau Espin Pedrol | 1a026a5 | 2019-06-18 17:21:52 +0200 | [diff] [blame] | 99 | out MGCP_Send, |
| 100 | MGCP_SendTo; |
Harald Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 101 | in MGCP_RecvFrom, |
Harald Welte | 45295c5 | 2017-11-18 13:00:57 +0100 | [diff] [blame] | 102 | ASP_ConnId_ReadyToRelease, |
Harald Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 103 | ASP_Event; |
| 104 | } with { extension "user IPL4asp_PT |
Pau Espin Pedrol | 1a026a5 | 2019-06-18 17:21:52 +0200 | [diff] [blame] | 105 | out(MGCP_Send -> ASP_Send:function(MGCP_to_IPL4_Send); |
| 106 | MGCP_SendTo -> ASP_SendTo: function(MGCP_to_IPL4_SendTo)) |
Harald Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 107 | in(ASP_RecvFrom -> MGCP_RecvFrom: function(IPL4_to_MGCP_RecvFrom); |
Harald Welte | 45295c5 | 2017-11-18 13:00:57 +0100 | [diff] [blame] | 108 | ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple; |
Harald Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 109 | ASP_Event -> ASP_Event: simple)" |
| 110 | } |
| 111 | } |