blob: fb5a09189b59bffd3a11216b82bf93a51940f423 [file] [log] [blame]
Harald Welte8c8f7912009-10-26 20:42:55 +01001/* GSM Mobile Radio Interface Layer 3 messages on the A-bis interface
Harald Welte6eafe912009-10-16 08:32:58 +02002 * 3GPP TS 04.08 version 7.21.0 Release 1998 / ETSI TS 100 940 V7.21.0 */
3
4/* (C) 2008-2009 by Harald Welte <laforge@gnumonks.org>
Holger Hans Peter Freyther680833e2010-07-25 18:08:53 +08005 * (C) 2008, 2009, 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
Harald Welte6eafe912009-10-16 08:32:58 +02006 * (C) 2009 by Mike Haben <michael.haben@btinternet.com>
7 *
8 * All Rights Reserved
9 *
10 * This program is free software; you can redistribute it and/or modify
Harald Welte9af6ddf2011-01-01 15:25:50 +010011 * it under the terms of the GNU Affero General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
Harald Welte6eafe912009-10-16 08:32:58 +020013 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Harald Welte9af6ddf2011-01-01 15:25:50 +010018 * GNU Affero General Public License for more details.
Harald Welte6eafe912009-10-16 08:32:58 +020019 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010020 * You should have received a copy of the GNU Affero General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Harald Welte6eafe912009-10-16 08:32:58 +020022 *
23 */
24
Vadim Yanitskiy0622ef52018-08-03 04:39:04 +070025#include <stdint.h>
Harald Welte6eafe912009-10-16 08:32:58 +020026#include <errno.h>
27
Neels Hofmeyr90843962017-09-04 15:04:35 +020028#include <osmocom/msc/gsm_04_80.h>
29#include <osmocom/msc/msc_ifaces.h>
Harald Welte6eafe912009-10-16 08:32:58 +020030
Vadim Yanitskiy0622ef52018-08-03 04:39:04 +070031#include <osmocom/gsm/protocol/gsm_04_80.h>
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010032#include <osmocom/gsm/gsm0480.h>
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010033#include <osmocom/core/msgb.h>
34#include <osmocom/gsm/tlv.h>
Holger Hans Peter Freytherc0714b82010-09-30 18:48:28 +080035
Vadim Yanitskiy5df4e4d2018-06-12 08:03:53 +070036/*! Send a MT RELEASE COMPLETE message with Reject component
37 * (see section 3.6.1) and given error code (see section 3.6.7).
38 *
Neels Hofmeyrc036b792018-11-29 22:37:51 +010039 * \param[in] conn Active RAN connection
Vadim Yanitskiy5df4e4d2018-06-12 08:03:53 +070040 * \param[in] transaction_id Transaction ID with TI flag set
41 * \param[in] invoke_id InvokeID of the request
42 * \param[in] problem_tag Problem code tag (table 3.13)
43 * \param[in] problem_code Problem code (tables 3.14-17)
44 * \return result of \ref msc_tx_dtap
45 *
46 * Note: if InvokeID is not available, e.g. when message parsing
47 * failed, any incorrect value can be passed (0x00 > x > 0xff), so
48 * the universal NULL-tag (see table 3.6) will be used instead.
49 */
Neels Hofmeyrc036b792018-11-29 22:37:51 +010050int msc_send_ussd_reject(struct ran_conn *conn,
Vadim Yanitskiy5df4e4d2018-06-12 08:03:53 +070051 uint8_t transaction_id, int invoke_id,
52 uint8_t problem_tag, uint8_t problem_code)
Harald Welte6eafe912009-10-16 08:32:58 +020053{
Harald Welte6eafe912009-10-16 08:32:58 +020054 struct gsm48_hdr *gh;
Vadim Yanitskiy0622ef52018-08-03 04:39:04 +070055 struct msgb *msg;
Harald Welte6eafe912009-10-16 08:32:58 +020056
Vadim Yanitskiy0622ef52018-08-03 04:39:04 +070057 msg = gsm0480_gen_reject(invoke_id, problem_tag, problem_code);
58 if (!msg)
59 return -1;
Harald Welte6eafe912009-10-16 08:32:58 +020060
61 /* Wrap the component in a Facility message */
62 msgb_wrap_with_TL(msg, GSM0480_IE_FACILITY);
63
64 /* And finally pre-pend the L3 header */
65 gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh));
Vadim Yanitskiy5df4e4d2018-06-12 08:03:53 +070066 gh->proto_discr = GSM48_PDISC_NC_SS;
67 gh->proto_discr |= transaction_id << 4;
Harald Welte6eafe912009-10-16 08:32:58 +020068 gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE;
69
Neels Hofmeyr84da6b12016-05-20 21:59:55 +020070 return msc_tx_dtap(conn, msg);
Harald Welte6eafe912009-10-16 08:32:58 +020071}
Holger Hans Peter Freytherdaf75342010-07-26 20:01:07 +080072
Neels Hofmeyrc036b792018-11-29 22:37:51 +010073int msc_send_ussd_notify(struct ran_conn *conn, int level, const char *text)
Holger Hans Peter Freytherdaf75342010-07-26 20:01:07 +080074{
Neels Hofmeyr43273c62016-05-10 12:50:31 +020075 struct msgb *msg = gsm0480_create_ussd_notify(level, text);
Holger Hans Peter Freytherdaf75342010-07-26 20:01:07 +080076 if (!msg)
77 return -1;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +020078 return msc_tx_dtap(conn, msg);
Holger Hans Peter Freytherdaf75342010-07-26 20:01:07 +080079}
Holger Hans Peter Freyther68d26792010-07-27 03:31:50 +080080
Neels Hofmeyrc036b792018-11-29 22:37:51 +010081int msc_send_ussd_release_complete(struct ran_conn *conn)
Holger Hans Peter Freyther68d26792010-07-27 03:31:50 +080082{
Neels Hofmeyr43273c62016-05-10 12:50:31 +020083 struct msgb *msg = gsm0480_create_ussd_release_complete();
Holger Hans Peter Freyther68d26792010-07-27 03:31:50 +080084 if (!msg)
85 return -1;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +020086 return msc_tx_dtap(conn, msg);
Holger Hans Peter Freyther68d26792010-07-27 03:31:50 +080087}