summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-05-30 14:57:14 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-03-09 18:34:15 +0100
commit412ae8684967f8f79c8c0f5835121f2bf6941409 (patch)
tree6ee3d6ba3b617c3e02a6d9f4bbe98b1683a47f81
parentbad881ea539a5054f6e9f5fb4dad5e3c38e19a30 (diff)
osmo-nitb becomes osmo-msc
-rw-r--r--openbsc/.gitignore1
-rw-r--r--openbsc/configure.ac4
-rw-r--r--openbsc/doc/examples/osmo-msc/osmo-msc.cfg36
-rw-r--r--openbsc/src/Makefile.am2
-rw-r--r--openbsc/src/osmo-msc/Makefile.am (renamed from openbsc/src/osmo-nitb/Makefile.am)25
-rw-r--r--openbsc/src/osmo-msc/iucs_ranap.c119
-rw-r--r--openbsc/src/osmo-msc/iucs_ranap.h6
-rw-r--r--openbsc/src/osmo-msc/msc_main.c (renamed from openbsc/src/osmo-nitb/bsc_hack.c)279
8 files changed, 374 insertions, 98 deletions
diff --git a/openbsc/.gitignore b/openbsc/.gitignore
index 0bf22de..abb8350 100644
--- a/openbsc/.gitignore
+++ b/openbsc/.gitignore
@@ -56,6 +56,7 @@ src/gprs/osmo-gbproxy
src/gprs/osmo-gtphub
src/osmo-bsc_nat/osmo-bsc_nat
src/libcommon/gsup_test_client
+src/osmo-msc/osmo-msc
#tests
tests/testsuite.dir
diff --git a/openbsc/configure.ac b/openbsc/configure.ac
index 190c04b..f13c85c 100644
--- a/openbsc/configure.ac
+++ b/openbsc/configure.ac
@@ -62,7 +62,7 @@ fi
AM_CONDITIONAL(BUILD_BSC, test "x$osmo_ac_build_bsc" = "xyes")
AC_SUBST(osmo_ac_build_bsc)
-# Enable/disable smpp support in the nitb?
+# Enable/disable smpp support in the msc?
AC_ARG_ENABLE([smpp], [AS_HELP_STRING([--enable-smpp], [Build the SMPP interface])],
[osmo_ac_build_smpp="$enableval"],[osmo_ac_build_smpp="no"])
if test "$osmo_ac_build_smpp" = "yes" ; then
@@ -228,7 +228,7 @@ AC_OUTPUT(
src/libfilter/Makefile
src/libiu/Makefile
src/libcommon-cs/Makefile
- src/osmo-nitb/Makefile
+ src/osmo-msc/Makefile
src/osmo-bsc/Makefile
src/osmo-bsc_nat/Makefile
src/osmo-bsc_mgcp/Makefile
diff --git a/openbsc/doc/examples/osmo-msc/osmo-msc.cfg b/openbsc/doc/examples/osmo-msc/osmo-msc.cfg
new file mode 100644
index 0000000..209ddd2
--- /dev/null
+++ b/openbsc/doc/examples/osmo-msc/osmo-msc.cfg
@@ -0,0 +1,36 @@
+!
+! OsmoMSC configuration saved from vty
+!
+line vty
+ no login
+!
+network
+ network country code 1
+ mobile network code 1
+ short name OsmoMSC
+ long name OsmoMSC
+ auth policy closed
+ location updating reject cause 13
+ encryption a5 0
+ rrlp mode none
+ mm info 1
+ handover 0
+ handover window rxlev averaging 10
+ handover window rxqual averaging 1
+ handover window rxlev neighbor averaging 10
+ handover power budget interval 6
+ handover power budget hysteresis 3
+ handover maximum distance 9999
+ timer t3101 10
+ timer t3103 0
+ timer t3105 0
+ timer t3107 0
+ timer t3109 4
+ timer t3111 0
+ timer t3113 60
+ timer t3115 0
+ timer t3117 0
+ timer t3119 0
+ timer t3141 0
+msc
+ subscriber-create-on-demand
diff --git a/openbsc/src/Makefile.am b/openbsc/src/Makefile.am
index c66f9e5..7e9e1dc 100644
--- a/openbsc/src/Makefile.am
+++ b/openbsc/src/Makefile.am
@@ -40,7 +40,7 @@ endif
# Programs
SUBDIRS += \
- osmo-nitb \
+ osmo-msc \
osmo-bsc_mgcp \
utils \
ipaccess \
diff --git a/openbsc/src/osmo-nitb/Makefile.am b/openbsc/src/osmo-msc/Makefile.am
index c5b00a1..ac2df63 100644
--- a/openbsc/src/osmo-nitb/Makefile.am
+++ b/openbsc/src/osmo-msc/Makefile.am
@@ -14,6 +14,9 @@ AM_CFLAGS = \
$(LIBOSMOABIS_CFLAGS) \
$(LIBSMPP34_CFLAGS) \
$(LIBCRYPTO_CFLAGS) \
+ $(LIBOSMORANAP_CFLAGS) \
+ $(LIBASN1C_CFLAGS) \
+ $(LIBOSMOSIGTRAN_CFLAGS) \
$(NULL)
AM_LDFLAGS = \
@@ -21,20 +24,23 @@ AM_LDFLAGS = \
$(NULL)
bin_PROGRAMS = \
- osmo-nitb \
+ osmo-msc \
$(NULL)
-osmo_nitb_SOURCES = \
- bsc_hack.c \
- $(top_builddir)/tests/libiudummy/iudummy.c \
+noinst_HEADERS = \
+ iucs_ranap.h \
$(NULL)
-# libiudummy is temporary until iu_tx() and the ranap libs are linked
-osmo_nitb_LDADD = \
- $(top_builddir)/src/libbsc/libbsc.a \
- $(top_builddir)/src/libcommon-cs/libcommon-cs.a \
+osmo_msc_SOURCES = \
+ msc_main.c \
+ iucs_ranap.c \
+ $(NULL)
+
+osmo_msc_LDADD = \
+ $(top_builddir)/src/libiu/libiu.a \
$(top_builddir)/src/libmsc/libmsc.a \
$(top_builddir)/src/libvlr/libvlr.a \
+ $(top_builddir)/src/libcommon-cs/libcommon-cs.a \
$(top_builddir)/src/libtrau/libtrau.a \
$(top_builddir)/src/libcommon/libcommon.a \
$(LIBOSMOGSM_LIBS) \
@@ -45,4 +51,7 @@ osmo_nitb_LDADD = \
$(LIBSMPP34_LIBS) \
$(LIBCRYPTO_LIBS) \
-ldbi \
+ $(LIBOSMORANAP_LIBS) \
+ $(LIBASN1C_LIBS) \
+ $(LIBOSMOSIGTRAN_LIBS) \
$(NULL)
diff --git a/openbsc/src/osmo-msc/iucs_ranap.c b/openbsc/src/osmo-msc/iucs_ranap.c
new file mode 100644
index 0000000..34f5bfe
--- /dev/null
+++ b/openbsc/src/osmo-msc/iucs_ranap.c
@@ -0,0 +1,119 @@
+/* Implementation of RANAP messages to/from an MSC via an Iu-CS interface.
+ * This keeps direct RANAP dependencies out of libmsc. */
+
+/* (C) 2016 by sysmocom s.m.f.c. GmbH <info@sysmocom.de>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+#include <osmocom/core/logging.h>
+
+#include <osmocom/ranap/ranap_ies_defs.h>
+
+#include <openbsc/debug.h>
+#include <openbsc/gsm_data.h>
+#include <openbsc/gsm_subscriber.h>
+#include <openbsc/iu.h>
+#include <openbsc/iucs.h>
+
+#include "iucs_ranap.h"
+
+/* To continue authorization after a Security Mode Complete */
+int gsm0408_authorize(struct gsm_subscriber_connection *conn);
+
+static int iucs_rx_rab_assign(struct gsm_subscriber_connection *conn,
+ RANAP_RAB_SetupOrModifiedItemIEs_t *setup_ies)
+{
+ uint8_t rab_id;
+ RANAP_RAB_SetupOrModifiedItem_t *item = &setup_ies->raB_SetupOrModifiedItem;
+
+ rab_id = item->rAB_ID.buf[0];
+
+ LOGP(DIUCS, LOGL_NOTICE, "Received RAB assignment event for %s"
+ " rab_id=%hhd\n", subscr_name(conn->subscr), rab_id);
+ /* TODO do stuff like in sgsn_ranap_rab_ass_resp() */
+
+ return 0;
+}
+
+int iucs_rx_sec_mode_compl(struct gsm_subscriber_connection *conn,
+ RANAP_SecurityModeCompleteIEs_t *ies)
+{
+ gsm_cbfn *cb;
+
+ OSMO_ASSERT(conn->via_iface == IFACE_IU);
+
+ if (!conn->sec_operation) {
+ LOGP(DIUCS, LOGL_ERROR,
+ "Received Security Mode Complete message, but no"
+ " authentication/cipher operation in progress"
+ " for subscr %s\n", subscr_name(conn->subscr));
+ return -EINVAL;
+ }
+
+ /* TODO evalute ies */
+
+ if (conn->iu.integrity_protection)
+ LOGP(DIUCS, LOGL_NOTICE, "Integrity Protection"
+ " was already enabled for %s\n",
+ subscr_name(conn->subscr));
+
+ conn->iu.integrity_protection = INTEGRITY_PROTECTION_IK;
+
+ cb = conn->sec_operation->cb;
+ if (cb)
+ cb(GSM_HOOK_RR_SECURITY, GSM_SECURITY_SUCCEEDED, NULL,
+ conn, conn->sec_operation->cb_data);
+ release_security_operation(conn);
+ return 0;
+}
+
+int iucs_rx_ranap_event(struct gsm_network *network,
+ struct ue_conn_ctx *ue_ctx, int type, void *data)
+{
+ struct gsm_subscriber_connection *conn;
+
+ conn = subscr_conn_lookup_iu(network, ue_ctx);
+
+ if (!conn) {
+ LOGP(DRANAP, LOGL_ERROR, "Cannot find subscriber for IU event %u\n", type);
+ return -1;
+ }
+
+ switch (type) {
+ case IU_EVENT_IU_RELEASE:
+ case IU_EVENT_LINK_INVALIDATED:
+ LOGP(DIUCS, LOGL_INFO, "IuCS release for %s\n",
+ subscr_name(conn->subscr));
+ gsm0408_clear_request(conn, 0);
+ return 0;
+
+ case IU_EVENT_SECURITY_MODE_COMPLETE:
+ LOGP(DIUCS, LOGL_INFO, "IuCS security mode complete for %s\n",
+ subscr_name(conn->subscr));
+ return iucs_rx_sec_mode_compl(conn,
+ (RANAP_SecurityModeCompleteIEs_t*)data);
+ case IU_EVENT_RAB_ASSIGN:
+ return iucs_rx_rab_assign(conn,
+ (RANAP_RAB_SetupOrModifiedItemIEs_t*)data);
+ default:
+ LOGP(DIUCS, LOGL_NOTICE, "Unknown message received:"
+ " RANAP event: %i\n", type);
+ return -1;
+ }
+}
diff --git a/openbsc/src/osmo-msc/iucs_ranap.h b/openbsc/src/osmo-msc/iucs_ranap.h
new file mode 100644
index 0000000..0aa1ee9
--- /dev/null
+++ b/openbsc/src/osmo-msc/iucs_ranap.h
@@ -0,0 +1,6 @@
+#pragma once
+
+struct ue_conn_ctx;
+
+int iucs_rx_ranap_event(struct gsm_network *network,
+ struct ue_conn_ctx *ue_ctx, int type, void *data);
diff --git a/openbsc/src/osmo-nitb/bsc_hack.c b/openbsc/src/osmo-msc/msc_main.c
index 10f152b..3ac546a 100644
--- a/openbsc/src/osmo-nitb/bsc_hack.c
+++ b/openbsc/src/osmo-msc/msc_main.c
@@ -1,6 +1,11 @@
-/* A hackish minimal BSC (+MSC +HLR) implementation */
+/* OsmoMSC - Circuit-Switched Core Network (MSC+VLR+HLR+SMSC) implementation
+ */
-/* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org>
+/* (C) 2016 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
+ * All Rights Reserved
+ *
+ * Based on OsmoNITB:
+ * (C) 2008-2010 by Harald Welte <laforge@gnumonks.org>
* (C) 2009-2012 by Holger Hans Peter Freyther <zecke@selfish.org>
* All Rights Reserved
*
@@ -29,6 +34,9 @@
#define _GNU_SOURCE
#include <getopt.h>
+/* build switches from the configure script */
+#include "../../bscconfig.h"
+
#include <openbsc/db.h>
#include <osmocom/core/application.h>
#include <osmocom/core/select.h>
@@ -41,6 +49,9 @@
#include <openbsc/osmo_msc.h>
#include <openbsc/bsc_msc_data.h>
#include <openbsc/sms_queue.h>
+#include <osmocom/vty/telnet_interface.h>
+#include <osmocom/vty/ports.h>
+#include <osmocom/vty/logging.h>
#include <openbsc/vty.h>
#include <openbsc/bss.h>
#include <openbsc/mncc.h>
@@ -48,23 +59,55 @@
#include <openbsc/handover_decision.h>
#include <openbsc/rrlp.h>
#include <osmocom/ctrl/control_if.h>
-#include <osmocom/ctrl/ports.h>
#include <osmocom/ctrl/control_vty.h>
+#include <osmocom/ctrl/ports.h>
#include <openbsc/ctrl.h>
#include <openbsc/osmo_bsc_rf.h>
#include <openbsc/smpp.h>
-
-#include "../../bscconfig.h"
-
-/* MCC and MNC for the Location Area Identifier */
-struct gsm_network *bsc_gsmnet = 0;
-static const char *database_name = "hlr.sqlite3";
-static const char *config_file = "openbsc.cfg";
-static const char *rf_ctrl_path = NULL;
-extern const char *openbsc_copyright;
-static int daemonize = 0;
-static const char *mncc_sock_path = NULL;
-static int use_db_counter = 1;
+#include <osmocom/sigtran/sccp_sap.h>
+#include <osmocom/sigtran/sua.h>
+
+#include <openbsc/msc_ifaces.h>
+#include <openbsc/iu.h>
+#include <openbsc/iucs.h>
+
+#include "iucs_ranap.h"
+
+static const char * const osmomsc_copyright =
+ "OsmoMSC - Osmocom Circuit-Switched Core Network implementation\r\n"
+ "Copyright (C) 2016 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>\r\n"
+ "Based on OsmoNITB:\r\n"
+ " (C) 2008-2010 by Harald Welte <laforge@gnumonks.org>\r\n"
+ " (C) 2009-2012 by Holger Hans Peter Freyther <zecke@selfish.org>\r\n"
+ "Contributions by Daniel Willmann, Jan Lübbe, Stefan Schmidt\r\n"
+ "Dieter Spaar, Andreas Eversberg, Sylvain Munaut, Neels Hofmeyr\r\n\r\n"
+ "License AGPLv3+: GNU AGPL version 3 or later <http://gnu.org/licenses/agpl-3.0.html>\r\n"
+ "This is free software: you are free to change and redistribute it.\r\n"
+ "There is NO WARRANTY, to the extent permitted by law.\r\n";
+
+void *tall_msc_ctx = NULL;
+
+/* satisfy deps from libbsc legacy.
+ TODO double check these */
+void *tall_fle_ctx = NULL;
+void *tall_paging_ctx = NULL;
+void *tall_map_ctx = NULL;
+void *tall_upq_ctx = NULL;
+/* end deps from libbsc legacy. */
+
+static struct {
+ const char *database_name;
+ const char *config_file;
+ int daemonize;
+ const char *mncc_sock_path;
+ int use_db_counter;
+} msc_cmdline_config = {
+ "hlr.sqlite3",
+ "osmo-msc.cfg",
+ 0,
+ 0,
+ 1
+};
/* timer to store statistics */
#define DB_SYNC_INTERVAL 60, 0
@@ -105,7 +148,7 @@ static void print_help()
printf(" -P --rtp-proxy Enable the RTP Proxy code inside OpenBSC.\n");
printf(" -e --log-level number Set a global loglevel.\n");
printf(" -M --mncc-sock-path PATH Disable built-in MNCC handler and offer socket.\n");
- printf(" -m --mncc-sock Same as `-M /tmp/bsc_mncc' (deprecated).\n");
+ printf(" -m --mncc-sock Same as `-M /tmp/bsc_mncc' (deprecated).\n");
printf(" -C --no-dbcounter Disable regular syncing of counters to database.\n");
printf(" -r --rf-ctl PATH A unix domain socket to listen for cmds.\n");
printf(" -p --pcap PATH Write abis communication to pcap trace file.\n");
@@ -131,11 +174,10 @@ static void handle_options(int argc, char **argv)
{"mncc-sock", 0, 0, 'm'},
{"mncc-sock-path", 1, 0, 'M'},
{"no-dbcounter", 0, 0, 'C'},
- {"rf-ctl", 1, 0, 'r'},
{0, 0, 0, 0}
};
- c = getopt_long(argc, argv, "hd:Dsl:ar:p:TPVc:e:mCr:M:",
+ c = getopt_long(argc, argv, "hd:Dsl:ap:TPVc:e:mCM:",
long_options, &option_index);
if (c == -1)
break;
@@ -152,13 +194,13 @@ static void handle_options(int argc, char **argv)
log_parse_category_mask(osmo_stderr_target, optarg);
break;
case 'D':
- daemonize = 1;
+ msc_cmdline_config.daemonize = 1;
break;
case 'l':
- database_name = optarg;
+ msc_cmdline_config.database_name = optarg;
break;
case 'c':
- config_file = optarg;
+ msc_cmdline_config.config_file = optarg;
break;
case 'p':
create_pcap_file(optarg);
@@ -166,37 +208,59 @@ static void handle_options(int argc, char **argv)
case 'T':
log_set_print_timestamp(osmo_stderr_target, 1);
break;
+#if BEFORE_MSCSPLIT
case 'P':
ipacc_rtp_direct = 0;
break;
+#endif
case 'e':
log_set_log_level(osmo_stderr_target, atoi(optarg));
break;
case 'M':
- mncc_sock_path = optarg;
+ msc_cmdline_config.mncc_sock_path = optarg;
break;
case 'm':
- mncc_sock_path = "/tmp/bsc_mncc";
+ msc_cmdline_config.mncc_sock_path = "/tmp/bsc_mncc";
break;
case 'C':
- use_db_counter = 0;
+ msc_cmdline_config.use_db_counter = 0;
break;
case 'V':
print_version(1);
exit(0);
break;
- case 'r':
- rf_ctrl_path = optarg;
- break;
default:
/* catch unknown options *as well as* missing arguments. */
fprintf(stderr, "Error in command line options. Exiting.\n");
exit(-1);
- break;
}
}
}
+struct gsm_network *msc_network_alloc(void *ctx,
+ mncc_recv_cb_t mncc_recv)
+{
+ struct gsm_network *net = gsm_network_init(ctx, 1, 1, mncc_recv);
+ if (!net)
+ return NULL;
+
+ net->name_long = talloc_strdup(net, "OsmoMSC");
+ net->name_short = talloc_strdup(net, "OsmoMSC");
+
+ return net;
+}
+
+void msc_network_shutdown(struct gsm_network *net)
+{
+ /* nothing here yet */
+}
+
+static struct gsm_network *msc_network = NULL;
+
+/* TODO this is here to satisfy linking during intermediate development. Once
+ * libbsc is not linked to osmo-msc, this should go away. */
+struct gsm_network *bsc_gsmnet = NULL;
+
extern void *tall_vty_ctx;
static void signal_handler(int signal)
{
@@ -204,7 +268,7 @@ static void signal_handler(int signal)
switch (signal) {
case SIGINT:
- bsc_shutdown_net(bsc_gsmnet);
+ msc_network_shutdown(msc_network);
osmo_signal_dispatch(SS_L_GLOBAL, S_L_GLOBAL_SHUTDOWN, NULL);
sleep(3);
exit(0);
@@ -215,7 +279,7 @@ static void signal_handler(int signal)
* and then return to the caller, who will abort the process */
case SIGUSR1:
talloc_report(tall_vty_ctx, stderr);
- talloc_report_full(tall_bsc_ctx, stderr);
+ talloc_report_full(tall_msc_ctx, stderr);
break;
case SIGUSR2:
talloc_report_full(tall_vty_ctx, stderr);
@@ -246,60 +310,84 @@ static void subscr_expire_cb(void *data)
extern int bsc_vty_go_parent(struct vty *vty);
-static struct vty_app_info vty_info = {
- .name = "OpenBSC",
+static struct vty_app_info msc_vty_info = {
+ .name = "OsmoMSC",
.version = PACKAGE_VERSION,
.go_parent_cb = bsc_vty_go_parent,
.is_config_node = bsc_vty_is_config_node,
};
+static int rcvmsg_iu_cs(struct msgb *msg, struct gprs_ra_id *ra_id, /* FIXME gprs_ in CS code */
+ uint16_t *sai)
+{
+ DEBUGP(DIUCS, "got IuCS message"
+ " %d bytes: %s\n",
+ msg->len, osmo_hexdump(msg->data, msg->len));
+ if (ra_id) {
+ DEBUGP(DIUCS, "got IuCS message on"
+ " MNC %d MCC %d LAC %d RAC %d\n",
+ ra_id->mnc, ra_id->mcc, ra_id->lac, ra_id->rac);
+ }
+
+ return gsm0408_rcvmsg_iucs(msc_network, msg, ra_id? &ra_id->lac : NULL);
+}
+
+static int rx_iu_event(struct ue_conn_ctx *ctx, enum iu_event_type type,
+ void *data)
+{
+ DEBUGP(DIUCS, "got IuCS event %u: %s\n", type,
+ iu_event_type_str(type));
+
+ return iucs_rx_ranap_event(msc_network, ctx, type, data);
+}
+
int main(int argc, char **argv)
{
int rc;
- vty_info.copyright = openbsc_copyright;
+ msc_vty_info.copyright = osmomsc_copyright;
- tall_bsc_ctx = talloc_named_const(NULL, 1, "openbsc");
- talloc_ctx_init(tall_bsc_ctx);
-#if 0
- on_dso_load_token();
-#endif
- on_dso_load_rrlp();
- on_dso_load_ho_dec();
+ tall_msc_ctx = talloc_named_const(NULL, 1, "osmo_msc");
+ talloc_ctx_init(tall_msc_ctx);
- libosmo_abis_init(tall_bsc_ctx);
osmo_init_logging(&log_info);
- osmo_stats_init(tall_bsc_ctx);
- bts_init();
- vty_init(&vty_info);
+ osmo_stats_init(tall_msc_ctx);
+
+ /* For --version, vty_init() must be called before handling options */
+ vty_init(&msc_vty_info);
/* Parse options */
handle_options(argc, argv);
/* Allocate global gsm_network struct; choose socket/internal MNCC */
- rc = bsc_network_alloc(mncc_sock_path?
- mncc_sock_from_cc : int_mncc_recv);
- if (rc) {
- fprintf(stderr, "Allocation failed. Exiting.\n");
- exit(1);
- }
-
- /* Initialize VTY */
- bsc_vty_init(bsc_gsmnet);
- ctrl_vty_init(tall_bsc_ctx);
- if (msc_vlr_alloc(bsc_gsmnet)) {
- fprintf(stderr, "Failed to allocate VLR\n");
- exit(1);
- }
+ msc_network = msc_network_alloc(tall_msc_ctx,
+ msc_cmdline_config.mncc_sock_path?
+ mncc_sock_from_cc
+ : int_mncc_recv);
+ if (!msc_network)
+ return -ENOMEM;
+
+ ctrl_vty_init(tall_msc_ctx);
+ logging_vty_add_cmds(&log_info);
+ msc_vty_init(msc_network);
+ bsc_vty_init_extra();
#ifdef BUILD_SMPP
- if (smpp_openbsc_alloc_init(tall_bsc_ctx) < 0)
+ if (smpp_openbsc_alloc_init(tall_msc_ctx) < 0)
return -1;
#endif
+ rc = vty_read_config_file(msc_cmdline_config.config_file, NULL);
+ if (rc < 0) {
+ LOGP(DNM, LOGL_FATAL, "Failed to parse the config file: '%s'\n",
+ msc_cmdline_config.config_file);
+ return 1;
+ }
+
/* Initialize MNCC socket if appropriate */
- if (mncc_sock_path) {
- rc = mncc_sock_init(bsc_gsmnet, mncc_sock_path);
+ if (msc_cmdline_config.mncc_sock_path) {
+ rc = mncc_sock_init(msc_network,
+ msc_cmdline_config.mncc_sock_path);
if (rc) {
fprintf(stderr, "MNCC socket initialization failed. exiting.\n");
exit(1);
@@ -307,17 +395,22 @@ int main(int argc, char **argv)
} else
DEBUGP(DMNCC, "Using internal MNCC handler.\n");
- /* Read the config */
- rc = bsc_network_configure(config_file);
- if (rc < 0) {
- fprintf(stderr, "Reading config failed. Exiting.\n");
- exit(1);
- }
+ /* start telnet after reading config for vty_get_bind_addr() */
+ rc = telnet_init_dynif(tall_msc_ctx, &msc_network,
+ vty_get_bind_addr(), OSMO_VTY_PORT_MSC);
+ if (rc < 0)
+ return 2;
+
+ /* BSC stuff is to be split behind an A-interface to be used with
+ * OsmoBSC, but there is no need to remove it yet. Most of the
+ * following code until iu_init() is legacy. */
#ifdef BUILD_SMPP
- smpp_openbsc_start(bsc_gsmnet);
+ smpp_openbsc_start(msc_network);
#endif
- bsc_api_init(bsc_gsmnet, msc_bsc_api());
+
+#if 0
+ the bsc_ctrl_node_lookup() only returns BSC specific ctrl nodes
/*
* For osmo-nitb, skip TCH/F for now, because otherwise dyn TS
@@ -334,31 +427,39 @@ int main(int argc, char **argv)
/* start control interface after reading config for
* ctrl_vty_get_bind_addr() */
- bsc_gsmnet->ctrl = bsc_controlif_setup(bsc_gsmnet,
- ctrl_vty_get_bind_addr(),
- OSMO_CTRL_PORT_NITB_BSC);
- if (!bsc_gsmnet->ctrl) {
+ msc_network->ctrl = bsc_controlif_setup(msc_network,
+ ctrl_vty_get_bind_addr(),
+ OSMO_CTRL_PORT_MSC);
+ if (!msc_network->ctrl) {
printf("Failed to initialize control interface. Exiting.\n");
return -1;
}
+#endif
+#if 0
+TODO: we probably want some of the _net_ ctrl commands from bsc_base_ctrl_cmds_install().
if (bsc_base_ctrl_cmds_install() != 0) {
printf("Failed to initialize the BSC control commands.\n");
return -1;
}
+#endif
+#if 0
if (msc_ctrl_cmds_install(bsc_gsmnet) != 0) {
printf("Failed to initialize the MSC control commands.\n");
return -1;
}
+#endif
/* seed the PRNG */
srand(time(NULL));
+ /* TODO: is this used for crypto?? Improve randomness, at least we
+ * should try to use the nanoseconds part of the current time. */
- bsc_gsmnet->bsc_data->rf_ctrl = osmo_bsc_rf_create(rf_ctrl_path, bsc_gsmnet);
- if (!bsc_gsmnet->bsc_data->rf_ctrl) {
- fprintf(stderr, "Failed to create the RF service.\n");
- exit(1);
+ if (db_init(msc_cmdline_config.database_name)) {
+ printf("DB: Failed to init database: %s\n",
+ msc_cmdline_config.database_name);
+ return 4;
}
osmo_fsm_log_addr(true);
@@ -377,19 +478,17 @@ int main(int argc, char **argv)
if (db_prepare()) {
printf("DB: Failed to prepare database.\n");
- return -1;
+ return 5;
}
- printf("DB: Database prepared.\n");
- /* setup the timer */
db_sync_timer.cb = db_sync_timer_cb;
db_sync_timer.data = NULL;
- if (use_db_counter)
+ if (msc_cmdline_config.use_db_counter)
osmo_timer_schedule(&db_sync_timer, DB_SYNC_INTERVAL);
- bsc_gsmnet->subscr_expire_timer.cb = subscr_expire_cb;
- bsc_gsmnet->subscr_expire_timer.data = NULL;
- osmo_timer_schedule(&bsc_gsmnet->subscr_expire_timer, EXPIRE_INTERVAL);
+ msc_network->subscr_expire_timer.cb = subscr_expire_cb;
+ msc_network->subscr_expire_timer.data = NULL;
+ osmo_timer_schedule(&msc_network->subscr_expire_timer, EXPIRE_INTERVAL);
signal(SIGINT, &signal_handler);
signal(SIGABRT, &signal_handler);
@@ -398,14 +497,20 @@ int main(int argc, char **argv)
osmo_init_ignore_signals();
/* start the SMS queue */
- if (sms_queue_start(bsc_gsmnet, 20) != 0)
+ if (sms_queue_start(msc_network, 20) != 0)
return -1;
- if (daemonize) {
+ /* Set up A-Interface */
+ /* TODO: implement A-Interface and remove above legacy stuff. */
+
+ /* Set up IuCS */
+ iu_init(tall_msc_ctx, "127.0.0.1", 14001, rcvmsg_iu_cs, rx_iu_event);
+
+ if (msc_cmdline_config.daemonize) {
rc = osmo_daemonize();
if (rc < 0) {
perror("Error during daemonize");
- exit(1);
+ return 6;
}
}