blob: d1fff914868284f263d1c42f0733a5a1fda484f8 [file] [log] [blame]
Holger Hans Peter Freyther689e3cc2010-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>
Holger Hans Peter Freyther9c61b2a2010-11-05 19:48:47 +010028#include <osmocore/talloc.h>
Holger Hans Peter Freyther689e3cc2010-11-03 16:40:03 +010029#include <osmocore/protocol/gsm_08_08.h>
30
31#include <osmocom/sccp/sccp.h>
32
33static void msc_sccp_write_ipa(struct sccp_connection *conn, struct msgb *msg, void *data)
34{
35 LOGP(DMSC, LOGL_ERROR, "Writing is not implemented.\n");
36 msgb_free(msg);
37}
38
39static int msc_sccp_accept(struct sccp_connection *connection, void *data)
40{
41 LOGP(DMSC, LOGL_DEBUG, "Rejecting incoming SCCP connection.\n");
42 return -1;
43}
44
45static int msc_sccp_read(struct msgb *msgb, unsigned int length, void *data)
46{
47 struct bssmap_header *bs;
48
49 LOGP(DMSC, LOGL_DEBUG, "Incoming SCCP message ftom MSC: %s\n",
50 hexdump(msgb->l3h, length));
51
52 if (length < sizeof(*bs)) {
53 LOGP(DMSC, LOGL_ERROR, "The header is too short.\n");
54 return -1;
55 }
56
57 bs = (struct bssmap_header *) msgb->l3h;
58 if (bs->length < length - sizeof(*bs))
59 return -1;
60
61 switch (bs->type) {
62 case BSSAP_MSG_BSS_MANAGEMENT:
Holger Hans Peter Freythere0f3bb52010-11-03 18:46:52 +010063 LOGP(DMSC, LOGL_ERROR, "BSS management not implemented.\n");
Holger Hans Peter Freyther689e3cc2010-11-03 16:40:03 +010064 break;
65 default:
66 LOGP(DMSC, LOGL_ERROR, "Unimplemented msg type: %d\n", bs->type);
67 }
68
69 return 0;
70}
71
Holger Hans Peter Freyther13cde942010-11-04 11:48:49 +010072int bsc_queue_for_msc(struct gsm_subscriber_connection *conn, struct msgb *msg)
73{
74 LOGP(DMSC, LOGL_ERROR, "Sending SCCP messages is not yet implemented.\n");
75 msgb_free(msg);
76 return 0;
77}
78
Holger Hans Peter Freyther9c61b2a2010-11-05 19:48:47 +010079int bsc_create_new_connection(struct gsm_subscriber_connection *conn)
Holger Hans Peter Freyther1b8e90a2010-11-05 11:10:46 +010080{
81 LOGP(DMSC, LOGL_ERROR, "Not implemented yet.\n");
82 return -1;
83}
84
Holger Hans Peter Freyther9c61b2a2010-11-05 19:48:47 +010085int bsc_open_connection(struct gsm_subscriber_connection *conn, struct msgb *msg)
86{
87 LOGP(DMSC, LOGL_ERROR, "Not implemented yet.\n");
88 return -1;
89}
90
91int bsc_delete_connection(struct gsm_subscriber_connection *conn)
92{
93 if (!conn->sccp_con)
94 return 0;
95
96 talloc_free(conn->sccp_con);
97 conn->sccp_con = NULL;
98 return 0;
99}
100
Holger Hans Peter Freyther689e3cc2010-11-03 16:40:03 +0100101int osmo_bsc_sccp_init(struct gsm_network *gsmnet)
102{
103 sccp_set_log_area(DSCCP);
104 sccp_system_init(msc_sccp_write_ipa, gsmnet);
105 sccp_connection_set_incoming(&sccp_ssn_bssap, msc_sccp_accept, NULL);
106 sccp_set_read(&sccp_ssn_bssap, msc_sccp_read, NULL);
107
108 return 0;
109}