blob: 5ffbde0cbb8251e92e8ded1774c8813d88cc74ae [file] [log] [blame]
Holger Hans Peter Freytherf3d1ae72010-11-03 16:40:03 +01001/* Interaction with the SCCP subsystem */
2/*
3 * (C) 2009-2010 by Holger Hans Peter Freyther <zecke@selfish.org>
4 * (C) 2009-2010 by On-Waves
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 General Public License as published by
9 * the Free Software Foundation; either version 2 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 General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 */
22
23#include <openbsc/gsm_data.h>
24#include <openbsc/osmo_msc_data.h>
25#include <openbsc/debug.h>
26
27#include <osmocore/gsm0808.h>
28#include <osmocore/protocol/gsm_08_08.h>
29
30#include <osmocom/sccp/sccp.h>
31
32static void msc_sccp_write_ipa(struct sccp_connection *conn, struct msgb *msg, void *data)
33{
34 LOGP(DMSC, LOGL_ERROR, "Writing is not implemented.\n");
35 msgb_free(msg);
36}
37
38static int msc_sccp_accept(struct sccp_connection *connection, void *data)
39{
40 LOGP(DMSC, LOGL_DEBUG, "Rejecting incoming SCCP connection.\n");
41 return -1;
42}
43
44static int msc_sccp_read(struct msgb *msgb, unsigned int length, void *data)
45{
46 struct bssmap_header *bs;
47
48 LOGP(DMSC, LOGL_DEBUG, "Incoming SCCP message ftom MSC: %s\n",
49 hexdump(msgb->l3h, length));
50
51 if (length < sizeof(*bs)) {
52 LOGP(DMSC, LOGL_ERROR, "The header is too short.\n");
53 return -1;
54 }
55
56 bs = (struct bssmap_header *) msgb->l3h;
57 if (bs->length < length - sizeof(*bs))
58 return -1;
59
60 switch (bs->type) {
61 case BSSAP_MSG_BSS_MANAGEMENT:
Holger Hans Peter Freyther1999cf12010-11-03 18:46:52 +010062 LOGP(DMSC, LOGL_ERROR, "BSS management not implemented.\n");
Holger Hans Peter Freytherf3d1ae72010-11-03 16:40:03 +010063 break;
64 default:
65 LOGP(DMSC, LOGL_ERROR, "Unimplemented msg type: %d\n", bs->type);
66 }
67
68 return 0;
69}
70
Holger Hans Peter Freyther45825862010-11-04 11:48:49 +010071int bsc_queue_for_msc(struct gsm_subscriber_connection *conn, struct msgb *msg)
72{
73 LOGP(DMSC, LOGL_ERROR, "Sending SCCP messages is not yet implemented.\n");
74 msgb_free(msg);
75 return 0;
76}
77
Holger Hans Peter Freytherf3d1ae72010-11-03 16:40:03 +010078int osmo_bsc_sccp_init(struct gsm_network *gsmnet)
79{
80 sccp_set_log_area(DSCCP);
81 sccp_system_init(msc_sccp_write_ipa, gsmnet);
82 sccp_connection_set_incoming(&sccp_ssn_bssap, msc_sccp_accept, NULL);
83 sccp_set_read(&sccp_ssn_bssap, msc_sccp_read, NULL);
84
85 return 0;
86}