blob: 82074e7e1b15bc23eabed400a59c2158ec303e2e [file] [log] [blame]
Holger Hans Peter Freyther4f448c92010-07-05 16:02:04 +08001/* (C) 2009-2010 by Holger Hans Peter Freyther <zecke@selfish.org>
2 * (C) 2009-2010 by On-Waves
3 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 */
20
21#include <openbsc/osmo_bsc.h>
Holger Hans Peter Freyther7225fd12010-11-03 19:03:35 +010022#include <openbsc/debug.h>
23
24#define return_when_not_connected(conn) \
25 if (!conn->sccp_con) {\
26 LOGP(DMSC, LOGL_ERROR, "MSC Connection not present.\n"); \
27 return; \
28 }
29
30#define return_when_not_connected_val(conn, ret) \
31 if (!conn->sccp_con) {\
32 LOGP(DMSC, LOGL_ERROR, "MSC Connection not present.\n"); \
33 return ret; \
34 }
Holger Hans Peter Freyther4f448c92010-07-05 16:02:04 +080035
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +080036static void bsc_sapi_n_reject(struct gsm_subscriber_connection *conn, int dlci)
37{
Holger Hans Peter Freyther7225fd12010-11-03 19:03:35 +010038 return_when_not_connected(conn);
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +080039}
40
41static void bsc_cipher_mode_compl(struct gsm_subscriber_connection *conn,
42 struct msgb *msg, uint8_t chosen_encr)
43{
Holger Hans Peter Freyther7225fd12010-11-03 19:03:35 +010044 return_when_not_connected(conn);
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +080045}
46
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +080047static int bsc_compl_l3(struct gsm_subscriber_connection *conn, struct msgb *msg,
48 uint16_t chosen_channel)
49{
50 return BSC_API_CONN_POL_REJECT;
51}
52
Holger Hans Peter Freyther46caa302010-11-04 12:18:00 +010053static void bsc_dtap(struct gsm_subscriber_connection *conn, uint8_t link_id, struct msgb *msg)
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +080054{
Holger Hans Peter Freyther7225fd12010-11-03 19:03:35 +010055 return_when_not_connected(conn);
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +080056}
57
Holger Hans Peter Freytherb0941712010-11-04 12:06:57 +010058static void bsc_assign_compl(struct gsm_subscriber_connection *conn, uint8_t rr_cause,
59 uint8_t chosen_channel, uint8_t encr_alg_id,
60 uint8_t speech_model)
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +080061{
Holger Hans Peter Freyther7225fd12010-11-03 19:03:35 +010062 return_when_not_connected(conn);
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +080063}
64
Holger Hans Peter Freyther45b575f2010-11-05 10:37:17 +010065static void bsc_assign_fail(struct gsm_subscriber_connection *conn,
66 uint8_t cause, uint8_t *rr_cause)
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +080067{
Holger Hans Peter Freyther7225fd12010-11-03 19:03:35 +010068 return_when_not_connected(conn);
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +080069}
70
Holger Hans Peter Freyther05c68842010-11-03 19:01:58 +010071static int bsc_clear_request(struct gsm_subscriber_connection *conn, uint32_t cause)
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +080072{
Holger Hans Peter Freyther7225fd12010-11-03 19:03:35 +010073 return_when_not_connected_val(conn, 1);
Holger Hans Peter Freyther05c68842010-11-03 19:01:58 +010074 return 0;
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +080075}
76
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +080077static struct bsc_api bsc_handler = {
78 .sapi_n_reject = bsc_sapi_n_reject,
79 .cipher_mode_compl = bsc_cipher_mode_compl,
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +080080 .compl_l3 = bsc_compl_l3,
81 .dtap = bsc_dtap,
82 .assign_compl = bsc_assign_compl,
83 .assign_fail = bsc_assign_fail,
84 .clear_request = bsc_clear_request,
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +080085};
86
Holger Hans Peter Freyther4f448c92010-07-05 16:02:04 +080087struct bsc_api *osmo_bsc_api()
88{
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +080089 return &bsc_handler;
Holger Hans Peter Freyther4f448c92010-07-05 16:02:04 +080090}