blob: 660d8849764c7eed2113cb66081a673fb893dc57 [file] [log] [blame]
Holger Hans Peter Freyther620c2e62010-11-14 20:38:06 +01001/*
2 * ipaccess audio handling
3 *
4 * (C) 2009-2010 by Holger Hans Peter Freyther <zecke@selfish.org>
5 * (C) 2009-2010 by On-Waves
6 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
Harald Welte9af6ddf2011-01-01 15:25:50 +01009 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
Holger Hans Peter Freyther620c2e62010-11-14 20:38:06 +010011 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Harald Welte9af6ddf2011-01-01 15:25:50 +010016 * GNU Affero General Public License for more details.
Holger Hans Peter Freyther620c2e62010-11-14 20:38:06 +010017 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010018 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Holger Hans Peter Freyther620c2e62010-11-14 20:38:06 +010020 *
21 */
22
23#include <openbsc/osmo_msc_data.h>
24#include <openbsc/osmo_bsc.h>
Holger Hans Peter Freythere2fee352010-12-22 12:32:56 +010025#include <openbsc/abis_rsl.h>
Holger Hans Peter Freyther620c2e62010-11-14 20:38:06 +010026#include <openbsc/gsm_data.h>
27#include <openbsc/debug.h>
28#include <openbsc/signal.h>
29
30#include <arpa/inet.h>
31
32static int handle_abisip_signal(unsigned int subsys, unsigned int signal,
33 void *handler_data, void *signal_data)
34{
35 struct gsm_subscriber_connection *con;
36 struct gsm_lchan *lchan = signal_data;
37 int rc;
38
39 if (subsys != SS_ABISIP)
40 return 0;
41
42 con = lchan->conn;
43 if (!con || !con->sccp_con)
44 return 0;
45
46 switch (signal) {
47 case S_ABISIP_CRCX_ACK:
Holger Hans Peter Freytherc121bb32012-12-26 10:17:42 +010048 /*
49 * TODO: handle handover here... then the audio should go to
50 * the old mgcp port..
51 */
Holger Hans Peter Freyther620c2e62010-11-14 20:38:06 +010052 /* we can ask it to connect now */
53 LOGP(DMSC, LOGL_DEBUG, "Connecting BTS to port: %d conn: %d\n",
54 con->sccp_con->rtp_port, lchan->abis_ip.conn_id);
55
56 rc = rsl_ipacc_mdcx(lchan, ntohl(INADDR_ANY),
57 con->sccp_con->rtp_port,
58 lchan->abis_ip.rtp_payload2);
59 if (rc < 0) {
60 LOGP(DMSC, LOGL_ERROR, "Failed to send MDCX: %d\n", rc);
61 return rc;
62 }
63 break;
64 }
65
66 return 0;
67}
68
69int osmo_bsc_audio_init(struct gsm_network *net)
70{
Pablo Neira Ayusobbc5b992011-05-06 12:12:31 +020071 osmo_signal_register_handler(SS_ABISIP, handle_abisip_signal, net);
Holger Hans Peter Freyther620c2e62010-11-14 20:38:06 +010072 return 0;
73}