blob: 8614eef1a35989d835c0f1a4d941da34a9e91e46 [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
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +020044 type record MGCP_SendTo {
45 ConnectionId connId,
46 HostName remName,
47 PortNumber remPort,
48 MgcpMessage msg
49 };
50
Harald Welte3c6ebb92017-09-16 00:56:57 +080051 template MGCP_Send t_MGCP_Send(template ConnectionId connId, template MgcpMessage msg) := {
52 connId := connId,
53 msg := msg
54 }
55
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +020056 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 Welte2c6dba12017-09-16 00:50:08 +080071 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 Welte9ccb4802017-09-17 16:22:34 +080077 /* 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 Willmann34e7dd02018-01-17 13:25:58 +010081 pout.msg := dec_MgcpMessage(oct2char(pin.msg));
Harald Welte2c6dba12017-09-16 00:50:08 +080082 } 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 Pedrol1a026a52019-06-18 17:21:52 +020090 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 Welte2c6dba12017-09-16 00:50:08 +080098 type port MGCP_CODEC_PT message {
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +020099 out MGCP_Send,
100 MGCP_SendTo;
Harald Welte2c6dba12017-09-16 00:50:08 +0800101 in MGCP_RecvFrom,
Harald Welte45295c52017-11-18 13:00:57 +0100102 ASP_ConnId_ReadyToRelease,
Harald Welte2c6dba12017-09-16 00:50:08 +0800103 ASP_Event;
104 } with { extension "user IPL4asp_PT
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +0200105 out(MGCP_Send -> ASP_Send:function(MGCP_to_IPL4_Send);
106 MGCP_SendTo -> ASP_SendTo: function(MGCP_to_IPL4_SendTo))
Harald Welte2c6dba12017-09-16 00:50:08 +0800107 in(ASP_RecvFrom -> MGCP_RecvFrom: function(IPL4_to_MGCP_RecvFrom);
Harald Welte45295c52017-11-18 13:00:57 +0100108 ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
Harald Welte2c6dba12017-09-16 00:50:08 +0800109 ASP_Event -> ASP_Event: simple)"
110 }
111}