Holger Hans Peter Freyther | 3f79397 | 2010-11-14 20:38:06 +0100 | [diff] [blame] | 1 | /* |
| 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 Welte | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 9 | * 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 Freyther | 3f79397 | 2010-11-14 20:38:06 +0100 | [diff] [blame] | 11 | * (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 Welte | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 16 | * GNU Affero General Public License for more details. |
Holger Hans Peter Freyther | 3f79397 | 2010-11-14 20:38:06 +0100 | [diff] [blame] | 17 | * |
Harald Welte | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 18 | * 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 Freyther | 3f79397 | 2010-11-14 20:38:06 +0100 | [diff] [blame] | 20 | * |
| 21 | */ |
| 22 | |
| 23 | #include <openbsc/osmo_msc_data.h> |
| 24 | #include <openbsc/osmo_bsc.h> |
Holger Hans Peter Freyther | 3463f1b | 2010-12-22 12:32:56 +0100 | [diff] [blame] | 25 | #include <openbsc/abis_rsl.h> |
Holger Hans Peter Freyther | 3f79397 | 2010-11-14 20:38:06 +0100 | [diff] [blame] | 26 | #include <openbsc/gsm_data.h> |
| 27 | #include <openbsc/debug.h> |
| 28 | #include <openbsc/signal.h> |
| 29 | |
| 30 | #include <arpa/inet.h> |
| 31 | |
| 32 | static 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 Freyther | c3649d2 | 2012-12-26 10:17:42 +0100 | [diff] [blame] | 48 | /* |
| 49 | * TODO: handle handover here... then the audio should go to |
| 50 | * the old mgcp port.. |
| 51 | */ |
Holger Hans Peter Freyther | 3f79397 | 2010-11-14 20:38:06 +0100 | [diff] [blame] | 52 | /* 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 | |
| 69 | int osmo_bsc_audio_init(struct gsm_network *net) |
| 70 | { |
Pablo Neira Ayuso | ef717c6 | 2011-05-06 12:12:31 +0200 | [diff] [blame] | 71 | osmo_signal_register_handler(SS_ABISIP, handle_abisip_signal, net); |
Holger Hans Peter Freyther | 3f79397 | 2010-11-14 20:38:06 +0100 | [diff] [blame] | 72 | return 0; |
| 73 | } |