From b4ed0e7b7824c15ca2f711daca32e6c34f0b7337 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Thu, 22 Sep 2016 20:28:35 +0200 Subject: bridge calls via mgcpgw Change-Id: Ie259e30bc532fe9817c96562022ac33443d5747a --- openbsc/include/openbsc/msc_ifaces.h | 1 + openbsc/src/libmsc/gsm_04_08.c | 3 +-- openbsc/src/libmsc/msc_ifaces.c | 29 +++++++++++++++++++++++++++++ openbsc/tests/db/db_test.c | 4 ++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/openbsc/include/openbsc/msc_ifaces.h b/openbsc/include/openbsc/msc_ifaces.h index 09d2487d6..3f6754e03 100644 --- a/openbsc/include/openbsc/msc_ifaces.h +++ b/openbsc/include/openbsc/msc_ifaces.h @@ -48,3 +48,4 @@ int msc_gsm0808_tx_cipher_mode(struct gsm_subscriber_connection *conn, int ciphe int msc_tx_common_id(struct gsm_subscriber_connection *conn); int msc_call_assignment(struct gsm_trans *trans); +int msc_call_bridge(struct gsm_trans *trans1, struct gsm_trans *trans2); diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c index 9ea63a61a..5cf14c4bb 100644 --- a/openbsc/src/libmsc/gsm_04_08.c +++ b/openbsc/src/libmsc/gsm_04_08.c @@ -1732,8 +1732,7 @@ static int tch_bridge(struct gsm_network *net, struct gsm_mncc_bridge *bridge) /* through-connect channel */ return tch_map(trans1->conn->lchan, trans2->conn->lchan); #else - /* not implemented yet! */ - return -1; + return msc_call_bridge(trans1, trans2); #endif } diff --git a/openbsc/src/libmsc/msc_ifaces.c b/openbsc/src/libmsc/msc_ifaces.c index 2937b54f6..585927c73 100644 --- a/openbsc/src/libmsc/msc_ifaces.c +++ b/openbsc/src/libmsc/msc_ifaces.c @@ -186,3 +186,32 @@ int msc_call_assignment(struct gsm_trans *trans) return -EINVAL; } } + +int msc_call_bridge(struct gsm_trans *trans1, struct gsm_trans *trans2) +{ + struct gsm_subscriber_connection *conn1 = trans1->conn; + struct gsm_subscriber_connection *conn2 = trans2->conn; + + struct mgcpgw_client *mgcp = conn1->network->mgcpgw.client; + OSMO_ASSERT(mgcp); + + const char *ip = mgcpgw_client_remote_addr_str(mgcp); + + /* First setup the counterparts' endpoints, so that when transmission + * starts the originating addresses are already known to be valid. */ + mgcpgw_client_tx_mdcx(mgcp, conn1->iu.mgcp_rtp_endpoint, + ip, conn2->iu.mgcp_rtp_port_cn, + MGCP_CONN_LOOPBACK); + mgcpgw_client_tx_mdcx(mgcp, conn2->iu.mgcp_rtp_endpoint, + ip, conn1->iu.mgcp_rtp_port_cn, + MGCP_CONN_LOOPBACK); + /* Now enable sending to and receiving from the peer. */ + mgcpgw_client_tx_mdcx(mgcp, conn1->iu.mgcp_rtp_endpoint, + ip, conn2->iu.mgcp_rtp_port_cn, + MGCP_CONN_RECV_SEND); + mgcpgw_client_tx_mdcx(mgcp, conn2->iu.mgcp_rtp_endpoint, + ip, conn1->iu.mgcp_rtp_port_cn, + MGCP_CONN_RECV_SEND); + + return 0; +} diff --git a/openbsc/tests/db/db_test.c b/openbsc/tests/db/db_test.c index 372806e7b..ee579bc34 100644 --- a/openbsc/tests/db/db_test.c +++ b/openbsc/tests/db/db_test.c @@ -261,6 +261,10 @@ int mgcpgw_client_tx_crcx(struct mgcpgw_client *client, uint16_t rtp_endpoint, unsigned int call_id, enum mgcp_connection_mode mode) { return -ENOTSUP; } +int mgcpgw_client_tx_mdcx(struct mgcpgw_client *client, uint16_t rtp_endpoint, + const char *rtp_conn_addr, uint16_t rtp_port, + enum mgcp_connection_mode mode) +{ return -ENOTSUP; } const char *mgcpgw_client_remote_addr_str(struct mgcpgw_client *mgcp) { return "0.0.0.0"; } uint32_t mgcpgw_client_remote_addr_n(struct mgcpgw_client *mgcp) -- cgit v1.2.3