blob: 1351997c49c3f80a2582882b4d8c421d678a793b [file] [log] [blame]
Harald Weltef09d1ba2017-11-25 02:20:13 +01001module MGCP_Adapter {
2
3import from IPL4asp_Types all;
4
5import from MGCP_Types all;
6import from MGCP_CodecPort all;
7import from MGCP_CodecPort_CtrlFunct all;
8
9import from IPA_Emulation all;
10
11
12type component MGCP_Adapter_CT {
13 /* MGCP Codec Port for MGCP-over-UDP */
14 port MGCP_CODEC_PT MGCP_UDP;
15 port IPA_MGCP_PT MGCP;
16 var integer g_mgcp_conn_id := -1;
17}
18
19modulepar {
20 charstring mp_callagent_ip := "127.0.0.1";
21 PortNumber mp_callagent_udp_port := 2727;
22 charstring mp_mgw_ip := "127.0.0.1";
23 PortNumber mp_mgw_udp_port := 2427;
24}
25
26/* build a receive template for receiving a MGCP message. You
27 * pass the MGCP response template in, and it will generate an
28 * MGCP_RecvFrom template that can match the primitives arriving on the
29 * MGCP_CodecPort */
30function tr_MGCP_RecvFrom_R(template MgcpResponse resp)
31runs on MGCP_Adapter_CT return template MGCP_RecvFrom {
32 var template MGCP_RecvFrom mrf := {
33 connId := g_mgcp_conn_id,
34 remName := mp_mgw_ip,
35 remPort := mp_mgw_udp_port,
36 locName := mp_callagent_ip,
37 locPort := mp_callagent_udp_port,
38 msg := { response := resp }
39 }
40 return mrf;
41}
42
43
44function main() runs on MGCP_Adapter_CT {
45 var Result res;
46 map(self:MGCP_UDP, system:MGCP_CODEC_PT);
47 res := MGCP_CodecPort_CtrlFunct.f_IPL4_connect(MGCP_UDP, mp_mgw_ip, mp_mgw_udp_port,
48 mp_callagent_ip, mp_callagent_udp_port,
49 0, { udp:={} });
50 g_mgcp_conn_id := res.connId;
51
52 while (true) {
53 var MgcpCommand mgcp_cmd;
54 var MGCP_RecvFrom mrf;
55
56 alt {
57 /* From BSC/MGW via UDP up to MSC / Call Agent */
58 [] MGCP_UDP.receive(tr_MGCP_RecvFrom_R(?)) -> value mrf {
59 MGCP.send(mrf.msg.response);
60 }
61
62 /* From MSC / Call Agent down to BSC/MGW */
63 [] MGCP.receive(MgcpCommand:?) -> value mgcp_cmd {
64 var MgcpMessage msg := { command := mgcp_cmd };
65 MGCP_UDP.send(t_MGCP_Send(g_mgcp_conn_id, msg));
66 }
67
68 }
69 }
70}
71
72}