blob: 8819fd8dc7dd32e4df15f83fc2e6905c0c6b8a96 [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;
Daniel Willmann34e7dd02018-01-17 13:25:58 +010077 pout.msg := dec_MgcpMessage(oct2char(pin.msg));
Harald Welte2c6dba12017-09-16 00:50:08 +080078 } with { extension "prototype(fast)" };
79
80 private function MGCP_to_IPL4_Send(in MGCP_Send pin, out ASP_Send pout) {
81 pout.connId := pin.connId;
82 pout.proto := { udp := {} };
83 pout.msg := char2oct(enc_MgcpMessage(pin.msg));
84 } with { extension "prototype(fast)" };
85
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +020086 private function MGCP_to_IPL4_SendTo(in MGCP_SendTo pin, out ASP_SendTo out_ud) {
87 out_ud.connId := pin.connId;
88 out_ud.remName := pin.remName;
89 out_ud.remPort := pin.remPort;
90 out_ud.proto := { udp := {} };
91 out_ud.msg := char2oct(enc_MgcpMessage(pin.msg));
92 } with { extension "prototype(fast)" };
93
Harald Welte2c6dba12017-09-16 00:50:08 +080094 type port MGCP_CODEC_PT message {
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +020095 out MGCP_Send,
96 MGCP_SendTo;
Harald Welte2c6dba12017-09-16 00:50:08 +080097 in MGCP_RecvFrom,
Harald Welte45295c52017-11-18 13:00:57 +010098 ASP_ConnId_ReadyToRelease,
Harald Welte2c6dba12017-09-16 00:50:08 +080099 ASP_Event;
100 } with { extension "user IPL4asp_PT
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +0200101 out(MGCP_Send -> ASP_Send:function(MGCP_to_IPL4_Send);
102 MGCP_SendTo -> ASP_SendTo: function(MGCP_to_IPL4_SendTo))
Harald Welte2c6dba12017-09-16 00:50:08 +0800103 in(ASP_RecvFrom -> MGCP_RecvFrom: function(IPL4_to_MGCP_RecvFrom);
Harald Welte45295c52017-11-18 13:00:57 +0100104 ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
Harald Welte2c6dba12017-09-16 00:50:08 +0800105 ASP_Event -> ASP_Event: simple)"
106 }
107}