Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 1 | /* mncc_builtin.c - default, minimal built-in MNCC Application for |
| 2 | * standalone bsc_hack (netowrk-in-the-box mode) */ |
| 3 | |
| 4 | /* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org> |
| 5 | * (C) 2009 by Andreas Eversberg <Andreas.Eversberg@versatel.de> |
| 6 | * All Rights Reserved |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 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 |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | |
| 25 | #include <stdio.h> |
| 26 | #include <stdlib.h> |
| 27 | #include <string.h> |
| 28 | #include <errno.h> |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 29 | |
| 30 | #include <openbsc/gsm_04_08.h> |
| 31 | #include <openbsc/debug.h> |
| 32 | #include <openbsc/mncc.h> |
Harald Welte | ab386e6 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 33 | #include <openbsc/mncc_int.h> |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 34 | #include <osmocom/core/talloc.h> |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 35 | #include <openbsc/gsm_data.h> |
| 36 | #include <openbsc/transaction.h> |
| 37 | #include <openbsc/rtp_proxy.h> |
| 38 | |
| 39 | void *tall_call_ctx; |
| 40 | |
| 41 | static LLIST_HEAD(call_list); |
| 42 | |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 43 | static uint32_t new_callref = 0x00000001; |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 44 | |
Harald Welte | ab386e6 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 45 | struct mncc_int mncc_int = { |
Andreas Eversberg | a83d511 | 2013-12-07 18:32:28 +0100 | [diff] [blame] | 46 | .def_codec = { GSM48_CMODE_SPEECH_V1, GSM48_CMODE_SPEECH_V1 }, |
Harald Welte | ab386e6 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 47 | }; |
| 48 | |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 49 | static void free_call(struct gsm_call *call) |
| 50 | { |
| 51 | llist_del(&call->entry); |
| 52 | DEBUGP(DMNCC, "(call %x) Call removed.\n", call->callref); |
| 53 | talloc_free(call); |
| 54 | } |
| 55 | |
| 56 | |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 57 | static struct gsm_call *get_call_ref(uint32_t callref) |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 58 | { |
| 59 | struct gsm_call *callt; |
| 60 | |
| 61 | llist_for_each_entry(callt, &call_list, entry) { |
| 62 | if (callt->callref == callref) |
| 63 | return callt; |
| 64 | } |
| 65 | return NULL; |
| 66 | } |
| 67 | |
Harald Welte | ab386e6 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 68 | static uint8_t determine_lchan_mode(struct gsm_mncc *setup) |
| 69 | { |
| 70 | /* FIXME: check codec capabilities of the phone */ |
| 71 | |
| 72 | if (setup->lchan_type == GSM_LCHAN_TCH_F) |
| 73 | return mncc_int.def_codec[0]; |
| 74 | else |
| 75 | return mncc_int.def_codec[1]; |
| 76 | } |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 77 | |
| 78 | /* on incoming call, look up database and send setup to remote subscr. */ |
| 79 | static int mncc_setup_ind(struct gsm_call *call, int msg_type, |
| 80 | struct gsm_mncc *setup) |
| 81 | { |
| 82 | struct gsm_mncc mncc; |
| 83 | struct gsm_call *remote; |
| 84 | |
| 85 | memset(&mncc, 0, sizeof(struct gsm_mncc)); |
| 86 | mncc.callref = call->callref; |
| 87 | |
| 88 | /* already have remote call */ |
| 89 | if (call->remote_ref) |
| 90 | return 0; |
| 91 | |
| 92 | /* transfer mode 1 would be packet mode, which was never specified */ |
| 93 | if (setup->bearer_cap.mode != 0) { |
| 94 | LOGP(DMNCC, LOGL_NOTICE, "(call %x) We don't support " |
| 95 | "packet mode\n", call->callref); |
| 96 | mncc_set_cause(&mncc, GSM48_CAUSE_LOC_PRN_S_LU, |
| 97 | GSM48_CC_CAUSE_BEARER_CA_UNAVAIL); |
| 98 | goto out_reject; |
| 99 | } |
| 100 | |
| 101 | /* we currently only do speech */ |
| 102 | if (setup->bearer_cap.transfer != GSM_MNCC_BCAP_SPEECH) { |
| 103 | LOGP(DMNCC, LOGL_NOTICE, "(call %x) We only support " |
| 104 | "voice calls\n", call->callref); |
| 105 | mncc_set_cause(&mncc, GSM48_CAUSE_LOC_PRN_S_LU, |
| 106 | GSM48_CC_CAUSE_BEARER_CA_UNAVAIL); |
| 107 | goto out_reject; |
| 108 | } |
| 109 | |
| 110 | /* create remote call */ |
Andreas Eversberg | c5e0851 | 2013-01-25 08:36:32 +0100 | [diff] [blame] | 111 | if (!(remote = talloc_zero(tall_call_ctx, struct gsm_call))) { |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 112 | mncc_set_cause(&mncc, GSM48_CAUSE_LOC_PRN_S_LU, |
| 113 | GSM48_CC_CAUSE_RESOURCE_UNAVAIL); |
| 114 | goto out_reject; |
| 115 | } |
| 116 | llist_add_tail(&remote->entry, &call_list); |
| 117 | remote->net = call->net; |
| 118 | remote->callref = new_callref++; |
| 119 | DEBUGP(DMNCC, "(call %x) Creating new remote instance %x.\n", |
| 120 | call->callref, remote->callref); |
| 121 | |
| 122 | /* link remote call */ |
| 123 | call->remote_ref = remote->callref; |
| 124 | remote->remote_ref = call->callref; |
| 125 | |
Harald Welte | bf0a7c9 | 2012-08-24 16:48:21 +0200 | [diff] [blame] | 126 | /* send call proceeding */ |
| 127 | memset(&mncc, 0, sizeof(struct gsm_mncc)); |
| 128 | mncc.callref = call->callref; |
| 129 | DEBUGP(DMNCC, "(call %x) Accepting call.\n", call->callref); |
| 130 | mncc_tx_to_cc(call->net, MNCC_CALL_PROC_REQ, &mncc); |
| 131 | |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 132 | /* modify mode */ |
| 133 | memset(&mncc, 0, sizeof(struct gsm_mncc)); |
| 134 | mncc.callref = call->callref; |
Harald Welte | ab386e6 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 135 | mncc.lchan_mode = determine_lchan_mode(setup); |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 136 | DEBUGP(DMNCC, "(call %x) Modify channel mode.\n", call->callref); |
Harald Welte | 7655637 | 2010-12-22 23:57:45 +0100 | [diff] [blame] | 137 | mncc_tx_to_cc(call->net, MNCC_LCHAN_MODIFY, &mncc); |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 138 | |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 139 | /* send setup to remote */ |
| 140 | // setup->fields |= MNCC_F_SIGNAL; |
| 141 | // setup->signal = GSM48_SIGNAL_DIALTONE; |
| 142 | setup->callref = remote->callref; |
| 143 | DEBUGP(DMNCC, "(call %x) Forwarding SETUP to remote.\n", call->callref); |
Harald Welte | 7655637 | 2010-12-22 23:57:45 +0100 | [diff] [blame] | 144 | return mncc_tx_to_cc(remote->net, MNCC_SETUP_REQ, setup); |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 145 | |
| 146 | out_reject: |
Harald Welte | 7655637 | 2010-12-22 23:57:45 +0100 | [diff] [blame] | 147 | mncc_tx_to_cc(call->net, MNCC_REJ_REQ, &mncc); |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 148 | free_call(call); |
| 149 | return 0; |
| 150 | } |
| 151 | |
| 152 | static int mncc_alert_ind(struct gsm_call *call, int msg_type, |
| 153 | struct gsm_mncc *alert) |
| 154 | { |
| 155 | struct gsm_call *remote; |
| 156 | |
| 157 | /* send alerting to remote */ |
| 158 | if (!(remote = get_call_ref(call->remote_ref))) |
| 159 | return 0; |
| 160 | alert->callref = remote->callref; |
| 161 | DEBUGP(DMNCC, "(call %x) Forwarding ALERT to remote.\n", call->callref); |
Harald Welte | 7655637 | 2010-12-22 23:57:45 +0100 | [diff] [blame] | 162 | return mncc_tx_to_cc(remote->net, MNCC_ALERT_REQ, alert); |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | static int mncc_notify_ind(struct gsm_call *call, int msg_type, |
| 166 | struct gsm_mncc *notify) |
| 167 | { |
| 168 | struct gsm_call *remote; |
| 169 | |
| 170 | /* send notify to remote */ |
| 171 | if (!(remote = get_call_ref(call->remote_ref))) |
| 172 | return 0; |
| 173 | notify->callref = remote->callref; |
| 174 | DEBUGP(DMNCC, "(call %x) Forwarding NOTIF to remote.\n", call->callref); |
Harald Welte | 7655637 | 2010-12-22 23:57:45 +0100 | [diff] [blame] | 175 | return mncc_tx_to_cc(remote->net, MNCC_NOTIFY_REQ, notify); |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | static int mncc_setup_cnf(struct gsm_call *call, int msg_type, |
| 179 | struct gsm_mncc *connect) |
| 180 | { |
| 181 | struct gsm_mncc connect_ack, frame_recv; |
| 182 | struct gsm_network *net = call->net; |
| 183 | struct gsm_call *remote; |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 184 | uint32_t refs[2]; |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 185 | |
| 186 | /* acknowledge connect */ |
| 187 | memset(&connect_ack, 0, sizeof(struct gsm_mncc)); |
| 188 | connect_ack.callref = call->callref; |
| 189 | DEBUGP(DMNCC, "(call %x) Acknowledge SETUP.\n", call->callref); |
Harald Welte | 7655637 | 2010-12-22 23:57:45 +0100 | [diff] [blame] | 190 | mncc_tx_to_cc(call->net, MNCC_SETUP_COMPL_REQ, &connect_ack); |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 191 | |
| 192 | /* send connect message to remote */ |
| 193 | if (!(remote = get_call_ref(call->remote_ref))) |
| 194 | return 0; |
| 195 | connect->callref = remote->callref; |
| 196 | DEBUGP(DMNCC, "(call %x) Sending CONNECT to remote.\n", call->callref); |
Harald Welte | 7655637 | 2010-12-22 23:57:45 +0100 | [diff] [blame] | 197 | mncc_tx_to_cc(remote->net, MNCC_SETUP_RSP, connect); |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 198 | |
| 199 | /* bridge tch */ |
| 200 | refs[0] = call->callref; |
| 201 | refs[1] = call->remote_ref; |
| 202 | DEBUGP(DMNCC, "(call %x) Bridging with remote.\n", call->callref); |
| 203 | |
| 204 | /* in direct mode, we always have to bridge the channels */ |
| 205 | if (ipacc_rtp_direct) |
Harald Welte | 7655637 | 2010-12-22 23:57:45 +0100 | [diff] [blame] | 206 | return mncc_tx_to_cc(call->net, MNCC_BRIDGE, refs); |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 207 | |
| 208 | /* proxy mode */ |
| 209 | if (!net->handover.active) { |
| 210 | /* in the no-handover case, we can bridge, i.e. use |
| 211 | * the old RTP proxy code */ |
Harald Welte | 7655637 | 2010-12-22 23:57:45 +0100 | [diff] [blame] | 212 | return mncc_tx_to_cc(call->net, MNCC_BRIDGE, refs); |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 213 | } else { |
| 214 | /* in case of handover, we need to re-write the RTP |
| 215 | * SSRC, sequence and timestamp values and thus |
| 216 | * need to enable RTP receive for both directions */ |
| 217 | memset(&frame_recv, 0, sizeof(struct gsm_mncc)); |
| 218 | frame_recv.callref = call->callref; |
Harald Welte | 7655637 | 2010-12-22 23:57:45 +0100 | [diff] [blame] | 219 | mncc_tx_to_cc(call->net, MNCC_FRAME_RECV, &frame_recv); |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 220 | frame_recv.callref = call->remote_ref; |
Harald Welte | 7655637 | 2010-12-22 23:57:45 +0100 | [diff] [blame] | 221 | return mncc_tx_to_cc(call->net, MNCC_FRAME_RECV, &frame_recv); |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 222 | } |
| 223 | } |
| 224 | |
| 225 | static int mncc_disc_ind(struct gsm_call *call, int msg_type, |
| 226 | struct gsm_mncc *disc) |
| 227 | { |
| 228 | struct gsm_call *remote; |
| 229 | |
| 230 | /* send release */ |
| 231 | DEBUGP(DMNCC, "(call %x) Releasing call with cause %d\n", |
| 232 | call->callref, disc->cause.value); |
Harald Welte | 7655637 | 2010-12-22 23:57:45 +0100 | [diff] [blame] | 233 | mncc_tx_to_cc(call->net, MNCC_REL_REQ, disc); |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 234 | |
| 235 | /* send disc to remote */ |
| 236 | if (!(remote = get_call_ref(call->remote_ref))) { |
| 237 | return 0; |
| 238 | } |
| 239 | disc->callref = remote->callref; |
| 240 | DEBUGP(DMNCC, "(call %x) Disconnecting remote with cause %d\n", |
| 241 | remote->callref, disc->cause.value); |
Harald Welte | 7655637 | 2010-12-22 23:57:45 +0100 | [diff] [blame] | 242 | return mncc_tx_to_cc(remote->net, MNCC_DISC_REQ, disc); |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | static int mncc_rel_ind(struct gsm_call *call, int msg_type, struct gsm_mncc *rel) |
| 246 | { |
| 247 | struct gsm_call *remote; |
| 248 | |
| 249 | /* send release to remote */ |
| 250 | if (!(remote = get_call_ref(call->remote_ref))) { |
| 251 | free_call(call); |
| 252 | return 0; |
| 253 | } |
Holger Hans Peter Freyther | a61c709 | 2011-01-27 15:05:45 +0100 | [diff] [blame] | 254 | |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 255 | rel->callref = remote->callref; |
| 256 | DEBUGP(DMNCC, "(call %x) Releasing remote with cause %d\n", |
| 257 | call->callref, rel->cause.value); |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 258 | |
Holger Hans Peter Freyther | a61c709 | 2011-01-27 15:05:45 +0100 | [diff] [blame] | 259 | /* |
| 260 | * Release this side of the call right now. Otherwise we end up |
| 261 | * in this method for the other call and will also try to release |
| 262 | * it and then we will end up with a double free and a crash |
| 263 | */ |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 264 | free_call(call); |
Holger Hans Peter Freyther | a61c709 | 2011-01-27 15:05:45 +0100 | [diff] [blame] | 265 | mncc_tx_to_cc(remote->net, MNCC_REL_REQ, rel); |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 266 | |
| 267 | return 0; |
| 268 | } |
| 269 | |
| 270 | static int mncc_rel_cnf(struct gsm_call *call, int msg_type, struct gsm_mncc *rel) |
| 271 | { |
| 272 | free_call(call); |
| 273 | return 0; |
| 274 | } |
| 275 | |
Andreas Eversberg | 9acbe4c | 2013-03-11 08:12:43 +0100 | [diff] [blame] | 276 | /* receiving a (speech) traffic frame from the BSC code */ |
| 277 | static int mncc_rcv_data(struct gsm_call *call, int msg_type, |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 278 | struct gsm_data_frame *dfr) |
| 279 | { |
| 280 | struct gsm_trans *remote_trans; |
| 281 | |
| 282 | remote_trans = trans_find_by_callref(call->net, call->remote_ref); |
| 283 | |
| 284 | /* this shouldn't really happen */ |
| 285 | if (!remote_trans || !remote_trans->conn) { |
| 286 | LOGP(DMNCC, LOGL_ERROR, "No transaction or transaction without lchan?!?\n"); |
| 287 | return -EIO; |
| 288 | } |
| 289 | |
| 290 | /* RTP socket of remote end has meanwhile died */ |
| 291 | if (!remote_trans->conn->lchan->abis_ip.rtp_socket) |
| 292 | return -EIO; |
| 293 | |
| 294 | return rtp_send_frame(remote_trans->conn->lchan->abis_ip.rtp_socket, dfr); |
| 295 | } |
| 296 | |
| 297 | |
| 298 | /* Internal MNCC handler input function (from CC -> MNCC -> here) */ |
Harald Welte | 29b64e9 | 2010-12-23 01:07:46 +0100 | [diff] [blame] | 299 | int int_mncc_recv(struct gsm_network *net, struct msgb *msg) |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 300 | { |
Harald Welte | 29b64e9 | 2010-12-23 01:07:46 +0100 | [diff] [blame] | 301 | void *arg = msgb_data(msg); |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 302 | struct gsm_mncc *data = arg; |
Harald Welte | 29b64e9 | 2010-12-23 01:07:46 +0100 | [diff] [blame] | 303 | int msg_type = data->msg_type; |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 304 | int callref; |
| 305 | struct gsm_call *call = NULL, *callt; |
| 306 | int rc = 0; |
| 307 | |
| 308 | /* Special messages */ |
| 309 | switch(msg_type) { |
| 310 | } |
| 311 | |
| 312 | /* find callref */ |
| 313 | callref = data->callref; |
| 314 | llist_for_each_entry(callt, &call_list, entry) { |
| 315 | if (callt->callref == callref) { |
| 316 | call = callt; |
| 317 | break; |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | /* create callref, if setup is received */ |
| 322 | if (!call) { |
| 323 | if (msg_type != MNCC_SETUP_IND) |
Harald Welte | 29b64e9 | 2010-12-23 01:07:46 +0100 | [diff] [blame] | 324 | goto out_free; /* drop */ |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 325 | /* create call */ |
| 326 | if (!(call = talloc_zero(tall_call_ctx, struct gsm_call))) { |
| 327 | struct gsm_mncc rel; |
| 328 | |
| 329 | memset(&rel, 0, sizeof(struct gsm_mncc)); |
| 330 | rel.callref = callref; |
| 331 | mncc_set_cause(&rel, GSM48_CAUSE_LOC_PRN_S_LU, |
| 332 | GSM48_CC_CAUSE_RESOURCE_UNAVAIL); |
Harald Welte | 7655637 | 2010-12-22 23:57:45 +0100 | [diff] [blame] | 333 | mncc_tx_to_cc(net, MNCC_REL_REQ, &rel); |
Harald Welte | 29b64e9 | 2010-12-23 01:07:46 +0100 | [diff] [blame] | 334 | goto out_free; |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 335 | } |
| 336 | llist_add_tail(&call->entry, &call_list); |
| 337 | call->net = net; |
| 338 | call->callref = callref; |
| 339 | DEBUGP(DMNCC, "(call %x) Call created.\n", call->callref); |
| 340 | } |
| 341 | |
Andreas Eversberg | 9acbe4c | 2013-03-11 08:12:43 +0100 | [diff] [blame] | 342 | if (mncc_is_data_frame(msg_type)) { |
| 343 | rc = mncc_rcv_data(call, msg_type, arg); |
| 344 | goto out_free; |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 345 | } |
| 346 | |
Andreas Eversberg | 9acbe4c | 2013-03-11 08:12:43 +0100 | [diff] [blame] | 347 | DEBUGP(DMNCC, "(call %x) Received message %s\n", call->callref, |
| 348 | get_mncc_name(msg_type)); |
| 349 | |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 350 | switch(msg_type) { |
| 351 | case MNCC_SETUP_IND: |
| 352 | rc = mncc_setup_ind(call, msg_type, arg); |
| 353 | break; |
| 354 | case MNCC_SETUP_CNF: |
| 355 | rc = mncc_setup_cnf(call, msg_type, arg); |
| 356 | break; |
| 357 | case MNCC_SETUP_COMPL_IND: |
| 358 | break; |
| 359 | case MNCC_CALL_CONF_IND: |
| 360 | /* we now need to MODIFY the channel */ |
Harald Welte | ab386e6 | 2011-09-01 18:18:43 +0200 | [diff] [blame] | 361 | data->lchan_mode = determine_lchan_mode(data); |
Harald Welte | 7655637 | 2010-12-22 23:57:45 +0100 | [diff] [blame] | 362 | mncc_tx_to_cc(call->net, MNCC_LCHAN_MODIFY, data); |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 363 | break; |
| 364 | case MNCC_ALERT_IND: |
| 365 | rc = mncc_alert_ind(call, msg_type, arg); |
| 366 | break; |
| 367 | case MNCC_NOTIFY_IND: |
| 368 | rc = mncc_notify_ind(call, msg_type, arg); |
| 369 | break; |
| 370 | case MNCC_DISC_IND: |
| 371 | rc = mncc_disc_ind(call, msg_type, arg); |
| 372 | break; |
| 373 | case MNCC_REL_IND: |
| 374 | case MNCC_REJ_IND: |
| 375 | rc = mncc_rel_ind(call, msg_type, arg); |
| 376 | break; |
| 377 | case MNCC_REL_CNF: |
| 378 | rc = mncc_rel_cnf(call, msg_type, arg); |
| 379 | break; |
| 380 | case MNCC_FACILITY_IND: |
| 381 | break; |
| 382 | case MNCC_START_DTMF_IND: |
| 383 | break; |
| 384 | case MNCC_STOP_DTMF_IND: |
| 385 | break; |
| 386 | case MNCC_MODIFY_IND: |
| 387 | mncc_set_cause(data, GSM48_CAUSE_LOC_PRN_S_LU, |
| 388 | GSM48_CC_CAUSE_SERV_OPT_UNIMPL); |
| 389 | DEBUGP(DMNCC, "(call %x) Rejecting MODIFY with cause %d\n", |
| 390 | call->callref, data->cause.value); |
Harald Welte | 7655637 | 2010-12-22 23:57:45 +0100 | [diff] [blame] | 391 | rc = mncc_tx_to_cc(net, MNCC_MODIFY_REJ, data); |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 392 | break; |
| 393 | case MNCC_MODIFY_CNF: |
| 394 | break; |
| 395 | case MNCC_HOLD_IND: |
| 396 | mncc_set_cause(data, GSM48_CAUSE_LOC_PRN_S_LU, |
| 397 | GSM48_CC_CAUSE_SERV_OPT_UNIMPL); |
| 398 | DEBUGP(DMNCC, "(call %x) Rejecting HOLD with cause %d\n", |
| 399 | call->callref, data->cause.value); |
Harald Welte | 7655637 | 2010-12-22 23:57:45 +0100 | [diff] [blame] | 400 | rc = mncc_tx_to_cc(net, MNCC_HOLD_REJ, data); |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 401 | break; |
| 402 | case MNCC_RETRIEVE_IND: |
| 403 | mncc_set_cause(data, GSM48_CAUSE_LOC_PRN_S_LU, |
| 404 | GSM48_CC_CAUSE_SERV_OPT_UNIMPL); |
| 405 | DEBUGP(DMNCC, "(call %x) Rejecting RETRIEVE with cause %d\n", |
| 406 | call->callref, data->cause.value); |
Harald Welte | 7655637 | 2010-12-22 23:57:45 +0100 | [diff] [blame] | 407 | rc = mncc_tx_to_cc(net, MNCC_RETRIEVE_REJ, data); |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 408 | break; |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 409 | default: |
| 410 | LOGP(DMNCC, LOGL_NOTICE, "(call %x) Message unhandled\n", callref); |
| 411 | break; |
| 412 | } |
| 413 | |
Harald Welte | 29b64e9 | 2010-12-23 01:07:46 +0100 | [diff] [blame] | 414 | out_free: |
Holger Hans Peter Freyther | a8ddb08 | 2012-03-01 20:30:32 +0100 | [diff] [blame] | 415 | msgb_free(msg); |
Harald Welte | 29b64e9 | 2010-12-23 01:07:46 +0100 | [diff] [blame] | 416 | |
Harald Welte | 3e6376d | 2010-12-22 23:54:51 +0100 | [diff] [blame] | 417 | return rc; |
| 418 | } |