blob: eca253505969769c2592aa4f6aa01960a8cbbced [file] [log] [blame]
Holger Hans Peter Freyther8ec49522011-08-15 15:53:00 +02001/* (C) 2009-2011 by Holger Hans Peter Freyther <zecke@selfish.org>
2 * (C) 2009-2011 by On-Waves
Holger Hans Peter Freyther4f448c92010-07-05 16:02:04 +08003 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
Harald Welte9af6ddf2011-01-01 15:25:50 +01006 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
Holger Hans Peter Freyther4f448c92010-07-05 16:02:04 +08008 * (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
Harald Welte9af6ddf2011-01-01 15:25:50 +010013 * GNU Affero General Public License for more details.
Holger Hans Peter Freyther4f448c92010-07-05 16:02:04 +080014 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010015 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Holger Hans Peter Freyther4f448c92010-07-05 16:02:04 +080017 *
18 */
19
20#include <openbsc/osmo_bsc.h>
Holger Hans Peter Freyther9b17c762010-11-05 19:48:47 +010021#include <openbsc/osmo_msc_data.h>
Holger Hans Peter Freyther7225fd12010-11-03 19:03:35 +010022#include <openbsc/debug.h>
23
Jacob Erlbeck56595f82013-09-11 10:46:55 +020024#include <openbsc/gsm_04_80.h>
25
Harald Welted36ff762011-03-23 18:26:56 +010026#include <osmocom/gsm/protocol/gsm_08_08.h>
27#include <osmocom/gsm/gsm0808.h>
Holger Hans Peter Freyther2d2c9102010-11-04 11:59:41 +010028
Holger Hans Peter Freyther9b9a1712011-06-09 14:44:47 +020029#include <osmocom/sccp/sccp.h>
30
Holger Hans Peter Freyther7225fd12010-11-03 19:03:35 +010031#define return_when_not_connected(conn) \
32 if (!conn->sccp_con) {\
33 LOGP(DMSC, LOGL_ERROR, "MSC Connection not present.\n"); \
34 return; \
35 }
36
37#define return_when_not_connected_val(conn, ret) \
38 if (!conn->sccp_con) {\
39 LOGP(DMSC, LOGL_ERROR, "MSC Connection not present.\n"); \
40 return ret; \
41 }
Holger Hans Peter Freyther4f448c92010-07-05 16:02:04 +080042
Holger Hans Peter Freyther46c5ab32010-11-05 11:02:28 +010043#define queue_msg_or_return(resp) \
44 if (!resp) { \
45 LOGP(DMSC, LOGL_ERROR, "Failed to allocate response.\n"); \
46 return; \
47 } \
Holger Hans Peter Freyther863a55d2010-11-10 09:31:41 +010048 bsc_queue_for_msc(conn->sccp_con, resp);
Holger Hans Peter Freyther46c5ab32010-11-05 11:02:28 +010049
Holger Hans Peter Freyther83d2d382011-06-09 17:37:04 +020050static int bsc_clear_request(struct gsm_subscriber_connection *conn, uint32_t cause);
51static int complete_layer3(struct gsm_subscriber_connection *conn,
52 struct msgb *msg, struct osmo_msc_data *msc);
53
Holger Hans Peter Freyther4cdb0502011-06-04 14:51:51 +020054static uint16_t get_network_code_for_msc(struct osmo_msc_data *msc)
Holger Hans Peter Freyther9b17c762010-11-05 19:48:47 +010055{
Holger Hans Peter Freyther4cdb0502011-06-04 14:51:51 +020056 if (msc->core_ncc != -1)
57 return msc->core_ncc;
58 return msc->network->network_code;
Holger Hans Peter Freyther9b17c762010-11-05 19:48:47 +010059}
60
Holger Hans Peter Freyther4cdb0502011-06-04 14:51:51 +020061static uint16_t get_country_code_for_msc(struct osmo_msc_data *msc)
Holger Hans Peter Freyther9b17c762010-11-05 19:48:47 +010062{
Holger Hans Peter Freyther4cdb0502011-06-04 14:51:51 +020063 if (msc->core_mcc != -1)
64 return msc->core_mcc;
65 return msc->network->country_code;
Holger Hans Peter Freyther9b17c762010-11-05 19:48:47 +010066}
67
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +080068static void bsc_sapi_n_reject(struct gsm_subscriber_connection *conn, int dlci)
69{
Holger Hans Peter Freytherc8166f32010-11-04 12:28:32 +010070 struct msgb *resp;
Holger Hans Peter Freyther7225fd12010-11-03 19:03:35 +010071 return_when_not_connected(conn);
Holger Hans Peter Freytherc8166f32010-11-04 12:28:32 +010072
Harald Welte7d33bdf2011-07-12 00:05:11 +020073 LOGP(DMSC, LOGL_NOTICE, "Tx MSC SAPI N REJECT DLCI=0x%02x\n", dlci);
74
Holger Hans Peter Freytherc8166f32010-11-04 12:28:32 +010075 resp = gsm0808_create_sapi_reject(dlci);
Holger Hans Peter Freyther46c5ab32010-11-05 11:02:28 +010076 queue_msg_or_return(resp);
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +080077}
78
79static void bsc_cipher_mode_compl(struct gsm_subscriber_connection *conn,
80 struct msgb *msg, uint8_t chosen_encr)
81{
Holger Hans Peter Freyther2d2c9102010-11-04 11:59:41 +010082 struct msgb *resp;
Holger Hans Peter Freyther7225fd12010-11-03 19:03:35 +010083 return_when_not_connected(conn);
Holger Hans Peter Freyther2d2c9102010-11-04 11:59:41 +010084
85 LOGP(DMSC, LOGL_DEBUG, "CIPHER MODE COMPLETE from MS, forwarding to MSC\n");
86 resp = gsm0808_create_cipher_complete(msg, chosen_encr);
Holger Hans Peter Freyther46c5ab32010-11-05 11:02:28 +010087 queue_msg_or_return(resp);
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +080088}
89
Holger Hans Peter Freyther28e183f2013-10-31 13:35:28 +010090static void bsc_send_ussd_notification(struct gsm_subscriber_connection *conn,
91 struct msgb *msg, const char *text)
Jacob Erlbeck56595f82013-09-11 10:46:55 +020092{
93 struct gsm48_hdr *gh;
94 int8_t pdisc;
95 uint8_t mtype;
96 int drop_message = 1;
97
98 if (!text)
99 return;
100
101 if (!msg || msgb_l3len(msg) < sizeof(*gh))
102 return;
103
104 gh = msgb_l3(msg);
105 pdisc = gh->proto_discr & 0x0f;
106 mtype = gh->msg_type & 0xbf;
107
108 /* Is CM service request? */
109 if (pdisc == GSM48_PDISC_MM && mtype == GSM48_MT_MM_CM_SERV_REQ) {
110 struct gsm48_service_request *cm;
111
112 cm = (struct gsm48_service_request *) &gh->data[0];
113
114 /* Is type SMS or call? */
115 if (cm->cm_service_type == GSM48_CMSERV_SMS)
116 drop_message = 0;
117 else if (cm->cm_service_type == GSM48_CMSERV_MO_CALL_PACKET)
118 drop_message = 0;
119 }
120
121 if (drop_message) {
Holger Hans Peter Freyther28e183f2013-10-31 13:35:28 +0100122 LOGP(DMSC, LOGL_DEBUG, "Skipping (not sending) USSD message: '%s'\n", text);
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200123 return;
124 }
125
Jacob Erlbeckb1250312013-10-31 15:36:42 +0100126 LOGP(DMSC, LOGL_INFO, "Sending CM Service Accept\n");
127 gsm48_tx_mm_serv_ack(conn);
128
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200129 LOGP(DMSC, LOGL_INFO, "Sending USSD message: '%s'\n", text);
130 gsm0480_send_ussdNotify(conn, 1, text);
131 gsm0480_send_releaseComplete(conn);
132}
133
Holger Hans Peter Freyther9b17c762010-11-05 19:48:47 +0100134/*
135 * Instruct to reserve data for a new connectiom, create the complete
136 * layer three message, send it to open the connection.
137 */
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +0800138static int bsc_compl_l3(struct gsm_subscriber_connection *conn, struct msgb *msg,
139 uint16_t chosen_channel)
140{
Holger Hans Peter Freyther354c87c2011-06-07 11:40:20 +0200141 struct osmo_msc_data *msc;
Holger Hans Peter Freyther9b17c762010-11-05 19:48:47 +0100142
Harald Welte7d33bdf2011-07-12 00:05:11 +0200143 LOGP(DMSC, LOGL_INFO, "Tx MSC COMPL L3\n");
144
Holger Hans Peter Freyther354c87c2011-06-07 11:40:20 +0200145 /* find the MSC link we want to use */
Holger Hans Peter Freyther076af1c2011-06-07 19:57:02 +0200146 msc = bsc_find_msc(conn, msg);
Holger Hans Peter Freyther354c87c2011-06-07 11:40:20 +0200147 if (!msc) {
148 LOGP(DMSC, LOGL_ERROR, "Failed to find a MSC for a connection.\n");
Holger Hans Peter Freyther28e183f2013-10-31 13:35:28 +0100149 bsc_send_ussd_notification(conn, msg, conn->bts->network->bsc_data->ussd_no_msc_txt);
Holger Hans Peter Freyther354c87c2011-06-07 11:40:20 +0200150 return -1;
151 }
152
Holger Hans Peter Freyther83d2d382011-06-09 17:37:04 +0200153 return complete_layer3(conn, msg, msc);
154}
155
156static int complete_layer3(struct gsm_subscriber_connection *conn,
157 struct msgb *msg, struct osmo_msc_data *msc)
158{
159 struct msgb *resp;
160 uint16_t network_code;
161 uint16_t country_code;
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200162 enum bsc_con ret;
Holger Hans Peter Freyther83d2d382011-06-09 17:37:04 +0200163
Holger Hans Peter Freyther9b17c762010-11-05 19:48:47 +0100164 /* allocate resource for a new connection */
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200165 ret = bsc_create_new_connection(conn, msc);
166
167 if (ret != BSC_CON_SUCCESS) {
168 /* allocation has failed */
169 if (ret == BSC_CON_REJECT_NO_LINK)
Holger Hans Peter Freyther28e183f2013-10-31 13:35:28 +0100170 bsc_send_ussd_notification(conn, msg, msc->ussd_msc_lost_txt);
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200171 else if (ret == BSC_CON_REJECT_RF_GRACE)
Holger Hans Peter Freyther28e183f2013-10-31 13:35:28 +0100172 bsc_send_ussd_notification(conn, msg, msc->ussd_grace_txt);
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200173
Holger Hans Peter Freyther9b17c762010-11-05 19:48:47 +0100174 return BSC_API_CONN_POL_REJECT;
Jacob Erlbeck56595f82013-09-11 10:46:55 +0200175 }
176
177 /* check return value, if failed check msg for and send USSD */
Holger Hans Peter Freyther9b17c762010-11-05 19:48:47 +0100178
Holger Hans Peter Freyther4cdb0502011-06-04 14:51:51 +0200179 network_code = get_network_code_for_msc(conn->sccp_con->msc);
180 country_code = get_country_code_for_msc(conn->sccp_con->msc);
181
Holger Hans Peter Freyther9b17c762010-11-05 19:48:47 +0100182 bsc_scan_bts_msg(conn, msg);
183 resp = gsm0808_create_layer3(msg, network_code, country_code,
184 conn->bts->location_area_code,
185 conn->bts->cell_identity);
186 if (!resp) {
187 LOGP(DMSC, LOGL_DEBUG, "Failed to create layer3 message.\n");
Holger Hans Peter Freyther9b9a1712011-06-09 14:44:47 +0200188 sccp_connection_free(conn->sccp_con->sccp);
Holger Hans Peter Freyther7e901082010-11-06 20:15:17 +0100189 bsc_delete_connection(conn->sccp_con);
Holger Hans Peter Freyther9b17c762010-11-05 19:48:47 +0100190 return BSC_API_CONN_POL_REJECT;
Holger Hans Peter Freyther5bb874d2010-11-05 11:21:18 +0100191 }
192
Holger Hans Peter Freyther7e901082010-11-06 20:15:17 +0100193 if (bsc_open_connection(conn->sccp_con, resp) != 0) {
Holger Hans Peter Freyther9b9a1712011-06-09 14:44:47 +0200194 sccp_connection_free(conn->sccp_con->sccp);
Holger Hans Peter Freyther7e901082010-11-06 20:15:17 +0100195 bsc_delete_connection(conn->sccp_con);
Holger Hans Peter Freyther9b17c762010-11-05 19:48:47 +0100196 msgb_free(resp);
197 return BSC_API_CONN_POL_REJECT;
198 }
199
200 return BSC_API_CONN_POL_ACCEPT;
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +0800201}
202
Holger Hans Peter Freyther83d2d382011-06-09 17:37:04 +0200203/*
204 * Plastic surgery... we want to give up the current connection
205 */
206static int move_to_msc(struct gsm_subscriber_connection *_conn,
207 struct msgb *msg, struct osmo_msc_data *msc)
208{
209 struct osmo_bsc_sccp_con *old_con = _conn->sccp_con;
210
211 /*
212 * 1. Give up the old connection.
213 * This happens by sending a clear request to the MSC,
214 * it should end with the MSC releasing the connection.
215 */
216 old_con->conn = NULL;
217 bsc_clear_request(_conn, 0);
218
219 /*
220 * 2. Attempt to create a new connection to the local
221 * MSC. If it fails the caller will need to handle this
222 * properly.
223 */
224 _conn->sccp_con = NULL;
225 if (complete_layer3(_conn, msg, msc) != BSC_API_CONN_POL_ACCEPT) {
226 gsm0808_clear(_conn);
227 subscr_con_free(_conn);
228 return 1;
229 }
230
231 return 2;
232}
233
234static int handle_cc_setup(struct gsm_subscriber_connection *conn,
235 struct msgb *msg)
236{
237 struct gsm48_hdr *gh = msgb_l3(msg);
238 uint8_t pdisc = gh->proto_discr & 0x0f;
239 uint8_t mtype = gh->msg_type & 0xbf;
240
241 struct osmo_msc_data *msc;
242 struct gsm_mncc_number called;
243 struct tlv_parsed tp;
244 unsigned payload_len;
245
246 char _dest_nr[35];
247
248 /*
249 * Do we have a setup message here? if not return fast.
250 */
251 if (pdisc != GSM48_PDISC_CC || mtype != GSM48_MT_CC_SETUP)
252 return 0;
253
254 payload_len = msgb_l3len(msg) - sizeof(*gh);
255
256 tlv_parse(&tp, &gsm48_att_tlvdef, gh->data, payload_len, 0, 0);
257 if (!TLVP_PRESENT(&tp, GSM48_IE_CALLED_BCD)) {
258 LOGP(DMSC, LOGL_ERROR, "Called BCD not present in setup.\n");
259 return -1;
260 }
261
262 memset(&called, 0, sizeof(called));
263 gsm48_decode_called(&called,
264 TLVP_VAL(&tp, GSM48_IE_CALLED_BCD) - 1);
265
Holger Hans Peter Freyther0b19d552011-09-30 16:24:27 +0200266 if (called.plan != 1 && called.plan != 0)
Holger Hans Peter Freyther83d2d382011-06-09 17:37:04 +0200267 return 0;
268
Holger Hans Peter Freyther0b19d552011-09-30 16:24:27 +0200269 if (called.plan == 1 && called.type == 1) {
Holger Hans Peter Freyther83d2d382011-06-09 17:37:04 +0200270 _dest_nr[0] = _dest_nr[1] = '0';
271 memcpy(_dest_nr + 2, called.number, sizeof(called.number));
272 } else
273 memcpy(_dest_nr, called.number, sizeof(called.number));
274
275 /*
276 * Check if the connection should be moved...
277 */
278 llist_for_each_entry(msc, &conn->bts->network->bsc_data->mscs, entry) {
279 if (msc->type != MSC_CON_TYPE_LOCAL)
280 continue;
281 if (!msc->local_pref)
282 continue;
283 if (regexec(&msc->local_pref_reg, _dest_nr, 0, NULL, 0) != 0)
284 continue;
285
286 return move_to_msc(conn, msg, msc);
287 }
288
289 return 0;
290}
291
292
Holger Hans Peter Freyther46caa302010-11-04 12:18:00 +0100293static void bsc_dtap(struct gsm_subscriber_connection *conn, uint8_t link_id, struct msgb *msg)
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +0800294{
Holger Hans Peter Freyther58f2cf62010-11-04 12:24:05 +0100295 struct msgb *resp;
Holger Hans Peter Freyther7225fd12010-11-03 19:03:35 +0100296 return_when_not_connected(conn);
Holger Hans Peter Freyther58f2cf62010-11-04 12:24:05 +0100297
Harald Welte7d33bdf2011-07-12 00:05:11 +0200298 LOGP(DMSC, LOGL_INFO, "Tx MSC DTAP LINK_ID=0x%02x\n", link_id);
299
Holger Hans Peter Freyther83d2d382011-06-09 17:37:04 +0200300 /*
301 * We might want to move this connection to a new MSC. Ask someone
302 * to handle it. If it was handled we will return.
303 */
Holger Hans Peter Freytherc7db4dc2011-06-27 21:29:03 +0200304 if (handle_cc_setup(conn, msg) >= 1)
Holger Hans Peter Freyther83d2d382011-06-09 17:37:04 +0200305 return;
306
Holger Hans Peter Freyther5bb874d2010-11-05 11:21:18 +0100307 bsc_scan_bts_msg(conn, msg);
Holger Hans Peter Freyther83d2d382011-06-09 17:37:04 +0200308
309
Holger Hans Peter Freyther58f2cf62010-11-04 12:24:05 +0100310 resp = gsm0808_create_dtap(msg, link_id);
Holger Hans Peter Freyther46c5ab32010-11-05 11:02:28 +0100311 queue_msg_or_return(resp);
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +0800312}
313
Holger Hans Peter Freytherb0941712010-11-04 12:06:57 +0100314static void bsc_assign_compl(struct gsm_subscriber_connection *conn, uint8_t rr_cause,
315 uint8_t chosen_channel, uint8_t encr_alg_id,
316 uint8_t speech_model)
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +0800317{
Holger Hans Peter Freytherda488ae2010-11-04 12:09:45 +0100318 struct msgb *resp;
Holger Hans Peter Freyther7225fd12010-11-03 19:03:35 +0100319 return_when_not_connected(conn);
Holger Hans Peter Freytherda488ae2010-11-04 12:09:45 +0100320
Harald Welte7d33bdf2011-07-12 00:05:11 +0200321 LOGP(DMSC, LOGL_INFO, "Tx MSC ASSIGN COMPL\n");
322
Holger Hans Peter Freytherda488ae2010-11-04 12:09:45 +0100323 resp = gsm0808_create_assignment_completed(rr_cause, chosen_channel,
324 encr_alg_id, speech_model);
Holger Hans Peter Freyther46c5ab32010-11-05 11:02:28 +0100325 queue_msg_or_return(resp);
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +0800326}
327
Holger Hans Peter Freyther45b575f2010-11-05 10:37:17 +0100328static void bsc_assign_fail(struct gsm_subscriber_connection *conn,
329 uint8_t cause, uint8_t *rr_cause)
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +0800330{
Holger Hans Peter Freythere46f1d62010-11-05 10:59:45 +0100331 struct msgb *resp;
Holger Hans Peter Freyther7225fd12010-11-03 19:03:35 +0100332 return_when_not_connected(conn);
Holger Hans Peter Freythere46f1d62010-11-05 10:59:45 +0100333
Harald Welte7d33bdf2011-07-12 00:05:11 +0200334 LOGP(DMSC, LOGL_INFO, "Tx MSC ASSIGN FAIL\n");
335
Holger Hans Peter Freythere46f1d62010-11-05 10:59:45 +0100336 resp = gsm0808_create_assignment_failure(cause, rr_cause);
Holger Hans Peter Freyther46c5ab32010-11-05 11:02:28 +0100337 queue_msg_or_return(resp);
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +0800338}
339
Holger Hans Peter Freyther05c68842010-11-03 19:01:58 +0100340static int bsc_clear_request(struct gsm_subscriber_connection *conn, uint32_t cause)
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +0800341{
Holger Hans Peter Freyther80c37bd2011-08-06 14:52:56 +0200342 struct osmo_bsc_sccp_con *sccp;
Holger Hans Peter Freytherc2b32702010-11-04 12:47:06 +0100343 struct msgb *resp;
Holger Hans Peter Freyther7225fd12010-11-03 19:03:35 +0100344 return_when_not_connected_val(conn, 1);
Holger Hans Peter Freytherc2b32702010-11-04 12:47:06 +0100345
Harald Welte7d33bdf2011-07-12 00:05:11 +0200346 LOGP(DMSC, LOGL_INFO, "Tx MSC CLEAR REQUEST\n");
347
Holger Hans Peter Freyther80c37bd2011-08-06 14:52:56 +0200348 /*
349 * Remove the connection from BSC<->SCCP part, the SCCP part
350 * will either be cleared by channel release or MSC disconnect
351 */
352 sccp = conn->sccp_con;
353 sccp->conn = NULL;
354 conn->sccp_con = NULL;
355
Holger Hans Peter Freytherc2b32702010-11-04 12:47:06 +0100356 resp = gsm0808_create_clear_rqst(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE);
357 if (!resp) {
358 LOGP(DMSC, LOGL_ERROR, "Failed to allocate response.\n");
Holger Hans Peter Freyther80c37bd2011-08-06 14:52:56 +0200359 return 1;
Holger Hans Peter Freytherc2b32702010-11-04 12:47:06 +0100360 }
361
Holger Hans Peter Freyther80c37bd2011-08-06 14:52:56 +0200362 bsc_queue_for_msc(sccp, resp);
363 return 1;
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +0800364}
365
Harald Welte95e862c2012-01-23 10:28:35 +0100366static void bsc_cm_update(struct gsm_subscriber_connection *conn,
367 const uint8_t *cm2, uint8_t cm2_len,
368 const uint8_t *cm3, uint8_t cm3_len)
369{
Harald Welte95e862c2012-01-23 10:28:35 +0100370 struct msgb *resp;
Holger Hans Peter Freytherdc3389f2012-03-16 11:49:46 +0100371 return_when_not_connected(conn);
Harald Welte95e862c2012-01-23 10:28:35 +0100372
373 resp = gsm0808_create_classmark_update(cm2, cm2_len, cm3, cm3_len);
374
375 queue_msg_or_return(resp);
376}
377
Holger Hans Peter Freyther25aa7492011-08-06 07:00:52 +0200378static void bsc_mr_config(struct gsm_subscriber_connection *conn,
379 struct gsm48_multi_rate_conf *conf)
380{
381 struct osmo_msc_data *msc;
382
383 if (!conn->sccp_con) {
384 LOGP(DMSC, LOGL_ERROR,
385 "No msc data available on conn %p. Audio will be broken.\n",
386 conn);
387 return;
388 }
389
390 msc = conn->sccp_con->msc;
391
392 conf->ver = 1;
393 conf->icmi = 1;
394
395 /* maybe gcc see's it is copy of _one_ byte */
396 conf->m4_75 = msc->amr_conf.m4_75;
397 conf->m5_15 = msc->amr_conf.m5_15;
398 conf->m5_90 = msc->amr_conf.m5_90;
399 conf->m6_70 = msc->amr_conf.m6_70;
400 conf->m7_40 = msc->amr_conf.m7_40;
401 conf->m7_95 = msc->amr_conf.m7_95;
402 conf->m10_2 = msc->amr_conf.m10_2;
403 conf->m12_2 = msc->amr_conf.m12_2;
404}
405
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +0800406static struct bsc_api bsc_handler = {
407 .sapi_n_reject = bsc_sapi_n_reject,
408 .cipher_mode_compl = bsc_cipher_mode_compl,
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +0800409 .compl_l3 = bsc_compl_l3,
410 .dtap = bsc_dtap,
411 .assign_compl = bsc_assign_compl,
412 .assign_fail = bsc_assign_fail,
413 .clear_request = bsc_clear_request,
Harald Welte95e862c2012-01-23 10:28:35 +0100414 .classmark_chg = bsc_cm_update,
Holger Hans Peter Freyther25aa7492011-08-06 07:00:52 +0200415 .mr_config = bsc_mr_config,
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +0800416};
417
Holger Hans Peter Freyther4f448c92010-07-05 16:02:04 +0800418struct bsc_api *osmo_bsc_api()
419{
Holger Hans Peter Freyther32aaef62010-09-16 17:26:35 +0800420 return &bsc_handler;
Holger Hans Peter Freyther4f448c92010-07-05 16:02:04 +0800421}