diff --git a/bsc/MSC_ConnectionHandler.ttcn b/bsc/MSC_ConnectionHandler.ttcn index 55cdb8958..b6e6540dd 100644 --- a/bsc/MSC_ConnectionHandler.ttcn +++ b/bsc/MSC_ConnectionHandler.ttcn @@ -75,7 +75,7 @@ function f_MediaState_init(inout MediaState g_media, integer nr, HostName bts, H peer := - } - //g_media.mgcp_ep := int2str(i) & "@mgw"; + g_media.mgcp_ep := "rtpbridge/" & int2str(nr) & "@mgw"; for (var integer i:= 0; i < sizeof(g_media.mgcp_conn); i := i+1) { g_media.mgcp_conn[i].mime_type := "AMR"; @@ -169,6 +169,16 @@ altstep as_Media() runs on MSC_ConnHdlr { [] MGCP.receive(tr_CRCX) -> value mgcp_cmd { var SDP_Message sdp; var integer cid := f_get_free_mgcp_conn(); + if (match(mgcp_cmd.line.ep, t_MGCP_EP_wildcard)) { + if (cid != 0) { + setverdict(fail, "MGCP wildcard EP only works in first CRCX"); + self.stop; + } + /* we keep the endpoint name allocated during MediaState_init */ + } else { + /* Call Agent allocated endpoint, trust/use it always */ + g_media.mgcp_ep := mgcp_cmd.line.ep; + } if (isvalue(mgcp_cmd.sdp)) { sdp := mgcp_cmd.sdp; g_media.mgcp_conn[cid].peer.host := sdp.connection.conn_addr.addr; @@ -181,7 +191,10 @@ altstep as_Media() runs on MSC_ConnHdlr { mgcp_conn.mime_type & "/" & int2str(mgcp_conn.sample_rate))), valueof(ts_SDP_ptime(mgcp_conn.ptime)) } )); - MGCP.send(ts_CRCX_ACK(mgcp_cmd.line.trans_id, mgcp_conn.conn_id, sdp)); + var template MgcpResponse mgcp_resp; + mgcp_resp := ts_CRCX_ACK(mgcp_cmd.line.trans_id, mgcp_conn.conn_id, sdp); + f_mgcp_par_append(mgcp_resp.params, ts_MgcpParSpecEP(g_media.mgcp_ep)); + MGCP.send(mgcp_resp); g_media.mgcp_conn[cid].crcx_seen := true; repeat; } diff --git a/library/MGCP_Emulation.ttcn b/library/MGCP_Emulation.ttcn index df8e4b446..adcb8b5d2 100644 --- a/library/MGCP_Emulation.ttcn +++ b/library/MGCP_Emulation.ttcn @@ -208,8 +208,12 @@ function f_mgcp_ep(MgcpMessage msg) return MgcpEndpoint { if (ischosen(msg.command)) { return msg.command.line.ep; } else { - /* FIXME */ - return "null@none"; + var MgcpEndpoint ep; + if (f_mgcp_find_param(msg, "Z", ep) == false) { + setverdict(fail, "No SpecificEndpointName in MGCP response", msg); + self.stop; + } + return ep; } } @@ -273,7 +277,8 @@ function main(MGCPOps ops, MGCP_conn_parameters p, charstring id) runs on MGCP_E } else { if (cmd.line.verb == "CRCX") { vc_conn := ops.create_cb.apply(cmd, id); - if (true /* non-wildcard EP */) { + if (not match(cmd.line.ep, t_MGCP_EP_wildcard)) { + /* non-wildcard EP, use directly */ f_ep_table_add(vc_conn, cmd.line.ep); } else { /* add this transaction to list of pending transactions */ diff --git a/library/MGCP_Templates.ttcn b/library/MGCP_Templates.ttcn index 5a8d9b166..9e32a34d4 100644 --- a/library/MGCP_Templates.ttcn +++ b/library/MGCP_Templates.ttcn @@ -34,6 +34,12 @@ module MGCP_Templates { val := hex2str(rid) }; + /* 3.2.1.3 SpecificEndpointId */ + template MgcpParameter ts_MgcpParSpecEP(MgcpEndpoint ep) := { + code := "Z", + val := ep + }; + /* 3.2.2.10: LocalConnectionOptions (codec, packetization, bandwidth, ToS, eco, gain, silence, ...) */ template MgcpParameter t_MgcpParLocConnOpt(template charstring lco) := { "L", lco }; @@ -326,5 +332,25 @@ module MGCP_Templates { sdp := * } + function f_mgcp_find_param(MgcpMessage msg, MgcpInfoCode code, out charstring ret) + return boolean { + var MgcpParameterList pars; + if (ischosen(msg.command)) { + pars := msg.command.params; + } else { + pars := msg.response.params; + } + for (var integer i := 0; i < sizeof(pars); i := i+1) { + if (pars[i].code == code) { + ret := pars[i].val; + return true; + } + } + return false; + } + + /* template to determine if a MGCP endpoint is a wildcard endpoint */ + template charstring t_MGCP_EP_wildcard := (pattern "\*@*", pattern "rtpbridge/\*@*"); + }