blob: 001fcbac047e8f9b7e66d47899643721ad5160e0 [file] [log] [blame]
Neels Hofmeyre2f24d52017-05-08 15:12:20 +02001/* Implementation for MSC decisions which interface to send messages out on. */
2
3/* (C) 2016 by sysmocom s.m.f.c GmbH <info@sysmocom.de>
4 *
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <osmocom/core/logging.h>
22
23#include <openbsc/debug.h>
24#include <openbsc/gsm_data.h>
25#include <openbsc/msc_ifaces.h>
26
27static int msc_tx(struct gsm_subscriber_connection *conn, struct msgb *msg)
28{
29 switch (conn->via_ran) {
30 /* FUTURE
31 case RAN_GERAN_A:
32 msg->dst = conn;
33 return a_tx(msg);
34
35 case RAN_UTRAN_IU:
36 msg->dst = conn->iu.ue_ctx;
37 return iu_tx(msg, 0);
38 */
39 default:
40 LOGP(DMSC, LOGL_ERROR,
41 "msc_tx(): conn->via_ran invalid (%d)\n",
42 conn->via_ran);
43 return -1;
44 }
45}
46
47
48int msc_tx_dtap(struct gsm_subscriber_connection *conn,
49 struct msgb *msg)
50{
51 return msc_tx(conn, msg);
52}
53
54
55/* 9.2.5 CM service accept */
56int msc_gsm48_tx_mm_serv_ack(struct gsm_subscriber_connection *conn)
57{
58 struct msgb *msg = gsm48_msgb_alloc_name("GSM 04.08 SERV ACC");
59 struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh));
60
61 gh->proto_discr = GSM48_PDISC_MM;
62 gh->msg_type = GSM48_MT_MM_CM_SERV_ACC;
63
64 DEBUGP(DMM, "-> CM SERVICE ACCEPT\n");
65
66 return msc_tx_dtap(conn, msg);
67}
68
69/* 9.2.6 CM service reject */
70int msc_gsm48_tx_mm_serv_rej(struct gsm_subscriber_connection *conn,
71 enum gsm48_reject_value value)
72{
73 struct msgb *msg;
74
75 msg = gsm48_create_mm_serv_rej(value);
76 if (!msg) {
77 LOGP(DMM, LOGL_ERROR, "Failed to allocate CM Service Reject.\n");
78 return -1;
79 }
80
81 DEBUGP(DMM, "-> CM SERVICE Reject cause: %d\n", value);
82
83 return msc_tx_dtap(conn, msg);
84}