Holger Hans Peter Freyther | 689e3cc | 2010-11-03 16:40:03 +0100 | [diff] [blame] | 1 | /* 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 | |
| 32 | static 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 | |
| 38 | static 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 | |
| 44 | static 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 Freyther | e0f3bb5 | 2010-11-03 18:46:52 +0100 | [diff] [blame] | 62 | LOGP(DMSC, LOGL_ERROR, "BSS management not implemented.\n"); |
Holger Hans Peter Freyther | 689e3cc | 2010-11-03 16:40:03 +0100 | [diff] [blame] | 63 | 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 Freyther | 13cde94 | 2010-11-04 11:48:49 +0100 | [diff] [blame] | 71 | int 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 Freyther | 689e3cc | 2010-11-03 16:40:03 +0100 | [diff] [blame] | 78 | int 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 | } |