blob: c20698683c50f03255a808f4521c586f23f196f7 [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>
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 Welte2c6dba12017-09-16 00:50:08 +080014 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 Welte3c6ebb92017-09-16 00:56:57 +080025 };
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 Welte2c6dba12017-09-16 00:50:08 +080034 }
35
36 type record MGCP_Send {
37 ConnectionId connId,
38 MgcpMessage msg
39 }
40
Harald Welte3c6ebb92017-09-16 00:56:57 +080041 template MGCP_Send t_MGCP_Send(template ConnectionId connId, template MgcpMessage msg) := {
42 connId := connId,
43 msg := msg
44 }
45
Harald Welte2c6dba12017-09-16 00:50:08 +080046 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 Welte9ccb4802017-09-17 16:22:34 +080052 /* 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 Willmann34e7dd02018-01-17 13:25:58 +010056 pout.msg := dec_MgcpMessage(oct2char(pin.msg));
Harald Welte2c6dba12017-09-16 00:50:08 +080057 } 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 Welte45295c52017-11-18 13:00:57 +010068 ASP_ConnId_ReadyToRelease,
Harald Welte2c6dba12017-09-16 00:50:08 +080069 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 Welte45295c52017-11-18 13:00:57 +010073 ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
Harald Welte2c6dba12017-09-16 00:50:08 +080074 ASP_Event -> ASP_Event: simple)"
75 }
76}