blob: d33afe18034b2048577bb00e7deb381e02fdb352 [file] [log] [blame]
Harald Welte2c6dba12017-09-16 00:50:08 +08001module MGCP_CodecPort {
2
Harald Welte35bb7162018-01-03 21:07:52 +01003/* 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 Welte34b5a952019-05-27 11:54:11 +02008 * contributions by sysmocom - s.f.m.c. GmbH
Harald Welte35bb7162018-01-03 21:07:52 +01009 * 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 Welte34b5a952019-05-27 11:54:11 +020013 *
14 * SPDX-License-Identifier: GPL-2.0-or-later
Harald Welte35bb7162018-01-03 21:07:52 +010015 */
16
Harald Welte2c6dba12017-09-16 00:50:08 +080017 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 Welte3c6ebb92017-09-16 00:56:57 +080028 };
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 Welte2c6dba12017-09-16 00:50:08 +080037 }
38
39 type record MGCP_Send {
40 ConnectionId connId,
41 MgcpMessage msg
42 }
43
Harald Welte3c6ebb92017-09-16 00:56:57 +080044 template MGCP_Send t_MGCP_Send(template ConnectionId connId, template MgcpMessage msg) := {
45 connId := connId,
46 msg := msg
47 }
48
Harald Welte2c6dba12017-09-16 00:50:08 +080049 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 Welte9ccb4802017-09-17 16:22:34 +080055 /* 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 Willmann34e7dd02018-01-17 13:25:58 +010059 pout.msg := dec_MgcpMessage(oct2char(pin.msg));
Harald Welte2c6dba12017-09-16 00:50:08 +080060 } 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 Welte45295c52017-11-18 13:00:57 +010071 ASP_ConnId_ReadyToRelease,
Harald Welte2c6dba12017-09-16 00:50:08 +080072 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 Welte45295c52017-11-18 13:00:57 +010076 ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
Harald Welte2c6dba12017-09-16 00:50:08 +080077 ASP_Event -> ASP_Event: simple)"
78 }
79}